The smokesignal.events web application
56
fork

Configure Feed

Select the types of activity you want to include in your feed.

feature: oauth overhaul with permission-set

+4326 -4825
-1
Cargo.toml
··· 30 30 atproto-identity = { git = "https://tangled.org/@smokesignal.events/atproto-identity-rs", features = ["lru", "zeroize", "hickory-dns"] } 31 31 atproto-tap = { git = "https://tangled.org/@smokesignal.events/atproto-identity-rs" } 32 32 atproto-oauth = { git = "https://tangled.org/@smokesignal.events/atproto-identity-rs", features = ["lru", "zeroize"] } 33 - atproto-oauth-aip = { git = "https://tangled.org/@smokesignal.events/atproto-identity-rs" } 34 33 atproto-oauth-axum = { git = "https://tangled.org/@smokesignal.events/atproto-identity-rs", features = ["zeroize"] } 35 34 atproto-record = { git = "https://tangled.org/@smokesignal.events/atproto-identity-rs" } 36 35 atproto-xrpcs = { git = "https://tangled.org/@smokesignal.events/atproto-identity-rs" }
+4
migrations/20260118000000_remove_oauth_sessions.sql
··· 1 + -- Sessions are now stored in encrypted cookies, not the database. 2 + -- This migration removes the oauth_sessions table. 3 + 4 + DROP TABLE IF EXISTS oauth_sessions;
+18
migrations/20260118000001_mcp_clients.sql
··· 1 + -- MCP client credentials for OAuth flow 2 + -- Stores dynamically registered MCP clients 3 + 4 + CREATE TABLE mcp_clients ( 5 + id VARCHAR(64) PRIMARY KEY, 6 + client_id VARCHAR(512) UNIQUE NOT NULL, 7 + client_secret VARCHAR(512) NOT NULL, 8 + redirect_uri VARCHAR(1024) NOT NULL, 9 + client_name VARCHAR(256), 10 + did VARCHAR(512), 11 + dpop_jwk TEXT NOT NULL, 12 + issuer VARCHAR(512), 13 + created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), 14 + updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW() 15 + ); 16 + 17 + CREATE INDEX idx_mcp_clients_client_id ON mcp_clients(client_id); 18 + CREATE INDEX idx_mcp_clients_did ON mcp_clients(did);
+8
migrations/20260118000002_mcp_configuration.sql
··· 1 + -- MCP configuration per user (DID) 2 + -- Controls permissions and safety settings for MCP clients 3 + 4 + CREATE TABLE mcp_configuration ( 5 + did VARCHAR(512) PRIMARY KEY, 6 + allow_dangerous BOOLEAN NOT NULL DEFAULT FALSE, 7 + updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW() 8 + );
-18
src-js/package-lock.json
··· 12 12 "cropperjs": "^1.6.2", 13 13 "h3-js": "^4.4.0", 14 14 "htmx.org": "^2.0.8", 15 - "leaflet": "^1.9.4", 16 15 "maplibre-gl": "^5.16.0" 17 16 }, 18 17 "devDependencies": { 19 18 "@biomejs/biome": "^2.0.0", 20 - "@types/leaflet": "^1.9.21", 21 19 "@types/node": "^22.0.0", 22 20 "lightningcss": "^1.28.0", 23 21 "oxlint": "^1.0.0", ··· 1217 1215 "@types/geojson": "*" 1218 1216 } 1219 1217 }, 1220 - "node_modules/@types/leaflet": { 1221 - "version": "1.9.21", 1222 - "resolved": "https://registry.npmjs.org/@types/leaflet/-/leaflet-1.9.21.tgz", 1223 - "integrity": "sha512-TbAd9DaPGSnzp6QvtYngntMZgcRk+igFELwR2N99XZn7RXUdKgsXMR+28bUO0rPsWp8MIu/f47luLIQuSLYv/w==", 1224 - "dev": true, 1225 - "license": "MIT", 1226 - "dependencies": { 1227 - "@types/geojson": "*" 1228 - } 1229 - }, 1230 1218 "node_modules/@types/node": { 1231 1219 "version": "22.19.7", 1232 1220 "resolved": "https://registry.npmjs.org/@types/node/-/node-22.19.7.tgz", ··· 1419 1407 "resolved": "https://registry.npmjs.org/kdbush/-/kdbush-4.0.2.tgz", 1420 1408 "integrity": "sha512-WbCVYJ27Sz8zi9Q7Q0xHC+05iwkm3Znipc2XTlrnJbsHMYktW4hPhXUE8Ys1engBrvffoSCqbil1JQAa7clRpA==", 1421 1409 "license": "ISC" 1422 - }, 1423 - "node_modules/leaflet": { 1424 - "version": "1.9.4", 1425 - "resolved": "https://registry.npmjs.org/leaflet/-/leaflet-1.9.4.tgz", 1426 - "integrity": "sha512-nxS1ynzJOmOlHp+iL3FyWqK89GtNL8U8rvlMOsQdTTssxZwCXh8N2NB3GDQOL+YR3XnWyZAxwQixURb+FA74PA==", 1427 - "license": "BSD-2-Clause" 1428 1410 }, 1429 1411 "node_modules/lightningcss": { 1430 1412 "version": "1.30.2",
-2
src-js/package.json
··· 15 15 }, 16 16 "devDependencies": { 17 17 "@biomejs/biome": "^2.0.0", 18 - "@types/leaflet": "^1.9.21", 19 18 "@types/node": "^22.0.0", 20 19 "lightningcss": "^1.28.0", 21 20 "oxlint": "^1.0.0", ··· 27 26 "cropperjs": "^1.6.2", 28 27 "h3-js": "^4.4.0", 29 28 "htmx.org": "^2.0.8", 30 - "leaflet": "^1.9.4", 31 29 "maplibre-gl": "^5.16.0" 32 30 } 33 31 }
+152
src-js/src/core/auth.ts
··· 1 + /** 2 + * Authentication utilities for session management 3 + * 4 + * Provides session refresh functionality that should be called before 5 + * making authenticated requests to AT Protocol services. 6 + */ 7 + 8 + /** 9 + * Session refresh error types 10 + */ 11 + export class AuthRequiredError extends Error { 12 + constructor(message = 'Authentication required') { 13 + super(message) 14 + this.name = 'AuthRequiredError' 15 + } 16 + } 17 + 18 + export class SessionExpiredError extends Error { 19 + constructor(message = 'Your session has expired. Please log in again.') { 20 + super(message) 21 + this.name = 'SessionExpiredError' 22 + } 23 + } 24 + 25 + /** 26 + * Refreshes the OAuth session token. 27 + * 28 + * This should be called before any request that uses AT Protocol OAuth tokens. 29 + * The server will use the refresh token to obtain new access tokens if needed. 30 + * 31 + * @throws {AuthRequiredError} If no session exists 32 + * @throws {SessionExpiredError} If the session cannot be refreshed 33 + */ 34 + export async function refreshSession(): Promise<void> { 35 + try { 36 + const response = await fetch('/oauth/refresh', { 37 + method: 'POST', 38 + credentials: 'same-origin', 39 + }) 40 + 41 + if (!response.ok) { 42 + if (response.status === 401) { 43 + throw new AuthRequiredError() 44 + } 45 + // For other errors, we'll let them pass through silently 46 + // The actual request will handle auth failures 47 + console.warn('Session refresh returned non-OK status:', response.status) 48 + } 49 + } catch (e) { 50 + if (e instanceof AuthRequiredError) throw e 51 + // Network errors during refresh shouldn't block the request 52 + // The actual request will handle auth failures 53 + console.warn('Session refresh failed:', e) 54 + } 55 + } 56 + 57 + /** 58 + * Refreshes authentication before an authenticated request. 59 + * Provides user-friendly error messages for session expiration. 60 + * 61 + * @throws {SessionExpiredError} If session has expired and cannot be refreshed 62 + */ 63 + export async function refreshAuth(): Promise<void> { 64 + try { 65 + await refreshSession() 66 + } catch (e) { 67 + if (e instanceof AuthRequiredError) { 68 + throw new SessionExpiredError() 69 + } 70 + // For other errors, let them pass - the actual request will handle it 71 + console.warn('Auth refresh warning:', e) 72 + } 73 + } 74 + 75 + /** 76 + * Options for authenticated fetch requests 77 + */ 78 + export interface AuthFetchOptions extends RequestInit { 79 + /** 80 + * Whether to skip session refresh before the request. 81 + * Default: false (always refresh) 82 + */ 83 + skipRefresh?: boolean 84 + } 85 + 86 + /** 87 + * Fetch wrapper that refreshes the session before making authenticated requests. 88 + * 89 + * Use this for any requests that require AT Protocol OAuth authentication. 90 + * 91 + * @param url - The URL to fetch 92 + * @param options - Fetch options with optional skipRefresh flag 93 + * @returns The fetch response 94 + * @throws {SessionExpiredError} If authentication fails 95 + */ 96 + export async function authFetch(url: string, options: AuthFetchOptions = {}): Promise<Response> { 97 + const { skipRefresh = false, ...fetchOptions } = options 98 + 99 + if (!skipRefresh) { 100 + await refreshAuth() 101 + } 102 + 103 + const response = await fetch(url, { 104 + ...fetchOptions, 105 + credentials: 'same-origin', 106 + }) 107 + 108 + // Handle authentication failures 109 + if (response.status === 401) { 110 + throw new SessionExpiredError() 111 + } 112 + 113 + return response 114 + } 115 + 116 + /** 117 + * JSON fetch helper that refreshes session and handles JSON parsing. 118 + * 119 + * @param url - The URL to fetch 120 + * @param options - Fetch options 121 + * @returns Parsed JSON response 122 + * @throws {SessionExpiredError} If authentication fails 123 + */ 124 + export async function authFetchJson<T>(url: string, options: AuthFetchOptions = {}): Promise<T> { 125 + const response = await authFetch(url, options) 126 + return response.json() as Promise<T> 127 + } 128 + 129 + /** 130 + * POST JSON helper that refreshes session before posting. 131 + * 132 + * @param url - The URL to post to 133 + * @param data - Data to send as JSON body 134 + * @param options - Additional fetch options 135 + * @returns The fetch response 136 + * @throws {SessionExpiredError} If authentication fails 137 + */ 138 + export async function authPostJson( 139 + url: string, 140 + data: unknown, 141 + options: AuthFetchOptions = {} 142 + ): Promise<Response> { 143 + return authFetch(url, { 144 + method: 'POST', 145 + headers: { 146 + 'Content-Type': 'application/json', 147 + ...((options.headers as Record<string, string>) || {}), 148 + }, 149 + body: JSON.stringify(data), 150 + ...options, 151 + }) 152 + }
+32
src-js/src/core/htmx-extensions/auth-refresh.ts
··· 1 + /** 2 + * htmx Auth Refresh Extension 3 + * 4 + * Automatically refreshes the OAuth session before HTMX requests. 5 + * This ensures that the access token is valid before navigation, 6 + * preventing users from being redirected to login mid-navigation. 7 + */ 8 + 9 + import type { HtmxApi, HtmxConfirmEvent } from '../types' 10 + import { refreshSession } from '../auth' 11 + 12 + export function initAuthRefreshExtension(htmx: HtmxApi): void { 13 + htmx.defineExtension('auth-refresh', { 14 + onEvent(name: string, evt: HtmxConfirmEvent) { 15 + if (name === 'htmx:confirm') { 16 + // Prevent the default request behavior 17 + evt.preventDefault() 18 + 19 + // Refresh session, then issue the request 20 + refreshSession() 21 + .catch((error) => { 22 + console.warn('Auth refresh before request failed:', error) 23 + }) 24 + .finally(() => { 25 + // Always issue the request, even if refresh failed 26 + // The server will handle 401 responses appropriately 27 + evt.detail.issueRequest() 28 + }) 29 + } 30 + }, 31 + }) 32 + }
+5 -1
src-js/src/core/index.ts
··· 14 14 import Alpine from 'alpinejs' 15 15 // Import htmx 16 16 import htmx from 'htmx.org' 17 + // Import auth utilities 18 + import { authFetch, authPostJson, refreshAuth, refreshSession } from './auth' 17 19 // Import htmx extensions 20 + import { initAuthRefreshExtension } from './htmx-extensions/auth-refresh' 18 21 import { initLoadingStatesExtension } from './htmx-extensions/loading-states' 19 22 import { initSSEExtension } from './htmx-extensions/sse' 20 23 ··· 34 37 window.htmx = htmxApi 35 38 36 39 // Initialize htmx extensions 40 + initAuthRefreshExtension(htmxApi) 37 41 initLoadingStatesExtension(htmxApi) 38 42 initSSEExtension(htmxApi) 39 43 ··· 49 53 Alpine.start() 50 54 } 51 55 52 - export { htmxApi as htmx, Alpine } 56 + export { htmxApi as htmx, Alpine, refreshSession, refreshAuth, authFetch, authPostJson }
+18
src-js/src/core/types.ts
··· 19 19 encodeParameters?: (xhr: XMLHttpRequest, parameters: FormData, elt: Element) => unknown 20 20 } 21 21 22 + /** 23 + * htmx:confirm event detail 24 + * Used to intercept requests and allow async processing before they proceed 25 + */ 26 + export interface HtmxConfirmEventDetail { 27 + elt: Element 28 + path: string 29 + verb: string 30 + triggeringEvent: Event 31 + etc: unknown 32 + issueRequest: () => void 33 + question?: string 34 + } 35 + 36 + export interface HtmxConfirmEvent extends CustomEvent<HtmxConfirmEventDetail> { 37 + detail: HtmxConfirmEventDetail 38 + } 39 + 22 40 export interface HtmxInternalData { 23 41 sseEventSource?: EventSource 24 42 sseEventListener?: EventListener
+29 -12
src-js/src/features/cropper/profile-cropper.ts
··· 6 6 */ 7 7 8 8 import type Cropper from 'cropperjs' 9 + import { authFetch, SessionExpiredError } from '../../core/auth' 9 10 import { loadCropper } from './index' 10 11 11 12 // Store cropper instances ··· 91 92 width: 400, 92 93 height: 400, 93 94 }) 94 - .toBlob((blob) => { 95 + .toBlob(async (blob) => { 95 96 if (!blob) return 96 97 97 98 const formData = new FormData() 98 99 formData.append('avatar', blob, 'avatar.png') 99 100 100 - fetch('/settings/avatar', { 101 - method: 'POST', 102 - body: formData, 103 - }).then((response) => { 101 + try { 102 + const response = await authFetch('/settings/avatar', { 103 + method: 'POST', 104 + body: formData, 105 + }) 104 106 if (response.ok) { 105 107 window.location.reload() 106 108 } 107 - }) 109 + } catch (error) { 110 + if (error instanceof SessionExpiredError) { 111 + alert(error.message) 112 + } else { 113 + console.error('Avatar upload error:', error) 114 + alert('Failed to upload avatar. Please try again.') 115 + } 116 + } 108 117 }, 'image/png') 109 118 }) 110 119 } ··· 157 166 width: 1600, 158 167 height: 900, 159 168 }) 160 - .toBlob((blob) => { 169 + .toBlob(async (blob) => { 161 170 if (!blob) return 162 171 163 172 const formData = new FormData() 164 173 formData.append('banner', blob, 'banner.png') 165 174 166 - fetch('/settings/banner', { 167 - method: 'POST', 168 - body: formData, 169 - }).then((response) => { 175 + try { 176 + const response = await authFetch('/settings/banner', { 177 + method: 'POST', 178 + body: formData, 179 + }) 170 180 if (response.ok) { 171 181 window.location.reload() 172 182 } 173 - }) 183 + } catch (error) { 184 + if (error instanceof SessionExpiredError) { 185 + alert(error.message) 186 + } else { 187 + console.error('Banner upload error:', error) 188 + alert('Failed to upload banner. Please try again.') 189 + } 190 + } 174 191 }, 'image/png') 175 192 }) 176 193 }
+22 -21
src-js/src/features/events/create.ts
··· 5 5 * This is an Alpine.js component factory that returns the component definition. 6 6 */ 7 7 8 + import { authFetch, authPostJson, SessionExpiredError } from '../../core/auth' 8 9 import type { EventFormData, FormLink, FormLocation, LocationSuggestion } from '../../types' 9 10 10 11 interface EventFormState { ··· 323 324 } 324 325 this.loadingSuggestions = true 325 326 try { 326 - const response = await fetch('/event/location-suggestions') 327 + const response = await authFetch('/event/location-suggestions') 327 328 const data = await response.json() 328 329 if (response.ok && data.suggestions) { 329 330 this.locationSuggestions = data.suggestions 330 331 } 331 332 } catch (error) { 332 - console.error('Failed to fetch location suggestions:', error) 333 + if (error instanceof SessionExpiredError) { 334 + this.errorMessage = error.message 335 + } else { 336 + console.error('Failed to fetch location suggestions:', error) 337 + } 333 338 } finally { 334 339 this.loadingSuggestions = false 335 340 this.showLocationSuggestions = true ··· 397 402 this.descriptionPreviewHtml = '' 398 403 399 404 try { 400 - const response = await fetch('/event/preview-description', { 401 - method: 'POST', 402 - headers: { 403 - 'Content-Type': 'application/json', 404 - }, 405 - body: JSON.stringify({ 406 - description: this.formData.description, 407 - }), 405 + const response = await authPostJson('/event/preview-description', { 406 + description: this.formData.description, 408 407 }) 409 408 410 409 const data = await response.json() ··· 416 415 this.showDescriptionPreview = false 417 416 } 418 417 } catch (error) { 419 - console.error('Preview error:', error) 420 - this.errorMessage = 'Failed to load preview. Please try again.' 418 + if (error instanceof SessionExpiredError) { 419 + this.errorMessage = error.message 420 + } else { 421 + console.error('Preview error:', error) 422 + this.errorMessage = 'Failed to load preview. Please try again.' 423 + } 421 424 this.showDescriptionPreview = false 422 425 } finally { 423 426 this.loadingPreview = false ··· 570 573 } 571 574 572 575 try { 573 - const response = await fetch(this.submitUrl, { 574 - method: 'POST', 575 - headers: { 576 - 'Content-Type': 'application/json', 577 - }, 578 - body: JSON.stringify(this.formData), 579 - }) 576 + const response = await authPostJson(this.submitUrl, this.formData) 580 577 581 578 const data = await response.json() 582 579 ··· 589 586 'Failed to ' + (this.isEditMode ? 'update' : 'create') + ' event. Please try again.' 590 587 } 591 588 } catch (error) { 592 - console.error('Submit error:', error) 593 - this.errorMessage = 'Network error. Please check your connection and try again.' 589 + if (error instanceof SessionExpiredError) { 590 + this.errorMessage = error.message 591 + } else { 592 + console.error('Submit error:', error) 593 + this.errorMessage = 'Network error. Please check your connection and try again.' 594 + } 594 595 } finally { 595 596 this.submitting = false 596 597 }
+17 -16
src-js/src/features/events/quick-create.ts
··· 5 5 * Supports both authenticated (direct API) and unauthenticated (localStorage) flows. 6 6 */ 7 7 8 + import { authPostJson, SessionExpiredError } from '../../core/auth' 9 + 8 10 const STORAGE_KEY = 'smokesignal_quick_event' 9 11 10 12 export function initQuickEventForm(): void { ··· 60 62 '<span class="icon"><i class="fas fa-spinner fa-pulse"></i></span><span>Creating...</span>' 61 63 } 62 64 63 - fetch('/event', { 64 - method: 'POST', 65 - headers: { 66 - 'Content-Type': 'application/json', 67 - }, 68 - body: JSON.stringify(eventData), 69 - }) 65 + const resetButton = () => { 66 + if (submitButton) { 67 + submitButton.disabled = false 68 + submitButton.innerHTML = '<strong>Create Event</strong>' 69 + } 70 + } 71 + 72 + authPostJson('/event', eventData) 70 73 .then(async (response) => { 71 74 const data = await response.json() 72 75 if (response.ok && data.url) { ··· 75 78 } else { 76 79 // Show error 77 80 alert(data.error || 'Failed to create event. Please try again.') 78 - if (submitButton) { 79 - submitButton.disabled = false 80 - submitButton.innerHTML = '<strong>Create Event</strong>' 81 - } 81 + resetButton() 82 82 } 83 83 }) 84 84 .catch((error) => { 85 - console.error('Error creating event:', error) 86 - alert('Failed to create event. Please try again.') 87 - if (submitButton) { 88 - submitButton.disabled = false 89 - submitButton.innerHTML = '<strong>Create Event</strong>' 85 + if (error instanceof SessionExpiredError) { 86 + alert(error.message) 87 + } else { 88 + console.error('Error creating event:', error) 89 + alert('Failed to create event. Please try again.') 90 90 } 91 + resetButton() 91 92 }) 92 93 } else { 93 94 // User is not authenticated, save to localStorage and redirect
+78 -83
src-js/src/features/lfg/form.ts
··· 5 5 * This is an Alpine.js component factory that returns the component definition. 6 6 */ 7 7 8 - import type * as h3Lib from 'h3-js' 9 - import type * as L from 'leaflet' 8 + import type { Map as MaplibreMap, MapMouseEvent } from 'maplibre-gl' 9 + import { authPostJson, SessionExpiredError } from '../../core/auth' 10 + import { 11 + loadMapLibraries, 12 + createMap, 13 + h3ToGeoJsonFeature, 14 + addHexagonLayers, 15 + updateHexagonSource, 16 + toMapCenter, 17 + getH3Module, 18 + } from '../maps/map-utils' 10 19 11 20 // H3 resolution 7 gives ~5 km² area (roughly 1.2km edge) 12 21 const H3_RESOLUTION = 7 13 22 14 - // Module-level cache for lazy-loaded libraries 15 - let leafletModule: typeof L | null = null 16 - let h3Module: typeof h3Lib | null = null 17 - 18 - /** 19 - * Lazy load Leaflet and H3 libraries 20 - */ 21 - async function loadMapLibraries(): Promise<{ L: typeof L; h3: typeof h3Lib }> { 22 - if (!leafletModule || !h3Module) { 23 - const [leaflet, h3] = await Promise.all([import('leaflet'), import('h3-js')]) 24 - 25 - // Import Leaflet CSS 26 - await import('leaflet/dist/leaflet.css') 27 - 28 - leafletModule = leaflet.default as unknown as typeof L 29 - h3Module = h3 30 - } 31 - 32 - return { L: leafletModule, h3: h3Module } 33 - } 34 - 35 23 interface LfgFormState { 36 24 latitude: string 37 25 longitude: string ··· 39 27 tags: string[] 40 28 tagInput: string 41 29 durationHours: string 42 - map: L.Map | null 43 - hexLayer: L.Polygon | null 30 + map: MaplibreMap | null 44 31 submitting: boolean 45 32 errors: { 46 33 location: string | null ··· 51 38 // Methods 52 39 init(): void 53 40 initMap(): Promise<void> 54 - handleMapClick(lat: number, lon: number): void 41 + handleMapClick(lng: number, lat: number): void 55 42 selectLocation(h3Index: string): void 56 43 clearLocation(): void 57 44 addTag(): void ··· 81 68 tagInput: '', 82 69 durationHours: '48', 83 70 map: null, 84 - hexLayer: null, 85 71 submitting: false, 86 72 errors: { 87 73 location: null, ··· 104 90 105 91 async initMap(this: LfgFormState): Promise<void> { 106 92 try { 107 - const { L } = await loadMapLibraries() 93 + const { maplibregl } = await loadMapLibraries() 108 94 109 95 // Initialize map centered on default location 110 96 const defaultLat = 40.7128 111 97 const defaultLon = -74.006 112 98 113 - this.map = L.map('lfg-map').setView([defaultLat, defaultLon], 12) 99 + this.map = createMap(maplibregl, { 100 + container: 'lfg-map', 101 + center: toMapCenter(defaultLat, defaultLon), 102 + zoom: 12, 103 + }) 114 104 115 - L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { 116 - attribution: '&copy; OpenStreetMap contributors', 117 - }).addTo(this.map) 105 + this.map.on('load', () => { 106 + if (!this.map) return 118 107 119 - // Handle map clicks 120 - this.map.on('click', (e: L.LeafletMouseEvent) => { 121 - this.handleMapClick(e.latlng.lat, e.latlng.lng) 108 + // Add hexagon layers 109 + addHexagonLayers(this.map) 110 + 111 + // Handle map clicks 112 + this.map.on('click', (e: MapMouseEvent) => { 113 + // Check if clicking on an existing hex 114 + const features = this.map?.queryRenderedFeatures(e.point, { 115 + layers: ['hexagons-fill'], 116 + }) 117 + 118 + if (features && features.length > 0) { 119 + // Clicked on existing hex - toggle off 120 + this.clearLocation() 121 + } else { 122 + // Clicked on empty space - select new location 123 + this.handleMapClick(e.lngLat.lng, e.lngLat.lat) 124 + } 125 + }) 126 + 127 + // Cursor style when hovering over hex 128 + this.map.on('mouseenter', 'hexagons-fill', () => { 129 + if (this.map) { 130 + this.map.getCanvas().style.cursor = 'pointer' 131 + } 132 + }) 133 + 134 + this.map.on('mouseleave', 'hexagons-fill', () => { 135 + if (this.map) { 136 + this.map.getCanvas().style.cursor = '' 137 + } 138 + }) 122 139 }) 123 140 124 141 // Try to get user's location ··· 127 144 (position) => { 128 145 const lat = position.coords.latitude 129 146 const lon = position.coords.longitude 130 - this.map?.setView([lat, lon], 12) 147 + this.map?.flyTo({ center: toMapCenter(lat, lon), zoom: 12 }) 131 148 }, 132 149 () => { 133 150 // Geolocation denied or failed, use default ··· 139 156 } 140 157 }, 141 158 142 - handleMapClick(this: LfgFormState, lat: number, lon: number): void { 143 - if (!h3Module) { 159 + handleMapClick(this: LfgFormState, lng: number, lat: number): void { 160 + const h3 = getH3Module() 161 + if (!h3) { 144 162 console.warn('H3 not loaded') 145 163 return 146 164 } 147 165 148 166 // Get H3 cell at resolution 149 - const clickedH3Index = h3Module.latLngToCell(lat, lon, H3_RESOLUTION) 167 + const clickedH3Index = h3.latLngToCell(lat, lng, H3_RESOLUTION) 150 168 151 169 // Check if clicking on already selected cell - toggle off 152 170 if (this.h3Index === clickedH3Index) { ··· 160 178 }, 161 179 162 180 selectLocation(this: LfgFormState, h3Index: string): void { 163 - if (!this.map || !leafletModule || !h3Module) return 164 - 165 - // Remove existing hex layer 166 - if (this.hexLayer) { 167 - this.map.removeLayer(this.hexLayer) 168 - } 181 + const h3 = getH3Module() 182 + if (!this.map || !h3) return 169 183 170 184 this.h3Index = h3Index 171 185 172 - // Get boundary for drawing - h3.cellToBoundary returns [lat, lng] pairs 173 - const boundary = h3Module.cellToBoundary(h3Index) 174 - const latLngs: [number, number][] = boundary.map((coord: [number, number]) => [ 175 - coord[0], 176 - coord[1], 177 - ]) 178 - 179 - // Draw the hex with tooltip 180 - this.hexLayer = leafletModule 181 - .polygon(latLngs, { 182 - color: '#00d1b2', 183 - fillColor: '#00d1b2', 184 - fillOpacity: 0.3, 185 - weight: 3, 186 - }) 187 - .addTo(this.map) 188 - 189 - // Add tooltip to indicate it can be clicked to unselect 190 - this.hexLayer.bindTooltip('Click to unselect', { 191 - permanent: false, 192 - direction: 'center', 186 + // Create feature for the selected hex 187 + const feature = h3ToGeoJsonFeature(h3, h3Index, { 188 + fillColor: '#00d1b2', 189 + fillOpacity: 0.3, 190 + strokeColor: '#00d1b2', 191 + strokeWidth: 3, 193 192 }) 194 193 195 - // Handle click on the polygon to unselect 196 - this.hexLayer.on('click', () => { 197 - this.clearLocation() 198 - }) 194 + // Update the source 195 + updateHexagonSource(this.map, [feature]) 199 196 200 197 // Get center coordinates for the API 201 - const center = h3Module.cellToLatLng(h3Index) 198 + const center = h3.cellToLatLng(h3Index) 202 199 this.latitude = center[0].toString() 203 200 this.longitude = center[1].toString() 204 201 }, 205 202 206 203 clearLocation(this: LfgFormState): void { 207 - if (this.hexLayer && this.map) { 208 - this.map.removeLayer(this.hexLayer) 209 - this.hexLayer = null 204 + if (this.map) { 205 + // Clear the hexagon source 206 + updateHexagonSource(this.map, []) 210 207 } 211 208 this.h3Index = '' 212 209 this.latitude = '' ··· 266 263 } 267 264 268 265 try { 269 - const response = await fetch('/lfg', { 270 - method: 'POST', 271 - headers: { 272 - 'Content-Type': 'application/json', 273 - }, 274 - body: JSON.stringify(payload), 275 - }) 266 + const response = await authPostJson('/lfg', payload) 276 267 277 268 if (response.ok) { 278 269 // Success - redirect to LFG page which will show matches view ··· 295 286 } 296 287 } 297 288 } catch (err) { 298 - console.error('LFG submission error:', err) 299 - this.errors.general = 'Network error. Please check your connection and try again.' 289 + if (err instanceof SessionExpiredError) { 290 + this.errors.general = err.message 291 + } else { 292 + console.error('LFG submission error:', err) 293 + this.errors.general = 'Network error. Please check your connection and try again.' 294 + } 300 295 } finally { 301 296 this.submitting = false 302 297 }
+93 -36
src-js/src/features/lfg/heatmap.ts
··· 2 2 * LFG Heatmap Feature 3 3 * 4 4 * Renders the LFG activity heatmap showing event and people distribution. 5 - * Uses Leaflet for map rendering and H3 for hexagon visualization. 5 + * Uses MapLibre GL for map rendering and H3 for hexagon visualization. 6 6 */ 7 + 8 + import type { Feature, Polygon } from 'geojson' 9 + import type { MapMouseEvent, Popup as MaplibrePopup } from 'maplibre-gl' 10 + import { 11 + loadMapLibraries, 12 + createMap, 13 + h3ToGeoJsonFeature, 14 + addHexagonLayers, 15 + updateHexagonSource, 16 + toMapCenter, 17 + } from '../maps/map-utils' 7 18 8 19 interface HeatmapBucket { 9 20 key: string ··· 29 40 const eventBucketsData = mapContainer.dataset.eventBuckets 30 41 const profileBucketsData = mapContainer.dataset.profileBuckets 31 42 32 - // Lazy load Leaflet and H3 33 - const [L, h3] = await Promise.all([import('leaflet').then((m) => m.default), import('h3-js')]) 34 - 35 - // Import Leaflet CSS 36 - await import('leaflet/dist/leaflet.css') 43 + // Lazy load MapLibre and H3 44 + const { maplibregl, h3 } = await loadMapLibraries() 37 45 38 46 // Create map 39 - const map = L.map('lfg-heatmap').setView([centerLat, centerLon], 12) 40 - 41 - L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { 42 - attribution: '&copy; OpenStreetMap contributors', 43 - }).addTo(map) 47 + const map = createMap(maplibregl, { 48 + container: 'lfg-heatmap', 49 + center: toMapCenter(centerLat, centerLon), 50 + zoom: 12, 51 + }) 44 52 45 53 // Parse bucket data 46 54 let eventBuckets: HeatmapBucket[] = [] ··· 79 87 if (total > maxCount) maxCount = total 80 88 }) 81 89 82 - // Draw combined heatmap hexes 83 - combinedBuckets.forEach((value, key) => { 84 - try { 85 - const boundary = h3.cellToBoundary(key) 86 - const latLngs: [number, number][] = boundary.map((coord) => [coord[0], coord[1]]) 87 - const total = value.events + value.people 88 - const intensity = Math.min(total / Math.max(maxCount, 1), 1) 89 - const opacity = 0.2 + intensity * 0.5 90 + map.on('load', () => { 91 + // Add hexagon layers 92 + addHexagonLayers(map) 93 + 94 + // Build features with tooltip data 95 + const features: Feature<Polygon>[] = [] 96 + 97 + combinedBuckets.forEach((value, key) => { 98 + try { 99 + const total = value.events + value.people 100 + const intensity = Math.min(total / Math.max(maxCount, 1), 1) 101 + const opacity = 0.2 + intensity * 0.5 102 + 103 + // Build tooltip text 104 + const parts: string[] = [] 105 + if (value.events > 0) parts.push(`${value.events} event${value.events !== 1 ? 's' : ''}`) 106 + if (value.people > 0) 107 + parts.push(`${value.people} ${value.people !== 1 ? 'people' : 'person'}`) 108 + const tooltipText = parts.join(', ') 109 + 110 + // Get center for popup positioning 111 + const center = h3.cellToLatLng(key) 112 + 113 + features.push( 114 + h3ToGeoJsonFeature(h3, key, { 115 + fillColor: '#3273dc', 116 + fillOpacity: opacity, 117 + strokeColor: '#3273dc', 118 + strokeWidth: 1, 119 + tooltipText, 120 + centerLat: center[0], 121 + centerLng: center[1], 122 + }) 123 + ) 124 + } catch { 125 + console.warn('Invalid H3 cell:', key) 126 + } 127 + }) 90 128 91 - // Build tooltip text 92 - const parts: string[] = [] 93 - if (value.events > 0) parts.push(`${value.events} event${value.events !== 1 ? 's' : ''}`) 94 - if (value.people > 0) 95 - parts.push(`${value.people} ${value.people !== 1 ? 'people' : 'person'}`) 96 - const tooltipText = parts.join(', ') 129 + // Update the source with features 130 + updateHexagonSource(map, features) 97 131 98 - L.polygon(latLngs, { 99 - color: '#3273dc', 100 - fillColor: '#3273dc', 101 - fillOpacity: opacity, 102 - weight: 1, 103 - }) 104 - .addTo(map) 105 - .bindTooltip(tooltipText, { direction: 'center' }) 106 - } catch (e) { 107 - console.warn('Invalid H3 cell:', key) 108 - } 132 + // Create popup for hover 133 + let popup: MaplibrePopup | null = null 134 + 135 + // Show popup on hover 136 + map.on('mouseenter', 'hexagons-fill', (e: MapMouseEvent & { features?: Feature[] }) => { 137 + const feature = e.features?.[0] 138 + if (!feature?.properties) return 139 + 140 + const props = feature.properties as Record<string, unknown> 141 + const text = props.tooltipText as string 142 + const centerLat = props.centerLat as number 143 + const centerLng = props.centerLng as number 144 + 145 + if (text && centerLat !== undefined && centerLng !== undefined) { 146 + map.getCanvas().style.cursor = 'pointer' 147 + 148 + popup = new maplibregl.Popup({ 149 + closeButton: false, 150 + closeOnClick: false, 151 + }) 152 + .setLngLat([centerLng, centerLat]) 153 + .setText(text) 154 + .addTo(map) 155 + } 156 + }) 157 + 158 + // Remove popup on leave 159 + map.on('mouseleave', 'hexagons-fill', () => { 160 + map.getCanvas().style.cursor = '' 161 + if (popup) { 162 + popup.remove() 163 + popup = null 164 + } 165 + }) 109 166 }) 110 167 111 168 mapContainer.dataset.mapInitialized = 'true'
+38 -39
src-js/src/features/maps/event-map.ts
··· 5 5 * Used on the event view page. 6 6 */ 7 7 8 + import type { Feature, Polygon } from 'geojson' 8 9 import type { GeoLocation } from '../../types' 10 + import { 11 + loadMapLibraries, 12 + createMap, 13 + h3ToGeoJsonFeature, 14 + addHexagonLayers, 15 + updateHexagonSource, 16 + calculateBounds, 17 + toMapCenter, 18 + } from './map-utils' 9 19 10 20 const H3_RESOLUTION = 9 11 21 ··· 52 62 return 53 63 } 54 64 55 - // Lazy load Leaflet and H3 56 - const [L, h3] = await Promise.all([import('leaflet').then((m) => m.default), import('h3-js')]) 57 - 58 - // Import Leaflet CSS 59 - await import('leaflet/dist/leaflet.css') 65 + // Lazy load MapLibre and H3 66 + const { maplibregl, h3 } = await loadMapLibraries() 60 67 61 68 // Double-check we haven't been initialized while loading 62 69 if (container.dataset.mapInitialized === 'true') { ··· 77 84 } 78 85 79 86 // Initialize map 80 - const map = L.map('event-map', { 81 - zoomControl: true, 82 - scrollWheelZoom: false, 83 - dragging: true, 84 - }).setView([avgLat, avgLng], 16) 87 + const map = createMap(maplibregl, { 88 + container: 'event-map', 89 + center: toMapCenter(avgLat, avgLng), 90 + zoom: 16, 91 + scrollZoom: false, 92 + }) 85 93 86 - // Add OpenStreetMap tiles 87 - L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { 88 - attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>', 89 - maxZoom: 19, 90 - }).addTo(map) 94 + map.on('load', () => { 95 + // Add hexagon layers 96 + addHexagonLayers(map) 91 97 92 - // Collect all boundaries for fitting map bounds 93 - const allBounds: [number, number][] = [] 98 + // Build GeoJSON features for each location 99 + const features: Feature<Polygon>[] = parsedLocations.map((loc) => { 100 + const h3Index = h3.latLngToCell(loc.latitude, loc.longitude, H3_RESOLUTION) 101 + return h3ToGeoJsonFeature(h3, h3Index, { 102 + fillColor: '#3273dc', 103 + fillOpacity: 0.2, 104 + strokeColor: '#3273dc', 105 + strokeWidth: 2, 106 + }) 107 + }) 94 108 95 - // Draw H3 hexagon for each geo location 96 - parsedLocations.forEach((loc) => { 97 - const h3Index = h3.latLngToCell(loc.latitude, loc.longitude, H3_RESOLUTION) 98 - const boundary = h3.cellToBoundary(h3Index) 99 - const latLngs: [number, number][] = boundary.map((coord) => [coord[0], coord[1]]) 100 - 101 - // Add to bounds 102 - latLngs.forEach((coord) => allBounds.push(coord)) 109 + // Update the source with features 110 + updateHexagonSource(map, features) 103 111 104 - // Draw H3 hexagon 105 - L.polygon(latLngs, { 106 - color: '#3273dc', 107 - fillColor: '#3273dc', 108 - fillOpacity: 0.2, 109 - weight: 2, 110 - className: 'h3-hex', 111 - }).addTo(map) 112 + // Fit map to show all hexagons 113 + const bounds = calculateBounds(features) 114 + if (bounds) { 115 + map.fitBounds(bounds, { padding: 20 }) 116 + } 112 117 }) 113 - 114 - // Fit map to show all hexagons if there are multiple locations 115 - if (allBounds.length > 0) { 116 - const bounds = L.latLngBounds(allBounds) 117 - map.fitBounds(bounds, { padding: [20, 20] }) 118 - } 119 118 120 119 // Mark as successfully initialized 121 120 container.dataset.mapInitialized = 'true'
+53 -92
src-js/src/features/maps/location-heatmap.ts
··· 2 2 * Location Heatmap Feature 3 3 * 4 4 * Renders the location heatmap on the location page showing event distribution. 5 - * Uses Leaflet for map rendering and H3 for hexagon visualization. 5 + * Uses MapLibre GL for map rendering and H3 for hexagon visualization. 6 6 */ 7 7 8 + import type { Feature, Polygon } from 'geojson' 8 9 import type { H3Bucket } from '../../types' 10 + import { 11 + loadMapLibraries, 12 + createMap, 13 + h3ToGeoJsonFeature, 14 + addHexagonLayers, 15 + updateHexagonSource, 16 + calculateBounds, 17 + heatmapGradientColor, 18 + toMapCenter, 19 + } from './map-utils' 9 20 10 21 export async function initLocationHeatmap(): Promise<void> { 11 22 const mapContainer = document.getElementById('location-heatmap') ··· 36 47 return 37 48 } 38 49 39 - // Lazy load Leaflet and H3 40 - const [L, h3] = await Promise.all([import('leaflet').then((m) => m.default), import('h3-js')]) 41 - 42 - // Import Leaflet CSS 43 - await import('leaflet/dist/leaflet.css') 50 + // Lazy load MapLibre and H3 51 + const { maplibregl, h3 } = await loadMapLibraries() 44 52 45 - // Create map centered on the H3 cell 46 - const map = L.map('location-heatmap', { 47 - center: [centerLat, centerLon], 53 + // Create non-interactive map 54 + const map = createMap(maplibregl, { 55 + container: 'location-heatmap', 56 + center: toMapCenter(centerLat, centerLon), 48 57 zoom: 9, 49 - zoomControl: false, 50 - dragging: false, 51 - touchZoom: false, 52 - scrollWheelZoom: false, 53 - doubleClickZoom: false, 54 - boxZoom: false, 55 - keyboard: false, 56 - attributionControl: true, 58 + interactive: false, 57 59 }) 58 60 59 - // Add OpenStreetMap tiles 60 - L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { 61 - attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>', 62 - maxZoom: 19, 63 - }).addTo(map) 61 + map.on('load', () => { 62 + // Add hexagon layers 63 + addHexagonLayers(map) 64 64 65 - // Heatmap color scale from low (blue) to high (red) 66 - function getHeatmapColor(value: number, min: number, max: number): string { 67 - if (max === min) return '#3273dc' 68 - const ratio = (value - min) / (max - min) 69 - // Blue (#3273dc) -> Purple (#8957e5) -> Orange (#f39c12) -> Red (#e74c3c) 70 - if (ratio < 0.33) { 71 - const t = ratio / 0.33 72 - return lerpColor('#3273dc', '#8957e5', t) 73 - } else if (ratio < 0.66) { 74 - const t = (ratio - 0.33) / 0.33 75 - return lerpColor('#8957e5', '#f39c12', t) 76 - } else { 77 - const t = (ratio - 0.66) / 0.34 78 - return lerpColor('#f39c12', '#e74c3c', t) 79 - } 80 - } 65 + // Only draw hexes with events 66 + if (geoBuckets && geoBuckets.length > 0) { 67 + const counts = geoBuckets.map((b) => b.doc_count ?? 0) 68 + const minCount = Math.min(...counts) 69 + const maxCount = Math.max(...counts) 81 70 82 - function lerpColor(a: string, b: string, t: number): string { 83 - const ah = parseInt(a.replace('#', ''), 16) 84 - const bh = parseInt(b.replace('#', ''), 16) 85 - const ar = ah >> 16, 86 - ag = (ah >> 8) & 0xff, 87 - ab = ah & 0xff 88 - const br = bh >> 16, 89 - bg = (bh >> 8) & 0xff, 90 - bb = bh & 0xff 91 - const rr = Math.round(ar + (br - ar) * t) 92 - const rg = Math.round(ag + (bg - ag) * t) 93 - const rb = Math.round(ab + (bb - ab) * t) 94 - return '#' + ((1 << 24) + (rr << 16) + (rg << 8) + rb).toString(16).slice(1) 95 - } 71 + const features: Feature<Polygon>[] = [] 96 72 97 - // Only draw hexes with events 98 - if (geoBuckets && geoBuckets.length > 0) { 99 - const counts = geoBuckets.map((b) => b.doc_count ?? 0) 100 - const minCount = Math.min(...counts) 101 - const maxCount = Math.max(...counts) 102 - 103 - geoBuckets.forEach((bucket) => { 104 - try { 105 - const cellIndex = bucket.key 106 - const count = bucket.doc_count ?? 0 107 - const boundary = h3.cellToBoundary(cellIndex) 108 - const latLngs: [number, number][] = boundary.map((coord) => [coord[0], coord[1]]) 73 + geoBuckets.forEach((bucket) => { 74 + try { 75 + const cellIndex = bucket.key 76 + const count = bucket.doc_count ?? 0 77 + const isCenter = cellIndex === centerCell 78 + const color = heatmapGradientColor(count, minCount, maxCount) 109 79 110 - const isCenter = cellIndex === centerCell 111 - const color = getHeatmapColor(count, minCount, maxCount) 80 + features.push( 81 + h3ToGeoJsonFeature(h3, cellIndex, { 82 + fillColor: color, 83 + fillOpacity: 0.5, 84 + strokeColor: isCenter ? '#1a1a1a' : color, 85 + strokeWidth: isCenter ? 3 : 2, 86 + }) 87 + ) 88 + } catch (e) { 89 + console.warn('Failed to draw hex:', bucket.key, e) 90 + } 91 + }) 112 92 113 - L.polygon(latLngs, { 114 - color: isCenter ? '#1a1a1a' : color, 115 - fillColor: color, 116 - fillOpacity: 0.5, 117 - weight: isCenter ? 3 : 2, 118 - className: isCenter ? 'h3-hex-center' : 'h3-hex', 119 - }).addTo(map) 120 - } catch (e) { 121 - console.warn('Failed to draw hex:', bucket.key, e) 122 - } 123 - }) 93 + // Update the source with features 94 + updateHexagonSource(map, features) 124 95 125 - // Fit bounds to show all hexes 126 - const allCoords: [number, number][] = geoBuckets.flatMap((bucket) => { 127 - try { 128 - return h3 129 - .cellToBoundary(bucket.key) 130 - .map((coord): [number, number] => [coord[0], coord[1]]) 131 - } catch (e) { 132 - return [] 96 + // Fit bounds to show all hexes 97 + const bounds = calculateBounds(features) 98 + if (bounds) { 99 + map.fitBounds(bounds, { padding: 10 }) 133 100 } 134 - }) 135 - if (allCoords.length > 0) { 136 - map.fitBounds(allCoords, { padding: [10, 10] }) 137 101 } 138 - } else { 139 - // No events - just show center marker 140 - L.marker([centerLat, centerLon]).addTo(map) 141 - } 102 + }) 142 103 143 104 mapContainer.dataset.mapInitialized = 'true' 144 105 } catch (err) {
+277
src-js/src/features/maps/map-utils.ts
··· 1 + /** 2 + * Map Utilities 3 + * 4 + * Shared utilities for MapLibre GL maps with H3 hexagon visualization. 5 + * Handles coordinate conversion between H3 (lat, lng) and GeoJSON (lng, lat). 6 + */ 7 + 8 + import type { Feature, FeatureCollection, Polygon } from 'geojson' 9 + import type { 10 + GeoJSONSource, 11 + LngLatBoundsLike, 12 + Map as MaplibreMap, 13 + MapOptions, 14 + StyleSpecification, 15 + } from 'maplibre-gl' 16 + import type * as h3Lib from 'h3-js' 17 + 18 + // Module-level cache for lazy-loaded libraries 19 + let maplibreModule: typeof import('maplibre-gl') | null = null 20 + let h3Module: typeof h3Lib | null = null 21 + 22 + export interface MapLibraries { 23 + maplibregl: typeof import('maplibre-gl') 24 + h3: typeof h3Lib 25 + } 26 + 27 + /** 28 + * Lazy load MapLibre GL and H3 libraries 29 + */ 30 + export async function loadMapLibraries(): Promise<MapLibraries> { 31 + if (!maplibreModule || !h3Module) { 32 + const [maplibre, h3] = await Promise.all([import('maplibre-gl'), import('h3-js')]) 33 + 34 + // Import MapLibre GL CSS 35 + await import('maplibre-gl/dist/maplibre-gl.css') 36 + 37 + maplibreModule = maplibre 38 + h3Module = h3 39 + } 40 + 41 + return { maplibregl: maplibreModule, h3: h3Module } 42 + } 43 + 44 + /** 45 + * Get the cached H3 module (must call loadMapLibraries first) 46 + */ 47 + export function getH3Module(): typeof h3Lib | null { 48 + return h3Module 49 + } 50 + 51 + /** 52 + * Base style for flat maps (non-globe, OSM tiles) 53 + */ 54 + export const flatMapStyle: StyleSpecification = { 55 + version: 8, 56 + sources: { 57 + osm: { 58 + type: 'raster', 59 + tiles: ['https://tile.openstreetmap.org/{z}/{x}/{y}.png'], 60 + tileSize: 256, 61 + attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>', 62 + maxzoom: 19, 63 + }, 64 + }, 65 + layers: [ 66 + { 67 + id: 'osm-tiles', 68 + type: 'raster', 69 + source: 'osm', 70 + }, 71 + ], 72 + } 73 + 74 + export interface CreateMapOptions { 75 + container: string | HTMLElement 76 + center?: [number, number] // [lng, lat] 77 + zoom?: number 78 + interactive?: boolean 79 + scrollZoom?: boolean 80 + maxZoom?: number 81 + minZoom?: number 82 + } 83 + 84 + /** 85 + * Create a standard MapLibre map with OSM tiles 86 + */ 87 + export function createMap( 88 + maplibregl: typeof import('maplibre-gl'), 89 + options: CreateMapOptions 90 + ): MaplibreMap { 91 + const { container, center = [0, 0], zoom = 12, interactive = true, scrollZoom = false } = options 92 + 93 + const mapOptions: MapOptions = { 94 + container, 95 + style: flatMapStyle, 96 + center, 97 + zoom, 98 + maxZoom: options.maxZoom, 99 + minZoom: options.minZoom, 100 + } 101 + 102 + if (!interactive) { 103 + mapOptions.interactive = false 104 + // Attribution control is shown by default when not set to false 105 + } else { 106 + // For interactive maps, disable scroll zoom by default 107 + mapOptions.scrollZoom = scrollZoom 108 + } 109 + 110 + return new maplibregl.Map(mapOptions) 111 + } 112 + 113 + export interface HexFeatureProperties { 114 + id: string 115 + fillColor: string 116 + fillOpacity: number 117 + strokeColor: string 118 + strokeWidth: number 119 + [key: string]: unknown 120 + } 121 + 122 + /** 123 + * Convert H3 cell to GeoJSON Feature 124 + * Handles coordinate order conversion from H3 [lat, lng] to GeoJSON [lng, lat] 125 + */ 126 + export function h3ToGeoJsonFeature( 127 + h3: typeof h3Lib, 128 + h3Index: string, 129 + properties: Partial<HexFeatureProperties> = {} 130 + ): Feature<Polygon> { 131 + const boundary = h3.cellToBoundary(h3Index) 132 + 133 + // Convert H3 [lat, lng] to GeoJSON [lng, lat] 134 + const coordinates: [number, number][] = boundary.map(([lat, lng]) => [lng, lat]) 135 + coordinates.push(coordinates[0]) // Close the ring 136 + 137 + return { 138 + type: 'Feature', 139 + properties: { 140 + id: h3Index, 141 + fillColor: properties.fillColor ?? '#3273dc', 142 + fillOpacity: properties.fillOpacity ?? 0.3, 143 + strokeColor: properties.strokeColor ?? '#3273dc', 144 + strokeWidth: properties.strokeWidth ?? 2, 145 + ...properties, 146 + }, 147 + geometry: { 148 + type: 'Polygon', 149 + coordinates: [coordinates], 150 + }, 151 + } 152 + } 153 + 154 + /** 155 + * Add hexagon layers to the map (fill + outline) 156 + * Uses data-driven styling from feature properties 157 + */ 158 + export function addHexagonLayers(map: MaplibreMap, sourceId = 'hexagons'): void { 159 + // Add empty GeoJSON source 160 + map.addSource(sourceId, { 161 + type: 'geojson', 162 + data: { type: 'FeatureCollection', features: [] }, 163 + }) 164 + 165 + // Add fill layer 166 + map.addLayer({ 167 + id: `${sourceId}-fill`, 168 + type: 'fill', 169 + source: sourceId, 170 + paint: { 171 + 'fill-color': ['get', 'fillColor'], 172 + 'fill-opacity': ['get', 'fillOpacity'], 173 + }, 174 + }) 175 + 176 + // Add outline layer 177 + map.addLayer({ 178 + id: `${sourceId}-outline`, 179 + type: 'line', 180 + source: sourceId, 181 + paint: { 182 + 'line-color': ['get', 'strokeColor'], 183 + 'line-width': ['get', 'strokeWidth'], 184 + }, 185 + }) 186 + } 187 + 188 + /** 189 + * Update the hexagon source data 190 + */ 191 + export function updateHexagonSource( 192 + map: MaplibreMap, 193 + features: Feature<Polygon>[], 194 + sourceId = 'hexagons' 195 + ): void { 196 + const source = map.getSource(sourceId) as GeoJSONSource | undefined 197 + if (source) { 198 + const data: FeatureCollection<Polygon> = { 199 + type: 'FeatureCollection', 200 + features, 201 + } 202 + source.setData(data) 203 + } 204 + } 205 + 206 + /** 207 + * Calculate bounds from GeoJSON features 208 + * Returns bounds in [sw, ne] format: [[minLng, minLat], [maxLng, maxLat]] 209 + */ 210 + export function calculateBounds(features: Feature<Polygon>[]): LngLatBoundsLike | null { 211 + if (features.length === 0) return null 212 + 213 + let minLng = Infinity 214 + let minLat = Infinity 215 + let maxLng = -Infinity 216 + let maxLat = -Infinity 217 + 218 + for (const feature of features) { 219 + const coords = feature.geometry.coordinates[0] 220 + for (const [lng, lat] of coords) { 221 + if (lng < minLng) minLng = lng 222 + if (lng > maxLng) maxLng = lng 223 + if (lat < minLat) minLat = lat 224 + if (lat > maxLat) maxLat = lat 225 + } 226 + } 227 + 228 + return [ 229 + [minLng, minLat], 230 + [maxLng, maxLat], 231 + ] 232 + } 233 + 234 + /** 235 + * Linear interpolation between two hex colors 236 + */ 237 + export function lerpColor(a: string, b: string, t: number): string { 238 + const ah = parseInt(a.replace('#', ''), 16) 239 + const bh = parseInt(b.replace('#', ''), 16) 240 + const ar = ah >> 16, 241 + ag = (ah >> 8) & 0xff, 242 + ab = ah & 0xff 243 + const br = bh >> 16, 244 + bg = (bh >> 8) & 0xff, 245 + bb = bh & 0xff 246 + const rr = Math.round(ar + (br - ar) * t) 247 + const rg = Math.round(ag + (bg - ag) * t) 248 + const rb = Math.round(ab + (bb - ab) * t) 249 + return '#' + ((1 << 24) + (rr << 16) + (rg << 8) + rb).toString(16).slice(1) 250 + } 251 + 252 + /** 253 + * Get heatmap gradient color based on value 254 + * Blue (#3273dc) -> Purple (#8957e5) -> Orange (#f39c12) -> Red (#e74c3c) 255 + */ 256 + export function heatmapGradientColor(value: number, min: number, max: number): string { 257 + if (max === min) return '#3273dc' 258 + const ratio = (value - min) / (max - min) 259 + 260 + if (ratio < 0.33) { 261 + const t = ratio / 0.33 262 + return lerpColor('#3273dc', '#8957e5', t) 263 + } else if (ratio < 0.66) { 264 + const t = (ratio - 0.33) / 0.33 265 + return lerpColor('#8957e5', '#f39c12', t) 266 + } else { 267 + const t = (ratio - 0.66) / 0.34 268 + return lerpColor('#f39c12', '#e74c3c', t) 269 + } 270 + } 271 + 272 + /** 273 + * Convert lat/lng to MapLibre center format [lng, lat] 274 + */ 275 + export function toMapCenter(lat: number, lng: number): [number, number] { 276 + return [lng, lat] 277 + }
+26
src-js/src/main.ts
··· 16 16 17 17 // Core utilities 18 18 import { initNavigation } from './components/navigation' 19 + // Auth utilities for session management 20 + import { 21 + AuthRequiredError, 22 + authFetch, 23 + authPostJson, 24 + refreshAuth, 25 + refreshSession, 26 + SessionExpiredError, 27 + } from './core/auth' 19 28 import { eventForm } from './features/events/create' 20 29 import { initQuickEventForm } from './features/events/quick-create' 21 30 // Features - Alpine.js components for page-specific functionality ··· 174 183 * Provides: 175 184 * - Alpine.js component factories (lfgForm, eventForm) 176 185 * - Lazy-loading initializers (initEventMap, initGlobeMap, etc.) 186 + * - Auth utilities (refreshSession, authFetch, authPostJson) 177 187 * 178 188 * Usage in templates: 179 189 * <div x-data="SmokesignalApp.lfgForm()">...</div> 180 190 * <script>SmokesignalApp.initEventMap()</script> 191 + * <script>SmokesignalApp.authPostJson('/api/endpoint', data)</script> 181 192 */ 182 193 const SmokesignalApp = { 183 194 // Alpine.js component factories ··· 195 206 196 207 // Re-initialize page (useful after major DOM changes) 197 208 initPage, 209 + 210 + // Auth utilities for session management 211 + refreshSession, 212 + refreshAuth, 213 + authFetch, 214 + authPostJson, 215 + SessionExpiredError, 216 + AuthRequiredError, 198 217 } 199 218 200 219 // Expose SmokesignalApp namespace for inline scripts ··· 218 237 initProfileCropper, 219 238 initLfgHeatmap, 220 239 initPage, 240 + // Auth utilities 241 + refreshSession, 242 + refreshAuth, 243 + authFetch, 244 + authPostJson, 245 + SessionExpiredError, 246 + AuthRequiredError, 221 247 }
+1 -5
src-js/vite.config.ts
··· 29 29 // htmx and Alpine are bundled in the main bundle for immediate availability 30 30 manualChunks: (id) => { 31 31 // Map libraries - lazy loaded together 32 - if ( 33 - id.includes('leaflet') || 34 - id.includes('maplibre-gl') || 35 - id.includes('h3-js') 36 - ) { 32 + if (id.includes('maplibre-gl') || id.includes('h3-js')) { 37 33 return 'maps' 38 34 } 39 35 // Cropper - lazy loaded separately
-221
src/aip_auth_cache.rs
··· 1 - //! AIP Authentication Cache 2 - //! 3 - //! This module provides caching for AIP OAuth userinfo lookups to validate 4 - //! Bearer tokens and retrieve user information for MCP requests. 5 - 6 - use serde::{Deserialize, Serialize}; 7 - use std::collections::HashMap; 8 - use std::sync::Arc; 9 - use std::time::{Duration, Instant}; 10 - use tokio::sync::RwLock; 11 - use tracing::{debug, error, warn}; 12 - 13 - /// User information from AIP OAuth userinfo endpoint 14 - #[derive(Debug, Clone, Deserialize, Serialize)] 15 - pub struct AipUserInfo { 16 - /// The DID of the user (subject identifier) 17 - pub sub: String, 18 - /// Optional display name 19 - #[serde(skip_serializing_if = "Option::is_none")] 20 - pub name: Option<String>, 21 - /// Optional email address 22 - #[serde(skip_serializing_if = "Option::is_none")] 23 - pub email: Option<String>, 24 - /// Optional DID (may be same as sub) 25 - #[serde(skip_serializing_if = "Option::is_none")] 26 - pub did: Option<String>, 27 - } 28 - 29 - /// Cached entry with expiration 30 - #[derive(Debug, Clone)] 31 - struct CachedEntry { 32 - user_info: AipUserInfo, 33 - expires_at: Instant, 34 - } 35 - 36 - /// AIP Authentication Cache 37 - /// 38 - /// Provides async-safe caching of AIP OAuth userinfo lookups. 39 - /// Tokens are validated by calling the AIP userinfo endpoint, 40 - /// and results are cached for a configurable duration. 41 - #[derive(Clone)] 42 - pub struct AipAuthCache { 43 - /// HTTP client for making requests 44 - http_client: reqwest::Client, 45 - /// AIP hostname for OAuth endpoints 46 - aip_hostname: String, 47 - /// Cache storage (token -> user info) 48 - cache: Arc<RwLock<HashMap<String, CachedEntry>>>, 49 - /// Time-to-live for cache entries 50 - ttl: Duration, 51 - } 52 - 53 - impl AipAuthCache { 54 - /// Create a new AIP auth cache 55 - /// 56 - /// # Arguments 57 - /// * `http_client` - HTTP client to use for requests 58 - /// * `aip_hostname` - AIP hostname (e.g., "bsky.social") 59 - /// * `ttl` - Time-to-live for cache entries (default: 5 minutes) 60 - pub fn new(http_client: reqwest::Client, aip_hostname: String, ttl: Option<Duration>) -> Self { 61 - Self { 62 - http_client, 63 - aip_hostname, 64 - cache: Arc::new(RwLock::new(HashMap::new())), 65 - ttl: ttl.unwrap_or(Duration::from_secs(300)), // 5 minutes default 66 - } 67 - } 68 - 69 - /// Validate a Bearer token and return user information 70 - /// 71 - /// This method will: 72 - /// 1. Check the cache for a valid entry 73 - /// 2. If not found or expired, call the AIP userinfo endpoint 74 - /// 3. Cache the result for future lookups 75 - /// 76 - /// # Arguments 77 - /// * `bearer_token` - The Bearer token value (without "Bearer " prefix) 78 - /// 79 - /// # Returns 80 - /// * `Ok(Some(AipUserInfo))` - Token is valid, user info returned 81 - /// * `Ok(None)` - Token is invalid (401 from userinfo endpoint) 82 - /// * `Err(...)` - Network error or other failure 83 - pub async fn validate_token( 84 - &self, 85 - bearer_token: &str, 86 - ) -> Result<Option<AipUserInfo>, anyhow::Error> { 87 - // Check cache first 88 - { 89 - let cache = self.cache.read().await; 90 - if let Some(entry) = cache.get(bearer_token) 91 - && entry.expires_at > Instant::now() 92 - { 93 - debug!(sub = %entry.user_info.sub, "Cache hit for Bearer token"); 94 - return Ok(Some(entry.user_info.clone())); 95 - } 96 - } 97 - 98 - // Cache miss or expired - fetch from AIP 99 - debug!("Cache miss for Bearer token, fetching from AIP"); 100 - 101 - let userinfo_url = format!("https://{}/oauth/userinfo", self.aip_hostname); 102 - 103 - let response = self 104 - .http_client 105 - .get(&userinfo_url) 106 - .header("Authorization", format!("Bearer {}", bearer_token)) 107 - .send() 108 - .await; 109 - 110 - let response = match response { 111 - Ok(resp) => resp, 112 - Err(e) => { 113 - error!(?e, "Failed to fetch userinfo from AIP"); 114 - return Err(anyhow::anyhow!("Failed to fetch userinfo: {}", e)); 115 - } 116 - }; 117 - 118 - // Check status code 119 - if response.status() == reqwest::StatusCode::UNAUTHORIZED { 120 - debug!("Token validation failed: 401 Unauthorized"); 121 - return Ok(None); 122 - } 123 - 124 - if !response.status().is_success() { 125 - warn!(status = %response.status(), "AIP userinfo endpoint returned error"); 126 - return Err(anyhow::anyhow!("AIP userinfo error: {}", response.status())); 127 - } 128 - 129 - // Parse response 130 - let user_info: AipUserInfo = match response.json().await { 131 - Ok(info) => info, 132 - Err(e) => { 133 - error!(?e, "Failed to parse userinfo response"); 134 - return Err(anyhow::anyhow!("Failed to parse userinfo: {}", e)); 135 - } 136 - }; 137 - 138 - debug!(sub = %user_info.sub, "Successfully validated token and fetched user info"); 139 - 140 - // Store in cache 141 - { 142 - let mut cache = self.cache.write().await; 143 - cache.insert( 144 - bearer_token.to_string(), 145 - CachedEntry { 146 - user_info: user_info.clone(), 147 - expires_at: Instant::now() + self.ttl, 148 - }, 149 - ); 150 - } 151 - 152 - Ok(Some(user_info)) 153 - } 154 - 155 - /// Clear expired entries from the cache 156 - /// 157 - /// This is called automatically during validation, but can also 158 - /// be called manually for cleanup. 159 - pub async fn cleanup_expired(&self) { 160 - let mut cache = self.cache.write().await; 161 - let now = Instant::now(); 162 - cache.retain(|_, entry| entry.expires_at > now); 163 - } 164 - 165 - /// Clear the entire cache 166 - pub async fn clear(&self) { 167 - let mut cache = self.cache.write().await; 168 - cache.clear(); 169 - } 170 - 171 - /// Get the number of entries in the cache 172 - pub async fn len(&self) -> usize { 173 - let cache = self.cache.read().await; 174 - cache.len() 175 - } 176 - 177 - /// Check if the cache is empty 178 - pub async fn is_empty(&self) -> bool { 179 - let cache = self.cache.read().await; 180 - cache.is_empty() 181 - } 182 - } 183 - 184 - #[cfg(test)] 185 - mod tests { 186 - use super::*; 187 - 188 - #[tokio::test] 189 - async fn test_cache_creation() { 190 - let client = reqwest::Client::new(); 191 - let cache = AipAuthCache::new(client, "bsky.social".to_string(), None); 192 - assert!(cache.is_empty().await); 193 - } 194 - 195 - #[tokio::test] 196 - async fn test_cache_clear() { 197 - let client = reqwest::Client::new(); 198 - let cache = AipAuthCache::new(client, "bsky.social".to_string(), None); 199 - 200 - // Manually insert an entry 201 - { 202 - let mut cache_inner = cache.cache.write().await; 203 - cache_inner.insert( 204 - "test_token".to_string(), 205 - CachedEntry { 206 - user_info: AipUserInfo { 207 - sub: "did:plc:test".to_string(), 208 - name: Some("Test User".to_string()), 209 - email: None, 210 - did: Some("did:plc:test".to_string()), 211 - }, 212 - expires_at: Instant::now() + Duration::from_secs(60), 213 - }, 214 - ); 215 - } 216 - 217 - assert_eq!(cache.len().await, 1); 218 - cache.clear().await; 219 - assert!(cache.is_empty().await); 220 - } 221 - }
+5 -30
src/atproto/auth.rs
··· 3 3 use atproto_client::client::DPoPAuth; 4 4 use atproto_identity::key::identify_key; 5 5 6 - use crate::storage::oauth::model::OAuthSession; 7 - use atproto_oauth_aip::{resources::oauth_protected_resource, workflow::session_exchange}; 6 + use crate::http::cookies::SessionCookie; 8 7 9 - /// Create DPoPAuth directly from OAuthSession 10 - pub(crate) fn create_dpop_auth_from_oauth_session( 11 - oauth_session: &OAuthSession, 12 - ) -> Result<DPoPAuth> { 13 - let dpop_private_key_data = identify_key(&oauth_session.dpop_jwk)?; 8 + /// Create DPoPAuth from SessionCookie 9 + pub(crate) fn create_dpop_auth_from_session(session: &SessionCookie) -> Result<DPoPAuth> { 10 + let dpop_private_key_data = identify_key(&session.dpop_private_key)?; 14 11 15 12 Ok(DPoPAuth { 16 13 dpop_private_key_data, 17 - oauth_access_token: oauth_session.access_token.clone(), 18 - }) 19 - } 20 - 21 - pub(crate) async fn create_dpop_auth_from_aip_session( 22 - http_client: &reqwest::Client, 23 - aip_server: &str, 24 - access_token: &str, 25 - ) -> Result<DPoPAuth> { 26 - let protected_resource = oauth_protected_resource(http_client, aip_server).await?; 27 - 28 - let session_response = 29 - session_exchange(http_client, &protected_resource.resource, access_token).await?; 30 - 31 - let dpop_key = session_response.dpop_key.ok_or_else(|| { 32 - anyhow::anyhow!("error-smokesignal-auth-1 DPoP key missing from session response") 33 - })?; 34 - 35 - let dpop_private_key_data = identify_key(&dpop_key)?; 36 - 37 - Ok(DPoPAuth { 38 - dpop_private_key_data, 39 - oauth_access_token: session_response.access_token.clone(), 14 + oauth_access_token: session.access_token.clone(), 40 15 }) 41 16 }
+17 -105
src/bin/smokesignal.rs
··· 1 1 use anyhow::Result; 2 - use atproto_identity::key::{IdentityDocumentKeyResolver, identify_key, to_public}; 2 + use atproto_identity::key::{IdentityDocumentKeyResolver, to_public}; 3 3 use atproto_identity::resolve::{ 4 4 HickoryDnsResolver, InnerIdentityResolver, SharedIdentityResolver, 5 5 }; ··· 23 23 }; 24 24 use tokio_util::sync::CancellationToken; 25 25 26 - use chrono::Duration; 27 - use smokesignal::config::OAuthBackendConfig; 28 - use smokesignal::task_identity_refresh::{IdentityRefreshTask, IdentityRefreshTaskConfig}; 29 - use smokesignal::task_oauth_requests_cleanup::{ 30 - OAuthRequestsCleanupTask, OAuthRequestsCleanupTaskConfig, 31 - }; 32 26 use sqlx::PgPool; 33 27 use std::{collections::HashMap, env, str::FromStr, sync::Arc}; 34 28 use tokio::net::TcpListener; ··· 114 108 let oauth_storage = PostgresOAuthRequestStorage::new_arc(pool.clone()); 115 109 let document_storage = PostgresDidDocumentStorage::new_arc(pool.clone()); 116 110 117 - // Create a key provider populated with signing keys from OAuth backend config 118 - let mut key_provider_keys = 119 - if let OAuthBackendConfig::ATProtocol { signing_keys } = &config.oauth_backend { 120 - signing_keys 121 - .as_ref() 122 - .iter() 123 - .filter_map(|(key_id, private_key)| match identify_key(private_key) { 124 - Ok(key_data) => Some((key_id.clone(), key_data)), 125 - Err(err) => { 126 - tracing::error!(?err, ?key_id, "failed to identify key for key provider"); 127 - None 128 - } 129 - }) 130 - .collect() 131 - } else { 132 - HashMap::new() // Empty for AIP backend 133 - }; 111 + // Create a key provider populated with OAuth client credentials key from config 112 + let oauth_key = config.oauth_client_credentials_key.as_ref().clone(); 113 + let oauth_public_key = to_public(&oauth_key) 114 + .map(|pk| pk.to_string()) 115 + .expect("oauth public key"); 116 + let mut key_provider_keys: HashMap<String, _> = HashMap::new(); 117 + key_provider_keys.insert(oauth_public_key, oauth_key.clone()); 134 118 key_provider_keys.insert(public_service_key, service_key.0.clone()); 135 119 let key_provider = Arc::new(SimpleKeyProvider::new(key_provider_keys)); 136 120 137 - // Create OAuth client config (only for AT Protocol backend) 121 + // Create OAuth client config for AT Protocol 138 122 let oauth_client_config = OAuthClientConfig { 139 - client_id: config.external_base.clone(), 123 + client_id: format!("https://{}/oauth-client-metadata.json", config.external_base), 140 124 jwks_uri: None, 141 - signing_keys: if let OAuthBackendConfig::ATProtocol { signing_keys } = &config.oauth_backend 142 - { 143 - signing_keys 144 - .as_ref() 145 - .iter() 146 - .filter_map(|value| identify_key(value.1).ok()) 147 - .collect() 148 - } else { 149 - Vec::new() // Empty for AIP backend 150 - }, 151 - redirect_uris: format!("{}/oauth/callback", config.external_base), 125 + signing_keys: vec![oauth_key], 126 + redirect_uris: format!("https://{}/oauth/callback", config.external_base), 152 127 client_name: Some("Smoke Signal".to_string()), 153 - client_uri: Some(config.external_base.clone()), 154 - logo_uri: Some(format!( 155 - "https://{}/logo-160x160x.png", 156 - config.external_base 157 - )), 158 - tos_uri: Some("https://smokesignal.events/terms-of-service".to_string()), 159 - policy_uri: Some("https://smokesignal.events/privacy-policy".to_string()), 160 - scope: Some("atproto transition:generic transition:email".to_string()), 128 + client_uri: Some(format!("https://{}", config.external_base)), 129 + logo_uri: Some(format!("https://{}/logo-160x160x.png", config.external_base)), 130 + tos_uri: Some(format!("https://{}/terms-of-service", config.external_base)), 131 + policy_uri: Some(format!("https://{}/privacy-policy", config.external_base)), 132 + scope: Some(config.oauth_scope()), 161 133 }; 162 134 163 135 let identity_resolver = Arc::new(SharedIdentityResolver(Arc::new(InnerIdentityResolver { ··· 231 203 232 204 let mcp_session_manager = Arc::new(smokesignal::mcp::session::MemoryMcpSessionManager::new()); 233 205 234 - // Create AIP auth cache if using AIP backend 235 - let aip_auth_cache = match &config.oauth_backend { 236 - OAuthBackendConfig::AIP { hostname, .. } => { 237 - // Extract hostname without https:// prefix 238 - let aip_hostname = hostname.trim_start_matches("https://").to_string(); 239 - let cache = Arc::new(smokesignal::aip_auth_cache::AipAuthCache::new( 240 - http_client.clone(), 241 - aip_hostname, 242 - None, // Use default TTL 243 - )); 244 - tracing::info!("AIP auth cache initialized"); 245 - Some(cache) 246 - } 247 - _ => { 248 - tracing::info!("AIP auth cache not initialized (not using AIP backend)"); 249 - None 250 - } 251 - }; 252 - 253 206 let web_context = WebContext::new( 254 207 pool.clone(), 255 208 cache_pool.clone(), ··· 269 222 service_document, 270 223 service_key, 271 224 mcp_session_manager, 272 - aip_auth_cache, 273 225 ); 274 226 275 227 let app = build_router(web_context.clone()); ··· 369 321 tracker.spawn(async move { 370 322 if let Err(err) = tap_processor.run().await { 371 323 tracing::error!(error = ?err, "TAP processor failed"); 372 - } 373 - inner_token.cancel(); 374 - }); 375 - } 376 - 377 - // Spawn OAuth requests cleanup task if enabled 378 - if config.enable_task_oauth_requests_cleanup { 379 - let cleanup_task_config = OAuthRequestsCleanupTaskConfig { 380 - sleep_interval: Duration::hours(1), // Run once per hour 381 - }; 382 - let cleanup_task = 383 - OAuthRequestsCleanupTask::new(cleanup_task_config, pool.clone(), token.clone()); 384 - 385 - let inner_token = token.clone(); 386 - tracker.spawn(async move { 387 - if let Err(err) = cleanup_task.run().await { 388 - tracing::error!("OAuth requests cleanup task failed: {}", err); 389 - } 390 - inner_token.cancel(); 391 - }); 392 - } 393 - 394 - // Spawn identity refresh task if enabled 395 - if config.enable_task_identity_refresh { 396 - let identity_refresh_config = IdentityRefreshTaskConfig { 397 - sleep_interval: Duration::hours(1), // Run once per hour 398 - worker_id: "dev".to_string(), 399 - }; 400 - let identity_refresh_task = IdentityRefreshTask::new( 401 - identity_refresh_config, 402 - pool.clone(), 403 - document_storage.clone(), 404 - identity_resolver.clone(), 405 - token.clone(), 406 - ); 407 - 408 - let inner_token = token.clone(); 409 - tracker.spawn(async move { 410 - if let Err(err) = identity_refresh_task.run().await { 411 - tracing::error!("Identity refresh task failed: {}", err); 412 324 } 413 325 inner_token.cancel(); 414 326 });
+42 -121
src/config.rs
··· 1 1 use anyhow::Result; 2 - use atproto_identity::key::{KeyData, KeyType, identify_key, to_public}; 2 + use atproto_identity::key::{KeyData, identify_key, to_public}; 3 3 use axum_extra::extract::cookie::Key; 4 4 use base64::{Engine as _, engine::general_purpose}; 5 - use ordermap::OrderMap; 6 5 7 6 use crate::config_errors::ConfigError; 8 7 ··· 18 17 #[derive(Clone)] 19 18 pub struct CertificateBundles(Vec<String>); 20 19 21 - #[derive(Clone, Debug)] 22 - pub struct SigningKeys(OrderMap<String, String>); 20 + #[derive(Clone)] 21 + pub struct OAuthClientCredentialsKey(KeyData); 23 22 24 23 #[derive(Clone)] 25 24 pub struct AdminDIDs(Vec<String>); ··· 27 26 #[derive(Clone)] 28 27 pub struct DnsNameservers(Vec<std::net::IpAddr>); 29 28 30 - #[derive(Clone, Debug)] 31 - pub enum OAuthBackendConfig { 32 - ATProtocol { 33 - signing_keys: SigningKeys, 34 - }, 35 - AIP { 36 - hostname: String, 37 - client_id: String, 38 - client_secret: String, 39 - }, 40 - } 41 29 42 30 #[derive(Clone)] 43 31 pub struct ServiceKey(KeyData); ··· 58 46 pub redis_url: String, 59 47 pub admin_dids: AdminDIDs, 60 48 pub dns_nameservers: DnsNameservers, 61 - pub oauth_backend: OAuthBackendConfig, 62 - pub enable_task_oauth_requests_cleanup: bool, 63 - pub enable_task_identity_refresh: bool, 49 + pub oauth_client_credentials_key: OAuthClientCredentialsKey, 64 50 pub enable_tap: bool, 65 51 pub content_storage: String, 66 52 pub service_key: ServiceKey, ··· 73 59 pub facets_tags_max: usize, 74 60 pub facets_links_max: usize, 75 61 pub facets_max: usize, 62 + /// Optional MCP JWT signing key (defaults to http_cookie_key if not set) 63 + pub mcp_jwt_key: Option<String>, 76 64 } 77 65 78 66 impl Config { ··· 112 100 113 101 let dns_nameservers: DnsNameservers = optional_env("DNS_NAMESERVERS").try_into()?; 114 102 115 - // Create OAuth backend configuration based on environment variables 116 - let oauth_backend_type = default_env("OAUTH_BACKEND", "pds"); 117 - let oauth_backend = match oauth_backend_type.to_lowercase().as_str() { 118 - "pds" => { 119 - let signing_keys: SigningKeys = 120 - require_env("SIGNING_KEYS").and_then(|value| value.try_into())?; 121 - OAuthBackendConfig::ATProtocol { signing_keys } 122 - } 123 - "aip" => { 124 - let hostname = 125 - require_env("AIP_HOSTNAME").map(|value| format!("https://{value}"))?; 126 - let client_id = require_env("AIP_CLIENT_ID")?; 127 - let client_secret = require_env("AIP_CLIENT_SECRET")?; 128 - OAuthBackendConfig::AIP { 129 - hostname, 130 - client_id, 131 - client_secret, 132 - } 133 - } 134 - _ => return Err(ConfigError::InvalidOAuthBackend(oauth_backend_type).into()), 135 - }; 136 - 137 - // Parse optional task enablement flags 138 - let enable_task_oauth_requests_cleanup = 139 - default_env("ENABLE_TASK_OAUTH_REQUESTS_CLEANUP", "true") 140 - .parse::<bool>() 141 - .unwrap_or(true); 142 - let enable_task_identity_refresh = default_env("ENABLE_TASK_IDENTITY_REFRESH", "true") 143 - .parse::<bool>() 144 - .unwrap_or(true); 103 + // Parse OAuth client credentials key for AT Protocol OAuth 104 + let oauth_client_credentials_key: OAuthClientCredentialsKey = 105 + require_env("OAUTH_CLIENT_CREDENTIALS_KEY").and_then(|value| value.try_into())?; 145 106 146 107 let enable_tap = parse_bool_env("ENABLE_TAP", true); 147 108 ··· 189 150 .parse::<usize>() 190 151 .unwrap_or(10); 191 152 153 + // Parse optional MCP JWT key (defaults to http_cookie_key if not set) 154 + let mcp_jwt_key_str = optional_env("MCP_JWT_KEY"); 155 + let mcp_jwt_key = if mcp_jwt_key_str.is_empty() { 156 + None 157 + } else { 158 + Some(mcp_jwt_key_str) 159 + }; 160 + 192 161 Ok(Self { 193 162 version: version()?, 194 163 http_port, ··· 204 173 redis_url, 205 174 admin_dids, 206 175 dns_nameservers, 207 - oauth_backend, 208 - enable_task_oauth_requests_cleanup, 209 - enable_task_identity_refresh, 176 + oauth_client_credentials_key, 210 177 enable_tap, 211 178 content_storage, 212 179 service_key, ··· 219 186 facets_tags_max, 220 187 facets_links_max, 221 188 facets_max, 189 + mcp_jwt_key, 222 190 }) 223 191 } 224 192 225 - pub fn select_oauth_signing_key(&self) -> Result<(String, String)> { 226 - match &self.oauth_backend { 227 - OAuthBackendConfig::ATProtocol { signing_keys } => { 228 - let item = signing_keys.as_ref().first(); 229 - item.map(|(key, value)| (key.clone(), value.clone())) 230 - .ok_or(ConfigError::SigningKeysEmpty.into()) 231 - } 232 - OAuthBackendConfig::AIP { .. } => { 233 - Err(ConfigError::SigningKeysNotAvailableForAIP.into()) 234 - } 235 - } 193 + /// Returns the OAuth client credentials key as (public_key_did, key_data) pair 194 + pub fn select_oauth_signing_key(&self) -> Result<(String, KeyData)> { 195 + let key_data = self.oauth_client_credentials_key.as_ref().clone(); 196 + let public_key = to_public(&key_data)?; 197 + Ok((public_key.to_string(), key_data)) 236 198 } 237 199 238 200 /// Check if a DID is in the admin allow list 239 201 pub fn is_admin(&self, did: &str) -> bool { 240 202 self.admin_dids.as_ref().contains(&did.to_string()) 203 + } 204 + 205 + /// Returns the OAuth scope string with the external_base interpolated 206 + pub fn oauth_scope(&self) -> String { 207 + format!( 208 + "atproto include:community.lexicon.calendar.authFull?aud=did:web:{}#smokesignal include:events.smokesignal.authFull blob:*/*", 209 + self.external_base 210 + ) 241 211 } 242 212 } 243 213 ··· 366 336 } 367 337 } 368 338 369 - impl AsRef<OrderMap<String, String>> for SigningKeys { 370 - fn as_ref(&self) -> &OrderMap<String, String> { 371 - &self.0 372 - } 373 - } 374 - 375 - impl TryFrom<String> for SigningKeys { 339 + impl TryFrom<String> for OAuthClientCredentialsKey { 376 340 type Error = anyhow::Error; 377 341 fn try_from(value: String) -> Result<Self, Self::Error> { 378 - // Allow empty signing keys for initial pass with in-memory storage 379 342 if value.is_empty() { 380 - return Ok(Self(OrderMap::new())); 343 + return Err(ConfigError::EmptySigningKeys.into()); 381 344 } 382 345 383 - // Parse semicolon-separated DID method key strings 384 - let private_keys: Vec<&str> = value.split(';').filter(|s| !s.is_empty()).collect(); 346 + identify_key(&value) 347 + .map(OAuthClientCredentialsKey) 348 + .map_err(|err| err.into()) 349 + } 350 + } 385 351 386 - if private_keys.is_empty() { 387 - return Ok(Self(OrderMap::new())); 388 - } 389 - 390 - let mut signing_keys = OrderMap::new(); 391 - 392 - for private_key in private_keys { 393 - // Verify this is a private key using identify_key 394 - let key_data = match identify_key(private_key) { 395 - Ok(key_data) => key_data, 396 - Err(err) => { 397 - tracing::error!(?err, ?private_key, "failed to identify key"); 398 - continue; 399 - } 400 - }; 401 - 402 - match key_data.0 { 403 - KeyType::P256Public | KeyType::K256Public => { 404 - tracing::error!(?private_key, "public key found"); 405 - continue; 406 - } 407 - _ => {} 408 - } 409 - 410 - // Generate public key using to_public and use it as the identifier 411 - let public_key = match to_public(&key_data) { 412 - Ok(public_key) => public_key, 413 - Err(err) => { 414 - tracing::error!( 415 - ?err, 416 - ?private_key, 417 - "unable to derive public key from signing key" 418 - ); 419 - continue; 420 - } 421 - }; 422 - 423 - // Store the original DID method key string as the value 424 - // This allows us to call identify_key again later when we need the KeyData 425 - signing_keys.insert(public_key.to_string(), private_key.to_string()); 426 - } 427 - 428 - // Check if we have any valid keys 429 - if signing_keys.is_empty() { 430 - return Err(ConfigError::EmptySigningKeys.into()); 431 - } 432 - 433 - Ok(Self(signing_keys)) 352 + impl AsRef<KeyData> for OAuthClientCredentialsKey { 353 + fn as_ref(&self) -> &KeyData { 354 + &self.0 434 355 } 435 356 } 436 357
+3 -99
src/config_errors.rs
··· 13 13 #[error("error-smokesignal-config-1 {0} must be set")] 14 14 EnvVarRequired(String), 15 15 16 - /// Error when the signing keys file cannot be read. 17 - /// 18 - /// This error occurs when the application fails to read the file 19 - /// containing signing keys, typically due to file system permissions 20 - /// or missing file issues. 21 - #[error("error-smokesignal-config-2 Unable to read signing keys file: {0:?}")] 22 - ReadSigningKeysFailed(std::io::Error), 23 - 24 - /// Error when the signing keys file cannot be parsed. 25 - /// 26 - /// This error occurs when the signing keys file contains malformed JSON 27 - /// that cannot be properly deserialized. 28 - #[error("error-smokesignal-config-3 Unable to parse signing keys file: {0:?}")] 29 - ParseSigningKeysFailed(serde_json::Error), 30 - 31 16 /// Error when no valid signing keys are found. 32 17 /// 33 - /// This error occurs when the signing keys file does not contain any 34 - /// valid keys that the application can use for signing operations. 35 - #[error("error-smokesignal-config-4 Signing keys must contain at least one valid key")] 18 + /// This error occurs when the OAuth client credentials key is empty 19 + /// or cannot be identified as a valid key. 20 + #[error("error-smokesignal-config-4 OAuth client credentials key must be a valid key")] 36 21 EmptySigningKeys, 37 22 38 - /// Error when no valid OAuth active keys are found. 39 - /// 40 - /// This error occurs when the configuration does not include any 41 - /// valid keys that can be used for OAuth operations. 42 - #[error("error-smokesignal-config-5 OAuth active keys must contain at least one valid key")] 43 - EmptyOAuthActiveKeys, 44 - 45 - /// Error when no valid invitation active keys are found. 46 - /// 47 - /// This error occurs when the configuration does not include any 48 - /// valid keys that can be used for invitation operations. 49 - #[error( 50 - "error-smokesignal-config-6 Invitation active keys must contain at least one valid key" 51 - )] 52 - EmptyInvitationActiveKeys, 53 - 54 23 /// Error when the PORT environment variable cannot be parsed. 55 24 /// 56 25 /// This error occurs when the PORT environment variable contains a value ··· 79 48 #[error("error-smokesignal-config-10 One of GIT_HASH or CARGO_PKG_VERSION must be set")] 80 49 VersionNotSet, 81 50 82 - /// Error when a referenced signing key is not found. 83 - /// 84 - /// This error occurs when attempting to use a signing key that 85 - /// does not exist in the loaded signing keys configuration. 86 - #[error("error-smokesignal-config-11 Signing key not found")] 87 - SigningKeyNotFound, 88 - 89 51 /// Error when a DNS nameserver IP cannot be parsed. 90 52 /// 91 53 /// This error occurs when the DNS_NAMESERVERS environment variable contains 92 54 /// an IP address that cannot be parsed as a valid IpAddr. 93 55 #[error("error-smokesignal-config-12 Unable to parse nameserver IP '{0}': {1}")] 94 56 NameserverParsingFailed(String, std::net::AddrParseError), 95 - 96 - /// Error when the signing keys file is not found. 97 - /// 98 - /// This error occurs when the file specified in the SIGNING_KEYS environment 99 - /// variable does not exist on the file system. 100 - #[error("error-smokesignal-config-13 Signing keys file not found: {0}")] 101 - SigningKeysFileNotFound(String), 102 - 103 - /// Error when the signing keys file is empty. 104 - /// 105 - /// This error occurs when the file specified in the SIGNING_KEYS environment 106 - /// variable exists but contains no data. 107 - #[error("error-smokesignal-config-14 Signing keys file is empty")] 108 - EmptySigningKeysFile, 109 - 110 - /// Error when the JWKS structure doesn't contain any keys. 111 - /// 112 - /// This error occurs when the signing keys file contains a valid JWKS structure, 113 - /// but the 'keys' array is empty. 114 - #[error("error-smokesignal-config-15 No keys found in JWKS")] 115 - MissingKeysInJWKS, 116 - 117 - /// Error when signing keys fail validation. 118 - /// 119 - /// This error occurs when the signing keys file contains keys 120 - /// that fail validation checks (such as having invalid format). 121 - #[error("error-smokesignal-config-16 Signing keys validation failed: {0:?}")] 122 - SigningKeysValidationFailed(Vec<String>), 123 - 124 - /// Error when AIP OAuth configuration is incomplete. 125 - /// 126 - /// This error occurs when oauth_backend is set to "aip" but 127 - /// required AIP configuration values are missing. 128 - #[error( 129 - "error-smokesignal-config-17 When oauth_backend is 'aip', AIP_HOSTNAME, AIP_CLIENT_ID, and AIP_CLIENT_SECRET must all be set" 130 - )] 131 - AipConfigurationIncomplete, 132 - 133 - /// Error when oauth_backend has an invalid value. 134 - /// 135 - /// This error occurs when the OAUTH_BACKEND environment variable 136 - /// contains a value other than "aip" or "pds". 137 - #[error("error-smokesignal-config-18 oauth_backend must be either 'aip' or 'pds', got: {0}")] 138 - InvalidOAuthBackend(String), 139 - 140 - /// Error when signing keys list is empty. 141 - /// 142 - /// This error occurs when attempting to select an OAuth signing key 143 - /// but the signing keys list contains no entries. 144 - #[error("error-smokesignal-config-19 signing keys is empty")] 145 - SigningKeysEmpty, 146 - 147 - /// Error when signing keys are not available for AIP OAuth backend. 148 - /// 149 - /// This error occurs when attempting to access signing keys 150 - /// while using the AIP OAuth backend, which doesn't support signing keys. 151 - #[error("error-smokesignal-config-20 signing keys not available for AIP OAuth backend")] 152 - SigningKeysNotAvailableForAIP, 153 57 154 58 /// Error when the EMAIL_SECRET_KEY cannot be decoded. 155 59 ///
-234
src/http/auth_utils.rs
··· 1 - use anyhow::Result; 2 - use atproto_client::client::get_dpop_json_with_headers; 3 - use deadpool_redis::redis::AsyncCommands; 4 - use http::HeaderMap; 5 - use reqwest::Client; 6 - use sha2::{Digest, Sha256}; 7 - 8 - use crate::atproto::auth::create_dpop_auth_from_aip_session; 9 - use crate::config::OAuthBackendConfig; 10 - use crate::http::context::WebContext; 11 1 use crate::http::errors::LoginError; 12 - use crate::http::errors::web_error::WebError; 13 - use crate::http::middleware_auth::Auth; 14 - 15 - /// TTL for AIP session ready cache entries (5 minutes). 16 - const AIP_SESSION_READY_CACHE_TTL_SECS: i64 = 300; 17 - 18 - /// Result of checking if an AIP session is ready for AT Protocol operations. 19 - pub(crate) enum AipSessionStatus { 20 - /// Session is valid and ready for operations. 21 - Ready, 22 - /// Session is stale and requires re-authentication. 23 - Stale, 24 - /// Not an AIP session (PDS or unauthenticated). 25 - NotAip, 26 - } 27 - 28 - /// Check if an AIP session is still valid by requesting service auth from the user's PDS. 29 - /// 30 - /// Calls `com.atproto.server.getServiceAuth` on the user's PDS with: 31 - /// - `aud`: did:web:[aip_hostname] (the AIP server) 32 - /// - `lxm`: tools.graze.aip.ready (the target method) 33 - /// 34 - /// Returns `true` if the session is valid, `false` if stale (401 during exchange 35 - /// or service auth request). 36 - pub(crate) async fn check_aip_session_ready( 37 - http_client: &Client, 38 - aip_hostname: &str, 39 - user_pds: &str, 40 - access_token: &str, 41 - ) -> Result<bool> { 42 - // Step 1: Attempt to get DPoP auth via AIP session exchange 43 - // This is where stale tokens are typically detected (401 response) 44 - let dpop_auth = 45 - match create_dpop_auth_from_aip_session(http_client, aip_hostname, access_token).await { 46 - Ok(auth) => auth, 47 - Err(e) => { 48 - let error_str = e.to_string(); 49 - if error_str.contains("401") 50 - || error_str.contains("Unauthorized") 51 - || error_str.contains("invalid_token") 52 - || error_str.contains("expired") 53 - { 54 - tracing::debug!("AIP session exchange returned stale token - session is stale"); 55 - return Ok(false); 56 - } 57 - return Err(e); 58 - } 59 - }; 60 - 61 - // Step 2: Call getServiceAuth on the user's PDS 62 - // Strip https:// prefix since config stores the full URL but did:web needs just the hostname 63 - let aip_did = format!("did:web:{}", aip_hostname.trim_start_matches("https://")); 64 - let service_auth_url = format!("{}/xrpc/tools.graze.aip.ready", user_pds,); 65 - 66 - let mut headers = HeaderMap::default(); 67 - headers.append("atproto-proxy", format!("{aip_did}#aip").parse()?); 68 - 69 - let response = 70 - get_dpop_json_with_headers(http_client, &dpop_auth, &service_auth_url, &headers).await; 71 - 72 - match response { 73 - Ok(json_value) => { 74 - let is_empty = json_value 75 - .as_object() 76 - .is_some_and(|payload| payload.is_empty()); 77 - Ok(is_empty) 78 - } 79 - Err(e) => { 80 - let error_str = e.to_string(); 81 - if error_str.contains("401") 82 - || error_str.contains("Unauthorized") 83 - || error_str.contains("invalid_token") 84 - || error_str.contains("expired") 85 - { 86 - tracing::debug!("PDS getServiceAuth returned stale token - session is stale"); 87 - Ok(false) 88 - } else { 89 - Err(anyhow::anyhow!( 90 - "error-smokesignal-aip-ready-1 Service auth check failed: {}", 91 - error_str 92 - )) 93 - } 94 - } 95 - } 96 - } 97 - 98 - /// Generate a cache key for AIP session ready status. 99 - /// 100 - /// Uses a SHA-256 hash of the access token to avoid storing raw tokens in Redis. 101 - fn aip_session_cache_key(access_token: &str) -> String { 102 - let mut hasher = Sha256::new(); 103 - hasher.update(access_token.as_bytes()); 104 - let hash = hasher.finalize(); 105 - format!("aip_session_ready:{:x}", hash) 106 - } 107 - 108 - /// Check Redis cache for AIP session ready status. 109 - /// 110 - /// Returns `Some(true)` if cached as ready, `Some(false)` if cached as stale, 111 - /// or `None` on cache miss or error. 112 - async fn get_cached_aip_session_status( 113 - web_context: &WebContext, 114 - access_token: &str, 115 - ) -> Option<bool> { 116 - let cache_key = aip_session_cache_key(access_token); 117 - 118 - let mut conn = match web_context.cache_pool.get().await { 119 - Ok(conn) => conn, 120 - Err(e) => { 121 - tracing::debug!(?e, "Failed to get Redis connection for AIP session cache"); 122 - return None; 123 - } 124 - }; 125 - 126 - match conn.get::<_, Option<String>>(&cache_key).await { 127 - Ok(Some(value)) => { 128 - tracing::debug!(cache_key = %cache_key, value = %value, "AIP session cache hit"); 129 - Some(value == "ready") 130 - } 131 - Ok(None) => { 132 - tracing::debug!(cache_key = %cache_key, "AIP session cache miss"); 133 - None 134 - } 135 - Err(e) => { 136 - tracing::debug!(?e, "Redis error reading AIP session cache"); 137 - None 138 - } 139 - } 140 - } 141 - 142 - /// Cache AIP session ready status in Redis with TTL. 143 - async fn cache_aip_session_status(web_context: &WebContext, access_token: &str, is_ready: bool) { 144 - let cache_key = aip_session_cache_key(access_token); 145 - let value = if is_ready { "ready" } else { "stale" }; 146 - 147 - let mut conn = match web_context.cache_pool.get().await { 148 - Ok(conn) => conn, 149 - Err(e) => { 150 - tracing::debug!( 151 - ?e, 152 - "Failed to get Redis connection for AIP session cache write" 153 - ); 154 - return; 155 - } 156 - }; 157 - 158 - if let Err(e) = conn 159 - .set_ex::<_, _, ()>(&cache_key, value, AIP_SESSION_READY_CACHE_TTL_SECS as u64) 160 - .await 161 - { 162 - tracing::debug!(?e, "Failed to cache AIP session status"); 163 - } else { 164 - tracing::debug!( 165 - cache_key = %cache_key, 166 - value = %value, 167 - ttl_secs = AIP_SESSION_READY_CACHE_TTL_SECS, 168 - "Cached AIP session status" 169 - ); 170 - } 171 - } 172 - 173 - /// Check if the current AIP session is ready for AT Protocol operations. 174 - /// 175 - /// This calls the AIP ready endpoint to validate the access token. 176 - /// Results are cached in Redis for 5 minutes to avoid repeated validation. 177 - /// For PDS sessions, this is a no-op (returns NotAip). 178 - pub(crate) async fn require_valid_aip_session( 179 - web_context: &WebContext, 180 - auth: &Auth, 181 - ) -> Result<AipSessionStatus, WebError> { 182 - match auth { 183 - Auth::Aip { 184 - profile, 185 - access_token, 186 - stale, 187 - } => { 188 - // If already marked stale, don't bother checking again 189 - if *stale { 190 - return Ok(AipSessionStatus::Stale); 191 - } 192 - 193 - // Check Redis cache first 194 - if let Some(cached_ready) = 195 - get_cached_aip_session_status(web_context, access_token).await 196 - { 197 - return if cached_ready { 198 - Ok(AipSessionStatus::Ready) 199 - } else { 200 - Ok(AipSessionStatus::Stale) 201 - }; 202 - } 203 - 204 - // Get AIP hostname from config 205 - let aip_hostname = match &web_context.config.oauth_backend { 206 - OAuthBackendConfig::AIP { hostname, .. } => hostname, 207 - _ => return Ok(AipSessionStatus::NotAip), 208 - }; 209 - 210 - // Check the ready endpoint using the user's PDS 211 - let is_ready = check_aip_session_ready( 212 - &web_context.http_client, 213 - aip_hostname, 214 - &profile.pds, 215 - access_token, 216 - ) 217 - .await 218 - .map_err(|e| { 219 - tracing::warn!(?e, "AIP ready check failed"); 220 - WebError::InternalError 221 - })?; 222 - 223 - // Cache the result 224 - cache_aip_session_status(web_context, access_token, is_ready).await; 225 - 226 - if is_ready { 227 - Ok(AipSessionStatus::Ready) 228 - } else { 229 - Ok(AipSessionStatus::Stale) 230 - } 231 - } 232 - Auth::Pds { .. } => Ok(AipSessionStatus::NotAip), 233 - Auth::Unauthenticated => Ok(AipSessionStatus::NotAip), 234 - } 235 - } 236 2 237 3 /// Validates and filters incoming login requests. 238 4 ///
-8
src/http/context.rs
··· 28 28 #[cfg(feature = "embed")] 29 29 pub type AppEngine = Engine<Environment<'static>>; 30 30 31 - use crate::aip_auth_cache::AipAuthCache; 32 31 use crate::emailer::Emailer; 33 32 use crate::mcp::session::McpSessionManager; 34 33 use crate::service::{ServiceDID, ServiceDocument, ServiceKey}; ··· 65 64 pub(crate) service_document: ServiceDocument, 66 65 pub(crate) service_key: ServiceKey, 67 66 pub(crate) mcp_session_manager: Arc<dyn McpSessionManager>, 68 - pub(crate) aip_auth_cache: Option<Arc<AipAuthCache>>, 69 67 } 70 68 71 69 #[derive(Clone, FromRef)] ··· 100 98 service_document: ServiceDocument, 101 99 service_key: ServiceKey, 102 100 mcp_session_manager: Arc<dyn McpSessionManager>, 103 - aip_auth_cache: Option<Arc<AipAuthCache>>, 104 101 ) -> Self { 105 102 Self(Arc::new(InnerWebContext { 106 103 pool, ··· 123 120 service_document, 124 121 service_key, 125 122 mcp_session_manager, 126 - aip_auth_cache, 127 123 })) 128 124 } 129 125 130 126 pub fn mcp_session_manager(&self) -> &Arc<dyn McpSessionManager> { 131 127 &self.0.mcp_session_manager 132 - } 133 - 134 - pub fn aip_auth_cache(&self) -> Option<&Arc<AipAuthCache>> { 135 - self.0.aip_auth_cache.as_ref() 136 128 } 137 129 } 138 130
+113
src/http/cookies.rs
··· 1 + //! Cookie utilities for session management. 2 + //! 3 + //! This module provides the `SessionCookie` struct and utilities for encoding/decoding 4 + //! session data directly in browser cookies rather than storing tokens in the database. 5 + 6 + use anyhow::Result; 7 + use chrono::{DateTime, Utc}; 8 + use serde::{Deserialize, Serialize}; 9 + 10 + use crate::http::errors::WebSessionError; 11 + 12 + /// Session data stored directly in the browser cookie. 13 + /// 14 + /// This struct contains all the data needed to authenticate requests without 15 + /// requiring a database lookup. The cookie is encrypted using the HTTP_COOKIE_KEY. 16 + #[derive(Clone, PartialEq, Serialize, Deserialize)] 17 + pub(crate) struct SessionCookie { 18 + /// The user's DID (Decentralized Identifier) 19 + pub did: String, 20 + /// The OAuth access token for AT Protocol requests 21 + pub access_token: String, 22 + /// The OAuth refresh token for obtaining new access tokens 23 + pub refresh_token: Option<String>, 24 + /// When the access token expires 25 + pub expires_at: DateTime<Utc>, 26 + /// The DPoP private key in did:key format for proof-of-possession 27 + pub dpop_private_key: String, 28 + /// The issuer (authorization server) URL 29 + pub issuer: String, 30 + } 31 + 32 + impl SessionCookie { 33 + /// Check if the access token has expired 34 + pub fn is_expired(&self) -> bool { 35 + Utc::now() >= self.expires_at 36 + } 37 + 38 + /// Check if the access token will expire within the given duration 39 + pub fn expires_within(&self, duration: chrono::Duration) -> bool { 40 + Utc::now() + duration >= self.expires_at 41 + } 42 + } 43 + 44 + impl TryFrom<String> for SessionCookie { 45 + type Error = anyhow::Error; 46 + 47 + fn try_from(value: String) -> Result<Self, Self::Error> { 48 + serde_json::from_str(&value) 49 + .map_err(WebSessionError::DeserializeFailed) 50 + .map_err(Into::into) 51 + } 52 + } 53 + 54 + impl TryInto<String> for SessionCookie { 55 + type Error = anyhow::Error; 56 + 57 + fn try_into(self) -> Result<String, Self::Error> { 58 + serde_json::to_string(&self) 59 + .map_err(WebSessionError::SerializeFailed) 60 + .map_err(Into::into) 61 + } 62 + } 63 + 64 + #[cfg(test)] 65 + mod tests { 66 + use super::*; 67 + use chrono::Duration; 68 + 69 + #[test] 70 + fn test_session_cookie_serialization() { 71 + let session = SessionCookie { 72 + did: "did:plc:test123".to_string(), 73 + access_token: "test_access_token".to_string(), 74 + refresh_token: Some("test_refresh_token".to_string()), 75 + expires_at: Utc::now() + Duration::hours(1), 76 + dpop_private_key: "did:key:test".to_string(), 77 + issuer: "https://bsky.social".to_string(), 78 + }; 79 + 80 + let serialized: String = session.clone().try_into().unwrap(); 81 + let deserialized: SessionCookie = serialized.try_into().unwrap(); 82 + 83 + assert_eq!(session.did, deserialized.did); 84 + assert_eq!(session.access_token, deserialized.access_token); 85 + assert_eq!(session.refresh_token, deserialized.refresh_token); 86 + assert_eq!(session.dpop_private_key, deserialized.dpop_private_key); 87 + assert_eq!(session.issuer, deserialized.issuer); 88 + } 89 + 90 + #[test] 91 + fn test_is_expired() { 92 + let expired_session = SessionCookie { 93 + did: "did:plc:test123".to_string(), 94 + access_token: "test".to_string(), 95 + refresh_token: None, 96 + expires_at: Utc::now() - Duration::hours(1), 97 + dpop_private_key: "did:key:test".to_string(), 98 + issuer: "https://bsky.social".to_string(), 99 + }; 100 + 101 + let valid_session = SessionCookie { 102 + did: "did:plc:test123".to_string(), 103 + access_token: "test".to_string(), 104 + refresh_token: None, 105 + expires_at: Utc::now() + Duration::hours(1), 106 + dpop_private_key: "did:key:test".to_string(), 107 + issuer: "https://bsky.social".to_string(), 108 + }; 109 + 110 + assert!(expired_session.is_expired()); 111 + assert!(!valid_session.is_expired()); 112 + } 113 + }
-7
src/http/errors/blob_error.rs
··· 41 41 #[error("error-smokesignal-blob-5 No avatar file provided")] 42 42 NoAvatarFile, 43 43 44 - /// Error when authentication backend doesn't match configuration. 45 - /// 46 - /// This error occurs when the user's authentication method (PDS/AIP) 47 - /// doesn't match the configured OAuth backend. 48 - #[error("error-smokesignal-blob-7 Mismatched auth and backend config")] 49 - MismatchedAuthBackend, 50 - 51 44 /// Error when parsing an existing profile record fails. 52 45 /// 53 46 /// This error occurs when deserializing a profile record from the PDS
-6
src/http/errors/delete_event_errors.rs
··· 15 15 )] 16 16 EventNotFound { aturi: String }, 17 17 18 - /// Error when there is an authentication configuration mismatch. 19 - /// 20 - /// This error occurs when the authentication type doesn't match the 21 - /// configured OAuth backend, indicating a system configuration issue. 22 - #[error("error-smokesignal-delete-event-2 Authentication configuration mismatch")] 23 - AuthenticationConfigurationMismatch, 24 18 }
-21
src/http/errors/login_error.rs
··· 46 46 /// due to expiration or invalid state parameter. 47 47 #[error("error-smokesignal-login-6 oauth request not found in storage")] 48 48 OAuthRequestNotFound, 49 - 50 - /// Error when HTTP request for AIP OAuth userinfo fails. 51 - /// 52 - /// This error occurs during AIP OAuth flow when the HTTP request 53 - /// to retrieve user information from the AIP server fails. 54 - #[error("error-smokesignal-login-7 HTTP request for userinfo failed")] 55 - AipUserinfoRequestFailed, 56 - 57 - /// Error when parsing AIP OAuth userinfo response fails. 58 - /// 59 - /// This error occurs during AIP OAuth flow when the JSON response 60 - /// from the AIP userinfo endpoint cannot be parsed. 61 - #[error("error-smokesignal-login-8 Parsing HTTP response for userinfo failed")] 62 - AipUserinfoParsingFailed, 63 - 64 - /// Error when AIP OAuth server returns an error response. 65 - /// 66 - /// This error occurs when the AIP OAuth server returns an error 67 - /// in the userinfo response instead of valid user claims. 68 - #[error("error-smokesignal-login-9 AIP OAuth server error: {message}")] 69 - AipServerError { message: String }, 70 49 }
-40
src/http/errors/web_error.rs
··· 158 158 /// such as creating, viewing, or deactivating LFG records. 159 159 #[error(transparent)] 160 160 LfgError(#[from] LfgError), 161 - 162 - /// The AIP session has expired and the user must re-authenticate. 163 - /// 164 - /// This error occurs when an AT Protocol operation is attempted with a stale 165 - /// AIP session token. The user should be redirected to the login page. 166 - /// The contained string is the destination URL to redirect to after re-authentication. 167 - /// 168 - /// **Error Code:** `error-smokesignal-web-3` 169 - #[error( 170 - "error-smokesignal-web-3 Session expired, re-authentication required (destination: {0})" 171 - )] 172 - SessionStale(String), 173 - 174 - /// An internal server error occurred. 175 - /// 176 - /// This is a generic error for internal failures that don't fit other categories. 177 - /// 178 - /// **Error Code:** `error-smokesignal-web-4` 179 - #[error("error-smokesignal-web-4 Internal server error")] 180 - InternalError, 181 161 } 182 162 183 163 /// Implementation of Axum's `IntoResponse` trait for WebError. ··· 190 170 fn into_response(self) -> Response { 191 171 match self { 192 172 WebError::MiddlewareAuthError(err) => err.into_response(), 193 - WebError::SessionStale(destination) => { 194 - // For HTMX requests, use HX-Redirect to force a full page navigation to login 195 - // For regular requests, this will also work as the browser follows the redirect 196 - // Include the destination so users return to where they were after re-authenticating 197 - let encoded_destination = urlencoding::encode(&destination); 198 - let redirect_url = format!( 199 - "/oauth/login?reason=session_expired&destination={}", 200 - encoded_destination 201 - ); 202 - ( 203 - StatusCode::UNAUTHORIZED, 204 - [("HX-Redirect", redirect_url)], 205 - "Session expired. Please log in again.", 206 - ) 207 - .into_response() 208 - } 209 - WebError::InternalError => { 210 - tracing::error!("Internal server error"); 211 - StatusCode::INTERNAL_SERVER_ERROR.into_response() 212 - } 213 173 _ => { 214 174 tracing::error!(error = ?self, "internal server error"); 215 175 StatusCode::INTERNAL_SERVER_ERROR.into_response()
+4 -19
src/http/handle_accept_rsvp.rs
··· 12 12 13 13 use crate::{ 14 14 atproto::{ 15 - auth::{create_dpop_auth_from_aip_session, create_dpop_auth_from_oauth_session}, 15 + auth::create_dpop_auth_from_session, 16 16 lexicon::acceptance::{Acceptance, NSID as ACCEPTANCE_NSID, TypedAcceptance}, 17 17 }, 18 - config::OAuthBackendConfig, 19 18 http::{ 20 19 acceptance_utils::{ 21 20 format_error_html, format_success_html, send_acceptance_email_notification, 22 21 verify_event_organizer_authorization, 23 22 }, 24 - auth_utils::{AipSessionStatus, require_valid_aip_session}, 25 23 context::WebContext, 26 24 errors::{WebError, acceptance_error::AcceptanceError}, 27 25 middleware_auth::Auth, ··· 43 41 Form(form): Form<AcceptRsvpForm>, 44 42 ) -> Result<impl IntoResponse, WebError> { 45 43 let current_handle = auth.require("/accept_rsvp")?; 44 + let session = auth.session().ok_or(AcceptanceError::NotAuthorized)?; 46 45 47 46 // Get the RSVP from storage 48 47 let rsvp = match rsvp_get(&web_context.pool, &form.rsvp_aturi).await { ··· 113 112 114 113 let record_key = Tid::new().to_string(); 115 114 116 - // Check AIP session validity before attempting AT Protocol operation 117 - if let AipSessionStatus::Stale = require_valid_aip_session(&web_context, &auth).await? { 118 - return Err(WebError::SessionStale("/".to_string())); 119 - } 120 - 121 - // Create DPoP auth based on OAuth backend type 122 - let dpop_auth = match (&auth, &web_context.config.oauth_backend) { 123 - (Auth::Pds { session, .. }, OAuthBackendConfig::ATProtocol { .. }) => { 124 - create_dpop_auth_from_oauth_session(session)? 125 - } 126 - (Auth::Aip { access_token, .. }, OAuthBackendConfig::AIP { hostname, .. }) => { 127 - create_dpop_auth_from_aip_session(&web_context.http_client, hostname, access_token) 128 - .await? 129 - } 130 - _ => return Err(AcceptanceError::NotAuthorized.into()), 131 - }; 115 + // Create DPoP auth from session 116 + let dpop_auth = create_dpop_auth_from_session(session)?; 132 117 133 118 let typed_acceptance = TypedAcceptance::new(acceptance.clone()); 134 119
+61
src/http/handle_api_mcp_configuration.rs
··· 1 + //! MCP configuration API handlers. 2 + //! 3 + //! Allows users to manage their MCP settings. 4 + 5 + use axum::{Json, http::StatusCode, response::IntoResponse}; 6 + use serde::{Deserialize, Serialize}; 7 + 8 + use crate::http::context::UserRequestContext; 9 + use crate::http::errors::WebError; 10 + use crate::storage::mcp_configuration::{mcp_config_get, mcp_config_upsert}; 11 + 12 + /// MCP configuration response. 13 + #[derive(Debug, Serialize)] 14 + pub(crate) struct McpConfigurationResponse { 15 + pub allow_dangerous: bool, 16 + } 17 + 18 + /// GET /api/mcp/configuration - Get MCP configuration for current user. 19 + pub(crate) async fn handle_api_mcp_configuration_get( 20 + ctx: UserRequestContext, 21 + ) -> Result<impl IntoResponse, WebError> { 22 + let current_handle = ctx.auth.require("/")?; 23 + 24 + let config = mcp_config_get(&ctx.web_context.pool, &current_handle.did) 25 + .await 26 + .map_err(WebError::from)?; 27 + 28 + let response = McpConfigurationResponse { 29 + allow_dangerous: config.map(|c| c.allow_dangerous).unwrap_or(false), 30 + }; 31 + 32 + Ok((StatusCode::OK, Json(response)).into_response()) 33 + } 34 + 35 + /// MCP configuration update request. 36 + #[derive(Debug, Deserialize)] 37 + pub(crate) struct McpConfigurationUpdateRequest { 38 + pub allow_dangerous: bool, 39 + } 40 + 41 + /// POST /api/mcp/configuration - Update MCP configuration for current user. 42 + pub(crate) async fn handle_api_mcp_configuration_post( 43 + ctx: UserRequestContext, 44 + Json(request): Json<McpConfigurationUpdateRequest>, 45 + ) -> Result<impl IntoResponse, WebError> { 46 + let current_handle = ctx.auth.require("/")?; 47 + 48 + let config = mcp_config_upsert( 49 + &ctx.web_context.pool, 50 + &current_handle.did, 51 + request.allow_dangerous, 52 + ) 53 + .await 54 + .map_err(WebError::from)?; 55 + 56 + let response = McpConfigurationResponse { 57 + allow_dangerous: config.allow_dangerous, 58 + }; 59 + 60 + Ok((StatusCode::OK, Json(response)).into_response()) 61 + }
+19 -106
src/http/handle_blob.rs
··· 12 12 use reqwest::header::CONTENT_TYPE; 13 13 14 14 use crate::{ 15 - atproto::{ 16 - auth::{create_dpop_auth_from_aip_session, create_dpop_auth_from_oauth_session}, 17 - lexicon::profile::Profile, 18 - }, 19 - config::OAuthBackendConfig, 15 + atproto::{auth::create_dpop_auth_from_session, lexicon::profile::Profile}, 20 16 contextual_error, 21 17 http::{ 22 - auth_utils::{AipSessionStatus, require_valid_aip_session}, 23 18 context::WebContext, 24 19 errors::{CommonError, WebError, blob_error::BlobError}, 25 20 middleware_auth::Auth, ··· 100 95 101 96 // Require authentication 102 97 let current_handle = auth.require_flat()?; 98 + let session = auth.session().ok_or(CommonError::NotAuthorized)?; 103 99 104 100 // Extract the file from multipart data 105 101 let mut file_data: Option<Vec<u8>> = None; ··· 130 126 // Get the PDS endpoint for the user 131 127 let pds_endpoint = current_handle.pds.clone(); 132 128 133 - // Create DPoP authentication based on backend type 134 - let dpop_auth = match (&auth, &web_context.config.oauth_backend) { 135 - (Auth::Pds { session, .. }, OAuthBackendConfig::ATProtocol { .. }) => { 136 - create_dpop_auth_from_oauth_session(session)? 137 - } 138 - (Auth::Aip { access_token, .. }, OAuthBackendConfig::AIP { hostname, .. }) => { 139 - create_dpop_auth_from_aip_session(&web_context.http_client, hostname, access_token) 140 - .await? 141 - } 142 - _ => { 143 - return Err(BlobError::MismatchedAuthBackend.into()); 144 - } 145 - }; 129 + // Create DPoP auth 130 + let dpop_auth = create_dpop_auth_from_session(session)?; 146 131 147 132 // Upload blob to PDS 148 133 let blob = upload_blob_to_pds( ··· 301 286 ) -> Result<impl IntoResponse, WebError> { 302 287 let error_template = select_template!(false, hx_request, language); 303 288 let current_handle = auth.require_flat()?; 289 + let session = auth.session().ok_or(CommonError::NotAuthorized)?; 304 290 305 291 let mut file_data: Option<Vec<u8>> = None; 306 292 while let Some(field) = multipart ··· 326 312 327 313 let pds_endpoint = current_handle.pds.clone(); 328 314 329 - // Check AIP session validity before attempting AT Protocol operation 330 - if let AipSessionStatus::Stale = require_valid_aip_session(&web_context, &auth).await? { 331 - return Err(WebError::SessionStale("/settings".to_string())); 332 - } 333 - 334 - let dpop_auth = match (&auth, &web_context.config.oauth_backend) { 335 - (Auth::Pds { session, .. }, OAuthBackendConfig::ATProtocol { .. }) => { 336 - create_dpop_auth_from_oauth_session(session)? 337 - } 338 - (Auth::Aip { access_token, .. }, OAuthBackendConfig::AIP { hostname, .. }) => { 339 - create_dpop_auth_from_aip_session(&web_context.http_client, hostname, access_token) 340 - .await? 341 - } 342 - _ => { 343 - return Err(BlobError::MismatchedAuthBackend.into()); 344 - } 345 - }; 315 + // Create DPoP auth 316 + let dpop_auth = create_dpop_auth_from_session(session)?; 346 317 347 318 let blob = upload_blob_to_pds( 348 319 &web_context.http_client, ··· 486 457 ) -> Result<impl IntoResponse, WebError> { 487 458 let error_template = select_template!(false, hx_request, language); 488 459 let current_handle = auth.require_flat()?; 460 + let session = auth.session().ok_or(CommonError::NotAuthorized)?; 489 461 let profile_aturi = format!( 490 462 "at://{}/events.smokesignal.profile/self", 491 463 current_handle.did ··· 515 487 516 488 let pds_endpoint = current_handle.pds.clone(); 517 489 518 - // Check AIP session validity before attempting AT Protocol operation 519 - if let AipSessionStatus::Stale = require_valid_aip_session(&web_context, &auth).await? { 520 - return Err(WebError::SessionStale("/settings".to_string())); 521 - } 522 - 523 - let dpop_auth = match (&auth, &web_context.config.oauth_backend) { 524 - (Auth::Pds { session, .. }, OAuthBackendConfig::ATProtocol { .. }) => { 525 - create_dpop_auth_from_oauth_session(session)? 526 - } 527 - (Auth::Aip { access_token, .. }, OAuthBackendConfig::AIP { hostname, .. }) => { 528 - create_dpop_auth_from_aip_session(&web_context.http_client, hostname, access_token) 529 - .await? 530 - } 531 - _ => { 532 - return Err(BlobError::MismatchedAuthBackend.into()); 533 - } 534 - }; 490 + // Create DPoP auth 491 + let dpop_auth = create_dpop_auth_from_session(session)?; 535 492 536 493 let put_record_request = PutRecordRequest { 537 494 repo: current_handle.did.clone(), ··· 616 573 ) -> Result<impl IntoResponse, WebError> { 617 574 let error_template = select_template!(false, hx_request, language); 618 575 let current_handle = auth.require_flat()?; 576 + let session = auth.session().ok_or(CommonError::NotAuthorized)?; 619 577 let profile_aturi = format!( 620 578 "at://{}/events.smokesignal.profile/self", 621 579 current_handle.did ··· 645 603 646 604 let pds_endpoint = current_handle.pds.clone(); 647 605 648 - // Check AIP session validity before attempting AT Protocol operation 649 - if let AipSessionStatus::Stale = require_valid_aip_session(&web_context, &auth).await? { 650 - return Err(WebError::SessionStale("/settings".to_string())); 651 - } 652 - 653 - let dpop_auth = match (&auth, &web_context.config.oauth_backend) { 654 - (Auth::Pds { session, .. }, OAuthBackendConfig::ATProtocol { .. }) => { 655 - create_dpop_auth_from_oauth_session(session)? 656 - } 657 - (Auth::Aip { access_token, .. }, OAuthBackendConfig::AIP { hostname, .. }) => { 658 - create_dpop_auth_from_aip_session(&web_context.http_client, hostname, access_token) 659 - .await? 660 - } 661 - _ => { 662 - return Err(BlobError::MismatchedAuthBackend.into()); 663 - } 664 - }; 606 + // Create DPoP auth 607 + let dpop_auth = create_dpop_auth_from_session(session)?; 665 608 666 609 let put_record_request = PutRecordRequest { 667 610 repo: current_handle.did.clone(), ··· 744 687 mut multipart: Multipart, 745 688 ) -> Result<impl IntoResponse, WebError> { 746 689 let current_handle = auth.require_flat()?; 690 + let session = auth.session().ok_or(CommonError::NotAuthorized)?; 747 691 748 692 // Extract the file from multipart data 749 693 let mut file_data: Option<Vec<u8>> = None; ··· 774 718 // Get the PDS endpoint for the user 775 719 let pds_endpoint = current_handle.pds.clone(); 776 720 777 - // Check AIP session validity before attempting AT Protocol operation 778 - if let AipSessionStatus::Stale = require_valid_aip_session(&web_context, &auth).await? { 779 - return Err(WebError::SessionStale("/event".to_string())); 780 - } 781 - 782 - // Create DPoP authentication based on backend type 783 - let dpop_auth = match (&auth, &web_context.config.oauth_backend) { 784 - (Auth::Pds { session, .. }, OAuthBackendConfig::ATProtocol { .. }) => { 785 - create_dpop_auth_from_oauth_session(session)? 786 - } 787 - (Auth::Aip { access_token, .. }, OAuthBackendConfig::AIP { hostname, .. }) => { 788 - create_dpop_auth_from_aip_session(&web_context.http_client, hostname, access_token) 789 - .await? 790 - } 791 - _ => { 792 - return Err(BlobError::MismatchedAuthBackend.into()); 793 - } 794 - }; 721 + // Create DPoP auth 722 + let dpop_auth = create_dpop_auth_from_session(session)?; 795 723 796 724 // Upload blob to PDS 797 725 let blob = upload_blob_to_pds( ··· 947 875 mut multipart: Multipart, 948 876 ) -> Result<impl IntoResponse, WebError> { 949 877 let current_handle = auth.require_flat()?; 878 + let session = auth.session().ok_or(CommonError::NotAuthorized)?; 950 879 951 880 // Extract the file from multipart data 952 881 let mut file_data: Option<Vec<u8>> = None; ··· 982 911 // Get the PDS endpoint for the user 983 912 let pds_endpoint = current_handle.pds.clone(); 984 913 985 - // Check AIP session validity before attempting AT Protocol operation 986 - if let AipSessionStatus::Stale = require_valid_aip_session(&web_context, &auth).await? { 987 - return Err(WebError::SessionStale("/event".to_string())); 988 - } 989 - 990 - // Create DPoP authentication based on backend type 991 - let dpop_auth = match (&auth, &web_context.config.oauth_backend) { 992 - (Auth::Pds { session, .. }, OAuthBackendConfig::ATProtocol { .. }) => { 993 - create_dpop_auth_from_oauth_session(session)? 994 - } 995 - (Auth::Aip { access_token, .. }, OAuthBackendConfig::AIP { hostname, .. }) => { 996 - create_dpop_auth_from_aip_session(&web_context.http_client, hostname, access_token) 997 - .await? 998 - } 999 - _ => { 1000 - return Err(BlobError::MismatchedAuthBackend.into()); 1001 - } 1002 - }; 914 + // Create DPoP auth 915 + let dpop_auth = create_dpop_auth_from_session(session)?; 1003 916 1004 917 // Upload blob to PDS 1005 918 let blob = upload_blob_to_pds(
+4 -22
src/http/handle_bulk_accept_rsvps.rs
··· 8 8 9 9 use crate::{ 10 10 atproto::{ 11 - auth::{create_dpop_auth_from_aip_session, create_dpop_auth_from_oauth_session}, 11 + auth::create_dpop_auth_from_session, 12 12 lexicon::acceptance::Acceptance, 13 13 }, 14 - config::OAuthBackendConfig, 15 14 http::{ 16 15 acceptance_utils::{ 17 16 format_error_html, format_success_html, send_acceptance_email_notification, 18 17 verify_event_organizer_authorization, 19 18 }, 20 - auth_utils::{AipSessionStatus, require_valid_aip_session}, 21 19 context::WebContext, 22 20 errors::WebError, 23 21 middleware_auth::Auth, ··· 214 212 let event = 215 213 verify_event_organizer_authorization(web_context, &rsvp.event_aturi, current_did).await?; 216 214 217 - // Check AIP session validity before attempting AT Protocol operation 218 - if let AipSessionStatus::Stale = require_valid_aip_session(web_context, auth) 219 - .await 220 - .map_err(|e| anyhow::anyhow!("{}", e))? 221 - { 222 - return Err(anyhow::anyhow!("Session expired, please log in again")); 223 - } 224 - 225 - // Create DPoP auth based on OAuth backend type 226 - let dpop_auth = match (auth, &web_context.config.oauth_backend) { 227 - (Auth::Pds { session, .. }, OAuthBackendConfig::ATProtocol { .. }) => { 228 - create_dpop_auth_from_oauth_session(session)? 229 - } 230 - (Auth::Aip { access_token, .. }, OAuthBackendConfig::AIP { hostname, .. }) => { 231 - create_dpop_auth_from_aip_session(&web_context.http_client, hostname, access_token) 232 - .await? 233 - } 234 - _ => return Err(anyhow::anyhow!("Not authorized")), 235 - }; 215 + // Get session and create DPoP auth 216 + let session = auth.session().ok_or_else(|| anyhow::anyhow!("Not authorized"))?; 217 + let dpop_auth = create_dpop_auth_from_session(session)?; 236 218 237 219 // Create or update the acceptance using the new helper 238 220 let (acceptance_uri, was_updated) =
+4 -26
src/http/handle_create_event.rs
··· 13 13 use serde_json::json; 14 14 use std::collections::HashMap; 15 15 16 - use crate::atproto::auth::{ 17 - create_dpop_auth_from_aip_session, create_dpop_auth_from_oauth_session, 18 - }; 19 - use crate::config::OAuthBackendConfig; 20 - use crate::http::auth_utils::{AipSessionStatus, require_valid_aip_session}; 16 + use crate::atproto::auth::create_dpop_auth_from_session; 21 17 use crate::http::context::WebContext; 22 18 use crate::http::errors::CommonError; 23 19 use crate::http::errors::WebError; ··· 131 127 ) -> Result<impl IntoResponse, WebError> { 132 128 let current_handle = auth.require(&query.to_redirect_url())?; 133 129 134 - // Check AIP session validity 135 - if let AipSessionStatus::Stale = require_valid_aip_session(&web_context, &auth).await? { 136 - return Err(WebError::SessionStale("/event".to_string())); 137 - } 138 - 139 130 let is_development = cfg!(debug_assertions); 140 131 let render_template = select_template!("create_event", hx_boosted, hx_request, language); 141 132 let (default_tz, timezones) = supported_timezones(auth.profile()); ··· 230 221 Json(request): Json<ManageEvent>, 231 222 ) -> Result<impl IntoResponse, WebError> { 232 223 let current_handle = auth.require("/event")?; 224 + let session = auth.session().ok_or(CommonError::NotAuthorized)?; 233 225 234 226 // For create, validate that end time requires start time 235 227 let starts_at = match parse_starts_at(request.starts_at.as_deref()) { ··· 265 257 Err(e) => return Ok(e.into_response()), 266 258 }; 267 259 268 - // Check AIP session validity before attempting AT Protocol operation 269 - if let AipSessionStatus::Stale = require_valid_aip_session(&web_context, &auth).await? { 270 - return Err(WebError::SessionStale("/event".to_string())); 271 - } 272 - 273 - // Create DPoP auth 274 - let dpop_auth = match (&auth, &web_context.config.oauth_backend) { 275 - (Auth::Pds { session, .. }, OAuthBackendConfig::ATProtocol { .. }) => { 276 - create_dpop_auth_from_oauth_session(session)? 277 - } 278 - (Auth::Aip { access_token, .. }, OAuthBackendConfig::AIP { hostname, .. }) => { 279 - create_dpop_auth_from_aip_session(&web_context.http_client, hostname, access_token) 280 - .await? 281 - } 282 - _ => return Err(CommonError::NotAuthorized.into()), 283 - }; 260 + // Create DPoP auth from session 261 + let dpop_auth = create_dpop_auth_from_session(session)?; 284 262 285 263 let now = Utc::now(); 286 264
+4 -33
src/http/handle_create_rsvp.rs
··· 12 12 use std::hash::Hasher; 13 13 use std::str::FromStr; 14 14 15 - use crate::atproto::auth::{ 16 - create_dpop_auth_from_aip_session, create_dpop_auth_from_oauth_session, 17 - }; 18 - use crate::config::OAuthBackendConfig; 15 + use crate::atproto::auth::create_dpop_auth_from_session; 19 16 use crate::{ 20 17 contextual_error, 21 18 http::{ 22 - auth_utils::{AipSessionStatus, require_valid_aip_session}, 23 19 context::WebContext, 24 20 errors::{CommonError, CreateRsvpError, WebError}, 25 21 middleware_auth::Auth, ··· 43 39 Form(mut build_rsvp_form): Form<BuildRSVPForm>, 44 40 ) -> Result<impl IntoResponse, WebError> { 45 41 let current_handle = auth.require("/rsvp")?; 46 - 47 - // Check AIP session validity before displaying RSVP form 48 - // This prevents users from filling out forms with stale sessions 49 - if let AipSessionStatus::Stale = require_valid_aip_session(&web_context, &auth).await? { 50 - return Err(WebError::SessionStale("/rsvp".to_string())); 51 - } 42 + let session = auth.session().ok_or(CommonError::NotAuthorized)?; 52 43 53 44 let default_context = template_context! { 54 45 current_handle, ··· 149 140 150 141 let now = Utc::now(); 151 142 152 - // Check AIP session validity before attempting AT Protocol operation 153 - if let AipSessionStatus::Stale = 154 - require_valid_aip_session(&web_context, &auth).await? 155 - { 156 - return Err(WebError::SessionStale("/rsvp".to_string())); 157 - } 158 - 159 - // Create DPoP auth based on OAuth backend type 160 - let dpop_auth = match (&auth, &web_context.config.oauth_backend) { 161 - (Auth::Pds { session, .. }, OAuthBackendConfig::ATProtocol { .. }) => { 162 - create_dpop_auth_from_oauth_session(session)? 163 - } 164 - (Auth::Aip { access_token, .. }, OAuthBackendConfig::AIP { hostname, .. }) => { 165 - create_dpop_auth_from_aip_session( 166 - &web_context.http_client, 167 - hostname, 168 - access_token, 169 - ) 170 - .await? 171 - } 172 - _ => return Err(CommonError::NotAuthorized.into()), 173 - }; 143 + // Create DPoP auth from session 144 + let dpop_auth = create_dpop_auth_from_session(session)?; 174 145 175 146 let subject = atproto_record::lexicon::com::atproto::repo::StrongRef { 176 147 uri: build_rsvp_form.subject_aturi.as_ref().unwrap().to_string(),
+16 -71
src/http/handle_delete_event.rs
··· 9 9 use atproto_client::com::atproto::repo::{DeleteRecordRequest, delete_record}; 10 10 11 11 use crate::{ 12 - atproto::auth::{create_dpop_auth_from_aip_session, create_dpop_auth_from_oauth_session}, 13 - config::OAuthBackendConfig, 12 + atproto::auth::create_dpop_auth_from_session, 14 13 contextual_error, 15 14 http::{ 16 - auth_utils::{AipSessionStatus, require_valid_aip_session}, 17 15 context::UserRequestContext, 18 16 errors::{DeleteEventError, WebError}, 19 17 middleware_auth::Auth, ··· 33 31 Path((handle_slug, event_rkey)): Path<(String, String)>, 34 32 Form(form): Form<DeleteEventForm>, 35 33 ) -> Result<impl IntoResponse, WebError> { 36 - let current_handle = match &ctx.auth { 37 - Auth::Pds { profile, .. } | Auth::Aip { profile, .. } => profile.clone(), 34 + let (current_handle, session) = match &ctx.auth { 35 + Auth::Authenticated { profile, session } => (profile.clone(), session), 38 36 Auth::Unauthenticated => { 39 37 return Ok(StatusCode::FORBIDDEN.into_response()); 40 38 } ··· 81 79 82 80 // If form is submitted with confirmation or it's a non-HTMX POST, proceed with deletion 83 81 if form.confirm.as_deref() == Some("true") { 84 - // Check AIP session validity before attempting AT Protocol operation 85 - if let AipSessionStatus::Stale = 86 - require_valid_aip_session(&ctx.web_context, &ctx.auth).await? 87 - { 88 - return Err(WebError::SessionStale("/".to_string())); 89 - } 90 - 91 - // Create DPoP authentication based on auth type 92 - let dpop_auth = match &ctx.auth { 93 - Auth::Pds { session, .. } => match create_dpop_auth_from_oauth_session(session) { 94 - Ok(auth) => auth, 95 - Err(err) => { 96 - tracing::error!("Failed to create DPoP auth from OAuth session: {}", err); 97 - return contextual_error!( 98 - ctx.web_context, 99 - ctx.language, 100 - error_template, 101 - default_context, 102 - err, 103 - StatusCode::INTERNAL_SERVER_ERROR 104 - ); 105 - } 106 - }, 107 - Auth::Aip { .. } => match &ctx.web_context.config.oauth_backend { 108 - OAuthBackendConfig::AIP { hostname, .. } => { 109 - let access_token = match &ctx.auth { 110 - Auth::Aip { access_token, .. } => access_token, 111 - _ => unreachable!("We already matched on Auth::Aip"), 112 - }; 113 - 114 - match create_dpop_auth_from_aip_session( 115 - &ctx.web_context.http_client, 116 - hostname, 117 - access_token, 118 - ) 119 - .await 120 - { 121 - Ok(auth) => auth, 122 - Err(err) => { 123 - tracing::error!("Failed to create DPoP auth from AIP session: {}", err); 124 - return contextual_error!( 125 - ctx.web_context, 126 - ctx.language, 127 - error_template, 128 - default_context, 129 - err, 130 - StatusCode::INTERNAL_SERVER_ERROR 131 - ); 132 - } 133 - } 134 - } 135 - _ => { 136 - tracing::error!("AIP auth found but OAuth backend is not AIP"); 137 - return contextual_error!( 138 - ctx.web_context, 139 - ctx.language, 140 - error_template, 141 - default_context, 142 - DeleteEventError::AuthenticationConfigurationMismatch, 143 - StatusCode::INTERNAL_SERVER_ERROR 144 - ); 145 - } 146 - }, 147 - Auth::Unauthenticated => { 148 - // This should not happen due to the check above 149 - return Ok(StatusCode::FORBIDDEN.into_response()); 82 + // Create DPoP authentication from session 83 + let dpop_auth = match create_dpop_auth_from_session(session) { 84 + Ok(auth) => auth, 85 + Err(err) => { 86 + tracing::error!("Failed to create DPoP auth from OAuth session: {}", err); 87 + return contextual_error!( 88 + ctx.web_context, 89 + ctx.language, 90 + error_template, 91 + default_context, 92 + err, 93 + StatusCode::INTERNAL_SERVER_ERROR 94 + ); 150 95 } 151 96 }; 152 97
+4 -23
src/http/handle_edit_event.rs
··· 2 2 use http::StatusCode; 3 3 use serde_json::json; 4 4 5 - use crate::atproto::auth::{ 6 - create_dpop_auth_from_aip_session, create_dpop_auth_from_oauth_session, 7 - }; 8 - use crate::http::auth_utils::{AipSessionStatus, require_valid_aip_session}; 5 + use crate::atproto::auth::create_dpop_auth_from_session; 9 6 use crate::http::context::UserRequestContext; 10 7 use crate::http::errors::{CommonError, WebError}; 11 8 use crate::http::event_form::ManageEvent; 12 9 use crate::http::event_validation::validate_event_request; 13 - use crate::http::middleware_auth::Auth; 14 10 use crate::search_index::SearchIndexManager; 15 11 use crate::storage::event::{event_get, event_update_with_metadata}; 16 12 use crate::storage::identity_profile::{handle_for_did, handle_for_handle}; ··· 28 24 Json(request): Json<ManageEvent>, 29 25 ) -> Result<impl IntoResponse, WebError> { 30 26 let current_handle = ctx.auth.require("/")?; 27 + let session = ctx.auth.session().ok_or(CommonError::NotAuthorized)?; 31 28 32 29 // Lookup the event to verify ownership 33 30 let profile = if handle_slug.starts_with("did:") { ··· 114 111 }; 115 112 116 113 // Check AIP session validity before attempting AT Protocol operation 117 - if let AipSessionStatus::Stale = require_valid_aip_session(&ctx.web_context, &ctx.auth).await? { 118 - return Err(WebError::SessionStale("/event".to_string())); 119 - } 120 - 121 - // Create DPoP auth 122 - let dpop_auth = match (&ctx.auth, &ctx.web_context.config.oauth_backend) { 123 - (Auth::Pds { session, .. }, crate::config::OAuthBackendConfig::ATProtocol { .. }) => { 124 - create_dpop_auth_from_oauth_session(session)? 125 - } 126 - ( 127 - Auth::Aip { access_token, .. }, 128 - crate::config::OAuthBackendConfig::AIP { hostname, .. }, 129 - ) => { 130 - create_dpop_auth_from_aip_session(&ctx.web_context.http_client, hostname, access_token) 131 - .await? 132 - } 133 - _ => return Err(CommonError::NotAuthorized.into()), 134 - }; 114 + // Create DPoP auth from session 115 + let dpop_auth = create_dpop_auth_from_session(session)?; 135 116 136 117 // Create updated record using validated data (preserve extra fields from existing event) 137 118 let the_record = LexiconCommunityEvent {
+4 -19
src/http/handle_finalize_acceptance.rs
··· 14 14 use std::str::FromStr; 15 15 16 16 use crate::{ 17 - atproto::auth::{create_dpop_auth_from_aip_session, create_dpop_auth_from_oauth_session}, 18 - config::OAuthBackendConfig, 17 + atproto::auth::create_dpop_auth_from_session, 19 18 http::{ 20 19 acceptance_utils::format_success_html, 21 - auth_utils::{AipSessionStatus, require_valid_aip_session}, 22 20 context::WebContext, 23 21 errors::{WebError, acceptance_error::AcceptanceError}, 24 22 middleware_auth::Auth, ··· 49 47 Form(form): Form<FinalizeAcceptanceForm>, 50 48 ) -> Result<impl IntoResponse, WebError> { 51 49 let current_handle = auth.require("/finalize_acceptance")?; 50 + let session = auth.session().ok_or(AcceptanceError::NotAuthorized)?; 52 51 53 52 // Get the old acceptance ticket to determine which event this is for 54 53 // We need the event_aturi to look up the latest ticket (in case organizer re-accepted with new metadata) ··· 234 233 (updated_record, rsvp.aturi.clone(), false, event_cid) 235 234 }; 236 235 237 - // Check AIP session validity before attempting AT Protocol operation 238 - if let AipSessionStatus::Stale = require_valid_aip_session(&web_context, &auth).await? { 239 - return Err(WebError::SessionStale("/".to_string())); 240 - } 241 - 242 - // Create DPoP auth based on OAuth backend type 243 - let dpop_auth = match (&auth, &web_context.config.oauth_backend) { 244 - (Auth::Pds { session, .. }, OAuthBackendConfig::ATProtocol { .. }) => { 245 - create_dpop_auth_from_oauth_session(session)? 246 - } 247 - (Auth::Aip { access_token, .. }, OAuthBackendConfig::AIP { hostname, .. }) => { 248 - create_dpop_auth_from_aip_session(&web_context.http_client, hostname, access_token) 249 - .await? 250 - } 251 - _ => return Err(AcceptanceError::NotAuthorized.into()), 252 - }; 236 + // Create DPoP auth from session 237 + let dpop_auth = create_dpop_auth_from_session(session)?; 253 238 254 239 // Parse the RSVP AT-URI to extract the record key 255 240 let parsed_rsvp_aturi = ATURI::from_str(&rsvp_aturi)
+6 -36
src/http/handle_lfg.rs
··· 22 22 23 23 use std::collections::HashMap; 24 24 25 - use crate::atproto::auth::{ 26 - create_dpop_auth_from_aip_session, create_dpop_auth_from_oauth_session, 27 - }; 25 + use crate::atproto::auth::create_dpop_auth_from_session; 28 26 use crate::atproto::lexicon::lfg::{Lfg, NSID}; 29 - use crate::config::OAuthBackendConfig; 30 - use crate::http::auth_utils::{AipSessionStatus, require_valid_aip_session}; 31 27 use crate::http::context::WebContext; 32 28 use crate::http::errors::{CommonError, LfgError, WebError}; 33 29 use crate::http::event_view::EventView; ··· 481 477 Json(request): Json<CreateLfgRequest>, 482 478 ) -> Result<Json<CreateLfgResponse>, WebError> { 483 479 let current_handle = auth.require("/lfg")?; 484 - 485 - // Check AIP session validity before attempting AT Protocol operation 486 - if let AipSessionStatus::Stale = require_valid_aip_session(&web_context, &auth).await? { 487 - return Err(WebError::SessionStale("/lfg".to_string())); 488 - } 480 + let session = auth.session().ok_or(CommonError::NotAuthorized)?; 489 481 490 482 // Validate the request 491 483 validate_create_lfg_request(&request)?; ··· 530 522 active: true, 531 523 }; 532 524 533 - // Create DPoP auth based on OAuth backend type 534 - let dpop_auth = match (&auth, &web_context.config.oauth_backend) { 535 - (Auth::Pds { session, .. }, OAuthBackendConfig::ATProtocol { .. }) => { 536 - create_dpop_auth_from_oauth_session(session)? 537 - } 538 - (Auth::Aip { access_token, .. }, OAuthBackendConfig::AIP { hostname, .. }) => { 539 - create_dpop_auth_from_aip_session(&web_context.http_client, hostname, access_token) 540 - .await? 541 - } 542 - _ => return Err(CommonError::NotAuthorized.into()), 543 - }; 525 + // Create DPoP auth from session 526 + let dpop_auth = create_dpop_auth_from_session(session)?; 544 527 545 528 let create_request = CreateRecordRequest { 546 529 repo: current_handle.did.clone(), ··· 631 614 Cached(auth): Cached<Auth>, 632 615 ) -> Result<impl IntoResponse, WebError> { 633 616 let current_handle = auth.require("/lfg/deactivate")?; 634 - 635 - // Check AIP session validity 636 - if let AipSessionStatus::Stale = require_valid_aip_session(&web_context, &auth).await? { 637 - return Err(WebError::SessionStale("/lfg".to_string())); 638 - } 617 + let session = auth.session().ok_or(CommonError::NotAuthorized)?; 639 618 640 619 // Get the active LFG record 641 620 let active_lfg = lfg_get_active_by_did(&web_context.pool, &current_handle.did) ··· 648 627 lfg.active = false; 649 628 650 629 // Create DPoP auth 651 - let dpop_auth = match (&auth, &web_context.config.oauth_backend) { 652 - (Auth::Pds { session, .. }, OAuthBackendConfig::ATProtocol { .. }) => { 653 - create_dpop_auth_from_oauth_session(session)? 654 - } 655 - (Auth::Aip { access_token, .. }, OAuthBackendConfig::AIP { hostname, .. }) => { 656 - create_dpop_auth_from_aip_session(&web_context.http_client, hostname, access_token) 657 - .await? 658 - } 659 - _ => return Err(CommonError::NotAuthorized.into()), 660 - }; 630 + let dpop_auth = create_dpop_auth_from_session(session)?; 661 631 662 632 // Extract rkey from AT-URI 663 633 let rkey = active_lfg
+783
src/http/handle_mcp_oauth.rs
··· 1 + //! MCP OAuth handlers for third-party MCP client authentication. 2 + //! 3 + //! Implements the OAuth 2.0 flow for MCP clients: 4 + //! 1. Client registers dynamically via POST /mcp/register 5 + //! 2. Client redirects user to GET /mcp/authorize 6 + //! 3. User authenticates via AT Protocol OAuth 7 + //! 4. Callback redirects to client with authorization code 8 + //! 5. Client exchanges code for tokens via POST /mcp/token 9 + 10 + use axum::{ 11 + Form, 12 + Json, 13 + extract::{Query, State}, 14 + http::StatusCode, 15 + response::{IntoResponse, Redirect, Response}, 16 + }; 17 + use deadpool_redis::redis; 18 + use serde::{Deserialize, Serialize}; 19 + use serde_json::json; 20 + 21 + use crate::http::context::WebContext; 22 + use crate::http::errors::WebError; 23 + use crate::http::mcp_jwt; 24 + use crate::storage::mcp_clients::{ 25 + mcp_client_create, mcp_client_get_by_client_id, mcp_client_update_auth, 26 + }; 27 + 28 + /// OAuth protected resource metadata for MCP endpoint. 29 + /// GET /.well-known/oauth-protected-resource/mcp 30 + pub(crate) async fn get_mcp_oauth_protected_resource( 31 + State(web_context): State<WebContext>, 32 + ) -> Response { 33 + let external_base = &web_context.config.external_base; 34 + 35 + let metadata = json!({ 36 + "resource": format!("https://{}/mcp", external_base), 37 + "authorization_servers": [format!("https://{}", external_base)], 38 + "bearer_methods_supported": ["header"], 39 + "scopes_supported": [ 40 + "openid", 41 + "profile", 42 + "atproto", 43 + "repo:community.lexicon.calendar.rsvp" 44 + ], 45 + "resource_documentation": format!("https://{}/help/mcp", external_base) 46 + }); 47 + 48 + (StatusCode::OK, Json(metadata)).into_response() 49 + } 50 + 51 + /// OAuth authorization server metadata for MCP. 52 + /// GET /.well-known/oauth-authorization-server/mcp 53 + pub(crate) async fn get_mcp_oauth_authorization_server( 54 + State(web_context): State<WebContext>, 55 + ) -> Response { 56 + let external_base = &web_context.config.external_base; 57 + 58 + let metadata = json!({ 59 + "issuer": format!("https://{}", external_base), 60 + "authorization_endpoint": format!("https://{}/mcp/authorize", external_base), 61 + "token_endpoint": format!("https://{}/mcp/token", external_base), 62 + "registration_endpoint": format!("https://{}/mcp/register", external_base), 63 + "scopes_supported": [ 64 + "openid", 65 + "profile", 66 + "atproto", 67 + "repo:community.lexicon.calendar.rsvp" 68 + ], 69 + "response_types_supported": ["code"], 70 + "response_modes_supported": ["query"], 71 + "grant_types_supported": ["authorization_code", "refresh_token"], 72 + "token_endpoint_auth_methods_supported": ["client_secret_basic", "client_secret_post"], 73 + "code_challenge_methods_supported": ["S256"], 74 + "dpop_signing_alg_values_supported": ["ES256"] 75 + }); 76 + 77 + (StatusCode::OK, Json(metadata)).into_response() 78 + } 79 + 80 + /// Dynamic client registration request. 81 + #[derive(Debug, Deserialize)] 82 + pub(crate) struct ClientRegistrationRequest { 83 + pub client_name: Option<String>, 84 + pub redirect_uris: Vec<String>, 85 + pub grant_types: Option<Vec<String>>, 86 + pub response_types: Option<Vec<String>>, 87 + pub scope: Option<String>, 88 + } 89 + 90 + /// Dynamic client registration response. 91 + #[derive(Debug, Serialize)] 92 + pub(crate) struct ClientRegistrationResponse { 93 + pub client_id: String, 94 + pub client_secret: String, 95 + pub client_id_issued_at: i64, 96 + pub client_secret_expires_at: i64, 97 + pub redirect_uris: Vec<String>, 98 + pub grant_types: Vec<String>, 99 + pub response_types: Vec<String>, 100 + pub client_name: Option<String>, 101 + } 102 + 103 + /// POST /mcp/register - Dynamic client registration. 104 + pub(crate) async fn post_mcp_register( 105 + State(web_context): State<WebContext>, 106 + Json(request): Json<ClientRegistrationRequest>, 107 + ) -> Result<impl IntoResponse, WebError> { 108 + // Validate request 109 + if request.redirect_uris.is_empty() { 110 + return Ok(( 111 + StatusCode::BAD_REQUEST, 112 + Json(json!({"error": "invalid_client_metadata", "error_description": "redirect_uris is required"})), 113 + ) 114 + .into_response()); 115 + } 116 + 117 + // Validate redirect URIs 118 + for uri in &request.redirect_uris { 119 + if !uri.starts_with("http://") && !uri.starts_with("https://") { 120 + return Ok(( 121 + StatusCode::BAD_REQUEST, 122 + Json(json!({ 123 + "error": "invalid_redirect_uri", 124 + "error_description": format!("Invalid redirect URI: {}", uri) 125 + })), 126 + ) 127 + .into_response()); 128 + } 129 + } 130 + 131 + // Generate client credentials 132 + let id = ulid::Ulid::new().to_string(); 133 + let client_id = format!("https://{}/mcp/clients/{}", web_context.config.external_base, id); 134 + let client_secret = generate_client_secret(); 135 + 136 + // Generate DPoP key for this client 137 + let dpop_jwk = generate_dpop_key()?; 138 + 139 + // Store client 140 + let client = mcp_client_create( 141 + &web_context.pool, 142 + &id, 143 + &client_id, 144 + &client_secret, 145 + &request.redirect_uris[0], 146 + request.client_name.as_deref(), 147 + &dpop_jwk, 148 + ) 149 + .await 150 + .map_err(WebError::from)?; 151 + 152 + let response = ClientRegistrationResponse { 153 + client_id: client.client_id, 154 + client_secret, 155 + client_id_issued_at: client.created_at.timestamp(), 156 + client_secret_expires_at: 0, // Never expires 157 + redirect_uris: request.redirect_uris, 158 + grant_types: request.grant_types.unwrap_or_else(|| vec!["authorization_code".to_string()]), 159 + response_types: request.response_types.unwrap_or_else(|| vec!["code".to_string()]), 160 + client_name: request.client_name, 161 + }; 162 + 163 + Ok((StatusCode::CREATED, Json(response)).into_response()) 164 + } 165 + 166 + /// Authorization request query parameters. 167 + #[derive(Debug, Deserialize)] 168 + pub(crate) struct AuthorizationRequest { 169 + pub client_id: String, 170 + pub redirect_uri: String, 171 + pub response_type: String, 172 + pub state: Option<String>, 173 + pub scope: Option<String>, 174 + pub code_challenge: Option<String>, 175 + pub code_challenge_method: Option<String>, 176 + } 177 + 178 + /// GET /mcp/authorize - Start authorization flow. 179 + pub(crate) async fn get_mcp_authorize( 180 + State(web_context): State<WebContext>, 181 + Query(request): Query<AuthorizationRequest>, 182 + ) -> Result<impl IntoResponse, WebError> { 183 + // Validate client 184 + let client = match mcp_client_get_by_client_id(&web_context.pool, &request.client_id).await { 185 + Ok(c) => c, 186 + Err(_) => { 187 + return Ok(( 188 + StatusCode::BAD_REQUEST, 189 + Json(json!({"error": "invalid_client", "error_description": "Client not found"})), 190 + ) 191 + .into_response()); 192 + } 193 + }; 194 + 195 + // Validate redirect_uri 196 + if client.redirect_uri != request.redirect_uri { 197 + return Ok(( 198 + StatusCode::BAD_REQUEST, 199 + Json(json!({ 200 + "error": "invalid_redirect_uri", 201 + "error_description": "Redirect URI does not match registered URI" 202 + })), 203 + ) 204 + .into_response()); 205 + } 206 + 207 + // Validate response_type 208 + if request.response_type != "code" { 209 + return Ok(( 210 + StatusCode::BAD_REQUEST, 211 + Json(json!({ 212 + "error": "unsupported_response_type", 213 + "error_description": "Only 'code' response type is supported" 214 + })), 215 + ) 216 + .into_response()); 217 + } 218 + 219 + // Store the MCP OAuth request state in Redis for later retrieval 220 + let mcp_state = ulid::Ulid::new().to_string(); 221 + let mcp_request_data = serde_json::to_string(&json!({ 222 + "client_id": request.client_id, 223 + "redirect_uri": request.redirect_uri, 224 + "state": request.state, 225 + "code_challenge": request.code_challenge, 226 + "code_challenge_method": request.code_challenge_method, 227 + "scope": request.scope, 228 + })) 229 + .map_err(|e| WebError::from(anyhow::anyhow!("Failed to serialize MCP request: {}", e)))?; 230 + 231 + // Store in Redis with 10 minute expiry 232 + { 233 + let mut conn = web_context 234 + .cache_pool 235 + .get() 236 + .await 237 + .map_err(|e| WebError::from(anyhow::anyhow!("Failed to get Redis connection: {}", e)))?; 238 + 239 + redis::cmd("SETEX") 240 + .arg(format!("mcp_oauth_request:{}", mcp_state)) 241 + .arg(600) // 10 minutes 242 + .arg(&mcp_request_data) 243 + .query_async::<()>(&mut *conn) 244 + .await 245 + .map_err(|e| WebError::from(anyhow::anyhow!("Failed to store MCP OAuth request: {}", e)))?; 246 + } 247 + 248 + // Redirect to standard OAuth login with MCP callback 249 + let oauth_login_url = format!( 250 + "https://{}/oauth/login?destination={}", 251 + web_context.config.external_base, 252 + urlencoding::encode(&format!( 253 + "/mcp/authorize/callback?mcp_state={}", 254 + mcp_state 255 + )) 256 + ); 257 + 258 + Ok(Redirect::to(&oauth_login_url).into_response()) 259 + } 260 + 261 + /// MCP authorization callback query parameters. 262 + #[derive(Debug, Deserialize)] 263 + pub(crate) struct McpAuthCallbackQuery { 264 + pub mcp_state: String, 265 + } 266 + 267 + /// GET /mcp/authorize/callback - Handle callback after user authenticates. 268 + pub(crate) async fn get_mcp_authorize_callback( 269 + State(web_context): State<WebContext>, 270 + Query(query): Query<McpAuthCallbackQuery>, 271 + jar: axum_extra::extract::PrivateCookieJar, 272 + ) -> Result<impl IntoResponse, WebError> { 273 + use crate::http::cookies::SessionCookie; 274 + use crate::http::middleware_auth::AUTH_COOKIE_NAME; 275 + 276 + // Get current session from cookie 277 + let session = jar 278 + .get(AUTH_COOKIE_NAME) 279 + .map(|cookie| cookie.value().to_owned()) 280 + .and_then(|value| SessionCookie::try_from(value).ok()); 281 + 282 + let session = match session { 283 + Some(s) => s, 284 + None => { 285 + return Ok(( 286 + StatusCode::UNAUTHORIZED, 287 + Json(json!({"error": "access_denied", "error_description": "User not authenticated"})), 288 + ) 289 + .into_response()); 290 + } 291 + }; 292 + 293 + // Retrieve MCP OAuth request from Redis 294 + let mcp_request_data: String = { 295 + let mut conn = web_context 296 + .cache_pool 297 + .get() 298 + .await 299 + .map_err(|e| WebError::from(anyhow::anyhow!("Failed to get Redis connection: {}", e)))?; 300 + 301 + let result: Option<String> = redis::cmd("GET") 302 + .arg(format!("mcp_oauth_request:{}", query.mcp_state)) 303 + .query_async(&mut *conn) 304 + .await 305 + .map_err(|e| WebError::from(anyhow::anyhow!("Failed to get MCP OAuth request: {}", e)))?; 306 + 307 + match result { 308 + Some(data) => data, 309 + None => { 310 + return Ok(( 311 + StatusCode::BAD_REQUEST, 312 + Json(json!({"error": "invalid_request", "error_description": "MCP OAuth request not found or expired"})), 313 + ) 314 + .into_response()); 315 + } 316 + } 317 + }; 318 + 319 + // Parse the stored request 320 + let mcp_request: serde_json::Value = serde_json::from_str(&mcp_request_data) 321 + .map_err(|e| WebError::from(anyhow::anyhow!("Failed to parse MCP request: {}", e)))?; 322 + 323 + let client_id = mcp_request["client_id"] 324 + .as_str() 325 + .ok_or_else(|| WebError::from(anyhow::anyhow!("Missing client_id")))?; 326 + let redirect_uri = mcp_request["redirect_uri"] 327 + .as_str() 328 + .ok_or_else(|| WebError::from(anyhow::anyhow!("Missing redirect_uri")))?; 329 + let client_state = mcp_request["state"].as_str(); 330 + 331 + // Generate authorization code 332 + let auth_code = ulid::Ulid::new().to_string(); 333 + 334 + // Store authorization code in Redis with the session info 335 + let auth_code_data = serde_json::to_string(&json!({ 336 + "client_id": client_id, 337 + "did": session.did, 338 + "access_token": session.access_token, 339 + "refresh_token": session.refresh_token, 340 + "dpop_private_key": session.dpop_private_key, 341 + "issuer": session.issuer, 342 + "code_challenge": mcp_request["code_challenge"], 343 + "code_challenge_method": mcp_request["code_challenge_method"], 344 + })) 345 + .map_err(|e| WebError::from(anyhow::anyhow!("Failed to serialize auth code data: {}", e)))?; 346 + 347 + { 348 + let mut conn = web_context 349 + .cache_pool 350 + .get() 351 + .await 352 + .map_err(|e| WebError::from(anyhow::anyhow!("Failed to get Redis connection: {}", e)))?; 353 + 354 + // Store auth code with 5 minute expiry 355 + redis::cmd("SETEX") 356 + .arg(format!("mcp_auth_code:{}", auth_code)) 357 + .arg(300) // 5 minutes 358 + .arg(&auth_code_data) 359 + .query_async::<()>(&mut *conn) 360 + .await 361 + .map_err(|e| WebError::from(anyhow::anyhow!("Failed to store auth code: {}", e)))?; 362 + 363 + // Delete the MCP OAuth request 364 + redis::cmd("DEL") 365 + .arg(format!("mcp_oauth_request:{}", query.mcp_state)) 366 + .query_async::<()>(&mut *conn) 367 + .await 368 + .ok(); // Ignore errors on cleanup 369 + } 370 + 371 + // Update the MCP client with user info 372 + mcp_client_update_auth(&web_context.pool, client_id, &session.did, &session.issuer) 373 + .await 374 + .map_err(WebError::from)?; 375 + 376 + // Redirect back to client with authorization code 377 + let mut callback_url = redirect_uri.to_string(); 378 + callback_url.push_str(&format!("?code={}", auth_code)); 379 + if let Some(state) = client_state { 380 + callback_url.push_str(&format!("&state={}", state)); 381 + } 382 + 383 + Ok(Redirect::to(&callback_url).into_response()) 384 + } 385 + 386 + /// Token request form data. 387 + #[derive(Debug, Deserialize)] 388 + pub(crate) struct TokenRequest { 389 + pub grant_type: String, 390 + pub code: Option<String>, 391 + pub redirect_uri: Option<String>, 392 + pub client_id: Option<String>, 393 + pub client_secret: Option<String>, 394 + pub code_verifier: Option<String>, 395 + pub refresh_token: Option<String>, 396 + } 397 + 398 + /// Token response. 399 + #[derive(Debug, Serialize)] 400 + pub(crate) struct TokenResponse { 401 + pub access_token: String, 402 + pub token_type: String, 403 + pub expires_in: i64, 404 + #[serde(skip_serializing_if = "Option::is_none")] 405 + pub refresh_token: Option<String>, 406 + #[serde(skip_serializing_if = "Option::is_none")] 407 + pub scope: Option<String>, 408 + } 409 + 410 + /// POST /mcp/token - Token endpoint. 411 + pub(crate) async fn post_mcp_token( 412 + State(web_context): State<WebContext>, 413 + Form(request): Form<TokenRequest>, 414 + ) -> Result<impl IntoResponse, WebError> { 415 + match request.grant_type.as_str() { 416 + "authorization_code" => handle_authorization_code_grant(web_context, request).await, 417 + "refresh_token" => handle_refresh_token_grant(web_context, request).await, 418 + _ => Ok(( 419 + StatusCode::BAD_REQUEST, 420 + Json(json!({ 421 + "error": "unsupported_grant_type", 422 + "error_description": "Only 'authorization_code' and 'refresh_token' grant types are supported" 423 + })), 424 + ) 425 + .into_response()), 426 + } 427 + } 428 + 429 + /// Handle authorization code grant. 430 + async fn handle_authorization_code_grant( 431 + web_context: WebContext, 432 + request: TokenRequest, 433 + ) -> Result<Response, WebError> { 434 + let code = request.code.ok_or_else(|| { 435 + WebError::from(anyhow::anyhow!("code is required")) 436 + })?; 437 + 438 + let client_id = request.client_id.ok_or_else(|| { 439 + WebError::from(anyhow::anyhow!("client_id is required")) 440 + })?; 441 + 442 + let client_secret = request.client_secret.ok_or_else(|| { 443 + WebError::from(anyhow::anyhow!("client_secret is required")) 444 + })?; 445 + 446 + // Validate client credentials 447 + let client = match mcp_client_get_by_client_id(&web_context.pool, &client_id).await { 448 + Ok(c) => c, 449 + Err(_) => { 450 + return Ok(( 451 + StatusCode::UNAUTHORIZED, 452 + Json(json!({"error": "invalid_client"})), 453 + ) 454 + .into_response()); 455 + } 456 + }; 457 + 458 + if client.client_secret != client_secret { 459 + return Ok(( 460 + StatusCode::UNAUTHORIZED, 461 + Json(json!({"error": "invalid_client"})), 462 + ) 463 + .into_response()); 464 + } 465 + 466 + // Retrieve and validate authorization code 467 + let auth_code_data: String = { 468 + let mut conn = web_context 469 + .cache_pool 470 + .get() 471 + .await 472 + .map_err(|e| WebError::from(anyhow::anyhow!("Failed to get Redis connection: {}", e)))?; 473 + 474 + let result: Option<String> = redis::cmd("GET") 475 + .arg(format!("mcp_auth_code:{}", code)) 476 + .query_async(&mut *conn) 477 + .await 478 + .map_err(|e| WebError::from(anyhow::anyhow!("Failed to get auth code: {}", e)))?; 479 + 480 + match result { 481 + Some(data) => data, 482 + None => { 483 + return Ok(( 484 + StatusCode::BAD_REQUEST, 485 + Json(json!({"error": "invalid_grant", "error_description": "Authorization code not found or expired"})), 486 + ) 487 + .into_response()); 488 + } 489 + } 490 + }; 491 + 492 + let auth_data: serde_json::Value = serde_json::from_str(&auth_code_data) 493 + .map_err(|e| WebError::from(anyhow::anyhow!("Failed to parse auth code data: {}", e)))?; 494 + 495 + // Verify client_id matches 496 + if auth_data["client_id"].as_str() != Some(client_id.as_str()) { 497 + return Ok(( 498 + StatusCode::BAD_REQUEST, 499 + Json(json!({"error": "invalid_grant", "error_description": "Client ID mismatch"})), 500 + ) 501 + .into_response()); 502 + } 503 + 504 + // Verify PKCE code_verifier if code_challenge was provided 505 + if let Some(code_challenge) = auth_data["code_challenge"].as_str() { 506 + let code_verifier = request.code_verifier.ok_or_else(|| { 507 + WebError::from(anyhow::anyhow!("code_verifier is required")) 508 + })?; 509 + 510 + let method = auth_data["code_challenge_method"] 511 + .as_str() 512 + .unwrap_or("S256"); 513 + 514 + if !verify_pkce(&code_verifier, code_challenge, method) { 515 + return Ok(( 516 + StatusCode::BAD_REQUEST, 517 + Json(json!({"error": "invalid_grant", "error_description": "Invalid code_verifier"})), 518 + ) 519 + .into_response()); 520 + } 521 + } 522 + 523 + // Delete the authorization code (one-time use) 524 + { 525 + let mut conn = web_context 526 + .cache_pool 527 + .get() 528 + .await 529 + .map_err(|e| WebError::from(anyhow::anyhow!("Failed to get Redis connection: {}", e)))?; 530 + 531 + redis::cmd("DEL") 532 + .arg(format!("mcp_auth_code:{}", code)) 533 + .query_async::<()>(&mut *conn) 534 + .await 535 + .ok(); 536 + } 537 + 538 + // Extract token info 539 + let did = auth_data["did"] 540 + .as_str() 541 + .ok_or_else(|| WebError::from(anyhow::anyhow!("Missing DID")))?; 542 + let atproto_access_token = auth_data["access_token"] 543 + .as_str() 544 + .ok_or_else(|| WebError::from(anyhow::anyhow!("Missing access token")))?; 545 + 546 + // Get JWT secret from config 547 + let jwt_secret = web_context 548 + .config 549 + .mcp_jwt_key 550 + .as_ref() 551 + .map(|s| s.as_bytes()) 552 + .unwrap_or_else(|| web_context.config.http_cookie_key.as_ref().master()); 553 + 554 + // Create MCP access token (wraps the AT Protocol token) 555 + let expires_in = 3600i64; // 1 hour 556 + let access_token = mcp_jwt::wrap_token( 557 + jwt_secret, 558 + &format!("https://{}", web_context.config.external_base), 559 + &client_id, 560 + &client.id, 561 + did, 562 + atproto_access_token, 563 + expires_in, 564 + ) 565 + .map_err(|e| WebError::from(anyhow::anyhow!("Failed to create access token: {}", e)))?; 566 + 567 + // Create refresh token (store in Redis) 568 + let refresh_token = ulid::Ulid::new().to_string(); 569 + let refresh_data = serde_json::to_string(&json!({ 570 + "client_id": client_id, 571 + "did": did, 572 + "atproto_access_token": atproto_access_token, 573 + "atproto_refresh_token": auth_data["refresh_token"], 574 + "dpop_private_key": auth_data["dpop_private_key"], 575 + "issuer": auth_data["issuer"], 576 + })) 577 + .map_err(|e| WebError::from(anyhow::anyhow!("Failed to serialize refresh data: {}", e)))?; 578 + 579 + { 580 + let mut conn = web_context 581 + .cache_pool 582 + .get() 583 + .await 584 + .map_err(|e| WebError::from(anyhow::anyhow!("Failed to get Redis connection: {}", e)))?; 585 + 586 + // Store refresh token with 30 day expiry 587 + redis::cmd("SETEX") 588 + .arg(format!("mcp_refresh_token:{}", refresh_token)) 589 + .arg(60 * 60 * 24 * 30) // 30 days 590 + .arg(&refresh_data) 591 + .query_async::<()>(&mut *conn) 592 + .await 593 + .map_err(|e| WebError::from(anyhow::anyhow!("Failed to store refresh token: {}", e)))?; 594 + } 595 + 596 + let response = TokenResponse { 597 + access_token, 598 + token_type: "Bearer".to_string(), 599 + expires_in, 600 + refresh_token: Some(refresh_token), 601 + scope: Some("openid profile atproto".to_string()), 602 + }; 603 + 604 + Ok((StatusCode::OK, Json(response)).into_response()) 605 + } 606 + 607 + /// Handle refresh token grant. 608 + async fn handle_refresh_token_grant( 609 + web_context: WebContext, 610 + request: TokenRequest, 611 + ) -> Result<Response, WebError> { 612 + let refresh_token = request.refresh_token.ok_or_else(|| { 613 + WebError::from(anyhow::anyhow!("refresh_token is required")) 614 + })?; 615 + 616 + let client_id = request.client_id.ok_or_else(|| { 617 + WebError::from(anyhow::anyhow!("client_id is required")) 618 + })?; 619 + 620 + let client_secret = request.client_secret.ok_or_else(|| { 621 + WebError::from(anyhow::anyhow!("client_secret is required")) 622 + })?; 623 + 624 + // Validate client credentials 625 + let client = match mcp_client_get_by_client_id(&web_context.pool, &client_id).await { 626 + Ok(c) => c, 627 + Err(_) => { 628 + return Ok(( 629 + StatusCode::UNAUTHORIZED, 630 + Json(json!({"error": "invalid_client"})), 631 + ) 632 + .into_response()); 633 + } 634 + }; 635 + 636 + if client.client_secret != client_secret { 637 + return Ok(( 638 + StatusCode::UNAUTHORIZED, 639 + Json(json!({"error": "invalid_client"})), 640 + ) 641 + .into_response()); 642 + } 643 + 644 + // Retrieve refresh token data 645 + let refresh_data: String = { 646 + let mut conn = web_context 647 + .cache_pool 648 + .get() 649 + .await 650 + .map_err(|e| WebError::from(anyhow::anyhow!("Failed to get Redis connection: {}", e)))?; 651 + 652 + let result: Option<String> = redis::cmd("GET") 653 + .arg(format!("mcp_refresh_token:{}", refresh_token)) 654 + .query_async(&mut *conn) 655 + .await 656 + .map_err(|e| WebError::from(anyhow::anyhow!("Failed to get refresh token: {}", e)))?; 657 + 658 + match result { 659 + Some(data) => data, 660 + None => { 661 + return Ok(( 662 + StatusCode::BAD_REQUEST, 663 + Json(json!({"error": "invalid_grant", "error_description": "Refresh token not found or expired"})), 664 + ) 665 + .into_response()); 666 + } 667 + } 668 + }; 669 + 670 + let token_data: serde_json::Value = serde_json::from_str(&refresh_data) 671 + .map_err(|e| WebError::from(anyhow::anyhow!("Failed to parse refresh token data: {}", e)))?; 672 + 673 + // Verify client_id matches 674 + if token_data["client_id"].as_str() != Some(client_id.as_str()) { 675 + return Ok(( 676 + StatusCode::BAD_REQUEST, 677 + Json(json!({"error": "invalid_grant", "error_description": "Client ID mismatch"})), 678 + ) 679 + .into_response()); 680 + } 681 + 682 + let did = token_data["did"] 683 + .as_str() 684 + .ok_or_else(|| WebError::from(anyhow::anyhow!("Missing DID")))?; 685 + let atproto_access_token = token_data["atproto_access_token"] 686 + .as_str() 687 + .ok_or_else(|| WebError::from(anyhow::anyhow!("Missing access token")))?; 688 + 689 + // Get JWT secret from config 690 + let jwt_secret = web_context 691 + .config 692 + .mcp_jwt_key 693 + .as_ref() 694 + .map(|s| s.as_bytes()) 695 + .unwrap_or_else(|| web_context.config.http_cookie_key.as_ref().master()); 696 + 697 + // Create new MCP access token 698 + let expires_in = 3600i64; 699 + let access_token = mcp_jwt::wrap_token( 700 + jwt_secret, 701 + &format!("https://{}", web_context.config.external_base), 702 + &client_id, 703 + &client.id, 704 + did, 705 + atproto_access_token, 706 + expires_in, 707 + ) 708 + .map_err(|e| WebError::from(anyhow::anyhow!("Failed to create access token: {}", e)))?; 709 + 710 + // Generate new refresh token and rotate 711 + let new_refresh_token = ulid::Ulid::new().to_string(); 712 + 713 + { 714 + let mut conn = web_context 715 + .cache_pool 716 + .get() 717 + .await 718 + .map_err(|e| WebError::from(anyhow::anyhow!("Failed to get Redis connection: {}", e)))?; 719 + 720 + // Store new refresh token 721 + redis::cmd("SETEX") 722 + .arg(format!("mcp_refresh_token:{}", new_refresh_token)) 723 + .arg(60 * 60 * 24 * 30) // 30 days 724 + .arg(&refresh_data) 725 + .query_async::<()>(&mut *conn) 726 + .await 727 + .map_err(|e| WebError::from(anyhow::anyhow!("Failed to store refresh token: {}", e)))?; 728 + 729 + // Delete old refresh token 730 + redis::cmd("DEL") 731 + .arg(format!("mcp_refresh_token:{}", refresh_token)) 732 + .query_async::<()>(&mut *conn) 733 + .await 734 + .ok(); 735 + } 736 + 737 + let response = TokenResponse { 738 + access_token, 739 + token_type: "Bearer".to_string(), 740 + expires_in, 741 + refresh_token: Some(new_refresh_token), 742 + scope: Some("openid profile atproto".to_string()), 743 + }; 744 + 745 + Ok((StatusCode::OK, Json(response)).into_response()) 746 + } 747 + 748 + /// Generate a secure client secret. 749 + fn generate_client_secret() -> String { 750 + use rand::RngCore; 751 + let mut bytes = [0u8; 32]; 752 + rand::rng().fill_bytes(&mut bytes); 753 + hex::encode(bytes) 754 + } 755 + 756 + /// Generate a DPoP key pair and return as did:key string. 757 + /// Uses the atproto_identity key generation utilities. 758 + fn generate_dpop_key() -> Result<String, WebError> { 759 + use atproto_identity::key::{KeyType, generate_key}; 760 + 761 + // Generate a new P-256 private key 762 + let key_data = generate_key(KeyType::P256Private) 763 + .map_err(|e| WebError::from(anyhow::anyhow!("Failed to generate DPoP key: {}", e)))?; 764 + 765 + // Convert to did:key string for storage 766 + Ok(key_data.to_string()) 767 + } 768 + 769 + /// Verify PKCE code_verifier against code_challenge. 770 + fn verify_pkce(code_verifier: &str, code_challenge: &str, method: &str) -> bool { 771 + use base64::{Engine as _, engine::general_purpose::URL_SAFE_NO_PAD}; 772 + use sha2::{Digest, Sha256}; 773 + 774 + match method { 775 + "S256" => { 776 + let hash = Sha256::digest(code_verifier.as_bytes()); 777 + let computed_challenge = URL_SAFE_NO_PAD.encode(hash); 778 + computed_challenge == code_challenge 779 + } 780 + "plain" => code_verifier == code_challenge, 781 + _ => false, 782 + } 783 + }
+938
src/http/handle_oauth.rs
··· 1 + //! Unified OAuth handlers for AT Protocol authentication. 2 + //! 3 + //! This module provides all OAuth-related endpoints: 4 + //! - `handle_oauth_metadata` - GET /oauth-client-metadata.json 5 + //! - `handle_auth_init` - GET/POST /oauth/login - Initiate OAuth flow 6 + //! - `handle_auth_callback` - GET /oauth/callback - Complete OAuth, set cookie 7 + //! - `handle_auth_refresh` - POST /oauth/refresh - Refresh tokens 8 + //! - `handle_auth_logout` - POST /oauth/logout - Clear session 9 + 10 + use std::sync::Arc; 11 + 12 + use anyhow::Result; 13 + use atproto_client::client::DPoPAuth; 14 + use atproto_identity::{ 15 + key::{KeyType, generate_key, identify_key, to_public}, 16 + resolve::IdentityResolver, 17 + traits::KeyResolver, 18 + }; 19 + use atproto_oauth::{ 20 + jwk::{self, WrappedJsonWebKeySet}, 21 + pkce::generate, 22 + resources::{oauth_authorization_server, pds_resources}, 23 + workflow::{OAuthClient, OAuthRequest, OAuthRequestState, oauth_complete, oauth_init}, 24 + }; 25 + use axum::{ 26 + Json, 27 + extract::State, 28 + response::{IntoResponse, Redirect}, 29 + }; 30 + use axum_extra::extract::{ 31 + Cached, Form, PrivateCookieJar, Query, 32 + cookie::{Cookie, SameSite}, 33 + }; 34 + use axum_htmx::{HxBoosted, HxRedirect, HxRequest}; 35 + use axum_template::RenderHtml; 36 + use chrono::{Duration, Utc}; 37 + use http::StatusCode; 38 + use minijinja::context as template_context; 39 + use rand::{Rng, distr::Alphanumeric}; 40 + use serde::{Deserialize, Serialize}; 41 + use serde_json::json; 42 + 43 + use atproto_tap::TapClient; 44 + 45 + use crate::{ 46 + contextual_error, 47 + facets::FacetLimits, 48 + http::{ 49 + auth_utils::validate_login_input, 50 + context::WebContext, 51 + cookies::SessionCookie, 52 + errors::{LoginError, WebError}, 53 + middleware_auth::{AUTH_COOKIE_NAME, Auth}, 54 + middleware_i18n::Language, 55 + profile_import::import_bluesky_profile, 56 + utils::stringify, 57 + }, 58 + select_template, 59 + storage::{denylist::denylist_exists, identity_profile::handle_warm_up}, 60 + }; 61 + 62 + // ============================================================================ 63 + // OAuth Client Metadata 64 + // ============================================================================ 65 + 66 + /// Response structure for OAuth client metadata endpoint. 67 + #[derive(Serialize)] 68 + struct OAuthClientMetadata { 69 + client_id: String, 70 + client_name: String, 71 + client_uri: String, 72 + redirect_uris: Vec<String>, 73 + grant_types: Vec<String>, 74 + response_types: Vec<String>, 75 + scope: String, 76 + application_type: String, 77 + token_endpoint_auth_method: String, 78 + token_endpoint_auth_signing_alg: String, 79 + dpop_bound_access_tokens: bool, 80 + jwks: jwk::WrappedJsonWebKeySet, 81 + } 82 + 83 + /// GET /oauth-client-metadata.json - OAuth client metadata endpoint. 84 + pub(crate) async fn handle_oauth_metadata( 85 + State(web_context): State<WebContext>, 86 + ) -> impl IntoResponse { 87 + let oauth_config = &web_context.oauth_client_config; 88 + 89 + // Get the OAuth client credentials key and convert to JWK 90 + let oauth_key = web_context.config.oauth_client_credentials_key.as_ref(); 91 + let public_key_data = match to_public(oauth_key) { 92 + Ok(pk) => pk, 93 + Err(_) => { 94 + return ( 95 + StatusCode::INTERNAL_SERVER_ERROR, 96 + Json(json!({"error": "Failed to derive public key"})), 97 + ) 98 + .into_response(); 99 + } 100 + }; 101 + let public_jwk = match jwk::generate(&public_key_data) { 102 + Ok(value) => value, 103 + Err(_) => { 104 + return ( 105 + StatusCode::INTERNAL_SERVER_ERROR, 106 + Json(json!({"error": "Failed to derive public key"})), 107 + ) 108 + .into_response(); 109 + } 110 + }; 111 + 112 + let metadata = OAuthClientMetadata { 113 + client_id: oauth_config.client_id.clone(), 114 + client_name: oauth_config 115 + .client_name 116 + .clone() 117 + .unwrap_or_else(|| "Smoke Signal".to_string()), 118 + client_uri: oauth_config.client_uri.clone().unwrap_or_default(), 119 + redirect_uris: vec![oauth_config.redirect_uris.clone()], 120 + grant_types: vec![ 121 + "authorization_code".to_string(), 122 + "refresh_token".to_string(), 123 + ], 124 + response_types: vec!["code".to_string()], 125 + scope: oauth_config 126 + .scope 127 + .clone() 128 + .unwrap_or_else(|| web_context.config.oauth_scope()), 129 + application_type: "web".to_string(), 130 + token_endpoint_auth_method: "private_key_jwt".to_string(), 131 + token_endpoint_auth_signing_alg: "ES256".to_string(), 132 + dpop_bound_access_tokens: true, 133 + jwks: WrappedJsonWebKeySet { 134 + keys: vec![public_jwk], 135 + }, 136 + }; 137 + 138 + Json(metadata).into_response() 139 + } 140 + 141 + // ============================================================================ 142 + // Login / Auth Init 143 + // ============================================================================ 144 + 145 + #[derive(Deserialize)] 146 + pub(crate) struct OAuthLoginForm { 147 + handle: Option<String>, 148 + destination: Option<String>, 149 + } 150 + 151 + #[derive(Deserialize)] 152 + pub(crate) struct LoginQueryParams { 153 + destination: Option<String>, 154 + /// Reason for showing the login page (e.g., "session_expired") 155 + reason: Option<String>, 156 + } 157 + 158 + /// GET/POST /oauth/login - Initiate OAuth flow. 159 + #[allow(clippy::too_many_arguments)] 160 + pub(crate) async fn handle_auth_init( 161 + State(web_context): State<WebContext>, 162 + identity_resolver: State<Arc<dyn IdentityResolver>>, 163 + Language(language): Language, 164 + Cached(auth): Cached<Auth>, 165 + HxRequest(hx_request): HxRequest, 166 + HxBoosted(hx_boosted): HxBoosted, 167 + Query(query_params): Query<LoginQueryParams>, 168 + Form(login_form): Form<OAuthLoginForm>, 169 + ) -> Result<impl IntoResponse, WebError> { 170 + // Check if showing session expired message 171 + let session_expired = query_params.reason.as_deref() == Some("session_expired"); 172 + 173 + // Prefer form destination (from POST) over query destination (from GET) 174 + let destination = login_form.destination.or(query_params.destination.clone()); 175 + 176 + let default_context = template_context! { 177 + current_handle => auth.profile(), 178 + language => language.to_string(), 179 + canonical_url => format!("https://{}/oauth/login", web_context.config.external_base), 180 + destination => destination.clone(), 181 + session_expired => session_expired, 182 + }; 183 + 184 + let render_template = select_template!("login", hx_boosted, hx_request, language); 185 + let error_template = select_template!(hx_boosted, hx_request, language); 186 + 187 + let validated_subject = match validate_login_input(login_form.handle.as_deref()) { 188 + Ok(subject) => subject, 189 + Err(err) => { 190 + let handle_input = if let LoginError::IncompleteHandle = err { 191 + login_form 192 + .handle 193 + .map(|value| format!("{}.bsky.social", value)) 194 + .unwrap_or_default() 195 + } else { 196 + login_form.handle.unwrap_or_default() 197 + }; 198 + return contextual_error!( 199 + web_context, 200 + language, 201 + render_template, 202 + template_context! { ..default_context, ..template_context! { 203 + handle_error => true, 204 + handle_input, 205 + }}, 206 + err 207 + ); 208 + } 209 + }; 210 + 211 + if let Some(subject) = validated_subject { 212 + let did_document = match identity_resolver.resolve(&subject).await { 213 + Ok(value) => value, 214 + Err(err) => { 215 + return contextual_error!( 216 + web_context, 217 + language, 218 + render_template, 219 + template_context! { ..default_context, ..template_context! { 220 + handle_error => true, 221 + handle_input => subject, 222 + }}, 223 + err 224 + ); 225 + } 226 + }; 227 + 228 + let mut lookup_values: Vec<&str> = vec![&did_document.id, &subject]; 229 + if let Some(pds) = did_document.pds_endpoints().first() { 230 + lookup_values.push(pds); 231 + } 232 + 233 + let handle_denied = match denylist_exists(&web_context.pool, &lookup_values).await { 234 + Ok(value) => value, 235 + Err(err) => { 236 + return contextual_error!( 237 + web_context, 238 + language, 239 + error_template, 240 + default_context, 241 + err 242 + ); 243 + } 244 + }; 245 + 246 + if handle_denied { 247 + return contextual_error!( 248 + web_context, 249 + language, 250 + render_template, 251 + template_context! { ..default_context, ..template_context! { 252 + handle_error => true, 253 + handle_input => subject, 254 + }}, 255 + "access-denied" 256 + ); 257 + } 258 + 259 + let pds = match did_document.pds_endpoints().first().cloned() { 260 + Some(value) => value, 261 + None => { 262 + return contextual_error!( 263 + web_context, 264 + language, 265 + render_template, 266 + template_context! { ..default_context, ..template_context! { 267 + handle_error => true, 268 + handle_input => subject, 269 + }}, 270 + LoginError::NoPDS 271 + ); 272 + } 273 + }; 274 + 275 + let primary_handle = match did_document.handles() { 276 + Some(value) => value, 277 + None => { 278 + return contextual_error!( 279 + web_context, 280 + language, 281 + render_template, 282 + template_context! { ..default_context, ..template_context! { 283 + handle_error => true, 284 + handle_input => subject, 285 + }}, 286 + LoginError::NoHandle 287 + ); 288 + } 289 + }; 290 + 291 + if let Err(err) = handle_warm_up( 292 + &web_context.pool, 293 + &did_document.id, 294 + primary_handle, 295 + pds, 296 + None, 297 + ) 298 + .await 299 + .map(|_is_new_user| ()) 300 + { 301 + return contextual_error!(web_context, language, error_template, default_context, err); 302 + } 303 + 304 + let state: String = rand::rng() 305 + .sample_iter(&Alphanumeric) 306 + .take(30) 307 + .map(char::from) 308 + .collect(); 309 + let nonce: String = rand::rng() 310 + .sample_iter(&Alphanumeric) 311 + .take(30) 312 + .map(char::from) 313 + .collect(); 314 + let (pkce_verifier, code_challenge) = generate(); 315 + 316 + let oauth_request_state = OAuthRequestState { 317 + state, 318 + nonce, 319 + code_challenge, 320 + scope: web_context.config.oauth_scope(), 321 + }; 322 + 323 + let authorization_server = match pds_resources(&web_context.http_client, pds).await { 324 + Ok(value) => value.1, 325 + Err(err) => { 326 + return contextual_error!( 327 + web_context, 328 + language, 329 + error_template, 330 + default_context, 331 + err 332 + ); 333 + } 334 + }; 335 + 336 + let (public_signing_key, private_signing_key_data) = 337 + match web_context.config.select_oauth_signing_key() { 338 + Ok(keys) => keys, 339 + Err(err) => { 340 + return contextual_error!( 341 + web_context, 342 + language, 343 + error_template, 344 + default_context, 345 + err 346 + ); 347 + } 348 + }; 349 + 350 + let private_dpop_key_data = match generate_key(KeyType::P256Private) { 351 + Ok(value) => value, 352 + Err(err) => { 353 + return contextual_error!( 354 + web_context, 355 + language, 356 + error_template, 357 + default_context, 358 + err 359 + ); 360 + } 361 + }; 362 + 363 + let private_dpop_key = private_dpop_key_data.to_string(); 364 + 365 + let oauth_client = OAuthClient { 366 + redirect_uri: format!( 367 + "https://{}/oauth/callback", 368 + &web_context.config.external_base 369 + ), 370 + client_id: format!( 371 + "https://{}/oauth-client-metadata.json", 372 + &web_context.config.external_base 373 + ), 374 + private_signing_key_data, 375 + }; 376 + 377 + let par_response = oauth_init( 378 + &web_context.http_client, 379 + &oauth_client, 380 + &private_dpop_key_data, 381 + Some(primary_handle), 382 + &authorization_server, 383 + &oauth_request_state, 384 + ) 385 + .await; 386 + 387 + if let Err(err) = par_response { 388 + return contextual_error!(web_context, language, error_template, default_context, err); 389 + } 390 + 391 + let par_response = par_response.unwrap(); 392 + 393 + // Store the DID document 394 + if let Err(err) = web_context 395 + .document_storage 396 + .store_document(did_document.clone()) 397 + .await 398 + { 399 + return contextual_error!(web_context, language, error_template, default_context, err); 400 + } 401 + 402 + let created_at = chrono::Utc::now(); 403 + let expires_at = created_at + chrono::Duration::seconds(par_response.expires_in as i64); 404 + 405 + let oauth_request = OAuthRequest { 406 + oauth_state: oauth_request_state.state.clone(), 407 + issuer: authorization_server.issuer.clone(), 408 + authorization_server: authorization_server.issuer.clone(), 409 + nonce: oauth_request_state.nonce.clone(), 410 + pkce_verifier: pkce_verifier.clone(), 411 + signing_public_key: public_signing_key, 412 + dpop_private_key: private_dpop_key, 413 + created_at, 414 + expires_at, 415 + }; 416 + 417 + if let Err(err) = web_context 418 + .oauth_storage 419 + .insert_oauth_request(oauth_request) 420 + .await 421 + { 422 + return contextual_error!(web_context, language, error_template, default_context, err); 423 + } 424 + 425 + // Store destination if provided and not "/" 426 + if let Some(ref dest) = destination 427 + && dest != "/" 428 + { 429 + let postgres_storage = 430 + crate::storage::atproto::PostgresOAuthRequestStorage::new(web_context.pool.clone()); 431 + if let Err(err) = postgres_storage 432 + .set_destination(&oauth_request_state.state, dest) 433 + .await 434 + { 435 + tracing::error!(?err, "set_destination"); 436 + // Don't fail the login flow if we can't store the destination 437 + } 438 + } 439 + 440 + let oauth_args = [ 441 + ( 442 + "request_uri".to_string(), 443 + urlencoding::encode(&par_response.request_uri).to_string(), 444 + ), 445 + ( 446 + "client_id".to_string(), 447 + urlencoding::encode(&format!( 448 + "https://{}/oauth-client-metadata.json", 449 + web_context.config.external_base 450 + )) 451 + .to_string(), 452 + ), 453 + ]; 454 + let oauth_args = oauth_args.iter().map(|(k, v)| (&**k, &**v)).collect(); 455 + 456 + let destination = format!( 457 + "{}?{}", 458 + authorization_server.authorization_endpoint, 459 + stringify(oauth_args) 460 + ); 461 + 462 + let hx_redirect = HxRedirect::from(destination.as_str()); 463 + return Ok((StatusCode::OK, hx_redirect, "").into_response()); 464 + } 465 + 466 + Ok(RenderHtml( 467 + &render_template, 468 + web_context.engine.clone(), 469 + template_context! { ..default_context, ..template_context! { 470 + destination => query_params.destination, 471 + }}, 472 + ) 473 + .into_response()) 474 + } 475 + 476 + // ============================================================================ 477 + // OAuth Callback 478 + // ============================================================================ 479 + 480 + #[derive(Deserialize, Serialize)] 481 + pub(crate) struct OAuthCallbackForm { 482 + state: Option<String>, 483 + iss: Option<String>, 484 + code: Option<String>, 485 + } 486 + 487 + /// GET /oauth/callback - Complete OAuth flow and set session cookie. 488 + pub(crate) async fn handle_auth_callback( 489 + State(web_context): State<WebContext>, 490 + key_provider: State<Arc<dyn KeyResolver>>, 491 + identity_resolver: State<Arc<dyn IdentityResolver>>, 492 + Language(language): Language, 493 + jar: PrivateCookieJar, 494 + Form(callback_form): Form<OAuthCallbackForm>, 495 + ) -> Result<impl IntoResponse, WebError> { 496 + let default_context = template_context! { 497 + language => language.to_string(), 498 + canonical_url => format!("https://{}/oauth/callback", web_context.config.external_base), 499 + }; 500 + 501 + let error_template = select_template!(false, false, language); 502 + 503 + let (callback_code, callback_iss, callback_state) = 504 + match (callback_form.code, callback_form.iss, callback_form.state) { 505 + (Some(x), Some(y), Some(z)) => (x, y, z), 506 + _ => { 507 + return contextual_error!( 508 + web_context, 509 + language, 510 + error_template, 511 + default_context, 512 + LoginError::OAuthCallbackIncomplete 513 + ); 514 + } 515 + }; 516 + 517 + let oauth_request = web_context 518 + .oauth_storage 519 + .get_oauth_request_by_state(&callback_state) 520 + .await; 521 + 522 + let oauth_request = match oauth_request { 523 + Err(err) => { 524 + return contextual_error!(web_context, language, error_template, default_context, err); 525 + } 526 + Ok(None) => { 527 + return contextual_error!( 528 + web_context, 529 + language, 530 + error_template, 531 + default_context, 532 + LoginError::OAuthRequestNotFound 533 + ); 534 + } 535 + Ok(Some(value)) => value, 536 + }; 537 + 538 + if oauth_request.issuer != callback_iss { 539 + return contextual_error!( 540 + web_context, 541 + language, 542 + error_template, 543 + default_context, 544 + LoginError::OAuthIssuerMismatch 545 + ); 546 + } 547 + 548 + let authorization_server = match oauth_authorization_server( 549 + &web_context.http_client, 550 + &oauth_request.authorization_server, 551 + ) 552 + .await 553 + { 554 + Ok(value) => value, 555 + Err(err) => { 556 + return contextual_error!(web_context, language, error_template, default_context, err); 557 + } 558 + }; 559 + 560 + let secret_signing_key = key_provider 561 + .0 562 + .resolve(&oauth_request.signing_public_key) 563 + .await; 564 + 565 + let secret_key_data = match secret_signing_key { 566 + Ok(value) => value, 567 + Err(err) => { 568 + return contextual_error!(web_context, language, error_template, default_context, err); 569 + } 570 + }; 571 + 572 + let dpop_key_data = match identify_key(&oauth_request.dpop_private_key) { 573 + Ok(value) => value, 574 + Err(err) => { 575 + return contextual_error!(web_context, language, error_template, default_context, err); 576 + } 577 + }; 578 + 579 + let oauth_client = OAuthClient { 580 + redirect_uri: format!( 581 + "https://{}/oauth/callback", 582 + &web_context.config.external_base 583 + ), 584 + client_id: format!( 585 + "https://{}/oauth-client-metadata.json", 586 + &web_context.config.external_base 587 + ), 588 + private_signing_key_data: secret_key_data, 589 + }; 590 + 591 + let token_response = oauth_complete( 592 + &web_context.http_client, 593 + &oauth_client, 594 + &dpop_key_data, 595 + &callback_code, 596 + &oauth_request, 597 + &authorization_server, 598 + ) 599 + .await; 600 + if let Err(err) = token_response { 601 + return contextual_error!(web_context, language, error_template, default_context, err); 602 + } 603 + 604 + let token_response = token_response.unwrap(); 605 + 606 + // Retrieve destination from OAuth request before deleting it 607 + let postgres_storage = 608 + crate::storage::atproto::PostgresOAuthRequestStorage::new(web_context.pool.clone()); 609 + let destination = match postgres_storage.get_destination(&callback_state).await { 610 + Ok(Some(dest)) => dest, 611 + Ok(None) => "/".to_string(), 612 + Err(err) => { 613 + tracing::error!(?err, "Failed to get destination"); 614 + "/".to_string() 615 + } 616 + }; 617 + 618 + if let Err(err) = web_context 619 + .oauth_storage 620 + .delete_oauth_request_by_state(&callback_state) 621 + .await 622 + { 623 + tracing::error!(error = ?err, "Unable to remove oauth_request"); 624 + } 625 + 626 + let did = token_response.sub.clone().unwrap(); 627 + 628 + // Resolve DID to get handle and PDS endpoint 629 + let document = match identity_resolver.resolve(&did).await { 630 + Ok(value) => value, 631 + Err(err) => { 632 + return contextual_error!(web_context, language, error_template, default_context, err); 633 + } 634 + }; 635 + 636 + let handle = match document 637 + .handles() 638 + .ok_or(WebError::Login(LoginError::NoHandle)) 639 + { 640 + Ok(value) => value, 641 + Err(err) => { 642 + tracing::error!(?err, "handles"); 643 + return contextual_error!(web_context, language, error_template, default_context, err); 644 + } 645 + }; 646 + 647 + let pds = match document 648 + .pds_endpoints() 649 + .first() 650 + .cloned() 651 + .ok_or(WebError::Login(LoginError::NoPDS)) 652 + { 653 + Ok(value) => value, 654 + Err(err) => { 655 + tracing::error!(?err, "pds_endpoints first"); 656 + return contextual_error!(web_context, language, error_template, default_context, err); 657 + } 658 + }; 659 + 660 + // Store the DID document 661 + if let Err(err) = web_context 662 + .document_storage 663 + .store_document(document.clone()) 664 + .await 665 + { 666 + tracing::error!(?err, "store_document"); 667 + return contextual_error!(web_context, language, error_template, default_context, err); 668 + } 669 + 670 + // Insert the handle if it doesn't exist 671 + let is_new_user = match handle_warm_up( 672 + &web_context.pool, 673 + &document.id, 674 + handle, 675 + pds, 676 + None, // PDS OAuth doesn't provide email 677 + ) 678 + .await 679 + { 680 + Ok(is_new) => is_new, 681 + Err(err) => { 682 + tracing::error!(?err, "handle_warm_up"); 683 + return contextual_error!(web_context, language, error_template, default_context, err); 684 + } 685 + }; 686 + 687 + // Register new user's DID with TAP for event streaming 688 + if is_new_user && web_context.config.enable_tap { 689 + let tap_client = TapClient::new( 690 + &web_context.config.tap_hostname, 691 + web_context.config.tap_password.clone(), 692 + ); 693 + if let Err(err) = tap_client.add_repos(&[&document.id]).await { 694 + // Log the error but don't fail the authentication flow 695 + tracing::warn!( 696 + did = %document.id, 697 + error = %err, 698 + "Failed to register DID with TAP" 699 + ); 700 + } else { 701 + tracing::info!(did = %document.id, "Registered new user DID with TAP"); 702 + } 703 + } 704 + 705 + // Import Bluesky profile for new users 706 + if is_new_user { 707 + // Create DPoP auth from the existing key data and token 708 + let dpop_auth = DPoPAuth { 709 + dpop_private_key_data: dpop_key_data.clone(), 710 + oauth_access_token: token_response.access_token.clone(), 711 + }; 712 + 713 + let facet_limits = FacetLimits::default(); 714 + match import_bluesky_profile( 715 + &web_context.http_client, 716 + &web_context.content_storage, 717 + &web_context.pool, 718 + &identity_resolver, 719 + &dpop_auth, 720 + pds, 721 + &document.id, 722 + handle, 723 + &facet_limits, 724 + ) 725 + .await 726 + { 727 + Ok(true) => { 728 + tracing::info!(did = %document.id, "Successfully imported Bluesky profile"); 729 + } 730 + Ok(false) => { 731 + tracing::debug!(did = %document.id, "Bluesky profile import skipped"); 732 + } 733 + Err(err) => { 734 + // Log but don't fail authentication - user can set up profile manually 735 + tracing::warn!(did = %document.id, error = %err, "Failed to import Bluesky profile"); 736 + } 737 + } 738 + } 739 + 740 + // Calculate token expiration 741 + let expires_in_secs = token_response.expires_in as i64; 742 + let expires_at = Utc::now() + Duration::seconds(expires_in_secs); 743 + 744 + // Create session cookie with tokens stored directly 745 + let session_cookie = SessionCookie { 746 + did: did.clone(), 747 + access_token: token_response.access_token.clone(), 748 + refresh_token: token_response.refresh_token.clone(), 749 + expires_at, 750 + dpop_private_key: oauth_request.dpop_private_key.clone(), 751 + issuer: callback_iss, 752 + }; 753 + 754 + let cookie_value: String = session_cookie.try_into()?; 755 + 756 + let mut cookie = Cookie::new(AUTH_COOKIE_NAME, cookie_value); 757 + cookie.set_domain(web_context.config.external_base.clone()); 758 + cookie.set_path("/"); 759 + cookie.set_http_only(true); 760 + cookie.set_secure(true); 761 + cookie.set_max_age(Some(cookie::time::Duration::days(30))); // Longer expiry since we have refresh tokens 762 + cookie.set_same_site(Some(SameSite::Lax)); 763 + 764 + let updated_jar = jar.add(cookie); 765 + 766 + Ok((updated_jar, Redirect::to(&destination)).into_response()) 767 + } 768 + 769 + // ============================================================================ 770 + // Token Refresh 771 + // ============================================================================ 772 + 773 + /// POST /oauth/refresh - Refresh access token using refresh token. 774 + pub(crate) async fn handle_auth_refresh( 775 + State(web_context): State<WebContext>, 776 + jar: PrivateCookieJar, 777 + ) -> Result<impl IntoResponse, WebError> { 778 + // Get current session from cookie 779 + let session = jar 780 + .get(AUTH_COOKIE_NAME) 781 + .map(|cookie| cookie.value().to_owned()) 782 + .and_then(|value| SessionCookie::try_from(value).ok()); 783 + 784 + let session = match session { 785 + Some(s) => s, 786 + None => { 787 + return Ok(( 788 + StatusCode::UNAUTHORIZED, 789 + Json(json!({"error": "No session found"})), 790 + ) 791 + .into_response()); 792 + } 793 + }; 794 + 795 + if !session.expires_within(Duration::seconds(10)) { 796 + return Ok(( 797 + StatusCode::OK, 798 + Json(json!({"success": true, "expires_at": session.expires_at.to_rfc3339()})), 799 + ) 800 + .into_response()); 801 + } 802 + 803 + let refresh_token = match &session.refresh_token { 804 + Some(token) => token.clone(), 805 + None => { 806 + return Ok(( 807 + StatusCode::BAD_REQUEST, 808 + Json(json!({"error": "No refresh token available"})), 809 + ) 810 + .into_response()); 811 + } 812 + }; 813 + 814 + // Resolve user's DID to get their document (required for oauth_refresh) 815 + let document = match web_context.identity_resolver.resolve(&session.did).await { 816 + Ok(doc) => doc, 817 + Err(err) => { 818 + tracing::error!(?err, "Failed to resolve DID document"); 819 + return Ok(( 820 + StatusCode::INTERNAL_SERVER_ERROR, 821 + Json(json!({"error": "Failed to refresh token"})), 822 + ) 823 + .into_response()); 824 + } 825 + }; 826 + 827 + // Get the signing key 828 + let (_, secret_key_data) = match web_context.config.select_oauth_signing_key() { 829 + Ok(keys) => keys, 830 + Err(err) => { 831 + tracing::error!(?err, "Failed to select signing key"); 832 + return Ok(( 833 + StatusCode::INTERNAL_SERVER_ERROR, 834 + Json(json!({"error": "Failed to refresh token"})), 835 + ) 836 + .into_response()); 837 + } 838 + }; 839 + 840 + let dpop_key_data = match identify_key(&session.dpop_private_key) { 841 + Ok(value) => value, 842 + Err(err) => { 843 + tracing::error!(?err, "Failed to identify DPoP key"); 844 + return Ok(( 845 + StatusCode::INTERNAL_SERVER_ERROR, 846 + Json(json!({"error": "Failed to refresh token"})), 847 + ) 848 + .into_response()); 849 + } 850 + }; 851 + 852 + let oauth_client = OAuthClient { 853 + redirect_uri: format!( 854 + "https://{}/oauth/callback", 855 + &web_context.config.external_base 856 + ), 857 + client_id: format!( 858 + "https://{}/oauth-client-metadata.json", 859 + &web_context.config.external_base 860 + ), 861 + private_signing_key_data: secret_key_data, 862 + }; 863 + 864 + // Call the refresh token endpoint 865 + let token_response = atproto_oauth::workflow::oauth_refresh( 866 + &web_context.http_client, 867 + &oauth_client, 868 + &dpop_key_data, 869 + &refresh_token, 870 + &document, 871 + ) 872 + .await; 873 + 874 + let token_response = match token_response { 875 + Ok(response) => response, 876 + Err(err) => { 877 + tracing::error!(?err, "Token refresh failed"); 878 + return Ok(( 879 + StatusCode::UNAUTHORIZED, 880 + Json(json!({"error": "Token refresh failed, please log in again"})), 881 + ) 882 + .into_response()); 883 + } 884 + }; 885 + 886 + // Calculate new expiration 887 + let expires_in_secs = token_response.expires_in as i64; 888 + let expires_at = Utc::now() + Duration::seconds(expires_in_secs); 889 + 890 + // Create updated session cookie 891 + let new_session = SessionCookie { 892 + did: session.did, 893 + access_token: token_response.access_token.clone(), 894 + refresh_token: token_response 895 + .refresh_token 896 + .clone() 897 + .or(session.refresh_token), 898 + expires_at, 899 + dpop_private_key: session.dpop_private_key, 900 + issuer: session.issuer, 901 + }; 902 + 903 + let cookie_value: String = new_session.try_into()?; 904 + 905 + let mut cookie = Cookie::new(AUTH_COOKIE_NAME, cookie_value); 906 + cookie.set_domain(web_context.config.external_base.clone()); 907 + cookie.set_path("/"); 908 + cookie.set_http_only(true); 909 + cookie.set_secure(true); 910 + cookie.set_max_age(Some(cookie::time::Duration::days(30))); 911 + cookie.set_same_site(Some(SameSite::Lax)); 912 + 913 + let updated_jar = jar.add(cookie); 914 + 915 + Ok(( 916 + updated_jar, 917 + Json(json!({"success": true, "expires_at": expires_at.to_rfc3339()})), 918 + ) 919 + .into_response()) 920 + } 921 + 922 + // ============================================================================ 923 + // Logout 924 + // ============================================================================ 925 + 926 + /// POST /oauth/logout - Clear session cookie. 927 + pub(crate) async fn handle_auth_logout( 928 + State(web_context): State<WebContext>, 929 + jar: PrivateCookieJar, 930 + ) -> Result<impl IntoResponse, WebError> { 931 + let mut removal_cookie = Cookie::from(AUTH_COOKIE_NAME); 932 + removal_cookie.set_domain(web_context.config.external_base.clone()); 933 + removal_cookie.set_path("/"); 934 + 935 + let updated_jar = jar.remove(removal_cookie); 936 + 937 + Ok((updated_jar, Redirect::to("/")).into_response()) 938 + }
-367
src/http/handle_oauth_aip_callback.rs
··· 1 - use std::{collections::HashMap, sync::Arc}; 2 - 3 - use crate::{ 4 - atproto::auth::create_dpop_auth_from_aip_session, config::OAuthBackendConfig, contextual_error, 5 - facets::FacetLimits, http::handle_email_confirm::send_confirmation_email, select_template, 6 - storage::identity_profile::handle_warm_up, 7 - }; 8 - use anyhow::Result; 9 - use atproto_client::errors::SimpleError; 10 - use atproto_identity::resolve::IdentityResolver; 11 - use atproto_tap::TapClient; 12 - use axum::{ 13 - extract::State, 14 - response::{IntoResponse, Redirect}, 15 - }; 16 - use axum_extra::extract::{ 17 - Form, PrivateCookieJar, 18 - cookie::{Cookie, SameSite}, 19 - }; 20 - use minijinja::context as template_context; 21 - use serde::{Deserialize, Serialize}; 22 - 23 - use super::{ 24 - context::WebContext, 25 - errors::{LoginError, WebError}, 26 - middleware_auth::{AUTH_COOKIE_NAME, WebSession}, 27 - middleware_i18n::Language, 28 - profile_import::import_bluesky_profile, 29 - }; 30 - 31 - #[derive(Deserialize, Serialize)] 32 - pub(crate) struct OAuthCallbackForm { 33 - pub(crate) state: Option<String>, 34 - pub(crate) code: Option<String>, 35 - } 36 - 37 - pub(crate) async fn handle_oauth_callback( 38 - State(web_context): State<WebContext>, 39 - Language(language): Language, 40 - identity_resolver: State<Arc<dyn IdentityResolver>>, 41 - jar: PrivateCookieJar, 42 - Form(callback_form): Form<OAuthCallbackForm>, 43 - ) -> Result<impl IntoResponse, WebError> { 44 - let default_context = template_context! { 45 - language => language.to_string(), 46 - canonical_url => format!("https://{}/oauth/callback", web_context.config.external_base), 47 - }; 48 - 49 - let error_template = select_template!(false, false, language); 50 - 51 - // Get AIP server configuration - config validation ensures these are set when oauth_backend is AIP 52 - let (hostname, client_id, client_secret) = if let OAuthBackendConfig::AIP { 53 - hostname, 54 - client_id, 55 - client_secret, 56 - } = &web_context.config.oauth_backend 57 - { 58 - (hostname, client_id, client_secret) 59 - } else { 60 - unreachable!("AIP OAuth backend should have AIP configuration") 61 - }; 62 - 63 - let (callback_code, callback_state) = match (callback_form.code, callback_form.state) { 64 - (Some(x), Some(z)) => (x, z), 65 - _ => { 66 - return contextual_error!( 67 - web_context, 68 - language, 69 - error_template, 70 - default_context, 71 - LoginError::OAuthCallbackIncomplete 72 - ); 73 - } 74 - }; 75 - 76 - let oauth_request = match web_context 77 - .oauth_storage 78 - .get_oauth_request_by_state(&callback_state) 79 - .await 80 - { 81 - Err(err) => { 82 - return contextual_error!(web_context, language, error_template, default_context, err); 83 - } 84 - Ok(None) => { 85 - return contextual_error!( 86 - web_context, 87 - language, 88 - error_template, 89 - default_context, 90 - LoginError::OAuthRequestNotFound 91 - ); 92 - } 93 - Ok(Some(value)) => value, 94 - }; 95 - 96 - let authorization_server = match atproto_oauth_aip::resources::oauth_authorization_server( 97 - &web_context.http_client, 98 - hostname, 99 - ) 100 - .await 101 - { 102 - Ok(value) => value, 103 - Err(err) => { 104 - return contextual_error!(web_context, language, error_template, default_context, err); 105 - } 106 - }; 107 - 108 - let oauth_client = atproto_oauth_aip::workflow::OAuthClient { 109 - redirect_uri: format!( 110 - "https://{}/oauth/callback", 111 - &web_context.config.external_base 112 - ), 113 - client_id: client_id.clone(), 114 - client_secret: client_secret.clone(), 115 - }; 116 - 117 - let token_response = atproto_oauth_aip::workflow::oauth_complete( 118 - &web_context.http_client, 119 - &oauth_client, 120 - &authorization_server.token_endpoint, 121 - &callback_code, 122 - &oauth_request, 123 - ) 124 - .await; 125 - 126 - if let Err(err) = token_response { 127 - tracing::error!( 128 - ?err, 129 - "atproto_oauth_aip::workflow::oautoauth_completeh_init" 130 - ); 131 - return contextual_error!(web_context, language, error_template, default_context, err); 132 - } 133 - 134 - let token_response = token_response.unwrap(); 135 - 136 - let (did, maybe_email) = match get_email_from_userinfo( 137 - &web_context.http_client, 138 - hostname, 139 - &token_response.access_token, 140 - ) 141 - .await 142 - { 143 - Ok(value) => value, 144 - Err(err) => { 145 - tracing::error!(error = ?err, "error getting AIP userinfo"); 146 - return contextual_error!(web_context, language, error_template, default_context, err); 147 - } 148 - }; 149 - 150 - let document = match identity_resolver.resolve(&did).await { 151 - Ok(value) => value, 152 - Err(err) => { 153 - return contextual_error!(web_context, language, error_template, default_context, err); 154 - } 155 - }; 156 - 157 - let handle = match document 158 - .handles() 159 - .ok_or(WebError::Login(LoginError::NoHandle)) 160 - { 161 - Ok(value) => value, 162 - Err(err) => { 163 - tracing::error!(?err, "handles"); 164 - return contextual_error!(web_context, language, error_template, default_context, err); 165 - } 166 - }; 167 - 168 - let pds = match document 169 - .pds_endpoints() 170 - .first() 171 - .cloned() 172 - .ok_or(WebError::Login(LoginError::NoPDS)) 173 - { 174 - Ok(value) => value, 175 - Err(err) => { 176 - tracing::error!(?err, "pds_endpoints first"); 177 - return contextual_error!(web_context, language, error_template, default_context, err); 178 - } 179 - }; 180 - 181 - if let Err(err) = web_context 182 - .document_storage 183 - .store_document(document.clone()) 184 - .await 185 - { 186 - tracing::error!(?err, "store_document"); 187 - return contextual_error!(web_context, language, error_template, default_context, err); 188 - } 189 - 190 - // Insert the handle if it doesn't exist 191 - let is_new_user = match handle_warm_up( 192 - &web_context.pool, 193 - &document.id, 194 - handle, 195 - pds, 196 - maybe_email.as_deref(), 197 - ) 198 - .await 199 - { 200 - Ok(is_new) => is_new, 201 - Err(err) => { 202 - tracing::error!(?err, "handle_warm_up"); 203 - return contextual_error!(web_context, language, error_template, default_context, err); 204 - } 205 - }; 206 - 207 - // Send email confirmation for new users with email addresses 208 - if is_new_user 209 - && let Some(ref email) = maybe_email 210 - && let Err(err) = send_confirmation_email(&web_context, &document.id, email).await 211 - { 212 - // Log the error but don't fail the authentication flow 213 - tracing::warn!(?err, "Failed to send confirmation email to new user"); 214 - } 215 - 216 - // Register new user's DID with TAP for event streaming 217 - if is_new_user && web_context.config.enable_tap { 218 - let tap_client = TapClient::new( 219 - &web_context.config.tap_hostname, 220 - web_context.config.tap_password.clone(), 221 - ); 222 - if let Err(err) = tap_client.add_repos(&[&document.id]).await { 223 - // Log the error but don't fail the authentication flow 224 - tracing::warn!( 225 - did = %document.id, 226 - error = %err, 227 - "Failed to register DID with TAP" 228 - ); 229 - } else { 230 - tracing::info!(did = %document.id, "Registered new user DID with TAP"); 231 - } 232 - } 233 - 234 - // Import Bluesky profile for new users 235 - if is_new_user { 236 - // Get DPoP credentials for writing to user's PDS 237 - match create_dpop_auth_from_aip_session( 238 - &web_context.http_client, 239 - hostname, 240 - &token_response.access_token, 241 - ) 242 - .await 243 - { 244 - Ok(dpop_auth) => { 245 - let facet_limits = FacetLimits::default(); 246 - match import_bluesky_profile( 247 - &web_context.http_client, 248 - &web_context.content_storage, 249 - &web_context.pool, 250 - &identity_resolver, 251 - &dpop_auth, 252 - pds, 253 - &document.id, 254 - handle, 255 - &facet_limits, 256 - ) 257 - .await 258 - { 259 - Ok(true) => { 260 - tracing::info!(did = %document.id, "Successfully imported Bluesky profile"); 261 - } 262 - Ok(false) => { 263 - tracing::debug!(did = %document.id, "Bluesky profile import skipped"); 264 - } 265 - Err(err) => { 266 - // Log but don't fail authentication - user can set up profile manually 267 - tracing::warn!(did = %document.id, error = %err, "Failed to import Bluesky profile"); 268 - } 269 - } 270 - } 271 - Err(err) => { 272 - // Log but don't fail authentication 273 - tracing::warn!(did = %document.id, error = %err, "Failed to get DPoP auth for profile import"); 274 - } 275 - } 276 - } 277 - 278 - let cookie_value: String = WebSession::Aip { 279 - did, 280 - access_token: token_response.access_token.clone(), 281 - } 282 - .try_into()?; 283 - 284 - let mut cookie = Cookie::new(AUTH_COOKIE_NAME, cookie_value); 285 - cookie.set_domain(web_context.config.external_base.clone()); 286 - cookie.set_path("/"); 287 - cookie.set_http_only(true); 288 - cookie.set_secure(true); 289 - // Long-lived session cookie (1 year) - token validity is checked lazily 290 - // before AT Protocol operations via the AIP ready check 291 - cookie.set_max_age(Some(cookie::time::Duration::seconds(365 * 24 * 60 * 60))); 292 - cookie.set_same_site(Some(SameSite::Lax)); 293 - 294 - let updated_jar = jar.add(cookie); 295 - 296 - // Retrieve destination from OAuth request before deleting it 297 - let postgres_storage = 298 - crate::storage::atproto::PostgresOAuthRequestStorage::new(web_context.pool.clone()); 299 - let destination = match postgres_storage.get_destination(&callback_state).await { 300 - Ok(Some(dest)) => dest, 301 - Ok(None) => "/".to_string(), 302 - Err(err) => { 303 - tracing::error!(?err, "Failed to get destination"); 304 - "/".to_string() 305 - } 306 - }; 307 - 308 - // Delete the OAuth request now that we're done with it 309 - if let Err(err) = web_context 310 - .oauth_storage 311 - .delete_oauth_request_by_state(&callback_state) 312 - .await 313 - { 314 - tracing::error!(error = ?err, "Unable to remove oauth_request"); 315 - } 316 - 317 - Ok((updated_jar, Redirect::to(destination.as_str())).into_response()) 318 - } 319 - 320 - #[derive(Clone, Deserialize)] 321 - pub struct OpenIDClaims { 322 - pub sub: String, 323 - pub profile: String, 324 - pub did: String, 325 - pub name: String, 326 - pub pds_endpoint: String, 327 - 328 - #[serde(skip_serializing_if = "Option::is_none")] 329 - pub email: Option<String>, 330 - 331 - #[serde(flatten)] 332 - pub additional_claims: HashMap<String, serde_json::Value>, 333 - } 334 - 335 - #[derive(Clone, Deserialize)] 336 - #[serde(untagged)] 337 - pub enum OpenIDClaimsResponse { 338 - OpenIDClaims(OpenIDClaims), 339 - 340 - SimpleError(SimpleError), 341 - } 342 - 343 - async fn get_email_from_userinfo( 344 - http_client: &reqwest::Client, 345 - aip_server: &str, 346 - aip_access_token: &str, 347 - ) -> Result<(String, Option<String>)> { 348 - let userinfo_endpoint = format!("{}/oauth/userinfo", aip_server); 349 - 350 - let response: OpenIDClaimsResponse = http_client 351 - .get(userinfo_endpoint) 352 - .bearer_auth(aip_access_token) 353 - .send() 354 - .await 355 - .map_err(|_| LoginError::AipUserinfoRequestFailed)? 356 - .json() 357 - .await 358 - .map_err(|_| LoginError::AipUserinfoParsingFailed)?; 359 - 360 - match response { 361 - OpenIDClaimsResponse::OpenIDClaims(claims) => Ok((claims.did, claims.email)), 362 - OpenIDClaimsResponse::SimpleError(simple_error) => Err(LoginError::AipServerError { 363 - message: simple_error.error_message(), 364 - } 365 - .into()), 366 - } 367 - }
-277
src/http/handle_oauth_aip_login.rs
··· 1 - use anyhow::Result; 2 - use atproto_oauth::pkce::generate; 3 - use atproto_oauth::workflow::OAuthRequestState as AipOAuthRequestState; 4 - use atproto_oauth_aip::{ 5 - resources::oauth_authorization_server, 6 - workflow::{OAuthClient, oauth_init}, 7 - }; 8 - use axum::response::Redirect; 9 - use axum::{extract::State, response::IntoResponse}; 10 - use axum_extra::extract::{Cached, Form, Query}; 11 - use axum_htmx::{HxBoosted, HxRedirect, HxRequest}; 12 - use axum_template::RenderHtml; 13 - use http::StatusCode; 14 - use minijinja::context as template_context; 15 - use rand::{Rng, distr::Alphanumeric}; 16 - use serde::Deserialize; 17 - 18 - use crate::{ 19 - config::OAuthBackendConfig, 20 - contextual_error, 21 - http::{ 22 - auth_utils::validate_login_input, 23 - context::WebContext, 24 - errors::{LoginError, WebError}, 25 - middleware_auth::Auth, 26 - middleware_i18n::Language, 27 - utils::stringify, 28 - }, 29 - select_template, 30 - }; 31 - 32 - #[derive(Deserialize)] 33 - pub(crate) struct OAuthLoginForm { 34 - handle: Option<String>, 35 - destination: Option<String>, 36 - } 37 - 38 - #[derive(Debug, Deserialize)] 39 - pub(crate) struct LoginQueryParams { 40 - destination: Option<String>, 41 - /// Reason for showing the login page (e.g., "session_expired") 42 - reason: Option<String>, 43 - } 44 - 45 - #[allow(clippy::too_many_arguments)] 46 - pub(crate) async fn handle_oauth_aip_login( 47 - State(web_context): State<WebContext>, 48 - Language(language): Language, 49 - Cached(auth): Cached<Auth>, 50 - HxRequest(hx_request): HxRequest, 51 - HxBoosted(hx_boosted): HxBoosted, 52 - Query(query_params): Query<LoginQueryParams>, 53 - Form(login_form): Form<OAuthLoginForm>, 54 - ) -> Result<impl IntoResponse, WebError> { 55 - // Check if showing session expired message 56 - let session_expired = query_params.reason.as_deref() == Some("session_expired"); 57 - 58 - let default_context = template_context! { 59 - current_handle => auth.profile(), 60 - language => language.to_string(), 61 - canonical_url => format!("https://{}/oauth/login", web_context.config.external_base), 62 - destination => query_params.destination, 63 - session_expired => session_expired, 64 - }; 65 - 66 - let render_template = select_template!("login", hx_boosted, hx_request, language); 67 - let error_template = select_template!(hx_boosted, hx_request, language); 68 - 69 - let validated_subject = match validate_login_input(login_form.handle.as_deref()) { 70 - Ok(subject) => subject, 71 - Err(err) => { 72 - let handle_input = if let LoginError::IncompleteHandle = err { 73 - login_form 74 - .handle 75 - .map(|value| format!("{}.bsky.social", value)) 76 - .unwrap_or_default() 77 - } else { 78 - login_form.handle.unwrap_or_default() 79 - }; 80 - return contextual_error!( 81 - web_context, 82 - language, 83 - render_template, 84 - template_context! { ..default_context, ..template_context! { 85 - handle_error => true, 86 - handle_input, 87 - }}, 88 - err 89 - ); 90 - } 91 - }; 92 - 93 - if let Some(subject) = validated_subject { 94 - // Generate OAuth parameters 95 - let state: String = rand::rng() 96 - .sample_iter(&Alphanumeric) 97 - .take(30) 98 - .map(char::from) 99 - .collect(); 100 - let nonce: String = rand::rng() 101 - .sample_iter(&Alphanumeric) 102 - .take(30) 103 - .map(char::from) 104 - .collect(); 105 - 106 - let (pkce_verifier, code_challenge) = generate(); 107 - 108 - let scope = [ 109 - "account:email", 110 - "atproto", 111 - "blob:image/*", 112 - "email", 113 - "openid", 114 - "profile", 115 - "repo:community.lexicon.calendar.event", 116 - "repo:community.lexicon.calendar.rsvp", 117 - "repo:events.smokesignal.calendar.acceptance", 118 - "repo:events.smokesignal.profile", 119 - "repo:events.smokesignal.lfg", 120 - "rpc:tools.graze.aip.ready?aud=*", 121 - ] 122 - .join(" "); 123 - 124 - // Create AIP-specific OAuth request state with scope 125 - let aip_oauth_request_state = AipOAuthRequestState { 126 - state: state.clone(), 127 - nonce: nonce.clone(), 128 - code_challenge, 129 - scope, 130 - }; 131 - 132 - // Get AIP server configuration - config validation ensures these are set when oauth_backend is AIP 133 - let (hostname, client_id, client_secret) = if let OAuthBackendConfig::AIP { 134 - hostname, 135 - client_id, 136 - client_secret, 137 - } = &web_context.config.oauth_backend 138 - { 139 - (hostname, client_id, client_secret) 140 - } else { 141 - unreachable!("AIP OAuth backend should have AIP configuration") 142 - }; 143 - 144 - // Get AIP authorization server metadata 145 - let authorization_server = 146 - match oauth_authorization_server(&web_context.http_client, hostname).await { 147 - Ok(value) => value, 148 - Err(err) => { 149 - tracing::error!(?err, "oauth_authorization_server"); 150 - return contextual_error!( 151 - web_context, 152 - language, 153 - error_template, 154 - default_context, 155 - err 156 - ); 157 - } 158 - }; 159 - 160 - // Create AIP OAuth client 161 - let oauth_client = OAuthClient { 162 - redirect_uri: format!( 163 - "https://{}/oauth/callback", 164 - web_context.config.external_base 165 - ), 166 - client_id: client_id.clone(), 167 - client_secret: client_secret.clone(), 168 - }; 169 - 170 - // Initialize AIP OAuth flow 171 - let par_response = oauth_init( 172 - &web_context.http_client, 173 - &oauth_client, 174 - Some(&subject), 175 - &authorization_server.pushed_authorization_request_endpoint, 176 - &aip_oauth_request_state, 177 - ) 178 - .await; 179 - 180 - if let Err(err) = par_response { 181 - // Check if this is an invalid handle format error 182 - let err_string = err.to_string(); 183 - if err_string.contains("Invalid handle format") 184 - || err_string.contains("error-aip-oauth-8") 185 - { 186 - tracing::warn!("encountered error, error: {}", err); 187 - return Ok(RenderHtml( 188 - &render_template, 189 - web_context.engine.clone(), 190 - template_context! { ..default_context, ..template_context! { 191 - handle_error => true, 192 - message => "The handle you entered is invalid. Please enter a valid AT Protocol handle (e.g., user.bsky.social).", 193 - handle_input => subject, 194 - }}, 195 - ) 196 - .into_response()); 197 - } 198 - 199 - tracing::warn!("encountered error, error: {}", err); 200 - return contextual_error!(web_context, language, error_template, default_context, err); 201 - } 202 - 203 - let par_response = par_response.unwrap(); 204 - 205 - let created_at = chrono::Utc::now(); 206 - let expires_at = created_at + chrono::Duration::seconds(par_response.expires_in as i64); 207 - 208 - let oauth_request = atproto_oauth::workflow::OAuthRequest { 209 - oauth_state: state.clone(), 210 - nonce: nonce.clone(), 211 - pkce_verifier: pkce_verifier.clone(), 212 - 213 - issuer: authorization_server.issuer.clone(), 214 - authorization_server: authorization_server.issuer.clone(), 215 - 216 - signing_public_key: "".to_string(), 217 - dpop_private_key: "".to_string(), 218 - created_at, 219 - expires_at, 220 - }; 221 - 222 - if let Err(err) = web_context 223 - .oauth_storage 224 - .insert_oauth_request(oauth_request) 225 - .await 226 - { 227 - tracing::error!(?err, "insert_oauth_request"); 228 - return contextual_error!(web_context, language, error_template, default_context, err); 229 - } 230 - 231 - if let Some(ref dest) = login_form.destination 232 - && dest != "/" 233 - { 234 - // Create a direct instance to access the set_destination method 235 - let postgres_storage = 236 - crate::storage::atproto::PostgresOAuthRequestStorage::new(web_context.pool.clone()); 237 - if let Err(err) = postgres_storage.set_destination(&state, dest).await { 238 - tracing::error!(?err, "set_destination"); 239 - // Don't fail the login flow if we can't store the destination 240 - } 241 - } 242 - 243 - let oauth_args = [ 244 - ( 245 - "request_uri".to_string(), 246 - urlencoding::encode(&par_response.request_uri).to_string(), 247 - ), 248 - ( 249 - "client_id".to_string(), 250 - urlencoding::encode(client_id).to_string(), 251 - ), 252 - ]; 253 - let oauth_args = oauth_args.iter().map(|(k, v)| (&**k, &**v)).collect(); 254 - 255 - let destination = format!( 256 - "{}?{}", 257 - authorization_server.authorization_endpoint, 258 - stringify(oauth_args) 259 - ); 260 - 261 - if hx_request { 262 - let hx_redirect = HxRedirect::from(destination.as_str()); 263 - return Ok((StatusCode::OK, hx_redirect, "").into_response()); 264 - } 265 - 266 - return Ok(Redirect::temporary(destination.as_str()).into_response()); 267 - } 268 - 269 - Ok(RenderHtml( 270 - &render_template, 271 - web_context.engine.clone(), 272 - template_context! { ..default_context, ..template_context! { 273 - destination => query_params.destination, 274 - }}, 275 - ) 276 - .into_response()) 277 - }
-314
src/http/handle_oauth_callback.rs
··· 1 - use std::sync::Arc; 2 - 3 - use anyhow::Result; 4 - use atproto_client::client::DPoPAuth; 5 - use atproto_identity::key::identify_key; 6 - use atproto_identity::resolve::IdentityResolver; 7 - use atproto_identity::traits::KeyResolver; 8 - use atproto_oauth::{ 9 - resources::oauth_authorization_server, 10 - workflow::{OAuthClient, oauth_complete}, 11 - }; 12 - use atproto_tap::TapClient; 13 - use axum::{ 14 - extract::State, 15 - response::{IntoResponse, Redirect}, 16 - }; 17 - use axum_extra::extract::{ 18 - Form, PrivateCookieJar, 19 - cookie::{Cookie, SameSite}, 20 - }; 21 - use minijinja::context as template_context; 22 - use serde::{Deserialize, Serialize}; 23 - 24 - use crate::{ 25 - contextual_error, facets::FacetLimits, select_template, 26 - storage::identity_profile::handle_warm_up, 27 - }; 28 - 29 - use super::{ 30 - context::WebContext, 31 - errors::{LoginError, WebError}, 32 - middleware_auth::{AUTH_COOKIE_NAME, WebSession}, 33 - middleware_i18n::Language, 34 - profile_import::import_bluesky_profile, 35 - }; 36 - 37 - #[derive(Deserialize, Serialize)] 38 - pub(crate) struct OAuthCallbackForm { 39 - state: Option<String>, 40 - iss: Option<String>, 41 - code: Option<String>, 42 - } 43 - 44 - pub(crate) async fn handle_oauth_callback( 45 - State(web_context): State<WebContext>, 46 - key_provider: State<Arc<dyn KeyResolver>>, 47 - identity_resolver: State<Arc<dyn IdentityResolver>>, 48 - Language(language): Language, 49 - jar: PrivateCookieJar, 50 - Form(callback_form): Form<OAuthCallbackForm>, 51 - ) -> Result<impl IntoResponse, WebError> { 52 - let default_context = template_context! { 53 - language => language.to_string(), 54 - canonical_url => format!("https://{}/oauth/callback", web_context.config.external_base), 55 - }; 56 - 57 - let error_template = select_template!(false, false, language); 58 - 59 - let (callback_code, callback_iss, callback_state) = 60 - match (callback_form.code, callback_form.iss, callback_form.state) { 61 - (Some(x), Some(y), Some(z)) => (x, y, z), 62 - _ => { 63 - return contextual_error!( 64 - web_context, 65 - language, 66 - error_template, 67 - default_context, 68 - LoginError::OAuthCallbackIncomplete 69 - ); 70 - } 71 - }; 72 - 73 - let oauth_request = web_context 74 - .oauth_storage 75 - .get_oauth_request_by_state(&callback_state) 76 - .await; 77 - 78 - let oauth_request = match oauth_request { 79 - Err(err) => { 80 - return contextual_error!(web_context, language, error_template, default_context, err); 81 - } 82 - Ok(None) => { 83 - return contextual_error!( 84 - web_context, 85 - language, 86 - error_template, 87 - default_context, 88 - LoginError::OAuthRequestNotFound 89 - ); 90 - } 91 - Ok(Some(value)) => value, 92 - }; 93 - 94 - if oauth_request.issuer != callback_iss { 95 - return contextual_error!( 96 - web_context, 97 - language, 98 - error_template, 99 - default_context, 100 - LoginError::OAuthIssuerMismatch 101 - ); 102 - } 103 - 104 - let authorization_server = match oauth_authorization_server( 105 - &web_context.http_client, 106 - &oauth_request.authorization_server, 107 - ) 108 - .await 109 - { 110 - Ok(value) => value, 111 - Err(err) => { 112 - return contextual_error!(web_context, language, error_template, default_context, err); 113 - } 114 - }; 115 - 116 - let secret_signing_key = key_provider 117 - .0 118 - .resolve(&oauth_request.signing_public_key) 119 - .await; 120 - 121 - let secret_key_data = match secret_signing_key { 122 - Ok(value) => value, 123 - Err(err) => { 124 - return contextual_error!(web_context, language, error_template, default_context, err); 125 - } 126 - }; 127 - 128 - let dpop_key_data = match identify_key(&oauth_request.dpop_private_key) { 129 - Ok(value) => value, 130 - Err(err) => { 131 - return contextual_error!(web_context, language, error_template, default_context, err); 132 - } 133 - }; 134 - 135 - let oauth_client = OAuthClient { 136 - redirect_uri: format!( 137 - "https://{}/oauth/callback", 138 - &web_context.config.external_base 139 - ), 140 - client_id: format!( 141 - "https://{}/oauth/client-metadata.json", 142 - &web_context.config.external_base 143 - ), 144 - private_signing_key_data: secret_key_data, 145 - }; 146 - 147 - let token_response = oauth_complete( 148 - &web_context.http_client, 149 - &oauth_client, 150 - &dpop_key_data, 151 - &callback_code, 152 - &oauth_request, 153 - &authorization_server, 154 - ) 155 - .await; 156 - if let Err(err) = token_response { 157 - return contextual_error!(web_context, language, error_template, default_context, err); 158 - } 159 - 160 - let token_response = token_response.unwrap(); 161 - 162 - // Retrieve destination from OAuth request before deleting it 163 - let postgres_storage = 164 - crate::storage::atproto::PostgresOAuthRequestStorage::new(web_context.pool.clone()); 165 - let destination = match postgres_storage.get_destination(&callback_state).await { 166 - Ok(Some(dest)) => dest, 167 - Ok(None) => "/".to_string(), 168 - Err(err) => { 169 - tracing::error!(?err, "Failed to get destination"); 170 - "/".to_string() 171 - } 172 - }; 173 - 174 - if let Err(err) = web_context 175 - .oauth_storage 176 - .delete_oauth_request_by_state(&callback_state) 177 - .await 178 - { 179 - tracing::error!(error = ?err, "Unable to remove oauth_request"); 180 - } 181 - 182 - let did = token_response.sub.clone().unwrap(); 183 - 184 - // Resolve DID to get handle and PDS endpoint 185 - let document = match identity_resolver.resolve(&did).await { 186 - Ok(value) => value, 187 - Err(err) => { 188 - return contextual_error!(web_context, language, error_template, default_context, err); 189 - } 190 - }; 191 - 192 - let handle = match document 193 - .handles() 194 - .ok_or(WebError::Login(LoginError::NoHandle)) 195 - { 196 - Ok(value) => value, 197 - Err(err) => { 198 - tracing::error!(?err, "handles"); 199 - return contextual_error!(web_context, language, error_template, default_context, err); 200 - } 201 - }; 202 - 203 - let pds = match document 204 - .pds_endpoints() 205 - .first() 206 - .cloned() 207 - .ok_or(WebError::Login(LoginError::NoPDS)) 208 - { 209 - Ok(value) => value, 210 - Err(err) => { 211 - tracing::error!(?err, "pds_endpoints first"); 212 - return contextual_error!(web_context, language, error_template, default_context, err); 213 - } 214 - }; 215 - 216 - // Store the DID document 217 - if let Err(err) = web_context 218 - .document_storage 219 - .store_document(document.clone()) 220 - .await 221 - { 222 - tracing::error!(?err, "store_document"); 223 - return contextual_error!(web_context, language, error_template, default_context, err); 224 - } 225 - 226 - // Insert the handle if it doesn't exist 227 - let is_new_user = match handle_warm_up( 228 - &web_context.pool, 229 - &document.id, 230 - handle, 231 - pds, 232 - None, // PDS OAuth doesn't provide email 233 - ) 234 - .await 235 - { 236 - Ok(is_new) => is_new, 237 - Err(err) => { 238 - tracing::error!(?err, "handle_warm_up"); 239 - return contextual_error!(web_context, language, error_template, default_context, err); 240 - } 241 - }; 242 - 243 - // Register new user's DID with TAP for event streaming 244 - if is_new_user && web_context.config.enable_tap { 245 - let tap_client = TapClient::new( 246 - &web_context.config.tap_hostname, 247 - web_context.config.tap_password.clone(), 248 - ); 249 - if let Err(err) = tap_client.add_repos(&[&document.id]).await { 250 - // Log the error but don't fail the authentication flow 251 - tracing::warn!( 252 - did = %document.id, 253 - error = %err, 254 - "Failed to register DID with TAP" 255 - ); 256 - } else { 257 - tracing::info!(did = %document.id, "Registered new user DID with TAP"); 258 - } 259 - } 260 - 261 - // Import Bluesky profile for new users 262 - if is_new_user { 263 - // Create DPoP auth from the existing key data and token 264 - let dpop_auth = DPoPAuth { 265 - dpop_private_key_data: dpop_key_data.clone(), 266 - oauth_access_token: token_response.access_token.clone(), 267 - }; 268 - 269 - let facet_limits = FacetLimits::default(); 270 - match import_bluesky_profile( 271 - &web_context.http_client, 272 - &web_context.content_storage, 273 - &web_context.pool, 274 - &identity_resolver, 275 - &dpop_auth, 276 - pds, 277 - &document.id, 278 - handle, 279 - &facet_limits, 280 - ) 281 - .await 282 - { 283 - Ok(true) => { 284 - tracing::info!(did = %document.id, "Successfully imported Bluesky profile"); 285 - } 286 - Ok(false) => { 287 - tracing::debug!(did = %document.id, "Bluesky profile import skipped"); 288 - } 289 - Err(err) => { 290 - // Log but don't fail authentication - user can set up profile manually 291 - tracing::warn!(did = %document.id, error = %err, "Failed to import Bluesky profile"); 292 - } 293 - } 294 - } 295 - 296 - // For standard OAuth, create a PDS session 297 - let cookie_value: String = WebSession::Pds { 298 - did: did.clone(), 299 - session_group: "".to_string(), // Simplified for initial pass 300 - } 301 - .try_into()?; 302 - 303 - let mut cookie = Cookie::new(AUTH_COOKIE_NAME, cookie_value); 304 - cookie.set_domain(web_context.config.external_base.clone()); 305 - cookie.set_path("/"); 306 - cookie.set_http_only(true); 307 - cookie.set_secure(true); 308 - cookie.set_max_age(Some(cookie::time::Duration::days(1))); 309 - cookie.set_same_site(Some(SameSite::Lax)); 310 - 311 - let updated_jar = jar.add(cookie); 312 - 313 - Ok((updated_jar, Redirect::to(&destination)).into_response()) 314 - }
-368
src/http/handle_oauth_login.rs
··· 1 - use std::sync::Arc; 2 - 3 - use anyhow::Result; 4 - use atproto_identity::{ 5 - key::{KeyType, generate_key, identify_key}, 6 - resolve::IdentityResolver, 7 - }; 8 - use atproto_oauth::{ 9 - pkce::generate, 10 - resources::pds_resources, 11 - workflow::{OAuthClient, OAuthRequest, OAuthRequestState, oauth_init}, 12 - }; 13 - use axum::{extract::State, response::IntoResponse}; 14 - use axum_extra::extract::{Cached, Form, Query}; 15 - use axum_htmx::{HxBoosted, HxRedirect, HxRequest}; 16 - use axum_template::RenderHtml; 17 - use http::StatusCode; 18 - use minijinja::context as template_context; 19 - use rand::{Rng, distr::Alphanumeric}; 20 - use serde::Deserialize; 21 - 22 - use crate::{ 23 - contextual_error, 24 - http::{ 25 - auth_utils::validate_login_input, 26 - context::WebContext, 27 - errors::{LoginError, WebError}, 28 - middleware_auth::Auth, 29 - middleware_i18n::Language, 30 - utils::stringify, 31 - }, 32 - select_template, 33 - storage::{denylist::denylist_exists, identity_profile::handle_warm_up}, 34 - }; 35 - 36 - #[derive(Deserialize)] 37 - pub(crate) struct OAuthLoginForm { 38 - handle: Option<String>, 39 - } 40 - 41 - #[derive(Deserialize)] 42 - pub(crate) struct LoginQueryParams { 43 - destination: Option<String>, 44 - /// Reason for showing the login page (e.g., "session_expired") 45 - reason: Option<String>, 46 - } 47 - 48 - #[allow(clippy::too_many_arguments)] 49 - pub(crate) async fn handle_oauth_login( 50 - State(web_context): State<WebContext>, 51 - identity_resolver: State<Arc<dyn IdentityResolver>>, 52 - Language(language): Language, 53 - Cached(auth): Cached<Auth>, 54 - HxRequest(hx_request): HxRequest, 55 - HxBoosted(hx_boosted): HxBoosted, 56 - Query(query_params): Query<LoginQueryParams>, 57 - Form(login_form): Form<OAuthLoginForm>, 58 - ) -> Result<impl IntoResponse, WebError> { 59 - // Check if showing session expired message 60 - let session_expired = query_params.reason.as_deref() == Some("session_expired"); 61 - 62 - let default_context = template_context! { 63 - current_handle => auth.profile(), 64 - language => language.to_string(), 65 - canonical_url => format!("https://{}/oauth/login", web_context.config.external_base), 66 - destination => query_params.destination, 67 - session_expired => session_expired, 68 - }; 69 - 70 - let render_template = select_template!("login", hx_boosted, hx_request, language); 71 - let error_template = select_template!(hx_boosted, hx_request, language); 72 - 73 - let validated_subject = match validate_login_input(login_form.handle.as_deref()) { 74 - Ok(subject) => subject, 75 - Err(err) => { 76 - let handle_input = if let LoginError::IncompleteHandle = err { 77 - login_form 78 - .handle 79 - .map(|value| format!("{}.bsky.social", value)) 80 - .unwrap_or_default() 81 - } else { 82 - login_form.handle.unwrap_or_default() 83 - }; 84 - return contextual_error!( 85 - web_context, 86 - language, 87 - render_template, 88 - template_context! { ..default_context, ..template_context! { 89 - handle_error => true, 90 - handle_input, 91 - }}, 92 - err 93 - ); 94 - } 95 - }; 96 - 97 - if let Some(subject) = validated_subject { 98 - let did_document = match identity_resolver.resolve(&subject).await { 99 - Ok(value) => value, 100 - Err(err) => { 101 - return contextual_error!( 102 - web_context, 103 - language, 104 - render_template, 105 - template_context! { ..default_context, ..template_context! { 106 - handle_error => true, 107 - handle_input => subject, 108 - }}, 109 - err 110 - ); 111 - } 112 - }; 113 - 114 - let mut lookup_values: Vec<&str> = vec![&did_document.id, &subject]; 115 - if let Some(pds) = did_document.pds_endpoints().first() { 116 - lookup_values.push(pds); 117 - } 118 - 119 - let handle_denied = match denylist_exists(&web_context.pool, &lookup_values).await { 120 - Ok(value) => value, 121 - Err(err) => { 122 - return contextual_error!( 123 - web_context, 124 - language, 125 - error_template, 126 - default_context, 127 - err 128 - ); 129 - } 130 - }; 131 - 132 - if handle_denied { 133 - return contextual_error!( 134 - web_context, 135 - language, 136 - render_template, 137 - template_context! { ..default_context, ..template_context! { 138 - handle_error => true, 139 - handle_input => subject, 140 - }}, 141 - "access-denied" 142 - ); 143 - } 144 - 145 - let pds = match did_document.pds_endpoints().first().cloned() { 146 - Some(value) => value, 147 - None => { 148 - return contextual_error!( 149 - web_context, 150 - language, 151 - render_template, 152 - template_context! { ..default_context, ..template_context! { 153 - handle_error => true, 154 - handle_input => subject, 155 - }}, 156 - LoginError::NoPDS 157 - ); 158 - } 159 - }; 160 - 161 - let primary_handle = match did_document.handles() { 162 - Some(value) => value, 163 - None => { 164 - return contextual_error!( 165 - web_context, 166 - language, 167 - render_template, 168 - template_context! { ..default_context, ..template_context! { 169 - handle_error => true, 170 - handle_input => subject, 171 - }}, 172 - LoginError::NoHandle 173 - ); 174 - } 175 - }; 176 - 177 - if let Err(err) = handle_warm_up( 178 - &web_context.pool, 179 - &did_document.id, 180 - primary_handle, 181 - pds, 182 - None, 183 - ) 184 - .await 185 - .map(|_is_new_user| ()) 186 - { 187 - return contextual_error!(web_context, language, error_template, default_context, err); 188 - } 189 - 190 - let state: String = rand::rng() 191 - .sample_iter(&Alphanumeric) 192 - .take(30) 193 - .map(char::from) 194 - .collect(); 195 - let nonce: String = rand::rng() 196 - .sample_iter(&Alphanumeric) 197 - .take(30) 198 - .map(char::from) 199 - .collect(); 200 - let (pkce_verifier, code_challenge) = generate(); 201 - 202 - let oauth_request_state = OAuthRequestState { 203 - state, 204 - nonce, 205 - code_challenge, 206 - scope: "atproto transition:generic transition:email".to_string(), 207 - }; 208 - 209 - let authorization_server = match pds_resources(&web_context.http_client, pds).await { 210 - Ok(value) => value.1, 211 - Err(err) => { 212 - return contextual_error!( 213 - web_context, 214 - language, 215 - error_template, 216 - default_context, 217 - err 218 - ); 219 - } 220 - }; 221 - 222 - let signing_key_selection = web_context.config.select_oauth_signing_key(); 223 - if let Err(err) = signing_key_selection { 224 - return contextual_error!(web_context, language, error_template, default_context, err); 225 - } 226 - 227 - let (public_signing_key, private_signing_key) = signing_key_selection.unwrap(); 228 - 229 - // Convert the DID method key string to KeyData using identify_key 230 - let private_signing_key_data = match identify_key(&private_signing_key) { 231 - Ok(key_data) => key_data, 232 - Err(err) => { 233 - return contextual_error!( 234 - web_context, 235 - language, 236 - error_template, 237 - default_context, 238 - err 239 - ); 240 - } 241 - }; 242 - 243 - let private_dpop_key_data = match generate_key(KeyType::P256Private) { 244 - Ok(value) => value, 245 - Err(err) => { 246 - return contextual_error!( 247 - web_context, 248 - language, 249 - error_template, 250 - default_context, 251 - err 252 - ); 253 - } 254 - }; 255 - 256 - let private_dpop_key = private_dpop_key_data.to_string(); 257 - 258 - let oauth_client = OAuthClient { 259 - redirect_uri: format!( 260 - "https://{}/oauth/callback", 261 - &web_context.config.external_base 262 - ), 263 - client_id: format!( 264 - "https://{}/oauth/client-metadata.json", 265 - &web_context.config.external_base 266 - ), 267 - private_signing_key_data, 268 - }; 269 - 270 - let par_response = oauth_init( 271 - &web_context.http_client, 272 - &oauth_client, 273 - &private_dpop_key_data, 274 - Some(primary_handle), 275 - &authorization_server, 276 - &oauth_request_state, 277 - ) 278 - .await; 279 - 280 - if let Err(err) = par_response { 281 - return contextual_error!(web_context, language, error_template, default_context, err); 282 - } 283 - 284 - let par_response = par_response.unwrap(); 285 - 286 - // Store the DID document 287 - if let Err(err) = web_context 288 - .document_storage 289 - .store_document(did_document.clone()) 290 - .await 291 - { 292 - return contextual_error!(web_context, language, error_template, default_context, err); 293 - } 294 - 295 - let created_at = chrono::Utc::now(); 296 - let expires_at = created_at + chrono::Duration::seconds(par_response.expires_in as i64); 297 - 298 - let oauth_request = OAuthRequest { 299 - oauth_state: oauth_request_state.state.clone(), 300 - issuer: authorization_server.issuer.clone(), 301 - authorization_server: authorization_server.issuer.clone(), 302 - nonce: oauth_request_state.nonce.clone(), 303 - pkce_verifier: pkce_verifier.clone(), 304 - signing_public_key: public_signing_key, 305 - dpop_private_key: private_dpop_key, 306 - created_at, 307 - expires_at, 308 - }; 309 - 310 - if let Err(err) = web_context 311 - .oauth_storage 312 - .insert_oauth_request(oauth_request) 313 - .await 314 - { 315 - return contextual_error!(web_context, language, error_template, default_context, err); 316 - } 317 - 318 - // Store destination if provided and not "/" 319 - if let Some(ref dest) = query_params.destination 320 - && dest != "/" 321 - { 322 - // Create a direct instance to access the set_destination method 323 - let postgres_storage = 324 - crate::storage::atproto::PostgresOAuthRequestStorage::new(web_context.pool.clone()); 325 - if let Err(err) = postgres_storage 326 - .set_destination(&oauth_request_state.state, dest) 327 - .await 328 - { 329 - tracing::error!(?err, "set_destination"); 330 - // Don't fail the login flow if we can't store the destination 331 - } 332 - } 333 - 334 - let oauth_args = [ 335 - ( 336 - "request_uri".to_string(), 337 - urlencoding::encode(&par_response.request_uri).to_string(), 338 - ), 339 - ( 340 - "client_id".to_string(), 341 - urlencoding::encode(&format!( 342 - "https://{}/oauth/client-metadata.json", 343 - web_context.config.external_base 344 - )) 345 - .to_string(), 346 - ), 347 - ]; 348 - let oauth_args = oauth_args.iter().map(|(k, v)| (&**k, &**v)).collect(); 349 - 350 - let destination = format!( 351 - "{}?{}", 352 - authorization_server.authorization_endpoint, 353 - stringify(oauth_args) 354 - ); 355 - 356 - let hx_redirect = HxRedirect::from(destination.as_str()); 357 - return Ok((StatusCode::OK, hx_redirect, "").into_response()); 358 - } 359 - 360 - Ok(RenderHtml( 361 - &render_template, 362 - web_context.engine.clone(), 363 - template_context! { ..default_context, ..template_context! { 364 - destination => query_params.destination, 365 - }}, 366 - ) 367 - .into_response()) 368 - }
-22
src/http/handle_oauth_logout.rs
··· 1 - use anyhow::Result; 2 - use axum::extract::State; 3 - use axum::response::{IntoResponse, Redirect}; 4 - use axum_extra::extract::PrivateCookieJar; 5 - use cookie::Cookie; 6 - 7 - use crate::http::{errors::WebError, middleware_auth::AUTH_COOKIE_NAME}; 8 - 9 - use crate::http::context::WebContext; 10 - 11 - pub(crate) async fn handle_logout( 12 - State(web_context): State<WebContext>, 13 - jar: PrivateCookieJar, 14 - ) -> Result<impl IntoResponse, WebError> { 15 - let mut removal_cookie = Cookie::from(AUTH_COOKIE_NAME); 16 - removal_cookie.set_domain(web_context.config.external_base.clone()); 17 - removal_cookie.set_path("/"); 18 - 19 - let updated_jar = jar.remove(removal_cookie); 20 - 21 - Ok((updated_jar, Redirect::to("/")).into_response()) 22 - }
-7
src/http/handle_quick_event.rs
··· 6 6 use axum_template::RenderHtml; 7 7 use minijinja::context as template_context; 8 8 9 - use crate::http::auth_utils::{AipSessionStatus, require_valid_aip_session}; 10 9 use crate::http::context::WebContext; 11 10 use crate::http::errors::WebError; 12 11 use crate::http::middleware_auth::Auth; ··· 21 20 ) -> Result<impl IntoResponse, WebError> { 22 21 // Require authentication for this page 23 22 let current_handle = auth.require("/quick-event")?; 24 - 25 - // Check AIP session validity before displaying quick event form 26 - // This prevents users from filling out forms with stale sessions 27 - if let AipSessionStatus::Stale = require_valid_aip_session(&web_context, &auth).await? { 28 - return Err(WebError::SessionStale("/quick-event".to_string())); 29 - } 30 23 31 24 let render_template = select_template!("quick_event", hx_boosted, false, language); 32 25
+14 -55
src/http/handle_settings.rs
··· 1 - use crate::atproto::auth::{ 2 - create_dpop_auth_from_aip_session, create_dpop_auth_from_oauth_session, 3 - }; 1 + use crate::atproto::auth::create_dpop_auth_from_session; 4 2 use crate::atproto::lexicon::profile::{NSID as ProfileNSID, Profile as ProfileRecord}; 5 - use crate::config::OAuthBackendConfig; 6 3 use anyhow::Result; 7 4 use atproto_client::com::atproto::repo::{PutRecordRequest, PutRecordResponse, put_record}; 8 5 use atproto_identity::resolve::IdentityResolver; ··· 19 16 use crate::{ 20 17 contextual_error, 21 18 http::{ 22 - auth_utils::{AipSessionStatus, require_valid_aip_session}, 23 19 context::WebContext, 24 - errors::WebError, 20 + errors::{CommonError, WebError}, 25 21 middleware_auth::Auth, 26 22 middleware_i18n::Language, 27 23 timezones::supported_timezones, ··· 32 28 identity_profile::{ 33 29 HandleField, handle_for_did, handle_update_field, identity_profile_set_email, 34 30 }, 31 + mcp_configuration::mcp_config_get, 35 32 notification::{ 36 33 notification_get, notification_reset_confirmation, notification_set_preference, 37 34 }, ··· 83 80 // Require authentication 84 81 let current_handle = auth.require("/settings")?; 85 82 86 - // Check AIP session validity before displaying settings form 87 - // This prevents users from filling out forms with stale sessions 88 - if let AipSessionStatus::Stale = require_valid_aip_session(&web_context, &auth).await? { 89 - return Err(WebError::SessionStale("/settings".to_string())); 90 - } 91 - 92 83 let default_context = template_context! { 93 84 current_handle => current_handle.clone(), 94 85 language => language.to_string(), ··· 157 148 denylist_exists(&web_context.pool, &[&current_handle.did]).await? 158 149 }; 159 150 151 + // Get MCP configuration 152 + let mcp_config = mcp_config_get(&web_context.pool, &current_handle.did).await?; 153 + let mcp_allow_dangerous = mcp_config.map(|c| c.allow_dangerous).unwrap_or(false); 154 + 160 155 // Render the form 161 156 Ok(( 162 157 StatusCode::OK, ··· 178 173 email_on_rsvp_summary, 179 174 notification_in_denylist => in_denylist, 180 175 smtp_enabled => web_context.config.smtp_credentials.is_some(), 176 + mcp_allow_dangerous, 181 177 ..default_context, 182 178 }, 183 179 ), ··· 406 402 Form(profile_form): Form<ProfileForm>, 407 403 ) -> Result<impl IntoResponse, WebError> { 408 404 let current_handle = auth.require_flat()?; 405 + let session = auth.session().ok_or(CommonError::NotAuthorized)?; 409 406 410 407 let default_context = template_context! { 411 408 current_handle => current_handle.clone(), ··· 522 519 ); 523 520 } 524 521 525 - // Check AIP session validity before attempting AT Protocol operation 526 - if let AipSessionStatus::Stale = require_valid_aip_session(&web_context, &auth).await? { 527 - return Err(WebError::SessionStale("/settings".to_string())); 528 - } 529 - 530 - // Create DPoP authentication based on backend type 531 - let dpop_auth = match (&auth, &web_context.config.oauth_backend) { 532 - (Auth::Pds { session, .. }, OAuthBackendConfig::ATProtocol { .. }) => { 533 - match create_dpop_auth_from_oauth_session(session) { 534 - Ok(auth) => auth, 535 - Err(err) => { 536 - return contextual_error!( 537 - web_context, 538 - language, 539 - error_template, 540 - default_context, 541 - format!("Failed to create authentication: {}", err) 542 - ); 543 - } 544 - } 545 - } 546 - (Auth::Aip { access_token, .. }, OAuthBackendConfig::AIP { hostname, .. }) => { 547 - match create_dpop_auth_from_aip_session( 548 - &web_context.http_client, 549 - hostname, 550 - access_token, 551 - ) 552 - .await 553 - { 554 - Ok(auth) => auth, 555 - Err(err) => { 556 - return contextual_error!( 557 - web_context, 558 - language, 559 - error_template, 560 - default_context, 561 - format!("Failed to create authentication: {}", err) 562 - ); 563 - } 564 - } 565 - } 566 - _ => { 522 + // Create DPoP authentication from session 523 + let dpop_auth = match create_dpop_auth_from_session(session) { 524 + Ok(auth) => auth, 525 + Err(err) => { 567 526 return contextual_error!( 568 527 web_context, 569 528 language, 570 529 error_template, 571 530 default_context, 572 - "Invalid authentication configuration" 531 + format!("Failed to create authentication: {}", err) 573 532 ); 574 533 } 575 534 };
+5 -30
src/http/handle_unaccept_rsvp.rs
··· 5 5 use serde::Deserialize; 6 6 7 7 use crate::{ 8 - atproto::auth::{create_dpop_auth_from_aip_session, create_dpop_auth_from_oauth_session}, 9 - config::OAuthBackendConfig, 8 + atproto::auth::create_dpop_auth_from_session, 10 9 http::{ 11 10 acceptance_utils::{ 12 11 format_error_html, format_success_html, verify_event_organizer_authorization, 13 12 }, 14 - auth_utils::{AipSessionStatus, require_valid_aip_session}, 15 13 context::WebContext, 16 - errors::WebError, 14 + errors::{CommonError, WebError}, 17 15 middleware_auth::Auth, 18 16 middleware_i18n::Language, 19 17 }, ··· 32 30 Form(form): Form<UnacceptRsvpForm>, 33 31 ) -> Result<impl IntoResponse, WebError> { 34 32 let current_handle = auth.require("/unaccept_rsvp")?; 33 + let session = auth.session().ok_or(CommonError::NotAuthorized)?; 35 34 36 35 // Get the RSVP from storage 37 36 let rsvp = match rsvp_get(&web_context.pool, &form.rsvp_aturi).await { ··· 78 77 } 79 78 }; 80 79 81 - // Check AIP session validity before attempting AT Protocol operation 82 - if let AipSessionStatus::Stale = require_valid_aip_session(&web_context, &auth).await? { 83 - return Err(WebError::SessionStale("/".to_string())); 84 - } 85 - 86 - // Create DPoP auth based on OAuth backend type 87 - let dpop_auth = match (&auth, &web_context.config.oauth_backend) { 88 - (Auth::Pds { session, .. }, OAuthBackendConfig::ATProtocol { .. }) => { 89 - create_dpop_auth_from_oauth_session(session)? 90 - } 91 - (Auth::Aip { access_token, .. }, OAuthBackendConfig::AIP { hostname, .. }) => { 92 - create_dpop_auth_from_aip_session(&web_context.http_client, hostname, access_token) 93 - .await? 94 - } 95 - _ => { 96 - return Ok(( 97 - StatusCode::UNAUTHORIZED, 98 - format_error_html( 99 - "Not authorized", 100 - "You must be logged in to unaccept RSVPs.", 101 - None, 102 - ), 103 - ) 104 - .into_response()); 105 - } 106 - }; 80 + // Create DPoP auth from session 81 + let dpop_auth = create_dpop_auth_from_session(session)?; 107 82 108 83 // Delete the acceptance 109 84 match crate::http::acceptance_operations::delete_acceptance(
+26 -246
src/http/handler_mcp.rs
··· 1 1 use axum::{ 2 2 extract::State, 3 - http::{HeaderMap, StatusCode, header}, 3 + http::{HeaderMap, StatusCode}, 4 4 response::{IntoResponse, Json, Response}, 5 5 }; 6 6 use serde::{Deserialize, Serialize}; 7 7 use serde_json::{Value, json}; 8 8 9 - use crate::aip_auth_cache::AipUserInfo; 10 9 use crate::http::context::WebContext; 11 10 use crate::mcp::tools; 12 11 ··· 44 43 pub(crate) data: Option<Value>, 45 44 } 46 45 47 - /// Extract Bearer token from Authorization header 48 - fn extract_bearer_token(headers: &HeaderMap) -> Option<String> { 49 - let auth_header = headers.get(header::AUTHORIZATION)?.to_str().ok()?; 50 - 51 - if !auth_header.starts_with("Bearer ") { 52 - return None; 53 - } 54 - 55 - Some(auth_header.trim_start_matches("Bearer ").to_string()) 56 - } 57 - 58 - /// Validate Bearer token and return user information 59 - /// 60 - /// Uses the AIP auth cache to validate the token by calling the OAuth userinfo endpoint. 61 - /// Results are cached for performance. 62 - async fn validate_bearer_token( 63 - web_context: &WebContext, 64 - bearer_token: &str, 65 - ) -> Option<AipUserInfo> { 66 - let auth_cache = web_context.aip_auth_cache()?; 67 - 68 - match auth_cache.validate_token(bearer_token).await { 69 - Ok(Some(user_info)) => { 70 - tracing::debug!(sub = %user_info.sub, "Bearer token validated successfully"); 71 - Some(user_info) 72 - } 73 - Ok(None) => { 74 - tracing::debug!("Bearer token validation failed: invalid token"); 75 - None 76 - } 77 - Err(e) => { 78 - tracing::error!(?e, "Error validating Bearer token"); 79 - None 80 - } 81 - } 82 - } 83 - 84 - /// Create 401 Unauthorized response with WWW-Authenticate header 85 - fn unauthorized_response(web_context: &WebContext) -> Response { 86 - let external_base = &web_context.config.external_base; 87 - 88 - let resource_metadata = format!( 89 - "https://{}/.well-known/oauth-protected-resource/mcp", 90 - external_base 91 - ); 92 - 93 - let www_authenticate = format!( 94 - "Bearer resource_metadata=\"{}\", scope=\"openid profile email atproto repo:community.lexicon.calendar.rsvp\"", 95 - resource_metadata 96 - ); 97 - 98 - let mut headers = HeaderMap::new(); 99 - headers.insert(header::WWW_AUTHENTICATE, www_authenticate.parse().unwrap()); 100 - 101 - (StatusCode::UNAUTHORIZED, headers, "Unauthorized").into_response() 102 - } 103 - 104 - /// Internal MCP handler (no authentication check) 105 - async fn post_mcp( 46 + /// POST /mcp - Handle MCP requests 47 + /// Note: Authentication will be implemented in Phase 4 with MCP OAuth flow 48 + pub(crate) async fn post_mcp_authenticated( 106 49 State(web_context): State<WebContext>, 107 50 headers: HeaderMap, 108 51 Json(request): Json<JsonRpcRequest>, ··· 148 91 } 149 92 } 150 93 151 - /// POST /mcp - Handle MCP requests (requires authentication) 152 - pub(crate) async fn post_mcp_authenticated( 153 - State(web_context): State<WebContext>, 154 - headers: HeaderMap, 155 - Json(request): Json<JsonRpcRequest>, 156 - ) -> Response { 157 - // Only enforce authentication if AIP backend is configured 158 - if web_context.aip_auth_cache().is_some() { 159 - let bearer_token = match extract_bearer_token(&headers) { 160 - Some(token) => token, 161 - None => return unauthorized_response(&web_context), 162 - }; 163 - 164 - let _user_info = match validate_bearer_token(&web_context, &bearer_token).await { 165 - Some(info) => info, 166 - None => return unauthorized_response(&web_context), 167 - }; 168 - 169 - tracing::debug!(sub = %_user_info.sub, "MCP POST request authenticated"); 170 - } 171 - 172 - post_mcp(State(web_context), headers, Json(request)).await 173 - } 174 - 175 94 /// Handle initialize method 176 95 async fn handle_initialize(web_context: &WebContext, request: JsonRpcRequest) -> Response { 177 96 tracing::debug!("Handling initialize request"); ··· 314 233 }, 315 234 { 316 235 "name": "create_rsvp", 317 - "description": "Create an RSVP to a Smoke Signal event", 236 + "description": "Create an RSVP to a Smoke Signal event (requires authentication)", 318 237 "inputSchema": { 319 238 "type": "object", 320 239 "properties": { ··· 351 270 /// Handle tools/call method 352 271 async fn handle_tools_call( 353 272 web_context: &WebContext, 354 - headers: &HeaderMap, 273 + _headers: &HeaderMap, 355 274 request: JsonRpcRequest, 356 275 ) -> Response { 357 276 tracing::debug!("Handling tools/call"); ··· 368 287 arguments = ?arguments, 369 288 "Executing tool" 370 289 ); 371 - 372 - // Extract optional bearer token for RSVP status checking 373 - let bearer_token = extract_bearer_token(headers); 374 290 375 291 let result = match tool_name { 376 292 "get_event" => { ··· 389 305 tracing::debug!( 390 306 repository = %repository, 391 307 record_key = %record_key, 392 - has_auth = bearer_token.is_some(), 393 308 "Calling get_event tool" 394 309 ); 395 310 396 - match tools::get_event( 397 - web_context, 398 - bearer_token.as_deref(), 399 - repository.clone(), 400 - record_key.clone(), 401 - ) 402 - .await 403 - { 311 + match tools::get_event(web_context, repository.clone(), record_key.clone()).await { 404 312 Ok(text) => { 405 313 tracing::info!( 406 314 repository = %repository, ··· 453 361 tracing::debug!( 454 362 repository = ?repository, 455 363 query = %query, 456 - has_auth = bearer_token.is_some(), 457 364 "Calling search_events tool" 458 365 ); 459 366 460 - match tools::search_events( 461 - web_context, 462 - bearer_token.as_deref(), 463 - repository.clone(), 464 - query.clone(), 465 - ) 466 - .await 467 - { 367 + match tools::search_events(web_context, repository.clone(), query.clone()).await { 468 368 Ok(text) => { 469 369 tracing::info!( 470 370 repository = ?repository, ··· 503 403 } 504 404 } 505 405 "create_rsvp" => { 506 - let repository = arguments 507 - .get("repository") 508 - .and_then(|v| v.as_str()) 509 - .unwrap_or("") 510 - .to_string(); 511 - 512 - let record_key = arguments 513 - .get("record_key") 514 - .and_then(|v| v.as_str()) 515 - .unwrap_or("") 516 - .to_string(); 517 - 518 - let status = arguments 519 - .get("status") 520 - .and_then(|v| v.as_str()) 521 - .unwrap_or("") 522 - .to_string(); 523 - 524 - tracing::debug!( 525 - repository = %repository, 526 - record_key = %record_key, 527 - status = %status, 528 - "Calling create_rsvp tool" 529 - ); 530 - 531 - // Extract bearer token for authentication 532 - let bearer_token = match extract_bearer_token(headers) { 533 - Some(token) => token, 534 - None => { 535 - tracing::error!("Missing bearer token for create_rsvp"); 536 - let error_response = JsonRpcResponse { 537 - jsonrpc: "2.0".to_string(), 538 - id: request.id, 539 - result: None, 540 - error: Some(JsonRpcError { 541 - code: -32000, 542 - message: "Authentication required".to_string(), 543 - data: None, 544 - }), 545 - }; 546 - return (StatusCode::OK, Json(error_response)).into_response(); 547 - } 406 + // create_rsvp requires MCP OAuth authentication 407 + // This will be fully implemented in Phase 4 408 + tracing::error!("create_rsvp requires MCP OAuth authentication (not yet implemented)"); 409 + let error_response = JsonRpcResponse { 410 + jsonrpc: "2.0".to_string(), 411 + id: request.id, 412 + result: None, 413 + error: Some(JsonRpcError { 414 + code: -32000, 415 + message: "Authentication required - MCP OAuth not yet implemented".to_string(), 416 + data: None, 417 + }), 548 418 }; 549 - 550 - match tools::create_rsvp( 551 - web_context, 552 - &bearer_token, 553 - repository.clone(), 554 - record_key.clone(), 555 - status.clone(), 556 - ) 557 - .await 558 - { 559 - Ok(text) => { 560 - tracing::info!( 561 - repository = %repository, 562 - record_key = %record_key, 563 - status = %status, 564 - result_length = text.len(), 565 - "create_rsvp tool succeeded" 566 - ); 567 - json!({ 568 - "content": [ 569 - { 570 - "type": "text", 571 - "text": text 572 - } 573 - ] 574 - }) 575 - } 576 - Err(err) => { 577 - tracing::error!( 578 - repository = %repository, 579 - record_key = %record_key, 580 - status = %status, 581 - error = %err, 582 - "create_rsvp tool failed" 583 - ); 584 - let error_response = JsonRpcResponse { 585 - jsonrpc: "2.0".to_string(), 586 - id: request.id, 587 - result: None, 588 - error: Some(JsonRpcError { 589 - code: -32000, 590 - message: err, 591 - data: None, 592 - }), 593 - }; 594 - return (StatusCode::OK, Json(error_response)).into_response(); 595 - } 596 - } 419 + return (StatusCode::OK, Json(error_response)).into_response(); 597 420 } 598 421 _ => { 599 422 tracing::warn!(tool_name = %tool_name, "Unknown tool requested"); ··· 623 446 (StatusCode::OK, Json(response)).into_response() 624 447 } 625 448 626 - /// Internal DELETE handler (no authentication check) 627 - async fn delete_mcp(State(web_context): State<WebContext>, headers: HeaderMap) -> Response { 449 + /// DELETE /mcp - Terminate MCP session 450 + pub(crate) async fn delete_mcp_authenticated( 451 + State(web_context): State<WebContext>, 452 + headers: HeaderMap, 453 + ) -> Response { 628 454 // Get session ID from header 629 455 let session_id = headers 630 456 .get(MCP_SESSION_ID_HEADER) ··· 636 462 637 463 StatusCode::NO_CONTENT.into_response() 638 464 } 639 - 640 - /// DELETE /mcp - Terminate MCP session (requires authentication) 641 - pub(crate) async fn delete_mcp_authenticated( 642 - State(web_context): State<WebContext>, 643 - headers: HeaderMap, 644 - ) -> Response { 645 - // Only enforce authentication if AIP backend is configured 646 - if web_context.aip_auth_cache().is_some() { 647 - let bearer_token = match extract_bearer_token(&headers) { 648 - Some(token) => token, 649 - None => return unauthorized_response(&web_context), 650 - }; 651 - 652 - let _user_info = match validate_bearer_token(&web_context, &bearer_token).await { 653 - Some(info) => info, 654 - None => return unauthorized_response(&web_context), 655 - }; 656 - 657 - tracing::debug!(sub = %_user_info.sub, "MCP DELETE request authenticated"); 658 - } 659 - 660 - delete_mcp(State(web_context), headers).await 661 - } 662 - 663 - /// GET /.well-known/oauth-protected-resource/mcp - OAuth resource metadata 664 - pub(crate) async fn get_oauth_protected_resource_mcp( 665 - State(web_context): State<WebContext>, 666 - ) -> Response { 667 - let external_base = &web_context.config.external_base; 668 - 669 - // Extract AIP hostname if using AIP backend 670 - let authorization_servers = match &web_context.config.oauth_backend { 671 - crate::config::OAuthBackendConfig::AIP { hostname, .. } => vec![hostname.clone()], 672 - _ => vec![format!("https://{}", external_base)], 673 - }; 674 - 675 - let metadata = json!({ 676 - "resource": format!("https://{}", external_base), 677 - "authorization_servers": authorization_servers, 678 - "bearer_methods_supported": ["header"], 679 - "scopes_supported": ["openid", "profile", "atproto", "repo:community.lexicon.calendar.rsvp"], 680 - "resource_documentation": format!("https://{}/help", external_base) 681 - }); 682 - 683 - (StatusCode::OK, Json(metadata)).into_response() 684 - }
+189
src/http/mcp_jwt.rs
··· 1 + //! MCP JWT utilities for wrapping and unwrapping AT Protocol tokens. 2 + //! 3 + //! MCP clients receive JWT-wrapped tokens that contain the underlying 4 + //! AT Protocol access token along with additional metadata. 5 + 6 + use anyhow::{Context, Result, anyhow}; 7 + use base64::{Engine as _, engine::general_purpose::URL_SAFE_NO_PAD}; 8 + use chrono::{Duration, Utc}; 9 + use serde::{Deserialize, Serialize}; 10 + use sha2::Sha256; 11 + 12 + /// Claims for the MCP access token JWT. 13 + #[derive(Debug, Serialize, Deserialize)] 14 + pub struct McpTokenClaims { 15 + /// Subject (user DID) 16 + pub sub: String, 17 + /// Issuer (smokesignal server) 18 + pub iss: String, 19 + /// Audience (client_id) 20 + pub aud: String, 21 + /// Expiration time (Unix timestamp) 22 + pub exp: i64, 23 + /// Issued at (Unix timestamp) 24 + pub iat: i64, 25 + /// JWT ID (unique identifier) 26 + pub jti: String, 27 + /// Wrapped AT Protocol access token 28 + pub atproto_access_token: String, 29 + /// Client ID 30 + pub client_id: String, 31 + /// MCP client internal ID 32 + pub mcp_client_id: String, 33 + } 34 + 35 + /// Create an MCP access token by wrapping an AT Protocol token. 36 + pub fn wrap_token( 37 + secret_key: &[u8], 38 + issuer: &str, 39 + client_id: &str, 40 + mcp_client_id: &str, 41 + did: &str, 42 + atproto_access_token: &str, 43 + expires_in_secs: i64, 44 + ) -> Result<String> { 45 + let now = Utc::now(); 46 + let exp = now + Duration::seconds(expires_in_secs); 47 + 48 + let claims = McpTokenClaims { 49 + sub: did.to_string(), 50 + iss: issuer.to_string(), 51 + aud: client_id.to_string(), 52 + exp: exp.timestamp(), 53 + iat: now.timestamp(), 54 + jti: ulid::Ulid::new().to_string(), 55 + atproto_access_token: atproto_access_token.to_string(), 56 + client_id: client_id.to_string(), 57 + mcp_client_id: mcp_client_id.to_string(), 58 + }; 59 + 60 + encode_jwt(secret_key, &claims) 61 + } 62 + 63 + /// Unwrap an MCP token to extract the underlying AT Protocol token and claims. 64 + pub fn unwrap_token(secret_key: &[u8], token: &str) -> Result<McpTokenClaims> { 65 + let claims: McpTokenClaims = decode_jwt(secret_key, token)?; 66 + 67 + // Verify expiration 68 + let now = Utc::now().timestamp(); 69 + if claims.exp < now { 70 + return Err(anyhow!("Token has expired")); 71 + } 72 + 73 + Ok(claims) 74 + } 75 + 76 + /// Encode claims into a JWT using HS256. 77 + fn encode_jwt<T: Serialize>(secret_key: &[u8], claims: &T) -> Result<String> { 78 + // Header: {"alg":"HS256","typ":"JWT"} 79 + let header = r#"{"alg":"HS256","typ":"JWT"}"#; 80 + let header_b64 = URL_SAFE_NO_PAD.encode(header); 81 + 82 + // Payload 83 + let payload = serde_json::to_string(claims).context("Failed to serialize JWT claims")?; 84 + let payload_b64 = URL_SAFE_NO_PAD.encode(&payload); 85 + 86 + // Signature 87 + let message = format!("{}.{}", header_b64, payload_b64); 88 + let signature = hmac_sha256(secret_key, message.as_bytes()); 89 + let signature_b64 = URL_SAFE_NO_PAD.encode(signature); 90 + 91 + Ok(format!("{}.{}.{}", header_b64, payload_b64, signature_b64)) 92 + } 93 + 94 + /// Decode and verify a JWT using HS256. 95 + fn decode_jwt<T: for<'de> Deserialize<'de>>(secret_key: &[u8], token: &str) -> Result<T> { 96 + let parts: Vec<&str> = token.split('.').collect(); 97 + if parts.len() != 3 { 98 + return Err(anyhow!("Invalid JWT format")); 99 + } 100 + 101 + let header_b64 = parts[0]; 102 + let payload_b64 = parts[1]; 103 + let signature_b64 = parts[2]; 104 + 105 + // Verify signature 106 + let message = format!("{}.{}", header_b64, payload_b64); 107 + let expected_signature = hmac_sha256(secret_key, message.as_bytes()); 108 + let expected_signature_b64 = URL_SAFE_NO_PAD.encode(expected_signature); 109 + 110 + if signature_b64 != expected_signature_b64 { 111 + return Err(anyhow!("Invalid JWT signature")); 112 + } 113 + 114 + // Decode payload 115 + let payload_bytes = URL_SAFE_NO_PAD 116 + .decode(payload_b64) 117 + .context("Failed to decode JWT payload")?; 118 + 119 + let claims: T = 120 + serde_json::from_slice(&payload_bytes).context("Failed to deserialize JWT claims")?; 121 + 122 + Ok(claims) 123 + } 124 + 125 + /// Compute HMAC-SHA256. 126 + fn hmac_sha256(key: &[u8], message: &[u8]) -> Vec<u8> { 127 + use hmac::{Hmac, Mac}; 128 + type HmacSha256 = Hmac<Sha256>; 129 + 130 + let mut mac = 131 + HmacSha256::new_from_slice(key).expect("HMAC can take key of any size"); 132 + mac.update(message); 133 + mac.finalize().into_bytes().to_vec() 134 + } 135 + 136 + /// Generate a secure random secret for JWT signing. 137 + pub fn generate_jwt_secret() -> String { 138 + use rand::RngCore; 139 + let mut key = [0u8; 32]; 140 + rand::rng().fill_bytes(&mut key); 141 + hex::encode(key) 142 + } 143 + 144 + #[cfg(test)] 145 + mod tests { 146 + use super::*; 147 + 148 + #[test] 149 + fn test_wrap_unwrap_token() { 150 + let secret = b"test_secret_key_for_jwt_signing_123"; 151 + let token = wrap_token( 152 + secret, 153 + "https://smokesignal.events", 154 + "https://client.example.com/mcp", 155 + "mcp_123", 156 + "did:plc:abc123", 157 + "atproto_token_xyz", 158 + 3600, 159 + ) 160 + .unwrap(); 161 + 162 + let claims = unwrap_token(secret, &token).unwrap(); 163 + 164 + assert_eq!(claims.sub, "did:plc:abc123"); 165 + assert_eq!(claims.atproto_access_token, "atproto_token_xyz"); 166 + assert_eq!(claims.client_id, "https://client.example.com/mcp"); 167 + assert_eq!(claims.mcp_client_id, "mcp_123"); 168 + } 169 + 170 + #[test] 171 + fn test_invalid_signature() { 172 + let secret1 = b"secret_key_1"; 173 + let secret2 = b"secret_key_2"; 174 + 175 + let token = wrap_token( 176 + secret1, 177 + "https://smokesignal.events", 178 + "https://client.example.com/mcp", 179 + "mcp_123", 180 + "did:plc:abc123", 181 + "atproto_token_xyz", 182 + 3600, 183 + ) 184 + .unwrap(); 185 + 186 + let result = unwrap_token(secret2, &token); 187 + assert!(result.is_err()); 188 + } 189 + }
+51 -83
src/http/middleware_auth.rs
··· 5 5 response::Response, 6 6 }; 7 7 use axum_extra::extract::PrivateCookieJar; 8 - use serde::{Deserialize, Serialize}; 9 8 use tracing::{debug, trace}; 10 9 11 10 use crate::{ 12 - config::Config, http::context::WebContext, http::errors::WebSessionError, 11 + config::Config, 12 + http::context::WebContext, 13 + http::cookies::SessionCookie, 13 14 storage::identity_profile::model::IdentityProfile, 14 15 }; 15 16 16 - use crate::{storage::oauth::model::OAuthSession, storage::oauth::web_session_lookup}; 17 - 18 17 use super::errors::middleware_errors::MiddlewareAuthError; 19 18 20 - pub(crate) const AUTH_COOKIE_NAME: &str = "session20251231"; 21 - 22 - #[derive(Clone, PartialEq, Serialize, Deserialize)] 23 - pub(crate) enum WebSession { 24 - Pds { did: String, session_group: String }, 25 - Aip { did: String, access_token: String }, 26 - } 27 - 28 - impl TryFrom<String> for WebSession { 29 - type Error = anyhow::Error; 30 - 31 - fn try_from(value: String) -> Result<Self, Self::Error> { 32 - serde_json::from_str(&value) 33 - .map_err(WebSessionError::DeserializeFailed) 34 - .map_err(Into::into) 35 - } 36 - } 37 - 38 - impl TryInto<String> for WebSession { 39 - type Error = anyhow::Error; 40 - 41 - fn try_into(self) -> Result<String, Self::Error> { 42 - serde_json::to_string(&self) 43 - .map_err(WebSessionError::SerializeFailed) 44 - .map_err(Into::into) 45 - } 46 - } 19 + /// Cookie name for session storage. 20 + /// Updated version to force re-authentication when cookie format changes. 21 + pub(crate) const AUTH_COOKIE_NAME: &str = "session20260118"; 47 22 48 23 #[derive(Clone)] 49 24 pub(crate) enum Auth { 50 25 Unauthenticated, 51 - Pds { 26 + Authenticated { 52 27 profile: IdentityProfile, 53 - session: OAuthSession, 54 - }, 55 - Aip { 56 - profile: IdentityProfile, 57 - access_token: String, 58 - /// Session is stale when the AIP ready endpoint returns 401. 59 - /// When true, AT Protocol operations will fail until re-authentication. 60 - stale: bool, 28 + session: SessionCookie, 61 29 }, 62 30 } 63 31 ··· 65 33 /// Get the profile if authenticated, None otherwise 66 34 pub(crate) fn profile(&self) -> Option<&IdentityProfile> { 67 35 match self { 68 - Auth::Pds { profile, .. } | Auth::Aip { profile, .. } => Some(profile), 36 + Auth::Authenticated { profile, .. } => Some(profile), 37 + Auth::Unauthenticated => None, 38 + } 39 + } 40 + 41 + /// Get the session if authenticated, None otherwise 42 + pub(crate) fn session(&self) -> Option<&SessionCookie> { 43 + match self { 44 + Auth::Authenticated { session, .. } => Some(session), 69 45 Auth::Unauthenticated => None, 70 46 } 71 47 } 48 + 72 49 /// Requires authentication and redirects to login with a signed token containing the original destination 73 50 /// 74 51 /// This creates a redirect URL with a signed token containing the destination, 75 52 /// which the login handler can verify and redirect back to after successful authentication. 76 53 pub(crate) fn require(&self, location: &str) -> Result<IdentityProfile, MiddlewareAuthError> { 77 54 match self { 78 - Auth::Pds { profile, .. } | Auth::Aip { profile, .. } => { 55 + Auth::Authenticated { profile, .. } => { 79 56 trace!(did = %profile.did, "User authenticated"); 80 57 return Ok(profile.clone()); 81 58 } ··· 90 67 /// Use this when you don't need to return to the original page after login 91 68 pub(crate) fn require_flat(&self) -> Result<IdentityProfile, MiddlewareAuthError> { 92 69 match self { 93 - Auth::Pds { profile, .. } | Auth::Aip { profile, .. } => { 70 + Auth::Authenticated { profile, .. } => { 94 71 trace!(did = %profile.did, "User authenticated"); 95 72 return Ok(profile.clone()); 96 73 } ··· 109 86 config: &Config, 110 87 ) -> Result<IdentityProfile, MiddlewareAuthError> { 111 88 match self { 112 - Auth::Pds { profile, .. } | Auth::Aip { profile, .. } => { 89 + Auth::Authenticated { profile, .. } => { 113 90 if config.is_admin(&profile.did) { 114 91 debug!(did = %profile.did, "Admin authenticated"); 115 92 return Ok(profile.clone()); ··· 142 119 web_context.config.http_cookie_key.as_ref().clone(), 143 120 ); 144 121 122 + // Try to get session from cookie 145 123 let session = cookie_jar 146 124 .get(AUTH_COOKIE_NAME) 147 125 .map(|user_cookie| user_cookie.value().to_owned()) 148 - .and_then(|inner_value| WebSession::try_from(inner_value).ok()); 126 + .and_then(|inner_value| SessionCookie::try_from(inner_value).ok()); 149 127 150 - if let Some(web_session) = session { 151 - match web_session { 152 - WebSession::Pds { did, session_group } => { 153 - trace!(?session_group, "Found PDS session cookie"); 128 + if let Some(session_cookie) = session { 129 + trace!(did = %session_cookie.did, "Found session cookie"); 154 130 155 - match web_session_lookup(&web_context.pool, &session_group, Some(&did)).await { 156 - Ok(record) => { 157 - debug!(?session_group, "Session validated"); 158 - return Ok(Auth::Pds { 159 - profile: record.0, 160 - session: record.1, 161 - }); 162 - } 163 - Err(err) => { 164 - debug!(?session_group, ?err, "Invalid session"); 165 - return Ok(Auth::Unauthenticated); 166 - } 167 - }; 131 + // Check if token is expired 132 + if session_cookie.is_expired() { 133 + debug!(did = %session_cookie.did, "Session token expired"); 134 + // Token is expired, but we could potentially refresh it 135 + // For now, treat as unauthenticated and let user re-login 136 + // A more sophisticated approach would auto-refresh here 137 + return Ok(Auth::Unauthenticated); 138 + } 139 + 140 + // Look up the user's profile from the database 141 + match crate::storage::identity_profile::handle_for_did( 142 + &web_context.pool, 143 + &session_cookie.did, 144 + ) 145 + .await 146 + { 147 + Ok(profile) => { 148 + debug!(did = %session_cookie.did, "Session validated"); 149 + return Ok(Auth::Authenticated { 150 + profile, 151 + session: session_cookie, 152 + }); 168 153 } 169 - WebSession::Aip { did, access_token } => { 170 - trace!(?access_token, "Found AIP session cookie with access token"); 171 - // For AIP OAuth, try to fetch the handle from the database 172 - let profile = sqlx::query_as::<_, IdentityProfile>( 173 - "SELECT * FROM identity_profiles WHERE did = $1", 174 - ) 175 - .bind(&did) 176 - .fetch_one(&web_context.pool) 177 - .await 178 - .ok(); 179 - 180 - if let Some(profile) = profile { 181 - return Ok(Auth::Aip { 182 - profile, 183 - access_token, 184 - stale: false, 185 - }); 186 - } else { 187 - return Ok(Auth::Unauthenticated); 188 - } 154 + Err(err) => { 155 + debug!(did = %session_cookie.did, ?err, "Failed to look up profile"); 156 + return Ok(Auth::Unauthenticated); 189 157 } 190 - } 158 + }; 191 159 } 192 160 193 161 trace!("No session cookie found");
+5 -5
src/http/mod.rs
··· 3 3 pub mod auth_utils; 4 4 pub mod cache_countries; 5 5 pub mod context; 6 + pub mod cookies; 6 7 pub mod errors; 7 8 pub mod event_form; 8 9 pub mod event_validation; ··· 26 27 pub mod handle_admin_rsvp_accepts; 27 28 pub mod handle_admin_rsvps; 28 29 pub mod handle_admin_search_index; 30 + pub mod handle_api_mcp_configuration; 29 31 pub mod handle_blob; 30 32 pub mod handle_bulk_accept_rsvps; 31 33 pub mod handle_content; ··· 49 51 pub mod handle_mailgun_webhook; 50 52 pub mod handle_manage_event; 51 53 pub mod handle_manage_event_content; 52 - pub mod handle_oauth_aip_callback; 53 - pub mod handle_oauth_aip_login; 54 - pub mod handle_oauth_callback; 55 - pub mod handle_oauth_login; 56 - pub mod handle_oauth_logout; 54 + pub mod handle_mcp_oauth; 55 + pub mod handle_oauth; 57 56 pub mod handle_policy; 58 57 pub mod handle_preview_description; 59 58 pub mod handle_profile; ··· 74 73 pub mod lfg_form; 75 74 pub mod location_edit_status; 76 75 pub mod macros; 76 + pub mod mcp_jwt; 77 77 pub mod middleware_auth; 78 78 pub mod middleware_i18n; 79 79 pub mod pagination;
+35 -36
src/http/server.rs
··· 79 79 handle_mailgun_webhook::handle_mailgun_webhook, 80 80 handle_manage_event::handle_manage_event, 81 81 handle_manage_event_content::handle_manage_event_content_save, 82 - handle_oauth_logout::handle_logout, 82 + handle_mcp_oauth::{ 83 + get_mcp_authorize_callback, get_mcp_oauth_authorization_server, 84 + get_mcp_oauth_protected_resource, get_mcp_authorize, post_mcp_register, post_mcp_token, 85 + }, 86 + handle_api_mcp_configuration::{ 87 + handle_api_mcp_configuration_get, handle_api_mcp_configuration_post, 88 + }, 89 + handle_oauth::{ 90 + handle_auth_callback, handle_auth_init, handle_auth_logout, handle_auth_refresh, 91 + handle_oauth_metadata, 92 + }, 83 93 handle_policy::{ 84 94 handle_about, handle_acknowledgement, handle_cookie_policy, handle_privacy_policy, 85 95 handle_terms_of_service, ··· 102 112 handle_xrpc_get_rsvp::handle_xrpc_get_rsvp, 103 113 handle_xrpc_link_attestation::handle_xrpc_link_attestation, 104 114 handle_xrpc_search_events::handle_xrpc_search_events, 105 - handler_mcp::{ 106 - delete_mcp_authenticated, get_oauth_protected_resource_mcp, post_mcp_authenticated, 107 - }, 108 - }; 109 - use crate::{ 110 - config::OAuthBackendConfig, 111 - http::handle_view_event::{handle_event_attendees, handle_event_ics}, 115 + handler_mcp::{delete_mcp_authenticated, post_mcp_authenticated}, 112 116 }; 117 + use crate::http::handle_view_event::{handle_event_attendees, handle_event_ics}; 113 118 114 - use crate::http::handle_oauth_aip_callback::handle_oauth_callback as handle_oauth_aip_callback; 115 - use crate::http::handle_oauth_aip_login::handle_oauth_aip_login; 116 - use crate::http::handle_oauth_callback::handle_oauth_callback as handle_oauth_pds_callback; 117 - use crate::http::handle_oauth_login::handle_oauth_login as handle_oauth_pds_login; 118 - use atproto_oauth_axum::handler_metadata::handle_oauth_metadata; 119 119 120 120 pub fn build_router(web_context: WebContext) -> Router { 121 121 let serve_dir = ServeDir::new(web_context.config.http_static_path.clone()); 122 122 123 - let mut router = Router::new() 123 + let router = Router::new() 124 124 .route("/", get(handle_index)) 125 125 .route("/robots.txt", get_service(serve_dir.clone())) 126 126 .route("/favicon.ico", get_service(serve_dir.clone())) ··· 139 139 .route("/.well-known/host-meta.json", get(handle_host_meta)) 140 140 .route( 141 141 "/.well-known/oauth-protected-resource/mcp", 142 - get(get_oauth_protected_resource_mcp), 142 + get(get_mcp_oauth_protected_resource), 143 + ) 144 + .route( 145 + "/.well-known/oauth-authorization-server/mcp", 146 + get(get_mcp_oauth_authorization_server), 143 147 ) 144 148 .route( 145 149 "/mcp", 146 150 post(post_mcp_authenticated).delete(delete_mcp_authenticated), 147 151 ) 152 + .route("/mcp/register", post(post_mcp_register)) 153 + .route("/mcp/authorize", get(get_mcp_authorize)) 154 + .route("/mcp/authorize/callback", get(get_mcp_authorize_callback)) 155 + .route("/mcp/token", post(post_mcp_token)) 148 156 .route("/_ready", get(handle_ready)) 149 157 .route("/_alive", get(handle_alive)) 150 158 .route("/_started", get(handle_started)) ··· 179 187 .route("/api/globe-aggregation", get(handle_globe_aggregation)) 180 188 .route("/api/lfg/tags", get(handle_lfg_tags_autocomplete)) 181 189 .route("/api/lfg/geo-aggregation", get(handle_lfg_geo_aggregation)) 190 + .route( 191 + "/api/mcp/configuration", 192 + get(handle_api_mcp_configuration_get).post(handle_api_mcp_configuration_post), 193 + ) 182 194 // LFG routes 183 195 .route("/lfg", get(handle_lfg_get)) 184 196 .route("/lfg", post(handle_lfg_post)) ··· 186 198 // Location route 187 199 .route("/l/{location}", get(handle_location)); 188 200 189 - // Add OAuth metadata route only for AT Protocol backend 190 - if matches!( 191 - web_context.config.oauth_backend, 192 - OAuthBackendConfig::ATProtocol { .. } 193 - ) { 194 - router = router.route("/oauth/client-metadata.json", get(handle_oauth_metadata)); 195 - } 196 - 197 - // Add OAuth routes based on backend configuration 198 - router = match web_context.config.oauth_backend { 199 - OAuthBackendConfig::AIP { .. } => router 200 - .route("/oauth/login", get(handle_oauth_aip_login)) 201 - .route("/oauth/login", post(handle_oauth_aip_login)) 202 - .route("/oauth/callback", get(handle_oauth_aip_callback)), 203 - OAuthBackendConfig::ATProtocol { .. } => router 204 - .route("/oauth/login", get(handle_oauth_pds_login)) 205 - .route("/oauth/login", post(handle_oauth_pds_login)) 206 - .route("/oauth/callback", get(handle_oauth_pds_callback)), 207 - }; 208 - 201 + // Add OAuth routes for AT Protocol 209 202 router 203 + .route("/oauth-client-metadata.json", get(handle_oauth_metadata)) 204 + .route("/oauth/login", get(handle_auth_init)) 205 + .route("/oauth/login", post(handle_auth_init)) 206 + .route("/oauth/callback", get(handle_auth_callback)) 207 + .route("/oauth/refresh", post(handle_auth_refresh)) 208 + .route("/oauth/logout", post(handle_auth_logout)) 210 209 .route("/admin", get(handle_admin_index)) 211 210 .route("/admin/identity_profiles", get(handle_admin_handles)) 212 211 .route( ··· 288 287 post(handle_admin_profile_index_rebuild), 289 288 ) 290 289 .route("/content/{cid}", get(handle_content)) 291 - .route("/logout", get(handle_logout)) 290 + .route("/logout", get(handle_auth_logout)) 292 291 .route("/language", post(handle_set_language)) 293 292 .route("/search", get(handle_search)) 294 293 .route("/settings", get(handle_settings))
-1
src/lib.rs
··· 1 - pub mod aip_auth_cache; 2 1 pub mod atproto; 3 2 pub mod config; 4 3 pub mod config_errors;
+3 -393
src/mcp/tools.rs
··· 1 - use anyhow::Result; 2 - use atproto_client::com::atproto::repo::{PutRecordRequest, PutRecordResponse, put_record}; 3 1 use atproto_identity::resolve::{InputType, parse_input}; 4 2 use atproto_record::lexicon::community::lexicon::calendar::event::NSID as CommunityLexiconCalendarEventNSID; 5 - use atproto_record::lexicon::community::lexicon::calendar::rsvp::{ 6 - NSID as RsvpNSID, Rsvp, RsvpStatus, 7 - }; 8 - use chrono::Utc; 9 - use metrohash::MetroHash64; 10 - use std::hash::Hasher; 11 3 12 - use crate::atproto::auth::create_dpop_auth_from_aip_session; 13 - use crate::config::OAuthBackendConfig; 14 4 use crate::http::{context::WebContext, utils::url_from_aturi}; 15 5 use crate::search_index::SearchIndexManager; 16 - use crate::storage::event::{ 17 - RsvpInsertParams, event_get, get_event_rsvp_counts, rsvp_get_by_event_and_did, 18 - rsvp_insert_with_metadata, 19 - }; 6 + use crate::storage::event::{event_get, get_event_rsvp_counts}; 20 7 21 8 /// Wrap response text with safety tags to prevent prompt injection 22 9 pub fn wrap_response_text(text: String) -> String { ··· 30 17 /// Get a single event by repository (DID) and record key 31 18 pub async fn get_event( 32 19 web_context: &WebContext, 33 - bearer_token: Option<&str>, 34 20 repository: String, 35 21 record_key: String, 36 22 ) -> Result<String, String> { 37 23 tracing::debug!( 38 24 repository = %repository, 39 25 record_key = %record_key, 40 - has_auth = bearer_token.is_some(), 41 26 "get_event tool called" 42 27 ); 43 28 ··· 93 78 "RSVP counts fetched" 94 79 ); 95 80 96 - // Check caller's RSVP status if authenticated 97 - let caller_rsvp_status = if let Some(token) = bearer_token { 98 - if let Some(cache) = &web_context.aip_auth_cache { 99 - match cache.validate_token(token).await { 100 - Ok(Some(user_info)) => { 101 - tracing::debug!(did = %user_info.sub, "Checking caller's RSVP status"); 102 - match rsvp_get_by_event_and_did(&web_context.pool, &aturi, &user_info.sub).await 103 - { 104 - Ok(Some(rsvp)) => { 105 - // Parse the RSVP record to get the status 106 - let status_str = rsvp 107 - .record 108 - .0 109 - .get("status") 110 - .and_then(|v| v.as_str()) 111 - .unwrap_or("unknown"); 112 - tracing::debug!(status = %status_str, "Found caller's RSVP"); 113 - Some(status_str.to_string()) 114 - } 115 - _ => { 116 - tracing::debug!("Caller has not RSVP'd to this event"); 117 - None 118 - } 119 - } 120 - } 121 - _ => { 122 - tracing::debug!("Failed to validate bearer token for RSVP check"); 123 - None 124 - } 125 - } 126 - } else { 127 - None 128 - } 129 - } else { 130 - None 131 - }; 132 - 133 81 // Generate event URL 134 82 tracing::debug!(aturi = %aturi, "Generating event URL"); 135 83 let url = url_from_aturi(&web_context.config.external_base, &event.aturi).map_err(|e| { ··· 170 118 }; 171 119 172 120 // Format as human-readable text 173 - let mut text = format!( 121 + let text = format!( 174 122 "Event: {}\nAT-URI: {}\nURL: {}\nStart: {}\nEnd: {}{}\n\nDescription:\n{}\n\nRSVPs:\n- Going: {}\n- Interested: {}\n- Not Going: {}", 175 123 name, 176 124 aturi, ··· 184 132 count_not_going 185 133 ); 186 134 187 - // Add caller's RSVP status if available 188 - if let Some(status) = caller_rsvp_status { 189 - text.push_str(&format!("\n\nYour RSVP: {}", status)); 190 - } 191 - 192 135 Ok(wrap_response_text(text)) 193 136 } 194 137 195 138 /// Search events using full-text search or get upcoming events 196 139 pub async fn search_events( 197 140 web_context: &WebContext, 198 - bearer_token: Option<&str>, 199 141 repository: Option<String>, 200 142 query: String, 201 143 ) -> Result<String, String> { 202 144 tracing::debug!( 203 145 repository = ?repository, 204 146 query = %query, 205 - has_auth = bearer_token.is_some(), 206 147 "search_events tool called" 207 148 ); 208 149 ··· 273 214 "Extracted event IDs from search results" 274 215 ); 275 216 276 - // Get caller's DID if authenticated 277 - let caller_did = if let Some(token) = bearer_token { 278 - if let Some(cache) = &web_context.aip_auth_cache { 279 - match cache.validate_token(token).await { 280 - Ok(Some(user_info)) => { 281 - tracing::debug!(did = %user_info.sub, "Caller authenticated for RSVP status checks"); 282 - Some(user_info.sub) 283 - } 284 - _ => { 285 - tracing::debug!("Failed to validate bearer token for RSVP checks"); 286 - None 287 - } 288 - } 289 - } else { 290 - None 291 - } 292 - } else { 293 - None 294 - }; 295 - 296 217 // Fetch full event records and RSVP counts 297 218 let mut event_texts = Vec::new(); 298 219 ··· 364 285 String::new() 365 286 }; 366 287 367 - // Check caller's RSVP status for this event 368 - let caller_rsvp_status = if let Some(ref did) = caller_did { 369 - match rsvp_get_by_event_and_did(&web_context.pool, aturi, did).await { 370 - Ok(Some(rsvp)) => { 371 - // Parse the RSVP record to get the status 372 - let status_str = rsvp 373 - .record 374 - .0 375 - .get("status") 376 - .and_then(|v| v.as_str()) 377 - .unwrap_or("unknown"); 378 - Some(status_str.to_string()) 379 - } 380 - _ => None, 381 - } 382 - } else { 383 - None 384 - }; 385 - 386 - let mut event_text = format!( 288 + let event_text = format!( 387 289 "- {}\n AT-URI: {}\n URL: {}\n Start: {}{}\n Description: {}\n RSVPs: {} going, {} interested, {} not going", 388 290 name, 389 291 aturi, ··· 396 298 count_not_going 397 299 ); 398 300 399 - // Add caller's RSVP status if they have one 400 - if let Some(status) = caller_rsvp_status { 401 - event_text.push_str(&format!("\n Your RSVP: {}", status)); 402 - } 403 - 404 301 event_texts.push(event_text); 405 302 } 406 303 ··· 419 316 420 317 Ok(wrap_response_text(text)) 421 318 } 422 - 423 - /// Create an RSVP to an event 424 - pub async fn create_rsvp( 425 - web_context: &WebContext, 426 - bearer_token: &str, 427 - repository: String, 428 - record_key: String, 429 - status: String, 430 - ) -> Result<String, String> { 431 - tracing::debug!( 432 - repository = %repository, 433 - record_key = %record_key, 434 - status = %status, 435 - "create_rsvp tool called" 436 - ); 437 - 438 - // Validate bearer token to get user info 439 - let user_info = match &web_context.aip_auth_cache { 440 - Some(cache) => cache 441 - .validate_token(bearer_token) 442 - .await 443 - .map_err(|e| { 444 - tracing::error!(error = ?e, "Failed to validate bearer token"); 445 - "Authentication failed".to_string() 446 - })? 447 - .ok_or_else(|| { 448 - tracing::warn!("Invalid bearer token"); 449 - "Invalid authentication token".to_string() 450 - })?, 451 - None => { 452 - tracing::error!("AIP auth cache not configured"); 453 - return Err("Authentication not available".to_string()); 454 - } 455 - }; 456 - 457 - let user_did = &user_info.sub; 458 - tracing::debug!(did = %user_did, "User authenticated"); 459 - 460 - // Parse repository as DID (reject handles) 461 - let event_creator_did = match parse_input(&repository) { 462 - Ok(InputType::Plc(value)) | Ok(InputType::Web(value)) => { 463 - tracing::debug!(did = %value, "Parsed repository as DID"); 464 - value 465 - } 466 - Ok(InputType::Handle(_)) | Err(_) => { 467 - tracing::warn!(repository = %repository, "Invalid repository: not a DID"); 468 - return Err( 469 - "Invalid repository: must be a DID (did:plc:... or did:web:...)".to_string(), 470 - ); 471 - } 472 - }; 473 - 474 - // Construct AT-URI for event 475 - let event_aturi = format!( 476 - "at://{}/{}/{}", 477 - event_creator_did, CommunityLexiconCalendarEventNSID, record_key 478 - ); 479 - 480 - tracing::debug!(aturi = %event_aturi, "Constructed event AT-URI"); 481 - 482 - // Fetch event to verify it exists and check requirements 483 - tracing::debug!(aturi = %event_aturi, "Fetching event from database"); 484 - let event = event_get(&web_context.pool, &event_aturi) 485 - .await 486 - .map_err(|e| { 487 - tracing::error!(aturi = %event_aturi, error = ?e, "Event not found"); 488 - "Event not found".to_string() 489 - })?; 490 - 491 - // Check if event requires confirmed email 492 - if event.require_confirmed_email { 493 - // Check if user has confirmed email 494 - let has_confirmed_email = crate::storage::notification::notification_get_confirmed_email( 495 - &web_context.pool, 496 - user_did, 497 - ) 498 - .await 499 - .map_err(|e| { 500 - tracing::error!(error = ?e, "Failed to check email confirmation"); 501 - "Failed to check email confirmation status".to_string() 502 - })? 503 - .is_some(); 504 - 505 - if !has_confirmed_email { 506 - tracing::warn!(did = %user_did, "User does not have confirmed email for event requiring it"); 507 - return Err("This event requires a confirmed email address to RSVP".to_string()); 508 - } 509 - } 510 - 511 - // Create DPoP auth from AIP session 512 - let dpop_auth = match &web_context.config.oauth_backend { 513 - OAuthBackendConfig::AIP { hostname, .. } => { 514 - create_dpop_auth_from_aip_session(&web_context.http_client, hostname, bearer_token) 515 - .await 516 - .map_err(|e| { 517 - tracing::error!(error = ?e, "Failed to create DPoP auth"); 518 - format!("Authentication error: {}", e) 519 - })? 520 - } 521 - _ => { 522 - tracing::error!("OAuth backend is not AIP"); 523 - return Err("RSVP creation requires AIP OAuth backend".to_string()); 524 - } 525 - }; 526 - 527 - // Parse status 528 - let rsvp_status = match status.as_str() { 529 - "going" => RsvpStatus::Going, 530 - "interested" => RsvpStatus::Interested, 531 - "notgoing" => RsvpStatus::NotGoing, 532 - _ => { 533 - tracing::warn!(status = %status, "Invalid RSVP status"); 534 - return Err("Invalid status: must be 'going', 'interested', or 'notgoing'".to_string()); 535 - } 536 - }; 537 - 538 - tracing::debug!(status = ?status, "Parsed RSVP status"); 539 - 540 - // Generate deterministic record key using MetroHash64 541 - let mut h = MetroHash64::default(); 542 - h.write(event_aturi.as_bytes()); 543 - let rsvp_record_key = crockford::encode(h.finish()); 544 - 545 - tracing::debug!(record_key = %rsvp_record_key, "Generated RSVP record key"); 546 - 547 - // Check for existing RSVP 548 - let existing_rsvp = rsvp_get_by_event_and_did(&web_context.pool, &event_aturi, user_did) 549 - .await 550 - .ok() 551 - .flatten(); 552 - 553 - let now = Utc::now(); 554 - 555 - // Determine timestamp, signatures, and status change 556 - let (created_at_timestamp, signatures_to_use, status_changed) = 557 - if let Some(ref existing) = existing_rsvp { 558 - // Parse existing RSVP record to get current status and signatures 559 - let existing_rsvp_record: Result<Rsvp, _> = 560 - serde_json::from_value(existing.record.0.clone()); 561 - 562 - if let Ok(existing_record) = existing_rsvp_record { 563 - // Check if status is changing 564 - let status_is_changing = existing_record.status != rsvp_status; 565 - 566 - if status_is_changing { 567 - tracing::debug!("RSVP status is changing, clearing signatures"); 568 - // Status changed - clear signatures, keep existing created_at, mark as changed 569 - (existing_record.created_at, vec![], true) 570 - } else { 571 - tracing::debug!("RSVP status unchanged, preserving signatures"); 572 - // Status unchanged - preserve signatures, created_at, mark as unchanged 573 - ( 574 - existing_record.created_at, 575 - existing_record.signatures, 576 - false, 577 - ) 578 - } 579 - } else { 580 - tracing::warn!("Could not parse existing RSVP record"); 581 - // Could not parse existing record - use current time, empty signatures 582 - (now, vec![], false) 583 - } 584 - } else { 585 - tracing::debug!("No existing RSVP found, creating new"); 586 - // No existing RSVP - use current time, empty signatures 587 - (now, vec![], false) 588 - }; 589 - 590 - // Create the RSVP record 591 - let subject = atproto_record::lexicon::com::atproto::repo::StrongRef { 592 - uri: event_aturi.clone(), 593 - cid: event.cid.clone(), 594 - }; 595 - 596 - let the_record = Rsvp { 597 - created_at: created_at_timestamp, 598 - subject, 599 - status: rsvp_status, 600 - signatures: signatures_to_use, 601 - extra: Default::default(), 602 - }; 603 - 604 - tracing::debug!("Creating RSVP record"); 605 - 606 - let rsvp_record = PutRecordRequest { 607 - repo: user_did.to_string(), 608 - collection: RsvpNSID.to_string(), 609 - validate: false, 610 - record_key: rsvp_record_key.clone(), 611 - record: the_record.clone(), 612 - swap_commit: None, 613 - swap_record: None, 614 - }; 615 - 616 - // Get user's PDS endpoint by resolving DID 617 - tracing::debug!(did = %user_did, "Resolving DID to get PDS endpoint"); 618 - let document = web_context 619 - .identity_resolver 620 - .resolve(user_did) 621 - .await 622 - .map_err(|e| { 623 - tracing::error!(error = ?e, "Failed to resolve DID"); 624 - format!("Failed to resolve user DID: {}", e) 625 - })?; 626 - 627 - // Find the PDS endpoint from the DID document 628 - let pds_endpoint = document 629 - .service 630 - .iter() 631 - .find(|s| s.r#type == "AtprotoPersonalDataServer") 632 - .map(|s| s.service_endpoint.as_str()) 633 - .ok_or_else(|| { 634 - tracing::error!(did = %user_did, "No PDS endpoint found in DID document"); 635 - format!("No PDS endpoint found for user DID: {}", user_did) 636 - })?; 637 - 638 - tracing::debug!(pds = %pds_endpoint, "Retrieved PDS endpoint"); 639 - 640 - // Put record to PDS 641 - tracing::debug!(pds = %pds_endpoint, record_key = %rsvp_record_key, "Putting RSVP record to PDS"); 642 - let put_record_result = put_record( 643 - &web_context.http_client, 644 - &atproto_client::client::Auth::DPoP(dpop_auth), 645 - pds_endpoint, 646 - rsvp_record, 647 - ) 648 - .await 649 - .map_err(|e| { 650 - tracing::error!(error = ?e, "Failed to put RSVP record to PDS"); 651 - format!("Failed to create RSVP record: {}", e) 652 - })?; 653 - 654 - let create_record_result = match put_record_result { 655 - PutRecordResponse::StrongRef { uri, cid, .. } => { 656 - atproto_record::lexicon::com::atproto::repo::StrongRef { uri, cid } 657 - } 658 - PutRecordResponse::Error(err) => { 659 - tracing::error!(error = err.error_message(), "PDS returned error"); 660 - return Err(format!("Failed to create RSVP: {}", err.error_message())); 661 - } 662 - }; 663 - 664 - tracing::debug!(uri = %create_record_result.uri, cid = %create_record_result.cid, "RSVP record created on PDS"); 665 - 666 - // Insert into local database 667 - tracing::debug!("Inserting RSVP into database"); 668 - rsvp_insert_with_metadata( 669 - &web_context.pool, 670 - RsvpInsertParams { 671 - aturi: &create_record_result.uri, 672 - cid: &create_record_result.cid, 673 - did: user_did, 674 - lexicon: RsvpNSID, 675 - record: &the_record, 676 - event_aturi: &event_aturi, 677 - event_cid: &event.cid, 678 - status: &status, 679 - clear_validated_at: status_changed, 680 - }, 681 - ) 682 - .await 683 - .map_err(|e| { 684 - tracing::error!(error = ?e, "Failed to insert RSVP into database"); 685 - format!("Failed to save RSVP: {}", e) 686 - })?; 687 - 688 - tracing::info!( 689 - uri = %create_record_result.uri, 690 - status = %status, 691 - "RSVP created successfully" 692 - ); 693 - 694 - // Generate event URL 695 - let event_url = 696 - url_from_aturi(&web_context.config.external_base, &event_aturi).map_err(|e| { 697 - tracing::error!(error = ?e, "Failed to generate event URL"); 698 - format!("Error generating URL: {}", e) 699 - })?; 700 - 701 - // Format response 702 - let text = format!( 703 - "RSVP created successfully\nEvent: {}\nEvent URL: {}\nStatus: {}\nRSVP AT-URI: {}", 704 - event.name, event_url, status, create_record_result.uri 705 - ); 706 - 707 - Ok(wrap_response_text(text)) 708 - }
+7 -1
src/service.rs
··· 20 20 "controller": format!("did:web:{external_base}"), 21 21 "publicKeyMultibase": public_service_key 22 22 }], 23 - "service":[] 23 + "service":[ 24 + { 25 + "id":"#smokesignal", 26 + "type":"SmokeSignalService", 27 + "serviceEndpoint": format!("https://{external_base}") 28 + } 29 + ] 24 30 } 25 31 )) 26 32 }
-16
src/storage/errors.rs
··· 28 28 /// JSON Web Key (JWK) for DPoP operations, typically due to invalid JSON format. 29 29 #[error("error-smokesignal-oauth-model-3 Failed to deserialize DPoP JWK: {0:?}")] 30 30 DpopJwkDeserializationFailed(serde_json::Error), 31 - 32 - /// Error when required OAuth session data is missing. 33 - /// 34 - /// This error occurs when attempting to use an OAuth session 35 - /// that is missing critical data needed for authentication or 36 - /// authorization operations, such as tokens or session identifiers. 37 - #[error("error-smokesignal-oauth-model-4 Missing required OAuth session data")] 38 - MissingRequiredOAuthSessionData(), 39 - 40 - /// Error when an OAuth session has expired. 41 - /// 42 - /// This error occurs when attempting to use an OAuth session 43 - /// that has exceeded its validity period and is no longer usable 44 - /// for authentication or authorization purposes. 45 - #[error("error-smokesignal-oauth-model-5 OAuth session has expired")] 46 - OAuthSessionExpired(), 47 31 } 48 32 49 33 /// Represents errors that can occur during storage and database operations.
+141
src/storage/mcp_clients.rs
··· 1 + //! MCP client storage operations. 2 + //! 3 + //! Stores dynamically registered MCP clients for OAuth flow. 4 + 5 + use chrono::{DateTime, Utc}; 6 + use serde::{Deserialize, Serialize}; 7 + use sqlx::FromRow; 8 + 9 + use super::{StoragePool, errors::StorageError}; 10 + 11 + /// An MCP client registered for OAuth. 12 + #[derive(Clone, Debug, FromRow, Serialize, Deserialize)] 13 + pub struct McpClient { 14 + /// Unique internal ID 15 + pub id: String, 16 + /// OAuth client_id (URL format) 17 + pub client_id: String, 18 + /// OAuth client_secret 19 + pub client_secret: String, 20 + /// OAuth redirect_uri 21 + pub redirect_uri: String, 22 + /// Human-readable client name 23 + pub client_name: Option<String>, 24 + /// DID of the authenticated user (after OAuth completes) 25 + pub did: Option<String>, 26 + /// DPoP JWK for token binding 27 + pub dpop_jwk: String, 28 + /// ATProto authorization server issuer 29 + pub issuer: Option<String>, 30 + /// When the client was registered 31 + pub created_at: DateTime<Utc>, 32 + /// When the client was last updated 33 + pub updated_at: DateTime<Utc>, 34 + } 35 + 36 + /// Create a new MCP client registration. 37 + pub async fn mcp_client_create( 38 + pool: &StoragePool, 39 + id: &str, 40 + client_id: &str, 41 + client_secret: &str, 42 + redirect_uri: &str, 43 + client_name: Option<&str>, 44 + dpop_jwk: &str, 45 + ) -> Result<McpClient, StorageError> { 46 + let now = Utc::now(); 47 + 48 + sqlx::query_as::<_, McpClient>( 49 + r#" 50 + INSERT INTO mcp_clients (id, client_id, client_secret, redirect_uri, client_name, dpop_jwk, created_at, updated_at) 51 + VALUES ($1, $2, $3, $4, $5, $6, $7, $7) 52 + RETURNING * 53 + "#, 54 + ) 55 + .bind(id) 56 + .bind(client_id) 57 + .bind(client_secret) 58 + .bind(redirect_uri) 59 + .bind(client_name) 60 + .bind(dpop_jwk) 61 + .bind(now) 62 + .fetch_one(pool) 63 + .await 64 + .map_err(StorageError::UnableToExecuteQuery) 65 + } 66 + 67 + /// Get an MCP client by its client_id. 68 + pub async fn mcp_client_get_by_client_id( 69 + pool: &StoragePool, 70 + client_id: &str, 71 + ) -> Result<McpClient, StorageError> { 72 + sqlx::query_as::<_, McpClient>("SELECT * FROM mcp_clients WHERE client_id = $1") 73 + .bind(client_id) 74 + .fetch_one(pool) 75 + .await 76 + .map_err(|err| match err { 77 + sqlx::Error::RowNotFound => StorageError::RowNotFound("mcp_client".to_string(), err), 78 + other => StorageError::UnableToExecuteQuery(other), 79 + }) 80 + } 81 + 82 + /// Get an MCP client by its internal ID. 83 + pub async fn mcp_client_get_by_id(pool: &StoragePool, id: &str) -> Result<McpClient, StorageError> { 84 + sqlx::query_as::<_, McpClient>("SELECT * FROM mcp_clients WHERE id = $1") 85 + .bind(id) 86 + .fetch_one(pool) 87 + .await 88 + .map_err(|err| match err { 89 + sqlx::Error::RowNotFound => StorageError::RowNotFound("mcp_client".to_string(), err), 90 + other => StorageError::UnableToExecuteQuery(other), 91 + }) 92 + } 93 + 94 + /// Update an MCP client with authentication info after OAuth completes. 95 + pub async fn mcp_client_update_auth( 96 + pool: &StoragePool, 97 + client_id: &str, 98 + did: &str, 99 + issuer: &str, 100 + ) -> Result<(), StorageError> { 101 + let now = Utc::now(); 102 + 103 + sqlx::query( 104 + r#" 105 + UPDATE mcp_clients 106 + SET did = $1, issuer = $2, updated_at = $3 107 + WHERE client_id = $4 108 + "#, 109 + ) 110 + .bind(did) 111 + .bind(issuer) 112 + .bind(now) 113 + .bind(client_id) 114 + .execute(pool) 115 + .await 116 + .map_err(StorageError::UnableToExecuteQuery)?; 117 + 118 + Ok(()) 119 + } 120 + 121 + /// Delete an MCP client by its client_id. 122 + pub async fn mcp_client_delete(pool: &StoragePool, client_id: &str) -> Result<(), StorageError> { 123 + sqlx::query("DELETE FROM mcp_clients WHERE client_id = $1") 124 + .bind(client_id) 125 + .execute(pool) 126 + .await 127 + .map_err(StorageError::UnableToExecuteQuery)?; 128 + 129 + Ok(()) 130 + } 131 + 132 + /// Delete an MCP client by its internal ID. 133 + pub async fn mcp_client_delete_by_id(pool: &StoragePool, id: &str) -> Result<(), StorageError> { 134 + sqlx::query("DELETE FROM mcp_clients WHERE id = $1") 135 + .bind(id) 136 + .execute(pool) 137 + .await 138 + .map_err(StorageError::UnableToExecuteQuery)?; 139 + 140 + Ok(()) 141 + }
+68
src/storage/mcp_configuration.rs
··· 1 + //! MCP configuration storage operations. 2 + //! 3 + //! Stores per-user MCP configuration settings. 4 + 5 + use chrono::{DateTime, Utc}; 6 + use serde::{Deserialize, Serialize}; 7 + use sqlx::FromRow; 8 + 9 + use super::{StoragePool, errors::StorageError}; 10 + 11 + /// MCP configuration for a user. 12 + #[derive(Clone, Debug, FromRow, Serialize, Deserialize)] 13 + pub struct McpConfiguration { 14 + /// User's DID 15 + pub did: String, 16 + /// Allow dangerous operations (delete, apply_writes, etc.) 17 + pub allow_dangerous: bool, 18 + /// When the configuration was last updated 19 + pub updated_at: DateTime<Utc>, 20 + } 21 + 22 + /// Get MCP configuration for a user. 23 + /// Returns None if no configuration exists (default settings apply). 24 + pub async fn mcp_config_get( 25 + pool: &StoragePool, 26 + did: &str, 27 + ) -> Result<Option<McpConfiguration>, StorageError> { 28 + sqlx::query_as::<_, McpConfiguration>("SELECT * FROM mcp_configuration WHERE did = $1") 29 + .bind(did) 30 + .fetch_optional(pool) 31 + .await 32 + .map_err(StorageError::UnableToExecuteQuery) 33 + } 34 + 35 + /// Upsert MCP configuration for a user. 36 + pub async fn mcp_config_upsert( 37 + pool: &StoragePool, 38 + did: &str, 39 + allow_dangerous: bool, 40 + ) -> Result<McpConfiguration, StorageError> { 41 + let now = Utc::now(); 42 + 43 + sqlx::query_as::<_, McpConfiguration>( 44 + r#" 45 + INSERT INTO mcp_configuration (did, allow_dangerous, updated_at) 46 + VALUES ($1, $2, $3) 47 + ON CONFLICT (did) 48 + DO UPDATE SET allow_dangerous = $2, updated_at = $3 49 + RETURNING * 50 + "#, 51 + ) 52 + .bind(did) 53 + .bind(allow_dangerous) 54 + .bind(now) 55 + .fetch_one(pool) 56 + .await 57 + .map_err(StorageError::UnableToExecuteQuery) 58 + } 59 + 60 + /// Check if dangerous operations are allowed for a user. 61 + /// Returns false if no configuration exists (safe default). 62 + pub async fn mcp_config_is_dangerous_allowed( 63 + pool: &StoragePool, 64 + did: &str, 65 + ) -> Result<bool, StorageError> { 66 + let config = mcp_config_get(pool, did).await?; 67 + Ok(config.map(|c| c.allow_dangerous).unwrap_or(false)) 68 + }
+2
src/storage/mod.rs
··· 9 9 pub mod event; 10 10 pub mod identity_profile; 11 11 pub mod lfg; 12 + pub mod mcp_clients; 13 + pub mod mcp_configuration; 12 14 pub mod notification; 13 15 pub mod oauth; 14 16 pub mod private_event_content;
+2 -163
src/storage/oauth.rs
··· 1 - use std::borrow::Cow; 2 - 3 - use chrono::{DateTime, Utc}; 4 - 5 - use crate::storage::{StoragePool, errors::StorageError, identity_profile::model::IdentityProfile}; 6 - use model::OAuthSession; 7 - 8 - pub async fn oauth_session_update( 9 - pool: &StoragePool, 10 - session_group: Cow<'_, str>, 11 - access_token: Cow<'_, str>, 12 - refresh_token: Cow<'_, str>, 13 - access_token_expires_at: DateTime<Utc>, 14 - ) -> Result<(), StorageError> { 15 - // Validate input parameters 16 - if session_group.trim().is_empty() { 17 - return Err(StorageError::UnableToExecuteQuery(sqlx::Error::Protocol( 18 - "Session group cannot be empty".into(), 19 - ))); 20 - } 21 - 22 - if access_token.trim().is_empty() { 23 - return Err(StorageError::UnableToExecuteQuery(sqlx::Error::Protocol( 24 - "Access token cannot be empty".into(), 25 - ))); 26 - } 27 - 28 - if refresh_token.trim().is_empty() { 29 - return Err(StorageError::UnableToExecuteQuery(sqlx::Error::Protocol( 30 - "Refresh token cannot be empty".into(), 31 - ))); 32 - } 33 - 34 - let mut tx = pool 35 - .begin() 36 - .await 37 - .map_err(StorageError::CannotBeginDatabaseTransaction)?; 38 - 39 - sqlx::query("UPDATE oauth_sessions SET access_token = $1, refresh_token = $2, access_token_expires_at = $3 WHERE session_group = $4") 40 - .bind(access_token) 41 - .bind(refresh_token) 42 - .bind(access_token_expires_at) 43 - .bind(session_group) 44 - .execute(tx.as_mut()) 45 - .await 46 - .map_err(StorageError::UnableToExecuteQuery)?; 47 - 48 - tx.commit() 49 - .await 50 - .map_err(StorageError::CannotCommitDatabaseTransaction) 51 - } 52 - 53 - /// Delete an OAuth session by its session group. 54 - pub async fn oauth_session_delete( 55 - pool: &StoragePool, 56 - session_group: &str, 57 - ) -> Result<(), StorageError> { 58 - // Validate session_group is not empty 59 - if session_group.trim().is_empty() { 60 - return Err(StorageError::UnableToExecuteQuery(sqlx::Error::Protocol( 61 - "Session group cannot be empty".into(), 62 - ))); 63 - } 64 - 65 - let mut tx = pool 66 - .begin() 67 - .await 68 - .map_err(StorageError::CannotBeginDatabaseTransaction)?; 69 - 70 - sqlx::query("DELETE FROM oauth_sessions WHERE session_group = $1") 71 - .bind(session_group) 72 - .execute(tx.as_mut()) 73 - .await 74 - .map_err(StorageError::UnableToExecuteQuery)?; 75 - 76 - tx.commit() 77 - .await 78 - .map_err(StorageError::CannotCommitDatabaseTransaction) 79 - } 80 - 81 - /// Look up a web session by session group and optionally filter by DID. 82 - pub async fn web_session_lookup( 83 - pool: &StoragePool, 84 - session_group: &str, 85 - did: Option<&str>, 86 - ) -> Result<(IdentityProfile, OAuthSession), StorageError> { 87 - // Validate session_group is not empty 88 - if session_group.trim().is_empty() { 89 - return Err(StorageError::UnableToExecuteQuery(sqlx::Error::Protocol( 90 - "Session group cannot be empty".into(), 91 - ))); 92 - } 93 - 94 - // If did is provided, validate it's not empty 95 - if let Some(did_value) = did 96 - && did_value.trim().is_empty() 97 - { 98 - return Err(StorageError::UnableToExecuteQuery(sqlx::Error::Protocol( 99 - "DID cannot be empty".into(), 100 - ))); 101 - } 102 - 103 - let mut tx = pool 104 - .begin() 105 - .await 106 - .map_err(StorageError::CannotBeginDatabaseTransaction)?; 107 - 108 - let oauth_session = match did { 109 - Some(did_value) => { 110 - sqlx::query_as::<_, OAuthSession>( 111 - "SELECT * FROM oauth_sessions WHERE session_group = $1 AND did = $2 ORDER BY created_at DESC LIMIT 1", 112 - ) 113 - .bind(session_group) 114 - .bind(did_value) 115 - .fetch_one(tx.as_mut()) 116 - .await 117 - }, 118 - None => { 119 - sqlx::query_as::<_, OAuthSession>( 120 - "SELECT * FROM oauth_sessions WHERE session_group = $1 ORDER BY created_at DESC LIMIT 1", 121 - ) 122 - .bind(session_group) 123 - .fetch_one(tx.as_mut()) 124 - .await 125 - } 126 - } 127 - .map_err(|err| match err { 128 - sqlx::Error::RowNotFound => StorageError::WebSessionNotFound, 129 - other => StorageError::UnableToExecuteQuery(other), 130 - })?; 131 - 132 - let did_for_handle = did.unwrap_or(&oauth_session.did); 133 - 134 - let handle = 135 - sqlx::query_as::<_, IdentityProfile>("SELECT * FROM identity_profiles WHERE did = $1") 136 - .bind(did_for_handle) 137 - .fetch_one(tx.as_mut()) 138 - .await 139 - .map_err(|err| match err { 140 - sqlx::Error::RowNotFound => StorageError::HandleNotFound, 141 - other => StorageError::UnableToExecuteQuery(other), 142 - })?; 143 - 144 - tx.commit() 145 - .await 146 - .map_err(StorageError::CannotCommitDatabaseTransaction)?; 147 - 148 - Ok((handle, oauth_session)) 149 - } 150 - 151 1 pub mod model { 152 2 use chrono::{DateTime, Utc}; 153 3 use serde::Deserialize; 154 4 use sqlx::FromRow; 155 5 6 + /// OAuth request state stored during the OAuth flow. 7 + /// Used for PKCE verification and nonce validation. 156 8 #[derive(Clone, FromRow, Deserialize)] 157 9 pub struct OAuthRequest { 158 10 pub oauth_state: String, ··· 165 17 pub dpop_jwk: String, 166 18 pub created_at: DateTime<Utc>, 167 19 pub expires_at: DateTime<Utc>, 168 - } 169 - 170 - #[derive(Clone, FromRow, Deserialize)] 171 - pub struct OAuthSession { 172 - pub session_group: String, 173 - pub access_token: String, 174 - pub did: String, 175 - pub issuer: String, 176 - pub refresh_token: String, 177 - pub secret_jwk_id: String, 178 - pub dpop_jwk: String, 179 - pub created_at: DateTime<Utc>, 180 - pub access_token_expires_at: DateTime<Utc>, 181 20 } 182 21 }
+22 -37
static/.vite/manifest.json
··· 11 11 "css/cropper-BJgXXBRK.css" 12 12 ] 13 13 }, 14 - "_maps-CpDLi3o_.css": { 15 - "file": "css/maps-CpDLi3o_.css", 16 - "src": "_maps-CpDLi3o_.css" 14 + "_maps-DYqiRqwW.css": { 15 + "file": "css/maps-DYqiRqwW.css", 16 + "src": "_maps-DYqiRqwW.css" 17 17 }, 18 - "_maps-GDfHpVyJ.js": { 19 - "file": "js/maps-GDfHpVyJ.js", 18 + "_maps-Dzpg4_su.js": { 19 + "file": "js/maps-Dzpg4_su.js", 20 20 "name": "maps", 21 21 "isDynamicEntry": true, 22 22 "css": [ 23 - "css/maps-CpDLi3o_.css" 23 + "css/maps-DYqiRqwW.css" 24 24 ] 25 25 }, 26 26 "src/features/cropper/index.ts": { 27 - "file": "js/index-Bcnf8oUZ.js", 27 + "file": "js/index-8MdtY9qF.js", 28 28 "name": "index", 29 29 "src": "src/features/cropper/index.ts", 30 30 "isDynamicEntry": true, ··· 37 37 ] 38 38 }, 39 39 "src/features/cropper/profile-cropper.ts": { 40 - "file": "js/profile-cropper-DwPaCPSP.js", 40 + "file": "js/profile-cropper-Cp_DD48I.js", 41 41 "name": "profile-cropper", 42 42 "src": "src/features/cropper/profile-cropper.ts", 43 43 "isDynamicEntry": true, 44 44 "imports": [ 45 - "src/features/cropper/index.ts", 46 - "src/main.ts" 45 + "src/main.ts", 46 + "src/features/cropper/index.ts" 47 47 ] 48 48 }, 49 49 "src/features/lfg/heatmap.ts": { 50 - "file": "js/heatmap-CJsCFdcC.js", 50 + "file": "js/heatmap-BojFLSXV.js", 51 51 "name": "heatmap", 52 52 "src": "src/features/lfg/heatmap.ts", 53 53 "isDynamicEntry": true, 54 54 "imports": [ 55 55 "src/main.ts" 56 - ], 57 - "dynamicImports": [ 58 - "_maps-GDfHpVyJ.js", 59 - "_maps-GDfHpVyJ.js", 60 - "_maps-GDfHpVyJ.js" 61 56 ] 62 57 }, 63 58 "src/features/maps/event-map.ts": { 64 - "file": "js/event-map-BMN8EESL.js", 59 + "file": "js/event-map-BQ9ES8zV.js", 65 60 "name": "event-map", 66 61 "src": "src/features/maps/event-map.ts", 67 62 "isDynamicEntry": true, 68 63 "imports": [ 69 64 "src/main.ts" 70 - ], 71 - "dynamicImports": [ 72 - "_maps-GDfHpVyJ.js", 73 - "_maps-GDfHpVyJ.js", 74 - "_maps-GDfHpVyJ.js" 75 65 ] 76 66 }, 77 67 "src/features/maps/globe-map.ts": { 78 - "file": "js/globe-map-v0wYAEFW.js", 68 + "file": "js/globe-map-C_o1blDz.js", 79 69 "name": "globe-map", 80 70 "src": "src/features/maps/globe-map.ts", 81 71 "isDynamicEntry": true, ··· 83 73 "src/main.ts" 84 74 ], 85 75 "dynamicImports": [ 86 - "_maps-GDfHpVyJ.js", 87 - "_maps-GDfHpVyJ.js", 88 - "_maps-GDfHpVyJ.js" 76 + "_maps-Dzpg4_su.js", 77 + "_maps-Dzpg4_su.js", 78 + "_maps-Dzpg4_su.js" 89 79 ] 90 80 }, 91 81 "src/features/maps/index.ts": { 92 - "file": "js/index-BP1lDIcH.js", 82 + "file": "js/index-Bb8tq7S1.js", 93 83 "name": "index", 94 84 "src": "src/features/maps/index.ts", 95 85 "isDynamicEntry": true, ··· 103 93 ] 104 94 }, 105 95 "src/features/maps/location-heatmap.ts": { 106 - "file": "js/location-heatmap-qsLOB3hq.js", 96 + "file": "js/location-heatmap-XJvZT2hb.js", 107 97 "name": "location-heatmap", 108 98 "src": "src/features/maps/location-heatmap.ts", 109 99 "isDynamicEntry": true, 110 100 "imports": [ 111 101 "src/main.ts" 112 - ], 113 - "dynamicImports": [ 114 - "_maps-GDfHpVyJ.js", 115 - "_maps-GDfHpVyJ.js", 116 - "_maps-GDfHpVyJ.js" 117 102 ] 118 103 }, 119 104 "src/main.ts": { 120 - "file": "js/main-CuQd5Sql.js", 105 + "file": "js/main-B2-Bk5P8.js", 121 106 "name": "main", 122 107 "src": "src/main.ts", 123 108 "isEntry": true, 124 109 "dynamicImports": [ 125 - "_maps-GDfHpVyJ.js", 126 - "_maps-GDfHpVyJ.js", 127 - "_maps-GDfHpVyJ.js", 110 + "_maps-Dzpg4_su.js", 111 + "_maps-Dzpg4_su.js", 112 + "_maps-Dzpg4_su.js", 128 113 "src/features/maps/index.ts", 129 114 "src/features/maps/index.ts", 130 115 "src/features/maps/index.ts",
-1
static/css/maps-CpDLi3o_.css
··· 1 - .leaflet-pane,.leaflet-tile,.leaflet-marker-icon,.leaflet-marker-shadow,.leaflet-tile-container,.leaflet-zoom-box,.leaflet-image-layer,.leaflet-layer,.leaflet-pane>svg,.leaflet-pane>canvas{position:absolute;top:0;left:0}.leaflet-container{overflow:hidden}.leaflet-tile,.leaflet-marker-icon,.leaflet-marker-shadow{-webkit-user-select:none;user-select:none;-webkit-user-drag:none}.leaflet-tile::selection{background:0 0}.leaflet-safari .leaflet-tile{image-rendering:-webkit-optimize-contrast}.leaflet-safari .leaflet-tile-container{-webkit-transform-origin:0 0;width:1600px;height:1600px}.leaflet-marker-icon,.leaflet-marker-shadow{display:block}.leaflet-container .leaflet-overlay-pane svg{max-width:none!important;max-height:none!important}.leaflet-container .leaflet-marker-pane img,.leaflet-container .leaflet-shadow-pane img,.leaflet-container .leaflet-tile-pane img,.leaflet-container img.leaflet-image-layer,.leaflet-container .leaflet-tile{width:auto;padding:0;max-width:none!important;max-height:none!important}.leaflet-container img.leaflet-tile{mix-blend-mode:plus-lighter}.leaflet-container.leaflet-touch-zoom{-ms-touch-action:pan-x pan-y;touch-action:pan-x pan-y}.leaflet-container.leaflet-touch-drag{-ms-touch-action:pinch-zoom;touch-action:none;touch-action:pinch-zoom}.leaflet-container.leaflet-touch-drag.leaflet-touch-zoom{-ms-touch-action:none;touch-action:none}.leaflet-container{-webkit-tap-highlight-color:transparent}.leaflet-container a{-webkit-tap-highlight-color:#33b5e566}.leaflet-tile{filter:inherit;visibility:hidden}.leaflet-tile-loaded{visibility:inherit}.leaflet-zoom-box{box-sizing:border-box;z-index:800;width:0;height:0}.leaflet-overlay-pane svg{-moz-user-select:none}.leaflet-pane{z-index:400}.leaflet-tile-pane{z-index:200}.leaflet-overlay-pane{z-index:400}.leaflet-shadow-pane{z-index:500}.leaflet-marker-pane{z-index:600}.leaflet-tooltip-pane{z-index:650}.leaflet-popup-pane{z-index:700}.leaflet-map-pane canvas{z-index:100}.leaflet-map-pane svg{z-index:200}.leaflet-vml-shape{width:1px;height:1px}.lvml{behavior:url(#default#VML);display:inline-block;position:absolute}.leaflet-control{z-index:800;pointer-events:visiblePainted;pointer-events:auto;position:relative}.leaflet-top,.leaflet-bottom{z-index:1000;pointer-events:none;position:absolute}.leaflet-top{top:0}.leaflet-right{right:0}.leaflet-bottom{bottom:0}.leaflet-left{left:0}.leaflet-control{float:left;clear:both}.leaflet-right .leaflet-control{float:right}.leaflet-top .leaflet-control{margin-top:10px}.leaflet-bottom .leaflet-control{margin-bottom:10px}.leaflet-left .leaflet-control{margin-left:10px}.leaflet-right .leaflet-control{margin-right:10px}.leaflet-fade-anim .leaflet-popup{opacity:0;transition:opacity .2s linear}.leaflet-fade-anim .leaflet-map-pane .leaflet-popup{opacity:1}.leaflet-zoom-animated{transform-origin:0 0}svg.leaflet-zoom-animated{will-change:transform}.leaflet-zoom-anim .leaflet-zoom-animated{-webkit-transition:-webkit-transform .25s cubic-bezier(0,0,.25,1);-moz-transition:-moz-transform .25s cubic-bezier(0,0,.25,1);transition:transform .25s cubic-bezier(0,0,.25,1)}.leaflet-zoom-anim .leaflet-tile,.leaflet-pan-anim .leaflet-tile{transition:none}.leaflet-zoom-anim .leaflet-zoom-hide{visibility:hidden}.leaflet-interactive{cursor:pointer}.leaflet-grab{cursor:-webkit-grab;cursor:-moz-grab;cursor:grab}.leaflet-crosshair,.leaflet-crosshair .leaflet-interactive{cursor:crosshair}.leaflet-popup-pane,.leaflet-control{cursor:auto}.leaflet-dragging .leaflet-grab,.leaflet-dragging .leaflet-grab .leaflet-interactive,.leaflet-dragging .leaflet-marker-draggable{cursor:move;cursor:-webkit-grabbing;cursor:-moz-grabbing;cursor:grabbing}.leaflet-marker-icon,.leaflet-marker-shadow,.leaflet-image-layer,.leaflet-tile-container,.leaflet-pane>svg path{pointer-events:none}.leaflet-marker-icon.leaflet-interactive,.leaflet-image-layer.leaflet-interactive,svg.leaflet-image-layer.leaflet-interactive path,.leaflet-pane>svg path.leaflet-interactive{pointer-events:visiblePainted;pointer-events:auto}.leaflet-container{outline-offset:1px;background:#ddd}.leaflet-container a{color:#0078a8}.leaflet-zoom-box{background:#ffffff80;border:2px dotted #38f}.leaflet-container{font-family:Helvetica Neue,Arial,Helvetica,sans-serif;font-size:.75rem;line-height:1.5}.leaflet-bar{border-radius:4px;box-shadow:0 1px 5px #000000a6}.leaflet-bar a{text-align:center;color:#000;background-color:#fff;border-bottom:1px solid #ccc;width:26px;height:26px;line-height:26px;text-decoration:none;display:block}.leaflet-bar a,.leaflet-control-layers-toggle{background-position:50%;background-repeat:no-repeat;display:block}.leaflet-bar a:hover,.leaflet-bar a:focus{background-color:#f4f4f4}.leaflet-bar a:first-child{border-top-left-radius:4px;border-top-right-radius:4px}.leaflet-bar a:last-child{border-bottom:none;border-bottom-right-radius:4px;border-bottom-left-radius:4px}.leaflet-bar a.leaflet-disabled{cursor:default;color:#bbb;background-color:#f4f4f4}.leaflet-touch .leaflet-bar a{width:30px;height:30px;line-height:30px}.leaflet-touch .leaflet-bar a:first-child{border-top-left-radius:2px;border-top-right-radius:2px}.leaflet-touch .leaflet-bar a:last-child{border-bottom-right-radius:2px;border-bottom-left-radius:2px}.leaflet-control-zoom-in,.leaflet-control-zoom-out{text-indent:1px;font:700 18px Lucida Console,Monaco,monospace}.leaflet-touch .leaflet-control-zoom-in,.leaflet-touch .leaflet-control-zoom-out{font-size:22px}.leaflet-control-layers{background:#fff;border-radius:5px;box-shadow:0 1px 5px #0006}.leaflet-control-layers-toggle{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAQAAAADQ4RFAAACf0lEQVR4AY1UM3gkARTePdvdoTxXKc+qTl3aU5U6b2Kbkz3Gtq3Zw6ziLGNPzrYx7946Tr6/ee/XeCQ4D3ykPtL5tHno4n0d/h3+xfuWHGLX81cn7r0iTNzjr7LrlxCqPtkbTQEHeqOrTy4Yyt3VCi/IOB0v7rVC7q45Q3Gr5K6jt+3Gl5nCoDD4MtO+j96Wu8atmhGqcNGHObuf8OM/x3AMx38+4Z2sPqzCxRFK2aF2e5Jol56XTLyggAMTL56XOMoS1W4pOyjUcGGQdZxU6qRh7B9Zp+PfpOFlqt0zyDZckPi1ttmIp03jX8gyJ8a/PG2yutpS/Vol7peZIbZcKBAEEheEIAgFbDkz5H6Zrkm2hVWGiXKiF4Ycw0RWKdtC16Q7qe3X4iOMxruonzegJzWaXFrU9utOSsLUmrc0YjeWYjCW4PDMADElpJSSQ0vQvA1Tm6/JlKnqFs1EGyZiFCqnRZTEJJJiKRYzVYzJck2Rm6P4iH+cmSY0YzimYa8l0EtTODFWhcMIMVqdsI2uiTvKmTisIDHJ3od5GILVhBCarCfVRmo4uTjkhrhzkiBV7SsaqS+TzrzM1qpGGUFt28pIySQHR6h7F6KSwGWm97ay+Z+ZqMcEjEWebE7wxCSQwpkhJqoZA5ivCdZDjJepuJ9IQjGGUmuXJdBFUygxVqVsxFsLMbDe8ZbDYVCGKxs+W080max1hFCarCfV+C1KATwcnvE9gRRuMP2prdbWGowm1KB1y+zwMMENkM755cJ2yPDtqhTI6ED1M/82yIDtC/4j4BijjeObflpO9I9MwXTCsSX8jWAFeHr05WoLTJ5G8IQVS/7vwR6ohirYM7f6HzYpogfS3R2OAAAAAElFTkSuQmCC);width:36px;height:36px}.leaflet-retina .leaflet-control-layers-toggle{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAAA0CAQAAABvcdNgAAAEsklEQVR4AWL4TydIhpZK1kpWOlg0w3ZXP6D2soBtG42jeI6ZmQTHzAxiTbSJsYLjO9HhP+WOmcuhciVnmHVQcJnp7DFvScowZorad/+V/fVzMdMT2g9Cv9guXGv/7pYOrXh2U+RRR3dSd9JRx6bIFc/ekqHI29JC6pJ5ZEh1yWkhkbcFeSjxgx3L2m1cb1C7bceyxA+CNjT/Ifff+/kDk2u/w/33/IeCMOSaWZ4glosqT3DNnNZQ7Cs58/3Ce5HL78iZH/vKVIaYlqzfdLu8Vi7dnvUbEza5Idt36tquZFldl6N5Z/POLof0XLK61mZCmJSWjVF9tEjUluu74IUXvgttuVIHE7YxSkaYhJZam7yiM9Pv82JYfl9nptxZaxMJE4YSPty+vF0+Y2up9d3wwijfjZbabqm/3bZ9ecKHsiGmRflnn1MW4pjHf9oLufyn2z3y1D6n8g8TZhxyzipLNPnAUpsOiuWimg52psrTZYnOWYNDTMuWBWa0tJb4rgq1UvmutpaYEbZlwU3CLJm/ayYjHW5/h7xWLn9Hh1vepDkyf7dE7MtT5LR4e7yYpHrkhOUpEfssBLq2pPhAqoSWKUkk7EDqkmK6RrCEzqDjhNDWNE+XSMvkJRDWlZTmCW0l0PHQGRZY5t1L83kT0Y3l2SItk5JAWHl2dCOBm+fPu3fo5/3v61RMCO9Jx2EEYYhb0rmNQMX/vm7gqOEJLcXTGw3CAuRNeyaPWwjR8PRqKQ1PDA/dpv+on9Shox52WFnx0KY8onHayrJzm87i5h9xGw/tfkev0jGsQizqezUKjk12hBMKJ4kbCqGPVNXudyyrShovGw5CgxsRICxF6aRmSjlBnHRzg7Gx8fKqEubI2rahQYdR1YgDIRQO7JvQyD52hoIQx0mxa0ODtW2Iozn1le2iIRdzwWewedyZzewidueOGqlsn1MvcnQpuVwLGG3/IR1hIKxCjelIDZ8ldqWz25jWAsnldEnK0Zxro19TGVb2ffIZEsIO89EIEDvKMPrzmBOQcKQ+rroye6NgRRxqR4U8EAkz0CL6uSGOm6KQCdWjvjRiSP1BPalCRS5iQYiEIvxuBMJEWgzSoHADcVMuN7IuqqTeyUPq22qFimFtxDyBBJEwNyt6TM88blFHao/6tWWhuuOM4SAK4EI4QmFHA+SEyWlp4EQoJ13cYGzMu7yszEIBOm2rVmHUNqwAIQabISNMRstmdhNWcFLsSm+0tjJH1MdRxO5Nx0WDMhCtgD6OKgZeljJqJKc9po8juskR9XN0Y1lZ3mWjLR9JCO1jRDMd0fpYC2VnvjBSEFg7wBENc0R9HFlb0xvF1+TBEpF68d+DHR6IOWVv2BECtxo46hOFUBd/APU57WIoEwJhIi2CdpyZX0m93BZicktMj1AS9dClteUFAUNUIEygRZCtik5zSxI9MubTBH1GOiHsiLJ3OCoSZkILa9PxiN0EbvhsAo8tdAf9Seepd36lGWHmtNANTv5Jd0z4QYyeo/UEJqxKRpg5LZx6btLPsOaEmdMyxYdlc8LMaJnikDlhclqmPiQnTEpLUIZEwkRagjYkEibQErwhkTAKCLQEbUgkzJQWc/0PstHHcfEdQ+UAAAAASUVORK5CYII=);background-size:26px 26px}.leaflet-touch .leaflet-control-layers-toggle{width:44px;height:44px}.leaflet-control-layers .leaflet-control-layers-list,.leaflet-control-layers-expanded .leaflet-control-layers-toggle{display:none}.leaflet-control-layers-expanded .leaflet-control-layers-list{display:block;position:relative}.leaflet-control-layers-expanded{color:#333;background:#fff;padding:6px 10px 6px 6px}.leaflet-control-layers-scrollbar{padding-right:5px;overflow:hidden scroll}.leaflet-control-layers-selector{margin-top:2px;position:relative;top:1px}.leaflet-control-layers label{font-size:1.08333em;display:block}.leaflet-control-layers-separator{border-top:1px solid #ddd;height:0;margin:5px -10px 5px -6px}.leaflet-default-icon-path{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAApCAYAAADAk4LOAAAFgUlEQVR4Aa1XA5BjWRTN2oW17d3YaZtr2962HUzbDNpjszW24mRt28p47v7zq/bXZtrp/lWnXr337j3nPCe85NcypgSFdugCpW5YoDAMRaIMqRi6aKq5E3YqDQO3qAwjVWrD8Ncq/RBpykd8oZUb/kaJutow8r1aP9II0WmLKLIsJyv1w/kqw9Ch2MYdB++12Onxee/QMwvf4/Dk/Lfp/i4nxTXtOoQ4pW5Aj7wpici1A9erdAN2OH64x8OSP9j3Ft3b7aWkTg/Fm91siTra0f9on5sQr9INejH6CUUUpavjFNq1B+Oadhxmnfa8RfEmN8VNAsQhPqF55xHkMzz3jSmChWU6f7/XZKNH+9+hBLOHYozuKQPxyMPUKkrX/K0uWnfFaJGS1QPRtZsOPtr3NsW0uyh6NNCOkU3Yz+bXbT3I8G3xE5EXLXtCXbbqwCO9zPQYPRTZ5vIDXD7U+w7rFDEoUUf7ibHIR4y6bLVPXrz8JVZEql13trxwue/uDivd3fkWRbS6/IA2bID4uk0UpF1N8qLlbBlXs4Ee7HLTfV1j54APvODnSfOWBqtKVvjgLKzF5YdEk5ewRkGlK0i33Eofffc7HT56jD7/6U+qH3Cx7SBLNntH5YIPvODnyfIXZYRVDPqgHtLs5ABHD3YzLuespb7t79FY34DjMwrVrcTuwlT55YMPvOBnRrJ4VXTdNnYug5ucHLBjEpt30701A3Ts+HEa73u6dT3FNWwflY86eMHPk+Yu+i6pzUpRrW7SNDg5JHR4KapmM5Wv2E8Tfcb1HoqqHMHU+uWDD7zg54mz5/2BSnizi9T1Dg4QQXLToGNCkb6tb1NU+QAlGr1++eADrzhn/u8Q2YZhQVlZ5+CAOtqfbhmaUCS1ezNFVm2imDbPmPng5wmz+gwh+oHDce0eUtQ6OGDIyR0uUhUsoO3vfDmmgOezH0mZN59x7MBi++WDL1g/eEiU3avlidO671bkLfwbw5XV2P8Pzo0ydy4t2/0eu33xYSOMOD8hTf4CrBtGMSoXfPLchX+J0ruSePw3LZeK0juPJbYzrhkH0io7B3k164hiGvawhOKMLkrQLyVpZg8rHFW7E2uHOL888IBPlNZ1FPzstSJM694fWr6RwpvcJK60+0HCILTBzZLFNdtAzJaohze60T8qBzyh5ZuOg5e7uwQppofEmf2++DYvmySqGBuKaicF1blQjhuHdvCIMvp8whTTfZzI7RldpwtSzL+F1+wkdZ2TBOW2gIF88PBTzD/gpeREAMEbxnJcaJHNHrpzji0gQCS6hdkEeYt9DF/2qPcEC8RM28Hwmr3sdNyht00byAut2k3gufWNtgtOEOFGUwcXWNDbdNbpgBGxEvKkOQsxivJx33iow0Vw5S6SVTrpVq11ysA2Rp7gTfPfktc6zhtXBBC+adRLshf6sG2RfHPZ5EAc4sVZ83yCN00Fk/4kggu40ZTvIEm5g24qtU4KjBrx/BTTH8ifVASAG7gKrnWxJDcU7x8X6Ecczhm3o6YicvsLXWfh3Ch1W0k8x0nXF+0fFxgt4phz8QvypiwCCFKMqXCnqXExjq10beH+UUA7+nG6mdG/Pu0f3LgFcGrl2s0kNNjpmoJ9o4B29CMO8dMT4Q5ox8uitF6fqsrJOr8qnwNbRzv6hSnG5wP+64C7h9lp30hKNtKdWjtdkbuPA19nJ7Tz3zR/ibgARbhb4AlhavcBebmTHcFl2fvYEnW0ox9xMxKBS8btJ+KiEbq9zA4RthQXDhPa0T9TEe69gWupwc6uBUphquXgf+/FrIjweHQS4/pduMe5ERUMHUd9xv8ZR98CxkS4F2n3EUrUZ10EYNw7BWm9x1GiPssi3GgiGRDKWRYZfXlON+dfNbM+GgIwYdwAAAAASUVORK5CYII=)}.leaflet-container .leaflet-control-attribution{background:#fffc;margin:0}.leaflet-control-attribution,.leaflet-control-scale-line{color:#333;padding:0 5px;line-height:1.4}.leaflet-control-attribution a{text-decoration:none}.leaflet-control-attribution a:hover,.leaflet-control-attribution a:focus{text-decoration:underline}.leaflet-attribution-flag{width:1em;height:.6669em;vertical-align:baseline!important;display:inline!important}.leaflet-left .leaflet-control-scale{margin-left:5px}.leaflet-bottom .leaflet-control-scale{margin-bottom:5px}.leaflet-control-scale-line{white-space:nowrap;box-sizing:border-box;text-shadow:1px 1px #fff;background:#fffc;border:2px solid #777;border-top:none;padding:2px 5px 1px;line-height:1.1}.leaflet-control-scale-line:not(:first-child){border-top:2px solid #777;border-bottom:none;margin-top:-2px}.leaflet-control-scale-line:not(:first-child):not(:last-child){border-bottom:2px solid #777}.leaflet-touch .leaflet-control-attribution,.leaflet-touch .leaflet-control-layers,.leaflet-touch .leaflet-bar{box-shadow:none}.leaflet-touch .leaflet-control-layers,.leaflet-touch .leaflet-bar{background-clip:padding-box;border:2px solid #0003}.leaflet-popup{text-align:center;margin-bottom:20px;position:absolute}.leaflet-popup-content-wrapper{text-align:left;border-radius:12px;padding:1px}.leaflet-popup-content{min-height:1px;margin:13px 24px 13px 20px;font-size:1.08333em;line-height:1.3}.leaflet-popup-content p{margin:1.3em 0}.leaflet-popup-tip-container{pointer-events:none;width:40px;height:20px;margin-top:-1px;margin-left:-20px;position:absolute;left:50%;overflow:hidden}.leaflet-popup-tip{pointer-events:auto;width:17px;height:17px;margin:-10px auto 0;padding:1px;transform:rotate(45deg)}.leaflet-popup-content-wrapper,.leaflet-popup-tip{color:#333;background:#fff;box-shadow:0 3px 14px #0006}.leaflet-container a.leaflet-popup-close-button{text-align:center;color:#757575;background:0 0;border:none;width:24px;height:24px;font:16px/24px Tahoma,Verdana,sans-serif;text-decoration:none;position:absolute;top:0;right:0}.leaflet-container a.leaflet-popup-close-button:hover,.leaflet-container a.leaflet-popup-close-button:focus{color:#585858}.leaflet-popup-scrolled{overflow:auto}.leaflet-oldie .leaflet-popup-content-wrapper{-ms-zoom:1}.leaflet-oldie .leaflet-popup-tip{-ms-filter:"progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)";width:24px;filter:progid:DXImageTransform.Microsoft.Matrix(M11=.707107,M12=.707107,M21=-.707107,M22=.707107);margin:0 auto}.leaflet-oldie .leaflet-control-zoom,.leaflet-oldie .leaflet-control-layers,.leaflet-oldie .leaflet-popup-content-wrapper,.leaflet-oldie .leaflet-popup-tip{border:1px solid #999}.leaflet-div-icon{background:#fff;border:1px solid #666}.leaflet-tooltip{color:#222;white-space:nowrap;-webkit-user-select:none;user-select:none;pointer-events:none;background-color:#fff;border:1px solid #fff;border-radius:3px;padding:6px;position:absolute;box-shadow:0 1px 3px #0006}.leaflet-tooltip.leaflet-interactive{cursor:pointer;pointer-events:auto}.leaflet-tooltip-top:before,.leaflet-tooltip-bottom:before,.leaflet-tooltip-left:before,.leaflet-tooltip-right:before{pointer-events:none;content:"";background:0 0;border:6px solid #0000;position:absolute}.leaflet-tooltip-bottom{margin-top:6px}.leaflet-tooltip-top{margin-top:-6px}.leaflet-tooltip-bottom:before,.leaflet-tooltip-top:before{margin-left:-6px;left:50%}.leaflet-tooltip-top:before{border-top-color:#fff;margin-bottom:-12px;bottom:0}.leaflet-tooltip-bottom:before{border-bottom-color:#fff;margin-top:-12px;margin-left:-6px;top:0}.leaflet-tooltip-left{margin-left:-6px}.leaflet-tooltip-right{margin-left:6px}.leaflet-tooltip-left:before,.leaflet-tooltip-right:before{margin-top:-6px;top:50%}.leaflet-tooltip-left:before{border-left-color:#fff;margin-right:-12px;right:0}.leaflet-tooltip-right:before{border-right-color:#fff;margin-left:-12px;left:0}@media print{.leaflet-control{-webkit-print-color-adjust:exact;print-color-adjust:exact}}.maplibregl-map{-webkit-tap-highlight-color:transparent;font:12px/20px Helvetica Neue,Arial,Helvetica,sans-serif;position:relative;overflow:hidden}.maplibregl-canvas{position:absolute;top:0;left:0}.maplibregl-map:-webkit-full-screen{width:100%;height:100%}.maplibregl-map:fullscreen{width:100%;height:100%}.maplibregl-ctrl-group button.maplibregl-ctrl-compass{touch-action:none}.maplibregl-canvas-container.maplibregl-interactive,.maplibregl-ctrl-group button.maplibregl-ctrl-compass{cursor:grab;-webkit-user-select:none;user-select:none}.maplibregl-canvas-container.maplibregl-interactive.maplibregl-track-pointer{cursor:pointer}.maplibregl-canvas-container.maplibregl-interactive:active,.maplibregl-ctrl-group button.maplibregl-ctrl-compass:active{cursor:grabbing}.maplibregl-canvas-container.maplibregl-touch-zoom-rotate,.maplibregl-canvas-container.maplibregl-touch-zoom-rotate .maplibregl-canvas{touch-action:pan-x pan-y}.maplibregl-canvas-container.maplibregl-touch-drag-pan,.maplibregl-canvas-container.maplibregl-touch-drag-pan .maplibregl-canvas{touch-action:pinch-zoom}.maplibregl-canvas-container.maplibregl-touch-zoom-rotate.maplibregl-touch-drag-pan,.maplibregl-canvas-container.maplibregl-touch-zoom-rotate.maplibregl-touch-drag-pan .maplibregl-canvas{touch-action:none}.maplibregl-canvas-container.maplibregl-touch-drag-pan.maplibregl-cooperative-gestures,.maplibregl-canvas-container.maplibregl-touch-drag-pan.maplibregl-cooperative-gestures .maplibregl-canvas{touch-action:pan-x pan-y}.maplibregl-ctrl-bottom-left,.maplibregl-ctrl-bottom-right,.maplibregl-ctrl-top-left,.maplibregl-ctrl-top-right{pointer-events:none;z-index:2;position:absolute}.maplibregl-ctrl-top-left{top:0;left:0}.maplibregl-ctrl-top-right{top:0;right:0}.maplibregl-ctrl-bottom-left{bottom:0;left:0}.maplibregl-ctrl-bottom-right{bottom:0;right:0}.maplibregl-ctrl{clear:both;pointer-events:auto;transform:translate(0)}.maplibregl-ctrl-top-left .maplibregl-ctrl{float:left;margin:10px 0 0 10px}.maplibregl-ctrl-top-right .maplibregl-ctrl{float:right;margin:10px 10px 0 0}.maplibregl-ctrl-bottom-left .maplibregl-ctrl{float:left;margin:0 0 10px 10px}.maplibregl-ctrl-bottom-right .maplibregl-ctrl{float:right;margin:0 10px 10px 0}.maplibregl-ctrl-group{background:#fff;border-radius:4px}.maplibregl-ctrl-group:not(:empty){box-shadow:0 0 0 2px #0000001a}@media (forced-colors:active){.maplibregl-ctrl-group:not(:empty){box-shadow:0 0 0 2px buttontext}}.maplibregl-ctrl-group button{box-sizing:border-box;cursor:pointer;background-color:#0000;border:0;outline:none;width:29px;height:29px;padding:0;display:block}.maplibregl-ctrl-group button+button{border-top:1px solid #ddd}.maplibregl-ctrl button .maplibregl-ctrl-icon{background-position:50%;background-repeat:no-repeat;width:100%;height:100%;display:block}@media (forced-colors:active){.maplibregl-ctrl-icon{background-color:#0000}.maplibregl-ctrl-group button+button{border-top:1px solid buttontext}}.maplibregl-ctrl button::-moz-focus-inner{border:0;padding:0}.maplibregl-ctrl-attrib-button:focus,.maplibregl-ctrl-group button:focus{box-shadow:0 0 2px 2px #0096ff}.maplibregl-ctrl button:disabled{cursor:not-allowed}.maplibregl-ctrl button:disabled .maplibregl-ctrl-icon{opacity:.25}@media (hover:hover){.maplibregl-ctrl button:not(:disabled):hover{background-color:#0000000d}}.maplibregl-ctrl button:not(:disabled):active{background-color:#0000000d}.maplibregl-ctrl-group button:focus:focus-visible{box-shadow:0 0 2px 2px #0096ff}.maplibregl-ctrl-group button:focus:not(:focus-visible){box-shadow:none}.maplibregl-ctrl-group button:focus:first-child{border-radius:4px 4px 0 0}.maplibregl-ctrl-group button:focus:last-child{border-radius:0 0 4px 4px}.maplibregl-ctrl-group button:focus:only-child{-webkit-border-radius:inherit;border-radius:inherit}.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5'/%3E%3C/svg%3E")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-globe .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='none' stroke='%23333' viewBox='0 0 22 22'%3E%3Ccircle cx='11' cy='11' r='8.5'/%3E%3Cpath d='M17.5 11c0 4.819-3.02 8.5-6.5 8.5S4.5 15.819 4.5 11 7.52 2.5 11 2.5s6.5 3.681 6.5 8.5Z'/%3E%3Cpath d='M13.5 11c0 2.447-.331 4.64-.853 6.206-.262.785-.562 1.384-.872 1.777-.314.399-.58.517-.775.517s-.461-.118-.775-.517c-.31-.393-.61-.992-.872-1.777C8.831 15.64 8.5 13.446 8.5 11s.331-4.64.853-6.206c.262-.785.562-1.384.872-1.777.314-.399.58-.517.775-.517s.461.118.775.517c.31.393.61.992.872 1.777.522 1.565.853 3.76.853 6.206Z'/%3E%3Cpath d='M11 7.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138q.07-.058.224-.138c.299-.151.763-.302 1.379-.434C7.378 5.666 9.091 5.5 11 5.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138q-.07.058-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428ZM4.486 6.436ZM11 16.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138 1.3 1.3 0 0 1 .224-.138c.299-.151.763-.302 1.379-.434C7.378 14.666 9.091 14.5 11 14.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138a1.3 1.3 0 0 1-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428Zm-6.514-1.064ZM11 12.5c-2.46 0-4.672-.222-6.255-.574-.796-.177-1.406-.38-1.805-.59a1.5 1.5 0 0 1-.39-.272.3.3 0 0 1-.047-.064.3.3 0 0 1 .048-.064c.066-.073.189-.167.389-.272.399-.21 1.009-.413 1.805-.59C6.328 9.722 8.54 9.5 11 9.5s4.672.222 6.256.574c.795.177 1.405.38 1.804.59.2.105.323.2.39.272a.3.3 0 0 1 .047.064.3.3 0 0 1-.048.064 1.4 1.4 0 0 1-.389.272c-.399.21-1.009.413-1.804.59-1.584.352-3.796.574-6.256.574Zm-8.501-1.51v.002zm0 .018v.002zm17.002.002v-.002zm0-.018v-.002z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-globe-enabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='none' stroke='%2333b5e5' viewBox='0 0 22 22'%3E%3Ccircle cx='11' cy='11' r='8.5'/%3E%3Cpath d='M17.5 11c0 4.819-3.02 8.5-6.5 8.5S4.5 15.819 4.5 11 7.52 2.5 11 2.5s6.5 3.681 6.5 8.5Z'/%3E%3Cpath d='M13.5 11c0 2.447-.331 4.64-.853 6.206-.262.785-.562 1.384-.872 1.777-.314.399-.58.517-.775.517s-.461-.118-.775-.517c-.31-.393-.61-.992-.872-1.777C8.831 15.64 8.5 13.446 8.5 11s.331-4.64.853-6.206c.262-.785.562-1.384.872-1.777.314-.399.58-.517.775-.517s.461.118.775.517c.31.393.61.992.872 1.777.522 1.565.853 3.76.853 6.206Z'/%3E%3Cpath d='M11 7.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138q.07-.058.224-.138c.299-.151.763-.302 1.379-.434C7.378 5.666 9.091 5.5 11 5.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138q-.07.058-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428ZM4.486 6.436ZM11 16.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138 1.3 1.3 0 0 1 .224-.138c.299-.151.763-.302 1.379-.434C7.378 14.666 9.091 14.5 11 14.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138a1.3 1.3 0 0 1-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428Zm-6.514-1.064ZM11 12.5c-2.46 0-4.672-.222-6.255-.574-.796-.177-1.406-.38-1.805-.59a1.5 1.5 0 0 1-.39-.272.3.3 0 0 1-.047-.064.3.3 0 0 1 .048-.064c.066-.073.189-.167.389-.272.399-.21 1.009-.413 1.805-.59C6.328 9.722 8.54 9.5 11 9.5s4.672.222 6.256.574c.795.177 1.405.38 1.804.59.2.105.323.2.39.272a.3.3 0 0 1 .047.064.3.3 0 0 1-.048.064 1.4 1.4 0 0 1-.389.272c-.399.21-1.009.413-1.804.59-1.584.352-3.796.574-6.256.574Zm-8.501-1.51v.002zm0 .018v.002zm17.002.002v-.002zm0-.018v-.002z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-terrain .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='%23333' viewBox='0 0 22 22'%3E%3Cpath d='m1.754 13.406 4.453-4.851 3.09 3.09 3.281 3.277.969-.969-3.309-3.312 3.844-4.121 6.148 6.886h1.082v-.855l-7.207-8.07-4.84 5.187L6.169 6.57l-5.48 5.965v.871ZM.688 16.844h20.625v1.375H.688Zm0 0'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-terrain-enabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='%2333b5e5' viewBox='0 0 22 22'%3E%3Cpath d='m1.754 13.406 4.453-4.851 3.09 3.09 3.281 3.277.969-.969-3.309-3.312 3.844-4.121 6.148 6.886h1.082v-.855l-7.207-8.07-4.84 5.187L6.169 6.57l-5.48 5.965v.871ZM.688 16.844h20.625v1.375H.688Zm0 0'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23aaa' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e58978' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e54e33' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-waiting .maplibregl-ctrl-icon{animation:2s linear infinite maplibregl-spin}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23999' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e58978' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e54e33' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23666' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E")}}@keyframes maplibregl-spin{0%{transform:rotate(0)}to{transform:rotate(1turn)}}a.maplibregl-ctrl-logo{cursor:pointer;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3C/g%3E%3C/svg%3E");background-repeat:no-repeat;width:88px;height:23px;margin:0 0 -4px -4px;display:block;overflow:hidden}a.maplibregl-ctrl-logo.maplibregl-compact{width:14px}@media (forced-colors:active){a.maplibregl-ctrl-logo{background-color:#0000;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3C/g%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){a.maplibregl-ctrl-logo{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3C/g%3E%3C/svg%3E")}}.maplibregl-ctrl.maplibregl-ctrl-attrib{background-color:#ffffff80;margin:0;padding:0 5px}@media screen{.maplibregl-ctrl-attrib.maplibregl-compact{box-sizing:content-box;color:#000;background-color:#fff;border-radius:12px;min-height:20px;margin:10px;padding:2px 24px 2px 0;position:relative}.maplibregl-ctrl-attrib.maplibregl-compact-show{visibility:visible;padding:2px 28px 2px 8px}.maplibregl-ctrl-bottom-left>.maplibregl-ctrl-attrib.maplibregl-compact-show,.maplibregl-ctrl-top-left>.maplibregl-ctrl-attrib.maplibregl-compact-show{border-radius:12px;padding:2px 8px 2px 28px}.maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-inner{display:none}.maplibregl-ctrl-attrib-button{box-sizing:border-box;cursor:pointer;background-color:#ffffff80;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill-rule='evenodd' viewBox='0 0 20 20'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E");border:0;border-radius:12px;outline:none;width:24px;height:24px;display:none;position:absolute;top:0;right:0}.maplibregl-ctrl-attrib summary.maplibregl-ctrl-attrib-button{-webkit-appearance:none;-moz-appearance:none;appearance:none;list-style:none}.maplibregl-ctrl-attrib summary.maplibregl-ctrl-attrib-button::-webkit-details-marker{display:none}.maplibregl-ctrl-bottom-left .maplibregl-ctrl-attrib-button,.maplibregl-ctrl-top-left .maplibregl-ctrl-attrib-button{left:0}.maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-button,.maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-inner{display:block}.maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-button{background-color:#0000000d}.maplibregl-ctrl-bottom-right>.maplibregl-ctrl-attrib.maplibregl-compact:after{bottom:0;right:0}.maplibregl-ctrl-top-right>.maplibregl-ctrl-attrib.maplibregl-compact:after{top:0;right:0}.maplibregl-ctrl-top-left>.maplibregl-ctrl-attrib.maplibregl-compact:after{top:0;left:0}.maplibregl-ctrl-bottom-left>.maplibregl-ctrl-attrib.maplibregl-compact:after{bottom:0;left:0}}@media screen and (forced-colors:active){.maplibregl-ctrl-attrib.maplibregl-compact:after{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='%23fff' fill-rule='evenodd' viewBox='0 0 20 20'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E")}}@media screen and (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl-attrib.maplibregl-compact:after{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill-rule='evenodd' viewBox='0 0 20 20'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E")}}.maplibregl-ctrl-attrib a{color:#000000bf;text-decoration:none}.maplibregl-ctrl-attrib a:hover{color:inherit;text-decoration:underline}.maplibregl-attrib-empty{display:none}.maplibregl-ctrl-scale{box-sizing:border-box;color:#333;white-space:nowrap;background-color:#ffffffbf;border:2px solid #333;border-top:#333;padding:0 5px;font-size:10px}.maplibregl-popup{pointer-events:none;will-change:transform;display:flex;position:absolute;top:0;left:0}.maplibregl-popup-anchor-top,.maplibregl-popup-anchor-top-left,.maplibregl-popup-anchor-top-right{flex-direction:column}.maplibregl-popup-anchor-bottom,.maplibregl-popup-anchor-bottom-left,.maplibregl-popup-anchor-bottom-right{flex-direction:column-reverse}.maplibregl-popup-anchor-left{flex-direction:row}.maplibregl-popup-anchor-right{flex-direction:row-reverse}.maplibregl-popup-tip{z-index:1;border:10px solid #0000;width:0;height:0}.maplibregl-popup-anchor-top .maplibregl-popup-tip{border-top:none;border-bottom-color:#fff;align-self:center}.maplibregl-popup-anchor-top-left .maplibregl-popup-tip{border-top:none;border-bottom-color:#fff;border-left:none;align-self:flex-start}.maplibregl-popup-anchor-top-right .maplibregl-popup-tip{border-top:none;border-bottom-color:#fff;border-right:none;align-self:flex-end}.maplibregl-popup-anchor-bottom .maplibregl-popup-tip{border-top-color:#fff;border-bottom:none;align-self:center}.maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip{border-top-color:#fff;border-bottom:none;border-left:none;align-self:flex-start}.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip{border-top-color:#fff;border-bottom:none;border-right:none;align-self:flex-end}.maplibregl-popup-anchor-left .maplibregl-popup-tip{border-left:none;border-right-color:#fff;align-self:center}.maplibregl-popup-anchor-right .maplibregl-popup-tip{border-left-color:#fff;border-right:none;align-self:center}.maplibregl-popup-close-button{cursor:pointer;background-color:#0000;border:0;border-radius:0 3px 0 0;position:absolute;top:0;right:0}.maplibregl-popup-close-button:hover{background-color:#0000000d}.maplibregl-popup-content{pointer-events:auto;background:#fff;border-radius:3px;padding:15px 10px;position:relative;box-shadow:0 1px 2px #0000001a}.maplibregl-popup-anchor-top-left .maplibregl-popup-content{border-top-left-radius:0}.maplibregl-popup-anchor-top-right .maplibregl-popup-content{border-top-right-radius:0}.maplibregl-popup-anchor-bottom-left .maplibregl-popup-content{border-bottom-left-radius:0}.maplibregl-popup-anchor-bottom-right .maplibregl-popup-content{border-bottom-right-radius:0}.maplibregl-popup-track-pointer{display:none}.maplibregl-popup-track-pointer *{pointer-events:none;-webkit-user-select:none;user-select:none}.maplibregl-map:hover .maplibregl-popup-track-pointer{display:flex}.maplibregl-map:active .maplibregl-popup-track-pointer{display:none}.maplibregl-marker{will-change:transform;transition:opacity .2s;position:absolute;top:0;left:0}.maplibregl-user-location-dot,.maplibregl-user-location-dot:before{background-color:#1da1f2;border-radius:50%;width:15px;height:15px}.maplibregl-user-location-dot:before{content:"";animation:2s infinite maplibregl-user-location-dot-pulse;position:absolute}.maplibregl-user-location-dot:after{box-sizing:border-box;content:"";border:2px solid #fff;border-radius:50%;width:19px;height:19px;position:absolute;top:-2px;left:-2px;box-shadow:0 0 3px #00000059}@keyframes maplibregl-user-location-dot-pulse{0%{opacity:1;transform:scale(1)}70%{opacity:0;transform:scale(3)}to{opacity:0;transform:scale(1)}}.maplibregl-user-location-dot-stale{background-color:#aaa}.maplibregl-user-location-dot-stale:after{display:none}.maplibregl-user-location-accuracy-circle{background-color:#1da1f233;border-radius:100%;width:1px;height:1px}.maplibregl-crosshair,.maplibregl-crosshair .maplibregl-interactive,.maplibregl-crosshair .maplibregl-interactive:active{cursor:crosshair}.maplibregl-boxzoom{opacity:.5;background:#fff;border:2px dotted #202020;width:0;height:0;position:absolute;top:0;left:0}.maplibregl-cooperative-gesture-screen{color:#fff;opacity:0;pointer-events:none;z-index:99999;background:#0006;justify-content:center;align-items:center;padding:1rem;font-size:1.4em;line-height:1.2;transition:opacity 1s 1s;display:flex;position:absolute;top:0;bottom:0;left:0;right:0}.maplibregl-cooperative-gesture-screen.maplibregl-show{opacity:1;transition:opacity 50ms}.maplibregl-cooperative-gesture-screen .maplibregl-mobile-message{display:none}@media (hover:none),(pointer:coarse){.maplibregl-cooperative-gesture-screen .maplibregl-desktop-message{display:none}.maplibregl-cooperative-gesture-screen .maplibregl-mobile-message{display:block}}.maplibregl-pseudo-fullscreen{z-index:99999;width:100%!important;height:100%!important;position:fixed!important;top:0!important;left:0!important}
+1
static/css/maps-DYqiRqwW.css
··· 1 + .maplibregl-map{-webkit-tap-highlight-color:transparent;font:12px/20px Helvetica Neue,Arial,Helvetica,sans-serif;position:relative;overflow:hidden}.maplibregl-canvas{position:absolute;top:0;left:0}.maplibregl-map:-webkit-full-screen{width:100%;height:100%}.maplibregl-map:fullscreen{width:100%;height:100%}.maplibregl-ctrl-group button.maplibregl-ctrl-compass{touch-action:none}.maplibregl-canvas-container.maplibregl-interactive,.maplibregl-ctrl-group button.maplibregl-ctrl-compass{cursor:grab;-webkit-user-select:none;user-select:none}.maplibregl-canvas-container.maplibregl-interactive.maplibregl-track-pointer{cursor:pointer}.maplibregl-canvas-container.maplibregl-interactive:active,.maplibregl-ctrl-group button.maplibregl-ctrl-compass:active{cursor:grabbing}.maplibregl-canvas-container.maplibregl-touch-zoom-rotate,.maplibregl-canvas-container.maplibregl-touch-zoom-rotate .maplibregl-canvas{touch-action:pan-x pan-y}.maplibregl-canvas-container.maplibregl-touch-drag-pan,.maplibregl-canvas-container.maplibregl-touch-drag-pan .maplibregl-canvas{touch-action:pinch-zoom}.maplibregl-canvas-container.maplibregl-touch-zoom-rotate.maplibregl-touch-drag-pan,.maplibregl-canvas-container.maplibregl-touch-zoom-rotate.maplibregl-touch-drag-pan .maplibregl-canvas{touch-action:none}.maplibregl-canvas-container.maplibregl-touch-drag-pan.maplibregl-cooperative-gestures,.maplibregl-canvas-container.maplibregl-touch-drag-pan.maplibregl-cooperative-gestures .maplibregl-canvas{touch-action:pan-x pan-y}.maplibregl-ctrl-bottom-left,.maplibregl-ctrl-bottom-right,.maplibregl-ctrl-top-left,.maplibregl-ctrl-top-right{pointer-events:none;z-index:2;position:absolute}.maplibregl-ctrl-top-left{top:0;left:0}.maplibregl-ctrl-top-right{top:0;right:0}.maplibregl-ctrl-bottom-left{bottom:0;left:0}.maplibregl-ctrl-bottom-right{bottom:0;right:0}.maplibregl-ctrl{clear:both;pointer-events:auto;transform:translate(0)}.maplibregl-ctrl-top-left .maplibregl-ctrl{float:left;margin:10px 0 0 10px}.maplibregl-ctrl-top-right .maplibregl-ctrl{float:right;margin:10px 10px 0 0}.maplibregl-ctrl-bottom-left .maplibregl-ctrl{float:left;margin:0 0 10px 10px}.maplibregl-ctrl-bottom-right .maplibregl-ctrl{float:right;margin:0 10px 10px 0}.maplibregl-ctrl-group{background:#fff;border-radius:4px}.maplibregl-ctrl-group:not(:empty){box-shadow:0 0 0 2px #0000001a}@media (forced-colors:active){.maplibregl-ctrl-group:not(:empty){box-shadow:0 0 0 2px buttontext}}.maplibregl-ctrl-group button{box-sizing:border-box;cursor:pointer;background-color:#0000;border:0;outline:none;width:29px;height:29px;padding:0;display:block}.maplibregl-ctrl-group button+button{border-top:1px solid #ddd}.maplibregl-ctrl button .maplibregl-ctrl-icon{background-position:50%;background-repeat:no-repeat;width:100%;height:100%;display:block}@media (forced-colors:active){.maplibregl-ctrl-icon{background-color:#0000}.maplibregl-ctrl-group button+button{border-top:1px solid buttontext}}.maplibregl-ctrl button::-moz-focus-inner{border:0;padding:0}.maplibregl-ctrl-attrib-button:focus,.maplibregl-ctrl-group button:focus{box-shadow:0 0 2px 2px #0096ff}.maplibregl-ctrl button:disabled{cursor:not-allowed}.maplibregl-ctrl button:disabled .maplibregl-ctrl-icon{opacity:.25}@media (hover:hover){.maplibregl-ctrl button:not(:disabled):hover{background-color:#0000000d}}.maplibregl-ctrl button:not(:disabled):active{background-color:#0000000d}.maplibregl-ctrl-group button:focus:focus-visible{box-shadow:0 0 2px 2px #0096ff}.maplibregl-ctrl-group button:focus:not(:focus-visible){box-shadow:none}.maplibregl-ctrl-group button:focus:first-child{border-radius:4px 4px 0 0}.maplibregl-ctrl-group button:focus:last-child{border-radius:0 0 4px 4px}.maplibregl-ctrl-group button:focus:only-child{-webkit-border-radius:inherit;border-radius:inherit}.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5'/%3E%3C/svg%3E")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-globe .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='none' stroke='%23333' viewBox='0 0 22 22'%3E%3Ccircle cx='11' cy='11' r='8.5'/%3E%3Cpath d='M17.5 11c0 4.819-3.02 8.5-6.5 8.5S4.5 15.819 4.5 11 7.52 2.5 11 2.5s6.5 3.681 6.5 8.5Z'/%3E%3Cpath d='M13.5 11c0 2.447-.331 4.64-.853 6.206-.262.785-.562 1.384-.872 1.777-.314.399-.58.517-.775.517s-.461-.118-.775-.517c-.31-.393-.61-.992-.872-1.777C8.831 15.64 8.5 13.446 8.5 11s.331-4.64.853-6.206c.262-.785.562-1.384.872-1.777.314-.399.58-.517.775-.517s.461.118.775.517c.31.393.61.992.872 1.777.522 1.565.853 3.76.853 6.206Z'/%3E%3Cpath d='M11 7.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138q.07-.058.224-.138c.299-.151.763-.302 1.379-.434C7.378 5.666 9.091 5.5 11 5.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138q-.07.058-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428ZM4.486 6.436ZM11 16.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138 1.3 1.3 0 0 1 .224-.138c.299-.151.763-.302 1.379-.434C7.378 14.666 9.091 14.5 11 14.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138a1.3 1.3 0 0 1-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428Zm-6.514-1.064ZM11 12.5c-2.46 0-4.672-.222-6.255-.574-.796-.177-1.406-.38-1.805-.59a1.5 1.5 0 0 1-.39-.272.3.3 0 0 1-.047-.064.3.3 0 0 1 .048-.064c.066-.073.189-.167.389-.272.399-.21 1.009-.413 1.805-.59C6.328 9.722 8.54 9.5 11 9.5s4.672.222 6.256.574c.795.177 1.405.38 1.804.59.2.105.323.2.39.272a.3.3 0 0 1 .047.064.3.3 0 0 1-.048.064 1.4 1.4 0 0 1-.389.272c-.399.21-1.009.413-1.804.59-1.584.352-3.796.574-6.256.574Zm-8.501-1.51v.002zm0 .018v.002zm17.002.002v-.002zm0-.018v-.002z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-globe-enabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='none' stroke='%2333b5e5' viewBox='0 0 22 22'%3E%3Ccircle cx='11' cy='11' r='8.5'/%3E%3Cpath d='M17.5 11c0 4.819-3.02 8.5-6.5 8.5S4.5 15.819 4.5 11 7.52 2.5 11 2.5s6.5 3.681 6.5 8.5Z'/%3E%3Cpath d='M13.5 11c0 2.447-.331 4.64-.853 6.206-.262.785-.562 1.384-.872 1.777-.314.399-.58.517-.775.517s-.461-.118-.775-.517c-.31-.393-.61-.992-.872-1.777C8.831 15.64 8.5 13.446 8.5 11s.331-4.64.853-6.206c.262-.785.562-1.384.872-1.777.314-.399.58-.517.775-.517s.461.118.775.517c.31.393.61.992.872 1.777.522 1.565.853 3.76.853 6.206Z'/%3E%3Cpath d='M11 7.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138q.07-.058.224-.138c.299-.151.763-.302 1.379-.434C7.378 5.666 9.091 5.5 11 5.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138q-.07.058-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428ZM4.486 6.436ZM11 16.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138 1.3 1.3 0 0 1 .224-.138c.299-.151.763-.302 1.379-.434C7.378 14.666 9.091 14.5 11 14.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138a1.3 1.3 0 0 1-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428Zm-6.514-1.064ZM11 12.5c-2.46 0-4.672-.222-6.255-.574-.796-.177-1.406-.38-1.805-.59a1.5 1.5 0 0 1-.39-.272.3.3 0 0 1-.047-.064.3.3 0 0 1 .048-.064c.066-.073.189-.167.389-.272.399-.21 1.009-.413 1.805-.59C6.328 9.722 8.54 9.5 11 9.5s4.672.222 6.256.574c.795.177 1.405.38 1.804.59.2.105.323.2.39.272a.3.3 0 0 1 .047.064.3.3 0 0 1-.048.064 1.4 1.4 0 0 1-.389.272c-.399.21-1.009.413-1.804.59-1.584.352-3.796.574-6.256.574Zm-8.501-1.51v.002zm0 .018v.002zm17.002.002v-.002zm0-.018v-.002z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-terrain .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='%23333' viewBox='0 0 22 22'%3E%3Cpath d='m1.754 13.406 4.453-4.851 3.09 3.09 3.281 3.277.969-.969-3.309-3.312 3.844-4.121 6.148 6.886h1.082v-.855l-7.207-8.07-4.84 5.187L6.169 6.57l-5.48 5.965v.871ZM.688 16.844h20.625v1.375H.688Zm0 0'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-terrain-enabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='%2333b5e5' viewBox='0 0 22 22'%3E%3Cpath d='m1.754 13.406 4.453-4.851 3.09 3.09 3.281 3.277.969-.969-3.309-3.312 3.844-4.121 6.148 6.886h1.082v-.855l-7.207-8.07-4.84 5.187L6.169 6.57l-5.48 5.965v.871ZM.688 16.844h20.625v1.375H.688Zm0 0'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23aaa' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e58978' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e54e33' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-waiting .maplibregl-ctrl-icon{animation:2s linear infinite maplibregl-spin}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23999' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e58978' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e54e33' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23666' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E")}}@keyframes maplibregl-spin{0%{transform:rotate(0)}to{transform:rotate(1turn)}}a.maplibregl-ctrl-logo{cursor:pointer;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3C/g%3E%3C/svg%3E");background-repeat:no-repeat;width:88px;height:23px;margin:0 0 -4px -4px;display:block;overflow:hidden}a.maplibregl-ctrl-logo.maplibregl-compact{width:14px}@media (forced-colors:active){a.maplibregl-ctrl-logo{background-color:#0000;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3C/g%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){a.maplibregl-ctrl-logo{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3C/g%3E%3C/svg%3E")}}.maplibregl-ctrl.maplibregl-ctrl-attrib{background-color:#ffffff80;margin:0;padding:0 5px}@media screen{.maplibregl-ctrl-attrib.maplibregl-compact{box-sizing:content-box;color:#000;background-color:#fff;border-radius:12px;min-height:20px;margin:10px;padding:2px 24px 2px 0;position:relative}.maplibregl-ctrl-attrib.maplibregl-compact-show{visibility:visible;padding:2px 28px 2px 8px}.maplibregl-ctrl-bottom-left>.maplibregl-ctrl-attrib.maplibregl-compact-show,.maplibregl-ctrl-top-left>.maplibregl-ctrl-attrib.maplibregl-compact-show{border-radius:12px;padding:2px 8px 2px 28px}.maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-inner{display:none}.maplibregl-ctrl-attrib-button{box-sizing:border-box;cursor:pointer;background-color:#ffffff80;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill-rule='evenodd' viewBox='0 0 20 20'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E");border:0;border-radius:12px;outline:none;width:24px;height:24px;display:none;position:absolute;top:0;right:0}.maplibregl-ctrl-attrib summary.maplibregl-ctrl-attrib-button{-webkit-appearance:none;-moz-appearance:none;appearance:none;list-style:none}.maplibregl-ctrl-attrib summary.maplibregl-ctrl-attrib-button::-webkit-details-marker{display:none}.maplibregl-ctrl-bottom-left .maplibregl-ctrl-attrib-button,.maplibregl-ctrl-top-left .maplibregl-ctrl-attrib-button{left:0}.maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-button,.maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-inner{display:block}.maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-button{background-color:#0000000d}.maplibregl-ctrl-bottom-right>.maplibregl-ctrl-attrib.maplibregl-compact:after{bottom:0;right:0}.maplibregl-ctrl-top-right>.maplibregl-ctrl-attrib.maplibregl-compact:after{top:0;right:0}.maplibregl-ctrl-top-left>.maplibregl-ctrl-attrib.maplibregl-compact:after{top:0;left:0}.maplibregl-ctrl-bottom-left>.maplibregl-ctrl-attrib.maplibregl-compact:after{bottom:0;left:0}}@media screen and (forced-colors:active){.maplibregl-ctrl-attrib.maplibregl-compact:after{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='%23fff' fill-rule='evenodd' viewBox='0 0 20 20'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E")}}@media screen and (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl-attrib.maplibregl-compact:after{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill-rule='evenodd' viewBox='0 0 20 20'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E")}}.maplibregl-ctrl-attrib a{color:#000000bf;text-decoration:none}.maplibregl-ctrl-attrib a:hover{color:inherit;text-decoration:underline}.maplibregl-attrib-empty{display:none}.maplibregl-ctrl-scale{box-sizing:border-box;color:#333;white-space:nowrap;background-color:#ffffffbf;border:2px solid #333;border-top:#333;padding:0 5px;font-size:10px}.maplibregl-popup{pointer-events:none;will-change:transform;display:flex;position:absolute;top:0;left:0}.maplibregl-popup-anchor-top,.maplibregl-popup-anchor-top-left,.maplibregl-popup-anchor-top-right{flex-direction:column}.maplibregl-popup-anchor-bottom,.maplibregl-popup-anchor-bottom-left,.maplibregl-popup-anchor-bottom-right{flex-direction:column-reverse}.maplibregl-popup-anchor-left{flex-direction:row}.maplibregl-popup-anchor-right{flex-direction:row-reverse}.maplibregl-popup-tip{z-index:1;border:10px solid #0000;width:0;height:0}.maplibregl-popup-anchor-top .maplibregl-popup-tip{border-top:none;border-bottom-color:#fff;align-self:center}.maplibregl-popup-anchor-top-left .maplibregl-popup-tip{border-top:none;border-bottom-color:#fff;border-left:none;align-self:flex-start}.maplibregl-popup-anchor-top-right .maplibregl-popup-tip{border-top:none;border-bottom-color:#fff;border-right:none;align-self:flex-end}.maplibregl-popup-anchor-bottom .maplibregl-popup-tip{border-top-color:#fff;border-bottom:none;align-self:center}.maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip{border-top-color:#fff;border-bottom:none;border-left:none;align-self:flex-start}.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip{border-top-color:#fff;border-bottom:none;border-right:none;align-self:flex-end}.maplibregl-popup-anchor-left .maplibregl-popup-tip{border-left:none;border-right-color:#fff;align-self:center}.maplibregl-popup-anchor-right .maplibregl-popup-tip{border-left-color:#fff;border-right:none;align-self:center}.maplibregl-popup-close-button{cursor:pointer;background-color:#0000;border:0;border-radius:0 3px 0 0;position:absolute;top:0;right:0}.maplibregl-popup-close-button:hover{background-color:#0000000d}.maplibregl-popup-content{pointer-events:auto;background:#fff;border-radius:3px;padding:15px 10px;position:relative;box-shadow:0 1px 2px #0000001a}.maplibregl-popup-anchor-top-left .maplibregl-popup-content{border-top-left-radius:0}.maplibregl-popup-anchor-top-right .maplibregl-popup-content{border-top-right-radius:0}.maplibregl-popup-anchor-bottom-left .maplibregl-popup-content{border-bottom-left-radius:0}.maplibregl-popup-anchor-bottom-right .maplibregl-popup-content{border-bottom-right-radius:0}.maplibregl-popup-track-pointer{display:none}.maplibregl-popup-track-pointer *{pointer-events:none;-webkit-user-select:none;user-select:none}.maplibregl-map:hover .maplibregl-popup-track-pointer{display:flex}.maplibregl-map:active .maplibregl-popup-track-pointer{display:none}.maplibregl-marker{will-change:transform;transition:opacity .2s;position:absolute;top:0;left:0}.maplibregl-user-location-dot,.maplibregl-user-location-dot:before{background-color:#1da1f2;border-radius:50%;width:15px;height:15px}.maplibregl-user-location-dot:before{content:"";animation:2s infinite maplibregl-user-location-dot-pulse;position:absolute}.maplibregl-user-location-dot:after{box-sizing:border-box;content:"";border:2px solid #fff;border-radius:50%;width:19px;height:19px;position:absolute;top:-2px;left:-2px;box-shadow:0 0 3px #00000059}@keyframes maplibregl-user-location-dot-pulse{0%{opacity:1;transform:scale(1)}70%{opacity:0;transform:scale(3)}to{opacity:0;transform:scale(1)}}.maplibregl-user-location-dot-stale{background-color:#aaa}.maplibregl-user-location-dot-stale:after{display:none}.maplibregl-user-location-accuracy-circle{background-color:#1da1f233;border-radius:100%;width:1px;height:1px}.maplibregl-crosshair,.maplibregl-crosshair .maplibregl-interactive,.maplibregl-crosshair .maplibregl-interactive:active{cursor:crosshair}.maplibregl-boxzoom{opacity:.5;background:#fff;border:2px dotted #202020;width:0;height:0;position:absolute;top:0;left:0}.maplibregl-cooperative-gesture-screen{color:#fff;opacity:0;pointer-events:none;z-index:99999;background:#0006;justify-content:center;align-items:center;padding:1rem;font-size:1.4em;line-height:1.2;transition:opacity 1s 1s;display:flex;position:absolute;top:0;bottom:0;left:0;right:0}.maplibregl-cooperative-gesture-screen.maplibregl-show{opacity:1;transition:opacity 50ms}.maplibregl-cooperative-gesture-screen .maplibregl-mobile-message{display:none}@media (hover:none),(pointer:coarse){.maplibregl-cooperative-gesture-screen .maplibregl-desktop-message{display:none}.maplibregl-cooperative-gesture-screen .maplibregl-mobile-message{display:block}}.maplibregl-pseudo-fullscreen{z-index:99999;width:100%!important;height:100%!important;position:fixed!important;top:0!important;left:0!important}
-2
static/js/event-map-BMN8EESL.js
··· 1 - const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/maps-GDfHpVyJ.js","css/maps-CpDLi3o_.css"])))=>i.map(i=>d[i]); 2 - import{_ as d}from"./main-CuQd5Sql.js";const f=9;async function I(){const e=document.getElementById("event-map");if(e&&!(e.dataset.mapInitialized==="true"||e.dataset.mapInitializing==="true")){e.dataset.mapInitializing="true";try{const n=e.dataset.geoLocations;if(!n){e.dataset.mapInitializing="false";return}let u;try{u=JSON.parse(n)}catch(t){console.error("Failed to parse geo locations:",t),e.dataset.mapInitializing="false";return}const a=u.filter(t=>t!=null).map(t=>({latitude:typeof t.latitude=="string"?parseFloat(t.latitude):t.latitude,longitude:typeof t.longitude=="string"?parseFloat(t.longitude):t.longitude,name:t.name})).filter(t=>Number.isFinite(t.latitude)&&Number.isFinite(t.longitude));if(a.length===0){e.dataset.mapInitializing="false";return}const[o,p]=await Promise.all([d(()=>import("./maps-GDfHpVyJ.js").then(t=>t.l),__vite__mapDeps([0,1])).then(t=>t.default),d(()=>import("./maps-GDfHpVyJ.js").then(t=>t.h),__vite__mapDeps([0,1]))]);if(await d(()=>import("./maps-GDfHpVyJ.js").then(t=>t.a),__vite__mapDeps([0,1])),e.dataset.mapInitialized==="true"){e.dataset.mapInitializing="false";return}const g=a.reduce((t,i)=>t+i.latitude,0)/a.length,m=a.reduce((t,i)=>t+i.longitude,0)/a.length;if(!Number.isFinite(g)||!Number.isFinite(m)){e.dataset.mapInitializing="false";return}const l=o.map("event-map",{zoomControl:!0,scrollWheelZoom:!1,dragging:!0}).setView([g,m],16);o.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",{attribution:'&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>',maxZoom:19}).addTo(l);const s=[];if(a.forEach(t=>{const i=p.latLngToCell(t.latitude,t.longitude,f),c=p.cellToBoundary(i).map(r=>[r[0],r[1]]);c.forEach(r=>s.push(r)),o.polygon(c,{color:"#3273dc",fillColor:"#3273dc",fillOpacity:.2,weight:2,className:"h3-hex"}).addTo(l)}),s.length>0){const t=o.latLngBounds(s);l.fitBounds(t,{padding:[20,20]})}e.dataset.mapInitialized="true"}catch(n){console.error("Failed to initialize event map:",n)}finally{e.dataset.mapInitializing="false"}}}export{I as initEventMap};
+1
static/js/event-map-BQ9ES8zV.js
··· 1 + import{l as c,c as m,t as f,b as I,h as z,u as h,d as L}from"./main-B2-Bk5P8.js";const y=9;async function b(){const e=document.getElementById("event-map");if(e&&!(e.dataset.mapInitialized==="true"||e.dataset.mapInitializing==="true")){e.dataset.mapInitializing="true";try{const n=e.dataset.geoLocations;if(!n){e.dataset.mapInitializing="false";return}let s;try{s=JSON.parse(n)}catch(t){console.error("Failed to parse geo locations:",t),e.dataset.mapInitializing="false";return}const a=s.filter(t=>t!=null).map(t=>({latitude:typeof t.latitude=="string"?parseFloat(t.latitude):t.latitude,longitude:typeof t.longitude=="string"?parseFloat(t.longitude):t.longitude,name:t.name})).filter(t=>Number.isFinite(t.latitude)&&Number.isFinite(t.longitude));if(a.length===0){e.dataset.mapInitializing="false";return}const{maplibregl:p,h3:r}=await c();if(e.dataset.mapInitialized==="true"){e.dataset.mapInitializing="false";return}const l=a.reduce((t,i)=>t+i.latitude,0)/a.length,d=a.reduce((t,i)=>t+i.longitude,0)/a.length;if(!Number.isFinite(l)||!Number.isFinite(d)){e.dataset.mapInitializing="false";return}const o=m(p,{container:"event-map",center:f(l,d),zoom:16,scrollZoom:!1});o.on("load",()=>{I(o);const t=a.map(u=>{const g=r.latLngToCell(u.latitude,u.longitude,y);return z(r,g,{fillColor:"#3273dc",fillOpacity:.2,strokeColor:"#3273dc",strokeWidth:2})});h(o,t);const i=L(t);i&&o.fitBounds(i,{padding:20})}),e.dataset.mapInitialized="true"}catch(n){console.error("Failed to initialize event map:",n)}finally{e.dataset.mapInitializing="false"}}}export{b as initEventMap};
+2 -2
static/js/globe-map-v0wYAEFW.js static/js/globe-map-C_o1blDz.js
··· 1 - const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/maps-GDfHpVyJ.js","css/maps-CpDLi3o_.css"])))=>i.map(i=>d[i]); 2 - import{_ as y}from"./main-CuQd5Sql.js";async function T(c){const m=(c==null?void 0:c.containerId)??"globe-map",v=(c==null?void 0:c.statusElementId)??"globe-status",u=document.getElementById(m),l=document.getElementById(v);if(u&&!(u.dataset.mapInitialized==="true"||u.dataset.mapInitializing==="true")){u.dataset.mapInitializing="true";try{let f=function(e,i){return i===0?"hsl(240, 70%, 50%)":`hsl(${240-e/i*180}, 70%, 50%)`},_=function(e,i){const o=h.cellToBoundary(e.key),r=h.cellToLatLng(e.key),n=o.map(([s,a])=>[a,s]);return n.push(n[0]),{type:"Feature",properties:{id:e.key,event_count:e.event_count??0,lfg_count:e.lfg_count??0,total:e.total??0,centerLat:r[0],centerLng:r[1],color:f(e.total??0,i)},geometry:{type:"Polygon",coordinates:[n]}}},b=function(){t=new p.Map({container:m,style:{version:8,projection:{type:"globe"},sources:{"carto-voyager":{type:"raster",tiles:["https://a.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}@2x.png","https://b.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}@2x.png","https://c.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}@2x.png"],tileSize:256,attribution:'&copy; <a href="https://carto.com/attributions">CARTO</a>'}},layers:[{id:"background",type:"background",paint:{"background-color":"#e8e8e8"}},{id:"carto-voyager",type:"raster",source:"carto-voyager"}]},center:[-100,40],zoom:4,maxZoom:8,minZoom:1}),t.on("load",()=>{t&&(t.addSource("hexagons",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),t.addLayer({id:"hexagons-fill",type:"fill",source:"hexagons",paint:{"fill-color":["get","color"],"fill-opacity":.4}}),t.addLayer({id:"hexagons-outline",type:"line",source:"hexagons",paint:{"line-color":"#333","line-width":.5,"line-opacity":.4}}),g=new p.Popup({closeButton:!0,closeOnClick:!1}),t.on("click","hexagons-fill",e=>{const i=e.features;if(i&&i.length>0){const o=i[0].properties;let r=`<strong>Activity:</strong> ${o.total} total<br/>`;o.event_count>0&&(r+=`${o.event_count} event${o.event_count===1?"":"s"}<br/>`),o.lfg_count>0&&(r+=`${o.lfg_count} ${o.lfg_count===1?"person":"people"} LFG`),g==null||g.setLngLat([o.centerLng,o.centerLat]).setHTML(r).addTo(t)}}),t.on("mouseenter","hexagons-fill",()=>{t.getCanvas().style.cursor="pointer"}),t.on("mouseleave","hexagons-fill",()=>{t.getCanvas().style.cursor=""}),x())}),L()},L=function(){var e,i,o,r;(e=document.getElementById("focus-north-america"))==null||e.addEventListener("click",()=>{t==null||t.flyTo({center:[-100,40],zoom:4,duration:1500})}),(i=document.getElementById("focus-europe"))==null||i.addEventListener("click",()=>{t==null||t.flyTo({center:[10,50],zoom:4,duration:1500})}),(o=document.getElementById("focus-world"))==null||o.addEventListener("click",()=>{t==null||t.flyTo({center:[0,20],zoom:2,duration:1500})}),(r=document.getElementById("focus-my-location"))==null||r.addEventListener("click",()=>{const n=document.getElementById("focus-my-location");if(!n)return;const s=n.innerHTML;n.innerHTML='<span class="icon is-small"><i class="fas fa-spinner fa-pulse"></i></span><span>Locating...</span>',n.disabled=!0,navigator.geolocation?navigator.geolocation.getCurrentPosition(a=>{t==null||t.flyTo({center:[a.coords.longitude,a.coords.latitude],zoom:8,duration:1500}),n.innerHTML=s,n.disabled=!1},a=>{console.warn("Geolocation failed:",a.message),l&&(l.textContent="Could not get your location."),n.innerHTML=s,n.disabled=!1},{timeout:1e4,maximumAge:3e5}):(l&&(l.textContent="Geolocation not supported."),n.innerHTML=s,n.disabled=!1)})},x=function(){fetch("/api/globe-aggregation?resolution=5").then(e=>e.json()).then(e=>{if(!e.buckets||e.buckets.length===0){l&&(l.textContent="No activity found.");return}const i=Math.max(...e.buckets.map(a=>a.total??0)),o=[];e.buckets.forEach(a=>{try{o.push(_(a,i))}catch(d){console.warn("Failed to process hex:",a.key,d)}});const r=t==null?void 0:t.getSource("hexagons");r==null||r.setData({type:"FeatureCollection",features:o});const n=e.buckets.reduce((a,d)=>a+(d.event_count??0),0),s=e.buckets.reduce((a,d)=>a+(d.lfg_count??0),0);l&&(l.textContent=`${e.buckets.length} active regions: ${n} events, ${s} people LFG`)}).catch(e=>{console.error("Failed to load globe aggregation:",e),l&&(l.textContent="Failed to load activity data.")})};const[p,h]=await Promise.all([y(()=>import("./maps-GDfHpVyJ.js").then(e=>e.m),__vite__mapDeps([0,1])),y(()=>import("./maps-GDfHpVyJ.js").then(e=>e.h),__vite__mapDeps([0,1]))]);await y(()=>import("./maps-GDfHpVyJ.js").then(e=>e.b),__vite__mapDeps([0,1]));let t=null,g=null;b(),u.dataset.mapInitialized="true"}catch(f){console.error("Failed to initialize globe map:",f),l&&(l.textContent="Failed to load map.")}finally{u.dataset.mapInitializing="false"}}}export{T as initGlobeMap}; 1 + const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/maps-Dzpg4_su.js","css/maps-DYqiRqwW.css"])))=>i.map(i=>d[i]); 2 + import{_ as y}from"./main-B2-Bk5P8.js";async function T(c){const m=(c==null?void 0:c.containerId)??"globe-map",v=(c==null?void 0:c.statusElementId)??"globe-status",u=document.getElementById(m),l=document.getElementById(v);if(u&&!(u.dataset.mapInitialized==="true"||u.dataset.mapInitializing==="true")){u.dataset.mapInitializing="true";try{let f=function(e,i){return i===0?"hsl(240, 70%, 50%)":`hsl(${240-e/i*180}, 70%, 50%)`},_=function(e,i){const o=h.cellToBoundary(e.key),r=h.cellToLatLng(e.key),n=o.map(([s,a])=>[a,s]);return n.push(n[0]),{type:"Feature",properties:{id:e.key,event_count:e.event_count??0,lfg_count:e.lfg_count??0,total:e.total??0,centerLat:r[0],centerLng:r[1],color:f(e.total??0,i)},geometry:{type:"Polygon",coordinates:[n]}}},b=function(){t=new p.Map({container:m,style:{version:8,projection:{type:"globe"},sources:{"carto-voyager":{type:"raster",tiles:["https://a.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}@2x.png","https://b.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}@2x.png","https://c.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}@2x.png"],tileSize:256,attribution:'&copy; <a href="https://carto.com/attributions">CARTO</a>'}},layers:[{id:"background",type:"background",paint:{"background-color":"#e8e8e8"}},{id:"carto-voyager",type:"raster",source:"carto-voyager"}]},center:[-100,40],zoom:4,maxZoom:8,minZoom:1}),t.on("load",()=>{t&&(t.addSource("hexagons",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),t.addLayer({id:"hexagons-fill",type:"fill",source:"hexagons",paint:{"fill-color":["get","color"],"fill-opacity":.4}}),t.addLayer({id:"hexagons-outline",type:"line",source:"hexagons",paint:{"line-color":"#333","line-width":.5,"line-opacity":.4}}),g=new p.Popup({closeButton:!0,closeOnClick:!1}),t.on("click","hexagons-fill",e=>{const i=e.features;if(i&&i.length>0){const o=i[0].properties;let r=`<strong>Activity:</strong> ${o.total} total<br/>`;o.event_count>0&&(r+=`${o.event_count} event${o.event_count===1?"":"s"}<br/>`),o.lfg_count>0&&(r+=`${o.lfg_count} ${o.lfg_count===1?"person":"people"} LFG`),g==null||g.setLngLat([o.centerLng,o.centerLat]).setHTML(r).addTo(t)}}),t.on("mouseenter","hexagons-fill",()=>{t.getCanvas().style.cursor="pointer"}),t.on("mouseleave","hexagons-fill",()=>{t.getCanvas().style.cursor=""}),x())}),L()},L=function(){var e,i,o,r;(e=document.getElementById("focus-north-america"))==null||e.addEventListener("click",()=>{t==null||t.flyTo({center:[-100,40],zoom:4,duration:1500})}),(i=document.getElementById("focus-europe"))==null||i.addEventListener("click",()=>{t==null||t.flyTo({center:[10,50],zoom:4,duration:1500})}),(o=document.getElementById("focus-world"))==null||o.addEventListener("click",()=>{t==null||t.flyTo({center:[0,20],zoom:2,duration:1500})}),(r=document.getElementById("focus-my-location"))==null||r.addEventListener("click",()=>{const n=document.getElementById("focus-my-location");if(!n)return;const s=n.innerHTML;n.innerHTML='<span class="icon is-small"><i class="fas fa-spinner fa-pulse"></i></span><span>Locating...</span>',n.disabled=!0,navigator.geolocation?navigator.geolocation.getCurrentPosition(a=>{t==null||t.flyTo({center:[a.coords.longitude,a.coords.latitude],zoom:8,duration:1500}),n.innerHTML=s,n.disabled=!1},a=>{console.warn("Geolocation failed:",a.message),l&&(l.textContent="Could not get your location."),n.innerHTML=s,n.disabled=!1},{timeout:1e4,maximumAge:3e5}):(l&&(l.textContent="Geolocation not supported."),n.innerHTML=s,n.disabled=!1)})},x=function(){fetch("/api/globe-aggregation?resolution=5").then(e=>e.json()).then(e=>{if(!e.buckets||e.buckets.length===0){l&&(l.textContent="No activity found.");return}const i=Math.max(...e.buckets.map(a=>a.total??0)),o=[];e.buckets.forEach(a=>{try{o.push(_(a,i))}catch(d){console.warn("Failed to process hex:",a.key,d)}});const r=t==null?void 0:t.getSource("hexagons");r==null||r.setData({type:"FeatureCollection",features:o});const n=e.buckets.reduce((a,d)=>a+(d.event_count??0),0),s=e.buckets.reduce((a,d)=>a+(d.lfg_count??0),0);l&&(l.textContent=`${e.buckets.length} active regions: ${n} events, ${s} people LFG`)}).catch(e=>{console.error("Failed to load globe aggregation:",e),l&&(l.textContent="Failed to load activity data.")})};const[p,h]=await Promise.all([y(()=>import("./maps-Dzpg4_su.js").then(e=>e.m),__vite__mapDeps([0,1])),y(()=>import("./maps-Dzpg4_su.js").then(e=>e.h),__vite__mapDeps([0,1]))]);await y(()=>import("./maps-Dzpg4_su.js").then(e=>e.a),__vite__mapDeps([0,1]));let t=null,g=null;b(),u.dataset.mapInitialized="true"}catch(f){console.error("Failed to initialize globe map:",f),l&&(l.textContent="Failed to load map.")}finally{u.dataset.mapInitializing="false"}}}export{T as initGlobeMap};
+1
static/js/heatmap-BojFLSXV.js
··· 1 + import{l as B,c as C,t as b,b as z,h as I,u as F}from"./main-B2-Bk5P8.js";async function T(){const o=document.getElementById("lfg-heatmap");if(o&&!(o.dataset.mapInitialized==="true"||o.dataset.mapInitializing==="true")){o.dataset.mapInitializing="true";try{const f=parseFloat(o.dataset.lat??"40.7128"),v=parseFloat(o.dataset.lon??"-74.006"),m=o.dataset.eventBuckets,g=o.dataset.profileBuckets,{maplibregl:h,h3:L}=await B(),a=C(h,{container:"lfg-heatmap",center:b(f,v),zoom:12});let k=[],y=[];try{m&&(k=JSON.parse(m)),g&&(y=JSON.parse(g))}catch(e){console.warn("Failed to parse heatmap buckets:",e)}const c=new Map;for(const e of k){const t=c.get(e.key)||{events:0,people:0};t.events=e.count,c.set(e.key,t)}for(const e of y){const t=c.get(e.key)||{events:0,people:0};t.people=e.count,c.set(e.key,t)}let u=0;c.forEach(e=>{const t=e.events+e.people;t>u&&(u=t)}),a.on("load",()=>{z(a);const e=[];c.forEach((n,s)=>{try{const r=n.events+n.people,p=.2+Math.min(r/Math.max(u,1),1)*.5,i=[];n.events>0&&i.push(`${n.events} event${n.events!==1?"s":""}`),n.people>0&&i.push(`${n.people} ${n.people!==1?"people":"person"}`);const l=i.join(", "),x=L.cellToLatLng(s);e.push(I(L,s,{fillColor:"#3273dc",fillOpacity:p,strokeColor:"#3273dc",strokeWidth:1,tooltipText:l,centerLat:x[0],centerLng:x[1]}))}catch{console.warn("Invalid H3 cell:",s)}}),F(a,e);let t=null;a.on("mouseenter","hexagons-fill",n=>{var l;const s=(l=n.features)==null?void 0:l[0];if(!(s!=null&&s.properties))return;const r=s.properties,d=r.tooltipText,p=r.centerLat,i=r.centerLng;d&&p!==void 0&&i!==void 0&&(a.getCanvas().style.cursor="pointer",t=new h.Popup({closeButton:!1,closeOnClick:!1}).setLngLat([i,p]).setText(d).addTo(a))}),a.on("mouseleave","hexagons-fill",()=>{a.getCanvas().style.cursor="",t&&(t.remove(),t=null)})}),o.dataset.mapInitialized="true"}catch(f){console.error("Failed to initialize LFG heatmap:",f)}finally{o.dataset.mapInitializing="false"}}}export{T as initLfgHeatmap};
-2
static/js/heatmap-CJsCFdcC.js
··· 1 - const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/maps-GDfHpVyJ.js","css/maps-CpDLi3o_.css"])))=>i.map(i=>d[i]); 2 - import{_ as c}from"./main-CuQd5Sql.js";async function B(){const o=document.getElementById("lfg-heatmap");if(o&&!(o.dataset.mapInitialized==="true"||o.dataset.mapInitializing==="true")){o.dataset.mapInitializing="true";try{const a=parseFloat(o.dataset.lat??"40.7128"),h=parseFloat(o.dataset.lon??"-74.006"),r=o.dataset.eventBuckets,l=o.dataset.profileBuckets,[i,y]=await Promise.all([c(()=>import("./maps-GDfHpVyJ.js").then(t=>t.l),__vite__mapDeps([0,1])).then(t=>t.default),c(()=>import("./maps-GDfHpVyJ.js").then(t=>t.h),__vite__mapDeps([0,1]))]);await c(()=>import("./maps-GDfHpVyJ.js").then(t=>t.a),__vite__mapDeps([0,1]));const d=i.map("lfg-heatmap").setView([a,h],12);i.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",{attribution:"&copy; OpenStreetMap contributors"}).addTo(d);let m=[],f=[];try{r&&(m=JSON.parse(r)),l&&(f=JSON.parse(l))}catch(t){console.warn("Failed to parse heatmap buckets:",t)}const n=new Map;for(const t of m){const e=n.get(t.key)||{events:0,people:0};e.events=t.count,n.set(t.key,e)}for(const t of f){const e=n.get(t.key)||{events:0,people:0};e.people=t.count,n.set(t.key,e)}let s=0;n.forEach(t=>{const e=t.events+t.people;e>s&&(s=e)}),n.forEach((t,e)=>{try{const g=y.cellToBoundary(e).map(u=>[u[0],u[1]]),k=t.events+t.people,I=.2+Math.min(k/Math.max(s,1),1)*.5,p=[];t.events>0&&p.push(`${t.events} event${t.events!==1?"s":""}`),t.people>0&&p.push(`${t.people} ${t.people!==1?"people":"person"}`);const L=p.join(", ");i.polygon(g,{color:"#3273dc",fillColor:"#3273dc",fillOpacity:I,weight:1}).addTo(d).bindTooltip(L,{direction:"center"})}catch{console.warn("Invalid H3 cell:",e)}}),o.dataset.mapInitialized="true"}catch(a){console.error("Failed to initialize LFG heatmap:",a)}finally{o.dataset.mapInitializing="false"}}}export{B as initLfgHeatmap};
+2 -2
static/js/index-BP1lDIcH.js static/js/index-Bb8tq7S1.js
··· 1 - const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/event-map-BMN8EESL.js","js/main-CuQd5Sql.js","css/main-DsS_JPFh.css","js/globe-map-v0wYAEFW.js","js/location-heatmap-qsLOB3hq.js"])))=>i.map(i=>d[i]); 2 - import{_ as i}from"./main-CuQd5Sql.js";async function o(){if(!document.getElementById("event-map"))return;const{initEventMap:t}=await i(async()=>{const{initEventMap:n}=await import("./event-map-BMN8EESL.js");return{initEventMap:n}},__vite__mapDeps([0,1,2]));await t()}async function e(){if(!document.getElementById("globe-map"))return;const{initGlobeMap:t}=await i(async()=>{const{initGlobeMap:n}=await import("./globe-map-v0wYAEFW.js");return{initGlobeMap:n}},__vite__mapDeps([3,1,2]));await t()}async function c(){if(!document.getElementById("location-heatmap"))return;const{initLocationHeatmap:t}=await i(async()=>{const{initLocationHeatmap:n}=await import("./location-heatmap-qsLOB3hq.js");return{initLocationHeatmap:n}},__vite__mapDeps([4,1,2]));await t()}function p(){o(),e(),c()}export{o as initEventMap,e as initGlobeMap,c as initLocationHeatmap,p as initMaps}; 1 + const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/event-map-BQ9ES8zV.js","js/main-B2-Bk5P8.js","css/main-DsS_JPFh.css","js/globe-map-C_o1blDz.js","js/location-heatmap-XJvZT2hb.js"])))=>i.map(i=>d[i]); 2 + import{_ as i}from"./main-B2-Bk5P8.js";async function o(){if(!document.getElementById("event-map"))return;const{initEventMap:t}=await i(async()=>{const{initEventMap:n}=await import("./event-map-BQ9ES8zV.js");return{initEventMap:n}},__vite__mapDeps([0,1,2]));await t()}async function e(){if(!document.getElementById("globe-map"))return;const{initGlobeMap:t}=await i(async()=>{const{initGlobeMap:n}=await import("./globe-map-C_o1blDz.js");return{initGlobeMap:n}},__vite__mapDeps([3,1,2]));await t()}async function c(){if(!document.getElementById("location-heatmap"))return;const{initLocationHeatmap:t}=await i(async()=>{const{initLocationHeatmap:n}=await import("./location-heatmap-XJvZT2hb.js");return{initLocationHeatmap:n}},__vite__mapDeps([4,1,2]));await t()}function p(){o(),e(),c()}export{o as initEventMap,e as initGlobeMap,c as initLocationHeatmap,p as initMaps};
+1 -1
static/js/index-Bcnf8oUZ.js static/js/index-8MdtY9qF.js
··· 1 1 const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/cropper-DyNc_82c.js","css/cropper-BJgXXBRK.css"])))=>i.map(i=>d[i]); 2 - import{_ as a}from"./main-CuQd5Sql.js";let t=null;async function o(){return t||(t=(async()=>{const[n]=await Promise.all([a(()=>import("./cropper-DyNc_82c.js").then(r=>r.c),__vite__mapDeps([0,1])),a(()=>import("./cropper-DyNc_82c.js").then(r=>r.a),__vite__mapDeps([0,1]))]),e=n.default;return window.Cropper=e,e})(),t)}async function s(){const n=document.getElementById("headerCanvas"),e=document.getElementById("thumbnailCanvas");!n&&!e||await o()}export{s as initCropper,o as loadCropper}; 2 + import{_ as a}from"./main-B2-Bk5P8.js";let t=null;async function o(){return t||(t=(async()=>{const[n]=await Promise.all([a(()=>import("./cropper-DyNc_82c.js").then(r=>r.c),__vite__mapDeps([0,1])),a(()=>import("./cropper-DyNc_82c.js").then(r=>r.a),__vite__mapDeps([0,1]))]),e=n.default;return window.Cropper=e,e})(),t)}async function s(){const n=document.getElementById("headerCanvas"),e=document.getElementById("thumbnailCanvas");!n&&!e||await o()}export{s as initCropper,o as loadCropper};
+1
static/js/location-heatmap-XJvZT2hb.js
··· 1 + import{l as x,c as z,t as I,b as L,e as k,h as B,u as F,d as M}from"./main-B2-Bk5P8.js";async function w(){const t=document.getElementById("location-heatmap");if(t&&!(t.dataset.mapInitialized==="true"||t.dataset.mapInitializing==="true")){t.dataset.mapInitializing="true";try{const s=parseFloat(t.dataset.centerLat??"0"),p=parseFloat(t.dataset.centerLon??"0"),m=t.dataset.centerCell??"",i=t.dataset.geoBuckets;if(!i)return;let a;try{a=JSON.parse(i)}catch(n){console.error("Failed to parse geo buckets:",n);return}const{maplibregl:h,h3:f}=await x(),o=z(h,{container:"location-heatmap",center:I(s,p),zoom:9,interactive:!1});o.on("load",()=>{if(L(o),a&&a.length>0){const n=a.map(e=>e.doc_count??0),g=Math.min(...n),y=Math.max(...n),c=[];a.forEach(e=>{try{const r=e.key,C=e.doc_count??0,d=r===m,u=k(C,g,y);c.push(B(f,r,{fillColor:u,fillOpacity:.5,strokeColor:d?"#1a1a1a":u,strokeWidth:d?3:2}))}catch(r){console.warn("Failed to draw hex:",e.key,r)}}),F(o,c);const l=M(c);l&&o.fitBounds(l,{padding:10})}}),t.dataset.mapInitialized="true"}catch(s){console.error("Failed to initialize location heatmap:",s)}finally{t.dataset.mapInitializing="false"}}}export{w as initLocationHeatmap};
-2
static/js/location-heatmap-qsLOB3hq.js
··· 1 - const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/maps-GDfHpVyJ.js","css/maps-CpDLi3o_.css"])))=>i.map(i=>d[i]); 2 - import{_}from"./main-CuQd5Sql.js";async function E(){const n=document.getElementById("location-heatmap");if(n&&!(n.dataset.mapInitialized==="true"||n.dataset.mapInitializing==="true")){n.dataset.mapInitializing="true";try{let h=function(e,c,r){if(r===c)return"#3273dc";const o=(e-c)/(r-c);if(o<.33){const t=o/.33;return f("#3273dc","#8957e5",t)}else if(o<.66){const t=(o-.33)/.33;return f("#8957e5","#f39c12",t)}else{const t=(o-.66)/.34;return f("#f39c12","#e74c3c",t)}},f=function(e,c,r){const o=parseInt(e.replace("#",""),16),t=parseInt(c.replace("#",""),16),a=o>>16,p=o>>8&255,g=o&255,y=t>>16,s=t>>8&255,u=t&255,m=Math.round(a+(y-a)*r),z=Math.round(p+(s-p)*r),k=Math.round(g+(u-g)*r);return"#"+(16777216+(m<<16)+(z<<8)+k).toString(16).slice(1)};const b=parseFloat(n.dataset.centerLat??"0"),C=parseFloat(n.dataset.centerLon??"0"),x=n.dataset.centerCell??"",I=n.dataset.geoBuckets;if(!I)return;let l;try{l=JSON.parse(I)}catch(e){console.error("Failed to parse geo buckets:",e);return}const[i,L]=await Promise.all([_(()=>import("./maps-GDfHpVyJ.js").then(e=>e.l),__vite__mapDeps([0,1])).then(e=>e.default),_(()=>import("./maps-GDfHpVyJ.js").then(e=>e.h),__vite__mapDeps([0,1]))]);await _(()=>import("./maps-GDfHpVyJ.js").then(e=>e.a),__vite__mapDeps([0,1]));const d=i.map("location-heatmap",{center:[b,C],zoom:9,zoomControl:!1,dragging:!1,touchZoom:!1,scrollWheelZoom:!1,doubleClickZoom:!1,boxZoom:!1,keyboard:!1,attributionControl:!0});if(i.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",{attribution:'&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>',maxZoom:19}).addTo(d),l&&l.length>0){const e=l.map(t=>t.doc_count??0),c=Math.min(...e),r=Math.max(...e);l.forEach(t=>{try{const a=t.key,p=t.doc_count??0,y=L.cellToBoundary(a).map(m=>[m[0],m[1]]),s=a===x,u=h(p,c,r);i.polygon(y,{color:s?"#1a1a1a":u,fillColor:u,fillOpacity:.5,weight:s?3:2,className:s?"h3-hex-center":"h3-hex"}).addTo(d)}catch(a){console.warn("Failed to draw hex:",t.key,a)}});const o=l.flatMap(t=>{try{return L.cellToBoundary(t.key).map(a=>[a[0],a[1]])}catch{return[]}});o.length>0&&d.fitBounds(o,{padding:[10,10]})}else i.marker([b,C]).addTo(d);n.dataset.mapInitialized="true"}catch(h){console.error("Failed to initialize location heatmap:",h)}finally{n.dataset.mapInitializing="false"}}}export{E as initLocationHeatmap};
+2 -2
static/js/main-CuQd5Sql.js static/js/main-B2-Bk5P8.js
··· 1 - const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/maps-GDfHpVyJ.js","css/maps-CpDLi3o_.css","js/profile-cropper-DwPaCPSP.js","js/index-Bcnf8oUZ.js"])))=>i.map(i=>d[i]); 1 + const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/maps-Dzpg4_su.js","css/maps-DYqiRqwW.css","js/profile-cropper-Cp_DD48I.js","js/index-8MdtY9qF.js"])))=>i.map(i=>d[i]); 2 2 const scriptRel="modulepreload",assetsURL=function(e){return"/static/"+e},seen={},__vitePreload=function(t,n,r){let i=Promise.resolve();if(n&&n.length>0){let s=function(c){return Promise.all(c.map(u=>Promise.resolve(u).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),l=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));i=s(n.map(c=>{if(c=assetsURL(c),c in seen)return;seen[c]=!0;const u=c.endsWith(".css"),f=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${f}`))return;const d=document.createElement("link");if(d.rel=u?"stylesheet":scriptRel,u||(d.as="script"),d.crossOrigin="",d.href=c,l&&d.setAttribute("nonce",l),document.head.appendChild(d),u)return new Promise((p,g)=>{d.addEventListener("load",p),d.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${c}`)))})}))}function o(s){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=s,window.dispatchEvent(a),!a.defaultPrevented)throw s}return i.then(s=>{for(const a of s||[])a.status==="rejected"&&o(a.reason);return t().catch(o)})};var flushPending=!1,flushing=!1,queue=[],lastFlushedIndex=-1;function scheduler(e){queueJob(e)}function queueJob(e){queue.includes(e)||queue.push(e),queueFlush()}function dequeueJob(e){let t=queue.indexOf(e);t!==-1&&t>lastFlushedIndex&&queue.splice(t,1)}function queueFlush(){!flushing&&!flushPending&&(flushPending=!0,queueMicrotask(flushJobs))}function flushJobs(){flushPending=!1,flushing=!0;for(let e=0;e<queue.length;e++)queue[e](),lastFlushedIndex=e;queue.length=0,lastFlushedIndex=-1,flushing=!1}var reactive,effect,release,raw,shouldSchedule=!0;function disableEffectScheduling(e){shouldSchedule=!1,e(),shouldSchedule=!0}function setReactivityEngine(e){reactive=e.reactive,release=e.release,effect=t=>e.effect(t,{scheduler:n=>{shouldSchedule?scheduler(n):n()}}),raw=e.raw}function overrideEffect(e){effect=e}function elementBoundEffect(e){let t=()=>{};return[r=>{let i=effect(r);return e._x_effects||(e._x_effects=new Set,e._x_runEffects=()=>{e._x_effects.forEach(o=>o())}),e._x_effects.add(i),t=()=>{i!==void 0&&(e._x_effects.delete(i),release(i))},i},()=>{t()}]}function watch(e,t){let n=!0,r,i=effect(()=>{let o=e();JSON.stringify(o),n?r=o:queueMicrotask(()=>{t(o,r),r=o}),n=!1});return()=>release(i)}var onAttributeAddeds=[],onElRemoveds=[],onElAddeds=[];function onElAdded(e){onElAddeds.push(e)}function onElRemoved(e,t){typeof t=="function"?(e._x_cleanups||(e._x_cleanups=[]),e._x_cleanups.push(t)):(t=e,onElRemoveds.push(t))}function onAttributesAdded(e){onAttributeAddeds.push(e)}function onAttributeRemoved(e,t,n){e._x_attributeCleanups||(e._x_attributeCleanups={}),e._x_attributeCleanups[t]||(e._x_attributeCleanups[t]=[]),e._x_attributeCleanups[t].push(n)}function cleanupAttributes(e,t){e._x_attributeCleanups&&Object.entries(e._x_attributeCleanups).forEach(([n,r])=>{(t===void 0||t.includes(n))&&(r.forEach(i=>i()),delete e._x_attributeCleanups[n])})}function cleanupElement(e){var t,n;for((t=e._x_effects)==null||t.forEach(dequeueJob);(n=e._x_cleanups)!=null&&n.length;)e._x_cleanups.pop()()}var observer=new MutationObserver(onMutate),currentlyObserving=!1;function startObservingMutations(){observer.observe(document,{subtree:!0,childList:!0,attributes:!0,attributeOldValue:!0}),currentlyObserving=!0}function stopObservingMutations(){flushObserver(),observer.disconnect(),currentlyObserving=!1}var queuedMutations=[];function flushObserver(){let e=observer.takeRecords();queuedMutations.push(()=>e.length>0&&onMutate(e));let t=queuedMutations.length;queueMicrotask(()=>{if(queuedMutations.length===t)for(;queuedMutations.length>0;)queuedMutations.shift()()})}function mutateDom(e){if(!currentlyObserving)return e();stopObservingMutations();let t=e();return startObservingMutations(),t}var isCollecting=!1,deferredMutations=[];function deferMutations(){isCollecting=!0}function flushAndStopDeferringMutations(){isCollecting=!1,onMutate(deferredMutations),deferredMutations=[]}function onMutate(e){if(isCollecting){deferredMutations=deferredMutations.concat(e);return}let t=[],n=new Set,r=new Map,i=new Map;for(let o=0;o<e.length;o++)if(!e[o].target._x_ignoreMutationObserver&&(e[o].type==="childList"&&(e[o].removedNodes.forEach(s=>{s.nodeType===1&&s._x_marker&&n.add(s)}),e[o].addedNodes.forEach(s=>{if(s.nodeType===1){if(n.has(s)){n.delete(s);return}s._x_marker||t.push(s)}})),e[o].type==="attributes")){let s=e[o].target,a=e[o].attributeName,l=e[o].oldValue,c=()=>{r.has(s)||r.set(s,[]),r.get(s).push({name:a,value:s.getAttribute(a)})},u=()=>{i.has(s)||i.set(s,[]),i.get(s).push(a)};s.hasAttribute(a)&&l===null?c():s.hasAttribute(a)?(u(),c()):u()}i.forEach((o,s)=>{cleanupAttributes(s,o)}),r.forEach((o,s)=>{onAttributeAddeds.forEach(a=>a(s,o))});for(let o of n)t.some(s=>s.contains(o))||onElRemoveds.forEach(s=>s(o));for(let o of t)o.isConnected&&onElAddeds.forEach(s=>s(o));t=null,n=null,r=null,i=null}function scope(e){return mergeProxies(closestDataStack(e))}function addScopeToNode(e,t,n){return e._x_dataStack=[t,...closestDataStack(n||e)],()=>{e._x_dataStack=e._x_dataStack.filter(r=>r!==t)}}function closestDataStack(e){return e._x_dataStack?e._x_dataStack:typeof ShadowRoot=="function"&&e instanceof ShadowRoot?closestDataStack(e.host):e.parentNode?closestDataStack(e.parentNode):[]}function mergeProxies(e){return new Proxy({objects:e},mergeProxyTrap)}var mergeProxyTrap={ownKeys({objects:e}){return Array.from(new Set(e.flatMap(t=>Object.keys(t))))},has({objects:e},t){return t==Symbol.unscopables?!1:e.some(n=>Object.prototype.hasOwnProperty.call(n,t)||Reflect.has(n,t))},get({objects:e},t,n){return t=="toJSON"?collapseProxies:Reflect.get(e.find(r=>Reflect.has(r,t))||{},t,n)},set({objects:e},t,n,r){const i=e.find(s=>Object.prototype.hasOwnProperty.call(s,t))||e[e.length-1],o=Object.getOwnPropertyDescriptor(i,t);return o!=null&&o.set&&(o!=null&&o.get)?o.set.call(r,n)||!0:Reflect.set(i,t,n)}};function collapseProxies(){return Reflect.ownKeys(this).reduce((t,n)=>(t[n]=Reflect.get(this,n),t),{})}function initInterceptors(e){let t=r=>typeof r=="object"&&!Array.isArray(r)&&r!==null,n=(r,i="")=>{Object.entries(Object.getOwnPropertyDescriptors(r)).forEach(([o,{value:s,enumerable:a}])=>{if(a===!1||s===void 0||typeof s=="object"&&s!==null&&s.__v_skip)return;let l=i===""?o:`${i}.${o}`;typeof s=="object"&&s!==null&&s._x_interceptor?r[o]=s.initialize(e,l,o):t(s)&&s!==r&&!(s instanceof Element)&&n(s,l)})};return n(e)}function interceptor(e,t=()=>{}){let n={initialValue:void 0,_x_interceptor:!0,initialize(r,i,o){return e(this.initialValue,()=>get(r,i),s=>set(r,i,s),i,o)}};return t(n),r=>{if(typeof r=="object"&&r!==null&&r._x_interceptor){let i=n.initialize.bind(n);n.initialize=(o,s,a)=>{let l=r.initialize(o,s,a);return n.initialValue=l,i(o,s,a)}}else n.initialValue=r;return n}}function get(e,t){return t.split(".").reduce((n,r)=>n[r],e)}function set(e,t,n){if(typeof t=="string"&&(t=t.split(".")),t.length===1)e[t[0]]=n;else{if(t.length===0)throw error;return e[t[0]]||(e[t[0]]={}),set(e[t[0]],t.slice(1),n)}}var magics={};function magic(e,t){magics[e]=t}function injectMagics(e,t){let n=getUtilities(t);return Object.entries(magics).forEach(([r,i])=>{Object.defineProperty(e,`$${r}`,{get(){return i(t,n)},enumerable:!1})}),e}function getUtilities(e){let[t,n]=getElementBoundUtilities(e),r={interceptor,...t};return onElRemoved(e,n),r}function tryCatch(e,t,n,...r){try{return n(...r)}catch(i){handleError(i,e,t)}}function handleError(...e){return errorHandler(...e)}var errorHandler=normalErrorHandler;function setErrorHandler(e){errorHandler=e}function normalErrorHandler(e,t,n=void 0){e=Object.assign(e??{message:"No error message given."},{el:t,expression:n}),console.warn(`Alpine Expression Error: ${e.message} 3 3 4 4 ${n?'Expression: "'+n+`" 5 5 6 - `:""}`,t),setTimeout(()=>{throw e},0)}var shouldAutoEvaluateFunctions=!0;function dontAutoEvaluateFunctions(e){let t=shouldAutoEvaluateFunctions;shouldAutoEvaluateFunctions=!1;let n=e();return shouldAutoEvaluateFunctions=t,n}function evaluate(e,t,n={}){let r;return evaluateLater(e,t)(i=>r=i,n),r}function evaluateLater(...e){return theEvaluatorFunction(...e)}var theEvaluatorFunction=normalEvaluator;function setEvaluator(e){theEvaluatorFunction=e}var theRawEvaluatorFunction;function setRawEvaluator(e){theRawEvaluatorFunction=e}function normalEvaluator(e,t){let n={};injectMagics(n,e);let r=[n,...closestDataStack(e)],i=typeof t=="function"?generateEvaluatorFromFunction(r,t):generateEvaluatorFromString(r,t,e);return tryCatch.bind(null,e,t,i)}function generateEvaluatorFromFunction(e,t){return(n=()=>{},{scope:r={},params:i=[],context:o}={})=>{if(!shouldAutoEvaluateFunctions){runIfTypeOfFunction(n,t,mergeProxies([r,...e]),i);return}let s=t.apply(mergeProxies([r,...e]),i);runIfTypeOfFunction(n,s)}}var evaluatorMemo={};function generateFunctionFromString(e,t){if(evaluatorMemo[e])return evaluatorMemo[e];let n=Object.getPrototypeOf(async function(){}).constructor,r=/^[\n\s]*if.*\(.*\)/.test(e.trim())||/^(let|const)\s/.test(e.trim())?`(async()=>{ ${e} })()`:e,o=(()=>{try{let s=new n(["__self","scope"],`with (scope) { __self.result = ${r} }; __self.finished = true; return __self.result;`);return Object.defineProperty(s,"name",{value:`[Alpine] ${e}`}),s}catch(s){return handleError(s,t,e),Promise.resolve()}})();return evaluatorMemo[e]=o,o}function generateEvaluatorFromString(e,t,n){let r=generateFunctionFromString(t,n);return(i=()=>{},{scope:o={},params:s=[],context:a}={})=>{r.result=void 0,r.finished=!1;let l=mergeProxies([o,...e]);if(typeof r=="function"){let c=r.call(a,r,l).catch(u=>handleError(u,n,t));r.finished?(runIfTypeOfFunction(i,r.result,l,s,n),r.result=void 0):c.then(u=>{runIfTypeOfFunction(i,u,l,s,n)}).catch(u=>handleError(u,n,t)).finally(()=>r.result=void 0)}}}function runIfTypeOfFunction(e,t,n,r,i){if(shouldAutoEvaluateFunctions&&typeof t=="function"){let o=t.apply(n,r);o instanceof Promise?o.then(s=>runIfTypeOfFunction(e,s,n,r)).catch(s=>handleError(s,i,t)):e(o)}else typeof t=="object"&&t instanceof Promise?t.then(o=>e(o)):e(t)}function evaluateRaw(...e){return theRawEvaluatorFunction(...e)}function normalRawEvaluator(e,t,n={}){let r={};injectMagics(r,e);let i=[r,...closestDataStack(e)],o=mergeProxies([n.scope??{},...i]),s=n.params??[];if(t.includes("await")){let a=Object.getPrototypeOf(async function(){}).constructor,l=/^[\n\s]*if.*\(.*\)/.test(t.trim())||/^(let|const)\s/.test(t.trim())?`(async()=>{ ${t} })()`:t;return new a(["scope"],`with (scope) { let __result = ${l}; return __result }`).call(n.context,o)}else{let a=/^[\n\s]*if.*\(.*\)/.test(t.trim())||/^(let|const)\s/.test(t.trim())?`(()=>{ ${t} })()`:t,c=new Function(["scope"],`with (scope) { let __result = ${a}; return __result }`).call(n.context,o);return typeof c=="function"&&shouldAutoEvaluateFunctions?c.apply(o,s):c}}var prefixAsString="x-";function prefix(e=""){return prefixAsString+e}function setPrefix(e){prefixAsString=e}var directiveHandlers={};function directive(e,t){return directiveHandlers[e]=t,{before(n){if(!directiveHandlers[n]){console.warn(String.raw`Cannot find directive \`${n}\`. \`${e}\` will use the default order of execution`);return}const r=directiveOrder.indexOf(n);directiveOrder.splice(r>=0?r:directiveOrder.indexOf("DEFAULT"),0,e)}}}function directiveExists(e){return Object.keys(directiveHandlers).includes(e)}function directives(e,t,n){if(t=Array.from(t),e._x_virtualDirectives){let o=Object.entries(e._x_virtualDirectives).map(([a,l])=>({name:a,value:l})),s=attributesOnly(o);o=o.map(a=>s.find(l=>l.name===a.name)?{name:`x-bind:${a.name}`,value:`"${a.value}"`}:a),t=t.concat(o)}let r={};return t.map(toTransformedAttributes((o,s)=>r[o]=s)).filter(outNonAlpineAttributes).map(toParsedDirectives(r,n)).sort(byPriority).map(o=>getDirectiveHandler(e,o))}function attributesOnly(e){return Array.from(e).map(toTransformedAttributes()).filter(t=>!outNonAlpineAttributes(t))}var isDeferringHandlers=!1,directiveHandlerStacks=new Map,currentHandlerStackKey=Symbol();function deferHandlingDirectives(e){isDeferringHandlers=!0;let t=Symbol();currentHandlerStackKey=t,directiveHandlerStacks.set(t,[]);let n=()=>{for(;directiveHandlerStacks.get(t).length;)directiveHandlerStacks.get(t).shift()();directiveHandlerStacks.delete(t)},r=()=>{isDeferringHandlers=!1,n()};e(n),r()}function getElementBoundUtilities(e){let t=[],n=a=>t.push(a),[r,i]=elementBoundEffect(e);return t.push(i),[{Alpine:alpine_default,effect:r,cleanup:n,evaluateLater:evaluateLater.bind(evaluateLater,e),evaluate:evaluate.bind(evaluate,e)},()=>t.forEach(a=>a())]}function getDirectiveHandler(e,t){let n=()=>{},r=directiveHandlers[t.type]||n,[i,o]=getElementBoundUtilities(e);onAttributeRemoved(e,t.original,o);let s=()=>{e._x_ignore||e._x_ignoreSelf||(r.inline&&r.inline(e,t,i),r=r.bind(r,e,t,i),isDeferringHandlers?directiveHandlerStacks.get(currentHandlerStackKey).push(r):r())};return s.runCleanups=o,s}var startingWith=(e,t)=>({name:n,value:r})=>(n.startsWith(e)&&(n=n.replace(e,t)),{name:n,value:r}),into=e=>e;function toTransformedAttributes(e=()=>{}){return({name:t,value:n})=>{let{name:r,value:i}=attributeTransformers.reduce((o,s)=>s(o),{name:t,value:n});return r!==t&&e(r,t),{name:r,value:i}}}var attributeTransformers=[];function mapAttributes(e){attributeTransformers.push(e)}function outNonAlpineAttributes({name:e}){return alpineAttributeRegex().test(e)}var alpineAttributeRegex=()=>new RegExp(`^${prefixAsString}([^:^.]+)\\b`);function toParsedDirectives(e,t){return({name:n,value:r})=>{n===r&&(r="");let i=n.match(alpineAttributeRegex()),o=n.match(/:([a-zA-Z0-9\-_:]+)/),s=n.match(/\.[^.\]]+(?=[^\]]*$)/g)||[],a=t||e[n]||n;return{type:i?i[1]:null,value:o?o[1]:null,modifiers:s.map(l=>l.replace(".","")),expression:r,original:a}}}var DEFAULT="DEFAULT",directiveOrder=["ignore","ref","data","id","anchor","bind","init","for","model","modelable","transition","show","if",DEFAULT,"teleport"];function byPriority(e,t){let n=directiveOrder.indexOf(e.type)===-1?DEFAULT:e.type,r=directiveOrder.indexOf(t.type)===-1?DEFAULT:t.type;return directiveOrder.indexOf(n)-directiveOrder.indexOf(r)}function dispatch(e,t,n={}){e.dispatchEvent(new CustomEvent(t,{detail:n,bubbles:!0,composed:!0,cancelable:!0}))}function walk(e,t){if(typeof ShadowRoot=="function"&&e instanceof ShadowRoot){Array.from(e.children).forEach(i=>walk(i,t));return}let n=!1;if(t(e,()=>n=!0),n)return;let r=e.firstElementChild;for(;r;)walk(r,t),r=r.nextElementSibling}function warn(e,...t){console.warn(`Alpine Warning: ${e}`,...t)}var started=!1;function start(){started&&warn("Alpine has already been initialized on this page. Calling Alpine.start() more than once can cause problems."),started=!0,document.body||warn("Unable to initialize. Trying to load Alpine before `<body>` is available. Did you forget to add `defer` in Alpine's `<script>` tag?"),dispatch(document,"alpine:init"),dispatch(document,"alpine:initializing"),startObservingMutations(),onElAdded(t=>initTree(t,walk)),onElRemoved(t=>destroyTree(t)),onAttributesAdded((t,n)=>{directives(t,n).forEach(r=>r())});let e=t=>!closestRoot(t.parentElement,!0);Array.from(document.querySelectorAll(allSelectors().join(","))).filter(e).forEach(t=>{initTree(t)}),dispatch(document,"alpine:initialized"),setTimeout(()=>{warnAboutMissingPlugins()})}var rootSelectorCallbacks=[],initSelectorCallbacks=[];function rootSelectors(){return rootSelectorCallbacks.map(e=>e())}function allSelectors(){return rootSelectorCallbacks.concat(initSelectorCallbacks).map(e=>e())}function addRootSelector(e){rootSelectorCallbacks.push(e)}function addInitSelector(e){initSelectorCallbacks.push(e)}function closestRoot(e,t=!1){return findClosest(e,n=>{if((t?allSelectors():rootSelectors()).some(i=>n.matches(i)))return!0})}function findClosest(e,t){if(e){if(t(e))return e;if(e._x_teleportBack&&(e=e._x_teleportBack),e.parentNode instanceof ShadowRoot)return findClosest(e.parentNode.host,t);if(e.parentElement)return findClosest(e.parentElement,t)}}function isRoot(e){return rootSelectors().some(t=>e.matches(t))}var initInterceptors2=[];function interceptInit(e){initInterceptors2.push(e)}var markerDispenser=1;function initTree(e,t=walk,n=()=>{}){findClosest(e,r=>r._x_ignore)||deferHandlingDirectives(()=>{t(e,(r,i)=>{r._x_marker||(n(r,i),initInterceptors2.forEach(o=>o(r,i)),directives(r,r.attributes).forEach(o=>o()),r._x_ignore||(r._x_marker=markerDispenser++),r._x_ignore&&i())})})}function destroyTree(e,t=walk){t(e,n=>{cleanupElement(n),cleanupAttributes(n),delete n._x_marker})}function warnAboutMissingPlugins(){[["ui","dialog",["[x-dialog], [x-popover]"]],["anchor","anchor",["[x-anchor]"]],["sort","sort",["[x-sort]"]]].forEach(([t,n,r])=>{directiveExists(n)||r.some(i=>{if(document.querySelector(i))return warn(`found "${i}", but missing ${t} plugin`),!0})})}var tickStack=[],isHolding=!1;function nextTick(e=()=>{}){return queueMicrotask(()=>{isHolding||setTimeout(()=>{releaseNextTicks()})}),new Promise(t=>{tickStack.push(()=>{e(),t()})})}function releaseNextTicks(){for(isHolding=!1;tickStack.length;)tickStack.shift()()}function holdNextTicks(){isHolding=!0}function setClasses(e,t){return Array.isArray(t)?setClassesFromString(e,t.join(" ")):typeof t=="object"&&t!==null?setClassesFromObject(e,t):typeof t=="function"?setClasses(e,t()):setClassesFromString(e,t)}function setClassesFromString(e,t){let n=i=>i.split(" ").filter(o=>!e.classList.contains(o)).filter(Boolean),r=i=>(e.classList.add(...i),()=>{e.classList.remove(...i)});return t=t===!0?t="":t||"",r(n(t))}function setClassesFromObject(e,t){let n=a=>a.split(" ").filter(Boolean),r=Object.entries(t).flatMap(([a,l])=>l?n(a):!1).filter(Boolean),i=Object.entries(t).flatMap(([a,l])=>l?!1:n(a)).filter(Boolean),o=[],s=[];return i.forEach(a=>{e.classList.contains(a)&&(e.classList.remove(a),s.push(a))}),r.forEach(a=>{e.classList.contains(a)||(e.classList.add(a),o.push(a))}),()=>{s.forEach(a=>e.classList.add(a)),o.forEach(a=>e.classList.remove(a))}}function setStyles(e,t){return typeof t=="object"&&t!==null?setStylesFromObject(e,t):setStylesFromString(e,t)}function setStylesFromObject(e,t){let n={};return Object.entries(t).forEach(([r,i])=>{n[r]=e.style[r],r.startsWith("--")||(r=kebabCase(r)),e.style.setProperty(r,i)}),setTimeout(()=>{e.style.length===0&&e.removeAttribute("style")}),()=>{setStyles(e,n)}}function setStylesFromString(e,t){let n=e.getAttribute("style",t);return e.setAttribute("style",t),()=>{e.setAttribute("style",n||"")}}function kebabCase(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function once(e,t=()=>{}){let n=!1;return function(){n?t.apply(this,arguments):(n=!0,e.apply(this,arguments))}}directive("transition",(e,{value:t,modifiers:n,expression:r},{evaluate:i})=>{typeof r=="function"&&(r=i(r)),r!==!1&&(!r||typeof r=="boolean"?registerTransitionsFromHelper(e,n,t):registerTransitionsFromClassString(e,r,t))});function registerTransitionsFromClassString(e,t,n){registerTransitionObject(e,setClasses,""),{enter:i=>{e._x_transition.enter.during=i},"enter-start":i=>{e._x_transition.enter.start=i},"enter-end":i=>{e._x_transition.enter.end=i},leave:i=>{e._x_transition.leave.during=i},"leave-start":i=>{e._x_transition.leave.start=i},"leave-end":i=>{e._x_transition.leave.end=i}}[n](t)}function registerTransitionsFromHelper(e,t,n){registerTransitionObject(e,setStyles);let r=!t.includes("in")&&!t.includes("out")&&!n,i=r||t.includes("in")||["enter"].includes(n),o=r||t.includes("out")||["leave"].includes(n);t.includes("in")&&!r&&(t=t.filter((m,y)=>y<t.indexOf("out"))),t.includes("out")&&!r&&(t=t.filter((m,y)=>y>t.indexOf("out")));let s=!t.includes("opacity")&&!t.includes("scale"),a=s||t.includes("opacity"),l=s||t.includes("scale"),c=a?0:1,u=l?modifierValue(t,"scale",95)/100:1,f=modifierValue(t,"delay",0)/1e3,d=modifierValue(t,"origin","center"),p="opacity, transform",g=modifierValue(t,"duration",150)/1e3,v=modifierValue(t,"duration",75)/1e3,h="cubic-bezier(0.4, 0.0, 0.2, 1)";i&&(e._x_transition.enter.during={transformOrigin:d,transitionDelay:`${f}s`,transitionProperty:p,transitionDuration:`${g}s`,transitionTimingFunction:h},e._x_transition.enter.start={opacity:c,transform:`scale(${u})`},e._x_transition.enter.end={opacity:1,transform:"scale(1)"}),o&&(e._x_transition.leave.during={transformOrigin:d,transitionDelay:`${f}s`,transitionProperty:p,transitionDuration:`${v}s`,transitionTimingFunction:h},e._x_transition.leave.start={opacity:1,transform:"scale(1)"},e._x_transition.leave.end={opacity:c,transform:`scale(${u})`})}function registerTransitionObject(e,t,n={}){e._x_transition||(e._x_transition={enter:{during:n,start:n,end:n},leave:{during:n,start:n,end:n},in(r=()=>{},i=()=>{}){transition(e,t,{during:this.enter.during,start:this.enter.start,end:this.enter.end},r,i)},out(r=()=>{},i=()=>{}){transition(e,t,{during:this.leave.during,start:this.leave.start,end:this.leave.end},r,i)}})}window.Element.prototype._x_toggleAndCascadeWithTransitions=function(e,t,n,r){const i=document.visibilityState==="visible"?requestAnimationFrame:setTimeout;let o=()=>i(n);if(t){e._x_transition&&(e._x_transition.enter||e._x_transition.leave)?e._x_transition.enter&&(Object.entries(e._x_transition.enter.during).length||Object.entries(e._x_transition.enter.start).length||Object.entries(e._x_transition.enter.end).length)?e._x_transition.in(n):o():e._x_transition?e._x_transition.in(n):o();return}e._x_hidePromise=e._x_transition?new Promise((s,a)=>{e._x_transition.out(()=>{},()=>s(r)),e._x_transitioning&&e._x_transitioning.beforeCancel(()=>a({isFromCancelledTransition:!0}))}):Promise.resolve(r),queueMicrotask(()=>{let s=closestHide(e);s?(s._x_hideChildren||(s._x_hideChildren=[]),s._x_hideChildren.push(e)):i(()=>{let a=l=>{let c=Promise.all([l._x_hidePromise,...(l._x_hideChildren||[]).map(a)]).then(([u])=>u==null?void 0:u());return delete l._x_hidePromise,delete l._x_hideChildren,c};a(e).catch(l=>{if(!l.isFromCancelledTransition)throw l})})})};function closestHide(e){let t=e.parentNode;if(t)return t._x_hidePromise?t:closestHide(t)}function transition(e,t,{during:n,start:r,end:i}={},o=()=>{},s=()=>{}){if(e._x_transitioning&&e._x_transitioning.cancel(),Object.keys(n).length===0&&Object.keys(r).length===0&&Object.keys(i).length===0){o(),s();return}let a,l,c;performTransition(e,{start(){a=t(e,r)},during(){l=t(e,n)},before:o,end(){a(),c=t(e,i)},after:s,cleanup(){l(),c()}})}function performTransition(e,t){let n,r,i,o=once(()=>{mutateDom(()=>{n=!0,r||t.before(),i||(t.end(),releaseNextTicks()),t.after(),e.isConnected&&t.cleanup(),delete e._x_transitioning})});e._x_transitioning={beforeCancels:[],beforeCancel(s){this.beforeCancels.push(s)},cancel:once(function(){for(;this.beforeCancels.length;)this.beforeCancels.shift()();o()}),finish:o},mutateDom(()=>{t.start(),t.during()}),holdNextTicks(),requestAnimationFrame(()=>{if(n)return;let s=Number(getComputedStyle(e).transitionDuration.replace(/,.*/,"").replace("s",""))*1e3,a=Number(getComputedStyle(e).transitionDelay.replace(/,.*/,"").replace("s",""))*1e3;s===0&&(s=Number(getComputedStyle(e).animationDuration.replace("s",""))*1e3),mutateDom(()=>{t.before()}),r=!0,requestAnimationFrame(()=>{n||(mutateDom(()=>{t.end()}),releaseNextTicks(),setTimeout(e._x_transitioning.finish,s+a),i=!0)})})}function modifierValue(e,t,n){if(e.indexOf(t)===-1)return n;const r=e[e.indexOf(t)+1];if(!r||t==="scale"&&isNaN(r))return n;if(t==="duration"||t==="delay"){let i=r.match(/([0-9]+)ms/);if(i)return i[1]}return t==="origin"&&["top","right","left","center","bottom"].includes(e[e.indexOf(t)+2])?[r,e[e.indexOf(t)+2]].join(" "):r}var isCloning=!1;function skipDuringClone(e,t=()=>{}){return(...n)=>isCloning?t(...n):e(...n)}function onlyDuringClone(e){return(...t)=>isCloning&&e(...t)}var interceptors=[];function interceptClone(e){interceptors.push(e)}function cloneNode(e,t){interceptors.forEach(n=>n(e,t)),isCloning=!0,dontRegisterReactiveSideEffects(()=>{initTree(t,(n,r)=>{r(n,()=>{})})}),isCloning=!1}var isCloningLegacy=!1;function clone(e,t){t._x_dataStack||(t._x_dataStack=e._x_dataStack),isCloning=!0,isCloningLegacy=!0,dontRegisterReactiveSideEffects(()=>{cloneTree(t)}),isCloning=!1,isCloningLegacy=!1}function cloneTree(e){let t=!1;initTree(e,(r,i)=>{walk(r,(o,s)=>{if(t&&isRoot(o))return s();t=!0,i(o,s)})})}function dontRegisterReactiveSideEffects(e){let t=effect;overrideEffect((n,r)=>{let i=t(n);return release(i),()=>{}}),e(),overrideEffect(t)}function bind(e,t,n,r=[]){switch(e._x_bindings||(e._x_bindings=reactive({})),e._x_bindings[t]=n,t=r.includes("camel")?camelCase(t):t,t){case"value":bindInputValue(e,n);break;case"style":bindStyles(e,n);break;case"class":bindClasses(e,n);break;case"selected":case"checked":bindAttributeAndProperty(e,t,n);break;default:bindAttribute(e,t,n);break}}function bindInputValue(e,t){if(isRadio(e))e.attributes.value===void 0&&(e.value=t),window.fromModel&&(typeof t=="boolean"?e.checked=safeParseBoolean(e.value)===t:e.checked=checkedAttrLooseCompare(e.value,t));else if(isCheckbox(e))Number.isInteger(t)?e.value=t:!Array.isArray(t)&&typeof t!="boolean"&&![null,void 0].includes(t)?e.value=String(t):Array.isArray(t)?e.checked=t.some(n=>checkedAttrLooseCompare(n,e.value)):e.checked=!!t;else if(e.tagName==="SELECT")updateSelect(e,t);else{if(e.value===t)return;e.value=t===void 0?"":t}}function bindClasses(e,t){e._x_undoAddedClasses&&e._x_undoAddedClasses(),e._x_undoAddedClasses=setClasses(e,t)}function bindStyles(e,t){e._x_undoAddedStyles&&e._x_undoAddedStyles(),e._x_undoAddedStyles=setStyles(e,t)}function bindAttributeAndProperty(e,t,n){bindAttribute(e,t,n),setPropertyIfChanged(e,t,n)}function bindAttribute(e,t,n){[null,void 0,!1].includes(n)&&attributeShouldntBePreservedIfFalsy(t)?e.removeAttribute(t):(isBooleanAttr(t)&&(n=t),setIfChanged(e,t,n))}function setIfChanged(e,t,n){e.getAttribute(t)!=n&&e.setAttribute(t,n)}function setPropertyIfChanged(e,t,n){e[t]!==n&&(e[t]=n)}function updateSelect(e,t){const n=[].concat(t).map(r=>r+"");Array.from(e.options).forEach(r=>{r.selected=n.includes(r.value)})}function camelCase(e){return e.toLowerCase().replace(/-(\w)/g,(t,n)=>n.toUpperCase())}function checkedAttrLooseCompare(e,t){return e==t}function safeParseBoolean(e){return[1,"1","true","on","yes",!0].includes(e)?!0:[0,"0","false","off","no",!1].includes(e)?!1:e?!!e:null}var booleanAttributes=new Set(["allowfullscreen","async","autofocus","autoplay","checked","controls","default","defer","disabled","formnovalidate","inert","ismap","itemscope","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected","shadowrootclonable","shadowrootdelegatesfocus","shadowrootserializable"]);function isBooleanAttr(e){return booleanAttributes.has(e)}function attributeShouldntBePreservedIfFalsy(e){return!["aria-pressed","aria-checked","aria-expanded","aria-selected"].includes(e)}function getBinding(e,t,n){return e._x_bindings&&e._x_bindings[t]!==void 0?e._x_bindings[t]:getAttributeBinding(e,t,n)}function extractProp(e,t,n,r=!0){if(e._x_bindings&&e._x_bindings[t]!==void 0)return e._x_bindings[t];if(e._x_inlineBindings&&e._x_inlineBindings[t]!==void 0){let i=e._x_inlineBindings[t];return i.extract=r,dontAutoEvaluateFunctions(()=>evaluate(e,i.expression))}return getAttributeBinding(e,t,n)}function getAttributeBinding(e,t,n){let r=e.getAttribute(t);return r===null?typeof n=="function"?n():n:r===""?!0:isBooleanAttr(t)?!![t,"true"].includes(r):r}function isCheckbox(e){return e.type==="checkbox"||e.localName==="ui-checkbox"||e.localName==="ui-switch"}function isRadio(e){return e.type==="radio"||e.localName==="ui-radio"}function debounce(e,t){let n;return function(){const r=this,i=arguments,o=function(){n=null,e.apply(r,i)};clearTimeout(n),n=setTimeout(o,t)}}function throttle(e,t){let n;return function(){let r=this,i=arguments;n||(e.apply(r,i),n=!0,setTimeout(()=>n=!1,t))}}function entangle({get:e,set:t},{get:n,set:r}){let i=!0,o,s=effect(()=>{let a=e(),l=n();if(i)r(cloneIfObject(a)),i=!1;else{let c=JSON.stringify(a),u=JSON.stringify(l);c!==o?r(cloneIfObject(a)):c!==u&&t(cloneIfObject(l))}o=JSON.stringify(e()),JSON.stringify(n())});return()=>{release(s)}}function cloneIfObject(e){return typeof e=="object"?JSON.parse(JSON.stringify(e)):e}function plugin(e){(Array.isArray(e)?e:[e]).forEach(n=>n(alpine_default))}var stores={},isReactive=!1;function store(e,t){if(isReactive||(stores=reactive(stores),isReactive=!0),t===void 0)return stores[e];stores[e]=t,initInterceptors(stores[e]),typeof t=="object"&&t!==null&&t.hasOwnProperty("init")&&typeof t.init=="function"&&stores[e].init()}function getStores(){return stores}var binds={};function bind2(e,t){let n=typeof t!="function"?()=>t:t;return e instanceof Element?applyBindingsObject(e,n()):(binds[e]=n,()=>{})}function injectBindingProviders(e){return Object.entries(binds).forEach(([t,n])=>{Object.defineProperty(e,t,{get(){return(...r)=>n(...r)}})}),e}function applyBindingsObject(e,t,n){let r=[];for(;r.length;)r.pop()();let i=Object.entries(t).map(([s,a])=>({name:s,value:a})),o=attributesOnly(i);return i=i.map(s=>o.find(a=>a.name===s.name)?{name:`x-bind:${s.name}`,value:`"${s.value}"`}:s),directives(e,i,n).map(s=>{r.push(s.runCleanups),s()}),()=>{for(;r.length;)r.pop()()}}var datas={};function data(e,t){datas[e]=t}function injectDataProviders(e,t){return Object.entries(datas).forEach(([n,r])=>{Object.defineProperty(e,n,{get(){return(...i)=>r.bind(t)(...i)},enumerable:!1})}),e}var Alpine={get reactive(){return reactive},get release(){return release},get effect(){return effect},get raw(){return raw},version:"3.15.4",flushAndStopDeferringMutations,dontAutoEvaluateFunctions,disableEffectScheduling,startObservingMutations,stopObservingMutations,setReactivityEngine,onAttributeRemoved,onAttributesAdded,closestDataStack,skipDuringClone,onlyDuringClone,addRootSelector,addInitSelector,setErrorHandler,interceptClone,addScopeToNode,deferMutations,mapAttributes,evaluateLater,interceptInit,initInterceptors,injectMagics,setEvaluator,setRawEvaluator,mergeProxies,extractProp,findClosest,onElRemoved,closestRoot,destroyTree,interceptor,transition,setStyles,mutateDom,directive,entangle,throttle,debounce,evaluate,evaluateRaw,initTree,nextTick,prefixed:prefix,prefix:setPrefix,plugin,magic,store,start,clone,cloneNode,bound:getBinding,$data:scope,watch,walk,data,bind:bind2},alpine_default=Alpine;function makeMap(e,t){const n=Object.create(null),r=e.split(",");for(let i=0;i<r.length;i++)n[r[i]]=!0;return i=>!!n[i]}var EMPTY_OBJ=Object.freeze({}),hasOwnProperty=Object.prototype.hasOwnProperty,hasOwn=(e,t)=>hasOwnProperty.call(e,t),isArray=Array.isArray,isMap=e=>toTypeString(e)==="[object Map]",isString=e=>typeof e=="string",isSymbol=e=>typeof e=="symbol",isObject=e=>e!==null&&typeof e=="object",objectToString=Object.prototype.toString,toTypeString=e=>objectToString.call(e),toRawType=e=>toTypeString(e).slice(8,-1),isIntegerKey=e=>isString(e)&&e!=="NaN"&&e[0]!=="-"&&""+parseInt(e,10)===e,cacheStringFunction=e=>{const t=Object.create(null);return n=>t[n]||(t[n]=e(n))},capitalize=cacheStringFunction(e=>e.charAt(0).toUpperCase()+e.slice(1)),hasChanged=(e,t)=>e!==t&&(e===e||t===t),targetMap=new WeakMap,effectStack=[],activeEffect,ITERATE_KEY=Symbol("iterate"),MAP_KEY_ITERATE_KEY=Symbol("Map key iterate");function isEffect(e){return e&&e._isEffect===!0}function effect2(e,t=EMPTY_OBJ){isEffect(e)&&(e=e.raw);const n=createReactiveEffect(e,t);return t.lazy||n(),n}function stop(e){e.active&&(cleanup(e),e.options.onStop&&e.options.onStop(),e.active=!1)}var uid=0;function createReactiveEffect(e,t){const n=function(){if(!n.active)return e();if(!effectStack.includes(n)){cleanup(n);try{return enableTracking(),effectStack.push(n),activeEffect=n,e()}finally{effectStack.pop(),resetTracking(),activeEffect=effectStack[effectStack.length-1]}}};return n.id=uid++,n.allowRecurse=!!t.allowRecurse,n._isEffect=!0,n.active=!0,n.raw=e,n.deps=[],n.options=t,n}function cleanup(e){const{deps:t}=e;if(t.length){for(let n=0;n<t.length;n++)t[n].delete(e);t.length=0}}var shouldTrack=!0,trackStack=[];function pauseTracking(){trackStack.push(shouldTrack),shouldTrack=!1}function enableTracking(){trackStack.push(shouldTrack),shouldTrack=!0}function resetTracking(){const e=trackStack.pop();shouldTrack=e===void 0?!0:e}function track(e,t,n){if(!shouldTrack||activeEffect===void 0)return;let r=targetMap.get(e);r||targetMap.set(e,r=new Map);let i=r.get(n);i||r.set(n,i=new Set),i.has(activeEffect)||(i.add(activeEffect),activeEffect.deps.push(i),activeEffect.options.onTrack&&activeEffect.options.onTrack({effect:activeEffect,target:e,type:t,key:n}))}function trigger(e,t,n,r,i,o){const s=targetMap.get(e);if(!s)return;const a=new Set,l=u=>{u&&u.forEach(f=>{(f!==activeEffect||f.allowRecurse)&&a.add(f)})};if(t==="clear")s.forEach(l);else if(n==="length"&&isArray(e))s.forEach((u,f)=>{(f==="length"||f>=r)&&l(u)});else switch(n!==void 0&&l(s.get(n)),t){case"add":isArray(e)?isIntegerKey(n)&&l(s.get("length")):(l(s.get(ITERATE_KEY)),isMap(e)&&l(s.get(MAP_KEY_ITERATE_KEY)));break;case"delete":isArray(e)||(l(s.get(ITERATE_KEY)),isMap(e)&&l(s.get(MAP_KEY_ITERATE_KEY)));break;case"set":isMap(e)&&l(s.get(ITERATE_KEY));break}const c=u=>{u.options.onTrigger&&u.options.onTrigger({effect:u,target:e,key:n,type:t,newValue:r,oldValue:i,oldTarget:o}),u.options.scheduler?u.options.scheduler(u):u()};a.forEach(c)}var isNonTrackableKeys=makeMap("__proto__,__v_isRef,__isVue"),builtInSymbols=new Set(Object.getOwnPropertyNames(Symbol).map(e=>Symbol[e]).filter(isSymbol)),get2=createGetter(),readonlyGet=createGetter(!0),arrayInstrumentations=createArrayInstrumentations();function createArrayInstrumentations(){const e={};return["includes","indexOf","lastIndexOf"].forEach(t=>{e[t]=function(...n){const r=toRaw(this);for(let o=0,s=this.length;o<s;o++)track(r,"get",o+"");const i=r[t](...n);return i===-1||i===!1?r[t](...n.map(toRaw)):i}}),["push","pop","shift","unshift","splice"].forEach(t=>{e[t]=function(...n){pauseTracking();const r=toRaw(this)[t].apply(this,n);return resetTracking(),r}}),e}function createGetter(e=!1,t=!1){return function(r,i,o){if(i==="__v_isReactive")return!e;if(i==="__v_isReadonly")return e;if(i==="__v_raw"&&o===(e?t?shallowReadonlyMap:readonlyMap:t?shallowReactiveMap:reactiveMap).get(r))return r;const s=isArray(r);if(!e&&s&&hasOwn(arrayInstrumentations,i))return Reflect.get(arrayInstrumentations,i,o);const a=Reflect.get(r,i,o);return(isSymbol(i)?builtInSymbols.has(i):isNonTrackableKeys(i))||(e||track(r,"get",i),t)?a:isRef(a)?!s||!isIntegerKey(i)?a.value:a:isObject(a)?e?readonly(a):reactive2(a):a}}var set2=createSetter();function createSetter(e=!1){return function(n,r,i,o){let s=n[r];if(!e&&(i=toRaw(i),s=toRaw(s),!isArray(n)&&isRef(s)&&!isRef(i)))return s.value=i,!0;const a=isArray(n)&&isIntegerKey(r)?Number(r)<n.length:hasOwn(n,r),l=Reflect.set(n,r,i,o);return n===toRaw(o)&&(a?hasChanged(i,s)&&trigger(n,"set",r,i,s):trigger(n,"add",r,i)),l}}function deleteProperty(e,t){const n=hasOwn(e,t),r=e[t],i=Reflect.deleteProperty(e,t);return i&&n&&trigger(e,"delete",t,void 0,r),i}function has(e,t){const n=Reflect.has(e,t);return(!isSymbol(t)||!builtInSymbols.has(t))&&track(e,"has",t),n}function ownKeys(e){return track(e,"iterate",isArray(e)?"length":ITERATE_KEY),Reflect.ownKeys(e)}var mutableHandlers={get:get2,set:set2,deleteProperty,has,ownKeys},readonlyHandlers={get:readonlyGet,set(e,t){return console.warn(`Set operation on key "${String(t)}" failed: target is readonly.`,e),!0},deleteProperty(e,t){return console.warn(`Delete operation on key "${String(t)}" failed: target is readonly.`,e),!0}},toReactive=e=>isObject(e)?reactive2(e):e,toReadonly=e=>isObject(e)?readonly(e):e,toShallow=e=>e,getProto=e=>Reflect.getPrototypeOf(e);function get$1(e,t,n=!1,r=!1){e=e.__v_raw;const i=toRaw(e),o=toRaw(t);t!==o&&!n&&track(i,"get",t),!n&&track(i,"get",o);const{has:s}=getProto(i),a=r?toShallow:n?toReadonly:toReactive;if(s.call(i,t))return a(e.get(t));if(s.call(i,o))return a(e.get(o));e!==i&&e.get(t)}function has$1(e,t=!1){const n=this.__v_raw,r=toRaw(n),i=toRaw(e);return e!==i&&!t&&track(r,"has",e),!t&&track(r,"has",i),e===i?n.has(e):n.has(e)||n.has(i)}function size(e,t=!1){return e=e.__v_raw,!t&&track(toRaw(e),"iterate",ITERATE_KEY),Reflect.get(e,"size",e)}function add(e){e=toRaw(e);const t=toRaw(this);return getProto(t).has.call(t,e)||(t.add(e),trigger(t,"add",e,e)),this}function set$1(e,t){t=toRaw(t);const n=toRaw(this),{has:r,get:i}=getProto(n);let o=r.call(n,e);o?checkIdentityKeys(n,r,e):(e=toRaw(e),o=r.call(n,e));const s=i.call(n,e);return n.set(e,t),o?hasChanged(t,s)&&trigger(n,"set",e,t,s):trigger(n,"add",e,t),this}function deleteEntry(e){const t=toRaw(this),{has:n,get:r}=getProto(t);let i=n.call(t,e);i?checkIdentityKeys(t,n,e):(e=toRaw(e),i=n.call(t,e));const o=r?r.call(t,e):void 0,s=t.delete(e);return i&&trigger(t,"delete",e,void 0,o),s}function clear(){const e=toRaw(this),t=e.size!==0,n=isMap(e)?new Map(e):new Set(e),r=e.clear();return t&&trigger(e,"clear",void 0,void 0,n),r}function createForEach(e,t){return function(r,i){const o=this,s=o.__v_raw,a=toRaw(s),l=t?toShallow:e?toReadonly:toReactive;return!e&&track(a,"iterate",ITERATE_KEY),s.forEach((c,u)=>r.call(i,l(c),l(u),o))}}function createIterableMethod(e,t,n){return function(...r){const i=this.__v_raw,o=toRaw(i),s=isMap(o),a=e==="entries"||e===Symbol.iterator&&s,l=e==="keys"&&s,c=i[e](...r),u=n?toShallow:t?toReadonly:toReactive;return!t&&track(o,"iterate",l?MAP_KEY_ITERATE_KEY:ITERATE_KEY),{next(){const{value:f,done:d}=c.next();return d?{value:f,done:d}:{value:a?[u(f[0]),u(f[1])]:u(f),done:d}},[Symbol.iterator](){return this}}}}function createReadonlyMethod(e){return function(...t){{const n=t[0]?`on key "${t[0]}" `:"";console.warn(`${capitalize(e)} operation ${n}failed: target is readonly.`,toRaw(this))}return e==="delete"?!1:this}}function createInstrumentations(){const e={get(o){return get$1(this,o)},get size(){return size(this)},has:has$1,add,set:set$1,delete:deleteEntry,clear,forEach:createForEach(!1,!1)},t={get(o){return get$1(this,o,!1,!0)},get size(){return size(this)},has:has$1,add,set:set$1,delete:deleteEntry,clear,forEach:createForEach(!1,!0)},n={get(o){return get$1(this,o,!0)},get size(){return size(this,!0)},has(o){return has$1.call(this,o,!0)},add:createReadonlyMethod("add"),set:createReadonlyMethod("set"),delete:createReadonlyMethod("delete"),clear:createReadonlyMethod("clear"),forEach:createForEach(!0,!1)},r={get(o){return get$1(this,o,!0,!0)},get size(){return size(this,!0)},has(o){return has$1.call(this,o,!0)},add:createReadonlyMethod("add"),set:createReadonlyMethod("set"),delete:createReadonlyMethod("delete"),clear:createReadonlyMethod("clear"),forEach:createForEach(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach(o=>{e[o]=createIterableMethod(o,!1,!1),n[o]=createIterableMethod(o,!0,!1),t[o]=createIterableMethod(o,!1,!0),r[o]=createIterableMethod(o,!0,!0)}),[e,n,t,r]}var[mutableInstrumentations,readonlyInstrumentations]=createInstrumentations();function createInstrumentationGetter(e,t){const n=e?readonlyInstrumentations:mutableInstrumentations;return(r,i,o)=>i==="__v_isReactive"?!e:i==="__v_isReadonly"?e:i==="__v_raw"?r:Reflect.get(hasOwn(n,i)&&i in r?n:r,i,o)}var mutableCollectionHandlers={get:createInstrumentationGetter(!1)},readonlyCollectionHandlers={get:createInstrumentationGetter(!0)};function checkIdentityKeys(e,t,n){const r=toRaw(n);if(r!==n&&t.call(e,r)){const i=toRawType(e);console.warn(`Reactive ${i} contains both the raw and reactive versions of the same object${i==="Map"?" as keys":""}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`)}}var reactiveMap=new WeakMap,shallowReactiveMap=new WeakMap,readonlyMap=new WeakMap,shallowReadonlyMap=new WeakMap;function targetTypeMap(e){switch(e){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function getTargetType(e){return e.__v_skip||!Object.isExtensible(e)?0:targetTypeMap(toRawType(e))}function reactive2(e){return e&&e.__v_isReadonly?e:createReactiveObject(e,!1,mutableHandlers,mutableCollectionHandlers,reactiveMap)}function readonly(e){return createReactiveObject(e,!0,readonlyHandlers,readonlyCollectionHandlers,readonlyMap)}function createReactiveObject(e,t,n,r,i){if(!isObject(e))return console.warn(`value cannot be made reactive: ${String(e)}`),e;if(e.__v_raw&&!(t&&e.__v_isReactive))return e;const o=i.get(e);if(o)return o;const s=getTargetType(e);if(s===0)return e;const a=new Proxy(e,s===2?r:n);return i.set(e,a),a}function toRaw(e){return e&&toRaw(e.__v_raw)||e}function isRef(e){return!!(e&&e.__v_isRef===!0)}magic("nextTick",()=>nextTick);magic("dispatch",e=>dispatch.bind(dispatch,e));magic("watch",(e,{evaluateLater:t,cleanup:n})=>(r,i)=>{let o=t(r),a=watch(()=>{let l;return o(c=>l=c),l},i);n(a)});magic("store",getStores);magic("data",e=>scope(e));magic("root",e=>closestRoot(e));magic("refs",e=>(e._x_refs_proxy||(e._x_refs_proxy=mergeProxies(getArrayOfRefObject(e))),e._x_refs_proxy));function getArrayOfRefObject(e){let t=[];return findClosest(e,n=>{n._x_refs&&t.push(n._x_refs)}),t}var globalIdMemo={};function findAndIncrementId(e){return globalIdMemo[e]||(globalIdMemo[e]=0),++globalIdMemo[e]}function closestIdRoot(e,t){return findClosest(e,n=>{if(n._x_ids&&n._x_ids[t])return!0})}function setIdRoot(e,t){e._x_ids||(e._x_ids={}),e._x_ids[t]||(e._x_ids[t]=findAndIncrementId(t))}magic("id",(e,{cleanup:t})=>(n,r=null)=>{let i=`${n}${r?`-${r}`:""}`;return cacheIdByNameOnElement(e,i,t,()=>{let o=closestIdRoot(e,n),s=o?o._x_ids[n]:findAndIncrementId(n);return r?`${n}-${s}-${r}`:`${n}-${s}`})});interceptClone((e,t)=>{e._x_id&&(t._x_id=e._x_id)});function cacheIdByNameOnElement(e,t,n,r){if(e._x_id||(e._x_id={}),e._x_id[t])return e._x_id[t];let i=r();return e._x_id[t]=i,n(()=>{delete e._x_id[t]}),i}magic("el",e=>e);warnMissingPluginMagic("Focus","focus","focus");warnMissingPluginMagic("Persist","persist","persist");function warnMissingPluginMagic(e,t,n){magic(t,r=>warn(`You can't use [$${t}] without first installing the "${e}" plugin here: https://alpinejs.dev/plugins/${n}`,r))}directive("modelable",(e,{expression:t},{effect:n,evaluateLater:r,cleanup:i})=>{let o=r(t),s=()=>{let u;return o(f=>u=f),u},a=r(`${t} = __placeholder`),l=u=>a(()=>{},{scope:{__placeholder:u}}),c=s();l(c),queueMicrotask(()=>{if(!e._x_model)return;e._x_removeModelListeners.default();let u=e._x_model.get,f=e._x_model.set,d=entangle({get(){return u()},set(p){f(p)}},{get(){return s()},set(p){l(p)}});i(d)})});directive("teleport",(e,{modifiers:t,expression:n},{cleanup:r})=>{e.tagName.toLowerCase()!=="template"&&warn("x-teleport can only be used on a <template> tag",e);let i=getTarget(n),o=e.content.cloneNode(!0).firstElementChild;e._x_teleport=o,o._x_teleportBack=e,e.setAttribute("data-teleport-template",!0),o.setAttribute("data-teleport-target",!0),e._x_forwardEvents&&e._x_forwardEvents.forEach(a=>{o.addEventListener(a,l=>{l.stopPropagation(),e.dispatchEvent(new l.constructor(l.type,l))})}),addScopeToNode(o,{},e);let s=(a,l,c)=>{c.includes("prepend")?l.parentNode.insertBefore(a,l):c.includes("append")?l.parentNode.insertBefore(a,l.nextSibling):l.appendChild(a)};mutateDom(()=>{s(o,i,t),skipDuringClone(()=>{initTree(o)})()}),e._x_teleportPutBack=()=>{let a=getTarget(n);mutateDom(()=>{s(e._x_teleport,a,t)})},r(()=>mutateDom(()=>{o.remove(),destroyTree(o)}))});var teleportContainerDuringClone=document.createElement("div");function getTarget(e){let t=skipDuringClone(()=>document.querySelector(e),()=>teleportContainerDuringClone)();return t||warn(`Cannot find x-teleport element for selector: "${e}"`),t}var handler=()=>{};handler.inline=(e,{modifiers:t},{cleanup:n})=>{t.includes("self")?e._x_ignoreSelf=!0:e._x_ignore=!0,n(()=>{t.includes("self")?delete e._x_ignoreSelf:delete e._x_ignore})};directive("ignore",handler);directive("effect",skipDuringClone((e,{expression:t},{effect:n})=>{n(evaluateLater(e,t))}));function on(e,t,n,r){let i=e,o=l=>r(l),s={},a=(l,c)=>u=>c(l,u);if(n.includes("dot")&&(t=dotSyntax(t)),n.includes("camel")&&(t=camelCase2(t)),n.includes("passive")&&(s.passive=!0),n.includes("capture")&&(s.capture=!0),n.includes("window")&&(i=window),n.includes("document")&&(i=document),n.includes("debounce")){let l=n[n.indexOf("debounce")+1]||"invalid-wait",c=isNumeric(l.split("ms")[0])?Number(l.split("ms")[0]):250;o=debounce(o,c)}if(n.includes("throttle")){let l=n[n.indexOf("throttle")+1]||"invalid-wait",c=isNumeric(l.split("ms")[0])?Number(l.split("ms")[0]):250;o=throttle(o,c)}return n.includes("prevent")&&(o=a(o,(l,c)=>{c.preventDefault(),l(c)})),n.includes("stop")&&(o=a(o,(l,c)=>{c.stopPropagation(),l(c)})),n.includes("once")&&(o=a(o,(l,c)=>{l(c),i.removeEventListener(t,o,s)})),(n.includes("away")||n.includes("outside"))&&(i=document,o=a(o,(l,c)=>{e.contains(c.target)||c.target.isConnected!==!1&&(e.offsetWidth<1&&e.offsetHeight<1||e._x_isShown!==!1&&l(c))})),n.includes("self")&&(o=a(o,(l,c)=>{c.target===e&&l(c)})),(isKeyEvent(t)||isClickEvent(t))&&(o=a(o,(l,c)=>{isListeningForASpecificKeyThatHasntBeenPressed(c,n)||l(c)})),i.addEventListener(t,o,s),()=>{i.removeEventListener(t,o,s)}}function dotSyntax(e){return e.replace(/-/g,".")}function camelCase2(e){return e.toLowerCase().replace(/-(\w)/g,(t,n)=>n.toUpperCase())}function isNumeric(e){return!Array.isArray(e)&&!isNaN(e)}function kebabCase2(e){return[" ","_"].includes(e)?e:e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[_\s]/,"-").toLowerCase()}function isKeyEvent(e){return["keydown","keyup"].includes(e)}function isClickEvent(e){return["contextmenu","click","mouse"].some(t=>e.includes(t))}function isListeningForASpecificKeyThatHasntBeenPressed(e,t){let n=t.filter(o=>!["window","document","prevent","stop","once","capture","self","away","outside","passive","preserve-scroll"].includes(o));if(n.includes("debounce")){let o=n.indexOf("debounce");n.splice(o,isNumeric((n[o+1]||"invalid-wait").split("ms")[0])?2:1)}if(n.includes("throttle")){let o=n.indexOf("throttle");n.splice(o,isNumeric((n[o+1]||"invalid-wait").split("ms")[0])?2:1)}if(n.length===0||n.length===1&&keyToModifiers(e.key).includes(n[0]))return!1;const i=["ctrl","shift","alt","meta","cmd","super"].filter(o=>n.includes(o));return n=n.filter(o=>!i.includes(o)),!(i.length>0&&i.filter(s=>((s==="cmd"||s==="super")&&(s="meta"),e[`${s}Key`])).length===i.length&&(isClickEvent(e.type)||keyToModifiers(e.key).includes(n[0])))}function keyToModifiers(e){if(!e)return[];e=kebabCase2(e);let t={ctrl:"control",slash:"/",space:" ",spacebar:" ",cmd:"meta",esc:"escape",up:"arrow-up",down:"arrow-down",left:"arrow-left",right:"arrow-right",period:".",comma:",",equal:"=",minus:"-",underscore:"_"};return t[e]=e,Object.keys(t).map(n=>{if(t[n]===e)return n}).filter(n=>n)}directive("model",(e,{modifiers:t,expression:n},{effect:r,cleanup:i})=>{let o=e;t.includes("parent")&&(o=e.parentNode);let s=evaluateLater(o,n),a;typeof n=="string"?a=evaluateLater(o,`${n} = __placeholder`):typeof n=="function"&&typeof n()=="string"?a=evaluateLater(o,`${n()} = __placeholder`):a=()=>{};let l=()=>{let d;return s(p=>d=p),isGetterSetter(d)?d.get():d},c=d=>{let p;s(g=>p=g),isGetterSetter(p)?p.set(d):a(()=>{},{scope:{__placeholder:d}})};typeof n=="string"&&e.type==="radio"&&mutateDom(()=>{e.hasAttribute("name")||e.setAttribute("name",n)});let u=e.tagName.toLowerCase()==="select"||["checkbox","radio"].includes(e.type)||t.includes("lazy")?"change":"input",f=isCloning?()=>{}:on(e,u,t,d=>{c(getInputValue(e,t,d,l()))});if(t.includes("fill")&&([void 0,null,""].includes(l())||isCheckbox(e)&&Array.isArray(l())||e.tagName.toLowerCase()==="select"&&e.multiple)&&c(getInputValue(e,t,{target:e},l())),e._x_removeModelListeners||(e._x_removeModelListeners={}),e._x_removeModelListeners.default=f,i(()=>e._x_removeModelListeners.default()),e.form){let d=on(e.form,"reset",[],p=>{nextTick(()=>e._x_model&&e._x_model.set(getInputValue(e,t,{target:e},l())))});i(()=>d())}e._x_model={get(){return l()},set(d){c(d)}},e._x_forceModelUpdate=d=>{d===void 0&&typeof n=="string"&&n.match(/\./)&&(d=""),window.fromModel=!0,mutateDom(()=>bind(e,"value",d)),delete window.fromModel},r(()=>{let d=l();t.includes("unintrusive")&&document.activeElement.isSameNode(e)||e._x_forceModelUpdate(d)})});function getInputValue(e,t,n,r){return mutateDom(()=>{if(n instanceof CustomEvent&&n.detail!==void 0)return n.detail!==null&&n.detail!==void 0?n.detail:n.target.value;if(isCheckbox(e))if(Array.isArray(r)){let i=null;return t.includes("number")?i=safeParseNumber(n.target.value):t.includes("boolean")?i=safeParseBoolean(n.target.value):i=n.target.value,n.target.checked?r.includes(i)?r:r.concat([i]):r.filter(o=>!checkedAttrLooseCompare2(o,i))}else return n.target.checked;else{if(e.tagName.toLowerCase()==="select"&&e.multiple)return t.includes("number")?Array.from(n.target.selectedOptions).map(i=>{let o=i.value||i.text;return safeParseNumber(o)}):t.includes("boolean")?Array.from(n.target.selectedOptions).map(i=>{let o=i.value||i.text;return safeParseBoolean(o)}):Array.from(n.target.selectedOptions).map(i=>i.value||i.text);{let i;return isRadio(e)?n.target.checked?i=n.target.value:i=r:i=n.target.value,t.includes("number")?safeParseNumber(i):t.includes("boolean")?safeParseBoolean(i):t.includes("trim")?i.trim():i}}})}function safeParseNumber(e){let t=e?parseFloat(e):null;return isNumeric2(t)?t:e}function checkedAttrLooseCompare2(e,t){return e==t}function isNumeric2(e){return!Array.isArray(e)&&!isNaN(e)}function isGetterSetter(e){return e!==null&&typeof e=="object"&&typeof e.get=="function"&&typeof e.set=="function"}directive("cloak",e=>queueMicrotask(()=>mutateDom(()=>e.removeAttribute(prefix("cloak")))));addInitSelector(()=>`[${prefix("init")}]`);directive("init",skipDuringClone((e,{expression:t},{evaluate:n})=>typeof t=="string"?!!t.trim()&&n(t,{},!1):n(t,{},!1)));directive("text",(e,{expression:t},{effect:n,evaluateLater:r})=>{let i=r(t);n(()=>{i(o=>{mutateDom(()=>{e.textContent=o})})})});directive("html",(e,{expression:t},{effect:n,evaluateLater:r})=>{let i=r(t);n(()=>{i(o=>{mutateDom(()=>{e.innerHTML=o,e._x_ignoreSelf=!0,initTree(e),delete e._x_ignoreSelf})})})});mapAttributes(startingWith(":",into(prefix("bind:"))));var handler2=(e,{value:t,modifiers:n,expression:r,original:i},{effect:o,cleanup:s})=>{if(!t){let l={};injectBindingProviders(l),evaluateLater(e,r)(u=>{applyBindingsObject(e,u,i)},{scope:l});return}if(t==="key")return storeKeyForXFor(e,r);if(e._x_inlineBindings&&e._x_inlineBindings[t]&&e._x_inlineBindings[t].extract)return;let a=evaluateLater(e,r);o(()=>a(l=>{l===void 0&&typeof r=="string"&&r.match(/\./)&&(l=""),mutateDom(()=>bind(e,t,l,n))})),s(()=>{e._x_undoAddedClasses&&e._x_undoAddedClasses(),e._x_undoAddedStyles&&e._x_undoAddedStyles()})};handler2.inline=(e,{value:t,modifiers:n,expression:r})=>{t&&(e._x_inlineBindings||(e._x_inlineBindings={}),e._x_inlineBindings[t]={expression:r,extract:!1})};directive("bind",handler2);function storeKeyForXFor(e,t){e._x_keyExpression=t}addRootSelector(()=>`[${prefix("data")}]`);directive("data",(e,{expression:t},{cleanup:n})=>{if(shouldSkipRegisteringDataDuringClone(e))return;t=t===""?"{}":t;let r={};injectMagics(r,e);let i={};injectDataProviders(i,r);let o=evaluate(e,t,{scope:i});(o===void 0||o===!0)&&(o={}),injectMagics(o,e);let s=reactive(o);initInterceptors(s);let a=addScopeToNode(e,s);s.init&&evaluate(e,s.init),n(()=>{s.destroy&&evaluate(e,s.destroy),a()})});interceptClone((e,t)=>{e._x_dataStack&&(t._x_dataStack=e._x_dataStack,t.setAttribute("data-has-alpine-state",!0))});function shouldSkipRegisteringDataDuringClone(e){return isCloning?isCloningLegacy?!0:e.hasAttribute("data-has-alpine-state"):!1}directive("show",(e,{modifiers:t,expression:n},{effect:r})=>{let i=evaluateLater(e,n);e._x_doHide||(e._x_doHide=()=>{mutateDom(()=>{e.style.setProperty("display","none",t.includes("important")?"important":void 0)})}),e._x_doShow||(e._x_doShow=()=>{mutateDom(()=>{e.style.length===1&&e.style.display==="none"?e.removeAttribute("style"):e.style.removeProperty("display")})});let o=()=>{e._x_doHide(),e._x_isShown=!1},s=()=>{e._x_doShow(),e._x_isShown=!0},a=()=>setTimeout(s),l=once(f=>f?s():o(),f=>{typeof e._x_toggleAndCascadeWithTransitions=="function"?e._x_toggleAndCascadeWithTransitions(e,f,s,o):f?a():o()}),c,u=!0;r(()=>i(f=>{!u&&f===c||(t.includes("immediate")&&(f?a():o()),l(f),c=f,u=!1)}))});directive("for",(e,{expression:t},{effect:n,cleanup:r})=>{let i=parseForExpression(t),o=evaluateLater(e,i.items),s=evaluateLater(e,e._x_keyExpression||"index");e._x_prevKeys=[],e._x_lookup={},n(()=>loop(e,i,o,s)),r(()=>{Object.values(e._x_lookup).forEach(a=>mutateDom(()=>{destroyTree(a),a.remove()})),delete e._x_prevKeys,delete e._x_lookup})});function loop(e,t,n,r){let i=s=>typeof s=="object"&&!Array.isArray(s),o=e;n(s=>{isNumeric3(s)&&s>=0&&(s=Array.from(Array(s).keys(),h=>h+1)),s===void 0&&(s=[]);let a=e._x_lookup,l=e._x_prevKeys,c=[],u=[];if(i(s))s=Object.entries(s).map(([h,m])=>{let y=getIterationScopeVariables(t,m,h,s);r(E=>{u.includes(E)&&warn("Duplicate key on x-for",e),u.push(E)},{scope:{index:h,...y}}),c.push(y)});else for(let h=0;h<s.length;h++){let m=getIterationScopeVariables(t,s[h],h,s);r(y=>{u.includes(y)&&warn("Duplicate key on x-for",e),u.push(y)},{scope:{index:h,...m}}),c.push(m)}let f=[],d=[],p=[],g=[];for(let h=0;h<l.length;h++){let m=l[h];u.indexOf(m)===-1&&p.push(m)}l=l.filter(h=>!p.includes(h));let v="template";for(let h=0;h<u.length;h++){let m=u[h],y=l.indexOf(m);if(y===-1)l.splice(h,0,m),f.push([v,h]);else if(y!==h){let E=l.splice(h,1)[0],b=l.splice(y-1,1)[0];l.splice(h,0,b),l.splice(y,0,E),d.push([E,b])}else g.push(m);v=m}for(let h=0;h<p.length;h++){let m=p[h];m in a&&(mutateDom(()=>{destroyTree(a[m]),a[m].remove()}),delete a[m])}for(let h=0;h<d.length;h++){let[m,y]=d[h],E=a[m],b=a[y],C=document.createElement("div");mutateDom(()=>{b||warn('x-for ":key" is undefined or invalid',o,y,a),b.after(C),E.after(b),b._x_currentIfEl&&b.after(b._x_currentIfEl),C.before(E),E._x_currentIfEl&&E.after(E._x_currentIfEl),C.remove()}),b._x_refreshXForScope(c[u.indexOf(y)])}for(let h=0;h<f.length;h++){let[m,y]=f[h],E=m==="template"?o:a[m];E._x_currentIfEl&&(E=E._x_currentIfEl);let b=c[y],C=u[y],T=document.importNode(o.content,!0).firstElementChild,A=reactive(b);addScopeToNode(T,A,o),T._x_refreshXForScope=L=>{Object.entries(L).forEach(([I,H])=>{A[I]=H})},mutateDom(()=>{E.after(T),skipDuringClone(()=>initTree(T))()}),typeof C=="object"&&warn("x-for key cannot be an object, it must be a string or an integer",o),a[C]=T}for(let h=0;h<g.length;h++)a[g[h]]._x_refreshXForScope(c[u.indexOf(g[h])]);o._x_prevKeys=u})}function parseForExpression(e){let t=/,([^,\}\]]*)(?:,([^,\}\]]*))?$/,n=/^\s*\(|\)\s*$/g,r=/([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/,i=e.match(r);if(!i)return;let o={};o.items=i[2].trim();let s=i[1].replace(n,"").trim(),a=s.match(t);return a?(o.item=s.replace(t,"").trim(),o.index=a[1].trim(),a[2]&&(o.collection=a[2].trim())):o.item=s,o}function getIterationScopeVariables(e,t,n,r){let i={};return/^\[.*\]$/.test(e.item)&&Array.isArray(t)?e.item.replace("[","").replace("]","").split(",").map(s=>s.trim()).forEach((s,a)=>{i[s]=t[a]}):/^\{.*\}$/.test(e.item)&&!Array.isArray(t)&&typeof t=="object"?e.item.replace("{","").replace("}","").split(",").map(s=>s.trim()).forEach(s=>{i[s]=t[s]}):i[e.item]=t,e.index&&(i[e.index]=n),e.collection&&(i[e.collection]=r),i}function isNumeric3(e){return!Array.isArray(e)&&!isNaN(e)}function handler3(){}handler3.inline=(e,{expression:t},{cleanup:n})=>{let r=closestRoot(e);r._x_refs||(r._x_refs={}),r._x_refs[t]=e,n(()=>delete r._x_refs[t])};directive("ref",handler3);directive("if",(e,{expression:t},{effect:n,cleanup:r})=>{e.tagName.toLowerCase()!=="template"&&warn("x-if can only be used on a <template> tag",e);let i=evaluateLater(e,t),o=()=>{if(e._x_currentIfEl)return e._x_currentIfEl;let a=e.content.cloneNode(!0).firstElementChild;return addScopeToNode(a,{},e),mutateDom(()=>{e.after(a),skipDuringClone(()=>initTree(a))()}),e._x_currentIfEl=a,e._x_undoIf=()=>{mutateDom(()=>{destroyTree(a),a.remove()}),delete e._x_currentIfEl},a},s=()=>{e._x_undoIf&&(e._x_undoIf(),delete e._x_undoIf)};n(()=>i(a=>{a?o():s()})),r(()=>e._x_undoIf&&e._x_undoIf())});directive("id",(e,{expression:t},{evaluate:n})=>{n(t).forEach(i=>setIdRoot(e,i))});interceptClone((e,t)=>{e._x_ids&&(t._x_ids=e._x_ids)});mapAttributes(startingWith("@",into(prefix("on:"))));directive("on",skipDuringClone((e,{value:t,modifiers:n,expression:r},{cleanup:i})=>{let o=r?evaluateLater(e,r):()=>{};e.tagName.toLowerCase()==="template"&&(e._x_forwardEvents||(e._x_forwardEvents=[]),e._x_forwardEvents.includes(t)||e._x_forwardEvents.push(t));let s=on(e,t,n,a=>{o(()=>{},{scope:{$event:a},params:[a]})});i(()=>s())}));warnMissingPluginDirective("Collapse","collapse","collapse");warnMissingPluginDirective("Intersect","intersect","intersect");warnMissingPluginDirective("Focus","trap","focus");warnMissingPluginDirective("Mask","mask","mask");function warnMissingPluginDirective(e,t,n){directive(t,r=>warn(`You can't use [x-${t}] without first installing the "${e}" plugin here: https://alpinejs.dev/plugins/${n}`,r))}alpine_default.setEvaluator(normalEvaluator);alpine_default.setRawEvaluator(normalRawEvaluator);alpine_default.setReactivityEngine({reactive:reactive2,effect:effect2,release:stop,raw:toRaw});var src_default=alpine_default,module_default=src_default,htmx=(function(){const htmx={onLoad:null,process:null,on:null,off:null,trigger:null,ajax:null,find:null,findAll:null,closest:null,values:function(e,t){return getInputValues(e,t||"post").values},remove:null,addClass:null,removeClass:null,toggleClass:null,takeClass:null,swap:null,defineExtension:null,removeExtension:null,logAll:null,logNone:null,logger:null,config:{historyEnabled:!0,historyCacheSize:10,refreshOnHistoryMiss:!1,defaultSwapStyle:"innerHTML",defaultSwapDelay:0,defaultSettleDelay:20,includeIndicatorStyles:!0,indicatorClass:"htmx-indicator",requestClass:"htmx-request",addedClass:"htmx-added",settlingClass:"htmx-settling",swappingClass:"htmx-swapping",allowEval:!0,allowScriptTags:!0,inlineScriptNonce:"",inlineStyleNonce:"",attributesToSettle:["class","style","width","height"],withCredentials:!1,timeout:0,wsReconnectDelay:"full-jitter",wsBinaryType:"blob",disableSelector:"[hx-disable], [data-hx-disable]",scrollBehavior:"instant",defaultFocusScroll:!1,getCacheBusterParam:!1,globalViewTransitions:!1,methodsThatUseUrlParams:["get","delete"],selfRequestsOnly:!0,ignoreTitle:!1,scrollIntoViewOnBoost:!0,triggerSpecsCache:null,disableInheritance:!1,responseHandling:[{code:"204",swap:!1},{code:"[23]..",swap:!0},{code:"[45]..",swap:!1,error:!0}],allowNestedOobSwaps:!0,historyRestoreAsHxRequest:!0,reportValidityOfForms:!1},parseInterval:null,location,_:null,version:"2.0.8"};htmx.onLoad=onLoadHelper,htmx.process=processNode,htmx.on=addEventListenerImpl,htmx.off=removeEventListenerImpl,htmx.trigger=triggerEvent,htmx.ajax=ajaxHelper,htmx.find=find,htmx.findAll=findAll,htmx.closest=closest,htmx.remove=removeElement,htmx.addClass=addClassToElement,htmx.removeClass=removeClassFromElement,htmx.toggleClass=toggleClassOnElement,htmx.takeClass=takeClassForElement,htmx.swap=swap,htmx.defineExtension=defineExtension,htmx.removeExtension=removeExtension,htmx.logAll=logAll,htmx.logNone=logNone,htmx.parseInterval=parseInterval,htmx._=internalEval;const internalAPI={addTriggerHandler,bodyContains,canAccessLocalStorage,findThisElement,filterValues,swap,hasAttribute,getAttributeValue,getClosestAttributeValue,getClosestMatch,getExpressionVars,getHeaders,getInputValues,getInternalData,getSwapSpecification,getTriggerSpecs,getTarget,makeFragment,mergeObjects,makeSettleInfo,oobSwap,querySelectorExt,settleImmediately,shouldCancel,triggerEvent,triggerErrorEvent,withExtensions},VERBS=["get","post","put","delete","patch"],VERB_SELECTOR=VERBS.map(function(e){return"[hx-"+e+"], [data-hx-"+e+"]"}).join(", ");function parseInterval(e){if(e==null)return;let t=NaN;return e.slice(-2)=="ms"?t=parseFloat(e.slice(0,-2)):e.slice(-1)=="s"?t=parseFloat(e.slice(0,-1))*1e3:e.slice(-1)=="m"?t=parseFloat(e.slice(0,-1))*1e3*60:t=parseFloat(e),isNaN(t)?void 0:t}function getRawAttribute(e,t){return e instanceof Element&&e.getAttribute(t)}function hasAttribute(e,t){return!!e.hasAttribute&&(e.hasAttribute(t)||e.hasAttribute("data-"+t))}function getAttributeValue(e,t){return getRawAttribute(e,t)||getRawAttribute(e,"data-"+t)}function parentElt(e){const t=e.parentElement;return!t&&e.parentNode instanceof ShadowRoot?e.parentNode:t}function getDocument(){return document}function getRootNode(e,t){return e.getRootNode?e.getRootNode({composed:t}):getDocument()}function getClosestMatch(e,t){for(;e&&!t(e);)e=parentElt(e);return e||null}function getAttributeValueWithDisinheritance(e,t,n){const r=getAttributeValue(t,n),i=getAttributeValue(t,"hx-disinherit");var o=getAttributeValue(t,"hx-inherit");if(e!==t){if(htmx.config.disableInheritance)return o&&(o==="*"||o.split(" ").indexOf(n)>=0)?r:null;if(i&&(i==="*"||i.split(" ").indexOf(n)>=0))return"unset"}return r}function getClosestAttributeValue(e,t){let n=null;if(getClosestMatch(e,function(r){return!!(n=getAttributeValueWithDisinheritance(e,asElement(r),t))}),n!=="unset")return n}function matches(e,t){return e instanceof Element&&e.matches(t)}function getStartTag(e){const n=/<([a-z][^\/\0>\x20\t\r\n\f]*)/i.exec(e);return n?n[1].toLowerCase():""}function parseHTML(e){return"parseHTMLUnsafe"in Document?Document.parseHTMLUnsafe(e):new DOMParser().parseFromString(e,"text/html")}function takeChildrenFor(e,t){for(;t.childNodes.length>0;)e.append(t.childNodes[0])}function duplicateScript(e){const t=getDocument().createElement("script");return forEach(e.attributes,function(n){t.setAttribute(n.name,n.value)}),t.textContent=e.textContent,t.async=!1,htmx.config.inlineScriptNonce&&(t.nonce=htmx.config.inlineScriptNonce),t}function isJavaScriptScriptNode(e){return e.matches("script")&&(e.type==="text/javascript"||e.type==="module"||e.type==="")}function normalizeScriptTags(e){Array.from(e.querySelectorAll("script")).forEach(t=>{if(isJavaScriptScriptNode(t)){const n=duplicateScript(t),r=t.parentNode;try{r.insertBefore(n,t)}catch(i){logError(i)}finally{t.remove()}}})}function makeFragment(e){const t=e.replace(/<head(\s[^>]*)?>[\s\S]*?<\/head>/i,""),n=getStartTag(t);let r;if(n==="html"){r=new DocumentFragment;const o=parseHTML(e);takeChildrenFor(r,o.body),r.title=o.title}else if(n==="body"){r=new DocumentFragment;const o=parseHTML(t);takeChildrenFor(r,o.body),r.title=o.title}else{const o=parseHTML('<body><template class="internal-htmx-wrapper">'+t+"</template></body>");r=o.querySelector("template").content,r.title=o.title;var i=r.querySelector("title");i&&i.parentNode===r&&(i.remove(),r.title=i.innerText)}return r&&(htmx.config.allowScriptTags?normalizeScriptTags(r):r.querySelectorAll("script").forEach(o=>o.remove())),r}function maybeCall(e){e&&e()}function isType(e,t){return Object.prototype.toString.call(e)==="[object "+t+"]"}function isFunction(e){return typeof e=="function"}function isRawObject(e){return isType(e,"Object")}function getInternalData(e){const t="htmx-internal-data";let n=e[t];return n||(n=e[t]={}),n}function toArray(e){const t=[];if(e)for(let n=0;n<e.length;n++)t.push(e[n]);return t}function forEach(e,t){if(e)for(let n=0;n<e.length;n++)t(e[n])}function isScrolledIntoView(e){const t=e.getBoundingClientRect(),n=t.top,r=t.bottom;return n<window.innerHeight&&r>=0}function bodyContains(e){return e.getRootNode({composed:!0})===document}function splitOnWhitespace(e){return e.trim().split(/\s+/)}function mergeObjects(e,t){for(const n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e}function parseJSON(e){try{return JSON.parse(e)}catch(t){return logError(t),null}}function canAccessLocalStorage(){const e="htmx:sessionStorageTest";try{return sessionStorage.setItem(e,e),sessionStorage.removeItem(e),!0}catch{return!1}}function normalizePath(e){const t=new URL(e,"http://x");return t&&(e=t.pathname+t.search),e!="/"&&(e=e.replace(/\/+$/,"")),e}function internalEval(str){return maybeEval(getDocument().body,function(){return eval(str)})}function onLoadHelper(e){return htmx.on("htmx:load",function(n){e(n.detail.elt)})}function logAll(){htmx.logger=function(e,t,n){console&&console.log(t,e,n)}}function logNone(){htmx.logger=null}function find(e,t){return typeof e!="string"?e.querySelector(t):find(getDocument(),e)}function findAll(e,t){return typeof e!="string"?e.querySelectorAll(t):findAll(getDocument(),e)}function getWindow(){return window}function removeElement(e,t){e=resolveTarget(e),t?getWindow().setTimeout(function(){removeElement(e),e=null},t):parentElt(e).removeChild(e)}function asElement(e){return e instanceof Element?e:null}function asHtmlElement(e){return e instanceof HTMLElement?e:null}function asString(e){return typeof e=="string"?e:null}function asParentNode(e){return e instanceof Element||e instanceof Document||e instanceof DocumentFragment?e:null}function addClassToElement(e,t,n){e=asElement(resolveTarget(e)),e&&(n?getWindow().setTimeout(function(){addClassToElement(e,t),e=null},n):e.classList&&e.classList.add(t))}function removeClassFromElement(e,t,n){let r=asElement(resolveTarget(e));r&&(n?getWindow().setTimeout(function(){removeClassFromElement(r,t),r=null},n):r.classList&&(r.classList.remove(t),r.classList.length===0&&r.removeAttribute("class")))}function toggleClassOnElement(e,t){e=resolveTarget(e),e.classList.toggle(t)}function takeClassForElement(e,t){e=resolveTarget(e),forEach(e.parentElement.children,function(n){removeClassFromElement(n,t)}),addClassToElement(asElement(e),t)}function closest(e,t){return e=asElement(resolveTarget(e)),e?e.closest(t):null}function startsWith(e,t){return e.substring(0,t.length)===t}function endsWith(e,t){return e.substring(e.length-t.length)===t}function normalizeSelector(e){const t=e.trim();return startsWith(t,"<")&&endsWith(t,"/>")?t.substring(1,t.length-2):t}function querySelectorAllExt(e,t,n){if(t.indexOf("global ")===0)return querySelectorAllExt(e,t.slice(7),!0);e=resolveTarget(e);const r=[];{let s=0,a=0;for(let l=0;l<t.length;l++){const c=t[l];if(c===","&&s===0){r.push(t.substring(a,l)),a=l+1;continue}c==="<"?s++:c==="/"&&l<t.length-1&&t[l+1]===">"&&s--}a<t.length&&r.push(t.substring(a))}const i=[],o=[];for(;r.length>0;){const s=normalizeSelector(r.shift());let a;s.indexOf("closest ")===0?a=closest(asElement(e),normalizeSelector(s.slice(8))):s.indexOf("find ")===0?a=find(asParentNode(e),normalizeSelector(s.slice(5))):s==="next"||s==="nextElementSibling"?a=asElement(e).nextElementSibling:s.indexOf("next ")===0?a=scanForwardQuery(e,normalizeSelector(s.slice(5)),!!n):s==="previous"||s==="previousElementSibling"?a=asElement(e).previousElementSibling:s.indexOf("previous ")===0?a=scanBackwardsQuery(e,normalizeSelector(s.slice(9)),!!n):s==="document"?a=document:s==="window"?a=window:s==="body"?a=document.body:s==="root"?a=getRootNode(e,!!n):s==="host"?a=e.getRootNode().host:o.push(s),a&&i.push(a)}if(o.length>0){const s=o.join(","),a=asParentNode(getRootNode(e,!!n));i.push(...toArray(a.querySelectorAll(s)))}return i}var scanForwardQuery=function(e,t,n){const r=asParentNode(getRootNode(e,n)).querySelectorAll(t);for(let i=0;i<r.length;i++){const o=r[i];if(o.compareDocumentPosition(e)===Node.DOCUMENT_POSITION_PRECEDING)return o}},scanBackwardsQuery=function(e,t,n){const r=asParentNode(getRootNode(e,n)).querySelectorAll(t);for(let i=r.length-1;i>=0;i--){const o=r[i];if(o.compareDocumentPosition(e)===Node.DOCUMENT_POSITION_FOLLOWING)return o}};function querySelectorExt(e,t){return typeof e!="string"?querySelectorAllExt(e,t)[0]:querySelectorAllExt(getDocument().body,e)[0]}function resolveTarget(e,t){return typeof e=="string"?find(asParentNode(t)||document,e):e}function processEventArgs(e,t,n,r){return isFunction(t)?{target:getDocument().body,event:asString(e),listener:t,options:n}:{target:resolveTarget(e),event:asString(t),listener:n,options:r}}function addEventListenerImpl(e,t,n,r){return ready(function(){const o=processEventArgs(e,t,n,r);o.target.addEventListener(o.event,o.listener,o.options)}),isFunction(t)?t:n}function removeEventListenerImpl(e,t,n){return ready(function(){const r=processEventArgs(e,t,n);r.target.removeEventListener(r.event,r.listener)}),isFunction(t)?t:n}const DUMMY_ELT=getDocument().createElement("output");function findAttributeTargets(e,t){const n=getClosestAttributeValue(e,t);if(n){if(n==="this")return[findThisElement(e,t)];{const r=querySelectorAllExt(e,n);if(/(^|,)(\s*)inherit(\s*)($|,)/.test(n)){const o=asElement(getClosestMatch(e,function(s){return s!==e&&hasAttribute(asElement(s),t)}));o&&r.push(...findAttributeTargets(o,t))}return r.length===0?(logError('The selector "'+n+'" on '+t+" returned no matches!"),[DUMMY_ELT]):r}}}function findThisElement(e,t){return asElement(getClosestMatch(e,function(n){return getAttributeValue(asElement(n),t)!=null}))}function getTarget(e){const t=getClosestAttributeValue(e,"hx-target");return t?t==="this"?findThisElement(e,"hx-target"):querySelectorExt(e,t):getInternalData(e).boosted?getDocument().body:e}function shouldSettleAttribute(e){return htmx.config.attributesToSettle.includes(e)}function cloneAttributes(e,t){forEach(Array.from(e.attributes),function(n){!t.hasAttribute(n.name)&&shouldSettleAttribute(n.name)&&e.removeAttribute(n.name)}),forEach(t.attributes,function(n){shouldSettleAttribute(n.name)&&e.setAttribute(n.name,n.value)})}function isInlineSwap(e,t){const n=getExtensions(t);for(let r=0;r<n.length;r++){const i=n[r];try{if(i.isInlineSwap(e))return!0}catch(o){logError(o)}}return e==="outerHTML"}function oobSwap(e,t,n,r){r=r||getDocument();let i="#"+CSS.escape(getRawAttribute(t,"id")),o="outerHTML";e==="true"||(e.indexOf(":")>0?(o=e.substring(0,e.indexOf(":")),i=e.substring(e.indexOf(":")+1)):o=e),t.removeAttribute("hx-swap-oob"),t.removeAttribute("data-hx-swap-oob");const s=querySelectorAllExt(r,i,!1);return s.length?(forEach(s,function(a){let l;const c=t.cloneNode(!0);l=getDocument().createDocumentFragment(),l.appendChild(c),isInlineSwap(o,a)||(l=asParentNode(c));const u={shouldSwap:!0,target:a,fragment:l};triggerEvent(a,"htmx:oobBeforeSwap",u)&&(a=u.target,u.shouldSwap&&(handlePreservedElements(l),swapWithStyle(o,a,a,l,n),restorePreservedElements()),forEach(n.elts,function(f){triggerEvent(f,"htmx:oobAfterSwap",u)}))}),t.parentNode.removeChild(t)):(t.parentNode.removeChild(t),triggerErrorEvent(getDocument().body,"htmx:oobErrorNoTarget",{content:t})),e}function restorePreservedElements(){const e=find("#--htmx-preserve-pantry--");if(e){for(const t of[...e.children]){const n=find("#"+t.id);n.parentNode.moveBefore(t,n),n.remove()}e.remove()}}function handlePreservedElements(e){forEach(findAll(e,"[hx-preserve], [data-hx-preserve]"),function(t){const n=getAttributeValue(t,"id"),r=getDocument().getElementById(n);if(r!=null)if(t.moveBefore){let i=find("#--htmx-preserve-pantry--");i==null&&(getDocument().body.insertAdjacentHTML("afterend","<div id='--htmx-preserve-pantry--'></div>"),i=find("#--htmx-preserve-pantry--")),i.moveBefore(r,null)}else t.parentNode.replaceChild(r,t)})}function handleAttributes(e,t,n){forEach(t.querySelectorAll("[id]"),function(r){const i=getRawAttribute(r,"id");if(i&&i.length>0){const o=i.replace("'","\\'"),s=r.tagName.replace(":","\\:"),a=asParentNode(e),l=a&&a.querySelector(s+"[id='"+o+"']");if(l&&l!==a){const c=r.cloneNode();cloneAttributes(r,l),n.tasks.push(function(){cloneAttributes(r,c)})}}})}function makeAjaxLoadTask(e){return function(){removeClassFromElement(e,htmx.config.addedClass),processNode(asElement(e)),processFocus(asParentNode(e)),triggerEvent(e,"htmx:load")}}function processFocus(e){const t="[autofocus]",n=asHtmlElement(matches(e,t)?e:e.querySelector(t));n!=null&&n.focus()}function insertNodesBefore(e,t,n,r){for(handleAttributes(e,n,r);n.childNodes.length>0;){const i=n.firstChild;addClassToElement(asElement(i),htmx.config.addedClass),e.insertBefore(i,t),i.nodeType!==Node.TEXT_NODE&&i.nodeType!==Node.COMMENT_NODE&&r.tasks.push(makeAjaxLoadTask(i))}}function stringHash(e,t){let n=0;for(;n<e.length;)t=(t<<5)-t+e.charCodeAt(n++)|0;return t}function attributeHash(e){let t=0;for(let n=0;n<e.attributes.length;n++){const r=e.attributes[n];r.value&&(t=stringHash(r.name,t),t=stringHash(r.value,t))}return t}function deInitOnHandlers(e){const t=getInternalData(e);if(t.onHandlers){for(let n=0;n<t.onHandlers.length;n++){const r=t.onHandlers[n];removeEventListenerImpl(e,r.event,r.listener)}delete t.onHandlers}}function deInitNode(e){const t=getInternalData(e);t.timeout&&clearTimeout(t.timeout),t.listenerInfos&&forEach(t.listenerInfos,function(n){n.on&&removeEventListenerImpl(n.on,n.trigger,n.listener)}),deInitOnHandlers(e),forEach(Object.keys(t),function(n){n!=="firstInitCompleted"&&delete t[n]})}function cleanUpElement(e){triggerEvent(e,"htmx:beforeCleanupElement"),deInitNode(e),forEach(e.children,function(t){cleanUpElement(t)})}function swapOuterHTML(e,t,n){if(e.tagName==="BODY")return swapInnerHTML(e,t,n);let r;const i=e.previousSibling,o=parentElt(e);if(o){for(insertNodesBefore(o,e,t,n),i==null?r=o.firstChild:r=i.nextSibling,n.elts=n.elts.filter(function(s){return s!==e});r&&r!==e;)r instanceof Element&&n.elts.push(r),r=r.nextSibling;cleanUpElement(e),e.remove()}}function swapAfterBegin(e,t,n){return insertNodesBefore(e,e.firstChild,t,n)}function swapBeforeBegin(e,t,n){return insertNodesBefore(parentElt(e),e,t,n)}function swapBeforeEnd(e,t,n){return insertNodesBefore(e,null,t,n)}function swapAfterEnd(e,t,n){return insertNodesBefore(parentElt(e),e.nextSibling,t,n)}function swapDelete(e){cleanUpElement(e);const t=parentElt(e);if(t)return t.removeChild(e)}function swapInnerHTML(e,t,n){const r=e.firstChild;if(insertNodesBefore(e,r,t,n),r){for(;r.nextSibling;)cleanUpElement(r.nextSibling),e.removeChild(r.nextSibling);cleanUpElement(r),e.removeChild(r)}}function swapWithStyle(e,t,n,r,i){switch(e){case"none":return;case"outerHTML":swapOuterHTML(n,r,i);return;case"afterbegin":swapAfterBegin(n,r,i);return;case"beforebegin":swapBeforeBegin(n,r,i);return;case"beforeend":swapBeforeEnd(n,r,i);return;case"afterend":swapAfterEnd(n,r,i);return;case"delete":swapDelete(n);return;default:var o=getExtensions(t);for(let s=0;s<o.length;s++){const a=o[s];try{const l=a.handleSwap(e,n,r,i);if(l){if(Array.isArray(l))for(let c=0;c<l.length;c++){const u=l[c];u.nodeType!==Node.TEXT_NODE&&u.nodeType!==Node.COMMENT_NODE&&i.tasks.push(makeAjaxLoadTask(u))}return}}catch(l){logError(l)}}e==="innerHTML"?swapInnerHTML(n,r,i):swapWithStyle(htmx.config.defaultSwapStyle,t,n,r,i)}}function findAndSwapOobElements(e,t,n){var r=findAll(e,"[hx-swap-oob], [data-hx-swap-oob]");return forEach(r,function(i){if(htmx.config.allowNestedOobSwaps||i.parentElement===null){const o=getAttributeValue(i,"hx-swap-oob");o!=null&&oobSwap(o,i,t,n)}else i.removeAttribute("hx-swap-oob"),i.removeAttribute("data-hx-swap-oob")}),r.length>0}function swap(e,t,n,r){r||(r={});let i=null,o=null,s=function(){maybeCall(r.beforeSwapCallback),e=resolveTarget(e);const c=r.contextElement?getRootNode(r.contextElement,!1):getDocument(),u=document.activeElement;let f={};f={elt:u,start:u?u.selectionStart:null,end:u?u.selectionEnd:null};const d=makeSettleInfo(e);if(n.swapStyle==="textContent")e.textContent=t;else{let g=makeFragment(t);if(d.title=r.title||g.title,r.historyRequest&&(g=g.querySelector("[hx-history-elt],[data-hx-history-elt]")||g),r.selectOOB){const v=r.selectOOB.split(",");for(let h=0;h<v.length;h++){const m=v[h].split(":",2);let y=m[0].trim();y.indexOf("#")===0&&(y=y.substring(1));const E=m[1]||"true",b=g.querySelector("#"+y);b&&oobSwap(E,b,d,c)}}if(findAndSwapOobElements(g,d,c),forEach(findAll(g,"template"),function(v){v.content&&findAndSwapOobElements(v.content,d,c)&&v.remove()}),r.select){const v=getDocument().createDocumentFragment();forEach(g.querySelectorAll(r.select),function(h){v.appendChild(h)}),g=v}handlePreservedElements(g),swapWithStyle(n.swapStyle,r.contextElement,e,g,d),restorePreservedElements()}if(f.elt&&!bodyContains(f.elt)&&getRawAttribute(f.elt,"id")){const g=document.getElementById(getRawAttribute(f.elt,"id")),v={preventScroll:n.focusScroll!==void 0?!n.focusScroll:!htmx.config.defaultFocusScroll};if(g){if(f.start&&g.setSelectionRange)try{g.setSelectionRange(f.start,f.end)}catch{}g.focus(v)}}e.classList.remove(htmx.config.swappingClass),forEach(d.elts,function(g){g.classList&&g.classList.add(htmx.config.settlingClass),triggerEvent(g,"htmx:afterSwap",r.eventInfo)}),maybeCall(r.afterSwapCallback),n.ignoreTitle||handleTitle(d.title);const p=function(){if(forEach(d.tasks,function(g){g.call()}),forEach(d.elts,function(g){g.classList&&g.classList.remove(htmx.config.settlingClass),triggerEvent(g,"htmx:afterSettle",r.eventInfo)}),r.anchor){const g=asElement(resolveTarget("#"+r.anchor));g&&g.scrollIntoView({block:"start",behavior:"auto"})}updateScrollState(d.elts,n),maybeCall(r.afterSettleCallback),maybeCall(i)};n.settleDelay>0?getWindow().setTimeout(p,n.settleDelay):p()},a=htmx.config.globalViewTransitions;n.hasOwnProperty("transition")&&(a=n.transition);const l=r.contextElement||getDocument();if(a&&triggerEvent(l,"htmx:beforeTransition",r.eventInfo)&&typeof Promise<"u"&&document.startViewTransition){const c=new Promise(function(f,d){i=f,o=d}),u=s;s=function(){document.startViewTransition(function(){return u(),c})}}try{n!=null&&n.swapDelay&&n.swapDelay>0?getWindow().setTimeout(s,n.swapDelay):s()}catch(c){throw triggerErrorEvent(l,"htmx:swapError",r.eventInfo),maybeCall(o),c}}function handleTriggerHeader(e,t,n){const r=e.getResponseHeader(t);if(r.indexOf("{")===0){const i=parseJSON(r);for(const o in i)if(i.hasOwnProperty(o)){let s=i[o];isRawObject(s)?n=s.target!==void 0?s.target:n:s={value:s},triggerEvent(n,o,s)}}else{const i=r.split(",");for(let o=0;o<i.length;o++)triggerEvent(n,i[o].trim(),[])}}const WHITESPACE_OR_COMMA=/[\s,]/,SYMBOL_START=/[_$a-zA-Z]/,SYMBOL_CONT=/[_$a-zA-Z0-9]/,STRINGISH_START=['"',"'","/"],NOT_WHITESPACE=/[^\s]/,COMBINED_SELECTOR_START=/[{(]/,COMBINED_SELECTOR_END=/[})]/;function tokenizeString(e){const t=[];let n=0;for(;n<e.length;){if(SYMBOL_START.exec(e.charAt(n))){for(var r=n;SYMBOL_CONT.exec(e.charAt(n+1));)n++;t.push(e.substring(r,n+1))}else if(STRINGISH_START.indexOf(e.charAt(n))!==-1){const i=e.charAt(n);var r=n;for(n++;n<e.length&&e.charAt(n)!==i;)e.charAt(n)==="\\"&&n++,n++;t.push(e.substring(r,n+1))}else{const i=e.charAt(n);t.push(i)}n++}return t}function isPossibleRelativeReference(e,t,n){return SYMBOL_START.exec(e.charAt(0))&&e!=="true"&&e!=="false"&&e!=="this"&&e!==n&&t!=="."}function maybeGenerateConditional(e,t,n){if(t[0]==="["){t.shift();let r=1,i=" return (function("+n+"){ return (",o=null;for(;t.length>0;){const s=t[0];if(s==="]"){if(r--,r===0){o===null&&(i=i+"true"),t.shift(),i+=")})";try{const a=maybeEval(e,function(){return Function(i)()},function(){return!0});return a.source=i,a}catch(a){return triggerErrorEvent(getDocument().body,"htmx:syntax:error",{error:a,source:i}),null}}}else s==="["&&r++;isPossibleRelativeReference(s,o,n)?i+="(("+n+"."+s+") ? ("+n+"."+s+") : (window."+s+"))":i=i+s,o=t.shift()}}}function consumeUntil(e,t){let n="";for(;e.length>0&&!t.test(e[0]);)n+=e.shift();return n}function consumeCSSSelector(e){let t;return e.length>0&&COMBINED_SELECTOR_START.test(e[0])?(e.shift(),t=consumeUntil(e,COMBINED_SELECTOR_END).trim(),e.shift()):t=consumeUntil(e,WHITESPACE_OR_COMMA),t}const INPUT_SELECTOR="input, textarea, select";function parseAndCacheTrigger(e,t,n){const r=[],i=tokenizeString(t);do{consumeUntil(i,NOT_WHITESPACE);const a=i.length,l=consumeUntil(i,/[,\[\s]/);if(l!=="")if(l==="every"){const c={trigger:"every"};consumeUntil(i,NOT_WHITESPACE),c.pollInterval=parseInterval(consumeUntil(i,/[,\[\s]/)),consumeUntil(i,NOT_WHITESPACE);var o=maybeGenerateConditional(e,i,"event");o&&(c.eventFilter=o),r.push(c)}else{const c={trigger:l};var o=maybeGenerateConditional(e,i,"event");for(o&&(c.eventFilter=o),consumeUntil(i,NOT_WHITESPACE);i.length>0&&i[0]!==",";){const f=i.shift();if(f==="changed")c.changed=!0;else if(f==="once")c.once=!0;else if(f==="consume")c.consume=!0;else if(f==="delay"&&i[0]===":")i.shift(),c.delay=parseInterval(consumeUntil(i,WHITESPACE_OR_COMMA));else if(f==="from"&&i[0]===":"){if(i.shift(),COMBINED_SELECTOR_START.test(i[0]))var s=consumeCSSSelector(i);else{var s=consumeUntil(i,WHITESPACE_OR_COMMA);if(s==="closest"||s==="find"||s==="next"||s==="previous"){i.shift();const p=consumeCSSSelector(i);p.length>0&&(s+=" "+p)}}c.from=s}else f==="target"&&i[0]===":"?(i.shift(),c.target=consumeCSSSelector(i)):f==="throttle"&&i[0]===":"?(i.shift(),c.throttle=parseInterval(consumeUntil(i,WHITESPACE_OR_COMMA))):f==="queue"&&i[0]===":"?(i.shift(),c.queue=consumeUntil(i,WHITESPACE_OR_COMMA)):f==="root"&&i[0]===":"?(i.shift(),c[f]=consumeCSSSelector(i)):f==="threshold"&&i[0]===":"?(i.shift(),c[f]=consumeUntil(i,WHITESPACE_OR_COMMA)):triggerErrorEvent(e,"htmx:syntax:error",{token:i.shift()});consumeUntil(i,NOT_WHITESPACE)}r.push(c)}i.length===a&&triggerErrorEvent(e,"htmx:syntax:error",{token:i.shift()}),consumeUntil(i,NOT_WHITESPACE)}while(i[0]===","&&i.shift());return n&&(n[t]=r),r}function getTriggerSpecs(e){const t=getAttributeValue(e,"hx-trigger");let n=[];if(t){const r=htmx.config.triggerSpecsCache;n=r&&r[t]||parseAndCacheTrigger(e,t,r)}return n.length>0?n:matches(e,"form")?[{trigger:"submit"}]:matches(e,'input[type="button"], input[type="submit"]')?[{trigger:"click"}]:matches(e,INPUT_SELECTOR)?[{trigger:"change"}]:[{trigger:"click"}]}function cancelPolling(e){getInternalData(e).cancelled=!0}function processPolling(e,t,n){const r=getInternalData(e);r.timeout=getWindow().setTimeout(function(){bodyContains(e)&&r.cancelled!==!0&&(maybeFilterEvent(n,e,makeEvent("hx:poll:trigger",{triggerSpec:n,target:e}))||t(e),processPolling(e,t,n))},n.pollInterval)}function isLocalLink(e){return location.hostname===e.hostname&&getRawAttribute(e,"href")&&getRawAttribute(e,"href").indexOf("#")!==0}function eltIsDisabled(e){return closest(e,htmx.config.disableSelector)}function boostElement(e,t,n){if(e instanceof HTMLAnchorElement&&isLocalLink(e)&&(e.target===""||e.target==="_self")||e.tagName==="FORM"&&String(getRawAttribute(e,"method")).toLowerCase()!=="dialog"){t.boosted=!0;let r,i;if(e.tagName==="A")r="get",i=getRawAttribute(e,"href");else{const o=getRawAttribute(e,"method");r=o?o.toLowerCase():"get",i=getRawAttribute(e,"action"),(i==null||i==="")&&(i=location.href),r==="get"&&i.includes("?")&&(i=i.replace(/\?[^#]+/,""))}n.forEach(function(o){addEventListener(e,function(s,a){const l=asElement(s);if(eltIsDisabled(l)){cleanUpElement(l);return}issueAjaxRequest(r,i,l,a)},t,o,!0)})}}function shouldCancel(e,t){if(e.type==="submit"&&t.tagName==="FORM")return!0;if(e.type==="click"){const n=t.closest('input[type="submit"], button');if(n&&n.form&&n.type==="submit")return!0;const r=t.closest("a"),i=/^#.+/;if(r&&r.href&&!i.test(r.getAttribute("href")))return!0}return!1}function ignoreBoostedAnchorCtrlClick(e,t){return getInternalData(e).boosted&&e instanceof HTMLAnchorElement&&t.type==="click"&&(t.ctrlKey||t.metaKey)}function maybeFilterEvent(e,t,n){const r=e.eventFilter;if(r)try{return r.call(t,n)!==!0}catch(i){const o=r.source;return triggerErrorEvent(getDocument().body,"htmx:eventFilter:error",{error:i,source:o}),!0}return!1}function addEventListener(e,t,n,r,i){const o=getInternalData(e);let s;r.from?s=querySelectorAllExt(e,r.from):s=[e],r.changed&&("lastValue"in o||(o.lastValue=new WeakMap),s.forEach(function(a){o.lastValue.has(r)||o.lastValue.set(r,new WeakMap),o.lastValue.get(r).set(a,a.value)})),forEach(s,function(a){const l=function(c){if(!bodyContains(e)){a.removeEventListener(r.trigger,l);return}if(ignoreBoostedAnchorCtrlClick(e,c)||((i||shouldCancel(c,a))&&c.preventDefault(),maybeFilterEvent(r,e,c)))return;const u=getInternalData(c);if(u.triggerSpec=r,u.handledFor==null&&(u.handledFor=[]),u.handledFor.indexOf(e)<0){if(u.handledFor.push(e),r.consume&&c.stopPropagation(),r.target&&c.target&&!matches(asElement(c.target),r.target))return;if(r.once){if(o.triggeredOnce)return;o.triggeredOnce=!0}if(r.changed){const f=c.target,d=f.value,p=o.lastValue.get(r);if(p.has(f)&&p.get(f)===d)return;p.set(f,d)}if(o.delayed&&clearTimeout(o.delayed),o.throttle)return;r.throttle>0?o.throttle||(triggerEvent(e,"htmx:trigger"),t(e,c),o.throttle=getWindow().setTimeout(function(){o.throttle=null},r.throttle)):r.delay>0?o.delayed=getWindow().setTimeout(function(){triggerEvent(e,"htmx:trigger"),t(e,c)},r.delay):(triggerEvent(e,"htmx:trigger"),t(e,c))}};n.listenerInfos==null&&(n.listenerInfos=[]),n.listenerInfos.push({trigger:r.trigger,listener:l,on:a}),a.addEventListener(r.trigger,l)})}let windowIsScrolling=!1,scrollHandler=null;function initScrollHandler(){scrollHandler||(scrollHandler=function(){windowIsScrolling=!0},window.addEventListener("scroll",scrollHandler),window.addEventListener("resize",scrollHandler),setInterval(function(){windowIsScrolling&&(windowIsScrolling=!1,forEach(getDocument().querySelectorAll("[hx-trigger*='revealed'],[data-hx-trigger*='revealed']"),function(e){maybeReveal(e)}))},200))}function maybeReveal(e){!hasAttribute(e,"data-hx-revealed")&&isScrolledIntoView(e)&&(e.setAttribute("data-hx-revealed","true"),getInternalData(e).initHash?triggerEvent(e,"revealed"):e.addEventListener("htmx:afterProcessNode",function(){triggerEvent(e,"revealed")},{once:!0}))}function loadImmediately(e,t,n,r){const i=function(){n.loaded||(n.loaded=!0,triggerEvent(e,"htmx:trigger"),t(e))};r>0?getWindow().setTimeout(i,r):i()}function processVerbs(e,t,n){let r=!1;return forEach(VERBS,function(i){if(hasAttribute(e,"hx-"+i)){const o=getAttributeValue(e,"hx-"+i);r=!0,t.path=o,t.verb=i,n.forEach(function(s){addTriggerHandler(e,s,t,function(a,l){const c=asElement(a);if(eltIsDisabled(c)){cleanUpElement(c);return}issueAjaxRequest(i,o,c,l)})})}}),r}function addTriggerHandler(e,t,n,r){if(t.trigger==="revealed")initScrollHandler(),addEventListener(e,r,n,t),maybeReveal(asElement(e));else if(t.trigger==="intersect"){const i={};t.root&&(i.root=querySelectorExt(e,t.root)),t.threshold&&(i.threshold=parseFloat(t.threshold)),new IntersectionObserver(function(s){for(let a=0;a<s.length;a++)if(s[a].isIntersecting){triggerEvent(e,"intersect");break}},i).observe(asElement(e)),addEventListener(asElement(e),r,n,t)}else!n.firstInitCompleted&&t.trigger==="load"?maybeFilterEvent(t,e,makeEvent("load",{elt:e}))||loadImmediately(asElement(e),r,n,t.delay):t.pollInterval>0?(n.polling=!0,processPolling(asElement(e),r,t)):addEventListener(e,r,n,t)}function shouldProcessHxOn(e){const t=asElement(e);if(!t)return!1;const n=t.attributes;for(let r=0;r<n.length;r++){const i=n[r].name;if(startsWith(i,"hx-on:")||startsWith(i,"data-hx-on:")||startsWith(i,"hx-on-")||startsWith(i,"data-hx-on-"))return!0}return!1}const HX_ON_QUERY=new XPathEvaluator().createExpression('.//*[@*[ starts-with(name(), "hx-on:") or starts-with(name(), "data-hx-on:") or starts-with(name(), "hx-on-") or starts-with(name(), "data-hx-on-") ]]');function processHXOnRoot(e,t){shouldProcessHxOn(e)&&t.push(asElement(e));const n=HX_ON_QUERY.evaluate(e);let r=null;for(;r=n.iterateNext();)t.push(asElement(r))}function findHxOnWildcardElements(e){const t=[];if(e instanceof DocumentFragment)for(const n of e.childNodes)processHXOnRoot(n,t);else processHXOnRoot(e,t);return t}function findElementsToProcess(e){if(e.querySelectorAll){const n=", [hx-boost] a, [data-hx-boost] a, a[hx-boost], a[data-hx-boost]",r=[];for(const o in extensions){const s=extensions[o];if(s.getSelectors){var t=s.getSelectors();t&&r.push(t)}}return e.querySelectorAll(VERB_SELECTOR+n+", form, [type='submit'], [hx-ext], [data-hx-ext], [hx-trigger], [data-hx-trigger]"+r.flat().map(o=>", "+o).join(""))}else return[]}function maybeSetLastButtonClicked(e){const t=getTargetButton(e.target),n=getRelatedFormData(e);n&&(n.lastButtonClicked=t)}function maybeUnsetLastButtonClicked(e){const t=getRelatedFormData(e);t&&(t.lastButtonClicked=null)}function getTargetButton(e){return closest(asElement(e),"button, input[type='submit']")}function getRelatedForm(e){return e.form||closest(e,"form")}function getRelatedFormData(e){const t=getTargetButton(e.target);if(!t)return;const n=getRelatedForm(t);if(n)return getInternalData(n)}function initButtonTracking(e){e.addEventListener("click",maybeSetLastButtonClicked),e.addEventListener("focusin",maybeSetLastButtonClicked),e.addEventListener("focusout",maybeUnsetLastButtonClicked)}function addHxOnEventHandler(e,t,n){const r=getInternalData(e);Array.isArray(r.onHandlers)||(r.onHandlers=[]);let i;const o=function(s){maybeEval(e,function(){eltIsDisabled(e)||(i||(i=new Function("event",n)),i.call(e,s))})};e.addEventListener(t,o),r.onHandlers.push({event:t,listener:o})}function processHxOnWildcard(e){deInitOnHandlers(e);for(let t=0;t<e.attributes.length;t++){const n=e.attributes[t].name,r=e.attributes[t].value;if(startsWith(n,"hx-on")||startsWith(n,"data-hx-on")){const i=n.indexOf("-on")+3,o=n.slice(i,i+1);if(o==="-"||o===":"){let s=n.slice(i+1);startsWith(s,":")?s="htmx"+s:startsWith(s,"-")?s="htmx:"+s.slice(1):startsWith(s,"htmx-")&&(s="htmx:"+s.slice(5)),addHxOnEventHandler(e,s,r)}}}}function initNode(e){triggerEvent(e,"htmx:beforeProcessNode");const t=getInternalData(e),n=getTriggerSpecs(e);processVerbs(e,t,n)||(getClosestAttributeValue(e,"hx-boost")==="true"?boostElement(e,t,n):hasAttribute(e,"hx-trigger")&&n.forEach(function(i){addTriggerHandler(e,i,t,function(){})})),(e.tagName==="FORM"||getRawAttribute(e,"type")==="submit"&&hasAttribute(e,"form"))&&initButtonTracking(e),t.firstInitCompleted=!0,triggerEvent(e,"htmx:afterProcessNode")}function maybeDeInitAndHash(e){if(!(e instanceof Element))return!1;const t=getInternalData(e),n=attributeHash(e);return t.initHash!==n?(deInitNode(e),t.initHash=n,!0):!1}function processNode(e){if(e=resolveTarget(e),eltIsDisabled(e)){cleanUpElement(e);return}const t=[];maybeDeInitAndHash(e)&&t.push(e),forEach(findElementsToProcess(e),function(n){if(eltIsDisabled(n)){cleanUpElement(n);return}maybeDeInitAndHash(n)&&t.push(n)}),forEach(findHxOnWildcardElements(e),processHxOnWildcard),forEach(t,initNode)}function kebabEventName(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function makeEvent(e,t){return new CustomEvent(e,{bubbles:!0,cancelable:!0,composed:!0,detail:t})}function triggerErrorEvent(e,t,n){triggerEvent(e,t,mergeObjects({error:t},n))}function ignoreEventForLogging(e){return e==="htmx:afterProcessNode"}function withExtensions(e,t,n){forEach(getExtensions(e,[],n),function(r){try{t(r)}catch(i){logError(i)}})}function logError(e){console.error(e)}function triggerEvent(e,t,n){e=resolveTarget(e),n==null&&(n={}),n.elt=e;const r=makeEvent(t,n);htmx.logger&&!ignoreEventForLogging(t)&&htmx.logger(e,t,n),n.error&&(logError(n.error),triggerEvent(e,"htmx:error",{errorInfo:n}));let i=e.dispatchEvent(r);const o=kebabEventName(t);if(i&&o!==t){const s=makeEvent(o,r.detail);i=i&&e.dispatchEvent(s)}return withExtensions(asElement(e),function(s){i=i&&s.onEvent(t,r)!==!1&&!r.defaultPrevented}),i}let currentPathForHistory;function setCurrentPathForHistory(e){currentPathForHistory=e,canAccessLocalStorage()&&sessionStorage.setItem("htmx-current-path-for-history",e)}setCurrentPathForHistory(location.pathname+location.search);function getHistoryElement(){return getDocument().querySelector("[hx-history-elt],[data-hx-history-elt]")||getDocument().body}function saveToHistoryCache(e,t){if(!canAccessLocalStorage())return;const n=cleanInnerHtmlForHistory(t),r=getDocument().title,i=window.scrollY;if(htmx.config.historyCacheSize<=0){sessionStorage.removeItem("htmx-history-cache");return}e=normalizePath(e);const o=parseJSON(sessionStorage.getItem("htmx-history-cache"))||[];for(let a=0;a<o.length;a++)if(o[a].url===e){o.splice(a,1);break}const s={url:e,content:n,title:r,scroll:i};for(triggerEvent(getDocument().body,"htmx:historyItemCreated",{item:s,cache:o}),o.push(s);o.length>htmx.config.historyCacheSize;)o.shift();for(;o.length>0;)try{sessionStorage.setItem("htmx-history-cache",JSON.stringify(o));break}catch(a){triggerErrorEvent(getDocument().body,"htmx:historyCacheError",{cause:a,cache:o}),o.shift()}}function getCachedHistory(e){if(!canAccessLocalStorage())return null;e=normalizePath(e);const t=parseJSON(sessionStorage.getItem("htmx-history-cache"))||[];for(let n=0;n<t.length;n++)if(t[n].url===e)return t[n];return null}function cleanInnerHtmlForHistory(e){const t=htmx.config.requestClass,n=e.cloneNode(!0);return forEach(findAll(n,"."+t),function(r){removeClassFromElement(r,t)}),forEach(findAll(n,"[data-disabled-by-htmx]"),function(r){r.removeAttribute("disabled")}),n.innerHTML}function saveCurrentPageToHistory(){const e=getHistoryElement();let t=currentPathForHistory;canAccessLocalStorage()&&(t=sessionStorage.getItem("htmx-current-path-for-history")),t=t||location.pathname+location.search,getDocument().querySelector('[hx-history="false" i],[data-hx-history="false" i]')||(triggerEvent(getDocument().body,"htmx:beforeHistorySave",{path:t,historyElt:e}),saveToHistoryCache(t,e)),htmx.config.historyEnabled&&history.replaceState({htmx:!0},getDocument().title,location.href)}function pushUrlIntoHistory(e){htmx.config.getCacheBusterParam&&(e=e.replace(/org\.htmx\.cache-buster=[^&]*&?/,""),(endsWith(e,"&")||endsWith(e,"?"))&&(e=e.slice(0,-1))),htmx.config.historyEnabled&&history.pushState({htmx:!0},"",e),setCurrentPathForHistory(e)}function replaceUrlInHistory(e){htmx.config.historyEnabled&&history.replaceState({htmx:!0},"",e),setCurrentPathForHistory(e)}function settleImmediately(e){forEach(e,function(t){t.call(void 0)})}function loadHistoryFromServer(e){const t=new XMLHttpRequest,n={swapStyle:"innerHTML",swapDelay:0,settleDelay:0},r={path:e,xhr:t,historyElt:getHistoryElement(),swapSpec:n};t.open("GET",e,!0),htmx.config.historyRestoreAsHxRequest&&t.setRequestHeader("HX-Request","true"),t.setRequestHeader("HX-History-Restore-Request","true"),t.setRequestHeader("HX-Current-URL",location.href),t.onload=function(){this.status>=200&&this.status<400?(r.response=this.response,triggerEvent(getDocument().body,"htmx:historyCacheMissLoad",r),swap(r.historyElt,r.response,n,{contextElement:r.historyElt,historyRequest:!0}),setCurrentPathForHistory(r.path),triggerEvent(getDocument().body,"htmx:historyRestore",{path:e,cacheMiss:!0,serverResponse:r.response})):triggerErrorEvent(getDocument().body,"htmx:historyCacheMissLoadError",r)},triggerEvent(getDocument().body,"htmx:historyCacheMiss",r)&&t.send()}function restoreHistory(e){saveCurrentPageToHistory(),e=e||location.pathname+location.search;const t=getCachedHistory(e);if(t){const n={swapStyle:"innerHTML",swapDelay:0,settleDelay:0,scroll:t.scroll},r={path:e,item:t,historyElt:getHistoryElement(),swapSpec:n};triggerEvent(getDocument().body,"htmx:historyCacheHit",r)&&(swap(r.historyElt,t.content,n,{contextElement:r.historyElt,title:t.title}),setCurrentPathForHistory(r.path),triggerEvent(getDocument().body,"htmx:historyRestore",r))}else htmx.config.refreshOnHistoryMiss?htmx.location.reload(!0):loadHistoryFromServer(e)}function addRequestIndicatorClasses(e){let t=findAttributeTargets(e,"hx-indicator");return t==null&&(t=[e]),forEach(t,function(n){const r=getInternalData(n);r.requestCount=(r.requestCount||0)+1,n.classList.add.call(n.classList,htmx.config.requestClass)}),t}function disableElements(e){let t=findAttributeTargets(e,"hx-disabled-elt");return t==null&&(t=[]),forEach(t,function(n){const r=getInternalData(n);r.requestCount=(r.requestCount||0)+1,n.setAttribute("disabled",""),n.setAttribute("data-disabled-by-htmx","")}),t}function removeRequestIndicators(e,t){forEach(e.concat(t),function(n){const r=getInternalData(n);r.requestCount=(r.requestCount||1)-1}),forEach(e,function(n){getInternalData(n).requestCount===0&&n.classList.remove.call(n.classList,htmx.config.requestClass)}),forEach(t,function(n){getInternalData(n).requestCount===0&&(n.removeAttribute("disabled"),n.removeAttribute("data-disabled-by-htmx"))})}function haveSeenNode(e,t){for(let n=0;n<e.length;n++)if(e[n].isSameNode(t))return!0;return!1}function shouldInclude(e){const t=e;return t.name===""||t.name==null||t.disabled||closest(t,"fieldset[disabled]")||t.type==="button"||t.type==="submit"||t.tagName==="image"||t.tagName==="reset"||t.tagName==="file"?!1:t.type==="checkbox"||t.type==="radio"?t.checked:!0}function addValueToFormData(e,t,n){e!=null&&t!=null&&(Array.isArray(t)?t.forEach(function(r){n.append(e,r)}):n.append(e,t))}function removeValueFromFormData(e,t,n){if(e!=null&&t!=null){let r=n.getAll(e);Array.isArray(t)?r=r.filter(i=>t.indexOf(i)<0):r=r.filter(i=>i!==t),n.delete(e),forEach(r,i=>n.append(e,i))}}function getValueFromInput(e){return e instanceof HTMLSelectElement&&e.multiple?toArray(e.querySelectorAll("option:checked")).map(function(t){return t.value}):e instanceof HTMLInputElement&&e.files?toArray(e.files):e.value}function processInputValue(e,t,n,r,i){if(!(r==null||haveSeenNode(e,r))){if(e.push(r),shouldInclude(r)){const o=getRawAttribute(r,"name");addValueToFormData(o,getValueFromInput(r),t),i&&validateElement(r,n)}r instanceof HTMLFormElement&&(forEach(r.elements,function(o){e.indexOf(o)>=0?removeValueFromFormData(o.name,getValueFromInput(o),t):e.push(o),i&&validateElement(o,n)}),new FormData(r).forEach(function(o,s){o instanceof File&&o.name===""||addValueToFormData(s,o,t)}))}}function validateElement(e,t){const n=e;n.willValidate&&(triggerEvent(n,"htmx:validation:validate"),n.checkValidity()||(triggerEvent(n,"htmx:validation:failed",{message:n.validationMessage,validity:n.validity})&&!t.length&&htmx.config.reportValidityOfForms&&n.reportValidity(),t.push({elt:n,message:n.validationMessage,validity:n.validity})))}function overrideFormData(e,t){for(const n of t.keys())e.delete(n);return t.forEach(function(n,r){e.append(r,n)}),e}function getInputValues(e,t){const n=[],r=new FormData,i=new FormData,o=[],s=getInternalData(e);s.lastButtonClicked&&!bodyContains(s.lastButtonClicked)&&(s.lastButtonClicked=null);let a=e instanceof HTMLFormElement&&e.noValidate!==!0||getAttributeValue(e,"hx-validate")==="true";if(s.lastButtonClicked&&(a=a&&s.lastButtonClicked.formNoValidate!==!0),t!=="get"&&processInputValue(n,i,o,getRelatedForm(e),a),processInputValue(n,r,o,e,a),s.lastButtonClicked||e.tagName==="BUTTON"||e.tagName==="INPUT"&&getRawAttribute(e,"type")==="submit"){const c=s.lastButtonClicked||e,u=getRawAttribute(c,"name");addValueToFormData(u,c.value,i)}const l=findAttributeTargets(e,"hx-include");return forEach(l,function(c){processInputValue(n,r,o,asElement(c),a),matches(c,"form")||forEach(asParentNode(c).querySelectorAll(INPUT_SELECTOR),function(u){processInputValue(n,r,o,u,a)})}),overrideFormData(r,i),{errors:o,formData:r,values:formDataProxy(r)}}function appendParam(e,t,n){e!==""&&(e+="&"),String(n)==="[object Object]"&&(n=JSON.stringify(n));const r=encodeURIComponent(n);return e+=encodeURIComponent(t)+"="+r,e}function urlEncode(e){e=formDataFromObject(e);let t="";return e.forEach(function(n,r){t=appendParam(t,r,n)}),t}function getHeaders(e,t,n){const r={"HX-Request":"true","HX-Trigger":getRawAttribute(e,"id"),"HX-Trigger-Name":getRawAttribute(e,"name"),"HX-Target":getAttributeValue(t,"id"),"HX-Current-URL":location.href};return getValuesForElement(e,"hx-headers",!1,r),n!==void 0&&(r["HX-Prompt"]=n),getInternalData(e).boosted&&(r["HX-Boosted"]="true"),r}function filterValues(e,t){const n=getClosestAttributeValue(t,"hx-params");if(n){if(n==="none")return new FormData;if(n==="*")return e;if(n.indexOf("not ")===0)return forEach(n.slice(4).split(","),function(r){r=r.trim(),e.delete(r)}),e;{const r=new FormData;return forEach(n.split(","),function(i){i=i.trim(),e.has(i)&&e.getAll(i).forEach(function(o){r.append(i,o)})}),r}}else return e}function isAnchorLink(e){return!!getRawAttribute(e,"href")&&getRawAttribute(e,"href").indexOf("#")>=0}function getSwapSpecification(e,t){const n=t||getClosestAttributeValue(e,"hx-swap"),r={swapStyle:getInternalData(e).boosted?"innerHTML":htmx.config.defaultSwapStyle,swapDelay:htmx.config.defaultSwapDelay,settleDelay:htmx.config.defaultSettleDelay};if(htmx.config.scrollIntoViewOnBoost&&getInternalData(e).boosted&&!isAnchorLink(e)&&(r.show="top"),n){const s=splitOnWhitespace(n);if(s.length>0)for(let a=0;a<s.length;a++){const l=s[a];if(l.indexOf("swap:")===0)r.swapDelay=parseInterval(l.slice(5));else if(l.indexOf("settle:")===0)r.settleDelay=parseInterval(l.slice(7));else if(l.indexOf("transition:")===0)r.transition=l.slice(11)==="true";else if(l.indexOf("ignoreTitle:")===0)r.ignoreTitle=l.slice(12)==="true";else if(l.indexOf("scroll:")===0){var i=l.slice(7).split(":");const u=i.pop();var o=i.length>0?i.join(":"):null;r.scroll=u,r.scrollTarget=o}else if(l.indexOf("show:")===0){var i=l.slice(5).split(":");const f=i.pop();var o=i.length>0?i.join(":"):null;r.show=f,r.showTarget=o}else if(l.indexOf("focus-scroll:")===0){const c=l.slice(13);r.focusScroll=c=="true"}else a==0?r.swapStyle=l:logError("Unknown modifier in hx-swap: "+l)}}return r}function usesFormData(e){return getClosestAttributeValue(e,"hx-encoding")==="multipart/form-data"||matches(e,"form")&&getRawAttribute(e,"enctype")==="multipart/form-data"}function encodeParamsForBody(e,t,n){let r=null;return withExtensions(t,function(i){r==null&&(r=i.encodeParameters(e,n,t))}),r??(usesFormData(t)?overrideFormData(new FormData,formDataFromObject(n)):urlEncode(n))}function makeSettleInfo(e){return{tasks:[],elts:[e]}}function updateScrollState(e,t){const n=e[0],r=e[e.length-1];if(t.scroll){var i=null;t.scrollTarget&&(i=asElement(querySelectorExt(n,t.scrollTarget))),t.scroll==="top"&&(n||i)&&(i=i||n,i.scrollTop=0),t.scroll==="bottom"&&(r||i)&&(i=i||r,i.scrollTop=i.scrollHeight),typeof t.scroll=="number"&&getWindow().setTimeout(function(){window.scrollTo(0,t.scroll)},0)}if(t.show){var i=null;if(t.showTarget){let s=t.showTarget;t.showTarget==="window"&&(s="body"),i=asElement(querySelectorExt(n,s))}t.show==="top"&&(n||i)&&(i=i||n,i.scrollIntoView({block:"start",behavior:htmx.config.scrollBehavior})),t.show==="bottom"&&(r||i)&&(i=i||r,i.scrollIntoView({block:"end",behavior:htmx.config.scrollBehavior}))}}function getValuesForElement(e,t,n,r,i){if(r==null&&(r={}),e==null)return r;const o=getAttributeValue(e,t);if(o){let s=o.trim(),a=n;if(s==="unset")return null;s.indexOf("javascript:")===0?(s=s.slice(11),a=!0):s.indexOf("js:")===0&&(s=s.slice(3),a=!0),s.indexOf("{")!==0&&(s="{"+s+"}");let l;a?l=maybeEval(e,function(){return i?Function("event","return ("+s+")").call(e,i):Function("return ("+s+")").call(e)},{}):l=parseJSON(s);for(const c in l)l.hasOwnProperty(c)&&r[c]==null&&(r[c]=l[c])}return getValuesForElement(asElement(parentElt(e)),t,n,r,i)}function maybeEval(e,t,n){return htmx.config.allowEval?t():(triggerErrorEvent(e,"htmx:evalDisallowedError"),n)}function getHXVarsForElement(e,t,n){return getValuesForElement(e,"hx-vars",!0,n,t)}function getHXValsForElement(e,t,n){return getValuesForElement(e,"hx-vals",!1,n,t)}function getExpressionVars(e,t){return mergeObjects(getHXVarsForElement(e,t),getHXValsForElement(e,t))}function safelySetHeaderValue(e,t,n){if(n!==null)try{e.setRequestHeader(t,n)}catch{e.setRequestHeader(t,encodeURIComponent(n)),e.setRequestHeader(t+"-URI-AutoEncoded","true")}}function getPathFromResponse(e){if(e.responseURL)try{const t=new URL(e.responseURL);return t.pathname+t.search}catch{triggerErrorEvent(getDocument().body,"htmx:badResponseUrl",{url:e.responseURL})}}function hasHeader(e,t){return t.test(e.getAllResponseHeaders())}function ajaxHelper(e,t,n){if(e=e.toLowerCase(),n){if(n instanceof Element||typeof n=="string")return issueAjaxRequest(e,t,null,null,{targetOverride:resolveTarget(n)||DUMMY_ELT,returnPromise:!0});{let r=resolveTarget(n.target);return(n.target&&!r||n.source&&!r&&!resolveTarget(n.source))&&(r=DUMMY_ELT),issueAjaxRequest(e,t,resolveTarget(n.source),n.event,{handler:n.handler,headers:n.headers,values:n.values,targetOverride:r,swapOverride:n.swap,select:n.select,returnPromise:!0,push:n.push,replace:n.replace,selectOOB:n.selectOOB})}}else return issueAjaxRequest(e,t,null,null,{returnPromise:!0})}function hierarchyForElt(e){const t=[];for(;e;)t.push(e),e=e.parentElement;return t}function verifyPath(e,t,n){const r=new URL(t,location.protocol!=="about:"?location.href:window.origin),o=(location.protocol!=="about:"?location.origin:window.origin)===r.origin;return htmx.config.selfRequestsOnly&&!o?!1:triggerEvent(e,"htmx:validateUrl",mergeObjects({url:r,sameHost:o},n))}function formDataFromObject(e){if(e instanceof FormData)return e;const t=new FormData;for(const n in e)e.hasOwnProperty(n)&&(e[n]&&typeof e[n].forEach=="function"?e[n].forEach(function(r){t.append(n,r)}):typeof e[n]=="object"&&!(e[n]instanceof Blob)?t.append(n,JSON.stringify(e[n])):t.append(n,e[n]));return t}function formDataArrayProxy(e,t,n){return new Proxy(n,{get:function(r,i){return typeof i=="number"?r[i]:i==="length"?r.length:i==="push"?function(o){r.push(o),e.append(t,o)}:typeof r[i]=="function"?function(){r[i].apply(r,arguments),e.delete(t),r.forEach(function(o){e.append(t,o)})}:r[i]&&r[i].length===1?r[i][0]:r[i]},set:function(r,i,o){return r[i]=o,e.delete(t),r.forEach(function(s){e.append(t,s)}),!0}})}function formDataProxy(e){return new Proxy(e,{get:function(t,n){if(typeof n=="symbol"){const i=Reflect.get(t,n);return typeof i=="function"?function(){return i.apply(e,arguments)}:i}if(n==="toJSON")return()=>Object.fromEntries(e);if(n in t&&typeof t[n]=="function")return function(){return e[n].apply(e,arguments)};const r=e.getAll(n);if(r.length!==0)return r.length===1?r[0]:formDataArrayProxy(t,n,r)},set:function(t,n,r){return typeof n!="string"?!1:(t.delete(n),r&&typeof r.forEach=="function"?r.forEach(function(i){t.append(n,i)}):typeof r=="object"&&!(r instanceof Blob)?t.append(n,JSON.stringify(r)):t.append(n,r),!0)},deleteProperty:function(t,n){return typeof n=="string"&&t.delete(n),!0},ownKeys:function(t){return Reflect.ownKeys(Object.fromEntries(t))},getOwnPropertyDescriptor:function(t,n){return Reflect.getOwnPropertyDescriptor(Object.fromEntries(t),n)}})}function issueAjaxRequest(e,t,n,r,i,o){let s=null,a=null;if(i=i??{},i.returnPromise&&typeof Promise<"u")var l=new Promise(function(x,_){s=x,a=_});n==null&&(n=getDocument().body);const c=i.handler||handleAjaxResponse,u=i.select||null;if(!bodyContains(n))return maybeCall(s),l;const f=i.targetOverride||asElement(getTarget(n));if(f==null||f==DUMMY_ELT)return triggerErrorEvent(n,"htmx:targetError",{target:getClosestAttributeValue(n,"hx-target")}),maybeCall(a),l;let d=getInternalData(n);const p=d.lastButtonClicked;if(p){const x=getRawAttribute(p,"formaction");x!=null&&(t=x);const _=getRawAttribute(p,"formmethod");if(_!=null)if(VERBS.includes(_.toLowerCase()))e=_;else return maybeCall(s),l}const g=getClosestAttributeValue(n,"hx-confirm");if(o===void 0&&triggerEvent(n,"htmx:confirm",{target:f,elt:n,path:t,verb:e,triggeringEvent:r,etc:i,issueRequest:function(R){return issueAjaxRequest(e,t,n,r,i,!!R)},question:g})===!1)return maybeCall(s),l;let v=n,h=getClosestAttributeValue(n,"hx-sync"),m=null,y=!1;if(h){const x=h.split(":"),_=x[0].trim();if(_==="this"?v=findThisElement(n,"hx-sync"):v=asElement(querySelectorExt(n,_)),h=(x[1]||"drop").trim(),d=getInternalData(v),h==="drop"&&d.xhr&&d.abortable!==!0)return maybeCall(s),l;if(h==="abort"){if(d.xhr)return maybeCall(s),l;y=!0}else h==="replace"?triggerEvent(v,"htmx:abort"):h.indexOf("queue")===0&&(m=(h.split(" ")[1]||"last").trim())}if(d.xhr)if(d.abortable)triggerEvent(v,"htmx:abort");else{if(m==null){if(r){const x=getInternalData(r);x&&x.triggerSpec&&x.triggerSpec.queue&&(m=x.triggerSpec.queue)}m==null&&(m="last")}return d.queuedRequests==null&&(d.queuedRequests=[]),m==="first"&&d.queuedRequests.length===0?d.queuedRequests.push(function(){issueAjaxRequest(e,t,n,r,i)}):m==="all"?d.queuedRequests.push(function(){issueAjaxRequest(e,t,n,r,i)}):m==="last"&&(d.queuedRequests=[],d.queuedRequests.push(function(){issueAjaxRequest(e,t,n,r,i)})),maybeCall(s),l}const E=new XMLHttpRequest;d.xhr=E,d.abortable=y;const b=function(){d.xhr=null,d.abortable=!1,d.queuedRequests!=null&&d.queuedRequests.length>0&&d.queuedRequests.shift()()},C=getClosestAttributeValue(n,"hx-prompt");if(C){var T=prompt(C);if(T===null||!triggerEvent(n,"htmx:prompt",{prompt:T,target:f}))return maybeCall(s),b(),l}if(g&&!o&&!confirm(g))return maybeCall(s),b(),l;let A=getHeaders(n,f,T);e!=="get"&&!usesFormData(n)&&(A["Content-Type"]="application/x-www-form-urlencoded"),i.headers&&(A=mergeObjects(A,i.headers));const L=getInputValues(n,e);let I=L.errors;const H=L.formData;i.values&&overrideFormData(H,formDataFromObject(i.values));const V=formDataFromObject(getExpressionVars(n,r)),F=overrideFormData(H,V);let O=filterValues(F,n);htmx.config.getCacheBusterParam&&e==="get"&&O.set("org.htmx.cache-buster",getRawAttribute(f,"id")||"true"),(t==null||t==="")&&(t=location.href);const N=getValuesForElement(n,"hx-request"),B=getInternalData(n).boosted;let M=htmx.config.methodsThatUseUrlParams.indexOf(e)>=0;const S={boosted:B,useUrlParams:M,formData:O,parameters:formDataProxy(O),unfilteredFormData:F,unfilteredParameters:formDataProxy(F),headers:A,elt:n,target:f,verb:e,errors:I,withCredentials:i.credentials||N.credentials||htmx.config.withCredentials,timeout:i.timeout||N.timeout||htmx.config.timeout,path:t,triggeringEvent:r};if(!triggerEvent(n,"htmx:configRequest",S))return maybeCall(s),b(),l;if(t=S.path,e=S.verb,A=S.headers,O=formDataFromObject(S.parameters),I=S.errors,M=S.useUrlParams,I&&I.length>0)return triggerEvent(n,"htmx:validation:halted",S),maybeCall(s),b(),l;const j=t.split("#"),U=j[0],q=j[1];let D=t;if(M&&(D=U,!O.keys().next().done&&(D.indexOf("?")<0?D+="?":D+="&",D+=urlEncode(O),q&&(D+="#"+q))),!verifyPath(n,D,S))return triggerErrorEvent(n,"htmx:invalidPath",S),maybeCall(a),b(),l;if(E.open(e.toUpperCase(),D,!0),E.overrideMimeType("text/html"),E.withCredentials=S.withCredentials,E.timeout=S.timeout,!N.noHeaders){for(const x in A)if(A.hasOwnProperty(x)){const _=A[x];safelySetHeaderValue(E,x,_)}}const w={xhr:E,target:f,requestConfig:S,etc:i,boosted:B,select:u,pathInfo:{requestPath:t,finalRequestPath:D,responsePath:null,anchor:q}};if(E.onload=function(){try{const x=hierarchyForElt(n);if(w.pathInfo.responsePath=getPathFromResponse(E),c(n,w),w.keepIndicators!==!0&&removeRequestIndicators(P,k),triggerEvent(n,"htmx:afterRequest",w),triggerEvent(n,"htmx:afterOnLoad",w),!bodyContains(n)){let _=null;for(;x.length>0&&_==null;){const R=x.shift();bodyContains(R)&&(_=R)}_&&(triggerEvent(_,"htmx:afterRequest",w),triggerEvent(_,"htmx:afterOnLoad",w))}maybeCall(s)}catch(x){throw triggerErrorEvent(n,"htmx:onLoadError",mergeObjects({error:x},w)),x}finally{b()}},E.onerror=function(){removeRequestIndicators(P,k),triggerErrorEvent(n,"htmx:afterRequest",w),triggerErrorEvent(n,"htmx:sendError",w),maybeCall(a),b()},E.onabort=function(){removeRequestIndicators(P,k),triggerErrorEvent(n,"htmx:afterRequest",w),triggerErrorEvent(n,"htmx:sendAbort",w),maybeCall(a),b()},E.ontimeout=function(){removeRequestIndicators(P,k),triggerErrorEvent(n,"htmx:afterRequest",w),triggerErrorEvent(n,"htmx:timeout",w),maybeCall(a),b()},!triggerEvent(n,"htmx:beforeRequest",w))return maybeCall(s),b(),l;var P=addRequestIndicatorClasses(n),k=disableElements(n);forEach(["loadstart","loadend","progress","abort"],function(x){forEach([E,E.upload],function(_){_.addEventListener(x,function(R){triggerEvent(n,"htmx:xhr:"+x,{lengthComputable:R.lengthComputable,loaded:R.loaded,total:R.total})})})}),triggerEvent(n,"htmx:beforeSend",w);const $=M?null:encodeParamsForBody(E,n,O);return E.send($),l}function determineHistoryUpdates(e,t){const n=t.xhr;let r=null,i=null;if(hasHeader(n,/HX-Push:/i)?(r=n.getResponseHeader("HX-Push"),i="push"):hasHeader(n,/HX-Push-Url:/i)?(r=n.getResponseHeader("HX-Push-Url"),i="push"):hasHeader(n,/HX-Replace-Url:/i)&&(r=n.getResponseHeader("HX-Replace-Url"),i="replace"),r)return r==="false"?{}:{type:i,path:r};const o=t.pathInfo.finalRequestPath,s=t.pathInfo.responsePath,a=t.etc.push||getClosestAttributeValue(e,"hx-push-url"),l=t.etc.replace||getClosestAttributeValue(e,"hx-replace-url"),c=getInternalData(e).boosted;let u=null,f=null;return a?(u="push",f=a):l?(u="replace",f=l):c&&(u="push",f=s||o),f?f==="false"?{}:(f==="true"&&(f=s||o),t.pathInfo.anchor&&f.indexOf("#")===-1&&(f=f+"#"+t.pathInfo.anchor),{type:u,path:f}):{}}function codeMatches(e,t){var n=new RegExp(e.code);return n.test(t.toString(10))}function resolveResponseHandling(e){for(var t=0;t<htmx.config.responseHandling.length;t++){var n=htmx.config.responseHandling[t];if(codeMatches(n,e.status))return n}return{swap:!1}}function handleTitle(e){if(e){const t=find("title");t?t.textContent=e:window.document.title=e}}function resolveRetarget(e,t){if(t==="this")return e;const n=asElement(querySelectorExt(e,t));if(n==null)throw triggerErrorEvent(e,"htmx:targetError",{target:t}),new Error(`Invalid re-target ${t}`);return n}function handleAjaxResponse(e,t){const n=t.xhr;let r=t.target;const i=t.etc,o=t.select;if(!triggerEvent(e,"htmx:beforeOnLoad",t))return;if(hasHeader(n,/HX-Trigger:/i)&&handleTriggerHeader(n,"HX-Trigger",e),hasHeader(n,/HX-Location:/i)){let y=n.getResponseHeader("HX-Location");var s={};y.indexOf("{")===0&&(s=parseJSON(y),y=s.path,delete s.path),s.push=s.push||"true",ajaxHelper("get",y,s);return}const a=hasHeader(n,/HX-Refresh:/i)&&n.getResponseHeader("HX-Refresh")==="true";if(hasHeader(n,/HX-Redirect:/i)){t.keepIndicators=!0,htmx.location.href=n.getResponseHeader("HX-Redirect"),a&&htmx.location.reload();return}if(a){t.keepIndicators=!0,htmx.location.reload();return}const l=determineHistoryUpdates(e,t),c=resolveResponseHandling(n),u=c.swap;let f=!!c.error,d=htmx.config.ignoreTitle||c.ignoreTitle,p=c.select;c.target&&(t.target=resolveRetarget(e,c.target));var g=i.swapOverride;g==null&&c.swapOverride&&(g=c.swapOverride),hasHeader(n,/HX-Retarget:/i)&&(t.target=resolveRetarget(e,n.getResponseHeader("HX-Retarget"))),hasHeader(n,/HX-Reswap:/i)&&(g=n.getResponseHeader("HX-Reswap"));var v=n.response,h=mergeObjects({shouldSwap:u,serverResponse:v,isError:f,ignoreTitle:d,selectOverride:p,swapOverride:g},t);if(!(c.event&&!triggerEvent(r,c.event,h))&&triggerEvent(r,"htmx:beforeSwap",h)){if(r=h.target,v=h.serverResponse,f=h.isError,d=h.ignoreTitle,p=h.selectOverride,g=h.swapOverride,t.target=r,t.failed=f,t.successful=!f,h.shouldSwap){n.status===286&&cancelPolling(e),withExtensions(e,function(b){v=b.transformResponse(v,n,e)}),l.type&&saveCurrentPageToHistory();var m=getSwapSpecification(e,g);m.hasOwnProperty("ignoreTitle")||(m.ignoreTitle=d),r.classList.add(htmx.config.swappingClass),o&&(p=o),hasHeader(n,/HX-Reselect:/i)&&(p=n.getResponseHeader("HX-Reselect"));const y=i.selectOOB||getClosestAttributeValue(e,"hx-select-oob"),E=getClosestAttributeValue(e,"hx-select");swap(r,v,m,{select:p==="unset"?null:p||E,selectOOB:y,eventInfo:t,anchor:t.pathInfo.anchor,contextElement:e,afterSwapCallback:function(){if(hasHeader(n,/HX-Trigger-After-Swap:/i)){let b=e;bodyContains(e)||(b=getDocument().body),handleTriggerHeader(n,"HX-Trigger-After-Swap",b)}},afterSettleCallback:function(){if(hasHeader(n,/HX-Trigger-After-Settle:/i)){let b=e;bodyContains(e)||(b=getDocument().body),handleTriggerHeader(n,"HX-Trigger-After-Settle",b)}},beforeSwapCallback:function(){l.type&&(triggerEvent(getDocument().body,"htmx:beforeHistoryUpdate",mergeObjects({history:l},t)),l.type==="push"?(pushUrlIntoHistory(l.path),triggerEvent(getDocument().body,"htmx:pushedIntoHistory",{path:l.path})):(replaceUrlInHistory(l.path),triggerEvent(getDocument().body,"htmx:replacedInHistory",{path:l.path})))}})}f&&triggerErrorEvent(e,"htmx:responseError",mergeObjects({error:"Response Status Error Code "+n.status+" from "+t.pathInfo.requestPath},t))}}const extensions={};function extensionBase(){return{init:function(e){return null},getSelectors:function(){return null},onEvent:function(e,t){return!0},transformResponse:function(e,t,n){return e},isInlineSwap:function(e){return!1},handleSwap:function(e,t,n,r){return!1},encodeParameters:function(e,t,n){return null}}}function defineExtension(e,t){t.init&&t.init(internalAPI),extensions[e]=mergeObjects(extensionBase(),t)}function removeExtension(e){delete extensions[e]}function getExtensions(e,t,n){if(t==null&&(t=[]),e==null)return t;n==null&&(n=[]);const r=getAttributeValue(e,"hx-ext");return r&&forEach(r.split(","),function(i){if(i=i.replace(/ /g,""),i.slice(0,7)=="ignore:"){n.push(i.slice(7));return}if(n.indexOf(i)<0){const o=extensions[i];o&&t.indexOf(o)<0&&t.push(o)}}),getExtensions(asElement(parentElt(e)),t,n)}var isReady=!1;getDocument().addEventListener("DOMContentLoaded",function(){isReady=!0});function ready(e){isReady||getDocument().readyState==="complete"?e():getDocument().addEventListener("DOMContentLoaded",e)}function insertIndicatorStyles(){if(htmx.config.includeIndicatorStyles!==!1){const e=htmx.config.inlineStyleNonce?` nonce="${htmx.config.inlineStyleNonce}"`:"",t=htmx.config.indicatorClass,n=htmx.config.requestClass;getDocument().head.insertAdjacentHTML("beforeend",`<style${e}>.${t}{opacity:0;visibility: hidden} .${n} .${t}, .${n}.${t}{opacity:1;visibility: visible;transition: opacity 200ms ease-in}</style>`)}}function getMetaConfig(){const e=getDocument().querySelector('meta[name="htmx-config"]');return e?parseJSON(e.content):null}function mergeMetaConfig(){const e=getMetaConfig();e&&(htmx.config=mergeObjects(htmx.config,e))}return ready(function(){mergeMetaConfig(),insertIndicatorStyles();let e=getDocument().body;processNode(e);const t=getDocument().querySelectorAll("[hx-trigger='restored'],[data-hx-trigger='restored']");e.addEventListener("htmx:abort",function(r){const i=r.detail.elt||r.target,o=getInternalData(i);o&&o.xhr&&o.xhr.abort()});const n=window.onpopstate?window.onpopstate.bind(window):null;window.onpopstate=function(r){r.state&&r.state.htmx?(restoreHistory(),forEach(t,function(i){triggerEvent(i,"htmx:restored",{document:getDocument(),triggerEvent})})):n&&n(r)},getWindow().setTimeout(function(){triggerEvent(e,"htmx:load",{}),e=null},0)}),htmx})();function initLoadingStatesExtension(e){const t=[];function n(l){return e.closest(l,"[data-loading-states]")||document.body}function r(l,c){document.body.contains(l)&&c()}function i(l,c){const u=e.closest(l,"[data-loading-path]");return u?u.getAttribute("data-loading-path")===c:!0}function o(l,c,u,f){const d=e.closest(l,"[data-loading-delay]");if(d){const p=Number.parseInt(d.getAttribute("data-loading-delay")||"200",10),g=setTimeout(()=>{u(),t.push(()=>{r(c,f)})},p);t.push(()=>{r(c,()=>clearTimeout(g))})}else u(),t.push(()=>{r(c,f)})}function s(l,c,u){return Array.from(e.findAll(l,`[${c}]`)).filter(f=>i(f,u))}function a(l){const c=l.getAttribute("data-loading-target");return c?Array.from(e.findAll(c)):[l]}e.defineExtension("loading-states",{onEvent(l,c){var u,f;if(l==="htmx:beforeRequest"){const d=n(c.target),p=((f=(u=c.detail)==null?void 0:u.pathInfo)==null?void 0:f.requestPath)||"",g=["data-loading","data-loading-class","data-loading-class-remove","data-loading-disable","data-loading-aria-busy"],v={};for(const h of g)v[h]=s(d,h,p);for(const h of v["data-loading"])for(const m of a(h))o(h,m,()=>{m.style.display=h.getAttribute("data-loading")||"inline-block"},()=>{m.style.display="none"});for(const h of v["data-loading-class"]){const m=(h.getAttribute("data-loading-class")||"").split(" ");for(const y of a(h))o(h,y,()=>{for(const E of m)y.classList.add(E)},()=>{for(const E of m)y.classList.remove(E)})}for(const h of v["data-loading-class-remove"]){const m=(h.getAttribute("data-loading-class-remove")||"").split(" ");for(const y of a(h))o(h,y,()=>{for(const E of m)y.classList.remove(E)},()=>{for(const E of m)y.classList.add(E)})}for(const h of v["data-loading-disable"])for(const m of a(h))o(h,m,()=>{m.disabled=!0},()=>{m.disabled=!1});for(const h of v["data-loading-aria-busy"])for(const m of a(h))o(h,m,()=>{m.setAttribute("aria-busy","true")},()=>{m.removeAttribute("aria-busy")})}if(l==="htmx:beforeOnLoad")for(;t.length>0;){const d=t.shift();d==null||d()}}})}function initSSEExtension(e){let t;function n(c){return new EventSource(c,{withCredentials:!0})}function r(c){return t.getInternalData(c).sseEventSource!=null}function i(c){if(!t.bodyContains(c)){const f=t.getInternalData(c).sseEventSource;if(f!=null)return t.triggerEvent(c,"htmx:sseClose",{source:f,type:"nodeMissing"}),f.close(),!0}return!1}function o(c,u){let f=u;t.withExtensions(c,g=>{g.transformResponse&&(f=g.transformResponse(f,null,c))});const d=t.getSwapSpecification(c),p=t.getTarget(c);p&&t.swap(p,f,d)}function s(c){const u=t.getAttributeValue(c,"sse-swap");if(u){const d=t.getClosestMatch(c,r);if(d==null)return;const g=t.getInternalData(d).sseEventSource,v=u.split(",");for(const h of v){const m=h.trim(),y=E=>{const b=E;if(!i(d)){if(!t.bodyContains(c)){g.removeEventListener(m,y);return}t.triggerEvent(c,"htmx:sseBeforeMessage",E)&&(o(c,b.data),t.triggerEvent(c,"htmx:sseMessage",E))}};t.getInternalData(c).sseEventListener=y,g.addEventListener(m,y)}}if(t.getAttributeValue(c,"hx-trigger")){const d=t.getClosestMatch(c,r);if(d==null)return;const g=t.getInternalData(d).sseEventSource,v=t.getTriggerSpecs(c);for(const h of v){if(!h.trigger.startsWith("sse:"))continue;const m=h.trigger.slice(4),y=E=>{i(d)||(t.bodyContains(c)||g.removeEventListener(m,y),e.trigger(c,h.trigger,E),e.trigger(c,"htmx:sseMessage",E))};t.getInternalData(c).sseEventListener=y,g.addEventListener(m,y)}}}function a(c,u,f){const d=e.createEventSource(u);d.onerror=g=>{if(t.triggerErrorEvent(c,"htmx:sseError",{error:g,source:d}),!i(c)&&d.readyState===EventSource.CLOSED){let v=f||0;v=Math.max(Math.min(v*2,128),1);const h=v*500;window.setTimeout(()=>{l(c,v)},h)}},d.onopen=()=>{if(t.triggerEvent(c,"htmx:sseOpen",{source:d}),f&&f>0){const g=c.querySelectorAll("[sse-swap], [data-sse-swap], [hx-trigger], [data-hx-trigger]");for(const v of g)s(v)}},t.getInternalData(c).sseEventSource=d;const p=t.getAttributeValue(c,"sse-close");p&&d.addEventListener(p,()=>{t.triggerEvent(c,"htmx:sseClose",{source:d,type:"message"}),d.close()})}function l(c,u){if(c==null)return;const f=t.getAttributeValue(c,"sse-connect");f&&a(c,f,u),s(c)}e.defineExtension("sse",{init(c){t=c,e.createEventSource==null&&(e.createEventSource=n)},getSelectors(){return["[sse-connect]","[data-sse-connect]","[sse-swap]","[data-sse-swap]"]},onEvent(c,u){var d;const f=u.target||((d=u.detail)==null?void 0:d.elt);switch(c){case"htmx:beforeCleanupElement":{const g=t.getInternalData(f).sseEventSource;g&&(t.triggerEvent(f,"htmx:sseClose",{source:g,type:"nodeReplaced"}),g.close());return}case"htmx:afterProcessNode":l(f);break}}})}const htmxApi=htmx;window.htmx=htmxApi;initLoadingStatesExtension(htmxApi);initSSEExtension(htmxApi);window.Alpine=module_default;document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{module_default.start()}):module_default.start();function initNavigation(){document.querySelectorAll(".navbar-burger").forEach(t=>{t.addEventListener("click",()=>{const n=t.dataset.target;if(!n)return;const r=document.getElementById(n);r&&(t.classList.toggle("is-active"),r.classList.toggle("is-active"))})})}function eventForm(){return{submitUrl:"/event",isEditMode:!1,formData:{name:"",description:"",status:"scheduled",mode:"inperson",tz:"America/New_York",startsAt:null,endsAt:null,locations:[],links:[],headerCid:null,headerAlt:null,headerSize:null,thumbnailCid:null,thumbnailAlt:null,requireConfirmedEmail:!1,sendNotifications:!1},startDateTimeLocal:"",endDateTimeLocal:"",submitting:!1,submitted:!1,uploading:!1,uploadingThumbnail:!1,errorMessage:null,eventUrl:null,headerCropper:null,thumbnailCropper:null,showCropper:!1,showThumbnailCropper:!1,showDescriptionPreview:!1,descriptionPreviewHtml:"",loadingPreview:!1,locationSuggestions:[],loadingSuggestions:!1,showLocationSuggestions:!1,locationFeedback:null,locationFilter:"",init(){const e=this.$el;if(e.dataset.submitUrl&&(this.submitUrl=e.dataset.submitUrl),e.dataset.editMode==="true"&&(this.isEditMode=!0),e.dataset.eventData)try{this.formData=JSON.parse(e.dataset.eventData)}catch(t){console.error("Failed to parse event data:",t)}if(e.dataset.defaultTz&&(this.formData.tz=e.dataset.defaultTz),this.formData.startsAt){const t=new Date(this.formData.startsAt);this.startDateTimeLocal=this.formatDateTimeLocal(t)}else{const t=new Date;t.setHours(t.getHours()+3);const n=new Date(t);t.getHours()>=18&&n.setDate(n.getDate()+1),n.setHours(18,0,0,0),this.startDateTimeLocal=this.formatDateTimeLocal(n)}if(this.formData.endsAt){const t=new Date(this.formData.endsAt);this.endDateTimeLocal=this.formatDateTimeLocal(t)}this.$watch("startDateTimeLocal",t=>{if(t){const n=new Date(t);this.formData.startsAt=n.toISOString()}else this.formData.startsAt=null}),this.$watch("endDateTimeLocal",t=>{if(t){const n=new Date(t);this.formData.endsAt=n.toISOString()}else this.formData.endsAt=null})},get addressLocations(){return this.formData.locations.filter(e=>e.type==="address")},get geoLocations(){return this.formData.locations.filter(e=>e.type==="geo")},addressLocationIndex(e){return e},geoLocationIndex(e){return e},findAddressLocationIndex(e){let t=0;for(let n=0;n<this.formData.locations.length;n++)if(this.formData.locations[n].type==="address"){if(t===e)return n;t++}return-1},findGeoLocationIndex(e){let t=0;for(let n=0;n<this.formData.locations.length;n++)if(this.formData.locations[n].type==="geo"){if(t===e)return n;t++}return-1},formatDateTimeLocal(e){const t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0"),i=String(e.getHours()).padStart(2,"0"),o=String(e.getMinutes()).padStart(2,"0");return`${t}-${n}-${r}T${i}:${o}`},get headerPreviewUrl(){return this.formData.headerCid?`/content/${this.formData.headerCid}.png`:null},get thumbnailPreviewUrl(){return this.formData.thumbnailCid?`/content/${this.formData.thumbnailCid}.png`:null},get filteredLocationSuggestions(){if(!this.locationFilter.trim())return this.locationSuggestions;const e=this.locationFilter.toLowerCase().trim();return this.locationSuggestions.filter(t=>{const n=[t.name,t.street,t.locality,t.region,t.postal_code,t.country].filter(Boolean).map(i=>i.toLowerCase());return e.split(/\s+/).every(i=>n.some(o=>o.includes(i)))})},addLocation(){this.formData.locations.push({type:"address",country:"",postalCode:null,region:null,locality:null,street:null,name:null})},removeAddressLocation(e){const t=this.findAddressLocationIndex(e);t!==-1&&this.formData.locations.splice(t,1)},addGeoLocation(){this.formData.locations.push({type:"geo",latitude:"",longitude:"",name:null})},removeGeoLocation(e){const t=this.findGeoLocationIndex(e);t!==-1&&this.formData.locations.splice(t,1)},addLink(){this.formData.links.push({url:"",label:null})},removeLink(e){this.formData.links.splice(e,1)},clearStartDateTime(){const e=document.getElementById("eventStartDateTime");e&&(e.value=""),this.startDateTimeLocal="",this.formData.startsAt=null},clearEndDateTime(){const e=document.getElementById("eventEndDateTime");e&&(e.value=""),this.endDateTimeLocal="",this.formData.endsAt=null},async fetchLocationSuggestions(){if(this.loadingSuggestions||this.locationSuggestions.length>0){this.showLocationSuggestions=!0;return}this.loadingSuggestions=!0;try{const e=await fetch("/event/location-suggestions"),t=await e.json();e.ok&&t.suggestions&&(this.locationSuggestions=t.suggestions)}catch(e){console.error("Failed to fetch location suggestions:",e)}finally{this.loadingSuggestions=!1,this.showLocationSuggestions=!0}},applyLocationSuggestion(e){const t=!!e.country,n=!!(e.latitude&&e.longitude);t&&this.formData.locations.push({type:"address",country:e.country||"",postalCode:e.postal_code||null,region:e.region||null,locality:e.locality||null,street:e.street||null,name:e.name||null}),n&&this.formData.locations.push({type:"geo",latitude:String(e.latitude),longitude:String(e.longitude),name:e.name||null}),t&&n?this.locationFeedback="Added address and coordinates":t?this.locationFeedback="Added address":n&&(this.locationFeedback="Added coordinates"),this.locationFeedback&&setTimeout(()=>{this.locationFeedback=null},3e3),this.showLocationSuggestions=!1,this.locationFilter=""},async toggleDescriptionPreview(){if(this.showDescriptionPreview){this.showDescriptionPreview=!1;return}if(!this.formData.description||this.formData.description.trim().length<10){alert("Description must be at least 10 characters to preview");return}this.showDescriptionPreview=!0,this.loadingPreview=!0,this.descriptionPreviewHtml="";try{const e=await fetch("/event/preview-description",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:this.formData.description})}),t=await e.json();e.ok?this.descriptionPreviewHtml=t.html:(this.errorMessage=t.error||"Failed to load preview",this.showDescriptionPreview=!1)}catch(e){console.error("Preview error:",e),this.errorMessage="Failed to load preview. Please try again.",this.showDescriptionPreview=!1}finally{this.loadingPreview=!1}},handleHeaderImageSelect(e){var r;const t=e.target,n=(r=t.files)==null?void 0:r[0];if(n){if(n.size>3e6){alert("Image must be smaller than 3MB"),t.value="";return}console.log("Header image selected, size:",n.size)}},handleThumbnailImageSelect(e){var r;const t=e.target,n=(r=t.files)==null?void 0:r[0];if(n){if(n.size>3e6){alert("Image must be smaller than 3MB"),t.value="";return}console.log("Thumbnail image selected, size:",n.size)}},removeHeader(){this.formData.headerCid=null,this.formData.headerAlt=null,this.formData.headerSize=null,this.showCropper=!1},removeThumbnail(){this.formData.thumbnailCid=null,this.formData.thumbnailAlt=null,this.showThumbnailCropper=!1},async submitForm(){if(this.errorMessage=null,!this.formData.name||this.formData.name.trim().length<10){this.errorMessage="Event name must be at least 10 characters.";return}if(this.formData.name.trim().length>500){this.errorMessage="Event name must be no more than 500 characters.";return}if(!this.formData.description||this.formData.description.trim().length<10){this.errorMessage="Description must be at least 10 characters.";return}if(this.formData.description.trim().length>3e3){this.errorMessage="Description must be no more than 3000 characters.";return}if(this.addressLocations.filter(n=>n.type==="address"&&(!n.country||n.country.trim()==="")).length>0){this.errorMessage="All locations must have a country selected. Please select a country or remove the location.";return}for(let n=0;n<this.geoLocations.length;n++){const r=this.geoLocations[n];if(r.type==="geo"){if(!r.latitude||!r.longitude){this.errorMessage=`Coordinates ${n+1} must have both latitude and longitude.`;return}const i=parseFloat(r.latitude),o=parseFloat(r.longitude);if(isNaN(i)||i<-90||i>90){this.errorMessage=`Coordinates ${n+1} has invalid latitude. Must be between -90 and 90.`;return}if(isNaN(o)||o<-180||o>180){this.errorMessage=`Coordinates ${n+1} has invalid longitude. Must be between -180 and 180.`;return}}}const t=[];for(let n=0;n<this.formData.links.length;n++){const r=this.formData.links[n];if(!r.url||r.url.trim()===""){t.push(`Link ${n+1} must have a URL or be removed.`);continue}if(!r.url.startsWith("https://")){t.push(`Link ${n+1} must be an HTTPS URL (starting with https://).`);continue}try{new URL(r.url)}catch{t.push(`Link ${n+1} has an invalid URL format.`)}}if(t.length>0){this.errorMessage=t.join(" ");return}this.submitting=!0,this.formData.locations=this.formData.locations.filter(n=>n.type==="address"?n.country&&n.country.trim()!=="":n.type==="geo"?n.latitude&&n.longitude:!1),this.formData.links=this.formData.links.filter(n=>n.url),this.formData.endsAt===""&&(this.formData.endsAt=null);try{const n=await fetch(this.submitUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(this.formData)}),r=await n.json();n.ok?(this.submitted=!0,this.eventUrl=r.url):this.errorMessage=r.error||"Failed to "+(this.isEditMode?"update":"create")+" event. Please try again."}catch(n){console.error("Submit error:",n),this.errorMessage="Network error. Please check your connection and try again."}finally{this.submitting=!1}},resetForm(){this.formData={name:"",description:"",status:"scheduled",mode:"inperson",tz:this.formData.tz,startsAt:null,endsAt:null,locations:[],links:[],headerCid:null,headerAlt:null,headerSize:null,thumbnailCid:null,thumbnailAlt:null,requireConfirmedEmail:!1,sendNotifications:!1},this.startDateTimeLocal="",this.endDateTimeLocal="",this.submitted=!1,this.eventUrl=null,this.errorMessage=null}}}const STORAGE_KEY="smokesignal_quick_event";function initQuickEventForm(){const e=document.getElementById("quick-event-form");if(!e)return;const t=e.dataset.authenticated==="true";e.addEventListener("submit",n=>{n.preventDefault();const r=document.getElementById("home-quick-event-title"),i=document.getElementById("home-quick-event-description"),o=document.getElementById("home-quick-event-starts");if(!(!r||!i||!o))if(t){const s=o.value;if(!s){alert("Please select a start time");return}const l=new Date(s).toISOString(),c={name:r.value,description:i.value,starts_at:l,status:"scheduled",mode:"inperson",locations:[],links:[],require_confirmed_email:!1,send_notifications:!0},u=e.querySelector('button[type="submit"]');u&&(u.disabled=!0,u.innerHTML='<span class="icon"><i class="fas fa-spinner fa-pulse"></i></span><span>Creating...</span>'),fetch("/event",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)}).then(async f=>{const d=await f.json();f.ok&&d.url?window.location.href=d.url:(alert(d.error||"Failed to create event. Please try again."),u&&(u.disabled=!1,u.innerHTML="<strong>Create Event</strong>"))}).catch(f=>{console.error("Error creating event:",f),alert("Failed to create event. Please try again."),u&&(u.disabled=!1,u.innerHTML="<strong>Create Event</strong>")})}else{const s={name:r.value,description:i.value,starts_at:o.value};localStorage.setItem(STORAGE_KEY,JSON.stringify(s)),window.location.href="/quick-event"}})}const H3_RESOLUTION=7;let leafletModule=null,h3Module=null;async function loadMapLibraries(){if(!leafletModule||!h3Module){const[e,t]=await Promise.all([__vitePreload(()=>import("./maps-GDfHpVyJ.js").then(n=>n.l),__vite__mapDeps([0,1])),__vitePreload(()=>import("./maps-GDfHpVyJ.js").then(n=>n.h),__vite__mapDeps([0,1]))]);await __vitePreload(()=>import("./maps-GDfHpVyJ.js").then(n=>n.a),__vite__mapDeps([0,1])),leafletModule=e.default,h3Module=t}return{L:leafletModule,h3:h3Module}}function lfgForm(){return{latitude:"",longitude:"",h3Index:"",tags:[],tagInput:"",durationHours:"48",map:null,hexLayer:null,submitting:!1,errors:{location:null,tags:null,duration:null,general:null},init(){const e=this.$el;e.dataset.defaultDuration&&(this.durationHours=e.dataset.defaultDuration),this.$nextTick(()=>{this.initMap()})},async initMap(){try{const{L:e}=await loadMapLibraries(),t=40.7128,n=-74.006;this.map=e.map("lfg-map").setView([t,n],12),e.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",{attribution:"&copy; OpenStreetMap contributors"}).addTo(this.map),this.map.on("click",r=>{this.handleMapClick(r.latlng.lat,r.latlng.lng)}),navigator.geolocation&&navigator.geolocation.getCurrentPosition(r=>{var s;const i=r.coords.latitude,o=r.coords.longitude;(s=this.map)==null||s.setView([i,o],12)},()=>{})}catch(e){console.error("Failed to load map libraries:",e)}},handleMapClick(e,t){if(!h3Module){console.warn("H3 not loaded");return}const n=h3Module.latLngToCell(e,t,H3_RESOLUTION);if(this.h3Index===n){this.clearLocation();return}this.selectLocation(n),this.errors.location=null},selectLocation(e){if(!this.map||!leafletModule||!h3Module)return;this.hexLayer&&this.map.removeLayer(this.hexLayer),this.h3Index=e;const n=h3Module.cellToBoundary(e).map(i=>[i[0],i[1]]);this.hexLayer=leafletModule.polygon(n,{color:"#00d1b2",fillColor:"#00d1b2",fillOpacity:.3,weight:3}).addTo(this.map),this.hexLayer.bindTooltip("Click to unselect",{permanent:!1,direction:"center"}),this.hexLayer.on("click",()=>{this.clearLocation()});const r=h3Module.cellToLatLng(e);this.latitude=r[0].toString(),this.longitude=r[1].toString()},clearLocation(){this.hexLayer&&this.map&&(this.map.removeLayer(this.hexLayer),this.hexLayer=null),this.h3Index="",this.latitude="",this.longitude=""},addTag(){const e=this.tagInput.trim().replace(/[^a-zA-Z0-9-]/g,""),t=e.toLowerCase(),n=this.tags.some(r=>r.toLowerCase()===t);e&&!n&&this.tags.length<10&&(this.tags.push(e),this.errors.tags=null),this.tagInput=""},addTagFromSuggestion(e){const t=e.toLowerCase();!this.tags.some(r=>r.toLowerCase()===t)&&this.tags.length<10&&(this.tags.push(e),this.errors.tags=null)},removeTag(e){this.tags.splice(e,1)},canSubmit(){return!!this.h3Index&&this.tags.length>=1},clearErrors(){this.errors={location:null,tags:null,duration:null,general:null}},async submitForm(){if(!this.canSubmit()||this.submitting)return;this.clearErrors(),this.submitting=!0;const e={latitude:parseFloat(this.latitude),longitude:parseFloat(this.longitude),tags:this.tags,duration_hours:parseInt(this.durationHours,10)};try{const t=await fetch("/lfg",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(t.ok)window.location.href="/lfg";else{const n=await t.json();n.error?n.error.includes("location")||n.error.includes("coordinate")?this.errors.location=n.message||"Invalid location":n.error.includes("tag")?this.errors.tags=n.message||"Invalid tags":n.error.includes("duration")?this.errors.duration=n.message||"Invalid duration":this.errors.general=n.message||"An error occurred":this.errors.general="An error occurred. Please try again."}}catch(t){console.error("LFG submission error:",t),this.errors.general="Network error. Please check your connection and try again."}finally{this.submitting=!1}}}}const loadingState={maps:null,cropper:null,profileCropper:null,lfgHeatmap:null};async function initEventMap(){if(!document.getElementById("event-map"))return;loadingState.maps||(loadingState.maps=__vitePreload(()=>import("./index-BP1lDIcH.js"),[]));const{initEventMap:e}=await loadingState.maps;await e()}async function initGlobeMap(){if(!document.getElementById("globe-map"))return;loadingState.maps||(loadingState.maps=__vitePreload(()=>import("./index-BP1lDIcH.js"),[]));const{initGlobeMap:e}=await loadingState.maps;await e()}async function initLocationHeatmap(){if(!document.getElementById("location-heatmap"))return;loadingState.maps||(loadingState.maps=__vitePreload(()=>import("./index-BP1lDIcH.js"),[]));const{initLocationHeatmap:e}=await loadingState.maps;await e()}async function initMaps(){await Promise.all([initEventMap(),initGlobeMap(),initLocationHeatmap()])}async function initCropper(){if(!document.getElementById("headerCanvas")&&!document.getElementById("thumbnailCanvas"))return;loadingState.cropper||(loadingState.cropper=__vitePreload(()=>import("./index-Bcnf8oUZ.js"),[]));const{initCropper:e}=await loadingState.cropper;await e()}async function initProfileCropper(){if(!document.getElementById("avatar-input")&&!document.getElementById("banner-input"))return;loadingState.profileCropper||(loadingState.profileCropper=__vitePreload(()=>import("./profile-cropper-DwPaCPSP.js"),__vite__mapDeps([2,3])));const{initProfileCropper:e}=await loadingState.profileCropper;await e()}async function initLfgHeatmap(){if(!document.getElementById("lfg-heatmap"))return;loadingState.lfgHeatmap||(loadingState.lfgHeatmap=__vitePreload(()=>import("./heatmap-CJsCFdcC.js"),[]));const{initLfgHeatmap:e}=await loadingState.lfgHeatmap;await e()}function initPage(){initNavigation(),initQuickEventForm(),initMaps(),initCropper(),initProfileCropper(),initLfgHeatmap()}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",initPage):initPage();document.body.addEventListener("htmx:afterSettle",()=>{initMaps(),initCropper(),initProfileCropper(),initLfgHeatmap()});const SmokesignalApp={lfgForm,eventForm,initEventMap,initGlobeMap,initLocationHeatmap,initMaps,initCropper,initProfileCropper,initLfgHeatmap,initPage};window.SmokesignalApp=SmokesignalApp;export{__vitePreload as _}; 6 + `:""}`,t),setTimeout(()=>{throw e},0)}var shouldAutoEvaluateFunctions=!0;function dontAutoEvaluateFunctions(e){let t=shouldAutoEvaluateFunctions;shouldAutoEvaluateFunctions=!1;let n=e();return shouldAutoEvaluateFunctions=t,n}function evaluate(e,t,n={}){let r;return evaluateLater(e,t)(i=>r=i,n),r}function evaluateLater(...e){return theEvaluatorFunction(...e)}var theEvaluatorFunction=normalEvaluator;function setEvaluator(e){theEvaluatorFunction=e}var theRawEvaluatorFunction;function setRawEvaluator(e){theRawEvaluatorFunction=e}function normalEvaluator(e,t){let n={};injectMagics(n,e);let r=[n,...closestDataStack(e)],i=typeof t=="function"?generateEvaluatorFromFunction(r,t):generateEvaluatorFromString(r,t,e);return tryCatch.bind(null,e,t,i)}function generateEvaluatorFromFunction(e,t){return(n=()=>{},{scope:r={},params:i=[],context:o}={})=>{if(!shouldAutoEvaluateFunctions){runIfTypeOfFunction(n,t,mergeProxies([r,...e]),i);return}let s=t.apply(mergeProxies([r,...e]),i);runIfTypeOfFunction(n,s)}}var evaluatorMemo={};function generateFunctionFromString(e,t){if(evaluatorMemo[e])return evaluatorMemo[e];let n=Object.getPrototypeOf(async function(){}).constructor,r=/^[\n\s]*if.*\(.*\)/.test(e.trim())||/^(let|const)\s/.test(e.trim())?`(async()=>{ ${e} })()`:e,o=(()=>{try{let s=new n(["__self","scope"],`with (scope) { __self.result = ${r} }; __self.finished = true; return __self.result;`);return Object.defineProperty(s,"name",{value:`[Alpine] ${e}`}),s}catch(s){return handleError(s,t,e),Promise.resolve()}})();return evaluatorMemo[e]=o,o}function generateEvaluatorFromString(e,t,n){let r=generateFunctionFromString(t,n);return(i=()=>{},{scope:o={},params:s=[],context:a}={})=>{r.result=void 0,r.finished=!1;let l=mergeProxies([o,...e]);if(typeof r=="function"){let c=r.call(a,r,l).catch(u=>handleError(u,n,t));r.finished?(runIfTypeOfFunction(i,r.result,l,s,n),r.result=void 0):c.then(u=>{runIfTypeOfFunction(i,u,l,s,n)}).catch(u=>handleError(u,n,t)).finally(()=>r.result=void 0)}}}function runIfTypeOfFunction(e,t,n,r,i){if(shouldAutoEvaluateFunctions&&typeof t=="function"){let o=t.apply(n,r);o instanceof Promise?o.then(s=>runIfTypeOfFunction(e,s,n,r)).catch(s=>handleError(s,i,t)):e(o)}else typeof t=="object"&&t instanceof Promise?t.then(o=>e(o)):e(t)}function evaluateRaw(...e){return theRawEvaluatorFunction(...e)}function normalRawEvaluator(e,t,n={}){let r={};injectMagics(r,e);let i=[r,...closestDataStack(e)],o=mergeProxies([n.scope??{},...i]),s=n.params??[];if(t.includes("await")){let a=Object.getPrototypeOf(async function(){}).constructor,l=/^[\n\s]*if.*\(.*\)/.test(t.trim())||/^(let|const)\s/.test(t.trim())?`(async()=>{ ${t} })()`:t;return new a(["scope"],`with (scope) { let __result = ${l}; return __result }`).call(n.context,o)}else{let a=/^[\n\s]*if.*\(.*\)/.test(t.trim())||/^(let|const)\s/.test(t.trim())?`(()=>{ ${t} })()`:t,c=new Function(["scope"],`with (scope) { let __result = ${a}; return __result }`).call(n.context,o);return typeof c=="function"&&shouldAutoEvaluateFunctions?c.apply(o,s):c}}var prefixAsString="x-";function prefix(e=""){return prefixAsString+e}function setPrefix(e){prefixAsString=e}var directiveHandlers={};function directive(e,t){return directiveHandlers[e]=t,{before(n){if(!directiveHandlers[n]){console.warn(String.raw`Cannot find directive \`${n}\`. \`${e}\` will use the default order of execution`);return}const r=directiveOrder.indexOf(n);directiveOrder.splice(r>=0?r:directiveOrder.indexOf("DEFAULT"),0,e)}}}function directiveExists(e){return Object.keys(directiveHandlers).includes(e)}function directives(e,t,n){if(t=Array.from(t),e._x_virtualDirectives){let o=Object.entries(e._x_virtualDirectives).map(([a,l])=>({name:a,value:l})),s=attributesOnly(o);o=o.map(a=>s.find(l=>l.name===a.name)?{name:`x-bind:${a.name}`,value:`"${a.value}"`}:a),t=t.concat(o)}let r={};return t.map(toTransformedAttributes((o,s)=>r[o]=s)).filter(outNonAlpineAttributes).map(toParsedDirectives(r,n)).sort(byPriority).map(o=>getDirectiveHandler(e,o))}function attributesOnly(e){return Array.from(e).map(toTransformedAttributes()).filter(t=>!outNonAlpineAttributes(t))}var isDeferringHandlers=!1,directiveHandlerStacks=new Map,currentHandlerStackKey=Symbol();function deferHandlingDirectives(e){isDeferringHandlers=!0;let t=Symbol();currentHandlerStackKey=t,directiveHandlerStacks.set(t,[]);let n=()=>{for(;directiveHandlerStacks.get(t).length;)directiveHandlerStacks.get(t).shift()();directiveHandlerStacks.delete(t)},r=()=>{isDeferringHandlers=!1,n()};e(n),r()}function getElementBoundUtilities(e){let t=[],n=a=>t.push(a),[r,i]=elementBoundEffect(e);return t.push(i),[{Alpine:alpine_default,effect:r,cleanup:n,evaluateLater:evaluateLater.bind(evaluateLater,e),evaluate:evaluate.bind(evaluate,e)},()=>t.forEach(a=>a())]}function getDirectiveHandler(e,t){let n=()=>{},r=directiveHandlers[t.type]||n,[i,o]=getElementBoundUtilities(e);onAttributeRemoved(e,t.original,o);let s=()=>{e._x_ignore||e._x_ignoreSelf||(r.inline&&r.inline(e,t,i),r=r.bind(r,e,t,i),isDeferringHandlers?directiveHandlerStacks.get(currentHandlerStackKey).push(r):r())};return s.runCleanups=o,s}var startingWith=(e,t)=>({name:n,value:r})=>(n.startsWith(e)&&(n=n.replace(e,t)),{name:n,value:r}),into=e=>e;function toTransformedAttributes(e=()=>{}){return({name:t,value:n})=>{let{name:r,value:i}=attributeTransformers.reduce((o,s)=>s(o),{name:t,value:n});return r!==t&&e(r,t),{name:r,value:i}}}var attributeTransformers=[];function mapAttributes(e){attributeTransformers.push(e)}function outNonAlpineAttributes({name:e}){return alpineAttributeRegex().test(e)}var alpineAttributeRegex=()=>new RegExp(`^${prefixAsString}([^:^.]+)\\b`);function toParsedDirectives(e,t){return({name:n,value:r})=>{n===r&&(r="");let i=n.match(alpineAttributeRegex()),o=n.match(/:([a-zA-Z0-9\-_:]+)/),s=n.match(/\.[^.\]]+(?=[^\]]*$)/g)||[],a=t||e[n]||n;return{type:i?i[1]:null,value:o?o[1]:null,modifiers:s.map(l=>l.replace(".","")),expression:r,original:a}}}var DEFAULT="DEFAULT",directiveOrder=["ignore","ref","data","id","anchor","bind","init","for","model","modelable","transition","show","if",DEFAULT,"teleport"];function byPriority(e,t){let n=directiveOrder.indexOf(e.type)===-1?DEFAULT:e.type,r=directiveOrder.indexOf(t.type)===-1?DEFAULT:t.type;return directiveOrder.indexOf(n)-directiveOrder.indexOf(r)}function dispatch(e,t,n={}){e.dispatchEvent(new CustomEvent(t,{detail:n,bubbles:!0,composed:!0,cancelable:!0}))}function walk(e,t){if(typeof ShadowRoot=="function"&&e instanceof ShadowRoot){Array.from(e.children).forEach(i=>walk(i,t));return}let n=!1;if(t(e,()=>n=!0),n)return;let r=e.firstElementChild;for(;r;)walk(r,t),r=r.nextElementSibling}function warn(e,...t){console.warn(`Alpine Warning: ${e}`,...t)}var started=!1;function start(){started&&warn("Alpine has already been initialized on this page. Calling Alpine.start() more than once can cause problems."),started=!0,document.body||warn("Unable to initialize. Trying to load Alpine before `<body>` is available. Did you forget to add `defer` in Alpine's `<script>` tag?"),dispatch(document,"alpine:init"),dispatch(document,"alpine:initializing"),startObservingMutations(),onElAdded(t=>initTree(t,walk)),onElRemoved(t=>destroyTree(t)),onAttributesAdded((t,n)=>{directives(t,n).forEach(r=>r())});let e=t=>!closestRoot(t.parentElement,!0);Array.from(document.querySelectorAll(allSelectors().join(","))).filter(e).forEach(t=>{initTree(t)}),dispatch(document,"alpine:initialized"),setTimeout(()=>{warnAboutMissingPlugins()})}var rootSelectorCallbacks=[],initSelectorCallbacks=[];function rootSelectors(){return rootSelectorCallbacks.map(e=>e())}function allSelectors(){return rootSelectorCallbacks.concat(initSelectorCallbacks).map(e=>e())}function addRootSelector(e){rootSelectorCallbacks.push(e)}function addInitSelector(e){initSelectorCallbacks.push(e)}function closestRoot(e,t=!1){return findClosest(e,n=>{if((t?allSelectors():rootSelectors()).some(i=>n.matches(i)))return!0})}function findClosest(e,t){if(e){if(t(e))return e;if(e._x_teleportBack&&(e=e._x_teleportBack),e.parentNode instanceof ShadowRoot)return findClosest(e.parentNode.host,t);if(e.parentElement)return findClosest(e.parentElement,t)}}function isRoot(e){return rootSelectors().some(t=>e.matches(t))}var initInterceptors2=[];function interceptInit(e){initInterceptors2.push(e)}var markerDispenser=1;function initTree(e,t=walk,n=()=>{}){findClosest(e,r=>r._x_ignore)||deferHandlingDirectives(()=>{t(e,(r,i)=>{r._x_marker||(n(r,i),initInterceptors2.forEach(o=>o(r,i)),directives(r,r.attributes).forEach(o=>o()),r._x_ignore||(r._x_marker=markerDispenser++),r._x_ignore&&i())})})}function destroyTree(e,t=walk){t(e,n=>{cleanupElement(n),cleanupAttributes(n),delete n._x_marker})}function warnAboutMissingPlugins(){[["ui","dialog",["[x-dialog], [x-popover]"]],["anchor","anchor",["[x-anchor]"]],["sort","sort",["[x-sort]"]]].forEach(([t,n,r])=>{directiveExists(n)||r.some(i=>{if(document.querySelector(i))return warn(`found "${i}", but missing ${t} plugin`),!0})})}var tickStack=[],isHolding=!1;function nextTick(e=()=>{}){return queueMicrotask(()=>{isHolding||setTimeout(()=>{releaseNextTicks()})}),new Promise(t=>{tickStack.push(()=>{e(),t()})})}function releaseNextTicks(){for(isHolding=!1;tickStack.length;)tickStack.shift()()}function holdNextTicks(){isHolding=!0}function setClasses(e,t){return Array.isArray(t)?setClassesFromString(e,t.join(" ")):typeof t=="object"&&t!==null?setClassesFromObject(e,t):typeof t=="function"?setClasses(e,t()):setClassesFromString(e,t)}function setClassesFromString(e,t){let n=i=>i.split(" ").filter(o=>!e.classList.contains(o)).filter(Boolean),r=i=>(e.classList.add(...i),()=>{e.classList.remove(...i)});return t=t===!0?t="":t||"",r(n(t))}function setClassesFromObject(e,t){let n=a=>a.split(" ").filter(Boolean),r=Object.entries(t).flatMap(([a,l])=>l?n(a):!1).filter(Boolean),i=Object.entries(t).flatMap(([a,l])=>l?!1:n(a)).filter(Boolean),o=[],s=[];return i.forEach(a=>{e.classList.contains(a)&&(e.classList.remove(a),s.push(a))}),r.forEach(a=>{e.classList.contains(a)||(e.classList.add(a),o.push(a))}),()=>{s.forEach(a=>e.classList.add(a)),o.forEach(a=>e.classList.remove(a))}}function setStyles(e,t){return typeof t=="object"&&t!==null?setStylesFromObject(e,t):setStylesFromString(e,t)}function setStylesFromObject(e,t){let n={};return Object.entries(t).forEach(([r,i])=>{n[r]=e.style[r],r.startsWith("--")||(r=kebabCase(r)),e.style.setProperty(r,i)}),setTimeout(()=>{e.style.length===0&&e.removeAttribute("style")}),()=>{setStyles(e,n)}}function setStylesFromString(e,t){let n=e.getAttribute("style",t);return e.setAttribute("style",t),()=>{e.setAttribute("style",n||"")}}function kebabCase(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function once(e,t=()=>{}){let n=!1;return function(){n?t.apply(this,arguments):(n=!0,e.apply(this,arguments))}}directive("transition",(e,{value:t,modifiers:n,expression:r},{evaluate:i})=>{typeof r=="function"&&(r=i(r)),r!==!1&&(!r||typeof r=="boolean"?registerTransitionsFromHelper(e,n,t):registerTransitionsFromClassString(e,r,t))});function registerTransitionsFromClassString(e,t,n){registerTransitionObject(e,setClasses,""),{enter:i=>{e._x_transition.enter.during=i},"enter-start":i=>{e._x_transition.enter.start=i},"enter-end":i=>{e._x_transition.enter.end=i},leave:i=>{e._x_transition.leave.during=i},"leave-start":i=>{e._x_transition.leave.start=i},"leave-end":i=>{e._x_transition.leave.end=i}}[n](t)}function registerTransitionsFromHelper(e,t,n){registerTransitionObject(e,setStyles);let r=!t.includes("in")&&!t.includes("out")&&!n,i=r||t.includes("in")||["enter"].includes(n),o=r||t.includes("out")||["leave"].includes(n);t.includes("in")&&!r&&(t=t.filter((m,y)=>y<t.indexOf("out"))),t.includes("out")&&!r&&(t=t.filter((m,y)=>y>t.indexOf("out")));let s=!t.includes("opacity")&&!t.includes("scale"),a=s||t.includes("opacity"),l=s||t.includes("scale"),c=a?0:1,u=l?modifierValue(t,"scale",95)/100:1,f=modifierValue(t,"delay",0)/1e3,d=modifierValue(t,"origin","center"),p="opacity, transform",g=modifierValue(t,"duration",150)/1e3,v=modifierValue(t,"duration",75)/1e3,h="cubic-bezier(0.4, 0.0, 0.2, 1)";i&&(e._x_transition.enter.during={transformOrigin:d,transitionDelay:`${f}s`,transitionProperty:p,transitionDuration:`${g}s`,transitionTimingFunction:h},e._x_transition.enter.start={opacity:c,transform:`scale(${u})`},e._x_transition.enter.end={opacity:1,transform:"scale(1)"}),o&&(e._x_transition.leave.during={transformOrigin:d,transitionDelay:`${f}s`,transitionProperty:p,transitionDuration:`${v}s`,transitionTimingFunction:h},e._x_transition.leave.start={opacity:1,transform:"scale(1)"},e._x_transition.leave.end={opacity:c,transform:`scale(${u})`})}function registerTransitionObject(e,t,n={}){e._x_transition||(e._x_transition={enter:{during:n,start:n,end:n},leave:{during:n,start:n,end:n},in(r=()=>{},i=()=>{}){transition(e,t,{during:this.enter.during,start:this.enter.start,end:this.enter.end},r,i)},out(r=()=>{},i=()=>{}){transition(e,t,{during:this.leave.during,start:this.leave.start,end:this.leave.end},r,i)}})}window.Element.prototype._x_toggleAndCascadeWithTransitions=function(e,t,n,r){const i=document.visibilityState==="visible"?requestAnimationFrame:setTimeout;let o=()=>i(n);if(t){e._x_transition&&(e._x_transition.enter||e._x_transition.leave)?e._x_transition.enter&&(Object.entries(e._x_transition.enter.during).length||Object.entries(e._x_transition.enter.start).length||Object.entries(e._x_transition.enter.end).length)?e._x_transition.in(n):o():e._x_transition?e._x_transition.in(n):o();return}e._x_hidePromise=e._x_transition?new Promise((s,a)=>{e._x_transition.out(()=>{},()=>s(r)),e._x_transitioning&&e._x_transitioning.beforeCancel(()=>a({isFromCancelledTransition:!0}))}):Promise.resolve(r),queueMicrotask(()=>{let s=closestHide(e);s?(s._x_hideChildren||(s._x_hideChildren=[]),s._x_hideChildren.push(e)):i(()=>{let a=l=>{let c=Promise.all([l._x_hidePromise,...(l._x_hideChildren||[]).map(a)]).then(([u])=>u==null?void 0:u());return delete l._x_hidePromise,delete l._x_hideChildren,c};a(e).catch(l=>{if(!l.isFromCancelledTransition)throw l})})})};function closestHide(e){let t=e.parentNode;if(t)return t._x_hidePromise?t:closestHide(t)}function transition(e,t,{during:n,start:r,end:i}={},o=()=>{},s=()=>{}){if(e._x_transitioning&&e._x_transitioning.cancel(),Object.keys(n).length===0&&Object.keys(r).length===0&&Object.keys(i).length===0){o(),s();return}let a,l,c;performTransition(e,{start(){a=t(e,r)},during(){l=t(e,n)},before:o,end(){a(),c=t(e,i)},after:s,cleanup(){l(),c()}})}function performTransition(e,t){let n,r,i,o=once(()=>{mutateDom(()=>{n=!0,r||t.before(),i||(t.end(),releaseNextTicks()),t.after(),e.isConnected&&t.cleanup(),delete e._x_transitioning})});e._x_transitioning={beforeCancels:[],beforeCancel(s){this.beforeCancels.push(s)},cancel:once(function(){for(;this.beforeCancels.length;)this.beforeCancels.shift()();o()}),finish:o},mutateDom(()=>{t.start(),t.during()}),holdNextTicks(),requestAnimationFrame(()=>{if(n)return;let s=Number(getComputedStyle(e).transitionDuration.replace(/,.*/,"").replace("s",""))*1e3,a=Number(getComputedStyle(e).transitionDelay.replace(/,.*/,"").replace("s",""))*1e3;s===0&&(s=Number(getComputedStyle(e).animationDuration.replace("s",""))*1e3),mutateDom(()=>{t.before()}),r=!0,requestAnimationFrame(()=>{n||(mutateDom(()=>{t.end()}),releaseNextTicks(),setTimeout(e._x_transitioning.finish,s+a),i=!0)})})}function modifierValue(e,t,n){if(e.indexOf(t)===-1)return n;const r=e[e.indexOf(t)+1];if(!r||t==="scale"&&isNaN(r))return n;if(t==="duration"||t==="delay"){let i=r.match(/([0-9]+)ms/);if(i)return i[1]}return t==="origin"&&["top","right","left","center","bottom"].includes(e[e.indexOf(t)+2])?[r,e[e.indexOf(t)+2]].join(" "):r}var isCloning=!1;function skipDuringClone(e,t=()=>{}){return(...n)=>isCloning?t(...n):e(...n)}function onlyDuringClone(e){return(...t)=>isCloning&&e(...t)}var interceptors=[];function interceptClone(e){interceptors.push(e)}function cloneNode(e,t){interceptors.forEach(n=>n(e,t)),isCloning=!0,dontRegisterReactiveSideEffects(()=>{initTree(t,(n,r)=>{r(n,()=>{})})}),isCloning=!1}var isCloningLegacy=!1;function clone(e,t){t._x_dataStack||(t._x_dataStack=e._x_dataStack),isCloning=!0,isCloningLegacy=!0,dontRegisterReactiveSideEffects(()=>{cloneTree(t)}),isCloning=!1,isCloningLegacy=!1}function cloneTree(e){let t=!1;initTree(e,(r,i)=>{walk(r,(o,s)=>{if(t&&isRoot(o))return s();t=!0,i(o,s)})})}function dontRegisterReactiveSideEffects(e){let t=effect;overrideEffect((n,r)=>{let i=t(n);return release(i),()=>{}}),e(),overrideEffect(t)}function bind(e,t,n,r=[]){switch(e._x_bindings||(e._x_bindings=reactive({})),e._x_bindings[t]=n,t=r.includes("camel")?camelCase(t):t,t){case"value":bindInputValue(e,n);break;case"style":bindStyles(e,n);break;case"class":bindClasses(e,n);break;case"selected":case"checked":bindAttributeAndProperty(e,t,n);break;default:bindAttribute(e,t,n);break}}function bindInputValue(e,t){if(isRadio(e))e.attributes.value===void 0&&(e.value=t),window.fromModel&&(typeof t=="boolean"?e.checked=safeParseBoolean(e.value)===t:e.checked=checkedAttrLooseCompare(e.value,t));else if(isCheckbox(e))Number.isInteger(t)?e.value=t:!Array.isArray(t)&&typeof t!="boolean"&&![null,void 0].includes(t)?e.value=String(t):Array.isArray(t)?e.checked=t.some(n=>checkedAttrLooseCompare(n,e.value)):e.checked=!!t;else if(e.tagName==="SELECT")updateSelect(e,t);else{if(e.value===t)return;e.value=t===void 0?"":t}}function bindClasses(e,t){e._x_undoAddedClasses&&e._x_undoAddedClasses(),e._x_undoAddedClasses=setClasses(e,t)}function bindStyles(e,t){e._x_undoAddedStyles&&e._x_undoAddedStyles(),e._x_undoAddedStyles=setStyles(e,t)}function bindAttributeAndProperty(e,t,n){bindAttribute(e,t,n),setPropertyIfChanged(e,t,n)}function bindAttribute(e,t,n){[null,void 0,!1].includes(n)&&attributeShouldntBePreservedIfFalsy(t)?e.removeAttribute(t):(isBooleanAttr(t)&&(n=t),setIfChanged(e,t,n))}function setIfChanged(e,t,n){e.getAttribute(t)!=n&&e.setAttribute(t,n)}function setPropertyIfChanged(e,t,n){e[t]!==n&&(e[t]=n)}function updateSelect(e,t){const n=[].concat(t).map(r=>r+"");Array.from(e.options).forEach(r=>{r.selected=n.includes(r.value)})}function camelCase(e){return e.toLowerCase().replace(/-(\w)/g,(t,n)=>n.toUpperCase())}function checkedAttrLooseCompare(e,t){return e==t}function safeParseBoolean(e){return[1,"1","true","on","yes",!0].includes(e)?!0:[0,"0","false","off","no",!1].includes(e)?!1:e?!!e:null}var booleanAttributes=new Set(["allowfullscreen","async","autofocus","autoplay","checked","controls","default","defer","disabled","formnovalidate","inert","ismap","itemscope","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected","shadowrootclonable","shadowrootdelegatesfocus","shadowrootserializable"]);function isBooleanAttr(e){return booleanAttributes.has(e)}function attributeShouldntBePreservedIfFalsy(e){return!["aria-pressed","aria-checked","aria-expanded","aria-selected"].includes(e)}function getBinding(e,t,n){return e._x_bindings&&e._x_bindings[t]!==void 0?e._x_bindings[t]:getAttributeBinding(e,t,n)}function extractProp(e,t,n,r=!0){if(e._x_bindings&&e._x_bindings[t]!==void 0)return e._x_bindings[t];if(e._x_inlineBindings&&e._x_inlineBindings[t]!==void 0){let i=e._x_inlineBindings[t];return i.extract=r,dontAutoEvaluateFunctions(()=>evaluate(e,i.expression))}return getAttributeBinding(e,t,n)}function getAttributeBinding(e,t,n){let r=e.getAttribute(t);return r===null?typeof n=="function"?n():n:r===""?!0:isBooleanAttr(t)?!![t,"true"].includes(r):r}function isCheckbox(e){return e.type==="checkbox"||e.localName==="ui-checkbox"||e.localName==="ui-switch"}function isRadio(e){return e.type==="radio"||e.localName==="ui-radio"}function debounce(e,t){let n;return function(){const r=this,i=arguments,o=function(){n=null,e.apply(r,i)};clearTimeout(n),n=setTimeout(o,t)}}function throttle(e,t){let n;return function(){let r=this,i=arguments;n||(e.apply(r,i),n=!0,setTimeout(()=>n=!1,t))}}function entangle({get:e,set:t},{get:n,set:r}){let i=!0,o,s=effect(()=>{let a=e(),l=n();if(i)r(cloneIfObject(a)),i=!1;else{let c=JSON.stringify(a),u=JSON.stringify(l);c!==o?r(cloneIfObject(a)):c!==u&&t(cloneIfObject(l))}o=JSON.stringify(e()),JSON.stringify(n())});return()=>{release(s)}}function cloneIfObject(e){return typeof e=="object"?JSON.parse(JSON.stringify(e)):e}function plugin(e){(Array.isArray(e)?e:[e]).forEach(n=>n(alpine_default))}var stores={},isReactive=!1;function store(e,t){if(isReactive||(stores=reactive(stores),isReactive=!0),t===void 0)return stores[e];stores[e]=t,initInterceptors(stores[e]),typeof t=="object"&&t!==null&&t.hasOwnProperty("init")&&typeof t.init=="function"&&stores[e].init()}function getStores(){return stores}var binds={};function bind2(e,t){let n=typeof t!="function"?()=>t:t;return e instanceof Element?applyBindingsObject(e,n()):(binds[e]=n,()=>{})}function injectBindingProviders(e){return Object.entries(binds).forEach(([t,n])=>{Object.defineProperty(e,t,{get(){return(...r)=>n(...r)}})}),e}function applyBindingsObject(e,t,n){let r=[];for(;r.length;)r.pop()();let i=Object.entries(t).map(([s,a])=>({name:s,value:a})),o=attributesOnly(i);return i=i.map(s=>o.find(a=>a.name===s.name)?{name:`x-bind:${s.name}`,value:`"${s.value}"`}:s),directives(e,i,n).map(s=>{r.push(s.runCleanups),s()}),()=>{for(;r.length;)r.pop()()}}var datas={};function data(e,t){datas[e]=t}function injectDataProviders(e,t){return Object.entries(datas).forEach(([n,r])=>{Object.defineProperty(e,n,{get(){return(...i)=>r.bind(t)(...i)},enumerable:!1})}),e}var Alpine={get reactive(){return reactive},get release(){return release},get effect(){return effect},get raw(){return raw},version:"3.15.4",flushAndStopDeferringMutations,dontAutoEvaluateFunctions,disableEffectScheduling,startObservingMutations,stopObservingMutations,setReactivityEngine,onAttributeRemoved,onAttributesAdded,closestDataStack,skipDuringClone,onlyDuringClone,addRootSelector,addInitSelector,setErrorHandler,interceptClone,addScopeToNode,deferMutations,mapAttributes,evaluateLater,interceptInit,initInterceptors,injectMagics,setEvaluator,setRawEvaluator,mergeProxies,extractProp,findClosest,onElRemoved,closestRoot,destroyTree,interceptor,transition,setStyles,mutateDom,directive,entangle,throttle,debounce,evaluate,evaluateRaw,initTree,nextTick,prefixed:prefix,prefix:setPrefix,plugin,magic,store,start,clone,cloneNode,bound:getBinding,$data:scope,watch,walk,data,bind:bind2},alpine_default=Alpine;function makeMap(e,t){const n=Object.create(null),r=e.split(",");for(let i=0;i<r.length;i++)n[r[i]]=!0;return i=>!!n[i]}var EMPTY_OBJ=Object.freeze({}),hasOwnProperty=Object.prototype.hasOwnProperty,hasOwn=(e,t)=>hasOwnProperty.call(e,t),isArray=Array.isArray,isMap=e=>toTypeString(e)==="[object Map]",isString=e=>typeof e=="string",isSymbol=e=>typeof e=="symbol",isObject=e=>e!==null&&typeof e=="object",objectToString=Object.prototype.toString,toTypeString=e=>objectToString.call(e),toRawType=e=>toTypeString(e).slice(8,-1),isIntegerKey=e=>isString(e)&&e!=="NaN"&&e[0]!=="-"&&""+parseInt(e,10)===e,cacheStringFunction=e=>{const t=Object.create(null);return n=>t[n]||(t[n]=e(n))},capitalize=cacheStringFunction(e=>e.charAt(0).toUpperCase()+e.slice(1)),hasChanged=(e,t)=>e!==t&&(e===e||t===t),targetMap=new WeakMap,effectStack=[],activeEffect,ITERATE_KEY=Symbol("iterate"),MAP_KEY_ITERATE_KEY=Symbol("Map key iterate");function isEffect(e){return e&&e._isEffect===!0}function effect2(e,t=EMPTY_OBJ){isEffect(e)&&(e=e.raw);const n=createReactiveEffect(e,t);return t.lazy||n(),n}function stop(e){e.active&&(cleanup(e),e.options.onStop&&e.options.onStop(),e.active=!1)}var uid=0;function createReactiveEffect(e,t){const n=function(){if(!n.active)return e();if(!effectStack.includes(n)){cleanup(n);try{return enableTracking(),effectStack.push(n),activeEffect=n,e()}finally{effectStack.pop(),resetTracking(),activeEffect=effectStack[effectStack.length-1]}}};return n.id=uid++,n.allowRecurse=!!t.allowRecurse,n._isEffect=!0,n.active=!0,n.raw=e,n.deps=[],n.options=t,n}function cleanup(e){const{deps:t}=e;if(t.length){for(let n=0;n<t.length;n++)t[n].delete(e);t.length=0}}var shouldTrack=!0,trackStack=[];function pauseTracking(){trackStack.push(shouldTrack),shouldTrack=!1}function enableTracking(){trackStack.push(shouldTrack),shouldTrack=!0}function resetTracking(){const e=trackStack.pop();shouldTrack=e===void 0?!0:e}function track(e,t,n){if(!shouldTrack||activeEffect===void 0)return;let r=targetMap.get(e);r||targetMap.set(e,r=new Map);let i=r.get(n);i||r.set(n,i=new Set),i.has(activeEffect)||(i.add(activeEffect),activeEffect.deps.push(i),activeEffect.options.onTrack&&activeEffect.options.onTrack({effect:activeEffect,target:e,type:t,key:n}))}function trigger(e,t,n,r,i,o){const s=targetMap.get(e);if(!s)return;const a=new Set,l=u=>{u&&u.forEach(f=>{(f!==activeEffect||f.allowRecurse)&&a.add(f)})};if(t==="clear")s.forEach(l);else if(n==="length"&&isArray(e))s.forEach((u,f)=>{(f==="length"||f>=r)&&l(u)});else switch(n!==void 0&&l(s.get(n)),t){case"add":isArray(e)?isIntegerKey(n)&&l(s.get("length")):(l(s.get(ITERATE_KEY)),isMap(e)&&l(s.get(MAP_KEY_ITERATE_KEY)));break;case"delete":isArray(e)||(l(s.get(ITERATE_KEY)),isMap(e)&&l(s.get(MAP_KEY_ITERATE_KEY)));break;case"set":isMap(e)&&l(s.get(ITERATE_KEY));break}const c=u=>{u.options.onTrigger&&u.options.onTrigger({effect:u,target:e,key:n,type:t,newValue:r,oldValue:i,oldTarget:o}),u.options.scheduler?u.options.scheduler(u):u()};a.forEach(c)}var isNonTrackableKeys=makeMap("__proto__,__v_isRef,__isVue"),builtInSymbols=new Set(Object.getOwnPropertyNames(Symbol).map(e=>Symbol[e]).filter(isSymbol)),get2=createGetter(),readonlyGet=createGetter(!0),arrayInstrumentations=createArrayInstrumentations();function createArrayInstrumentations(){const e={};return["includes","indexOf","lastIndexOf"].forEach(t=>{e[t]=function(...n){const r=toRaw(this);for(let o=0,s=this.length;o<s;o++)track(r,"get",o+"");const i=r[t](...n);return i===-1||i===!1?r[t](...n.map(toRaw)):i}}),["push","pop","shift","unshift","splice"].forEach(t=>{e[t]=function(...n){pauseTracking();const r=toRaw(this)[t].apply(this,n);return resetTracking(),r}}),e}function createGetter(e=!1,t=!1){return function(r,i,o){if(i==="__v_isReactive")return!e;if(i==="__v_isReadonly")return e;if(i==="__v_raw"&&o===(e?t?shallowReadonlyMap:readonlyMap:t?shallowReactiveMap:reactiveMap).get(r))return r;const s=isArray(r);if(!e&&s&&hasOwn(arrayInstrumentations,i))return Reflect.get(arrayInstrumentations,i,o);const a=Reflect.get(r,i,o);return(isSymbol(i)?builtInSymbols.has(i):isNonTrackableKeys(i))||(e||track(r,"get",i),t)?a:isRef(a)?!s||!isIntegerKey(i)?a.value:a:isObject(a)?e?readonly(a):reactive2(a):a}}var set2=createSetter();function createSetter(e=!1){return function(n,r,i,o){let s=n[r];if(!e&&(i=toRaw(i),s=toRaw(s),!isArray(n)&&isRef(s)&&!isRef(i)))return s.value=i,!0;const a=isArray(n)&&isIntegerKey(r)?Number(r)<n.length:hasOwn(n,r),l=Reflect.set(n,r,i,o);return n===toRaw(o)&&(a?hasChanged(i,s)&&trigger(n,"set",r,i,s):trigger(n,"add",r,i)),l}}function deleteProperty(e,t){const n=hasOwn(e,t),r=e[t],i=Reflect.deleteProperty(e,t);return i&&n&&trigger(e,"delete",t,void 0,r),i}function has(e,t){const n=Reflect.has(e,t);return(!isSymbol(t)||!builtInSymbols.has(t))&&track(e,"has",t),n}function ownKeys(e){return track(e,"iterate",isArray(e)?"length":ITERATE_KEY),Reflect.ownKeys(e)}var mutableHandlers={get:get2,set:set2,deleteProperty,has,ownKeys},readonlyHandlers={get:readonlyGet,set(e,t){return console.warn(`Set operation on key "${String(t)}" failed: target is readonly.`,e),!0},deleteProperty(e,t){return console.warn(`Delete operation on key "${String(t)}" failed: target is readonly.`,e),!0}},toReactive=e=>isObject(e)?reactive2(e):e,toReadonly=e=>isObject(e)?readonly(e):e,toShallow=e=>e,getProto=e=>Reflect.getPrototypeOf(e);function get$1(e,t,n=!1,r=!1){e=e.__v_raw;const i=toRaw(e),o=toRaw(t);t!==o&&!n&&track(i,"get",t),!n&&track(i,"get",o);const{has:s}=getProto(i),a=r?toShallow:n?toReadonly:toReactive;if(s.call(i,t))return a(e.get(t));if(s.call(i,o))return a(e.get(o));e!==i&&e.get(t)}function has$1(e,t=!1){const n=this.__v_raw,r=toRaw(n),i=toRaw(e);return e!==i&&!t&&track(r,"has",e),!t&&track(r,"has",i),e===i?n.has(e):n.has(e)||n.has(i)}function size(e,t=!1){return e=e.__v_raw,!t&&track(toRaw(e),"iterate",ITERATE_KEY),Reflect.get(e,"size",e)}function add(e){e=toRaw(e);const t=toRaw(this);return getProto(t).has.call(t,e)||(t.add(e),trigger(t,"add",e,e)),this}function set$1(e,t){t=toRaw(t);const n=toRaw(this),{has:r,get:i}=getProto(n);let o=r.call(n,e);o?checkIdentityKeys(n,r,e):(e=toRaw(e),o=r.call(n,e));const s=i.call(n,e);return n.set(e,t),o?hasChanged(t,s)&&trigger(n,"set",e,t,s):trigger(n,"add",e,t),this}function deleteEntry(e){const t=toRaw(this),{has:n,get:r}=getProto(t);let i=n.call(t,e);i?checkIdentityKeys(t,n,e):(e=toRaw(e),i=n.call(t,e));const o=r?r.call(t,e):void 0,s=t.delete(e);return i&&trigger(t,"delete",e,void 0,o),s}function clear(){const e=toRaw(this),t=e.size!==0,n=isMap(e)?new Map(e):new Set(e),r=e.clear();return t&&trigger(e,"clear",void 0,void 0,n),r}function createForEach(e,t){return function(r,i){const o=this,s=o.__v_raw,a=toRaw(s),l=t?toShallow:e?toReadonly:toReactive;return!e&&track(a,"iterate",ITERATE_KEY),s.forEach((c,u)=>r.call(i,l(c),l(u),o))}}function createIterableMethod(e,t,n){return function(...r){const i=this.__v_raw,o=toRaw(i),s=isMap(o),a=e==="entries"||e===Symbol.iterator&&s,l=e==="keys"&&s,c=i[e](...r),u=n?toShallow:t?toReadonly:toReactive;return!t&&track(o,"iterate",l?MAP_KEY_ITERATE_KEY:ITERATE_KEY),{next(){const{value:f,done:d}=c.next();return d?{value:f,done:d}:{value:a?[u(f[0]),u(f[1])]:u(f),done:d}},[Symbol.iterator](){return this}}}}function createReadonlyMethod(e){return function(...t){{const n=t[0]?`on key "${t[0]}" `:"";console.warn(`${capitalize(e)} operation ${n}failed: target is readonly.`,toRaw(this))}return e==="delete"?!1:this}}function createInstrumentations(){const e={get(o){return get$1(this,o)},get size(){return size(this)},has:has$1,add,set:set$1,delete:deleteEntry,clear,forEach:createForEach(!1,!1)},t={get(o){return get$1(this,o,!1,!0)},get size(){return size(this)},has:has$1,add,set:set$1,delete:deleteEntry,clear,forEach:createForEach(!1,!0)},n={get(o){return get$1(this,o,!0)},get size(){return size(this,!0)},has(o){return has$1.call(this,o,!0)},add:createReadonlyMethod("add"),set:createReadonlyMethod("set"),delete:createReadonlyMethod("delete"),clear:createReadonlyMethod("clear"),forEach:createForEach(!0,!1)},r={get(o){return get$1(this,o,!0,!0)},get size(){return size(this,!0)},has(o){return has$1.call(this,o,!0)},add:createReadonlyMethod("add"),set:createReadonlyMethod("set"),delete:createReadonlyMethod("delete"),clear:createReadonlyMethod("clear"),forEach:createForEach(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach(o=>{e[o]=createIterableMethod(o,!1,!1),n[o]=createIterableMethod(o,!0,!1),t[o]=createIterableMethod(o,!1,!0),r[o]=createIterableMethod(o,!0,!0)}),[e,n,t,r]}var[mutableInstrumentations,readonlyInstrumentations]=createInstrumentations();function createInstrumentationGetter(e,t){const n=e?readonlyInstrumentations:mutableInstrumentations;return(r,i,o)=>i==="__v_isReactive"?!e:i==="__v_isReadonly"?e:i==="__v_raw"?r:Reflect.get(hasOwn(n,i)&&i in r?n:r,i,o)}var mutableCollectionHandlers={get:createInstrumentationGetter(!1)},readonlyCollectionHandlers={get:createInstrumentationGetter(!0)};function checkIdentityKeys(e,t,n){const r=toRaw(n);if(r!==n&&t.call(e,r)){const i=toRawType(e);console.warn(`Reactive ${i} contains both the raw and reactive versions of the same object${i==="Map"?" as keys":""}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`)}}var reactiveMap=new WeakMap,shallowReactiveMap=new WeakMap,readonlyMap=new WeakMap,shallowReadonlyMap=new WeakMap;function targetTypeMap(e){switch(e){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function getTargetType(e){return e.__v_skip||!Object.isExtensible(e)?0:targetTypeMap(toRawType(e))}function reactive2(e){return e&&e.__v_isReadonly?e:createReactiveObject(e,!1,mutableHandlers,mutableCollectionHandlers,reactiveMap)}function readonly(e){return createReactiveObject(e,!0,readonlyHandlers,readonlyCollectionHandlers,readonlyMap)}function createReactiveObject(e,t,n,r,i){if(!isObject(e))return console.warn(`value cannot be made reactive: ${String(e)}`),e;if(e.__v_raw&&!(t&&e.__v_isReactive))return e;const o=i.get(e);if(o)return o;const s=getTargetType(e);if(s===0)return e;const a=new Proxy(e,s===2?r:n);return i.set(e,a),a}function toRaw(e){return e&&toRaw(e.__v_raw)||e}function isRef(e){return!!(e&&e.__v_isRef===!0)}magic("nextTick",()=>nextTick);magic("dispatch",e=>dispatch.bind(dispatch,e));magic("watch",(e,{evaluateLater:t,cleanup:n})=>(r,i)=>{let o=t(r),a=watch(()=>{let l;return o(c=>l=c),l},i);n(a)});magic("store",getStores);magic("data",e=>scope(e));magic("root",e=>closestRoot(e));magic("refs",e=>(e._x_refs_proxy||(e._x_refs_proxy=mergeProxies(getArrayOfRefObject(e))),e._x_refs_proxy));function getArrayOfRefObject(e){let t=[];return findClosest(e,n=>{n._x_refs&&t.push(n._x_refs)}),t}var globalIdMemo={};function findAndIncrementId(e){return globalIdMemo[e]||(globalIdMemo[e]=0),++globalIdMemo[e]}function closestIdRoot(e,t){return findClosest(e,n=>{if(n._x_ids&&n._x_ids[t])return!0})}function setIdRoot(e,t){e._x_ids||(e._x_ids={}),e._x_ids[t]||(e._x_ids[t]=findAndIncrementId(t))}magic("id",(e,{cleanup:t})=>(n,r=null)=>{let i=`${n}${r?`-${r}`:""}`;return cacheIdByNameOnElement(e,i,t,()=>{let o=closestIdRoot(e,n),s=o?o._x_ids[n]:findAndIncrementId(n);return r?`${n}-${s}-${r}`:`${n}-${s}`})});interceptClone((e,t)=>{e._x_id&&(t._x_id=e._x_id)});function cacheIdByNameOnElement(e,t,n,r){if(e._x_id||(e._x_id={}),e._x_id[t])return e._x_id[t];let i=r();return e._x_id[t]=i,n(()=>{delete e._x_id[t]}),i}magic("el",e=>e);warnMissingPluginMagic("Focus","focus","focus");warnMissingPluginMagic("Persist","persist","persist");function warnMissingPluginMagic(e,t,n){magic(t,r=>warn(`You can't use [$${t}] without first installing the "${e}" plugin here: https://alpinejs.dev/plugins/${n}`,r))}directive("modelable",(e,{expression:t},{effect:n,evaluateLater:r,cleanup:i})=>{let o=r(t),s=()=>{let u;return o(f=>u=f),u},a=r(`${t} = __placeholder`),l=u=>a(()=>{},{scope:{__placeholder:u}}),c=s();l(c),queueMicrotask(()=>{if(!e._x_model)return;e._x_removeModelListeners.default();let u=e._x_model.get,f=e._x_model.set,d=entangle({get(){return u()},set(p){f(p)}},{get(){return s()},set(p){l(p)}});i(d)})});directive("teleport",(e,{modifiers:t,expression:n},{cleanup:r})=>{e.tagName.toLowerCase()!=="template"&&warn("x-teleport can only be used on a <template> tag",e);let i=getTarget(n),o=e.content.cloneNode(!0).firstElementChild;e._x_teleport=o,o._x_teleportBack=e,e.setAttribute("data-teleport-template",!0),o.setAttribute("data-teleport-target",!0),e._x_forwardEvents&&e._x_forwardEvents.forEach(a=>{o.addEventListener(a,l=>{l.stopPropagation(),e.dispatchEvent(new l.constructor(l.type,l))})}),addScopeToNode(o,{},e);let s=(a,l,c)=>{c.includes("prepend")?l.parentNode.insertBefore(a,l):c.includes("append")?l.parentNode.insertBefore(a,l.nextSibling):l.appendChild(a)};mutateDom(()=>{s(o,i,t),skipDuringClone(()=>{initTree(o)})()}),e._x_teleportPutBack=()=>{let a=getTarget(n);mutateDom(()=>{s(e._x_teleport,a,t)})},r(()=>mutateDom(()=>{o.remove(),destroyTree(o)}))});var teleportContainerDuringClone=document.createElement("div");function getTarget(e){let t=skipDuringClone(()=>document.querySelector(e),()=>teleportContainerDuringClone)();return t||warn(`Cannot find x-teleport element for selector: "${e}"`),t}var handler=()=>{};handler.inline=(e,{modifiers:t},{cleanup:n})=>{t.includes("self")?e._x_ignoreSelf=!0:e._x_ignore=!0,n(()=>{t.includes("self")?delete e._x_ignoreSelf:delete e._x_ignore})};directive("ignore",handler);directive("effect",skipDuringClone((e,{expression:t},{effect:n})=>{n(evaluateLater(e,t))}));function on(e,t,n,r){let i=e,o=l=>r(l),s={},a=(l,c)=>u=>c(l,u);if(n.includes("dot")&&(t=dotSyntax(t)),n.includes("camel")&&(t=camelCase2(t)),n.includes("passive")&&(s.passive=!0),n.includes("capture")&&(s.capture=!0),n.includes("window")&&(i=window),n.includes("document")&&(i=document),n.includes("debounce")){let l=n[n.indexOf("debounce")+1]||"invalid-wait",c=isNumeric(l.split("ms")[0])?Number(l.split("ms")[0]):250;o=debounce(o,c)}if(n.includes("throttle")){let l=n[n.indexOf("throttle")+1]||"invalid-wait",c=isNumeric(l.split("ms")[0])?Number(l.split("ms")[0]):250;o=throttle(o,c)}return n.includes("prevent")&&(o=a(o,(l,c)=>{c.preventDefault(),l(c)})),n.includes("stop")&&(o=a(o,(l,c)=>{c.stopPropagation(),l(c)})),n.includes("once")&&(o=a(o,(l,c)=>{l(c),i.removeEventListener(t,o,s)})),(n.includes("away")||n.includes("outside"))&&(i=document,o=a(o,(l,c)=>{e.contains(c.target)||c.target.isConnected!==!1&&(e.offsetWidth<1&&e.offsetHeight<1||e._x_isShown!==!1&&l(c))})),n.includes("self")&&(o=a(o,(l,c)=>{c.target===e&&l(c)})),(isKeyEvent(t)||isClickEvent(t))&&(o=a(o,(l,c)=>{isListeningForASpecificKeyThatHasntBeenPressed(c,n)||l(c)})),i.addEventListener(t,o,s),()=>{i.removeEventListener(t,o,s)}}function dotSyntax(e){return e.replace(/-/g,".")}function camelCase2(e){return e.toLowerCase().replace(/-(\w)/g,(t,n)=>n.toUpperCase())}function isNumeric(e){return!Array.isArray(e)&&!isNaN(e)}function kebabCase2(e){return[" ","_"].includes(e)?e:e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[_\s]/,"-").toLowerCase()}function isKeyEvent(e){return["keydown","keyup"].includes(e)}function isClickEvent(e){return["contextmenu","click","mouse"].some(t=>e.includes(t))}function isListeningForASpecificKeyThatHasntBeenPressed(e,t){let n=t.filter(o=>!["window","document","prevent","stop","once","capture","self","away","outside","passive","preserve-scroll"].includes(o));if(n.includes("debounce")){let o=n.indexOf("debounce");n.splice(o,isNumeric((n[o+1]||"invalid-wait").split("ms")[0])?2:1)}if(n.includes("throttle")){let o=n.indexOf("throttle");n.splice(o,isNumeric((n[o+1]||"invalid-wait").split("ms")[0])?2:1)}if(n.length===0||n.length===1&&keyToModifiers(e.key).includes(n[0]))return!1;const i=["ctrl","shift","alt","meta","cmd","super"].filter(o=>n.includes(o));return n=n.filter(o=>!i.includes(o)),!(i.length>0&&i.filter(s=>((s==="cmd"||s==="super")&&(s="meta"),e[`${s}Key`])).length===i.length&&(isClickEvent(e.type)||keyToModifiers(e.key).includes(n[0])))}function keyToModifiers(e){if(!e)return[];e=kebabCase2(e);let t={ctrl:"control",slash:"/",space:" ",spacebar:" ",cmd:"meta",esc:"escape",up:"arrow-up",down:"arrow-down",left:"arrow-left",right:"arrow-right",period:".",comma:",",equal:"=",minus:"-",underscore:"_"};return t[e]=e,Object.keys(t).map(n=>{if(t[n]===e)return n}).filter(n=>n)}directive("model",(e,{modifiers:t,expression:n},{effect:r,cleanup:i})=>{let o=e;t.includes("parent")&&(o=e.parentNode);let s=evaluateLater(o,n),a;typeof n=="string"?a=evaluateLater(o,`${n} = __placeholder`):typeof n=="function"&&typeof n()=="string"?a=evaluateLater(o,`${n()} = __placeholder`):a=()=>{};let l=()=>{let d;return s(p=>d=p),isGetterSetter(d)?d.get():d},c=d=>{let p;s(g=>p=g),isGetterSetter(p)?p.set(d):a(()=>{},{scope:{__placeholder:d}})};typeof n=="string"&&e.type==="radio"&&mutateDom(()=>{e.hasAttribute("name")||e.setAttribute("name",n)});let u=e.tagName.toLowerCase()==="select"||["checkbox","radio"].includes(e.type)||t.includes("lazy")?"change":"input",f=isCloning?()=>{}:on(e,u,t,d=>{c(getInputValue(e,t,d,l()))});if(t.includes("fill")&&([void 0,null,""].includes(l())||isCheckbox(e)&&Array.isArray(l())||e.tagName.toLowerCase()==="select"&&e.multiple)&&c(getInputValue(e,t,{target:e},l())),e._x_removeModelListeners||(e._x_removeModelListeners={}),e._x_removeModelListeners.default=f,i(()=>e._x_removeModelListeners.default()),e.form){let d=on(e.form,"reset",[],p=>{nextTick(()=>e._x_model&&e._x_model.set(getInputValue(e,t,{target:e},l())))});i(()=>d())}e._x_model={get(){return l()},set(d){c(d)}},e._x_forceModelUpdate=d=>{d===void 0&&typeof n=="string"&&n.match(/\./)&&(d=""),window.fromModel=!0,mutateDom(()=>bind(e,"value",d)),delete window.fromModel},r(()=>{let d=l();t.includes("unintrusive")&&document.activeElement.isSameNode(e)||e._x_forceModelUpdate(d)})});function getInputValue(e,t,n,r){return mutateDom(()=>{if(n instanceof CustomEvent&&n.detail!==void 0)return n.detail!==null&&n.detail!==void 0?n.detail:n.target.value;if(isCheckbox(e))if(Array.isArray(r)){let i=null;return t.includes("number")?i=safeParseNumber(n.target.value):t.includes("boolean")?i=safeParseBoolean(n.target.value):i=n.target.value,n.target.checked?r.includes(i)?r:r.concat([i]):r.filter(o=>!checkedAttrLooseCompare2(o,i))}else return n.target.checked;else{if(e.tagName.toLowerCase()==="select"&&e.multiple)return t.includes("number")?Array.from(n.target.selectedOptions).map(i=>{let o=i.value||i.text;return safeParseNumber(o)}):t.includes("boolean")?Array.from(n.target.selectedOptions).map(i=>{let o=i.value||i.text;return safeParseBoolean(o)}):Array.from(n.target.selectedOptions).map(i=>i.value||i.text);{let i;return isRadio(e)?n.target.checked?i=n.target.value:i=r:i=n.target.value,t.includes("number")?safeParseNumber(i):t.includes("boolean")?safeParseBoolean(i):t.includes("trim")?i.trim():i}}})}function safeParseNumber(e){let t=e?parseFloat(e):null;return isNumeric2(t)?t:e}function checkedAttrLooseCompare2(e,t){return e==t}function isNumeric2(e){return!Array.isArray(e)&&!isNaN(e)}function isGetterSetter(e){return e!==null&&typeof e=="object"&&typeof e.get=="function"&&typeof e.set=="function"}directive("cloak",e=>queueMicrotask(()=>mutateDom(()=>e.removeAttribute(prefix("cloak")))));addInitSelector(()=>`[${prefix("init")}]`);directive("init",skipDuringClone((e,{expression:t},{evaluate:n})=>typeof t=="string"?!!t.trim()&&n(t,{},!1):n(t,{},!1)));directive("text",(e,{expression:t},{effect:n,evaluateLater:r})=>{let i=r(t);n(()=>{i(o=>{mutateDom(()=>{e.textContent=o})})})});directive("html",(e,{expression:t},{effect:n,evaluateLater:r})=>{let i=r(t);n(()=>{i(o=>{mutateDom(()=>{e.innerHTML=o,e._x_ignoreSelf=!0,initTree(e),delete e._x_ignoreSelf})})})});mapAttributes(startingWith(":",into(prefix("bind:"))));var handler2=(e,{value:t,modifiers:n,expression:r,original:i},{effect:o,cleanup:s})=>{if(!t){let l={};injectBindingProviders(l),evaluateLater(e,r)(u=>{applyBindingsObject(e,u,i)},{scope:l});return}if(t==="key")return storeKeyForXFor(e,r);if(e._x_inlineBindings&&e._x_inlineBindings[t]&&e._x_inlineBindings[t].extract)return;let a=evaluateLater(e,r);o(()=>a(l=>{l===void 0&&typeof r=="string"&&r.match(/\./)&&(l=""),mutateDom(()=>bind(e,t,l,n))})),s(()=>{e._x_undoAddedClasses&&e._x_undoAddedClasses(),e._x_undoAddedStyles&&e._x_undoAddedStyles()})};handler2.inline=(e,{value:t,modifiers:n,expression:r})=>{t&&(e._x_inlineBindings||(e._x_inlineBindings={}),e._x_inlineBindings[t]={expression:r,extract:!1})};directive("bind",handler2);function storeKeyForXFor(e,t){e._x_keyExpression=t}addRootSelector(()=>`[${prefix("data")}]`);directive("data",(e,{expression:t},{cleanup:n})=>{if(shouldSkipRegisteringDataDuringClone(e))return;t=t===""?"{}":t;let r={};injectMagics(r,e);let i={};injectDataProviders(i,r);let o=evaluate(e,t,{scope:i});(o===void 0||o===!0)&&(o={}),injectMagics(o,e);let s=reactive(o);initInterceptors(s);let a=addScopeToNode(e,s);s.init&&evaluate(e,s.init),n(()=>{s.destroy&&evaluate(e,s.destroy),a()})});interceptClone((e,t)=>{e._x_dataStack&&(t._x_dataStack=e._x_dataStack,t.setAttribute("data-has-alpine-state",!0))});function shouldSkipRegisteringDataDuringClone(e){return isCloning?isCloningLegacy?!0:e.hasAttribute("data-has-alpine-state"):!1}directive("show",(e,{modifiers:t,expression:n},{effect:r})=>{let i=evaluateLater(e,n);e._x_doHide||(e._x_doHide=()=>{mutateDom(()=>{e.style.setProperty("display","none",t.includes("important")?"important":void 0)})}),e._x_doShow||(e._x_doShow=()=>{mutateDom(()=>{e.style.length===1&&e.style.display==="none"?e.removeAttribute("style"):e.style.removeProperty("display")})});let o=()=>{e._x_doHide(),e._x_isShown=!1},s=()=>{e._x_doShow(),e._x_isShown=!0},a=()=>setTimeout(s),l=once(f=>f?s():o(),f=>{typeof e._x_toggleAndCascadeWithTransitions=="function"?e._x_toggleAndCascadeWithTransitions(e,f,s,o):f?a():o()}),c,u=!0;r(()=>i(f=>{!u&&f===c||(t.includes("immediate")&&(f?a():o()),l(f),c=f,u=!1)}))});directive("for",(e,{expression:t},{effect:n,cleanup:r})=>{let i=parseForExpression(t),o=evaluateLater(e,i.items),s=evaluateLater(e,e._x_keyExpression||"index");e._x_prevKeys=[],e._x_lookup={},n(()=>loop(e,i,o,s)),r(()=>{Object.values(e._x_lookup).forEach(a=>mutateDom(()=>{destroyTree(a),a.remove()})),delete e._x_prevKeys,delete e._x_lookup})});function loop(e,t,n,r){let i=s=>typeof s=="object"&&!Array.isArray(s),o=e;n(s=>{isNumeric3(s)&&s>=0&&(s=Array.from(Array(s).keys(),h=>h+1)),s===void 0&&(s=[]);let a=e._x_lookup,l=e._x_prevKeys,c=[],u=[];if(i(s))s=Object.entries(s).map(([h,m])=>{let y=getIterationScopeVariables(t,m,h,s);r(E=>{u.includes(E)&&warn("Duplicate key on x-for",e),u.push(E)},{scope:{index:h,...y}}),c.push(y)});else for(let h=0;h<s.length;h++){let m=getIterationScopeVariables(t,s[h],h,s);r(y=>{u.includes(y)&&warn("Duplicate key on x-for",e),u.push(y)},{scope:{index:h,...m}}),c.push(m)}let f=[],d=[],p=[],g=[];for(let h=0;h<l.length;h++){let m=l[h];u.indexOf(m)===-1&&p.push(m)}l=l.filter(h=>!p.includes(h));let v="template";for(let h=0;h<u.length;h++){let m=u[h],y=l.indexOf(m);if(y===-1)l.splice(h,0,m),f.push([v,h]);else if(y!==h){let E=l.splice(h,1)[0],b=l.splice(y-1,1)[0];l.splice(h,0,b),l.splice(y,0,E),d.push([E,b])}else g.push(m);v=m}for(let h=0;h<p.length;h++){let m=p[h];m in a&&(mutateDom(()=>{destroyTree(a[m]),a[m].remove()}),delete a[m])}for(let h=0;h<d.length;h++){let[m,y]=d[h],E=a[m],b=a[y],C=document.createElement("div");mutateDom(()=>{b||warn('x-for ":key" is undefined or invalid',o,y,a),b.after(C),E.after(b),b._x_currentIfEl&&b.after(b._x_currentIfEl),C.before(E),E._x_currentIfEl&&E.after(E._x_currentIfEl),C.remove()}),b._x_refreshXForScope(c[u.indexOf(y)])}for(let h=0;h<f.length;h++){let[m,y]=f[h],E=m==="template"?o:a[m];E._x_currentIfEl&&(E=E._x_currentIfEl);let b=c[y],C=u[y],T=document.importNode(o.content,!0).firstElementChild,A=reactive(b);addScopeToNode(T,A,o),T._x_refreshXForScope=L=>{Object.entries(L).forEach(([I,M])=>{A[I]=M})},mutateDom(()=>{E.after(T),skipDuringClone(()=>initTree(T))()}),typeof C=="object"&&warn("x-for key cannot be an object, it must be a string or an integer",o),a[C]=T}for(let h=0;h<g.length;h++)a[g[h]]._x_refreshXForScope(c[u.indexOf(g[h])]);o._x_prevKeys=u})}function parseForExpression(e){let t=/,([^,\}\]]*)(?:,([^,\}\]]*))?$/,n=/^\s*\(|\)\s*$/g,r=/([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/,i=e.match(r);if(!i)return;let o={};o.items=i[2].trim();let s=i[1].replace(n,"").trim(),a=s.match(t);return a?(o.item=s.replace(t,"").trim(),o.index=a[1].trim(),a[2]&&(o.collection=a[2].trim())):o.item=s,o}function getIterationScopeVariables(e,t,n,r){let i={};return/^\[.*\]$/.test(e.item)&&Array.isArray(t)?e.item.replace("[","").replace("]","").split(",").map(s=>s.trim()).forEach((s,a)=>{i[s]=t[a]}):/^\{.*\}$/.test(e.item)&&!Array.isArray(t)&&typeof t=="object"?e.item.replace("{","").replace("}","").split(",").map(s=>s.trim()).forEach(s=>{i[s]=t[s]}):i[e.item]=t,e.index&&(i[e.index]=n),e.collection&&(i[e.collection]=r),i}function isNumeric3(e){return!Array.isArray(e)&&!isNaN(e)}function handler3(){}handler3.inline=(e,{expression:t},{cleanup:n})=>{let r=closestRoot(e);r._x_refs||(r._x_refs={}),r._x_refs[t]=e,n(()=>delete r._x_refs[t])};directive("ref",handler3);directive("if",(e,{expression:t},{effect:n,cleanup:r})=>{e.tagName.toLowerCase()!=="template"&&warn("x-if can only be used on a <template> tag",e);let i=evaluateLater(e,t),o=()=>{if(e._x_currentIfEl)return e._x_currentIfEl;let a=e.content.cloneNode(!0).firstElementChild;return addScopeToNode(a,{},e),mutateDom(()=>{e.after(a),skipDuringClone(()=>initTree(a))()}),e._x_currentIfEl=a,e._x_undoIf=()=>{mutateDom(()=>{destroyTree(a),a.remove()}),delete e._x_currentIfEl},a},s=()=>{e._x_undoIf&&(e._x_undoIf(),delete e._x_undoIf)};n(()=>i(a=>{a?o():s()})),r(()=>e._x_undoIf&&e._x_undoIf())});directive("id",(e,{expression:t},{evaluate:n})=>{n(t).forEach(i=>setIdRoot(e,i))});interceptClone((e,t)=>{e._x_ids&&(t._x_ids=e._x_ids)});mapAttributes(startingWith("@",into(prefix("on:"))));directive("on",skipDuringClone((e,{value:t,modifiers:n,expression:r},{cleanup:i})=>{let o=r?evaluateLater(e,r):()=>{};e.tagName.toLowerCase()==="template"&&(e._x_forwardEvents||(e._x_forwardEvents=[]),e._x_forwardEvents.includes(t)||e._x_forwardEvents.push(t));let s=on(e,t,n,a=>{o(()=>{},{scope:{$event:a},params:[a]})});i(()=>s())}));warnMissingPluginDirective("Collapse","collapse","collapse");warnMissingPluginDirective("Intersect","intersect","intersect");warnMissingPluginDirective("Focus","trap","focus");warnMissingPluginDirective("Mask","mask","mask");function warnMissingPluginDirective(e,t,n){directive(t,r=>warn(`You can't use [x-${t}] without first installing the "${e}" plugin here: https://alpinejs.dev/plugins/${n}`,r))}alpine_default.setEvaluator(normalEvaluator);alpine_default.setRawEvaluator(normalRawEvaluator);alpine_default.setReactivityEngine({reactive:reactive2,effect:effect2,release:stop,raw:toRaw});var src_default=alpine_default,module_default=src_default,htmx=(function(){const htmx={onLoad:null,process:null,on:null,off:null,trigger:null,ajax:null,find:null,findAll:null,closest:null,values:function(e,t){return getInputValues(e,t||"post").values},remove:null,addClass:null,removeClass:null,toggleClass:null,takeClass:null,swap:null,defineExtension:null,removeExtension:null,logAll:null,logNone:null,logger:null,config:{historyEnabled:!0,historyCacheSize:10,refreshOnHistoryMiss:!1,defaultSwapStyle:"innerHTML",defaultSwapDelay:0,defaultSettleDelay:20,includeIndicatorStyles:!0,indicatorClass:"htmx-indicator",requestClass:"htmx-request",addedClass:"htmx-added",settlingClass:"htmx-settling",swappingClass:"htmx-swapping",allowEval:!0,allowScriptTags:!0,inlineScriptNonce:"",inlineStyleNonce:"",attributesToSettle:["class","style","width","height"],withCredentials:!1,timeout:0,wsReconnectDelay:"full-jitter",wsBinaryType:"blob",disableSelector:"[hx-disable], [data-hx-disable]",scrollBehavior:"instant",defaultFocusScroll:!1,getCacheBusterParam:!1,globalViewTransitions:!1,methodsThatUseUrlParams:["get","delete"],selfRequestsOnly:!0,ignoreTitle:!1,scrollIntoViewOnBoost:!0,triggerSpecsCache:null,disableInheritance:!1,responseHandling:[{code:"204",swap:!1},{code:"[23]..",swap:!0},{code:"[45]..",swap:!1,error:!0}],allowNestedOobSwaps:!0,historyRestoreAsHxRequest:!0,reportValidityOfForms:!1},parseInterval:null,location,_:null,version:"2.0.8"};htmx.onLoad=onLoadHelper,htmx.process=processNode,htmx.on=addEventListenerImpl,htmx.off=removeEventListenerImpl,htmx.trigger=triggerEvent,htmx.ajax=ajaxHelper,htmx.find=find,htmx.findAll=findAll,htmx.closest=closest,htmx.remove=removeElement,htmx.addClass=addClassToElement,htmx.removeClass=removeClassFromElement,htmx.toggleClass=toggleClassOnElement,htmx.takeClass=takeClassForElement,htmx.swap=swap,htmx.defineExtension=defineExtension,htmx.removeExtension=removeExtension,htmx.logAll=logAll,htmx.logNone=logNone,htmx.parseInterval=parseInterval,htmx._=internalEval;const internalAPI={addTriggerHandler,bodyContains,canAccessLocalStorage,findThisElement,filterValues,swap,hasAttribute,getAttributeValue,getClosestAttributeValue,getClosestMatch,getExpressionVars,getHeaders,getInputValues,getInternalData,getSwapSpecification,getTriggerSpecs,getTarget,makeFragment,mergeObjects,makeSettleInfo,oobSwap,querySelectorExt,settleImmediately,shouldCancel,triggerEvent,triggerErrorEvent,withExtensions},VERBS=["get","post","put","delete","patch"],VERB_SELECTOR=VERBS.map(function(e){return"[hx-"+e+"], [data-hx-"+e+"]"}).join(", ");function parseInterval(e){if(e==null)return;let t=NaN;return e.slice(-2)=="ms"?t=parseFloat(e.slice(0,-2)):e.slice(-1)=="s"?t=parseFloat(e.slice(0,-1))*1e3:e.slice(-1)=="m"?t=parseFloat(e.slice(0,-1))*1e3*60:t=parseFloat(e),isNaN(t)?void 0:t}function getRawAttribute(e,t){return e instanceof Element&&e.getAttribute(t)}function hasAttribute(e,t){return!!e.hasAttribute&&(e.hasAttribute(t)||e.hasAttribute("data-"+t))}function getAttributeValue(e,t){return getRawAttribute(e,t)||getRawAttribute(e,"data-"+t)}function parentElt(e){const t=e.parentElement;return!t&&e.parentNode instanceof ShadowRoot?e.parentNode:t}function getDocument(){return document}function getRootNode(e,t){return e.getRootNode?e.getRootNode({composed:t}):getDocument()}function getClosestMatch(e,t){for(;e&&!t(e);)e=parentElt(e);return e||null}function getAttributeValueWithDisinheritance(e,t,n){const r=getAttributeValue(t,n),i=getAttributeValue(t,"hx-disinherit");var o=getAttributeValue(t,"hx-inherit");if(e!==t){if(htmx.config.disableInheritance)return o&&(o==="*"||o.split(" ").indexOf(n)>=0)?r:null;if(i&&(i==="*"||i.split(" ").indexOf(n)>=0))return"unset"}return r}function getClosestAttributeValue(e,t){let n=null;if(getClosestMatch(e,function(r){return!!(n=getAttributeValueWithDisinheritance(e,asElement(r),t))}),n!=="unset")return n}function matches(e,t){return e instanceof Element&&e.matches(t)}function getStartTag(e){const n=/<([a-z][^\/\0>\x20\t\r\n\f]*)/i.exec(e);return n?n[1].toLowerCase():""}function parseHTML(e){return"parseHTMLUnsafe"in Document?Document.parseHTMLUnsafe(e):new DOMParser().parseFromString(e,"text/html")}function takeChildrenFor(e,t){for(;t.childNodes.length>0;)e.append(t.childNodes[0])}function duplicateScript(e){const t=getDocument().createElement("script");return forEach(e.attributes,function(n){t.setAttribute(n.name,n.value)}),t.textContent=e.textContent,t.async=!1,htmx.config.inlineScriptNonce&&(t.nonce=htmx.config.inlineScriptNonce),t}function isJavaScriptScriptNode(e){return e.matches("script")&&(e.type==="text/javascript"||e.type==="module"||e.type==="")}function normalizeScriptTags(e){Array.from(e.querySelectorAll("script")).forEach(t=>{if(isJavaScriptScriptNode(t)){const n=duplicateScript(t),r=t.parentNode;try{r.insertBefore(n,t)}catch(i){logError(i)}finally{t.remove()}}})}function makeFragment(e){const t=e.replace(/<head(\s[^>]*)?>[\s\S]*?<\/head>/i,""),n=getStartTag(t);let r;if(n==="html"){r=new DocumentFragment;const o=parseHTML(e);takeChildrenFor(r,o.body),r.title=o.title}else if(n==="body"){r=new DocumentFragment;const o=parseHTML(t);takeChildrenFor(r,o.body),r.title=o.title}else{const o=parseHTML('<body><template class="internal-htmx-wrapper">'+t+"</template></body>");r=o.querySelector("template").content,r.title=o.title;var i=r.querySelector("title");i&&i.parentNode===r&&(i.remove(),r.title=i.innerText)}return r&&(htmx.config.allowScriptTags?normalizeScriptTags(r):r.querySelectorAll("script").forEach(o=>o.remove())),r}function maybeCall(e){e&&e()}function isType(e,t){return Object.prototype.toString.call(e)==="[object "+t+"]"}function isFunction(e){return typeof e=="function"}function isRawObject(e){return isType(e,"Object")}function getInternalData(e){const t="htmx-internal-data";let n=e[t];return n||(n=e[t]={}),n}function toArray(e){const t=[];if(e)for(let n=0;n<e.length;n++)t.push(e[n]);return t}function forEach(e,t){if(e)for(let n=0;n<e.length;n++)t(e[n])}function isScrolledIntoView(e){const t=e.getBoundingClientRect(),n=t.top,r=t.bottom;return n<window.innerHeight&&r>=0}function bodyContains(e){return e.getRootNode({composed:!0})===document}function splitOnWhitespace(e){return e.trim().split(/\s+/)}function mergeObjects(e,t){for(const n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e}function parseJSON(e){try{return JSON.parse(e)}catch(t){return logError(t),null}}function canAccessLocalStorage(){const e="htmx:sessionStorageTest";try{return sessionStorage.setItem(e,e),sessionStorage.removeItem(e),!0}catch{return!1}}function normalizePath(e){const t=new URL(e,"http://x");return t&&(e=t.pathname+t.search),e!="/"&&(e=e.replace(/\/+$/,"")),e}function internalEval(str){return maybeEval(getDocument().body,function(){return eval(str)})}function onLoadHelper(e){return htmx.on("htmx:load",function(n){e(n.detail.elt)})}function logAll(){htmx.logger=function(e,t,n){console&&console.log(t,e,n)}}function logNone(){htmx.logger=null}function find(e,t){return typeof e!="string"?e.querySelector(t):find(getDocument(),e)}function findAll(e,t){return typeof e!="string"?e.querySelectorAll(t):findAll(getDocument(),e)}function getWindow(){return window}function removeElement(e,t){e=resolveTarget(e),t?getWindow().setTimeout(function(){removeElement(e),e=null},t):parentElt(e).removeChild(e)}function asElement(e){return e instanceof Element?e:null}function asHtmlElement(e){return e instanceof HTMLElement?e:null}function asString(e){return typeof e=="string"?e:null}function asParentNode(e){return e instanceof Element||e instanceof Document||e instanceof DocumentFragment?e:null}function addClassToElement(e,t,n){e=asElement(resolveTarget(e)),e&&(n?getWindow().setTimeout(function(){addClassToElement(e,t),e=null},n):e.classList&&e.classList.add(t))}function removeClassFromElement(e,t,n){let r=asElement(resolveTarget(e));r&&(n?getWindow().setTimeout(function(){removeClassFromElement(r,t),r=null},n):r.classList&&(r.classList.remove(t),r.classList.length===0&&r.removeAttribute("class")))}function toggleClassOnElement(e,t){e=resolveTarget(e),e.classList.toggle(t)}function takeClassForElement(e,t){e=resolveTarget(e),forEach(e.parentElement.children,function(n){removeClassFromElement(n,t)}),addClassToElement(asElement(e),t)}function closest(e,t){return e=asElement(resolveTarget(e)),e?e.closest(t):null}function startsWith(e,t){return e.substring(0,t.length)===t}function endsWith(e,t){return e.substring(e.length-t.length)===t}function normalizeSelector(e){const t=e.trim();return startsWith(t,"<")&&endsWith(t,"/>")?t.substring(1,t.length-2):t}function querySelectorAllExt(e,t,n){if(t.indexOf("global ")===0)return querySelectorAllExt(e,t.slice(7),!0);e=resolveTarget(e);const r=[];{let s=0,a=0;for(let l=0;l<t.length;l++){const c=t[l];if(c===","&&s===0){r.push(t.substring(a,l)),a=l+1;continue}c==="<"?s++:c==="/"&&l<t.length-1&&t[l+1]===">"&&s--}a<t.length&&r.push(t.substring(a))}const i=[],o=[];for(;r.length>0;){const s=normalizeSelector(r.shift());let a;s.indexOf("closest ")===0?a=closest(asElement(e),normalizeSelector(s.slice(8))):s.indexOf("find ")===0?a=find(asParentNode(e),normalizeSelector(s.slice(5))):s==="next"||s==="nextElementSibling"?a=asElement(e).nextElementSibling:s.indexOf("next ")===0?a=scanForwardQuery(e,normalizeSelector(s.slice(5)),!!n):s==="previous"||s==="previousElementSibling"?a=asElement(e).previousElementSibling:s.indexOf("previous ")===0?a=scanBackwardsQuery(e,normalizeSelector(s.slice(9)),!!n):s==="document"?a=document:s==="window"?a=window:s==="body"?a=document.body:s==="root"?a=getRootNode(e,!!n):s==="host"?a=e.getRootNode().host:o.push(s),a&&i.push(a)}if(o.length>0){const s=o.join(","),a=asParentNode(getRootNode(e,!!n));i.push(...toArray(a.querySelectorAll(s)))}return i}var scanForwardQuery=function(e,t,n){const r=asParentNode(getRootNode(e,n)).querySelectorAll(t);for(let i=0;i<r.length;i++){const o=r[i];if(o.compareDocumentPosition(e)===Node.DOCUMENT_POSITION_PRECEDING)return o}},scanBackwardsQuery=function(e,t,n){const r=asParentNode(getRootNode(e,n)).querySelectorAll(t);for(let i=r.length-1;i>=0;i--){const o=r[i];if(o.compareDocumentPosition(e)===Node.DOCUMENT_POSITION_FOLLOWING)return o}};function querySelectorExt(e,t){return typeof e!="string"?querySelectorAllExt(e,t)[0]:querySelectorAllExt(getDocument().body,e)[0]}function resolveTarget(e,t){return typeof e=="string"?find(asParentNode(t)||document,e):e}function processEventArgs(e,t,n,r){return isFunction(t)?{target:getDocument().body,event:asString(e),listener:t,options:n}:{target:resolveTarget(e),event:asString(t),listener:n,options:r}}function addEventListenerImpl(e,t,n,r){return ready(function(){const o=processEventArgs(e,t,n,r);o.target.addEventListener(o.event,o.listener,o.options)}),isFunction(t)?t:n}function removeEventListenerImpl(e,t,n){return ready(function(){const r=processEventArgs(e,t,n);r.target.removeEventListener(r.event,r.listener)}),isFunction(t)?t:n}const DUMMY_ELT=getDocument().createElement("output");function findAttributeTargets(e,t){const n=getClosestAttributeValue(e,t);if(n){if(n==="this")return[findThisElement(e,t)];{const r=querySelectorAllExt(e,n);if(/(^|,)(\s*)inherit(\s*)($|,)/.test(n)){const o=asElement(getClosestMatch(e,function(s){return s!==e&&hasAttribute(asElement(s),t)}));o&&r.push(...findAttributeTargets(o,t))}return r.length===0?(logError('The selector "'+n+'" on '+t+" returned no matches!"),[DUMMY_ELT]):r}}}function findThisElement(e,t){return asElement(getClosestMatch(e,function(n){return getAttributeValue(asElement(n),t)!=null}))}function getTarget(e){const t=getClosestAttributeValue(e,"hx-target");return t?t==="this"?findThisElement(e,"hx-target"):querySelectorExt(e,t):getInternalData(e).boosted?getDocument().body:e}function shouldSettleAttribute(e){return htmx.config.attributesToSettle.includes(e)}function cloneAttributes(e,t){forEach(Array.from(e.attributes),function(n){!t.hasAttribute(n.name)&&shouldSettleAttribute(n.name)&&e.removeAttribute(n.name)}),forEach(t.attributes,function(n){shouldSettleAttribute(n.name)&&e.setAttribute(n.name,n.value)})}function isInlineSwap(e,t){const n=getExtensions(t);for(let r=0;r<n.length;r++){const i=n[r];try{if(i.isInlineSwap(e))return!0}catch(o){logError(o)}}return e==="outerHTML"}function oobSwap(e,t,n,r){r=r||getDocument();let i="#"+CSS.escape(getRawAttribute(t,"id")),o="outerHTML";e==="true"||(e.indexOf(":")>0?(o=e.substring(0,e.indexOf(":")),i=e.substring(e.indexOf(":")+1)):o=e),t.removeAttribute("hx-swap-oob"),t.removeAttribute("data-hx-swap-oob");const s=querySelectorAllExt(r,i,!1);return s.length?(forEach(s,function(a){let l;const c=t.cloneNode(!0);l=getDocument().createDocumentFragment(),l.appendChild(c),isInlineSwap(o,a)||(l=asParentNode(c));const u={shouldSwap:!0,target:a,fragment:l};triggerEvent(a,"htmx:oobBeforeSwap",u)&&(a=u.target,u.shouldSwap&&(handlePreservedElements(l),swapWithStyle(o,a,a,l,n),restorePreservedElements()),forEach(n.elts,function(f){triggerEvent(f,"htmx:oobAfterSwap",u)}))}),t.parentNode.removeChild(t)):(t.parentNode.removeChild(t),triggerErrorEvent(getDocument().body,"htmx:oobErrorNoTarget",{content:t})),e}function restorePreservedElements(){const e=find("#--htmx-preserve-pantry--");if(e){for(const t of[...e.children]){const n=find("#"+t.id);n.parentNode.moveBefore(t,n),n.remove()}e.remove()}}function handlePreservedElements(e){forEach(findAll(e,"[hx-preserve], [data-hx-preserve]"),function(t){const n=getAttributeValue(t,"id"),r=getDocument().getElementById(n);if(r!=null)if(t.moveBefore){let i=find("#--htmx-preserve-pantry--");i==null&&(getDocument().body.insertAdjacentHTML("afterend","<div id='--htmx-preserve-pantry--'></div>"),i=find("#--htmx-preserve-pantry--")),i.moveBefore(r,null)}else t.parentNode.replaceChild(r,t)})}function handleAttributes(e,t,n){forEach(t.querySelectorAll("[id]"),function(r){const i=getRawAttribute(r,"id");if(i&&i.length>0){const o=i.replace("'","\\'"),s=r.tagName.replace(":","\\:"),a=asParentNode(e),l=a&&a.querySelector(s+"[id='"+o+"']");if(l&&l!==a){const c=r.cloneNode();cloneAttributes(r,l),n.tasks.push(function(){cloneAttributes(r,c)})}}})}function makeAjaxLoadTask(e){return function(){removeClassFromElement(e,htmx.config.addedClass),processNode(asElement(e)),processFocus(asParentNode(e)),triggerEvent(e,"htmx:load")}}function processFocus(e){const t="[autofocus]",n=asHtmlElement(matches(e,t)?e:e.querySelector(t));n!=null&&n.focus()}function insertNodesBefore(e,t,n,r){for(handleAttributes(e,n,r);n.childNodes.length>0;){const i=n.firstChild;addClassToElement(asElement(i),htmx.config.addedClass),e.insertBefore(i,t),i.nodeType!==Node.TEXT_NODE&&i.nodeType!==Node.COMMENT_NODE&&r.tasks.push(makeAjaxLoadTask(i))}}function stringHash(e,t){let n=0;for(;n<e.length;)t=(t<<5)-t+e.charCodeAt(n++)|0;return t}function attributeHash(e){let t=0;for(let n=0;n<e.attributes.length;n++){const r=e.attributes[n];r.value&&(t=stringHash(r.name,t),t=stringHash(r.value,t))}return t}function deInitOnHandlers(e){const t=getInternalData(e);if(t.onHandlers){for(let n=0;n<t.onHandlers.length;n++){const r=t.onHandlers[n];removeEventListenerImpl(e,r.event,r.listener)}delete t.onHandlers}}function deInitNode(e){const t=getInternalData(e);t.timeout&&clearTimeout(t.timeout),t.listenerInfos&&forEach(t.listenerInfos,function(n){n.on&&removeEventListenerImpl(n.on,n.trigger,n.listener)}),deInitOnHandlers(e),forEach(Object.keys(t),function(n){n!=="firstInitCompleted"&&delete t[n]})}function cleanUpElement(e){triggerEvent(e,"htmx:beforeCleanupElement"),deInitNode(e),forEach(e.children,function(t){cleanUpElement(t)})}function swapOuterHTML(e,t,n){if(e.tagName==="BODY")return swapInnerHTML(e,t,n);let r;const i=e.previousSibling,o=parentElt(e);if(o){for(insertNodesBefore(o,e,t,n),i==null?r=o.firstChild:r=i.nextSibling,n.elts=n.elts.filter(function(s){return s!==e});r&&r!==e;)r instanceof Element&&n.elts.push(r),r=r.nextSibling;cleanUpElement(e),e.remove()}}function swapAfterBegin(e,t,n){return insertNodesBefore(e,e.firstChild,t,n)}function swapBeforeBegin(e,t,n){return insertNodesBefore(parentElt(e),e,t,n)}function swapBeforeEnd(e,t,n){return insertNodesBefore(e,null,t,n)}function swapAfterEnd(e,t,n){return insertNodesBefore(parentElt(e),e.nextSibling,t,n)}function swapDelete(e){cleanUpElement(e);const t=parentElt(e);if(t)return t.removeChild(e)}function swapInnerHTML(e,t,n){const r=e.firstChild;if(insertNodesBefore(e,r,t,n),r){for(;r.nextSibling;)cleanUpElement(r.nextSibling),e.removeChild(r.nextSibling);cleanUpElement(r),e.removeChild(r)}}function swapWithStyle(e,t,n,r,i){switch(e){case"none":return;case"outerHTML":swapOuterHTML(n,r,i);return;case"afterbegin":swapAfterBegin(n,r,i);return;case"beforebegin":swapBeforeBegin(n,r,i);return;case"beforeend":swapBeforeEnd(n,r,i);return;case"afterend":swapAfterEnd(n,r,i);return;case"delete":swapDelete(n);return;default:var o=getExtensions(t);for(let s=0;s<o.length;s++){const a=o[s];try{const l=a.handleSwap(e,n,r,i);if(l){if(Array.isArray(l))for(let c=0;c<l.length;c++){const u=l[c];u.nodeType!==Node.TEXT_NODE&&u.nodeType!==Node.COMMENT_NODE&&i.tasks.push(makeAjaxLoadTask(u))}return}}catch(l){logError(l)}}e==="innerHTML"?swapInnerHTML(n,r,i):swapWithStyle(htmx.config.defaultSwapStyle,t,n,r,i)}}function findAndSwapOobElements(e,t,n){var r=findAll(e,"[hx-swap-oob], [data-hx-swap-oob]");return forEach(r,function(i){if(htmx.config.allowNestedOobSwaps||i.parentElement===null){const o=getAttributeValue(i,"hx-swap-oob");o!=null&&oobSwap(o,i,t,n)}else i.removeAttribute("hx-swap-oob"),i.removeAttribute("data-hx-swap-oob")}),r.length>0}function swap(e,t,n,r){r||(r={});let i=null,o=null,s=function(){maybeCall(r.beforeSwapCallback),e=resolveTarget(e);const c=r.contextElement?getRootNode(r.contextElement,!1):getDocument(),u=document.activeElement;let f={};f={elt:u,start:u?u.selectionStart:null,end:u?u.selectionEnd:null};const d=makeSettleInfo(e);if(n.swapStyle==="textContent")e.textContent=t;else{let g=makeFragment(t);if(d.title=r.title||g.title,r.historyRequest&&(g=g.querySelector("[hx-history-elt],[data-hx-history-elt]")||g),r.selectOOB){const v=r.selectOOB.split(",");for(let h=0;h<v.length;h++){const m=v[h].split(":",2);let y=m[0].trim();y.indexOf("#")===0&&(y=y.substring(1));const E=m[1]||"true",b=g.querySelector("#"+y);b&&oobSwap(E,b,d,c)}}if(findAndSwapOobElements(g,d,c),forEach(findAll(g,"template"),function(v){v.content&&findAndSwapOobElements(v.content,d,c)&&v.remove()}),r.select){const v=getDocument().createDocumentFragment();forEach(g.querySelectorAll(r.select),function(h){v.appendChild(h)}),g=v}handlePreservedElements(g),swapWithStyle(n.swapStyle,r.contextElement,e,g,d),restorePreservedElements()}if(f.elt&&!bodyContains(f.elt)&&getRawAttribute(f.elt,"id")){const g=document.getElementById(getRawAttribute(f.elt,"id")),v={preventScroll:n.focusScroll!==void 0?!n.focusScroll:!htmx.config.defaultFocusScroll};if(g){if(f.start&&g.setSelectionRange)try{g.setSelectionRange(f.start,f.end)}catch{}g.focus(v)}}e.classList.remove(htmx.config.swappingClass),forEach(d.elts,function(g){g.classList&&g.classList.add(htmx.config.settlingClass),triggerEvent(g,"htmx:afterSwap",r.eventInfo)}),maybeCall(r.afterSwapCallback),n.ignoreTitle||handleTitle(d.title);const p=function(){if(forEach(d.tasks,function(g){g.call()}),forEach(d.elts,function(g){g.classList&&g.classList.remove(htmx.config.settlingClass),triggerEvent(g,"htmx:afterSettle",r.eventInfo)}),r.anchor){const g=asElement(resolveTarget("#"+r.anchor));g&&g.scrollIntoView({block:"start",behavior:"auto"})}updateScrollState(d.elts,n),maybeCall(r.afterSettleCallback),maybeCall(i)};n.settleDelay>0?getWindow().setTimeout(p,n.settleDelay):p()},a=htmx.config.globalViewTransitions;n.hasOwnProperty("transition")&&(a=n.transition);const l=r.contextElement||getDocument();if(a&&triggerEvent(l,"htmx:beforeTransition",r.eventInfo)&&typeof Promise<"u"&&document.startViewTransition){const c=new Promise(function(f,d){i=f,o=d}),u=s;s=function(){document.startViewTransition(function(){return u(),c})}}try{n!=null&&n.swapDelay&&n.swapDelay>0?getWindow().setTimeout(s,n.swapDelay):s()}catch(c){throw triggerErrorEvent(l,"htmx:swapError",r.eventInfo),maybeCall(o),c}}function handleTriggerHeader(e,t,n){const r=e.getResponseHeader(t);if(r.indexOf("{")===0){const i=parseJSON(r);for(const o in i)if(i.hasOwnProperty(o)){let s=i[o];isRawObject(s)?n=s.target!==void 0?s.target:n:s={value:s},triggerEvent(n,o,s)}}else{const i=r.split(",");for(let o=0;o<i.length;o++)triggerEvent(n,i[o].trim(),[])}}const WHITESPACE_OR_COMMA=/[\s,]/,SYMBOL_START=/[_$a-zA-Z]/,SYMBOL_CONT=/[_$a-zA-Z0-9]/,STRINGISH_START=['"',"'","/"],NOT_WHITESPACE=/[^\s]/,COMBINED_SELECTOR_START=/[{(]/,COMBINED_SELECTOR_END=/[})]/;function tokenizeString(e){const t=[];let n=0;for(;n<e.length;){if(SYMBOL_START.exec(e.charAt(n))){for(var r=n;SYMBOL_CONT.exec(e.charAt(n+1));)n++;t.push(e.substring(r,n+1))}else if(STRINGISH_START.indexOf(e.charAt(n))!==-1){const i=e.charAt(n);var r=n;for(n++;n<e.length&&e.charAt(n)!==i;)e.charAt(n)==="\\"&&n++,n++;t.push(e.substring(r,n+1))}else{const i=e.charAt(n);t.push(i)}n++}return t}function isPossibleRelativeReference(e,t,n){return SYMBOL_START.exec(e.charAt(0))&&e!=="true"&&e!=="false"&&e!=="this"&&e!==n&&t!=="."}function maybeGenerateConditional(e,t,n){if(t[0]==="["){t.shift();let r=1,i=" return (function("+n+"){ return (",o=null;for(;t.length>0;){const s=t[0];if(s==="]"){if(r--,r===0){o===null&&(i=i+"true"),t.shift(),i+=")})";try{const a=maybeEval(e,function(){return Function(i)()},function(){return!0});return a.source=i,a}catch(a){return triggerErrorEvent(getDocument().body,"htmx:syntax:error",{error:a,source:i}),null}}}else s==="["&&r++;isPossibleRelativeReference(s,o,n)?i+="(("+n+"."+s+") ? ("+n+"."+s+") : (window."+s+"))":i=i+s,o=t.shift()}}}function consumeUntil(e,t){let n="";for(;e.length>0&&!t.test(e[0]);)n+=e.shift();return n}function consumeCSSSelector(e){let t;return e.length>0&&COMBINED_SELECTOR_START.test(e[0])?(e.shift(),t=consumeUntil(e,COMBINED_SELECTOR_END).trim(),e.shift()):t=consumeUntil(e,WHITESPACE_OR_COMMA),t}const INPUT_SELECTOR="input, textarea, select";function parseAndCacheTrigger(e,t,n){const r=[],i=tokenizeString(t);do{consumeUntil(i,NOT_WHITESPACE);const a=i.length,l=consumeUntil(i,/[,\[\s]/);if(l!=="")if(l==="every"){const c={trigger:"every"};consumeUntil(i,NOT_WHITESPACE),c.pollInterval=parseInterval(consumeUntil(i,/[,\[\s]/)),consumeUntil(i,NOT_WHITESPACE);var o=maybeGenerateConditional(e,i,"event");o&&(c.eventFilter=o),r.push(c)}else{const c={trigger:l};var o=maybeGenerateConditional(e,i,"event");for(o&&(c.eventFilter=o),consumeUntil(i,NOT_WHITESPACE);i.length>0&&i[0]!==",";){const f=i.shift();if(f==="changed")c.changed=!0;else if(f==="once")c.once=!0;else if(f==="consume")c.consume=!0;else if(f==="delay"&&i[0]===":")i.shift(),c.delay=parseInterval(consumeUntil(i,WHITESPACE_OR_COMMA));else if(f==="from"&&i[0]===":"){if(i.shift(),COMBINED_SELECTOR_START.test(i[0]))var s=consumeCSSSelector(i);else{var s=consumeUntil(i,WHITESPACE_OR_COMMA);if(s==="closest"||s==="find"||s==="next"||s==="previous"){i.shift();const p=consumeCSSSelector(i);p.length>0&&(s+=" "+p)}}c.from=s}else f==="target"&&i[0]===":"?(i.shift(),c.target=consumeCSSSelector(i)):f==="throttle"&&i[0]===":"?(i.shift(),c.throttle=parseInterval(consumeUntil(i,WHITESPACE_OR_COMMA))):f==="queue"&&i[0]===":"?(i.shift(),c.queue=consumeUntil(i,WHITESPACE_OR_COMMA)):f==="root"&&i[0]===":"?(i.shift(),c[f]=consumeCSSSelector(i)):f==="threshold"&&i[0]===":"?(i.shift(),c[f]=consumeUntil(i,WHITESPACE_OR_COMMA)):triggerErrorEvent(e,"htmx:syntax:error",{token:i.shift()});consumeUntil(i,NOT_WHITESPACE)}r.push(c)}i.length===a&&triggerErrorEvent(e,"htmx:syntax:error",{token:i.shift()}),consumeUntil(i,NOT_WHITESPACE)}while(i[0]===","&&i.shift());return n&&(n[t]=r),r}function getTriggerSpecs(e){const t=getAttributeValue(e,"hx-trigger");let n=[];if(t){const r=htmx.config.triggerSpecsCache;n=r&&r[t]||parseAndCacheTrigger(e,t,r)}return n.length>0?n:matches(e,"form")?[{trigger:"submit"}]:matches(e,'input[type="button"], input[type="submit"]')?[{trigger:"click"}]:matches(e,INPUT_SELECTOR)?[{trigger:"change"}]:[{trigger:"click"}]}function cancelPolling(e){getInternalData(e).cancelled=!0}function processPolling(e,t,n){const r=getInternalData(e);r.timeout=getWindow().setTimeout(function(){bodyContains(e)&&r.cancelled!==!0&&(maybeFilterEvent(n,e,makeEvent("hx:poll:trigger",{triggerSpec:n,target:e}))||t(e),processPolling(e,t,n))},n.pollInterval)}function isLocalLink(e){return location.hostname===e.hostname&&getRawAttribute(e,"href")&&getRawAttribute(e,"href").indexOf("#")!==0}function eltIsDisabled(e){return closest(e,htmx.config.disableSelector)}function boostElement(e,t,n){if(e instanceof HTMLAnchorElement&&isLocalLink(e)&&(e.target===""||e.target==="_self")||e.tagName==="FORM"&&String(getRawAttribute(e,"method")).toLowerCase()!=="dialog"){t.boosted=!0;let r,i;if(e.tagName==="A")r="get",i=getRawAttribute(e,"href");else{const o=getRawAttribute(e,"method");r=o?o.toLowerCase():"get",i=getRawAttribute(e,"action"),(i==null||i==="")&&(i=location.href),r==="get"&&i.includes("?")&&(i=i.replace(/\?[^#]+/,""))}n.forEach(function(o){addEventListener(e,function(s,a){const l=asElement(s);if(eltIsDisabled(l)){cleanUpElement(l);return}issueAjaxRequest(r,i,l,a)},t,o,!0)})}}function shouldCancel(e,t){if(e.type==="submit"&&t.tagName==="FORM")return!0;if(e.type==="click"){const n=t.closest('input[type="submit"], button');if(n&&n.form&&n.type==="submit")return!0;const r=t.closest("a"),i=/^#.+/;if(r&&r.href&&!i.test(r.getAttribute("href")))return!0}return!1}function ignoreBoostedAnchorCtrlClick(e,t){return getInternalData(e).boosted&&e instanceof HTMLAnchorElement&&t.type==="click"&&(t.ctrlKey||t.metaKey)}function maybeFilterEvent(e,t,n){const r=e.eventFilter;if(r)try{return r.call(t,n)!==!0}catch(i){const o=r.source;return triggerErrorEvent(getDocument().body,"htmx:eventFilter:error",{error:i,source:o}),!0}return!1}function addEventListener(e,t,n,r,i){const o=getInternalData(e);let s;r.from?s=querySelectorAllExt(e,r.from):s=[e],r.changed&&("lastValue"in o||(o.lastValue=new WeakMap),s.forEach(function(a){o.lastValue.has(r)||o.lastValue.set(r,new WeakMap),o.lastValue.get(r).set(a,a.value)})),forEach(s,function(a){const l=function(c){if(!bodyContains(e)){a.removeEventListener(r.trigger,l);return}if(ignoreBoostedAnchorCtrlClick(e,c)||((i||shouldCancel(c,a))&&c.preventDefault(),maybeFilterEvent(r,e,c)))return;const u=getInternalData(c);if(u.triggerSpec=r,u.handledFor==null&&(u.handledFor=[]),u.handledFor.indexOf(e)<0){if(u.handledFor.push(e),r.consume&&c.stopPropagation(),r.target&&c.target&&!matches(asElement(c.target),r.target))return;if(r.once){if(o.triggeredOnce)return;o.triggeredOnce=!0}if(r.changed){const f=c.target,d=f.value,p=o.lastValue.get(r);if(p.has(f)&&p.get(f)===d)return;p.set(f,d)}if(o.delayed&&clearTimeout(o.delayed),o.throttle)return;r.throttle>0?o.throttle||(triggerEvent(e,"htmx:trigger"),t(e,c),o.throttle=getWindow().setTimeout(function(){o.throttle=null},r.throttle)):r.delay>0?o.delayed=getWindow().setTimeout(function(){triggerEvent(e,"htmx:trigger"),t(e,c)},r.delay):(triggerEvent(e,"htmx:trigger"),t(e,c))}};n.listenerInfos==null&&(n.listenerInfos=[]),n.listenerInfos.push({trigger:r.trigger,listener:l,on:a}),a.addEventListener(r.trigger,l)})}let windowIsScrolling=!1,scrollHandler=null;function initScrollHandler(){scrollHandler||(scrollHandler=function(){windowIsScrolling=!0},window.addEventListener("scroll",scrollHandler),window.addEventListener("resize",scrollHandler),setInterval(function(){windowIsScrolling&&(windowIsScrolling=!1,forEach(getDocument().querySelectorAll("[hx-trigger*='revealed'],[data-hx-trigger*='revealed']"),function(e){maybeReveal(e)}))},200))}function maybeReveal(e){!hasAttribute(e,"data-hx-revealed")&&isScrolledIntoView(e)&&(e.setAttribute("data-hx-revealed","true"),getInternalData(e).initHash?triggerEvent(e,"revealed"):e.addEventListener("htmx:afterProcessNode",function(){triggerEvent(e,"revealed")},{once:!0}))}function loadImmediately(e,t,n,r){const i=function(){n.loaded||(n.loaded=!0,triggerEvent(e,"htmx:trigger"),t(e))};r>0?getWindow().setTimeout(i,r):i()}function processVerbs(e,t,n){let r=!1;return forEach(VERBS,function(i){if(hasAttribute(e,"hx-"+i)){const o=getAttributeValue(e,"hx-"+i);r=!0,t.path=o,t.verb=i,n.forEach(function(s){addTriggerHandler(e,s,t,function(a,l){const c=asElement(a);if(eltIsDisabled(c)){cleanUpElement(c);return}issueAjaxRequest(i,o,c,l)})})}}),r}function addTriggerHandler(e,t,n,r){if(t.trigger==="revealed")initScrollHandler(),addEventListener(e,r,n,t),maybeReveal(asElement(e));else if(t.trigger==="intersect"){const i={};t.root&&(i.root=querySelectorExt(e,t.root)),t.threshold&&(i.threshold=parseFloat(t.threshold)),new IntersectionObserver(function(s){for(let a=0;a<s.length;a++)if(s[a].isIntersecting){triggerEvent(e,"intersect");break}},i).observe(asElement(e)),addEventListener(asElement(e),r,n,t)}else!n.firstInitCompleted&&t.trigger==="load"?maybeFilterEvent(t,e,makeEvent("load",{elt:e}))||loadImmediately(asElement(e),r,n,t.delay):t.pollInterval>0?(n.polling=!0,processPolling(asElement(e),r,t)):addEventListener(e,r,n,t)}function shouldProcessHxOn(e){const t=asElement(e);if(!t)return!1;const n=t.attributes;for(let r=0;r<n.length;r++){const i=n[r].name;if(startsWith(i,"hx-on:")||startsWith(i,"data-hx-on:")||startsWith(i,"hx-on-")||startsWith(i,"data-hx-on-"))return!0}return!1}const HX_ON_QUERY=new XPathEvaluator().createExpression('.//*[@*[ starts-with(name(), "hx-on:") or starts-with(name(), "data-hx-on:") or starts-with(name(), "hx-on-") or starts-with(name(), "data-hx-on-") ]]');function processHXOnRoot(e,t){shouldProcessHxOn(e)&&t.push(asElement(e));const n=HX_ON_QUERY.evaluate(e);let r=null;for(;r=n.iterateNext();)t.push(asElement(r))}function findHxOnWildcardElements(e){const t=[];if(e instanceof DocumentFragment)for(const n of e.childNodes)processHXOnRoot(n,t);else processHXOnRoot(e,t);return t}function findElementsToProcess(e){if(e.querySelectorAll){const n=", [hx-boost] a, [data-hx-boost] a, a[hx-boost], a[data-hx-boost]",r=[];for(const o in extensions){const s=extensions[o];if(s.getSelectors){var t=s.getSelectors();t&&r.push(t)}}return e.querySelectorAll(VERB_SELECTOR+n+", form, [type='submit'], [hx-ext], [data-hx-ext], [hx-trigger], [data-hx-trigger]"+r.flat().map(o=>", "+o).join(""))}else return[]}function maybeSetLastButtonClicked(e){const t=getTargetButton(e.target),n=getRelatedFormData(e);n&&(n.lastButtonClicked=t)}function maybeUnsetLastButtonClicked(e){const t=getRelatedFormData(e);t&&(t.lastButtonClicked=null)}function getTargetButton(e){return closest(asElement(e),"button, input[type='submit']")}function getRelatedForm(e){return e.form||closest(e,"form")}function getRelatedFormData(e){const t=getTargetButton(e.target);if(!t)return;const n=getRelatedForm(t);if(n)return getInternalData(n)}function initButtonTracking(e){e.addEventListener("click",maybeSetLastButtonClicked),e.addEventListener("focusin",maybeSetLastButtonClicked),e.addEventListener("focusout",maybeUnsetLastButtonClicked)}function addHxOnEventHandler(e,t,n){const r=getInternalData(e);Array.isArray(r.onHandlers)||(r.onHandlers=[]);let i;const o=function(s){maybeEval(e,function(){eltIsDisabled(e)||(i||(i=new Function("event",n)),i.call(e,s))})};e.addEventListener(t,o),r.onHandlers.push({event:t,listener:o})}function processHxOnWildcard(e){deInitOnHandlers(e);for(let t=0;t<e.attributes.length;t++){const n=e.attributes[t].name,r=e.attributes[t].value;if(startsWith(n,"hx-on")||startsWith(n,"data-hx-on")){const i=n.indexOf("-on")+3,o=n.slice(i,i+1);if(o==="-"||o===":"){let s=n.slice(i+1);startsWith(s,":")?s="htmx"+s:startsWith(s,"-")?s="htmx:"+s.slice(1):startsWith(s,"htmx-")&&(s="htmx:"+s.slice(5)),addHxOnEventHandler(e,s,r)}}}}function initNode(e){triggerEvent(e,"htmx:beforeProcessNode");const t=getInternalData(e),n=getTriggerSpecs(e);processVerbs(e,t,n)||(getClosestAttributeValue(e,"hx-boost")==="true"?boostElement(e,t,n):hasAttribute(e,"hx-trigger")&&n.forEach(function(i){addTriggerHandler(e,i,t,function(){})})),(e.tagName==="FORM"||getRawAttribute(e,"type")==="submit"&&hasAttribute(e,"form"))&&initButtonTracking(e),t.firstInitCompleted=!0,triggerEvent(e,"htmx:afterProcessNode")}function maybeDeInitAndHash(e){if(!(e instanceof Element))return!1;const t=getInternalData(e),n=attributeHash(e);return t.initHash!==n?(deInitNode(e),t.initHash=n,!0):!1}function processNode(e){if(e=resolveTarget(e),eltIsDisabled(e)){cleanUpElement(e);return}const t=[];maybeDeInitAndHash(e)&&t.push(e),forEach(findElementsToProcess(e),function(n){if(eltIsDisabled(n)){cleanUpElement(n);return}maybeDeInitAndHash(n)&&t.push(n)}),forEach(findHxOnWildcardElements(e),processHxOnWildcard),forEach(t,initNode)}function kebabEventName(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function makeEvent(e,t){return new CustomEvent(e,{bubbles:!0,cancelable:!0,composed:!0,detail:t})}function triggerErrorEvent(e,t,n){triggerEvent(e,t,mergeObjects({error:t},n))}function ignoreEventForLogging(e){return e==="htmx:afterProcessNode"}function withExtensions(e,t,n){forEach(getExtensions(e,[],n),function(r){try{t(r)}catch(i){logError(i)}})}function logError(e){console.error(e)}function triggerEvent(e,t,n){e=resolveTarget(e),n==null&&(n={}),n.elt=e;const r=makeEvent(t,n);htmx.logger&&!ignoreEventForLogging(t)&&htmx.logger(e,t,n),n.error&&(logError(n.error),triggerEvent(e,"htmx:error",{errorInfo:n}));let i=e.dispatchEvent(r);const o=kebabEventName(t);if(i&&o!==t){const s=makeEvent(o,r.detail);i=i&&e.dispatchEvent(s)}return withExtensions(asElement(e),function(s){i=i&&s.onEvent(t,r)!==!1&&!r.defaultPrevented}),i}let currentPathForHistory;function setCurrentPathForHistory(e){currentPathForHistory=e,canAccessLocalStorage()&&sessionStorage.setItem("htmx-current-path-for-history",e)}setCurrentPathForHistory(location.pathname+location.search);function getHistoryElement(){return getDocument().querySelector("[hx-history-elt],[data-hx-history-elt]")||getDocument().body}function saveToHistoryCache(e,t){if(!canAccessLocalStorage())return;const n=cleanInnerHtmlForHistory(t),r=getDocument().title,i=window.scrollY;if(htmx.config.historyCacheSize<=0){sessionStorage.removeItem("htmx-history-cache");return}e=normalizePath(e);const o=parseJSON(sessionStorage.getItem("htmx-history-cache"))||[];for(let a=0;a<o.length;a++)if(o[a].url===e){o.splice(a,1);break}const s={url:e,content:n,title:r,scroll:i};for(triggerEvent(getDocument().body,"htmx:historyItemCreated",{item:s,cache:o}),o.push(s);o.length>htmx.config.historyCacheSize;)o.shift();for(;o.length>0;)try{sessionStorage.setItem("htmx-history-cache",JSON.stringify(o));break}catch(a){triggerErrorEvent(getDocument().body,"htmx:historyCacheError",{cause:a,cache:o}),o.shift()}}function getCachedHistory(e){if(!canAccessLocalStorage())return null;e=normalizePath(e);const t=parseJSON(sessionStorage.getItem("htmx-history-cache"))||[];for(let n=0;n<t.length;n++)if(t[n].url===e)return t[n];return null}function cleanInnerHtmlForHistory(e){const t=htmx.config.requestClass,n=e.cloneNode(!0);return forEach(findAll(n,"."+t),function(r){removeClassFromElement(r,t)}),forEach(findAll(n,"[data-disabled-by-htmx]"),function(r){r.removeAttribute("disabled")}),n.innerHTML}function saveCurrentPageToHistory(){const e=getHistoryElement();let t=currentPathForHistory;canAccessLocalStorage()&&(t=sessionStorage.getItem("htmx-current-path-for-history")),t=t||location.pathname+location.search,getDocument().querySelector('[hx-history="false" i],[data-hx-history="false" i]')||(triggerEvent(getDocument().body,"htmx:beforeHistorySave",{path:t,historyElt:e}),saveToHistoryCache(t,e)),htmx.config.historyEnabled&&history.replaceState({htmx:!0},getDocument().title,location.href)}function pushUrlIntoHistory(e){htmx.config.getCacheBusterParam&&(e=e.replace(/org\.htmx\.cache-buster=[^&]*&?/,""),(endsWith(e,"&")||endsWith(e,"?"))&&(e=e.slice(0,-1))),htmx.config.historyEnabled&&history.pushState({htmx:!0},"",e),setCurrentPathForHistory(e)}function replaceUrlInHistory(e){htmx.config.historyEnabled&&history.replaceState({htmx:!0},"",e),setCurrentPathForHistory(e)}function settleImmediately(e){forEach(e,function(t){t.call(void 0)})}function loadHistoryFromServer(e){const t=new XMLHttpRequest,n={swapStyle:"innerHTML",swapDelay:0,settleDelay:0},r={path:e,xhr:t,historyElt:getHistoryElement(),swapSpec:n};t.open("GET",e,!0),htmx.config.historyRestoreAsHxRequest&&t.setRequestHeader("HX-Request","true"),t.setRequestHeader("HX-History-Restore-Request","true"),t.setRequestHeader("HX-Current-URL",location.href),t.onload=function(){this.status>=200&&this.status<400?(r.response=this.response,triggerEvent(getDocument().body,"htmx:historyCacheMissLoad",r),swap(r.historyElt,r.response,n,{contextElement:r.historyElt,historyRequest:!0}),setCurrentPathForHistory(r.path),triggerEvent(getDocument().body,"htmx:historyRestore",{path:e,cacheMiss:!0,serverResponse:r.response})):triggerErrorEvent(getDocument().body,"htmx:historyCacheMissLoadError",r)},triggerEvent(getDocument().body,"htmx:historyCacheMiss",r)&&t.send()}function restoreHistory(e){saveCurrentPageToHistory(),e=e||location.pathname+location.search;const t=getCachedHistory(e);if(t){const n={swapStyle:"innerHTML",swapDelay:0,settleDelay:0,scroll:t.scroll},r={path:e,item:t,historyElt:getHistoryElement(),swapSpec:n};triggerEvent(getDocument().body,"htmx:historyCacheHit",r)&&(swap(r.historyElt,t.content,n,{contextElement:r.historyElt,title:t.title}),setCurrentPathForHistory(r.path),triggerEvent(getDocument().body,"htmx:historyRestore",r))}else htmx.config.refreshOnHistoryMiss?htmx.location.reload(!0):loadHistoryFromServer(e)}function addRequestIndicatorClasses(e){let t=findAttributeTargets(e,"hx-indicator");return t==null&&(t=[e]),forEach(t,function(n){const r=getInternalData(n);r.requestCount=(r.requestCount||0)+1,n.classList.add.call(n.classList,htmx.config.requestClass)}),t}function disableElements(e){let t=findAttributeTargets(e,"hx-disabled-elt");return t==null&&(t=[]),forEach(t,function(n){const r=getInternalData(n);r.requestCount=(r.requestCount||0)+1,n.setAttribute("disabled",""),n.setAttribute("data-disabled-by-htmx","")}),t}function removeRequestIndicators(e,t){forEach(e.concat(t),function(n){const r=getInternalData(n);r.requestCount=(r.requestCount||1)-1}),forEach(e,function(n){getInternalData(n).requestCount===0&&n.classList.remove.call(n.classList,htmx.config.requestClass)}),forEach(t,function(n){getInternalData(n).requestCount===0&&(n.removeAttribute("disabled"),n.removeAttribute("data-disabled-by-htmx"))})}function haveSeenNode(e,t){for(let n=0;n<e.length;n++)if(e[n].isSameNode(t))return!0;return!1}function shouldInclude(e){const t=e;return t.name===""||t.name==null||t.disabled||closest(t,"fieldset[disabled]")||t.type==="button"||t.type==="submit"||t.tagName==="image"||t.tagName==="reset"||t.tagName==="file"?!1:t.type==="checkbox"||t.type==="radio"?t.checked:!0}function addValueToFormData(e,t,n){e!=null&&t!=null&&(Array.isArray(t)?t.forEach(function(r){n.append(e,r)}):n.append(e,t))}function removeValueFromFormData(e,t,n){if(e!=null&&t!=null){let r=n.getAll(e);Array.isArray(t)?r=r.filter(i=>t.indexOf(i)<0):r=r.filter(i=>i!==t),n.delete(e),forEach(r,i=>n.append(e,i))}}function getValueFromInput(e){return e instanceof HTMLSelectElement&&e.multiple?toArray(e.querySelectorAll("option:checked")).map(function(t){return t.value}):e instanceof HTMLInputElement&&e.files?toArray(e.files):e.value}function processInputValue(e,t,n,r,i){if(!(r==null||haveSeenNode(e,r))){if(e.push(r),shouldInclude(r)){const o=getRawAttribute(r,"name");addValueToFormData(o,getValueFromInput(r),t),i&&validateElement(r,n)}r instanceof HTMLFormElement&&(forEach(r.elements,function(o){e.indexOf(o)>=0?removeValueFromFormData(o.name,getValueFromInput(o),t):e.push(o),i&&validateElement(o,n)}),new FormData(r).forEach(function(o,s){o instanceof File&&o.name===""||addValueToFormData(s,o,t)}))}}function validateElement(e,t){const n=e;n.willValidate&&(triggerEvent(n,"htmx:validation:validate"),n.checkValidity()||(triggerEvent(n,"htmx:validation:failed",{message:n.validationMessage,validity:n.validity})&&!t.length&&htmx.config.reportValidityOfForms&&n.reportValidity(),t.push({elt:n,message:n.validationMessage,validity:n.validity})))}function overrideFormData(e,t){for(const n of t.keys())e.delete(n);return t.forEach(function(n,r){e.append(r,n)}),e}function getInputValues(e,t){const n=[],r=new FormData,i=new FormData,o=[],s=getInternalData(e);s.lastButtonClicked&&!bodyContains(s.lastButtonClicked)&&(s.lastButtonClicked=null);let a=e instanceof HTMLFormElement&&e.noValidate!==!0||getAttributeValue(e,"hx-validate")==="true";if(s.lastButtonClicked&&(a=a&&s.lastButtonClicked.formNoValidate!==!0),t!=="get"&&processInputValue(n,i,o,getRelatedForm(e),a),processInputValue(n,r,o,e,a),s.lastButtonClicked||e.tagName==="BUTTON"||e.tagName==="INPUT"&&getRawAttribute(e,"type")==="submit"){const c=s.lastButtonClicked||e,u=getRawAttribute(c,"name");addValueToFormData(u,c.value,i)}const l=findAttributeTargets(e,"hx-include");return forEach(l,function(c){processInputValue(n,r,o,asElement(c),a),matches(c,"form")||forEach(asParentNode(c).querySelectorAll(INPUT_SELECTOR),function(u){processInputValue(n,r,o,u,a)})}),overrideFormData(r,i),{errors:o,formData:r,values:formDataProxy(r)}}function appendParam(e,t,n){e!==""&&(e+="&"),String(n)==="[object Object]"&&(n=JSON.stringify(n));const r=encodeURIComponent(n);return e+=encodeURIComponent(t)+"="+r,e}function urlEncode(e){e=formDataFromObject(e);let t="";return e.forEach(function(n,r){t=appendParam(t,r,n)}),t}function getHeaders(e,t,n){const r={"HX-Request":"true","HX-Trigger":getRawAttribute(e,"id"),"HX-Trigger-Name":getRawAttribute(e,"name"),"HX-Target":getAttributeValue(t,"id"),"HX-Current-URL":location.href};return getValuesForElement(e,"hx-headers",!1,r),n!==void 0&&(r["HX-Prompt"]=n),getInternalData(e).boosted&&(r["HX-Boosted"]="true"),r}function filterValues(e,t){const n=getClosestAttributeValue(t,"hx-params");if(n){if(n==="none")return new FormData;if(n==="*")return e;if(n.indexOf("not ")===0)return forEach(n.slice(4).split(","),function(r){r=r.trim(),e.delete(r)}),e;{const r=new FormData;return forEach(n.split(","),function(i){i=i.trim(),e.has(i)&&e.getAll(i).forEach(function(o){r.append(i,o)})}),r}}else return e}function isAnchorLink(e){return!!getRawAttribute(e,"href")&&getRawAttribute(e,"href").indexOf("#")>=0}function getSwapSpecification(e,t){const n=t||getClosestAttributeValue(e,"hx-swap"),r={swapStyle:getInternalData(e).boosted?"innerHTML":htmx.config.defaultSwapStyle,swapDelay:htmx.config.defaultSwapDelay,settleDelay:htmx.config.defaultSettleDelay};if(htmx.config.scrollIntoViewOnBoost&&getInternalData(e).boosted&&!isAnchorLink(e)&&(r.show="top"),n){const s=splitOnWhitespace(n);if(s.length>0)for(let a=0;a<s.length;a++){const l=s[a];if(l.indexOf("swap:")===0)r.swapDelay=parseInterval(l.slice(5));else if(l.indexOf("settle:")===0)r.settleDelay=parseInterval(l.slice(7));else if(l.indexOf("transition:")===0)r.transition=l.slice(11)==="true";else if(l.indexOf("ignoreTitle:")===0)r.ignoreTitle=l.slice(12)==="true";else if(l.indexOf("scroll:")===0){var i=l.slice(7).split(":");const u=i.pop();var o=i.length>0?i.join(":"):null;r.scroll=u,r.scrollTarget=o}else if(l.indexOf("show:")===0){var i=l.slice(5).split(":");const f=i.pop();var o=i.length>0?i.join(":"):null;r.show=f,r.showTarget=o}else if(l.indexOf("focus-scroll:")===0){const c=l.slice(13);r.focusScroll=c=="true"}else a==0?r.swapStyle=l:logError("Unknown modifier in hx-swap: "+l)}}return r}function usesFormData(e){return getClosestAttributeValue(e,"hx-encoding")==="multipart/form-data"||matches(e,"form")&&getRawAttribute(e,"enctype")==="multipart/form-data"}function encodeParamsForBody(e,t,n){let r=null;return withExtensions(t,function(i){r==null&&(r=i.encodeParameters(e,n,t))}),r??(usesFormData(t)?overrideFormData(new FormData,formDataFromObject(n)):urlEncode(n))}function makeSettleInfo(e){return{tasks:[],elts:[e]}}function updateScrollState(e,t){const n=e[0],r=e[e.length-1];if(t.scroll){var i=null;t.scrollTarget&&(i=asElement(querySelectorExt(n,t.scrollTarget))),t.scroll==="top"&&(n||i)&&(i=i||n,i.scrollTop=0),t.scroll==="bottom"&&(r||i)&&(i=i||r,i.scrollTop=i.scrollHeight),typeof t.scroll=="number"&&getWindow().setTimeout(function(){window.scrollTo(0,t.scroll)},0)}if(t.show){var i=null;if(t.showTarget){let s=t.showTarget;t.showTarget==="window"&&(s="body"),i=asElement(querySelectorExt(n,s))}t.show==="top"&&(n||i)&&(i=i||n,i.scrollIntoView({block:"start",behavior:htmx.config.scrollBehavior})),t.show==="bottom"&&(r||i)&&(i=i||r,i.scrollIntoView({block:"end",behavior:htmx.config.scrollBehavior}))}}function getValuesForElement(e,t,n,r,i){if(r==null&&(r={}),e==null)return r;const o=getAttributeValue(e,t);if(o){let s=o.trim(),a=n;if(s==="unset")return null;s.indexOf("javascript:")===0?(s=s.slice(11),a=!0):s.indexOf("js:")===0&&(s=s.slice(3),a=!0),s.indexOf("{")!==0&&(s="{"+s+"}");let l;a?l=maybeEval(e,function(){return i?Function("event","return ("+s+")").call(e,i):Function("return ("+s+")").call(e)},{}):l=parseJSON(s);for(const c in l)l.hasOwnProperty(c)&&r[c]==null&&(r[c]=l[c])}return getValuesForElement(asElement(parentElt(e)),t,n,r,i)}function maybeEval(e,t,n){return htmx.config.allowEval?t():(triggerErrorEvent(e,"htmx:evalDisallowedError"),n)}function getHXVarsForElement(e,t,n){return getValuesForElement(e,"hx-vars",!0,n,t)}function getHXValsForElement(e,t,n){return getValuesForElement(e,"hx-vals",!1,n,t)}function getExpressionVars(e,t){return mergeObjects(getHXVarsForElement(e,t),getHXValsForElement(e,t))}function safelySetHeaderValue(e,t,n){if(n!==null)try{e.setRequestHeader(t,n)}catch{e.setRequestHeader(t,encodeURIComponent(n)),e.setRequestHeader(t+"-URI-AutoEncoded","true")}}function getPathFromResponse(e){if(e.responseURL)try{const t=new URL(e.responseURL);return t.pathname+t.search}catch{triggerErrorEvent(getDocument().body,"htmx:badResponseUrl",{url:e.responseURL})}}function hasHeader(e,t){return t.test(e.getAllResponseHeaders())}function ajaxHelper(e,t,n){if(e=e.toLowerCase(),n){if(n instanceof Element||typeof n=="string")return issueAjaxRequest(e,t,null,null,{targetOverride:resolveTarget(n)||DUMMY_ELT,returnPromise:!0});{let r=resolveTarget(n.target);return(n.target&&!r||n.source&&!r&&!resolveTarget(n.source))&&(r=DUMMY_ELT),issueAjaxRequest(e,t,resolveTarget(n.source),n.event,{handler:n.handler,headers:n.headers,values:n.values,targetOverride:r,swapOverride:n.swap,select:n.select,returnPromise:!0,push:n.push,replace:n.replace,selectOOB:n.selectOOB})}}else return issueAjaxRequest(e,t,null,null,{returnPromise:!0})}function hierarchyForElt(e){const t=[];for(;e;)t.push(e),e=e.parentElement;return t}function verifyPath(e,t,n){const r=new URL(t,location.protocol!=="about:"?location.href:window.origin),o=(location.protocol!=="about:"?location.origin:window.origin)===r.origin;return htmx.config.selfRequestsOnly&&!o?!1:triggerEvent(e,"htmx:validateUrl",mergeObjects({url:r,sameHost:o},n))}function formDataFromObject(e){if(e instanceof FormData)return e;const t=new FormData;for(const n in e)e.hasOwnProperty(n)&&(e[n]&&typeof e[n].forEach=="function"?e[n].forEach(function(r){t.append(n,r)}):typeof e[n]=="object"&&!(e[n]instanceof Blob)?t.append(n,JSON.stringify(e[n])):t.append(n,e[n]));return t}function formDataArrayProxy(e,t,n){return new Proxy(n,{get:function(r,i){return typeof i=="number"?r[i]:i==="length"?r.length:i==="push"?function(o){r.push(o),e.append(t,o)}:typeof r[i]=="function"?function(){r[i].apply(r,arguments),e.delete(t),r.forEach(function(o){e.append(t,o)})}:r[i]&&r[i].length===1?r[i][0]:r[i]},set:function(r,i,o){return r[i]=o,e.delete(t),r.forEach(function(s){e.append(t,s)}),!0}})}function formDataProxy(e){return new Proxy(e,{get:function(t,n){if(typeof n=="symbol"){const i=Reflect.get(t,n);return typeof i=="function"?function(){return i.apply(e,arguments)}:i}if(n==="toJSON")return()=>Object.fromEntries(e);if(n in t&&typeof t[n]=="function")return function(){return e[n].apply(e,arguments)};const r=e.getAll(n);if(r.length!==0)return r.length===1?r[0]:formDataArrayProxy(t,n,r)},set:function(t,n,r){return typeof n!="string"?!1:(t.delete(n),r&&typeof r.forEach=="function"?r.forEach(function(i){t.append(n,i)}):typeof r=="object"&&!(r instanceof Blob)?t.append(n,JSON.stringify(r)):t.append(n,r),!0)},deleteProperty:function(t,n){return typeof n=="string"&&t.delete(n),!0},ownKeys:function(t){return Reflect.ownKeys(Object.fromEntries(t))},getOwnPropertyDescriptor:function(t,n){return Reflect.getOwnPropertyDescriptor(Object.fromEntries(t),n)}})}function issueAjaxRequest(e,t,n,r,i,o){let s=null,a=null;if(i=i??{},i.returnPromise&&typeof Promise<"u")var l=new Promise(function(x,_){s=x,a=_});n==null&&(n=getDocument().body);const c=i.handler||handleAjaxResponse,u=i.select||null;if(!bodyContains(n))return maybeCall(s),l;const f=i.targetOverride||asElement(getTarget(n));if(f==null||f==DUMMY_ELT)return triggerErrorEvent(n,"htmx:targetError",{target:getClosestAttributeValue(n,"hx-target")}),maybeCall(a),l;let d=getInternalData(n);const p=d.lastButtonClicked;if(p){const x=getRawAttribute(p,"formaction");x!=null&&(t=x);const _=getRawAttribute(p,"formmethod");if(_!=null)if(VERBS.includes(_.toLowerCase()))e=_;else return maybeCall(s),l}const g=getClosestAttributeValue(n,"hx-confirm");if(o===void 0&&triggerEvent(n,"htmx:confirm",{target:f,elt:n,path:t,verb:e,triggeringEvent:r,etc:i,issueRequest:function(R){return issueAjaxRequest(e,t,n,r,i,!!R)},question:g})===!1)return maybeCall(s),l;let v=n,h=getClosestAttributeValue(n,"hx-sync"),m=null,y=!1;if(h){const x=h.split(":"),_=x[0].trim();if(_==="this"?v=findThisElement(n,"hx-sync"):v=asElement(querySelectorExt(n,_)),h=(x[1]||"drop").trim(),d=getInternalData(v),h==="drop"&&d.xhr&&d.abortable!==!0)return maybeCall(s),l;if(h==="abort"){if(d.xhr)return maybeCall(s),l;y=!0}else h==="replace"?triggerEvent(v,"htmx:abort"):h.indexOf("queue")===0&&(m=(h.split(" ")[1]||"last").trim())}if(d.xhr)if(d.abortable)triggerEvent(v,"htmx:abort");else{if(m==null){if(r){const x=getInternalData(r);x&&x.triggerSpec&&x.triggerSpec.queue&&(m=x.triggerSpec.queue)}m==null&&(m="last")}return d.queuedRequests==null&&(d.queuedRequests=[]),m==="first"&&d.queuedRequests.length===0?d.queuedRequests.push(function(){issueAjaxRequest(e,t,n,r,i)}):m==="all"?d.queuedRequests.push(function(){issueAjaxRequest(e,t,n,r,i)}):m==="last"&&(d.queuedRequests=[],d.queuedRequests.push(function(){issueAjaxRequest(e,t,n,r,i)})),maybeCall(s),l}const E=new XMLHttpRequest;d.xhr=E,d.abortable=y;const b=function(){d.xhr=null,d.abortable=!1,d.queuedRequests!=null&&d.queuedRequests.length>0&&d.queuedRequests.shift()()},C=getClosestAttributeValue(n,"hx-prompt");if(C){var T=prompt(C);if(T===null||!triggerEvent(n,"htmx:prompt",{prompt:T,target:f}))return maybeCall(s),b(),l}if(g&&!o&&!confirm(g))return maybeCall(s),b(),l;let A=getHeaders(n,f,T);e!=="get"&&!usesFormData(n)&&(A["Content-Type"]="application/x-www-form-urlencoded"),i.headers&&(A=mergeObjects(A,i.headers));const L=getInputValues(n,e);let I=L.errors;const M=L.formData;i.values&&overrideFormData(M,formDataFromObject(i.values));const V=formDataFromObject(getExpressionVars(n,r)),k=overrideFormData(M,V);let O=filterValues(k,n);htmx.config.getCacheBusterParam&&e==="get"&&O.set("org.htmx.cache-buster",getRawAttribute(f,"id")||"true"),(t==null||t==="")&&(t=location.href);const N=getValuesForElement(n,"hx-request"),B=getInternalData(n).boosted;let H=htmx.config.methodsThatUseUrlParams.indexOf(e)>=0;const S={boosted:B,useUrlParams:H,formData:O,parameters:formDataProxy(O),unfilteredFormData:k,unfilteredParameters:formDataProxy(k),headers:A,elt:n,target:f,verb:e,errors:I,withCredentials:i.credentials||N.credentials||htmx.config.withCredentials,timeout:i.timeout||N.timeout||htmx.config.timeout,path:t,triggeringEvent:r};if(!triggerEvent(n,"htmx:configRequest",S))return maybeCall(s),b(),l;if(t=S.path,e=S.verb,A=S.headers,O=formDataFromObject(S.parameters),I=S.errors,H=S.useUrlParams,I&&I.length>0)return triggerEvent(n,"htmx:validation:halted",S),maybeCall(s),b(),l;const j=t.split("#"),U=j[0],q=j[1];let D=t;if(H&&(D=U,!O.keys().next().done&&(D.indexOf("?")<0?D+="?":D+="&",D+=urlEncode(O),q&&(D+="#"+q))),!verifyPath(n,D,S))return triggerErrorEvent(n,"htmx:invalidPath",S),maybeCall(a),b(),l;if(E.open(e.toUpperCase(),D,!0),E.overrideMimeType("text/html"),E.withCredentials=S.withCredentials,E.timeout=S.timeout,!N.noHeaders){for(const x in A)if(A.hasOwnProperty(x)){const _=A[x];safelySetHeaderValue(E,x,_)}}const w={xhr:E,target:f,requestConfig:S,etc:i,boosted:B,select:u,pathInfo:{requestPath:t,finalRequestPath:D,responsePath:null,anchor:q}};if(E.onload=function(){try{const x=hierarchyForElt(n);if(w.pathInfo.responsePath=getPathFromResponse(E),c(n,w),w.keepIndicators!==!0&&removeRequestIndicators(P,F),triggerEvent(n,"htmx:afterRequest",w),triggerEvent(n,"htmx:afterOnLoad",w),!bodyContains(n)){let _=null;for(;x.length>0&&_==null;){const R=x.shift();bodyContains(R)&&(_=R)}_&&(triggerEvent(_,"htmx:afterRequest",w),triggerEvent(_,"htmx:afterOnLoad",w))}maybeCall(s)}catch(x){throw triggerErrorEvent(n,"htmx:onLoadError",mergeObjects({error:x},w)),x}finally{b()}},E.onerror=function(){removeRequestIndicators(P,F),triggerErrorEvent(n,"htmx:afterRequest",w),triggerErrorEvent(n,"htmx:sendError",w),maybeCall(a),b()},E.onabort=function(){removeRequestIndicators(P,F),triggerErrorEvent(n,"htmx:afterRequest",w),triggerErrorEvent(n,"htmx:sendAbort",w),maybeCall(a),b()},E.ontimeout=function(){removeRequestIndicators(P,F),triggerErrorEvent(n,"htmx:afterRequest",w),triggerErrorEvent(n,"htmx:timeout",w),maybeCall(a),b()},!triggerEvent(n,"htmx:beforeRequest",w))return maybeCall(s),b(),l;var P=addRequestIndicatorClasses(n),F=disableElements(n);forEach(["loadstart","loadend","progress","abort"],function(x){forEach([E,E.upload],function(_){_.addEventListener(x,function(R){triggerEvent(n,"htmx:xhr:"+x,{lengthComputable:R.lengthComputable,loaded:R.loaded,total:R.total})})})}),triggerEvent(n,"htmx:beforeSend",w);const $=H?null:encodeParamsForBody(E,n,O);return E.send($),l}function determineHistoryUpdates(e,t){const n=t.xhr;let r=null,i=null;if(hasHeader(n,/HX-Push:/i)?(r=n.getResponseHeader("HX-Push"),i="push"):hasHeader(n,/HX-Push-Url:/i)?(r=n.getResponseHeader("HX-Push-Url"),i="push"):hasHeader(n,/HX-Replace-Url:/i)&&(r=n.getResponseHeader("HX-Replace-Url"),i="replace"),r)return r==="false"?{}:{type:i,path:r};const o=t.pathInfo.finalRequestPath,s=t.pathInfo.responsePath,a=t.etc.push||getClosestAttributeValue(e,"hx-push-url"),l=t.etc.replace||getClosestAttributeValue(e,"hx-replace-url"),c=getInternalData(e).boosted;let u=null,f=null;return a?(u="push",f=a):l?(u="replace",f=l):c&&(u="push",f=s||o),f?f==="false"?{}:(f==="true"&&(f=s||o),t.pathInfo.anchor&&f.indexOf("#")===-1&&(f=f+"#"+t.pathInfo.anchor),{type:u,path:f}):{}}function codeMatches(e,t){var n=new RegExp(e.code);return n.test(t.toString(10))}function resolveResponseHandling(e){for(var t=0;t<htmx.config.responseHandling.length;t++){var n=htmx.config.responseHandling[t];if(codeMatches(n,e.status))return n}return{swap:!1}}function handleTitle(e){if(e){const t=find("title");t?t.textContent=e:window.document.title=e}}function resolveRetarget(e,t){if(t==="this")return e;const n=asElement(querySelectorExt(e,t));if(n==null)throw triggerErrorEvent(e,"htmx:targetError",{target:t}),new Error(`Invalid re-target ${t}`);return n}function handleAjaxResponse(e,t){const n=t.xhr;let r=t.target;const i=t.etc,o=t.select;if(!triggerEvent(e,"htmx:beforeOnLoad",t))return;if(hasHeader(n,/HX-Trigger:/i)&&handleTriggerHeader(n,"HX-Trigger",e),hasHeader(n,/HX-Location:/i)){let y=n.getResponseHeader("HX-Location");var s={};y.indexOf("{")===0&&(s=parseJSON(y),y=s.path,delete s.path),s.push=s.push||"true",ajaxHelper("get",y,s);return}const a=hasHeader(n,/HX-Refresh:/i)&&n.getResponseHeader("HX-Refresh")==="true";if(hasHeader(n,/HX-Redirect:/i)){t.keepIndicators=!0,htmx.location.href=n.getResponseHeader("HX-Redirect"),a&&htmx.location.reload();return}if(a){t.keepIndicators=!0,htmx.location.reload();return}const l=determineHistoryUpdates(e,t),c=resolveResponseHandling(n),u=c.swap;let f=!!c.error,d=htmx.config.ignoreTitle||c.ignoreTitle,p=c.select;c.target&&(t.target=resolveRetarget(e,c.target));var g=i.swapOverride;g==null&&c.swapOverride&&(g=c.swapOverride),hasHeader(n,/HX-Retarget:/i)&&(t.target=resolveRetarget(e,n.getResponseHeader("HX-Retarget"))),hasHeader(n,/HX-Reswap:/i)&&(g=n.getResponseHeader("HX-Reswap"));var v=n.response,h=mergeObjects({shouldSwap:u,serverResponse:v,isError:f,ignoreTitle:d,selectOverride:p,swapOverride:g},t);if(!(c.event&&!triggerEvent(r,c.event,h))&&triggerEvent(r,"htmx:beforeSwap",h)){if(r=h.target,v=h.serverResponse,f=h.isError,d=h.ignoreTitle,p=h.selectOverride,g=h.swapOverride,t.target=r,t.failed=f,t.successful=!f,h.shouldSwap){n.status===286&&cancelPolling(e),withExtensions(e,function(b){v=b.transformResponse(v,n,e)}),l.type&&saveCurrentPageToHistory();var m=getSwapSpecification(e,g);m.hasOwnProperty("ignoreTitle")||(m.ignoreTitle=d),r.classList.add(htmx.config.swappingClass),o&&(p=o),hasHeader(n,/HX-Reselect:/i)&&(p=n.getResponseHeader("HX-Reselect"));const y=i.selectOOB||getClosestAttributeValue(e,"hx-select-oob"),E=getClosestAttributeValue(e,"hx-select");swap(r,v,m,{select:p==="unset"?null:p||E,selectOOB:y,eventInfo:t,anchor:t.pathInfo.anchor,contextElement:e,afterSwapCallback:function(){if(hasHeader(n,/HX-Trigger-After-Swap:/i)){let b=e;bodyContains(e)||(b=getDocument().body),handleTriggerHeader(n,"HX-Trigger-After-Swap",b)}},afterSettleCallback:function(){if(hasHeader(n,/HX-Trigger-After-Settle:/i)){let b=e;bodyContains(e)||(b=getDocument().body),handleTriggerHeader(n,"HX-Trigger-After-Settle",b)}},beforeSwapCallback:function(){l.type&&(triggerEvent(getDocument().body,"htmx:beforeHistoryUpdate",mergeObjects({history:l},t)),l.type==="push"?(pushUrlIntoHistory(l.path),triggerEvent(getDocument().body,"htmx:pushedIntoHistory",{path:l.path})):(replaceUrlInHistory(l.path),triggerEvent(getDocument().body,"htmx:replacedInHistory",{path:l.path})))}})}f&&triggerErrorEvent(e,"htmx:responseError",mergeObjects({error:"Response Status Error Code "+n.status+" from "+t.pathInfo.requestPath},t))}}const extensions={};function extensionBase(){return{init:function(e){return null},getSelectors:function(){return null},onEvent:function(e,t){return!0},transformResponse:function(e,t,n){return e},isInlineSwap:function(e){return!1},handleSwap:function(e,t,n,r){return!1},encodeParameters:function(e,t,n){return null}}}function defineExtension(e,t){t.init&&t.init(internalAPI),extensions[e]=mergeObjects(extensionBase(),t)}function removeExtension(e){delete extensions[e]}function getExtensions(e,t,n){if(t==null&&(t=[]),e==null)return t;n==null&&(n=[]);const r=getAttributeValue(e,"hx-ext");return r&&forEach(r.split(","),function(i){if(i=i.replace(/ /g,""),i.slice(0,7)=="ignore:"){n.push(i.slice(7));return}if(n.indexOf(i)<0){const o=extensions[i];o&&t.indexOf(o)<0&&t.push(o)}}),getExtensions(asElement(parentElt(e)),t,n)}var isReady=!1;getDocument().addEventListener("DOMContentLoaded",function(){isReady=!0});function ready(e){isReady||getDocument().readyState==="complete"?e():getDocument().addEventListener("DOMContentLoaded",e)}function insertIndicatorStyles(){if(htmx.config.includeIndicatorStyles!==!1){const e=htmx.config.inlineStyleNonce?` nonce="${htmx.config.inlineStyleNonce}"`:"",t=htmx.config.indicatorClass,n=htmx.config.requestClass;getDocument().head.insertAdjacentHTML("beforeend",`<style${e}>.${t}{opacity:0;visibility: hidden} .${n} .${t}, .${n}.${t}{opacity:1;visibility: visible;transition: opacity 200ms ease-in}</style>`)}}function getMetaConfig(){const e=getDocument().querySelector('meta[name="htmx-config"]');return e?parseJSON(e.content):null}function mergeMetaConfig(){const e=getMetaConfig();e&&(htmx.config=mergeObjects(htmx.config,e))}return ready(function(){mergeMetaConfig(),insertIndicatorStyles();let e=getDocument().body;processNode(e);const t=getDocument().querySelectorAll("[hx-trigger='restored'],[data-hx-trigger='restored']");e.addEventListener("htmx:abort",function(r){const i=r.detail.elt||r.target,o=getInternalData(i);o&&o.xhr&&o.xhr.abort()});const n=window.onpopstate?window.onpopstate.bind(window):null;window.onpopstate=function(r){r.state&&r.state.htmx?(restoreHistory(),forEach(t,function(i){triggerEvent(i,"htmx:restored",{document:getDocument(),triggerEvent})})):n&&n(r)},getWindow().setTimeout(function(){triggerEvent(e,"htmx:load",{}),e=null},0)}),htmx})();class AuthRequiredError extends Error{constructor(t="Authentication required"){super(t),this.name="AuthRequiredError"}}class SessionExpiredError extends Error{constructor(t="Your session has expired. Please log in again."){super(t),this.name="SessionExpiredError"}}async function refreshSession(){try{const e=await fetch("/oauth/refresh",{method:"POST",credentials:"same-origin"});if(!e.ok){if(e.status===401)throw new AuthRequiredError;console.warn("Session refresh returned non-OK status:",e.status)}}catch(e){if(e instanceof AuthRequiredError)throw e;console.warn("Session refresh failed:",e)}}async function refreshAuth(){try{await refreshSession()}catch(e){if(e instanceof AuthRequiredError)throw new SessionExpiredError;console.warn("Auth refresh warning:",e)}}async function authFetch(e,t={}){const{skipRefresh:n=!1,...r}=t;n||await refreshAuth();const i=await fetch(e,{...r,credentials:"same-origin"});if(i.status===401)throw new SessionExpiredError;return i}async function authPostJson(e,t,n={}){return authFetch(e,{method:"POST",headers:{"Content-Type":"application/json",...n.headers||{}},body:JSON.stringify(t),...n})}function initAuthRefreshExtension(e){e.defineExtension("auth-refresh",{onEvent(t,n){t==="htmx:confirm"&&(n.preventDefault(),refreshSession().catch(r=>{console.warn("Auth refresh before request failed:",r)}).finally(()=>{n.detail.issueRequest()}))}})}function initLoadingStatesExtension(e){const t=[];function n(l){return e.closest(l,"[data-loading-states]")||document.body}function r(l,c){document.body.contains(l)&&c()}function i(l,c){const u=e.closest(l,"[data-loading-path]");return u?u.getAttribute("data-loading-path")===c:!0}function o(l,c,u,f){const d=e.closest(l,"[data-loading-delay]");if(d){const p=Number.parseInt(d.getAttribute("data-loading-delay")||"200",10),g=setTimeout(()=>{u(),t.push(()=>{r(c,f)})},p);t.push(()=>{r(c,()=>clearTimeout(g))})}else u(),t.push(()=>{r(c,f)})}function s(l,c,u){return Array.from(e.findAll(l,`[${c}]`)).filter(f=>i(f,u))}function a(l){const c=l.getAttribute("data-loading-target");return c?Array.from(e.findAll(c)):[l]}e.defineExtension("loading-states",{onEvent(l,c){var u,f;if(l==="htmx:beforeRequest"){const d=n(c.target),p=((f=(u=c.detail)==null?void 0:u.pathInfo)==null?void 0:f.requestPath)||"",g=["data-loading","data-loading-class","data-loading-class-remove","data-loading-disable","data-loading-aria-busy"],v={};for(const h of g)v[h]=s(d,h,p);for(const h of v["data-loading"])for(const m of a(h))o(h,m,()=>{m.style.display=h.getAttribute("data-loading")||"inline-block"},()=>{m.style.display="none"});for(const h of v["data-loading-class"]){const m=(h.getAttribute("data-loading-class")||"").split(" ");for(const y of a(h))o(h,y,()=>{for(const E of m)y.classList.add(E)},()=>{for(const E of m)y.classList.remove(E)})}for(const h of v["data-loading-class-remove"]){const m=(h.getAttribute("data-loading-class-remove")||"").split(" ");for(const y of a(h))o(h,y,()=>{for(const E of m)y.classList.remove(E)},()=>{for(const E of m)y.classList.add(E)})}for(const h of v["data-loading-disable"])for(const m of a(h))o(h,m,()=>{m.disabled=!0},()=>{m.disabled=!1});for(const h of v["data-loading-aria-busy"])for(const m of a(h))o(h,m,()=>{m.setAttribute("aria-busy","true")},()=>{m.removeAttribute("aria-busy")})}if(l==="htmx:beforeOnLoad")for(;t.length>0;){const d=t.shift();d==null||d()}}})}function initSSEExtension(e){let t;function n(c){return new EventSource(c,{withCredentials:!0})}function r(c){return t.getInternalData(c).sseEventSource!=null}function i(c){if(!t.bodyContains(c)){const f=t.getInternalData(c).sseEventSource;if(f!=null)return t.triggerEvent(c,"htmx:sseClose",{source:f,type:"nodeMissing"}),f.close(),!0}return!1}function o(c,u){let f=u;t.withExtensions(c,g=>{g.transformResponse&&(f=g.transformResponse(f,null,c))});const d=t.getSwapSpecification(c),p=t.getTarget(c);p&&t.swap(p,f,d)}function s(c){const u=t.getAttributeValue(c,"sse-swap");if(u){const d=t.getClosestMatch(c,r);if(d==null)return;const g=t.getInternalData(d).sseEventSource,v=u.split(",");for(const h of v){const m=h.trim(),y=E=>{const b=E;if(!i(d)){if(!t.bodyContains(c)){g.removeEventListener(m,y);return}t.triggerEvent(c,"htmx:sseBeforeMessage",E)&&(o(c,b.data),t.triggerEvent(c,"htmx:sseMessage",E))}};t.getInternalData(c).sseEventListener=y,g.addEventListener(m,y)}}if(t.getAttributeValue(c,"hx-trigger")){const d=t.getClosestMatch(c,r);if(d==null)return;const g=t.getInternalData(d).sseEventSource,v=t.getTriggerSpecs(c);for(const h of v){if(!h.trigger.startsWith("sse:"))continue;const m=h.trigger.slice(4),y=E=>{i(d)||(t.bodyContains(c)||g.removeEventListener(m,y),e.trigger(c,h.trigger,E),e.trigger(c,"htmx:sseMessage",E))};t.getInternalData(c).sseEventListener=y,g.addEventListener(m,y)}}}function a(c,u,f){const d=e.createEventSource(u);d.onerror=g=>{if(t.triggerErrorEvent(c,"htmx:sseError",{error:g,source:d}),!i(c)&&d.readyState===EventSource.CLOSED){let v=f||0;v=Math.max(Math.min(v*2,128),1);const h=v*500;window.setTimeout(()=>{l(c,v)},h)}},d.onopen=()=>{if(t.triggerEvent(c,"htmx:sseOpen",{source:d}),f&&f>0){const g=c.querySelectorAll("[sse-swap], [data-sse-swap], [hx-trigger], [data-hx-trigger]");for(const v of g)s(v)}},t.getInternalData(c).sseEventSource=d;const p=t.getAttributeValue(c,"sse-close");p&&d.addEventListener(p,()=>{t.triggerEvent(c,"htmx:sseClose",{source:d,type:"message"}),d.close()})}function l(c,u){if(c==null)return;const f=t.getAttributeValue(c,"sse-connect");f&&a(c,f,u),s(c)}e.defineExtension("sse",{init(c){t=c,e.createEventSource==null&&(e.createEventSource=n)},getSelectors(){return["[sse-connect]","[data-sse-connect]","[sse-swap]","[data-sse-swap]"]},onEvent(c,u){var d;const f=u.target||((d=u.detail)==null?void 0:d.elt);switch(c){case"htmx:beforeCleanupElement":{const g=t.getInternalData(f).sseEventSource;g&&(t.triggerEvent(f,"htmx:sseClose",{source:g,type:"nodeReplaced"}),g.close());return}case"htmx:afterProcessNode":l(f);break}}})}const htmxApi=htmx;window.htmx=htmxApi;initAuthRefreshExtension(htmxApi);initLoadingStatesExtension(htmxApi);initSSEExtension(htmxApi);window.Alpine=module_default;document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{module_default.start()}):module_default.start();function initNavigation(){document.querySelectorAll(".navbar-burger").forEach(t=>{t.addEventListener("click",()=>{const n=t.dataset.target;if(!n)return;const r=document.getElementById(n);r&&(t.classList.toggle("is-active"),r.classList.toggle("is-active"))})})}function eventForm(){return{submitUrl:"/event",isEditMode:!1,formData:{name:"",description:"",status:"scheduled",mode:"inperson",tz:"America/New_York",startsAt:null,endsAt:null,locations:[],links:[],headerCid:null,headerAlt:null,headerSize:null,thumbnailCid:null,thumbnailAlt:null,requireConfirmedEmail:!1,sendNotifications:!1},startDateTimeLocal:"",endDateTimeLocal:"",submitting:!1,submitted:!1,uploading:!1,uploadingThumbnail:!1,errorMessage:null,eventUrl:null,headerCropper:null,thumbnailCropper:null,showCropper:!1,showThumbnailCropper:!1,showDescriptionPreview:!1,descriptionPreviewHtml:"",loadingPreview:!1,locationSuggestions:[],loadingSuggestions:!1,showLocationSuggestions:!1,locationFeedback:null,locationFilter:"",init(){const e=this.$el;if(e.dataset.submitUrl&&(this.submitUrl=e.dataset.submitUrl),e.dataset.editMode==="true"&&(this.isEditMode=!0),e.dataset.eventData)try{this.formData=JSON.parse(e.dataset.eventData)}catch(t){console.error("Failed to parse event data:",t)}if(e.dataset.defaultTz&&(this.formData.tz=e.dataset.defaultTz),this.formData.startsAt){const t=new Date(this.formData.startsAt);this.startDateTimeLocal=this.formatDateTimeLocal(t)}else{const t=new Date;t.setHours(t.getHours()+3);const n=new Date(t);t.getHours()>=18&&n.setDate(n.getDate()+1),n.setHours(18,0,0,0),this.startDateTimeLocal=this.formatDateTimeLocal(n)}if(this.formData.endsAt){const t=new Date(this.formData.endsAt);this.endDateTimeLocal=this.formatDateTimeLocal(t)}this.$watch("startDateTimeLocal",t=>{if(t){const n=new Date(t);this.formData.startsAt=n.toISOString()}else this.formData.startsAt=null}),this.$watch("endDateTimeLocal",t=>{if(t){const n=new Date(t);this.formData.endsAt=n.toISOString()}else this.formData.endsAt=null})},get addressLocations(){return this.formData.locations.filter(e=>e.type==="address")},get geoLocations(){return this.formData.locations.filter(e=>e.type==="geo")},addressLocationIndex(e){return e},geoLocationIndex(e){return e},findAddressLocationIndex(e){let t=0;for(let n=0;n<this.formData.locations.length;n++)if(this.formData.locations[n].type==="address"){if(t===e)return n;t++}return-1},findGeoLocationIndex(e){let t=0;for(let n=0;n<this.formData.locations.length;n++)if(this.formData.locations[n].type==="geo"){if(t===e)return n;t++}return-1},formatDateTimeLocal(e){const t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0"),i=String(e.getHours()).padStart(2,"0"),o=String(e.getMinutes()).padStart(2,"0");return`${t}-${n}-${r}T${i}:${o}`},get headerPreviewUrl(){return this.formData.headerCid?`/content/${this.formData.headerCid}.png`:null},get thumbnailPreviewUrl(){return this.formData.thumbnailCid?`/content/${this.formData.thumbnailCid}.png`:null},get filteredLocationSuggestions(){if(!this.locationFilter.trim())return this.locationSuggestions;const e=this.locationFilter.toLowerCase().trim();return this.locationSuggestions.filter(t=>{const n=[t.name,t.street,t.locality,t.region,t.postal_code,t.country].filter(Boolean).map(i=>i.toLowerCase());return e.split(/\s+/).every(i=>n.some(o=>o.includes(i)))})},addLocation(){this.formData.locations.push({type:"address",country:"",postalCode:null,region:null,locality:null,street:null,name:null})},removeAddressLocation(e){const t=this.findAddressLocationIndex(e);t!==-1&&this.formData.locations.splice(t,1)},addGeoLocation(){this.formData.locations.push({type:"geo",latitude:"",longitude:"",name:null})},removeGeoLocation(e){const t=this.findGeoLocationIndex(e);t!==-1&&this.formData.locations.splice(t,1)},addLink(){this.formData.links.push({url:"",label:null})},removeLink(e){this.formData.links.splice(e,1)},clearStartDateTime(){const e=document.getElementById("eventStartDateTime");e&&(e.value=""),this.startDateTimeLocal="",this.formData.startsAt=null},clearEndDateTime(){const e=document.getElementById("eventEndDateTime");e&&(e.value=""),this.endDateTimeLocal="",this.formData.endsAt=null},async fetchLocationSuggestions(){if(this.loadingSuggestions||this.locationSuggestions.length>0){this.showLocationSuggestions=!0;return}this.loadingSuggestions=!0;try{const e=await authFetch("/event/location-suggestions"),t=await e.json();e.ok&&t.suggestions&&(this.locationSuggestions=t.suggestions)}catch(e){e instanceof SessionExpiredError?this.errorMessage=e.message:console.error("Failed to fetch location suggestions:",e)}finally{this.loadingSuggestions=!1,this.showLocationSuggestions=!0}},applyLocationSuggestion(e){const t=!!e.country,n=!!(e.latitude&&e.longitude);t&&this.formData.locations.push({type:"address",country:e.country||"",postalCode:e.postal_code||null,region:e.region||null,locality:e.locality||null,street:e.street||null,name:e.name||null}),n&&this.formData.locations.push({type:"geo",latitude:String(e.latitude),longitude:String(e.longitude),name:e.name||null}),t&&n?this.locationFeedback="Added address and coordinates":t?this.locationFeedback="Added address":n&&(this.locationFeedback="Added coordinates"),this.locationFeedback&&setTimeout(()=>{this.locationFeedback=null},3e3),this.showLocationSuggestions=!1,this.locationFilter=""},async toggleDescriptionPreview(){if(this.showDescriptionPreview){this.showDescriptionPreview=!1;return}if(!this.formData.description||this.formData.description.trim().length<10){alert("Description must be at least 10 characters to preview");return}this.showDescriptionPreview=!0,this.loadingPreview=!0,this.descriptionPreviewHtml="";try{const e=await authPostJson("/event/preview-description",{description:this.formData.description}),t=await e.json();e.ok?this.descriptionPreviewHtml=t.html:(this.errorMessage=t.error||"Failed to load preview",this.showDescriptionPreview=!1)}catch(e){e instanceof SessionExpiredError?this.errorMessage=e.message:(console.error("Preview error:",e),this.errorMessage="Failed to load preview. Please try again."),this.showDescriptionPreview=!1}finally{this.loadingPreview=!1}},handleHeaderImageSelect(e){var r;const t=e.target,n=(r=t.files)==null?void 0:r[0];if(n){if(n.size>3e6){alert("Image must be smaller than 3MB"),t.value="";return}console.log("Header image selected, size:",n.size)}},handleThumbnailImageSelect(e){var r;const t=e.target,n=(r=t.files)==null?void 0:r[0];if(n){if(n.size>3e6){alert("Image must be smaller than 3MB"),t.value="";return}console.log("Thumbnail image selected, size:",n.size)}},removeHeader(){this.formData.headerCid=null,this.formData.headerAlt=null,this.formData.headerSize=null,this.showCropper=!1},removeThumbnail(){this.formData.thumbnailCid=null,this.formData.thumbnailAlt=null,this.showThumbnailCropper=!1},async submitForm(){if(this.errorMessage=null,!this.formData.name||this.formData.name.trim().length<10){this.errorMessage="Event name must be at least 10 characters.";return}if(this.formData.name.trim().length>500){this.errorMessage="Event name must be no more than 500 characters.";return}if(!this.formData.description||this.formData.description.trim().length<10){this.errorMessage="Description must be at least 10 characters.";return}if(this.formData.description.trim().length>3e3){this.errorMessage="Description must be no more than 3000 characters.";return}if(this.addressLocations.filter(n=>n.type==="address"&&(!n.country||n.country.trim()==="")).length>0){this.errorMessage="All locations must have a country selected. Please select a country or remove the location.";return}for(let n=0;n<this.geoLocations.length;n++){const r=this.geoLocations[n];if(r.type==="geo"){if(!r.latitude||!r.longitude){this.errorMessage=`Coordinates ${n+1} must have both latitude and longitude.`;return}const i=parseFloat(r.latitude),o=parseFloat(r.longitude);if(isNaN(i)||i<-90||i>90){this.errorMessage=`Coordinates ${n+1} has invalid latitude. Must be between -90 and 90.`;return}if(isNaN(o)||o<-180||o>180){this.errorMessage=`Coordinates ${n+1} has invalid longitude. Must be between -180 and 180.`;return}}}const t=[];for(let n=0;n<this.formData.links.length;n++){const r=this.formData.links[n];if(!r.url||r.url.trim()===""){t.push(`Link ${n+1} must have a URL or be removed.`);continue}if(!r.url.startsWith("https://")){t.push(`Link ${n+1} must be an HTTPS URL (starting with https://).`);continue}try{new URL(r.url)}catch{t.push(`Link ${n+1} has an invalid URL format.`)}}if(t.length>0){this.errorMessage=t.join(" ");return}this.submitting=!0,this.formData.locations=this.formData.locations.filter(n=>n.type==="address"?n.country&&n.country.trim()!=="":n.type==="geo"?n.latitude&&n.longitude:!1),this.formData.links=this.formData.links.filter(n=>n.url),this.formData.endsAt===""&&(this.formData.endsAt=null);try{const n=await authPostJson(this.submitUrl,this.formData),r=await n.json();n.ok?(this.submitted=!0,this.eventUrl=r.url):this.errorMessage=r.error||"Failed to "+(this.isEditMode?"update":"create")+" event. Please try again."}catch(n){n instanceof SessionExpiredError?this.errorMessage=n.message:(console.error("Submit error:",n),this.errorMessage="Network error. Please check your connection and try again.")}finally{this.submitting=!1}},resetForm(){this.formData={name:"",description:"",status:"scheduled",mode:"inperson",tz:this.formData.tz,startsAt:null,endsAt:null,locations:[],links:[],headerCid:null,headerAlt:null,headerSize:null,thumbnailCid:null,thumbnailAlt:null,requireConfirmedEmail:!1,sendNotifications:!1},this.startDateTimeLocal="",this.endDateTimeLocal="",this.submitted=!1,this.eventUrl=null,this.errorMessage=null}}}const STORAGE_KEY="smokesignal_quick_event";function initQuickEventForm(){const e=document.getElementById("quick-event-form");if(!e)return;const t=e.dataset.authenticated==="true";e.addEventListener("submit",n=>{n.preventDefault();const r=document.getElementById("home-quick-event-title"),i=document.getElementById("home-quick-event-description"),o=document.getElementById("home-quick-event-starts");if(!(!r||!i||!o))if(t){const s=o.value;if(!s){alert("Please select a start time");return}const l=new Date(s).toISOString(),c={name:r.value,description:i.value,starts_at:l,status:"scheduled",mode:"inperson",locations:[],links:[],require_confirmed_email:!1,send_notifications:!0},u=e.querySelector('button[type="submit"]');u&&(u.disabled=!0,u.innerHTML='<span class="icon"><i class="fas fa-spinner fa-pulse"></i></span><span>Creating...</span>');const f=()=>{u&&(u.disabled=!1,u.innerHTML="<strong>Create Event</strong>")};authPostJson("/event",c).then(async d=>{const p=await d.json();d.ok&&p.url?window.location.href=p.url:(alert(p.error||"Failed to create event. Please try again."),f())}).catch(d=>{d instanceof SessionExpiredError?alert(d.message):(console.error("Error creating event:",d),alert("Failed to create event. Please try again.")),f()})}else{const s={name:r.value,description:i.value,starts_at:o.value};localStorage.setItem(STORAGE_KEY,JSON.stringify(s)),window.location.href="/quick-event"}})}let maplibreModule=null,h3Module=null;async function loadMapLibraries(){if(!maplibreModule||!h3Module){const[e,t]=await Promise.all([__vitePreload(()=>import("./maps-Dzpg4_su.js").then(n=>n.m),__vite__mapDeps([0,1])),__vitePreload(()=>import("./maps-Dzpg4_su.js").then(n=>n.h),__vite__mapDeps([0,1]))]);await __vitePreload(()=>import("./maps-Dzpg4_su.js").then(n=>n.a),__vite__mapDeps([0,1])),maplibreModule=e,h3Module=t}return{maplibregl:maplibreModule,h3:h3Module}}function getH3Module(){return h3Module}const flatMapStyle={version:8,sources:{osm:{type:"raster",tiles:["https://tile.openstreetmap.org/{z}/{x}/{y}.png"],tileSize:256,attribution:'&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>',maxzoom:19}},layers:[{id:"osm-tiles",type:"raster",source:"osm"}]};function createMap(e,t){const{container:n,center:r=[0,0],zoom:i=12,interactive:o=!0,scrollZoom:s=!1}=t,a={container:n,style:flatMapStyle,center:r,zoom:i,maxZoom:t.maxZoom,minZoom:t.minZoom};return o?a.scrollZoom=s:a.interactive=!1,new e.Map(a)}function h3ToGeoJsonFeature(e,t,n={}){const i=e.cellToBoundary(t).map(([o,s])=>[s,o]);return i.push(i[0]),{type:"Feature",properties:{id:t,fillColor:n.fillColor??"#3273dc",fillOpacity:n.fillOpacity??.3,strokeColor:n.strokeColor??"#3273dc",strokeWidth:n.strokeWidth??2,...n},geometry:{type:"Polygon",coordinates:[i]}}}function addHexagonLayers(e,t="hexagons"){e.addSource(t,{type:"geojson",data:{type:"FeatureCollection",features:[]}}),e.addLayer({id:`${t}-fill`,type:"fill",source:t,paint:{"fill-color":["get","fillColor"],"fill-opacity":["get","fillOpacity"]}}),e.addLayer({id:`${t}-outline`,type:"line",source:t,paint:{"line-color":["get","strokeColor"],"line-width":["get","strokeWidth"]}})}function updateHexagonSource(e,t,n="hexagons"){const r=e.getSource(n);if(r){const i={type:"FeatureCollection",features:t};r.setData(i)}}function calculateBounds(e){if(e.length===0)return null;let t=1/0,n=1/0,r=-1/0,i=-1/0;for(const o of e){const s=o.geometry.coordinates[0];for(const[a,l]of s)a<t&&(t=a),a>r&&(r=a),l<n&&(n=l),l>i&&(i=l)}return[[t,n],[r,i]]}function lerpColor(e,t,n){const r=parseInt(e.replace("#",""),16),i=parseInt(t.replace("#",""),16),o=r>>16,s=r>>8&255,a=r&255,l=i>>16,c=i>>8&255,u=i&255,f=Math.round(o+(l-o)*n),d=Math.round(s+(c-s)*n),p=Math.round(a+(u-a)*n);return"#"+((1<<24)+(f<<16)+(d<<8)+p).toString(16).slice(1)}function heatmapGradientColor(e,t,n){if(n===t)return"#3273dc";const r=(e-t)/(n-t);if(r<.33){const i=r/.33;return lerpColor("#3273dc","#8957e5",i)}else if(r<.66){const i=(r-.33)/.33;return lerpColor("#8957e5","#f39c12",i)}else{const i=(r-.66)/.34;return lerpColor("#f39c12","#e74c3c",i)}}function toMapCenter(e,t){return[t,e]}const H3_RESOLUTION=7;function lfgForm(){return{latitude:"",longitude:"",h3Index:"",tags:[],tagInput:"",durationHours:"48",map:null,submitting:!1,errors:{location:null,tags:null,duration:null,general:null},init(){const e=this.$el;e.dataset.defaultDuration&&(this.durationHours=e.dataset.defaultDuration),this.$nextTick(()=>{this.initMap()})},async initMap(){try{const{maplibregl:e}=await loadMapLibraries(),t=40.7128,n=-74.006;this.map=createMap(e,{container:"lfg-map",center:toMapCenter(t,n),zoom:12}),this.map.on("load",()=>{this.map&&(addHexagonLayers(this.map),this.map.on("click",r=>{var o;const i=(o=this.map)==null?void 0:o.queryRenderedFeatures(r.point,{layers:["hexagons-fill"]});i&&i.length>0?this.clearLocation():this.handleMapClick(r.lngLat.lng,r.lngLat.lat)}),this.map.on("mouseenter","hexagons-fill",()=>{this.map&&(this.map.getCanvas().style.cursor="pointer")}),this.map.on("mouseleave","hexagons-fill",()=>{this.map&&(this.map.getCanvas().style.cursor="")}))}),navigator.geolocation&&navigator.geolocation.getCurrentPosition(r=>{var s;const i=r.coords.latitude,o=r.coords.longitude;(s=this.map)==null||s.flyTo({center:toMapCenter(i,o),zoom:12})},()=>{})}catch(e){console.error("Failed to load map libraries:",e)}},handleMapClick(e,t){const n=getH3Module();if(!n){console.warn("H3 not loaded");return}const r=n.latLngToCell(t,e,H3_RESOLUTION);if(this.h3Index===r){this.clearLocation();return}this.selectLocation(r),this.errors.location=null},selectLocation(e){const t=getH3Module();if(!this.map||!t)return;this.h3Index=e;const n=h3ToGeoJsonFeature(t,e,{fillColor:"#00d1b2",fillOpacity:.3,strokeColor:"#00d1b2",strokeWidth:3});updateHexagonSource(this.map,[n]);const r=t.cellToLatLng(e);this.latitude=r[0].toString(),this.longitude=r[1].toString()},clearLocation(){this.map&&updateHexagonSource(this.map,[]),this.h3Index="",this.latitude="",this.longitude=""},addTag(){const e=this.tagInput.trim().replace(/[^a-zA-Z0-9-]/g,""),t=e.toLowerCase(),n=this.tags.some(r=>r.toLowerCase()===t);e&&!n&&this.tags.length<10&&(this.tags.push(e),this.errors.tags=null),this.tagInput=""},addTagFromSuggestion(e){const t=e.toLowerCase();!this.tags.some(r=>r.toLowerCase()===t)&&this.tags.length<10&&(this.tags.push(e),this.errors.tags=null)},removeTag(e){this.tags.splice(e,1)},canSubmit(){return!!this.h3Index&&this.tags.length>=1},clearErrors(){this.errors={location:null,tags:null,duration:null,general:null}},async submitForm(){if(!this.canSubmit()||this.submitting)return;this.clearErrors(),this.submitting=!0;const e={latitude:parseFloat(this.latitude),longitude:parseFloat(this.longitude),tags:this.tags,duration_hours:parseInt(this.durationHours,10)};try{const t=await authPostJson("/lfg",e);if(t.ok)window.location.href="/lfg";else{const n=await t.json();n.error?n.error.includes("location")||n.error.includes("coordinate")?this.errors.location=n.message||"Invalid location":n.error.includes("tag")?this.errors.tags=n.message||"Invalid tags":n.error.includes("duration")?this.errors.duration=n.message||"Invalid duration":this.errors.general=n.message||"An error occurred":this.errors.general="An error occurred. Please try again."}}catch(t){t instanceof SessionExpiredError?this.errors.general=t.message:(console.error("LFG submission error:",t),this.errors.general="Network error. Please check your connection and try again.")}finally{this.submitting=!1}}}}const loadingState={maps:null,cropper:null,profileCropper:null,lfgHeatmap:null};async function initEventMap(){if(!document.getElementById("event-map"))return;loadingState.maps||(loadingState.maps=__vitePreload(()=>import("./index-Bb8tq7S1.js"),[]));const{initEventMap:e}=await loadingState.maps;await e()}async function initGlobeMap(){if(!document.getElementById("globe-map"))return;loadingState.maps||(loadingState.maps=__vitePreload(()=>import("./index-Bb8tq7S1.js"),[]));const{initGlobeMap:e}=await loadingState.maps;await e()}async function initLocationHeatmap(){if(!document.getElementById("location-heatmap"))return;loadingState.maps||(loadingState.maps=__vitePreload(()=>import("./index-Bb8tq7S1.js"),[]));const{initLocationHeatmap:e}=await loadingState.maps;await e()}async function initMaps(){await Promise.all([initEventMap(),initGlobeMap(),initLocationHeatmap()])}async function initCropper(){if(!document.getElementById("headerCanvas")&&!document.getElementById("thumbnailCanvas"))return;loadingState.cropper||(loadingState.cropper=__vitePreload(()=>import("./index-8MdtY9qF.js"),[]));const{initCropper:e}=await loadingState.cropper;await e()}async function initProfileCropper(){if(!document.getElementById("avatar-input")&&!document.getElementById("banner-input"))return;loadingState.profileCropper||(loadingState.profileCropper=__vitePreload(()=>import("./profile-cropper-Cp_DD48I.js"),__vite__mapDeps([2,3])));const{initProfileCropper:e}=await loadingState.profileCropper;await e()}async function initLfgHeatmap(){if(!document.getElementById("lfg-heatmap"))return;loadingState.lfgHeatmap||(loadingState.lfgHeatmap=__vitePreload(()=>import("./heatmap-BojFLSXV.js"),[]));const{initLfgHeatmap:e}=await loadingState.lfgHeatmap;await e()}function initPage(){initNavigation(),initQuickEventForm(),initMaps(),initCropper(),initProfileCropper(),initLfgHeatmap()}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",initPage):initPage();document.body.addEventListener("htmx:afterSettle",()=>{initMaps(),initCropper(),initProfileCropper(),initLfgHeatmap()});const SmokesignalApp={lfgForm,eventForm,initEventMap,initGlobeMap,initLocationHeatmap,initMaps,initCropper,initProfileCropper,initLfgHeatmap,initPage,refreshSession,refreshAuth,authFetch,authPostJson,SessionExpiredError,AuthRequiredError};window.SmokesignalApp=SmokesignalApp;export{SessionExpiredError as S,__vitePreload as _,authFetch as a,addHexagonLayers as b,createMap as c,calculateBounds as d,heatmapGradientColor as e,h3ToGeoJsonFeature as h,loadMapLibraries as l,toMapCenter as t,updateHexagonSource as u};
+811
static/js/maps-Dzpg4_su.js
··· 1 + var Om=Object.defineProperty;var Vm=(pe,Q,be)=>Q in pe?Om(pe,Q,{enumerable:!0,configurable:!0,writable:!0,value:be}):pe[Q]=be;var er=(pe,Q,be)=>Vm(pe,typeof Q!="symbol"?Q+"":Q,be);function jm(pe,Q){for(var be=0;be<Q.length;be++){const Ie=Q[be];if(typeof Ie!="string"&&!Array.isArray(Ie)){for(const We in Ie)if(We!=="default"&&!(We in pe)){const it=Object.getOwnPropertyDescriptor(Ie,We);it&&Object.defineProperty(pe,We,it.get?it:{enumerable:!0,get:()=>Ie[We]})}}}return Object.freeze(Object.defineProperty(pe,Symbol.toStringTag,{value:"Module"}))}function Nm(pe){return pe&&pe.__esModule&&Object.prototype.hasOwnProperty.call(pe,"default")?pe.default:pe}var bc={exports:{}};/** 2 + * MapLibre GL JS 3 + * @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v5.16.0/LICENSE.txt 4 + */var Gm=bc.exports,Up;function Um(){return Up||(Up=1,(function(pe,Q){(function(be,Ie){pe.exports=Ie()})(Gm,(function(){var be={},Ie={};function We(G,d,nt){if(Ie[G]=nt,G==="index"){var Vr="var sharedModule = {}; ("+Ie.shared+")(sharedModule); ("+Ie.worker+")(sharedModule);",si={};return Ie.shared(si),Ie.index(be,si),typeof window<"u"&&be.setWorkerUrl(window.URL.createObjectURL(new Blob([Vr],{type:"text/javascript"}))),be}}We("shared",["exports"],(function(G){function d(i,e,r,s){return new(r||(r=Promise))((function(c,p){function m(E){try{T(s.next(E))}catch(S){p(S)}}function v(E){try{T(s.throw(E))}catch(S){p(S)}}function T(E){var S;E.done?c(E.value):(S=E.value,S instanceof r?S:new r((function(k){k(S)}))).then(m,v)}T((s=s.apply(i,e||[])).next())}))}function nt(i,e){this.x=i,this.y=e}function Vr(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var si,kn;typeof SuppressedError=="function"&&SuppressedError,nt.prototype={clone(){return new nt(this.x,this.y)},add(i){return this.clone()._add(i)},sub(i){return this.clone()._sub(i)},multByPoint(i){return this.clone()._multByPoint(i)},divByPoint(i){return this.clone()._divByPoint(i)},mult(i){return this.clone()._mult(i)},div(i){return this.clone()._div(i)},rotate(i){return this.clone()._rotate(i)},rotateAround(i,e){return this.clone()._rotateAround(i,e)},matMult(i){return this.clone()._matMult(i)},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(i){return this.x===i.x&&this.y===i.y},dist(i){return Math.sqrt(this.distSqr(i))},distSqr(i){const e=i.x-this.x,r=i.y-this.y;return e*e+r*r},angle(){return Math.atan2(this.y,this.x)},angleTo(i){return Math.atan2(this.y-i.y,this.x-i.x)},angleWith(i){return this.angleWithSep(i.x,i.y)},angleWithSep(i,e){return Math.atan2(this.x*e-this.y*i,this.x*i+this.y*e)},_matMult(i){const e=i[2]*this.x+i[3]*this.y;return this.x=i[0]*this.x+i[1]*this.y,this.y=e,this},_add(i){return this.x+=i.x,this.y+=i.y,this},_sub(i){return this.x-=i.x,this.y-=i.y,this},_mult(i){return this.x*=i,this.y*=i,this},_div(i){return this.x/=i,this.y/=i,this},_multByPoint(i){return this.x*=i.x,this.y*=i.y,this},_divByPoint(i){return this.x/=i.x,this.y/=i.y,this},_unit(){return this._div(this.mag()),this},_perp(){const i=this.y;return this.y=this.x,this.x=-i,this},_rotate(i){const e=Math.cos(i),r=Math.sin(i),s=r*this.x+e*this.y;return this.x=e*this.x-r*this.y,this.y=s,this},_rotateAround(i,e){const r=Math.cos(i),s=Math.sin(i),c=e.y+s*(this.x-e.x)+r*(this.y-e.y);return this.x=e.x+r*(this.x-e.x)-s*(this.y-e.y),this.y=c,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:nt},nt.convert=function(i){if(i instanceof nt)return i;if(Array.isArray(i))return new nt(+i[0],+i[1]);if(i.x!==void 0&&i.y!==void 0)return new nt(+i.x,+i.y);throw new Error("Expected [x, y] or {x, y} point format")};var bs=(function(){if(kn)return si;function i(e,r,s,c){this.cx=3*e,this.bx=3*(s-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*r,this.by=3*(c-r)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=r,this.p2x=s,this.p2y=c}return kn=1,si=i,i.prototype={sampleCurveX:function(e){return((this.ax*e+this.bx)*e+this.cx)*e},sampleCurveY:function(e){return((this.ay*e+this.by)*e+this.cy)*e},sampleCurveDerivativeX:function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},solveCurveX:function(e,r){if(r===void 0&&(r=1e-6),e<0)return 0;if(e>1)return 1;for(var s=e,c=0;c<8;c++){var p=this.sampleCurveX(s)-e;if(Math.abs(p)<r)return s;var m=this.sampleCurveDerivativeX(s);if(Math.abs(m)<1e-6)break;s-=p/m}var v=0,T=1;for(s=e,c=0;c<20&&(p=this.sampleCurveX(s),!(Math.abs(p-e)<r));c++)e>p?v=s:T=s,s=.5*(T-v)+v;return s},solve:function(e,r){return this.sampleCurveY(this.solveCurveX(e,r))}},si})(),hi=Vr(bs);let ss,Ar;function Ze(){return ss==null&&(ss=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")&&typeof createImageBitmap=="function"),ss}function Gs(){if(Ar==null&&(Ar=!1,Ze())){const e=new OffscreenCanvas(5,5).getContext("2d",{willReadFrequently:!0});if(e){for(let s=0;s<25;s++){const c=4*s;e.fillStyle=`rgb(${c},${c+1},${c+2})`,e.fillRect(s%5,Math.floor(s/5),1,1)}const r=e.getImageData(0,0,5,5).data;for(let s=0;s<100;s++)if(s%4!=3&&r[s]!==s){Ar=!0;break}}}return Ar||!1}var jr=1e-6,Rr=typeof Float32Array<"u"?Float32Array:Array;function Us(){var i=new Rr(9);return Rr!=Float32Array&&(i[1]=0,i[2]=0,i[3]=0,i[5]=0,i[6]=0,i[7]=0),i[0]=1,i[4]=1,i[8]=1,i}function yo(i){return i[0]=1,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=1,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=1,i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,i}function ws(){var i=new Rr(3);return Rr!=Float32Array&&(i[0]=0,i[1]=0,i[2]=0),i}function Yi(i){var e=i[0],r=i[1],s=i[2];return Math.sqrt(e*e+r*r+s*s)}function vo(i,e,r){var s=new Rr(3);return s[0]=i,s[1]=e,s[2]=r,s}function Ts(i,e,r){return i[0]=e[0]+r[0],i[1]=e[1]+r[1],i[2]=e[2]+r[2],i}function Qn(i,e,r){return i[0]=e[0]*r,i[1]=e[1]*r,i[2]=e[2]*r,i}function xn(i,e,r){var s=e[0],c=e[1],p=e[2],m=r[0],v=r[1],T=r[2];return i[0]=c*T-p*v,i[1]=p*m-s*T,i[2]=s*v-c*m,i}var Ti,Gi=Yi;function qs(i,e,r){var s=e[0],c=e[1],p=e[2],m=e[3];return i[0]=r[0]*s+r[4]*c+r[8]*p+r[12]*m,i[1]=r[1]*s+r[5]*c+r[9]*p+r[13]*m,i[2]=r[2]*s+r[6]*c+r[10]*p+r[14]*m,i[3]=r[3]*s+r[7]*c+r[11]*p+r[15]*m,i}function Ki(){var i=new Rr(4);return Rr!=Float32Array&&(i[0]=0,i[1]=0,i[2]=0),i[3]=1,i}function xo(i,e,r,s){var c=arguments.length>4&&arguments[4]!==void 0?arguments[4]:"zyx",p=Math.PI/360;e*=p,s*=p,r*=p;var m=Math.sin(e),v=Math.cos(e),T=Math.sin(r),E=Math.cos(r),S=Math.sin(s),k=Math.cos(s);switch(c){case"xyz":i[0]=m*E*k+v*T*S,i[1]=v*T*k-m*E*S,i[2]=v*E*S+m*T*k,i[3]=v*E*k-m*T*S;break;case"xzy":i[0]=m*E*k-v*T*S,i[1]=v*T*k-m*E*S,i[2]=v*E*S+m*T*k,i[3]=v*E*k+m*T*S;break;case"yxz":i[0]=m*E*k+v*T*S,i[1]=v*T*k-m*E*S,i[2]=v*E*S-m*T*k,i[3]=v*E*k+m*T*S;break;case"yzx":i[0]=m*E*k+v*T*S,i[1]=v*T*k+m*E*S,i[2]=v*E*S-m*T*k,i[3]=v*E*k-m*T*S;break;case"zxy":i[0]=m*E*k-v*T*S,i[1]=v*T*k+m*E*S,i[2]=v*E*S+m*T*k,i[3]=v*E*k-m*T*S;break;case"zyx":i[0]=m*E*k-v*T*S,i[1]=v*T*k+m*E*S,i[2]=v*E*S-m*T*k,i[3]=v*E*k+m*T*S;break;default:throw new Error("Unknown angle order "+c)}return i}function Ui(){var i=new Rr(2);return Rr!=Float32Array&&(i[0]=0,i[1]=0),i}function Ps(i,e){var r=new Rr(2);return r[0]=i,r[1]=e,r}ws(),Ti=new Rr(4),Rr!=Float32Array&&(Ti[0]=0,Ti[1]=0,Ti[2]=0,Ti[3]=0),ws(),vo(1,0,0),vo(0,1,0),Ki(),Ki(),Us(),Ui();const dr=8192;function Zs(i,e,r){return e*(dr/(i.tileSize*Math.pow(2,r-i.tileID.overscaledZ)))}function $n(i,e){return(i%e+e)%e}function os(i,e,r){return i*(1-r)+e*r}function bo(i){if(i<=0)return 0;if(i>=1)return 1;const e=i*i,r=e*i;return 4*(i<.5?r:3*(i-e)+r-.75)}function Qs(i,e,r,s){const c=new hi(i,e,r,s);return p=>c.solve(p)}const Si=Qs(.25,.1,.25,1);function bn(i,e,r){return Math.min(r,Math.max(e,i))}function as(i,e,r){const s=r-e,c=((i-e)%s+s)%s+e;return c===e?r:c}function qi(i,...e){for(const r of e)for(const s in r)i[s]=r[s];return i}let $s=1;function zn(i,e,r){const s={};for(const c in i)s[c]=e.call(this,i[c],c,i);return s}function na(i,e,r){const s={};for(const c in i)e.call(this,i[c],c,i)&&(s[c]=i[c]);return s}function Bn(i){return Array.isArray(i)?i.map(Bn):typeof i=="object"&&i?zn(i,Bn):i}const sa={};function di(i){sa[i]||(typeof console<"u"&&console.warn(i),sa[i]=!0)}function wn(i,e,r){return(r.y-i.y)*(e.x-i.x)>(e.y-i.y)*(r.x-i.x)}function Wn(i){return typeof WorkerGlobalScope<"u"&&i!==void 0&&i instanceof WorkerGlobalScope}let xr=null;function Tn(i){return typeof ImageBitmap<"u"&&i instanceof ImageBitmap}const Ws="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function wo(i,e,r,s,c){return d(this,void 0,void 0,(function*(){if(typeof VideoFrame>"u")throw new Error("VideoFrame not supported");const p=new VideoFrame(i,{timestamp:0});try{const m=p==null?void 0:p.format;if(!m||!m.startsWith("BGR")&&!m.startsWith("RGB"))throw new Error(`Unrecognized format ${m}`);const v=m.startsWith("BGR"),T=new Uint8ClampedArray(s*c*4);if(yield p.copyTo(T,(function(E,S,k,R,L){const j=4*Math.max(-S,0),N=(Math.max(0,k)-k)*R*4+j,q=4*R,Y=Math.max(0,S),ue=Math.max(0,k);return{rect:{x:Y,y:ue,width:Math.min(E.width,S+R)-Y,height:Math.min(E.height,k+L)-ue},layout:[{offset:N,stride:q}]}})(i,e,r,s,c)),v)for(let E=0;E<T.length;E+=4){const S=T[E];T[E]=T[E+2],T[E+2]=S}return T}finally{p.close()}}))}let Ci,fn;function Hs(i,e,r,s){return i.addEventListener(e,r,s),{unsubscribe:()=>{i.removeEventListener(e,r,s)}}}function Rn(i){return i*Math.PI/180}function Di(i){return i/Math.PI*180}const De={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},W={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0},$="AbortError";class te extends Error{constructor(e=$){super(e instanceof Error?e.message:e),this.name=$,e instanceof Error&&e.stack&&(this.stack=e.stack)}}function _e(i){return i.name===$}const ve={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function Re(i){return ve.REGISTERED_PROTOCOLS[i.substring(0,i.indexOf("://"))]}const Ce="global-dispatcher";class Te extends Error{constructor(e,r,s,c){super(`AJAXError: ${r} (${e}): ${s}`),this.status=e,this.statusText=r,this.url=s,this.body=c}}const je=()=>Wn(self)?self.worker&&self.worker.referrer:(window.location.protocol==="blob:"?window.parent:window).location.href,tt=function(i,e){if(/:\/\//.test(i.url)&&!/^https?:|^file:/.test(i.url)){const s=Re(i.url);if(s)return s(i,e);if(Wn(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:i,targetMapId:Ce},e)}if(!(/^file:/.test(r=i.url)||/^file:/.test(je())&&!/^\w+:/.test(r))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return(function(s,c){return d(this,void 0,void 0,(function*(){const p=new Request(s.url,{method:s.method||"GET",body:s.body,credentials:s.credentials,headers:s.headers,cache:s.cache,referrer:je(),signal:c.signal});let m,v;s.type!=="json"||p.headers.has("Accept")||p.headers.set("Accept","application/json");try{m=yield fetch(p)}catch(E){throw _e(E)?E:new Te(0,E.message,s.url,new Blob)}if(!m.ok){const E=yield m.blob();throw new Te(m.status,m.statusText,s.url,E)}v=s.type==="arrayBuffer"||s.type==="image"?m.arrayBuffer():s.type==="json"?m.json():m.text();const T=yield v;return c.signal.throwIfAborted(),{data:T,cacheControl:m.headers.get("Cache-Control"),expires:m.headers.get("Expires")}}))})(i,e);if(Wn(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:i,mustQueue:!0,targetMapId:Ce},e)}var r;return(function(s,c){return new Promise(((p,m)=>{var v;const T=new XMLHttpRequest;T.open(s.method||"GET",s.url,!0),s.type!=="arrayBuffer"&&s.type!=="image"||(T.responseType="arraybuffer");for(const E in s.headers)T.setRequestHeader(E,s.headers[E]);s.type==="json"&&(T.responseType="text",!((v=s.headers)===null||v===void 0)&&v.Accept||T.setRequestHeader("Accept","application/json")),T.withCredentials=s.credentials==="include",T.onerror=()=>{m(new Error(T.statusText))},T.onload=()=>{if(!c.signal.aborted)if((T.status>=200&&T.status<300||T.status===0)&&T.response!==null){let E=T.response;if(s.type==="json")try{E=JSON.parse(T.response)}catch(S){return void m(S)}p({data:E,cacheControl:T.getResponseHeader("Cache-Control"),expires:T.getResponseHeader("Expires")})}else{const E=new Blob([T.response],{type:T.getResponseHeader("Content-Type")});m(new Te(T.status,T.statusText,s.url,E))}},c.signal.addEventListener("abort",(()=>{T.abort(),m(new te(c.signal.reason))})),T.send(s.body)}))})(i,e)};function Ke(i){if(!i||i.indexOf("://")<=0||i.indexOf("data:image/")===0||i.indexOf("blob:")===0)return!0;const e=new URL(i),r=window.location;return e.protocol===r.protocol&&e.host===r.host}function _t(i,e,r){r[i]&&r[i].indexOf(e)!==-1||(r[i]=r[i]||[],r[i].push(e))}function Be(i,e,r){if(r&&r[i]){const s=r[i].indexOf(e);s!==-1&&r[i].splice(s,1)}}class Vt{constructor(e,r={}){qi(this,r),this.type=e}}class gr extends Vt{constructor(e,r={}){super("error",qi({error:e},r))}}class hr{on(e,r){return this._listeners=this._listeners||{},_t(e,r,this._listeners),{unsubscribe:()=>{this.off(e,r)}}}off(e,r){return Be(e,r,this._listeners),Be(e,r,this._oneTimeListeners),this}once(e,r){return r?(this._oneTimeListeners=this._oneTimeListeners||{},_t(e,r,this._oneTimeListeners),this):new Promise((s=>this.once(e,s)))}fire(e,r){typeof e=="string"&&(e=new Vt(e,r||{}));const s=e.type;if(this.listens(s)){e.target=this;const c=this._listeners&&this._listeners[s]?this._listeners[s].slice():[];for(const v of c)v.call(this,e);const p=this._oneTimeListeners&&this._oneTimeListeners[s]?this._oneTimeListeners[s].slice():[];for(const v of p)Be(s,v,this._oneTimeListeners),v.call(this,e);const m=this._eventedParent;m&&(qi(e,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),m.fire(e))}else e instanceof gr&&console.error(e.error);return this}listens(e){return this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e)}setEventedParent(e,r){return this._eventedParent=e,this._eventedParentData=r,this}}var Le={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number",length:2},centerAltitude:{type:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},roll:{type:"number",default:0,units:"degrees"},state:{type:"state",default:{}},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},"font-faces":{type:"fontFaces"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},encoding:{type:"enum",values:{mvt:{},mlt:{}},default:"mvt"},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"filter"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},"color-relief":{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_color-relief","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"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"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},"layout_color-relief":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},filter:{type:"boolean",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"expression_name",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"projectionDefinition",default:"mercator","property-type":"data-constant",transition:!1,expression:{interpolated:!0,parameters:["zoom"]}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_color-relief","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"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"}},"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"}},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 _r=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function mi(i,e){const r={};for(const s in i)s!=="ref"&&(r[s]=i[s]);return _r.forEach((s=>{s in e&&(r[s]=e[s])})),r}function Lt(i,e){if(Array.isArray(i)){if(!Array.isArray(e)||i.length!==e.length)return!1;for(let r=0;r<i.length;r++)if(!Lt(i[r],e[r]))return!1;return!0}if(typeof i=="object"&&i!==null&&e!==null){if(typeof e!="object"||Object.keys(i).length!==Object.keys(e).length)return!1;for(const r in i)if(!Lt(i[r],e[r]))return!1;return!0}return i===e}function mr(i,e){i.push(e)}function oi(i,e,r){mr(r,{command:"addSource",args:[i,e[i]]})}function Pr(i,e,r){mr(e,{command:"removeSource",args:[i]}),r[i]=!0}function Mr(i,e,r,s){Pr(i,r,s),oi(i,e,r)}function ke(i,e,r){let s;for(s in i[r])if(Object.prototype.hasOwnProperty.call(i[r],s)&&s!=="data"&&!Lt(i[r][s],e[r][s]))return!1;for(s in e[r])if(Object.prototype.hasOwnProperty.call(e[r],s)&&s!=="data"&&!Lt(i[r][s],e[r][s]))return!1;return!0}function Xe(i,e,r,s,c,p){i=i||{},e=e||{};for(const m in i)Object.prototype.hasOwnProperty.call(i,m)&&(Lt(i[m],e[m])||r.push({command:p,args:[s,m,e[m],c]}));for(const m in e)Object.prototype.hasOwnProperty.call(e,m)&&!Object.prototype.hasOwnProperty.call(i,m)&&(Lt(i[m],e[m])||r.push({command:p,args:[s,m,e[m],c]}))}function vt(i){return i.id}function ot(i,e){return i[e.id]=e,i}class o{constructor(e,r,s,c){this.message=(e?`${e}: `:"")+s,c&&(this.identifier=c),r!=null&&r.__line__&&(this.line=r.__line__)}}function Z(i,...e){for(const r of e)for(const s in r)i[s]=r[s];return i}class Ut extends Error{constructor(e,r){super(r),this.message=r,this.key=e}}class pr{constructor(e,r=[]){this.parent=e,this.bindings={};for(const[s,c]of r)this.bindings[s]=c}concat(e){return new pr(this,e)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw new Error(`${e} not found in scope.`)}has(e){return!!this.bindings[e]||!!this.parent&&this.parent.has(e)}}const br={kind:"null"},Je={kind:"number"},wt={kind:"string"},Ft={kind:"boolean"},Jt={kind:"color"},Yt={kind:"projectionDefinition"},ai={kind:"object"},qt={kind:"value"},oa={kind:"collator"},Xs={kind:"formatted"},Zi={kind:"padding"},Ln={kind:"colorArray"},Ji={kind:"numberArray"},Ms={kind:"resolvedImage"},aa={kind:"variableAnchorOffsetCollection"};function Zr(i,e){return{kind:"array",itemType:i,N:e}}function Pt(i){if(i.kind==="array"){const e=Pt(i.itemType);return typeof i.N=="number"?`array<${e}, ${i.N}>`:i.itemType.kind==="value"?"array":`array<${e}>`}return i.kind}const ee=[br,Je,wt,Ft,Jt,Yt,Xs,ai,Zr(qt),Zi,Ji,Ln,Ms,aa];function zt(i,e){if(e.kind==="error")return null;if(i.kind==="array"){if(e.kind==="array"&&(e.N===0&&e.itemType.kind==="value"||!zt(i.itemType,e.itemType))&&(typeof i.N!="number"||i.N===e.N))return null}else{if(i.kind===e.kind)return null;if(i.kind==="value"){for(const r of ee)if(!zt(r,e))return null}}return`Expected ${Pt(i)} but found ${Pt(e)} instead.`}function To(i,e){return e.some((r=>r.kind===i.kind))}function Ys(i,e){return e.some((r=>r==="null"?i===null:r==="array"?Array.isArray(i):r==="object"?i&&!Array.isArray(i)&&typeof i=="object":r===typeof i))}function Fn(i,e){return i.kind==="array"&&e.kind==="array"?i.itemType.kind===e.itemType.kind&&typeof i.N=="number":i.kind===e.kind}const Kl=.96422,Ks=.82521,H=4/29,Qr=6/29,Jl=3*Qr*Qr,eA=Qr*Qr*Qr,la=Math.PI/180,tA=180/Math.PI;function rA(i){return(i%=360)<0&&(i+=360),i}function ul([i,e,r,s]){let c,p;const m=La((.2225045*(i=Aa(i))+.7168786*(e=Aa(e))+.0606169*(r=Aa(r)))/1);i===e&&e===r?c=p=m:(c=La((.4360747*i+.3850649*e+.1430804*r)/Kl),p=La((.0139322*i+.0971045*e+.7141733*r)/Ks));const v=116*m-16;return[v<0?0:v,500*(c-m),200*(m-p),s]}function Aa(i){return i<=.04045?i/12.92:Math.pow((i+.055)/1.055,2.4)}function La(i){return i>eA?Math.pow(i,1/3):i/Jl+H}function Pn([i,e,r,s]){let c=(i+16)/116,p=isNaN(e)?c:c+e/500,m=isNaN(r)?c:c-r/200;return c=1*cl(c),p=Kl*cl(p),m=Ks*cl(m),[li(3.1338561*p-1.6168667*c-.4906146*m),li(-.9787684*p+1.9161415*c+.033454*m),li(.0719453*p-.2289914*c+1.4052427*m),s]}function li(i){return(i=i<=.00304?12.92*i:1.055*Math.pow(i,1/2.4)-.055)<0?0:i>1?1:i}function cl(i){return i>Qr?i*i*i:Jl*(i-H)}const iA=Object.hasOwn||function(i,e){return Object.prototype.hasOwnProperty.call(i,e)};function ua(i,e){return iA(i,e)?i[e]:void 0}function Po(i){return parseInt(i.padEnd(2,i),16)/255}function nA(i,e){return Js(e?i/100:i,0,1)}function Js(i,e,r){return Math.min(Math.max(e,i),r)}function hl(i){return!i.some(Number.isNaN)}const ca={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 Es(i,e,r){return i+r*(e-i)}function yr(i,e,r){return i.map(((s,c)=>Es(s,e[c],r)))}class Kt{constructor(e,r,s,c=1,p=!0){this.r=e,this.g=r,this.b=s,this.a=c,p||(this.r*=c,this.g*=c,this.b*=c,c||this.overwriteGetter("rgb",[e,r,s,c]))}static parse(e){if(e instanceof Kt)return e;if(typeof e!="string")return;const r=(function(s){if((s=s.toLowerCase().trim())==="transparent")return[0,0,0,0];const c=ua(ca,s);if(c){const[m,v,T]=c;return[m/255,v/255,T/255,1]}if(s.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(s)){const m=s.length<6?1:2;let v=1;return[Po(s.slice(v,v+=m)),Po(s.slice(v,v+=m)),Po(s.slice(v,v+=m)),Po(s.slice(v,v+m)||"ff")]}if(s.startsWith("rgb")){const m=s.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(m){const[v,T,E,S,k,R,L,j,N,q,Y,ue]=m,J=[S||" ",L||" ",q].join("");if(J===" "||J===" /"||J===",,"||J===",,,"){const re=[E,R,N].join(""),he=re==="%%%"?100:re===""?255:0;if(he){const me=[Js(+T/he,0,1),Js(+k/he,0,1),Js(+j/he,0,1),Y?nA(+Y,ue):1];if(hl(me))return me}}return}}const p=s.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(p){const[m,v,T,E,S,k,R,L,j]=p,N=[T||" ",S||" ",R].join("");if(N===" "||N===" /"||N===",,"||N===",,,"){const q=[+v,Js(+E,0,100),Js(+k,0,100),L?nA(+L,j):1];if(hl(q))return(function([Y,ue,J,re]){function he(me){const ze=(me+Y/30)%12,He=ue*Math.min(J,1-J);return J-He*Math.max(-1,Math.min(ze-3,9-ze,1))}return Y=rA(Y),ue/=100,J/=100,[he(0),he(8),he(4),re]})(q)}}})(e);return r?new Kt(...r,!1):void 0}get rgb(){const{r:e,g:r,b:s,a:c}=this,p=c||1/0;return this.overwriteGetter("rgb",[e/p,r/p,s/p,c])}get hcl(){return this.overwriteGetter("hcl",(function(e){const[r,s,c,p]=ul(e),m=Math.sqrt(s*s+c*c);return[Math.round(1e4*m)?rA(Math.atan2(c,s)*tA):NaN,m,r,p]})(this.rgb))}get lab(){return this.overwriteGetter("lab",ul(this.rgb))}overwriteGetter(e,r){return Object.defineProperty(this,e,{value:r}),r}toString(){const[e,r,s,c]=this.rgb;return`rgba(${[e,r,s].map((p=>Math.round(255*p))).join(",")},${c})`}static interpolate(e,r,s,c="rgb"){switch(c){case"rgb":{const[p,m,v,T]=yr(e.rgb,r.rgb,s);return new Kt(p,m,v,T,!1)}case"hcl":{const[p,m,v,T]=e.hcl,[E,S,k,R]=r.hcl;let L,j;if(isNaN(p)||isNaN(E))isNaN(p)?isNaN(E)?L=NaN:(L=E,v!==1&&v!==0||(j=S)):(L=p,k!==1&&k!==0||(j=m));else{let J=E-p;E>p&&J>180?J-=360:E<p&&p-E>180&&(J+=360),L=p+s*J}const[N,q,Y,ue]=(function([J,re,he,me]){return J=isNaN(J)?0:J*la,Pn([he,Math.cos(J)*re,Math.sin(J)*re,me])})([L,j??Es(m,S,s),Es(v,k,s),Es(T,R,s)]);return new Kt(N,q,Y,ue,!1)}case"lab":{const[p,m,v,T]=Pn(yr(e.lab,r.lab,s));return new Kt(p,m,v,T,!1)}}}}Kt.black=new Kt(0,0,0,1),Kt.white=new Kt(1,1,1,1),Kt.transparent=new Kt(0,0,0,0),Kt.red=new Kt(1,0,0,1);class Fa{constructor(e,r,s){this.sensitivity=e?r?"variant":"case":r?"accent":"base",this.locale=s,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,r){return this.collator.compare(e,r)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}const su=["bottom","center","top"];class pl{constructor(e,r,s,c,p,m){this.text=e,this.image=r,this.scale=s,this.fontStack=c,this.textColor=p,this.verticalAlign=m}}class en{constructor(e){this.sections=e}static fromString(e){return new en([new pl(e,null,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some((e=>e.text.length!==0||e.image&&e.image.name.length!==0))}static factory(e){return e instanceof en?e:en.fromString(e)}toString(){return this.sections.length===0?"":this.sections.map((e=>e.text)).join("")}}class Pi{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Pi)return e;if(typeof e=="number")return new Pi([e,e,e,e]);if(Array.isArray(e)&&!(e.length<1||e.length>4)){for(const r of e)if(typeof r!="number")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 Pi(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,r,s){return new Pi(yr(e.values,r.values,s))}}class Cr{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Cr)return e;if(typeof e=="number")return new Cr([e]);if(Array.isArray(e)){for(const r of e)if(typeof r!="number")return;return new Cr(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,r,s){return new Cr(yr(e.values,r.values,s))}}class Bt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Bt)return e;if(typeof e=="string"){const s=Kt.parse(e);return s?new Bt([s]):void 0}if(!Array.isArray(e))return;const r=[];for(const s of e){if(typeof s!="string")return;const c=Kt.parse(s);if(!c)return;r.push(c)}return new Bt(r)}toString(){return JSON.stringify(this.values)}static interpolate(e,r,s,c="rgb"){const p=[];if(e.values.length!=r.values.length)throw new Error(`colorArray: Arrays have mismatched length (${e.values.length} vs. ${r.values.length}), cannot interpolate.`);for(let m=0;m<e.values.length;m++)p.push(Kt.interpolate(e.values[m],r.values[m],s,c));return new Bt(p)}}class Er extends Error{constructor(e){super(e),this.name="RuntimeError"}toJSON(){return this.message}}const Is=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class Qi{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Qi)return e;if(Array.isArray(e)&&!(e.length<1)&&e.length%2==0){for(let r=0;r<e.length;r+=2){const s=e[r],c=e[r+1];if(typeof s!="string"||!Is.has(s)||!Array.isArray(c)||c.length!==2||typeof c[0]!="number"||typeof c[1]!="number")return}return new Qi(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,r,s){const c=e.values,p=r.values;if(c.length!==p.length)throw new Er(`Cannot interpolate values of different length. from: ${e.toString()}, to: ${r.toString()}`);const m=[];for(let v=0;v<c.length;v+=2){if(c[v]!==p[v])throw new Er(`Cannot interpolate values containing mismatched anchors. from[${v}]: ${c[v]}, to[${v}]: ${p[v]}`);m.push(c[v]);const[T,E]=c[v+1],[S,k]=p[v+1];m.push([Es(T,S,s),Es(E,k,s)])}return new Qi(m)}}class tn{constructor(e){this.name=e.name,this.available=e.available}toString(){return this.name}static fromString(e){return e?new tn({name:e,available:!1}):null}}class $i{constructor(e,r,s){this.from=e,this.to=r,this.transition=s}static interpolate(e,r,s){return new $i(e,r,s)}static parse(e){return e instanceof $i?e:Array.isArray(e)&&e.length===3&&typeof e[0]=="string"&&typeof e[1]=="string"&&typeof e[2]=="number"?new $i(e[0],e[1],e[2]):typeof e=="object"&&typeof e.from=="string"&&typeof e.to=="string"&&typeof e.transition=="number"?new $i(e.from,e.to,e.transition):typeof e=="string"?new $i(e,e,1):void 0}}function Ss(i,e,r,s){return typeof i=="number"&&i>=0&&i<=255&&typeof e=="number"&&e>=0&&e<=255&&typeof r=="number"&&r>=0&&r<=255?s===void 0||typeof s=="number"&&s>=0&&s<=1?null:`Invalid rgba value [${[i,e,r,s].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof s=="number"?[i,e,r,s]:[i,e,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Hn(i){if(i===null||typeof i=="string"||typeof i=="boolean"||typeof i=="number"||i instanceof $i||i instanceof Kt||i instanceof Fa||i instanceof en||i instanceof Pi||i instanceof Cr||i instanceof Bt||i instanceof Qi||i instanceof tn)return!0;if(Array.isArray(i)){for(const e of i)if(!Hn(e))return!1;return!0}if(typeof i=="object"){for(const e in i)if(!Hn(i[e]))return!1;return!0}return!1}function Kr(i){if(i===null)return br;if(typeof i=="string")return wt;if(typeof i=="boolean")return Ft;if(typeof i=="number")return Je;if(i instanceof Kt)return Jt;if(i instanceof $i)return Yt;if(i instanceof Fa)return oa;if(i instanceof en)return Xs;if(i instanceof Pi)return Zi;if(i instanceof Cr)return Ji;if(i instanceof Bt)return Ln;if(i instanceof Qi)return aa;if(i instanceof tn)return Ms;if(Array.isArray(i)){const e=i.length;let r;for(const s of i){const c=Kr(s);if(r){if(r===c)continue;r=qt;break}r=c}return Zr(r||qt,e)}return ai}function Cs(i){const e=typeof i;return i===null?"":e==="string"||e==="number"||e==="boolean"?String(i):i instanceof Kt||i instanceof $i||i instanceof en||i instanceof Pi||i instanceof Cr||i instanceof Bt||i instanceof Qi||i instanceof tn?i.toString():JSON.stringify(i)}class On{constructor(e,r){this.type=e,this.value=r}static parse(e,r){if(e.length!==2)return r.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!Hn(e[1]))return r.error("invalid value");const s=e[1];let c=Kr(s);const p=r.expectedType;return c.kind!=="array"||c.N!==0||!p||p.kind!=="array"||typeof p.N=="number"&&p.N!==0||(c=p),new On(c,s)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}const ha={string:wt,number:Je,boolean:Ft,object:ai};class rn{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");let s,c=1;const p=e[0];if(p==="array"){let v,T;if(e.length>2){const E=e[1];if(typeof E!="string"||!(E in ha)||E==="object")return r.error('The item type argument of "array" must be one of string, number, boolean',1);v=ha[E],c++}else v=qt;if(e.length>3){if(e[2]!==null&&(typeof e[2]!="number"||e[2]<0||e[2]!==Math.floor(e[2])))return r.error('The length argument to "array" must be a positive integer literal',2);T=e[2],c++}s=Zr(v,T)}else{if(!ha[p])throw new Error(`Types doesn't contain name = ${p}`);s=ha[p]}const m=[];for(;c<e.length;c++){const v=r.parse(e[c],c,qt);if(!v)return null;m.push(v)}return new rn(s,m)}evaluate(e){for(let r=0;r<this.args.length;r++){const s=this.args[r].evaluate(e);if(!zt(this.type,Kr(s)))return s;if(r===this.args.length-1)throw new Er(`Expected value to be of type ${Pt(this.type)}, but found ${Pt(Kr(s))} instead.`)}throw new Error}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}const eo={"to-boolean":Ft,"to-color":Jt,"to-number":Je,"to-string":wt};class ls{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");const s=e[0];if(!eo[s])throw new Error(`Can't parse ${s} as it is not part of the known types`);if((s==="to-boolean"||s==="to-string")&&e.length!==2)return r.error("Expected one argument.");const c=eo[s],p=[];for(let m=1;m<e.length;m++){const v=r.parse(e[m],m,qt);if(!v)return null;p.push(v)}return new ls(c,p)}evaluate(e){switch(this.type.kind){case"boolean":return!!this.args[0].evaluate(e);case"color":{let r,s;for(const c of this.args){if(r=c.evaluate(e),s=null,r instanceof Kt)return r;if(typeof r=="string"){const p=e.parseColor(r);if(p)return p}else if(Array.isArray(r)&&(s=r.length<3||r.length>4?`Invalid rgba value ${JSON.stringify(r)}: expected an array containing either three or four numeric values.`:Ss(r[0],r[1],r[2],r[3]),!s))return new Kt(r[0]/255,r[1]/255,r[2]/255,r[3])}throw new Er(s||`Could not parse color from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"padding":{let r;for(const s of this.args){r=s.evaluate(e);const c=Pi.parse(r);if(c)return c}throw new Er(`Could not parse padding from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"numberArray":{let r;for(const s of this.args){r=s.evaluate(e);const c=Cr.parse(r);if(c)return c}throw new Er(`Could not parse numberArray from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"colorArray":{let r;for(const s of this.args){r=s.evaluate(e);const c=Bt.parse(r);if(c)return c}throw new Er(`Could not parse colorArray from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"variableAnchorOffsetCollection":{let r;for(const s of this.args){r=s.evaluate(e);const c=Qi.parse(r);if(c)return c}throw new Er(`Could not parse variableAnchorOffsetCollection from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"number":{let r=null;for(const s of this.args){if(r=s.evaluate(e),r===null)return 0;const c=Number(r);if(!isNaN(c))return c}throw new Er(`Could not convert ${JSON.stringify(r)} to number.`)}case"formatted":return en.fromString(Cs(this.args[0].evaluate(e)));case"resolvedImage":return tn.fromString(Cs(this.args[0].evaluate(e)));case"projectionDefinition":return this.args[0].evaluate(e);default:return Cs(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}const sA=["Unknown","Point","LineString","Polygon"];class gi{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?typeof this.feature.type=="number"?sA[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(e){let r=this._parseColorCache.get(e);return r||(r=Kt.parse(e),this._parseColorCache.set(e,r)),r}}class dn{constructor(e,r,s=[],c,p=new pr,m=[]){this.registry=e,this.path=s,this.key=s.map((v=>`[${v}]`)).join(""),this.scope=p,this.errors=m,this.expectedType=c,this._isConstant=r}parse(e,r,s,c,p={}){return r?this.concat(r,s,c)._parse(e,p):this._parse(e,p)}_parse(e,r){function s(c,p,m){return m==="assert"?new rn(p,[c]):m==="coerce"?new ls(p,[c]):c}if(e!==null&&typeof e!="string"&&typeof e!="boolean"&&typeof e!="number"||(e=["literal",e]),Array.isArray(e)){if(e.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const c=e[0];if(typeof c!="string")return this.error(`Expression name must be a string, but found ${typeof c} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const p=this.registry[c];if(p){let m=p.parse(e,this);if(!m)return null;if(this.expectedType){const v=this.expectedType,T=m.type;if(v.kind!=="string"&&v.kind!=="number"&&v.kind!=="boolean"&&v.kind!=="object"&&v.kind!=="array"||T.kind!=="value"){if(v.kind==="projectionDefinition"&&["string","array"].includes(T.kind)||["color","formatted","resolvedImage"].includes(v.kind)&&["value","string"].includes(T.kind)||["padding","numberArray"].includes(v.kind)&&["value","number","array"].includes(T.kind)||v.kind==="colorArray"&&["value","string","array"].includes(T.kind)||v.kind==="variableAnchorOffsetCollection"&&["value","array"].includes(T.kind))m=s(m,v,r.typeAnnotation||"coerce");else if(this.checkSubtype(v,T))return null}else m=s(m,v,r.typeAnnotation||"assert")}if(!(m instanceof On)&&m.type.kind!=="resolvedImage"&&this._isConstant(m)){const v=new gi;try{m=new On(m.type,m.evaluate(v))}catch(T){return this.error(T.message),null}}return m}return this.error(`Unknown expression "${c}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(e===void 0?"'undefined' value invalid. Use null instead.":typeof e=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,r,s){const c=typeof e=="number"?this.path.concat(e):this.path,p=s?this.scope.concat(s):this.scope;return new dn(this.registry,this._isConstant,c,r||null,p,this.errors)}error(e,...r){const s=`${this.key}${r.map((c=>`[${c}]`)).join("")}`;this.errors.push(new Ut(s,e))}checkSubtype(e,r){const s=zt(e,r);return s&&this.error(s),s}}class rr{constructor(e,r){this.type=r.type,this.bindings=[].concat(e),this.result=r}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const r of this.bindings)e(r[1]);e(this.result)}static parse(e,r){if(e.length<4)return r.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const s=[];for(let p=1;p<e.length-1;p+=2){const m=e[p];if(typeof m!="string")return r.error(`Expected string, but found ${typeof m} instead.`,p);if(/[^a-zA-Z0-9_]/.test(m))return r.error("Variable names must contain only alphanumeric characters or '_'.",p);const v=r.parse(e[p+1],p+1);if(!v)return null;s.push([m,v])}const c=r.parse(e[e.length-1],e.length-1,r.expectedType,s);return c?new rr(s,c):null}outputDefined(){return this.result.outputDefined()}}class Ds{constructor(e,r){this.type=r.type,this.name=e,this.boundExpression=r}static parse(e,r){if(e.length!==2||typeof e[1]!="string")return r.error("'var' expression requires exactly one string literal argument.");const s=e[1];return r.scope.has(s)?new Ds(s,r.scope.get(s)):r.error(`Unknown variable "${s}". Make sure "${s}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}}class or{constructor(e,r,s){this.type=e,this.index=r,this.input=s}static parse(e,r){if(e.length!==3)return r.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const s=r.parse(e[1],1,Je),c=r.parse(e[2],2,Zr(r.expectedType||qt));return s&&c?new or(c.type.itemType,s,c):null}evaluate(e){const r=this.index.evaluate(e),s=this.input.evaluate(e);if(r<0)throw new Er(`Array index out of bounds: ${r} < 0.`);if(r>=s.length)throw new Er(`Array index out of bounds: ${r} > ${s.length-1}.`);if(r!==Math.floor(r))throw new Er(`Array index must be an integer, but found ${r} instead.`);return s[r]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}}class Zt{constructor(e,r){this.type=Ft,this.needle=e,this.haystack=r}static parse(e,r){if(e.length!==3)return r.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const s=r.parse(e[1],1,qt),c=r.parse(e[2],2,qt);return s&&c?To(s.type,[Ft,wt,Je,br,qt])?new Zt(s,c):r.error(`Expected first argument to be of type boolean, string, number or null, but found ${Pt(s.type)} instead`):null}evaluate(e){const r=this.needle.evaluate(e),s=this.haystack.evaluate(e);if(!s)return!1;if(!Ys(r,["boolean","string","number","null"]))throw new Er(`Expected first argument to be of type boolean, string, number or null, but found ${Pt(Kr(r))} instead.`);if(!Ys(s,["string","array"]))throw new Er(`Expected second argument to be of type array or string, but found ${Pt(Kr(s))} instead.`);return s.indexOf(r)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class Mo{constructor(e,r,s){this.type=Je,this.needle=e,this.haystack=r,this.fromIndex=s}static parse(e,r){if(e.length<=2||e.length>=5)return r.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);const s=r.parse(e[1],1,qt),c=r.parse(e[2],2,qt);if(!s||!c)return null;if(!To(s.type,[Ft,wt,Je,br,qt]))return r.error(`Expected first argument to be of type boolean, string, number or null, but found ${Pt(s.type)} instead`);if(e.length===4){const p=r.parse(e[3],3,Je);return p?new Mo(s,c,p):null}return new Mo(s,c)}evaluate(e){const r=this.needle.evaluate(e),s=this.haystack.evaluate(e);if(!Ys(r,["boolean","string","number","null"]))throw new Er(`Expected first argument to be of type boolean, string, number or null, but found ${Pt(Kr(r))} instead.`);let c;if(this.fromIndex&&(c=this.fromIndex.evaluate(e)),Ys(s,["string"])){const p=s.indexOf(r,c);return p===-1?-1:[...s.slice(0,p)].length}if(Ys(s,["array"]))return s.indexOf(r,c);throw new Er(`Expected second argument to be of type array or string, but found ${Pt(Kr(s))} instead.`)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class ur{constructor(e,r,s,c,p,m){this.inputType=e,this.type=r,this.input=s,this.cases=c,this.outputs=p,this.otherwise=m}static parse(e,r){if(e.length<5)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return r.error("Expected an even number of arguments.");let s,c;r.expectedType&&r.expectedType.kind!=="value"&&(c=r.expectedType);const p={},m=[];for(let E=2;E<e.length-1;E+=2){let S=e[E];const k=e[E+1];Array.isArray(S)||(S=[S]);const R=r.concat(E);if(S.length===0)return R.error("Expected at least one branch label.");for(const j of S){if(typeof j!="number"&&typeof j!="string")return R.error("Branch labels must be numbers or strings.");if(typeof j=="number"&&Math.abs(j)>Number.MAX_SAFE_INTEGER)return R.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof j=="number"&&Math.floor(j)!==j)return R.error("Numeric branch labels must be integer values.");if(s){if(R.checkSubtype(s,Kr(j)))return null}else s=Kr(j);if(p[String(j)]!==void 0)return R.error("Branch labels must be unique.");p[String(j)]=m.length}const L=r.parse(k,E,c);if(!L)return null;c=c||L.type,m.push(L)}const v=r.parse(e[1],1,qt);if(!v)return null;const T=r.parse(e[e.length-1],e.length-1,c);return T?v.type.kind!=="value"&&r.concat(1).checkSubtype(s,v.type)?null:new ur(s,c,v,p,m,T):null}evaluate(e){const r=this.input.evaluate(e);return(Kr(r)===this.inputType&&this.outputs[this.cases[r]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))&&this.otherwise.outputDefined()}}class pa{constructor(e,r,s){this.type=e,this.branches=r,this.otherwise=s}static parse(e,r){if(e.length<4)return r.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return r.error("Expected an odd number of arguments.");let s;r.expectedType&&r.expectedType.kind!=="value"&&(s=r.expectedType);const c=[];for(let m=1;m<e.length-1;m+=2){const v=r.parse(e[m],m,Ft);if(!v)return null;const T=r.parse(e[m+1],m+1,s);if(!T)return null;c.push([v,T]),s=s||T.type}const p=r.parse(e[e.length-1],e.length-1,s);if(!p)return null;if(!s)throw new Error("Can't infer output type");return new pa(s,c,p)}evaluate(e){for(const[r,s]of this.branches)if(r.evaluate(e))return s.evaluate(e);return this.otherwise.evaluate(e)}eachChild(e){for(const[r,s]of this.branches)e(r),e(s);e(this.otherwise)}outputDefined(){return this.branches.every((([e,r])=>r.outputDefined()))&&this.otherwise.outputDefined()}}class mn{constructor(e,r,s,c){this.type=e,this.input=r,this.beginIndex=s,this.endIndex=c}static parse(e,r){if(e.length<=2||e.length>=5)return r.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);const s=r.parse(e[1],1,qt),c=r.parse(e[2],2,Je);if(!s||!c)return null;if(!To(s.type,[Zr(qt),wt,qt]))return r.error(`Expected first argument to be of type array or string, but found ${Pt(s.type)} instead`);if(e.length===4){const p=r.parse(e[3],3,Je);return p?new mn(s.type,s,c,p):null}return new mn(s.type,s,c)}evaluate(e){const r=this.input.evaluate(e),s=this.beginIndex.evaluate(e);let c;if(this.endIndex&&(c=this.endIndex.evaluate(e)),Ys(r,["string"]))return[...r].slice(s,c).join("");if(Ys(r,["array"]))return r.slice(s,c);throw new Er(`Expected first argument to be of type array or string, but found ${Pt(Kr(r))} instead.`)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function As(i,e){const r=i.length-1;let s,c,p=0,m=r,v=0;for(;p<=m;)if(v=Math.floor((p+m)/2),s=i[v],c=i[v+1],s<=e){if(v===r||e<c)return v;p=v+1}else{if(!(s>e))throw new Er("Input is not a number.");m=v-1}return 0}class nn{constructor(e,r,s){this.type=e,this.input=r,this.labels=[],this.outputs=[];for(const[c,p]of s)this.labels.push(c),this.outputs.push(p)}static parse(e,r){if(e.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return r.error("Expected an even number of arguments.");const s=r.parse(e[1],1,Je);if(!s)return null;const c=[];let p=null;r.expectedType&&r.expectedType.kind!=="value"&&(p=r.expectedType);for(let m=1;m<e.length;m+=2){const v=m===1?-1/0:e[m],T=e[m+1],E=m,S=m+1;if(typeof v!="number")return r.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',E);if(c.length&&c[c.length-1][0]>=v)return r.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',E);const k=r.parse(T,S,p);if(!k)return null;p=p||k.type,c.push([v,k])}return new nn(p,s,c)}evaluate(e){const r=this.labels,s=this.outputs;if(r.length===1)return s[0].evaluate(e);const c=this.input.evaluate(e);if(c<=r[0])return s[0].evaluate(e);const p=r.length;return c>=r[p-1]?s[p-1].evaluate(e):s[As(r,c)].evaluate(e)}eachChild(e){e(this.input);for(const r of this.outputs)e(r)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function fl(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Eo,Io,to=(function(){if(Io)return Eo;function i(e,r,s,c){this.cx=3*e,this.bx=3*(s-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*r,this.by=3*(c-r)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=r,this.p2x=s,this.p2y=c}return Io=1,Eo=i,i.prototype={sampleCurveX:function(e){return((this.ax*e+this.bx)*e+this.cx)*e},sampleCurveY:function(e){return((this.ay*e+this.by)*e+this.cy)*e},sampleCurveDerivativeX:function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},solveCurveX:function(e,r){if(r===void 0&&(r=1e-6),e<0)return 0;if(e>1)return 1;for(var s=e,c=0;c<8;c++){var p=this.sampleCurveX(s)-e;if(Math.abs(p)<r)return s;var m=this.sampleCurveDerivativeX(s);if(Math.abs(m)<1e-6)break;s-=p/m}var v=0,T=1;for(s=e,c=0;c<20&&(p=this.sampleCurveX(s),!(Math.abs(p-e)<r));c++)e>p?v=s:T=s,s=.5*(T-v)+v;return s},solve:function(e,r){return this.sampleCurveY(this.solveCurveX(e,r))}},Eo})(),us=fl(to);class ki{constructor(e,r,s,c,p){this.type=e,this.operator=r,this.interpolation=s,this.input=c,this.labels=[],this.outputs=[];for(const[m,v]of p)this.labels.push(m),this.outputs.push(v)}static interpolationFactor(e,r,s,c){let p=0;if(e.name==="exponential")p=Vn(r,e.base,s,c);else if(e.name==="linear")p=Vn(r,1,s,c);else if(e.name==="cubic-bezier"){const m=e.controlPoints;p=new us(m[0],m[1],m[2],m[3]).solve(Vn(r,1,s,c))}return p}static parse(e,r){let[s,c,p,...m]=e;if(!Array.isArray(c)||c.length===0)return r.error("Expected an interpolation type expression.",1);if(c[0]==="linear")c={name:"linear"};else if(c[0]==="exponential"){const E=c[1];if(typeof E!="number")return r.error("Exponential interpolation requires a numeric base.",1,1);c={name:"exponential",base:E}}else{if(c[0]!=="cubic-bezier")return r.error(`Unknown interpolation type ${String(c[0])}`,1,0);{const E=c.slice(1);if(E.length!==4||E.some((S=>typeof S!="number"||S<0||S>1)))return r.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);c={name:"cubic-bezier",controlPoints:E}}}if(e.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return r.error("Expected an even number of arguments.");if(p=r.parse(p,2,Je),!p)return null;const v=[];let T=null;s!=="interpolate-hcl"&&s!=="interpolate-lab"||r.expectedType==Ln?r.expectedType&&r.expectedType.kind!=="value"&&(T=r.expectedType):T=Jt;for(let E=0;E<m.length;E+=2){const S=m[E],k=m[E+1],R=E+3,L=E+4;if(typeof S!="number")return r.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',R);if(v.length&&v[v.length-1][0]>=S)return r.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',R);const j=r.parse(k,L,T);if(!j)return null;T=T||j.type,v.push([S,j])}return Fn(T,Je)||Fn(T,Yt)||Fn(T,Jt)||Fn(T,Zi)||Fn(T,Ji)||Fn(T,Ln)||Fn(T,aa)||Fn(T,Zr(Je))?new ki(T,s,c,p,v):r.error(`Type ${Pt(T)} is not interpolatable.`)}evaluate(e){const r=this.labels,s=this.outputs;if(r.length===1)return s[0].evaluate(e);const c=this.input.evaluate(e);if(c<=r[0])return s[0].evaluate(e);const p=r.length;if(c>=r[p-1])return s[p-1].evaluate(e);const m=As(r,c),v=ki.interpolationFactor(this.interpolation,c,r[m],r[m+1]),T=s[m].evaluate(e),E=s[m+1].evaluate(e);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return Es(T,E,v);case"color":return Kt.interpolate(T,E,v);case"padding":return Pi.interpolate(T,E,v);case"colorArray":return Bt.interpolate(T,E,v);case"numberArray":return Cr.interpolate(T,E,v);case"variableAnchorOffsetCollection":return Qi.interpolate(T,E,v);case"array":return yr(T,E,v);case"projectionDefinition":return $i.interpolate(T,E,v)}case"interpolate-hcl":switch(this.type.kind){case"color":return Kt.interpolate(T,E,v,"hcl");case"colorArray":return Bt.interpolate(T,E,v,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return Kt.interpolate(T,E,v,"lab");case"colorArray":return Bt.interpolate(T,E,v,"lab")}}}eachChild(e){e(this.input);for(const r of this.outputs)e(r)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function Vn(i,e,r,s){const c=s-r,p=i-r;return c===0?0:e===1?p/c:(Math.pow(e,p)-1)/(Math.pow(e,c)-1)}const Sr={color:Kt.interpolate,number:Es,padding:Pi.interpolate,numberArray:Cr.interpolate,colorArray:Bt.interpolate,variableAnchorOffsetCollection:Qi.interpolate,array:yr};class ro{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");let s=null;const c=r.expectedType;c&&c.kind!=="value"&&(s=c);const p=[];for(const v of e.slice(1)){const T=r.parse(v,1+p.length,s,void 0,{typeAnnotation:"omit"});if(!T)return null;s=s||T.type,p.push(T)}if(!s)throw new Error("No output type");const m=c&&p.some((v=>zt(c,v.type)));return new ro(m?qt:s,p)}evaluate(e){let r,s=null,c=0;for(const p of this.args)if(c++,s=p.evaluate(e),s&&s instanceof tn&&!s.available&&(r||(r=s.name),s=null,c===this.args.length&&(s=r)),s!==null)break;return s}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}function dl(i,e){return i==="=="||i==="!="?e.kind==="boolean"||e.kind==="string"||e.kind==="number"||e.kind==="null"||e.kind==="value":e.kind==="string"||e.kind==="number"||e.kind==="value"}function So(i,e,r,s){return s.compare(e,r)===0}function $r(i,e,r){const s=i!=="=="&&i!=="!=";return class Wp{constructor(p,m,v){this.type=Ft,this.lhs=p,this.rhs=m,this.collator=v,this.hasUntypedArgument=p.type.kind==="value"||m.type.kind==="value"}static parse(p,m){if(p.length!==3&&p.length!==4)return m.error("Expected two or three arguments.");const v=p[0];let T=m.parse(p[1],1,qt);if(!T)return null;if(!dl(v,T.type))return m.concat(1).error(`"${v}" comparisons are not supported for type '${Pt(T.type)}'.`);let E=m.parse(p[2],2,qt);if(!E)return null;if(!dl(v,E.type))return m.concat(2).error(`"${v}" comparisons are not supported for type '${Pt(E.type)}'.`);if(T.type.kind!==E.type.kind&&T.type.kind!=="value"&&E.type.kind!=="value")return m.error(`Cannot compare types '${Pt(T.type)}' and '${Pt(E.type)}'.`);s&&(T.type.kind==="value"&&E.type.kind!=="value"?T=new rn(E.type,[T]):T.type.kind!=="value"&&E.type.kind==="value"&&(E=new rn(T.type,[E])));let S=null;if(p.length===4){if(T.type.kind!=="string"&&E.type.kind!=="string"&&T.type.kind!=="value"&&E.type.kind!=="value")return m.error("Cannot use collator to compare non-string types.");if(S=m.parse(p[3],3,oa),!S)return null}return new Wp(T,E,S)}evaluate(p){const m=this.lhs.evaluate(p),v=this.rhs.evaluate(p);if(s&&this.hasUntypedArgument){const T=Kr(m),E=Kr(v);if(T.kind!==E.kind||T.kind!=="string"&&T.kind!=="number")throw new Er(`Expected arguments for "${i}" to be (string, string) or (number, number), but found (${T.kind}, ${E.kind}) instead.`)}if(this.collator&&!s&&this.hasUntypedArgument){const T=Kr(m),E=Kr(v);if(T.kind!=="string"||E.kind!=="string")return e(p,m,v)}return this.collator?r(p,m,v,this.collator.evaluate(p)):e(p,m,v)}eachChild(p){p(this.lhs),p(this.rhs),this.collator&&p(this.collator)}outputDefined(){return!0}}}const oA=$r("==",(function(i,e,r){return e===r}),So),ml=$r("!=",(function(i,e,r){return e!==r}),(function(i,e,r,s){return!So(0,e,r,s)})),aA=$r("<",(function(i,e,r){return e<r}),(function(i,e,r,s){return s.compare(e,r)<0})),ou=$r(">",(function(i,e,r){return e>r}),(function(i,e,r,s){return s.compare(e,r)>0})),io=$r("<=",(function(i,e,r){return e<=r}),(function(i,e,r,s){return s.compare(e,r)<=0})),Oa=$r(">=",(function(i,e,r){return e>=r}),(function(i,e,r,s){return s.compare(e,r)>=0}));class Co{constructor(e,r,s){this.type=oa,this.locale=s,this.caseSensitive=e,this.diacriticSensitive=r}static parse(e,r){if(e.length!==2)return r.error("Expected one argument.");const s=e[1];if(typeof s!="object"||Array.isArray(s))return r.error("Collator options argument must be an object.");const c=r.parse(s["case-sensitive"]!==void 0&&s["case-sensitive"],1,Ft);if(!c)return null;const p=r.parse(s["diacritic-sensitive"]!==void 0&&s["diacritic-sensitive"],1,Ft);if(!p)return null;let m=null;return s.locale&&(m=r.parse(s.locale,1,wt),!m)?null:new Co(c,p,m)}evaluate(e){return new Fa(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}}class Do{constructor(e,r,s,c,p){this.type=wt,this.number=e,this.locale=r,this.currency=s,this.minFractionDigits=c,this.maxFractionDigits=p}static parse(e,r){if(e.length!==3)return r.error("Expected two arguments.");const s=r.parse(e[1],1,Je);if(!s)return null;const c=e[2];if(typeof c!="object"||Array.isArray(c))return r.error("NumberFormat options argument must be an object.");let p=null;if(c.locale&&(p=r.parse(c.locale,1,wt),!p))return null;let m=null;if(c.currency&&(m=r.parse(c.currency,1,wt),!m))return null;let v=null;if(c["min-fraction-digits"]&&(v=r.parse(c["min-fraction-digits"],1,Je),!v))return null;let T=null;return c["max-fraction-digits"]&&(T=r.parse(c["max-fraction-digits"],1,Je),!T)?null:new Do(s,p,m,v,T)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}}class fa{constructor(e){this.type=Xs,this.sections=e}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");const s=e[1];if(!Array.isArray(s)&&typeof s=="object")return r.error("First argument must be an image or text section.");const c=[];let p=!1;for(let m=1;m<=e.length-1;++m){const v=e[m];if(p&&typeof v=="object"&&!Array.isArray(v)){p=!1;let T=null;if(v["font-scale"]&&(T=r.parse(v["font-scale"],1,Je),!T))return null;let E=null;if(v["text-font"]&&(E=r.parse(v["text-font"],1,Zr(wt)),!E))return null;let S=null;if(v["text-color"]&&(S=r.parse(v["text-color"],1,Jt),!S))return null;let k=null;if(v["vertical-align"]){if(typeof v["vertical-align"]=="string"&&!su.includes(v["vertical-align"]))return r.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${v["vertical-align"]}' instead.`);if(k=r.parse(v["vertical-align"],1,wt),!k)return null}const R=c[c.length-1];R.scale=T,R.font=E,R.textColor=S,R.verticalAlign=k}else{const T=r.parse(e[m],1,qt);if(!T)return null;const E=T.type.kind;if(E!=="string"&&E!=="value"&&E!=="null"&&E!=="resolvedImage")return r.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");p=!0,c.push({content:T,scale:null,font:null,textColor:null,verticalAlign:null})}}return new fa(c)}evaluate(e){return new en(this.sections.map((r=>{const s=r.content.evaluate(e);return Kr(s)===Ms?new pl("",s,null,null,null,r.verticalAlign?r.verticalAlign.evaluate(e):null):new pl(Cs(s),null,r.scale?r.scale.evaluate(e):null,r.font?r.font.evaluate(e).join(","):null,r.textColor?r.textColor.evaluate(e):null,r.verticalAlign?r.verticalAlign.evaluate(e):null)})))}eachChild(e){for(const r of this.sections)e(r.content),r.scale&&e(r.scale),r.font&&e(r.font),r.textColor&&e(r.textColor),r.verticalAlign&&e(r.verticalAlign)}outputDefined(){return!1}}class ko{constructor(e){this.type=Ms,this.input=e}static parse(e,r){if(e.length!==2)return r.error("Expected two arguments.");const s=r.parse(e[1],1,wt);return s?new ko(s):r.error("No image name provided.")}evaluate(e){const r=this.input.evaluate(e),s=tn.fromString(r);return s&&e.availableImages&&(s.available=e.availableImages.indexOf(r)>-1),s}eachChild(e){e(this.input)}outputDefined(){return!1}}class zo{constructor(e){this.type=Je,this.input=e}static parse(e,r){if(e.length!==2)return r.error(`Expected 1 argument, but found ${e.length-1} instead.`);const s=r.parse(e[1],1);return s?s.type.kind!=="array"&&s.type.kind!=="string"&&s.type.kind!=="value"?r.error(`Expected argument of type string or array, but found ${Pt(s.type)} instead.`):new zo(s):null}evaluate(e){const r=this.input.evaluate(e);if(typeof r=="string")return[...r].length;if(Array.isArray(r))return r.length;throw new Er(`Expected value to be of type string or array, but found ${Pt(Kr(r))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}const Nr=8192;function lA(i,e){const r=(180+i[0])/360,s=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i[1]*Math.PI/360)))/360,c=Math.pow(2,e.z);return[Math.round(r*c*Nr),Math.round(s*c*Nr)]}function ks(i,e){const r=Math.pow(2,e.z);return[(c=(i[0]/Nr+e.x)/r,360*c-180),(s=(i[1]/Nr+e.y)/r,360/Math.PI*Math.atan(Math.exp((180-360*s)*Math.PI/180))-90)];var s,c}function Bo(i,e){i[0]=Math.min(i[0],e[0]),i[1]=Math.min(i[1],e[1]),i[2]=Math.max(i[2],e[0]),i[3]=Math.max(i[3],e[1])}function Mn(i,e){return!(i[0]<=e[0]||i[2]>=e[2]||i[1]<=e[1]||i[3]>=e[3])}function au(i,e,r){const s=i[0]-e[0],c=i[1]-e[1],p=i[0]-r[0],m=i[1]-r[1];return s*m-p*c==0&&s*p<=0&&c*m<=0}function Ro(i,e,r,s){return(c=[s[0]-r[0],s[1]-r[1]])[0]*(p=[e[0]-i[0],e[1]-i[1]])[1]-c[1]*p[0]!=0&&!(!ma(i,e,r,s)||!ma(r,s,i,e));var c,p}function AA(i,e,r){for(const s of r)for(let c=0;c<s.length-1;++c)if(Ro(i,e,s[c],s[c+1]))return!0;return!1}function Lo(i,e,r=!1){let s=!1;for(const v of e)for(let T=0;T<v.length-1;T++){if(au(i,v[T],v[T+1]))return r;(p=v[T])[1]>(c=i)[1]!=(m=v[T+1])[1]>c[1]&&c[0]<(m[0]-p[0])*(c[1]-p[1])/(m[1]-p[1])+p[0]&&(s=!s)}var c,p,m;return s}function da(i,e){for(const r of e)if(Lo(i,r))return!0;return!1}function uA(i,e){for(const r of i)if(!Lo(r,e))return!1;for(let r=0;r<i.length-1;++r)if(AA(i[r],i[r+1],e))return!1;return!0}function cA(i,e){for(const r of e)if(uA(i,r))return!0;return!1}function ma(i,e,r,s){const c=s[0]-r[0],p=s[1]-r[1],m=(i[0]-r[0])*p-c*(i[1]-r[1]),v=(e[0]-r[0])*p-c*(e[1]-r[1]);return m>0&&v<0||m<0&&v>0}function gl(i,e,r){const s=[];for(let c=0;c<i.length;c++){const p=[];for(let m=0;m<i[c].length;m++){const v=lA(i[c][m],r);Bo(e,v),p.push(v)}s.push(p)}return s}function ga(i,e,r){const s=[];for(let c=0;c<i.length;c++){const p=gl(i[c],e,r);s.push(p)}return s}function Va(i,e,r,s){if(i[0]<r[0]||i[0]>r[2]){const c=.5*s;let p=i[0]-r[0]>c?-s:r[0]-i[0]>c?s:0;p===0&&(p=i[0]-r[2]>c?-s:r[2]-i[0]>c?s:0),i[0]+=p}Bo(e,i)}function Fo(i,e,r,s){const c=Math.pow(2,s.z)*Nr,p=[s.x*Nr,s.y*Nr],m=[];for(const v of i)for(const T of v){const E=[T.x+p[0],T.y+p[1]];Va(E,e,r,c),m.push(E)}return m}function wr(i,e,r,s){const c=Math.pow(2,s.z)*Nr,p=[s.x*Nr,s.y*Nr],m=[];for(const T of i){const E=[];for(const S of T){const k=[S.x+p[0],S.y+p[1]];Bo(e,k),E.push(k)}m.push(E)}if(e[2]-e[0]<=c/2){(v=e)[0]=v[1]=1/0,v[2]=v[3]=-1/0;for(const T of m)for(const E of T)Va(E,e,r,c)}var v;return m}class no{constructor(e,r){this.type=Ft,this.geojson=e,this.geometries=r}static parse(e,r){if(e.length!==2)return r.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Hn(e[1])){const s=e[1];if(s.type==="FeatureCollection"){const c=[];for(const p of s.features){const{type:m,coordinates:v}=p.geometry;m==="Polygon"&&c.push(v),m==="MultiPolygon"&&c.push(...v)}if(c.length)return new no(s,{type:"MultiPolygon",coordinates:c})}else if(s.type==="Feature"){const c=s.geometry.type;if(c==="Polygon"||c==="MultiPolygon")return new no(s,s.geometry)}else if(s.type==="Polygon"||s.type==="MultiPolygon")return new no(s,s)}return r.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(e.geometry()!=null&&e.canonicalID()!=null){if(e.geometryType()==="Point")return(function(r,s){const c=[1/0,1/0,-1/0,-1/0],p=[1/0,1/0,-1/0,-1/0],m=r.canonicalID();if(s.type==="Polygon"){const v=gl(s.coordinates,p,m),T=Fo(r.geometry(),c,p,m);if(!Mn(c,p))return!1;for(const E of T)if(!Lo(E,v))return!1}if(s.type==="MultiPolygon"){const v=ga(s.coordinates,p,m),T=Fo(r.geometry(),c,p,m);if(!Mn(c,p))return!1;for(const E of T)if(!da(E,v))return!1}return!0})(e,this.geometries);if(e.geometryType()==="LineString")return(function(r,s){const c=[1/0,1/0,-1/0,-1/0],p=[1/0,1/0,-1/0,-1/0],m=r.canonicalID();if(s.type==="Polygon"){const v=gl(s.coordinates,p,m),T=wr(r.geometry(),c,p,m);if(!Mn(c,p))return!1;for(const E of T)if(!uA(E,v))return!1}if(s.type==="MultiPolygon"){const v=ga(s.coordinates,p,m),T=wr(r.geometry(),c,p,m);if(!Mn(c,p))return!1;for(const E of T)if(!cA(E,v))return!1}return!0})(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let _l=class{constructor(i=[],e=(r,s)=>r<s?-1:r>s?1:0){if(this.data=i,this.length=this.data.length,this.compare=e,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(i){this.data.push(i),this._up(this.length++)}pop(){if(this.length===0)return;const i=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),i}peek(){return this.data[0]}_up(i){const{data:e,compare:r}=this,s=e[i];for(;i>0;){const c=i-1>>1,p=e[c];if(r(s,p)>=0)break;e[i]=p,i=c}e[i]=s}_down(i){const{data:e,compare:r}=this,s=this.length>>1,c=e[i];for(;i<s;){let p=1+(i<<1);const m=p+1;if(m<this.length&&r(e[m],e[p])<0&&(p=m),r(e[p],c)>=0)break;e[i]=e[p],i=p}e[i]=c}};function ja(i,e,r=0,s=i.length-1,c=hA){for(;s>r;){if(s-r>600){const T=s-r+1,E=e-r+1,S=Math.log(T),k=.5*Math.exp(2*S/3),R=.5*Math.sqrt(S*k*(T-k)/T)*(E-T/2<0?-1:1);ja(i,e,Math.max(r,Math.floor(e-E*k/T+R)),Math.min(s,Math.floor(e+(T-E)*k/T+R)),c)}const p=i[e];let m=r,v=s;for(Oo(i,r,e),c(i[s],p)>0&&Oo(i,r,s);m<v;){for(Oo(i,m,v),m++,v--;c(i[m],p)<0;)m++;for(;c(i[v],p)>0;)v--}c(i[r],p)===0?Oo(i,r,v):(v++,Oo(i,v,s)),v<=e&&(r=v+1),e<=v&&(s=v-1)}}function Oo(i,e,r){const s=i[e];i[e]=i[r],i[r]=s}function hA(i,e){return i<e?-1:i>e?1:0}function Na(i,e){if(i.length<=1)return[i];const r=[];let s,c;for(const p of i){const m=sn(p);m!==0&&(p.area=Math.abs(m),c===void 0&&(c=m<0),c===m<0?(s&&r.push(s),s=[p]):s.push(p))}if(s&&r.push(s),e>1)for(let p=0;p<r.length;p++)r[p].length<=e||(ja(r[p],e,1,r[p].length-1,lu),r[p]=r[p].slice(0,e));return r}function lu(i,e){return e.area-i.area}function sn(i){let e=0;for(let r,s,c=0,p=i.length,m=p-1;c<p;m=c++)r=i[c],s=i[m],e+=(s.x-r.x)*(r.y+s.y);return e}const Ga=1/298.257223563,jn=Ga*(2-Ga),pA=Math.PI/180;class _a{constructor(e){const r=6378.137*pA*1e3,s=Math.cos(e*pA),c=1/(1-jn*(1-s*s)),p=Math.sqrt(c);this.kx=r*p*s,this.ky=r*p*c*(1-jn)}distance(e,r){const s=this.wrap(e[0]-r[0])*this.kx,c=(e[1]-r[1])*this.ky;return Math.sqrt(s*s+c*c)}pointOnLine(e,r){let s,c,p,m,v=1/0;for(let T=0;T<e.length-1;T++){let E=e[T][0],S=e[T][1],k=this.wrap(e[T+1][0]-E)*this.kx,R=(e[T+1][1]-S)*this.ky,L=0;k===0&&R===0||(L=(this.wrap(r[0]-E)*this.kx*k+(r[1]-S)*this.ky*R)/(k*k+R*R),L>1?(E=e[T+1][0],S=e[T+1][1]):L>0&&(E+=k/this.kx*L,S+=R/this.ky*L)),k=this.wrap(r[0]-E)*this.kx,R=(r[1]-S)*this.ky;const j=k*k+R*R;j<v&&(v=j,s=E,c=S,p=T,m=L)}return{point:[s,c],index:p,t:Math.max(0,Math.min(1,m))}}wrap(e){for(;e<-180;)e+=360;for(;e>180;)e-=360;return e}}function fA(i,e){return e[0]-i[0]}function Wi(i){return i[1]-i[0]+1}function gn(i,e){return i[1]>=i[0]&&i[1]<e}function Vo(i,e){if(i[0]>i[1])return[null,null];const r=Wi(i);if(e){if(r===2)return[i,null];const c=Math.floor(r/2);return[[i[0],i[0]+c],[i[0]+c,i[1]]]}if(r===1)return[i,null];const s=Math.floor(r/2)-1;return[[i[0],i[0]+s],[i[0]+s+1,i[1]]]}function zs(i,e){if(!gn(e,i.length))return[1/0,1/0,-1/0,-1/0];const r=[1/0,1/0,-1/0,-1/0];for(let s=e[0];s<=e[1];++s)Bo(r,i[s]);return r}function cs(i){const e=[1/0,1/0,-1/0,-1/0];for(const r of i)for(const s of r)Bo(e,s);return e}function Bs(i){return i[0]!==-1/0&&i[1]!==-1/0&&i[2]!==1/0&&i[3]!==1/0}function Ua(i,e,r){if(!Bs(i)||!Bs(e))return NaN;let s=0,c=0;return i[2]<e[0]&&(s=e[0]-i[2]),i[0]>e[2]&&(s=i[0]-e[2]),i[1]>e[3]&&(c=i[1]-e[3]),i[3]<e[1]&&(c=e[1]-i[3]),r.distance([0,0],[s,c])}function Rs(i,e,r){const s=r.pointOnLine(e,i);return r.distance(i,s.point)}function yl(i,e,r,s,c){const p=Math.min(Rs(i,[r,s],c),Rs(e,[r,s],c)),m=Math.min(Rs(r,[i,e],c),Rs(s,[i,e],c));return Math.min(p,m)}function vl(i,e,r,s,c){if(!gn(e,i.length)||!gn(s,r.length))return 1/0;let p=1/0;for(let m=e[0];m<e[1];++m){const v=i[m],T=i[m+1];for(let E=s[0];E<s[1];++E){const S=r[E],k=r[E+1];if(Ro(v,T,S,k))return 0;p=Math.min(p,yl(v,T,S,k,c))}}return p}function dA(i,e,r,s,c){if(!gn(e,i.length)||!gn(s,r.length))return NaN;let p=1/0;for(let m=e[0];m<=e[1];++m)for(let v=s[0];v<=s[1];++v)if(p=Math.min(p,c.distance(i[m],r[v])),p===0)return p;return p}function Au(i,e,r){if(Lo(i,e,!0))return 0;let s=1/0;for(const c of e){const p=c[0],m=c[c.length-1];if(p!==m&&(s=Math.min(s,Rs(i,[m,p],r)),s===0))return s;const v=r.pointOnLine(c,i);if(s=Math.min(s,r.distance(i,v.point)),s===0)return s}return s}function xl(i,e,r,s){if(!gn(e,i.length))return NaN;for(let p=e[0];p<=e[1];++p)if(Lo(i[p],r,!0))return 0;let c=1/0;for(let p=e[0];p<e[1];++p){const m=i[p],v=i[p+1];for(const T of r)for(let E=0,S=T.length,k=S-1;E<S;k=E++){const R=T[k],L=T[E];if(Ro(m,v,R,L))return 0;c=Math.min(c,yl(m,v,R,L,s))}}return c}function bl(i,e){for(const r of i)for(const s of r)if(Lo(s,e,!0))return!0;return!1}function wl(i,e,r,s=1/0){const c=cs(i),p=cs(e);if(s!==1/0&&Ua(c,p,r)>=s)return s;if(Mn(c,p)){if(bl(i,e))return 0}else if(bl(e,i))return 0;let m=1/0;for(const v of i)for(let T=0,E=v.length,S=E-1;T<E;S=T++){const k=v[S],R=v[T];for(const L of e)for(let j=0,N=L.length,q=N-1;j<N;q=j++){const Y=L[q],ue=L[j];if(Ro(k,R,Y,ue))return 0;m=Math.min(m,yl(k,R,Y,ue,r))}}return m}function lr(i,e,r,s,c,p){if(!p)return;const m=Ua(zs(s,p),c,r);m<e&&i.push([m,p,[0,0]])}function hs(i,e,r,s,c,p,m){if(!p||!m)return;const v=Ua(zs(s,p),zs(c,m),r);v<e&&i.push([v,p,m])}function zi(i,e,r,s,c=1/0){let p=Math.min(s.distance(i[0],r[0][0]),c);if(p===0)return p;const m=new _l([[0,[0,i.length-1],[0,0]]],fA),v=cs(r);for(;m.length>0;){const T=m.pop();if(T[0]>=p)continue;const E=T[1],S=e?50:100;if(Wi(E)<=S){if(!gn(E,i.length))return NaN;if(e){const k=xl(i,E,r,s);if(isNaN(k)||k===0)return k;p=Math.min(p,k)}else for(let k=E[0];k<=E[1];++k){const R=Au(i[k],r,s);if(p=Math.min(p,R),p===0)return 0}}else{const k=Vo(E,e);lr(m,p,s,i,v,k[0]),lr(m,p,s,i,v,k[1])}}return p}function qa(i,e,r,s,c,p=1/0){let m=Math.min(p,c.distance(i[0],r[0]));if(m===0)return m;const v=new _l([[0,[0,i.length-1],[0,r.length-1]]],fA);for(;v.length>0;){const T=v.pop();if(T[0]>=m)continue;const E=T[1],S=T[2],k=e?50:100,R=s?50:100;if(Wi(E)<=k&&Wi(S)<=R){if(!gn(E,i.length)&&gn(S,r.length))return NaN;let L;if(e&&s)L=vl(i,E,r,S,c),m=Math.min(m,L);else if(e&&!s){const j=i.slice(E[0],E[1]+1);for(let N=S[0];N<=S[1];++N)if(L=Rs(r[N],j,c),m=Math.min(m,L),m===0)return m}else if(!e&&s){const j=r.slice(S[0],S[1]+1);for(let N=E[0];N<=E[1];++N)if(L=Rs(i[N],j,c),m=Math.min(m,L),m===0)return m}else L=dA(i,E,r,S,c),m=Math.min(m,L)}else{const L=Vo(E,e),j=Vo(S,s);hs(v,m,c,i,r,L[0],j[0]),hs(v,m,c,i,r,L[0],j[1]),hs(v,m,c,i,r,L[1],j[0]),hs(v,m,c,i,r,L[1],j[1])}}return m}function so(i){return i.type==="MultiPolygon"?i.coordinates.map((e=>({type:"Polygon",coordinates:e}))):i.type==="MultiLineString"?i.coordinates.map((e=>({type:"LineString",coordinates:e}))):i.type==="MultiPoint"?i.coordinates.map((e=>({type:"Point",coordinates:e}))):[i]}class oo{constructor(e,r){this.type=Je,this.geojson=e,this.geometries=r}static parse(e,r){if(e.length!==2)return r.error(`'distance' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Hn(e[1])){const s=e[1];if(s.type==="FeatureCollection")return new oo(s,s.features.map((c=>so(c.geometry))).flat());if(s.type==="Feature")return new oo(s,so(s.geometry));if("type"in s&&"coordinates"in s)return new oo(s,so(s))}return r.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(e.geometry()!=null&&e.canonicalID()!=null){if(e.geometryType()==="Point")return(function(r,s){const c=r.geometry(),p=c.flat().map((T=>ks([T.x,T.y],r.canonical)));if(c.length===0)return NaN;const m=new _a(p[0][1]);let v=1/0;for(const T of s){switch(T.type){case"Point":v=Math.min(v,qa(p,!1,[T.coordinates],!1,m,v));break;case"LineString":v=Math.min(v,qa(p,!1,T.coordinates,!0,m,v));break;case"Polygon":v=Math.min(v,zi(p,!1,T.coordinates,m,v))}if(v===0)return v}return v})(e,this.geometries);if(e.geometryType()==="LineString")return(function(r,s){const c=r.geometry(),p=c.flat().map((T=>ks([T.x,T.y],r.canonical)));if(c.length===0)return NaN;const m=new _a(p[0][1]);let v=1/0;for(const T of s){switch(T.type){case"Point":v=Math.min(v,qa(p,!0,[T.coordinates],!1,m,v));break;case"LineString":v=Math.min(v,qa(p,!0,T.coordinates,!0,m,v));break;case"Polygon":v=Math.min(v,zi(p,!0,T.coordinates,m,v))}if(v===0)return v}return v})(e,this.geometries);if(e.geometryType()==="Polygon")return(function(r,s){const c=r.geometry();if(c.length===0||c[0].length===0)return NaN;const p=Na(c,0).map((T=>T.map((E=>E.map((S=>ks([S.x,S.y],r.canonical))))))),m=new _a(p[0][0][0][1]);let v=1/0;for(const T of s)for(const E of p){switch(T.type){case"Point":v=Math.min(v,zi([T.coordinates],!1,E,m,v));break;case"LineString":v=Math.min(v,zi(T.coordinates,!0,E,m,v));break;case"Polygon":v=Math.min(v,wl(E,T.coordinates,m,v))}if(v===0)return v}return v})(e,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}class ya{constructor(e){this.type=qt,this.key=e}static parse(e,r){if(e.length!==2)return r.error(`Expected 1 argument, but found ${e.length-1} instead.`);const s=e[1];return s==null?r.error("Global state property must be defined."):typeof s!="string"?r.error(`Global state property must be string, but found ${typeof e[1]} instead.`):new ya(s)}evaluate(e){var r;const s=(r=e.globals)===null||r===void 0?void 0:r.globalState;return s&&Object.keys(s).length!==0?ua(s,this.key):null}eachChild(){}outputDefined(){return!1}}const jo={"==":oA,"!=":ml,">":ou,"<":aA,">=":Oa,"<=":io,array:rn,at:or,boolean:rn,case:pa,coalesce:ro,collator:Co,format:fa,image:ko,in:Zt,"index-of":Mo,interpolate:ki,"interpolate-hcl":ki,"interpolate-lab":ki,length:zo,let:rr,literal:On,match:ur,number:rn,"number-format":Do,object:rn,slice:mn,step:nn,string:rn,"to-boolean":ls,"to-color":ls,"to-number":ls,"to-string":ls,var:Ds,within:no,distance:oo,"global-state":ya};class _n{constructor(e,r,s,c){this.name=e,this.type=r,this._evaluate=s,this.args=c}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(e,r){const s=e[0],c=_n.definitions[s];if(!c)return r.error(`Unknown expression "${s}". If you wanted a literal array, use ["literal", [...]].`,0);const p=Array.isArray(c)?c[0]:c.type,m=Array.isArray(c)?[[c[1],c[2]]]:c.overloads,v=m.filter((([E])=>!Array.isArray(E)||E.length===e.length-1));let T=null;for(const[E,S]of v){T=new dn(r.registry,va,r.path,null,r.scope);const k=[];let R=!1;for(let L=1;L<e.length;L++){const j=e[L],N=Array.isArray(E)?E[L-1]:E.type,q=T.parse(j,1+k.length,N);if(!q){R=!0;break}k.push(q)}if(!R)if(Array.isArray(E)&&E.length!==k.length)T.error(`Expected ${E.length} arguments, but found ${k.length} instead.`);else{for(let L=0;L<k.length;L++){const j=Array.isArray(E)?E[L]:E.type,N=k[L];T.concat(L+1).checkSubtype(j,N.type)}if(T.errors.length===0)return new _n(s,p,S,k)}}if(v.length===1)r.errors.push(...T.errors);else{const E=(v.length?v:m).map((([k])=>{return R=k,Array.isArray(R)?`(${R.map(Pt).join(", ")})`:`(${Pt(R.type)}...)`;var R})).join(" | "),S=[];for(let k=1;k<e.length;k++){const R=r.parse(e[k],1+S.length);if(!R)return null;S.push(Pt(R.type))}r.error(`Expected arguments of type ${E}, but found (${S.join(", ")}) instead.`)}return null}static register(e,r){_n.definitions=r;for(const s in r)e[s]=_n}}function mA(i,[e,r,s,c]){e=e.evaluate(i),r=r.evaluate(i),s=s.evaluate(i);const p=c?c.evaluate(i):1,m=Ss(e,r,s,p);if(m)throw new Er(m);return new Kt(e/255,r/255,s/255,p,!1)}function gA(i,e){return i in e}function Tl(i,e){const r=e[i];return r===void 0?null:r}function Xn(i){return{type:i}}function va(i){if(i instanceof Ds)return va(i.boundExpression);if(i instanceof _n&&i.name==="error"||i instanceof Co||i instanceof no||i instanceof oo||i instanceof ya)return!1;const e=i instanceof ls||i instanceof rn;let r=!0;return i.eachChild((s=>{r=e?r&&va(s):r&&s instanceof On})),!!r&&No(i)&&Za(i,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"])}function No(i){if(i instanceof _n&&(i.name==="get"&&i.args.length===1||i.name==="feature-state"||i.name==="has"&&i.args.length===1||i.name==="properties"||i.name==="geometry-type"||i.name==="id"||/^filter-/.test(i.name))||i instanceof no||i instanceof oo)return!1;let e=!0;return i.eachChild((r=>{e&&!No(r)&&(e=!1)})),e}function xa(i){if(i instanceof _n&&i.name==="feature-state")return!1;let e=!0;return i.eachChild((r=>{e&&!xa(r)&&(e=!1)})),e}function Za(i,e){if(i instanceof _n&&e.indexOf(i.name)>=0)return!1;let r=!0;return i.eachChild((s=>{r&&!Za(s,e)&&(r=!1)})),r}function _A(i){return{result:"success",value:i}}function Go(i){return{result:"error",value:i}}function Uo(i){return i["property-type"]==="data-driven"||i["property-type"]==="cross-faded-data-driven"}function yA(i){return!!i.expression&&i.expression.parameters.indexOf("zoom")>-1}function Pl(i){return!!i.expression&&i.expression.interpolated}function tr(i){return i instanceof Number?"number":i instanceof String?"string":i instanceof Boolean?"boolean":Array.isArray(i)?"array":i===null?"null":typeof i}function Qa(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)&&Kr(i)===ai}function vA(i){return i}function Yn(i,e){const r=i.stops&&typeof i.stops[0][0]=="object",s=r||!(r||i.property!==void 0),c=i.type||(Pl(e)?"exponential":"interval"),p=(function(S){switch(S.type){case"color":return Kt.parse;case"padding":return Pi.parse;case"numberArray":return Cr.parse;case"colorArray":return Bt.parse;default:return null}})(e);if(p&&((i=Z({},i)).stops&&(i.stops=i.stops.map((S=>[S[0],p(S[1])]))),i.default=p(i.default?i.default:e.default)),i.colorSpace&&(m=i.colorSpace)!=="rgb"&&m!=="hcl"&&m!=="lab")throw new Error(`Unknown color space: "${i.colorSpace}"`);var m;const v=(function(S){switch(S){case"exponential":return xA;case"interval":return cu;case"categorical":return uu;case"identity":return hu;default:throw new Error(`Unknown function type "${S}"`)}})(c);let T,E;if(c==="categorical"){T=Object.create(null);for(const S of i.stops)T[S[0]]=S[1];E=typeof i.stops[0][0]}if(r){const S={},k=[];for(let j=0;j<i.stops.length;j++){const N=i.stops[j],q=N[0].zoom;S[q]===void 0&&(S[q]={zoom:q,type:i.type,property:i.property,default:i.default,stops:[]},k.push(q)),S[q].stops.push([N[0].value,N[1]])}const R=[];for(const j of k)R.push([S[j].zoom,Yn(S[j],e)]);const L={name:"linear"};return{kind:"composite",interpolationType:L,interpolationFactor:ki.interpolationFactor.bind(void 0,L),zoomStops:R.map((j=>j[0])),evaluate:({zoom:j},N)=>xA({stops:R,base:i.base},e,j).evaluate(j,N)}}if(s){const S=c==="exponential"?{name:"exponential",base:i.base!==void 0?i.base:1}:null;return{kind:"camera",interpolationType:S,interpolationFactor:ki.interpolationFactor.bind(void 0,S),zoomStops:i.stops.map((k=>k[0])),evaluate:({zoom:k})=>v(i,e,k,T,E)}}return{kind:"source",evaluate(S,k){const R=k&&k.properties?k.properties[i.property]:void 0;return R===void 0?qo(i.default,e.default):v(i,e,R,T,E)}}}function qo(i,e,r){return i!==void 0?i:e!==void 0?e:r!==void 0?r:void 0}function uu(i,e,r,s,c){return qo(typeof r===c?s[r]:void 0,i.default,e.default)}function cu(i,e,r){if(tr(r)!=="number")return qo(i.default,e.default);const s=i.stops.length;if(s===1||r<=i.stops[0][0])return i.stops[0][1];if(r>=i.stops[s-1][0])return i.stops[s-1][1];const c=As(i.stops.map((p=>p[0])),r);return i.stops[c][1]}function xA(i,e,r){const s=i.base!==void 0?i.base:1;if(tr(r)!=="number")return qo(i.default,e.default);const c=i.stops.length;if(c===1||r<=i.stops[0][0])return i.stops[0][1];if(r>=i.stops[c-1][0])return i.stops[c-1][1];const p=As(i.stops.map((S=>S[0])),r),m=(function(S,k,R,L){const j=L-R,N=S-R;return j===0?0:k===1?N/j:(Math.pow(k,N)-1)/(Math.pow(k,j)-1)})(r,s,i.stops[p][0],i.stops[p+1][0]),v=i.stops[p][1],T=i.stops[p+1][1],E=Sr[e.type]||vA;return typeof v.evaluate=="function"?{evaluate(...S){const k=v.evaluate.apply(void 0,S),R=T.evaluate.apply(void 0,S);if(k!==void 0&&R!==void 0)return E(k,R,m,i.colorSpace)}}:E(v,T,m,i.colorSpace)}function hu(i,e,r){switch(e.type){case"color":r=Kt.parse(r);break;case"formatted":r=en.fromString(r.toString());break;case"resolvedImage":r=tn.fromString(r.toString());break;case"padding":r=Pi.parse(r);break;case"colorArray":r=Bt.parse(r);break;case"numberArray":r=Cr.parse(r);break;default:tr(r)===e.type||e.type==="enum"&&e.values[r]||(r=void 0)}return qo(r,i.default,e.default)}_n.register(jo,{error:[{kind:"error"},[wt],(i,[e])=>{throw new Er(e.evaluate(i))}],typeof:[wt,[qt],(i,[e])=>Pt(Kr(e.evaluate(i)))],"to-rgba":[Zr(Je,4),[Jt],(i,[e])=>{const[r,s,c,p]=e.evaluate(i).rgb;return[255*r,255*s,255*c,p]}],rgb:[Jt,[Je,Je,Je],mA],rgba:[Jt,[Je,Je,Je,Je],mA],has:{type:Ft,overloads:[[[wt],(i,[e])=>gA(e.evaluate(i),i.properties())],[[wt,ai],(i,[e,r])=>gA(e.evaluate(i),r.evaluate(i))]]},get:{type:qt,overloads:[[[wt],(i,[e])=>Tl(e.evaluate(i),i.properties())],[[wt,ai],(i,[e,r])=>Tl(e.evaluate(i),r.evaluate(i))]]},"feature-state":[qt,[wt],(i,[e])=>Tl(e.evaluate(i),i.featureState||{})],properties:[ai,[],i=>i.properties()],"geometry-type":[wt,[],i=>i.geometryType()],id:[qt,[],i=>i.id()],zoom:[Je,[],i=>i.globals.zoom],"heatmap-density":[Je,[],i=>i.globals.heatmapDensity||0],elevation:[Je,[],i=>i.globals.elevation||0],"line-progress":[Je,[],i=>i.globals.lineProgress||0],accumulated:[qt,[],i=>i.globals.accumulated===void 0?null:i.globals.accumulated],"+":[Je,Xn(Je),(i,e)=>{let r=0;for(const s of e)r+=s.evaluate(i);return r}],"*":[Je,Xn(Je),(i,e)=>{let r=1;for(const s of e)r*=s.evaluate(i);return r}],"-":{type:Je,overloads:[[[Je,Je],(i,[e,r])=>e.evaluate(i)-r.evaluate(i)],[[Je],(i,[e])=>-e.evaluate(i)]]},"/":[Je,[Je,Je],(i,[e,r])=>e.evaluate(i)/r.evaluate(i)],"%":[Je,[Je,Je],(i,[e,r])=>e.evaluate(i)%r.evaluate(i)],ln2:[Je,[],()=>Math.LN2],pi:[Je,[],()=>Math.PI],e:[Je,[],()=>Math.E],"^":[Je,[Je,Je],(i,[e,r])=>Math.pow(e.evaluate(i),r.evaluate(i))],sqrt:[Je,[Je],(i,[e])=>Math.sqrt(e.evaluate(i))],log10:[Je,[Je],(i,[e])=>Math.log(e.evaluate(i))/Math.LN10],ln:[Je,[Je],(i,[e])=>Math.log(e.evaluate(i))],log2:[Je,[Je],(i,[e])=>Math.log(e.evaluate(i))/Math.LN2],sin:[Je,[Je],(i,[e])=>Math.sin(e.evaluate(i))],cos:[Je,[Je],(i,[e])=>Math.cos(e.evaluate(i))],tan:[Je,[Je],(i,[e])=>Math.tan(e.evaluate(i))],asin:[Je,[Je],(i,[e])=>Math.asin(e.evaluate(i))],acos:[Je,[Je],(i,[e])=>Math.acos(e.evaluate(i))],atan:[Je,[Je],(i,[e])=>Math.atan(e.evaluate(i))],min:[Je,Xn(Je),(i,e)=>Math.min(...e.map((r=>r.evaluate(i))))],max:[Je,Xn(Je),(i,e)=>Math.max(...e.map((r=>r.evaluate(i))))],abs:[Je,[Je],(i,[e])=>Math.abs(e.evaluate(i))],round:[Je,[Je],(i,[e])=>{const r=e.evaluate(i);return r<0?-Math.round(-r):Math.round(r)}],floor:[Je,[Je],(i,[e])=>Math.floor(e.evaluate(i))],ceil:[Je,[Je],(i,[e])=>Math.ceil(e.evaluate(i))],"filter-==":[Ft,[wt,qt],(i,[e,r])=>i.properties()[e.value]===r.value],"filter-id-==":[Ft,[qt],(i,[e])=>i.id()===e.value],"filter-type-==":[Ft,[wt],(i,[e])=>i.geometryType()===e.value],"filter-<":[Ft,[wt,qt],(i,[e,r])=>{const s=i.properties()[e.value],c=r.value;return typeof s==typeof c&&s<c}],"filter-id-<":[Ft,[qt],(i,[e])=>{const r=i.id(),s=e.value;return typeof r==typeof s&&r<s}],"filter->":[Ft,[wt,qt],(i,[e,r])=>{const s=i.properties()[e.value],c=r.value;return typeof s==typeof c&&s>c}],"filter-id->":[Ft,[qt],(i,[e])=>{const r=i.id(),s=e.value;return typeof r==typeof s&&r>s}],"filter-<=":[Ft,[wt,qt],(i,[e,r])=>{const s=i.properties()[e.value],c=r.value;return typeof s==typeof c&&s<=c}],"filter-id-<=":[Ft,[qt],(i,[e])=>{const r=i.id(),s=e.value;return typeof r==typeof s&&r<=s}],"filter->=":[Ft,[wt,qt],(i,[e,r])=>{const s=i.properties()[e.value],c=r.value;return typeof s==typeof c&&s>=c}],"filter-id->=":[Ft,[qt],(i,[e])=>{const r=i.id(),s=e.value;return typeof r==typeof s&&r>=s}],"filter-has":[Ft,[qt],(i,[e])=>e.value in i.properties()],"filter-has-id":[Ft,[],i=>i.id()!==null&&i.id()!==void 0],"filter-type-in":[Ft,[Zr(wt)],(i,[e])=>e.value.indexOf(i.geometryType())>=0],"filter-id-in":[Ft,[Zr(qt)],(i,[e])=>e.value.indexOf(i.id())>=0],"filter-in-small":[Ft,[wt,Zr(qt)],(i,[e,r])=>r.value.indexOf(i.properties()[e.value])>=0],"filter-in-large":[Ft,[wt,Zr(qt)],(i,[e,r])=>(function(s,c,p,m){for(;p<=m;){const v=p+m>>1;if(c[v]===s)return!0;c[v]>s?m=v-1:p=v+1}return!1})(i.properties()[e.value],r.value,0,r.value.length-1)],all:{type:Ft,overloads:[[[Ft,Ft],(i,[e,r])=>e.evaluate(i)&&r.evaluate(i)],[Xn(Ft),(i,e)=>{for(const r of e)if(!r.evaluate(i))return!1;return!0}]]},any:{type:Ft,overloads:[[[Ft,Ft],(i,[e,r])=>e.evaluate(i)||r.evaluate(i)],[Xn(Ft),(i,e)=>{for(const r of e)if(r.evaluate(i))return!0;return!1}]]},"!":[Ft,[Ft],(i,[e])=>!e.evaluate(i)],"is-supported-script":[Ft,[wt],(i,[e])=>{const r=i.globals&&i.globals.isSupportedScript;return!r||r(e.evaluate(i))}],upcase:[wt,[wt],(i,[e])=>e.evaluate(i).toUpperCase()],downcase:[wt,[wt],(i,[e])=>e.evaluate(i).toLowerCase()],concat:[wt,Xn(qt),(i,e)=>e.map((r=>Cs(r.evaluate(i)))).join("")],"resolved-locale":[wt,[oa],(i,[e])=>e.evaluate(i).resolvedLocale()]});class Ml{constructor(e,r,s){this.expression=e,this._warningHistory={},this._evaluator=new gi,this._defaultValue=r?(function(c){if(c.type==="color"&&Qa(c.default))return new Kt(0,0,0,0);switch(c.type){case"color":return Kt.parse(c.default)||null;case"padding":return Pi.parse(c.default)||null;case"numberArray":return Cr.parse(c.default)||null;case"colorArray":return Bt.parse(c.default)||null;case"variableAnchorOffsetCollection":return Qi.parse(c.default)||null;case"projectionDefinition":return $i.parse(c.default)||null;default:return c.default===void 0?null:c.default}})(r):null,this._enumValues=r&&r.type==="enum"?r.values:null,this._globalState=s}evaluateWithoutErrorHandling(e,r,s,c,p,m){return this._globalState&&(e=Ls(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=r,this._evaluator.featureState=s,this._evaluator.canonical=c,this._evaluator.availableImages=p||null,this._evaluator.formattedSection=m,this.expression.evaluate(this._evaluator)}evaluate(e,r,s,c,p,m){this._globalState&&(e=Ls(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=r||null,this._evaluator.featureState=s||null,this._evaluator.canonical=c,this._evaluator.availableImages=p||null,this._evaluator.formattedSection=m||null;try{const v=this.expression.evaluate(this._evaluator);if(v==null||typeof v=="number"&&v!=v)return this._defaultValue;if(this._enumValues&&!(v in this._enumValues))throw new Er(`Expected value to be one of ${Object.keys(this._enumValues).map((T=>JSON.stringify(T))).join(", ")}, but found ${JSON.stringify(v)} instead.`);return v}catch(v){return this._warningHistory[v.message]||(this._warningHistory[v.message]=!0,typeof console<"u"&&console.warn(v.message)),this._defaultValue}}}function yn(i){return Array.isArray(i)&&i.length>0&&typeof i[0]=="string"&&i[0]in jo}function ao(i,e,r){const s=new dn(jo,va,[],e?(function(p){const m={color:Jt,string:wt,number:Je,enum:wt,boolean:Ft,formatted:Xs,padding:Zi,numberArray:Ji,colorArray:Ln,projectionDefinition:Yt,resolvedImage:Ms,variableAnchorOffsetCollection:aa};return p.type==="array"?Zr(m[p.value]||qt,p.length):m[p.type]})(e):void 0),c=s.parse(i,void 0,void 0,void 0,e&&e.type==="string"?{typeAnnotation:"coerce"}:void 0);return c?_A(new Ml(c,e,r)):Go(s.errors)}class $a{constructor(e,r,s){this.kind=e,this._styleExpression=r,this.isStateDependent=e!=="constant"&&!xa(r.expression),this.globalStateRefs=En(r.expression),this._globalState=s}evaluateWithoutErrorHandling(e,r,s,c,p,m){return this._globalState&&(e=Ls(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,r,s,c,p,m)}evaluate(e,r,s,c,p,m){return this._globalState&&(e=Ls(e,this._globalState)),this._styleExpression.evaluate(e,r,s,c,p,m)}}class Zo{constructor(e,r,s,c,p){this.kind=e,this.zoomStops=s,this._styleExpression=r,this.isStateDependent=e!=="camera"&&!xa(r.expression),this.globalStateRefs=En(r.expression),this.interpolationType=c,this._globalState=p}evaluateWithoutErrorHandling(e,r,s,c,p,m){return this._globalState&&(e=Ls(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,r,s,c,p,m)}evaluate(e,r,s,c,p,m){return this._globalState&&(e=Ls(e,this._globalState)),this._styleExpression.evaluate(e,r,s,c,p,m)}interpolationFactor(e,r,s){return this.interpolationType?ki.interpolationFactor(this.interpolationType,e,r,s):0}}function Wa(i,e,r){const s=ao(i,e,r);if(s.result==="error")return s;const c=s.value.expression,p=No(c);if(!p&&!Uo(e))return Go([new Ut("","data expressions not supported")]);const m=Za(c,["zoom"]);if(!m&&!yA(e))return Go([new Ut("","zoom expressions not supported")]);const v=Xa(c);return v||m?v instanceof Ut?Go([v]):v instanceof ki&&!Pl(e)?Go([new Ut("",'"interpolate" expressions cannot be used with this property')]):_A(v?new Zo(p?"camera":"composite",s.value,v.labels,v instanceof ki?v.interpolation:void 0,r):new $a(p?"constant":"source",s.value,r)):Go([new Ut("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Ha{constructor(e,r){this._parameters=e,this._specification=r,Z(this,Yn(this._parameters,this._specification))}static deserialize(e){return new Ha(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function Xa(i){let e=null;if(i instanceof rr)e=Xa(i.result);else if(i instanceof ro){for(const r of i.args)if(e=Xa(r),e)break}else(i instanceof nn||i instanceof ki)&&i.input instanceof _n&&i.input.name==="zoom"&&(e=i);return e instanceof Ut||i.eachChild((r=>{const s=Xa(r);s instanceof Ut?e=s:!e&&s?e=new Ut("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&s&&e!==s&&(e=new Ut("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}function En(i,e=new Set){return i instanceof ya&&e.add(i.key),i.eachChild((r=>{En(r,e)})),e}function Ls(i,e){const{zoom:r,heatmapDensity:s,elevation:c,lineProgress:p,isSupportedScript:m,accumulated:v}=i??{};return{zoom:r,heatmapDensity:s,elevation:c,lineProgress:p,isSupportedScript:m,accumulated:v,globalState:e}}function lo(i){if(i===!0||i===!1)return!0;if(!Array.isArray(i)||i.length===0)return!1;switch(i[0]){case"has":return i.length>=2&&i[1]!=="$id"&&i[1]!=="$type";case"in":return i.length>=3&&(typeof i[1]!="string"||Array.isArray(i[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return i.length!==3||Array.isArray(i[1])||Array.isArray(i[2]);case"any":case"all":for(const e of i.slice(1))if(!lo(e)&&typeof e!="boolean")return!1;return!0;default:return!0}}const El={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function Ao(i,e){if(i==null)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};lo(i)||(i=Qo(i));const r=ao(i,El,e);if(r.result==="error")throw new Error(r.value.map((s=>`${s.key}: ${s.message}`)).join(", "));return{filter:(s,c,p)=>r.value.evaluate(s,c,{},p),needGeometry:ba(i),getGlobalStateRefs:()=>En(r.value.expression)}}function bA(i,e){return i<e?-1:i>e?1:0}function ba(i){if(!Array.isArray(i))return!1;if(i[0]==="within"||i[0]==="distance")return!0;for(let e=1;e<i.length;e++)if(ba(i[e]))return!0;return!1}function Qo(i){if(!i)return!0;const e=i[0];return i.length<=1?e!=="any":e==="=="?Ya(i[1],i[2],"=="):e==="!="?wa(Ya(i[1],i[2],"==")):e==="<"||e===">"||e==="<="||e===">="?Ya(i[1],i[2],e):e==="any"?(r=i.slice(1),["any"].concat(r.map(Qo))):e==="all"?["all"].concat(i.slice(1).map(Qo)):e==="none"?["all"].concat(i.slice(1).map(Qo).map(wa)):e==="in"?wA(i[1],i.slice(2)):e==="!in"?wa(wA(i[1],i.slice(2))):e==="has"?TA(i[1]):e!=="!has"||wa(TA(i[1]));var r}function Ya(i,e,r){switch(i){case"$type":return[`filter-type-${r}`,e];case"$id":return[`filter-id-${r}`,e];default:return[`filter-${r}`,i,e]}}function wA(i,e){if(e.length===0)return!1;switch(i){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((r=>typeof r!=typeof e[0]))?["filter-in-large",i,["literal",e.sort(bA)]]:["filter-in-small",i,["literal",e]]}}function TA(i){switch(i){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",i]}}function wa(i){return["!",i]}function Ka(i){const e=typeof i;if(e==="number"||e==="boolean"||e==="string"||i==null)return JSON.stringify(i);if(Array.isArray(i)){let c="[";for(const p of i)c+=`${Ka(p)},`;return`${c}]`}const r=Object.keys(i).sort();let s="{";for(let c=0;c<r.length;c++)s+=`${JSON.stringify(r[c])}:${Ka(i[r[c]])},`;return`${s}}`}function PA(i){let e="";for(const r of _r)e+=`/${Ka(i[r])}`;return e}function MA(i){const e=i.value;return e?[new o(i.key,e,"constants have been deprecated as of v8")]:[]}function Jr(i){return i instanceof Number||i instanceof String||i instanceof Boolean?i.valueOf():i}function uo(i){if(Array.isArray(i))return i.map(uo);if(i instanceof Object&&!(i instanceof Number||i instanceof String||i instanceof Boolean)){const e={};for(const r in i)e[r]=uo(i[r]);return e}return Jr(i)}function on(i){const e=i.key,r=i.value,s=i.valueSpec||{},c=i.objectElementValidators||{},p=i.style,m=i.styleSpec,v=i.validateSpec;let T=[];const E=tr(r);if(E!=="object")return[new o(e,r,`object expected, ${E} found`)];for(const S in r){const k=S.split(".")[0],R=ua(s,k)||s["*"];let L;if(ua(c,k))L=c[k];else if(ua(s,k)){if(r[S]===void 0)continue;L=v}else if(c["*"])L=c["*"];else{if(!s["*"]){T.push(new o(e,r[S],`unknown property "${S}"`));continue}L=v}T=T.concat(L({key:(e&&`${e}.`)+S,value:r[S],valueSpec:R,style:p,styleSpec:m,object:r,objectKey:S,validateSpec:v},r))}for(const S in s)c[S]||s[S].required&&s[S].default===void 0&&r[S]===void 0&&T.push(new o(e,r,`missing required property "${S}"`));return T}function Ta(i){const e=i.value,r=i.valueSpec,s=i.style,c=i.styleSpec,p=i.key,m=i.arrayElementValidator||i.validateSpec;if(tr(e)!=="array")return[new o(p,e,`array expected, ${tr(e)} found`)];if(r.length&&e.length!==r.length)return[new o(p,e,`array length ${r.length} expected, length ${e.length} found`)];let v={type:r.value,values:r.values};c.$version<7&&(v.function=r.function),tr(r.value)==="object"&&(v=r.value);let T=[];for(let E=0;E<e.length;E++)T=T.concat(m({array:e,arrayIndex:E,value:e[E],valueSpec:v,validateSpec:i.validateSpec,style:s,styleSpec:c,key:`${p}[${E}]`}));return T}function Gr(i){const e=i.key,r=i.value,s=i.valueSpec;let c=tr(r);return c==="number"&&r!=r&&(c="NaN"),c!=="number"?[new o(e,r,`number expected, ${c} found`)]:"minimum"in s&&r<s.minimum?[new o(e,r,`${r} is less than the minimum value ${s.minimum}`)]:"maximum"in s&&r>s.maximum?[new o(e,r,`${r} is greater than the maximum value ${s.maximum}`)]:[]}function Ja(i){const e=i.valueSpec,r=Jr(i.value.type);let s,c,p,m={};const v=r!=="categorical"&&i.value.property===void 0,T=!v,E=tr(i.value.stops)==="array"&&tr(i.value.stops[0])==="array"&&tr(i.value.stops[0][0])==="object",S=on({key:i.key,value:i.value,valueSpec:i.styleSpec.function,validateSpec:i.validateSpec,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{stops:function(L){if(r==="identity")return[new o(L.key,L.value,'identity function may not have a "stops" property')];let j=[];const N=L.value;return j=j.concat(Ta({key:L.key,value:N,valueSpec:L.valueSpec,validateSpec:L.validateSpec,style:L.style,styleSpec:L.styleSpec,arrayElementValidator:k})),tr(N)==="array"&&N.length===0&&j.push(new o(L.key,N,"array must have at least one stop")),j},default:function(L){return L.validateSpec({key:L.key,value:L.value,valueSpec:e,validateSpec:L.validateSpec,style:L.style,styleSpec:L.styleSpec})}}});return r==="identity"&&v&&S.push(new o(i.key,i.value,'missing required property "property"')),r==="identity"||i.value.stops||S.push(new o(i.key,i.value,'missing required property "stops"')),r==="exponential"&&i.valueSpec.expression&&!Pl(i.valueSpec)&&S.push(new o(i.key,i.value,"exponential functions not supported")),i.styleSpec.$version>=8&&(T&&!Uo(i.valueSpec)?S.push(new o(i.key,i.value,"property functions not supported")):v&&!yA(i.valueSpec)&&S.push(new o(i.key,i.value,"zoom functions not supported"))),r!=="categorical"&&!E||i.value.property!==void 0||S.push(new o(i.key,i.value,'"property" property is required')),S;function k(L){let j=[];const N=L.value,q=L.key;if(tr(N)!=="array")return[new o(q,N,`array expected, ${tr(N)} found`)];if(N.length!==2)return[new o(q,N,`array length 2 expected, length ${N.length} found`)];if(E){if(tr(N[0])!=="object")return[new o(q,N,`object expected, ${tr(N[0])} found`)];if(N[0].zoom===void 0)return[new o(q,N,"object stop key must have zoom")];if(N[0].value===void 0)return[new o(q,N,"object stop key must have value")];if(p&&p>Jr(N[0].zoom))return[new o(q,N[0].zoom,"stop zoom values must appear in ascending order")];Jr(N[0].zoom)!==p&&(p=Jr(N[0].zoom),c=void 0,m={}),j=j.concat(on({key:`${q}[0]`,value:N[0],valueSpec:{zoom:{}},validateSpec:L.validateSpec,style:L.style,styleSpec:L.styleSpec,objectElementValidators:{zoom:Gr,value:R}}))}else j=j.concat(R({key:`${q}[0]`,value:N[0],validateSpec:L.validateSpec,style:L.style,styleSpec:L.styleSpec},N));return yn(uo(N[1]))?j.concat([new o(`${q}[1]`,N[1],"expressions are not allowed in function stops.")]):j.concat(L.validateSpec({key:`${q}[1]`,value:N[1],valueSpec:e,validateSpec:L.validateSpec,style:L.style,styleSpec:L.styleSpec}))}function R(L,j){const N=tr(L.value),q=Jr(L.value),Y=L.value!==null?L.value:j;if(s){if(N!==s)return[new o(L.key,Y,`${N} stop domain type must match previous stop domain type ${s}`)]}else s=N;if(N!=="number"&&N!=="string"&&N!=="boolean")return[new o(L.key,Y,"stop domain value must be a number, string, or boolean")];if(N!=="number"&&r!=="categorical"){let ue=`number expected, ${N} found`;return Uo(e)&&r===void 0&&(ue+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new o(L.key,Y,ue)]}return r!=="categorical"||N!=="number"||isFinite(q)&&Math.floor(q)===q?r!=="categorical"&&N==="number"&&c!==void 0&&q<c?[new o(L.key,Y,"stop domain values must appear in ascending order")]:(c=q,r==="categorical"&&q in m?[new o(L.key,Y,"stop domain values must be unique")]:(m[q]=!0,[])):[new o(L.key,Y,`integer expected, found ${q}`)]}}function Fs(i){const e=(i.expressionContext==="property"?Wa:ao)(uo(i.value),i.valueSpec);if(e.result==="error")return e.value.map((s=>new o(`${i.key}${s.key}`,i.value,s.message)));const r=e.value.expression||e.value._styleExpression.expression;if(i.expressionContext==="property"&&i.propertyKey==="text-font"&&!r.outputDefined())return[new o(i.key,i.value,`Invalid data expression for "${i.propertyKey}". Output values must be contained as literals within the expression.`)];if(i.expressionContext==="property"&&i.propertyType==="layout"&&!xa(r))return[new o(i.key,i.value,'"feature-state" data expressions are not supported with layout properties.')];if(i.expressionContext==="filter"&&!xa(r))return[new o(i.key,i.value,'"feature-state" data expressions are not supported with filters.')];if(i.expressionContext&&i.expressionContext.indexOf("cluster")===0){if(!Za(r,["zoom","feature-state"]))return[new o(i.key,i.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(i.expressionContext==="cluster-initial"&&!No(r))return[new o(i.key,i.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function ps(i){const e=i.key,r=i.value,s=tr(r);return s!=="string"?[new o(e,r,`color expected, ${s} found`)]:Kt.parse(String(r))?[]:[new o(e,r,`color expected, "${r}" found`)]}function _i(i){const e=i.key,r=i.value,s=i.valueSpec,c=[];return Array.isArray(s.values)?s.values.indexOf(Jr(r))===-1&&c.push(new o(e,r,`expected one of [${s.values.join(", ")}], ${JSON.stringify(r)} found`)):Object.keys(s.values).indexOf(Jr(r))===-1&&c.push(new o(e,r,`expected one of [${Object.keys(s.values).join(", ")}], ${JSON.stringify(r)} found`)),c}function $o(i){return lo(uo(i.value))?Fs(Z({},i,{expressionContext:"filter",valueSpec:{value:"boolean"}})):EA(i)}function EA(i){const e=i.value,r=i.key;if(tr(e)!=="array")return[new o(r,e,`array expected, ${tr(e)} found`)];const s=i.styleSpec;let c,p=[];if(e.length<1)return[new o(r,e,"filter array must have at least 1 element")];switch(p=p.concat(_i({key:`${r}[0]`,value:e[0],valueSpec:s.filter_operator,style:i.style,styleSpec:i.styleSpec})),Jr(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&Jr(e[1])==="$type"&&p.push(new o(r,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":e.length!==3&&p.push(new o(r,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(c=tr(e[1]),c!=="string"&&p.push(new o(`${r}[1]`,e[1],`string expected, ${c} found`)));for(let m=2;m<e.length;m++)c=tr(e[m]),Jr(e[1])==="$type"?p=p.concat(_i({key:`${r}[${m}]`,value:e[m],valueSpec:s.geometry_type,style:i.style,styleSpec:i.styleSpec})):c!=="string"&&c!=="number"&&c!=="boolean"&&p.push(new o(`${r}[${m}]`,e[m],`string, number, or boolean expected, ${c} found`));break;case"any":case"all":case"none":for(let m=1;m<e.length;m++)p=p.concat(EA({key:`${r}[${m}]`,value:e[m],style:i.style,styleSpec:i.styleSpec}));break;case"has":case"!has":c=tr(e[1]),e.length!==2?p.push(new o(r,e,`filter array for "${e[0]}" operator must have 2 elements`)):c!=="string"&&p.push(new o(`${r}[1]`,e[1],`string expected, ${c} found`))}return p}function Il(i,e){const r=i.key,s=i.validateSpec,c=i.style,p=i.styleSpec,m=i.value,v=i.objectKey,T=p[`${e}_${i.layerType}`];if(!T)return[];const E=v.match(/^(.*)-transition$/);if(e==="paint"&&E&&T[E[1]]&&T[E[1]].transition)return s({key:r,value:m,valueSpec:p.transition,style:c,styleSpec:p});const S=i.valueSpec||T[v];if(!S)return[new o(r,m,`unknown property "${v}"`)];let k;if(tr(m)==="string"&&Uo(S)&&!S.tokens&&(k=/^{([^}]+)}$/.exec(m)))return[new o(r,m,`"${v}" does not support interpolation syntax 5 + Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(k[1])} }\`.`)];const R=[];return i.layerType==="symbol"&&v==="text-font"&&Qa(uo(m))&&Jr(m.type)==="identity"&&R.push(new o(r,m,'"text-font" does not support identity functions')),R.concat(s({key:i.key,value:m,valueSpec:S,style:c,styleSpec:p,expressionContext:"property",propertyType:e,propertyKey:v}))}function Sl(i){return Il(i,"paint")}function Cl(i){return Il(i,"layout")}function Dl(i){let e=[];const r=i.value,s=i.key,c=i.style,p=i.styleSpec;if(tr(r)!=="object")return[new o(s,r,`object expected, ${tr(r)} found`)];r.type||r.ref||e.push(new o(s,r,'either "type" or "ref" is required'));let m=Jr(r.type);const v=Jr(r.ref);if(r.id){const T=Jr(r.id);for(let E=0;E<i.arrayIndex;E++){const S=c.layers[E];Jr(S.id)===T&&e.push(new o(s,r.id,`duplicate layer id "${r.id}", previously used at line ${S.id.__line__}`))}}if("ref"in r){let T;["type","source","source-layer","filter","layout"].forEach((E=>{E in r&&e.push(new o(s,r[E],`"${E}" is prohibited for ref layers`))})),c.layers.forEach((E=>{Jr(E.id)===v&&(T=E)})),T?T.ref?e.push(new o(s,r.ref,"ref cannot reference another ref layer")):m=Jr(T.type):e.push(new o(s,r.ref,`ref layer "${v}" not found`))}else if(m!=="background")if(r.source){const T=c.sources&&c.sources[r.source],E=T&&Jr(T.type);T?E==="vector"&&m==="raster"?e.push(new o(s,r.source,`layer "${r.id}" requires a raster source`)):E!=="raster-dem"&&m==="hillshade"||E!=="raster-dem"&&m==="color-relief"?e.push(new o(s,r.source,`layer "${r.id}" requires a raster-dem source`)):E==="raster"&&m!=="raster"?e.push(new o(s,r.source,`layer "${r.id}" requires a vector source`)):E!=="vector"||r["source-layer"]?E==="raster-dem"&&m!=="hillshade"&&m!=="color-relief"?e.push(new o(s,r.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):m!=="line"||!r.paint||!r.paint["line-gradient"]||E==="geojson"&&T.lineMetrics||e.push(new o(s,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new o(s,r,`layer "${r.id}" must specify a "source-layer"`)):e.push(new o(s,r.source,`source "${r.source}" not found`))}else e.push(new o(s,r,'missing required property "source"'));return e=e.concat(on({key:s,value:r,valueSpec:p.layer,style:i.style,styleSpec:i.styleSpec,validateSpec:i.validateSpec,objectElementValidators:{"*":()=>[],type:()=>i.validateSpec({key:`${s}.type`,value:r.type,valueSpec:p.layer.type,style:i.style,styleSpec:i.styleSpec,validateSpec:i.validateSpec,object:r,objectKey:"type"}),filter:$o,layout:T=>on({layer:r,key:T.key,value:T.value,style:T.style,styleSpec:T.styleSpec,validateSpec:T.validateSpec,objectElementValidators:{"*":E=>Cl(Z({layerType:m},E))}}),paint:T=>on({layer:r,key:T.key,value:T.value,style:T.style,styleSpec:T.styleSpec,validateSpec:T.validateSpec,objectElementValidators:{"*":E=>Sl(Z({layerType:m},E))}})}})),e}function fs(i){const e=i.value,r=i.key,s=tr(e);return s!=="string"?[new o(r,e,`string expected, ${s} found`)]:[]}const kl={promoteId:function({key:i,value:e}){if(tr(e)==="string")return fs({key:i,value:e});{const r=[];for(const s in e)r.push(...fs({key:`${i}.${s}`,value:e[s]}));return r}}};function zl(i){const e=i.value,r=i.key,s=i.styleSpec,c=i.style,p=i.validateSpec;if(!e.type)return[new o(r,e,'"type" is required')];const m=Jr(e.type);let v;switch(m){case"vector":case"raster":return v=on({key:r,value:e,valueSpec:s[`source_${m.replace("-","_")}`],style:i.style,styleSpec:s,objectElementValidators:kl,validateSpec:p}),v;case"raster-dem":return v=(function(T){var E;const S=(E=T.sourceName)!==null&&E!==void 0?E:"",k=T.value,R=T.styleSpec,L=R.source_raster_dem,j=T.style;let N=[];const q=tr(k);if(k===void 0)return N;if(q!=="object")return N.push(new o("source_raster_dem",k,`object expected, ${q} found`)),N;const Y=Jr(k.encoding)==="custom",ue=["redFactor","greenFactor","blueFactor","baseShift"],J=T.value.encoding?`"${T.value.encoding}"`:"Default";for(const re in k)!Y&&ue.includes(re)?N.push(new o(re,k[re],`In "${S}": "${re}" is only valid when "encoding" is set to "custom". ${J} encoding found`)):L[re]?N=N.concat(T.validateSpec({key:re,value:k[re],valueSpec:L[re],validateSpec:T.validateSpec,style:j,styleSpec:R})):N.push(new o(re,k[re],`unknown property "${re}"`));return N})({sourceName:r,value:e,style:i.style,styleSpec:s,validateSpec:p}),v;case"geojson":if(v=on({key:r,value:e,valueSpec:s.source_geojson,style:c,styleSpec:s,validateSpec:p,objectElementValidators:kl}),e.cluster)for(const T in e.clusterProperties){const[E,S]=e.clusterProperties[T],k=typeof E=="string"?[E,["accumulated"],["get",T]]:E;v.push(...Fs({key:`${r}.${T}.map`,value:S,expressionContext:"cluster-map"})),v.push(...Fs({key:`${r}.${T}.reduce`,value:k,expressionContext:"cluster-reduce"}))}return v;case"video":return on({key:r,value:e,valueSpec:s.source_video,style:c,validateSpec:p,styleSpec:s});case"image":return on({key:r,value:e,valueSpec:s.source_image,style:c,validateSpec:p,styleSpec:s});case"canvas":return[new o(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return _i({key:`${r}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function Pa(i){const e=i.value,r=i.styleSpec,s=r.light,c=i.style;let p=[];const m=tr(e);if(e===void 0)return p;if(m!=="object")return p=p.concat([new o("light",e,`object expected, ${m} found`)]),p;for(const v in e){const T=v.match(/^(.*)-transition$/);p=p.concat(T&&s[T[1]]&&s[T[1]].transition?i.validateSpec({key:v,value:e[v],valueSpec:r.transition,validateSpec:i.validateSpec,style:c,styleSpec:r}):s[v]?i.validateSpec({key:v,value:e[v],valueSpec:s[v],validateSpec:i.validateSpec,style:c,styleSpec:r}):[new o(v,e[v],`unknown property "${v}"`)])}return p}function IA(i){const e=i.value,r=i.styleSpec,s=r.sky,c=i.style,p=tr(e);if(e===void 0)return[];if(p!=="object")return[new o("sky",e,`object expected, ${p} found`)];let m=[];for(const v in e)m=m.concat(s[v]?i.validateSpec({key:v,value:e[v],valueSpec:s[v],style:c,styleSpec:r}):[new o(v,e[v],`unknown property "${v}"`)]);return m}function Kn(i){const e=i.value,r=i.styleSpec,s=r.terrain,c=i.style;let p=[];const m=tr(e);if(e===void 0)return p;if(m!=="object")return p=p.concat([new o("terrain",e,`object expected, ${m} found`)]),p;for(const v in e)p=p.concat(s[v]?i.validateSpec({key:v,value:e[v],valueSpec:s[v],validateSpec:i.validateSpec,style:c,styleSpec:r}):[new o(v,e[v],`unknown property "${v}"`)]);return p}function In(i){let e=[];const r=i.value,s=i.key;if(Array.isArray(r)){const c=[],p=[];for(const m in r)r[m].id&&c.includes(r[m].id)&&e.push(new o(s,r,`all the sprites' ids must be unique, but ${r[m].id} is duplicated`)),c.push(r[m].id),r[m].url&&p.includes(r[m].url)&&e.push(new o(s,r,`all the sprites' URLs must be unique, but ${r[m].url} is duplicated`)),p.push(r[m].url),e=e.concat(on({key:`${s}[${m}]`,value:r[m],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:i.validateSpec}));return e}return fs({key:s,value:r})}function kt(i){return!!i&&i.constructor===Object}function Bi(i){return kt(i.value)?[]:[new o(i.key,i.value,`object expected, ${tr(i.value)} found`)]}const Dt={"*":()=>[],array:Ta,boolean:function(i){const e=i.value,r=i.key,s=tr(e);return s!=="boolean"?[new o(r,e,`boolean expected, ${s} found`)]:[]},number:Gr,color:ps,constants:MA,enum:_i,filter:$o,function:Ja,layer:Dl,object:on,source:zl,light:Pa,sky:IA,terrain:Kn,projection:function(i){const e=i.value,r=i.styleSpec,s=r.projection,c=i.style,p=tr(e);if(e===void 0)return[];if(p!=="object")return[new o("projection",e,`object expected, ${p} found`)];let m=[];for(const v in e)m=m.concat(s[v]?i.validateSpec({key:v,value:e[v],valueSpec:s[v],style:c,styleSpec:r}):[new o(v,e[v],`unknown property "${v}"`)]);return m},projectionDefinition:function(i){const e=i.key;let r=i.value;r=r instanceof String?r.valueOf():r;const s=tr(r);return s!=="array"||(function(c){return Array.isArray(c)&&c.length===3&&typeof c[0]=="string"&&typeof c[1]=="string"&&typeof c[2]=="number"})(r)||(function(c){return!!["interpolate","step","literal"].includes(c[0])})(r)?["array","string"].includes(s)?[]:[new o(e,r,`projection expected, invalid type "${s}" found`)]:[new o(e,r,`projection expected, invalid array ${JSON.stringify(r)} found`)]},string:fs,formatted:function(i){return fs(i).length===0?[]:Fs(i)},resolvedImage:function(i){return fs(i).length===0?[]:Fs(i)},padding:function(i){const e=i.key,r=i.value;if(tr(r)==="array"){if(r.length<1||r.length>4)return[new o(e,r,`padding requires 1 to 4 values; ${r.length} values found`)];const s={type:"number"};let c=[];for(let p=0;p<r.length;p++)c=c.concat(i.validateSpec({key:`${e}[${p}]`,value:r[p],validateSpec:i.validateSpec,valueSpec:s}));return c}return Gr({key:e,value:r,valueSpec:{}})},numberArray:function(i){const e=i.key,r=i.value;if(tr(r)==="array"){const s={type:"number"};if(r.length<1)return[new o(e,r,"array length at least 1 expected, length 0 found")];let c=[];for(let p=0;p<r.length;p++)c=c.concat(i.validateSpec({key:`${e}[${p}]`,value:r[p],validateSpec:i.validateSpec,valueSpec:s}));return c}return Gr({key:e,value:r,valueSpec:{}})},colorArray:function(i){const e=i.key,r=i.value;if(tr(r)==="array"){if(r.length<1)return[new o(e,r,"array length at least 1 expected, length 0 found")];let s=[];for(let c=0;c<r.length;c++)s=s.concat(ps({key:`${e}[${c}]`,value:r[c]}));return s}return ps({key:e,value:r})},variableAnchorOffsetCollection:function(i){const e=i.key,r=i.value,s=tr(r),c=i.styleSpec;if(s!=="array"||r.length<1||r.length%2!=0)return[new o(e,r,"variableAnchorOffsetCollection requires a non-empty array of even length")];let p=[];for(let m=0;m<r.length;m+=2)p=p.concat(_i({key:`${e}[${m}]`,value:r[m],valueSpec:c.layout_symbol["text-anchor"]})),p=p.concat(Ta({key:`${e}[${m+1}]`,value:r[m+1],valueSpec:{length:2,value:"number"},validateSpec:i.validateSpec,style:i.style,styleSpec:c}));return p},sprite:In,state:Bi,fontFaces:function(i){const e=i.key,r=i.value,s=i.validateSpec,c=i.styleSpec,p=i.style;if(!kt(r))return[new o(e,r,`object expected, ${tr(r)} found`)];const m=[];for(const v in r){const T=r[v],E=tr(T);if(E==="string")m.push(...fs({key:`${e}.${v}`,value:T}));else if(E==="array"){const S={url:{type:"string",required:!0},"unicode-range":{type:"array",value:"string"}};for(const[k,R]of T.entries())m.push(...on({key:`${e}.${v}[${k}]`,value:R,valueSpec:S,styleSpec:c,style:p,validateSpec:s}))}else m.push(new o(`${e}.${v}`,T,`string or array expected, ${E} found`))}return m}};function Lr(i){const e=i.value,r=i.valueSpec,s=i.styleSpec;return i.validateSpec=Lr,r.expression&&Qa(Jr(e))?Ja(i):r.expression&&yn(uo(e))?Fs(i):r.type&&Dt[r.type]?Dt[r.type](i):on(Z({},i,{valueSpec:r.type?s[r.type]:r}))}function Bl(i){const e=i.value,r=i.key,s=fs(i);return s.length||(e.indexOf("{fontstack}")===-1&&s.push(new o(r,e,'"glyphs" url must include a "{fontstack}" token')),e.indexOf("{range}")===-1&&s.push(new o(r,e,'"glyphs" url must include a "{range}" token'))),s}function an(i,e=Le){let r=[];return r=r.concat(Lr({key:"",value:i,valueSpec:e.$root,styleSpec:e,style:i,validateSpec:Lr,objectElementValidators:{glyphs:Bl,"*":()=>[]}})),i.constants&&(r=r.concat(MA({key:"constants",value:i.constants}))),SA(r)}function yi(i){return function(e){return i(Object.assign({},e,{validateSpec:Lr}))}}function SA(i){return[].concat(i).sort(((e,r)=>e.line-r.line))}function Ir(i){return function(...e){return SA(i.apply(this,e))}}an.source=Ir(yi(zl)),an.sprite=Ir(yi(In)),an.glyphs=Ir(yi(Bl)),an.light=Ir(yi(Pa)),an.sky=Ir(yi(IA)),an.terrain=Ir(yi(Kn)),an.state=Ir(yi(Bi)),an.layer=Ir(yi(Dl)),an.filter=Ir(yi($o)),an.paintProperty=Ir(yi(Sl)),an.layoutProperty=Ir(yi(Cl));const Wo={type:"enum","property-type":"data-constant",expression:{interpolated:!1,parameters:["global-state"]},values:{visible:{},none:{}},transition:!1,default:"visible"};class Jn{constructor(e,r){this._globalState=r,this.setValue(e)}evaluate(){var e;return(e=this._literalValue)!==null&&e!==void 0?e:this._compiledValue.evaluate({})}setValue(e){if(e==null||e==="visible"||e==="none")return this._literalValue=e==="none"?"none":"visible",this._compiledValue=void 0,void(this._globalStateRefs=new Set);const r=ao(e,Wo,this._globalState);if(r.result==="error")throw this._literalValue="visible",this._compiledValue=void 0,new Error(r.value.map((s=>`${s.key}: ${s.message}`)).join(", "));this._literalValue=void 0,this._compiledValue=r.value,this._globalStateRefs=En(r.value.expression)}getGlobalStateRefs(){return this._globalStateRefs}}const Ho=Le,Ye=an,lt=Ye.light,el=Ye.sky,CA=Ye.paintProperty,tl=Ye.layoutProperty;function ds(i,e){let r=!1;if(e&&e.length)for(const s of e)i.fire(new gr(new Error(s.message))),r=!0;return r}class Nn{constructor(e,r,s){const c=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;const m=new Int32Array(this.arrayBuffer);e=m[0],this.d=(r=m[1])+2*(s=m[2]);for(let T=0;T<this.d*this.d;T++){const E=m[3+T],S=m[3+T+1];c.push(E===S?null:m.subarray(E,S))}const v=m[3+c.length+1];this.keys=m.subarray(m[3+c.length],v),this.bboxes=m.subarray(v),this.insert=this._insertReadonly}else{this.d=r+2*s;for(let m=0;m<this.d*this.d;m++)c.push([]);this.keys=[],this.bboxes=[]}this.n=r,this.extent=e,this.padding=s,this.scale=r/e,this.uid=0;const p=s/r*e;this.min=-p,this.max=e+p}insert(e,r,s,c,p){this._forEachCell(r,s,c,p,this._insertCell,this.uid++,void 0,void 0),this.keys.push(e),this.bboxes.push(r),this.bboxes.push(s),this.bboxes.push(c),this.bboxes.push(p)}_insertReadonly(){throw new Error("Cannot insert into a GridIndex created from an ArrayBuffer.")}_insertCell(e,r,s,c,p,m){this.cells[p].push(m)}query(e,r,s,c,p){const m=this.min,v=this.max;if(e<=m&&r<=m&&v<=s&&v<=c&&!p)return Array.prototype.slice.call(this.keys);{const T=[];return this._forEachCell(e,r,s,c,this._queryCell,T,{},p),T}}_queryCell(e,r,s,c,p,m,v,T){const E=this.cells[p];if(E!==null){const S=this.keys,k=this.bboxes;for(let R=0;R<E.length;R++){const L=E[R];if(v[L]===void 0){const j=4*L;(T?T(k[j+0],k[j+1],k[j+2],k[j+3]):e<=k[j+2]&&r<=k[j+3]&&s>=k[j+0]&&c>=k[j+1])?(v[L]=!0,m.push(S[L])):v[L]=!1}}}}_forEachCell(e,r,s,c,p,m,v,T){const E=this._convertToCellCoord(e),S=this._convertToCellCoord(r),k=this._convertToCellCoord(s),R=this._convertToCellCoord(c);for(let L=E;L<=k;L++)for(let j=S;j<=R;j++){const N=this.d*j+L;if((!T||T(this._convertFromCellCoord(L),this._convertFromCellCoord(j),this._convertFromCellCoord(L+1),this._convertFromCellCoord(j+1)))&&p.call(this,e,r,s,c,N,m,v,T))return}}_convertFromCellCoord(e){return(e-this.padding)/this.scale}_convertToCellCoord(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const e=this.cells,r=3+this.cells.length+1+1;let s=0;for(let m=0;m<this.cells.length;m++)s+=this.cells[m].length;const c=new Int32Array(r+s+this.keys.length+this.bboxes.length);c[0]=this.extent,c[1]=this.n,c[2]=this.padding;let p=r;for(let m=0;m<e.length;m++){const v=e[m];c[3+m]=p,c.set(v,p),p+=v.length}return c[3+e.length]=p,c.set(this.keys,p),p+=this.keys.length,c[3+e.length+1]=p,c.set(this.bboxes,p),p+=this.bboxes.length,c.buffer}static serialize(e,r){const s=e.toArrayBuffer();return r&&r.push(s),{buffer:s}}static deserialize(e){return new Nn(e.buffer)}}const vi={};function yt(i,e,r={}){if(vi[i])throw new Error(`${i} is already registered.`);Object.defineProperty(e,"_classRegistryKey",{value:i,writeable:!1}),vi[i]={klass:e,omit:r.omit||[],shallow:r.shallow||[]}}yt("Object",Object),yt("Set",Set),yt("TransferableGridIndex",Nn),yt("Color",Kt),yt("Error",Error),yt("AJAXError",Te),yt("ResolvedImage",tn),yt("StylePropertyFunction",Ha),yt("StyleExpression",Ml,{omit:["_evaluator"]}),yt("ZoomDependentExpression",Zo),yt("ZoomConstantExpression",$a),yt("CompoundExpression",_n,{omit:["_evaluate"]});for(const i in jo)jo[i]._classRegistryKey||yt(`Expression_${i}`,jo[i]);function Gn(i){return i&&typeof ArrayBuffer<"u"&&(i instanceof ArrayBuffer||i.constructor&&i.constructor.name==="ArrayBuffer")}function l(i){return i.$name||i.constructor._classRegistryKey}function a(i){return!(function(e){if(e===null||typeof e!="object")return!1;const r=l(e);return!(!r||r==="Object")})(i)&&(i==null||typeof i=="boolean"||typeof i=="number"||typeof i=="string"||i instanceof Boolean||i instanceof Number||i instanceof String||i instanceof Date||i instanceof RegExp||i instanceof Blob||i instanceof Error||Gn(i)||Tn(i)||ArrayBuffer.isView(i)||i instanceof ImageData)}function u(i,e){if(a(i))return(Gn(i)||Tn(i))&&e&&e.push(i),ArrayBuffer.isView(i)&&e&&e.push(i.buffer),i instanceof ImageData&&e&&e.push(i.data.buffer),i;if(Array.isArray(i)){const p=[];for(const m of i)p.push(u(m,e));return p}if(typeof i!="object")throw new Error("can't serialize object of type "+typeof i);const r=l(i);if(!r)throw new Error(`can't serialize object of unregistered class ${i.constructor.name}`);if(!vi[r])throw new Error(`${r} is not registered.`);const{klass:s}=vi[r],c=s.serialize?s.serialize(i,e):{};if(s.serialize){if(e&&c===e[e.length-1])throw new Error("statically serialized object won't survive transfer of $name property")}else{for(const p in i){if(!i.hasOwnProperty(p)||vi[r].omit.indexOf(p)>=0)continue;const m=i[p];c[p]=vi[r].shallow.indexOf(p)>=0?m:u(m,e)}i instanceof Error&&(c.message=i.message)}if(c.$name)throw new Error("$name property is reserved for worker serialization logic.");return r!=="Object"&&(c.$name=r),c}function f(i){if(a(i))return i;if(Array.isArray(i))return i.map(f);if(typeof i!="object")throw new Error("can't deserialize object of type "+typeof i);const e=l(i)||"Object";if(!vi[e])throw new Error(`can't deserialize unregistered class ${e}`);const{klass:r}=vi[e];if(!r)throw new Error(`can't deserialize unregistered class ${e}`);if(r.deserialize)return r.deserialize(i);const s=Object.create(r.prototype);for(const c of Object.keys(i)){if(c==="$name")continue;const p=i[c];s[c]=vi[e].shallow.indexOf(c)>=0?p:f(p)}return s}class g{constructor(){this.first=!0}update(e,r){const s=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=s,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=s,!0):(this.lastFloorZoom>s?(this.lastIntegerZoom=s+1,this.lastIntegerZoomTime=r):this.lastFloorZoom<s&&(this.lastIntegerZoom=s,this.lastIntegerZoomTime=r),e!==this.lastZoom&&(this.lastZoom=e,this.lastFloorZoom=s,!0))}}function x(i){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(i))}function w(i){return/[\u02EA\u02EB\u1100-\u11FF\u1400-\u167F\u18B0-\u18F5\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u3007\u3012\u3013\u3020-\u302F\u3031-\u303F\u3041-\u3096\u309D-\u30FB\u30FD-\u30FF\u3105-\u312F\u3131-\u318E\u3190-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE48\uFE50-\uFE57\uFE5F-\uFE62\uFE67-\uFE6F\uFF00-\uFF07\uFF0A-\uFF0C\uFF0E-\uFF19\uFF1F-\uFF3A\uFF3C\uFF3E\uFF40-\uFF5A\uFFE0-\uFFE2\uFFE4-\uFFE7]|\uD802[\uDD80-\uDD9F]|\uD805[\uDD80-\uDDFF]|\uD806[\uDE00-\uDEBF]|\uD811[\uDC00-\uDE7F]|\uD81B[\uDFE0-\uDFE4\uDFF0-\uDFF6]|[\uD81C-\uD822\uD83D\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD30-\uDEFB]|\uD833[\uDEC0-\uDFCF]|\uD834[\uDC00-\uDDFF\uDEE0-\uDF7F]|\uD836[\uDC00-\uDEAF]|\uD83C[\uDC00-\uDE00\uDF00-\uDFFF]|\uD83E[\uDD00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(i))}function P(i){return/\s/u.test(String.fromCodePoint(i))}function C(i){for(const e of i)if(w(e.codePointAt(0)))return!0;return!1}function z(i){for(const e of i)if(!ae(e.codePointAt(0)))return!1;return!0}function F(i){const e=i.map((r=>{try{return new RegExp(`\\p{sc=${r}}`,"u").source}catch{return null}})).filter((r=>r));return new RegExp(e.join("|"),"u")}const K=F(["Arab","Dupl","Mong","Ougr","Syrc"]);function ae(i){return!K.test(String.fromCodePoint(i))}function oe(i){return!(w(i)||(e=i,/[\xA7\xA9\xAE\xB1\xBC-\xBE\xD7\xF7\u2016\u2020\u2021\u2030\u2031\u203B\u203C\u2042\u2047-\u2049\u2051\u2100-\u218F\u221E\u2234\u2235\u2300-\u2307\u230C-\u231F\u2324-\u2328\u232B\u237D-\u239A\u23BE-\u23CD\u23CF\u23D1-\u23DB\u23E2-\u2422\u2424-\u24FF\u25A0-\u2619\u2620-\u2767\u2776-\u2793\u2B12-\u2B2F\u2B50-\u2B59\u2BB8-\u2BEB\u3000-\u303F\u30A0-\u30FF\uE000-\uF8FF\uFE30-\uFE6F\uFF00-\uFFEF\uFFFC\uFFFD]|[\uDB80-\uDBFF][\uDC00-\uDFFF]/gim.test(String.fromCodePoint(e))));var e}const le=F(["Adlm","Arab","Armi","Avst","Chrs","Cprt","Egyp","Elym","Gara","Hatr","Hebr","Hung","Khar","Lydi","Mand","Mani","Mend","Merc","Mero","Narb","Nbat","Nkoo","Orkh","Palm","Phli","Phlp","Phnx","Prti","Rohg","Samr","Sarb","Sogo","Syrc","Thaa","Todr","Yezi"]);function xe(i){return le.test(String.fromCodePoint(i))}function Ee(i,e){return!(!e&&xe(i)||/[\u0900-\u0DFF\u0F00-\u109F\u1780-\u17FF]/gim.test(String.fromCodePoint(i)))}function Ue(i){for(const e of i)if(xe(e.codePointAt(0)))return!0;return!1}const Se=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null,this.loadScriptResolve=()=>{}}setState(i){this.pluginStatus=i.pluginStatus,this.pluginURL=i.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(i){if(Se.isParsed())throw new Error("RTL text plugin already registered.");this.applyArabicShaping=i.applyArabicShaping,this.processBidirectionalText=i.processBidirectionalText,this.processStyledBidirectionalText=i.processStyledBidirectionalText,this.loadScriptResolve()}isParsed(){return this.applyArabicShaping!=null&&this.processBidirectionalText!=null&&this.processStyledBidirectionalText!=null}getRTLTextPluginStatus(){return this.pluginStatus}syncState(i,e){return d(this,void 0,void 0,(function*(){if(this.isParsed())return this.getState();if(i.pluginStatus!=="loading")return this.setState(i),i;const r=i.pluginURL,s=new Promise((p=>{this.loadScriptResolve=p}));e(r);const c=new Promise((p=>setTimeout((()=>p()),this.TIMEOUT)));if(yield Promise.race([s,c]),this.isParsed()){const p={pluginStatus:"loaded",pluginURL:r};return this.setState(p),p}throw this.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${r}`)}))}};class Pe{constructor(e,r){this.isSupportedScript=we,this.zoom=e,r?(this.now=r.now||0,this.fadeDuration=r.fadeDuration||0,this.zoomHistory=r.zoomHistory||new g,this.transition=r.transition||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new g,this.transition={})}crossFadingFactor(){return this.fadeDuration===0?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const e=this.zoom,r=e-Math.floor(e),s=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:r+(1-r)*s}:{fromScale:.5,toScale:1,t:1-(1-s)*r}}}function we(i){return(function(e,r){for(const s of e)if(!Ee(s.codePointAt(0),r))return!1;return!0})(i,Se.getRTLTextPluginStatus()==="loaded")}const ct="-transition";class St{constructor(e,r,s){this.property=e,this.value=r,this.expression=(function(c,p,m){if(Qa(c))return new Ha(c,p);if(yn(c)){const v=Wa(c,p,m);if(v.result==="error")throw new Error(v.value.map((T=>`${T.key}: ${T.message}`)).join(", "));return v.value}{let v=c;return p.type==="color"&&typeof c=="string"?v=Kt.parse(c):p.type!=="padding"||typeof c!="number"&&!Array.isArray(c)?p.type!=="numberArray"||typeof c!="number"&&!Array.isArray(c)?p.type!=="colorArray"||typeof c!="string"&&!Array.isArray(c)?p.type==="variableAnchorOffsetCollection"&&Array.isArray(c)?v=Qi.parse(c):p.type==="projectionDefinition"&&typeof c=="string"&&(v=$i.parse(c)):v=Bt.parse(c):v=Cr.parse(c):v=Pi.parse(c),{globalStateRefs:new Set,_globalState:null,kind:"constant",evaluate:()=>v}}})(r===void 0?e.specification.default:r,e.specification,s)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}getGlobalStateRefs(){return this.expression.globalStateRefs||new Set}possiblyEvaluate(e,r,s){return this.property.possiblyEvaluate(this,e,r,s)}}class Mt{constructor(e,r){this.property=e,this.value=new St(e,void 0,r)}transitioned(e,r){return new $t(this.property,this.value,r,qi({},e.transition,this.transition),e.now)}untransitioned(){return new $t(this.property,this.value,null,{},0)}}class jt{constructor(e,r){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._globalState=r}getValue(e){return Bn(this._values[e].value.value)}setValue(e,r){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Mt(this._values[e].property,this._globalState)),this._values[e].value=new St(this._values[e].property,r===null?void 0:Bn(r),this._globalState)}getTransition(e){return Bn(this._values[e].transition)}setTransition(e,r){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Mt(this._values[e].property,this._globalState)),this._values[e].transition=Bn(r)||void 0}serialize(){const e={};for(const r of Object.keys(this._values)){const s=this.getValue(r);s!==void 0&&(e[r]=s);const c=this.getTransition(r);c!==void 0&&(e[`${r}${ct}`]=c)}return e}transitioned(e,r){const s=new ir(this._properties);for(const c of Object.keys(this._values))s._values[c]=this._values[c].transitioned(e,r._values[c]);return s}untransitioned(){const e=new ir(this._properties);for(const r of Object.keys(this._values))e._values[r]=this._values[r].untransitioned();return e}}class $t{constructor(e,r,s,c,p){this.property=e,this.value=r,this.begin=p+c.delay||0,this.end=this.begin+c.duration||0,e.specification.transition&&(c.delay||c.duration)&&(this.prior=s)}possiblyEvaluate(e,r,s){const c=e.now||0,p=this.value.possiblyEvaluate(e,r,s),m=this.prior;if(m){if(c>this.end)return this.prior=null,p;if(this.value.isDataDriven())return this.prior=null,p;if(c<this.begin)return m.possiblyEvaluate(e,r,s);{const v=(c-this.begin)/(this.end-this.begin);return this.property.interpolate(m.possiblyEvaluate(e,r,s),p,bo(v))}}return p}}class ir{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,r,s){const c=new At(this._properties);for(const p of Object.keys(this._values))c._values[p]=this._values[p].possiblyEvaluate(e,r,s);return c}hasTransition(){for(const e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class Rt{constructor(e,r){this._properties=e,this._values=Object.create(e.defaultPropertyValues),this._globalState=r}hasValue(e){return this._values[e].value!==void 0}getValue(e){return Bn(this._values[e].value)}setValue(e,r){this._values[e]=new St(this._values[e].property,r===null?void 0:Bn(r),this._globalState)}serialize(){const e={};for(const r of Object.keys(this._values)){const s=this.getValue(r);s!==void 0&&(e[r]=s)}return e}possiblyEvaluate(e,r,s){const c=new At(this._properties);for(const p of Object.keys(this._values))c._values[p]=this._values[p].possiblyEvaluate(e,r,s);return c}}class Et{constructor(e,r,s){this.property=e,this.value=r,this.parameters=s}isConstant(){return this.value.kind==="constant"}constantOr(e){return this.value.kind==="constant"?this.value.value:e}evaluate(e,r,s,c){return this.property.evaluate(this.value,this.parameters,e,r,s,c)}}class At{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class at{constructor(e){this.specification=e}possiblyEvaluate(e,r){if(e.isDataDriven())throw new Error("Value should not be data driven");return e.expression.evaluate(r)}interpolate(e,r,s){const c=Sr[this.specification.type];return c?c(e,r,s):e}}class dt{constructor(e,r){this.specification=e,this.overrides=r}possiblyEvaluate(e,r,s,c){return new Et(this,e.expression.kind==="constant"||e.expression.kind==="camera"?{kind:"constant",value:e.expression.evaluate(r,null,{},s,c)}:e.expression,r)}interpolate(e,r,s){if(e.value.kind!=="constant"||r.value.kind!=="constant")return e;if(e.value.value===void 0||r.value.value===void 0)return new Et(this,{kind:"constant",value:void 0},e.parameters);const c=Sr[this.specification.type];if(c){const p=c(e.value.value,r.value.value,s);return new Et(this,{kind:"constant",value:p},e.parameters)}return e}evaluate(e,r,s,c,p,m){return e.kind==="constant"?e.value:e.evaluate(r,s,c,p,m)}}class Nt extends dt{possiblyEvaluate(e,r,s,c){if(e.value===void 0)return new Et(this,{kind:"constant",value:void 0},r);if(e.expression.kind==="constant"){const p=e.expression.evaluate(r,null,{},s,c),m=e.property.specification.type==="resolvedImage"&&typeof p!="string"?p.name:p,v=this._calculate(m,m,m,r);return new Et(this,{kind:"constant",value:v},r)}if(e.expression.kind==="camera"){const p=this._calculate(e.expression.evaluate({zoom:r.zoom-1}),e.expression.evaluate({zoom:r.zoom}),e.expression.evaluate({zoom:r.zoom+1}),r);return new Et(this,{kind:"constant",value:p},r)}return new Et(this,e.expression,r)}evaluate(e,r,s,c,p,m){if(e.kind==="source"){const v=e.evaluate(r,s,c,p,m);return this._calculate(v,v,v,r)}return e.kind==="composite"?this._calculate(e.evaluate({zoom:Math.floor(r.zoom)-1},s,c),e.evaluate({zoom:Math.floor(r.zoom)},s,c),e.evaluate({zoom:Math.floor(r.zoom)+1},s,c),r):e.value}_calculate(e,r,s,c){return c.zoom>c.zoomHistory.lastIntegerZoom?{from:e,to:r}:{from:s,to:r}}interpolate(e){return e}}class fr{constructor(e){this.specification=e}possiblyEvaluate(e,r,s,c){if(e.value!==void 0){if(e.expression.kind==="constant"){const p=e.expression.evaluate(r,null,{},s,c);return this._calculate(p,p,p,r)}return this._calculate(e.expression.evaluate(new Pe(Math.floor(r.zoom-1),r)),e.expression.evaluate(new Pe(Math.floor(r.zoom),r)),e.expression.evaluate(new Pe(Math.floor(r.zoom+1),r)),r)}}_calculate(e,r,s,c){return c.zoom>c.zoomHistory.lastIntegerZoom?{from:e,to:r}:{from:s,to:r}}interpolate(e){return e}}class xi{constructor(e){this.specification=e}possiblyEvaluate(e,r,s,c){return!!e.expression.evaluate(r,null,{},s,c)}interpolate(){return!1}}class Ri{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const r in e){const s=e[r];s.specification.overridable&&this.overridableProperties.push(r);const c=this.defaultPropertyValues[r]=new St(s,void 0,void 0),p=this.defaultTransitionablePropertyValues[r]=new Mt(s,void 0);this.defaultTransitioningPropertyValues[r]=p.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=c.possiblyEvaluate({})}}}yt("DataDrivenProperty",dt),yt("DataConstantProperty",at),yt("CrossFadedDataDrivenProperty",Nt),yt("CrossFadedProperty",fr),yt("ColorRampProperty",xi);class es extends hr{constructor(e,r,s){if(super(),this.id=e.id,this.type=e.type,this._globalState=s,this._featureFilter={filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set},this._visibilityExpression=(function(c,p){return new Jn(c,p)})(this.visibility,s),e.type!=="custom"&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,e.type!=="background"&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter,this._featureFilter=Ao(e.filter,s)),r.layout&&(this._unevaluatedLayout=new Rt(r.layout,s)),r.paint)){this._transitionablePaint=new jt(r.paint,s);for(const c in e.paint)this.setPaintProperty(c,e.paint[c],{validate:!1});for(const c in e.layout)this.setLayoutProperty(c,e.layout[c],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new At(r.paint)}}setFilter(e){this.filter=e,this._featureFilter=Ao(e,this._globalState)}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){return e==="visibility"?this.visibility:this._unevaluatedLayout.getValue(e)}getLayoutAffectingGlobalStateRefs(){const e=new Set;for(const r of this._visibilityExpression.getGlobalStateRefs())e.add(r);if(this._unevaluatedLayout)for(const r in this._unevaluatedLayout._values){const s=this._unevaluatedLayout._values[r];for(const c of s.getGlobalStateRefs())e.add(c)}for(const r of this._featureFilter.getGlobalStateRefs())e.add(r);return e}getPaintAffectingGlobalStateRefs(){var e;const r=new globalThis.Map;if(this._transitionablePaint)for(const s in this._transitionablePaint._values){const c=this._transitionablePaint._values[s].value;for(const p of c.getGlobalStateRefs()){const m=(e=r.get(p))!==null&&e!==void 0?e:[];m.push({name:s,value:c.value}),r.set(p,m)}}return r}getVisibilityAffectingGlobalStateRefs(){return this._visibilityExpression.getGlobalStateRefs()}setLayoutProperty(e,r,s={}){if(r==null||!this._validate(tl,`layers.${this.id}.layout.${e}`,e,r,s))return e==="visibility"?(this.visibility=r,this._visibilityExpression.setValue(r),void this.recalculateVisibility()):void this._unevaluatedLayout.setValue(e,r)}getPaintProperty(e){return e.endsWith(ct)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,r,s={}){if(r!=null&&this._validate(CA,`layers.${this.id}.paint.${e}`,e,r,s))return!1;if(e.endsWith(ct))return this._transitionablePaint.setTransition(e.slice(0,-11),r||void 0),!1;{const c=this._transitionablePaint._values[e],p=c.property.specification["property-type"]==="cross-faded-data-driven",m=c.value.isDataDriven(),v=c.value;this._transitionablePaint.setValue(e,r),this._handleSpecialPaintPropertyUpdate(e);const T=this._transitionablePaint._values[e].value;return T.isDataDriven()||m||p||this._handleOverridablePaintPropertyUpdate(e,v,T)}}_handleSpecialPaintPropertyUpdate(e){}_handleOverridablePaintPropertyUpdate(e,r,s){return!1}isHidden(e=this.minzoom,r=!1){return!!(this.minzoom&&e<(r?Math.floor(this.minzoom):this.minzoom))||!!(this.maxzoom&&e>=this.maxzoom)||this._evaluatedVisibility==="none"}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculateVisibility(){this._evaluatedVisibility=this._visibilityExpression.evaluate()}recalculate(e,r){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,r)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,r)}serialize(){const e={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&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(e.layout=e.layout||{},e.layout.visibility=this.visibility),na(e,((r,s)=>!(r===void 0||s==="layout"&&!Object.keys(r).length||s==="paint"&&!Object.keys(r).length)))}_validate(e,r,s,c,p={}){return(!p||p.validate!==!1)&&ds(this,e.call(Ye,{key:r,layerType:this.type,objectKey:s,value:c,styleSpec:Le,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const e in this.paint._values){const r=this.paint.get(e);if(r instanceof Et&&Uo(r.property.specification)&&(r.value.kind==="source"||r.value.kind==="composite")&&r.value.isStateDependent)return!0}return!1}}let pu;var Qu={get paint(){return pu=pu||new Ri({"raster-opacity":new at(Le.paint_raster["raster-opacity"]),"raster-hue-rotate":new at(Le.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new at(Le.paint_raster["raster-brightness-min"]),"raster-brightness-max":new at(Le.paint_raster["raster-brightness-max"]),"raster-saturation":new at(Le.paint_raster["raster-saturation"]),"raster-contrast":new at(Le.paint_raster["raster-contrast"]),"raster-resampling":new at(Le.paint_raster["raster-resampling"]),"raster-fade-duration":new at(Le.paint_raster["raster-fade-duration"])})}};class Ic extends es{constructor(e,r){super(e,Qu,r)}}const Sc={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Rl{constructor(e,r){this._structArray=e,this._pos1=r*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class ei{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,r){return e._trim(),r&&(e.isTransferred=!0,r.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const r=Object.create(this.prototype);return r.arrayBuffer=e.arrayBuffer,r.length=e.length,r.capacity=e.arrayBuffer.byteLength/r.bytesPerElement,r._refreshViews(),r}_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(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const r=this.uint8;this._refreshViews(),r&&this.uint8.set(r)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function Ai(i,e=1){let r=0,s=0;return{members:i.map((c=>{const p=Sc[c.type].BYTES_PER_ELEMENT,m=r=Ma(r,Math.max(e,p)),v=c.components||1;return s=Math.max(s,p),r+=p*v,{name:c.name,type:c.type,components:v,offset:m}})),size:Ma(r,Math.max(s,e)),alignment:e}}function Ma(i,e){return Math.ceil(i/e)*e}class Ll extends ei{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r){const s=this.length;return this.resize(s+1),this.emplace(s,e,r)}emplace(e,r,s){const c=2*e;return this.int16[c+0]=r,this.int16[c+1]=s,e}}Ll.prototype.bytesPerElement=4,yt("StructArrayLayout2i4",Ll);class DA extends ei{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,s){const c=this.length;return this.resize(c+1),this.emplace(c,e,r,s)}emplace(e,r,s,c){const p=3*e;return this.int16[p+0]=r,this.int16[p+1]=s,this.int16[p+2]=c,e}}DA.prototype.bytesPerElement=6,yt("StructArrayLayout3i6",DA);class fu extends ei{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,s,c){const p=this.length;return this.resize(p+1),this.emplace(p,e,r,s,c)}emplace(e,r,s,c,p){const m=4*e;return this.int16[m+0]=r,this.int16[m+1]=s,this.int16[m+2]=c,this.int16[m+3]=p,e}}fu.prototype.bytesPerElement=8,yt("StructArrayLayout4i8",fu);class kA extends ei{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,s,c,p,m){const v=this.length;return this.resize(v+1),this.emplace(v,e,r,s,c,p,m)}emplace(e,r,s,c,p,m,v){const T=6*e;return this.int16[T+0]=r,this.int16[T+1]=s,this.int16[T+2]=c,this.int16[T+3]=p,this.int16[T+4]=m,this.int16[T+5]=v,e}}kA.prototype.bytesPerElement=12,yt("StructArrayLayout2i4i12",kA);class du extends ei{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,s,c,p,m){const v=this.length;return this.resize(v+1),this.emplace(v,e,r,s,c,p,m)}emplace(e,r,s,c,p,m,v){const T=4*e,E=8*e;return this.int16[T+0]=r,this.int16[T+1]=s,this.uint8[E+4]=c,this.uint8[E+5]=p,this.uint8[E+6]=m,this.uint8[E+7]=v,e}}du.prototype.bytesPerElement=8,yt("StructArrayLayout2i4ub8",du);class Fl extends ei{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r){const s=this.length;return this.resize(s+1),this.emplace(s,e,r)}emplace(e,r,s){const c=2*e;return this.float32[c+0]=r,this.float32[c+1]=s,e}}Fl.prototype.bytesPerElement=8,yt("StructArrayLayout2f8",Fl);class co extends ei{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,s,c,p,m,v,T,E,S){const k=this.length;return this.resize(k+1),this.emplace(k,e,r,s,c,p,m,v,T,E,S)}emplace(e,r,s,c,p,m,v,T,E,S,k){const R=10*e;return this.uint16[R+0]=r,this.uint16[R+1]=s,this.uint16[R+2]=c,this.uint16[R+3]=p,this.uint16[R+4]=m,this.uint16[R+5]=v,this.uint16[R+6]=T,this.uint16[R+7]=E,this.uint16[R+8]=S,this.uint16[R+9]=k,e}}co.prototype.bytesPerElement=20,yt("StructArrayLayout10ui20",co);class zA extends ei{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,s,c,p,m,v,T){const E=this.length;return this.resize(E+1),this.emplace(E,e,r,s,c,p,m,v,T)}emplace(e,r,s,c,p,m,v,T,E){const S=8*e;return this.uint16[S+0]=r,this.uint16[S+1]=s,this.uint16[S+2]=c,this.uint16[S+3]=p,this.uint16[S+4]=m,this.uint16[S+5]=v,this.uint16[S+6]=T,this.uint16[S+7]=E,e}}zA.prototype.bytesPerElement=16,yt("StructArrayLayout8ui16",zA);class Ol extends ei{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,s,c,p,m,v,T,E,S,k,R){const L=this.length;return this.resize(L+1),this.emplace(L,e,r,s,c,p,m,v,T,E,S,k,R)}emplace(e,r,s,c,p,m,v,T,E,S,k,R,L){const j=12*e;return this.int16[j+0]=r,this.int16[j+1]=s,this.int16[j+2]=c,this.int16[j+3]=p,this.uint16[j+4]=m,this.uint16[j+5]=v,this.uint16[j+6]=T,this.uint16[j+7]=E,this.int16[j+8]=S,this.int16[j+9]=k,this.int16[j+10]=R,this.int16[j+11]=L,e}}Ol.prototype.bytesPerElement=24,yt("StructArrayLayout4i4ui4i24",Ol);class BA extends ei{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,s){const c=this.length;return this.resize(c+1),this.emplace(c,e,r,s)}emplace(e,r,s,c){const p=3*e;return this.float32[p+0]=r,this.float32[p+1]=s,this.float32[p+2]=c,e}}BA.prototype.bytesPerElement=12,yt("StructArrayLayout3f12",BA);class Vl extends ei{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.uint32[1*e+0]=r,e}}Vl.prototype.bytesPerElement=4,yt("StructArrayLayout1ul4",Vl);class mu extends ei{_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(e,r,s,c,p,m,v,T,E){const S=this.length;return this.resize(S+1),this.emplace(S,e,r,s,c,p,m,v,T,E)}emplace(e,r,s,c,p,m,v,T,E,S){const k=10*e,R=5*e;return this.int16[k+0]=r,this.int16[k+1]=s,this.int16[k+2]=c,this.int16[k+3]=p,this.int16[k+4]=m,this.int16[k+5]=v,this.uint32[R+3]=T,this.uint16[k+8]=E,this.uint16[k+9]=S,e}}mu.prototype.bytesPerElement=20,yt("StructArrayLayout6i1ul2ui20",mu);class rl extends ei{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,s,c,p,m){const v=this.length;return this.resize(v+1),this.emplace(v,e,r,s,c,p,m)}emplace(e,r,s,c,p,m,v){const T=6*e;return this.int16[T+0]=r,this.int16[T+1]=s,this.int16[T+2]=c,this.int16[T+3]=p,this.int16[T+4]=m,this.int16[T+5]=v,e}}rl.prototype.bytesPerElement=12,yt("StructArrayLayout2i2i2i12",rl);class Ea extends ei{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,s,c,p){const m=this.length;return this.resize(m+1),this.emplace(m,e,r,s,c,p)}emplace(e,r,s,c,p,m){const v=4*e,T=8*e;return this.float32[v+0]=r,this.float32[v+1]=s,this.float32[v+2]=c,this.int16[T+6]=p,this.int16[T+7]=m,e}}Ea.prototype.bytesPerElement=16,yt("StructArrayLayout2f1f2i16",Ea);class gu extends ei{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,s,c,p,m){const v=this.length;return this.resize(v+1),this.emplace(v,e,r,s,c,p,m)}emplace(e,r,s,c,p,m,v){const T=16*e,E=4*e,S=8*e;return this.uint8[T+0]=r,this.uint8[T+1]=s,this.float32[E+1]=c,this.float32[E+2]=p,this.int16[S+6]=m,this.int16[S+7]=v,e}}gu.prototype.bytesPerElement=16,yt("StructArrayLayout2ub2f2i16",gu);class jl extends ei{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,s){const c=this.length;return this.resize(c+1),this.emplace(c,e,r,s)}emplace(e,r,s,c){const p=3*e;return this.uint16[p+0]=r,this.uint16[p+1]=s,this.uint16[p+2]=c,e}}jl.prototype.bytesPerElement=6,yt("StructArrayLayout3ui6",jl);class Ia extends ei{_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(e,r,s,c,p,m,v,T,E,S,k,R,L,j,N,q,Y){const ue=this.length;return this.resize(ue+1),this.emplace(ue,e,r,s,c,p,m,v,T,E,S,k,R,L,j,N,q,Y)}emplace(e,r,s,c,p,m,v,T,E,S,k,R,L,j,N,q,Y,ue){const J=24*e,re=12*e,he=48*e;return this.int16[J+0]=r,this.int16[J+1]=s,this.uint16[J+2]=c,this.uint16[J+3]=p,this.uint32[re+2]=m,this.uint32[re+3]=v,this.uint32[re+4]=T,this.uint16[J+10]=E,this.uint16[J+11]=S,this.uint16[J+12]=k,this.float32[re+7]=R,this.float32[re+8]=L,this.uint8[he+36]=j,this.uint8[he+37]=N,this.uint8[he+38]=q,this.uint32[re+10]=Y,this.int16[J+22]=ue,e}}Ia.prototype.bytesPerElement=48,yt("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",Ia);class _u extends ei{_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(e,r,s,c,p,m,v,T,E,S,k,R,L,j,N,q,Y,ue,J,re,he,me,ze,He,Qe,et,pt,st){const $e=this.length;return this.resize($e+1),this.emplace($e,e,r,s,c,p,m,v,T,E,S,k,R,L,j,N,q,Y,ue,J,re,he,me,ze,He,Qe,et,pt,st)}emplace(e,r,s,c,p,m,v,T,E,S,k,R,L,j,N,q,Y,ue,J,re,he,me,ze,He,Qe,et,pt,st,$e){const Ne=32*e,xt=16*e;return this.int16[Ne+0]=r,this.int16[Ne+1]=s,this.int16[Ne+2]=c,this.int16[Ne+3]=p,this.int16[Ne+4]=m,this.int16[Ne+5]=v,this.int16[Ne+6]=T,this.int16[Ne+7]=E,this.uint16[Ne+8]=S,this.uint16[Ne+9]=k,this.uint16[Ne+10]=R,this.uint16[Ne+11]=L,this.uint16[Ne+12]=j,this.uint16[Ne+13]=N,this.uint16[Ne+14]=q,this.uint16[Ne+15]=Y,this.uint16[Ne+16]=ue,this.uint16[Ne+17]=J,this.uint16[Ne+18]=re,this.uint16[Ne+19]=he,this.uint16[Ne+20]=me,this.uint16[Ne+21]=ze,this.uint16[Ne+22]=He,this.uint32[xt+12]=Qe,this.float32[xt+13]=et,this.float32[xt+14]=pt,this.uint16[Ne+30]=st,this.uint16[Ne+31]=$e,e}}_u.prototype.bytesPerElement=64,yt("StructArrayLayout8i15ui1ul2f2ui64",_u);class RA extends ei{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.float32[1*e+0]=r,e}}RA.prototype.bytesPerElement=4,yt("StructArrayLayout1f4",RA);class LA extends ei{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,s){const c=this.length;return this.resize(c+1),this.emplace(c,e,r,s)}emplace(e,r,s,c){const p=3*e;return this.uint16[6*e+0]=r,this.float32[p+1]=s,this.float32[p+2]=c,e}}LA.prototype.bytesPerElement=12,yt("StructArrayLayout1ui2f12",LA);class yu extends ei{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,s){const c=this.length;return this.resize(c+1),this.emplace(c,e,r,s)}emplace(e,r,s,c){const p=4*e;return this.uint32[2*e+0]=r,this.uint16[p+2]=s,this.uint16[p+3]=c,e}}yu.prototype.bytesPerElement=8,yt("StructArrayLayout1ul2ui8",yu);class _ extends ei{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r){const s=this.length;return this.resize(s+1),this.emplace(s,e,r)}emplace(e,r,s){const c=2*e;return this.uint16[c+0]=r,this.uint16[c+1]=s,e}}_.prototype.bytesPerElement=4,yt("StructArrayLayout2ui4",_);class t extends ei{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.uint16[1*e+0]=r,e}}t.prototype.bytesPerElement=2,yt("StructArrayLayout1ui2",t);class n extends ei{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,s,c){const p=this.length;return this.resize(p+1),this.emplace(p,e,r,s,c)}emplace(e,r,s,c,p){const m=4*e;return this.float32[m+0]=r,this.float32[m+1]=s,this.float32[m+2]=c,this.float32[m+3]=p,e}}n.prototype.bytesPerElement=16,yt("StructArrayLayout4f16",n);class A extends Rl{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 nt(this.anchorPointX,this.anchorPointY)}}A.prototype.size=20;class h extends mu{get(e){return new A(this,e)}}yt("CollisionBoxArray",h);class y extends Rl{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(e){this._structArray.uint8[this._pos1+37]=e}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(e){this._structArray.uint8[this._pos1+38]=e}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(e){this._structArray.uint32[this._pos4+10]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}y.prototype.size=48;class b extends Ia{get(e){return new y(this,e)}}yt("PlacedSymbolArray",b);class M extends Rl{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(e){this._structArray.uint32[this._pos4+12]=e}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]}}M.prototype.size=64;class I extends _u{get(e){return new M(this,e)}}yt("SymbolInstanceArray",I);class D extends RA{getoffsetX(e){return this.float32[1*e+0]}}yt("GlyphOffsetArray",D);class B extends DA{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}yt("SymbolLineVertexArray",B);class V extends Rl{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]}}V.prototype.size=12;class O extends LA{get(e){return new V(this,e)}}yt("TextAnchorOffsetArray",O);class U extends Rl{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]}}U.prototype.size=8;class X extends yu{get(e){return new U(this,e)}}yt("FeatureIndexArray",X);class ie extends Ll{}class se extends Ll{}class ne extends Ll{}class ce extends kA{}class ge extends du{}class Ae extends Fl{}class de extends co{}class ye extends zA{}class fe extends Ol{}class Me extends BA{}class Ge extends Vl{}class Fe extends rl{}class Oe extends gu{}class Ve extends jl{}class ut extends _{}const ht=Ai([{name:"a_pos",components:2,type:"Int16"}],4),{members:rt}=ht;class ft{constructor(e=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=e}prepareSegment(e,r,s,c){const p=this.segments[this.segments.length-1];return e>ft.MAX_VERTEX_ARRAY_LENGTH&&di(`Max vertices per segment is ${ft.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${ft.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!p||p.vertexLength+e>ft.MAX_VERTEX_ARRAY_LENGTH||p.sortKey!==c?this.createNewSegment(r,s,c):p}createNewSegment(e,r,s){const c={vertexOffset:e.length,primitiveOffset:r.length,vertexLength:0,primitiveLength:0,vaos:{}};return s!==void 0&&(c.sortKey=s),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(c),c}getOrCreateLatestSegment(e,r,s){return this.prepareSegment(0,e,r,s)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}get(){return this.segments}destroy(){for(const e of this.segments)for(const r in e.vaos)e.vaos[r].destroy()}static simpleSegment(e,r,s,c){return new ft([{vertexOffset:e,primitiveOffset:r,vertexLength:s,primitiveLength:c,vaos:{},sortKey:0}])}}function Wt(i,e){return 256*(i=bn(Math.floor(i),0,255))+bn(Math.floor(e),0,255)}ft.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,yt("SegmentVector",ft);const Tr=Ai([{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"}]),Ur=Ai([{name:"a_dasharray_from",components:4,type:"Uint16"},{name:"a_dasharray_to",components:4,type:"Uint16"}]);var Dr,Wr,kr,ri={exports:{}},Hr={exports:{}},Li={exports:{}},pi=(function(){if(kr)return ri.exports;kr=1;var i=(Dr||(Dr=1,Hr.exports=function(r,s){var c,p,m,v,T,E,S,k;for(p=r.length-(c=3&r.length),m=s,T=3432918353,E=461845907,k=0;k<p;)S=255&r.charCodeAt(k)|(255&r.charCodeAt(++k))<<8|(255&r.charCodeAt(++k))<<16|(255&r.charCodeAt(++k))<<24,++k,m=27492+(65535&(v=5*(65535&(m=(m^=S=(65535&(S=(S=(65535&S)*T+(((S>>>16)*T&65535)<<16)&4294967295)<<15|S>>>17))*E+(((S>>>16)*E&65535)<<16)&4294967295)<<13|m>>>19))+((5*(m>>>16)&65535)<<16)&4294967295))+((58964+(v>>>16)&65535)<<16);switch(S=0,c){case 3:S^=(255&r.charCodeAt(k+2))<<16;case 2:S^=(255&r.charCodeAt(k+1))<<8;case 1:m^=S=(65535&(S=(S=(65535&(S^=255&r.charCodeAt(k)))*T+(((S>>>16)*T&65535)<<16)&4294967295)<<15|S>>>17))*E+(((S>>>16)*E&65535)<<16)&4294967295}return m^=r.length,m=2246822507*(65535&(m^=m>>>16))+((2246822507*(m>>>16)&65535)<<16)&4294967295,m=3266489909*(65535&(m^=m>>>13))+((3266489909*(m>>>16)&65535)<<16)&4294967295,(m^=m>>>16)>>>0}),Hr.exports),e=(Wr||(Wr=1,Li.exports=function(r,s){for(var c,p=r.length,m=s^p,v=0;p>=4;)c=1540483477*(65535&(c=255&r.charCodeAt(v)|(255&r.charCodeAt(++v))<<8|(255&r.charCodeAt(++v))<<16|(255&r.charCodeAt(++v))<<24))+((1540483477*(c>>>16)&65535)<<16),m=1540483477*(65535&m)+((1540483477*(m>>>16)&65535)<<16)^(c=1540483477*(65535&(c^=c>>>24))+((1540483477*(c>>>16)&65535)<<16)),p-=4,++v;switch(p){case 3:m^=(255&r.charCodeAt(v+2))<<16;case 2:m^=(255&r.charCodeAt(v+1))<<8;case 1:m=1540483477*(65535&(m^=255&r.charCodeAt(v)))+((1540483477*(m>>>16)&65535)<<16)}return m=1540483477*(65535&(m^=m>>>13))+((1540483477*(m>>>16)&65535)<<16),(m^=m>>>15)>>>0}),Li.exports);return ri.exports=i,ri.exports.murmur3=i,ri.exports.murmur2=e,ri.exports})(),ui=Vr(pi);class Hi{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,r,s,c){this.ids.push(Xo(e)),this.positions.push(r,s,c)}getPositions(e){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const r=Xo(e);let s=0,c=this.ids.length-1;for(;s<c;){const m=s+c>>1;this.ids[m]>=r?c=m:s=m+1}const p=[];for(;this.ids[s]===r;)p.push({index:this.positions[3*s],start:this.positions[3*s+1],end:this.positions[3*s+2]}),s++;return p}static serialize(e,r){const s=new Float64Array(e.ids),c=new Uint32Array(e.positions);return ho(s,c,0,s.length-1),r&&r.push(s.buffer,c.buffer),{ids:s,positions:c}}static deserialize(e){const r=new Hi;return r.ids=e.ids,r.positions=e.positions,r.indexed=!0,r}}function Xo(i){const e=+i;return!isNaN(e)&&e<=Number.MAX_SAFE_INTEGER?e:ui(String(i))}function ho(i,e,r,s){for(;r<s;){const c=i[r+s>>1];let p=r-1,m=s+1;for(;;){do p++;while(i[p]<c);do m--;while(i[m]>c);if(p>=m)break;Os(i,p,m),Os(e,3*p,3*m),Os(e,3*p+1,3*m+1),Os(e,3*p+2,3*m+2)}m-r<s-m?(ho(i,e,r,m),r=m+1):(ho(i,e,m+1,s),s=m)}}function Os(i,e,r){const s=i[e];i[e]=i[r],i[r]=s}yt("FeaturePositionMap",Hi);class Sn{constructor(e,r){this.gl=e.gl,this.location=r}}class Sa extends Sn{constructor(e,r){super(e,r),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1f(this.location,e))}}class Nl extends Sn{constructor(e,r){super(e,r),this.current=[0,0,0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]&&e[2]===this.current[2]&&e[3]===this.current[3]||(this.current=e,this.gl.uniform4f(this.location,e[0],e[1],e[2],e[3]))}}class Ca extends Sn{constructor(e,r){super(e,r),this.current=Kt.transparent}set(e){e.r===this.current.r&&e.g===this.current.g&&e.b===this.current.b&&e.a===this.current.a||(this.current=e,this.gl.uniform4f(this.location,e.r,e.g,e.b,e.a))}}const ts=new Float32Array(16);function Vs(i){return[Wt(255*i.r,255*i.g),Wt(255*i.b,255*i.a)]}class ms{constructor(e,r,s){this.value=e,this.uniformNames=r.map((c=>`u_${c}`)),this.type=s}setUniform(e,r,s){e.set(s.constantOr(this.value))}getBinding(e,r,s){return this.type==="color"?new Ca(e,r):new Sa(e,r)}}class gs{constructor(e,r){this.uniformNames=r.map((s=>`u_${s}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,r){this.pixelRatioFrom=r.pixelRatio,this.pixelRatioTo=e.pixelRatio,this.patternFrom=r.tlbr,this.patternTo=e.tlbr}setConstantDashPositions(e,r){this.dashTo=[0,e.y,e.height,e.width],this.dashFrom=[0,r.y,r.height,r.width]}setUniform(e,r,s,c){let p=null;c==="u_pattern_to"?p=this.patternTo:c==="u_pattern_from"?p=this.patternFrom:c==="u_dasharray_to"?p=this.dashTo:c==="u_dasharray_from"?p=this.dashFrom:c==="u_pixel_ratio_to"?p=this.pixelRatioTo:c==="u_pixel_ratio_from"&&(p=this.pixelRatioFrom),p!==null&&e.set(p)}getBinding(e,r,s){return s.substr(0,9)==="u_pattern"||s.substr(0,12)==="u_dasharray_"?new Nl(e,r):new Sa(e,r)}}class Fr{constructor(e,r,s,c){this.expression=e,this.type=s,this.maxValue=0,this.paintVertexAttributes=r.map((p=>({name:`a_${p}`,type:"Float32",components:s==="color"?2:1,offset:0}))),this.paintVertexArray=new c}populatePaintArray(e,r,s){const c=this.paintVertexArray.length,p=this.expression.evaluate(new Pe(0,s),r,{},s.canonical,[],s.formattedSection);this.paintVertexArray.resize(e),this._setPaintValue(c,e,p)}updatePaintArray(e,r,s,c,p){const m=this.expression.evaluate(new Pe(0,p),s,c);this._setPaintValue(e,r,m)}_setPaintValue(e,r,s){if(this.type==="color"){const c=Vs(s);for(let p=e;p<r;p++)this.paintVertexArray.emplace(p,c[0],c[1])}else{for(let c=e;c<r;c++)this.paintVertexArray.emplace(c,s);this.maxValue=Math.max(this.maxValue,Math.abs(s))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class zr{constructor(e,r,s,c,p,m){this.expression=e,this.uniformNames=r.map((v=>`u_${v}_t`)),this.type=s,this.useIntegerZoom=c,this.zoom=p,this.maxValue=0,this.paintVertexAttributes=r.map((v=>({name:`a_${v}`,type:"Float32",components:s==="color"?4:2,offset:0}))),this.paintVertexArray=new m}populatePaintArray(e,r,s){const c=this.expression.evaluate(new Pe(this.zoom,s),r,{},s.canonical,[],s.formattedSection),p=this.expression.evaluate(new Pe(this.zoom+1,s),r,{},s.canonical,[],s.formattedSection),m=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(m,e,c,p)}updatePaintArray(e,r,s,c,p){const m=this.expression.evaluate(new Pe(this.zoom,p),s,c),v=this.expression.evaluate(new Pe(this.zoom+1,p),s,c);this._setPaintValue(e,r,m,v)}_setPaintValue(e,r,s,c){if(this.type==="color"){const p=Vs(s),m=Vs(c);for(let v=e;v<r;v++)this.paintVertexArray.emplace(v,p[0],p[1],m[0],m[1])}else{for(let p=e;p<r;p++)this.paintVertexArray.emplace(p,s,c);this.maxValue=Math.max(this.maxValue,Math.abs(s),Math.abs(c))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(e,r){const s=this.useIntegerZoom?Math.floor(r.zoom):r.zoom,c=bn(this.expression.interpolationFactor(s,this.zoom,this.zoom+1),0,1);e.set(c)}getBinding(e,r,s){return new Sa(e,r)}}class Mi{constructor(e,r,s,c,p,m){this.expression=e,this.type=r,this.useIntegerZoom=s,this.zoom=c,this.layerId=m,this.zoomInPaintVertexArray=new p,this.zoomOutPaintVertexArray=new p}populatePaintArray(e,r,s){const c=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(e),this.zoomOutPaintVertexArray.resize(e),this._setPaintValues(c,e,this.getPositionIds(r),s)}updatePaintArray(e,r,s,c,p){this._setPaintValues(e,r,this.getPositionIds(s),p)}_setPaintValues(e,r,s,c){const p=this.getPositions(c);if(!p||!s)return;const m=p[s.min],v=p[s.mid],T=p[s.max];if(m&&v&&T)for(let E=e;E<r;E++)this.emplace(this.zoomInPaintVertexArray,E,v,m),this.emplace(this.zoomOutPaintVertexArray,E,v,T)}upload(e){if(this.zoomInPaintVertexArray&&this.zoomInPaintVertexArray.arrayBuffer&&this.zoomOutPaintVertexArray&&this.zoomOutPaintVertexArray.arrayBuffer){const r=this.getVertexAttributes();this.zoomInPaintVertexBuffer=e.createVertexBuffer(this.zoomInPaintVertexArray,r,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=e.createVertexBuffer(this.zoomOutPaintVertexArray,r,this.expression.isStateDependent)}}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class Ei extends Mi{getPositions(e){return e.imagePositions}getPositionIds(e){return e.patterns&&e.patterns[this.layerId]}getVertexAttributes(){return Tr.members}emplace(e,r,s,c){e.emplace(r,s.tlbr[0],s.tlbr[1],s.tlbr[2],s.tlbr[3],c.tlbr[0],c.tlbr[1],c.tlbr[2],c.tlbr[3],s.pixelRatio,c.pixelRatio)}}class $u extends Mi{getPositions(e){return e.dashPositions}getPositionIds(e){return e.dashes&&e.dashes[this.layerId]}getVertexAttributes(){return Ur.members}emplace(e,r,s,c){e.emplace(r,0,s.y,s.height,s.width,0,c.y,c.height,c.width)}}class Wu{constructor(e,r,s){this.binders={},this._buffers=[];const c=[];for(const p in e.paint._values){if(!s(p))continue;const m=e.paint.get(p);if(!(m instanceof Et&&Uo(m.property.specification)))continue;const v=Cc(p,e.type),T=m.value,E=m.property.specification.type,S=m.property.useIntegerZoom,k=m.property.specification["property-type"],R=k==="cross-faded"||k==="cross-faded-data-driven";if(T.kind==="constant")this.binders[p]=R?new gs(T.value,v):new ms(T.value,v,E),c.push(`/u_${p}`);else if(T.kind==="source"||R){const L=Hu(p,E,"source");this.binders[p]=R?p==="line-dasharray"?new $u(T,E,S,r,L,e.id):new Ei(T,E,S,r,L,e.id):new Fr(T,v,E,L),c.push(`/a_${p}`)}else{const L=Hu(p,E,"composite");this.binders[p]=new zr(T,v,E,S,r,L),c.push(`/z_${p}`)}}this.cacheKey=c.sort().join("")}getMaxValue(e){const r=this.binders[e];return r instanceof Fr||r instanceof zr?r.maxValue:0}populatePaintArrays(e,r,s){for(const c in this.binders){const p=this.binders[c];(p instanceof Fr||p instanceof zr||p instanceof Mi)&&p.populatePaintArray(e,r,s)}}setConstantPatternPositions(e,r){for(const s in this.binders){const c=this.binders[s];c instanceof gs&&c.setConstantPatternPositions(e,r)}}setConstantDashPositions(e,r){for(const s in this.binders){const c=this.binders[s];c instanceof gs&&c.setConstantDashPositions(e,r)}}updatePaintArrays(e,r,s,c,p){let m=!1;for(const v in e){const T=r.getPositions(v);for(const E of T){const S=s.feature(E.index);for(const k in this.binders){const R=this.binders[k];if((R instanceof Fr||R instanceof zr||R instanceof Mi)&&R.expression.isStateDependent===!0){const L=c.paint.get(k);R.expression=L.value,R.updatePaintArray(E.start,E.end,S,e[v],p),m=!0}}}}return m}defines(){const e=[];for(const r in this.binders){const s=this.binders[r];(s instanceof ms||s instanceof gs)&&e.push(...s.uniformNames.map((c=>`#define HAS_UNIFORM_${c}`)))}return e}getBinderAttributes(){const e=[];for(const r in this.binders){const s=this.binders[r];if(s instanceof Fr||s instanceof zr)for(let c=0;c<s.paintVertexAttributes.length;c++)e.push(s.paintVertexAttributes[c].name);else if(s instanceof Mi){const c=s.getVertexAttributes();for(const p of c)e.push(p.name)}}return e}getBinderUniforms(){const e=[];for(const r in this.binders){const s=this.binders[r];if(s instanceof ms||s instanceof gs||s instanceof zr)for(const c of s.uniformNames)e.push(c)}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e,r){const s=[];for(const c in this.binders){const p=this.binders[c];if(p instanceof ms||p instanceof gs||p instanceof zr){for(const m of p.uniformNames)if(r[m]){const v=p.getBinding(e,r[m],m);s.push({name:m,property:c,binding:v})}}}return s}setUniforms(e,r,s,c){for(const{name:p,property:m,binding:v}of r)this.binders[m].setUniform(v,c,s.get(m),p)}updatePaintBuffers(e){this._buffers=[];for(const r in this.binders){const s=this.binders[r];if(e&&s instanceof Mi){const c=e.fromScale===2?s.zoomInPaintVertexBuffer:s.zoomOutPaintVertexBuffer;c&&this._buffers.push(c)}else(s instanceof Fr||s instanceof zr)&&s.paintVertexBuffer&&this._buffers.push(s.paintVertexBuffer)}}upload(e){for(const r in this.binders){const s=this.binders[r];(s instanceof Fr||s instanceof zr||s instanceof Mi)&&s.upload(e)}this.updatePaintBuffers()}destroy(){for(const e in this.binders){const r=this.binders[e];(r instanceof Fr||r instanceof zr||r instanceof Mi)&&r.destroy()}}}class Da{constructor(e,r,s=()=>!0){this.programConfigurations={};for(const c of e)this.programConfigurations[c.id]=new Wu(c,r,s);this.needsUpload=!1,this._featureMap=new Hi,this._bufferOffset=0}populatePaintArrays(e,r,s,c){for(const p in this.programConfigurations)this.programConfigurations[p].populatePaintArrays(e,r,c);r.id!==void 0&&this._featureMap.add(r.id,s,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,r,s,c){for(const p of s)this.needsUpload=this.programConfigurations[p.id].updatePaintArrays(e,this._featureMap,r,p,c)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const r in this.programConfigurations)this.programConfigurations[r].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}}function Cc(i,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"]}[i]||[i.replace(`${e}-`,"").replace(/-/g,"_")]}function Hu(i,e,r){const s={color:{source:Fl,composite:n},number:{source:RA,composite:Fl}},c=(function(p){return{"line-pattern":{source:de,composite:de},"fill-pattern":{source:de,composite:de},"fill-extrusion-pattern":{source:de,composite:de},"line-dasharray":{source:ye,composite:ye}}[p]})(i);return c&&c[r]||s[e][r]}yt("ConstantBinder",ms),yt("CrossFadedConstantBinder",gs),yt("SourceExpressionBinder",Fr),yt("CrossFadedPatternBinder",Ei),yt("CrossFadedDasharrayBinder",$u),yt("CompositeExpressionBinder",zr),yt("ProgramConfiguration",Wu,{omit:["_buffers"]}),yt("ProgramConfigurationSet",Da);const vu=Math.pow(2,14)-1,Yo=-vu-1;function Ko(i){const e=dr/i.extent,r=i.loadGeometry();for(let s=0;s<r.length;s++){const c=r[s];for(let p=0;p<c.length;p++){const m=c[p],v=Math.round(m.x*e),T=Math.round(m.y*e);m.x=bn(v,Yo,vu),m.y=bn(T,Yo,vu),(v<m.x||v>m.x+1||T<m.y||T>m.y+1)&&di("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return r}function Jo(i,e){return{type:i.type,id:i.id,properties:i.properties,geometry:e?Ko(i):[]}}const xu=-32768;function bu(i,e,r,s,c){i.emplaceBack(xu+8*e+s,xu+8*r+c)}class FA{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((r=>r.id)),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new se,this.indexArray=new Ve,this.segments=new ft,this.programConfigurations=new Da(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter((r=>r.isStateDependent())).map((r=>r.id))}populate(e,r,s){const c=this.layers[0],p=[];let m=null,v=!1,T=c.type==="heatmap";if(c.type==="circle"){const S=c;m=S.layout.get("circle-sort-key"),v=!m.isConstant(),T=T||S.paint.get("circle-pitch-alignment")==="map"}const E=T?r.subdivisionGranularity.circle:1;for(const{feature:S,id:k,index:R,sourceLayerIndex:L}of e){const j=this.layers[0]._featureFilter.needGeometry,N=Jo(S,j);if(!this.layers[0]._featureFilter.filter(new Pe(this.zoom),N,s))continue;const q=v?m.evaluate(N,{},s):void 0,Y={id:k,properties:S.properties,type:S.type,sourceLayerIndex:L,index:R,geometry:j?N.geometry:Ko(S),patterns:{},sortKey:q};p.push(Y)}v&&p.sort(((S,k)=>S.sortKey-k.sortKey));for(const S of p){const{geometry:k,index:R,sourceLayerIndex:L}=S,j=e[R].feature;this.addFeature(S,k,R,s,E),r.featureIndex.insert(j,k,R,L,this.index)}}update(e,r,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,{imagePositions:s})}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,rt),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,r,s,c,p=1){let m;switch(p){case 1:m=[0,7];break;case 3:m=[0,2,5,7];break;case 5:m=[0,1,3,4,6,7];break;case 7:m=[0,1,2,3,4,5,6,7];break;default:throw new Error(`Invalid circle bucket granularity: ${p}; valid values are 1, 3, 5, 7.`)}const v=m.length;for(const T of r)for(const E of T){const S=E.x,k=E.y;if(S<0||S>=dr||k<0||k>=dr)continue;const R=this.segments.prepareSegment(v*v,this.layoutVertexArray,this.indexArray,e.sortKey),L=R.vertexLength;for(let j=0;j<v;j++)for(let N=0;N<v;N++)bu(this.layoutVertexArray,S,k,m[N],m[j]);for(let j=0;j<v-1;j++)for(let N=0;N<v-1;N++){const q=L+j*v+N,Y=L+(j+1)*v+N;this.indexArray.emplaceBack(q,Y+1,q+1),this.indexArray.emplaceBack(q,Y,Y+1)}R.vertexLength+=v*v,R.primitiveLength+=(v-1)*(v-1)*2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,s,{imagePositions:{},canonical:c})}}function OA(i,e){for(let r=0;r<i.length;r++)if(VA(e,i[r]))return!0;for(let r=0;r<e.length;r++)if(VA(i,e[r]))return!0;return!!Dc(i,e)}function Xu(i,e,r){return!!VA(i,e)||!!kc(e,i,r)}function kh(i,e){if(i.length===1)return Bh(e,i[0]);for(let r=0;r<e.length;r++){const s=e[r];for(let c=0;c<s.length;c++)if(VA(i,s[c]))return!0}for(let r=0;r<i.length;r++)if(Bh(e,i[r]))return!0;for(let r=0;r<e.length;r++)if(Dc(i,e[r]))return!0;return!1}function ff(i,e,r){if(i.length>1){if(Dc(i,e))return!0;for(let s=0;s<e.length;s++)if(kc(e[s],i,r))return!0}for(let s=0;s<i.length;s++)if(kc(i[s],e,r))return!0;return!1}function Dc(i,e){if(i.length===0||e.length===0)return!1;for(let r=0;r<i.length-1;r++){const s=i[r],c=i[r+1];for(let p=0;p<e.length-1;p++)if(df(s,c,e[p],e[p+1]))return!0}return!1}function df(i,e,r,s){return wn(i,r,s)!==wn(e,r,s)&&wn(i,e,r)!==wn(i,e,s)}function kc(i,e,r){const s=r*r;if(e.length===1)return i.distSqr(e[0])<s;for(let c=1;c<e.length;c++)if(zh(i,e[c-1],e[c])<s)return!0;return!1}function zh(i,e,r){const s=e.distSqr(r);if(s===0)return i.distSqr(e);const c=((i.x-e.x)*(r.x-e.x)+(i.y-e.y)*(r.y-e.y))/s;return i.distSqr(c<0?e:c>1?r:r.sub(e)._mult(c)._add(e))}function Bh(i,e){let r,s,c,p=!1;for(let m=0;m<i.length;m++){r=i[m];for(let v=0,T=r.length-1;v<r.length;T=v++)s=r[v],c=r[T],s.y>e.y!=c.y>e.y&&e.x<(c.x-s.x)*(e.y-s.y)/(c.y-s.y)+s.x&&(p=!p)}return p}function VA(i,e){let r=!1;for(let s=0,c=i.length-1;s<i.length;c=s++){const p=i[s],m=i[c];p.y>e.y!=m.y>e.y&&e.x<(m.x-p.x)*(e.y-p.y)/(m.y-p.y)+p.x&&(r=!r)}return r}function mf(i,e,r){const s=r[0],c=r[2];if(i.x<s.x&&e.x<s.x||i.x>c.x&&e.x>c.x||i.y<s.y&&e.y<s.y||i.y>c.y&&e.y>c.y)return!1;const p=wn(i,e,r[0]);return p!==wn(i,e,r[1])||p!==wn(i,e,r[2])||p!==wn(i,e,r[3])}function jA(i,e,r){const s=e.paint.get(i).value;return s.kind==="constant"?s.value:r.programConfigurations.get(e.id).getMaxValue(i)}function Yu(i){return Math.sqrt(i[0]*i[0]+i[1]*i[1])}function Ku(i,e,r,s,c){if(!e[0]&&!e[1])return i;const p=nt.convert(e)._mult(c);r==="viewport"&&p._rotate(-s);const m=[];for(let v=0;v<i.length;v++)m.push(i[v].sub(p));return m}function gf(i){const e=[];for(let r=0;r<i.length;r++){const s=i[r],c=e.at(-1);(r===0||c&&!s.equals(c))&&e.push(s)}return e}function _f({queryGeometry:i,size:e},r){return Xu(i,r,e)}function yf({queryGeometry:i,size:e,transform:r,unwrappedTileID:s,getElevation:c},p){return Xu(i,p,e*(r.projectTileCoordinates(p.x,p.y,s,c).signedDistanceFromCamera/r.cameraToCenterDistance))}function vf({queryGeometry:i,size:e,transform:r,unwrappedTileID:s,getElevation:c},p){const m=r.projectTileCoordinates(p.x,p.y,s,c).signedDistanceFromCamera,v=e*(r.cameraToCenterDistance/m);return Xu(i,zc(p,r,s,c),v)}function xf({queryGeometry:i,size:e,transform:r,unwrappedTileID:s,getElevation:c},p){return Xu(i,zc(p,r,s,c),e)}function Rh({queryGeometry:i,size:e,transform:r,unwrappedTileID:s,getElevation:c,pitchAlignment:p="map",pitchScale:m="map"},v){const T=p==="map"?m==="map"?_f:yf:m==="map"?vf:xf,E={queryGeometry:i,size:e,transform:r,unwrappedTileID:s,getElevation:c};for(const S of v)for(const k of S)if(T(E,k))return!0;return!1}function zc(i,e,r,s){const c=e.projectTileCoordinates(i.x,i.y,r,s).point;return new nt((.5*c.x+.5)*e.width,(.5*-c.y+.5)*e.height)}let Lh,Fh;yt("CircleBucket",FA,{omit:["layers"]});var bf={get paint(){return Fh=Fh||new Ri({"circle-radius":new dt(Le.paint_circle["circle-radius"]),"circle-color":new dt(Le.paint_circle["circle-color"]),"circle-blur":new dt(Le.paint_circle["circle-blur"]),"circle-opacity":new dt(Le.paint_circle["circle-opacity"]),"circle-translate":new at(Le.paint_circle["circle-translate"]),"circle-translate-anchor":new at(Le.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new at(Le.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new at(Le.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new dt(Le.paint_circle["circle-stroke-width"]),"circle-stroke-color":new dt(Le.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new dt(Le.paint_circle["circle-stroke-opacity"])})},get layout(){return Lh=Lh||new Ri({"circle-sort-key":new dt(Le.layout_circle["circle-sort-key"])})}};class wf extends es{constructor(e,r){super(e,bf,r)}createBucket(e){return new FA(e)}queryRadius(e){const r=e;return jA("circle-radius",this,r)+jA("circle-stroke-width",this,r)+Yu(this.paint.get("circle-translate"))}queryIntersectsFeature({queryGeometry:e,feature:r,featureState:s,geometry:c,transform:p,pixelsToTileUnits:m,unwrappedTileID:v,getElevation:T}){const E=Ku(e,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),-p.bearingInRadians,m),S=this.paint.get("circle-radius").evaluate(r,s)+this.paint.get("circle-stroke-width").evaluate(r,s),k=this.paint.get("circle-pitch-scale"),R=this.paint.get("circle-pitch-alignment");let L,j;return R==="map"?(L=E,j=S*m):(L=(function(N,q,Y,ue){return N.map((J=>zc(J,q,Y,ue)))})(E,p,v,T),j=S),Rh({queryGeometry:L,size:j,transform:p,unwrappedTileID:v,getElevation:T,pitchAlignment:R,pitchScale:k},c)}}class Oh extends FA{}let Vh;yt("HeatmapBucket",Oh,{omit:["layers"]});var Tf={get paint(){return Vh=Vh||new Ri({"heatmap-radius":new dt(Le.paint_heatmap["heatmap-radius"]),"heatmap-weight":new dt(Le.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new at(Le.paint_heatmap["heatmap-intensity"]),"heatmap-color":new xi(Le.paint_heatmap["heatmap-color"]),"heatmap-opacity":new at(Le.paint_heatmap["heatmap-opacity"])})}};function Bc(i,{width:e,height:r},s,c){if(c){if(c instanceof Uint8ClampedArray)c=new Uint8Array(c.buffer);else if(c.length!==e*r*s)throw new RangeError(`mismatched image size. expected: ${c.length} but got: ${e*r*s}`)}else c=new Uint8Array(e*r*s);return i.width=e,i.height=r,i.data=c,i}function jh(i,{width:e,height:r},s){if(e===i.width&&r===i.height)return;const c=Bc({},{width:e,height:r},s);Rc(i,c,{x:0,y:0},{x:0,y:0},{width:Math.min(i.width,e),height:Math.min(i.height,r)},s),i.width=e,i.height=r,i.data=c.data}function Rc(i,e,r,s,c,p){if(c.width===0||c.height===0)return e;if(c.width>i.width||c.height>i.height||r.x>i.width-c.width||r.y>i.height-c.height)throw new RangeError("out of range source coordinates for image copy");if(c.width>e.width||c.height>e.height||s.x>e.width-c.width||s.y>e.height-c.height)throw new RangeError("out of range destination coordinates for image copy");const m=i.data,v=e.data;if(m===v)throw new Error("srcData equals dstData, so image is already copied");for(let T=0;T<c.height;T++){const E=((r.y+T)*i.width+r.x)*p,S=((s.y+T)*e.width+s.x)*p;for(let k=0;k<c.width*p;k++)v[S+k]=m[E+k]}return e}class wu{constructor(e,r){Bc(this,e,1,r)}resize(e){jh(this,e,1)}clone(){return new wu({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,r,s,c,p){Rc(e,r,s,c,p,1)}}class Un{constructor(e,r){Bc(this,e,4,r)}resize(e){jh(this,e,4)}replace(e,r){r?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e}clone(){return new Un({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,r,s,c,p){Rc(e,r,s,c,p,4)}setPixel(e,r,s){const c=4*(e*this.width+r);this.data[c+0]=Math.round(255*s.r/s.a),this.data[c+1]=Math.round(255*s.g/s.a),this.data[c+2]=Math.round(255*s.b/s.a),this.data[c+3]=Math.round(255*s.a)}}function Nh(i){const e={},r=i.resolution||256,s=i.clips?i.clips.length:1,c=i.image||new Un({width:r,height:s});if(Math.log(r)/Math.LN2%1!=0)throw new Error(`width is not a power of 2 - ${r}`);const p=(m,v,T)=>{e[i.evaluationKey]=T;const E=i.expression.evaluate(e);c.setPixel(m/4/r,v/4,E)};if(i.clips)for(let m=0,v=0;m<s;++m,v+=4*r)for(let T=0,E=0;T<r;T++,E+=4){const S=T/(r-1),{start:k,end:R}=i.clips[m];p(v,E,k*(1-S)+R*S)}else for(let m=0,v=0;m<r;m++,v+=4)p(0,v,m/(r-1));return c}yt("AlphaImage",wu),yt("RGBAImage",Un);const Lc="big-fb";class Pf extends es{createBucket(e){return new Oh(e)}constructor(e,r){super(e,Tf,r),this.heatmapFbos=new Map,this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){e==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=Nh({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbos.has(Lc)&&this.heatmapFbos.delete(Lc)}queryRadius(e){return jA("heatmap-radius",this,e)}queryIntersectsFeature({queryGeometry:e,feature:r,featureState:s,geometry:c,transform:p,pixelsToTileUnits:m,unwrappedTileID:v,getElevation:T}){return Rh({queryGeometry:e,size:this.paint.get("heatmap-radius").evaluate(r,s)*m,transform:p,unwrappedTileID:v,getElevation:T},c)}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&!this.isHidden()}}let Gh;var Mf={get paint(){return Gh=Gh||new Ri({"hillshade-illumination-direction":new at(Le.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-altitude":new at(Le.paint_hillshade["hillshade-illumination-altitude"]),"hillshade-illumination-anchor":new at(Le.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new at(Le.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new at(Le.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new at(Le.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new at(Le.paint_hillshade["hillshade-accent-color"]),"hillshade-method":new at(Le.paint_hillshade["hillshade-method"])})}};class Ef extends es{constructor(e,r){super(e,Mf,r),this.recalculate({zoom:0,zoomHistory:{}},void 0)}getIlluminationProperties(){let e=this.paint.get("hillshade-illumination-direction").values,r=this.paint.get("hillshade-illumination-altitude").values,s=this.paint.get("hillshade-highlight-color").values,c=this.paint.get("hillshade-shadow-color").values;const p=Math.max(e.length,r.length,s.length,c.length);e=e.concat(Array(p-e.length).fill(e.at(-1))),r=r.concat(Array(p-r.length).fill(r.at(-1))),s=s.concat(Array(p-s.length).fill(s.at(-1))),c=c.concat(Array(p-c.length).fill(c.at(-1)));const m=r.map(Rn);return{directionRadians:e.map(Rn),altitudeRadians:m,shadowColor:c,highlightColor:s}}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&!this.isHidden()}}let Uh;var If={get paint(){return Uh=Uh||new Ri({"color-relief-opacity":new at(Le["paint_color-relief"]["color-relief-opacity"]),"color-relief-color":new xi(Le["paint_color-relief"]["color-relief-color"])})}};class Fc{constructor(e,r,s,c){this.context=e,this.format=s,this.texture=e.gl.createTexture(),this.update(r,c)}update(e,r,s){const{width:c,height:p}=e,m=!(this.size&&this.size[0]===c&&this.size[1]===p||s),{context:v}=this,{gl:T}=v;if(this.useMipmap=!!(r&&r.useMipmap),T.bindTexture(T.TEXTURE_2D,this.texture),v.pixelStoreUnpackFlipY.set(!1),v.pixelStoreUnpack.set(1),v.pixelStoreUnpackPremultiplyAlpha.set(this.format===T.RGBA&&(!r||r.premultiply!==!1)),m)this.size=[c,p],e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||Tn(e)?T.texImage2D(T.TEXTURE_2D,0,this.format,this.format,T.UNSIGNED_BYTE,e):T.texImage2D(T.TEXTURE_2D,0,this.format,c,p,0,this.format,T.UNSIGNED_BYTE,e.data);else{const{x:E,y:S}=s||{x:0,y:0};e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||Tn(e)?T.texSubImage2D(T.TEXTURE_2D,0,E,S,T.RGBA,T.UNSIGNED_BYTE,e):T.texSubImage2D(T.TEXTURE_2D,0,E,S,c,p,T.RGBA,T.UNSIGNED_BYTE,e.data)}this.useMipmap&&this.isSizePowerOfTwo()&&T.generateMipmap(T.TEXTURE_2D),v.pixelStoreUnpackFlipY.setDefault(),v.pixelStoreUnpack.setDefault(),v.pixelStoreUnpackPremultiplyAlpha.setDefault()}bind(e,r,s){const{context:c}=this,{gl:p}=c;p.bindTexture(p.TEXTURE_2D,this.texture),s!==p.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(s=p.LINEAR),e!==this.filter&&(p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,e),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,s||e),this.filter=e),r!==this.wrap&&(p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,r),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,r),this.wrap=r)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}class qh{constructor(e,r,s,c=1,p=1,m=1,v=0){if(this.uid=e,r.height!==r.width)throw new RangeError("DEM tiles must be square");if(s&&!["mapbox","terrarium","custom"].includes(s))return void di(`"${s}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);this.stride=r.height;const T=this.dim=r.height-2;switch(this.data=new Uint32Array(r.data.buffer),s){case"terrarium":this.redFactor=256,this.greenFactor=1,this.blueFactor=1/256,this.baseShift=32768;break;case"custom":this.redFactor=c,this.greenFactor=p,this.blueFactor=m,this.baseShift=v;break;default:this.redFactor=6553.6,this.greenFactor=25.6,this.blueFactor=.1,this.baseShift=1e4}for(let E=0;E<T;E++)this.data[this._idx(-1,E)]=this.data[this._idx(0,E)],this.data[this._idx(T,E)]=this.data[this._idx(T-1,E)],this.data[this._idx(E,-1)]=this.data[this._idx(E,0)],this.data[this._idx(E,T)]=this.data[this._idx(E,T-1)];this.data[this._idx(-1,-1)]=this.data[this._idx(0,0)],this.data[this._idx(T,-1)]=this.data[this._idx(T-1,0)],this.data[this._idx(-1,T)]=this.data[this._idx(0,T-1)],this.data[this._idx(T,T)]=this.data[this._idx(T-1,T-1)],this.min=Number.MAX_SAFE_INTEGER,this.max=Number.MIN_SAFE_INTEGER;for(let E=0;E<T;E++)for(let S=0;S<T;S++){const k=this.get(E,S);k>this.max&&(this.max=k),k<this.min&&(this.min=k)}}get(e,r){const s=new Uint8Array(this.data.buffer),c=4*this._idx(e,r);return this.unpack(s[c],s[c+1],s[c+2])}getUnpackVector(){return[this.redFactor,this.greenFactor,this.blueFactor,this.baseShift]}_idx(e,r){if(e<-1||e>=this.dim+1||r<-1||r>=this.dim+1)throw new RangeError(`Out of range source coordinates for DEM data. x: ${e}, y: ${r}, dim: ${this.dim}`);return(r+1)*this.stride+(e+1)}unpack(e,r,s){return e*this.redFactor+r*this.greenFactor+s*this.blueFactor-this.baseShift}pack(e){return Zh(e,this.getUnpackVector())}getPixels(){return new Un({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(e,r,s){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let c=r*this.dim,p=r*this.dim+this.dim,m=s*this.dim,v=s*this.dim+this.dim;switch(r){case-1:c=p-1;break;case 1:p=c+1}switch(s){case-1:m=v-1;break;case 1:v=m+1}const T=-r*this.dim,E=-s*this.dim;for(let S=m;S<v;S++)for(let k=c;k<p;k++)this.data[this._idx(k,S)]=e.data[this._idx(k+T,S+E)]}}function Zh(i,e){const r=e[0],s=e[1],c=e[2],p=e[3],m=Math.min(r,s,c),v=Math.round((i+p)/m);return{r:Math.floor(v*m/r)%256,g:Math.floor(v*m/s)%256,b:Math.floor(v*m/c)%256}}yt("DEMData",qh);class Sf extends es{constructor(e,r){super(e,If,r)}_createColorRamp(e){const r={elevationStops:[],colorStops:[]},s=this._transitionablePaint._values["color-relief-color"].value.expression;if(s instanceof $a&&s._styleExpression.expression instanceof ki){this.colorRampExpression=s;const m=s._styleExpression.expression;r.elevationStops=m.labels,r.colorStops=[];for(const v of r.elevationStops)r.colorStops.push(m.evaluate({globals:{elevation:v}}))}if(r.elevationStops.length<1&&(r.elevationStops=[0],r.colorStops=[Kt.transparent]),r.elevationStops.length<2&&(r.elevationStops.push(r.elevationStops[0]+1),r.colorStops.push(r.colorStops[0])),r.elevationStops.length<=e)return r;const c={elevationStops:[],colorStops:[]},p=(r.elevationStops.length-1)/(e-1);for(let m=0;m<r.elevationStops.length-.5;m+=p)c.elevationStops.push(r.elevationStops[Math.round(m)]),c.colorStops.push(r.colorStops[Math.round(m)]);return di(`Too many colors in specification of ${this.id} color-relief layer, may not render properly. Max possible colors: ${e}, provided: ${r.elevationStops.length}`),c}_colorRampChanged(){return this.colorRampExpression!=this._transitionablePaint._values["color-relief-color"].value.expression}getColorRampTextures(e,r,s){if(this.colorRampTextures&&!this._colorRampChanged())return this.colorRampTextures;const c=this._createColorRamp(r),p=new Un({width:c.colorStops.length,height:1}),m=new Un({width:c.colorStops.length,height:1});for(let v=0;v<c.elevationStops.length;v++){const T=Zh(c.elevationStops[v],s);m.setPixel(0,v,new Kt(T.r/255,T.g/255,T.b/255,1)),p.setPixel(0,v,c.colorStops[v])}return this.colorRampTextures={elevationTexture:new Fc(e,m,e.gl.RGBA),colorTexture:new Fc(e,p,e.gl.RGBA)},this.colorRampTextures}hasOffscreenPass(){return!this.isHidden()&&!!this.colorRampTextures}}const Cf=Ai([{name:"a_pos",components:2,type:"Int16"}],4),{members:Df}=Cf;function Ju(i,e,r){const s=r.patternDependencies;let c=!1;for(const p of e){const m=p.paint.get(`${i}-pattern`);m.isConstant()||(c=!0);const v=m.constantOr(null);v&&(c=!0,s[v.to]=!0,s[v.from]=!0)}return c}function Oc(i,e,r,s,c){const{zoom:p}=s,m=c.patternDependencies;for(const v of e){const T=v.paint.get(`${i}-pattern`).value;if(T.kind!=="constant"){let E=T.evaluate({zoom:p-1},r,{},c.availableImages),S=T.evaluate({zoom:p},r,{},c.availableImages),k=T.evaluate({zoom:p+1},r,{},c.availableImages);E=E&&E.name?E.name:E,S=S&&S.name?S.name:S,k=k&&k.name?k.name:k,m[E]=!0,m[S]=!0,m[k]=!0,r.patterns[v.id]={min:E,mid:S,max:k}}}return r}function Qh(i,e,r,s,c){let p;if(c===(function(m,v,T,E){let S=0;for(let k=v,R=T-E;k<T;k+=E)S+=(m[R]-m[k])*(m[k+1]+m[R+1]),R=k;return S})(i,e,r,s)>0)for(let m=e;m<r;m+=s)p=Xh(m/s|0,i[m],i[m+1],p);else for(let m=r-s;m>=e;m-=s)p=Xh(m/s|0,i[m],i[m+1],p);return p&&NA(p,p.next)&&(Eu(p),p=p.next),p}function Gl(i,e){if(!i)return i;e||(e=i);let r,s=i;do if(r=!1,s.steiner||!NA(s,s.next)&&fi(s.prev,s,s.next)!==0)s=s.next;else{if(Eu(s),s=e=s.prev,s===s.next)break;r=!0}while(r||s!==e);return e}function Tu(i,e,r,s,c,p,m){if(!i)return;!m&&p&&(function(T,E,S,k){let R=T;do R.z===0&&(R.z=Vc(R.x,R.y,E,S,k)),R.prevZ=R.prev,R.nextZ=R.next,R=R.next;while(R!==T);R.prevZ.nextZ=null,R.prevZ=null,(function(L){let j,N=1;do{let q,Y=L;L=null;let ue=null;for(j=0;Y;){j++;let J=Y,re=0;for(let me=0;me<N&&(re++,J=J.nextZ,J);me++);let he=N;for(;re>0||he>0&&J;)re!==0&&(he===0||!J||Y.z<=J.z)?(q=Y,Y=Y.nextZ,re--):(q=J,J=J.nextZ,he--),ue?ue.nextZ=q:L=q,q.prevZ=ue,ue=q;Y=J}ue.nextZ=null,N*=2}while(j>1)})(R)})(i,s,c,p);let v=i;for(;i.prev!==i.next;){const T=i.prev,E=i.next;if(p?zf(i,s,c,p):kf(i))e.push(T.i,i.i,E.i),Eu(i),i=E.next,v=E.next;else if((i=E)===v){m?m===1?Tu(i=Bf(Gl(i),e),e,r,s,c,p,2):m===2&&Rf(i,e,r,s,c,p):Tu(Gl(i),e,r,s,c,p,1);break}}}function kf(i){const e=i.prev,r=i,s=i.next;if(fi(e,r,s)>=0)return!1;const c=e.x,p=r.x,m=s.x,v=e.y,T=r.y,E=s.y,S=Math.min(c,p,m),k=Math.min(v,T,E),R=Math.max(c,p,m),L=Math.max(v,T,E);let j=s.next;for(;j!==e;){if(j.x>=S&&j.x<=R&&j.y>=k&&j.y<=L&&Pu(c,v,p,T,m,E,j.x,j.y)&&fi(j.prev,j,j.next)>=0)return!1;j=j.next}return!0}function zf(i,e,r,s){const c=i.prev,p=i,m=i.next;if(fi(c,p,m)>=0)return!1;const v=c.x,T=p.x,E=m.x,S=c.y,k=p.y,R=m.y,L=Math.min(v,T,E),j=Math.min(S,k,R),N=Math.max(v,T,E),q=Math.max(S,k,R),Y=Vc(L,j,e,r,s),ue=Vc(N,q,e,r,s);let J=i.prevZ,re=i.nextZ;for(;J&&J.z>=Y&&re&&re.z<=ue;){if(J.x>=L&&J.x<=N&&J.y>=j&&J.y<=q&&J!==c&&J!==m&&Pu(v,S,T,k,E,R,J.x,J.y)&&fi(J.prev,J,J.next)>=0||(J=J.prevZ,re.x>=L&&re.x<=N&&re.y>=j&&re.y<=q&&re!==c&&re!==m&&Pu(v,S,T,k,E,R,re.x,re.y)&&fi(re.prev,re,re.next)>=0))return!1;re=re.nextZ}for(;J&&J.z>=Y;){if(J.x>=L&&J.x<=N&&J.y>=j&&J.y<=q&&J!==c&&J!==m&&Pu(v,S,T,k,E,R,J.x,J.y)&&fi(J.prev,J,J.next)>=0)return!1;J=J.prevZ}for(;re&&re.z<=ue;){if(re.x>=L&&re.x<=N&&re.y>=j&&re.y<=q&&re!==c&&re!==m&&Pu(v,S,T,k,E,R,re.x,re.y)&&fi(re.prev,re,re.next)>=0)return!1;re=re.nextZ}return!0}function Bf(i,e){let r=i;do{const s=r.prev,c=r.next.next;!NA(s,c)&&Wh(s,r,r.next,c)&&Mu(s,c)&&Mu(c,s)&&(e.push(s.i,r.i,c.i),Eu(r),Eu(r.next),r=i=c),r=r.next}while(r!==i);return Gl(r)}function Rf(i,e,r,s,c,p){let m=i;do{let v=m.next.next;for(;v!==m.prev;){if(m.i!==v.i&&jf(m,v)){let T=Hh(m,v);return m=Gl(m,m.next),T=Gl(T,T.next),Tu(m,e,r,s,c,p,0),void Tu(T,e,r,s,c,p,0)}v=v.next}m=m.next}while(m!==i)}function Lf(i,e){let r=i.x-e.x;return r===0&&(r=i.y-e.y,r===0)&&(r=(i.next.y-i.y)/(i.next.x-i.x)-(e.next.y-e.y)/(e.next.x-e.x)),r}function Ff(i,e){const r=(function(c,p){let m=p;const v=c.x,T=c.y;let E,S=-1/0;if(NA(c,m))return m;do{if(NA(c,m.next))return m.next;if(T<=m.y&&T>=m.next.y&&m.next.y!==m.y){const N=m.x+(T-m.y)*(m.next.x-m.x)/(m.next.y-m.y);if(N<=v&&N>S&&(S=N,E=m.x<m.next.x?m:m.next,N===v))return E}m=m.next}while(m!==p);if(!E)return null;const k=E,R=E.x,L=E.y;let j=1/0;m=E;do{if(v>=m.x&&m.x>=R&&v!==m.x&&$h(T<L?v:S,T,R,L,T<L?S:v,T,m.x,m.y)){const N=Math.abs(T-m.y)/(v-m.x);Mu(m,c)&&(N<j||N===j&&(m.x>E.x||m.x===E.x&&Of(E,m)))&&(E=m,j=N)}m=m.next}while(m!==k);return E})(i,e);if(!r)return e;const s=Hh(r,i);return Gl(s,s.next),Gl(r,r.next)}function Of(i,e){return fi(i.prev,i,e.prev)<0&&fi(e.next,i,i.next)<0}function Vc(i,e,r,s,c){return(i=1431655765&((i=858993459&((i=252645135&((i=16711935&((i=(i-r)*c|0)|i<<8))|i<<4))|i<<2))|i<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-s)*c|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Vf(i){let e=i,r=i;do(e.x<r.x||e.x===r.x&&e.y<r.y)&&(r=e),e=e.next;while(e!==i);return r}function $h(i,e,r,s,c,p,m,v){return(c-m)*(e-v)>=(i-m)*(p-v)&&(i-m)*(s-v)>=(r-m)*(e-v)&&(r-m)*(p-v)>=(c-m)*(s-v)}function Pu(i,e,r,s,c,p,m,v){return!(i===m&&e===v)&&$h(i,e,r,s,c,p,m,v)}function jf(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!(function(r,s){let c=r;do{if(c.i!==r.i&&c.next.i!==r.i&&c.i!==s.i&&c.next.i!==s.i&&Wh(c,c.next,r,s))return!0;c=c.next}while(c!==r);return!1})(i,e)&&(Mu(i,e)&&Mu(e,i)&&(function(r,s){let c=r,p=!1;const m=(r.x+s.x)/2,v=(r.y+s.y)/2;do c.y>v!=c.next.y>v&&c.next.y!==c.y&&m<(c.next.x-c.x)*(v-c.y)/(c.next.y-c.y)+c.x&&(p=!p),c=c.next;while(c!==r);return p})(i,e)&&(fi(i.prev,i,e.prev)||fi(i,e.prev,e))||NA(i,e)&&fi(i.prev,i,i.next)>0&&fi(e.prev,e,e.next)>0)}function fi(i,e,r){return(e.y-i.y)*(r.x-e.x)-(e.x-i.x)*(r.y-e.y)}function NA(i,e){return i.x===e.x&&i.y===e.y}function Wh(i,e,r,s){const c=tc(fi(i,e,r)),p=tc(fi(i,e,s)),m=tc(fi(r,s,i)),v=tc(fi(r,s,e));return c!==p&&m!==v||!(c!==0||!ec(i,r,e))||!(p!==0||!ec(i,s,e))||!(m!==0||!ec(r,i,s))||!(v!==0||!ec(r,e,s))}function ec(i,e,r){return e.x<=Math.max(i.x,r.x)&&e.x>=Math.min(i.x,r.x)&&e.y<=Math.max(i.y,r.y)&&e.y>=Math.min(i.y,r.y)}function tc(i){return i>0?1:i<0?-1:0}function Mu(i,e){return fi(i.prev,i,i.next)<0?fi(i,e,i.next)>=0&&fi(i,i.prev,e)>=0:fi(i,e,i.prev)<0||fi(i,i.next,e)<0}function Hh(i,e){const r=jc(i.i,i.x,i.y),s=jc(e.i,e.x,e.y),c=i.next,p=e.prev;return i.next=e,e.prev=i,r.next=c,c.prev=r,s.next=r,r.prev=s,p.next=s,s.prev=p,s}function Xh(i,e,r,s){const c=jc(i,e,r);return s?(c.next=s.next,c.prev=s,s.next.prev=c,s.next=c):(c.prev=c,c.next=c),c}function Eu(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function jc(i,e,r){return{i,x:e,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class GA{constructor(e,r){if(r>e)throw new Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=e,this._minGranularity=r}getGranularityForZoomLevel(e){return Math.max(Math.floor(this._baseZoomGranularity/(1<<e)),this._minGranularity,1)}}class rc{constructor(e){this.fill=e.fill,this.line=e.line,this.tile=e.tile,this.stencil=e.stencil,this.circle=e.circle}}rc.noSubdivision=new rc({fill:new GA(0,0),line:new GA(0,0),tile:new GA(0,0),stencil:new GA(0,0),circle:1}),yt("SubdivisionGranularityExpression",GA),yt("SubdivisionGranularitySetting",rc);const UA=-32768,Iu=32767;class Nf{constructor(e,r){this._vertexBuffer=[],this._vertexDictionary=new Map,this._used=!1,this._granularity=e,this._granularityCellSize=dr/e,this._canonical=r}_getKey(e,r){return(e+=32768)<<16|r+32768}_vertexToIndex(e,r){if(e<-32768||r<-32768||e>32767||r>32767)throw new Error("Vertex coordinates are out of signed 16 bit integer range.");const s=0|Math.round(e),c=0|Math.round(r),p=this._getKey(s,c);if(this._vertexDictionary.has(p))return this._vertexDictionary.get(p);const m=this._vertexBuffer.length/2;return this._vertexDictionary.set(p,m),this._vertexBuffer.push(s,c),m}_subdivideTrianglesScanline(e){if(this._granularity<2)return(function(c,p){const m=[];for(let v=0;v<p.length;v+=3){const T=p[v],E=p[v+1],S=p[v+2],k=c[2*T],R=c[2*T+1];(c[2*E]-k)*(c[2*S+1]-R)-(c[2*E+1]-R)*(c[2*S]-k)>0?(m.push(T),m.push(S),m.push(E)):(m.push(T),m.push(E),m.push(S))}return m})(this._vertexBuffer,e);const r=[],s=e.length;for(let c=0;c<s;c+=3){const p=[e[c+0],e[c+1],e[c+2]],m=[this._vertexBuffer[2*e[c+0]+0],this._vertexBuffer[2*e[c+0]+1],this._vertexBuffer[2*e[c+1]+0],this._vertexBuffer[2*e[c+1]+1],this._vertexBuffer[2*e[c+2]+0],this._vertexBuffer[2*e[c+2]+1]];let v=1/0,T=1/0,E=-1/0,S=-1/0;for(let N=0;N<3;N++){const q=m[2*N],Y=m[2*N+1];v=Math.min(v,q),E=Math.max(E,q),T=Math.min(T,Y),S=Math.max(S,Y)}if(v===E||T===S)continue;const k=Math.floor(v/this._granularityCellSize),R=Math.ceil(E/this._granularityCellSize),L=Math.floor(T/this._granularityCellSize),j=Math.ceil(S/this._granularityCellSize);if(k!==R||L!==j)for(let N=L;N<j;N++){const q=this._scanlineGenerateVertexRingForCellRow(N,m,p);Gf(this._vertexBuffer,q,r)}else r.push(...p)}return r}_scanlineGenerateVertexRingForCellRow(e,r,s){const c=e*this._granularityCellSize,p=c+this._granularityCellSize,m=[];for(let v=0;v<3;v++){const T=r[2*v],E=r[2*v+1],S=r[2*(v+1)%6],k=r[(2*(v+1)+1)%6],R=r[2*(v+2)%6],L=r[(2*(v+2)+1)%6],j=S-T,N=k-E,q=j===0,Y=N===0,ue=(c-E)/N,J=(p-E)/N,re=Math.min(ue,J),he=Math.max(ue,J);if(!Y&&(re>=1||he<=0)||Y&&(E<c||E>p)){k>=c&&k<=p&&m.push(s[(v+1)%3]);continue}!Y&&re>0&&m.push(this._vertexToIndex(T+j*re,E+N*re));const me=T+j*Math.max(re,0),ze=T+j*Math.min(he,1);q||this._generateIntraEdgeVertices(m,T,E,S,k,me,ze),!Y&&he<1&&m.push(this._vertexToIndex(T+j*he,E+N*he)),(Y||k>=c&&k<=p)&&m.push(s[(v+1)%3]),!Y&&(k<=c||k>=p)&&this._generateInterEdgeVertices(m,T,E,S,k,R,L,ze,c,p)}return m}_generateIntraEdgeVertices(e,r,s,c,p,m,v){const T=c-r,E=p-s,S=E===0,k=S?Math.min(r,c):Math.min(m,v),R=S?Math.max(r,c):Math.max(m,v),L=Math.floor(k/this._granularityCellSize)+1,j=Math.ceil(R/this._granularityCellSize)-1;if(S?r<c:m<v)for(let N=L;N<=j;N++){const q=N*this._granularityCellSize;e.push(this._vertexToIndex(q,s+E*(q-r)/T))}else for(let N=j;N>=L;N--){const q=N*this._granularityCellSize;e.push(this._vertexToIndex(q,s+E*(q-r)/T))}}_generateInterEdgeVertices(e,r,s,c,p,m,v,T,E,S){const k=p-s,R=m-c,L=v-p,j=(E-p)/L,N=(S-p)/L,q=Math.min(j,N),Y=Math.max(j,N),ue=c+R*q;let J=Math.floor(Math.min(ue,T)/this._granularityCellSize)+1,re=Math.ceil(Math.max(ue,T)/this._granularityCellSize)-1,he=T<ue;const me=L===0;if(me&&(v===E||v===S))return;if(me||q>=1||Y<=0){const He=s-v,Qe=m+(r-m)*Math.min((E-v)/He,(S-v)/He);J=Math.floor(Math.min(Qe,T)/this._granularityCellSize)+1,re=Math.ceil(Math.max(Qe,T)/this._granularityCellSize)-1,he=T<Qe}const ze=k>0?S:E;if(he)for(let He=J;He<=re;He++)e.push(this._vertexToIndex(He*this._granularityCellSize,ze));else for(let He=re;He>=J;He--)e.push(this._vertexToIndex(He*this._granularityCellSize,ze))}_generateOutline(e){const r=[];for(const s of e){const c=Ul(s,this._granularity,!0),p=this._pointArrayToIndices(c),m=[];for(let v=1;v<p.length;v++)m.push(p[v-1]),m.push(p[v]);r.push(m)}return r}_handlePoles(e){let r=!1,s=!1;this._canonical&&(this._canonical.y===0&&(r=!0),this._canonical.y===(1<<this._canonical.z)-1&&(s=!0)),(r||s)&&this._fillPoles(e,r,s)}_ensureNoPoleVertices(){const e=this._vertexBuffer;for(let r=0;r<e.length;r+=2){const s=e[r+1];s===UA&&(e[r+1]=-32767),s===Iu&&(e[r+1]=32766)}}_generatePoleQuad(e,r,s,c,p,m){c>p!=(m===UA)?(e.push(r),e.push(s),e.push(this._vertexToIndex(c,m)),e.push(s),e.push(this._vertexToIndex(p,m)),e.push(this._vertexToIndex(c,m))):(e.push(s),e.push(r),e.push(this._vertexToIndex(c,m)),e.push(this._vertexToIndex(p,m)),e.push(s),e.push(this._vertexToIndex(c,m)))}_fillPoles(e,r,s){const c=this._vertexBuffer,p=dr,m=e.length;for(let v=2;v<m;v+=3){const T=e[v-2],E=e[v-1],S=e[v],k=c[2*T],R=c[2*T+1],L=c[2*E],j=c[2*E+1],N=c[2*S],q=c[2*S+1];r&&(R===0&&j===0&&this._generatePoleQuad(e,T,E,k,L,UA),j===0&&q===0&&this._generatePoleQuad(e,E,S,L,N,UA),q===0&&R===0&&this._generatePoleQuad(e,S,T,N,k,UA)),s&&(R===p&&j===p&&this._generatePoleQuad(e,T,E,k,L,Iu),j===p&&q===p&&this._generatePoleQuad(e,E,S,L,N,Iu),q===p&&R===p&&this._generatePoleQuad(e,S,T,N,k,Iu))}}_initializeVertices(e){for(let r=0;r<e.length;r+=2)this._vertexToIndex(e[r],e[r+1])}subdividePolygonInternal(e,r){if(this._used)throw new Error("Subdivision: multiple use not allowed.");this._used=!0;const{flattened:s,holeIndices:c}=(function(v){const T=[],E=[];for(const S of v)if(S.length!==0){S!==v[0]&&T.push(E.length/2);for(let k=0;k<S.length;k++)E.push(S[k].x),E.push(S[k].y)}return{flattened:E,holeIndices:T}})(e);let p;this._initializeVertices(s);try{const v=(function(E,S,k=2){const R=S&&S.length,L=R?S[0]*k:E.length;let j=Qh(E,0,L,k,!0);const N=[];if(!j||j.next===j.prev)return N;let q,Y,ue;if(R&&(j=(function(J,re,he,me){const ze=[];for(let He=0,Qe=re.length;He<Qe;He++){const et=Qh(J,re[He]*me,He<Qe-1?re[He+1]*me:J.length,me,!1);et===et.next&&(et.steiner=!0),ze.push(Vf(et))}ze.sort(Lf);for(let He=0;He<ze.length;He++)he=Ff(ze[He],he);return he})(E,S,j,k)),E.length>80*k){q=E[0],Y=E[1];let J=q,re=Y;for(let he=k;he<L;he+=k){const me=E[he],ze=E[he+1];me<q&&(q=me),ze<Y&&(Y=ze),me>J&&(J=me),ze>re&&(re=ze)}ue=Math.max(J-q,re-Y),ue=ue!==0?32767/ue:0}return Tu(j,N,k,q,Y,ue,0),N})(s,c),T=this._convertIndices(s,v);p=this._subdivideTrianglesScanline(T)}catch(v){console.error(v)}let m=[];return r&&(m=this._generateOutline(e)),this._ensureNoPoleVertices(),this._handlePoles(p),{verticesFlattened:this._vertexBuffer,indicesTriangles:p,indicesLineList:m}}_convertIndices(e,r){const s=[];for(let c=0;c<r.length;c++)s.push(this._vertexToIndex(e[2*r[c]],e[2*r[c]+1]));return s}_pointArrayToIndices(e){const r=[];for(let s=0;s<e.length;s++){const c=e[s];r.push(this._vertexToIndex(c.x,c.y))}return r}}function Yh(i,e,r,s=!0){return new Nf(r,e).subdividePolygonInternal(i,s)}function Ul(i,e,r=!1){if(!i||i.length<1)return[];if(i.length<2)return[];const s=i[0],c=i[i.length-1],p=r&&(s.x!==c.x||s.y!==c.y);if(e<2)return p?[...i,i[0]]:[...i];const m=Math.floor(dr/e),v=[];v.push(new nt(i[0].x,i[0].y));const T=i.length,E=p?T:T-1;for(let S=0;S<E;S++){const k=i[S],R=S<T-1?i[S+1]:i[0],L=k.x,j=k.y,N=R.x,q=R.y,Y=L!==N,ue=j!==q;if(!Y&&!ue)continue;const J=N-L,re=q-j,he=Math.abs(J),me=Math.abs(re);let ze=L,He=j;for(;;){const et=J>0?(Math.floor(ze/m)+1)*m:(Math.ceil(ze/m)-1)*m,pt=re>0?(Math.floor(He/m)+1)*m:(Math.ceil(He/m)-1)*m,st=Math.abs(ze-et),$e=Math.abs(He-pt),Ne=Math.abs(ze-N),xt=Math.abs(He-q),gt=Y?st/he:Number.POSITIVE_INFINITY,Tt=ue?$e/me:Number.POSITIVE_INFINITY;if((Ne<=st||!Y)&&(xt<=$e||!ue))break;if(gt<Tt&&Y||!ue){ze=et,He+=re*gt;const mt=new nt(ze,Math.round(He));v[v.length-1].x===mt.x&&v[v.length-1].y===mt.y||v.push(mt)}else{ze+=J*Tt,He=pt;const mt=new nt(Math.round(ze),He);v[v.length-1].x===mt.x&&v[v.length-1].y===mt.y||v.push(mt)}}const Qe=new nt(N,q);v[v.length-1].x===Qe.x&&v[v.length-1].y===Qe.y||v.push(Qe)}return v}function Gf(i,e,r){if(e.length===0)throw new Error("Subdivision vertex ring is empty.");let s=0,c=i[2*e[0]];for(let T=1;T<e.length;T++){const E=i[2*e[T]];E<c&&(c=E,s=T)}const p=e.length;let m=s,v=(m+1)%p;for(;;){const T=m-1>=0?m-1:p-1,E=(v+1)%p,S=i[2*e[T]],k=i[2*e[E]],R=i[2*e[m]],L=i[2*e[m]+1],j=i[2*e[v]+1];let N=!1;if(S<k)N=!0;else if(S>k)N=!1;else{const q=j-L,Y=-(i[2*e[v]]-R),ue=L<j?1:-1;((S-R)*q+(i[2*e[T]+1]-L)*Y)*ue>((k-R)*q+(i[2*e[E]+1]-L)*Y)*ue&&(N=!0)}if(N){const q=e[T],Y=e[m],ue=e[v];q!==Y&&q!==ue&&Y!==ue&&r.push(ue,Y,q),m--,m<0&&(m=p-1)}else{const q=e[E],Y=e[m],ue=e[v];q!==Y&&q!==ue&&Y!==ue&&r.push(ue,Y,q),v++,v>=p&&(v=0)}if(T===E)break}}function Kh(i,e,r,s,c,p,m,v,T){const E=c.length/2,S=m&&v&&T;if(E<ft.MAX_VERTEX_ARRAY_LENGTH){const k=e.prepareSegment(E,r,s),R=k.vertexLength;for(let N=0;N<p.length;N+=3)s.emplaceBack(R+p[N],R+p[N+1],R+p[N+2]);let L,j;k.vertexLength+=E,k.primitiveLength+=p.length/3,S&&(j=m.prepareSegment(E,r,v),L=j.vertexLength,j.vertexLength+=E);for(let N=0;N<c.length;N+=2)i(c[N],c[N+1]);if(S)for(let N=0;N<T.length;N++){const q=T[N];for(let Y=1;Y<q.length;Y+=2)v.emplaceBack(L+q[Y-1],L+q[Y]);j.primitiveLength+=q.length/2}}else(function(k,R,L,j,N,q){const Y=[];for(let me=0;me<j.length/2;me++)Y.push(-1);const ue={count:0};let J=0,re=k.getOrCreateLatestSegment(R,L),he=re.vertexLength;for(let me=2;me<N.length;me+=3){const ze=N[me-2],He=N[me-1],Qe=N[me];let et=Y[ze]<J,pt=Y[He]<J,st=Y[Qe]<J;re.vertexLength+((et?1:0)+(pt?1:0)+(st?1:0))>ft.MAX_VERTEX_ARRAY_LENGTH&&(re=k.createNewSegment(R,L),J=ue.count,et=!0,pt=!0,st=!0,he=0);const $e=Su(Y,j,q,ue,ze,et,re),Ne=Su(Y,j,q,ue,He,pt,re),xt=Su(Y,j,q,ue,Qe,st,re);L.emplaceBack(he+$e-J,he+Ne-J,he+xt-J),re.primitiveLength++}})(e,r,s,c,p,i),S&&(function(k,R,L,j,N,q){const Y=[];for(let me=0;me<j.length/2;me++)Y.push(-1);const ue={count:0};let J=0,re=k.getOrCreateLatestSegment(R,L),he=re.vertexLength;for(let me=0;me<N.length;me++){const ze=N[me];for(let He=1;He<N[me].length;He+=2){const Qe=ze[He-1],et=ze[He];let pt=Y[Qe]<J,st=Y[et]<J;re.vertexLength+((pt?1:0)+(st?1:0))>ft.MAX_VERTEX_ARRAY_LENGTH&&(re=k.createNewSegment(R,L),J=ue.count,pt=!0,st=!0,he=0);const $e=Su(Y,j,q,ue,Qe,pt,re),Ne=Su(Y,j,q,ue,et,st,re);L.emplaceBack(he+$e-J,he+Ne-J),re.primitiveLength++}}})(m,r,v,c,T,i),e.forceNewSegmentOnNextPrepare(),m==null||m.forceNewSegmentOnNextPrepare()}function Su(i,e,r,s,c,p,m){if(p){const v=s.count;return r(e[2*c],e[2*c+1]),i[c]=s.count,s.count++,m.vertexLength++,v}return i[c]}class Nc{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((r=>r.id)),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.layoutVertexArray=new ne,this.indexArray=new Ve,this.indexArray2=new ut,this.programConfigurations=new Da(e.layers,e.zoom),this.segments=new ft,this.segments2=new ft,this.stateDependentLayerIds=this.layers.filter((r=>r.isStateDependent())).map((r=>r.id))}populate(e,r,s){this.hasDependencies=Ju("fill",this.layers,r);const c=this.layers[0].layout.get("fill-sort-key"),p=!c.isConstant(),m=[];for(const{feature:v,id:T,index:E,sourceLayerIndex:S}of e){const k=this.layers[0]._featureFilter.needGeometry,R=Jo(v,k);if(!this.layers[0]._featureFilter.filter(new Pe(this.zoom),R,s))continue;const L=p?c.evaluate(R,{},s,r.availableImages):void 0,j={id:T,properties:v.properties,type:v.type,sourceLayerIndex:S,index:E,geometry:k?R.geometry:Ko(v),patterns:{},sortKey:L};m.push(j)}p&&m.sort(((v,T)=>v.sortKey-T.sortKey));for(const v of m){const{geometry:T,index:E,sourceLayerIndex:S}=v;if(this.hasDependencies){const k=Oc("fill",this.layers,v,{zoom:this.zoom},r);this.patternFeatures.push(k)}else this.addFeature(v,T,E,s,{},r.subdivisionGranularity);r.featureIndex.insert(e[E].feature,T,E,S,this.index)}}update(e,r,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,{imagePositions:s})}addFeatures(e,r,s){for(const c of this.patternFeatures)this.addFeature(c,c.geometry,c.index,r,s,e.subdivisionGranularity)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Df),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),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(e,r,s,c,p,m){for(const v of Na(r,500)){const T=Yh(v,c,m.fill.getGranularityForZoomLevel(c.z)),E=this.layoutVertexArray;Kh(((S,k)=>{E.emplaceBack(S,k)}),this.segments,this.layoutVertexArray,this.indexArray,T.verticesFlattened,T.indicesTriangles,this.segments2,this.indexArray2,T.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,s,{imagePositions:p,canonical:c})}}let Jh,e0;yt("FillBucket",Nc,{omit:["layers","patternFeatures"]});var Uf={get paint(){return e0=e0||new Ri({"fill-antialias":new at(Le.paint_fill["fill-antialias"]),"fill-opacity":new dt(Le.paint_fill["fill-opacity"]),"fill-color":new dt(Le.paint_fill["fill-color"]),"fill-outline-color":new dt(Le.paint_fill["fill-outline-color"]),"fill-translate":new at(Le.paint_fill["fill-translate"]),"fill-translate-anchor":new at(Le.paint_fill["fill-translate-anchor"]),"fill-pattern":new Nt(Le.paint_fill["fill-pattern"])})},get layout(){return Jh=Jh||new Ri({"fill-sort-key":new dt(Le.layout_fill["fill-sort-key"])})}};class qf extends es{constructor(e,r){super(e,Uf,r)}recalculate(e,r){super.recalculate(e,r);const s=this.paint._values["fill-outline-color"];s.value.kind==="constant"&&s.value.value===void 0&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(e){return new Nc(e)}queryRadius(){return Yu(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:e,geometry:r,transform:s,pixelsToTileUnits:c}){return kh(Ku(e,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-s.bearingInRadians,c),r)}isTileClipped(){return!0}}const Zf=Ai([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),Qf=Ai([{name:"a_centroid",components:2,type:"Int16"}],4),{members:$f}=Zf;class Cu{constructor(e,r,s,c,p){this.properties={},this.extent=s,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=c,this._values=p,e.readFields(Wf,this,r)}loadGeometry(){const e=this._pbf;e.pos=this._geometry;const r=e.readVarint()+e.pos,s=[];let c,p=1,m=0,v=0,T=0;for(;e.pos<r;){if(m<=0){const E=e.readVarint();p=7&E,m=E>>3}if(m--,p===1||p===2)v+=e.readSVarint(),T+=e.readSVarint(),p===1&&(c&&s.push(c),c=[]),c&&c.push(new nt(v,T));else{if(p!==7)throw new Error(`unknown command ${p}`);c&&c.push(c[0].clone())}}return c&&s.push(c),s}bbox(){const e=this._pbf;e.pos=this._geometry;const r=e.readVarint()+e.pos;let s=1,c=0,p=0,m=0,v=1/0,T=-1/0,E=1/0,S=-1/0;for(;e.pos<r;){if(c<=0){const k=e.readVarint();s=7&k,c=k>>3}if(c--,s===1||s===2)p+=e.readSVarint(),m+=e.readSVarint(),p<v&&(v=p),p>T&&(T=p),m<E&&(E=m),m>S&&(S=m);else if(s!==7)throw new Error(`unknown command ${s}`)}return[v,E,T,S]}toGeoJSON(e,r,s){const c=this.extent*Math.pow(2,s),p=this.extent*e,m=this.extent*r,v=this.loadGeometry();function T(R){return[360*(R.x+p)/c-180,360/Math.PI*Math.atan(Math.exp((1-2*(R.y+m)/c)*Math.PI))-90]}function E(R){return R.map(T)}let S;if(this.type===1){const R=[];for(const j of v)R.push(j[0]);const L=E(R);S=R.length===1?{type:"Point",coordinates:L[0]}:{type:"MultiPoint",coordinates:L}}else if(this.type===2){const R=v.map(E);S=R.length===1?{type:"LineString",coordinates:R[0]}:{type:"MultiLineString",coordinates:R}}else{if(this.type!==3)throw new Error("unknown feature type");{const R=t0(v),L=[];for(const j of R)L.push(j.map(E));S=L.length===1?{type:"Polygon",coordinates:L[0]}:{type:"MultiPolygon",coordinates:L}}}const k={type:"Feature",geometry:S,properties:this.properties};return this.id!=null&&(k.id=this.id),k}}function Wf(i,e,r){i===1?e.id=r.readVarint():i===2?(function(s,c){const p=s.readVarint()+s.pos;for(;s.pos<p;){const m=c._keys[s.readVarint()],v=c._values[s.readVarint()];c.properties[m]=v}})(r,e):i===3?e.type=r.readVarint():i===4&&(e._geometry=r.pos)}function t0(i){const e=i.length;if(e<=1)return[i];const r=[];let s,c;for(let p=0;p<e;p++){const m=Hf(i[p]);m!==0&&(c===void 0&&(c=m<0),c===m<0?(s&&r.push(s),s=[i[p]]):s&&s.push(i[p]))}return s&&r.push(s),r}function Hf(i){let e=0;for(let r,s,c=0,p=i.length,m=p-1;c<p;m=c++)r=i[c],s=i[m],e+=(s.x-r.x)*(r.y+s.y);return e}Cu.types=["Unknown","Point","LineString","Polygon"];class Xf{constructor(e,r){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],e.readFields(Yf,this,r),this.length=this._features.length}feature(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];const r=this._pbf.readVarint()+this._pbf.pos;return new Cu(this._pbf,r,this.extent,this._keys,this._values)}}function Yf(i,e,r){i===15?e.version=r.readVarint():i===1?e.name=r.readString():i===5?e.extent=r.readVarint():i===2?e._features.push(r.pos):i===3?e._keys.push(r.readString()):i===4&&e._values.push((function(s){let c=null;const p=s.readVarint()+s.pos;for(;s.pos<p;){const m=s.readVarint()>>3;c=m===1?s.readString():m===2?s.readFloat():m===3?s.readDouble():m===4?s.readVarint64():m===5?s.readVarint():m===6?s.readSVarint():m===7?s.readBoolean():null}if(c==null)throw new Error("unknown feature value");return c})(r))}class r0{constructor(e,r){this.layers=e.readFields(Kf,{},r)}}function Kf(i,e,r){if(i===3){const s=new Xf(r,r.readVarint()+r.pos);s.length&&(e[s.name]=s)}}const Gc=Math.pow(2,13);function Du(i,e,r,s,c,p,m,v){i.emplaceBack(e,r,2*Math.floor(s*Gc)+m,c*Gc*2,p*Gc*2,Math.round(v))}class Uc{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((r=>r.id)),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new ce,this.centroidVertexArray=new ie,this.indexArray=new Ve,this.programConfigurations=new Da(e.layers,e.zoom),this.segments=new ft,this.stateDependentLayerIds=this.layers.filter((r=>r.isStateDependent())).map((r=>r.id))}populate(e,r,s){this.features=[],this.hasDependencies=Ju("fill-extrusion",this.layers,r);for(const{feature:c,id:p,index:m,sourceLayerIndex:v}of e){const T=this.layers[0]._featureFilter.needGeometry,E=Jo(c,T);if(!this.layers[0]._featureFilter.filter(new Pe(this.zoom),E,s))continue;const S={id:p,sourceLayerIndex:v,index:m,geometry:T?E.geometry:Ko(c),properties:c.properties,type:c.type,patterns:{}};this.hasDependencies?this.features.push(Oc("fill-extrusion",this.layers,S,{zoom:this.zoom},r)):this.addFeature(S,S.geometry,m,s,{},r.subdivisionGranularity),r.featureIndex.insert(c,S.geometry,m,v,this.index,!0)}}addFeatures(e,r,s){for(const c of this.features){const{geometry:p}=c;this.addFeature(c,p,c.index,r,s,e.subdivisionGranularity)}}update(e,r,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,{imagePositions:s})}isEmpty(){return this.layoutVertexArray.length===0&&this.centroidVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,$f),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,Qf.members,!0),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(e,r,s,c,p,m){for(const v of Na(r,500)){const T={x:0,y:0,sampleCount:0},E=this.layoutVertexArray.length;this.processPolygon(T,c,e,v,m);const S=this.layoutVertexArray.length-E,k=Math.floor(T.x/T.sampleCount),R=Math.floor(T.y/T.sampleCount);for(let L=0;L<S;L++)this.centroidVertexArray.emplaceBack(k,R)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,s,{imagePositions:p,canonical:c})}processPolygon(e,r,s,c,p){if(c.length<1||i0(c[0]))return;for(const k of c)k.length!==0&&Jf(e,k);const m={segment:this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray)},v=p.fill.getGranularityForZoomLevel(r.z),T=Cu.types[s.type]==="Polygon";for(const k of c){if(k.length===0||i0(k))continue;const R=Ul(k,v,T);this._generateSideFaces(R,m)}if(!T)return;const E=Yh(c,r,v,!1),S=this.layoutVertexArray;Kh(((k,R)=>{Du(S,k,R,0,0,1,1,0)}),this.segments,this.layoutVertexArray,this.indexArray,E.verticesFlattened,E.indicesTriangles)}_generateSideFaces(e,r){let s=0;for(let c=1;c<e.length;c++){const p=e[c],m=e[c-1];if(ed(p,m))continue;r.segment.vertexLength+4>ft.MAX_VERTEX_ARRAY_LENGTH&&(r.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const v=p.sub(m)._perp()._unit(),T=m.dist(p);s+T>32768&&(s=0),Du(this.layoutVertexArray,p.x,p.y,v.x,v.y,0,0,s),Du(this.layoutVertexArray,p.x,p.y,v.x,v.y,0,1,s),s+=T,Du(this.layoutVertexArray,m.x,m.y,v.x,v.y,0,0,s),Du(this.layoutVertexArray,m.x,m.y,v.x,v.y,0,1,s);const E=r.segment.vertexLength;this.indexArray.emplaceBack(E,E+2,E+1),this.indexArray.emplaceBack(E+1,E+2,E+3),r.segment.vertexLength+=4,r.segment.primitiveLength+=2}}}function Jf(i,e){for(let r=0;r<e.length;r++){const s=e[r];r===e.length-1&&e[0].x===s.x&&e[0].y===s.y||(i.x+=s.x,i.y+=s.y,i.sampleCount++)}}function ed(i,e){return i.x===e.x&&(i.x<0||i.x>dr)||i.y===e.y&&(i.y<0||i.y>dr)}function i0(i){return i.every((e=>e.x<0))||i.every((e=>e.x>dr))||i.every((e=>e.y<0))||i.every((e=>e.y>dr))}let n0;yt("FillExtrusionBucket",Uc,{omit:["layers","features"]});var td={get paint(){return n0=n0||new Ri({"fill-extrusion-opacity":new at(Le["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new dt(Le["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new at(Le["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new at(Le["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Nt(Le["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new dt(Le["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new dt(Le["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new at(Le["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class rd extends es{constructor(e,r){super(e,td,r)}createBucket(e){return new Uc(e)}queryRadius(){return Yu(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:e,feature:r,featureState:s,geometry:c,transform:p,pixelsToTileUnits:m,pixelPosMatrix:v}){const T=Ku(e,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-p.bearingInRadians,m),E=this.paint.get("fill-extrusion-height").evaluate(r,s),S=this.paint.get("fill-extrusion-base").evaluate(r,s),k=(function(L,j){const N=[];for(const q of L){const Y=[q.x,q.y,0,1];qs(Y,Y,j),N.push(new nt(Y[0]/Y[3],Y[1]/Y[3]))}return N})(T,v),R=(function(L,j,N,q){const Y=[],ue=[],J=q[8]*j,re=q[9]*j,he=q[10]*j,me=q[11]*j,ze=q[8]*N,He=q[9]*N,Qe=q[10]*N,et=q[11]*N;for(const pt of L){const st=[],$e=[];for(const Ne of pt){const xt=Ne.x,gt=Ne.y,Tt=q[0]*xt+q[4]*gt+q[12],mt=q[1]*xt+q[5]*gt+q[13],Ct=q[2]*xt+q[6]*gt+q[14],cr=q[3]*xt+q[7]*gt+q[15],sr=Ct+he,Xr=cr+me,un=Tt+ze,bi=mt+He,Yr=Ct+Qe,qr=cr+et,vr=new nt((Tt+J)/Xr,(mt+re)/Xr);vr.z=sr/Xr,st.push(vr);const ii=new nt(un/qr,bi/qr);ii.z=Yr/qr,$e.push(ii)}Y.push(st),ue.push($e)}return[Y,ue]})(c,S,E,v);return(function(L,j,N){let q=1/0;kh(N,j)&&(q=s0(N,j[0]));for(let Y=0;Y<j.length;Y++){const ue=j[Y],J=L[Y];for(let re=0;re<ue.length-1;re++){const he=ue[re],me=[he,ue[re+1],J[re+1],J[re],he];OA(N,me)&&(q=Math.min(q,s0(N,me)))}}return q!==1/0&&q})(R[0],R[1],k)}}function ku(i,e){return i.x*e.x+i.y*e.y}function s0(i,e){if(i.length===1){let r=0;const s=e[r++];let c;for(;!c||s.equals(c);)if(c=e[r++],!c)return 1/0;for(;r<e.length;r++){const p=e[r],m=i[0],v=c.sub(s),T=p.sub(s),E=m.sub(s),S=ku(v,v),k=ku(v,T),R=ku(T,T),L=ku(E,v),j=ku(E,T),N=S*R-k*k,q=(R*L-k*j)/N,Y=(S*j-k*L)/N,ue=s.z*(1-q-Y)+c.z*q+p.z*Y;if(isFinite(ue))return ue}return 1/0}{let r=1/0;for(const s of e)r=Math.min(r,s.z);return r}}const id=Ai([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"}],4),{members:nd}=id,sd=Ai([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]),{members:od}=sd,ad=Math.cos(Math.PI/180*37.5),o0=Math.pow(2,14)/.5;class qc{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((r=>r.id)),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((r=>{this.gradients[r.id]={}})),this.layoutVertexArray=new ge,this.layoutVertexArray2=new Ae,this.indexArray=new Ve,this.programConfigurations=new Da(e.layers,e.zoom),this.segments=new ft,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((r=>r.isStateDependent())).map((r=>r.id))}populate(e,r,s){this.hasDependencies=Ju("line",this.layers,r)||this.hasLineDasharray(this.layers);const c=this.layers[0].layout.get("line-sort-key"),p=!c.isConstant(),m=[];for(const{feature:v,id:T,index:E,sourceLayerIndex:S}of e){const k=this.layers[0]._featureFilter.needGeometry,R=Jo(v,k);if(!this.layers[0]._featureFilter.filter(new Pe(this.zoom),R,s))continue;const L=p?c.evaluate(R,{},s):void 0,j={id:T,properties:v.properties,type:v.type,sourceLayerIndex:S,index:E,geometry:k?R.geometry:Ko(v),patterns:{},dashes:{},sortKey:L};m.push(j)}p&&m.sort(((v,T)=>v.sortKey-T.sortKey));for(const v of m){const{geometry:T,index:E,sourceLayerIndex:S}=v;this.hasDependencies?(Ju("line",this.layers,r)?Oc("line",this.layers,v,{zoom:this.zoom},r):this.hasLineDasharray(this.layers)&&this.addLineDashDependencies(this.layers,v,this.zoom,r),this.patternFeatures.push(v)):this.addFeature(v,T,E,s,{},{},r.subdivisionGranularity),r.featureIndex.insert(e[E].feature,T,E,S,this.index)}}update(e,r,s,c){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,{imagePositions:s,dashPositions:c})}addFeatures(e,r,s,c){for(const p of this.patternFeatures)this.addFeature(p,p.geometry,p.index,r,s,c,e.subdivisionGranularity)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,od)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,nd),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,r,s,c,p,m,v){const T=this.layers[0].layout,E=T.get("line-join").evaluate(e,{}),S=T.get("line-cap"),k=T.get("line-miter-limit"),R=T.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const L of r)this.addLine(L,e,E,S,k,R,c,v);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,s,{imagePositions:p,dashPositions:m,canonical:c})}addLine(e,r,s,c,p,m,v,T){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,e=Ul(e,v?T.line.getGranularityForZoomLevel(v.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let J=0;J<e.length-1;J++)this.totalDistance+=e[J].dist(e[J+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const E=Cu.types[r.type]==="Polygon";let S=e.length;for(;S>=2&&e[S-1].equals(e[S-2]);)S--;let k=0;for(;k<S-1&&e[k].equals(e[k+1]);)k++;if(S<(E?3:2))return;s==="bevel"&&(p=1.05);const R=this.overscaling<=16?122880/(512*this.overscaling):0,L=this.segments.prepareSegment(10*S,this.layoutVertexArray,this.indexArray);let j,N,q,Y,ue;this.e1=this.e2=-1,E&&(j=e[S-2],ue=e[k].sub(j)._unit()._perp());for(let J=k;J<S;J++){if(q=J===S-1?E?e[k+1]:void 0:e[J+1],q&&e[J].equals(q))continue;ue&&(Y=ue),j&&(N=j),j=e[J],ue=q?q.sub(j)._unit()._perp():Y,Y=Y||ue;let re=Y.add(ue);re.x===0&&re.y===0||re._unit();const he=Y.x*ue.x+Y.y*ue.y,me=re.x*ue.x+re.y*ue.y,ze=me!==0?1/me:1/0,He=2*Math.sqrt(2-2*me),Qe=me<ad&&N&&q,et=Y.x*ue.y-Y.y*ue.x>0;if(Qe&&J>k){const $e=j.dist(N);if($e>2*R){const Ne=j.sub(j.sub(N)._mult(R/$e)._round());this.updateDistance(N,Ne),this.addCurrentVertex(Ne,Y,0,0,L),N=Ne}}const pt=N&&q;let st=pt?s:E?"butt":c;if(pt&&st==="round"&&(ze<m?st="miter":ze<=2&&(st="fakeround")),st==="miter"&&ze>p&&(st="bevel"),st==="bevel"&&(ze>2&&(st="flipbevel"),ze<p&&(st="miter")),N&&this.updateDistance(N,j),st==="miter")re._mult(ze),this.addCurrentVertex(j,re,0,0,L);else if(st==="flipbevel"){if(ze>100)re=ue.mult(-1);else{const $e=ze*Y.add(ue).mag()/Y.sub(ue).mag();re._perp()._mult($e*(et?-1:1))}this.addCurrentVertex(j,re,0,0,L),this.addCurrentVertex(j,re.mult(-1),0,0,L)}else if(st==="bevel"||st==="fakeround"){const $e=-Math.sqrt(ze*ze-1),Ne=et?$e:0,xt=et?0:$e;if(N&&this.addCurrentVertex(j,Y,Ne,xt,L),st==="fakeround"){const gt=Math.round(180*He/Math.PI/20);for(let Tt=1;Tt<gt;Tt++){let mt=Tt/gt;if(mt!==.5){const cr=mt-.5;mt+=mt*cr*(mt-1)*((1.0904+he*(he*(3.55645-1.43519*he)-3.2452))*cr*cr+(.848013+he*(.215638*he-1.06021)))}const Ct=ue.sub(Y)._mult(mt)._add(Y)._unit()._mult(et?-1:1);this.addHalfVertex(j,Ct.x,Ct.y,!1,et,0,L)}}q&&this.addCurrentVertex(j,ue,-Ne,-xt,L)}else if(st==="butt")this.addCurrentVertex(j,re,0,0,L);else if(st==="square"){const $e=N?1:-1;this.addCurrentVertex(j,re,$e,$e,L)}else st==="round"&&(N&&(this.addCurrentVertex(j,Y,0,0,L),this.addCurrentVertex(j,Y,1,1,L,!0)),q&&(this.addCurrentVertex(j,ue,-1,-1,L,!0),this.addCurrentVertex(j,ue,0,0,L)));if(Qe&&J<S-1){const $e=j.dist(q);if($e>2*R){const Ne=j.add(q.sub(j)._mult(R/$e)._round());this.updateDistance(j,Ne),this.addCurrentVertex(Ne,ue,0,0,L),j=Ne}}}}addCurrentVertex(e,r,s,c,p,m=!1){const v=r.y*c-r.x,T=-r.y-r.x*c;this.addHalfVertex(e,r.x+r.y*s,r.y-r.x*s,m,!1,s,p),this.addHalfVertex(e,v,T,m,!0,-c,p),this.distance>o0/2&&this.totalDistance===0&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,r,s,c,p,m))}addHalfVertex({x:e,y:r},s,c,p,m,v,T){const E=.5*(this.lineClips?this.scaledDistance*(o0-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((e<<1)+(p?1:0),(r<<1)+(m?1:0),Math.round(63*s)+128,Math.round(63*c)+128,1+(v===0?0:v<0?-1:1)|(63&E)<<2,E>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const S=T.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,S,this.e2),T.primitiveLength++),m?this.e2=S:this.e1=S}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(e,r){this.distance+=e.dist(r),this.updateScaledDistance()}hasLineDasharray(e){for(const r of e){const s=r.paint.get("line-dasharray");if(s&&!s.isConstant())return!0}return!1}addLineDashDependencies(e,r,s,c){for(const p of e){const m=p.paint.get("line-dasharray");if(!m||m.value.kind==="constant")continue;const v=p.layout.get("line-cap")==="round",T={dasharray:m.value.evaluate({zoom:s-1},r,{}),round:v},E={dasharray:m.value.evaluate({zoom:s},r,{}),round:v},S={dasharray:m.value.evaluate({zoom:s+1},r,{}),round:v},k=`${T.dasharray.join(",")},${T.round}`,R=`${E.dasharray.join(",")},${E.round}`,L=`${S.dasharray.join(",")},${S.round}`;c.dashDependencies[k]=T,c.dashDependencies[R]=E,c.dashDependencies[L]=S,r.dashes[p.id]={min:k,mid:R,max:L}}}}let a0,l0;yt("LineBucket",qc,{omit:["layers","patternFeatures"]});var A0={get paint(){return l0=l0||new Ri({"line-opacity":new dt(Le.paint_line["line-opacity"]),"line-color":new dt(Le.paint_line["line-color"]),"line-translate":new at(Le.paint_line["line-translate"]),"line-translate-anchor":new at(Le.paint_line["line-translate-anchor"]),"line-width":new dt(Le.paint_line["line-width"]),"line-gap-width":new dt(Le.paint_line["line-gap-width"]),"line-offset":new dt(Le.paint_line["line-offset"]),"line-blur":new dt(Le.paint_line["line-blur"]),"line-dasharray":new Nt(Le.paint_line["line-dasharray"]),"line-pattern":new Nt(Le.paint_line["line-pattern"]),"line-gradient":new xi(Le.paint_line["line-gradient"])})},get layout(){return a0=a0||new Ri({"line-cap":new at(Le.layout_line["line-cap"]),"line-join":new dt(Le.layout_line["line-join"]),"line-miter-limit":new at(Le.layout_line["line-miter-limit"]),"line-round-limit":new at(Le.layout_line["line-round-limit"]),"line-sort-key":new dt(Le.layout_line["line-sort-key"])})}};class ld extends dt{possiblyEvaluate(e,r){return r=new Pe(Math.floor(r.zoom),{now:r.now,fadeDuration:r.fadeDuration,zoomHistory:r.zoomHistory,transition:r.transition}),super.possiblyEvaluate(e,r)}evaluate(e,r,s,c){return r=qi({},r,{zoom:Math.floor(r.zoom)}),super.evaluate(e,r,s,c)}}let ic;class Ad extends es{constructor(e,r){super(e,A0,r),this.gradientVersion=0,ic||(ic=new ld(A0.paint.properties["line-width"].specification),ic.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(e){if(e==="line-gradient"){const r=this.gradientExpression();this.stepInterpolant=!!(function(s){return s._styleExpression!==void 0})(r)&&r._styleExpression.expression instanceof nn,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(e,r){super.recalculate(e,r),this.paint._values["line-floorwidth"]=ic.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new qc(e)}queryRadius(e){const r=e,s=u0(jA("line-width",this,r),jA("line-gap-width",this,r)),c=jA("line-offset",this,r);return s/2+Math.abs(c)+Yu(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:e,feature:r,featureState:s,geometry:c,transform:p,pixelsToTileUnits:m}){const v=Ku(e,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-p.bearingInRadians,m),T=m/2*u0(this.paint.get("line-width").evaluate(r,s),this.paint.get("line-gap-width").evaluate(r,s)),E=this.paint.get("line-offset").evaluate(r,s);return E&&(c=(function(S,k){const R=[];for(let L=0;L<S.length;L++){const j=gf(S[L]),N=[];for(let q=0;q<j.length;q++){const Y=j[q],ue=j[q-1],J=j[q+1],re=q===0?new nt(0,0):Y.sub(ue)._unit()._perp(),he=q===j.length-1?new nt(0,0):J.sub(Y)._unit()._perp(),me=re._add(he)._unit(),ze=me.x*he.x+me.y*he.y;ze!==0&&me._mult(1/ze),N.push(me._mult(k)._add(Y))}R.push(N)}return R})(c,E*m)),(function(S,k,R){for(let L=0;L<k.length;L++){const j=k[L];if(S.length>=3){for(let N=0;N<j.length;N++)if(VA(S,j[N]))return!0}if(ff(S,j,R))return!0}return!1})(v,c,T)}isTileClipped(){return!0}}function u0(i,e){return e>0?e+2*i:i}const ud=Ai([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),cd=Ai([{name:"a_projected_pos",components:3,type:"Float32"}],4);Ai([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const hd=Ai([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);Ai([{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 c0=Ai([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),pd=Ai([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function fd(i,e,r){return i.sections.forEach((s=>{s.text=(function(c,p,m){const v=p.layout.get("text-transform").evaluate(m,{});return v==="uppercase"?c=c.toLocaleUpperCase():v==="lowercase"&&(c=c.toLocaleLowerCase()),Se.applyArabicShaping&&(c=Se.applyArabicShaping(c)),c})(s.text,e,r)})),i}Ai([{name:"triangle",components:3,type:"Uint16"}]),Ai([{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"}]),Ai([{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"}]),Ai([{type:"Float32",name:"offsetX"}]),Ai([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),Ai([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);var Fi=24;const zu={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","⋯":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"},dd={10:!0,32:!0,38:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0},md={40:!0};function h0(i,e,r,s,c,p){if("fontStack"in e){const m=r[e.fontStack],v=m&&m[i];return v?v.metrics.advance*e.scale+c:0}{const m=s[e.imageName];return m?m.displaySize[0]*e.scale*Fi/p+c:0}}function p0(i,e,r,s){const c=Math.pow(i-e,2);return s?i<e?c/2:2*c:c+Math.abs(r)*r}function gd(i,e,r){let s=0;return i===10&&(s-=1e4),r&&(s+=150),i!==40&&i!==65288||(s+=50),e!==41&&e!==65289||(s+=50),s}function f0(i,e,r,s,c,p){let m=null,v=p0(e,r,c,p);for(const T of s){const E=p0(e-T.x,r,c,p)+T.badness;E<=v&&(m=T,v=E)}return{index:i,x:e,priorBreak:m,badness:v}}function d0(i){return i?d0(i.priorBreak).concat(i.index):[]}class qA{constructor(e="",r=[],s=[]){this.text=e,this.sections=r,this.sectionIndex=s,this.imageSectionID=null}static fromFeature(e,r){const s=new qA;for(let c=0;c<e.sections.length;c++){const p=e.sections[c];p.image?s.addImageSection(p):s.addTextSection(p,r)}return s}length(){return[...this.text].length}getSection(e){return this.sections[this.sectionIndex[e]]}getSectionIndex(e){return this.sectionIndex[e]}verticalizePunctuation(){this.text=(function(e){let r="",s={premature:!0,value:void 0};const c=e[Symbol.iterator]();let p=c.next();const m=e[Symbol.iterator]();m.next();let v=m.next();for(;!p.done;)r+=!v.done&&oe(v.value.codePointAt(0))&&!zu[v.value]||!s.premature&&oe(s.value.codePointAt(0))&&!zu[s.value]||!zu[p.value]?p.value:zu[p.value],s={value:p.value,premature:!1},p=c.next(),v=m.next();return r})(this.text)}hasZeroWidthSpaces(){return this.text.includes("​")}trim(){const e=this.text.match(/^\s*/),r=e?e[0].length:0,s=this.text.match(/\S\s*$/),c=s?s[0].length-1:0;this.text=this.text.substring(r,this.text.length-c),this.sectionIndex=this.sectionIndex.slice(r,this.sectionIndex.length-c)}substring(e,r){const s=[...this.text].slice(e,r).join(""),c=this.sectionIndex.slice(e,r);return new qA(s,this.sections,c)}toCodeUnitIndex(e){return[...this.text].slice(0,e).join("").length}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((e,r)=>Math.max(e,this.sections[r].scale)),0)}getMaxImageSize(e){let r=0,s=0;for(let c=0;c<this.length();c++){const p=this.getSection(c);if("imageName"in p){const m=e[p.imageName];if(!m)continue;const v=m.displaySize;r=Math.max(r,v[0]),s=Math.max(s,v[1])}}return{maxImageWidth:r,maxImageHeight:s}}addTextSection(e,r){this.text+=e.text,this.sections.push({scale:e.scale||1,verticalAlign:e.verticalAlign||"bottom",fontStack:e.fontStack||r});const s=this.sections.length-1;this.sectionIndex.push(...[...e.text].map((()=>s)))}addImageSection(e){const r=e.image?e.image.name:"";if(r.length===0)return void di("Can't add FormattedSection with an empty image.");const s=this.getNextImageSectionCharCode();s?(this.text+=String.fromCharCode(s),this.sections.push({scale:1,verticalAlign:e.verticalAlign||"bottom",imageName:r}),this.sectionIndex.push(this.sections.length-1)):di("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}determineLineBreaks(e,r,s,c,p){const m=[],v=this.determineAverageLineWidth(e,r,s,c,p),T=this.hasZeroWidthSpaces();let E=0,S=0;const k=this.text[Symbol.iterator]();let R=k.next();const L=this.text[Symbol.iterator]();L.next();let j=L.next();const N=this.text[Symbol.iterator]();N.next(),N.next();let q=N.next();for(;!R.done;){const Y=this.getSection(S),ue=R.value.codePointAt(0);if(P(ue)||(E+=h0(ue,Y,s,c,e,p)),!j.done){const J=x(ue),re=j.value.codePointAt(0);(dd[ue]||J||"imageName"in Y||!q.done&&md[re])&&m.push(f0(S+1,E,v,m,gd(ue,re,J&&T),!1))}S++,R=k.next(),j=L.next(),q=N.next()}return d0(f0(this.length(),E,v,m,0,!0))}determineAverageLineWidth(e,r,s,c,p){let m=0,v=0;for(const T of this.text){const E=this.getSection(v);m+=h0(T.codePointAt(0),E,s,c,e,p),v++}return m/Math.max(1,Math.ceil(m/r))}}const Zc=4294967296,m0=1/Zc,g0=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");class nc{constructor(e=new Uint8Array(16)){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(e,r,s=this.length){for(;this.pos<s;){const c=this.readVarint(),p=c>>3,m=this.pos;this.type=7&c,e(p,r,this),this.pos===m&&this.skip(c)}return r}readMessage(e,r){return this.readFields(e,r,this.readVarint()+this.pos)}readFixed32(){const e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){const e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*Zc;return this.pos+=8,e}readSFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Zc;return this.pos+=8,e}readFloat(){const e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){const e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){const r=this.buf;let s,c;return c=r[this.pos++],s=127&c,c<128?s:(c=r[this.pos++],s|=(127&c)<<7,c<128?s:(c=r[this.pos++],s|=(127&c)<<14,c<128?s:(c=r[this.pos++],s|=(127&c)<<21,c<128?s:(c=r[this.pos],s|=(15&c)<<28,(function(p,m,v){const T=v.buf;let E,S;if(S=T[v.pos++],E=(112&S)>>4,S<128||(S=T[v.pos++],E|=(127&S)<<3,S<128)||(S=T[v.pos++],E|=(127&S)<<10,S<128)||(S=T[v.pos++],E|=(127&S)<<17,S<128)||(S=T[v.pos++],E|=(127&S)<<24,S<128)||(S=T[v.pos++],E|=(1&S)<<31,S<128))return ZA(p,E,m);throw new Error("Expected varint not more than 10 bytes")})(s,e,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const e=this.readVarint();return e%2==1?(e+1)/-2:e/2}readBoolean(){return!!this.readVarint()}readString(){const e=this.readVarint()+this.pos,r=this.pos;return this.pos=e,e-r>=12&&g0?g0.decode(this.buf.subarray(r,e)):(function(s,c,p){let m="",v=c;for(;v<p;){const T=s[v];let E,S,k,R=null,L=T>239?4:T>223?3:T>191?2:1;if(v+L>p)break;L===1?T<128&&(R=T):L===2?(E=s[v+1],(192&E)==128&&(R=(31&T)<<6|63&E,R<=127&&(R=null))):L===3?(E=s[v+1],S=s[v+2],(192&E)==128&&(192&S)==128&&(R=(15&T)<<12|(63&E)<<6|63&S,(R<=2047||R>=55296&&R<=57343)&&(R=null))):L===4&&(E=s[v+1],S=s[v+2],k=s[v+3],(192&E)==128&&(192&S)==128&&(192&k)==128&&(R=(15&T)<<18|(63&E)<<12|(63&S)<<6|63&k,(R<=65535||R>=1114112)&&(R=null))),R===null?(R=65533,L=1):R>65535&&(R-=65536,m+=String.fromCharCode(R>>>10&1023|55296),R=56320|1023&R),m+=String.fromCharCode(R),v+=L}return m})(this.buf,r,e)}readBytes(){const e=this.readVarint()+this.pos,r=this.buf.subarray(this.pos,e);return this.pos=e,r}readPackedVarint(e=[],r){const s=this.readPackedEnd();for(;this.pos<s;)e.push(this.readVarint(r));return e}readPackedSVarint(e=[]){const r=this.readPackedEnd();for(;this.pos<r;)e.push(this.readSVarint());return e}readPackedBoolean(e=[]){const r=this.readPackedEnd();for(;this.pos<r;)e.push(this.readBoolean());return e}readPackedFloat(e=[]){const r=this.readPackedEnd();for(;this.pos<r;)e.push(this.readFloat());return e}readPackedDouble(e=[]){const r=this.readPackedEnd();for(;this.pos<r;)e.push(this.readDouble());return e}readPackedFixed32(e=[]){const r=this.readPackedEnd();for(;this.pos<r;)e.push(this.readFixed32());return e}readPackedSFixed32(e=[]){const r=this.readPackedEnd();for(;this.pos<r;)e.push(this.readSFixed32());return e}readPackedFixed64(e=[]){const r=this.readPackedEnd();for(;this.pos<r;)e.push(this.readFixed64());return e}readPackedSFixed64(e=[]){const r=this.readPackedEnd();for(;this.pos<r;)e.push(this.readSFixed64());return e}readPackedEnd(){return this.type===2?this.readVarint()+this.pos:this.pos+1}skip(e){const r=7&e;if(r===0)for(;this.buf[this.pos++]>127;);else if(r===2)this.pos=this.readVarint()+this.pos;else if(r===5)this.pos+=4;else{if(r!==1)throw new Error(`Unimplemented type: ${r}`);this.pos+=8}}writeTag(e,r){this.writeVarint(e<<3|r)}realloc(e){let r=this.length||16;for(;r<this.pos+e;)r*=2;if(r!==this.length){const s=new Uint8Array(r);s.set(this.buf),this.buf=s,this.dataView=new DataView(s.buffer),this.length=r}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}writeFixed32(e){this.realloc(4),this.dataView.setInt32(this.pos,e,!0),this.pos+=4}writeSFixed32(e){this.realloc(4),this.dataView.setInt32(this.pos,e,!0),this.pos+=4}writeFixed64(e){this.realloc(8),this.dataView.setInt32(this.pos,-1&e,!0),this.dataView.setInt32(this.pos+4,Math.floor(e*m0),!0),this.pos+=8}writeSFixed64(e){this.realloc(8),this.dataView.setInt32(this.pos,-1&e,!0),this.dataView.setInt32(this.pos+4,Math.floor(e*m0),!0),this.pos+=8}writeVarint(e){(e=+e||0)>268435455||e<0?(function(r,s){let c,p;if(r>=0?(c=r%4294967296|0,p=r/4294967296|0):(c=~(-r%4294967296),p=~(-r/4294967296),4294967295^c?c=c+1|0:(c=0,p=p+1|0)),r>=18446744073709552e3||r<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");s.realloc(10),(function(m,v,T){T.buf[T.pos++]=127&m|128,m>>>=7,T.buf[T.pos++]=127&m|128,m>>>=7,T.buf[T.pos++]=127&m|128,m>>>=7,T.buf[T.pos++]=127&m|128,T.buf[T.pos]=127&(m>>>=7)})(c,0,s),(function(m,v){const T=(7&m)<<4;v.buf[v.pos++]|=T|((m>>>=3)?128:0),m&&(v.buf[v.pos++]=127&m|((m>>>=7)?128:0),m&&(v.buf[v.pos++]=127&m|((m>>>=7)?128:0),m&&(v.buf[v.pos++]=127&m|((m>>>=7)?128:0),m&&(v.buf[v.pos++]=127&m|((m>>>=7)?128:0),m&&(v.buf[v.pos++]=127&m)))))})(p,s)})(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))))}writeSVarint(e){this.writeVarint(e<0?2*-e-1:2*e)}writeBoolean(e){this.writeVarint(+e)}writeString(e){e=String(e),this.realloc(4*e.length),this.pos++;const r=this.pos;this.pos=(function(c,p,m){for(let v,T,E=0;E<p.length;E++){if(v=p.charCodeAt(E),v>55295&&v<57344){if(!T){v>56319||E+1===p.length?(c[m++]=239,c[m++]=191,c[m++]=189):T=v;continue}if(v<56320){c[m++]=239,c[m++]=191,c[m++]=189,T=v;continue}v=T-55296<<10|v-56320|65536,T=null}else T&&(c[m++]=239,c[m++]=191,c[m++]=189,T=null);v<128?c[m++]=v:(v<2048?c[m++]=v>>6|192:(v<65536?c[m++]=v>>12|224:(c[m++]=v>>18|240,c[m++]=v>>12&63|128),c[m++]=v>>6&63|128),c[m++]=63&v|128)}return m})(this.buf,e,this.pos);const s=this.pos-r;s>=128&&_0(r,s,this),this.pos=r-1,this.writeVarint(s),this.pos+=s}writeFloat(e){this.realloc(4),this.dataView.setFloat32(this.pos,e,!0),this.pos+=4}writeDouble(e){this.realloc(8),this.dataView.setFloat64(this.pos,e,!0),this.pos+=8}writeBytes(e){const r=e.length;this.writeVarint(r),this.realloc(r);for(let s=0;s<r;s++)this.buf[this.pos++]=e[s]}writeRawMessage(e,r){this.pos++;const s=this.pos;e(r,this);const c=this.pos-s;c>=128&&_0(s,c,this),this.pos=s-1,this.writeVarint(c),this.pos+=c}writeMessage(e,r,s){this.writeTag(e,2),this.writeRawMessage(r,s)}writePackedVarint(e,r){r.length&&this.writeMessage(e,_d,r)}writePackedSVarint(e,r){r.length&&this.writeMessage(e,yd,r)}writePackedBoolean(e,r){r.length&&this.writeMessage(e,bd,r)}writePackedFloat(e,r){r.length&&this.writeMessage(e,vd,r)}writePackedDouble(e,r){r.length&&this.writeMessage(e,xd,r)}writePackedFixed32(e,r){r.length&&this.writeMessage(e,wd,r)}writePackedSFixed32(e,r){r.length&&this.writeMessage(e,Td,r)}writePackedFixed64(e,r){r.length&&this.writeMessage(e,Pd,r)}writePackedSFixed64(e,r){r.length&&this.writeMessage(e,Md,r)}writeBytesField(e,r){this.writeTag(e,2),this.writeBytes(r)}writeFixed32Field(e,r){this.writeTag(e,5),this.writeFixed32(r)}writeSFixed32Field(e,r){this.writeTag(e,5),this.writeSFixed32(r)}writeFixed64Field(e,r){this.writeTag(e,1),this.writeFixed64(r)}writeSFixed64Field(e,r){this.writeTag(e,1),this.writeSFixed64(r)}writeVarintField(e,r){this.writeTag(e,0),this.writeVarint(r)}writeSVarintField(e,r){this.writeTag(e,0),this.writeSVarint(r)}writeStringField(e,r){this.writeTag(e,2),this.writeString(r)}writeFloatField(e,r){this.writeTag(e,5),this.writeFloat(r)}writeDoubleField(e,r){this.writeTag(e,1),this.writeDouble(r)}writeBooleanField(e,r){this.writeVarintField(e,+r)}}function ZA(i,e,r){return r?4294967296*e+(i>>>0):4294967296*(e>>>0)+(i>>>0)}function _0(i,e,r){const s=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));r.realloc(s);for(let c=r.pos-1;c>=i;c--)r.buf[c+s]=r.buf[c]}function _d(i,e){for(let r=0;r<i.length;r++)e.writeVarint(i[r])}function yd(i,e){for(let r=0;r<i.length;r++)e.writeSVarint(i[r])}function vd(i,e){for(let r=0;r<i.length;r++)e.writeFloat(i[r])}function xd(i,e){for(let r=0;r<i.length;r++)e.writeDouble(i[r])}function bd(i,e){for(let r=0;r<i.length;r++)e.writeBoolean(i[r])}function wd(i,e){for(let r=0;r<i.length;r++)e.writeFixed32(i[r])}function Td(i,e){for(let r=0;r<i.length;r++)e.writeSFixed32(i[r])}function Pd(i,e){for(let r=0;r<i.length;r++)e.writeFixed64(i[r])}function Md(i,e){for(let r=0;r<i.length;r++)e.writeSFixed64(i[r])}function Ed(i,e,r){i===1&&r.readMessage(Id,e)}function Id(i,e,r){if(i===3){const{id:s,bitmap:c,width:p,height:m,left:v,top:T,advance:E}=r.readMessage(Sd,{});e.push({id:s,bitmap:new wu({width:p+6,height:m+6},c),metrics:{width:p,height:m,left:v,top:T,advance:E}})}}function Sd(i,e,r){i===1?e.id=r.readVarint():i===2?e.bitmap=r.readBytes():i===3?e.width=r.readVarint():i===4?e.height=r.readVarint():i===5?e.left=r.readSVarint():i===6?e.top=r.readSVarint():i===7&&(e.advance=r.readVarint())}function y0(i){let e=0,r=0;for(const m of i)e+=m.w*m.h,r=Math.max(r,m.w);i.sort(((m,v)=>v.h-m.h));const s=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),r),h:1/0}];let c=0,p=0;for(const m of i)for(let v=s.length-1;v>=0;v--){const T=s[v];if(!(m.w>T.w||m.h>T.h)){if(m.x=T.x,m.y=T.y,p=Math.max(p,m.y+m.h),c=Math.max(c,m.x+m.w),m.w===T.w&&m.h===T.h){const E=s.pop();E&&v<s.length&&(s[v]=E)}else m.h===T.h?(T.x+=m.w,T.w-=m.w):m.w===T.w?(T.y+=m.h,T.h-=m.h):(s.push({x:T.x+m.w,y:T.y,w:T.w-m.w,h:m.h}),T.y+=m.h,T.h-=m.h);break}}return{w:c,h:p,fill:e/(c*p)||0}}class Qc{constructor(e,{pixelRatio:r,version:s,stretchX:c,stretchY:p,content:m,textFitWidth:v,textFitHeight:T}){this.paddedRect=e,this.pixelRatio=r,this.stretchX=c,this.stretchY=p,this.content=m,this.version=s,this.textFitWidth=v,this.textFitHeight=T}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]}get tlbr(){return this.tl.concat(this.br)}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}}class v0{constructor(e,r){const s={},c={};this.haveRenderCallbacks=[];const p=[];this.addImages(e,s,p),this.addImages(r,c,p);const{w:m,h:v}=y0(p),T=new Un({width:m||1,height:v||1});for(const E in e){const S=e[E],k=s[E].paddedRect;Un.copy(S.data,T,{x:0,y:0},{x:k.x+1,y:k.y+1},S.data)}for(const E in r){const S=r[E],k=c[E].paddedRect,R=k.x+1,L=k.y+1,j=S.data.width,N=S.data.height;Un.copy(S.data,T,{x:0,y:0},{x:R,y:L},S.data),Un.copy(S.data,T,{x:0,y:N-1},{x:R,y:L-1},{width:j,height:1}),Un.copy(S.data,T,{x:0,y:0},{x:R,y:L+N},{width:j,height:1}),Un.copy(S.data,T,{x:j-1,y:0},{x:R-1,y:L},{width:1,height:N}),Un.copy(S.data,T,{x:0,y:0},{x:R+j,y:L},{width:1,height:N})}this.image=T,this.iconPositions=s,this.patternPositions=c}addImages(e,r,s){for(const c in e){const p=e[c],m={x:0,y:0,w:p.data.width+2,h:p.data.height+2};s.push(m),r[c]=new Qc(m,p),p.hasRenderCallback&&this.haveRenderCallbacks.push(c)}}patchUpdatedImages(e,r){e.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const s in e.updatedImages)this.patchUpdatedImage(this.iconPositions[s],e.getImage(s),r),this.patchUpdatedImage(this.patternPositions[s],e.getImage(s),r)}patchUpdatedImage(e,r,s){if(!e||!r||e.version===r.version)return;e.version=r.version;const[c,p]=e.tl;s.update(r.data,void 0,{x:c,y:p})}}var il;function sc(i,e,r,s,c,p,m,v,T,E,S,k,R,L,j){const N=qA.fromFeature(i,c);let q;k===G.az.vertical&&N.verticalizePunctuation();let Y=N.determineLineBreaks(E,p,e,s,L);const{processBidirectionalText:ue,processStyledBidirectionalText:J}=Se;if(ue&&N.sections.length===1){q=[],Y=Y.map((ze=>N.toCodeUnitIndex(ze)));const me=ue(N.toString(),Y);for(const ze of me){const He=[...ze].map((()=>0));q.push(new qA(ze,N.sections,He))}}else if(J){q=[],Y=Y.map((Qe=>N.toCodeUnitIndex(Qe)));let me=0;const ze=[];for(const Qe of N.text)ze.push(...Array(Qe.length).fill(N.sectionIndex[me])),me++;const He=J(N.text,ze,Y);for(const Qe of He){const et=[];let pt="";for(const st of Qe[0])et.push(Qe[1][pt.length]),pt+=st;q.push(new qA(Qe[0],N.sections,et))}}else q=(function(me,ze){const He=[];let Qe=0;for(const et of ze)He.push(me.substring(Qe,et)),Qe=et;return Qe<me.length()&&He.push(me.substring(Qe,me.length())),He})(N,Y);const re=[],he={positionedLines:re,text:N.toString(),top:S[1],bottom:S[1],left:S[0],right:S[0],writingMode:k,iconsInText:!1,verticalizable:!1};return(function(me,ze,He,Qe,et,pt,st,$e,Ne,xt,gt,Tt){let mt=0,Ct=0,cr=0,sr=0;const Xr=$e==="right"?1:$e==="left"?0:.5,un=Fi/Tt;let bi=0;for(const vr of et){vr.trim();const ii=vr.getMaxScale(),ci={positionedGlyphs:[],lineOffset:0};me.positionedLines[bi]=ci;const Or=ci.positionedGlyphs;let qn=0;if(!vr.length()){Ct+=pt,++bi;continue}const cn=Cd(Qe,vr,un);let Zn=0;for(const ji of vr.text){const ti=vr.getSection(Zn),wi=ji.codePointAt(0),ni=Dd(Ne,gt,wi),Ni={glyph:wi,imageName:null,x:mt,y:Ct+-17,vertical:ni,scale:1,fontStack:"",sectionIndex:vr.getSectionIndex(Zn),metrics:null,rect:null};let Ba;if("fontStack"in ti){if(Ba=kd(ti,wi,ni,cn,ze,He),!Ba)continue;Ni.fontStack=ti.fontStack}else{if(me.iconsInText=!0,ti.scale*=un,Ba=zd(ti,ni,ii,cn,Qe),!Ba)continue;qn=Math.max(qn,Ba.imageOffset),Ni.imageName=ti.imageName}const{rect:mo,metrics:ju,baselineOffset:ll}=Ba;Ni.y+=ll,Ni.scale=ti.scale,Ni.metrics=ju,Ni.rect=mo,Or.push(Ni),ni?(me.verticalizable=!0,mt+=("imageName"in ti?ju.advance:Fi)*ti.scale+xt):mt+=ju.advance*ti.scale+xt,Zn++}Or.length!==0&&(cr=Math.max(mt-xt,cr),Bd(Or,0,Or.length-1,Xr)),mt=0,ci.lineOffset=Math.max(qn,(ii-1)*Fi);const js=pt*ii+qn;Ct+=js,sr=Math.max(js,sr),++bi}const{horizontalAlign:Yr,verticalAlign:qr}=$c(st);(function(vr,ii,ci,Or,qn,cn,Zn,js,ji){const ti=(ii-ci)*qn;let wi=0;wi=cn!==Zn?-js*Or- -17:-Or*ji*Zn+.5*Zn;for(const ni of vr)for(const Ni of ni.positionedGlyphs)Ni.x+=ti,Ni.y+=wi})(me.positionedLines,Xr,Yr,qr,cr,sr,pt,Ct,et.length),me.top+=-qr*Ct,me.bottom=me.top+Ct,me.left+=-Yr*cr,me.right=me.left+cr})(he,e,r,s,q,m,v,T,k,E,R,j),!(function(me){for(const ze of me)if(ze.positionedGlyphs.length!==0)return!1;return!0})(re)&&he}function $c(i){let e=.5,r=.5;switch(i){case"right":case"top-right":case"bottom-right":e=1;break;case"left":case"top-left":case"bottom-left":e=0}switch(i){case"bottom":case"bottom-right":case"bottom-left":r=1;break;case"top":case"top-right":case"top-left":r=0}return{horizontalAlign:e,verticalAlign:r}}function Cd(i,e,r){const s=e.getMaxScale()*Fi,{maxImageWidth:c,maxImageHeight:p}=e.getMaxImageSize(i),m=Math.max(s,p*r);return{verticalLineContentWidth:Math.max(s,c*r),horizontalLineContentHeight:m}}function x0(i){switch(i){case"top":return 0;case"center":return .5;default:return 1}}function Dd(i,e,r){return!(i===G.az.horizontal||!e&&!w(r)||e&&(P(r)||(s=r,new RegExp("\\p{sc=Arab}","u").test(String.fromCodePoint(s)))));var s}function kd(i,e,r,s,c,p){const m=p[i.fontStack],v=(function(E,S,k,R){if(E&&E.rect)return E;const L=S[k.fontStack],j=L&&L[R];return j?{rect:null,metrics:j.metrics}:null})(m&&m[e],c,i,e);if(v===null)return null;let T;if(r)T=s.verticalLineContentWidth-i.scale*Fi;else{const E=x0(i.verticalAlign);T=(s.horizontalLineContentHeight-i.scale*Fi)*E}return{rect:v.rect,metrics:v.metrics,baselineOffset:T}}function zd(i,e,r,s,c){const p=c[i.imageName];if(!p)return null;const m=p.paddedRect,v=p.displaySize,T={width:v[0],height:v[1],left:1,top:-3,advance:e?v[1]:v[0]};let E;if(e)E=s.verticalLineContentWidth-v[1]*i.scale;else{const S=x0(i.verticalAlign);E=(s.horizontalLineContentHeight-v[1]*i.scale)*S}return{rect:m,metrics:T,baselineOffset:E,imageOffset:(e?v[0]:v[1])*i.scale-Fi*r}}function Bd(i,e,r,s){if(s===0)return;const c=i[r],p=(i[r].x+c.metrics.advance*c.scale)*s;for(let m=e;m<=r;m++)i[m].x-=p}function Rd(i,e,r){const{horizontalAlign:s,verticalAlign:c}=$c(r),p=e[0]-i.displaySize[0]*s,m=e[1]-i.displaySize[1]*c;return{image:i,top:m,bottom:m+i.displaySize[1],left:p,right:p+i.displaySize[0]}}function b0(i){var e,r;let s=i.left,c=i.top,p=i.right-s,m=i.bottom-c;const v=(e=i.image.textFitWidth)!==null&&e!==void 0?e:"stretchOrShrink",T=(r=i.image.textFitHeight)!==null&&r!==void 0?r:"stretchOrShrink",E=(i.image.content[2]-i.image.content[0])/(i.image.content[3]-i.image.content[1]);if(T==="proportional"){if(v==="stretchOnly"&&p/m<E||v==="proportional"){const S=Math.ceil(m*E);s*=S/p,p=S}}else if(v==="proportional"&&T==="stretchOnly"&&E!==0&&p/m>E){const S=Math.ceil(p/E);c*=S/m,m=S}return{x1:s,y1:c,x2:s+p,y2:c+m}}function w0(i,e,r,s,c,p){const m=i.image;let v;if(m.content){const q=m.content,Y=m.pixelRatio||1;v=[q[0]/Y,q[1]/Y,m.displaySize[0]-q[2]/Y,m.displaySize[1]-q[3]/Y]}const T=e.left*p,E=e.right*p;let S,k,R,L;r==="width"||r==="both"?(L=c[0]+T-s[3],k=c[0]+E+s[1]):(L=c[0]+(T+E-m.displaySize[0])/2,k=L+m.displaySize[0]);const j=e.top*p,N=e.bottom*p;return r==="height"||r==="both"?(S=c[1]+j-s[0],R=c[1]+N+s[2]):(S=c[1]+(j+N-m.displaySize[1])/2,R=S+m.displaySize[1]),{image:m,top:S,right:k,bottom:R,left:L,collisionPadding:v}}yt("ImagePosition",Qc),yt("ImageAtlas",v0),G.az=void 0,(il=G.az||(G.az={}))[il.none=0]="none",il[il.horizontal=1]="horizontal",il[il.vertical=2]="vertical",il[il.horizontalOnly=3]="horizontalOnly";const ka=128,nl=32640;function T0(i,e){const{expression:r}=e;if(r.kind==="constant")return{kind:"constant",layoutSize:r.evaluate(new Pe(i+1))};if(r.kind==="source")return{kind:"source"};{const{zoomStops:s,interpolationType:c}=r;let p=0;for(;p<s.length&&s[p]<=i;)p++;p=Math.max(0,p-1);let m=p;for(;m<s.length&&s[m]<i+1;)m++;m=Math.min(s.length-1,m);const v=s[p],T=s[m];return r.kind==="composite"?{kind:"composite",minZoom:v,maxZoom:T,interpolationType:c}:{kind:"camera",minZoom:v,maxZoom:T,minSize:r.evaluate(new Pe(v)),maxSize:r.evaluate(new Pe(T)),interpolationType:c}}}function Wc(i,e,r){let s="never";const c=i.get(e);return c?s=c:i.get(r)&&(s="always"),s}const Ld=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function oc(i,e,r,s,c,p,m,v,T,E,S,k,R){const L=v?Math.min(nl,Math.round(v[0])):0,j=v?Math.min(nl,Math.round(v[1])):0;i.emplaceBack(e,r,Math.round(32*s),Math.round(32*c),p,m,(L<<1)+(T?1:0),j,16*E,16*S,256*k,256*R)}function Hc(i,e,r){i.emplaceBack(e.x,e.y,r),i.emplaceBack(e.x,e.y,r),i.emplaceBack(e.x,e.y,r),i.emplaceBack(e.x,e.y,r)}function Fd(i){for(const e of i.sections)if(Ue(e.text))return!0;return!1}class Xc{constructor(e){this.layoutVertexArray=new fe,this.indexArray=new Ve,this.programConfigurations=e,this.segments=new ft,this.dynamicLayoutVertexArray=new Me,this.opacityVertexArray=new Ge,this.hasVisibleVertices=!1,this.placedSymbolArray=new b}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0}upload(e,r,s,c){this.isEmpty()||(s&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,ud.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,r),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,cd.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,Ld,!0),this.opacityVertexBuffer.itemSize=1),(s||c)&&this.programConfigurations.upload(e))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}yt("SymbolBuffers",Xc);class Yc{constructor(e,r,s){this.layoutVertexArray=new e,this.layoutAttributes=r,this.indexArray=new s,this.segments=new ft,this.collisionVertexArray=new Oe}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,hd.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}}yt("CollisionBuffers",Yc);class QA{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((m=>m.id)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasDependencies=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=T0(this.zoom,r["text-size"]),this.iconSizeData=T0(this.zoom,r["icon-size"]);const s=this.layers[0].layout,c=s.get("symbol-sort-key"),p=s.get("symbol-z-order");this.canOverlap=Wc(s,"text-overlap","text-allow-overlap")!=="never"||Wc(s,"icon-overlap","icon-allow-overlap")!=="never"||s.get("text-ignore-placement")||s.get("icon-ignore-placement"),this.sortFeaturesByKey=p!=="viewport-y"&&!c.isConstant(),this.sortFeaturesByY=(p==="viewport-y"||p==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,s.get("symbol-placement")==="point"&&(this.writingModes=s.get("text-writing-mode").map((m=>G.az[m]))),this.stateDependentLayerIds=this.layers.filter((m=>m.isStateDependent())).map((m=>m.id)),this.sourceID=e.sourceID}createArrays(){this.text=new Xc(new Da(this.layers,this.zoom,(e=>/^text/.test(e)))),this.icon=new Xc(new Da(this.layers,this.zoom,(e=>/^icon/.test(e)))),this.glyphOffsetArray=new D,this.lineVertexArray=new B,this.symbolInstances=new I,this.textAnchorOffsets=new O}calculateGlyphDependencies(e,r,s,c,p){for(const m of e)if(r[m.codePointAt(0)]=!0,(s||c)&&p){const v=zu[m];v&&(r[v.codePointAt(0)]=!0)}}populate(e,r,s){const c=this.layers[0],p=c.layout,m=p.get("text-font"),v=p.get("text-field"),T=p.get("icon-image"),E=(v.value.kind!=="constant"||v.value.value instanceof en&&!v.value.value.isEmpty()||v.value.value.toString().length>0)&&(m.value.kind!=="constant"||m.value.value.length>0),S=T.value.kind!=="constant"||!!T.value.value||Object.keys(T.parameters).length>0,k=p.get("symbol-sort-key");if(this.features=[],!E&&!S)return;const R=r.iconDependencies,L=r.glyphDependencies,j=r.availableImages,N=new Pe(this.zoom);for(const{feature:q,id:Y,index:ue,sourceLayerIndex:J}of e){const re=c._featureFilter.needGeometry,he=Jo(q,re);if(!c._featureFilter.filter(N,he,s))continue;let me,ze;if(re||(he.geometry=Ko(q)),E){const Qe=c.getValueAndResolveTokens("text-field",he,s,j),et=en.factory(Qe),pt=this.hasRTLText=this.hasRTLText||Fd(et);(!pt||Se.getRTLTextPluginStatus()==="unavailable"||pt&&Se.isParsed())&&(me=fd(et,c,he))}if(S){const Qe=c.getValueAndResolveTokens("icon-image",he,s,j);ze=Qe instanceof tn?Qe:tn.fromString(Qe)}if(!me&&!ze)continue;const He=this.sortFeaturesByKey?k.evaluate(he,{},s):void 0;if(this.features.push({id:Y,text:me,icon:ze,index:ue,sourceLayerIndex:J,geometry:he.geometry,properties:q.properties,type:Cu.types[q.type],sortKey:He}),ze&&(R[ze.name]=!0),me){const Qe=m.evaluate(he,{},s).join(","),et=p.get("text-rotation-alignment")!=="viewport"&&p.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(G.az.vertical)>=0;for(const pt of me.sections)if(pt.image)R[pt.image.name]=!0;else{const st=C(me.toString()),$e=pt.fontStack||Qe,Ne=L[$e]=L[$e]||{};this.calculateGlyphDependencies(pt.text,Ne,et,this.allowVerticalPlacement,st)}}}p.get("symbol-placement")==="line"&&(this.features=(function(q){const Y={},ue={},J=[];let re=0;function he(Qe){J.push(q[Qe]),re++}function me(Qe,et,pt){const st=ue[Qe];return delete ue[Qe],ue[et]=st,J[st].geometry[0].pop(),J[st].geometry[0]=J[st].geometry[0].concat(pt[0]),st}function ze(Qe,et,pt){const st=Y[et];return delete Y[et],Y[Qe]=st,J[st].geometry[0].shift(),J[st].geometry[0]=pt[0].concat(J[st].geometry[0]),st}function He(Qe,et,pt){const st=pt?et[0][et[0].length-1]:et[0][0];return`${Qe}:${st.x}:${st.y}`}for(let Qe=0;Qe<q.length;Qe++){const et=q[Qe],pt=et.geometry,st=et.text?et.text.toString():null;if(!st){he(Qe);continue}const $e=He(st,pt),Ne=He(st,pt,!0);if($e in ue&&Ne in Y&&ue[$e]!==Y[Ne]){const xt=ze($e,Ne,pt),gt=me($e,Ne,J[xt].geometry);delete Y[$e],delete ue[Ne],ue[He(st,J[gt].geometry,!0)]=gt,J[xt].geometry=null}else $e in ue?me($e,Ne,pt):Ne in Y?ze($e,Ne,pt):(he(Qe),Y[$e]=re-1,ue[Ne]=re-1)}return J.filter((Qe=>Qe.geometry))})(this.features)),this.sortFeaturesByKey&&this.features.sort(((q,Y)=>q.sortKey-Y.sortKey))}update(e,r,s){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,r,this.layers,{imagePositions:s}),this.icon.programConfigurations.updatePaintArrays(e,r,this.layers,{imagePositions:s}))}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,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(e,r){const s=this.lineVertexArray.length;if(e.segment!==void 0){let c=e.dist(r[e.segment+1]),p=e.dist(r[e.segment]);const m={};for(let v=e.segment+1;v<r.length;v++)m[v]={x:r[v].x,y:r[v].y,tileUnitDistanceFromAnchor:c},v<r.length-1&&(c+=r[v+1].dist(r[v]));for(let v=e.segment||0;v>=0;v--)m[v]={x:r[v].x,y:r[v].y,tileUnitDistanceFromAnchor:p},v>0&&(p+=r[v-1].dist(r[v]));for(let v=0;v<r.length;v++){const T=m[v];this.lineVertexArray.emplaceBack(T.x,T.y,T.tileUnitDistanceFromAnchor)}}return{lineStartIndex:s,lineLength:this.lineVertexArray.length-s}}addSymbols(e,r,s,c,p,m,v,T,E,S,k,R){const L=e.indexArray,j=e.layoutVertexArray,N=e.segments.prepareSegment(4*r.length,j,L,this.canOverlap?m.sortKey:void 0),q=this.glyphOffsetArray.length,Y=N.vertexLength,ue=this.allowVerticalPlacement&&v===G.az.vertical?Math.PI/2:0,J=m.text&&m.text.sections;for(let re=0;re<r.length;re++){const{tl:he,tr:me,bl:ze,br:He,tex:Qe,pixelOffsetTL:et,pixelOffsetBR:pt,minFontScaleX:st,minFontScaleY:$e,glyphOffset:Ne,isSDF:xt,sectionIndex:gt}=r[re],Tt=N.vertexLength,mt=Ne[1];oc(j,T.x,T.y,he.x,mt+he.y,Qe.x,Qe.y,s,xt,et.x,et.y,st,$e),oc(j,T.x,T.y,me.x,mt+me.y,Qe.x+Qe.w,Qe.y,s,xt,pt.x,et.y,st,$e),oc(j,T.x,T.y,ze.x,mt+ze.y,Qe.x,Qe.y+Qe.h,s,xt,et.x,pt.y,st,$e),oc(j,T.x,T.y,He.x,mt+He.y,Qe.x+Qe.w,Qe.y+Qe.h,s,xt,pt.x,pt.y,st,$e),Hc(e.dynamicLayoutVertexArray,T,ue),L.emplaceBack(Tt,Tt+2,Tt+1),L.emplaceBack(Tt+1,Tt+2,Tt+3),N.vertexLength+=4,N.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(Ne[0]),re!==r.length-1&&gt===r[re+1].sectionIndex||e.programConfigurations.populatePaintArrays(j.length,m,m.index,{imagePositions:{},canonical:R,formattedSection:J&&J[gt]})}e.placedSymbolArray.emplaceBack(T.x,T.y,q,this.glyphOffsetArray.length-q,Y,E,S,T.segment,s?s[0]:0,s?s[1]:0,c[0],c[1],v,0,!1,0,k)}_addCollisionDebugVertex(e,r,s,c,p,m){return r.emplaceBack(0,0),e.emplaceBack(s.x,s.y,c,p,Math.round(m.x),Math.round(m.y))}addCollisionDebugVertices(e,r,s,c,p,m,v){const T=p.segments.prepareSegment(4,p.layoutVertexArray,p.indexArray),E=T.vertexLength,S=p.layoutVertexArray,k=p.collisionVertexArray,R=v.anchorX,L=v.anchorY;this._addCollisionDebugVertex(S,k,m,R,L,new nt(e,r)),this._addCollisionDebugVertex(S,k,m,R,L,new nt(s,r)),this._addCollisionDebugVertex(S,k,m,R,L,new nt(s,c)),this._addCollisionDebugVertex(S,k,m,R,L,new nt(e,c)),T.vertexLength+=4;const j=p.indexArray;j.emplaceBack(E,E+1),j.emplaceBack(E+1,E+2),j.emplaceBack(E+2,E+3),j.emplaceBack(E+3,E),T.primitiveLength+=4}addDebugCollisionBoxes(e,r,s,c){for(let p=e;p<r;p++){const m=this.collisionBoxArray.get(p);this.addCollisionDebugVertices(m.x1,m.y1,m.x2,m.y2,c?this.textCollisionBox:this.iconCollisionBox,m.anchorPoint,s)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new Yc(Fe,c0.members,ut),this.iconCollisionBox=new Yc(Fe,c0.members,ut);for(let e=0;e<this.symbolInstances.length;e++){const r=this.symbolInstances.get(e);this.addDebugCollisionBoxes(r.textBoxStartIndex,r.textBoxEndIndex,r,!0),this.addDebugCollisionBoxes(r.verticalTextBoxStartIndex,r.verticalTextBoxEndIndex,r,!0),this.addDebugCollisionBoxes(r.iconBoxStartIndex,r.iconBoxEndIndex,r,!1),this.addDebugCollisionBoxes(r.verticalIconBoxStartIndex,r.verticalIconBoxEndIndex,r,!1)}}_deserializeCollisionBoxesForSymbol(e,r,s,c,p,m,v,T,E){const S={};for(let k=r;k<s;k++){const R=e.get(k);S.textBox={x1:R.x1,y1:R.y1,x2:R.x2,y2:R.y2,anchorPointX:R.anchorPointX,anchorPointY:R.anchorPointY},S.textFeatureIndex=R.featureIndex;break}for(let k=c;k<p;k++){const R=e.get(k);S.verticalTextBox={x1:R.x1,y1:R.y1,x2:R.x2,y2:R.y2,anchorPointX:R.anchorPointX,anchorPointY:R.anchorPointY},S.verticalTextFeatureIndex=R.featureIndex;break}for(let k=m;k<v;k++){const R=e.get(k);S.iconBox={x1:R.x1,y1:R.y1,x2:R.x2,y2:R.y2,anchorPointX:R.anchorPointX,anchorPointY:R.anchorPointY},S.iconFeatureIndex=R.featureIndex;break}for(let k=T;k<E;k++){const R=e.get(k);S.verticalIconBox={x1:R.x1,y1:R.y1,x2:R.x2,y2:R.y2,anchorPointX:R.anchorPointX,anchorPointY:R.anchorPointY},S.verticalIconFeatureIndex=R.featureIndex;break}return S}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let r=0;r<this.symbolInstances.length;r++){const s=this.symbolInstances.get(r);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(e,s.textBoxStartIndex,s.textBoxEndIndex,s.verticalTextBoxStartIndex,s.verticalTextBoxEndIndex,s.iconBoxStartIndex,s.iconBoxEndIndex,s.verticalIconBoxStartIndex,s.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(e,r){const s=e.placedSymbolArray.get(r),c=s.vertexStartIndex+4*s.numGlyphs;for(let p=s.vertexStartIndex;p<c;p+=4)e.indexArray.emplaceBack(p,p+2,p+1),e.indexArray.emplaceBack(p+1,p+2,p+3)}getSortedSymbolIndexes(e){if(this.sortedAngle===e&&this.symbolInstanceIndexes!==void 0)return this.symbolInstanceIndexes;const r=Math.sin(e),s=Math.cos(e),c=[],p=[],m=[];for(let v=0;v<this.symbolInstances.length;++v){m.push(v);const T=this.symbolInstances.get(v);c.push(0|Math.round(r*T.anchorX+s*T.anchorY)),p.push(T.featureIndex)}return m.sort(((v,T)=>c[v]-c[T]||p[T]-p[v])),m}addToSortKeyRanges(e,r){const s=this.sortKeyRanges[this.sortKeyRanges.length-1];s&&s.sortKey===r?s.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:r,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const r of this.symbolInstanceIndexes){const s=this.symbolInstances.get(r);this.featureSortOrder.push(s.featureIndex),[s.rightJustifiedTextSymbolIndex,s.centerJustifiedTextSymbolIndex,s.leftJustifiedTextSymbolIndex].forEach(((c,p,m)=>{c>=0&&m.indexOf(c)===p&&this.addIndicesForPlacedSymbol(this.text,c)})),s.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,s.verticalPlacedTextSymbolIndex),s.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,s.placedIconSymbolIndex),s.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,s.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let P0,M0;yt("SymbolBucket",QA,{omit:["layers","collisionBoxArray","features","compareText"]}),QA.MAX_GLYPHS=65535,QA.addDynamicAttributes=Hc;var Kc={get paint(){return M0=M0||new Ri({"icon-opacity":new dt(Le.paint_symbol["icon-opacity"]),"icon-color":new dt(Le.paint_symbol["icon-color"]),"icon-halo-color":new dt(Le.paint_symbol["icon-halo-color"]),"icon-halo-width":new dt(Le.paint_symbol["icon-halo-width"]),"icon-halo-blur":new dt(Le.paint_symbol["icon-halo-blur"]),"icon-translate":new at(Le.paint_symbol["icon-translate"]),"icon-translate-anchor":new at(Le.paint_symbol["icon-translate-anchor"]),"text-opacity":new dt(Le.paint_symbol["text-opacity"]),"text-color":new dt(Le.paint_symbol["text-color"],{runtimeType:Jt,getOverride:i=>i.textColor,hasOverride:i=>!!i.textColor}),"text-halo-color":new dt(Le.paint_symbol["text-halo-color"]),"text-halo-width":new dt(Le.paint_symbol["text-halo-width"]),"text-halo-blur":new dt(Le.paint_symbol["text-halo-blur"]),"text-translate":new at(Le.paint_symbol["text-translate"]),"text-translate-anchor":new at(Le.paint_symbol["text-translate-anchor"])})},get layout(){return P0=P0||new Ri({"symbol-placement":new at(Le.layout_symbol["symbol-placement"]),"symbol-spacing":new at(Le.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new at(Le.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new dt(Le.layout_symbol["symbol-sort-key"]),"symbol-z-order":new at(Le.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new at(Le.layout_symbol["icon-allow-overlap"]),"icon-overlap":new at(Le.layout_symbol["icon-overlap"]),"icon-ignore-placement":new at(Le.layout_symbol["icon-ignore-placement"]),"icon-optional":new at(Le.layout_symbol["icon-optional"]),"icon-rotation-alignment":new at(Le.layout_symbol["icon-rotation-alignment"]),"icon-size":new dt(Le.layout_symbol["icon-size"]),"icon-text-fit":new at(Le.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new at(Le.layout_symbol["icon-text-fit-padding"]),"icon-image":new dt(Le.layout_symbol["icon-image"]),"icon-rotate":new dt(Le.layout_symbol["icon-rotate"]),"icon-padding":new dt(Le.layout_symbol["icon-padding"]),"icon-keep-upright":new at(Le.layout_symbol["icon-keep-upright"]),"icon-offset":new dt(Le.layout_symbol["icon-offset"]),"icon-anchor":new dt(Le.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new at(Le.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new at(Le.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new at(Le.layout_symbol["text-rotation-alignment"]),"text-field":new dt(Le.layout_symbol["text-field"]),"text-font":new dt(Le.layout_symbol["text-font"]),"text-size":new dt(Le.layout_symbol["text-size"]),"text-max-width":new dt(Le.layout_symbol["text-max-width"]),"text-line-height":new at(Le.layout_symbol["text-line-height"]),"text-letter-spacing":new dt(Le.layout_symbol["text-letter-spacing"]),"text-justify":new dt(Le.layout_symbol["text-justify"]),"text-radial-offset":new dt(Le.layout_symbol["text-radial-offset"]),"text-variable-anchor":new at(Le.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new dt(Le.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new dt(Le.layout_symbol["text-anchor"]),"text-max-angle":new at(Le.layout_symbol["text-max-angle"]),"text-writing-mode":new at(Le.layout_symbol["text-writing-mode"]),"text-rotate":new dt(Le.layout_symbol["text-rotate"]),"text-padding":new at(Le.layout_symbol["text-padding"]),"text-keep-upright":new at(Le.layout_symbol["text-keep-upright"]),"text-transform":new dt(Le.layout_symbol["text-transform"]),"text-offset":new dt(Le.layout_symbol["text-offset"]),"text-allow-overlap":new at(Le.layout_symbol["text-allow-overlap"]),"text-overlap":new at(Le.layout_symbol["text-overlap"]),"text-ignore-placement":new at(Le.layout_symbol["text-ignore-placement"]),"text-optional":new at(Le.layout_symbol["text-optional"])})}};class E0{constructor(e){if(e.property.overrides===void 0)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=e.property.overrides?e.property.overrides.runtimeType:br,this.defaultValue=e}evaluate(e){if(e.formattedSection){const r=this.defaultValue.property.overrides;if(r&&r.hasOverride(e.formattedSection))return r.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}yt("FormatSectionOverride",E0,{omit:["defaultValue"]});class ac extends es{constructor(e,r){super(e,Kc,r)}recalculate(e,r){if(super.recalculate(e,r),this.layout.get("icon-rotation-alignment")==="auto"&&(this.layout._values["icon-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-rotation-alignment")==="auto"&&(this.layout._values["text-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-pitch-alignment")==="auto"&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")==="map"?"map":"viewport"),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),this.layout.get("symbol-placement")==="point"){const s=this.layout.get("text-writing-mode");if(s){const c=[];for(const p of s)c.indexOf(p)<0&&c.push(p);this.layout._values["text-writing-mode"]=c}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(e,r,s,c){const p=this.layout.get(e).evaluate(r,{},s,c),m=this._unevaluatedLayout._values[e];return m.isDataDriven()||yn(m.value)||!p?p:(function(v,T){return T.replace(/{([^{}]+)}/g,((E,S)=>v&&S in v?String(v[S]):""))})(r.properties,p)}createBucket(e){return new QA(e)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const e of Kc.paint.overridableProperties){if(!ac.hasPaintOverride(this.layout,e))continue;const r=this.paint.get(e),s=new E0(r),c=new Ml(s,r.property.specification);let p=null;p=r.value.kind==="constant"||r.value.kind==="source"?new $a("source",c):new Zo("composite",c,r.value.zoomStops),this.paint._values[e]=new Et(r.property,p,r.parameters)}}_handleOverridablePaintPropertyUpdate(e,r,s){return!(!this.layout||r.isDataDriven()||s.isDataDriven())&&ac.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,r){const s=e.get("text-field"),c=Kc.paint.properties[r];let p=!1;const m=v=>{for(const T of v)if(c.overrides&&c.overrides.hasOverride(T))return void(p=!0)};if(s.value.kind==="constant"&&s.value.value instanceof en)m(s.value.value.sections);else if(s.value.kind==="source"||s.value.kind==="composite"){const v=E=>{p||(E instanceof On&&Kr(E.value)===Xs?m(E.value.sections):E instanceof fa?m(E.sections):E.eachChild(v))},T=s.value;T._styleExpression&&v(T._styleExpression.expression)}return p}}let I0;var Od={get paint(){return I0=I0||new Ri({"background-color":new at(Le.paint_background["background-color"]),"background-pattern":new fr(Le.paint_background["background-pattern"]),"background-opacity":new at(Le.paint_background["background-opacity"])})}};class Vd extends es{constructor(e,r){super(e,Od,r)}}class jd extends es{constructor(e,r){super(e,{},r),this.onAdd=s=>{this.implementation.onAdd&&this.implementation.onAdd(s,s.painter.context.gl)},this.onRemove=s=>{this.implementation.onRemove&&this.implementation.onRemove(s,s.painter.context.gl)},this.implementation=e}is3D(){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}class Nd{constructor(e){this._methodToThrottle=e,this._triggered=!1,typeof MessageChannel<"u"&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._methodToThrottle()}),0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}}const Gd={once:!0},Jc=63710088e-1;class sl{constructor(e,r){if(isNaN(e)||isNaN(r))throw new Error(`Invalid LngLat object: (${e}, ${r})`);if(this.lng=+e,this.lat=+r,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new sl(as(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const r=Math.PI/180,s=this.lat*r,c=e.lat*r,p=Math.sin(s)*Math.sin(c)+Math.cos(s)*Math.cos(c)*Math.cos((e.lng-this.lng)*r);return Jc*Math.acos(Math.min(p,1))}static convert(e){if(e instanceof sl)return e;if(Array.isArray(e)&&(e.length===2||e.length===3))return new sl(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e=="object"&&e!==null)return new sl(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}const S0=2*Math.PI*Jc;function C0(i){return S0*Math.cos(i*Math.PI/180)}function D0(i){return(180+i)/360}function k0(i){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i*Math.PI/360)))/360}function z0(i,e){return i/C0(e)}function B0(i){return 360*i-180}function lc(i){return 360/Math.PI*Math.atan(Math.exp((180-360*i)*Math.PI/180))-90}function R0(i,e){return i*C0(lc(e))}class Bu{constructor(e,r,s=0){this.x=+e,this.y=+r,this.z=+s}static fromLngLat(e,r=0){const s=sl.convert(e);return new Bu(D0(s.lng),k0(s.lat),z0(r,s.lat))}toLngLat(){return new sl(B0(this.x),lc(this.y))}toAltitude(){return R0(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/S0*(e=lc(this.y),1/Math.cos(e*Math.PI/180));var e}}function L0(i,e,r){var s=2*Math.PI*6378137/256/Math.pow(2,r);return[i*s-2*Math.PI*6378137/2,e*s-2*Math.PI*6378137/2]}class eh{constructor(e,r,s){if(!(function(c,p,m){return!(c<0||c>25||m<0||m>=Math.pow(2,c)||p<0||p>=Math.pow(2,c))})(e,r,s))throw new Error(`x=${r}, y=${s}, z=${e} outside of bounds. 0<=x<${Math.pow(2,e)}, 0<=y<${Math.pow(2,e)} 0<=z<=25 `);this.z=e,this.x=r,this.y=s,this.key=$A(0,e,e,r,s)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,r,s){const c=(function(m,v,T){var E=L0(256*m,256*(v=Math.pow(2,T)-v-1),T),S=L0(256*(m+1),256*(v+1),T);return E[0]+","+E[1]+","+S[0]+","+S[1]})(this.x,this.y,this.z),p=(function(m,v,T){let E,S="";for(let k=m;k>0;k--)E=1<<k-1,S+=(v&E?1:0)+(T&E?2:0);return S})(this.z,this.x,this.y);return e[(this.x+this.y)%e.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(s==="tms"?Math.pow(2,this.z)-this.y-1:this.y)).replace(/{ratio}/g,r>1?"@2x":"").replace(/{quadkey}/g,p).replace(/{bbox-epsg-3857}/g,c)}isChildOf(e){const r=this.z-e.z;return r>0&&e.x===this.x>>r&&e.y===this.y>>r}getTilePoint(e){const r=Math.pow(2,this.z);return new nt((e.x*r-this.x)*dr,(e.y*r-this.y)*dr)}toString(){return`${this.z}/${this.x}/${this.y}`}}class F0{constructor(e,r){this.wrap=e,this.canonical=r,this.key=$A(e,r.z,r.z,r.x,r.y)}}class _s{constructor(e,r,s,c,p){if(this.terrainRttPosMatrix32f=null,e<s)throw new Error(`overscaledZ should be >= z; overscaledZ = ${e}; z = ${s}`);this.overscaledZ=e,this.wrap=r,this.canonical=new eh(s,+c,+p),this.key=$A(r,e,s,c,p)}clone(){return new _s(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const r=this.canonical.z-e;return e>this.canonical.z?new _s(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new _s(e,this.wrap,e,this.canonical.x>>r,this.canonical.y>>r)}isOverscaled(){return this.overscaledZ>this.canonical.z}calculateScaledKey(e,r){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const s=this.canonical.z-e;return e>this.canonical.z?$A(this.wrap*+r,e,this.canonical.z,this.canonical.x,this.canonical.y):$A(this.wrap*+r,e,e,this.canonical.x>>s,this.canonical.y>>s)}isChildOf(e){if(e.wrap!==this.wrap||this.overscaledZ-e.overscaledZ<=0)return!1;if(e.overscaledZ===0)return this.overscaledZ>0;const r=this.canonical.z-e.canonical.z;return!(r<0)&&e.canonical.x===this.canonical.x>>r&&e.canonical.y===this.canonical.y>>r}children(e){if(this.overscaledZ>=e)return[new _s(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const r=this.canonical.z+1,s=2*this.canonical.x,c=2*this.canonical.y;return[new _s(r,this.wrap,r,s,c),new _s(r,this.wrap,r,s+1,c),new _s(r,this.wrap,r,s,c+1),new _s(r,this.wrap,r,s+1,c+1)]}isLessThan(e){return this.wrap<e.wrap||!(this.wrap>e.wrap)&&(this.overscaledZ<e.overscaledZ||!(this.overscaledZ>e.overscaledZ)&&(this.canonical.x<e.canonical.x||!(this.canonical.x>e.canonical.x)&&this.canonical.y<e.canonical.y))}wrapped(){return new _s(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new _s(this.overscaledZ,e,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new F0(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(e){return this.canonical.getTilePoint(new Bu(e.x-this.wrap,e.y))}}function $A(i,e,r,s,c){(i*=2)<0&&(i=-1*i-1);const p=1<<r;return(p*p*i+p*c+s).toString(36)+r.toString(36)+e.toString(36)}function th(i,e){return e?i.properties[e]:i.id}function Ud(i,e){const r={id:i.id};if(e.removeAllProperties&&(delete i.removeProperties,delete i.addOrUpdateProperties,delete e.removeProperties),e.removeProperties)for(const s of e.removeProperties){const c=i.addOrUpdateProperties.findIndex((p=>p.key===s));c>-1&&i.addOrUpdateProperties.splice(c,1)}return(i.removeAllProperties||e.removeAllProperties)&&(r.removeAllProperties=!0),(i.removeProperties||e.removeProperties)&&(r.removeProperties=[...i.removeProperties||[],...e.removeProperties||[]]),(i.addOrUpdateProperties||e.addOrUpdateProperties)&&(r.addOrUpdateProperties=[...i.addOrUpdateProperties||[],...e.addOrUpdateProperties||[]]),(i.newGeometry||e.newGeometry)&&(r.newGeometry=e.newGeometry||i.newGeometry),r}function O0(i){var e,r;if(!i)return{};const s={};return s.removeAll=i.removeAll,s.remove=new Set(i.remove||[]),s.add=new Map((e=i.add)===null||e===void 0?void 0:e.map((c=>[c.id,c]))),s.update=new Map((r=i.update)===null||r===void 0?void 0:r.map((c=>[c.id,c]))),s}yt("CanonicalTileID",eh),yt("OverscaledTileID",_s,{omit:["terrainRttPosMatrix32f"]});class ql{constructor(){this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0}extend(e){return this.minX=Math.min(this.minX,e.x),this.minY=Math.min(this.minY,e.y),this.maxX=Math.max(this.maxX,e.x),this.maxY=Math.max(this.maxY,e.y),this}expandBy(e){return this.minX-=e,this.minY-=e,this.maxX+=e,this.maxY+=e,(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(e){return this.expandBy(-e)}map(e){const r=new ql;return r.extend(e(new nt(this.minX,this.minY))),r.extend(e(new nt(this.maxX,this.minY))),r.extend(e(new nt(this.minX,this.maxY))),r.extend(e(new nt(this.maxX,this.maxY))),r}static fromPoints(e){const r=new ql;for(const s of e)r.extend(s);return r}contains(e){return e.x>=this.minX&&e.x<=this.maxX&&e.y>=this.minY&&e.y<=this.maxY}empty(){return this.minX>this.maxX}width(){return this.maxX-this.minX}height(){return this.maxY-this.minY}covers(e){return!this.empty()&&!e.empty()&&e.minX>=this.minX&&e.maxX<=this.maxX&&e.minY>=this.minY&&e.maxY<=this.maxY}intersects(e){return!this.empty()&&!e.empty()&&e.minX<=this.maxX&&e.maxX>=this.minX&&e.minY<=this.maxY&&e.maxY>=this.minY}}class V0{constructor(e){this._stringToNumber={},this._numberToString=[];for(let r=0;r<e.length;r++){const s=e[r];this._stringToNumber[s]=r,this._numberToString[r]=s}}encode(e){return this._stringToNumber[e]}decode(e){if(e>=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${e} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[e]}}class j0{constructor(e,r,s,c,p){this.type="Feature",this._vectorTileFeature=e,this._x=s,this._y=c,this._z=r,this.properties=e.properties,this.id=p}projectPoint(e,r,s,c){return[360*(e.x+r)/c-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+s)/c)*Math.PI))-90]}projectLine(e,r,s,c){return e.map((p=>this.projectPoint(p,r,s,c)))}get geometry(){if(this._geometry)return this._geometry;const e=this._vectorTileFeature,r=e.extent*Math.pow(2,this._z),s=e.extent*this._x,c=e.extent*this._y,p=e.loadGeometry();switch(e.type){case 1:{const m=[];for(const T of p)m.push(T[0]);const v=this.projectLine(m,s,c,r);this._geometry=m.length===1?{type:"Point",coordinates:v[0]}:{type:"MultiPoint",coordinates:v};break}case 2:{const m=p.map((v=>this.projectLine(v,s,c,r)));this._geometry=m.length===1?{type:"LineString",coordinates:m[0]}:{type:"MultiLineString",coordinates:m};break}case 3:{const m=t0(p),v=[];for(const T of m)v.push(T.map((E=>this.projectLine(E,s,c,r))));this._geometry=v.length===1?{type:"Polygon",coordinates:v[0]}:{type:"MultiPolygon",coordinates:v};break}default:throw new Error(`unknown feature type: ${e.type}`)}return this._geometry}set geometry(e){this._geometry=e}toJSON(){const e={geometry:this.geometry};for(const r in this)r!=="_geometry"&&r!=="_vectorTileFeature"&&r!=="_x"&&r!=="_y"&&r!=="_z"&&(e[r]=this[r]);return e}}class WA{constructor(e,r,s){er(this,"_name");er(this,"dataBuffer");er(this,"nullabilityBuffer");er(this,"_size");this._name=e,this.dataBuffer=r,typeof s=="number"?this._size=s:(this.nullabilityBuffer=s,this._size=s.size())}getValue(e){return this.nullabilityBuffer&&!this.nullabilityBuffer.get(e)?null:this.getValueFromBuffer(e)}has(e){return this.nullabilityBuffer&&this.nullabilityBuffer.get(e)||!this.nullabilityBuffer}get name(){return this._name}get size(){return this._size}}class Ac extends WA{}class rh extends Ac{getValueFromBuffer(e){return this.dataBuffer[e]}}class ih extends Ac{getValueFromBuffer(e){return this.dataBuffer[e]}}class N0 extends WA{constructor(r,s,c,p){super(r,s,p);er(this,"delta");this.delta=c}}class nh extends N0{constructor(e,r,s,c){super(e,Int32Array.of(r),s,c)}getValueFromBuffer(e){return this.dataBuffer[0]+e*this.delta}}class sh extends WA{constructor(e,r,s){super(e,Int32Array.of(r),s)}getValueFromBuffer(e){return this.dataBuffer[0]}}class qd{constructor(e,r,s,c,p=4096){er(this,"_name");er(this,"_geometryVector");er(this,"_idVector");er(this,"_propertyVectors");er(this,"_extent");er(this,"propertyVectorsMap");this._name=e,this._geometryVector=r,this._idVector=s,this._propertyVectors=c,this._extent=p}get name(){return this._name}get idVector(){return this._idVector}get geometryVector(){return this._geometryVector}get propertyVectors(){return this._propertyVectors}getPropertyVector(e){return this.propertyVectorsMap||(this.propertyVectorsMap=new Map(this._propertyVectors.map((r=>[r.name,r])))),this.propertyVectorsMap.get(e)}*[Symbol.iterator](){const e=this.geometryVector[Symbol.iterator]();let r=0;for(;r<this.numFeatures;){let s;this.idVector&&(s=this.containsMaxSaveIntegerValues(this.idVector)?Number(this.idVector.getValue(r)):this.idVector.getValue(r));const c=e==null?void 0:e.next().value,p={};for(const m of this.propertyVectors){if(!m)continue;const v=m.name,T=m.getValue(r);T!==null&&(p[v]=T)}r++,yield{id:s,geometry:c,properties:p}}}get numFeatures(){return this.geometryVector.numGeometries}get extent(){return this._extent}getFeatures(){const e=[],r=this.geometryVector.getGeometries();for(let s=0;s<this.numFeatures;s++){let c;this.idVector&&(c=this.containsMaxSaveIntegerValues(this.idVector)?Number(this.idVector.getValue(s)):this.idVector.getValue(s));const p={coordinates:r[s],type:this.geometryVector.geometryType(s)},m={};for(const v of this.propertyVectors){if(!v)continue;const T=v.name,E=v.getValue(s);E!==null&&(m[T]=E)}e.push({id:c,geometry:p,properties:m})}return e}containsMaxSaveIntegerValues(e){return e instanceof rh||e instanceof sh&&e instanceof nh||e instanceof ih}}class Zd{constructor(e){er(this,"value");this.value=e}get(){return this.value}set(e){this.value=e}increment(){return this.value++}add(e){this.value+=e}}var ar,za,ln,po,Zl,rs,Oi,Vi,G0,ys;function Xi(i,e,r){const s=new Int32Array(r);let c=0,p=e.get();for(let m=0;m<s.length;m++){let v=i[p++],T=127&v;v<128||(v=i[p++],T|=(127&v)<<7,v<128||(v=i[p++],T|=(127&v)<<14,v<128||(v=i[p++],T|=(127&v)<<21,v<128||(v=i[p++],T|=(15&v)<<28)))),s[c++]=T}return e.set(p),s}function uc(i,e,r){const s=new BigInt64Array(r);for(let c=0;c<s.length;c++)s[c]=$d(i,e);return s}function Qd(i,e){let r,s;return s=i[e.get()],e.increment(),r=127&s,s<128?r:(s=i[e.get()],e.increment(),r|=(127&s)<<7,s<128?r:(s=i[e.get()],e.increment(),r|=(127&s)<<14,s<128?r:(s=i[e.get()],e.increment(),r|=(127&s)<<21,s<128?r:(s=i[e.get()],r|=(15&s)<<28,(function(c,p,m){let v,T;if(T=p[m.get()],m.increment(),v=(112&T)>>4,T<128||(T=p[m.get()],m.increment(),v|=(127&T)<<3,T<128)||(T=p[m.get()],m.increment(),v|=(127&T)<<10,T<128)||(T=p[m.get()],m.increment(),v|=(127&T)<<17,T<128)||(T=p[m.get()],m.increment(),v|=(127&T)<<24,T<128)||(T=p[m.get()],m.increment(),v|=(1&T)<<31,T<128))return 4294967296*v+(c>>>0);throw new Error("Expected varint not more than 10 bytes")})(r,i,e)))))}function U0(i,e,r,s){throw new Error("FastPFor is not implemented yet.")}function Ql(i){return i>>>1^-(1&i)}function HA(i){return i>>1n^-(1n&i)}function $d(i,e){let r=0n,s=0,c=e.get();for(;c<i.length;){const p=i[c++];if(r|=BigInt(127&p)<<BigInt(s),!(128&p))break;if(s+=7,s>=64)throw new Error("Varint too long")}return e.set(c),r}function q0(i,e,r){const s=new Int32Array(r);let c=0;for(let p=0;p<e;p++){const m=i[p];s.fill(i[p+e],c,c+m),c+=m}return s}function Z0(i,e,r){const s=new BigInt64Array(r);let c=0;for(let p=0;p<e;p++){const m=Number(i[p]);s.fill(i[p+e],c,c+m),c+=m}return s}function Q0(i,e,r){const s=new Float64Array(r);let c=0;for(let p=0;p<e;p++){const m=i[p];s.fill(i[p+e],c,c+m),c+=m}return s}function oh(i){const e=i.length/4*4;let r=1;if(e>=4)for(let s=i[0];r<e-4;r+=4)s=i[r]+=s,s=i[r+1]+=s,s=i[r+2]+=s,s=i[r+3]+=s;for(;r!=i.length;)i[r]+=i[r-1],++r}function $0(i){i[0]=i[0]>>>1^-(1&i[0]),i[1]=i[1]>>>1^-(1&i[1]);const e=i.length/4*4;let r=2;if(e>=4)for(;r<e-4;r+=4){const s=i[r],c=i[r+1],p=i[r+2],m=i[r+3];i[r]=(s>>>1^-(1&s))+i[r-2],i[r+1]=(c>>>1^-(1&c))+i[r-1],i[r+2]=(p>>>1^-(1&p))+i[r],i[r+3]=(m>>>1^-(1&m))+i[r+1]}for(;r!=i.length;r+=2)i[r]=(i[r]>>>1^-(1&i[r]))+i[r-2],i[r+1]=(i[r+1]>>>1^-(1&i[r+1]))+i[r-1]}(function(i){i.NONE="NONE",i.DELTA="DELTA",i.COMPONENTWISE_DELTA="COMPONENTWISE_DELTA",i.RLE="RLE",i.MORTON="MORTON",i.PDE="PDE"})(ar||(ar={})),(function(i){i.NONE="NONE",i.FAST_PFOR="FAST_PFOR",i.VARINT="VARINT",i.ALP="ALP"})(za||(za={})),(function(i){i.PRESENT="PRESENT",i.DATA="DATA",i.OFFSET="OFFSET",i.LENGTH="LENGTH"})(ln||(ln={}));class ah{constructor(e,r,s){er(this,"_dictionaryType");er(this,"_offsetType");er(this,"_lengthType");this._dictionaryType=e,this._offsetType=r,this._lengthType=s}get dictionaryType(){return this._dictionaryType}get offsetType(){return this._offsetType}get lengthType(){return this._lengthType}}function Cn(i,e){const r=(function(s,c){const p=s[c.get()],m=Object.values(ln)[p>>4];let v=null;switch(m){case ln.DATA:v=new ah(Object.values(po)[15&p]);break;case ln.OFFSET:v=new ah(null,Object.values(Zl)[15&p]);break;case ln.LENGTH:v=new ah(null,null,Object.values(rs)[15&p])}c.increment();const T=s[c.get()],E=Object.values(ar)[T>>5],S=Object.values(ar)[T>>2&7],k=Object.values(za)[3&T];c.increment();const R=Xi(s,c,2),L=R[0];return{physicalStreamType:m,logicalStreamType:v,logicalLevelTechnique1:E,logicalLevelTechnique2:S,physicalLevelTechnique:k,numValues:L,byteLength:R[1],decompressedCount:L}})(i,e);return r.logicalLevelTechnique1===ar.MORTON?(function(s,c,p){const m=Xi(c,p,2);return{physicalStreamType:s.physicalStreamType,logicalStreamType:s.logicalStreamType,logicalLevelTechnique1:s.logicalLevelTechnique1,logicalLevelTechnique2:s.logicalLevelTechnique2,physicalLevelTechnique:s.physicalLevelTechnique,numValues:s.numValues,byteLength:s.byteLength,decompressedCount:s.decompressedCount,numBits:m[0],coordinateShift:m[1]}})(r,i,e):ar.RLE!==r.logicalLevelTechnique1&&ar.RLE!==r.logicalLevelTechnique2||za.NONE===r.physicalLevelTechnique?r:(function(s,c,p){const m=Xi(c,p,2);return{physicalStreamType:s.physicalStreamType,logicalStreamType:s.logicalStreamType,logicalLevelTechnique1:s.logicalLevelTechnique1,logicalLevelTechnique2:s.logicalLevelTechnique2,physicalLevelTechnique:s.physicalLevelTechnique,numValues:s.numValues,byteLength:s.byteLength,decompressedCount:m[1],runs:m[0],numRleValues:m[1]}})(r,i,e)}(function(i){i.NONE="NONE",i.SINGLE="SINGLE",i.SHARED="SHARED",i.VERTEX="VERTEX",i.MORTON="MORTON",i.FSST="FSST"})(po||(po={})),(function(i){i.VERTEX="VERTEX",i.INDEX="INDEX",i.STRING="STRING",i.KEY="KEY"})(Zl||(Zl={})),(function(i){i.VAR_BINARY="VAR_BINARY",i.GEOMETRIES="GEOMETRIES",i.PARTS="PARTS",i.RINGS="RINGS",i.TRIANGLES="TRIANGLES",i.SYMBOL="SYMBOL",i.DICTIONARY="DICTIONARY"})(rs||(rs={})),(function(i){i[i.FLAT=0]="FLAT",i[i.CONST=1]="CONST",i[i.SEQUENCE=2]="SEQUENCE",i[i.DICTIONARY=3]="DICTIONARY",i[i.FSST_DICTIONARY=4]="FSST_DICTIONARY"})(Oi||(Oi={}));class fo{constructor(e,r){er(this,"values");er(this,"_size");this.values=e,this._size=r}get(e){const r=Math.floor(e/8);return(this.values[r]>>e%8&1)==1}set(e,r){const s=Math.floor(e/8);this.values[s]=this.values[s]|(r?1:0)<<e%8}getInt(e){const r=Math.floor(e/8);return this.values[r]>>e%8&1}size(){return this._size}getBuffer(){return this.values}}function Dn(i,e,r,s,c){return(function(p,m,v){switch(m.logicalLevelTechnique1){case ar.DELTA:return m.logicalLevelTechnique2===ar.RLE?(function(T,E,S){const k=new Int32Array(S);let R=0,L=0;for(let j=0;j<E;j++){const N=T[j],q=Ql(T[j+E]);for(let Y=0;Y<N;Y++)L+=q,k[R++]=L}return k})(p,m.runs,m.numRleValues):((function(T){T[0]=T[0]>>>1^-(1&T[0]);const E=T.length/4*4;let S=1;if(E>=4)for(;S<E-4;S+=4){const k=T[S],R=T[S+1],L=T[S+2],j=T[S+3];T[S]=(k>>>1^-(1&k))+T[S-1],T[S+1]=(R>>>1^-(1&R))+T[S],T[S+2]=(L>>>1^-(1&L))+T[S+1],T[S+3]=(j>>>1^-(1&j))+T[S+2]}for(;S!=T.length;++S)T[S]=(T[S]>>>1^-(1&T[S]))+T[S-1]})(p),p);case ar.RLE:return(function(T,E,S){return S?(function(k,R,L){const j=new Int32Array(L);let N=0;for(let q=0;q<R;q++){const Y=k[q];let ue=k[q+R];ue=ue>>>1^-(1&ue),j.fill(ue,N,N+Y),N+=Y}return j})(T,E.runs,E.numRleValues):q0(T,E.runs,E.numRleValues)})(p,m,v);case ar.MORTON:return oh(p),p;case ar.COMPONENTWISE_DELTA:return $0(p),p;case ar.NONE:return v&&(function(T){for(let E=0;E<T.length;E++){const S=T[E];T[E]=S>>>1^-(1&S)}})(p),p;default:throw new Error(`The specified Logical level technique is not supported: ${m.logicalLevelTechnique1}`)}})(cc(i,e,r),r,s)}function ol(i,e,r){return(function(s,c){if(c.logicalLevelTechnique1===ar.DELTA&&c.logicalLevelTechnique2===ar.NONE)return(function(m){const v=new Int32Array(m.length+1);v[0]=0,v[1]=Ql(m[0]);let T=v[1],E=2;for(;E!=v.length;++E){const S=m[E-1];T+=S>>>1^-(1&S),v[E]=v[E-1]+T}return v})(s);if(c.logicalLevelTechnique1===ar.RLE&&c.logicalLevelTechnique2===ar.NONE)return(function(m,v,T){const E=new Int32Array(T+1);E[0]=0;let S=1,k=E[0];for(let R=0;R<v;R++){const L=m[R],j=m[R+v];for(let N=S;N<S+L;N++)E[N]=j+k,k=E[N];S+=L}return E})(s,c.runs,c.numRleValues);if(c.logicalLevelTechnique1===ar.NONE&&c.logicalLevelTechnique2===ar.NONE){(function(m){let v=0;for(let T=0;T<m.length;T++)m[T]+=v,v=m[T]})(s);const p=new Int32Array(c.numValues+1);return p[0]=0,p.set(s,1),p}if(c.logicalLevelTechnique1===ar.DELTA&&c.logicalLevelTechnique2===ar.RLE){const p=(function(m,v,T){const E=new Int32Array(T+1);E[0]=0;let S=1,k=E[0];for(let R=0;R<v;R++){const L=m[R];let j=m[R+v];j=j>>>1^-(1&j);for(let N=S;N<S+L;N++)E[N]=j+k,k=E[N];S+=L}return E})(s,c.runs,c.numRleValues);return oh(p),p}throw new Error("Only delta encoding is supported for transforming length to offset streams yet.")})(cc(i,e,r),r)}function cc(i,e,r){const s=r.physicalLevelTechnique;if(s===za.FAST_PFOR)return U0();if(s===za.VARINT)return Xi(i,e,r.numValues);if(s===za.NONE){const c=e.get();e.add(r.byteLength);const p=i.subarray(c,e.get());return new Int32Array(p)}throw new Error("Specified physicalLevelTechnique is not supported (yet).")}function lh(i,e,r,s){const c=cc(i,e,r);if(c.length===1){const p=c[0];return s?Ql(p):p}return s?(function(p){return Ql(p[1])})(c):(function(p){return p[1]})(c)}function W0(i,e,r){return(function(s){if(s.length==2){const c=Ql(s[1]);return[c,c]}return[Ql(s[2]),Ql(s[3])]})(cc(i,e,r))}function H0(i,e,r){return(function(s){if(s.length==2){const c=HA(s[1]);return[c,c]}return[HA(s[2]),HA(s[3])]})(uc(i,e,r.numValues))}function X0(i,e,r,s){return(function(c,p,m){switch(p.logicalLevelTechnique1){case ar.DELTA:return p.logicalLevelTechnique2===ar.RLE?(function(v,T,E){const S=new BigInt64Array(E);let k=0,R=0n;for(let L=0;L<T;L++){const j=Number(v[L]),N=HA(v[L+T]);for(let q=0;q<j;q++)R+=N,S[k++]=R}return S})(c,p.runs,p.numRleValues):((function(v){v[0]=v[0]>>1n^-(1n&v[0]);const T=v.length/4*4;let E=1;if(T>=4)for(;E<T-4;E+=4){const S=v[E],k=v[E+1],R=v[E+2],L=v[E+3];v[E]=(S>>1n^-(1n&S))+v[E-1],v[E+1]=(k>>1n^-(1n&k))+v[E],v[E+2]=(R>>1n^-(1n&R))+v[E+1],v[E+3]=(L>>1n^-(1n&L))+v[E+2]}for(;E!=v.length;++E)v[E]=(v[E]>>1n^-(1n&v[E]))+v[E-1]})(c),c);case ar.RLE:return(function(v,T,E){return E?(function(S,k,R){const L=new BigInt64Array(R);let j=0;for(let N=0;N<k;N++){const q=Number(S[N]);let Y=S[N+k];Y=Y>>1n^-(1n&Y),L.fill(Y,j,j+q),j+=q}return L})(v,T.runs,T.numRleValues):Z0(v,T.runs,T.numRleValues)})(c,p,m);case ar.NONE:return m&&(function(v){for(let T=0;T<v.length;T++){const E=v[T];v[T]=E>>1n^-(1n&E)}})(c),c;default:throw new Error(`The specified Logical level technique is not supported: ${p.logicalLevelTechnique1}`)}})(uc(i,e,r.numValues),r,s)}function Y0(i,e,r,s){const c=uc(i,e,r.numValues);if(c.length===1){const p=c[0];return s?HA(p):p}return s?(function(p){return HA(p[1])})(c):(function(p){return p[1]})(c)}function Ah(i,e,r,s,c){return(function(p,m,v,T){switch(m.logicalLevelTechnique1){case ar.DELTA:return m.logicalLevelTechnique2===ar.RLE&&(p=q0(p,m.runs,m.numRleValues)),(function(E,S){const k=new Int32Array(E.size());let R=0;E.get(0)?(k[0]=E.get(0)?S[0]>>>1^-(1&S[0]):0,R=1):k[0]=0;let L=1;for(;L!=k.length;++L)k[L]=E.get(L)?k[L-1]+(S[R]>>>1^-(1&S[R++])):k[L-1];return k})(T,p);case ar.RLE:return(function(E,S,k,R){const L=S;return k?(function(j,N,q){const Y=new Int32Array(j.size());let ue=0;for(let J=0;J<q;J++){const re=N[J];let he=N[J+q];he=he>>>1^-(1&he);for(let me=ue;me<ue+re;me++)j.get(me)?Y[me]=he:(Y[me]=0,ue++);ue+=re}return Y})(R,E,L.runs):(function(j,N,q){const Y=new Int32Array(j.size());let ue=0;for(let J=0;J<q;J++){const re=N[J],he=N[J+q];for(let me=ue;me<ue+re;me++)j.get(me)?Y[me]=he:(Y[me]=0,ue++);ue+=re}return Y})(R,E,L.runs)})(p,m,v,T);case ar.MORTON:return oh(p),p;case ar.COMPONENTWISE_DELTA:return $0(p),p;case ar.NONE:return p=v?(function(E,S){const k=new Int32Array(E.size());let R=0,L=0;for(;L!=k.length;++L)if(E.get(L)){const j=S[R++];k[L]=j>>>1^-(1&j)}else k[L]=0;return k})(T,p):(function(E,S){const k=new Int32Array(E.size());let R=0,L=0;for(;L!=k.length;++L)k[L]=E.get(L)?S[R++]:0;return k})(T,p),p;default:throw new Error("The specified Logical level technique is not supported")}})(r.physicalLevelTechnique===za.FAST_PFOR?U0():Xi(i,e,r.numValues),r,s,c)}function hc(i,e,r,s){const c=i.logicalLevelTechnique1;if(c===ar.RLE)return i.runs===1?Oi.CONST:Oi.FLAT;const p=e instanceof fo?e.size():e;if(c===ar.DELTA&&i.logicalLevelTechnique2===ar.RLE){const m=i.runs,v=2;if(i.numRleValues!==p)return Oi.FLAT;if(m===1)return Oi.SEQUENCE;if(m===2){const T=s.get();let E;if(i.physicalLevelTechnique===za.VARINT)E=Xi(r,s,4);else{const S=s.get();E=new Int32Array(r.buffer,r.byteOffset+S,4)}if(s.set(T),E[2]===v&&E[3]===v)return Oi.SEQUENCE}}return i.numValues===1?Oi.CONST:Oi.FLAT}class K0 extends Ac{getValueFromBuffer(e){return this.dataBuffer[e]}}class J0 extends N0{constructor(e,r,s,c){super(e,BigInt64Array.of(r),s,c)}getValueFromBuffer(e){return this.dataBuffer[0]+BigInt(e)*this.delta}}class XA{constructor(e,r,s){er(this,"_geometryOffsets");er(this,"_partOffsets");er(this,"_ringOffsets");this._geometryOffsets=e,this._partOffsets=r,this._ringOffsets=s}get geometryOffsets(){return this._geometryOffsets}get partOffsets(){return this._partOffsets}get ringOffsets(){return this._ringOffsets}}function uh(i,e,r){return{x:ep(i,e)-r,y:ep(i>>1,e)-r}}function ep(i,e){let r=0;for(let s=0;s<e;s++)r|=(i&1<<2*s)>>s;return r}(function(i){i[i.POINT=0]="POINT",i[i.LINESTRING=1]="LINESTRING",i[i.POLYGON=2]="POLYGON",i[i.MULTIPOINT=3]="MULTIPOINT",i[i.MULTILINESTRING=4]="MULTILINESTRING",i[i.MULTIPOLYGON=5]="MULTIPOLYGON"})(Vi||(Vi={})),(function(i){i[i.POINT=0]="POINT",i[i.LINESTRING=1]="LINESTRING",i[i.POLYGON=2]="POLYGON"})(G0||(G0={})),(function(i){i[i.MORTON=0]="MORTON",i[i.VEC_2=1]="VEC_2",i[i.VEC_3=2]="VEC_3"})(ys||(ys={}));class Wd{createPoint(e){return[[e]]}createMultiPoint(e){return e.map((r=>[r]))}createLineString(e){return[e]}createMultiLineString(e){return e}createPolygon(e,r){return[e].concat(r)}createMultiPolygon(e){return e.flat()}}function tp(i){const e=new Array(i.numGeometries);let r=1,s=1,c=1,p=0;const m=new Wd;let v=0,T=0;const E=i.mortonSettings,S=i.topologyVector,k=S.geometryOffsets,R=S.partOffsets,L=S.ringOffsets,j=i.vertexOffsets,N=i.containsPolygonGeometry(),q=i.vertexBuffer;for(let Y=0;Y<i.numGeometries;Y++){const ue=i.geometryType(Y);if(ue===Vi.POINT){if(j&&j.length!==0)if(i.vertexBufferType===ys.VEC_2){const J=2*j[T++],re=new nt(q[J],q[J+1]);e[p++]=m.createPoint(re)}else{const J=uh(q[j[T++]],E.numBits,E.coordinateShift),re=new nt(J.x,J.y);e[p++]=m.createPoint(re)}else{const J=new nt(q[v++],q[v++]);e[p++]=m.createPoint(J)}k&&c++,R&&r++,L&&s++}else if(ue===Vi.MULTIPOINT){const J=k[c]-k[c-1];c++;const re=new Array(J);if(j&&j.length!==0){for(let he=0;he<J;he++){const me=2*j[T++];re[he]=new nt(q[me],q[me+1])}e[p++]=m.createMultiPoint(re)}else{for(let he=0;he<J;he++){const me=q[v++],ze=q[v++];re[he]=new nt(me,ze)}e[p++]=m.createMultiPoint(re)}}else if(ue===Vi.LINESTRING){let J,re=0;N?(re=L[s]-L[s-1],s++):re=R[r]-R[r-1],r++,j&&j.length!==0?(J=i.vertexBufferType===ys.VEC_2?hh(q,j,T,re,!1):ph(q,j,T,re,!1,E),T+=re):(J=ch(q,v,re,!1),v+=2*re),e[p++]=m.createLineString(J),k&&c++}else if(ue===Vi.POLYGON){const J=R[r]-R[r-1];r++;const re=new Array(J-1);let he=L[s]-L[s-1];if(s++,j&&j.length!==0){const me=i.vertexBufferType===ys.VEC_2?fc(q,j,T,he):dc(q,j,T,he,0,E);T+=he;for(let ze=0;ze<re.length;ze++)he=L[s]-L[s-1],s++,re[ze]=i.vertexBufferType===ys.VEC_2?fc(q,j,T,he):dc(q,j,T,he,0,E),T+=he;e[p++]=m.createPolygon(me,re)}else{const me=pc(q,v,he);v+=2*he;for(let ze=0;ze<re.length;ze++)he=L[s]-L[s-1],s++,re[ze]=pc(q,v,he),v+=2*he;e[p++]=m.createPolygon(me,re)}k&&c++}else if(ue===Vi.MULTILINESTRING){const J=k[c]-k[c-1];c++;const re=new Array(J);if(j&&j.length!==0){for(let he=0;he<J;he++){let me=0;N?(me=L[s]-L[s-1],s++):me=R[r]-R[r-1],r++;const ze=i.vertexBufferType===ys.VEC_2?hh(q,j,T,me,!1):ph(q,j,T,me,!1,E);re[he]=ze,T+=me}e[p++]=m.createMultiLineString(re)}else{for(let he=0;he<J;he++){let me=0;N?(me=L[s]-L[s-1],s++):me=R[r]-R[r-1],r++,re[he]=ch(q,v,me,!1),v+=2*me}e[p++]=m.createMultiLineString(re)}}else{if(ue!==Vi.MULTIPOLYGON)throw new Error("The specified geometry type is currently not supported.");{const J=k[c]-k[c-1];c++;const re=new Array(J);let he=0;if(j&&j.length!==0){for(let me=0;me<J;me++){const ze=R[r]-R[r-1];r++;const He=new Array(ze-1);he=L[s]-L[s-1],s++;const Qe=i.vertexBufferType===ys.VEC_2?fc(q,j,T,he):dc(q,j,T,he,0,E);T+=he;for(let et=0;et<He.length;et++)he=L[s]-L[s-1],s++,He[et]=i.vertexBufferType===ys.VEC_2?fc(q,j,T,he):dc(q,j,T,he,0,E),T+=he;re[me]=m.createPolygon(Qe,He)}e[p++]=m.createMultiPolygon(re)}else{for(let me=0;me<J;me++){const ze=R[r]-R[r-1];r++;const He=new Array(ze-1);he=L[s]-L[s-1],s++;const Qe=pc(q,v,he);v+=2*he;for(let et=0;et<He.length;et++){const pt=L[s]-L[s-1];s++,He[et]=pc(q,v,pt),v+=2*pt}re[me]=m.createPolygon(Qe,He)}e[p++]=m.createMultiPolygon(re)}}}}return e}function pc(i,e,r){return ch(i,e,r,!0)}function fc(i,e,r,s){return hh(i,e,r,s,!0)}function dc(i,e,r,s,c,p){return ph(i,e,r,s,!0,p)}function ch(i,e,r,s){const c=new Array(s?r+1:r);for(let p=0;p<2*r;p+=2)c[p/2]=new nt(i[e+p],i[e+p+1]);return s&&(c[c.length-1]=c[0]),c}function hh(i,e,r,s,c){const p=new Array(c?s+1:s);for(let m=0;m<2*s;m+=2){const v=2*e[r+m/2];p[m/2]=new nt(i[v],i[v+1])}return c&&(p[p.length-1]=p[0]),p}function ph(i,e,r,s,c,p){const m=new Array(c?s+1:s);for(let v=0;v<s;v++){const T=uh(i[e[r+v]],p.numBits,p.coordinateShift);m[v]=new nt(T.x,T.y)}return c&&(m[m.length-1]=m[0]),m}class rp{constructor(e,r,s,c,p){er(this,"_vertexBufferType");er(this,"_topologyVector");er(this,"_vertexOffsets");er(this,"_vertexBuffer");er(this,"_mortonSettings");this._vertexBufferType=e,this._topologyVector=r,this._vertexOffsets=s,this._vertexBuffer=c,this._mortonSettings=p}get vertexBufferType(){return this._vertexBufferType}get topologyVector(){return this._topologyVector}get vertexOffsets(){return this._vertexOffsets}get vertexBuffer(){return this._vertexBuffer}*[Symbol.iterator](){const e=tp(this);let r=0;for(;r<this.numGeometries;)yield{coordinates:e[r],type:this.geometryType(r)},r++}getSimpleEncodedVertex(e){const r=this.vertexOffsets?2*this.vertexOffsets[e]:2*e;return[this.vertexBuffer[r],this.vertexBuffer[r+1]]}getVertex(e){if(this.vertexOffsets&&this.mortonSettings){const s=uh(this.vertexBuffer[this.vertexOffsets[e]],this.mortonSettings.numBits,this.mortonSettings.coordinateShift);return[s.x,s.y]}const r=this.vertexOffsets?2*this.vertexOffsets[e]:2*e;return[this.vertexBuffer[r],this.vertexBuffer[r+1]]}getGeometries(){return tp(this)}get mortonSettings(){return this._mortonSettings}}class ip extends rp{constructor(r,s,c,p,m,v,T){super(c,p,m,v,T);er(this,"_numGeometries");er(this,"_geometryType");this._numGeometries=r,this._geometryType=s}geometryType(r){return this._geometryType}get numGeometries(){return this._numGeometries}containsPolygonGeometry(){return this._geometryType===Vi.POLYGON||this._geometryType===Vi.MULTIPOLYGON}containsSingleGeometryType(){return!0}}class np extends rp{constructor(r,s,c,p,m,v){super(r,c,p,m,v);er(this,"_geometryTypes");this._geometryTypes=s}geometryType(r){return this._geometryTypes[r]}get numGeometries(){return this._geometryTypes.length}containsPolygonGeometry(){for(let r=0;r<this.numGeometries;r++)if(this.geometryType(r)===Vi.POLYGON||this.geometryType(r)===Vi.MULTIPOLYGON)return!0;return!1}containsSingleGeometryType(){return!1}}class sp{constructor(e,r,s,c){er(this,"_triangleOffsets");er(this,"_indexBuffer");er(this,"_vertexBuffer");er(this,"_topologyVector");this._triangleOffsets=e,this._indexBuffer=r,this._vertexBuffer=s,this._topologyVector=c}get triangleOffsets(){return this._triangleOffsets}get indexBuffer(){return this._indexBuffer}get vertexBuffer(){return this._vertexBuffer}get topologyVector(){return this._topologyVector}getGeometries(){if(!this._topologyVector)throw new Error("Cannot convert GpuVector to coordinates without topology information");const e=new Array(this.numGeometries),r=this._topologyVector,s=r.partOffsets,c=r.ringOffsets,p=r.geometryOffsets;let m=0,v=1,T=1,E=1;for(let S=0;S<this.numGeometries;S++)switch(this.geometryType(S)){case Vi.POLYGON:{const k=s[v]-s[v-1];v++;const R=[];for(let L=0;L<k;L++){const j=c[T]-c[T-1];T++;const N=[];for(let q=0;q<j;q++){const Y=this._vertexBuffer[m++],ue=this._vertexBuffer[m++];N.push(new nt(Y,ue))}N.length>0&&N.push(N[0]),R.push(N)}e[S]=R,p&&E++}break;case Vi.MULTIPOLYGON:{const k=p[E]-p[E-1];E++;const R=[];for(let L=0;L<k;L++){const j=s[v]-s[v-1];v++;for(let N=0;N<j;N++){const q=c[T]-c[T-1];T++;const Y=[];for(let ue=0;ue<q;ue++){const J=this._vertexBuffer[m++],re=this._vertexBuffer[m++];Y.push(new nt(J,re))}Y.length>0&&Y.push(Y[0]),R.push(Y)}}e[S]=R}}return e}[Symbol.iterator](){return null}}function op(i,e,r,s,c,p){return new Hd(i,e,r,s,c,p)}class Hd extends sp{constructor(r,s,c,p,m,v){super(c,p,m,v);er(this,"_numGeometries");er(this,"_geometryType");this._numGeometries=r,this._geometryType=s}geometryType(r){return this._geometryType}get numGeometries(){return this._numGeometries}containsSingleGeometryType(){return!0}}function ap(i,e,r,s,c){return new Xd(i,e,r,s,c)}class Xd extends sp{constructor(r,s,c,p,m){super(s,c,p,m);er(this,"_geometryTypes");this._geometryTypes=r}geometryType(r){return this._geometryTypes[r]}get numGeometries(){return this._geometryTypes.length}containsSingleGeometryType(){return!1}}function Yd(i,e,r,s,c){const p=Cn(i,r);let m=null,v=null,T=null,E=null,S=null,k=null,R=null,L=null;if(hc(p,s,i,r)===Oi.CONST){const N=lh(i,r,p,!1);for(let q=0;q<e-1;q++){const Y=Cn(i,r);switch(Y.physicalStreamType){case ln.LENGTH:switch(Y.logicalStreamType.lengthType){case rs.GEOMETRIES:m=ol(i,r,Y);break;case rs.PARTS:v=ol(i,r,Y);break;case rs.RINGS:T=ol(i,r,Y);break;case rs.TRIANGLES:R=ol(i,r,Y)}break;case ln.OFFSET:switch(Y.logicalStreamType.offsetType){case Zl.VERTEX:E=Dn(i,r,Y,!1);break;case Zl.INDEX:L=Dn(i,r,Y,!1)}break;case ln.DATA:po.VERTEX===Y.logicalStreamType.dictionaryType?S=Dn(i,r,Y,!0):(k={numBits:Y.numBits,coordinateShift:Y.coordinateShift},S=Dn(i,r,Y,!1))}}return L!==null?m!=null||v!=null?op(s,N,R,L,S,new XA(m,v,T)):op(s,N,R,L,S):k===null?(function(q,Y,ue,J,re){return new ip(q,Y,ys.VEC_2,ue,J,re)})(s,N,new XA(m,v,T),E,S):(function(q,Y,ue,J,re,he){return new ip(q,Y,ys.MORTON,ue,J,re,he)})(s,N,new XA(m,v,T),E,S,k)}const j=Dn(i,r,p,!1);for(let N=0;N<e-1;N++){const q=Cn(i,r);switch(q.physicalStreamType){case ln.LENGTH:switch(q.logicalStreamType.lengthType){case rs.GEOMETRIES:m=Dn(i,r,q,!1);break;case rs.PARTS:v=Dn(i,r,q,!1);break;case rs.RINGS:T=Dn(i,r,q,!1);break;case rs.TRIANGLES:R=ol(i,r,q)}break;case ln.OFFSET:switch(q.logicalStreamType.offsetType){case Zl.VERTEX:E=Dn(i,r,q,!1);break;case Zl.INDEX:L=Dn(i,r,q,!1)}break;case ln.DATA:po.VERTEX===q.logicalStreamType.dictionaryType?S=Dn(i,r,q,!0):(k={numBits:q.numBits,coordinateShift:q.coordinateShift},S=Dn(i,r,q,!1))}}return L!==null&&v===null?ap(j,R,L,S):(m!==null?(m=fh(j,m,2),v!==null&&T!==null?(v=lp(j,m,v,!1),T=(function(N,q,Y,ue){const J=new Int32Array(Y[Y.length-1]+1);let re=0;J[0]=re;let he=1,me=1,ze=0;for(let He=0;He<N.length;He++){const Qe=N[He],et=q[He+1]-q[He];if(Qe!==0&&Qe!==3)for(let pt=0;pt<et;pt++){const st=Y[he]-Y[he-1];he++;for(let $e=0;$e<st;$e++)re=J[me++]=re+ue[ze++]}else for(let pt=0;pt<et;pt++)J[me++]=++re,he++}return J})(j,m,v,T)):v!==null&&(v=(function(N,q,Y){const ue=new Int32Array(q[q.length-1]+1);let J=0;ue[0]=J;let re=1,he=0;for(let me=0;me<N.length;me++){const ze=N[me],He=q[me+1]-q[me];if(ze===4||ze===1)for(let Qe=0;Qe<He;Qe++)J=ue[re++]=J+Y[he++];else for(let Qe=0;Qe<He;Qe++)ue[re++]=++J}return ue})(j,m,v))):v!==null&&T!==null?(v=fh(j,v,1),T=lp(j,v,T,!0)):v!==null&&(v=fh(j,v,0)),L!==null?ap(j,R,L,S,new XA(m,v,T)):k===null?(function(N,q,Y,ue){return new np(ys.VEC_2,N,q,Y,ue)})(j,new XA(m,v,T),E,S):(function(N,q,Y,ue,J){return new np(ys.MORTON,N,q,Y,ue,J)})(j,new XA(m,v,T),E,S,k))}function fh(i,e,r){const s=new Int32Array(i.length+1);let c=0;s[0]=c;let p=0;for(let m=0;m<i.length;m++)c=s[m+1]=c+(i[m]>r?e[p++]:1);return s}function lp(i,e,r,s){const c=new Int32Array(e[e.length-1]+1);let p=0;c[0]=p;let m=1,v=0;for(let T=0;T<i.length;T++){const E=i[T],S=e[T+1]-e[T];if(E===5||E===2||s&&(E===4||E===1))for(let k=0;k<S;k++)p=c[m++]=p+r[v++];else for(let k=0;k<S;k++)c[m++]=++p}return c}class Kd extends WA{constructor(r,s,c){super(r,s.getBuffer(),c);er(this,"dataVector");this.dataVector=s}getValueFromBuffer(r){return this.dataVector.get(r)}}class Jd extends Ac{getValueFromBuffer(e){return this.dataBuffer[e]}}class Ap extends WA{constructor(e,r,s){super(e,BigInt64Array.of(r),s)}getValueFromBuffer(e){return this.dataBuffer[0]}}function Ru(i,e,r){return up(i,Math.ceil(e/8),r)}function up(i,e,r){const s=new Uint8Array(e);let c=0;for(;c<e;){const p=i[r.increment()];if(p<=127){const m=p+3,v=i[r.increment()],T=c+m;s.fill(v,c,T),c=T}else{const m=256-p;for(let v=0;v<m;v++)s[c++]=i[r.increment()]}}return s}const em=new TextDecoder;function dh(i,e,r){return r-e>=12?em.decode(i.subarray(e,r)):(function(s,c,p){let m="",v=c;for(;v<p;){const T=s[v];let E,S,k,R=null,L=T>239?4:T>223?3:T>191?2:1;if(v+L>p)break;L===1?T<128&&(R=T):L===2?(E=s[v+1],(192&E)==128&&(R=(31&T)<<6|63&E,R<=127&&(R=null))):L===3?(E=s[v+1],S=s[v+2],(192&E)==128&&(192&S)==128&&(R=(15&T)<<12|(63&E)<<6|63&S,(R<=2047||R>=55296&&R<=57343)&&(R=null))):L===4&&(E=s[v+1],S=s[v+2],k=s[v+3],(192&E)==128&&(192&S)==128&&(192&k)==128&&(R=(15&T)<<18|(63&E)<<12|(63&S)<<6|63&k,(R<=65535||R>=1114112)&&(R=null))),R===null?(R=65533,L=1):R>65535&&(R-=65536,m+=String.fromCharCode(R>>>10&1023|55296),R=56320|1023&R),m+=String.fromCharCode(R),v+=L}return m})(i,e,r)}class mh extends WA{constructor(r,s,c,p){super(r,c,p);er(this,"offsetBuffer");this.offsetBuffer=s}}class cp extends mh{constructor(r,s,c,p){super(r,s,c,p??s.length-1);er(this,"textEncoder");this.textEncoder=new TextEncoder}getValueFromBuffer(r){return dh(this.dataBuffer,this.offsetBuffer[r],this.offsetBuffer[r+1])}}class YA extends mh{constructor(r,s,c,p,m){super(r,c,p,m??s.length);er(this,"indexBuffer");er(this,"textEncoder");this.indexBuffer=s,this.indexBuffer=s,this.textEncoder=new TextEncoder}getValueFromBuffer(r){const s=this.indexBuffer[r];return dh(this.dataBuffer,this.offsetBuffer[s],this.offsetBuffer[s+1])}}class hp extends mh{constructor(r,s,c,p,m,v,T){super(r,c,p,T);er(this,"indexBuffer");er(this,"symbolOffsetBuffer");er(this,"symbolTableBuffer");er(this,"textEncoder");er(this,"symbolLengthBuffer");er(this,"lengthBuffer");er(this,"decodedDictionary");this.indexBuffer=s,this.symbolOffsetBuffer=m,this.symbolTableBuffer=v,this.textEncoder=new TextEncoder}getValueFromBuffer(r){this.decodedDictionary==null&&(this.symbolLengthBuffer==null&&(this.symbolLengthBuffer=this.offsetToLengthBuffer(this.symbolOffsetBuffer),this.lengthBuffer=this.offsetToLengthBuffer(this.offsetBuffer)),this.decodedDictionary=(function(c,p,m){const v=[],T=new Array(p.length).fill(0);for(let E=1;E<p.length;E++)T[E]=T[E-1]+p[E-1];for(let E=0;E<m.length;E++)if(m[E]===255)v.push(m[++E]);else{const S=p[m[E]],k=T[m[E]];for(let R=0;R<S;R++)v.push(c[k+R])}return new Uint8Array(v)})(this.symbolTableBuffer,this.symbolLengthBuffer,this.dataBuffer));const s=this.indexBuffer[r];return dh(this.decodedDictionary,this.offsetBuffer[s],this.offsetBuffer[s+1])}offsetToLengthBuffer(r){const s=new Uint32Array(r.length-1);let c=r[0];for(let p=1;p<r.length;p++){const m=r[p];s[p-1]=m-c,c=m}return s}}function tm(i,e,r,s,c,p){return r.type==="scalarType"?(function(m,v,T,E,S,k){let R=null,L=0;if(m===0)return null;if(k.nullable){const N=Cn(v,T);L=N.numValues;const q=T.get(),Y=Ru(v,L,T);T.set(q+N.byteLength),R=new fo(Y,N.numValues)}const j=R??E;switch(S.physicalType){case 4:case 3:return(function(N,q,Y,ue,J){const re=Cn(N,q),he=hc(re,J,N,q),me=ue.physicalType===3;if(he===Oi.FLAT){const ze=Lu(J)?Ah(N,q,re,me,J):Dn(N,q,re,me);return new rh(Y.name,ze,J)}if(he===Oi.SEQUENCE){const ze=W0(N,q,re);return new nh(Y.name,ze[0],ze[1],re.numRleValues)}{const ze=lh(N,q,re,me);return new sh(Y.name,ze,J)}})(v,T,k,S,j);case 9:return(function(N,q,Y,ue,J){let re=null,he=null,me=null,ze=null,He=null,Qe=null,et=null,pt=null;for(let st=0;st<ue;st++){const $e=Cn(q,Y);if($e.byteLength!==0)switch($e.physicalStreamType){case ln.PRESENT:{const Ne=Ru(q,$e.numValues,Y);Qe=new fo(Ne,$e.numValues);break}case ln.OFFSET:he=J!=null||Qe!=null?Ah(q,Y,$e,!1,J??Qe):Dn(q,Y,$e,!1);break;case ln.LENGTH:{const Ne=ol(q,Y,$e);rs.DICTIONARY===$e.logicalStreamType.lengthType?re=Ne:rs.SYMBOL===$e.logicalStreamType.lengthType?ze=Ne:et=Ne;break}case ln.DATA:{const Ne=q.subarray(Y.get(),Y.get()+$e.byteLength);Y.add($e.byteLength);const xt=$e.logicalStreamType.dictionaryType;po.FSST===xt?He=Ne:po.SINGLE===xt||po.SHARED===xt?me=Ne:po.NONE===xt&&(pt=Ne);break}}}return(function(st,$e,Ne,xt,gt,Tt,mt){return $e?new hp(st,Ne,xt,gt,Tt,$e,mt):null})(N,He,he,re,me,ze,J??Qe)??(function(st,$e,Ne,xt,gt){return $e?gt?new YA(st,Ne,xt,$e,gt):new YA(st,Ne,xt,$e):null})(N,me,he,re,J??Qe)??(function(st,$e,Ne,xt,gt){if(!$e||!Ne)return null;if(xt)return gt?new YA(st,xt,$e,Ne,gt):new YA(st,xt,$e,Ne);if(gt&&gt.size()!==$e.length-1){const Tt=new Int32Array(gt.size());let mt=0;for(let Ct=0;Ct<gt.size();Ct++)Tt[Ct]=gt.get(Ct)?mt++:0;return new YA(st,Tt,$e,Ne,gt)}return gt?new cp(st,$e,Ne,gt):new cp(st,$e,Ne)})(N,et,pt,he,J??Qe)})(k.name,v,T,k.nullable?m-1:m,R);case 0:return(function(N,q,Y,ue,J){const re=Cn(N,q),he=re.numValues,me=q.get(),ze=Lu(J)?(function(Qe,et,pt,st){const $e=up(Qe,Math.ceil(et/8),pt),Ne=new fo($e,et),xt=st.size(),gt=new fo(new Uint8Array(xt),xt);let Tt=0;for(let mt=0;mt<st.size();mt++){const Ct=!!st.get(mt)&&Ne.get(Tt++);gt.set(mt,Ct)}return gt.getBuffer()})(N,he,q,J):Ru(N,he,q);q.set(me+re.byteLength);const He=new fo(ze,he);return new Kd(Y.name,He,J)})(v,T,k,0,j);case 6:case 5:return(function(N,q,Y,ue,J){const re=Cn(N,q),he=hc(re,ue,N,q),me=J.physicalType===5;if(he===Oi.FLAT){const ze=Lu(ue)?(function(He,Qe,et,pt,st){return(function($e,Ne,xt,gt){switch(Ne.logicalLevelTechnique1){case ar.DELTA:return Ne.logicalLevelTechnique2===ar.RLE&&($e=Z0($e,Ne.runs,Ne.numRleValues)),(function(Tt,mt){const Ct=new BigInt64Array(Tt.size());let cr=0;Tt.get(0)?(Ct[0]=Tt.get(0)?mt[0]>>1n^-(1n&mt[0]):0n,cr=1):Ct[0]=0n;let sr=1;for(;sr!=Ct.length;++sr)Ct[sr]=Tt.get(sr)?Ct[sr-1]+(mt[cr]>>1n^-(1n&mt[cr++])):Ct[sr-1];return Ct})(gt,$e);case ar.RLE:return(function(Tt,mt,Ct,cr){const sr=mt;return Ct?(function(Xr,un,bi){const Yr=new BigInt64Array(Xr.size());let qr=0;for(let vr=0;vr<bi;vr++){const ii=Number(un[vr]);let ci=un[vr+bi];ci=ci>>1n^-(1n&ci);for(let Or=qr;Or<qr+ii;Or++)Xr.get(Or)?Yr[Or]=ci:(Yr[Or]=0n,qr++);qr+=ii}return Yr})(cr,Tt,sr.runs):(function(Xr,un,bi){const Yr=new BigInt64Array(Xr.size());let qr=0;for(let vr=0;vr<bi;vr++){const ii=Number(un[vr]),ci=un[vr+bi];for(let Or=qr;Or<qr+ii;Or++)Xr.get(Or)?Yr[Or]=ci:(Yr[Or]=0n,qr++);qr+=ii}return Yr})(cr,Tt,sr.runs)})($e,Ne,xt,gt);case ar.NONE:return $e=xt?(function(Tt,mt){const Ct=new BigInt64Array(Tt.size());let cr=0,sr=0;for(;sr!=Ct.length;++sr)if(Tt.get(sr)){const Xr=mt[cr++];Ct[sr]=Xr>>1n^-(1n&Xr)}else Ct[sr]=0n;return Ct})(gt,$e):(function(Tt,mt){const Ct=new BigInt64Array(Tt.size());let cr=0,sr=0;for(;sr!=Ct.length;++sr)Ct[sr]=Tt.get(sr)?mt[cr++]:0n;return Ct})(gt,$e),$e;default:throw new Error("The specified Logical level technique is not supported")}})(uc(He,Qe,et.numValues),et,pt,st)})(N,q,re,me,ue):X0(N,q,re,me);return new K0(Y.name,ze,ue)}if(he===Oi.SEQUENCE){const ze=H0(N,q,re);return new J0(Y.name,ze[0],ze[1],re.numRleValues)}{const ze=Y0(N,q,re,me);return new Ap(Y.name,ze,ue)}})(v,T,k,j,S);case 7:return(function(N,q,Y,ue){const J=Cn(N,q),re=Lu(ue)?(function(he,me,ze,He){const Qe=me.get(),et=Qe+He*Float32Array.BYTES_PER_ELEMENT,pt=new Uint8Array(he.subarray(Qe,et)).buffer,st=new Float32Array(pt);me.set(et);const $e=ze.size(),Ne=new Float32Array($e);let xt=0;for(let gt=0;gt<$e;gt++)Ne[gt]=ze.get(gt)?st[xt++]:0;return Ne})(N,q,ue,J.numValues):(function(he,me,ze){const He=me.get(),Qe=He+ze*Float32Array.BYTES_PER_ELEMENT,et=new Uint8Array(he.subarray(He,Qe)).buffer,pt=new Float32Array(et);return me.set(Qe),pt})(N,q,J.numValues);return new Jd(Y.name,re,ue)})(v,T,k,j);case 8:return(function(N,q,Y,ue){const J=Cn(N,q),re=Lu(ue)?(function(he,me,ze,He){const Qe=me.get(),et=Qe+He*Float64Array.BYTES_PER_ELEMENT,pt=new Uint8Array(he.subarray(Qe,et)).buffer,st=new Float64Array(pt);me.set(et);const $e=ze.size(),Ne=new Float64Array($e);let xt=0;for(let gt=0;gt<$e;gt++)Ne[gt]=ze.get(gt)?st[xt++]:0;return Ne})(N,q,ue,J.numValues):(function(he,me,ze){const He=me.get(),Qe=He+ze*Float64Array.BYTES_PER_ELEMENT,et=new Uint8Array(he.subarray(He,Qe)).buffer,pt=new Float64Array(et);return me.set(Qe),pt})(N,q,J.numValues);return new ih(Y.name,re,ue)})(v,T,k,j);default:throw new Error(`The specified data type for the field is currently not supported: ${S}`)}})(s,i,e,c,r.scalarType,r):s!=1?null:(function(m,v,T,E){let S=null,k=null,R=null,L=null,j=!1;for(;!j;){const ue=Cn(m,v);switch(ue.physicalStreamType){case ln.LENGTH:rs.DICTIONARY===ue.logicalStreamType.lengthType?S=ol(m,v,ue):R=ol(m,v,ue);break;case ln.DATA:po.SINGLE===ue.logicalStreamType.dictionaryType||po.SHARED===ue.logicalStreamType.dictionaryType?(k=m.subarray(v.get(),v.get()+ue.byteLength),j=!0):L=m.subarray(v.get(),v.get()+ue.byteLength),v.add(ue.byteLength)}}const N=T.complexType.children,q=[];let Y=0;for(const ue of N){const J=Xi(m,v,1)[0];if(J==0)continue;const re=`${T.name}${ue.name==="default"?"":":"+ue.name}`;if(J!==2||ue.type!=="scalarField"||ue.scalarField.physicalType!==9)throw new Error("Currently only optional string fields are implemented for a struct.");const he=Cn(m,v),me=Ru(m,he.numValues,v),ze=Cn(m,v),He=ze.decompressedCount!==E?Ah(m,v,ze,!1,new fo(me,he.numValues)):Dn(m,v,ze,!1);q[Y++]=L?new hp(re,He,S,k,R,L,new fo(me,he.numValues)):new YA(re,He,S,k,new fo(me,he.numValues))}return q})(i,e,r,c)}function Lu(i){return i instanceof fo}function rm(i){if(i.name==="id")return!1;if(i.type==="scalarType"){const e=i.scalarType;if(e.type==="physicalType")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}else if(e.type==="logicalType")return!1}else if(i.type==="complexType"){const e=i.complexType;if(e.type==="physicalType")switch(e.physicalType){case 0:case 1:return!0;default:return!1}}return console.warn("Unexpected column type in hasStreamCount",i),!1}const im=new TextDecoder;function pp(i,e){const r=Xi(i,e,1)[0];if(r===0)return"";const s=e.get(),c=i.subarray(s,s+r);return e.add(r),im.decode(c)}function fp(i,e){const r=Xi(i,e,1)[0]>>>0,s=!!(4&r),c=!!(2&r),p=Xi(i,e,1)[0]>>>0,m={};if(1&r&&(m.nullable=!0),c){const v={};if(s?(v.type="logicalType",v.logicalType=p):(v.type="physicalType",v.physicalType=p),8&r){const T=Xi(i,e,1)[0]>>>0;v.children=new Array(T);for(let E=0;E<T;E++)v.children[E]=fp(i,e)}m.type="complexField",m.complexField=v}else{const v={};s?(v.type="logicalType",v.logicalType=p):(v.type="physicalType",v.physicalType=p),m.type="scalarField",m.scalarField=v}return m}function nm(i,e){const r=Xi(i,e,1)[0]>>>0,s=(function(c){switch(c){case 0:case 1:case 2:case 3:{const p={};p.nullable=!!(1&c),p.columnScope=0;const m={};return m.physicalType=c>1?6:4,m.type="physicalType",p.scalarType=m,p.type="scalarType",p}case 4:{const p={nullable:!1,columnScope:0},m={type:"physicalType",physicalType:0};return p.type="complexType",p.complexType=m,p}case 30:{const p={nullable:!1,columnScope:0},m={type:"physicalType",physicalType:1};return p.type="complexType",p.complexType=m,p}default:return(function(p){let m=null;switch(p){case 10:case 11:m=0;break;case 12:case 13:m=1;break;case 14:case 15:m=2;break;case 16:case 17:m=3;break;case 18:case 19:m=4;break;case 20:case 21:m=5;break;case 22:case 23:m=6;break;case 24:case 25:m=7;break;case 26:case 27:m=8;break;case 28:case 29:m=9;break;default:return null}const v={};v.nullable=!!(1&p),v.columnScope=0;const T={type:"physicalType"};return T.physicalType=m,v.type="scalarType",v.scalarType=T,v})(c)}})(r);if(!s)throw new Error(`Unsupported column type code: ${r}`);if((function(c){return c>=10})(r)?s.name=pp(i,e):r>=0&&r<=3?s.name="id":r===4&&(s.name="geometry"),(function(c){return c===30})(r)){const c=Xi(i,e,1)[0]>>>0,p=s.complexType;p.children=new Array(c);for(let m=0;m<c;m++)p.children[m]=fp(i,e)}return s}function sm(i,e){const r={featureTables:[]},s={};s.name=pp(i,e);const c=Xi(i,e,1)[0]>>>0,p=Xi(i,e,1)[0]>>>0;s.columns=new Array(p);for(let m=0;m<p;m++)s.columns[m]=nm(i,e);return r.featureTables.push(s),[r,c]}function om(i,e,r,s,c,p,m=!1){const v=e.scalarType.physicalType,T=hc(c,p,i,r);if(v===4)switch(T){case Oi.FLAT:{const E=Dn(i,r,c,!1);return new rh(s,E,p)}case Oi.SEQUENCE:{const E=W0(i,r,c);return new nh(s,E[0],E[1],c.numRleValues)}case Oi.CONST:{const E=lh(i,r,c,!1);return new sh(s,E,p)}}else switch(T){case Oi.FLAT:{if(m){const S=(function(k,R,L,j){const N=(function(q,Y,ue){const J=new Float64Array(Y);for(let re=0;re<Y;re++)J[re]=Qd(q,ue);return J})(k,L.numValues,R);return(function(q,Y,ue){switch(Y.logicalLevelTechnique1){case ar.DELTA:return Y.logicalLevelTechnique2===ar.RLE&&(q=Q0(q,Y.runs,Y.numRleValues)),(function(J){J[0]=J[0]%2==1?(J[0]+1)/-2:J[0]/2;const re=J.length/4*4;let he=1;if(re>=4)for(;he<re-4;he+=4){const me=J[he],ze=J[he+1],He=J[he+2],Qe=J[he+3];J[he]=(me%2==1?(me+1)/-2:me/2)+J[he-1],J[he+1]=(ze%2==1?(ze+1)/-2:ze/2)+J[he],J[he+2]=(He%2==1?(He+1)/-2:He/2)+J[he+1],J[he+3]=(Qe%2==1?(Qe+1)/-2:Qe/2)+J[he+2]}for(;he!=J.length;++he)J[he]=(J[he]%2==1?(J[he]+1)/-2:J[he]/2)+J[he-1]})(q),q;case ar.RLE:return(function(J,re,he){return Q0(J,re.runs,re.numRleValues)})(q,Y);case ar.NONE:return q;default:throw new Error(`The specified Logical level technique is not supported: ${Y.logicalLevelTechnique1}`)}})(N,L)})(i,r,c);return new ih(s,S,p)}const E=X0(i,r,c,!1);return new K0(s,E,p)}case Oi.SEQUENCE:{const E=H0(i,r,c);return new J0(s,E[0],E[1],c.numRleValues)}case Oi.CONST:{const E=Y0(i,r,c,!1);return new Ap(s,E,p)}}throw new Error("Vector type not supported for id column.")}class am{constructor(e,r){var s;switch(this._featureData=e,this.properties=this._featureData.properties||{},(s=this._featureData.geometry)===null||s===void 0?void 0:s.type){case Vi.POINT:case Vi.MULTIPOINT:this.type=1;break;case Vi.LINESTRING:case Vi.MULTILINESTRING:this.type=2;break;case Vi.POLYGON:case Vi.MULTIPOLYGON:this.type=3;break;default:this.type=0}this.extent=r,this.id=Number(this._featureData.id)}loadGeometry(){const e=[];for(const r of this._featureData.geometry.coordinates){const s=[];for(const c of r)s.push(new nt(c.x,c.y));e.push(s)}return e}}class lm{constructor(e){this.features=[],this.featureTable=e,this.name=e.name,this.extent=e.extent,this.version=2,this.features=e.getFeatures(),this.length=this.features.length}feature(e){return new am(this.features[e],this.extent)}}class dp{constructor(e){this.layers={};const r=(function(s,c,p=!0){const m=new Zd(0),v=[];for(;m.get()<s.length;){const T=Xi(s,m,1)[0]>>>0,E=m.get()+T;if(E>s.length)throw new Error(`Block overruns tile: ${E} > ${s.length}`);if(Xi(s,m,1)[0]>>>0!=1){m.set(E);continue}const S=sm(s,m),k=S[1],R=S[0].featureTables[0];let L=null,j=null;const N=[];let q=0;for(const ue of R.columns){const J=ue.name;if(J==="id"){let re=null;if(ue.nullable){const me=Cn(s,m),ze=m.get(),He=Ru(s,me.numValues,m);m.set(ze+me.byteLength),re=new fo(He,me.numValues)}const he=Cn(s,m);q=he.decompressedCount,L=om(s,ue,m,J,he,re??q,p)}else if(J==="geometry"){const re=Xi(s,m,1)[0];if(q===0){const he=m.get();q=Cn(s,m).decompressedCount,m.set(he)}j=Yd(s,re,m,q)}else{const re=rm(ue)?Xi(s,m,1)[0]:1;if(re===0&&ue.type==="scalarType")continue;const he=tm(s,m,ue,re,q);if(he)if(Array.isArray(he))for(const me of he)N.push(me);else N.push(he)}}const Y=new qd(R.name,j,L,N,k);v.push(Y),m.set(E)}return v})(new Uint8Array(e));this.layers=r.reduce(((s,c)=>Object.assign(Object.assign({},s),{[c.name]:new lm(c)})),{})}}class Am{constructor(e,r){this.feature=e,this.type=e.type,this.properties=e.tags?e.tags:{},this.extent=r,"id"in e&&(typeof e.id=="string"?this.id=parseInt(e.id,10):typeof e.id!="number"||isNaN(e.id)||(this.id=e.id))}loadGeometry(){const e=[],r=this.feature.type===1?[this.feature.geometry]:this.feature.geometry;for(const s of r){const c=[];for(const p of s)c.push(new nt(p[0],p[1]));e.push(c)}return e}}const Fu="_geojsonTileLayer";function um(i,e){e.writeVarintField(15,i.version||1),e.writeStringField(1,i.name||""),e.writeVarintField(5,i.extent||4096);const r={keys:[],values:[],keycache:{},valuecache:{}};for(let p=0;p<i.length;p++)r.feature=i.feature(p),e.writeMessage(2,cm,r);const s=r.keys;for(const p of s)e.writeStringField(3,p);const c=r.values;for(const p of c)e.writeMessage(4,fm,p)}function cm(i,e){if(!i.feature)return;const r=i.feature;r.id!==void 0&&e.writeVarintField(1,r.id),e.writeMessage(2,hm,i),e.writeVarintField(3,r.type),e.writeMessage(4,pm,r)}function hm(i,e){var r;for(const s in(r=i.feature)==null?void 0:r.properties){let c=i.feature.properties[s],p=i.keycache[s];if(c==null)continue;p===void 0&&(i.keys.push(s),p=i.keys.length-1,i.keycache[s]=p),e.writeVarint(p),typeof c!="string"&&typeof c!="boolean"&&typeof c!="number"&&(c=JSON.stringify(c));const m=typeof c+":"+c;let v=i.valuecache[m];v===void 0&&(i.values.push(c),v=i.values.length-1,i.valuecache[m]=v),e.writeVarint(v)}}function gh(i,e){return(e<<3)+(7&i)}function mp(i){return i<<1^i>>31}function pm(i,e){const r=i.loadGeometry(),s=i.type;let c=0,p=0;for(const m of r){let v=1;s===1&&(v=m.length),e.writeVarint(gh(1,v));const T=s===3?m.length-1:m.length;for(let E=0;E<T;E++){E===1&&s!==1&&e.writeVarint(gh(2,T-1));const S=m[E].x-c,k=m[E].y-p;e.writeVarint(mp(S)),e.writeVarint(mp(k)),c+=S,p+=k}i.type===3&&e.writeVarint(gh(7,1))}}function fm(i,e){const r=typeof i;r==="string"?e.writeStringField(1,i):r==="boolean"?e.writeBooleanField(7,i):r==="number"&&(i%1!=0?e.writeDoubleField(3,i):i<0?e.writeSVarintField(6,i):e.writeVarintField(5,i))}class gp{constructor(e,r){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new Nn(dr,16,0),this.grid3D=new Nn(dr,16,0),this.featureIndexArray=new X,this.promoteId=r}insert(e,r,s,c,p,m){const v=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(s,c,p);const T=m?this.grid3D:this.grid;for(let E=0;E<r.length;E++){const S=r[E],k=[1/0,1/0,-1/0,-1/0];for(let R=0;R<S.length;R++){const L=S[R];k[0]=Math.min(k[0],L.x),k[1]=Math.min(k[1],L.y),k[2]=Math.max(k[2],L.x),k[3]=Math.max(k[3],L.y)}k[0]<dr&&k[1]<dr&&k[2]>=0&&k[3]>=0&&T.insert(v,k[0],k[1],k[2],k[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=this.encoding!=="mlt"?new r0(new nc(this.rawTileData)).layers:new dp(this.rawTileData).layers,this.sourceLayerCoder=new V0(this.vtLayers?Object.keys(this.vtLayers).sort():[Fu])),this.vtLayers}query(e,r,s,c){this.loadVTLayers();const p=e.params,m=dr/e.tileSize/e.scale,v=Ao(p.filter,p.globalState),T=e.queryGeometry,E=e.queryPadding*m,S=ql.fromPoints(T),k=this.grid.query(S.minX-E,S.minY-E,S.maxX+E,S.maxY+E),R=ql.fromPoints(e.cameraQueryGeometry).expandBy(E),L=this.grid3D.query(R.minX,R.minY,R.maxX,R.maxY,((q,Y,ue,J)=>(function(re,he,me,ze,He){for(const et of re)if(he<=et.x&&me<=et.y&&ze>=et.x&&He>=et.y)return!0;const Qe=[new nt(he,me),new nt(he,He),new nt(ze,He),new nt(ze,me)];if(re.length>2){for(const et of Qe)if(VA(re,et))return!0}for(let et=0;et<re.length-1;et++)if(mf(re[et],re[et+1],Qe))return!0;return!1})(e.cameraQueryGeometry,q-E,Y-E,ue+E,J+E)));for(const q of L)k.push(q);k.sort(dm);const j={};let N;for(let q=0;q<k.length;q++){const Y=k[q];if(Y===N)continue;N=Y;const ue=this.featureIndexArray.get(Y);let J=null;this.loadMatchingFeature(j,ue.bucketIndex,ue.sourceLayerIndex,ue.featureIndex,v,p.layers,p.availableImages,r,s,c,((re,he,me)=>(J||(J=Ko(re)),he.queryIntersectsFeature({queryGeometry:T,feature:re,featureState:me,geometry:J,zoom:this.z,transform:e.transform,pixelsToTileUnits:m,pixelPosMatrix:e.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:e.getElevation}))))}return j}loadMatchingFeature(e,r,s,c,p,m,v,T,E,S,k){const R=this.bucketLayerIDs[r];if(m&&!R.some((q=>m.has(q))))return;const L=this.sourceLayerCoder.decode(s),j=this.vtLayers[L].feature(c);if(p.needGeometry){const q=Jo(j,!0);if(!p.filter(new Pe(this.tileID.overscaledZ),q,this.tileID.canonical))return}else if(!p.filter(new Pe(this.tileID.overscaledZ),j))return;const N=this.getId(j,L);for(let q=0;q<R.length;q++){const Y=R[q];if(m&&!m.has(Y))continue;const ue=T[Y];if(!ue)continue;let J={};N&&S&&(J=S.getState(ue.sourceLayer||Fu,N));const re=qi({},E[Y]);re.paint=_p(re.paint,ue.paint,j,J,v),re.layout=_p(re.layout,ue.layout,j,J,v);const he=!k||k(j,ue,J);if(!he)continue;const me=new j0(j,this.z,this.x,this.y,N);me.layer=re;let ze=e[Y];ze===void 0&&(ze=e[Y]=[]),ze.push({featureIndex:c,feature:me,intersectionZ:he})}}lookupSymbolFeatures(e,r,s,c,p,m,v,T){const E={};this.loadVTLayers();const S=Ao(p.filterSpec,p.globalState);for(const k of e)this.loadMatchingFeature(E,s,c,k,S,m,v,T,r);return E}hasLayer(e){for(const r of this.bucketLayerIDs)for(const s of r)if(e===s)return!0;return!1}getId(e,r){var s;let c=e.id;return this.promoteId&&(c=e.properties[typeof this.promoteId=="string"?this.promoteId:this.promoteId[r]],typeof c=="boolean"&&(c=Number(c)),c===void 0&&(!((s=e.properties)===null||s===void 0)&&s.cluster)&&this.promoteId&&(c=Number(e.properties.cluster_id))),c}}function _p(i,e,r,s,c){return zn(i,((p,m)=>{const v=e instanceof At?e.get(m):null;return v&&v.evaluate?v.evaluate(r,s,c):v}))}function dm(i,e){return e-i}function yp(i,e,r,s,c){const p=[];for(let m=0;m<i.length;m++){const v=i[m];let T;for(let E=0;E<v.length-1;E++){let S=v[E],k=v[E+1];S.x<e&&k.x<e||(S.x<e?S=new nt(e,S.y+(e-S.x)/(k.x-S.x)*(k.y-S.y))._round():k.x<e&&(k=new nt(e,S.y+(e-S.x)/(k.x-S.x)*(k.y-S.y))._round()),S.y<r&&k.y<r||(S.y<r?S=new nt(S.x+(r-S.y)/(k.y-S.y)*(k.x-S.x),r)._round():k.y<r&&(k=new nt(S.x+(r-S.y)/(k.y-S.y)*(k.x-S.x),r)._round()),S.x>=s&&k.x>=s||(S.x>=s?S=new nt(s,S.y+(s-S.x)/(k.x-S.x)*(k.y-S.y))._round():k.x>=s&&(k=new nt(s,S.y+(s-S.x)/(k.x-S.x)*(k.y-S.y))._round()),S.y>=c&&k.y>=c||(S.y>=c?S=new nt(S.x+(c-S.y)/(k.y-S.y)*(k.x-S.x),c)._round():k.y>=c&&(k=new nt(S.x+(c-S.y)/(k.y-S.y)*(k.x-S.x),c)._round()),T&&S.equals(T[T.length-1])||(T=[S],p.push(T)),T.push(k)))))}}return p}function vp(i,e,r,s,c){switch(e){case 1:return(function(p,m,v,T){const E=[];for(const S of p)for(const k of S){const R=T===0?k.x:k.y;R>=m&&R<=v&&E.push([k])}return E})(i,r,s,c);case 2:return xp(i,r,s,c,!1);case 3:return xp(i,r,s,c,!0)}return[]}function mm(i,e,r,s,c){const p=s===0?gm:_m;let m=[];const v=[];for(let S=0;S<i.length-1;S++){const k=i[S],R=i[S+1],L=s===0?k.x:k.y,j=s===0?R.x:R.y;let N=!1;L<e?j>e&&m.push(p(k,R,e)):L>r?j<r&&m.push(p(k,R,r)):m.push(k),j<e&&L>=e&&(m.push(p(k,R,e)),N=!0),j>r&&L<=r&&(m.push(p(k,R,r)),N=!0),!c&&N&&(v.push(m),m=[])}const T=i.length-1,E=s===0?i[T].x:i[T].y;return E>=e&&E<=r&&m.push(i[T]),c&&m.length>0&&!m[0].equals(m[m.length-1])&&m.push(new nt(m[0].x,m[0].y)),m.length>0&&v.push(m),v}function xp(i,e,r,s,c){const p=[];for(const m of i){const v=mm(m,e,r,s,c);v.length>0&&p.push(...v)}return p}function gm(i,e,r){return new nt(r,i.y+(r-i.x)/(e.x-i.x)*(e.y-i.y))}function _m(i,e,r){return new nt(i.x+(r-i.y)/(e.y-i.y)*(e.x-i.x),r)}yt("FeatureIndex",gp,{omit:["rawTileData","sourceLayerCoder"]});class al extends nt{constructor(e,r,s,c){super(e,r),this.angle=s,c!==void 0&&(this.segment=c)}clone(){return new al(this.x,this.y,this.angle,this.segment)}}function bp(i,e,r,s,c){if(e.segment===void 0||r===0)return!0;let p=e,m=e.segment+1,v=0;for(;v>-r/2;){if(m--,m<0)return!1;v-=i[m].dist(p),p=i[m]}v+=i[m].dist(i[m+1]),m++;const T=[];let E=0;for(;v<r/2;){const S=i[m],k=i[m+1];if(!k)return!1;let R=i[m-1].angleTo(S)-S.angleTo(k);for(R=Math.abs((R+3*Math.PI)%(2*Math.PI)-Math.PI),T.push({distance:v,angleDelta:R}),E+=R;v-T[0].distance>s;)E-=T.shift().angleDelta;if(E>c)return!1;m++,v+=S.dist(k)}return!0}function wp(i){let e=0;for(let r=0;r<i.length-1;r++)e+=i[r].dist(i[r+1]);return e}function Tp(i,e,r){return i?.6*e*r:0}function Pp(i,e){return Math.max(i?i.right-i.left:0,e?e.right-e.left:0)}function ym(i,e,r,s,c,p){const m=Tp(r,c,p),v=Pp(r,s)*p;let T=0;const E=wp(i)/2;for(let S=0;S<i.length-1;S++){const k=i[S],R=i[S+1],L=k.dist(R);if(T+L>E){const j=(E-T)/L,N=Sr.number(k.x,R.x,j),q=Sr.number(k.y,R.y,j),Y=new al(N,q,R.angleTo(k),S);return Y._round(),!m||bp(i,Y,v,m,e)?Y:void 0}T+=L}}function vm(i,e,r,s,c,p,m,v,T){const E=Tp(s,p,m),S=Pp(s,c),k=S*m,R=i[0].x===0||i[0].x===T||i[0].y===0||i[0].y===T;return e-k<e/4&&(e=k+e/4),Mp(i,R?e/2*v%e:(S/2+2*p)*m*v%e,e,E,r,k,R,!1,T)}function Mp(i,e,r,s,c,p,m,v,T){const E=p/2,S=wp(i);let k=0,R=e-r,L=[];for(let j=0;j<i.length-1;j++){const N=i[j],q=i[j+1],Y=N.dist(q),ue=q.angleTo(N);for(;R+r<k+Y;){R+=r;const J=(R-k)/Y,re=Sr.number(N.x,q.x,J),he=Sr.number(N.y,q.y,J);if(re>=0&&re<T&&he>=0&&he<T&&R-E>=0&&R+E<=S){const me=new al(re,he,ue,j);me._round(),s&&!bp(i,me,p,s,c)||L.push(me)}}k+=Y}return v||L.length||m||(L=Mp(i,k/2,r,s,c,p,m,!0,T)),L}function Ep(i,e,r,s){const c=[],p=i.image,m=p.pixelRatio,v=p.paddedRect.w-2,T=p.paddedRect.h-2;let E={x1:i.left,y1:i.top,x2:i.right,y2:i.bottom};const S=p.stretchX||[[0,v]],k=p.stretchY||[[0,T]],R=(Ne,xt)=>Ne+xt[1]-xt[0],L=S.reduce(R,0),j=k.reduce(R,0),N=v-L,q=T-j;let Y=0,ue=L,J=0,re=j,he=0,me=N,ze=0,He=q;if(p.content&&s){const Ne=p.content,xt=Ne[2]-Ne[0],gt=Ne[3]-Ne[1];(p.textFitWidth||p.textFitHeight)&&(E=b0(i)),Y=mc(S,0,Ne[0]),J=mc(k,0,Ne[1]),ue=mc(S,Ne[0],Ne[2]),re=mc(k,Ne[1],Ne[3]),he=Ne[0]-Y,ze=Ne[1]-J,me=xt-ue,He=gt-re}const Qe=E.x1,et=E.y1,pt=E.x2-Qe,st=E.y2-et,$e=(Ne,xt,gt,Tt)=>{const mt=gc(Ne.stretch-Y,ue,pt,Qe),Ct=_c(Ne.fixed-he,me,Ne.stretch,L),cr=gc(xt.stretch-J,re,st,et),sr=_c(xt.fixed-ze,He,xt.stretch,j),Xr=gc(gt.stretch-Y,ue,pt,Qe),un=_c(gt.fixed-he,me,gt.stretch,L),bi=gc(Tt.stretch-J,re,st,et),Yr=_c(Tt.fixed-ze,He,Tt.stretch,j),qr=new nt(mt,cr),vr=new nt(Xr,cr),ii=new nt(Xr,bi),ci=new nt(mt,bi),Or=new nt(Ct/m,sr/m),qn=new nt(un/m,Yr/m),cn=e*Math.PI/180;if(cn){const ji=Math.sin(cn),ti=Math.cos(cn),wi=[ti,-ji,ji,ti];qr._matMult(wi),vr._matMult(wi),ci._matMult(wi),ii._matMult(wi)}const Zn=Ne.stretch+Ne.fixed,js=xt.stretch+xt.fixed;return{tl:qr,tr:vr,bl:ci,br:ii,tex:{x:p.paddedRect.x+1+Zn,y:p.paddedRect.y+1+js,w:gt.stretch+gt.fixed-Zn,h:Tt.stretch+Tt.fixed-js},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:Or,pixelOffsetBR:qn,minFontScaleX:me/m/pt,minFontScaleY:He/m/st,isSDF:r}};if(s&&(p.stretchX||p.stretchY)){const Ne=Ip(S,N,L),xt=Ip(k,q,j);for(let gt=0;gt<Ne.length-1;gt++){const Tt=Ne[gt],mt=Ne[gt+1];for(let Ct=0;Ct<xt.length-1;Ct++)c.push($e(Tt,xt[Ct],mt,xt[Ct+1]))}}else c.push($e({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:v+1},{fixed:0,stretch:T+1}));return c}function mc(i,e,r){let s=0;for(const c of i)s+=Math.max(e,Math.min(r,c[1]))-Math.max(e,Math.min(r,c[0]));return s}function Ip(i,e,r){const s=[{fixed:-1,stretch:0}];for(const[c,p]of i){const m=s[s.length-1];s.push({fixed:c-m.stretch,stretch:m.stretch}),s.push({fixed:c-m.stretch,stretch:m.stretch+(p-c)})}return s.push({fixed:e+1,stretch:r}),s}function gc(i,e,r,s){return i/e*r+s}function _c(i,e,r,s){return i-e*r/s}yt("Anchor",al);class yc{constructor(e,r,s,c,p,m,v,T,E,S){var k;if(this.boxStartIndex=e.length,E){let R=m.top,L=m.bottom;const j=m.collisionPadding;j&&(R-=j[1],L+=j[3]);let N=L-R;N>0&&(N=Math.max(10,N),this.circleDiameter=N)}else{const R=!((k=m.image)===null||k===void 0)&&k.content&&(m.image.textFitWidth||m.image.textFitHeight)?b0(m):{x1:m.left,y1:m.top,x2:m.right,y2:m.bottom};R.y1=R.y1*v-T[0],R.y2=R.y2*v+T[2],R.x1=R.x1*v-T[3],R.x2=R.x2*v+T[1];const L=m.collisionPadding;if(L&&(R.x1-=L[0]*v,R.y1-=L[1]*v,R.x2+=L[2]*v,R.y2+=L[3]*v),S){const j=new nt(R.x1,R.y1),N=new nt(R.x2,R.y1),q=new nt(R.x1,R.y2),Y=new nt(R.x2,R.y2),ue=S*Math.PI/180;j._rotate(ue),N._rotate(ue),q._rotate(ue),Y._rotate(ue),R.x1=Math.min(j.x,N.x,q.x,Y.x),R.x2=Math.max(j.x,N.x,q.x,Y.x),R.y1=Math.min(j.y,N.y,q.y,Y.y),R.y2=Math.max(j.y,N.y,q.y,Y.y)}e.emplaceBack(r.x,r.y,R.x1,R.y1,R.x2,R.y2,s,c,p)}this.boxEndIndex=e.length}}class xm{constructor(e=[],r=(s,c)=>s<c?-1:s>c?1:0){if(this.data=e,this.length=this.data.length,this.compare=r,this.length>0)for(let s=(this.length>>1)-1;s>=0;s--)this._down(s)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(this.length===0)return;const e=this.data[0],r=this.data.pop();return--this.length>0&&(this.data[0]=r,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:r,compare:s}=this,c=r[e];for(;e>0;){const p=e-1>>1,m=r[p];if(s(c,m)>=0)break;r[e]=m,e=p}r[e]=c}_down(e){const{data:r,compare:s}=this,c=this.length>>1,p=r[e];for(;e<c;){let m=1+(e<<1);const v=m+1;if(v<this.length&&s(r[v],r[m])<0&&(m=v),s(r[m],p)>=0)break;r[e]=r[m],e=m}r[e]=p}}function bm(i,e=1,r=!1){const s=ql.fromPoints(i[0]),c=Math.min(s.width(),s.height());let p=c/2;const m=new xm([],wm),{minX:v,minY:T,maxX:E,maxY:S}=s;if(c===0)return new nt(v,T);for(let L=v;L<E;L+=c)for(let j=T;j<S;j+=c)m.push(new KA(L+p,j+p,p,i));let k=(function(L){let j=0,N=0,q=0;const Y=L[0];for(let ue=0,J=Y.length,re=J-1;ue<J;re=ue++){const he=Y[ue],me=Y[re],ze=he.x*me.y-me.x*he.y;N+=(he.x+me.x)*ze,q+=(he.y+me.y)*ze,j+=3*ze}return new KA(N/j,q/j,0,L)})(i),R=m.length;for(;m.length;){const L=m.pop();(L.d>k.d||!k.d)&&(k=L,r&&console.log("found best %d after %d probes",Math.round(1e4*L.d)/1e4,R)),L.max-k.d<=e||(p=L.h/2,m.push(new KA(L.p.x-p,L.p.y-p,p,i)),m.push(new KA(L.p.x+p,L.p.y-p,p,i)),m.push(new KA(L.p.x-p,L.p.y+p,p,i)),m.push(new KA(L.p.x+p,L.p.y+p,p,i)),R+=4)}return r&&(console.log(`num probes: ${R}`),console.log(`best distance: ${k.d}`)),k.p}function wm(i,e){return e.max-i.max}function KA(i,e,r,s){this.p=new nt(i,e),this.h=r,this.d=(function(c,p){let m=!1,v=1/0;for(let T=0;T<p.length;T++){const E=p[T];for(let S=0,k=E.length,R=k-1;S<k;R=S++){const L=E[S],j=E[R];L.y>c.y!=j.y>c.y&&c.x<(j.x-L.x)*(c.y-L.y)/(j.y-L.y)+L.x&&(m=!m),v=Math.min(v,zh(c,L,j))}}return(m?1:-1)*Math.sqrt(v)})(this.p,s),this.max=this.d+this.h*Math.SQRT2}var An;G.aP=void 0,(An=G.aP||(G.aP={}))[An.center=1]="center",An[An.left=2]="left",An[An.right=3]="right",An[An.top=4]="top",An[An.bottom=5]="bottom",An[An["top-left"]=6]="top-left",An[An["top-right"]=7]="top-right",An[An["bottom-left"]=8]="bottom-left",An[An["bottom-right"]=9]="bottom-right";const _h=Number.POSITIVE_INFINITY;function Sp(i,e){return e[1]!==_h?(function(r,s,c){let p=0,m=0;switch(s=Math.abs(s),c=Math.abs(c),r){case"top-right":case"top-left":case"top":m=c-7;break;case"bottom-right":case"bottom-left":case"bottom":m=7-c}switch(r){case"top-right":case"bottom-right":case"right":p=-s;break;case"top-left":case"bottom-left":case"left":p=s}return[p,m]})(i,e[0],e[1]):(function(r,s){let c=0,p=0;s<0&&(s=0);const m=s/Math.SQRT2;switch(r){case"top-right":case"top-left":p=m-7;break;case"bottom-right":case"bottom-left":p=7-m;break;case"bottom":p=7-s;break;case"top":p=s-7}switch(r){case"top-right":case"bottom-right":c=-m;break;case"top-left":case"bottom-left":c=m;break;case"left":c=s;break;case"right":c=-s}return[c,p]})(i,e[0])}function Cp(i,e,r){var s;const c=i.layout,p=(s=c.get("text-variable-anchor-offset"))===null||s===void 0?void 0:s.evaluate(e,{},r);if(p){const v=p.values,T=[];for(let E=0;E<v.length;E+=2){const S=T[E]=v[E],k=v[E+1].map((R=>R*Fi));S.startsWith("top")?k[1]-=7:S.startsWith("bottom")&&(k[1]+=7),T[E+1]=k}return new Qi(T)}const m=c.get("text-variable-anchor");if(m){let v;v=i._unevaluatedLayout.getValue("text-radial-offset")!==void 0?[c.get("text-radial-offset").evaluate(e,{},r)*Fi,_h]:c.get("text-offset").evaluate(e,{},r).map((E=>E*Fi));const T=[];for(const E of m)T.push(E,Sp(E,v));return new Qi(T)}return null}function yh(i){switch(i){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function Tm(i,e,r,s,c,p,m,v,T,E,S,k){let R=p.textMaxSize.evaluate(e,{});R===void 0&&(R=m);const L=i.layers[0].layout,j=L.get("icon-offset").evaluate(e,{},S),N=kp(r.horizontal),q=m/24,Y=i.tilePixelRatio*q,ue=i.tilePixelRatio*R/24,J=i.tilePixelRatio*v,re=i.tilePixelRatio*L.get("symbol-spacing"),he=L.get("text-padding")*i.tilePixelRatio,me=(function(gt,Tt,mt,Ct=1){const cr=gt.get("icon-padding").evaluate(Tt,{},mt),sr=cr&&cr.values;return[sr[0]*Ct,sr[1]*Ct,sr[2]*Ct,sr[3]*Ct]})(L,e,S,i.tilePixelRatio),ze=L.get("text-max-angle")/180*Math.PI,He=L.get("text-rotation-alignment")!=="viewport"&&L.get("symbol-placement")!=="point",Qe=L.get("icon-rotation-alignment")==="map"&&L.get("symbol-placement")!=="point",et=L.get("symbol-placement"),pt=re/2,st=L.get("icon-text-fit");let $e;s&&st!=="none"&&(i.allowVerticalPlacement&&r.vertical&&($e=w0(s,r.vertical,st,L.get("icon-text-fit-padding"),j,q)),N&&(s=w0(s,N,st,L.get("icon-text-fit-padding"),j,q)));const Ne=S?k.line.getGranularityForZoomLevel(S.z):1,xt=(gt,Tt)=>{Tt.x<0||Tt.x>=dr||Tt.y<0||Tt.y>=dr||(function(mt,Ct,cr,sr,Xr,un,bi,Yr,qr,vr,ii,ci,Or,qn,cn,Zn,js,ji,ti,wi,ni,Ni,Ba,mo,ju){const ll=mt.addToLineVertexArray(Ct,cr);let $l,JA,eu,tu,Lp=0,Fp=0,Op=0,Vp=0,Eh=-1,Ih=-1;const Ra={};let jp=ui("");if(mt.allowVerticalPlacement&&sr.vertical){const vn=Yr.layout.get("text-rotate").evaluate(ni,{},mo)+90;eu=new yc(qr,Ct,vr,ii,ci,sr.vertical,Or,qn,cn,vn),bi&&(tu=new yc(qr,Ct,vr,ii,ci,bi,js,ji,cn,vn))}if(Xr){const vn=Yr.layout.get("icon-rotate").evaluate(ni,{}),vs=Yr.layout.get("icon-text-fit")!=="none",Wl=Ep(Xr,vn,Ba,vs),_o=bi?Ep(bi,vn,Ba,vs):void 0;JA=new yc(qr,Ct,vr,ii,ci,Xr,js,ji,!1,vn),Lp=4*Wl.length;const Hl=mt.iconSizeData;let ea=null;Hl.kind==="source"?(ea=[ka*Yr.layout.get("icon-size").evaluate(ni,{})],ea[0]>nl&&di(`${mt.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):Hl.kind==="composite"&&(ea=[ka*Ni.compositeIconSizes[0].evaluate(ni,{},mo),ka*Ni.compositeIconSizes[1].evaluate(ni,{},mo)],(ea[0]>nl||ea[1]>nl)&&di(`${mt.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),mt.addSymbols(mt.icon,Wl,ea,wi,ti,ni,G.az.none,Ct,ll.lineStartIndex,ll.lineLength,-1,mo),Eh=mt.icon.placedSymbolArray.length-1,_o&&(Fp=4*_o.length,mt.addSymbols(mt.icon,_o,ea,wi,ti,ni,G.az.vertical,Ct,ll.lineStartIndex,ll.lineLength,-1,mo),Ih=mt.icon.placedSymbolArray.length-1)}const Np=Object.keys(sr.horizontal);for(const vn of Np){const vs=sr.horizontal[vn];if(!$l){jp=ui(vs.text);const _o=Yr.layout.get("text-rotate").evaluate(ni,{},mo);$l=new yc(qr,Ct,vr,ii,ci,vs,Or,qn,cn,_o)}const Wl=vs.positionedLines.length===1;if(Op+=Dp(mt,Ct,vs,un,Yr,cn,ni,Zn,ll,sr.vertical?G.az.horizontal:G.az.horizontalOnly,Wl?Np:[vn],Ra,Eh,Ni,mo),Wl)break}sr.vertical&&(Vp+=Dp(mt,Ct,sr.vertical,un,Yr,cn,ni,Zn,ll,G.az.vertical,["vertical"],Ra,Ih,Ni,mo));const Em=$l?$l.boxStartIndex:mt.collisionBoxArray.length,Im=$l?$l.boxEndIndex:mt.collisionBoxArray.length,Sm=eu?eu.boxStartIndex:mt.collisionBoxArray.length,Cm=eu?eu.boxEndIndex:mt.collisionBoxArray.length,Dm=JA?JA.boxStartIndex:mt.collisionBoxArray.length,km=JA?JA.boxEndIndex:mt.collisionBoxArray.length,zm=tu?tu.boxStartIndex:mt.collisionBoxArray.length,Bm=tu?tu.boxEndIndex:mt.collisionBoxArray.length;let go=-1;const xc=(vn,vs)=>vn&&vn.circleDiameter?Math.max(vn.circleDiameter,vs):vs;go=xc($l,go),go=xc(eu,go),go=xc(JA,go),go=xc(tu,go);const Gp=go>-1?1:0;Gp&&(go*=ju/Fi),mt.glyphOffsetArray.length>=QA.MAX_GLYPHS&&di("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),ni.sortKey!==void 0&&mt.addToSortKeyRanges(mt.symbolInstances.length,ni.sortKey);const Rm=Cp(Yr,ni,mo),[Lm,Fm]=(function(vn,vs){const Wl=vn.length,_o=vs==null?void 0:vs.values;if((_o==null?void 0:_o.length)>0)for(let Hl=0;Hl<_o.length;Hl+=2){const ea=_o[Hl+1];vn.emplaceBack(G.aP[_o[Hl]],ea[0],ea[1])}return[Wl,vn.length]})(mt.textAnchorOffsets,Rm);mt.symbolInstances.emplaceBack(Ct.x,Ct.y,Ra.right>=0?Ra.right:-1,Ra.center>=0?Ra.center:-1,Ra.left>=0?Ra.left:-1,Ra.vertical||-1,Eh,Ih,jp,Em,Im,Sm,Cm,Dm,km,zm,Bm,vr,Op,Vp,Lp,Fp,Gp,0,Or,go,Lm,Fm)})(i,Tt,gt,r,s,c,$e,i.layers[0],i.collisionBoxArray,e.index,e.sourceLayerIndex,i.index,Y,[he,he,he,he],He,T,J,me,Qe,j,e,p,E,S,m)};if(et==="line")for(const gt of yp(e.geometry,0,0,dr,dr)){const Tt=Ul(gt,Ne),mt=vm(Tt,re,ze,r.vertical||N,s,24,ue,i.overscaling,dr);for(const Ct of mt)N&&Pm(i,N.text,pt,Ct)||xt(Tt,Ct)}else if(et==="line-center"){for(const gt of e.geometry)if(gt.length>1){const Tt=Ul(gt,Ne),mt=ym(Tt,ze,r.vertical||N,s,24,ue);mt&&xt(Tt,mt)}}else if(e.type==="Polygon")for(const gt of Na(e.geometry,0)){const Tt=bm(gt,16);xt(Ul(gt[0],Ne,!0),new al(Tt.x,Tt.y,0))}else if(e.type==="LineString")for(const gt of e.geometry){const Tt=Ul(gt,Ne);xt(Tt,new al(Tt[0].x,Tt[0].y,0))}else if(e.type==="Point")for(const gt of e.geometry)for(const Tt of gt)xt([Tt],new al(Tt.x,Tt.y,0))}function Dp(i,e,r,s,c,p,m,v,T,E,S,k,R,L,j){const N=(function(ue,J,re,he,me,ze,He,Qe){const et=he.layout.get("text-rotate").evaluate(ze,{})*Math.PI/180,pt=[];for(const st of J.positionedLines)for(const $e of st.positionedGlyphs){if(!$e.rect)continue;const Ne=$e.rect||{};let xt=4,gt=!0,Tt=1,mt=0;const Ct=(me||Qe)&&$e.vertical,cr=$e.metrics.advance*$e.scale/2;if(Qe&&J.verticalizable&&(mt=st.lineOffset/2-($e.imageName?-(Fi-$e.metrics.width*$e.scale)/2:($e.scale-1)*Fi)),$e.imageName){const ji=He[$e.imageName];gt=ji.sdf,Tt=ji.pixelRatio,xt=1/Tt}const sr=me?[$e.x+cr,$e.y]:[0,0];let Xr=me?[0,0]:[$e.x+cr+re[0],$e.y+re[1]-mt],un=[0,0];Ct&&(un=Xr,Xr=[0,0]);const bi=$e.metrics.isDoubleResolution?2:1,Yr=($e.metrics.left-xt)*$e.scale-cr+Xr[0],qr=(-$e.metrics.top-xt)*$e.scale+Xr[1],vr=Yr+Ne.w/bi*$e.scale/Tt,ii=qr+Ne.h/bi*$e.scale/Tt,ci=new nt(Yr,qr),Or=new nt(vr,qr),qn=new nt(Yr,ii),cn=new nt(vr,ii);if(Ct){const ji=new nt(-cr,cr- -17),ti=-Math.PI/2,wi=12-cr,ni=new nt(22-wi,-($e.imageName?wi:0)),Ni=new nt(...un);ci._rotateAround(ti,ji)._add(ni)._add(Ni),Or._rotateAround(ti,ji)._add(ni)._add(Ni),qn._rotateAround(ti,ji)._add(ni)._add(Ni),cn._rotateAround(ti,ji)._add(ni)._add(Ni)}if(et){const ji=Math.sin(et),ti=Math.cos(et),wi=[ti,-ji,ji,ti];ci._matMult(wi),Or._matMult(wi),qn._matMult(wi),cn._matMult(wi)}const Zn=new nt(0,0),js=new nt(0,0);pt.push({tl:ci,tr:Or,bl:qn,br:cn,tex:Ne,writingMode:J.writingMode,glyphOffset:sr,sectionIndex:$e.sectionIndex,isSDF:gt,pixelOffsetTL:Zn,pixelOffsetBR:js,minFontScaleX:0,minFontScaleY:0})}return pt})(0,r,v,c,p,m,s,i.allowVerticalPlacement),q=i.textSizeData;let Y=null;q.kind==="source"?(Y=[ka*c.layout.get("text-size").evaluate(m,{})],Y[0]>nl&&di(`${i.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):q.kind==="composite"&&(Y=[ka*L.compositeTextSizes[0].evaluate(m,{},j),ka*L.compositeTextSizes[1].evaluate(m,{},j)],(Y[0]>nl||Y[1]>nl)&&di(`${i.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),i.addSymbols(i.text,N,Y,v,p,m,E,e,T.lineStartIndex,T.lineLength,R,j);for(const ue of S)k[ue]=i.text.placedSymbolArray.length-1;return 4*N.length}function kp(i){for(const e in i)return i[e];return null}function Pm(i,e,r,s){const c=i.compareText;if(e in c){const p=c[e];for(let m=p.length-1;m>=0;m--)if(s.dist(p[m])<r)return!0}else c[e]=[];return c[e].push(s),!1}const zp=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class vh{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[r,s]=new Uint8Array(e,0,2);if(r!==219)throw new Error("Data does not appear to be in a KDBush format.");const c=s>>4;if(c!==1)throw new Error(`Got v${c} data when expected v1.`);const p=zp[15&s];if(!p)throw new Error("Unrecognized array type.");const[m]=new Uint16Array(e,2,1),[v]=new Uint32Array(e,4,1);return new vh(v,m,p,e)}constructor(e,r=64,s=Float64Array,c){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+r,2),65535),this.ArrayType=s,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const p=zp.indexOf(this.ArrayType),m=2*e*this.ArrayType.BYTES_PER_ELEMENT,v=e*this.IndexArrayType.BYTES_PER_ELEMENT,T=(8-v%8)%8;if(p<0)throw new Error(`Unexpected typed array class: ${s}.`);c&&c instanceof ArrayBuffer?(this.data=c,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+v+T,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+m+v+T),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+v+T,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+p]),new Uint16Array(this.data,2,1)[0]=r,new Uint32Array(this.data,4,1)[0]=e)}add(e,r){const s=this._pos>>1;return this.ids[s]=s,this.coords[this._pos++]=e,this.coords[this._pos++]=r,s}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return xh(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,r,s,c){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:p,coords:m,nodeSize:v}=this,T=[0,p.length-1,0],E=[];for(;T.length;){const S=T.pop()||0,k=T.pop()||0,R=T.pop()||0;if(k-R<=v){for(let q=R;q<=k;q++){const Y=m[2*q],ue=m[2*q+1];Y>=e&&Y<=s&&ue>=r&&ue<=c&&E.push(p[q])}continue}const L=R+k>>1,j=m[2*L],N=m[2*L+1];j>=e&&j<=s&&N>=r&&N<=c&&E.push(p[L]),(S===0?e<=j:r<=N)&&(T.push(R),T.push(L-1),T.push(1-S)),(S===0?s>=j:c>=N)&&(T.push(L+1),T.push(k),T.push(1-S))}return E}within(e,r,s){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:c,coords:p,nodeSize:m}=this,v=[0,c.length-1,0],T=[],E=s*s;for(;v.length;){const S=v.pop()||0,k=v.pop()||0,R=v.pop()||0;if(k-R<=m){for(let q=R;q<=k;q++)Rp(p[2*q],p[2*q+1],e,r)<=E&&T.push(c[q]);continue}const L=R+k>>1,j=p[2*L],N=p[2*L+1];Rp(j,N,e,r)<=E&&T.push(c[L]),(S===0?e-s<=j:r-s<=N)&&(v.push(R),v.push(L-1),v.push(1-S)),(S===0?e+s>=j:r+s>=N)&&(v.push(L+1),v.push(k),v.push(1-S))}return T}}function xh(i,e,r,s,c,p){if(c-s<=r)return;const m=s+c>>1;Bp(i,e,m,s,c,p),xh(i,e,r,s,m-1,1-p),xh(i,e,r,m+1,c,1-p)}function Bp(i,e,r,s,c,p){for(;c>s;){if(c-s>600){const E=c-s+1,S=r-s+1,k=Math.log(E),R=.5*Math.exp(2*k/3),L=.5*Math.sqrt(k*R*(E-R)/E)*(S-E/2<0?-1:1);Bp(i,e,r,Math.max(s,Math.floor(r-S*R/E+L)),Math.min(c,Math.floor(r+(E-S)*R/E+L)),p)}const m=e[2*r+p];let v=s,T=c;for(Ou(i,e,s,r),e[2*c+p]>m&&Ou(i,e,s,c);v<T;){for(Ou(i,e,v,T),v++,T--;e[2*v+p]<m;)v++;for(;e[2*T+p]>m;)T--}e[2*s+p]===m?Ou(i,e,s,T):(T++,Ou(i,e,T,c)),T<=r&&(s=T+1),r<=T&&(c=T-1)}}function Ou(i,e,r,s){bh(i,r,s),bh(e,2*r,2*s),bh(e,2*r+1,2*s+1)}function bh(i,e,r){const s=i[e];i[e]=i[r],i[r]=s}function Rp(i,e,r,s){const c=i-r,p=e-s;return c*c+p*p}var wh;G.cH=void 0,(wh=G.cH||(G.cH={})).create="create",wh.load="load",wh.fullLoad="fullLoad";let vc=null,Vu=[];const Th=1e3/60,Ph="loadTime",Mh="fullLoadTime",Mm={mark(i){performance.mark(i)},frame(i){const e=i;vc!=null&&Vu.push(e-vc),vc=e},clearMetrics(){vc=null,Vu=[],performance.clearMeasures(Ph),performance.clearMeasures(Mh);for(const i in G.cH)performance.clearMarks(G.cH[i])},getPerformanceMetrics(){performance.measure(Ph,G.cH.create,G.cH.load),performance.measure(Mh,G.cH.create,G.cH.fullLoad);const i=performance.getEntriesByName(Ph)[0].duration,e=performance.getEntriesByName(Mh)[0].duration,r=Vu.length,s=1/(Vu.reduce(((p,m)=>p+m),0)/r/1e3),c=Vu.filter((p=>p>Th)).reduce(((p,m)=>p+(m-Th)/Th),0);return{loadTime:i,fullLoadTime:e,fps:s,percentDroppedFrames:c/(r+c)*100,totalFrames:r}}};G.$=Ze,G.A=Rr,G.B=ds,G.C=Ye,G.D=at,G.E=hr,G.F=function([i,e,r]){return e+=90,e*=Math.PI/180,r*=Math.PI/180,{x:i*Math.cos(e)*Math.sin(r),y:i*Math.sin(e)*Math.sin(r),z:i*Math.cos(r)}},G.G=Sr,G.H=Pe,G.I=Qc,G.J=el,G.K=function(i){if(xr==null){const e=i.navigator?i.navigator.userAgent:null;xr=!!i.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return xr},G.L=class{constructor(i,e){this.target=i,this.mapId=e,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new Nd((()=>this.process())),this.subscription=Hs(this.target,"message",(r=>this.receive(r)),!1),this.globalScope=Wn(self)?i:window}registerMessageHandler(i,e){this.messageHandlers[i]=e}unregisterMessageHandler(i){delete this.messageHandlers[i]}sendAsync(i,e){return new Promise(((r,s)=>{const c=Math.round(1e18*Math.random()).toString(36).substring(0,10),p=e?Hs(e.signal,"abort",(()=>{p==null||p.unsubscribe(),delete this.resolveRejects[c];const T={id:c,type:"<cancel>",origin:location.origin,targetMapId:i.targetMapId,sourceMapId:this.mapId};this.target.postMessage(T)}),Gd):null;this.resolveRejects[c]={resolve:T=>{p==null||p.unsubscribe(),r(T)},reject:T=>{p==null||p.unsubscribe(),s(T)}};const m=[],v=Object.assign(Object.assign({},i),{id:c,sourceMapId:this.mapId,origin:location.origin,data:u(i.data,m)});this.target.postMessage(v,{transfer:m})}))}receive(i){const e=i.data,r=e.id;if(!(e.origin!=="file://"&&location.origin!=="file://"&&e.origin!=="resource://android"&&location.origin!=="resource://android"&&e.origin!==location.origin||e.targetMapId&&this.mapId!==e.targetMapId)){if(e.type==="<cancel>"){delete this.tasks[r];const s=this.abortControllers[r];return delete this.abortControllers[r],void(s&&s.abort())}if(Wn(self)||e.mustQueue)return this.tasks[r]=e,this.taskQueue.push(r),void this.invoker.trigger();this.processTask(r,e)}}process(){if(this.taskQueue.length===0)return;const i=this.taskQueue.shift(),e=this.tasks[i];delete this.tasks[i],this.taskQueue.length>0&&this.invoker.trigger(),e&&this.processTask(i,e)}processTask(i,e){return d(this,void 0,void 0,(function*(){if(e.type==="<response>"){const c=this.resolveRejects[i];return delete this.resolveRejects[i],c?void(e.error?c.reject(f(e.error)):c.resolve(f(e.data))):void 0}if(!this.messageHandlers[e.type])return void this.completeTask(i,new Error(`Could not find a registered handler for ${e.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const r=f(e.data),s=new AbortController;this.abortControllers[i]=s;try{const c=yield this.messageHandlers[e.type](e.sourceMapId,r,s);this.completeTask(i,null,c)}catch(c){this.completeTask(i,c)}}))}completeTask(i,e,r){const s=[];delete this.abortControllers[i];const c={id:i,type:"<response>",sourceMapId:this.mapId,origin:location.origin,error:e?u(e):null,data:u(r,s)};this.target.postMessage(c,{transfer:s})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},G.M=Ce,G.N=function(){var i=new Rr(16);return Rr!=Float32Array&&(i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=0,i[12]=0,i[13]=0,i[14]=0),i[0]=1,i[5]=1,i[10]=1,i[15]=1,i},G.O=function(i,e,r){var s,c,p,m,v,T,E,S,k,R,L,j,N=r[0],q=r[1],Y=r[2];return e===i?(i[12]=e[0]*N+e[4]*q+e[8]*Y+e[12],i[13]=e[1]*N+e[5]*q+e[9]*Y+e[13],i[14]=e[2]*N+e[6]*q+e[10]*Y+e[14],i[15]=e[3]*N+e[7]*q+e[11]*Y+e[15]):(c=e[1],p=e[2],m=e[3],v=e[4],T=e[5],E=e[6],S=e[7],k=e[8],R=e[9],L=e[10],j=e[11],i[0]=s=e[0],i[1]=c,i[2]=p,i[3]=m,i[4]=v,i[5]=T,i[6]=E,i[7]=S,i[8]=k,i[9]=R,i[10]=L,i[11]=j,i[12]=s*N+v*q+k*Y+e[12],i[13]=c*N+T*q+R*Y+e[13],i[14]=p*N+E*q+L*Y+e[14],i[15]=m*N+S*q+j*Y+e[15]),i},G.P=nt,G.Q=function(i,e,r){var s=r[0],c=r[1],p=r[2];return i[0]=e[0]*s,i[1]=e[1]*s,i[2]=e[2]*s,i[3]=e[3]*s,i[4]=e[4]*c,i[5]=e[5]*c,i[6]=e[6]*c,i[7]=e[7]*c,i[8]=e[8]*p,i[9]=e[9]*p,i[10]=e[10]*p,i[11]=e[11]*p,i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15],i},G.R=Un,G.S=function(i,e,r){var s=e[0],c=e[1],p=e[2],m=e[3],v=e[4],T=e[5],E=e[6],S=e[7],k=e[8],R=e[9],L=e[10],j=e[11],N=e[12],q=e[13],Y=e[14],ue=e[15],J=r[0],re=r[1],he=r[2],me=r[3];return i[0]=J*s+re*v+he*k+me*N,i[1]=J*c+re*T+he*R+me*q,i[2]=J*p+re*E+he*L+me*Y,i[3]=J*m+re*S+he*j+me*ue,i[4]=(J=r[4])*s+(re=r[5])*v+(he=r[6])*k+(me=r[7])*N,i[5]=J*c+re*T+he*R+me*q,i[6]=J*p+re*E+he*L+me*Y,i[7]=J*m+re*S+he*j+me*ue,i[8]=(J=r[8])*s+(re=r[9])*v+(he=r[10])*k+(me=r[11])*N,i[9]=J*c+re*T+he*R+me*q,i[10]=J*p+re*E+he*L+me*Y,i[11]=J*m+re*S+he*j+me*ue,i[12]=(J=r[12])*s+(re=r[13])*v+(he=r[14])*k+(me=r[15])*N,i[13]=J*c+re*T+he*R+me*q,i[14]=J*p+re*E+he*L+me*Y,i[15]=J*m+re*S+he*j+me*ue,i},G.T=Fc,G.U=function(i,e){const r={};for(let s=0;s<e.length;s++){const c=e[s];c in i&&(r[c]=i[c])}return r},G.V=sl,G.W=as,G.X=k0,G.Y=D0,G.Z=_e,G._=d,G.a=te,G.a$=Qn,G.a0=Gs,G.a1=wo,G.a2=_s,G.a3=B0,G.a4=lc,G.a5=dr,G.a6=function(i,e,r){if(!i)return e||{};if(!e)return i||{};const s=O0(i),c=O0(e);(function(m,v){v.removeAll&&(m.add.clear(),m.update.clear(),m.remove.clear(),v.remove.clear());for(const T of v.remove)m.add.delete(T),m.update.delete(T);for(const[T,E]of v.update){const S=m.update.get(T);S&&(v.update.set(T,Ud(S,E)),m.update.delete(T))}})(s,c);const p={};if((s.removeAll||c.removeAll)&&(p.removeAll=!0),p.remove=new Set([...s.remove,...c.remove]),p.add=new Map([...s.add,...c.add]),p.update=new Map([...s.update,...c.update]),p.remove.size&&p.add.size)for(const m of p.add.keys())p.remove.delete(m);return(function(m){const v={};return m.removeAll&&(v.removeAll=m.removeAll),m.remove&&(v.remove=Array.from(m.remove)),m.add&&(v.add=Array.from(m.add.values())),m.update&&(v.update=Array.from(m.update.values())),v})(p)},G.a7=function(i,e){const r=new Map;if(i==null||i.type==null)return r;if(i.type==="Feature"){const s=th(i,e);return s==null?void 0:(r.set(s,i),r)}if(i.type==="FeatureCollection"){const s=new Set;for(const c of i.features){const p=th(c,e);if(p==null||s.has(p))return;s.add(p),r.set(p,c)}return r}},G.a8=function(i,e,r){var s,c;const p=[];if(e.removeAll)i.clear();else if(e.remove)for(const m of e.remove){const v=i.get(m);v&&(p.push(v.geometry),i.delete(m))}if(e.add)for(const m of e.add){const v=th(m,r);if(v==null)continue;const T=i.get(v);T&&p.push(T.geometry),p.push(m.geometry),i.set(v,m)}if(e.update)for(const m of e.update){const v=i.get(m.id);if(!v)continue;const T=!!m.newGeometry,E=m.removeAllProperties||((s=m.removeProperties)===null||s===void 0?void 0:s.length)>0||((c=m.addOrUpdateProperties)===null||c===void 0?void 0:c.length)>0;if(!T&&!E)continue;p.push(v.geometry);const S=Object.assign({},v);if(i.set(m.id,S),T&&(p.push(m.newGeometry),S.geometry=m.newGeometry),E){if(S.properties=m.removeAllProperties?{}:Object.assign({},S.properties||{}),m.removeProperties)for(const k of m.removeProperties)delete S.properties[k];if(m.addOrUpdateProperties)for(const{key:k,value:R}of m.addOrUpdateProperties)S.properties[k]=R}}return p},G.a9=Bu,G.aA=function(i,{uSize:e,uSizeT:r},{lowerSize:s,upperSize:c}){return i.kind==="source"?s/ka:i.kind==="composite"?Sr.number(s/ka,c/ka,r):e},G.aB=function(i,e){var r=e[0],s=e[1],c=e[2],p=e[3],m=e[4],v=e[5],T=e[6],E=e[7],S=e[8],k=e[9],R=e[10],L=e[11],j=e[12],N=e[13],q=e[14],Y=e[15],ue=r*v-s*m,J=r*T-c*m,re=r*E-p*m,he=s*T-c*v,me=s*E-p*v,ze=c*E-p*T,He=S*N-k*j,Qe=S*q-R*j,et=S*Y-L*j,pt=k*q-R*N,st=k*Y-L*N,$e=R*Y-L*q,Ne=ue*$e-J*st+re*pt+he*et-me*Qe+ze*He;return Ne?(i[0]=(v*$e-T*st+E*pt)*(Ne=1/Ne),i[1]=(c*st-s*$e-p*pt)*Ne,i[2]=(N*ze-q*me+Y*he)*Ne,i[3]=(R*me-k*ze-L*he)*Ne,i[4]=(T*et-m*$e-E*Qe)*Ne,i[5]=(r*$e-c*et+p*Qe)*Ne,i[6]=(q*re-j*ze-Y*J)*Ne,i[7]=(S*ze-R*re+L*J)*Ne,i[8]=(m*st-v*et+E*He)*Ne,i[9]=(s*et-r*st-p*He)*Ne,i[10]=(j*me-N*re+Y*ue)*Ne,i[11]=(k*re-S*me-L*ue)*Ne,i[12]=(v*Qe-m*pt-T*He)*Ne,i[13]=(r*pt-s*Qe+c*He)*Ne,i[14]=(N*J-j*he-q*ue)*Ne,i[15]=(S*he-k*J+R*ue)*Ne,i):null},G.aC=Ui,G.aD=function(i){var e=i[0],r=i[1];return Math.sqrt(e*e+r*r)},G.aE=function(i){return i[0]=0,i[1]=0,i},G.aF=function(i,e,r){return i[0]=e[0]*r,i[1]=e[1]*r,i},G.aG=Hc,G.aH=qs,G.aI=function(i,e,r,s){const c=e.y-i.y,p=e.x-i.x,m=s.y-r.y,v=s.x-r.x,T=m*p-v*c;if(T===0)return null;const E=(v*(i.y-r.y)-m*(i.x-r.x))/T;return new nt(i.x+E*p,i.y+E*c)},G.aJ=yp,G.aK=OA,G.aL=function(i){let e=1/0,r=1/0,s=-1/0,c=-1/0;for(const p of i)e=Math.min(e,p.x),r=Math.min(r,p.y),s=Math.max(s,p.x),c=Math.max(c,p.y);return[e,r,s,c]},G.aM=Fi,G.aN=Zs,G.aO=function(i,e,r,s,c=!1){if(!r[0]&&!r[1])return[0,0];const p=c?s==="map"?-i.bearingInRadians:0:s==="viewport"?i.bearingInRadians:0;if(p){const m=Math.sin(p),v=Math.cos(p);r=[r[0]*v-r[1]*m,r[0]*m+r[1]*v]}return[c?r[0]:Zs(e,r[0],i.zoom),c?r[1]:Zs(e,r[1],i.zoom)]},G.aQ=Wc,G.aR=yh,G.aS=$c,G.aT=vh,G.aU=Ai,G.aV=rc,G.aW=ie,G.aX=ft,G.aY=Ve,G.aZ=Di,G.a_=R0,G.aa=ql,G.ab=25,G.ac=eh,G.ad=i=>{const e=window.document.createElement("video");return e.muted=!0,new Promise((r=>{e.onloadstart=()=>{r(e)};for(const s of i){const c=window.document.createElement("source");Ke(s)||(e.crossOrigin="Anonymous"),c.src=s,e.appendChild(c)}}))},G.ae=o,G.af=function(){return $s++},G.ag=h,G.ah=QA,G.ai=Fu,G.aj=Ao,G.ak=Jo,G.al=j0,G.am=function(i){const e={};if(i.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((r,s,c,p)=>{const m=c||p;return e[s]=!m||m.toLowerCase(),""})),e["max-age"]){const r=parseInt(e["max-age"],10);isNaN(r)?delete e["max-age"]:e["max-age"]=r}return e},G.an=bn,G.ao=85.051129,G.ap=Rn,G.aq=function(i){return Math.pow(2,i)},G.ar=yo,G.as=z0,G.at=function(i){return Math.log(i)/Math.LN2},G.au=function(i){var e=i[0],r=i[1];return e*e+r*r},G.av=function(i){if(!i.length)return new Set;const e=Math.max(...i.map((T=>T.canonical.z)));let r=1/0,s=-1/0,c=1/0,p=-1/0;const m=[];for(const T of i){const{x:E,y:S,z:k}=T.canonical,R=Math.pow(2,e-k),L=E*R,j=S*R;m.push({id:T,x:L,y:j}),L<r&&(r=L),L>s&&(s=L),j<c&&(c=j),j>p&&(p=j)}const v=new Set;for(const T of m)T.x!==r&&T.x!==s&&T.y!==c&&T.y!==p||v.add(T.id);return v},G.aw=function(i,e){const r=Math.abs(2*i.wrap)-+(i.wrap<0),s=Math.abs(2*e.wrap)-+(e.wrap<0);return i.overscaledZ-e.overscaledZ||s-r||e.canonical.y-i.canonical.y||e.canonical.x-i.canonical.x},G.ax=class{constructor(i,e){this.max=i,this.onRemove=e,this.reset()}reset(){for(const i in this.data)for(const e of this.data[i])e.timeout&&clearTimeout(e.timeout),this.onRemove(e.value);return this.data={},this.order=[],this}add(i,e,r){const s=i.wrapped().key;this.data[s]===void 0&&(this.data[s]=[]);const c={value:e,timeout:void 0};if(r!==void 0&&(c.timeout=setTimeout((()=>{this.remove(i,c)}),r)),this.data[s].push(c),this.order.push(s),this.order.length>this.max){const p=this._getAndRemoveByKey(this.order[0]);p&&this.onRemove(p)}return this}has(i){return i.wrapped().key in this.data}getAndRemove(i){return this.has(i)?this._getAndRemoveByKey(i.wrapped().key):null}_getAndRemoveByKey(i){const e=this.data[i].shift();return e.timeout&&clearTimeout(e.timeout),this.data[i].length===0&&delete this.data[i],this.order.splice(this.order.indexOf(i),1),e.value}getByKey(i){const e=this.data[i];return e?e[0].value:null}get(i){return this.has(i)?this.data[i.wrapped().key][0].value:null}remove(i,e){if(!this.has(i))return this;const r=i.wrapped().key,s=e===void 0?0:this.data[r].indexOf(e),c=this.data[r][s];return this.data[r].splice(s,1),c.timeout&&clearTimeout(c.timeout),this.data[r].length===0&&delete this.data[r],this.onRemove(c.value),this.order.splice(this.order.indexOf(r),1),this}setMaxSize(i){for(this.max=i;this.order.length>this.max;){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}filter(i){const e=[];for(const r in this.data)for(const s of this.data[r])i(s.value)||e.push(s);for(const r of e)this.remove(r.value.tileID,r)}},G.ay=function(i,e){let r=0,s=0;if(i.kind==="constant")s=i.layoutSize;else if(i.kind!=="source"){const{interpolationType:c,minZoom:p,maxZoom:m}=i,v=c?bn(ki.interpolationFactor(c,e,p,m),0,1):0;i.kind==="camera"?s=Sr.number(i.minSize,i.maxSize,v):r=v}return{uSizeT:r,uSize:s}},G.b=Tn,G.b$=Ca,G.b0=Ts,G.b1=function(i){var e=new Rr(3);return e[0]=i[0],e[1]=i[1],e[2]=i[2],e},G.b2=function(i,e,r){return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],i},G.b3=function(i,e){var r=e[0],s=e[1],c=e[2],p=r*r+s*s+c*c;return p>0&&(p=1/Math.sqrt(p)),i[0]=e[0]*p,i[1]=e[1]*p,i[2]=e[2]*p,i},G.b4=xn,G.b5=function(i,e){return i[0]*e[0]+i[1]*e[1]+i[2]*e[2]},G.b6=function(i,e,r){return i[0]=e[0]*r[0],i[1]=e[1]*r[1],i[2]=e[2]*r[2],i[3]=e[3]*r[3],i},G.b7=Yi,G.b8=function(i,e,r){const s=e[0]*r[0]+e[1]*r[1]+e[2]*r[2];return s===0?null:(-(i[0]*r[0]+i[1]*r[1]+i[2]*r[2])-r[3])/s},G.b9=Gi,G.bA=function(i,e,r,s){return i[0]=e[0]+r[0]*s,i[1]=e[1]+r[1]*s,i[2]=e[2]+r[2]*s,i},G.bB=xo,G.bC=function(i,e,r){var s=r[0],c=r[1],p=r[2],m=r[3],v=e[0],T=e[1],E=e[2],S=c*E-p*T,k=p*v-s*E,R=s*T-c*v;return i[0]=v+m*(S+=S)+c*(R+=R)-p*(k+=k),i[1]=T+m*k+p*S-s*R,i[2]=E+m*R+s*k-c*S,i},G.bD=function(i,e,r){const s=(function(T){var E=T[3],S=T[4],k=T[5],R=T[6],L=T[7],j=T[8];return T[0]*(j*S-k*L)+T[1]*(-j*E+k*R)+T[2]*(L*E-S*R)})([i[0],i[1],i[2],e[0],e[1],e[2],r[0],r[1],r[2]]);if(s===0)return null;const c=xn([],[e[0],e[1],e[2]],[r[0],r[1],r[2]]),p=xn([],[r[0],r[1],r[2]],[i[0],i[1],i[2]]),m=xn([],[i[0],i[1],i[2]],[e[0],e[1],e[2]]),v=Qn([],c,-i[3]);return Ts(v,v,Qn([],p,-e[3])),Ts(v,v,Qn([],m,-r[3])),Qn(v,v,1/s),v},G.bE=Jc,G.bF=function(){return new Float64Array(4)},G.bG=function(i,e,r,s){var c=[],p=[];return c[0]=e[0]-r[0],c[1]=e[1]-r[1],c[2]=e[2]-r[2],p[0]=c[0]*Math.cos(s)-c[1]*Math.sin(s),p[1]=c[0]*Math.sin(s)+c[1]*Math.cos(s),p[2]=c[2],i[0]=p[0]+r[0],i[1]=p[1]+r[1],i[2]=p[2]+r[2],i},G.bH=function(i,e,r,s){var c=[],p=[];return c[0]=e[0]-r[0],c[1]=e[1]-r[1],c[2]=e[2]-r[2],p[0]=c[0],p[1]=c[1]*Math.cos(s)-c[2]*Math.sin(s),p[2]=c[1]*Math.sin(s)+c[2]*Math.cos(s),i[0]=p[0]+r[0],i[1]=p[1]+r[1],i[2]=p[2]+r[2],i},G.bI=function(i,e,r,s){var c=[],p=[];return c[0]=e[0]-r[0],c[1]=e[1]-r[1],c[2]=e[2]-r[2],p[0]=c[2]*Math.sin(s)+c[0]*Math.cos(s),p[1]=c[1],p[2]=c[2]*Math.cos(s)-c[0]*Math.sin(s),i[0]=p[0]+r[0],i[1]=p[1]+r[1],i[2]=p[2]+r[2],i},G.bJ=function(i,e,r){var s=Math.sin(r),c=Math.cos(r),p=e[0],m=e[1],v=e[2],T=e[3],E=e[8],S=e[9],k=e[10],R=e[11];return e!==i&&(i[4]=e[4],i[5]=e[5],i[6]=e[6],i[7]=e[7],i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15]),i[0]=p*c-E*s,i[1]=m*c-S*s,i[2]=v*c-k*s,i[3]=T*c-R*s,i[8]=p*s+E*c,i[9]=m*s+S*c,i[10]=v*s+k*c,i[11]=T*s+R*c,i},G.bK=function(i,e){const r=$n(i,360),s=$n(e,360),c=s-r,p=s>r?c-360:c+360;return Math.abs(c)<Math.abs(p)?c:p},G.bL=function(i){return i[0]=0,i[1]=0,i[2]=0,i},G.bM=function(i,e,r,s){const c=Math.sqrt(i*i+e*e),p=Math.sqrt(r*r+s*s);i/=c,e/=c,r/=p,s/=p;const m=Math.acos(i*r+e*s);return-e*r+i*s>0?m:-m},G.bN=function(i,e){const r=$n(i,2*Math.PI),s=$n(e,2*Math.PI);return Math.min(Math.abs(r-s),Math.abs(r-s+2*Math.PI),Math.abs(r-s-2*Math.PI))},G.bO=function(){const i={},e=Le.$version;for(const r in Le.$root){const s=Le.$root[r];if(s.required){let c=null;c=r==="version"?e:s.type==="array"?[]:{},c!=null&&(i[r]=c)}}return i},G.bP=je,G.bQ=g,G.bR=function i(e,r){if(Array.isArray(e)){if(!Array.isArray(r)||e.length!==r.length)return!1;for(let s=0;s<e.length;s++)if(!i(e[s],r[s]))return!1;return!0}if(typeof e=="object"&&e!==null&&r!==null){if(typeof r!="object"||Object.keys(e).length!==Object.keys(r).length)return!1;for(const s in e)if(!i(e[s],r[s]))return!1;return!0}return e===r},G.bS=function(i){i=i.slice();const e=Object.create(null);for(let r=0;r<i.length;r++)e[i[r].id]=i[r];for(let r=0;r<i.length;r++)"ref"in i[r]&&(i[r]=mi(i[r],e[i[r].ref]));return i},G.bT=function(i,e){if(i.type==="custom")return new jd(i,e);switch(i.type){case"background":return new Vd(i,e);case"circle":return new wf(i,e);case"color-relief":return new Sf(i,e);case"fill":return new qf(i,e);case"fill-extrusion":return new rd(i,e);case"heatmap":return new Pf(i,e);case"hillshade":return new Ef(i,e);case"line":return new Ad(i,e);case"raster":return new Ic(i,e);case"symbol":return new ac(i,e)}},G.bU=i=>i.type==="raster",G.bV=Bn,G.bW=function(i,e){if(!i)return[{command:"setStyle",args:[e]}];let r=[];try{if(!Lt(i.version,e.version))return[{command:"setStyle",args:[e]}];Lt(i.center,e.center)||r.push({command:"setCenter",args:[e.center]}),Lt(i.state,e.state)||r.push({command:"setGlobalState",args:[e.state]}),Lt(i.centerAltitude,e.centerAltitude)||r.push({command:"setCenterAltitude",args:[e.centerAltitude]}),Lt(i.zoom,e.zoom)||r.push({command:"setZoom",args:[e.zoom]}),Lt(i.bearing,e.bearing)||r.push({command:"setBearing",args:[e.bearing]}),Lt(i.pitch,e.pitch)||r.push({command:"setPitch",args:[e.pitch]}),Lt(i.roll,e.roll)||r.push({command:"setRoll",args:[e.roll]}),Lt(i.sprite,e.sprite)||r.push({command:"setSprite",args:[e.sprite]}),Lt(i.glyphs,e.glyphs)||r.push({command:"setGlyphs",args:[e.glyphs]}),Lt(i.transition,e.transition)||r.push({command:"setTransition",args:[e.transition]}),Lt(i.light,e.light)||r.push({command:"setLight",args:[e.light]}),Lt(i.terrain,e.terrain)||r.push({command:"setTerrain",args:[e.terrain]}),Lt(i.sky,e.sky)||r.push({command:"setSky",args:[e.sky]}),Lt(i.projection,e.projection)||r.push({command:"setProjection",args:[e.projection]});const s={},c=[];(function(m,v,T,E){let S;for(S in v=v||{},m=m||{})Object.prototype.hasOwnProperty.call(m,S)&&(Object.prototype.hasOwnProperty.call(v,S)||Pr(S,T,E));for(S in v)Object.prototype.hasOwnProperty.call(v,S)&&(Object.prototype.hasOwnProperty.call(m,S)?Lt(m[S],v[S])||(m[S].type==="geojson"&&v[S].type==="geojson"&&ke(m,v,S)?mr(T,{command:"setGeoJSONSourceData",args:[S,v[S].data]}):Mr(S,v,T,E)):oi(S,v,T))})(i.sources,e.sources,c,s);const p=[];i.layers&&i.layers.forEach((m=>{"source"in m&&s[m.source]?r.push({command:"removeLayer",args:[m.id]}):p.push(m)})),r=r.concat(c),(function(m,v,T){v=v||[];const E=(m=m||[]).map(vt),S=v.map(vt),k=m.reduce(ot,{}),R=v.reduce(ot,{}),L=E.slice(),j=Object.create(null);let N,q,Y,ue,J;for(let re=0,he=0;re<E.length;re++)N=E[re],Object.prototype.hasOwnProperty.call(R,N)?he++:(mr(T,{command:"removeLayer",args:[N]}),L.splice(L.indexOf(N,he),1));for(let re=0,he=0;re<S.length;re++)N=S[S.length-1-re],L[L.length-1-re]!==N&&(Object.prototype.hasOwnProperty.call(k,N)?(mr(T,{command:"removeLayer",args:[N]}),L.splice(L.lastIndexOf(N,L.length-he),1)):he++,ue=L[L.length-re],mr(T,{command:"addLayer",args:[R[N],ue]}),L.splice(L.length-re,0,N),j[N]=!0);for(let re=0;re<S.length;re++)if(N=S[re],q=k[N],Y=R[N],!j[N]&&!Lt(q,Y))if(Lt(q.source,Y.source)&&Lt(q["source-layer"],Y["source-layer"])&&Lt(q.type,Y.type)){for(J in Xe(q.layout,Y.layout,T,N,null,"setLayoutProperty"),Xe(q.paint,Y.paint,T,N,null,"setPaintProperty"),Lt(q.filter,Y.filter)||mr(T,{command:"setFilter",args:[N,Y.filter]}),Lt(q.minzoom,Y.minzoom)&&Lt(q.maxzoom,Y.maxzoom)||mr(T,{command:"setLayerZoomRange",args:[N,Y.minzoom,Y.maxzoom]}),q)Object.prototype.hasOwnProperty.call(q,J)&&J!=="layout"&&J!=="paint"&&J!=="filter"&&J!=="metadata"&&J!=="minzoom"&&J!=="maxzoom"&&(J.indexOf("paint.")===0?Xe(q[J],Y[J],T,N,J.slice(6),"setPaintProperty"):Lt(q[J],Y[J])||mr(T,{command:"setLayerProperty",args:[N,J,Y[J]]}));for(J in Y)Object.prototype.hasOwnProperty.call(Y,J)&&!Object.prototype.hasOwnProperty.call(q,J)&&J!=="layout"&&J!=="paint"&&J!=="filter"&&J!=="metadata"&&J!=="minzoom"&&J!=="maxzoom"&&(J.indexOf("paint.")===0?Xe(q[J],Y[J],T,N,J.slice(6),"setPaintProperty"):Lt(q[J],Y[J])||mr(T,{command:"setLayerProperty",args:[N,J,Y[J]]}))}else mr(T,{command:"removeLayer",args:[N]}),ue=L[L.lastIndexOf(N)+1],mr(T,{command:"addLayer",args:[Y,ue]})})(p,e.layers,r)}catch(s){console.warn("Unable to compute style diff:",s),r=[{command:"setStyle",args:[e]}]}return r},G.bX=function(i){const e=[],r=i.id;return r===void 0&&e.push({message:`layers.${r}: missing required property "id"`}),i.render===void 0&&e.push({message:`layers.${r}: missing required method "render"`}),i.renderingMode&&i.renderingMode!=="2d"&&i.renderingMode!=="3d"&&e.push({message:`layers.${r}: property "renderingMode" must be either "2d" or "3d"`}),e},G.bY=zn,G.bZ=na,G.b_=class extends Sn{constructor(i,e){super(i,e),this.current=0}set(i){this.current!==i&&(this.current=i,this.gl.uniform1i(this.location,i))}},G.ba=function(i,e,r){return i[0]=e[0]*r,i[1]=e[1]*r,i[2]=e[2]*r,i[3]=e[3]*r,i},G.bb=function(i,e){return i[0]*e[0]+i[1]*e[1]+i[2]*e[2]+i[3]},G.bc=F0,G.bd=$A,G.be=function(i,e,r,s,c){var p=1/Math.tan(e/2);if(i[0]=p/r,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=p,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=-1,i[12]=0,i[13]=0,i[15]=0,c!=null&&c!==1/0){var m=1/(s-c);i[10]=(c+s)*m,i[14]=2*c*s*m}else i[10]=-1,i[14]=-2*s;return i},G.bf=function(i){var e=new Rr(16);return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],e},G.bg=function(i,e,r){var s=Math.sin(r),c=Math.cos(r),p=e[0],m=e[1],v=e[2],T=e[3],E=e[4],S=e[5],k=e[6],R=e[7];return e!==i&&(i[8]=e[8],i[9]=e[9],i[10]=e[10],i[11]=e[11],i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15]),i[0]=p*c+E*s,i[1]=m*c+S*s,i[2]=v*c+k*s,i[3]=T*c+R*s,i[4]=E*c-p*s,i[5]=S*c-m*s,i[6]=k*c-v*s,i[7]=R*c-T*s,i},G.bh=function(i,e,r){var s=Math.sin(r),c=Math.cos(r),p=e[4],m=e[5],v=e[6],T=e[7],E=e[8],S=e[9],k=e[10],R=e[11];return e!==i&&(i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15]),i[4]=p*c+E*s,i[5]=m*c+S*s,i[6]=v*c+k*s,i[7]=T*c+R*s,i[8]=E*c-p*s,i[9]=S*c-m*s,i[10]=k*c-v*s,i[11]=R*c-T*s,i},G.bi=function(){const i=new Float32Array(16);return yo(i),i},G.bj=function(){const i=new Float64Array(16);return yo(i),i},G.bk=function(){return new Float64Array(16)},G.bl=function(i,e,r){const s=new Float64Array(4);return xo(s,i,e-90,r),s},G.bm=function(i,e,r,s){var c,p,m,v,T,E=e[0],S=e[1],k=e[2],R=e[3],L=r[0],j=r[1],N=r[2],q=r[3];return(p=E*L+S*j+k*N+R*q)<0&&(p=-p,L=-L,j=-j,N=-N,q=-q),1-p>jr?(c=Math.acos(p),m=Math.sin(c),v=Math.sin((1-s)*c)/m,T=Math.sin(s*c)/m):(v=1-s,T=s),i[0]=v*E+T*L,i[1]=v*S+T*j,i[2]=v*k+T*N,i[3]=v*R+T*q,i},G.bn=function(i){const e=new Float64Array(9);(function(p,m){var v=m[0],T=m[1],E=m[2],S=m[3],k=v+v,R=T+T,L=E+E,j=v*k,N=T*k,q=T*R,Y=E*k,ue=E*R,J=E*L,re=S*k,he=S*R,me=S*L;p[0]=1-q-J,p[3]=N-me,p[6]=Y+he,p[1]=N+me,p[4]=1-j-J,p[7]=ue-re,p[2]=Y-he,p[5]=ue+re,p[8]=1-j-q})(e,i);const r=Di(-Math.asin(bn(e[2],-1,1)));let s,c;return Math.hypot(e[5],e[8])<.001?(s=0,c=-Di(Math.atan2(e[3],e[4]))):(s=Di(e[5]===0&&e[8]===0?0:Math.atan2(e[5],e[8])),c=Di(e[1]===0&&e[0]===0?0:Math.atan2(e[1],e[0]))),{roll:s,pitch:r+90,bearing:c}},G.bo=function(i,e){return i.roll==e.roll&&i.pitch==e.pitch&&i.bearing==e.bearing},G.bp=Kt,G.bq=Sa,G.br=UA,G.bs=Iu,G.bt=GA,G.bu=os,G.bv=bo,G.bw=$i,G.bx=function(i,e,r,s,c){return os(s,c,bn((i-e)/(r-e),0,1))},G.by=$n,G.bz=function(){return new Float64Array(3)},G.c=ve,G.c$=function(i,e,r,s,c){return d(this,void 0,void 0,(function*(){if(Gs())try{return yield wo(i,e,r,s,c)}catch{}return(function(p,m,v,T,E){const S=p.width,k=p.height;Ci&&fn||(Ci=new OffscreenCanvas(S,k),fn=Ci.getContext("2d",{willReadFrequently:!0})),Ci.width=S,Ci.height=k,fn.drawImage(p,0,0,S,k);const R=fn.getImageData(m,v,T,E);return fn.clearRect(0,0,S,k),R.data})(i,e,r,s,c)}))},G.c0=class extends Sn{constructor(i,e){super(i,e),this.current=ts}set(i){if(i[12]!==this.current[12]||i[0]!==this.current[0])return this.current=i,void this.gl.uniformMatrix4fv(this.location,!1,i);for(let e=1;e<16;e++)if(i[e]!==this.current[e]){this.current=i,this.gl.uniformMatrix4fv(this.location,!1,i);break}}},G.c1=Nl,G.c2=class extends Sn{constructor(i,e){super(i,e),this.current=[0,0,0]}set(i){i[0]===this.current[0]&&i[1]===this.current[1]&&i[2]===this.current[2]||(this.current=i,this.gl.uniform3f(this.location,i[0],i[1],i[2]))}},G.c3=class extends Sn{constructor(i,e){super(i,e),this.current=[0,0]}set(i){i[0]===this.current[0]&&i[1]===this.current[1]||(this.current=i,this.gl.uniform2f(this.location,i[0],i[1]))}},G.c4=Us,G.c5=function(i,e){var r=Math.sin(e),s=Math.cos(e);return i[0]=s,i[1]=r,i[2]=0,i[3]=-r,i[4]=s,i[5]=0,i[6]=0,i[7]=0,i[8]=1,i},G.c6=function(i,e,r){var s=e[0],c=e[1],p=e[2];return i[0]=s*r[0]+c*r[3]+p*r[6],i[1]=s*r[1]+c*r[4]+p*r[7],i[2]=s*r[2]+c*r[5]+p*r[8],i},G.c7=function(i,e,r,s,c,p,m){var v=1/(e-r),T=1/(s-c),E=1/(p-m);return i[0]=-2*v,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=-2*T,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=2*E,i[11]=0,i[12]=(e+r)*v,i[13]=(c+s)*T,i[14]=(m+p)*E,i[15]=1,i},G.c8=class extends Sn{constructor(i,e){super(i,e),this.current=new Array}set(i){if(i!=this.current){this.current=i;const e=new Float32Array(4*i.length);for(let r=0;r<i.length;r++)e[4*r]=i[r].r,e[4*r+1]=i[r].g,e[4*r+2]=i[r].b,e[4*r+3]=i[r].a;this.gl.uniform4fv(this.location,e)}}},G.c9=class extends Sn{constructor(i,e){super(i,e),this.current=new Array}set(i){if(i!=this.current){this.current=i;const e=new Float32Array(i);this.gl.uniform1fv(this.location,e)}}},G.cA=function(i,e){return De[e]&&"touches"in i},G.cB=function(i){return De[i]||W[i]},G.cC=function(i,e,r){var s=e[0],c=e[1];return i[0]=r[0]*s+r[4]*c+r[12],i[1]=r[1]*s+r[5]*c+r[13],i},G.cD=function(i,e){const{x:r,y:s}=Bu.fromLngLat(e);return!(i<0||i>25||s<0||s>=1||r<0||r>=1)},G.cE=function(i,e){return i[0]=e[0],i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=e[1],i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=e[2],i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,i},G.cF=class extends DA{},G.cG=Mm,G.cI=Te,G.cJ=function(i,e){ve.REGISTERED_PROTOCOLS[i]=e},G.cK=function(i){delete ve.REGISTERED_PROTOCOLS[i]},G.cL=function(i,e){const r={};for(let c=0;c<i.length;c++){const p=e&&e[i[c].id]||PA(i[c]);e&&(e[i[c].id]=p);let m=r[p];m||(m=r[p]=[]),m.push(i[c])}const s=[];for(const c in r)s.push(r[c]);return s},G.cM=yt,G.cN=V0,G.cO=gp,G.cP=v0,G.cQ=function(i){i.bucket.createArrays(),i.bucket.tilePixelRatio=dr/(512*i.bucket.overscaling),i.bucket.compareText={},i.bucket.iconsNeedLinear=!1;const e=i.bucket.layers[0],r=e.layout,s=e._unevaluatedLayout._values,c={layoutIconSize:s["icon-size"].possiblyEvaluate(new Pe(i.bucket.zoom+1),i.canonical),layoutTextSize:s["text-size"].possiblyEvaluate(new Pe(i.bucket.zoom+1),i.canonical),textMaxSize:s["text-size"].possiblyEvaluate(new Pe(18))};if(i.bucket.textSizeData.kind==="composite"){const{minZoom:E,maxZoom:S}=i.bucket.textSizeData;c.compositeTextSizes=[s["text-size"].possiblyEvaluate(new Pe(E),i.canonical),s["text-size"].possiblyEvaluate(new Pe(S),i.canonical)]}if(i.bucket.iconSizeData.kind==="composite"){const{minZoom:E,maxZoom:S}=i.bucket.iconSizeData;c.compositeIconSizes=[s["icon-size"].possiblyEvaluate(new Pe(E),i.canonical),s["icon-size"].possiblyEvaluate(new Pe(S),i.canonical)]}const p=r.get("text-line-height")*Fi,m=r.get("text-rotation-alignment")!=="viewport"&&r.get("symbol-placement")!=="point",v=r.get("text-keep-upright"),T=r.get("text-size");for(const E of i.bucket.features){const S=r.get("text-font").evaluate(E,{},i.canonical).join(","),k=T.evaluate(E,{},i.canonical),R=c.layoutTextSize.evaluate(E,{},i.canonical),L=c.layoutIconSize.evaluate(E,{},i.canonical),j={horizontal:{},vertical:void 0},N=E.text;let q,Y=[0,0];if(N){const re=N.toString(),he=r.get("text-letter-spacing").evaluate(E,{},i.canonical)*Fi,me=z(re)?he:0,ze=r.get("text-anchor").evaluate(E,{},i.canonical),He=Cp(e,E,i.canonical);if(!He){const st=r.get("text-radial-offset").evaluate(E,{},i.canonical);Y=st?Sp(ze,[st*Fi,_h]):r.get("text-offset").evaluate(E,{},i.canonical).map(($e=>$e*Fi))}let Qe=m?"center":r.get("text-justify").evaluate(E,{},i.canonical);const et=r.get("symbol-placement")==="point"?r.get("text-max-width").evaluate(E,{},i.canonical)*Fi:1/0,pt=()=>{i.bucket.allowVerticalPlacement&&C(re)&&(j.vertical=sc(N,i.glyphMap,i.glyphPositions,i.imagePositions,S,et,p,ze,"left",me,Y,G.az.vertical,!0,R,k))};if(!m&&He){const st=new Set;if(Qe==="auto")for(let Ne=0;Ne<He.values.length;Ne+=2)st.add(yh(He.values[Ne]));else st.add(Qe);let $e=!1;for(const Ne of st)if(!j.horizontal[Ne])if($e)j.horizontal[Ne]=j.horizontal[0];else{const xt=sc(N,i.glyphMap,i.glyphPositions,i.imagePositions,S,et,p,"center",Ne,me,Y,G.az.horizontal,!1,R,k);xt&&(j.horizontal[Ne]=xt,$e=xt.positionedLines.length===1)}pt()}else{Qe==="auto"&&(Qe=yh(ze));const st=sc(N,i.glyphMap,i.glyphPositions,i.imagePositions,S,et,p,ze,Qe,me,Y,G.az.horizontal,!1,R,k);st&&(j.horizontal[Qe]=st),pt(),C(re)&&m&&v&&(j.vertical=sc(N,i.glyphMap,i.glyphPositions,i.imagePositions,S,et,p,ze,Qe,me,Y,G.az.vertical,!1,R,k))}}let ue=!1;if(E.icon&&E.icon.name){const re=i.imageMap[E.icon.name];re&&(q=Rd(i.imagePositions[E.icon.name],r.get("icon-offset").evaluate(E,{},i.canonical),r.get("icon-anchor").evaluate(E,{},i.canonical)),ue=!!re.sdf,i.bucket.sdfIcons===void 0?i.bucket.sdfIcons=ue:i.bucket.sdfIcons!==ue&&di("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(re.pixelRatio!==i.bucket.pixelRatio||r.get("icon-rotate").constantOr(1)!==0)&&(i.bucket.iconsNeedLinear=!0))}const J=kp(j.horizontal)||j.vertical;i.bucket.iconsInText=!!J&&J.iconsInText,(J||q)&&Tm(i.bucket,E,j,q,i.imageMap,c,R,L,Y,ue,i.canonical,i.subdivisionGranularity)}i.showCollisionBoxes&&i.bucket.generateCollisionDebugBuffers()},G.cR=Nc,G.cS=Uc,G.cT=qc,G.cU=function(i){const e=new nc;return(function(r,s){for(const c in r.layers)s.writeMessage(3,um,r.layers[c])})(i,e),e.finish()},G.cV=function(i,e,r,s,c,p){let m=vp(i,e,r,c,0);return m=vp(m,e,s,p,1),m},G.cW=class{constructor(i){this.maxEntries=i,this.map=new Map}get(i){const e=this.map.get(i);return e!==void 0&&(this.map.delete(i),this.map.set(i,e)),e}set(i,e){if(this.map.has(i))this.map.delete(i);else if(this.map.size>=this.maxEntries){const r=this.map.keys().next().value;this.map.delete(r)}this.map.set(i,e)}clear(){this.map.clear()}},G.cX=r0,G.cY=nc,G.cZ=dp,G.c_=class{constructor(i){this._marks={start:[i.url,"start"].join("#"),end:[i.url,"end"].join("#"),measure:i.url.toString()},performance.mark(this._marks.start)}finish(){performance.mark(this._marks.end);let i=performance.getEntriesByName(this._marks.measure);return i.length===0&&(performance.measure(this._marks.measure,this._marks.start,this._marks.end),i=performance.getEntriesByName(this._marks.measure),performance.clearMarks(this._marks.start),performance.clearMarks(this._marks.end),performance.clearMeasures(this._marks.measure)),i}},G.ca=class extends Ea{},G.cb=pd,G.cc=class extends jl{},G.cd=Lc,G.ce=function(i){return i<=1?1:Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))},G.cf=Nh,G.cg=function(i,e,r){var s=e[0],c=e[1],p=e[2],m=r[3]*s+r[7]*c+r[11]*p+r[15];return i[0]=(r[0]*s+r[4]*c+r[8]*p+r[12])/(m=m||1),i[1]=(r[1]*s+r[5]*c+r[9]*p+r[13])/m,i[2]=(r[2]*s+r[6]*c+r[10]*p+r[14])/m,i},G.ch=class extends fu{},G.ci=class extends t{},G.cj=function(i,e){return i[0]===e[0]&&i[1]===e[1]&&i[2]===e[2]&&i[3]===e[3]&&i[4]===e[4]&&i[5]===e[5]&&i[6]===e[6]&&i[7]===e[7]&&i[8]===e[8]&&i[9]===e[9]&&i[10]===e[10]&&i[11]===e[11]&&i[12]===e[12]&&i[13]===e[13]&&i[14]===e[14]&&i[15]===e[15]},G.ck=function(i,e){var r=i[0],s=i[1],c=i[2],p=i[3],m=i[4],v=i[5],T=i[6],E=i[7],S=i[8],k=i[9],R=i[10],L=i[11],j=i[12],N=i[13],q=i[14],Y=i[15],ue=e[0],J=e[1],re=e[2],he=e[3],me=e[4],ze=e[5],He=e[6],Qe=e[7],et=e[8],pt=e[9],st=e[10],$e=e[11],Ne=e[12],xt=e[13],gt=e[14],Tt=e[15];return Math.abs(r-ue)<=jr*Math.max(1,Math.abs(r),Math.abs(ue))&&Math.abs(s-J)<=jr*Math.max(1,Math.abs(s),Math.abs(J))&&Math.abs(c-re)<=jr*Math.max(1,Math.abs(c),Math.abs(re))&&Math.abs(p-he)<=jr*Math.max(1,Math.abs(p),Math.abs(he))&&Math.abs(m-me)<=jr*Math.max(1,Math.abs(m),Math.abs(me))&&Math.abs(v-ze)<=jr*Math.max(1,Math.abs(v),Math.abs(ze))&&Math.abs(T-He)<=jr*Math.max(1,Math.abs(T),Math.abs(He))&&Math.abs(E-Qe)<=jr*Math.max(1,Math.abs(E),Math.abs(Qe))&&Math.abs(S-et)<=jr*Math.max(1,Math.abs(S),Math.abs(et))&&Math.abs(k-pt)<=jr*Math.max(1,Math.abs(k),Math.abs(pt))&&Math.abs(R-st)<=jr*Math.max(1,Math.abs(R),Math.abs(st))&&Math.abs(L-$e)<=jr*Math.max(1,Math.abs(L),Math.abs($e))&&Math.abs(j-Ne)<=jr*Math.max(1,Math.abs(j),Math.abs(Ne))&&Math.abs(N-xt)<=jr*Math.max(1,Math.abs(N),Math.abs(xt))&&Math.abs(q-gt)<=jr*Math.max(1,Math.abs(q),Math.abs(gt))&&Math.abs(Y-Tt)<=jr*Math.max(1,Math.abs(Y),Math.abs(Tt))},G.cl=function(i,e){return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],i[4]=e[4],i[5]=e[5],i[6]=e[6],i[7]=e[7],i[8]=e[8],i[9]=e[9],i[10]=e[10],i[11]=e[11],i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15],i},G.cm=i=>i.type==="symbol",G.cn=i=>i.type==="circle",G.co=i=>i.type==="heatmap",G.cp=i=>i.type==="line",G.cq=i=>i.type==="fill",G.cr=i=>i.type==="fill-extrusion",G.cs=i=>i.type==="hillshade",G.ct=i=>i.type==="color-relief",G.cu=i=>i.type==="background",G.cv=i=>i.type==="custom",G.cw=Qs,G.cx=function(i,e,r){const s=Ps(e.x-r.x,e.y-r.y),c=Ps(i.x-r.x,i.y-r.y),p=Math.atan2(s[0]*c[1]-s[1]*c[0],(function(m,v){return m[0]*v[0]+m[1]*v[1]})(s,c));return Di(p)},G.cy=Si,G.cz=function(i,e){return W[e]&&(i instanceof MouseEvent||i instanceof WheelEvent)},G.d=Ke,G.d0=qh,G.d1=Vr,G.d2=class{constructor(i,e){this.layers={[Fu]:this},this.name=Fu,this.version=e?e.version:1,this.extent=e?e.extent:4096,this.length=i.length,this.features=i}feature(i){return new Am(this.features[i],this.extent)}},G.d3=ao,G.d4=Se,G.e=qi,G.f=i=>d(void 0,void 0,void 0,(function*(){if(i.byteLength===0)return createImageBitmap(new ImageData(1,1));const e=new Blob([new Uint8Array(i)],{type:"image/png"});try{return createImageBitmap(e)}catch(r){throw new Error(`Could not load image because of ${r.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}})),G.g=Re,G.h=i=>new Promise(((e,r)=>{const s=new Image;s.onload=()=>{e(s),URL.revokeObjectURL(s.src),s.onload=null,window.requestAnimationFrame((()=>{s.src=Ws}))},s.onerror=()=>r(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const c=new Blob([new Uint8Array(i)],{type:"image/png"});s.src=i.byteLength?URL.createObjectURL(c):Ws})),G.i=Wn,G.j=(i,e)=>tt(qi(i,{type:"json"}),e),G.k=gr,G.l=Vt,G.m=tt,G.n=(i,e)=>tt(qi(i,{type:"arrayBuffer"}),e),G.o=function(i){return new nc(i).readFields(Ed,[])},G.p=y0,G.q=function(i){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(i))},G.r=wu,G.s=Hs,G.t=Ri,G.u=Le,G.v=Ho,G.w=di,G.x=jt,G.y=lt,G.z=ct})),We("worker",["./shared"],(function(G){class d{constructor(W,$){this.keyCache={},W&&this.replace(W,$)}replace(W,$){this._layerConfigs={},this._layers={},this.update(W,[],$)}update(W,$,te){for(const ve of W){this._layerConfigs[ve.id]=ve;const Re=this._layers[ve.id]=G.bT(ve,te);Re._featureFilter=G.aj(Re.filter,te),this.keyCache[ve.id]&&delete this.keyCache[ve.id]}for(const ve of $)delete this.keyCache[ve],delete this._layerConfigs[ve],delete this._layers[ve];this.familiesBySource={};const _e=G.cL(Object.values(this._layerConfigs),this.keyCache);for(const ve of _e){const Re=ve.map((_t=>this._layers[_t.id])),Ce=Re[0];if(Ce.isHidden())continue;const Te=Ce.source||"";let je=this.familiesBySource[Te];je||(je=this.familiesBySource[Te]={});const tt=Ce.sourceLayer||G.ai;let Ke=je[tt];Ke||(Ke=je[tt]=[]),Ke.push(Re)}}}class nt{constructor(W){const $={},te=[];for(const Ce in W){const Te=W[Ce],je=$[Ce]={};for(const tt in Te){const Ke=Te[+tt];if(!Ke||Ke.bitmap.width===0||Ke.bitmap.height===0)continue;const _t={x:0,y:0,w:Ke.bitmap.width+2,h:Ke.bitmap.height+2};te.push(_t),je[tt]={rect:_t,metrics:Ke.metrics}}}const{w:_e,h:ve}=G.p(te),Re=new G.r({width:_e||1,height:ve||1});for(const Ce in W){const Te=W[Ce];for(const je in Te){const tt=Te[+je];if(!tt||tt.bitmap.width===0||tt.bitmap.height===0)continue;const Ke=$[Ce][je].rect;G.r.copy(tt.bitmap,Re,{x:0,y:0},{x:Ke.x+1,y:Ke.y+1},tt.bitmap)}}this.image=Re,this.positions=$}}G.cM("GlyphAtlas",nt);class Vr{constructor(W){this.tileID=new G.a2(W.tileID.overscaledZ,W.tileID.wrap,W.tileID.canonical.z,W.tileID.canonical.x,W.tileID.canonical.y),this.uid=W.uid,this.zoom=W.zoom,this.pixelRatio=W.pixelRatio,this.tileSize=W.tileSize,this.source=W.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=W.showCollisionBoxes,this.collectResourceTiming=!!W.collectResourceTiming,this.returnDependencies=!!W.returnDependencies,this.promoteId=W.promoteId,this.inFlightDependencies=[]}parse(W,$,te,_e,ve){return G._(this,void 0,void 0,(function*(){this.status="parsing",this.data=W,this.collisionBoxArray=new G.ag;const Re=new G.cN(Object.keys(W.layers).sort()),Ce=new G.cO(this.tileID,this.promoteId);Ce.bucketLayerIDs=[];const Te={},je={featureIndex:Ce,iconDependencies:{},patternDependencies:{},glyphDependencies:{},dashDependencies:{},availableImages:te,subdivisionGranularity:ve},tt=$.familiesBySource[this.source];for(const ke in tt){const Xe=W.layers[ke];if(!Xe)continue;Xe.version===1&&G.w(`Vector tile source "${this.source}" layer "${ke}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const vt=Re.encode(ke),ot=[];for(let o=0;o<Xe.length;o++){const Z=Xe.feature(o),Ut=Ce.getId(Z,ke);ot.push({feature:Z,id:Ut,index:o,sourceLayerIndex:vt})}for(const o of tt[ke]){const Z=o[0];Z.source!==this.source&&G.w(`layer.source = ${Z.source} does not equal this.source = ${this.source}`),Z.isHidden(this.zoom,!0)||(si(o,this.zoom,te),(Te[Z.id]=Z.createBucket({index:Ce.bucketLayerIDs.length,layers:o,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:vt,sourceID:this.source})).populate(ot,je,this.tileID.canonical),Ce.bucketLayerIDs.push(o.map((Ut=>Ut.id))))}}const Ke=G.bY(je.glyphDependencies,(ke=>Object.keys(ke).map(Number)));this.inFlightDependencies.forEach((ke=>ke==null?void 0:ke.abort())),this.inFlightDependencies=[];let _t=Promise.resolve({});if(Object.keys(Ke).length){const ke=new AbortController;this.inFlightDependencies.push(ke),_t=_e.sendAsync({type:"GG",data:{stacks:Ke,source:this.source,tileID:this.tileID,type:"glyphs"}},ke)}const Be=Object.keys(je.iconDependencies);let Vt=Promise.resolve({});if(Be.length){const ke=new AbortController;this.inFlightDependencies.push(ke),Vt=_e.sendAsync({type:"GI",data:{icons:Be,source:this.source,tileID:this.tileID,type:"icons"}},ke)}const gr=Object.keys(je.patternDependencies);let hr=Promise.resolve({});if(gr.length){const ke=new AbortController;this.inFlightDependencies.push(ke),hr=_e.sendAsync({type:"GI",data:{icons:gr,source:this.source,tileID:this.tileID,type:"patterns"}},ke)}const Le=je.dashDependencies;let _r=Promise.resolve({});if(Object.keys(Le).length){const ke=new AbortController;this.inFlightDependencies.push(ke),_r=_e.sendAsync({type:"GDA",data:{dashes:Le}},ke)}const[mi,Lt,mr,oi]=yield Promise.all([_t,Vt,hr,_r]),Pr=new nt(mi),Mr=new G.cP(Lt,mr);for(const ke in Te){const Xe=Te[ke];Xe instanceof G.ah?(si(Xe.layers,this.zoom,te),G.cQ({bucket:Xe,glyphMap:mi,glyphPositions:Pr.positions,imageMap:Lt,imagePositions:Mr.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:je.subdivisionGranularity})):Xe.hasDependencies&&(Xe instanceof G.cR||Xe instanceof G.cS||Xe instanceof G.cT)&&(si(Xe.layers,this.zoom,te),Xe.addFeatures(je,this.tileID.canonical,Mr.patternPositions,oi))}return this.status="done",{buckets:Object.values(Te).filter((ke=>!ke.isEmpty())),featureIndex:Ce,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:Pr.image,imageAtlas:Mr,dashPositions:oi,glyphMap:this.returnDependencies?mi:null,iconMap:this.returnDependencies?Lt:null,glyphPositions:this.returnDependencies?Pr.positions:null}}))}}function si(De,W,$){const te=new G.H(W);for(const _e of De)_e.recalculate(te,$)}class kn{constructor(W,$,te,_e,ve){this.type=W,this.properties=te||{},this.extent=ve,this.pointsArray=$,this.id=_e}loadGeometry(){return this.pointsArray.map((W=>W.map(($=>new G.P($.x,$.y)))))}}class bs{constructor(W,$,te){this.version=2,this._myFeatures=W,this.name=$,this.length=W.length,this.extent=te}feature(W){return this._myFeatures[W]}}class hi{constructor(){this.layers={}}addLayer(W){this.layers[W.name]=W}}function ss(De){let W=G.cU(De);return W.byteOffset===0&&W.byteLength===W.buffer.byteLength||(W=new Uint8Array(W)),{vectorTile:De,rawData:W.buffer}}function Ar(De,W,$){const{extent:te}=De,_e=Math.pow(2,$.z-W.z),ve=($.x-W.x*_e)*te,Re=($.y-W.y*_e)*te,Ce=[];for(let Te=0;Te<De.length;Te++){const je=De.feature(Te);let tt=je.loadGeometry();for(const _t of tt)for(const Be of _t)Be.x=Be.x*_e-ve,Be.y=Be.y*_e-Re;const Ke=128;tt=G.cV(tt,je.type,-Ke,-Ke,te+Ke,te+Ke),tt.length!==0&&Ce.push(new kn(je.type,tt,je.properties,je.id,te))}return new bs(Ce,De.name,te)}class Ze{constructor(W,$,te){this.actor=W,this.layerIndex=$,this.availableImages=te,this.fetching={},this.loading={},this.loaded={},this.overzoomedTileResultCache=new G.cW(1e3)}loadVectorTile(W,$){return G._(this,void 0,void 0,(function*(){const te=yield G.n(W.request,$);try{return{vectorTile:W.encoding!=="mlt"?new G.cX(new G.cY(te.data)):new G.cZ(te.data),rawData:te.data,cacheControl:te.cacheControl,expires:te.expires}}catch(_e){const ve=new Uint8Array(te.data);let Re=`Unable to parse the tile at ${W.request.url}, `;throw Re+=ve[0]===31&&ve[1]===139?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${_e.message}`,new Error(Re)}}))}loadTile(W){return G._(this,void 0,void 0,(function*(){const{uid:$,overzoomParameters:te}=W;te&&(W.request=te.overzoomRequest);const _e=!!(W&&W.request&&W.request.collectResourceTiming)&&new G.c_(W.request),ve=new Vr(W);this.loading[$]=ve;const Re=new AbortController;ve.abort=Re;try{const Ce=yield this.loadVectorTile(W,Re);if(delete this.loading[$],!Ce)return null;if(te){const _t=this._getOverzoomTile(W,Ce.vectorTile);Ce.rawData=_t.rawData,Ce.vectorTile=_t.vectorTile}const Te=Ce.rawData,je={};Ce.expires&&(je.expires=Ce.expires),Ce.cacheControl&&(je.cacheControl=Ce.cacheControl);const tt={};if(_e){const _t=_e.finish();_t&&(tt.resourceTiming=JSON.parse(JSON.stringify(_t)))}ve.vectorTile=Ce.vectorTile;const Ke=ve.parse(Ce.vectorTile,this.layerIndex,this.availableImages,this.actor,W.subdivisionGranularity);this.loaded[$]=ve,this.fetching[$]={rawTileData:Te,cacheControl:je,resourceTiming:tt};try{const _t=yield Ke;return G.e({rawTileData:Te.slice(0),encoding:W.encoding},_t,je,tt)}finally{delete this.fetching[$]}}catch(Ce){throw delete this.loading[$],ve.status="done",this.loaded[$]=ve,Ce}}))}_getOverzoomTile(W,$){const{tileID:te,source:_e,overzoomParameters:ve}=W,{maxZoomTileID:Re}=ve,Ce=`${Re.key}_${te.key}`,Te=this.overzoomedTileResultCache.get(Ce);if(Te)return Te;const je=new hi,tt=this.layerIndex.familiesBySource[_e];for(const _t in tt){const Be=$.layers[_t];if(!Be)continue;const Vt=Ar(Be,Re,te.canonical);Vt.length>0&&je.addLayer(Vt)}const Ke=ss(je);return this.overzoomedTileResultCache.set(Ce,Ke),Ke}reloadTile(W){return G._(this,void 0,void 0,(function*(){const $=W.uid;if(!this.loaded||!this.loaded[$])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");const te=this.loaded[$];if(te.showCollisionBoxes=W.showCollisionBoxes,te.status==="parsing"){const _e=yield te.parse(te.vectorTile,this.layerIndex,this.availableImages,this.actor,W.subdivisionGranularity);let ve;if(this.fetching[$]){const{rawTileData:Re,cacheControl:Ce,resourceTiming:Te}=this.fetching[$];delete this.fetching[$],ve=G.e({rawTileData:Re.slice(0),encoding:W.encoding},_e,Ce,Te)}else ve=_e;return ve}if(te.status==="done"&&te.vectorTile)return te.parse(te.vectorTile,this.layerIndex,this.availableImages,this.actor,W.subdivisionGranularity)}))}abortTile(W){return G._(this,void 0,void 0,(function*(){const $=this.loading,te=W.uid;$&&$[te]&&$[te].abort&&($[te].abort.abort(),delete $[te])}))}removeTile(W){return G._(this,void 0,void 0,(function*(){this.loaded&&this.loaded[W.uid]&&delete this.loaded[W.uid]}))}}class Gs{constructor(){this.loaded={}}loadTile(W){return G._(this,void 0,void 0,(function*(){const{uid:$,encoding:te,rawImageData:_e,redFactor:ve,greenFactor:Re,blueFactor:Ce,baseShift:Te}=W,je=_e.width+2,tt=_e.height+2,Ke=G.b(_e)?new G.R({width:je,height:tt},yield G.c$(_e,-1,-1,je,tt)):_e,_t=new G.d0($,Ke,te,ve,Re,Ce,Te);return this.loaded=this.loaded||{},this.loaded[$]=_t,_t}))}removeTile(W){const $=this.loaded,te=W.uid;$&&$[te]&&delete $[te]}}var jr,Rr,Us=(function(){if(Rr)return jr;function De($,te){if($.length!==0){W($[0],te);for(var _e=1;_e<$.length;_e++)W($[_e],!te)}}function W($,te){for(var _e=0,ve=0,Re=0,Ce=$.length,Te=Ce-1;Re<Ce;Te=Re++){var je=($[Re][0]-$[Te][0])*($[Te][1]+$[Re][1]),tt=_e+je;ve+=Math.abs(_e)>=Math.abs(je)?_e-tt+je:je-tt+_e,_e=tt}_e+ve>=0!=!!te&&$.reverse()}return Rr=1,jr=function $(te,_e){var ve,Re=te&&te.type;if(Re==="FeatureCollection")for(ve=0;ve<te.features.length;ve++)$(te.features[ve],_e);else if(Re==="GeometryCollection")for(ve=0;ve<te.geometries.length;ve++)$(te.geometries[ve],_e);else if(Re==="Feature")$(te.geometry,_e);else if(Re==="Polygon")De(te.coordinates,_e);else if(Re==="MultiPolygon")for(ve=0;ve<te.coordinates.length;ve++)De(te.coordinates[ve],_e);return te}})(),yo=G.d1(Us);const ws={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:De=>De},Yi=Math.fround||(vo=new Float32Array(1),De=>(vo[0]=+De,vo[0]));var vo;class Ts{constructor(W){this.options=Object.assign(Object.create(ws),W),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(W){const{log:$,minZoom:te,maxZoom:_e}=this.options;$&&console.time("total time");const ve=`prepare ${W.length} points`;$&&console.time(ve),this.points=W;const Re=[];for(let Te=0;Te<W.length;Te++){const je=W[Te];if(!je.geometry)continue;const[tt,Ke]=je.geometry.coordinates,_t=Yi(Ti(tt)),Be=Yi(Gi(Ke));Re.push(_t,Be,1/0,Te,-1,1),this.options.reduce&&Re.push(0)}let Ce=this.trees[_e+1]=this._createTree(Re);$&&console.timeEnd(ve);for(let Te=_e;Te>=te;Te--){const je=+Date.now();Ce=this.trees[Te]=this._createTree(this._cluster(Ce,Te)),$&&console.log("z%d: %d clusters in %dms",Te,Ce.numItems,+Date.now()-je)}return $&&console.timeEnd("total time"),this}getClusters(W,$){let te=((W[0]+180)%360+360)%360-180;const _e=Math.max(-90,Math.min(90,W[1]));let ve=W[2]===180?180:((W[2]+180)%360+360)%360-180;const Re=Math.max(-90,Math.min(90,W[3]));if(W[2]-W[0]>=360)te=-180,ve=180;else if(te>ve){const Ke=this.getClusters([te,_e,180,Re],$),_t=this.getClusters([-180,_e,ve,Re],$);return Ke.concat(_t)}const Ce=this.trees[this._limitZoom($)],Te=Ce.range(Ti(te),Gi(Re),Ti(ve),Gi(_e)),je=Ce.data,tt=[];for(const Ke of Te){const _t=this.stride*Ke;tt.push(je[_t+5]>1?Qn(je,_t,this.clusterProps):this.points[je[_t+3]])}return tt}getChildren(W){const $=this._getOriginId(W),te=this._getOriginZoom(W),_e="No cluster with the specified id.",ve=this.trees[te];if(!ve)throw new Error(_e);const Re=ve.data;if($*this.stride>=Re.length)throw new Error(_e);const Ce=this.options.radius/(this.options.extent*Math.pow(2,te-1)),Te=ve.within(Re[$*this.stride],Re[$*this.stride+1],Ce),je=[];for(const tt of Te){const Ke=tt*this.stride;Re[Ke+4]===W&&je.push(Re[Ke+5]>1?Qn(Re,Ke,this.clusterProps):this.points[Re[Ke+3]])}if(je.length===0)throw new Error(_e);return je}getLeaves(W,$,te){const _e=[];return this._appendLeaves(_e,W,$=$||10,te=te||0,0),_e}getTile(W,$,te){const _e=this.trees[this._limitZoom(W)],ve=Math.pow(2,W),{extent:Re,radius:Ce}=this.options,Te=Ce/Re,je=(te-Te)/ve,tt=(te+1+Te)/ve,Ke={features:[]};return this._addTileFeatures(_e.range(($-Te)/ve,je,($+1+Te)/ve,tt),_e.data,$,te,ve,Ke),$===0&&this._addTileFeatures(_e.range(1-Te/ve,je,1,tt),_e.data,ve,te,ve,Ke),$===ve-1&&this._addTileFeatures(_e.range(0,je,Te/ve,tt),_e.data,-1,te,ve,Ke),Ke.features.length?Ke:null}getClusterExpansionZoom(W){let $=this._getOriginZoom(W)-1;for(;$<=this.options.maxZoom;){const te=this.getChildren(W);if($++,te.length!==1)break;W=te[0].properties.cluster_id}return $}_appendLeaves(W,$,te,_e,ve){const Re=this.getChildren($);for(const Ce of Re){const Te=Ce.properties;if(Te&&Te.cluster?ve+Te.point_count<=_e?ve+=Te.point_count:ve=this._appendLeaves(W,Te.cluster_id,te,_e,ve):ve<_e?ve++:W.push(Ce),W.length===te)break}return ve}_createTree(W){const $=new G.aT(W.length/this.stride|0,this.options.nodeSize,Float32Array);for(let te=0;te<W.length;te+=this.stride)$.add(W[te],W[te+1]);return $.finish(),$.data=W,$}_addTileFeatures(W,$,te,_e,ve,Re){for(const Ce of W){const Te=Ce*this.stride,je=$[Te+5]>1;let tt,Ke,_t;if(je)tt=xn($,Te,this.clusterProps),Ke=$[Te],_t=$[Te+1];else{const gr=this.points[$[Te+3]];tt=gr.properties;const[hr,Le]=gr.geometry.coordinates;Ke=Ti(hr),_t=Gi(Le)}const Be={type:1,geometry:[[Math.round(this.options.extent*(Ke*ve-te)),Math.round(this.options.extent*(_t*ve-_e))]],tags:tt};let Vt;Vt=je||this.options.generateId?$[Te+3]:this.points[$[Te+3]].id,Vt!==void 0&&(Be.id=Vt),Re.features.push(Be)}}_limitZoom(W){return Math.max(this.options.minZoom,Math.min(Math.floor(+W),this.options.maxZoom+1))}_cluster(W,$){const{radius:te,extent:_e,reduce:ve,minPoints:Re}=this.options,Ce=te/(_e*Math.pow(2,$)),Te=W.data,je=[],tt=this.stride;for(let Ke=0;Ke<Te.length;Ke+=tt){if(Te[Ke+2]<=$)continue;Te[Ke+2]=$;const _t=Te[Ke],Be=Te[Ke+1],Vt=W.within(Te[Ke],Te[Ke+1],Ce),gr=Te[Ke+5];let hr=gr;for(const Le of Vt){const _r=Le*tt;Te[_r+2]>$&&(hr+=Te[_r+5])}if(hr>gr&&hr>=Re){let Le,_r=_t*gr,mi=Be*gr,Lt=-1;const mr=(Ke/tt<<5)+($+1)+this.points.length;for(const oi of Vt){const Pr=oi*tt;if(Te[Pr+2]<=$)continue;Te[Pr+2]=$;const Mr=Te[Pr+5];_r+=Te[Pr]*Mr,mi+=Te[Pr+1]*Mr,Te[Pr+4]=mr,ve&&(Le||(Le=this._map(Te,Ke,!0),Lt=this.clusterProps.length,this.clusterProps.push(Le)),ve(Le,this._map(Te,Pr)))}Te[Ke+4]=mr,je.push(_r/hr,mi/hr,1/0,mr,-1,hr),ve&&je.push(Lt)}else{for(let Le=0;Le<tt;Le++)je.push(Te[Ke+Le]);if(hr>1)for(const Le of Vt){const _r=Le*tt;if(!(Te[_r+2]<=$)){Te[_r+2]=$;for(let mi=0;mi<tt;mi++)je.push(Te[_r+mi])}}}}return je}_getOriginId(W){return W-this.points.length>>5}_getOriginZoom(W){return(W-this.points.length)%32}_map(W,$,te){if(W[$+5]>1){const Re=this.clusterProps[W[$+6]];return te?Object.assign({},Re):Re}const _e=this.points[W[$+3]].properties,ve=this.options.map(_e);return te&&ve===_e?Object.assign({},ve):ve}}function Qn(De,W,$){return{type:"Feature",id:De[W+3],properties:xn(De,W,$),geometry:{type:"Point",coordinates:[(te=De[W],360*(te-.5)),qs(De[W+1])]}};var te}function xn(De,W,$){const te=De[W+5],_e=te>=1e4?`${Math.round(te/1e3)}k`:te>=1e3?Math.round(te/100)/10+"k":te,ve=De[W+6],Re=ve===-1?{}:Object.assign({},$[ve]);return Object.assign(Re,{cluster:!0,cluster_id:De[W+3],point_count:te,point_count_abbreviated:_e})}function Ti(De){return De/360+.5}function Gi(De){const W=Math.sin(De*Math.PI/180),$=.5-.25*Math.log((1+W)/(1-W))/Math.PI;return $<0?0:$>1?1:$}function qs(De){const W=(180-360*De)*Math.PI/180;return 360*Math.atan(Math.exp(W))/Math.PI-90}function Ki(De,W,$,te){let _e=te;const ve=W+($-W>>1);let Re,Ce=$-W;const Te=De[W],je=De[W+1],tt=De[$],Ke=De[$+1];for(let _t=W+3;_t<$;_t+=3){const Be=xo(De[_t],De[_t+1],Te,je,tt,Ke);if(Be>_e)Re=_t,_e=Be;else if(Be===_e){const Vt=Math.abs(_t-ve);Vt<Ce&&(Re=_t,Ce=Vt)}}_e>te&&(Re-W>3&&Ki(De,W,Re,te),De[Re+2]=_e,$-Re>3&&Ki(De,Re,$,te))}function xo(De,W,$,te,_e,ve){let Re=_e-$,Ce=ve-te;if(Re!==0||Ce!==0){const Te=((De-$)*Re+(W-te)*Ce)/(Re*Re+Ce*Ce);Te>1?($=_e,te=ve):Te>0&&($+=Re*Te,te+=Ce*Te)}return Re=De-$,Ce=W-te,Re*Re+Ce*Ce}function Ui(De,W,$,te){const _e={id:De??null,type:W,geometry:$,tags:te,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(W==="Point"||W==="MultiPoint"||W==="LineString")Ps(_e,$);else if(W==="Polygon")Ps(_e,$[0]);else if(W==="MultiLineString")for(const ve of $)Ps(_e,ve);else if(W==="MultiPolygon")for(const ve of $)Ps(_e,ve[0]);return _e}function Ps(De,W){for(let $=0;$<W.length;$+=3)De.minX=Math.min(De.minX,W[$]),De.minY=Math.min(De.minY,W[$+1]),De.maxX=Math.max(De.maxX,W[$]),De.maxY=Math.max(De.maxY,W[$+1])}function dr(De,W,$,te){if(!W.geometry)return;const _e=W.geometry.coordinates;if(_e&&_e.length===0)return;const ve=W.geometry.type,Re=Math.pow($.tolerance/((1<<$.maxZoom)*$.extent),2);let Ce=[],Te=W.id;if($.promoteId?Te=W.properties[$.promoteId]:$.generateId&&(Te=te||0),ve==="Point")Zs(_e,Ce);else if(ve==="MultiPoint")for(const je of _e)Zs(je,Ce);else if(ve==="LineString")$n(_e,Ce,Re,!1);else if(ve==="MultiLineString"){if($.lineMetrics){for(const je of _e)Ce=[],$n(je,Ce,Re,!1),De.push(Ui(Te,"LineString",Ce,W.properties));return}os(_e,Ce,Re,!1)}else if(ve==="Polygon")os(_e,Ce,Re,!0);else{if(ve!=="MultiPolygon"){if(ve==="GeometryCollection"){for(const je of W.geometry.geometries)dr(De,{id:Te,geometry:je,properties:W.properties},$,te);return}throw new Error("Input data is not a valid GeoJSON object.")}for(const je of _e){const tt=[];os(je,tt,Re,!0),Ce.push(tt)}}De.push(Ui(Te,ve,Ce,W.properties))}function Zs(De,W){W.push(bo(De[0]),Qs(De[1]),0)}function $n(De,W,$,te){let _e,ve,Re=0;for(let Te=0;Te<De.length;Te++){const je=bo(De[Te][0]),tt=Qs(De[Te][1]);W.push(je,tt,0),Te>0&&(Re+=te?(_e*tt-je*ve)/2:Math.sqrt(Math.pow(je-_e,2)+Math.pow(tt-ve,2))),_e=je,ve=tt}const Ce=W.length-3;W[2]=1,Ki(W,0,Ce,$),W[Ce+2]=1,W.size=Math.abs(Re),W.start=0,W.end=W.size}function os(De,W,$,te){for(let _e=0;_e<De.length;_e++){const ve=[];$n(De[_e],ve,$,te),W.push(ve)}}function bo(De){return De/360+.5}function Qs(De){const W=Math.sin(De*Math.PI/180),$=.5-.25*Math.log((1+W)/(1-W))/Math.PI;return $<0?0:$>1?1:$}function Si(De,W,$,te,_e,ve,Re,Ce){if(te/=W,ve>=($/=W)&&Re<te)return De;if(Re<$||ve>=te)return null;const Te=[];for(const je of De){const tt=je.geometry;let Ke=je.type;const _t=_e===0?je.minX:je.minY,Be=_e===0?je.maxX:je.maxY;if(_t>=$&&Be<te){Te.push(je);continue}if(Be<$||_t>=te)continue;let Vt=[];if(Ke==="Point"||Ke==="MultiPoint")bn(tt,Vt,$,te,_e);else if(Ke==="LineString")as(tt,Vt,$,te,_e,!1,Ce.lineMetrics);else if(Ke==="MultiLineString")$s(tt,Vt,$,te,_e,!1);else if(Ke==="Polygon")$s(tt,Vt,$,te,_e,!0);else if(Ke==="MultiPolygon")for(const gr of tt){const hr=[];$s(gr,hr,$,te,_e,!0),hr.length&&Vt.push(hr)}if(Vt.length){if(Ce.lineMetrics&&Ke==="LineString"){for(const gr of Vt)Te.push(Ui(je.id,Ke,gr,je.tags));continue}Ke!=="LineString"&&Ke!=="MultiLineString"||(Vt.length===1?(Ke="LineString",Vt=Vt[0]):Ke="MultiLineString"),Ke!=="Point"&&Ke!=="MultiPoint"||(Ke=Vt.length===3?"Point":"MultiPoint"),Te.push(Ui(je.id,Ke,Vt,je.tags))}}return Te.length?Te:null}function bn(De,W,$,te,_e){for(let ve=0;ve<De.length;ve+=3){const Re=De[ve+_e];Re>=$&&Re<=te&&zn(W,De[ve],De[ve+1],De[ve+2])}}function as(De,W,$,te,_e,ve,Re){let Ce=qi(De);const Te=_e===0?na:Bn;let je,tt,Ke=De.start;for(let hr=0;hr<De.length-3;hr+=3){const Le=De[hr],_r=De[hr+1],mi=De[hr+2],Lt=De[hr+3],mr=De[hr+4],oi=_e===0?Le:_r,Pr=_e===0?Lt:mr;let Mr=!1;Re&&(je=Math.sqrt(Math.pow(Le-Lt,2)+Math.pow(_r-mr,2))),oi<$?Pr>$&&(tt=Te(Ce,Le,_r,Lt,mr,$),Re&&(Ce.start=Ke+je*tt)):oi>te?Pr<te&&(tt=Te(Ce,Le,_r,Lt,mr,te),Re&&(Ce.start=Ke+je*tt)):zn(Ce,Le,_r,mi),Pr<$&&oi>=$&&(tt=Te(Ce,Le,_r,Lt,mr,$),Mr=!0),Pr>te&&oi<=te&&(tt=Te(Ce,Le,_r,Lt,mr,te),Mr=!0),!ve&&Mr&&(Re&&(Ce.end=Ke+je*tt),W.push(Ce),Ce=qi(De)),Re&&(Ke+=je)}let _t=De.length-3;const Be=De[_t],Vt=De[_t+1],gr=_e===0?Be:Vt;gr>=$&&gr<=te&&zn(Ce,Be,Vt,De[_t+2]),_t=Ce.length-3,ve&&_t>=3&&(Ce[_t]!==Ce[0]||Ce[_t+1]!==Ce[1])&&zn(Ce,Ce[0],Ce[1],Ce[2]),Ce.length&&W.push(Ce)}function qi(De){const W=[];return W.size=De.size,W.start=De.start,W.end=De.end,W}function $s(De,W,$,te,_e,ve){for(const Re of De)as(Re,W,$,te,_e,ve,!1)}function zn(De,W,$,te){De.push(W,$,te)}function na(De,W,$,te,_e,ve){const Re=(ve-W)/(te-W);return zn(De,ve,$+(_e-$)*Re,1),Re}function Bn(De,W,$,te,_e,ve){const Re=(ve-$)/(_e-$);return zn(De,W+(te-W)*Re,ve,1),Re}function sa(De,W){const $=[];for(let te=0;te<De.length;te++){const _e=De[te],ve=_e.type;let Re;if(ve==="Point"||ve==="MultiPoint"||ve==="LineString")Re=di(_e.geometry,W);else if(ve==="MultiLineString"||ve==="Polygon"){Re=[];for(const Ce of _e.geometry)Re.push(di(Ce,W))}else if(ve==="MultiPolygon"){Re=[];for(const Ce of _e.geometry){const Te=[];for(const je of Ce)Te.push(di(je,W));Re.push(Te)}}$.push(Ui(_e.id,ve,Re,_e.tags))}return $}function di(De,W){const $=[];$.size=De.size,De.start!==void 0&&($.start=De.start,$.end=De.end);for(let te=0;te<De.length;te+=3)$.push(De[te]+W,De[te+1],De[te+2]);return $}function wn(De,W){if(De.transformed)return De;const $=1<<De.z,te=De.x,_e=De.y;for(const ve of De.features){const Re=ve.geometry,Ce=ve.type;if(ve.geometry=[],Ce===1)for(let Te=0;Te<Re.length;Te+=2)ve.geometry.push(Wn(Re[Te],Re[Te+1],W,$,te,_e));else for(let Te=0;Te<Re.length;Te++){const je=[];for(let tt=0;tt<Re[Te].length;tt+=2)je.push(Wn(Re[Te][tt],Re[Te][tt+1],W,$,te,_e));ve.geometry.push(je)}}return De.transformed=!0,De}function Wn(De,W,$,te,_e,ve){return[Math.round($*(De*te-_e)),Math.round($*(W*te-ve))]}function xr(De,W,$,te,_e){const ve=W===_e.maxZoom?0:_e.tolerance/((1<<W)*_e.extent),Re={features:[],numPoints:0,numSimplified:0,numFeatures:De.length,source:null,x:$,y:te,z:W,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0};for(const Ce of De)Tn(Re,Ce,ve,_e);return Re}function Tn(De,W,$,te){const _e=W.geometry,ve=W.type,Re=[];if(De.minX=Math.min(De.minX,W.minX),De.minY=Math.min(De.minY,W.minY),De.maxX=Math.max(De.maxX,W.maxX),De.maxY=Math.max(De.maxY,W.maxY),ve==="Point"||ve==="MultiPoint")for(let Ce=0;Ce<_e.length;Ce+=3)Re.push(_e[Ce],_e[Ce+1]),De.numPoints++,De.numSimplified++;else if(ve==="LineString")Ws(Re,_e,De,$,!1,!1);else if(ve==="MultiLineString"||ve==="Polygon")for(let Ce=0;Ce<_e.length;Ce++)Ws(Re,_e[Ce],De,$,ve==="Polygon",Ce===0);else if(ve==="MultiPolygon")for(let Ce=0;Ce<_e.length;Ce++){const Te=_e[Ce];for(let je=0;je<Te.length;je++)Ws(Re,Te[je],De,$,!0,je===0)}if(Re.length){let Ce=W.tags||null;if(ve==="LineString"&&te.lineMetrics){Ce={};for(const je in W.tags)Ce[je]=W.tags[je];Ce.mapbox_clip_start=_e.start/_e.size,Ce.mapbox_clip_end=_e.end/_e.size}const Te={geometry:Re,type:ve==="Polygon"||ve==="MultiPolygon"?3:ve==="LineString"||ve==="MultiLineString"?2:1,tags:Ce};W.id!==null&&(Te.id=W.id),De.features.push(Te)}}function Ws(De,W,$,te,_e,ve){const Re=te*te;if(te>0&&W.size<(_e?Re:te))return void($.numPoints+=W.length/3);const Ce=[];for(let Te=0;Te<W.length;Te+=3)(te===0||W[Te+2]>Re)&&($.numSimplified++,Ce.push(W[Te],W[Te+1])),$.numPoints++;_e&&(function(Te,je){let tt=0;for(let Ke=0,_t=Te.length,Be=_t-2;Ke<_t;Be=Ke,Ke+=2)tt+=(Te[Ke]-Te[Be])*(Te[Ke+1]+Te[Be+1]);if(tt>0===je)for(let Ke=0,_t=Te.length;Ke<_t/2;Ke+=2){const Be=Te[Ke],Vt=Te[Ke+1];Te[Ke]=Te[_t-2-Ke],Te[Ke+1]=Te[_t-1-Ke],Te[_t-2-Ke]=Be,Te[_t-1-Ke]=Vt}})(Ce,ve),De.push(Ce)}const wo={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0};class Ci{constructor(W,$){const te=($=this.options=(function(ve,Re){for(const Ce in Re)ve[Ce]=Re[Ce];return ve})(Object.create(wo),$)).debug;if(te&&console.time("preprocess data"),$.maxZoom<0||$.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if($.promoteId&&$.generateId)throw new Error("promoteId and generateId cannot be used together.");let _e=(function(ve,Re){const Ce=[];if(ve.type==="FeatureCollection")for(let Te=0;Te<ve.features.length;Te++)dr(Ce,ve.features[Te],Re,Te);else dr(Ce,ve.type==="Feature"?ve:{geometry:ve},Re);return Ce})(W,$);this.tiles={},this.tileCoords=[],te&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",$.indexMaxZoom,$.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),_e=(function(ve,Re){const Ce=Re.buffer/Re.extent;let Te=ve;const je=Si(ve,1,-1-Ce,Ce,0,-1,2,Re),tt=Si(ve,1,1-Ce,2+Ce,0,-1,2,Re);return(je||tt)&&(Te=Si(ve,1,-Ce,1+Ce,0,-1,2,Re)||[],je&&(Te=sa(je,1).concat(Te)),tt&&(Te=Te.concat(sa(tt,-1)))),Te})(_e,$),_e.length&&this.splitTile(_e,0,0,0),te&&(_e.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}splitTile(W,$,te,_e,ve,Re,Ce){const Te=[W,$,te,_e],je=this.options,tt=je.debug;for(;Te.length;){_e=Te.pop(),te=Te.pop(),$=Te.pop(),W=Te.pop();const Ke=1<<$,_t=fn($,te,_e);let Be=this.tiles[_t];if(!Be&&(tt>1&&console.time("creation"),Be=this.tiles[_t]=xr(W,$,te,_e,je),this.tileCoords.push({z:$,x:te,y:_e}),tt)){tt>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",$,te,_e,Be.numFeatures,Be.numPoints,Be.numSimplified),console.timeEnd("creation"));const Mr=`z${$}`;this.stats[Mr]=(this.stats[Mr]||0)+1,this.total++}if(Be.source=W,ve==null){if($===je.indexMaxZoom||Be.numPoints<=je.indexMaxPoints)continue}else{if($===je.maxZoom||$===ve)continue;if(ve!=null){const Mr=ve-$;if(te!==Re>>Mr||_e!==Ce>>Mr)continue}}if(Be.source=null,W.length===0)continue;tt>1&&console.time("clipping");const Vt=.5*je.buffer/je.extent,gr=.5-Vt,hr=.5+Vt,Le=1+Vt;let _r=null,mi=null,Lt=null,mr=null,oi=Si(W,Ke,te-Vt,te+hr,0,Be.minX,Be.maxX,je),Pr=Si(W,Ke,te+gr,te+Le,0,Be.minX,Be.maxX,je);W=null,oi&&(_r=Si(oi,Ke,_e-Vt,_e+hr,1,Be.minY,Be.maxY,je),mi=Si(oi,Ke,_e+gr,_e+Le,1,Be.minY,Be.maxY,je),oi=null),Pr&&(Lt=Si(Pr,Ke,_e-Vt,_e+hr,1,Be.minY,Be.maxY,je),mr=Si(Pr,Ke,_e+gr,_e+Le,1,Be.minY,Be.maxY,je),Pr=null),tt>1&&console.timeEnd("clipping"),Te.push(_r||[],$+1,2*te,2*_e),Te.push(mi||[],$+1,2*te,2*_e+1),Te.push(Lt||[],$+1,2*te+1,2*_e),Te.push(mr||[],$+1,2*te+1,2*_e+1)}}getTile(W,$,te){W=+W,$=+$,te=+te;const _e=this.options,{extent:ve,debug:Re}=_e;if(W<0||W>24)return null;const Ce=1<<W,Te=fn(W,$=$+Ce&Ce-1,te);if(this.tiles[Te])return wn(this.tiles[Te],ve);Re>1&&console.log("drilling down to z%d-%d-%d",W,$,te);let je,tt=W,Ke=$,_t=te;for(;!je&&tt>0;)tt--,Ke>>=1,_t>>=1,je=this.tiles[fn(tt,Ke,_t)];return je&&je.source?(Re>1&&(console.log("found parent tile z%d-%d-%d",tt,Ke,_t),console.time("drilling down")),this.splitTile(je.source,tt,Ke,_t,W,$,te),Re>1&&console.timeEnd("drilling down"),this.tiles[Te]?wn(this.tiles[Te],ve):null):null}}function fn(De,W,$){return 32*((1<<De)*$+W)+De}class Hs extends Ze{constructor(W,$,te,_e=Rn){super(W,$,te),this._dataUpdateable=new Map,this._createGeoJSONIndex=_e}loadVectorTile(W,$){return G._(this,void 0,void 0,(function*(){const te=W.tileID.canonical;if(!this._geoJSONIndex)throw new Error("Unable to parse the data into a cluster or geojson");const _e=this._geoJSONIndex.getTile(te.z,te.x,te.y);return _e?ss(new G.d2(_e.features,{version:2,extent:G.a5})):null}))}loadData(W){return G._(this,void 0,void 0,(function*(){var $;($=this._pendingRequest)===null||$===void 0||$.abort();const te=this._startPerformance(W);this._pendingRequest=new AbortController;try{(!this._pendingData||W.request||W.data||W.dataDiff)&&(this._pendingData=this.loadAndProcessGeoJSON(W,this._pendingRequest));const _e=yield this._pendingData;this._geoJSONIndex=this._createGeoJSONIndex(_e,W),this.loaded={};const ve={};return W.request&&(ve.data=_e),this._finishPerformance(te,W,ve),ve}catch(_e){if(delete this._pendingRequest,G.Z(_e))return{abandoned:!0};throw _e}}))}_startPerformance(W){var $;if(!(($=W==null?void 0:W.request)===null||$===void 0)&&$.collectResourceTiming)return new G.c_(W.request)}_finishPerformance(W,$,te){if(!W)return;const _e=W.finish();_e&&(te.resourceTiming={},te.resourceTiming[$.source]=JSON.parse(JSON.stringify(_e)))}getData(){return G._(this,void 0,void 0,(function*(){return this._pendingData}))}reloadTile(W){const $=this.loaded;return $&&$[W.uid]?super.reloadTile(W):this.loadTile(W)}loadAndProcessGeoJSON(W,$){return G._(this,void 0,void 0,(function*(){let te;if(W.request?te=yield this.loadGeoJSONFromUrl(W.request,W.promoteId,$):W.data?te=this._loadGeoJSONFromObject(W.data,W.promoteId):W.dataDiff&&(te=this._loadGeoJSONFromDiff(W.dataDiff,W.promoteId,W.source)),delete this._pendingRequest,typeof te!="object")throw new Error(`Input data given to '${W.source}' is not a valid GeoJSON object.`);return yo(te,!0),W.filter&&(te=this._filterGeoJSON(te,W.filter)),te}))}loadGeoJSONFromUrl(W,$,te){return G._(this,void 0,void 0,(function*(){const _e=yield G.j(W,te);return this._dataUpdateable=G.a7(_e.data,$),_e.data}))}_loadGeoJSONFromObject(W,$){return this._dataUpdateable=G.a7(W,$),W}_loadGeoJSONFromDiff(W,$,te){if(!this._dataUpdateable)throw new Error(`Cannot update existing geojson data in ${te}`);G.a8(this._dataUpdateable,W,$);const _e=Array.from(this._dataUpdateable.values());return this._toFeatureCollection(_e)}_filterGeoJSON(W,$){const te=G.d3($,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(te.result==="error")throw new Error(te.value.map((ve=>`${ve.key}: ${ve.message}`)).join(", "));const _e=W.features.filter((ve=>te.value.evaluate({zoom:0},ve)));return this._toFeatureCollection(_e)}_toFeatureCollection(W){return{type:"FeatureCollection",features:W}}removeSource(W){return G._(this,void 0,void 0,(function*(){this._pendingRequest&&this._pendingRequest.abort()}))}getClusterExpansionZoom(W){return this._geoJSONIndex.getClusterExpansionZoom(W.clusterId)}getClusterChildren(W){return this._geoJSONIndex.getChildren(W.clusterId)}getClusterLeaves(W){return this._geoJSONIndex.getLeaves(W.clusterId,W.limit,W.offset)}}function Rn(De,W){return W.cluster?new Ts((function({superclusterOptions:$,clusterProperties:te}){if(!te||!$)return $;const _e={},ve={},Re={accumulated:null,zoom:0},Ce={properties:null},Te=Object.keys(te);for(const je of Te){const[tt,Ke]=te[je],_t=G.d3(Ke),Be=G.d3(typeof tt=="string"?[tt,["accumulated"],["get",je]]:tt);_e[je]=_t.value,ve[je]=Be.value}return $.map=je=>{Ce.properties=je;const tt={};for(const Ke of Te)tt[Ke]=_e[Ke].evaluate(Re,Ce);return tt},$.reduce=(je,tt)=>{Ce.properties=tt;for(const Ke of Te)Re.accumulated=je[Ke],je[Ke]=ve[Ke].evaluate(Re,Ce)},$})(W)).load(De.features):(function($,te){return new Ci($,te)})(De,W.geojsonVtOptions)}class Di{constructor(W){this.self=W,this.actor=new G.L(W),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.globalStates=new Map,this.self.registerWorkerSource=($,te)=>{if(this.externalWorkerSourceTypes[$])throw new Error(`Worker source with name "${$}" already registered.`);this.externalWorkerSourceTypes[$]=te},this.self.addProtocol=G.cJ,this.self.removeProtocol=G.cK,this.self.registerRTLTextPlugin=$=>{G.d4.setMethods($)},this.actor.registerMessageHandler("LDT",(($,te)=>this._getDEMWorkerSource($,te.source).loadTile(te))),this.actor.registerMessageHandler("RDT",(($,te)=>G._(this,void 0,void 0,(function*(){this._getDEMWorkerSource($,te.source).removeTile(te)})))),this.actor.registerMessageHandler("GCEZ",(($,te)=>G._(this,void 0,void 0,(function*(){return this._getWorkerSource($,te.type,te.source).getClusterExpansionZoom(te)})))),this.actor.registerMessageHandler("GCC",(($,te)=>G._(this,void 0,void 0,(function*(){return this._getWorkerSource($,te.type,te.source).getClusterChildren(te)})))),this.actor.registerMessageHandler("GCL",(($,te)=>G._(this,void 0,void 0,(function*(){return this._getWorkerSource($,te.type,te.source).getClusterLeaves(te)})))),this.actor.registerMessageHandler("LD",(($,te)=>this._getWorkerSource($,te.type,te.source).loadData(te))),this.actor.registerMessageHandler("GD",(($,te)=>this._getWorkerSource($,te.type,te.source).getData())),this.actor.registerMessageHandler("LT",(($,te)=>this._getWorkerSource($,te.type,te.source).loadTile(te))),this.actor.registerMessageHandler("RT",(($,te)=>this._getWorkerSource($,te.type,te.source).reloadTile(te))),this.actor.registerMessageHandler("AT",(($,te)=>this._getWorkerSource($,te.type,te.source).abortTile(te))),this.actor.registerMessageHandler("RMT",(($,te)=>this._getWorkerSource($,te.type,te.source).removeTile(te))),this.actor.registerMessageHandler("RS",(($,te)=>G._(this,void 0,void 0,(function*(){if(!this.workerSources[$]||!this.workerSources[$][te.type]||!this.workerSources[$][te.type][te.source])return;const _e=this.workerSources[$][te.type][te.source];delete this.workerSources[$][te.type][te.source],_e.removeSource!==void 0&&_e.removeSource(te)})))),this.actor.registerMessageHandler("RM",($=>G._(this,void 0,void 0,(function*(){delete this.layerIndexes[$],delete this.availableImages[$],delete this.workerSources[$],delete this.demWorkerSources[$],this.globalStates.delete($)})))),this.actor.registerMessageHandler("SR",(($,te)=>G._(this,void 0,void 0,(function*(){this.referrer=te})))),this.actor.registerMessageHandler("SRPS",(($,te)=>this._syncRTLPluginState($,te))),this.actor.registerMessageHandler("IS",(($,te)=>G._(this,void 0,void 0,(function*(){this.self.importScripts(te)})))),this.actor.registerMessageHandler("SI",(($,te)=>this._setImages($,te))),this.actor.registerMessageHandler("UL",(($,te)=>G._(this,void 0,void 0,(function*(){this._getLayerIndex($).update(te.layers,te.removedIds,this._getGlobalState($))})))),this.actor.registerMessageHandler("UGS",(($,te)=>G._(this,void 0,void 0,(function*(){const _e=this._getGlobalState($);for(const ve in te)_e[ve]=te[ve]})))),this.actor.registerMessageHandler("SL",(($,te)=>G._(this,void 0,void 0,(function*(){this._getLayerIndex($).replace(te,this._getGlobalState($))}))))}_getGlobalState(W){let $=this.globalStates.get(W);return $||($={},this.globalStates.set(W,$)),$}_setImages(W,$){return G._(this,void 0,void 0,(function*(){this.availableImages[W]=$;for(const te in this.workerSources[W]){const _e=this.workerSources[W][te];for(const ve in _e)_e[ve].availableImages=$}}))}_syncRTLPluginState(W,$){return G._(this,void 0,void 0,(function*(){return yield G.d4.syncState($,this.self.importScripts)}))}_getAvailableImages(W){let $=this.availableImages[W];return $||($=[]),$}_getLayerIndex(W){let $=this.layerIndexes[W];return $||($=this.layerIndexes[W]=new d),$}_getWorkerSource(W,$,te){if(this.workerSources[W]||(this.workerSources[W]={}),this.workerSources[W][$]||(this.workerSources[W][$]={}),!this.workerSources[W][$][te]){const _e={sendAsync:(ve,Re)=>(ve.targetMapId=W,this.actor.sendAsync(ve,Re))};switch($){case"vector":this.workerSources[W][$][te]=new Ze(_e,this._getLayerIndex(W),this._getAvailableImages(W));break;case"geojson":this.workerSources[W][$][te]=new Hs(_e,this._getLayerIndex(W),this._getAvailableImages(W));break;default:this.workerSources[W][$][te]=new this.externalWorkerSourceTypes[$](_e,this._getLayerIndex(W),this._getAvailableImages(W))}}return this.workerSources[W][$][te]}_getDEMWorkerSource(W,$){return this.demWorkerSources[W]||(this.demWorkerSources[W]={}),this.demWorkerSources[W][$]||(this.demWorkerSources[W][$]=new Gs),this.demWorkerSources[W][$]}}return G.i(self)&&(self.worker=new Di(self)),Di})),We("index",["exports","./shared"],(function(G,d){var nt="5.16.0";function Vr(){var _=new d.A(4);return d.A!=Float32Array&&(_[1]=0,_[2]=0),_[0]=1,_[3]=1,_}let si,kn,bs;const hi={frame(_,t,n){const A=requestAnimationFrame((y=>{h(),t(y)})),{unsubscribe:h}=d.s(_.signal,"abort",(()=>{h(),cancelAnimationFrame(A),n(new d.a(_.signal.reason))}),!1)},frameAsync(_){return new Promise(((t,n)=>{this.frame(_,t,n)}))},getImageData(_,t=0){return this.getImageCanvasContext(_).getImageData(-t,-t,_.width+2*t,_.height+2*t)},getImageCanvasContext(_){const t=window.document.createElement("canvas"),n=t.getContext("2d",{willReadFrequently:!0});if(!n)throw new Error("failed to create canvas 2d context");return t.width=_.width,t.height=_.height,n.drawImage(_,0,0,_.width,_.height),n},resolveURL:_=>(si||(si=document.createElement("a")),si.href=_,si.href),hardwareConcurrency:typeof navigator<"u"&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return bs!==void 0?bs:!!matchMedia&&(kn==null&&(kn=matchMedia("(prefers-reduced-motion: reduce)")),kn.matches)},set prefersReducedMotion(_){bs=_}},ss=new class{constructor(){this._realTime=typeof performance<"u"&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),this._frozenAt=null}getCurrentTime(){return this._frozenAt!==null?this._frozenAt:this._realTime()}setNow(_){this._frozenAt=_}restoreNow(){this._frozenAt=null}isFrozen(){return this._frozenAt!==null}};function Ar(){return ss.getCurrentTime()}class Ze{static testProp(t){if(!Ze.docStyle)return t[0];for(let n=0;n<t.length;n++)if(t[n]in Ze.docStyle)return t[n];return t[0]}static create(t,n,A){const h=window.document.createElement(t);return n!==void 0&&(h.className=n),A&&A.appendChild(h),h}static createNS(t,n){return window.document.createElementNS(t,n)}static disableDrag(){Ze.docStyle&&Ze.selectProp&&(Ze.userSelect=Ze.docStyle[Ze.selectProp],Ze.docStyle[Ze.selectProp]="none")}static enableDrag(){Ze.docStyle&&Ze.selectProp&&(Ze.docStyle[Ze.selectProp]=Ze.userSelect)}static setTransform(t,n){t.style[Ze.transformProp]=n}static addEventListener(t,n,A,h={}){t.addEventListener(n,A,"passive"in h?h:h.capture)}static removeEventListener(t,n,A,h={}){t.removeEventListener(n,A,"passive"in h?h:h.capture)}static suppressClickInternal(t){t.preventDefault(),t.stopPropagation(),window.removeEventListener("click",Ze.suppressClickInternal,!0)}static suppressClick(){window.addEventListener("click",Ze.suppressClickInternal,!0),window.setTimeout((()=>{window.removeEventListener("click",Ze.suppressClickInternal,!0)}),0)}static getScale(t){const n=t.getBoundingClientRect();return{x:n.width/t.offsetWidth||1,y:n.height/t.offsetHeight||1,boundingClientRect:n}}static getPoint(t,n,A){const h=n.boundingClientRect;return new d.P((A.clientX-h.left)/n.x-t.clientLeft,(A.clientY-h.top)/n.y-t.clientTop)}static mousePos(t,n){const A=Ze.getScale(t);return Ze.getPoint(t,A,n)}static touchPos(t,n){const A=[],h=Ze.getScale(t);for(let y=0;y<n.length;y++)A.push(Ze.getPoint(t,h,n[y]));return A}static mouseButton(t){return t.button}static remove(t){t.parentNode&&t.parentNode.removeChild(t)}static sanitize(t){const n=new DOMParser().parseFromString(t,"text/html").body||document.createElement("body"),A=n.querySelectorAll("script");for(const h of A)h.remove();return Ze.clean(n),n.innerHTML}static isPossiblyDangerous(t,n){const A=n.replace(/\s+/g,"").toLowerCase();return!(!["src","href","xlink:href"].includes(t)||!A.includes("javascript:")&&!A.includes("data:"))||!!t.startsWith("on")||void 0}static clean(t){const n=t.children;for(const A of n)Ze.removeAttributes(A),Ze.clean(A)}static removeAttributes(t){for(const{name:n,value:A}of t.attributes)Ze.isPossiblyDangerous(n,A)&&t.removeAttribute(n)}}Ze.docStyle=typeof window<"u"&&window.document&&window.document.documentElement.style,Ze.selectProp=Ze.testProp(["userSelect","MozUserSelect","WebkitUserSelect","msUserSelect"]),Ze.transformProp=Ze.testProp(["transform","WebkitTransform"]);const Gs={supported:!1,testSupport:function(_){!Us&&Rr&&(yo?ws(_):jr=_)}};let jr,Rr,Us=!1,yo=!1;function ws(_){const t=_.createTexture();_.bindTexture(_.TEXTURE_2D,t);try{if(_.texImage2D(_.TEXTURE_2D,0,_.RGBA,_.RGBA,_.UNSIGNED_BYTE,Rr),_.isContextLost())return;Gs.supported=!0}catch{}_.deleteTexture(t),Us=!0}var Yi;typeof document<"u"&&(Rr=document.createElement("img"),Rr.onload=()=>{jr&&ws(jr),jr=null,yo=!0},Rr.onerror=()=>{Us=!0,jr=null},Rr.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),(function(_){let t,n,A,h;_.resetRequestQueue=()=>{t=[],n=0,A=0,h={}},_.addThrottleControl=I=>{const D=A++;return h[D]=I,D},_.removeThrottleControl=I=>{delete h[I],b()},_.getImage=(I,D,B=!0)=>new Promise(((V,O)=>{Gs.supported&&(I.headers||(I.headers={}),I.headers.accept="image/webp,*/*"),d.e(I,{type:"image"}),t.push({abortController:D,requestParameters:I,supportImageRefresh:B,state:"queued",onError:U=>{O(U)},onSuccess:U=>{V(U)}}),b()}));const y=I=>d._(this,void 0,void 0,(function*(){I.state="running";const{requestParameters:D,supportImageRefresh:B,onError:V,onSuccess:O,abortController:U}=I,X=B===!1&&!d.i(self)&&!d.g(D.url)&&(!D.headers||Object.keys(D.headers).reduce(((ne,ce)=>ne&&ce==="accept"),!0));n++;const ie=X?M(D,U):d.m(D,U);try{const ne=yield ie;delete I.abortController,I.state="completed",ne.data instanceof HTMLImageElement||d.b(ne.data)?O(ne):ne.data&&O({data:yield(se=ne.data,typeof createImageBitmap=="function"?d.f(se):d.h(se)),cacheControl:ne.cacheControl,expires:ne.expires})}catch(ne){delete I.abortController,V(ne)}finally{n--,b()}var se})),b=()=>{const I=(()=>{for(const D of Object.keys(h))if(h[D]())return!0;return!1})()?d.c.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:d.c.MAX_PARALLEL_IMAGE_REQUESTS;for(let D=n;D<I&&t.length>0;D++){const B=t.shift();B.abortController.signal.aborted?D--:y(B)}},M=(I,D)=>new Promise(((B,V)=>{const O=new Image,U=I.url,X=I.credentials;X&&X==="include"?O.crossOrigin="use-credentials":(X&&X==="same-origin"||!d.d(U))&&(O.crossOrigin="anonymous"),D.signal.addEventListener("abort",(()=>{O.src="",V(new d.a(D.signal.reason))})),O.fetchPriority="high",O.onload=()=>{O.onerror=O.onload=null,B({data:O})},O.onerror=()=>{O.onerror=O.onload=null,D.signal.aborted||V(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."))},O.src=U}))})(Yi||(Yi={})),Yi.resetRequestQueue();class vo{constructor(t){this._transformRequestFn=t??null}transformRequest(t,n){return this._transformRequestFn&&this._transformRequestFn(t,n)||{url:t}}setTransformRequest(t){this._transformRequestFn=t}}function Ts(_){const t=[];if(typeof _=="string")t.push({id:"default",url:_});else if(_&&_.length>0){const n=[];for(const{id:A,url:h}of _){const y=`${A}${h}`;n.indexOf(y)===-1&&(n.push(y),t.push({id:A,url:h}))}}return t}function Qn(_,t,n){try{const A=new URL(_);return A.pathname+=`${t}${n}`,A.toString()}catch{throw new Error(`Invalid sprite URL "${_}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}function xn(_){const{userImage:t}=_;return!!(t&&t.render&&t.render())&&(_.data.replace(new Uint8Array(t.data.buffer)),!0)}class Ti extends d.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new d.R({width:1,height:1}),this.dirty=!0}destroy(){this.atlasTexture&&(this.atlasTexture.destroy(),this.atlasTexture=null);for(const t of Object.keys(this.images))this.removeImage(t);this.patterns={},this.atlasImage=new d.R({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(t){if(this.loaded!==t&&(this.loaded=t,t)){for(const{ids:n,promiseResolve:A}of this.requestors)A(this._getImagesForIds(n));this.requestors=[]}}getImage(t){const n=this.images[t];if(n&&!n.data&&n.spriteData){const A=n.spriteData;n.data=new d.R({width:A.width,height:A.height},A.context.getImageData(A.x,A.y,A.width,A.height).data),n.spriteData=null}return n}addImage(t,n){if(this.images[t])throw new Error(`Image id ${t} already exist, use updateImage instead`);this._validate(t,n)&&(this.images[t]=n)}_validate(t,n){let A=!0;const h=n.data||n.spriteData;return this._validateStretch(n.stretchX,h&&h.width)||(this.fire(new d.k(new Error(`Image "${t}" has invalid "stretchX" value`))),A=!1),this._validateStretch(n.stretchY,h&&h.height)||(this.fire(new d.k(new Error(`Image "${t}" has invalid "stretchY" value`))),A=!1),this._validateContent(n.content,n)||(this.fire(new d.k(new Error(`Image "${t}" has invalid "content" value`))),A=!1),A}_validateStretch(t,n){if(!t)return!0;let A=0;for(const h of t){if(h[0]<A||h[1]<h[0]||n<h[1])return!1;A=h[1]}return!0}_validateContent(t,n){if(!t)return!0;if(t.length!==4)return!1;const A=n.spriteData,h=A&&A.width||n.data.width,y=A&&A.height||n.data.height;return!(t[0]<0||h<t[0]||t[1]<0||y<t[1]||t[2]<0||h<t[2]||t[3]<0||y<t[3]||t[2]<t[0]||t[3]<t[1])}updateImage(t,n,A=!0){const h=this.getImage(t);if(A&&(h.data.width!==n.data.width||h.data.height!==n.data.height))throw new Error(`size mismatch between old image (${h.data.width}x${h.data.height}) and new image (${n.data.width}x${n.data.height}).`);n.version=h.version+1,this.images[t]=n,this.updatedImages[t]=!0}removeImage(t){const n=this.images[t];delete this.images[t],delete this.patterns[t],n.userImage&&n.userImage.onRemove&&n.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(t){return new Promise(((n,A)=>{let h=!0;if(!this.isLoaded())for(const y of t)this.images[y]||(h=!1);this.isLoaded()||h?n(this._getImagesForIds(t)):this.requestors.push({ids:t,promiseResolve:n})}))}_getImagesForIds(t){const n={};for(const A of t){let h=this.getImage(A);h||(this.fire(new d.l("styleimagemissing",{id:A})),h=this.getImage(A)),h?n[A]={data:h.data.clone(),pixelRatio:h.pixelRatio,sdf:h.sdf,version:h.version,stretchX:h.stretchX,stretchY:h.stretchY,content:h.content,textFitWidth:h.textFitWidth,textFitHeight:h.textFitHeight,hasRenderCallback:!!(h.userImage&&h.userImage.render)}:d.w(`Image "${A}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}return n}getPixelSize(){const{width:t,height:n}=this.atlasImage;return{width:t,height:n}}getPattern(t){const n=this.patterns[t],A=this.getImage(t);if(!A)return null;if(n&&n.position.version===A.version)return n.position;if(n)n.position.version=A.version;else{const h={w:A.data.width+2,h:A.data.height+2,x:0,y:0},y=new d.I(h,A);this.patterns[t]={bin:h,position:y}}return this._updatePatternAtlas(),this.patterns[t].position}bind(t){const n=t.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new d.T(t,this.atlasImage,n.RGBA),this.atlasTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE)}_updatePatternAtlas(){const t=[];for(const y in this.patterns)t.push(this.patterns[y].bin);const{w:n,h:A}=d.p(t),h=this.atlasImage;h.resize({width:n||1,height:A||1});for(const y in this.patterns){const{bin:b}=this.patterns[y],M=b.x+1,I=b.y+1,D=this.getImage(y).data,B=D.width,V=D.height;d.R.copy(D,h,{x:0,y:0},{x:M,y:I},{width:B,height:V}),d.R.copy(D,h,{x:0,y:V-1},{x:M,y:I-1},{width:B,height:1}),d.R.copy(D,h,{x:0,y:0},{x:M,y:I+V},{width:B,height:1}),d.R.copy(D,h,{x:B-1,y:0},{x:M-1,y:I},{width:1,height:V}),d.R.copy(D,h,{x:0,y:0},{x:M+B,y:I},{width:1,height:V})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(t){for(const n of t){if(this.callbackDispatchedThisFrame[n])continue;this.callbackDispatchedThisFrame[n]=!0;const A=this.getImage(n);A||d.w(`Image with ID: "${n}" was not found`),xn(A)&&this.updateImage(n,A)}}cloneImages(){const t={};for(const n in this.images){const A=this.images[n];t[n]=Object.assign(Object.assign({},A),{data:A.data?A.data.clone():null})}return t}}const Gi=1e20;function qs(_,t,n,A,h,y,b,M,I){for(let D=t;D<t+A;D++)Ki(_,n*y+D,y,h,b,M,I);for(let D=n;D<n+h;D++)Ki(_,D*y+t,1,A,b,M,I)}function Ki(_,t,n,A,h,y,b){y[0]=0,b[0]=-Gi,b[1]=Gi,h[0]=_[t];for(let M=1,I=0,D=0;M<A;M++){h[M]=_[t+M*n];const B=M*M;do{const V=y[I];D=(h[M]-h[V]+B-V*V)/(M-V)/2}while(D<=b[I]&&--I>-1);I++,y[I]=M,b[I]=D,b[I+1]=Gi}for(let M=0,I=0;M<A;M++){for(;b[I+1]<M;)I++;const D=y[I],B=M-D;_[t+M*n]=h[D]+B*B}}const xo=d.v.layout_symbol["text-font"].default.join(",");class Ui{constructor(t,n,A){this.requestManager=t,this.localIdeographFontFamily=n,this.entries={},this.lang=A}setURL(t){this.url=t}getGlyphs(t){return d._(this,void 0,void 0,(function*(){const n=[];for(const y in t)for(const b of t[y])n.push(this._getAndCacheGlyphsPromise(y,b));const A=yield Promise.all(n),h={};for(const{stack:y,id:b,glyph:M}of A)h[y]||(h[y]={}),h[y][b]=M&&{id:M.id,bitmap:M.bitmap.clone(),metrics:M.metrics};return h}))}_getAndCacheGlyphsPromise(t,n){return d._(this,void 0,void 0,(function*(){let A=this.entries[t];A||(A=this.entries[t]={glyphs:{},requests:{},ranges:{}});let h=A.glyphs[n];return h!==void 0?{stack:t,id:n,glyph:h}:!this.url||this._charUsesLocalIdeographFontFamily(n)?(h=A.glyphs[n]=this._drawGlyph(A,t,n),{stack:t,id:n,glyph:h}):yield this._downloadAndCacheRangePromise(t,n)}))}_downloadAndCacheRangePromise(t,n){return d._(this,void 0,void 0,(function*(){const A=this.entries[t],h=Math.floor(n/256);if(A.ranges[h])return{stack:t,id:n,glyph:null};if(!A.requests[h]){const y=Ui.loadGlyphRange(t,h,this.url,this.requestManager);A.requests[h]=y}try{const y=yield A.requests[h];for(const b in y)A.glyphs[+b]=y[+b];return A.ranges[h]=!0,{stack:t,id:n,glyph:y[n]||null}}catch(y){const b=A.glyphs[n]=this._drawGlyph(A,t,n);return this._warnOnMissingGlyphRange(b,h,n,y),{stack:t,id:n,glyph:b}}}))}_warnOnMissingGlyphRange(t,n,A,h){const y=256*n,b=y+255,M=A.toString(16).padStart(4,"0").toUpperCase();d.w(`Unable to load glyph range ${n}, ${y}-${b}. Rendering codepoint U+${M} locally instead. ${h}`)}_charUsesLocalIdeographFontFamily(t){return!!this.localIdeographFontFamily&&d.q(t)}_drawGlyph(t,n,A){const h=n===xo&&this.localIdeographFontFamily!==""&&this._charUsesLocalIdeographFontFamily(A),y=h?"ideographTinySDF":"tinySDF";t[y]||(t[y]=this._createTinySDF(h?this.localIdeographFontFamily:n));const b=t[y].draw(String.fromCodePoint(A)),M=new RegExp("^\\p{gc=Cf}+$","u").test(String.fromCodePoint(A));return{id:A,bitmap:new d.r({width:b.width||60,height:b.height||60},b.data),metrics:{width:M?0:b.glyphWidth/2||24,height:b.glyphHeight/2||24,left:b.glyphLeft/2+.5||0,top:b.glyphTop/2-27.5||-8,advance:M?0:b.glyphAdvance/2||24,isDoubleResolution:!0}}}_createTinySDF(t){const n=t?t.split(","):[];n.push("sans-serif");const A=n.map((h=>/[-\w]+/.test(h)?h:`'${CSS.escape(h)}'`)).join(",");return new Ui.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:A,fontWeight:this._fontWeight(n[0]),fontStyle:this._fontStyle(n[0]),lang:this.lang})}_fontStyle(t){return/italic/i.test(t)?"italic":/oblique/i.test(t)?"oblique":"normal"}_fontWeight(t){const n={thin:100,hairline:100,"extra light":200,"ultra light":200,light:300,normal:400,regular:400,medium:500,semibold:600,demibold:600,bold:700,"extra bold":800,"ultra bold":800,black:900,heavy:900,"extra black":950,"ultra black":950};let A;for(const[h,y]of Object.entries(n))new RegExp(`\\b${h}\\b`,"i").test(t)&&(A=`${y}`);return A}destroy(){for(const t in this.entries){const n=this.entries[t];n.tinySDF&&(n.tinySDF=null),n.ideographTinySDF&&(n.ideographTinySDF=null),n.glyphs={},n.requests={},n.ranges={}}this.entries={}}}Ui.loadGlyphRange=function(_,t,n,A){return d._(this,void 0,void 0,(function*(){const h=256*t,y=h+255,b=A.transformRequest(n.replace("{fontstack}",_).replace("{range}",`${h}-${y}`),"Glyphs"),M=yield d.n(b,new AbortController);if(!M||!M.data)throw new Error(`Could not load glyph range. range: ${t}, ${h}-${y}`);const I={};for(const D of d.o(M.data))I[D.id]=D;return I}))},Ui.TinySDF=class{constructor({fontSize:_=24,buffer:t=3,radius:n=8,cutoff:A=.25,fontFamily:h="sans-serif",fontWeight:y="normal",fontStyle:b="normal",lang:M=null}={}){this.buffer=t,this.cutoff=A,this.radius=n,this.lang=M;const I=this.size=_+4*t,D=this._createCanvas(I),B=this.ctx=D.getContext("2d",{willReadFrequently:!0});B.font=`${b} ${y} ${_}px ${h}`,B.textBaseline="alphabetic",B.textAlign="left",B.fillStyle="black",this.gridOuter=new Float64Array(I*I),this.gridInner=new Float64Array(I*I),this.f=new Float64Array(I),this.z=new Float64Array(I+1),this.v=new Uint16Array(I)}_createCanvas(_){const t=document.createElement("canvas");return t.width=t.height=_,t}draw(_){const{width:t,actualBoundingBoxAscent:n,actualBoundingBoxDescent:A,actualBoundingBoxLeft:h,actualBoundingBoxRight:y}=this.ctx.measureText(_),b=Math.ceil(n),M=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(y-h))),I=Math.min(this.size-this.buffer,b+Math.ceil(A)),D=M+2*this.buffer,B=I+2*this.buffer,V=Math.max(D*B,0),O=new Uint8ClampedArray(V),U={data:O,width:D,height:B,glyphWidth:M,glyphHeight:I,glyphTop:b,glyphLeft:0,glyphAdvance:t};if(M===0||I===0)return U;const{ctx:X,buffer:ie,gridInner:se,gridOuter:ne}=this;this.lang&&(X.lang=this.lang),X.clearRect(ie,ie,M,I),X.fillText(_,ie,ie+b);const ce=X.getImageData(ie,ie,M,I);ne.fill(Gi,0,V),se.fill(0,0,V);for(let ge=0;ge<I;ge++)for(let Ae=0;Ae<M;Ae++){const de=ce.data[4*(ge*M+Ae)+3]/255;if(de===0)continue;const ye=(ge+ie)*D+Ae+ie;if(de===1)ne[ye]=0,se[ye]=Gi;else{const fe=.5-de;ne[ye]=fe>0?fe*fe:0,se[ye]=fe<0?fe*fe:0}}qs(ne,0,0,D,B,D,this.f,this.v,this.z),qs(se,ie,ie,M,I,D,this.f,this.v,this.z);for(let ge=0;ge<V;ge++){const Ae=Math.sqrt(ne[ge])-Math.sqrt(se[ge]);O[ge]=Math.round(255-255*(Ae/this.radius+this.cutoff))}return U}};class Ps{constructor(){this.specification=d.u.light.position}possiblyEvaluate(t,n){return d.F(t.expression.evaluate(n))}interpolate(t,n,A){return{x:d.G.number(t.x,n.x,A),y:d.G.number(t.y,n.y,A),z:d.G.number(t.z,n.z,A)}}}let dr;class Zs extends d.E{constructor(t){super(),dr=dr||new d.t({anchor:new d.D(d.u.light.anchor),position:new Ps,color:new d.D(d.u.light.color),intensity:new d.D(d.u.light.intensity)}),this._transitionable=new d.x(dr,void 0),this.setLight(t),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(t,n={}){if(!this._validate(d.y,t,n))for(const A in t){const h=t[A];A.endsWith(d.z)?this._transitionable.setTransition(A.slice(0,-d.z.length),h):this._transitionable.setValue(A,h)}}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,n,A){return(!A||A.validate!==!1)&&d.B(this,t.call(d.C,{value:n,style:{glyphs:!0,sprite:!0},styleSpec:d.u}))}}const $n=new d.t({"sky-color":new d.D(d.u.sky["sky-color"]),"horizon-color":new d.D(d.u.sky["horizon-color"]),"fog-color":new d.D(d.u.sky["fog-color"]),"fog-ground-blend":new d.D(d.u.sky["fog-ground-blend"]),"horizon-fog-blend":new d.D(d.u.sky["horizon-fog-blend"]),"sky-horizon-blend":new d.D(d.u.sky["sky-horizon-blend"]),"atmosphere-blend":new d.D(d.u.sky["atmosphere-blend"])});class os extends d.E{constructor(t){super(),this._transitionable=new d.x($n,void 0),this.setSky(t),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new d.H(0))}setSky(t,n={}){if(!this._validate(d.J,t,n)){t||(t={"sky-color":"transparent","horizon-color":"transparent","fog-color":"transparent","fog-ground-blend":1,"atmosphere-blend":0});for(const A in t){const h=t[A];A.endsWith(d.z)?this._transitionable.setTransition(A.slice(0,-d.z.length),h):this._transitionable.setValue(A,h)}}}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,n,A={}){return(A==null?void 0:A.validate)!==!1&&d.B(this,t.call(d.C,d.e({value:n,style:{glyphs:!0,sprite:!0},styleSpec:d.u})))}calculateFogBlendOpacity(t){return t<60?0:t<70?(t-60)/10:1}}class bo{constructor(t,n){this.width=t,this.height=n,this.nextRow=0,this.data=new Uint8Array(this.width*this.height),this.dashEntry={}}getDash(t,n){const A=t.join(",")+String(n);return this.dashEntry[A]||(this.dashEntry[A]=this.addDash(t,n)),this.dashEntry[A]}getDashRanges(t,n,A){const h=[];let y=t.length%2==1?-t[t.length-1]*A:0,b=t[0]*A,M=!0;h.push({left:y,right:b,isDash:M,zeroLength:t[0]===0});let I=t[0];for(let D=1;D<t.length;D++){M=!M;const B=t[D];y=I*A,I+=B,b=I*A,h.push({left:y,right:b,isDash:M,zeroLength:B===0})}return h}addRoundDash(t,n,A){const h=n/2;for(let y=-A;y<=A;y++){const b=this.width*(this.nextRow+A+y);let M=0,I=t[M];for(let D=0;D<this.width;D++){D/I.right>1&&(I=t[++M]);const B=Math.abs(D-I.left),V=Math.abs(D-I.right),O=Math.min(B,V);let U;const X=y/A*(h+1);if(I.isDash){const ie=h-Math.abs(X);U=Math.sqrt(O*O+ie*ie)}else U=h-Math.sqrt(O*O+X*X);this.data[b+D]=Math.max(0,Math.min(255,U+128))}}}addRegularDash(t){for(let M=t.length-1;M>=0;--M){const I=t[M],D=t[M+1];I.zeroLength?t.splice(M,1):D&&D.isDash===I.isDash&&(D.left=I.left,t.splice(M,1))}const n=t[0],A=t[t.length-1];n.isDash===A.isDash&&(n.left=A.left-this.width,A.right=n.right+this.width);const h=this.width*this.nextRow;let y=0,b=t[y];for(let M=0;M<this.width;M++){M/b.right>1&&(b=t[++y]);const I=Math.abs(M-b.left),D=Math.abs(M-b.right),B=Math.min(I,D);this.data[h+M]=Math.max(0,Math.min(255,(b.isDash?B:-B)+128))}}addDash(t,n){const A=n?7:0,h=2*A+1;if(this.nextRow+h>this.height)return d.w("LineAtlas out of space"),null;let y=0;for(let M=0;M<t.length;M++)y+=t[M];if(y!==0){const M=this.width/y,I=this.getDashRanges(t,this.width,M);n?this.addRoundDash(I,M,A):this.addRegularDash(I)}const b={y:this.nextRow+A,height:2*A,width:y};return this.nextRow+=h,this.dirty=!0,b}bind(t){const n=t.gl;this.texture?(n.bindTexture(n.TEXTURE_2D,this.texture),this.dirty&&(this.dirty=!1,n.texSubImage2D(n.TEXTURE_2D,0,0,0,this.width,this.height,n.ALPHA,n.UNSIGNED_BYTE,this.data))):(this.texture=n.createTexture(),n.bindTexture(n.TEXTURE_2D,this.texture),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.REPEAT),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.REPEAT),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),n.texImage2D(n.TEXTURE_2D,0,n.ALPHA,this.width,this.height,0,n.ALPHA,n.UNSIGNED_BYTE,this.data))}}const Qs="maplibre_preloaded_worker_pool";class Si{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length<Si.workerCount;)this.workers.push(new Worker(d.c.WORKER_URL));return this.active[t]=!0,this.workers.slice()}release(t){delete this.active[t],this.numActive()===0&&(this.workers.forEach((n=>{n.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[Qs]}numActive(){return Object.keys(this.active).length}}const bn=Math.floor(hi.hardwareConcurrency/2);let as,qi;function $s(){return as||(as=new Si),as}Si.workerCount=d.K(globalThis)?Math.max(Math.min(bn,3),1):1;class zn{constructor(t,n){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=n;const A=this.workerPool.acquire(n);for(let h=0;h<A.length;h++){const y=new d.L(A[h],n);y.name=`Worker ${h}`,this.actors.push(y)}if(!this.actors.length)throw new Error("No actors found")}broadcast(t,n){const A=[];for(const h of this.actors)A.push(h.sendAsync({type:t,data:n}));return Promise.all(A)}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(t=!0){this.actors.forEach((n=>{n.remove()})),this.actors=[],t&&this.workerPool.release(this.id)}registerMessageHandler(t,n){for(const A of this.actors)A.registerMessageHandler(t,n)}unregisterMessageHandler(t){for(const n of this.actors)n.unregisterMessageHandler(t)}}function na(){return qi||(qi=new zn($s(),d.M),qi.registerMessageHandler("GR",((_,t,n)=>d.m(t,n)))),qi}function Bn(_,t){const n=d.N();return d.O(n,n,[1,1,0]),d.Q(n,n,[.5*_.width,.5*_.height,1]),_.calculatePosMatrix?d.S(n,n,_.calculatePosMatrix(t.toUnwrapped())):n}function sa(_,t,n,A,h,y,b){var M;const I=(function(O,U,X){if(O)for(const ie of O){const se=U[ie];if(se&&se.source===X&&se.type==="fill-extrusion")return!0}else for(const ie in U){const se=U[ie];if(se.source===X&&se.type==="fill-extrusion")return!0}return!1})((M=h==null?void 0:h.layers)!==null&&M!==void 0?M:null,t,_.id),D=y.maxPitchScaleFactor(),B=_.tilesIn(A,D,I);B.sort(di);const V=[];for(const O of B)V.push({wrappedTileID:O.tileID.wrapped().key,queryResults:O.tile.queryRenderedFeatures(t,n,_.getState(),O.queryGeometry,O.cameraQueryGeometry,O.scale,h,y,D,Bn(y,O.tileID),b?(U,X)=>b(O.tileID,U,X):void 0)});return(function(O,U){for(const X in O)for(const ie of O[X])wn(ie,U);return O})((function(O){const U={},X={};for(const ie of O){const se=ie.queryResults,ne=ie.wrappedTileID,ce=X[ne]=X[ne]||{};for(const ge in se){const Ae=se[ge],de=ce[ge]=ce[ge]||{},ye=U[ge]=U[ge]||[];for(const fe of Ae)de[fe.featureIndex]||(de[fe.featureIndex]=!0,ye.push(fe))}}return U})(V),_)}function di(_,t){const n=_.tileID,A=t.tileID;return n.overscaledZ-A.overscaledZ||n.canonical.y-A.canonical.y||n.wrap-A.wrap||n.canonical.x-A.canonical.x}function wn(_,t){const n=_.feature,A=t.getFeatureState(n.layer["source-layer"],n.id);n.source=n.layer.source,n.layer["source-layer"]&&(n.sourceLayer=n.layer["source-layer"]),n.state=A}function Wn(_,t,n){return d._(this,void 0,void 0,(function*(){let A=_;if(_.url?A=(yield d.j(t.transformRequest(_.url,"Source"),n)).data:yield hi.frameAsync(n),!A)return null;const h=d.U(d.e(A,_),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in A&&A.vector_layers&&(h.vectorLayerIds=A.vector_layers.map((y=>y.id))),h}))}class xr{constructor(t,n){t&&(n?this.setSouthWest(t).setNorthEast(n):Array.isArray(t)&&(t.length===4?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 d.V?new d.V(t.lng,t.lat):d.V.convert(t),this}setSouthWest(t){return this._sw=t instanceof d.V?new d.V(t.lng,t.lat):d.V.convert(t),this}extend(t){const n=this._sw,A=this._ne;let h,y;if(t instanceof d.V)h=t,y=t;else{if(!(t instanceof xr))return Array.isArray(t)?t.length===4||t.every(Array.isArray)?this.extend(xr.convert(t)):this.extend(d.V.convert(t)):t&&("lng"in t||"lon"in t)&&"lat"in t?this.extend(d.V.convert(t)):this;if(h=t._sw,y=t._ne,!h||!y)return this}return n||A?(n.lng=Math.min(h.lng,n.lng),n.lat=Math.min(h.lat,n.lat),A.lng=Math.max(y.lng,A.lng),A.lat=Math.max(y.lat,A.lat)):(this._sw=new d.V(h.lng,h.lat),this._ne=new d.V(y.lng,y.lat)),this}getCenter(){return new d.V((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 d.V(this.getWest(),this.getNorth())}getSouthEast(){return new d.V(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(t){const{lng:n,lat:A}=d.V.convert(t);let h=this._sw.lng<=n&&n<=this._ne.lng;return this._sw.lng>this._ne.lng&&(h=this._sw.lng>=n&&n>=this._ne.lng),this._sw.lat<=A&&A<=this._ne.lat&&h}intersects(t){if(!((t=xr.convert(t)).getNorth()>=this.getSouth()&&t.getSouth()<=this.getNorth()))return!1;const n=Math.abs(this.getEast()-this.getWest()),A=Math.abs(t.getEast()-t.getWest());if(n>=360||A>=360)return!0;const h=d.W(this.getWest(),-180,180),y=d.W(this.getEast(),-180,180),b=d.W(t.getWest(),-180,180),M=d.W(t.getEast(),-180,180),I=h>=y,D=b>=M;return!(!I||!D)||(I?M>=h||b<=y:D?y>=b||h<=M:b<=y&&M>=h)}static convert(t){return t instanceof xr?t:t&&new xr(t)}static fromLngLat(t,n=0){const A=360*n/40075017,h=A/Math.cos(Math.PI/180*t.lat);return new xr(new d.V(t.lng-h,t.lat-A),new d.V(t.lng+h,t.lat+A))}adjustAntiMeridian(){const t=new d.V(this._sw.lng,this._sw.lat),n=new d.V(this._ne.lng,this._ne.lat);return new xr(t,t.lng>n.lng?new d.V(n.lng+360,n.lat):n)}}class Tn{constructor(t,n,A){this.bounds=xr.convert(this.validateBounds(t)),this.minzoom=n||0,this.maxzoom=A||24}validateBounds(t){return Array.isArray(t)&&t.length===4?[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]:[-180,-90,180,90]}contains(t){const n=Math.pow(2,t.z),A=Math.floor(d.Y(this.bounds.getWest())*n),h=Math.floor(d.X(this.bounds.getNorth())*n),y=Math.ceil(d.Y(this.bounds.getEast())*n),b=Math.ceil(d.X(this.bounds.getSouth())*n);return t.x>=A&&t.x<y&&t.y>=h&&t.y<b}}class Ws extends d.E{constructor(t,n,A,h){if(super(),this.id=t,this.dispatcher=A,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,d.e(this,d.U(n,["url","scheme","tileSize","promoteId","encoding"])),this._options=d.e({type:"vector"},n),this._collectResourceTiming=n.collectResourceTiming,this.tileSize!==512)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(h)}load(){return d._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new d.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const t=yield Wn(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,this.map.style.tileManagers[this.id].clearTiles(),t&&(d.e(this,t),t.bounds&&(this.tileBounds=new Tn(t.bounds,this.minzoom,this.maxzoom)),this.fire(new d.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new d.l("data",{dataType:"source",sourceDataType:"content"})))}catch(t){this._tileJSONRequest=null,this._loaded=!0,d.Z(t)||this.fire(new d.k(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()}setTiles(t){return this.setSourceProperty((()=>{this._options.tiles=t})),this}setUrl(t){return this.setSourceProperty((()=>{this.url=t,this._options.url=t})),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}serialize(){return d.e({},this._options)}loadTile(t){return d._(this,void 0,void 0,(function*(){const n=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),A={request:this.map._requestManager.transformRequest(n,"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:this._getOverzoomParameters(t)};A.request.collectResourceTiming=this._collectResourceTiming;let h="RT";if(t.actor&&t.state!=="expired"){if(t.state==="loading")return new Promise(((y,b)=>{t.reloadPromise={resolve:y,reject:b}}))}else t.actor=this.dispatcher.getActor(),h="LT";t.abortController=new AbortController;try{const y=yield t.actor.sendAsync({type:h,data:A},t.abortController);if(delete t.abortController,t.aborted)return;this._afterTileLoadWorkerResponse(t,y)}catch(y){if(delete t.abortController,t.aborted)return;if(y&&y.status!==404)throw y;this._afterTileLoadWorkerResponse(t,null)}}))}_getOverzoomParameters(t){if(t.tileID.canonical.z<=this.maxzoom||this.map._zoomLevelsToOverscale===void 0)return;const n=t.tileID.scaledTo(this.maxzoom).canonical,A=n.url(this.tiles,this.map.getPixelRatio(),this.scheme);return{maxZoomTileID:n,overzoomRequest:this.map._requestManager.transformRequest(A,"Tile")}}_afterTileLoadWorkerResponse(t,n){if(n&&n.resourceTiming&&(t.resourceTiming=n.resourceTiming),n&&this.map._refreshExpiredTiles&&t.setExpiryData(n),t.loadVectorData(n,this.map.painter),t.reloadPromise){const A=t.reloadPromise;t.reloadPromise=null,this.loadTile(t).then(A.resolve).catch(A.reject)}}abortTile(t){return d._(this,void 0,void 0,(function*(){t.abortController&&(t.abortController.abort(),delete t.abortController),t.actor&&(yield t.actor.sendAsync({type:"AT",data:{uid:t.uid,type:this.type,source:this.id}}))}))}unloadTile(t){return d._(this,void 0,void 0,(function*(){t.unloadVectorData(),t.actor&&(yield t.actor.sendAsync({type:"RMT",data:{uid:t.uid,type:this.type,source:this.id}}))}))}hasTransition(){return!1}}class wo extends d.E{constructor(t,n,A,h){super(),this.id=t,this.dispatcher=A,this.setEventedParent(h),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=d.e({type:"raster"},n),d.e(this,d.U(n,["url","scheme","tileSize"]))}load(){return d._(this,arguments,void 0,(function*(t=!1){this._loaded=!1,this.fire(new d.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const n=yield Wn(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,n&&(d.e(this,n),n.bounds&&(this.tileBounds=new Tn(n.bounds,this.minzoom,this.maxzoom)),this.fire(new d.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new d.l("data",{dataType:"source",sourceDataType:"content",sourceDataChanged:t})))}catch(n){this._tileJSONRequest=null,this._loaded=!0,d.Z(n)||this.fire(new d.k(n))}}))}loaded(){return this._loaded}onAdd(t){this.map=t,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}setSourceProperty(t){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),t(),this.load(!0)}setTiles(t){return this.setSourceProperty((()=>{this._options.tiles=t})),this}setUrl(t){return this.setSourceProperty((()=>{this.url=t,this._options.url=t})),this}serialize(){return d.e({},this._options)}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(t){return d._(this,void 0,void 0,(function*(){const n=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);t.abortController=new AbortController;try{const A=yield Yi.getImage(this.map._requestManager.transformRequest(n,"Tile"),t.abortController,this.map._refreshExpiredTiles);if(delete t.abortController,t.aborted)return void(t.state="unloaded");if(A&&A.data){this.map._refreshExpiredTiles&&(A.cacheControl||A.expires)&&t.setExpiryData({cacheControl:A.cacheControl,expires:A.expires});const h=this.map.painter.context,y=h.gl,b=A.data;t.texture=this.map.painter.getTileTexture(b.width),t.texture?t.texture.update(b,{useMipmap:!0}):(t.texture=new d.T(h,b,y.RGBA,{useMipmap:!0}),t.texture.bind(y.LINEAR,y.CLAMP_TO_EDGE,y.LINEAR_MIPMAP_NEAREST)),t.state="loaded"}}catch(A){if(delete t.abortController,t.aborted)t.state="unloaded";else if(A)throw t.state="errored",A}}))}abortTile(t){return d._(this,void 0,void 0,(function*(){t.abortController&&(t.abortController.abort(),delete t.abortController)}))}unloadTile(t){return d._(this,void 0,void 0,(function*(){t.texture&&this.map.painter.saveTileTexture(t.texture)}))}hasTransition(){return!1}}class Ci extends wo{constructor(t,n,A,h){super(t,n,A,h),this.type="raster-dem",this.maxzoom=22,this._options=d.e({type:"raster-dem"},n),this.encoding=n.encoding||"mapbox",this.redFactor=n.redFactor,this.greenFactor=n.greenFactor,this.blueFactor=n.blueFactor,this.baseShift=n.baseShift}loadTile(t){return d._(this,void 0,void 0,(function*(){const n=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),A=this.map._requestManager.transformRequest(n,"Tile");t.neighboringTiles=this._getNeighboringTiles(t.tileID),t.abortController=new AbortController;try{const h=yield Yi.getImage(A,t.abortController,this.map._refreshExpiredTiles);if(delete t.abortController,t.aborted)return void(t.state="unloaded");if(h&&h.data){const y=h.data;this.map._refreshExpiredTiles&&(h.cacheControl||h.expires)&&t.setExpiryData({cacheControl:h.cacheControl,expires:h.expires});const b=d.b(y)&&d.$()?y:yield this.readImageNow(y),M={type:this.type,uid:t.uid,source:this.id,rawImageData:b,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!t.actor||t.state==="expired"){t.actor=this.dispatcher.getActor();const I=yield t.actor.sendAsync({type:"LDT",data:M});t.dem=I,t.needsHillshadePrepare=!0,t.needsTerrainPrepare=!0,t.state="loaded"}}}catch(h){if(delete t.abortController,t.aborted)t.state="unloaded";else if(h)throw t.state="errored",h}}))}readImageNow(t){return d._(this,void 0,void 0,(function*(){if(typeof VideoFrame<"u"&&d.a0()){const n=t.width+2,A=t.height+2;try{return new d.R({width:n,height:A},yield d.a1(t,-1,-1,n,A))}catch{}}return hi.getImageData(t,1)}))}_getNeighboringTiles(t){const n=t.canonical,A=Math.pow(2,n.z),h=(n.x-1+A)%A,y=n.x===0?t.wrap-1:t.wrap,b=(n.x+1+A)%A,M=n.x+1===A?t.wrap+1:t.wrap,I={};return I[new d.a2(t.overscaledZ,y,n.z,h,n.y).key]={backfilled:!1},I[new d.a2(t.overscaledZ,M,n.z,b,n.y).key]={backfilled:!1},n.y>0&&(I[new d.a2(t.overscaledZ,y,n.z,h,n.y-1).key]={backfilled:!1},I[new d.a2(t.overscaledZ,t.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},I[new d.a2(t.overscaledZ,M,n.z,b,n.y-1).key]={backfilled:!1}),n.y+1<A&&(I[new d.a2(t.overscaledZ,y,n.z,h,n.y+1).key]={backfilled:!1},I[new d.a2(t.overscaledZ,t.wrap,n.z,n.x,n.y+1).key]={backfilled:!1},I[new d.a2(t.overscaledZ,M,n.z,b,n.y+1).key]={backfilled:!1}),I}unloadTile(t){return d._(this,void 0,void 0,(function*(){t.demTexture&&this.map.painter.saveTileTexture(t.demTexture),t.fbo&&(t.fbo.destroy(),delete t.fbo),t.dem&&delete t.dem,delete t.neighboringTiles,t.state="unloaded",t.actor&&(yield t.actor.sendAsync({type:"RDT",data:{type:this.type,uid:t.uid,source:this.id}}))}))}}function fn(_){return _.type==="GeometryCollection"?_.geometries.map((t=>t.coordinates)).flat(1/0):_.coordinates.flat(1/0)}function Hs(_){const t=new xr;let n;switch(_.type){case"FeatureCollection":n=_.features.map((A=>fn(A.geometry))).flat(1/0);break;case"Feature":n=fn(_.geometry);break;default:n=fn(_)}if(n.length==0)return t;for(let A=0;A<n.length-1;A+=2)t.extend([n[A],n[A+1]]);return t}class Rn extends d.E{constructor(t,n,A,h){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:n.data},this.actor=A.getActor(),this.setEventedParent(h),this._data=typeof n.data=="string"?{url:n.data}:{geojson:n.data},this._options=d.e({},n),this._collectResourceTiming=n.collectResourceTiming,n.maxzoom!==void 0&&(this.maxzoom=n.maxzoom),n.type&&(this.type=n.type),n.attribution&&(this.attribution=n.attribution),this.promoteId=n.promoteId,n.clusterMaxZoom!==void 0&&this.maxzoom<=n.clusterMaxZoom&&d.w(`The maxzoom value "${this.maxzoom}" is expected to be greater than the clusterMaxZoom value "${n.clusterMaxZoom}".`),this.workerOptions=d.e({source:this.id,cluster:n.cluster||!1,geojsonVtOptions:{buffer:this._pixelsToTileUnits(n.buffer!==void 0?n.buffer:128),tolerance:this._pixelsToTileUnits(n.tolerance!==void 0?n.tolerance:.375),extent:d.a5,maxZoom:this.maxzoom,lineMetrics:n.lineMetrics||!1,generateId:n.generateId||!1},superclusterOptions:{maxZoom:this._getClusterMaxZoom(n.clusterMaxZoom),minPoints:Math.max(2,n.clusterMinPoints||2),extent:d.a5,radius:this._pixelsToTileUnits(n.clusterRadius||50),log:!1,generateId:n.generateId||!1},clusterProperties:n.clusterProperties,filter:n.filter},n.workerOptions),typeof this.promoteId=="string"&&(this.workerOptions.promoteId=this.promoteId)}_hasPendingWorkerUpdate(){return this._pendingWorkerUpdate.data!==void 0||this._pendingWorkerUpdate.diff!==void 0||this._pendingWorkerUpdate.optionsChanged}_pixelsToTileUnits(t){return t*(d.a5/this.tileSize)}_getClusterMaxZoom(t){const n=t?Math.round(t):this.maxzoom-1;return Number.isInteger(t)||t===void 0||d.w(`Integer expected for option 'clusterMaxZoom': provided value "${t}" rounded to "${n}"`),n}load(){return d._(this,void 0,void 0,(function*(){yield this._updateWorkerData()}))}onAdd(t){this.map=t,this.load()}setData(t,n){this._data=typeof t=="string"?{url:t}:{geojson:t},this._pendingWorkerUpdate={data:t};const A=this._updateWorkerData();return n?A:this}updateData(t,n){this._pendingWorkerUpdate.diff=d.a6(this._pendingWorkerUpdate.diff,t);const A=this._updateWorkerData();return n?A:this}getData(){return d._(this,void 0,void 0,(function*(){const t=d.e({type:this.type},this.workerOptions);return this.actor.sendAsync({type:"GD",data:t})}))}getBounds(){return d._(this,void 0,void 0,(function*(){return Hs(yield this.getData())}))}setClusterOptions(t){return this.workerOptions.cluster=t.cluster,t.clusterRadius!==void 0&&(this.workerOptions.superclusterOptions.radius=this._pixelsToTileUnits(t.clusterRadius)),t.clusterMaxZoom!==void 0&&(this.workerOptions.superclusterOptions.maxZoom=this._getClusterMaxZoom(t.clusterMaxZoom)),this._pendingWorkerUpdate.optionsChanged=!0,this._updateWorkerData(),this}getClusterExpansionZoom(t){return this.actor.sendAsync({type:"GCEZ",data:{type:this.type,clusterId:t,source:this.id}})}getClusterChildren(t){return this.actor.sendAsync({type:"GCC",data:{type:this.type,clusterId:t,source:this.id}})}getClusterLeaves(t,n,A){return this.actor.sendAsync({type:"GCL",data:{type:this.type,source:this.id,clusterId:t,limit:n,offset:A}})}_updateWorkerData(){return d._(this,void 0,void 0,(function*(){if(this._isUpdatingWorker)return;if(!this._hasPendingWorkerUpdate())return void d.w(`No pending worker updates for GeoJSONSource ${this.id}.`);const{data:t,diff:n}=this._pendingWorkerUpdate,A=d.e({type:this.type},this.workerOptions);t!==void 0?(typeof t=="string"?(A.request=this.map._requestManager.transformRequest(hi.resolveURL(t),"Source"),A.request.collectResourceTiming=this._collectResourceTiming):A.data=t,this._pendingWorkerUpdate.data=void 0):n&&(A.dataDiff=n,this._pendingWorkerUpdate.diff=void 0),this._pendingWorkerUpdate.optionsChanged=void 0,this._isUpdatingWorker=!0,this.fire(new d.l("dataloading",{dataType:"source"}));try{const h=yield this.actor.sendAsync({type:"LD",data:A});if(this._isUpdatingWorker=!1,this._removed||h.abandoned)return void this.fire(new d.l("dataabort",{dataType:"source"}));h.data&&(this._data={geojson:h.data});const y=this._applyDiffToSource(n),b=this._getShouldReloadTileOptions(y);let M=null;h.resourceTiming&&h.resourceTiming[this.id]&&(M=h.resourceTiming[this.id].slice(0));const I={dataType:"source"};this._collectResourceTiming&&M&&M.length>0&&d.e(I,{resourceTiming:M}),this.fire(new d.l("data",Object.assign(Object.assign({},I),{sourceDataType:"metadata"}))),this.fire(new d.l("data",Object.assign(Object.assign({},I),{sourceDataType:"content",shouldReloadTileOptions:b})))}catch(h){if(this._isUpdatingWorker=!1,this._removed)return void this.fire(new d.l("dataabort",{dataType:"source"}));this.fire(new d.k(h))}finally{this._hasPendingWorkerUpdate()&&this._updateWorkerData()}}))}_applyDiffToSource(t){if(!t)return;const n=typeof this.promoteId=="string"?this.promoteId:void 0;if(!this._data.url&&!this._data.updateable){const h=d.a7(this._data.geojson,n);if(!h)throw new Error(`GeoJSONSource "${this.id}": GeoJSON data is not compatible with updateData`);this._data={updateable:h}}if(!this._data.updateable)return;const A=d.a8(this._data.updateable,t,n);return t.removeAll||this._options.cluster?void 0:A}_getShouldReloadTileOptions(t){if(t)return{affectedBounds:t.filter(Boolean).map((n=>Hs(n)))}}shouldReloadTile(t,{affectedBounds:n}){if(t.state==="loading")return!0;if(t.state==="unloaded")return!1;const{buffer:A,extent:h}=this.workerOptions.geojsonVtOptions,y=(function({x:b,y:M,z:I},D=0){const B=d.a3((b-D)/Math.pow(2,I)),V=d.a4((M+1+D)/Math.pow(2,I)),O=d.a3((b+1+D)/Math.pow(2,I)),U=d.a4((M-D)/Math.pow(2,I));return new xr([B,V],[O,U])})(t.tileID.canonical,A/h);for(const b of n)if(y.intersects(b))return!0;return!1}loaded(){return!this._isUpdatingWorker&&!this._hasPendingWorkerUpdate()}loadTile(t){return d._(this,void 0,void 0,(function*(){const n=t.actor?"RT":"LT";t.actor=this.actor;const A={type:this.type,uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity};t.abortController=new AbortController;const h=yield this.actor.sendAsync({type:n,data:A},t.abortController);delete t.abortController,t.unloadVectorData(),t.aborted||t.loadVectorData(h,this.map.painter,n==="RT")}))}abortTile(t){return d._(this,void 0,void 0,(function*(){t.abortController&&(t.abortController.abort(),delete t.abortController),t.aborted=!0}))}unloadTile(t){return d._(this,void 0,void 0,(function*(){t.unloadVectorData(),yield this.actor.sendAsync({type:"RMT",data:{uid:t.uid,type:this.type,source:this.id}})}))}onRemove(){this._removed=!0,this.actor.sendAsync({type:"RS",data:{type:this.type,source:this.id}})}serialize(){return d.e({},this._options,{type:this.type,data:this._data.updateable?{type:"FeatureCollection",features:Array.from(this._data.updateable.values())}:this._data.url||this._data.geojson})}hasTransition(){return!1}}class Di extends d.E{constructor(t,n,A,h){super(),this.flippedWindingOrder=!1,this.id=t,this.dispatcher=A,this.coordinates=n.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(h),this.options=n}load(t){return d._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new d.l("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{const n=yield Yi.getImage(this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,n&&n.data&&(this.image=n.data,t&&(this.coordinates=t),this._finishLoading())}catch(n){this._request=null,this._loaded=!0,d.Z(n)||this.fire(new d.k(n))}}))}loaded(){return this._loaded}updateImage(t){return t.url?(this._request&&(this._request.abort(),this._request=null),this.options.url=t.url,this.load(t.coordinates).finally((()=>{this.texture=null})),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new d.l("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(){this._request&&(this._request.abort(),this._request=null)}setCoordinates(t){this.coordinates=t;const n=t.map(d.a9.fromLngLat);var A;return this.tileID=(function(h){const y=d.aa.fromPoints(h),b=y.width(),M=y.height(),I=Math.max(b,M),D=Math.max(0,Math.floor(-Math.log(I)/Math.LN2)),B=Math.pow(2,D);return new d.ac(D,Math.floor((y.minX+y.maxX)/2*B),Math.floor((y.minY+y.maxY)/2*B))})(n),this.terrainTileRanges=this._getOverlappingTileRanges(n),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=n.map((h=>this.tileID.getTilePoint(h)._round())),this.flippedWindingOrder=((A=this.tileCoords)[1].x-A[0].x)*(A[2].y-A[0].y)-(A[1].y-A[0].y)*(A[2].x-A[0].x)<0,this.fire(new d.l("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;const t=this.map.painter.context,n=t.gl;this.texture||(this.texture=new d.T(t,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));let A=!1;for(const h in this.tiles){const y=this.tiles[h];y.state!=="loaded"&&(y.state="loaded",y.texture=this.texture,A=!0)}A&&this.fire(new d.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(t){return d._(this,void 0,void 0,(function*(){this.tileID&&this.tileID.equals(t.tileID.canonical)?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={}):t.state="errored"}))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}_getOverlappingTileRanges(t){const{minX:n,minY:A,maxX:h,maxY:y}=d.aa.fromPoints(t),b={};for(let M=0;M<=d.ab;M++){const I=Math.pow(2,M),D=Math.floor(n*I),B=Math.floor(A*I),V=Math.floor(h*I),O=Math.floor(y*I),U=(D%I+I)%I,X=V%I,ie=Math.floor(D/I),se=Math.floor(V/I);b[M]={minWrap:ie,maxWrap:se,minTileXWrapped:U,maxTileXWrapped:X,minTileY:B,maxTileY:O}}return b}}class De extends Di{constructor(t,n,A,h){super(t,n,A,h),this.roundZoom=!0,this.type="video",this.options=n}load(){return d._(this,void 0,void 0,(function*(){this._loaded=!1;const t=this.options;this.urls=[];for(const n of t.urls)this.urls.push(this.map._requestManager.transformRequest(n,"Source").url);try{const n=yield d.ad(this.urls);if(this._loaded=!0,!n)return;this.video=n,this.video.loop=!0,this.video.addEventListener("playing",(()=>{this.map.triggerRepaint()})),this.map&&this.video.play(),this._finishLoading()}catch(n){this.fire(new d.k(n))}}))}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(t){if(this.video){const n=this.video.seekable;t<n.start(0)||t>n.end(0)?this.fire(new d.k(new d.ae(`sources.${this.id}`,null,`Playback for this video can be set only between the ${n.start(0)} and ${n.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)))}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;const t=this.map.painter.context,n=t.gl;this.texture?this.video.paused||(this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,this.video)):(this.texture=new d.T(t,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));let A=!1;for(const h in this.tiles){const y=this.tiles[h];y.state!=="loaded"&&(y.state="loaded",y.texture=this.texture,A=!0)}A&&this.fire(new d.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class W extends Di{constructor(t,n,A,h){super(t,n,A,h),n.coordinates?Array.isArray(n.coordinates)&&n.coordinates.length===4&&!n.coordinates.some((y=>!Array.isArray(y)||y.length!==2||y.some((b=>typeof b!="number"))))||this.fire(new d.k(new d.ae(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new d.k(new d.ae(`sources.${t}`,null,'missing required property "coordinates"'))),n.animate&&typeof n.animate!="boolean"&&this.fire(new d.k(new d.ae(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),n.canvas?typeof n.canvas=="string"||n.canvas instanceof HTMLCanvasElement||this.fire(new d.k(new d.ae(`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 d.k(new d.ae(`sources.${t}`,null,'missing required property "canvas"'))),this.options=n,this.animate=n.animate===void 0||n.animate}load(){return d._(this,void 0,void 0,(function*(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new d.k(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}))}getCanvas(){return this.canvas}onAdd(t){this.map=t,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const n=this.map.painter.context,A=n.gl;this.texture?(t||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):(this.texture=new d.T(n,this.canvas,A.RGBA,{premultiply:!0}),this.texture.bind(A.LINEAR,A.CLAMP_TO_EDGE));let h=!1;for(const y in this.tiles){const b=this.tiles[y];b.state!=="loaded"&&(b.state="loaded",b.texture=this.texture,h=!0)}h&&this.fire(new d.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"canvas",animate:this.animate,canvas:this.options.canvas,coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const t of[this.canvas.width,this.canvas.height])if(isNaN(t)||t<=0)return!0;return!1}}const $={},te=_=>{switch(_){case"geojson":return Rn;case"image":return Di;case"raster":return wo;case"raster-dem":return Ci;case"vector":return Ws;case"video":return De;case"canvas":return W}return $[_]},_e="RTLPluginLoaded";class ve extends d.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=na()}_syncState(t){return this.status=t,this.dispatcher.broadcast("SRPS",{pluginStatus:t,pluginURL:this.url}).catch((n=>{throw this.status="error",n}))}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null}setRTLTextPlugin(t){return d._(this,arguments,void 0,(function*(n,A=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=hi.resolveURL(n),!this.url)throw new Error(`requested url ${n} is invalid`);if(this.status==="unavailable"){if(!A)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if(this.status==="requested")return this._requestImport()}))}_requestImport(){return d._(this,void 0,void 0,(function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new d.l(_e))}))}lazyLoad(){this.status==="unavailable"?this.status="requested":this.status==="deferred"&&this._requestImport()}}let Re=null;function Ce(){return Re||(Re=new ve),Re}var Te,je;(function(_){_[_.Base=0]="Base",_[_.Parent=1]="Parent"})(Te||(Te={})),(function(_){_[_.Departing=0]="Departing",_[_.Incoming=1]="Incoming"})(je||(je={}));class tt{constructor(t,n){this.timeAdded=0,this.fadeEndTime=0,this.fadeOpacity=1,this.tileID=t,this.uid=d.af(),this.uses=0,this.tileSize=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading"}isRenderable(t){return this.hasData()&&(!this.fadeEndTime||this.fadeOpacity>0)&&(t||!this.holdingForSymbolFade())}setCrossFadeLogic({fadingRole:t,fadingDirection:n,fadingParentID:A,fadeEndTime:h}){this.resetFadeLogic(),this.fadingRole=t,this.fadingDirection=n,this.fadingParentID=A,this.fadeEndTime=h}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=Ar(),this.fadeEndTime=0,this.fadeOpacity=1}wasRequested(){return this.state==="errored"||this.state==="loaded"||this.state==="reloading"}clearTextures(t){this.demTexture&&t.saveTileTexture(this.demTexture),this.demTexture=null}loadVectorData(t,n,A){if(this.hasData()&&this.unloadVectorData(),this.state="loaded",t){t.featureIndex&&(this.latestFeatureIndex=t.featureIndex,t.rawTileData?(this.latestRawTileData=t.rawTileData,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(h,y){const b={};if(!y)return b;for(const M of h){const I=M.layerIds.map((D=>y.getLayer(D))).filter(Boolean);if(I.length!==0){M.layers=I,M.stateDependentLayerIds&&(M.stateDependentLayers=M.stateDependentLayerIds.map((D=>I.filter((B=>B.id===D))[0])));for(const D of I)b[D.id]=M}}return b})(t.buckets,n==null?void 0:n.style),this.hasSymbolBuckets=!1;for(const h in this.buckets){const y=this.buckets[h];if(y instanceof d.ah){if(this.hasSymbolBuckets=!0,!A)break;y.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const h in this.buckets){const y=this.buckets[h];if(y instanceof d.ah&&y.hasRTLText){this.hasRTLText=!0,Ce().lazyLoad();break}}this.queryPadding=0;for(const h in this.buckets){const y=this.buckets[h];this.queryPadding=Math.max(this.queryPadding,n.style.getLayer(h).queryRadius(y))}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),this.dashPositions=t.dashPositions}else this.collisionBoxArray=new d.ag}unloadVectorData(){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.dashPositions&&(this.dashPositions=null),this.latestFeatureIndex=null,this.state="unloaded"}getBucket(t){return this.buckets[t.id]}upload(t){for(const A in this.buckets){const h=this.buckets[A];h.uploadPending()&&h.upload(t)}const n=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new d.T(t,this.imageAtlas.image,n.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new d.T(t,this.glyphAtlasImage,n.ALPHA),this.glyphAtlasImage=null)}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture)}queryRenderedFeatures(t,n,A,h,y,b,M,I,D,B,V){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:h,cameraQueryGeometry:y,scale:b,tileSize:this.tileSize,pixelPosMatrix:B,transform:I,params:M,queryPadding:this.queryPadding*D,getElevation:V},t,n,A):{}}querySourceFeatures(t,n){const A=this.latestFeatureIndex;if(!A||!A.rawTileData)return;const h=A.loadVTLayers(),y=n&&n.sourceLayer?n.sourceLayer:"",b=h[d.ai]||h[y];if(!b)return;const M=d.aj(n==null?void 0:n.filter,n==null?void 0:n.globalState),{z:I,x:D,y:B}=this.tileID.canonical,V={z:I,x:D,y:B};for(let O=0;O<b.length;O++){const U=b.feature(O);if(M.needGeometry){const se=d.ak(U,!0);if(!M.filter(new d.H(this.tileID.overscaledZ),se,this.tileID.canonical))continue}else if(!M.filter(new d.H(this.tileID.overscaledZ),U))continue;const X=A.getId(U,y),ie=new d.al(U,I,D,B,X);ie.tile=V,t.push(ie)}}hasData(){return this.state==="loaded"||this.state==="reloading"||this.state==="expired"}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(t){const n=this.expirationTime;if(t.cacheControl){const A=d.am(t.cacheControl);A["max-age"]&&(this.expirationTime=Date.now()+1e3*A["max-age"])}else t.expires&&(this.expirationTime=new Date(t.expires).getTime());if(this.expirationTime){const A=Date.now();let h=!1;if(this.expirationTime>A)h=!1;else if(n)if(this.expirationTime<n)h=!0;else{const y=this.expirationTime-n;y?this.expirationTime=A+Math.max(y,3e4):h=!0}else h=!0;h?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-new Date().getTime(),Math.pow(2,31)-1)}setFeatureState(t,n){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData||Object.keys(t).length===0)return;const A=this.latestFeatureIndex.loadVTLayers();for(const h in this.buckets){if(!n.style.hasLayer(h))continue;const y=this.buckets[h],b=y.layers[0].sourceLayer||d.ai,M=A[b],I=t[b];if(!M||!I||Object.keys(I).length===0)continue;y.update(I,M,this.imageAtlas&&this.imageAtlas.patternPositions||{},this.dashPositions||{});const D=n&&n.style&&n.style.getLayer(h);D&&(this.queryPadding=Math.max(this.queryPadding,D.queryRadius(y)))}}holdingForSymbolFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<Ar()}clearSymbolFadeHold(){this.symbolFadeHoldUntil=void 0}setSymbolHoldDuration(t){this.symbolFadeHoldUntil=Ar()+t}setDependencies(t,n){const A={};for(const h of n)A[h]=!0;this.dependencies[t]=A}hasDependency(t,n){for(const A of t){const h=this.dependencies[A];if(h){for(const y of n)if(h[y])return!0}}return!1}}class Ke{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,n,A){const h=String(n);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][h]=this.stateChanges[t][h]||{},d.e(this.stateChanges[t][h],A),this.deletedStates[t]===null){this.deletedStates[t]={};for(const y in this.state[t])y!==h&&(this.deletedStates[t][y]=null)}else if(this.deletedStates[t]&&this.deletedStates[t][h]===null){this.deletedStates[t][h]={};for(const y in this.state[t][h])A[y]||(this.deletedStates[t][h][y]=null)}else for(const y in A)this.deletedStates[t]&&this.deletedStates[t][h]&&this.deletedStates[t][h][y]===null&&delete this.deletedStates[t][h][y]}removeFeatureState(t,n,A){if(this.deletedStates[t]===null)return;const h=String(n);if(this.deletedStates[t]=this.deletedStates[t]||{},A&&n!==void 0)this.deletedStates[t][h]!==null&&(this.deletedStates[t][h]=this.deletedStates[t][h]||{},this.deletedStates[t][h][A]=null);else if(n!==void 0)if(this.stateChanges[t]&&this.stateChanges[t][h])for(A in this.deletedStates[t][h]={},this.stateChanges[t][h])this.deletedStates[t][h][A]=null;else this.deletedStates[t][h]=null;else this.deletedStates[t]=null}getState(t,n){const A=String(n),h=d.e({},(this.state[t]||{})[A],(this.stateChanges[t]||{})[A]);if(this.deletedStates[t]===null)return{};if(this.deletedStates[t]){const y=this.deletedStates[t][n];if(y===null)return{};for(const b in y)delete h[b]}return h}initializeTileState(t,n){t.setFeatureState(this.state,n)}coalesceChanges(t,n){const A={};for(const h in this.stateChanges){this.state[h]=this.state[h]||{};const y={};for(const b in this.stateChanges[h])this.state[h][b]||(this.state[h][b]={}),d.e(this.state[h][b],this.stateChanges[h][b]),y[b]=this.state[h][b];A[h]=y}for(const h in this.deletedStates){this.state[h]=this.state[h]||{};const y={};if(this.deletedStates[h]===null)for(const b in this.state[h])y[b]={},this.state[h][b]={};else for(const b in this.deletedStates[h]){if(this.deletedStates[h][b]===null)this.state[h][b]={};else for(const M of Object.keys(this.deletedStates[h][b]))delete this.state[h][b][M];y[b]=this.state[h][b]}A[h]=A[h]||{},d.e(A[h],y)}this.stateChanges={},this.deletedStates={},Object.keys(A).length!==0&&t.setFeatureState(A,n)}}const _t=89.25;function Be(_,t){const n=d.an(t.lat,-d.ao,d.ao);return new d.P(d.Y(t.lng)*_,d.X(n)*_)}function Vt(_,t){return new d.a9(t.x/_,t.y/_).toLngLat()}function gr(_){return _.cameraToCenterDistance*Math.min(.85*Math.tan(d.ap(90-_.pitch)),Math.tan(d.ap(_t-_.pitch)))}function hr(_,t){const n=_.canonical,A=t/d.aq(n.z),h=n.x+Math.pow(2,n.z)*_.wrap,y=d.ar(new Float64Array(16));return d.O(y,y,[h*A,n.y*A,0]),d.Q(y,y,[A/d.a5,A/d.a5,1]),y}function Le(_,t,n,A,h){const y=d.a9.fromLngLat(_,t),b=h*d.as(1,_.lat),{x:M,y:I,z:D}=_r(n,A);return new d.a9(y.x+b*-M,y.y+b*-I,y.z+b*-D)}function _r(_,t){const n=d.ap(_),A=d.ap(t),h=Math.cos(-n),y=Math.sin(n);return{x:y*Math.sin(A),y:-y*Math.cos(A),z:h}}function mi(_,t,n){const A=t.intersectsFrustum(_);if(!n||A===0)return A;const h=t.intersectsPlane(n);return h===0?0:A===2&&h===2?2:1}function Lt(_,t,n){let A=0;const h=(n-t)/10;for(let y=0;y<10;y++)A+=h*Math.pow(Math.cos(t+(y+.5)/10*(n-t)),_);return A}function mr(_,t){return function(n,A,h,y,b){const M=2*((_-1)/d.at(Math.cos(d.ap(_t-b))/Math.cos(d.ap(_t)))-1),I=Math.acos(h/y),D=2*Lt(M-1,0,d.ap(b/2)),B=Math.min(d.ap(_t),I+d.ap(b/2)),V=Lt(M-1,Math.min(B,I-d.ap(b/2)),B),O=Math.atan(A/h),U=Math.hypot(A,h);let X=n;return X+=d.at(y/U/Math.max(.5,Math.cos(d.ap(b/2)))),X+=M*d.at(Math.cos(O))/2,X-=d.at(Math.max(1,V/D/t))/2,X}}const oi=mr(9.314,3);function Pr(_,t){const n=(t.roundZoom?Math.round:Math.floor)(_.zoom+d.at(_.tileSize/t.tileSize));return Math.max(0,n)}function Mr(_,t){const n=_.getCameraFrustum(),A=_.getClippingPlane(),h=_.screenPointToMercatorCoordinate(_.getCameraPoint()),y=d.a9.fromLngLat(_.center,_.elevation);h.z=y.z+Math.cos(_.pitchInRadians)*_.cameraToCenterDistance/_.worldSize;const b=_.getCoveringTilesDetailsProvider(),M=b.allowVariableZoom(_,t),I=Pr(_,t),D=t.minzoom||0,B=t.maxzoom!==void 0?t.maxzoom:_.maxZoom,V=Math.min(Math.max(0,I),B),O=Math.pow(2,V),U=[O*h.x,O*h.y,0],X=[O*y.x,O*y.y,0],ie=Math.hypot(y.x-h.x,y.y-h.y),se=Math.abs(y.z-h.z),ne=Math.hypot(ie,se),ce=de=>({zoom:0,x:0,y:0,wrap:de,fullyVisible:!1}),ge=[],Ae=[];if(_.renderWorldCopies&&b.allowWorldCopies())for(let de=1;de<=3;de++)ge.push(ce(-de)),ge.push(ce(de));for(ge.push(ce(0));ge.length>0;){const de=ge.pop(),ye=de.x,fe=de.y;let Me=de.fullyVisible;const Ge={x:ye,y:fe,z:de.zoom},Fe=b.getTileBoundingVolume(Ge,de.wrap,_.elevation,t);if(!Me){const ht=mi(n,Fe,A);if(ht===0)continue;Me=ht===2}const Oe=b.distanceToTile2d(h.x,h.y,Ge,Fe);let Ve=I;M&&(Ve=(t.calculateTileZoom||oi)(_.zoom+d.at(_.tileSize/t.tileSize),Oe,se,ne,_.fov)),Ve=(t.roundZoom?Math.round:Math.floor)(Ve),Ve=Math.max(0,Ve);const ut=Math.min(Ve,B);if(de.wrap=b.getWrap(y,Ge,de.wrap),de.zoom>=ut){if(de.zoom<D)continue;const ht=V-de.zoom,rt=U[0]-.5-(ye<<ht),ft=U[1]-.5-(fe<<ht),Wt=t.reparseOverscaled?Math.max(de.zoom,Ve):de.zoom;Ae.push({tileID:new d.a2(de.zoom===B?Wt:de.zoom,de.wrap,de.zoom,ye,fe),distanceSq:d.au([X[0]-.5-ye,X[1]-.5-fe]),tileDistanceToCamera:Math.sqrt(rt*rt+ft*ft)})}else for(let ht=0;ht<4;ht++)ge.push({zoom:de.zoom+1,x:(ye<<1)+ht%2,y:(fe<<1)+(ht>>1),wrap:de.wrap,fullyVisible:Me})}return Ae.sort(((de,ye)=>de.distanceSq-ye.distanceSq)).map((de=>de.tileID))}const ke=d.aa.fromPoints([new d.P(0,0),new d.P(d.a5,d.a5)]);function Xe(_){return _==="raster"||_==="image"||_==="video"}function vt(_,t,n,A,h,y,b){if(!t.hasData())return!1;const{tileID:M,fadingRole:I,fadingDirection:D,fadingParentID:B}=t;if(I===Te.Base&&D===je.Incoming&&B)return n[B.key]=B,!0;const V=Math.max(M.overscaledZ-h,y);for(let O=M.overscaledZ-1;O>=V;O--){const U=M.scaledTo(O),X=_.getLoadedTile(U);if(X)return t.setCrossFadeLogic({fadingRole:Te.Base,fadingDirection:je.Incoming,fadingParentID:X.tileID,fadeEndTime:A+b}),X.setCrossFadeLogic({fadingRole:Te.Parent,fadingDirection:je.Departing,fadeEndTime:A+b}),n[U.key]=U,!0}return!1}function ot(_,t,n,A,h,y){if(!t.hasData())return!1;const b=t.tileID.children(h);let M=o(_,t,b,n,A,h,y);if(M)return!0;for(const I of b)o(_,t,I.children(h),n,A,h,y)&&(M=!0);return M}function o(_,t,n,A,h,y,b){if(n[0].overscaledZ>=y)return!1;let M=!1;for(const I of n){const D=_.getLoadedTile(I);if(!D)continue;const{fadingRole:B,fadingDirection:V,fadingParentID:O}=D;B===Te.Base&&V===je.Departing&&O||(D.setCrossFadeLogic({fadingRole:Te.Base,fadingDirection:je.Departing,fadingParentID:t.tileID,fadeEndTime:h+b}),t.setCrossFadeLogic({fadingRole:Te.Parent,fadingDirection:je.Incoming,fadeEndTime:h+b})),A[I.key]=I,M=!0}return M}function Z(_,t,n,A){const h=_.tileID;return!!_.selfFading||!_.hasData()&&!!t.has(h)&&(_.setSelfFadeLogic(n+A),!0)}function Ut(_,t){var n;_.needsHillshadePrepare=!0,_.needsTerrainPrepare=!0;let A=t.tileID.canonical.x-_.tileID.canonical.x;const h=t.tileID.canonical.y-_.tileID.canonical.y,y=Math.pow(2,_.tileID.canonical.z),b=t.tileID.key;A===0&&h===0||Math.abs(h)>1||(Math.abs(A)>1&&(Math.abs(A+y)===1?A+=y:Math.abs(A-y)===1&&(A-=y)),t.dem&&_.dem&&(_.dem.backfillBorder(t.dem,A,h),!((n=_.neighboringTiles)===null||n===void 0)&&n[b]&&(_.neighboringTiles[b].backfilled=!0)))}class pr{constructor(){this._tiles={}}handleWrapJump(t){const n={};for(const A in this._tiles){const h=this._tiles[A];h.tileID=h.tileID.unwrapTo(h.tileID.wrap+t),n[h.tileID.key]=h}this._tiles=n}setFeatureState(t,n){for(const A in this._tiles)this._tiles[A].setFeatureState(t,n)}getAllTiles(){return Object.values(this._tiles)}getAllIds(t=!1){return t?Object.values(this._tiles).map((n=>n.tileID)).sort(d.aw).map((n=>n.key)):Object.keys(this._tiles)}getTileById(t){return this._tiles[t]}setTile(t,n){this._tiles[t]=n}deleteTileById(t){delete this._tiles[t]}getLoadedTile(t){const n=this.getTileById(t.key);return n!=null&&n.hasData()?n:null}isIdRenderable(t,n=!1){var A;return(A=this.getTileById(t))===null||A===void 0?void 0:A.isRenderable(n)}getRenderableIds(t=0,n){const A=[];for(const h of this.getAllIds())this.isIdRenderable(h,n)&&A.push(this.getTileById(h));return n?A.sort(((h,y)=>{const b=h.tileID,M=y.tileID,I=new d.P(b.canonical.x,b.canonical.y)._rotate(-t),D=new d.P(M.canonical.x,M.canonical.y)._rotate(-t);return b.overscaledZ-M.overscaledZ||D.y-I.y||D.x-I.x})).map((h=>h.tileID.key)):A.map((h=>h.tileID)).sort(d.aw).map((h=>h.key))}}class br extends d.E{constructor(t,n,A){super(),this.id=t,this.dispatcher=A,this.on("data",(h=>this._dataHandler(h))),this.on("dataloading",(()=>{this._sourceErrored=!1})),this.on("error",(()=>{this._sourceErrored=this._source.loaded()})),this._source=((h,y,b,M)=>{const I=new(te(y.type))(h,y,b,M);if(I.id!==h)throw new Error(`Expected Source id to be ${h} instead of ${I.id}`);return I})(t,n,A,this),this._inViewTiles=new pr,this._outOfViewCache=new d.ax(0,(h=>this._unloadTile(h))),this._timers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._rasterFadeDuration=0,this._maxFadingAncestorLevels=5,this._state=new Ke,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&&this._source.onAdd&&this._source.onAdd(t)}onRemove(t){for(const n of this._inViewTiles.getAllTiles())n.unloadVectorData();this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(t),this._inViewTiles=new pr}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;if(!(this.used===void 0&&this.usedForTerrain===void 0||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(const t of this._inViewTiles.getAllTiles())if(t.state!=="loaded"&&t.state!=="errored")return!1;return!0}getSource(){return this._source}getState(){return this._state}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}_loadTile(t,n,A){return d._(this,void 0,void 0,(function*(){try{yield this._source.loadTile(t),this._tileLoaded(t,n,A)}catch(h){t.state="errored",h.status!==404?this._source.fire(new d.k(h,{tile:t})):this.update(this.transform,this.terrain)}}))}_unloadTile(t){this._source.unloadTile&&this._source.unloadTile(t)}_abortTile(t){this._source.abortTile&&this._source.abortTile(t),this._source.fire(new d.l("dataabort",{tile:t,coord:t.tileID,dataType:"source"}))}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._inViewTiles,this.map?this.map.painter:null);for(const n of this._inViewTiles.getAllTiles())n.upload(t),n.prepare(this.map.style.imageManager)}getIds(){return this._inViewTiles.getAllIds(!0)}getRenderableIds(t){var n;return this._inViewTiles.getRenderableIds((n=this.transform)===null||n===void 0?void 0:n.bearingInRadians,t)}hasRenderableParent(t){const n=t.overscaledZ-1;if(n>=this._source.minzoom){const A=this.getLoadedTile(t.scaledTo(n));if(A)return this._inViewTiles.isIdRenderable(A.tileID.key)}return!1}reload(t,n=void 0){if(this._paused)this._shouldReloadOnResume=!0;else{this._outOfViewCache.reset();for(const A of this._inViewTiles.getAllIds()){const h=this._inViewTiles.getTileById(A);n&&!this._source.shouldReloadTile(h,n)||(t?this._reloadTile(A,"expired"):h.state!=="errored"&&this._reloadTile(A,"reloading"))}}}_reloadTile(t,n){return d._(this,void 0,void 0,(function*(){const A=this._inViewTiles.getTileById(t);A&&(A.state!=="loading"&&(A.state=n),yield this._loadTile(A,t,n))}))}_tileLoaded(t,n,A){t.timeAdded=Ar(),t.selfFading&&(t.fadeEndTime=t.timeAdded+this._rasterFadeDuration),A==="expired"&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(n,t),this.getSource().type==="raster-dem"&&t.dem&&(function(h,y){var b,M;const I=y.getRenderableIds();for(const D of I){if(!h.neighboringTiles||!h.neighboringTiles[D])continue;const B=y.getTileById(D);h.neighboringTiles[D].backfilled||Ut(h,B),!((M=(b=B.neighboringTiles)===null||b===void 0?void 0:b[h.tileID.key])===null||M===void 0)&&M.backfilled||Ut(B,h)}})(t,this._inViewTiles),this._state.initializeTileState(t,this.map?this.map.painter:null),t.aborted||this._source.fire(new d.l("data",{dataType:"source",tile:t,coord:t.tileID}))}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._inViewTiles.getTileById(t)}_retainLoadedChildren(t,n){const A=this._getLoadedDescendents(n),h=new Set;for(const y of n){const b=A[y.key];if(!(b!=null&&b.length)){h.add(y);continue}const M=y.overscaledZ+br.maxOverzooming,I=b.filter((V=>V.tileID.overscaledZ<=M));if(!I.length){h.add(y);continue}const D=Math.min(...I.map((V=>V.tileID.overscaledZ))),B=I.filter((V=>V.tileID.overscaledZ===D)).map((V=>V.tileID));for(const V of B)t[V.key]=V;this._areDescendentsComplete(B,D,y.overscaledZ)||h.add(y)}return h}_getLoadedDescendents(t){var n;const A={};for(const h of this._inViewTiles.getAllTiles().filter((y=>y.hasData())))for(const y of t)h.tileID.isChildOf(y)&&(A[n=y.key]||(A[n]=[])).push(h);return A}_areDescendentsComplete(t,n,A){return t.length===1&&t[0].isOverscaled()?t[0].overscaledZ===n:Math.pow(4,n-A)===t.length}getLoadedTile(t){return this._inViewTiles.getLoadedTile(t)}updateCacheSize(t){const n=Math.ceil(t.width/this._source.tileSize)+1,A=Math.ceil(t.height/this._source.tileSize)+1,h=Math.floor(n*A*(this._maxTileCacheZoomLevels===null?d.c.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),y=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,h):h;this._outOfViewCache.setMaxSize(y)}handleWrapJump(t){const n=Math.round((t-(this._prevLng===void 0?t:this._prevLng))/360);this._prevLng=t,n&&(this._inViewTiles.handleWrapJump(n),this._resetTileReloadTimers())}update(t,n){if(!this._sourceLoaded||this._paused)return;let A;this.transform=t,this.terrain=n,this.updateCacheSize(t),this.handleWrapJump(this.transform.center.lng),this.used||this.usedForTerrain?this._source.tileID?A=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((I=>new d.a2(I.canonical.z,I.wrap,I.canonical.z,I.canonical.x,I.canonical.y))):(A=Mr(t,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.type==="vector"&&this.map._zoomLevelsToOverscale!==void 0?t.maxZoom-this.map._zoomLevelsToOverscale:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:n,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(A=A.filter((I=>this._source.hasTile(I))))):A=[],this.usedForTerrain&&(A=this._addTerrainIdealTiles(A));const h=A.length===0&&!this._updated&&this._didEmitContent;this._updated=!0,h&&this.fire(new d.l("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const y=Pr(t,this._source),b=this._updateRetainedTiles(A,y),M=Xe(this._source.type);M&&this._rasterFadeDuration>0&&!n&&(function(I,D,B,V,O,U,X){const ie=Ar(),se=d.av(D);for(const ne of D){const ce=I.getTileById(ne.key);ce.fadingDirection!==je.Departing&&ce.fadeOpacity!==0||ce.resetFadeLogic(),vt(I,ce,B,ie,V,O,X)||ot(I,ce,B,ie,U,X)||Z(ce,se,ie,X)||ce.resetFadeLogic()}})(this._inViewTiles,A,b,this._maxFadingAncestorLevels,this._source.minzoom,this._source.maxzoom,this._rasterFadeDuration),M?this._cleanUpRasterTiles(b):this._cleanUpVectorTiles(b)}_cleanUpRasterTiles(t){for(const n of this._inViewTiles.getAllIds())t[n]||this._removeTile(n)}_cleanUpVectorTiles(t){for(const n of this._inViewTiles.getAllIds()){const A=this._inViewTiles.getTileById(n);t[n]?A.clearSymbolFadeHold():A.hasSymbolBuckets?A.holdingForSymbolFade()?A.symbolFadeFinished()&&this._removeTile(n):A.setSymbolHoldDuration(this.map._fadeDuration):this._removeTile(n)}}_addTerrainIdealTiles(t){const n=[];for(const A of t)if(A.canonical.z>this._source.minzoom){const h=A.scaledTo(A.canonical.z-1);n.push(h);const y=A.scaledTo(Math.max(this._source.minzoom,Math.min(A.canonical.z,5)));n.push(y)}return t.concat(n)}releaseSymbolFadeTiles(){for(const t of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(t).holdingForSymbolFade()&&this._removeTile(t)}_updateRetainedTiles(t,n){var A;const h=new Set;for(const D of t)this._addTile(D).hasData()||h.add(D);const y=t.reduce(((D,B)=>(D[B.key]=B,D)),{}),b=this._retainLoadedChildren(y,h),M={},I=Math.max(n-br.maxUnderzooming,this._source.minzoom);for(const D of b){let B=this._inViewTiles.getTileById(D.key),V=B==null?void 0:B.wasRequested();for(let O=D.overscaledZ-1;O>=I;--O){const U=D.scaledTo(O);if(M[U.key])break;if(M[U.key]=!0,B=this.getTile(U),!B&&V&&(B=this._addTile(U)),B){const X=B.hasData();if((X||!(!((A=this.map)===null||A===void 0)&&A.cancelPendingTileRequestsWhileZooming)||V)&&(y[U.key]=U),V=B.wasRequested(),X)break}}}return y}_addTile(t){let n=this._inViewTiles.getTileById(t.key);if(n)return n;n=this._outOfViewCache.getAndRemove(t),n&&(n.resetFadeLogic(),this._setTileReloadTimer(t.key,n),n.tileID=t,this._state.initializeTileState(n,this.map?this.map.painter:null));const A=n;return n||(n=new tt(t,this._source.tileSize*t.overscaleFactor()),this._loadTile(n,t.key,n.state)),n.uses++,this._inViewTiles.setTile(t.key,n),A||this._source.fire(new d.l("dataloading",{tile:n,coord:n.tileID,dataType:"source"})),n}_setTileReloadTimer(t,n){this._clearTileReloadTimer(t);const A=n.getExpiryTimeout();A&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),A))}_clearTileReloadTimer(t){const n=this._timers[t];n&&(clearTimeout(n),delete this._timers[t])}_resetTileReloadTimers(){for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t of this._inViewTiles.getAllIds()){const n=this._inViewTiles.getTileById(t);this._setTileReloadTimer(t,n)}}refreshTiles(t){for(const n of this._inViewTiles.getAllIds()){const A=this._inViewTiles.getTileById(n);(this._inViewTiles.isIdRenderable(n)||A.state=="errored")&&t.some((h=>h.equals(A.tileID.canonical)))&&this._reloadTile(n,"expired")}}_removeTile(t){const n=this._inViewTiles.getTileById(t);n&&(n.uses--,this._inViewTiles.deleteTileById(t),this._clearTileReloadTimer(t),n.uses>0||(n.hasData()&&n.state!=="reloading"?this._outOfViewCache.add(n.tileID,n,n.getExpiryTimeout()):(n.aborted=!0,this._abortTile(n),this._unloadTile(n))))}_dataHandler(t){t.dataType==="source"&&(t.sourceDataType!=="metadata"?t.sourceDataType==="content"&&this._sourceLoaded&&!this._paused&&(this.reload(t.sourceDataChanged,t.shouldReloadTileOptions),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0):this._sourceLoaded=!0)}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t of this._inViewTiles.getAllIds())this._removeTile(t);this._outOfViewCache.reset()}tilesIn(t,n,A){const h=[],y=this.transform;if(!y)return h;const b=y.getCoveringTilesDetailsProvider().allowWorldCopies(),M=A?y.getCameraQueryGeometry(t):t,I=U=>y.screenPointToMercatorCoordinate(U,this.terrain),D=this.transformBbox(t,I,!b),B=this.transformBbox(M,I,!b),V=this.getIds(),O=d.aa.fromPoints(B);for(let U=0;U<V.length;U++){const X=this._inViewTiles.getTileById(V[U]);if(X.holdingForSymbolFade())continue;const ie=b?[X.tileID]:[X.tileID.unwrapTo(-1),X.tileID.unwrapTo(0)],se=Math.pow(2,y.zoom-X.tileID.overscaledZ),ne=n*X.queryPadding*d.a5/X.tileSize/se;for(const ce of ie){const ge=O.map((Ae=>ce.getTilePoint(new d.a9(Ae.x,Ae.y))));if(ge.expandBy(ne),ge.intersects(ke)){const Ae=D.map((ye=>ce.getTilePoint(ye))),de=B.map((ye=>ce.getTilePoint(ye)));h.push({tile:X,tileID:b?ce:ce.unwrapTo(0),queryGeometry:Ae,cameraQueryGeometry:de,scale:se})}}}return h}transformBbox(t,n,A){let h=t.map(n);if(A){const y=d.aa.fromPoints(t);y.shrinkBy(.001*Math.min(y.width(),y.height()));const b=y.map(n);d.aa.fromPoints(h).covers(b)||(h=h.map((M=>M.x>.5?new d.a9(M.x-1,M.y,M.z):M)))}return h}getVisibleCoordinates(t){const n=this.getRenderableIds(t).map((A=>this._inViewTiles.getTileById(A).tileID));return this.transform&&this.transform.populateCache(n),n}hasTransition(){return!!this._source.hasTransition()||!(!Xe(this._source.type)||!(function(t,n){if(n<=0)return!1;const A=Ar();for(const h of t.getAllTiles())if(h.fadeEndTime>=A)return!0;return!1})(this._inViewTiles,this._rasterFadeDuration))}setRasterFadeDuration(t){this._rasterFadeDuration=t}setFeatureState(t,n,A){this._state.updateState(t=t||d.ai,n,A)}removeFeatureState(t,n,A){this._state.removeFeatureState(t=t||d.ai,n,A)}getFeatureState(t,n){return this._state.getState(t=t||d.ai,n)}setDependencies(t,n,A){const h=this._inViewTiles.getTileById(t);h&&h.setDependencies(n,A)}reloadTilesForDependencies(t,n){for(const A of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(A).hasDependency(t,n)&&this._reloadTile(A,"reloading");this._outOfViewCache.filter((A=>!A.hasDependency(t,n)))}areTilesLoaded(){for(const t of this._inViewTiles.getAllTiles())if(t.state!=="loaded"&&t.state!=="errored")return!1;return!0}}br.maxUnderzooming=10,br.maxOverzooming=3;class Je{constructor(t,n){this.reset(t,n)}reset(t,n){this.points=t||[],this._distances=[0];for(let A=1;A<this.points.length;A++)this._distances[A]=this._distances[A-1]+this.points[A].dist(this.points[A-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(n||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(t){if(this.points.length===1)return this.points[0];t=d.an(t,0,1);let n=1,A=this._distances[n];const h=t*this.paddedLength+this.padding;for(;A<h&&n<this._distances.length;)A=this._distances[++n];const y=n-1,b=this._distances[y],M=A-b,I=M>0?(h-b)/M:0;return this.points[y].mult(1-I).add(this.points[n].mult(I))}}function wt(_,t){let n=!0;return _==="always"||_!=="never"&&t!=="never"||(n=!1),n}class Ft{constructor(t,n,A){const h=this.boxCells=[],y=this.circleCells=[];this.xCellCount=Math.ceil(t/A),this.yCellCount=Math.ceil(n/A);for(let b=0;b<this.xCellCount*this.yCellCount;b++)h.push([]),y.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=t,this.height=n,this.xScale=this.xCellCount/t,this.yScale=this.yCellCount/n,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(t,n,A,h,y){this._forEachCell(n,A,h,y,this._insertBoxCell,this.boxUid++),this.boxKeys.push(t),this.bboxes.push(n),this.bboxes.push(A),this.bboxes.push(h),this.bboxes.push(y)}insertCircle(t,n,A,h){this._forEachCell(n-h,A-h,n+h,A+h,this._insertCircleCell,this.circleUid++),this.circleKeys.push(t),this.circles.push(n),this.circles.push(A),this.circles.push(h)}_insertBoxCell(t,n,A,h,y,b){this.boxCells[y].push(b)}_insertCircleCell(t,n,A,h,y,b){this.circleCells[y].push(b)}_query(t,n,A,h,y,b,M){if(A<0||t>this.width||h<0||n>this.height)return[];const I=[];if(t<=0&&n<=0&&this.width<=A&&this.height<=h){if(y)return[{key:null,x1:t,y1:n,x2:A,y2:h}];for(let D=0;D<this.boxKeys.length;D++)I.push({key:this.boxKeys[D],x1:this.bboxes[4*D],y1:this.bboxes[4*D+1],x2:this.bboxes[4*D+2],y2:this.bboxes[4*D+3]});for(let D=0;D<this.circleKeys.length;D++){const B=this.circles[3*D],V=this.circles[3*D+1],O=this.circles[3*D+2];I.push({key:this.circleKeys[D],x1:B-O,y1:V-O,x2:B+O,y2:V+O})}}else this._forEachCell(t,n,A,h,this._queryCell,I,{hitTest:y,overlapMode:b,seenUids:{box:{},circle:{}}},M);return I}query(t,n,A,h){return this._query(t,n,A,h,!1,null)}hitTest(t,n,A,h,y,b){return this._query(t,n,A,h,!0,y,b).length>0}hitTestCircle(t,n,A,h,y){const b=t-A,M=t+A,I=n-A,D=n+A;if(M<0||b>this.width||D<0||I>this.height)return!1;const B=[];return this._forEachCell(b,I,M,D,this._queryCellCircle,B,{hitTest:!0,overlapMode:h,circle:{x:t,y:n,radius:A},seenUids:{box:{},circle:{}}},y),B.length>0}_queryCell(t,n,A,h,y,b,M,I){const{seenUids:D,hitTest:B,overlapMode:V}=M,O=this.boxCells[y];if(O!==null){const X=this.bboxes;for(const ie of O)if(!D.box[ie]){D.box[ie]=!0;const se=4*ie,ne=this.boxKeys[ie];if(t<=X[se+2]&&n<=X[se+3]&&A>=X[se+0]&&h>=X[se+1]&&(!I||I(ne))&&(!B||!wt(V,ne.overlapMode))&&(b.push({key:ne,x1:X[se],y1:X[se+1],x2:X[se+2],y2:X[se+3]}),B))return!0}}const U=this.circleCells[y];if(U!==null){const X=this.circles;for(const ie of U)if(!D.circle[ie]){D.circle[ie]=!0;const se=3*ie,ne=this.circleKeys[ie];if(this._circleAndRectCollide(X[se],X[se+1],X[se+2],t,n,A,h)&&(!I||I(ne))&&(!B||!wt(V,ne.overlapMode))){const ce=X[se],ge=X[se+1],Ae=X[se+2];if(b.push({key:ne,x1:ce-Ae,y1:ge-Ae,x2:ce+Ae,y2:ge+Ae}),B)return!0}}}return!1}_queryCellCircle(t,n,A,h,y,b,M,I){const{circle:D,seenUids:B,overlapMode:V}=M,O=this.boxCells[y];if(O!==null){const X=this.bboxes;for(const ie of O)if(!B.box[ie]){B.box[ie]=!0;const se=4*ie,ne=this.boxKeys[ie];if(this._circleAndRectCollide(D.x,D.y,D.radius,X[se+0],X[se+1],X[se+2],X[se+3])&&(!I||I(ne))&&!wt(V,ne.overlapMode))return b.push(!0),!0}}const U=this.circleCells[y];if(U!==null){const X=this.circles;for(const ie of U)if(!B.circle[ie]){B.circle[ie]=!0;const se=3*ie,ne=this.circleKeys[ie];if(this._circlesCollide(X[se],X[se+1],X[se+2],D.x,D.y,D.radius)&&(!I||I(ne))&&!wt(V,ne.overlapMode))return b.push(!0),!0}}}_forEachCell(t,n,A,h,y,b,M,I){const D=this._convertToXCellCoord(t),B=this._convertToYCellCoord(n),V=this._convertToXCellCoord(A),O=this._convertToYCellCoord(h);for(let U=D;U<=V;U++)for(let X=B;X<=O;X++)if(y.call(this,t,n,A,h,this.xCellCount*X+U,b,M,I))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,n,A,h,y,b){const M=h-t,I=y-n,D=A+b;return D*D>M*M+I*I}_circleAndRectCollide(t,n,A,h,y,b,M){const I=(b-h)/2,D=Math.abs(t-(h+I));if(D>I+A)return!1;const B=(M-y)/2,V=Math.abs(n-(y+B));if(V>B+A)return!1;if(D<=I||V<=B)return!0;const O=D-I,U=V-B;return O*O+U*U<=A*A}}function Jt(_,t,n){const A=d.N();if(!_){const{vecSouth:V,vecEast:O}=ai(t),U=Vr();U[0]=O[0],U[1]=O[1],U[2]=V[0],U[3]=V[1],h=U,(B=(b=(y=U)[0])*(D=y[3])-(I=y[2])*(M=y[1]))&&(h[0]=D*(B=1/B),h[1]=-M*B,h[2]=-I*B,h[3]=b*B),A[0]=U[0],A[1]=U[1],A[4]=U[2],A[5]=U[3]}var h,y,b,M,I,D,B;return d.Q(A,A,[1/n,1/n,1]),A}function Yt(_,t,n,A){if(_){const h=d.N();if(!t){const{vecSouth:y,vecEast:b}=ai(n);h[0]=b[0],h[1]=b[1],h[4]=y[0],h[5]=y[1]}return d.Q(h,h,[A,A,1]),h}return n.pixelsToClipSpaceMatrix}function ai(_){const t=Math.cos(_.rollInRadians),n=Math.sin(_.rollInRadians),A=Math.cos(_.pitchInRadians),h=Math.cos(_.bearingInRadians),y=Math.sin(_.bearingInRadians),b=d.aC();b[0]=-h*A*n-y*t,b[1]=-y*A*n+h*t;const M=d.aD(b);M<1e-9?d.aE(b):d.aF(b,b,1/M);const I=d.aC();I[0]=h*A*t-y*n,I[1]=y*A*t+h*n;const D=d.aD(I);return D<1e-9?d.aE(I):d.aF(I,I,1/D),{vecEast:I,vecSouth:b}}function qt(_,t,n,A){let h;A?(h=[_,t,A(_,t),1],d.aH(h,h,n)):(h=[_,t,0,1],H(h,h,n));const y=h[3];return{point:new d.P(h[0]/y,h[1]/y),signedDistanceFromCamera:y,isOccluded:!1}}function oa(_,t){return .5+_/t*.5}function Xs(_,t){return _.x>=-t[0]&&_.x<=t[0]&&_.y>=-t[1]&&_.y<=t[1]}function Zi(_,t,n,A,h,y,b,M,I,D,B,V,O){const U=n?_.textSizeData:_.iconSizeData,X=d.ay(U,t.transform.zoom),ie=[256/t.width*2+1,256/t.height*2+1],se=n?_.text.dynamicLayoutVertexArray:_.icon.dynamicLayoutVertexArray;se.clear();const ne=_.lineVertexArray,ce=n?_.text.placedSymbolArray:_.icon.placedSymbolArray,ge=t.transform.width/t.transform.height;let Ae=!1;for(let de=0;de<ce.length;de++){const ye=ce.get(de);if(ye.hidden||ye.writingMode===d.az.vertical&&!Ae){Ks(ye.numGlyphs,se);continue}Ae=!1;const fe=new d.P(ye.anchorX,ye.anchorY),Me={getElevation:O,pitchedLabelPlaneMatrix:A,lineVertexArray:ne,pitchWithMap:y,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:t.transform,tileAnchorPoint:fe,unwrappedTileID:I,width:D,height:B,translation:V},Ge=zt(ye.anchorX,ye.anchorY,Me);if(!Xs(Ge.point,ie)){Ks(ye.numGlyphs,se);continue}const Fe=oa(t.transform.cameraToCenterDistance,Ge.signedDistanceFromCamera),Oe=d.aA(U,X,ye),Ve=y?Oe*t.transform.getPitchedTextCorrection(ye.anchorX,ye.anchorY,I)/Fe:Oe*Fe,ut=Ms({projectionContext:Me,pitchedLabelPlaneMatrixInverse:h,symbol:ye,fontSize:Ve,flip:!1,keepUpright:b,glyphOffsetArray:_.glyphOffsetArray,dynamicLayoutVertexArray:se,aspectRatio:ge,rotateToLine:M});Ae=ut.useVertical,(ut.notEnoughRoom||Ae||ut.needsFlipping&&Ms({projectionContext:Me,pitchedLabelPlaneMatrixInverse:h,symbol:ye,fontSize:Ve,flip:!0,keepUpright:b,glyphOffsetArray:_.glyphOffsetArray,dynamicLayoutVertexArray:se,aspectRatio:ge,rotateToLine:M}).notEnoughRoom)&&Ks(ye.numGlyphs,se)}n?_.text.dynamicLayoutVertexBuffer.updateData(se):_.icon.dynamicLayoutVertexBuffer.updateData(se)}function Ln(_,t,n,A,h,y,b,M){const I=y.glyphStartIndex+y.numGlyphs,D=y.lineStartIndex,B=y.lineStartIndex+y.lineLength,V=t.getoffsetX(y.glyphStartIndex),O=t.getoffsetX(I-1),U=Fn(_*V,n,A,h,y.segment,D,B,M,b);if(!U)return null;const X=Fn(_*O,n,A,h,y.segment,D,B,M,b);return X?M.projectionCache.anyProjectionOccluded?null:{first:U,last:X}:null}function Ji(_,t,n,A){return _===d.az.horizontal&&Math.abs(n.y-t.y)>Math.abs(n.x-t.x)*A?{useVertical:!0}:(_===d.az.vertical?t.y<n.y:t.x>n.x)?{needsFlipping:!0}:null}function Ms(_){const{projectionContext:t,pitchedLabelPlaneMatrixInverse:n,symbol:A,fontSize:h,flip:y,keepUpright:b,glyphOffsetArray:M,dynamicLayoutVertexArray:I,aspectRatio:D,rotateToLine:B}=_,V=h/24,O=A.lineOffsetX*V,U=A.lineOffsetY*V;let X;if(A.numGlyphs>1){const ie=A.glyphStartIndex+A.numGlyphs,se=A.lineStartIndex,ne=A.lineStartIndex+A.lineLength,ce=Ln(V,M,O,U,y,A,B,t);if(!ce)return{notEnoughRoom:!0};const ge=ee(ce.first.point.x,ce.first.point.y,t,n),Ae=ee(ce.last.point.x,ce.last.point.y,t,n);if(b&&!y){const de=Ji(A.writingMode,ge,Ae,D);if(de)return de}X=[ce.first];for(let de=A.glyphStartIndex+1;de<ie-1;de++){const ye=Fn(V*M.getoffsetX(de),O,U,y,A.segment,se,ne,t,B);if(!ye)return{notEnoughRoom:!0};X.push(ye)}X.push(ce.last)}else{if(b&&!y){const se=Pt(t.tileAnchorPoint.x,t.tileAnchorPoint.y,t).point,ne=A.lineStartIndex+A.segment+1,ce=new d.P(t.lineVertexArray.getx(ne),t.lineVertexArray.gety(ne)),ge=Pt(ce.x,ce.y,t),Ae=ge.signedDistanceFromCamera>0?ge.point:aa(t.tileAnchorPoint,ce,se,1,t),de=ee(se.x,se.y,t,n),ye=ee(Ae.x,Ae.y,t,n),fe=Ji(A.writingMode,de,ye,D);if(fe)return fe}const ie=Fn(V*M.getoffsetX(A.glyphStartIndex),O,U,y,A.segment,A.lineStartIndex,A.lineStartIndex+A.lineLength,t,B);if(!ie||t.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};X=[ie]}for(const ie of X)d.aG(I,ie.point,ie.angle);return{}}function aa(_,t,n,A,h){const y=_.add(_.sub(t)._unit()),b=Pt(y.x,y.y,h).point,M=n.sub(b);return n.add(M._mult(A/M.mag()))}function Zr(_,t,n){const A=t.projectionCache;if(A.projections[_])return A.projections[_];const h=new d.P(t.lineVertexArray.getx(_),t.lineVertexArray.gety(_)),y=Pt(h.x,h.y,t);if(y.signedDistanceFromCamera>0)return A.projections[_]=y.point,A.anyProjectionOccluded=A.anyProjectionOccluded||y.isOccluded,y.point;const b=_-n.direction;return aa(n.distanceFromAnchor===0?t.tileAnchorPoint:new d.P(t.lineVertexArray.getx(b),t.lineVertexArray.gety(b)),h,n.previousVertex,n.absOffsetX-n.distanceFromAnchor+1,t)}function Pt(_,t,n){const A=_+n.translation[0],h=t+n.translation[1];let y;return n.pitchWithMap?(y=qt(A,h,n.pitchedLabelPlaneMatrix,n.getElevation),y.isOccluded=!1):(y=n.transform.projectTileCoordinates(A,h,n.unwrappedTileID,n.getElevation),y.point.x=(.5*y.point.x+.5)*n.width,y.point.y=(.5*-y.point.y+.5)*n.height),y}function ee(_,t,n,A){if(n.pitchWithMap){const h=[_,t,0,1];return d.aH(h,h,A),n.transform.projectTileCoordinates(h[0]/h[3],h[1]/h[3],n.unwrappedTileID,n.getElevation).point}return{x:_/n.width*2-1,y:1-t/n.height*2}}function zt(_,t,n){return n.transform.projectTileCoordinates(_,t,n.unwrappedTileID,n.getElevation)}function To(_,t,n){return _._unit()._perp()._mult(t*n)}function Ys(_,t,n,A,h,y,b,M,I){if(M.projectionCache.offsets[_])return M.projectionCache.offsets[_];const D=n.add(t);if(_+I.direction<A||_+I.direction>=h)return M.projectionCache.offsets[_]=D,D;const B=Zr(_+I.direction,M,I),V=To(B.sub(n),b,I.direction),O=n.add(V),U=B.add(V);return M.projectionCache.offsets[_]=d.aI(y,D,O,U)||D,M.projectionCache.offsets[_]}function Fn(_,t,n,A,h,y,b,M,I){const D=A?_-t:_+t;let B=D>0?1:-1,V=0;A&&(B*=-1,V=Math.PI),B<0&&(V+=Math.PI);let O,U=B>0?y+h:y+h+1;M.projectionCache.cachedAnchorPoint?O=M.projectionCache.cachedAnchorPoint:(O=Pt(M.tileAnchorPoint.x,M.tileAnchorPoint.y,M).point,M.projectionCache.cachedAnchorPoint=O);let X,ie,se=O,ne=O,ce=0,ge=0;const Ae=Math.abs(D),de=[];let ye;for(;ce+ge<=Ae;){if(U+=B,U<y||U>=b)return null;ce+=ge,ne=se,ie=X;const Ge={absOffsetX:Ae,direction:B,distanceFromAnchor:ce,previousVertex:ne};if(se=Zr(U,M,Ge),n===0)de.push(ne),ye=se.sub(ne);else{let Fe;const Oe=se.sub(ne);Fe=Oe.mag()===0?To(Zr(U+B,M,Ge).sub(se),n,B):To(Oe,n,B),ie||(ie=ne.add(Fe)),X=Ys(U,Fe,se,y,b,ie,n,M,Ge),de.push(ie),ye=X.sub(ie)}ge=ye.mag()}const fe=ye._mult((Ae-ce)/ge)._add(ie||ne),Me=V+Math.atan2(se.y-ne.y,se.x-ne.x);return de.push(fe),{point:fe,angle:I?Me:0,path:de}}const Kl=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function Ks(_,t){for(let n=0;n<_;n++){const A=t.length;t.resize(A+4),t.float32.set(Kl,3*A)}}function H(_,t,n){const A=t[0],h=t[1];return _[0]=n[0]*A+n[4]*h+n[12],_[1]=n[1]*A+n[5]*h+n[13],_[3]=n[3]*A+n[7]*h+n[15],_}const Qr=100;class Jl{constructor(t,n=new Ft(t.width+200,t.height+200,25),A=new Ft(t.width+200,t.height+200,25)){this.transform=t,this.grid=n,this.ignoredGrid=A,this.pitchFactor=Math.cos(t.pitch*Math.PI/180)*t.cameraToCenterDistance,this.screenRightBoundary=t.width+Qr,this.screenBottomBoundary=t.height+Qr,this.gridRightBoundary=t.width+200,this.gridBottomBoundary=t.height+200,this.perspectiveRatioCutoff=.6}placeCollisionBox(t,n,A,h,y,b,M,I,D,B,V,O){const U=this.projectAndGetPerspectiveRatio(t.anchorPointX+I[0],t.anchorPointY+I[1],y,B,O),X=A*U.perspectiveRatio;let ie;if(b||M)ie=this._projectCollisionBox(t,X,h,y,b,M,I,U,B,V,O);else{const ye=U.x+(V?V.x*X:0),fe=U.y+(V?V.y*X:0);ie={allPointsOccluded:!1,box:[ye+t.x1*X,fe+t.y1*X,ye+t.x2*X,fe+t.y2*X]}}const[se,ne,ce,ge]=ie.box,Ae=b?ie.allPointsOccluded:U.isOccluded;let de=Ae;return de||(de=U.perspectiveRatio<this.perspectiveRatioCutoff),de||(de=!this.isInsideGrid(se,ne,ce,ge)),de||n!=="always"&&this.grid.hitTest(se,ne,ce,ge,n,D)?{box:[se,ne,ce,ge],placeable:!1,offscreen:!1,occluded:Ae}:{box:[se,ne,ce,ge],placeable:!0,offscreen:this.isOffscreen(se,ne,ce,ge),occluded:Ae}}placeCollisionCircles(t,n,A,h,y,b,M,I,D,B,V,O,U,X){const ie=[],se=new d.P(n.anchorX,n.anchorY),ne=this.getPerspectiveRatio(se.x,se.y,b,X),ce=(D?y*this.transform.getPitchedTextCorrection(n.anchorX,n.anchorY,b)/ne:y*ne)/d.aM,ge={getElevation:X,pitchedLabelPlaneMatrix:M,lineVertexArray:A,pitchWithMap:D,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:this.transform,tileAnchorPoint:se,unwrappedTileID:b,width:this.transform.width,height:this.transform.height,translation:U},Ae=Ln(ce,h,n.lineOffsetX*ce,n.lineOffsetY*ce,!1,n,!1,ge);let de=!1,ye=!1,fe=!0;if(Ae){const Me=.5*V*ne+O,Ge=new d.P(-100,-100),Fe=new d.P(this.screenRightBoundary,this.screenBottomBoundary),Oe=new Je,Ve=Ae.first,ut=Ae.last;let ht=[];for(let Wt=Ve.path.length-1;Wt>=1;Wt--)ht.push(Ve.path[Wt]);for(let Wt=1;Wt<ut.path.length;Wt++)ht.push(ut.path[Wt]);const rt=2.5*Me;if(D){const Wt=this.projectPathToScreenSpace(ht,ge);ht=Wt.some((Tr=>Tr.signedDistanceFromCamera<=0))?[]:Wt.map((Tr=>Tr.point))}let ft=[];if(ht.length>0){const Wt=ht[0].clone(),Tr=ht[0].clone();for(let Ur=1;Ur<ht.length;Ur++)Wt.x=Math.min(Wt.x,ht[Ur].x),Wt.y=Math.min(Wt.y,ht[Ur].y),Tr.x=Math.max(Tr.x,ht[Ur].x),Tr.y=Math.max(Tr.y,ht[Ur].y);ft=Wt.x>=Ge.x&&Tr.x<=Fe.x&&Wt.y>=Ge.y&&Tr.y<=Fe.y?[ht]:Tr.x<Ge.x||Wt.x>Fe.x||Tr.y<Ge.y||Wt.y>Fe.y?[]:d.aJ([ht],Ge.x,Ge.y,Fe.x,Fe.y)}for(const Wt of ft){Oe.reset(Wt,.25*Me);let Tr=0;Tr=Oe.length<=.5*Me?1:Math.ceil(Oe.paddedLength/rt)+1;for(let Ur=0;Ur<Tr;Ur++){const Dr=Ur/Math.max(Tr-1,1),Wr=Oe.lerp(Dr),kr=Wr.x+Qr,ri=Wr.y+Qr;ie.push(kr,ri,Me,0);const Hr=kr-Me,Li=ri-Me,pi=kr+Me,ui=ri+Me;if(fe=fe&&this.isOffscreen(Hr,Li,pi,ui),ye=ye||this.isInsideGrid(Hr,Li,pi,ui),t!=="always"&&this.grid.hitTestCircle(kr,ri,Me,t,B)&&(de=!0,!I))return{circles:[],offscreen:!1,collisionDetected:de}}}}return{circles:!I&&de||!ye||ne<this.perspectiveRatioCutoff?[]:ie,offscreen:fe,collisionDetected:de}}projectPathToScreenSpace(t,n){const A=(function(h,y){const b=d.N();return d.aB(b,y.pitchedLabelPlaneMatrix),h.map((M=>{const I=qt(M.x,M.y,b,y.getElevation),D=y.transform.projectTileCoordinates(I.point.x,I.point.y,y.unwrappedTileID,y.getElevation);return D.point.x=(.5*D.point.x+.5)*y.width,D.point.y=(.5*-D.point.y+.5)*y.height,D}))})(t,n);return(function(h){let y=0,b=0,M=0,I=0;for(let D=0;D<h.length;D++)h[D].isOccluded?(M=D+1,I=0):(I++,I>b&&(b=I,y=M));return h.slice(y,y+b)})(A)}queryRenderedSymbols(t){if(t.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};const n=[],A=new d.aa;for(const V of t){const O=new d.P(V.x+Qr,V.y+Qr);A.extend(O),n.push(O)}const{minX:h,minY:y,maxX:b,maxY:M}=A,I=this.grid.query(h,y,b,M).concat(this.ignoredGrid.query(h,y,b,M)),D={},B={};for(const V of I){const O=V.key;if(D[O.bucketInstanceId]===void 0&&(D[O.bucketInstanceId]={}),D[O.bucketInstanceId][O.featureIndex])continue;const U=[new d.P(V.x1,V.y1),new d.P(V.x2,V.y1),new d.P(V.x2,V.y2),new d.P(V.x1,V.y2)];d.aK(n,U)&&(D[O.bucketInstanceId][O.featureIndex]=!0,B[O.bucketInstanceId]===void 0&&(B[O.bucketInstanceId]=[]),B[O.bucketInstanceId].push(O.featureIndex))}return B}insertCollisionBox(t,n,A,h,y,b){(A?this.ignoredGrid:this.grid).insert({bucketInstanceId:h,featureIndex:y,collisionGroupID:b,overlapMode:n},t[0],t[1],t[2],t[3])}insertCollisionCircles(t,n,A,h,y,b){const M=A?this.ignoredGrid:this.grid,I={bucketInstanceId:h,featureIndex:y,collisionGroupID:b,overlapMode:n};for(let D=0;D<t.length;D+=4)M.insertCircle(I,t[D],t[D+1],t[D+2])}projectAndGetPerspectiveRatio(t,n,A,h,y){if(y){let b;h?(b=[t,n,h(t,n),1],d.aH(b,b,y)):(b=[t,n,0,1],H(b,b,y));const M=b[3];return{x:(b[0]/M+1)/2*this.transform.width+Qr,y:(-b[1]/M+1)/2*this.transform.height+Qr,perspectiveRatio:.5+this.transform.cameraToCenterDistance/M*.5,isOccluded:!1,signedDistanceFromCamera:M}}{const b=this.transform.projectTileCoordinates(t,n,A,h);return{x:(b.point.x+1)/2*this.transform.width+Qr,y:(1-b.point.y)/2*this.transform.height+Qr,perspectiveRatio:.5+this.transform.cameraToCenterDistance/b.signedDistanceFromCamera*.5,isOccluded:b.isOccluded,signedDistanceFromCamera:b.signedDistanceFromCamera}}}getPerspectiveRatio(t,n,A,h){const y=this.transform.projectTileCoordinates(t,n,A,h);return .5+this.transform.cameraToCenterDistance/y.signedDistanceFromCamera*.5}isOffscreen(t,n,A,h){return A<Qr||t>=this.screenRightBoundary||h<Qr||n>this.screenBottomBoundary}isInsideGrid(t,n,A,h){return A>=0&&t<this.gridRightBoundary&&h>=0&&n<this.gridBottomBoundary}getViewportMatrix(){const t=d.ar([]);return d.O(t,t,[-100,-100,0]),t}_projectCollisionBox(t,n,A,h,y,b,M,I,D,B,V){let O=1,U=0,X=0,ie=1;const se=t.anchorPointX+M[0],ne=t.anchorPointY+M[1];if(b&&!y){const ht=this.projectAndGetPerspectiveRatio(se+1,ne,h,D,V),rt=ht.x-I.x,ft=Math.atan((ht.y-I.y)/rt)+(rt<0?Math.PI:0),Wt=Math.sin(ft),Tr=Math.cos(ft);O=Tr,U=Wt,X=-Wt,ie=Tr}else if(!b&&y){const ht=ai(this.transform);O=ht.vecEast[0],U=ht.vecEast[1],X=ht.vecSouth[0],ie=ht.vecSouth[1]}let ce=I.x,ge=I.y,Ae=n;y&&(ce=se,ge=ne,Ae=Math.pow(2,-(this.transform.zoom-A.overscaledZ)),Ae*=this.transform.getPitchedTextCorrection(se,ne,h),B||(Ae*=d.an(.5+I.signedDistanceFromCamera/this.transform.cameraToCenterDistance*.5,0,4))),B&&(ce+=O*B.x*Ae+X*B.y*Ae,ge+=U*B.x*Ae+ie*B.y*Ae);const de=t.x1*Ae,ye=t.x2*Ae,fe=(de+ye)/2,Me=t.y1*Ae,Ge=t.y2*Ae,Fe=(Me+Ge)/2,Oe=[{offsetX:de,offsetY:Me},{offsetX:fe,offsetY:Me},{offsetX:ye,offsetY:Me},{offsetX:ye,offsetY:Fe},{offsetX:ye,offsetY:Ge},{offsetX:fe,offsetY:Ge},{offsetX:de,offsetY:Ge},{offsetX:de,offsetY:Fe}];let Ve=[];for(const{offsetX:ht,offsetY:rt}of Oe)Ve.push(new d.P(ce+O*ht+X*rt,ge+U*ht+ie*rt));let ut=!1;if(y){const ht=Ve.map((rt=>this.projectAndGetPerspectiveRatio(rt.x,rt.y,h,D,V)));ut=ht.some((rt=>!rt.isOccluded)),Ve=ht.map((rt=>new d.P(rt.x,rt.y)))}else ut=!0;return{box:d.aL(Ve),allPointsOccluded:!ut}}}class eA{constructor(t,n,A,h){this.opacity=t?Math.max(0,Math.min(1,t.opacity+(t.placed?n:-n))):h&&A?1:0,this.placed=A}isHidden(){return this.opacity===0&&!this.placed}}class la{constructor(t,n,A,h,y){this.text=new eA(t?t.text:null,n,A,y),this.icon=new eA(t?t.icon:null,n,h,y)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class tA{constructor(t,n,A){this.text=t,this.icon=n,this.skipFade=A}}class rA{constructor(t,n,A,h,y){this.bucketInstanceId=t,this.featureIndex=n,this.sourceLayerIndex=A,this.bucketIndex=h,this.tileID=y}}class ul{constructor(t){this.crossSourceCollisions=t,this.maxGroupID=0,this.collisionGroups={}}get(t){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[t]){const n=++this.maxGroupID;this.collisionGroups[t]={ID:n,predicate:A=>A.collisionGroupID===n}}return this.collisionGroups[t]}}function Aa(_,t,n,A,h){const{horizontalAlign:y,verticalAlign:b}=d.aS(_);return new d.P(-(y-.5)*t+A[0]*h,-(b-.5)*n+A[1]*h)}class La{constructor(t,n,A,h,y){this.transform=t.clone(),this.terrain=n,this.collisionIndex=new Jl(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=A,this.retainedQueryData={},this.collisionGroups=new ul(h),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=y,y&&(y.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(t){const n=this.terrain;return n?(A,h)=>n.getElevation(t,A,h):null}getBucketParts(t,n,A,h){const y=A.getBucket(n),b=A.latestFeatureIndex;if(!y||!b||n.id!==y.layerIds[0])return;const M=A.collisionBoxArray,I=y.layers[0].layout,D=y.layers[0].paint,B=Math.pow(2,this.transform.zoom-A.tileID.overscaledZ),V=A.tileSize/d.a5,O=A.tileID.toUnwrapped(),U=I.get("text-rotation-alignment")==="map",X=d.aN(A,1,this.transform.zoom),ie=d.aO(this.collisionIndex.transform,A,D.get("text-translate"),D.get("text-translate-anchor")),se=d.aO(this.collisionIndex.transform,A,D.get("icon-translate"),D.get("icon-translate-anchor")),ne=Jt(U,this.transform,X);this.retainedQueryData[y.bucketInstanceId]=new rA(y.bucketInstanceId,b,y.sourceLayerIndex,y.index,A.tileID);const ce={bucket:y,layout:I,translationText:ie,translationIcon:se,unwrappedTileID:O,pitchedLabelPlaneMatrix:ne,scale:B,textPixelRatio:V,holdingForFade:A.holdingForSymbolFade(),collisionBoxArray:M,partiallyEvaluatedTextSize:d.ay(y.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(y.sourceID)};if(h)for(const ge of y.sortKeyRanges){const{sortKey:Ae,symbolInstanceStart:de,symbolInstanceEnd:ye}=ge;t.push({sortKey:Ae,symbolInstanceStart:de,symbolInstanceEnd:ye,parameters:ce})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:y.symbolInstances.length,parameters:ce})}attemptAnchorPlacement(t,n,A,h,y,b,M,I,D,B,V,O,U,X,ie,se,ne,ce,ge,Ae){const de=d.aP[t.textAnchor],ye=[t.textOffset0,t.textOffset1],fe=Aa(de,A,h,ye,y),Me=this.collisionIndex.placeCollisionBox(n,O,I,D,B,M,b,se,V.predicate,ge,fe,Ae);if((!ce||this.collisionIndex.placeCollisionBox(ce,O,I,D,B,M,b,ne,V.predicate,ge,fe,Ae).placeable)&&Me.placeable){let Ge;if(this.prevPlacement&&this.prevPlacement.variableOffsets[U.crossTileID]&&this.prevPlacement.placements[U.crossTileID]&&this.prevPlacement.placements[U.crossTileID].text&&(Ge=this.prevPlacement.variableOffsets[U.crossTileID].anchor),U.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[U.crossTileID]={textOffset:ye,width:A,height:h,anchor:de,textBoxScale:y,prevAnchor:Ge},this.markUsedJustification(X,de,U,ie),X.allowVerticalPlacement&&(this.markUsedOrientation(X,ie,U),this.placedOrientations[U.crossTileID]=ie),{shift:fe,placedGlyphBoxes:Me}}}placeLayerBucketPart(t,n,A){const{bucket:h,layout:y,translationText:b,translationIcon:M,unwrappedTileID:I,pitchedLabelPlaneMatrix:D,textPixelRatio:B,holdingForFade:V,collisionBoxArray:O,partiallyEvaluatedTextSize:U,collisionGroup:X}=t.parameters,ie=y.get("text-optional"),se=y.get("icon-optional"),ne=d.aQ(y,"text-overlap","text-allow-overlap"),ce=ne==="always",ge=d.aQ(y,"icon-overlap","icon-allow-overlap"),Ae=ge==="always",de=y.get("text-rotation-alignment")==="map",ye=y.get("text-pitch-alignment")==="map",fe=y.get("icon-text-fit")!=="none",Me=y.get("symbol-z-order")==="viewport-y",Ge=ce&&(Ae||!h.hasIconData()||se),Fe=Ae&&(ce||!h.hasTextData()||ie);!h.collisionArrays&&O&&h.deserializeCollisionBoxes(O);const Oe=this.retainedQueryData[h.bucketInstanceId].tileID,Ve=this._getTerrainElevationFunc(Oe),ut=this.transform.getFastPathSimpleProjectionMatrix(Oe),ht=(rt,ft,Wt)=>{var Tr,Ur;if(n[rt.crossTileID])return;if(V)return void(this.placements[rt.crossTileID]=new tA(!1,!1,!1));let Dr=!1,Wr=!1,kr=!0,ri=null,Hr={box:null,placeable:!1,offscreen:null,occluded:!1},Li={placeable:!1},pi=null,ui=null,Hi=null,Xo=0,ho=0,Os=0;ft.textFeatureIndex?Xo=ft.textFeatureIndex:rt.useRuntimeCollisionCircles&&(Xo=rt.featureIndex),ft.verticalTextFeatureIndex&&(ho=ft.verticalTextFeatureIndex);const Sn=ft.textBox;if(Sn){const ts=Fr=>{let zr=d.az.horizontal;if(h.allowVerticalPlacement&&!Fr&&this.prevPlacement){const Mi=this.prevPlacement.placedOrientations[rt.crossTileID];Mi&&(this.placedOrientations[rt.crossTileID]=Mi,zr=Mi,this.markUsedOrientation(h,zr,rt))}return zr},Vs=(Fr,zr)=>{if(h.allowVerticalPlacement&&rt.numVerticalGlyphVertices>0&&ft.verticalTextBox){for(const Mi of h.writingModes)if(Mi===d.az.vertical?(Hr=zr(),Li=Hr):Hr=Fr(),Hr&&Hr.placeable)break}else Hr=Fr()},ms=rt.textAnchorOffsetStartIndex,gs=rt.textAnchorOffsetEndIndex;if(gs===ms){const Fr=(zr,Mi)=>{const Ei=this.collisionIndex.placeCollisionBox(zr,ne,B,Oe,I,ye,de,b,X.predicate,Ve,void 0,ut);return Ei&&Ei.placeable&&(this.markUsedOrientation(h,Mi,rt),this.placedOrientations[rt.crossTileID]=Mi),Ei};Vs((()=>Fr(Sn,d.az.horizontal)),(()=>{const zr=ft.verticalTextBox;return h.allowVerticalPlacement&&rt.numVerticalGlyphVertices>0&&zr?Fr(zr,d.az.vertical):{box:null,offscreen:null}})),ts(Hr&&Hr.placeable)}else{let Fr=d.aP[(Ur=(Tr=this.prevPlacement)===null||Tr===void 0?void 0:Tr.variableOffsets[rt.crossTileID])===null||Ur===void 0?void 0:Ur.anchor];const zr=(Ei,$u,Wu)=>{const Da=Ei.x2-Ei.x1,Cc=Ei.y2-Ei.y1,Hu=rt.textBoxScale,vu=fe&&ge==="never"?$u:null;let Yo=null,Ko=ne==="never"?1:2,Jo="never";Fr&&Ko++;for(let xu=0;xu<Ko;xu++){for(let bu=ms;bu<gs;bu++){const FA=h.textAnchorOffsets.get(bu);if(Fr&&FA.textAnchor!==Fr)continue;const OA=this.attemptAnchorPlacement(FA,Ei,Da,Cc,Hu,de,ye,B,Oe,I,X,Jo,rt,h,Wu,b,M,vu,Ve);if(OA&&(Yo=OA.placedGlyphBoxes,Yo&&Yo.placeable))return Dr=!0,ri=OA.shift,Yo}Fr?Fr=null:Jo=ne}return A&&!Yo&&(Yo={box:this.collisionIndex.placeCollisionBox(Sn,"always",B,Oe,I,ye,de,b,X.predicate,Ve,void 0,ut).box,offscreen:!1,placeable:!1,occluded:!1}),Yo};Vs((()=>zr(Sn,ft.iconBox,d.az.horizontal)),(()=>{const Ei=ft.verticalTextBox;return h.allowVerticalPlacement&&(!Hr||!Hr.placeable)&&rt.numVerticalGlyphVertices>0&&Ei?zr(Ei,ft.verticalIconBox,d.az.vertical):{box:null,occluded:!0,offscreen:null}})),Hr&&(Dr=Hr.placeable,kr=Hr.offscreen);const Mi=ts(Hr&&Hr.placeable);if(!Dr&&this.prevPlacement){const Ei=this.prevPlacement.variableOffsets[rt.crossTileID];Ei&&(this.variableOffsets[rt.crossTileID]=Ei,this.markUsedJustification(h,Ei.anchor,rt,Mi))}}}if(pi=Hr,Dr=pi&&pi.placeable,kr=pi&&pi.offscreen,rt.useRuntimeCollisionCircles&&rt.centerJustifiedTextSymbolIndex>=0){const ts=h.text.placedSymbolArray.get(rt.centerJustifiedTextSymbolIndex),Vs=d.aA(h.textSizeData,U,ts),ms=y.get("text-padding");ui=this.collisionIndex.placeCollisionCircles(ne,ts,h.lineVertexArray,h.glyphOffsetArray,Vs,I,D,A,ye,X.predicate,rt.collisionCircleDiameter,ms,b,Ve),ui.circles.length&&ui.collisionDetected&&!A&&d.w("Collisions detected, but collision boxes are not shown"),Dr=ce||ui.circles.length>0&&!ui.collisionDetected,kr=kr&&ui.offscreen}if(ft.iconFeatureIndex&&(Os=ft.iconFeatureIndex),ft.iconBox){const ts=Vs=>this.collisionIndex.placeCollisionBox(Vs,ge,B,Oe,I,ye,de,M,X.predicate,Ve,fe&&ri?ri:void 0,ut);Li&&Li.placeable&&ft.verticalIconBox?(Hi=ts(ft.verticalIconBox),Wr=Hi.placeable):(Hi=ts(ft.iconBox),Wr=Hi.placeable),kr=kr&&Hi.offscreen}const Sa=ie||rt.numHorizontalGlyphVertices===0&&rt.numVerticalGlyphVertices===0,Nl=se||rt.numIconVertices===0;Sa||Nl?Nl?Sa||(Wr=Wr&&Dr):Dr=Wr&&Dr:Wr=Dr=Wr&&Dr;const Ca=Wr&&Hi.placeable;if(Dr&&pi.placeable&&this.collisionIndex.insertCollisionBox(pi.box,ne,y.get("text-ignore-placement"),h.bucketInstanceId,Li&&Li.placeable&&ho?ho:Xo,X.ID),Ca&&this.collisionIndex.insertCollisionBox(Hi.box,ge,y.get("icon-ignore-placement"),h.bucketInstanceId,Os,X.ID),ui&&Dr&&this.collisionIndex.insertCollisionCircles(ui.circles,ne,y.get("text-ignore-placement"),h.bucketInstanceId,Xo,X.ID),A&&this.storeCollisionData(h.bucketInstanceId,Wt,ft,pi,Hi,ui),rt.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");if(h.bucketInstanceId===0)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[rt.crossTileID]=new tA((Dr||Ge)&&!(pi!=null&&pi.occluded),(Wr||Fe)&&!(Hi!=null&&Hi.occluded),kr||h.justReloaded),n[rt.crossTileID]=!0};if(Me){if(t.symbolInstanceStart!==0)throw new Error("bucket.bucketInstanceId should be 0");const rt=h.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let ft=rt.length-1;ft>=0;--ft){const Wt=rt[ft];ht(h.symbolInstances.get(Wt),h.collisionArrays[Wt],Wt)}}else for(let rt=t.symbolInstanceStart;rt<t.symbolInstanceEnd;rt++)ht(h.symbolInstances.get(rt),h.collisionArrays[rt],rt);h.justReloaded=!1}storeCollisionData(t,n,A,h,y,b){if(A.textBox||A.iconBox){let M,I;this.collisionBoxArrays.has(t)?M=this.collisionBoxArrays.get(t):(M=new Map,this.collisionBoxArrays.set(t,M)),M.has(n)?I=M.get(n):(I={text:null,icon:null},M.set(n,I)),A.textBox&&(I.text=h.box),A.iconBox&&(I.icon=y.box)}if(b){let M=this.collisionCircleArrays[t];M===void 0&&(M=this.collisionCircleArrays[t]=[]);for(let I=0;I<b.circles.length;I+=4)M.push(b.circles[I+0]-Qr),M.push(b.circles[I+1]-Qr),M.push(b.circles[I+2]),M.push(b.collisionDetected?1:0)}}markUsedJustification(t,n,A,h){let y;y=h===d.az.vertical?A.verticalPlacedTextSymbolIndex:{left:A.leftJustifiedTextSymbolIndex,center:A.centerJustifiedTextSymbolIndex,right:A.rightJustifiedTextSymbolIndex}[d.aR(n)];const b=[A.leftJustifiedTextSymbolIndex,A.centerJustifiedTextSymbolIndex,A.rightJustifiedTextSymbolIndex,A.verticalPlacedTextSymbolIndex];for(const M of b)M>=0&&(t.text.placedSymbolArray.get(M).crossTileID=y>=0&&M!==y?0:A.crossTileID)}markUsedOrientation(t,n,A){const h=n===d.az.horizontal||n===d.az.horizontalOnly?n:0,y=n===d.az.vertical?n:0,b=[A.leftJustifiedTextSymbolIndex,A.centerJustifiedTextSymbolIndex,A.rightJustifiedTextSymbolIndex];for(const M of b)t.text.placedSymbolArray.get(M).placedOrientation=h;A.verticalPlacedTextSymbolIndex&&(t.text.placedSymbolArray.get(A.verticalPlacedTextSymbolIndex).placedOrientation=y)}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;const n=this.prevPlacement;let A=!1;this.prevZoomAdjustment=n?n.zoomAdjustment(this.transform.zoom):0;const h=n?n.symbolFadeChange(t):1,y=n?n.opacities:{},b=n?n.variableOffsets:{},M=n?n.placedOrientations:{};for(const I in this.placements){const D=this.placements[I],B=y[I];B?(this.opacities[I]=new la(B,h,D.text,D.icon),A=A||D.text!==B.text.placed||D.icon!==B.icon.placed):(this.opacities[I]=new la(null,h,D.text,D.icon,D.skipFade),A=A||D.text||D.icon)}for(const I in y){const D=y[I];if(!this.opacities[I]){const B=new la(D,h,!1,!1);B.isHidden()||(this.opacities[I]=B,A=A||D.text.placed||D.icon.placed)}}for(const I in b)this.variableOffsets[I]||!this.opacities[I]||this.opacities[I].isHidden()||(this.variableOffsets[I]=b[I]);for(const I in M)this.placedOrientations[I]||!this.opacities[I]||this.opacities[I].isHidden()||(this.placedOrientations[I]=M[I]);if(n&&n.lastPlacementChangeTime===void 0)throw new Error("Last placement time for previous placement is not defined");A?this.lastPlacementChangeTime=t:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=n?n.lastPlacementChangeTime:t)}updateLayerOpacities(t,n){const A={};for(const h of n){const y=h.getBucket(t);y&&h.latestFeatureIndex&&t.id===y.layerIds[0]&&this.updateBucketOpacities(y,h.tileID,A,h.collisionBoxArray)}}updateBucketOpacities(t,n,A,h){t.hasTextData()&&(t.text.opacityVertexArray.clear(),t.text.hasVisibleVertices=!1),t.hasIconData()&&(t.icon.opacityVertexArray.clear(),t.icon.hasVisibleVertices=!1),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const y=t.layers[0],b=y.layout,M=new la(null,0,!1,!1,!0),I=b.get("text-allow-overlap"),D=b.get("icon-allow-overlap"),B=y._unevaluatedLayout.hasValue("text-variable-anchor")||y._unevaluatedLayout.hasValue("text-variable-anchor-offset"),V=b.get("text-rotation-alignment")==="map",O=b.get("text-pitch-alignment")==="map",U=b.get("icon-text-fit")!=="none",X=new la(null,0,I&&(D||!t.hasIconData()||b.get("icon-optional")),D&&(I||!t.hasTextData()||b.get("text-optional")),!0);!t.collisionArrays&&h&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(h);const ie=(ne,ce,ge)=>{for(let Ae=0;Ae<ce/4;Ae++)ne.opacityVertexArray.emplaceBack(ge);ne.hasVisibleVertices=ne.hasVisibleVertices||ge!==ca},se=this.collisionBoxArrays.get(t.bucketInstanceId);for(let ne=0;ne<t.symbolInstances.length;ne++){const ce=t.symbolInstances.get(ne),{numHorizontalGlyphVertices:ge,numVerticalGlyphVertices:Ae,crossTileID:de}=ce;let ye=this.opacities[de];A[de]?ye=M:ye||(ye=X,this.opacities[de]=ye),A[de]=!0;const fe=ce.numIconVertices>0,Me=this.placedOrientations[ce.crossTileID],Ge=Me===d.az.vertical,Fe=Me===d.az.horizontal||Me===d.az.horizontalOnly;if(ge>0||Ae>0){const Ve=hl(ye.text);ie(t.text,ge,Ge?ca:Ve),ie(t.text,Ae,Fe?ca:Ve);const ut=ye.text.isHidden();[ce.rightJustifiedTextSymbolIndex,ce.centerJustifiedTextSymbolIndex,ce.leftJustifiedTextSymbolIndex].forEach((ft=>{ft>=0&&(t.text.placedSymbolArray.get(ft).hidden=ut||Ge?1:0)})),ce.verticalPlacedTextSymbolIndex>=0&&(t.text.placedSymbolArray.get(ce.verticalPlacedTextSymbolIndex).hidden=ut||Fe?1:0);const ht=this.variableOffsets[ce.crossTileID];ht&&this.markUsedJustification(t,ht.anchor,ce,Me);const rt=this.placedOrientations[ce.crossTileID];rt&&(this.markUsedJustification(t,"left",ce,rt),this.markUsedOrientation(t,rt,ce))}if(fe){const Ve=hl(ye.icon),ut=!(U&&ce.verticalPlacedIconSymbolIndex&&Ge);ce.placedIconSymbolIndex>=0&&(ie(t.icon,ce.numIconVertices,ut?Ve:ca),t.icon.placedSymbolArray.get(ce.placedIconSymbolIndex).hidden=ye.icon.isHidden()),ce.verticalPlacedIconSymbolIndex>=0&&(ie(t.icon,ce.numVerticalIconVertices,ut?ca:Ve),t.icon.placedSymbolArray.get(ce.verticalPlacedIconSymbolIndex).hidden=ye.icon.isHidden())}const Oe=se&&se.has(ne)?se.get(ne):{text:null,icon:null};if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const Ve=t.collisionArrays[ne];if(Ve){let ut=new d.P(0,0);if(Ve.textBox||Ve.verticalTextBox){let ht=!0;if(B){const rt=this.variableOffsets[de];rt?(ut=Aa(rt.anchor,rt.width,rt.height,rt.textOffset,rt.textBoxScale),V&&ut._rotate(O?-this.transform.bearingInRadians:this.transform.bearingInRadians)):ht=!1}if(Ve.textBox||Ve.verticalTextBox){let rt;Ve.textBox&&(rt=Ge),Ve.verticalTextBox&&(rt=Fe),Pn(t.textCollisionBox.collisionVertexArray,ye.text.placed,!ht||rt,Oe.text,ut.x,ut.y)}}if(Ve.iconBox||Ve.verticalIconBox){const ht=!!(!Fe&&Ve.verticalIconBox);let rt;Ve.iconBox&&(rt=ht),Ve.verticalIconBox&&(rt=!ht),Pn(t.iconCollisionBox.collisionVertexArray,ye.icon.placed,rt,Oe.icon,U?ut.x:0,U?ut.y:0)}}}}if(t.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.text.opacityVertexArray.length!==t.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${t.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${t.text.layoutVertexArray.length}) / 4`);if(t.icon.opacityVertexArray.length!==t.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${t.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${t.icon.layoutVertexArray.length}) / 4`);t.bucketInstanceId in this.collisionCircleArrays&&(t.collisionCircleArray=this.collisionCircleArrays[t.bucketInstanceId],delete this.collisionCircleArrays[t.bucketInstanceId])}symbolFadeChange(t){return this.fadeDuration===0?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,n){const A=this.zoomAtLastRecencyCheck===n?1-this.zoomAdjustment(n):1;return this.zoomAtLastRecencyCheck=n,this.commitTime+this.fadeDuration*A>t}setStale(){this.stale=!0}}function Pn(_,t,n,A,h,y){A&&A.length!==0||(A=[0,0,0,0]);const b=A[0]-Qr,M=A[1]-Qr,I=A[2]-Qr,D=A[3]-Qr;_.emplaceBack(t?1:0,n?1:0,h||0,y||0,b,M),_.emplaceBack(t?1:0,n?1:0,h||0,y||0,I,M),_.emplaceBack(t?1:0,n?1:0,h||0,y||0,I,D),_.emplaceBack(t?1:0,n?1:0,h||0,y||0,b,D)}const li=Math.pow(2,25),cl=Math.pow(2,24),iA=Math.pow(2,17),ua=Math.pow(2,16),Po=Math.pow(2,9),nA=Math.pow(2,8),Js=Math.pow(2,1);function hl(_){if(_.opacity===0&&!_.placed)return 0;if(_.opacity===1&&_.placed)return 4294967295;const t=_.placed?1:0,n=Math.floor(127*_.opacity);return n*li+t*cl+n*iA+t*ua+n*Po+t*nA+n*Js+t}const ca=0;class Es{constructor(t){this._sortAcrossTiles=t.layout.get("symbol-z-order")!=="viewport-y"&&!t.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(t,n,A,h,y){const b=this._bucketParts;for(;this._currentTileIndex<t.length;)if(n.getBucketParts(b,h,t[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,y())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,b.sort(((M,I)=>M.sortKey-I.sortKey)));this._currentPartIndex<b.length;)if(n.placeLayerBucketPart(b[this._currentPartIndex],this._seenCrossTileIDs,A),this._currentPartIndex++,y())return!0;return!1}}class yr{constructor(t,n,A,h,y,b,M,I){this.placement=new La(t,n,b,M,I),this._currentPlacementIndex=A.length-1,this._forceFullPlacement=h,this._showCollisionBoxes=y,this._done=!1}isDone(){return this._done}continuePlacement(t,n,A){const h=Ar(),y=()=>!this._forceFullPlacement&&Ar()-h>2;for(;this._currentPlacementIndex>=0;){const b=n[t[this._currentPlacementIndex]],M=this.placement.collisionIndex.transform.zoom;if(b.type==="symbol"&&(!b.minzoom||b.minzoom<=M)&&(!b.maxzoom||b.maxzoom>M)){if(this._inProgressLayer||(this._inProgressLayer=new Es(b)),this._inProgressLayer.continuePlacement(A[b.source],this.placement,this._showCollisionBoxes,b,y))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(t){return this.placement.commit(t),this.placement}}const Kt=512/d.a5/2;class Fa{constructor(t,n,A){this.tileID=t,this.bucketInstanceId=A,this._symbolsByKey={};const h=new Map;for(let y=0;y<n.length;y++){const b=n.get(y),M=b.key,I=h.get(M);I?I.push(b):h.set(M,[b])}for(const[y,b]of h){const M={positions:b.map((I=>({x:Math.floor(I.anchorX*Kt),y:Math.floor(I.anchorY*Kt)}))),crossTileIDs:b.map((I=>I.crossTileID))};if(M.positions.length>128){const I=new d.aT(M.positions.length,16,Uint16Array);for(const{x:D,y:B}of M.positions)I.add(D,B);I.finish(),delete M.positions,M.index=I}this._symbolsByKey[y]=M}}getScaledCoordinates(t,n){const{x:A,y:h,z:y}=this.tileID.canonical,{x:b,y:M,z:I}=n.canonical,D=Kt/Math.pow(2,I-y),B=(M*d.a5+t.anchorY)*D,V=h*d.a5*Kt;return{x:Math.floor((b*d.a5+t.anchorX)*D-A*d.a5*Kt),y:Math.floor(B-V)}}findMatches(t,n,A){const h=this.tileID.canonical.z<n.canonical.z?1:Math.pow(2,this.tileID.canonical.z-n.canonical.z);for(let y=0;y<t.length;y++){const b=t.get(y);if(b.crossTileID)continue;const M=this._symbolsByKey[b.key];if(!M)continue;const I=this.getScaledCoordinates(b,n);if(M.index){const D=M.index.range(I.x-h,I.y-h,I.x+h,I.y+h).sort();for(const B of D){const V=M.crossTileIDs[B];if(!A[V]){A[V]=!0,b.crossTileID=V;break}}}else if(M.positions)for(let D=0;D<M.positions.length;D++){const B=M.positions[D],V=M.crossTileIDs[D];if(Math.abs(B.x-I.x)<=h&&Math.abs(B.y-I.y)<=h&&!A[V]){A[V]=!0,b.crossTileID=V;break}}}}getCrossTileIDsLists(){return Object.values(this._symbolsByKey).map((({crossTileIDs:t})=>t))}}class su{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class pl{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(t){const n=Math.round((t-this.lng)/360);if(n!==0)for(const A in this.indexes){const h=this.indexes[A],y={};for(const b in h){const M=h[b];M.tileID=M.tileID.unwrapTo(M.tileID.wrap+n),y[M.tileID.key]=M}this.indexes[A]=y}this.lng=t}addBucket(t,n,A){if(this.indexes[t.overscaledZ]&&this.indexes[t.overscaledZ][t.key]){if(this.indexes[t.overscaledZ][t.key].bucketInstanceId===n.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(t.overscaledZ,this.indexes[t.overscaledZ][t.key])}for(let y=0;y<n.symbolInstances.length;y++)n.symbolInstances.get(y).crossTileID=0;this.usedCrossTileIDs[t.overscaledZ]||(this.usedCrossTileIDs[t.overscaledZ]={});const h=this.usedCrossTileIDs[t.overscaledZ];for(const y in this.indexes){const b=this.indexes[y];if(Number(y)>t.overscaledZ)for(const M in b){const I=b[M];I.tileID.isChildOf(t)&&I.findMatches(n.symbolInstances,t,h)}else{const M=b[t.scaledTo(Number(y)).key];M&&M.findMatches(n.symbolInstances,t,h)}}for(let y=0;y<n.symbolInstances.length;y++){const b=n.symbolInstances.get(y);b.crossTileID||(b.crossTileID=A.generate(),h[b.crossTileID]=!0)}return this.indexes[t.overscaledZ]===void 0&&(this.indexes[t.overscaledZ]={}),this.indexes[t.overscaledZ][t.key]=new Fa(t,n.symbolInstances,n.bucketInstanceId),!0}removeBucketCrossTileIDs(t,n){for(const A of n.getCrossTileIDsLists())for(const h of A)delete this.usedCrossTileIDs[t][h]}removeStaleBuckets(t){let n=!1;for(const A in this.indexes){const h=this.indexes[A];for(const y in h)t[h[y].bucketInstanceId]||(this.removeBucketCrossTileIDs(A,h[y]),delete h[y],n=!0)}return n}}class en{constructor(){this.layerIndexes={},this.crossTileIDs=new su,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(t,n,A){let h=this.layerIndexes[t.id];h===void 0&&(h=this.layerIndexes[t.id]=new pl);let y=!1;const b={};h.handleWrapJump(A);for(const M of n){const I=M.getBucket(t);I&&t.id===I.layerIds[0]&&(I.bucketInstanceId||(I.bucketInstanceId=++this.maxBucketInstanceId),h.addBucket(M.tileID,I,this.crossTileIDs)&&(y=!0),b[I.bucketInstanceId]=!0)}return h.removeStaleBuckets(b)&&(y=!0),y}pruneUnusedLayers(t){const n={};t.forEach((A=>{n[A]=!0}));for(const A in this.layerIndexes)n[A]||delete this.layerIndexes[A]}}var Pi="void main() {fragColor=vec4(1.0);}";const Cr={prelude:Bt(`#ifdef GL_ES 6 + precision mediump float; 7 + #else 8 + #if !defined(lowp) 9 + #define lowp 10 + #endif 11 + #if !defined(mediump) 12 + #define mediump 13 + #endif 14 + #if !defined(highp) 15 + #define highp 16 + #endif 17 + #endif 18 + out highp vec4 fragColor;`,`#ifdef GL_ES 19 + precision highp float; 20 + #else 21 + #if !defined(lowp) 22 + #define lowp 23 + #endif 24 + #if !defined(mediump) 25 + #define mediump 26 + #endif 27 + #if !defined(highp) 28 + #define highp 29 + #endif 30 + #endif 31 + vec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0 32 + );}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 33 + );} 34 + #ifdef TERRAIN3D 35 + uniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth; 36 + #endif 37 + const 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) { 38 + #ifdef TERRAIN3D 39 + highp 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)); 40 + #else 41 + return 1.0; 42 + #endif 43 + }float calculate_visibility(vec4 pos) { 44 + #ifdef TERRAIN3D 45 + vec3 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; 46 + #else 47 + return 1.0; 48 + #endif 49 + }float ele(vec2 pos) { 50 + #ifdef TERRAIN3D 51 + vec4 rgb=(texture(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a; 52 + #else 53 + return 0.0; 54 + #endif 55 + }float get_elevation(vec2 pos) { 56 + #ifdef TERRAIN3D 57 + #ifdef GLOBE 58 + if ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;} 59 + #endif 60 + vec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration; 61 + #else 62 + return 0.0; 63 + #endif 64 + }const float PI=3.141592653589793;uniform mat4 u_projection_matrix;`),projectionMercator:Bt("","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:Bt("",`#define GLOBE_RADIUS 6371008.8 65 + uniform highp vec4 u_projection_tile_mercator_coords;uniform highp vec4 u_projection_clipping_plane;uniform highp float u_projection_transition;uniform mat4 u_projection_fallback_matrix;vec3 globeRotateVector(vec3 vec,vec2 angles) {vec3 axisRight=vec3(vec.z,0.0,-vec.x);vec3 axisUp=cross(axisRight,vec);axisRight=normalize(axisRight);axisUp=normalize(axisUp);vec2 t=tan(angles);return normalize(vec+axisRight*t.x+axisUp*t.y);}mat3 globeGetRotationMatrix(vec3 spherePos) {vec3 axisRight=vec3(spherePos.z,0.0,-spherePos.x);vec3 axisDown=cross(axisRight,spherePos);axisRight=normalize(axisRight);axisDown=normalize(axisDown);return mat3(axisRight,axisDown,spherePos 66 + );}float circumferenceRatioAtTileY(float tileY) {float mercator_pos_y=u_projection_tile_mercator_coords.y+u_projection_tile_mercator_coords.w*tileY;float spherical_y=2.0*atan(exp(PI-(mercator_pos_y*PI*2.0)))-PI*0.5;return cos(spherical_y);}float projectLineThickness(float tileY) {float thickness=1.0/circumferenceRatioAtTileY(tileY); 67 + 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;vec2 spherical;spherical.x=mercator_pos.x*PI*2.0+PI;spherical.y=2.0*atan(exp(PI-(mercator_pos.y*PI*2.0)))-PI*0.5;float len=cos(spherical.y);vec3 pos=vec3(sin(spherical.x)*len,sin(spherical.y),cos(spherical.x)*len 68 + );if (rawPos.y <-32767.5) {pos=vec3(0.0,1.0,0.0);}if (rawPos.y > 32766.5) {pos=vec3(0.0,-1.0,0.0);}return pos;}vec3 projectToSphere(vec2 posInTile) {return projectToSphere(posInTile,vec2(0.0,0.0));}float globeComputeClippingZ(vec3 spherePos) {return (1.0-(dot(spherePos,u_projection_clipping_plane.xyz)+u_projection_clipping_plane.w));}vec4 interpolateProjection(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);globePosition.z=globeComputeClippingZ(elevatedPos)*globePosition.w;if (u_projection_transition > 0.999) {return globePosition;}vec4 flatPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);const float z_globeness_threshold=0.2;vec4 result=globePosition;result.z=mix(0.0,globePosition.z,clamp((u_projection_transition-z_globeness_threshold)/(1.0-z_globeness_threshold),0.0,1.0));result.xyw=mix(flatPosition.xyw,globePosition.xyw,u_projection_transition);if ((posInTile.y <-32767.5) || (posInTile.y > 32766.5)) {result=globePosition;const float poles_hidden_anim_percentage=0.02;result.z=mix(globePosition.z,100.0,pow(max((1.0-u_projection_transition)/poles_hidden_anim_percentage,0.0),8.0));}return result;}vec4 interpolateProjectionFor3D(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);if (u_projection_transition > 0.999) {return globePosition;}vec4 fallbackPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);return mix(fallbackPosition,globePosition,u_projection_transition);}vec4 projectTile(vec2 posInTile) {return interpolateProjection(posInTile,projectToSphere(posInTile),0.0);}vec4 projectTile(vec2 posInTile,vec2 rawPos) {return interpolateProjection(posInTile,projectToSphere(posInTile,rawPos),0.0);}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return interpolateProjection(posInTile,projectToSphere(posInTile),elevation);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {vec3 spherePos=projectToSphere(posInTile,posInTile);return interpolateProjectionFor3D(posInTile,spherePos,elevation);}`),background:Bt(`uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity; 69 + #ifdef OVERDRAW_INSPECTOR 70 + fragColor=vec4(1.0); 71 + #endif 72 + }`,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),backgroundPattern:Bt(`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; 73 + #ifdef OVERDRAW_INSPECTOR 74 + fragColor=vec4(1.0); 75 + #endif 76 + }`,"uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;void main() {gl_Position=projectTile(a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}"),circle:Bt(`in vec3 v_data;in float v_visibility; 77 + #pragma mapbox: define highp vec4 color 78 + #pragma mapbox: define mediump float radius 79 + #pragma mapbox: define lowp float blur 80 + #pragma mapbox: define lowp float opacity 81 + #pragma mapbox: define highp vec4 stroke_color 82 + #pragma mapbox: define mediump float stroke_width 83 + #pragma mapbox: define lowp float stroke_opacity 84 + void main() { 85 + #pragma mapbox: initialize highp vec4 color 86 + #pragma mapbox: initialize mediump float radius 87 + #pragma mapbox: initialize lowp float blur 88 + #pragma mapbox: initialize lowp float opacity 89 + #pragma mapbox: initialize highp vec4 stroke_color 90 + #pragma mapbox: initialize mediump float stroke_width 91 + #pragma mapbox: initialize lowp float stroke_opacity 92 + vec2 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;} 93 + #ifdef OVERDRAW_INSPECTOR 94 + fragColor=vec4(1.0); 95 + #endif 96 + }`,`uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform highp float u_globe_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;uniform vec2 u_translate;in vec2 a_pos;out vec3 v_data;out float v_visibility; 97 + #pragma mapbox: define highp vec4 color 98 + #pragma mapbox: define mediump float radius 99 + #pragma mapbox: define lowp float blur 100 + #pragma mapbox: define lowp float opacity 101 + #pragma mapbox: define highp vec4 stroke_color 102 + #pragma mapbox: define mediump float stroke_width 103 + #pragma mapbox: define lowp float stroke_opacity 104 + void main(void) { 105 + #pragma mapbox: initialize highp vec4 color 106 + #pragma mapbox: initialize mediump float radius 107 + #pragma mapbox: initialize lowp float blur 108 + #pragma mapbox: initialize lowp float opacity 109 + #pragma mapbox: initialize highp vec4 stroke_color 110 + #pragma mapbox: initialize mediump float stroke_width 111 + #pragma mapbox: initialize lowp float stroke_opacity 112 + vec2 pos_raw=a_pos+32768.0;vec2 extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);vec2 circle_center=floor(pos_raw/8.0)+u_translate;float ele=get_elevation(circle_center);v_visibility=calculate_visibility(projectTileWithElevation(circle_center,ele));if (u_pitch_with_map) { 113 + #ifdef GLOBE 114 + vec3 center_vector=projectToSphere(circle_center); 115 + #endif 116 + float 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 { 117 + #ifdef GLOBE 118 + vec4 projected_center=interpolateProjection(circle_center,center_vector,ele); 119 + #else 120 + vec4 projected_center=projectTileWithElevation(circle_center,ele); 121 + #endif 122 + corner_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);} 123 + #ifdef GLOBE 124 + vec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele); 125 + #else 126 + gl_Position=projectTileWithElevation(corner_position,ele); 127 + #endif 128 + } 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:Bt(Pi,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:Bt(`uniform highp float u_intensity;in vec2 v_extrude; 129 + #pragma mapbox: define highp float weight 130 + #define GAUSS_COEF 0.3989422804014327 131 + void main() { 132 + #pragma mapbox: initialize highp float weight 133 + float 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); 134 + #ifdef OVERDRAW_INSPECTOR 135 + fragColor=vec4(1.0); 136 + #endif 137 + }`,`uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;uniform highp float u_globe_extrude_scale;in vec2 a_pos;out vec2 v_extrude; 138 + #pragma mapbox: define highp float weight 139 + #pragma mapbox: define mediump float radius 140 + const highp float ZERO=1.0/255.0/16.0; 141 + #define GAUSS_COEF 0.3989422804014327 142 + void main(void) { 143 + #pragma mapbox: initialize highp float weight 144 + #pragma mapbox: initialize mediump float radius 145 + vec2 pos_raw=a_pos+32768.0;vec2 unscaled_extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 circle_center=floor(pos_raw/8.0); 146 + #ifdef GLOBE 147 + vec2 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); 148 + #else 149 + gl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center)); 150 + #endif 151 + }`),heatmapTexture:Bt(`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; 152 + #ifdef OVERDRAW_INSPECTOR 153 + fragColor=vec4(0.0); 154 + #endif 155 + }`,"uniform mat4 u_matrix;uniform vec2 u_world;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:Bt("in float v_placed;in float v_notUsed;void main() {float alpha=0.5;fragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {fragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {fragColor*=.1;}}","in vec2 a_anchor_pos;in vec2 a_placed;in vec2 a_box_real;uniform vec2 u_pixel_extrude_scale;out float v_placed;out float v_notUsed;void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:Bt("in float v_radius;in vec2 v_extrude;in float v_collision;void main() {float alpha=0.5;float stroke_radius=0.9;float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);fragColor=color*alpha*opacity_t;}","in vec2 a_pos;in float a_radius;in vec2 a_flags;uniform vec2 u_viewport_size;out float v_radius;out vec2 v_extrude;out float v_collision;void main() {float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_collision=collision;gl_Position=vec4((a_pos/u_viewport_size*2.0-1.0)*vec2(1.0,-1.0),0.0,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),colorRelief:Bt(`#ifdef GL_ES 156 + precision highp float; 157 + #endif 158 + uniform sampler2D u_image;uniform vec4 u_unpack;uniform sampler2D u_elevation_stops;uniform sampler2D u_color_stops;uniform int u_color_ramp_size;uniform float u_opacity;in vec2 v_pos;float getElevation(vec2 coord) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}float getElevationStop(int stop) {float x=(float(stop)+0.5)/float(u_color_ramp_size);vec4 data=texture(u_elevation_stops,vec2(x,0))*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {float el=getElevation(v_pos);int r=(u_color_ramp_size-1);int l=0;float el_l=getElevationStop(l);float el_r=getElevationStop(r);while(r-l > 1){int m=(r+l)/2;float el_m=getElevationStop(m);if(el < el_m){r=m;el_r=el_m;}else 159 + {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)); 160 + #ifdef OVERDRAW_INSPECTOR 161 + fragColor=vec4(1.0); 162 + #endif 163 + }`,"uniform vec2 u_dimension;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_pos/8192.0)*scale+epsilon;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),debug:Bt("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);fragColor=mix(u_color,overlay_color,overlay_color.a);}","in vec2 a_pos;out vec2 v_uv;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=projectTileWithElevation(a_pos*u_overlay_scale,get_elevation(a_pos));}"),depth:Bt(Pi,`in vec2 a_pos;void main() { 164 + #ifdef GLOBE 165 + gl_Position=projectTileFor3D(a_pos,0.0); 166 + #else 167 + gl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0); 168 + #endif 169 + }`),fill:Bt(`#pragma mapbox: define highp vec4 color 170 + #pragma mapbox: define lowp float opacity 171 + void main() { 172 + #pragma mapbox: initialize highp vec4 color 173 + #pragma mapbox: initialize lowp float opacity 174 + fragColor=color*opacity; 175 + #ifdef OVERDRAW_INSPECTOR 176 + fragColor=vec4(1.0); 177 + #endif 178 + }`,`uniform vec2 u_fill_translate;in vec2 a_pos; 179 + #pragma mapbox: define highp vec4 color 180 + #pragma mapbox: define lowp float opacity 181 + void main() { 182 + #pragma mapbox: initialize highp vec4 color 183 + #pragma mapbox: initialize lowp float opacity 184 + gl_Position=projectTile(a_pos+u_fill_translate,a_pos);}`),fillOutline:Bt(`in vec2 v_pos; 185 + #ifdef GLOBE 186 + in float v_depth; 187 + #endif 188 + #pragma mapbox: define highp vec4 outline_color 189 + #pragma mapbox: define lowp float opacity 190 + void main() { 191 + #pragma mapbox: initialize highp vec4 outline_color 192 + #pragma mapbox: initialize lowp float opacity 193 + float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=outline_color*(alpha*opacity); 194 + #ifdef GLOBE 195 + if (v_depth > 1.0) {discard;} 196 + #endif 197 + #ifdef OVERDRAW_INSPECTOR 198 + fragColor=vec4(1.0); 199 + #endif 200 + }`,`uniform vec2 u_world;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos; 201 + #ifdef GLOBE 202 + out float v_depth; 203 + #endif 204 + #pragma mapbox: define highp vec4 outline_color 205 + #pragma mapbox: define lowp float opacity 206 + void main() { 207 + #pragma mapbox: initialize highp vec4 outline_color 208 + #pragma mapbox: initialize lowp float opacity 209 + gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world; 210 + #ifdef GLOBE 211 + v_depth=gl_Position.z/gl_Position.w; 212 + #endif 213 + }`),fillOutlinePattern:Bt(`uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;in vec2 v_pos_a;in vec2 v_pos_b;in vec2 v_pos; 214 + #ifdef GLOBE 215 + in float v_depth; 216 + #endif 217 + #pragma mapbox: define lowp float opacity 218 + #pragma mapbox: define lowp vec4 pattern_from 219 + #pragma mapbox: define lowp vec4 pattern_to 220 + void main() { 221 + #pragma mapbox: initialize lowp float opacity 222 + #pragma mapbox: initialize mediump vec4 pattern_from 223 + #pragma mapbox: initialize mediump vec4 pattern_to 224 + 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;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=mix(color1,color2,u_fade)*alpha*opacity; 225 + #ifdef GLOBE 226 + if (v_depth > 1.0) {discard;} 227 + #endif 228 + #ifdef OVERDRAW_INSPECTOR 229 + fragColor=vec4(1.0); 230 + #endif 231 + }`,`uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;out vec2 v_pos; 232 + #ifdef GLOBE 233 + out float v_depth; 234 + #endif 235 + #pragma mapbox: define lowp float opacity 236 + #pragma mapbox: define lowp vec4 pattern_from 237 + #pragma mapbox: define lowp vec4 pattern_to 238 + #pragma mapbox: define lowp float pixel_ratio_from 239 + #pragma mapbox: define lowp float pixel_ratio_to 240 + void main() { 241 + #pragma mapbox: initialize lowp float opacity 242 + #pragma mapbox: initialize mediump vec4 pattern_from 243 + #pragma mapbox: initialize mediump vec4 pattern_to 244 + #pragma mapbox: initialize lowp float pixel_ratio_from 245 + #pragma mapbox: initialize lowp float pixel_ratio_to 246 + 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; 247 + #ifdef GLOBE 248 + v_depth=gl_Position.z/gl_Position.w; 249 + #endif 250 + }`),fillPattern:Bt(`#ifdef GL_ES 251 + precision highp float; 252 + #endif 253 + uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b; 254 + #pragma mapbox: define lowp float opacity 255 + #pragma mapbox: define lowp vec4 pattern_from 256 + #pragma mapbox: define lowp vec4 pattern_to 257 + void main() { 258 + #pragma mapbox: initialize lowp float opacity 259 + #pragma mapbox: initialize mediump vec4 pattern_from 260 + #pragma mapbox: initialize mediump vec4 pattern_to 261 + 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;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_fade)*opacity; 262 + #ifdef OVERDRAW_INSPECTOR 263 + fragColor=vec4(1.0); 264 + #endif 265 + }`,`uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b; 266 + #pragma mapbox: define lowp float opacity 267 + #pragma mapbox: define lowp vec4 pattern_from 268 + #pragma mapbox: define lowp vec4 pattern_to 269 + #pragma mapbox: define lowp float pixel_ratio_from 270 + #pragma mapbox: define lowp float pixel_ratio_to 271 + void main() { 272 + #pragma mapbox: initialize lowp float opacity 273 + #pragma mapbox: initialize mediump vec4 pattern_from 274 + #pragma mapbox: initialize mediump vec4 pattern_to 275 + #pragma mapbox: initialize lowp float pixel_ratio_from 276 + #pragma mapbox: initialize lowp float pixel_ratio_to 277 + 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:Bt(`in vec4 v_color;void main() {fragColor=v_color; 278 + #ifdef OVERDRAW_INSPECTOR 279 + fragColor=vec4(1.0); 280 + #endif 281 + }`,`uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;in vec2 a_pos;in vec4 a_normal_ed; 282 + #ifdef TERRAIN3D 283 + in vec2 a_centroid; 284 + #endif 285 + out vec4 v_color; 286 + #pragma mapbox: define highp float base 287 + #pragma mapbox: define highp float height 288 + #pragma mapbox: define highp vec4 color 289 + void main() { 290 + #pragma mapbox: initialize highp float base 291 + #pragma mapbox: initialize highp float height 292 + #pragma mapbox: initialize highp vec4 color 293 + vec3 normal=a_normal_ed.xyz; 294 + #ifdef TERRAIN3D 295 + float height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0); 296 + #else 297 + float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0; 298 + #endif 299 + base=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate; 300 + #ifdef GLOBE 301 + vec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation); 302 + #else 303 + gl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0); 304 + #endif 305 + float 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); 306 + #ifdef GLOBE 307 + mat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition); 308 + #endif 309 + directional=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:Bt(`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; 310 + #pragma mapbox: define lowp float base 311 + #pragma mapbox: define lowp float height 312 + #pragma mapbox: define lowp vec4 pattern_from 313 + #pragma mapbox: define lowp vec4 pattern_to 314 + #pragma mapbox: define lowp float pixel_ratio_from 315 + #pragma mapbox: define lowp float pixel_ratio_to 316 + void main() { 317 + #pragma mapbox: initialize lowp float base 318 + #pragma mapbox: initialize lowp float height 319 + #pragma mapbox: initialize mediump vec4 pattern_from 320 + #pragma mapbox: initialize mediump vec4 pattern_to 321 + #pragma mapbox: initialize lowp float pixel_ratio_from 322 + #pragma mapbox: initialize lowp float pixel_ratio_to 323 + 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;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; 324 + #ifdef OVERDRAW_INSPECTOR 325 + fragColor=vec4(1.0); 326 + #endif 327 + }`,`uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;in vec2 a_pos;in vec4 a_normal_ed; 328 + #ifdef TERRAIN3D 329 + in vec2 a_centroid; 330 + #endif 331 + #ifdef GLOBE 332 + out vec3 v_sphere_pos; 333 + #endif 334 + out vec2 v_pos_a;out vec2 v_pos_b;out vec4 v_lighting; 335 + #pragma mapbox: define lowp float base 336 + #pragma mapbox: define lowp float height 337 + #pragma mapbox: define lowp vec4 pattern_from 338 + #pragma mapbox: define lowp vec4 pattern_to 339 + #pragma mapbox: define lowp float pixel_ratio_from 340 + #pragma mapbox: define lowp float pixel_ratio_to 341 + void main() { 342 + #pragma mapbox: initialize lowp float base 343 + #pragma mapbox: initialize lowp float height 344 + #pragma mapbox: initialize mediump vec4 pattern_from 345 + #pragma mapbox: initialize mediump vec4 pattern_to 346 + #pragma mapbox: initialize lowp float pixel_ratio_from 347 + #pragma mapbox: initialize lowp float pixel_ratio_to 348 + 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;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to; 349 + #ifdef TERRAIN3D 350 + float height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0); 351 + #else 352 + float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0; 353 + #endif 354 + base=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate; 355 + #ifdef GLOBE 356 + vec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation); 357 + #else 358 + gl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0); 359 + #endif 360 + vec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0 361 + ? a_pos 362 + : 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:Bt(`#ifdef GL_ES 363 + precision highp float; 364 + #endif 365 + uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {vec2 epsilon=1.0/u_dimension;float tileSize=u_dimension.x-2.0;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))*tileSize/pow(2.0,exaggeration+(28.2562-u_zoom));fragColor=clamp(vec4(deriv.x/8.0+0.5,deriv.y/8.0+0.5,1.0,1.0),0.0,1.0); 366 + #ifdef OVERDRAW_INSPECTOR 367 + fragColor=vec4(1.0); 368 + #endif 369 + }`,"uniform mat4 u_matrix;uniform vec2 u_dimension;in vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:Bt(`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]; 370 + #define PI 3.141592653589793 371 + #define STANDARD 0 372 + #define COMBINED 1 373 + #define IGOR 2 374 + #define MULTIDIRECTIONAL 3 375 + #define BASIC 4 376 + float 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 377 + {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 378 + {fragColor+=u_shadows[i]*(1.0-2.0*shade)/float(NUM_ILLUMINATION_SOURCES);}}}void combined_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=acos((sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv)));cang=clamp(cang,0.0,PI/2.0);float shade=cang*atan(length(deriv))*4.0/PI/PI;float highlight=(PI/2.0-cang)*atan(length(deriv))*4.0/PI/PI;fragColor=u_shadows[0]*shade+u_highlights[0]*highlight;}void main() {vec4 pixel=texture(u_image,v_pos);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));vec2 deriv=((pixel.rg*8.0)-4.0)/scaleFactor;if (u_method==BASIC) {basic_hillshade(deriv);} else if (u_method==COMBINED) {combined_hillshade(deriv);} else if (u_method==IGOR) {igor_hillshade(deriv);} else if (u_method==MULTIDIRECTIONAL) {multidirectional_hillshade(deriv);} else if (u_method==STANDARD) {standard_hillshade(deriv);} else {standard_hillshade(deriv);} 379 + #ifdef OVERDRAW_INSPECTOR 380 + fragColor=vec4(1.0); 381 + #endif 382 + }`,"uniform mat4 u_matrix;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);v_pos=a_pos/8192.0;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),line:Bt(`uniform lowp float u_device_pixel_ratio;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale; 383 + #ifdef GLOBE 384 + in float v_depth; 385 + #endif 386 + #pragma mapbox: define highp vec4 color 387 + #pragma mapbox: define lowp float blur 388 + #pragma mapbox: define lowp float opacity 389 + void main() { 390 + #pragma mapbox: initialize highp vec4 color 391 + #pragma mapbox: initialize lowp float blur 392 + #pragma mapbox: initialize lowp float opacity 393 + 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); 394 + #ifdef GLOBE 395 + if (v_depth > 1.0) {discard;} 396 + #endif 397 + #ifdef OVERDRAW_INSPECTOR 398 + fragColor=vec4(1.0); 399 + #endif 400 + }`,` 401 + #define scale 0.015873016 402 + in vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp float v_linesofar; 403 + #ifdef GLOBE 404 + out float v_depth; 405 + #endif 406 + #pragma mapbox: define highp vec4 color 407 + #pragma mapbox: define lowp float blur 408 + #pragma mapbox: define lowp float opacity 409 + #pragma mapbox: define mediump float gapwidth 410 + #pragma mapbox: define lowp float offset 411 + #pragma mapbox: define mediump float width 412 + void main() { 413 + #pragma mapbox: initialize highp vec4 color 414 + #pragma mapbox: initialize lowp float blur 415 + #pragma mapbox: initialize lowp float opacity 416 + #pragma mapbox: initialize mediump float gapwidth 417 + #pragma mapbox: initialize lowp float offset 418 + #pragma mapbox: initialize mediump float width 419 + float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude; 420 + #ifdef GLOBE 421 + v_depth=gl_Position.z/gl_Position.w; 422 + #endif 423 + #ifdef TERRAIN3D 424 + v_gamma_scale=1.0; 425 + #else 426 + float 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; 427 + #endif 428 + v_width2=vec2(outset,inset);}`),lineGradient:Bt(`uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec2 v_uv; 429 + #ifdef GLOBE 430 + in float v_depth; 431 + #endif 432 + #pragma mapbox: define lowp float blur 433 + #pragma mapbox: define lowp float opacity 434 + void main() { 435 + #pragma mapbox: initialize lowp float blur 436 + #pragma mapbox: initialize lowp float opacity 437 + 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); 438 + #ifdef GLOBE 439 + if (v_depth > 1.0) {discard;} 440 + #endif 441 + #ifdef OVERDRAW_INSPECTOR 442 + fragColor=vec4(1.0); 443 + #endif 444 + }`,` 445 + #define scale 0.015873016 446 + in vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv; 447 + #ifdef GLOBE 448 + out float v_depth; 449 + #endif 450 + #pragma mapbox: define lowp float blur 451 + #pragma mapbox: define lowp float opacity 452 + #pragma mapbox: define mediump float gapwidth 453 + #pragma mapbox: define lowp float offset 454 + #pragma mapbox: define mediump float width 455 + void main() { 456 + #pragma mapbox: initialize lowp float blur 457 + #pragma mapbox: initialize lowp float opacity 458 + #pragma mapbox: initialize mediump float gapwidth 459 + #pragma mapbox: initialize lowp float offset 460 + #pragma mapbox: initialize mediump float width 461 + float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude; 462 + #ifdef GLOBE 463 + v_depth=gl_Position.z/gl_Position.w; 464 + #endif 465 + #ifdef TERRAIN3D 466 + v_gamma_scale=1.0; 467 + #else 468 + float 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; 469 + #endif 470 + v_width2=vec2(outset,inset);}`),linePattern:Bt(`#ifdef GL_ES 471 + precision highp float; 472 + #endif 473 + uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;in vec2 v_normal;in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;in float v_width; 474 + #ifdef GLOBE 475 + in float v_depth; 476 + #endif 477 + #pragma mapbox: define lowp vec4 pattern_from 478 + #pragma mapbox: define lowp vec4 pattern_to 479 + #pragma mapbox: define lowp float pixel_ratio_from 480 + #pragma mapbox: define lowp float pixel_ratio_to 481 + #pragma mapbox: define lowp float blur 482 + #pragma mapbox: define lowp float opacity 483 + void main() { 484 + #pragma mapbox: initialize mediump vec4 pattern_from 485 + #pragma mapbox: initialize mediump vec4 pattern_to 486 + #pragma mapbox: initialize lowp float pixel_ratio_from 487 + #pragma mapbox: initialize lowp float pixel_ratio_to 488 + #pragma mapbox: initialize lowp float blur 489 + #pragma mapbox: initialize lowp float opacity 490 + 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; 491 + #ifdef GLOBE 492 + if (v_depth > 1.0) {discard;} 493 + #endif 494 + #ifdef OVERDRAW_INSPECTOR 495 + fragColor=vec4(1.0); 496 + #endif 497 + }`,` 498 + #define scale 0.015873016 499 + #define LINE_DISTANCE_SCALE 2.0 500 + in vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;out float v_width; 501 + #ifdef GLOBE 502 + out float v_depth; 503 + #endif 504 + #pragma mapbox: define lowp float blur 505 + #pragma mapbox: define lowp float opacity 506 + #pragma mapbox: define lowp float offset 507 + #pragma mapbox: define mediump float gapwidth 508 + #pragma mapbox: define mediump float width 509 + #pragma mapbox: define lowp float floorwidth 510 + #pragma mapbox: define lowp vec4 pattern_from 511 + #pragma mapbox: define lowp vec4 pattern_to 512 + #pragma mapbox: define lowp float pixel_ratio_from 513 + #pragma mapbox: define lowp float pixel_ratio_to 514 + void main() { 515 + #pragma mapbox: initialize lowp float blur 516 + #pragma mapbox: initialize lowp float opacity 517 + #pragma mapbox: initialize lowp float offset 518 + #pragma mapbox: initialize mediump float gapwidth 519 + #pragma mapbox: initialize mediump float width 520 + #pragma mapbox: initialize lowp float floorwidth 521 + #pragma mapbox: initialize mediump vec4 pattern_from 522 + #pragma mapbox: initialize mediump vec4 pattern_to 523 + #pragma mapbox: initialize lowp float pixel_ratio_from 524 + #pragma mapbox: initialize lowp float pixel_ratio_to 525 + float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude; 526 + #ifdef GLOBE 527 + v_depth=gl_Position.z/gl_Position.w; 528 + #endif 529 + #ifdef TERRAIN3D 530 + v_gamma_scale=1.0; 531 + #else 532 + float 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; 533 + #endif 534 + v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}`),lineSDF:Bt(`uniform lowp float u_device_pixel_ratio;uniform lowp float u_lineatlas_width;uniform sampler2D u_image;uniform float u_mix;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale; 535 + #ifdef GLOBE 536 + in float v_depth; 537 + #endif 538 + #pragma mapbox: define highp vec4 color 539 + #pragma mapbox: define lowp float blur 540 + #pragma mapbox: define lowp float opacity 541 + #pragma mapbox: define mediump float width 542 + #pragma mapbox: define lowp float floorwidth 543 + #pragma mapbox: define mediump vec4 dasharray_from 544 + #pragma mapbox: define mediump vec4 dasharray_to 545 + void main() { 546 + #pragma mapbox: initialize highp vec4 color 547 + #pragma mapbox: initialize lowp float blur 548 + #pragma mapbox: initialize lowp float opacity 549 + #pragma mapbox: initialize mediump float width 550 + #pragma mapbox: initialize lowp float floorwidth 551 + #pragma mapbox: initialize mediump vec4 dasharray_from 552 + #pragma mapbox: initialize mediump vec4 dasharray_to 553 + 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); 554 + #ifdef GLOBE 555 + if (v_depth > 1.0) {discard;} 556 + #endif 557 + #ifdef OVERDRAW_INSPECTOR 558 + fragColor=vec4(1.0); 559 + #endif 560 + }`,` 561 + #define scale 0.015873016 562 + #define LINE_DISTANCE_SCALE 2.0 563 + in vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale; 564 + #ifdef GLOBE 565 + out float v_depth; 566 + #endif 567 + #pragma mapbox: define highp vec4 color 568 + #pragma mapbox: define lowp float blur 569 + #pragma mapbox: define lowp float opacity 570 + #pragma mapbox: define mediump float gapwidth 571 + #pragma mapbox: define lowp float offset 572 + #pragma mapbox: define mediump float width 573 + #pragma mapbox: define lowp float floorwidth 574 + #pragma mapbox: define mediump vec4 dasharray_from 575 + #pragma mapbox: define mediump vec4 dasharray_to 576 + void main() { 577 + #pragma mapbox: initialize highp vec4 color 578 + #pragma mapbox: initialize lowp float blur 579 + #pragma mapbox: initialize lowp float opacity 580 + #pragma mapbox: initialize mediump float gapwidth 581 + #pragma mapbox: initialize lowp float offset 582 + #pragma mapbox: initialize mediump float width 583 + #pragma mapbox: initialize lowp float floorwidth 584 + #pragma mapbox: initialize mediump vec4 dasharray_from 585 + #pragma mapbox: initialize mediump vec4 dasharray_to 586 + float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude; 587 + #ifdef GLOBE 588 + v_depth=gl_Position.z/gl_Position.w; 589 + #endif 590 + #ifdef TERRAIN3D 591 + v_gamma_scale=1.0; 592 + #else 593 + float 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; 594 + #endif 595 + float 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:Bt(`uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform sampler2D u_image_dash;uniform float u_mix;uniform lowp float u_lineatlas_width;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;in highp vec2 v_uv; 596 + #ifdef GLOBE 597 + in float v_depth; 598 + #endif 599 + #pragma mapbox: define lowp float blur 600 + #pragma mapbox: define lowp float opacity 601 + #pragma mapbox: define mediump float width 602 + #pragma mapbox: define lowp float floorwidth 603 + #pragma mapbox: define mediump vec4 dasharray_from 604 + #pragma mapbox: define mediump vec4 dasharray_to 605 + void main() { 606 + #pragma mapbox: initialize lowp float blur 607 + #pragma mapbox: initialize lowp float opacity 608 + #pragma mapbox: initialize mediump float width 609 + #pragma mapbox: initialize lowp float floorwidth 610 + #pragma mapbox: initialize mediump vec4 dasharray_from 611 + #pragma mapbox: initialize mediump vec4 dasharray_to 612 + 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); 613 + #ifdef GLOBE 614 + if (v_depth > 1.0) {discard;} 615 + #endif 616 + #ifdef OVERDRAW_INSPECTOR 617 + fragColor=vec4(1.0); 618 + #endif 619 + }`,` 620 + #define scale 0.015873016 621 + #define LINE_DISTANCE_SCALE 2.0 622 + in vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;out vec2 v_tex_a;out vec2 v_tex_b; 623 + #ifdef GLOBE 624 + out float v_depth; 625 + #endif 626 + #pragma mapbox: define lowp float blur 627 + #pragma mapbox: define lowp float opacity 628 + #pragma mapbox: define mediump float gapwidth 629 + #pragma mapbox: define lowp float offset 630 + #pragma mapbox: define mediump float width 631 + #pragma mapbox: define lowp float floorwidth 632 + #pragma mapbox: define mediump vec4 dasharray_from 633 + #pragma mapbox: define mediump vec4 dasharray_to 634 + void main() { 635 + #pragma mapbox: initialize lowp float blur 636 + #pragma mapbox: initialize lowp float opacity 637 + #pragma mapbox: initialize mediump float gapwidth 638 + #pragma mapbox: initialize lowp float offset 639 + #pragma mapbox: initialize mediump float width 640 + #pragma mapbox: initialize lowp float floorwidth 641 + #pragma mapbox: initialize mediump vec4 dasharray_from 642 + #pragma mapbox: initialize mediump vec4 dasharray_to 643 + float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;float texel_height=1.0/u_image_height;float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude; 644 + #ifdef GLOBE 645 + v_depth=gl_Position.z/gl_Position.w; 646 + #endif 647 + #ifdef TERRAIN3D 648 + v_gamma_scale=1.0; 649 + #else 650 + float 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; 651 + #endif 652 + float u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}`),raster:Bt(`uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec2 v_pos0;in vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture(u_image0,v_pos0);vec4 color1=texture(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);fragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a); 653 + #ifdef OVERDRAW_INSPECTOR 654 + fragColor=vec4(1.0); 655 + #endif 656 + }`,`uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;uniform vec4 u_coords_top;uniform vec4 u_coords_bottom;in vec2 a_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {vec2 fractionalPos=a_pos/8192.0;vec2 position=mix(mix(u_coords_top.xy,u_coords_top.zw,fractionalPos.x),mix(u_coords_bottom.xy,u_coords_bottom.zw,fractionalPos.x),fractionalPos.y);gl_Position=projectTile(position,position);v_pos0=((fractionalPos-0.5)/u_buffer_scale)+0.5; 657 + #ifdef GLOBE 658 + if (a_pos.y <-32767.5) {v_pos0.y=0.0;}if (a_pos.y > 32766.5) {v_pos0.y=1.0;} 659 + #endif 660 + v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}`),symbolIcon:Bt(`uniform sampler2D u_texture;in vec2 v_tex;in float v_fade_opacity; 661 + #pragma mapbox: define lowp float opacity 662 + void main() { 663 + #pragma mapbox: initialize lowp float opacity 664 + lowp float alpha=opacity*v_fade_opacity;fragColor=texture(u_texture,v_tex)*alpha; 665 + #ifdef OVERDRAW_INSPECTOR 666 + fragColor=vec4(1.0); 667 + #endif 668 + }`,`in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_tex;out float v_fade_opacity; 669 + #pragma mapbox: define lowp float opacity 670 + void main() { 671 + #pragma mapbox: initialize lowp float opacity 672 + vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ? 673 + camera_to_anchor_distance/u_camera_to_center_distance : 674 + u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0; 675 + #ifdef GLOBE 676 + if(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);} 677 + #endif 678 + vec4 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;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}`),symbolSDF:Bt(`#define SDF_PX 8.0 679 + uniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;in vec2 v_data0;in vec3 v_data1; 680 + #pragma mapbox: define highp vec4 fill_color 681 + #pragma mapbox: define highp vec4 halo_color 682 + #pragma mapbox: define lowp float opacity 683 + #pragma mapbox: define lowp float halo_width 684 + #pragma mapbox: define lowp float halo_blur 685 + void main() { 686 + #pragma mapbox: initialize highp vec4 fill_color 687 + #pragma mapbox: initialize highp vec4 halo_color 688 + #pragma mapbox: initialize lowp float opacity 689 + #pragma mapbox: initialize lowp float halo_width 690 + #pragma mapbox: initialize lowp float halo_blur 691 + float 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 fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}fragColor=color*(alpha*opacity*fade_opacity); 692 + #ifdef OVERDRAW_INSPECTOR 693 + fragColor=vec4(1.0); 694 + #endif 695 + }`,`in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_data0;out vec3 v_data1; 696 + #pragma mapbox: define highp vec4 fill_color 697 + #pragma mapbox: define highp vec4 halo_color 698 + #pragma mapbox: define lowp float opacity 699 + #pragma mapbox: define lowp float halo_width 700 + #pragma mapbox: define lowp float halo_blur 701 + void main() { 702 + #pragma mapbox: initialize highp vec4 fill_color 703 + #pragma mapbox: initialize highp vec4 halo_color 704 + #pragma mapbox: initialize lowp float opacity 705 + #pragma mapbox: initialize lowp float halo_width 706 + #pragma mapbox: initialize lowp float halo_blur 707 + vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ? 708 + camera_to_anchor_distance/u_camera_to_center_distance : 709 + u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0; 710 + #ifdef GLOBE 711 + if(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);} 712 + #endif 713 + vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*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;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}`),symbolTextAndIcon:Bt(`#define SDF_PX 8.0 714 + #define SDF 1.0 715 + #define ICON 0.0 716 + uniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;in vec4 v_data0;in vec4 v_data1; 717 + #pragma mapbox: define highp vec4 fill_color 718 + #pragma mapbox: define highp vec4 halo_color 719 + #pragma mapbox: define lowp float opacity 720 + #pragma mapbox: define lowp float halo_width 721 + #pragma mapbox: define lowp float halo_blur 722 + void main() { 723 + #pragma mapbox: initialize highp vec4 fill_color 724 + #pragma mapbox: initialize highp vec4 halo_color 725 + #pragma mapbox: initialize lowp float opacity 726 + #pragma mapbox: initialize lowp float halo_width 727 + #pragma mapbox: initialize lowp float halo_blur 728 + float fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;fragColor=texture(u_texture_icon,tex_icon)*alpha; 729 + #ifdef OVERDRAW_INSPECTOR 730 + fragColor=vec4(1.0); 731 + #endif 732 + return;}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;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);fragColor=color*(alpha*opacity*fade_opacity); 733 + #ifdef OVERDRAW_INSPECTOR 734 + fragColor=vec4(1.0); 735 + #endif 736 + }`,`in vec4 a_pos_offset;in vec4 a_data;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec4 v_data0;out vec4 v_data1; 737 + #pragma mapbox: define highp vec4 fill_color 738 + #pragma mapbox: define highp vec4 halo_color 739 + #pragma mapbox: define lowp float opacity 740 + #pragma mapbox: define lowp float halo_width 741 + #pragma mapbox: define lowp float halo_blur 742 + void main() { 743 + #pragma mapbox: initialize highp vec4 fill_color 744 + #pragma mapbox: initialize highp vec4 halo_color 745 + #pragma mapbox: initialize lowp float opacity 746 + #pragma mapbox: initialize lowp float halo_width 747 + #pragma mapbox: initialize lowp float halo_blur 748 + vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ? 749 + camera_to_anchor_distance/u_camera_to_center_distance : 750 + u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0; 751 + #ifdef GLOBE 752 + if(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);} 753 + #endif 754 + vec4 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;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}`),terrain:Bt("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 && v_fog_depth > u_fog_ground_blend) {vec4 surface_color_linear=gammaToLinear(surface_color);float blend_color=smoothstep(0.0,1.0,max((v_fog_depth-u_horizon_fog_blend)/(1.0-u_horizon_fog_blend),0.0));vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);float factor_fog=max(v_fog_depth-u_fog_ground_blend,0.0)/(1.0-u_fog_ground_blend);fragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {fragColor=surface_color;}}","in vec3 a_pos3d;uniform mat4 u_fog_matrix;uniform float u_ele_delta;out vec2 v_texture_pos;out float v_fog_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,get_elevation(a_pos3d.xy)-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:Bt("in float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {fragColor=pack(v_depth);}","in vec3 a_pos3d;uniform float u_ele_delta;out float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);v_depth=gl_Position.z/gl_Position.w;}"),terrainCoords:Bt("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;in vec2 v_texture_pos;void main() {vec4 rgba=texture(u_texture,v_texture_pos);fragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}","in vec3 a_pos3d;uniform float u_ele_delta;out vec2 v_texture_pos;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);}"),projectionErrorMeasurement:Bt("in vec4 v_output_error_encoded;void main() {fragColor=v_output_error_encoded;}","in vec2 a_pos;uniform highp float u_input;uniform highp float u_output_expected;out vec4 v_output_error_encoded;void main() {float real_output=2.0*atan(exp(PI-(u_input*PI*2.0)))-PI*0.5;float error=real_output-u_output_expected;float abs_error=abs(error)*128.0;v_output_error_encoded.x=min(floor(abs_error*256.0),255.0)/255.0;abs_error-=v_output_error_encoded.x;v_output_error_encoded.y=min(floor(abs_error*65536.0),255.0)/255.0;abs_error-=v_output_error_encoded.x/255.0;v_output_error_encoded.z=min(floor(abs_error*16777216.0),255.0)/255.0;v_output_error_encoded.w=error >=0.0 ? 1.0 : 0.0;gl_Position=vec4(a_pos,0.0,1.0);}"),atmosphere:Bt(`#ifdef GL_ES 755 + precision highp float; 756 + #endif 757 + in 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 758 + );color.rgb=1.0-exp(-1.0*color.rgb);color=pow(color,vec4(1.0/2.2));fragColor=vec4(color.rgb,1.0-color.a)*u_atmosphere_blend;}`,"in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 view_direction;void main() {view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,0.0,1.0);}"),sky:Bt("uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform vec2 u_horizon;uniform vec2 u_horizon_normal;uniform float u_sky_horizon_blend;uniform float u_sky_blend;void main() {float x=gl_FragCoord.x;float y=gl_FragCoord.y;float blend=(y-u_horizon.y)*u_horizon_normal.y+(x-u_horizon.x)*u_horizon_normal.x;if (blend > 0.0) {if (blend < u_sky_horizon_blend) {fragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {fragColor=u_sky_color;}}fragColor=mix(fragColor,vec4(vec3(0.0),0.0),u_sky_blend);}","in vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}")};function Bt(_,t){const n=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,A=t.match(/in ([\w]+) ([\w]+)/g),h=_.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),y=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),b=y?y.concat(h):h,M={};return{fragmentSource:_=_.replace(n,((I,D,B,V,O)=>(M[O]=!0,D==="define"?` 759 + #ifndef HAS_UNIFORM_u_${O} 760 + in ${B} ${V} ${O}; 761 + #else 762 + uniform ${B} ${V} u_${O}; 763 + #endif 764 + `:` 765 + #ifdef HAS_UNIFORM_u_${O} 766 + ${B} ${V} ${O} = u_${O}; 767 + #endif 768 + `))),vertexSource:t=t.replace(n,((I,D,B,V,O)=>{const U=V==="float"?"vec2":"vec4",X=O.match(/color/)?"color":U;return M[O]?D==="define"?` 769 + #ifndef HAS_UNIFORM_u_${O} 770 + uniform lowp float u_${O}_t; 771 + in ${B} ${U} a_${O}; 772 + out ${B} ${V} ${O}; 773 + #else 774 + uniform ${B} ${V} u_${O}; 775 + #endif 776 + `:X==="vec4"?` 777 + #ifndef HAS_UNIFORM_u_${O} 778 + ${O} = a_${O}; 779 + #else 780 + ${B} ${V} ${O} = u_${O}; 781 + #endif 782 + `:` 783 + #ifndef HAS_UNIFORM_u_${O} 784 + ${O} = unpack_mix_${X}(a_${O}, u_${O}_t); 785 + #else 786 + ${B} ${V} ${O} = u_${O}; 787 + #endif 788 + `:D==="define"?` 789 + #ifndef HAS_UNIFORM_u_${O} 790 + uniform lowp float u_${O}_t; 791 + in ${B} ${U} a_${O}; 792 + #else 793 + uniform ${B} ${V} u_${O}; 794 + #endif 795 + `:X==="vec4"?` 796 + #ifndef HAS_UNIFORM_u_${O} 797 + ${B} ${V} ${O} = a_${O}; 798 + #else 799 + ${B} ${V} ${O} = u_${O}; 800 + #endif 801 + `:` 802 + #ifndef HAS_UNIFORM_u_${O} 803 + ${B} ${V} ${O} = unpack_mix_${X}(a_${O}, u_${O}_t); 804 + #else 805 + ${B} ${V} ${O} = u_${O}; 806 + #endif 807 + `})),staticAttributes:A,staticUniforms:b}}class Er{constructor(t,n,A){this.vertexBuffer=t,this.indexBuffer=n,this.segments=A}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}var Is=d.aU([{name:"a_pos",type:"Int16",components:2}]);const Qi="#define PROJECTION_MERCATOR",tn="mercator";class $i{constructor(){this._cachedMesh=null}get name(){return"mercator"}get useSubdivision(){return!1}get shaderVariantName(){return tn}get shaderDefine(){return Qi}get shaderPreludeCode(){return Cr.projectionMercator}get vertexShaderPreludeCode(){return Cr.projectionMercator.vertexSource}get subdivisionGranularity(){return d.aV.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(t){}getMeshFromTileID(t,n,A,h,y){if(this._cachedMesh)return this._cachedMesh;const b=new d.aW;b.emplaceBack(0,0),b.emplaceBack(d.a5,0),b.emplaceBack(0,d.a5),b.emplaceBack(d.a5,d.a5);const M=t.createVertexBuffer(b,Is.members),I=d.aX.simpleSegment(0,0,4,2),D=new d.aY;D.emplaceBack(1,0,2),D.emplaceBack(1,2,3);const B=t.createIndexBuffer(D);return this._cachedMesh=new Er(M,B,I),this._cachedMesh}recalculate(){}hasTransition(){return!1}setErrorQueryLatitudeDegrees(t){}}class Ss{constructor(t=0,n=0,A=0,h=0){if(isNaN(t)||t<0||isNaN(n)||n<0||isNaN(A)||A<0||isNaN(h)||h<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=n,this.left=A,this.right=h}interpolate(t,n,A){return n.top!=null&&t.top!=null&&(this.top=d.G.number(t.top,n.top,A)),n.bottom!=null&&t.bottom!=null&&(this.bottom=d.G.number(t.bottom,n.bottom,A)),n.left!=null&&t.left!=null&&(this.left=d.G.number(t.left,n.left,A)),n.right!=null&&t.right!=null&&(this.right=d.G.number(t.right,n.right,A)),this}getCenter(t,n){const A=d.an((this.left+t-this.right)/2,0,t),h=d.an((this.top+n-this.bottom)/2,0,n);return new d.P(A,h)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new Ss(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Hn(_,t){if(!_.renderWorldCopies||_.lngRange)return;const n=t.lng-_.center.lng;t.lng+=n>180?-360:n<-180?360:0}function Kr(_){return Math.max(0,Math.floor(_))}class Cs{constructor(t,n){var A;this.applyConstrain=(h,y)=>this._constrainOverride!==null?this._constrainOverride(h,y):this._callbacks.defaultConstrain(h,y),this._callbacks=t,this._tileSize=512,this._renderWorldCopies=(n==null?void 0:n.renderWorldCopies)===void 0||!!(n!=null&&n.renderWorldCopies),this._minZoom=(n==null?void 0:n.minZoom)||0,this._maxZoom=(n==null?void 0:n.maxZoom)||22,this._minPitch=(n==null?void 0:n.minPitch)==null?0:n==null?void 0:n.minPitch,this._maxPitch=(n==null?void 0:n.maxPitch)==null?60:n==null?void 0:n.maxPitch,this._constrainOverride=(A=n==null?void 0:n.constrainOverride)!==null&&A!==void 0?A:null,this.setMaxBounds(),this._width=0,this._height=0,this._center=new d.V(0,0),this._elevation=0,this._zoom=0,this._tileZoom=Kr(this._zoom),this._scale=d.aq(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new Ss,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0}apply(t,n,A){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=Kr(this._zoom),this._scale=d.aq(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 Ss(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=!A&&t.autoCalculateNearFarZ,n&&this.constrainInternal(),this._calcMatrices()}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(t){this._minElevationForCurrentTile=t}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(t){this._minZoom!==t&&(this._minZoom=t,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get maxZoom(){return this._maxZoom}setMaxZoom(t){this._maxZoom!==t&&(this._maxZoom=t,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get minPitch(){return this._minPitch}setMinPitch(t){this._minPitch!==t&&(this._minPitch=t,this.setPitch(Math.max(this.pitch,t)))}get maxPitch(){return this._maxPitch}setMaxPitch(t){this._maxPitch!==t&&(this._maxPitch=t,this.setPitch(Math.min(this.pitch,t)))}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(t){t===void 0?t=!0:t===null&&(t=!1),this._renderWorldCopies=t}get constrainOverride(){return this._constrainOverride}setConstrainOverride(t){t===void 0&&(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 d.P(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(t){const n=d.W(t,-180,180)*Math.PI/180;var A,h,y,b,M,I,D,B,V;this._bearingInRadians!==n&&(this._unmodified=!1,this._bearingInRadians=n,this._calcMatrices(),this._rotationMatrix=Vr(),A=this._rotationMatrix,y=-this._bearingInRadians,b=(h=this._rotationMatrix)[0],M=h[1],I=h[2],D=h[3],B=Math.sin(y),V=Math.cos(y),A[0]=b*V+I*B,A[1]=M*V+D*B,A[2]=b*-B+I*V,A[3]=M*-B+D*V)}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(t){const n=d.an(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==n&&(this._unmodified=!1,this._pitchInRadians=n,this._calcMatrices())}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(t){const n=t/180*Math.PI;this._rollInRadians!==n&&(this._unmodified=!1,this._rollInRadians=n,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return d.aZ(this._fovInRadians)}setFov(t){t=d.an(t,.1,150),this.fov!==t&&(this._unmodified=!1,this._fovInRadians=d.ap(t),this._calcMatrices())}get zoom(){return this._zoom}setZoom(t){const n=this.applyConstrain(this._center,t).zoom;this._zoom!==n&&(this._unmodified=!1,this._zoom=n,this._tileZoom=Math.max(0,Math.floor(n)),this._scale=d.aq(n),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,n){this._autoCalculateNearFarZ=!1,this._nearZ=t,this._farZ=n,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(t){return this._edgeInsets.equals(t)}interpolatePadding(t,n,A){this._unmodified=!1,this._edgeInsets.interpolate(t,n,A),this.constrainInternal(),this._calcMatrices()}resize(t,n,A=!0){this._width=t,this._height=n,A&&this.constrainInternal(),this._calcMatrices()}getMaxBounds(){return this._latRange&&this._latRange.length===2&&this._lngRange&&this._lngRange.length===2?new xr([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]]):null}setMaxBounds(t){t?(this._lngRange=[t.getWest(),t.getEast()],this._latRange=[t.getSouth(),t.getNorth()],this.constrainInternal()):(this._lngRange=null,this._latRange=[-d.ao,d.ao])}getCameraQueryGeometry(t,n){if(n.length===1)return[n[0],t];{const{minX:A,minY:h,maxX:y,maxY:b}=d.aa.fromPoints(n).extend(t);return[new d.P(A,h),new d.P(y,h),new d.P(y,b),new d.P(A,b),new d.P(A,h)]}}constrainInternal(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;const t=this._unmodified,{center:n,zoom:A}=this.applyConstrain(this.center,this.zoom);this.setCenter(n),this.setZoom(A),this._unmodified=t,this._constraining=!1}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let t=d.ar(new Float64Array(16));d.Q(t,t,[this._width/2,-this._height/2,1]),d.O(t,t,[1,-1,0]),this._clipSpaceToPixelsMatrix=t,t=d.ar(new Float64Array(16)),d.Q(t,t,[1,-1,1]),d.O(t,t,[-1,-1,0]),d.Q(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,n,A,h){const y=A!==void 0?A:this.bearing,b=h=h!==void 0?h:this.pitch,{distanceToCenter:M,clampedElevation:I}=this._distanceToCenterFromAltElevationPitch(n,this.elevation,b),{x:D,y:B}=_r(b,y),V=d.a9.fromLngLat(t,n);let O,U,X=d.a_(1,V.y),ie=0;do{if(ie+=1,ie>10)break;U=M/X,O=new d.a9(V.x+D*U,V.y+B*U),X=1/O.meterInMercatorCoordinateUnits()}while(Math.abs(M-U*X)>1e-12);return{center:O.toLngLat(),elevation:I,zoom:d.at(this.height/2/Math.tan(this.fovInRadians/2)/U/this.tileSize)}}recalculateZoomAndCenter(t){if(this.elevation-t==0)return;const n=1/this.worldSize,A=d.as(1,this.center.lat)*this.worldSize,h=d.a9.fromLngLat(this.center,this.elevation),y=h.x/n,b=h.y/n,M=h.z/n,I=this.pitch,D=this.bearing,{x:B,y:V,z:O}=_r(I,D),U=this.cameraToCenterDistance,X=y+U*-B,ie=b+U*-V,se=M+U*O,{distanceToCenter:ne,clampedElevation:ce}=this._distanceToCenterFromAltElevationPitch(se/A,t,I),ge=ne*A,Ae=new d.a9((X+B*ge)*n,(ie+V*ge)*n,0).toLngLat(),de=d.as(1,Ae.lat),ye=d.at(this.height/2/Math.tan(this.fovInRadians/2)/ne/de/this.tileSize);this._elevation=ce,this._center=Ae,this.setZoom(ye)}_distanceToCenterFromAltElevationPitch(t,n,A){const h=-Math.cos(d.ap(A)),y=t-n;let b,M=n;return h*y>=0||Math.abs(h)<.1?(b=1e4,M=t+b*h):b=-y/h,{distanceToCenter:b,clampedElevation:M}}getCameraPoint(){const t=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new d.P(t*Math.sin(this.rollInRadians),t*Math.cos(this.rollInRadians)))}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this._cameraToCenterDistance/this._pixelPerMeter+this.elevation}getCameraLngLat(){const t=d.as(1,this.center.lat)*this.worldSize;return Le(this.center,this.elevation,this.pitch,this.bearing,this.cameraToCenterDistance/t).toLngLat()}getMercatorTileCoordinates(t){if(!t)return[0,0,1,1];const n=t.canonical.z>=0?1<<t.canonical.z:Math.pow(2,t.canonical.z);return[t.canonical.x/n,t.canonical.y/n,1/n/d.a5,1/n/d.a5]}}class On{constructor(t,n){this.min=t,this.max=n,this.center=d.a$([],d.b0([],this.min,this.max),.5)}quadrant(t){const n=[t%2==0,t<2],A=d.b1(this.min),h=d.b1(this.max);for(let y=0;y<n.length;y++)A[y]=n[y]?this.min[y]:this.center[y],h[y]=n[y]?this.center[y]:this.max[y];return h[2]=this.max[2],new On(A,h)}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 n=!0;for(let A=0;A<t.planes.length;A++){const h=this.intersectsPlane(t.planes[A]);if(h===0)return 0;h===1&&(n=!1)}return n?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 n=t[3],A=t[3];for(let h=0;h<3;h++)t[h]>0?(n+=t[h]*this.min[h],A+=t[h]*this.max[h]):(A+=t[h]*this.min[h],n+=t[h]*this.max[h]);return n>=0?2:A<0?0:1}}class ha{distanceToTile2d(t,n,A,h){const y=h.distanceX([t,n]),b=h.distanceY([t,n]);return Math.hypot(y,b)}getWrap(t,n,A){return A}getTileBoundingVolume(t,n,A,h){var y,b;let M=0,I=0;if(h!=null&&h.terrain){const B=new d.a2(t.z,n,t.z,t.x,t.y),V=h.terrain.getMinMaxElevation(B);M=(y=V.minElevation)!==null&&y!==void 0?y:Math.min(0,A),I=(b=V.maxElevation)!==null&&b!==void 0?b:Math.max(0,A)}const D=1<<t.z;return new On([n+t.x/D,t.y/D,M],[n+(t.x+1)/D,(t.y+1)/D,I])}allowVariableZoom(t,n){const A=t.fov*(Math.abs(Math.cos(t.rollInRadians))*t.height+Math.abs(Math.sin(t.rollInRadians))*t.width)/t.height,h=d.an(78.5-A/2,0,60);return!!n.terrain||t.pitch>h}allowWorldCopies(){return!0}prepareNextFrame(){}}class rn{constructor(t,n,A){this.points=t,this.planes=n,this.aabb=A}static fromInvProjectionMatrix(t,n=1,A=0,h,y){const b=y?[[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]],M=Math.pow(2,A),I=[[-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((O=>(function(U,X,ie,se){const ne=d.aH([],U,X),ce=1/ne[3]/ie*se;return d.b6(ne,ne,[ce,ce,1/ne[3],ce])})(O,t,n,M)));h&&(function(O,U,X,ie){const se=ie?4:0,ne=ie?0:4;let ce=0;const ge=[],Ae=[];for(let fe=0;fe<4;fe++){const Me=d.b2([],O[fe+ne],O[fe+se]),Ge=d.b7(Me);d.a$(Me,Me,1/Ge),ge.push(Ge),Ae.push(Me)}for(let fe=0;fe<4;fe++){const Me=d.b8(O[fe+se],Ae[fe],X);ce=Me!==null&&Me>=0?Math.max(ce,Me):Math.max(ce,ge[fe])}const de=(function(fe,Me){const Ge=d.b2([],fe[Me[0]],fe[Me[1]]),Fe=d.b2([],fe[Me[2]],fe[Me[1]]),Oe=[0,0,0,0];return d.b3(Oe,d.b4([],Ge,Fe)),Oe[3]=-d.b5(Oe,fe[Me[0]]),Oe})(O,U),ye=(function(fe,Me){const Ge=d.b9(fe),Fe=d.ba([],fe,1/Ge),Oe=d.b2([],Me,d.a$([],Fe,d.b5(Me,Fe))),Ve=d.b9(Oe);if(Ve>0){const ut=Math.sqrt(1-Fe[3]*Fe[3]),ht=d.a$([],Fe,-Fe[3]),rt=d.b0([],ht,d.a$([],Oe,ut/Ve));return d.bb(Me,rt)}return null})(X,de);if(ye!==null){const fe=ye/d.b5(Ae[0],de);ce=Math.min(ce,fe)}for(let fe=0;fe<4;fe++){const Me=Math.min(ce,ge[fe]);O[fe+ne]=[O[fe+se][0]+Ae[fe][0]*Me,O[fe+se][1]+Ae[fe][1]*Me,O[fe+se][2]+Ae[fe][2]*Me,1]}})(I,b[0],h,y);const D=b.map((O=>{const U=d.b2([],I[O[0]],I[O[1]]),X=d.b2([],I[O[2]],I[O[1]]),ie=d.b3([],d.b4([],U,X)),se=-d.b5(ie,I[O[1]]);return ie.concat(se)})),B=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],V=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const O of I)for(let U=0;U<3;U++)B[U]=Math.min(B[U],O[U]),V[U]=Math.max(V[U],O[U]);return new rn(I,D,new On(B,V))}}class eo{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,n,A){return this._helper.interpolatePadding(t,n,A)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,n,A=!0){this._helper.resize(t,n,A)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}setConstrainOverride(t){this._helper.setConstrainOverride(t)}overrideNearFarZ(t,n){this._helper.overrideNearFarZ(t,n)}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,n){}constructor(t){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this.defaultConstrain=(n,A)=>{A=d.an(+A,this.minZoom,this.maxZoom);const h={center:new d.V(n.lng,n.lat),zoom:A};let y=this._helper._lngRange;if(!this._helper._renderWorldCopies&&y===null){const Ae=179.9999999999;y=[-Ae,Ae]}const b=this.tileSize*d.aq(h.zoom);let M=0,I=b,D=0,B=b,V=0,O=0;const{x:U,y:X}=this.size;if(this._helper._latRange){const Ae=this._helper._latRange;M=d.X(Ae[1])*b,I=d.X(Ae[0])*b,I-M<X&&(V=X/(I-M))}y&&(D=d.W(d.Y(y[0])*b,0,b),B=d.W(d.Y(y[1])*b,0,b),B<D&&(B+=b),B-D<U&&(O=U/(B-D)));const{x:ie,y:se}=Be(b,n);let ne,ce;const ge=Math.max(O||0,V||0);if(ge){const Ae=new d.P(O?(B+D)/2:ie,V?(I+M)/2:se);return h.center=Vt(b,Ae).wrap(),h.zoom+=d.at(ge),h}if(this._helper._latRange){const Ae=X/2;se-Ae<M&&(ce=M+Ae),se+Ae>I&&(ce=I-Ae)}if(y){const Ae=(D+B)/2;let de=ie;this._helper._renderWorldCopies&&(de=d.W(ie,Ae-b/2,Ae+b/2));const ye=U/2;de-ye<D&&(ne=D+ye),de+ye>B&&(ne=B-ye)}if(ne!==void 0||ce!==void 0){const Ae=new d.P(ne??ie,ce??se);h.center=Vt(b,Ae).wrap()}return h},this.applyConstrain=(n,A)=>this._helper.applyConstrain(n,A),this._helper=new Cs({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(n,A)=>this.defaultConstrain(n,A)},t),this._coveringTilesDetailsProvider=new ha}clone(){const t=new eo;return t.apply(this,!1),t}apply(t,n,A){this._helper.apply(t,n,A)}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(t){const n=[new d.bc(0,t)];if(this._helper._renderWorldCopies){const A=this.screenPointToMercatorCoordinate(new d.P(0,0)),h=this.screenPointToMercatorCoordinate(new d.P(this._helper._width,0)),y=this.screenPointToMercatorCoordinate(new d.P(this._helper._width,this._helper._height)),b=this.screenPointToMercatorCoordinate(new d.P(0,this._helper._height)),M=Math.floor(Math.min(A.x,h.x,y.x,b.x)),I=Math.floor(Math.max(A.x,h.x,y.x,b.x)),D=1;for(let B=M-D;B<=I+D;B++)B!==0&&n.push(new d.bc(B,t))}return n}getCameraFrustum(){return rn.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(t){const n=this.screenPointToLocation(this.centerPoint,t),A=t?t.getElevationForLngLatZoom(n,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(A)}setLocationAtPoint(t,n){const A=d.as(this.elevation,this.center.lat),h=this.screenPointToMercatorCoordinateAtZ(n,A),y=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,A),b=d.a9.fromLngLat(t),M=new d.a9(b.x-(h.x-y.x),b.y-(h.y-y.y));this.setCenter(M==null?void 0:M.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(t,n){return n?this.coordinatePoint(d.a9.fromLngLat(t),n.getElevationForLngLat(t,this),this._pixelMatrix3D):this.coordinatePoint(d.a9.fromLngLat(t))}screenPointToLocation(t,n){var A;return(A=this.screenPointToMercatorCoordinate(t,n))===null||A===void 0?void 0:A.toLngLat()}screenPointToMercatorCoordinate(t,n){if(n){const A=n.pointCoordinate(t);if(A!=null)return A}return this.screenPointToMercatorCoordinateAtZ(t)}screenPointToMercatorCoordinateAtZ(t,n){const A=n||0,h=[t.x,t.y,0,1],y=[t.x,t.y,1,1];d.aH(h,h,this._pixelMatrixInverse),d.aH(y,y,this._pixelMatrixInverse);const b=h[3],M=y[3],I=h[1]/b,D=y[1]/M,B=h[2]/b,V=y[2]/M,O=B===V?0:(A-B)/(V-B);return new d.a9(d.G.number(h[0]/b,y[0]/M,O)/this.worldSize,d.G.number(I,D,O)/this.worldSize,A)}coordinatePoint(t,n=0,A=this._pixelMatrix){const h=[t.x*this.worldSize,t.y*this.worldSize,n,1];return d.aH(h,h,A),new d.P(h[0]/h[3],h[1]/h[3])}getBounds(){const t=Math.max(0,this._helper._height/2-gr(this));return new xr().extend(this.screenPointToLocation(new d.P(0,t))).extend(this.screenPointToLocation(new d.P(this._helper._width,t))).extend(this.screenPointToLocation(new d.P(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new d.P(0,this._helper._height)))}isPointOnMapSurface(t,n){return n?n.pointCoordinate(t)!=null:t.y>this.height/2-gr(this)}calculatePosMatrix(t,n=!1,A){var h;const y=(h=t.key)!==null&&h!==void 0?h:d.bd(t.wrap,t.canonical.z,t.canonical.z,t.canonical.x,t.canonical.y),b=n?this._alignedPosMatrixCache:this._posMatrixCache;if(b.has(y)){const D=b.get(y);return A?D.f32:D.f64}const M=hr(t,this.worldSize);d.S(M,n?this._alignedProjMatrix:this._viewProjMatrix,M);const I={f64:M,f32:new Float32Array(M)};return b.set(y,I),A?I.f32:I.f64}calculateFogMatrix(t){const n=t.key,A=this._fogMatrixCacheF32;if(A.has(n))return A.get(n);const h=hr(t,this.worldSize);return d.S(h,this._fogMatrix,h),A.set(n,new Float32Array(h)),A.get(n)}calculateCenterFromCameraLngLatAlt(t,n,A,h){return this._helper.calculateCenterFromCameraLngLatAlt(t,n,A,h)}_calculateNearFarZIfNeeded(t,n,A){if(!this._helper.autoCalculateNearFarZ)return;const h=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),y=t-h*this._helper._pixelPerMeter/Math.cos(n),b=h<0?y:t,M=Math.PI/2+this.pitchInRadians,I=d.ap(this.fov)*(Math.abs(Math.cos(d.ap(this.roll)))*this.height+Math.abs(Math.sin(d.ap(this.roll)))*this.width)/this.height*(.5+A.y/this.height),D=Math.sin(I)*b/Math.sin(d.an(Math.PI-M-I,.01,Math.PI-.01)),B=gr(this),V=Math.atan(B/this._helper.cameraToCenterDistance),O=d.ap(.75),U=V>O?2*V*(.5+A.y/(2*B)):O,X=Math.sin(U)*b/Math.sin(d.an(Math.PI-M-U,.01,Math.PI-.01)),ie=Math.min(D,X);this._helper._farZ=1.01*(Math.cos(Math.PI/2-n)*ie+b),this._helper._nearZ=this._helper._height/50}_calcMatrices(){if(!this._helper._height)return;const t=this.centerOffset,n=Be(this.worldSize,this.center),A=n.x,h=n.y;this._helper._pixelPerMeter=d.as(1,this.center.lat)*this.worldSize;const y=d.ap(Math.min(this.pitch,_t)),b=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(y));let M;this._calculateNearFarZIfNeeded(b,y,t),M=new Float64Array(16),d.be(M,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),d.aB(this._invProjMatrix,M),M[8]=2*-t.x/this._helper._width,M[9]=2*t.y/this._helper._height,this._projectionMatrix=d.bf(M),d.Q(M,M,[1,-1,1]),d.O(M,M,[0,0,-this._helper.cameraToCenterDistance]),d.bg(M,M,-this.rollInRadians),d.bh(M,M,this.pitchInRadians),d.bg(M,M,-this.bearingInRadians),d.O(M,M,[-A,-h,0]),this._mercatorMatrix=d.Q([],M,[this.worldSize,this.worldSize,this.worldSize]),d.Q(M,M,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=d.S(new Float64Array(16),this.clipSpaceToPixelsMatrix,M),d.O(M,M,[0,0,-this.elevation]),this._viewProjMatrix=M,this._invViewProjMatrix=d.aB([],M);const I=[0,0,-1,1];d.aH(I,I,this._invViewProjMatrix),this._cameraPosition=[I[0]/I[3],I[1]/I[3],I[2]/I[3]],this._fogMatrix=new Float64Array(16),d.be(this._fogMatrix,this.fovInRadians,this.width/this.height,b,this._helper._farZ),this._fogMatrix[8]=2*-t.x/this.width,this._fogMatrix[9]=2*t.y/this.height,d.Q(this._fogMatrix,this._fogMatrix,[1,-1,1]),d.O(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),d.bg(this._fogMatrix,this._fogMatrix,-this.rollInRadians),d.bh(this._fogMatrix,this._fogMatrix,this.pitchInRadians),d.bg(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),d.O(this._fogMatrix,this._fogMatrix,[-A,-h,0]),d.Q(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),d.O(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=d.S(new Float64Array(16),this.clipSpaceToPixelsMatrix,M);const D=this._helper._width%2/2,B=this._helper._height%2/2,V=Math.cos(this.bearingInRadians),O=Math.sin(-this.bearingInRadians),U=A-Math.round(A)+V*D+O*B,X=h-Math.round(h)+V*B+O*D,ie=new Float64Array(M);if(d.O(ie,ie,[U>.5?U-1:U,X>.5?X-1:X,0]),this._alignedProjMatrix=ie,M=d.aB(new Float64Array(16),this._pixelMatrix),!M)throw new Error("failed to invert matrix");this._pixelMatrixInverse=M,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;const t=this.screenPointToMercatorCoordinate(new d.P(0,0)),n=[t.x*this.worldSize,t.y*this.worldSize,0,1];return d.aH(n,n,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){const t=d.as(1,this.center.lat)*this.worldSize;return Le(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/t).toLngLat()}lngLatToCameraDepth(t,n){const A=d.a9.fromLngLat(t),h=[A.x*this.worldSize,A.y*this.worldSize,n,1];return d.aH(h,h,this._viewProjMatrix),h[2]/h[3]}getProjectionData(t){const{overscaledTileID:n,aligned:A,applyTerrainMatrix:h}=t,y=this._helper.getMercatorTileCoordinates(n),b=n?this.calculatePosMatrix(n,A,!0):null;let M;return M=n&&n.terrainRttPosMatrix32f&&h?n.terrainRttPosMatrix32f:b||d.bi(),{mainMatrix:M,tileMercatorCoords:y,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:M}}isLocationOccluded(t){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(t,n,A){return 1}transformLightDirection(t){return d.b1(t)}getRayDirectionFromPixel(t){throw new Error("Not implemented.")}projectTileCoordinates(t,n,A,h){const y=this.calculatePosMatrix(A);let b;h?(b=[t,n,h(t,n),1],d.aH(b,b,y)):(b=[t,n,0,1],H(b,b,y));const M=b[3];return{point:new d.P(b[0]/M,b[1]/M),signedDistanceFromCamera:M,isOccluded:!1}}populateCache(t){for(const n of t)this.calculatePosMatrix(n)}getMatrixForModel(t,n){const A=d.a9.fromLngLat(t,n),h=A.meterInMercatorCoordinateUnits(),y=d.bj();return d.O(y,y,[A.x,A.y,A.z]),d.bg(y,y,Math.PI),d.bh(y,y,Math.PI/2),d.Q(y,y,[-h,h,h]),y}getProjectionDataForCustomLayer(t=!0){const n=new d.a2(0,0,0,0,0),A=this.getProjectionData({overscaledTileID:n,applyGlobeMatrix:t}),h=hr(n,this.worldSize);d.S(h,this._viewProjMatrix,h),A.tileMercatorCoords=[0,0,1,1];const y=[d.a5,d.a5,this.worldSize/this._helper.pixelsPerMeter],b=d.bk();return d.Q(b,h,y),A.fallbackMatrix=b,A.mainMatrix=b,A}getFastPathSimpleProjectionMatrix(t){return this.calculatePosMatrix(t)}}function ls(){d.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function sA(_){if(_.useSlerp)if(_.k<1){const t=d.bl(_.startEulerAngles.roll,_.startEulerAngles.pitch,_.startEulerAngles.bearing),n=d.bl(_.endEulerAngles.roll,_.endEulerAngles.pitch,_.endEulerAngles.bearing),A=new Float64Array(4);d.bm(A,t,n,_.k);const h=d.bn(A);_.tr.setRoll(h.roll),_.tr.setPitch(h.pitch),_.tr.setBearing(h.bearing)}else _.tr.setRoll(_.endEulerAngles.roll),_.tr.setPitch(_.endEulerAngles.pitch),_.tr.setBearing(_.endEulerAngles.bearing);else _.tr.setRoll(d.G.number(_.startEulerAngles.roll,_.endEulerAngles.roll,_.k)),_.tr.setPitch(d.G.number(_.startEulerAngles.pitch,_.endEulerAngles.pitch,_.k)),_.tr.setBearing(d.G.number(_.startEulerAngles.bearing,_.endEulerAngles.bearing,_.k))}function gi(_,t,n,A,h){const y=h.padding,b=Be(h.worldSize,n.getNorthWest()),M=Be(h.worldSize,n.getNorthEast()),I=Be(h.worldSize,n.getSouthEast()),D=Be(h.worldSize,n.getSouthWest()),B=d.ap(-A),V=b.rotate(B),O=M.rotate(B),U=I.rotate(B),X=D.rotate(B),ie=new d.P(Math.max(V.x,O.x,X.x,U.x),Math.max(V.y,O.y,X.y,U.y)),se=new d.P(Math.min(V.x,O.x,X.x,U.x),Math.min(V.y,O.y,X.y,U.y)),ne=ie.sub(se),ce=(h.width-(y.left+y.right+t.left+t.right))/ne.x,ge=(h.height-(y.top+y.bottom+t.top+t.bottom))/ne.y;if(ge<0||ce<0)return void ls();const Ae=Math.min(d.at(h.scale*Math.min(ce,ge)),_.maxZoom),de=d.P.convert(_.offset),ye=new d.P((t.left-t.right)/2,(t.top-t.bottom)/2).rotate(d.ap(A)),fe=de.add(ye).mult(h.scale/d.aq(Ae));return{center:Vt(h.worldSize,b.add(I).div(2).sub(fe)),zoom:Ae,bearing:A}}class dn{get useGlobeControls(){return!1}handlePanInertia(t,n){const A=t.mag(),h=Math.abs(gr(n));return{easingOffset:t.mult(Math.min(.75*h/A,1)),easingCenter:n.center}}handleMapControlsRollPitchBearingZoom(t,n){t.bearingDelta&&n.setBearing(n.bearing+t.bearingDelta),t.pitchDelta&&n.setPitch(n.pitch+t.pitchDelta),t.rollDelta&&n.setRoll(n.roll+t.rollDelta),t.zoomDelta&&n.setZoom(n.zoom+t.zoomDelta)}handleMapControlsPan(t,n,A){t.around.distSqr(n.centerPoint)<.01||n.setLocationAtPoint(A,t.around)}cameraForBoxAndBearing(t,n,A,h,y){return gi(t,n,A,h,y)}handleJumpToCenterZoom(t,n){t.zoom!==(n.zoom!==void 0?+n.zoom:t.zoom)&&t.setZoom(+n.zoom),n.center!==void 0&&t.setCenter(d.V.convert(n.center))}handleEaseTo(t,n){const A=t.zoom,h=t.padding,y={roll:t.roll,pitch:t.pitch,bearing:t.bearing},b={roll:n.roll===void 0?t.roll:n.roll,pitch:n.pitch===void 0?t.pitch:n.pitch,bearing:n.bearing===void 0?t.bearing:n.bearing},M=n.zoom!==void 0,I=!t.isPaddingEqual(n.padding);let D=!1;const B=M?+n.zoom:t.zoom;let V=t.centerPoint.add(n.offsetAsPoint);const O=t.screenPointToLocation(V),{center:U,zoom:X}=t.applyConstrain(d.V.convert(n.center||O),B??A);Hn(t,U);const ie=Be(t.worldSize,O),se=Be(t.worldSize,U).sub(ie),ne=d.aq(X-A);return D=X!==A,{easeFunc:ce=>{if(D&&t.setZoom(d.G.number(A,X,ce)),d.bo(y,b)||sA({startEulerAngles:y,endEulerAngles:b,tr:t,k:ce,useSlerp:y.roll!=b.roll}),I&&(t.interpolatePadding(h,n.padding,ce),V=t.centerPoint.add(n.offsetAsPoint)),n.around)t.setLocationAtPoint(n.around,n.aroundPoint);else{const ge=d.aq(t.zoom-A),Ae=X>A?Math.min(2,ne):Math.max(.5,ne),de=Math.pow(Ae,1-ce),ye=Vt(t.worldSize,ie.add(se.mult(ce*de)).mult(ge));t.setLocationAtPoint(t.renderWorldCopies?ye.wrap():ye,V)}},isZooming:D,elevationCenter:U}}handleFlyTo(t,n){const A=n.zoom!==void 0,h=t.zoom,y=t.applyConstrain(d.V.convert(n.center||n.locationAtOffset),A?+n.zoom:h),b=y.center,M=y.zoom;Hn(t,b);const I=Be(t.worldSize,n.locationAtOffset),D=Be(t.worldSize,b).sub(I),B=D.mag(),V=d.aq(M-h);let O;if(n.minZoom!==void 0){const U=Math.min(+n.minZoom,h,M),X=t.applyConstrain(b,U).zoom;O=d.aq(X-h)}return{easeFunc:(U,X,ie,se)=>{t.setZoom(U===1?M:h+d.at(X));const ne=U===1?b:Vt(t.worldSize,I.add(D.mult(ie)).mult(X));t.setLocationAtPoint(t.renderWorldCopies?ne.wrap():ne,se)},scaleOfZoom:V,targetCenter:b,scaleOfMinZoom:O,pixelPathLength:B}}}class rr{constructor(t,n,A){this.blendFunction=t,this.blendColor=n,this.mask=A}}rr.Replace=[1,0],rr.disabled=new rr(rr.Replace,d.bp.transparent,[!1,!1,!1,!1]),rr.unblended=new rr(rr.Replace,d.bp.transparent,[!0,!0,!0,!0]),rr.alphaBlended=new rr([1,771],d.bp.transparent,[!0,!0,!0,!0]);const Ds=2305;class or{constructor(t,n,A){this.enable=t,this.mode=n,this.frontFace=A}}or.disabled=new or(!1,1029,Ds),or.backCCW=new or(!0,1029,Ds),or.frontCCW=new or(!0,1028,Ds);class Zt{constructor(t,n,A){this.func=t,this.mask=n,this.range=A}}Zt.ReadOnly=!1,Zt.ReadWrite=!0,Zt.disabled=new Zt(519,Zt.ReadOnly,[0,1]);const Mo=7680;class ur{constructor(t,n,A,h,y,b){this.test=t,this.ref=n,this.mask=A,this.fail=h,this.depthFail=y,this.pass=b}}ur.disabled=new ur({func:519,mask:0},0,0,Mo,Mo,Mo);const pa=new WeakMap;function mn(_){var t;if(pa.has(_))return pa.get(_);{const n=(t=_.getParameter(_.VERSION))===null||t===void 0?void 0:t.startsWith("WebGL 2.0");return pa.set(_,n),n}}class As{get awaitingQuery(){return!!this._readbackQueue}constructor(t){this._readbackWaitFrames=4,this._measureWaitFrames=6,this._texWidth=1,this._texHeight=1,this._measuredError=0,this._updateCount=0,this._lastReadbackFrame=-1e3,this._readbackQueue=null,this._cachedRenderContext=t;const n=t.context,A=n.gl;this._texFormat=A.RGBA,this._texType=A.UNSIGNED_BYTE;const h=new d.aW;h.emplaceBack(-1,-1),h.emplaceBack(2,-1),h.emplaceBack(-1,2);const y=new d.aY;y.emplaceBack(0,1,2),this._fullscreenTriangle=new Er(n.createVertexBuffer(h,Is.members),n.createIndexBuffer(y),d.aX.simpleSegment(0,0,h.length,y.length)),this._resultBuffer=new Uint8Array(4),n.activeTexture.set(A.TEXTURE1);const b=A.createTexture();A.bindTexture(A.TEXTURE_2D,b),A.texParameteri(A.TEXTURE_2D,A.TEXTURE_WRAP_S,A.CLAMP_TO_EDGE),A.texParameteri(A.TEXTURE_2D,A.TEXTURE_WRAP_T,A.CLAMP_TO_EDGE),A.texParameteri(A.TEXTURE_2D,A.TEXTURE_MIN_FILTER,A.NEAREST),A.texParameteri(A.TEXTURE_2D,A.TEXTURE_MAG_FILTER,A.NEAREST),A.texImage2D(A.TEXTURE_2D,0,this._texFormat,this._texWidth,this._texHeight,0,this._texFormat,this._texType,null),this._fbo=n.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(b),mn(A)&&(this._pbo=A.createBuffer(),A.bindBuffer(A.PIXEL_PACK_BUFFER,this._pbo),A.bufferData(A.PIXEL_PACK_BUFFER,4,A.STREAM_READ),A.bindBuffer(A.PIXEL_PACK_BUFFER,null))}destroy(){const t=this._cachedRenderContext.context.gl;this._fullscreenTriangle.destroy(),this._fbo.destroy(),t.deleteBuffer(this._pbo),this._fullscreenTriangle=null,this._fbo=null,this._pbo=null,this._resultBuffer=null}updateErrorLoop(t,n){const A=this._updateCount;return this._readbackQueue?A>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():A>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(t,n),this._updateCount++,this._measuredError}_bindFramebuffer(){const t=this._cachedRenderContext.context,n=t.gl;t.activeTexture.set(n.TEXTURE1),n.bindTexture(n.TEXTURE_2D,this._fbo.colorAttachment.get()),t.bindFramebuffer.set(this._fbo.framebuffer)}_renderErrorTexture(t,n){const A=this._cachedRenderContext.context,h=A.gl;if(this._bindFramebuffer(),A.viewport.set([0,0,this._texWidth,this._texHeight]),A.clear({color:d.bp.transparent}),this._cachedRenderContext.useProgram("projectionErrorMeasurement").draw(A,h.TRIANGLES,Zt.disabled,ur.disabled,rr.unblended,or.disabled,((y,b)=>({u_input:y,u_output_expected:b}))(t,n),null,null,"$clipping",this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),this._pbo&&mn(h)){h.bindBuffer(h.PIXEL_PACK_BUFFER,this._pbo),h.readBuffer(h.COLOR_ATTACHMENT0),h.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),h.bindBuffer(h.PIXEL_PACK_BUFFER,null);const y=h.fenceSync(h.SYNC_GPU_COMMANDS_COMPLETE,0);h.flush(),this._readbackQueue={frameNumberIssued:this._updateCount,sync:y}}else this._readbackQueue={frameNumberIssued:this._updateCount,sync:null}}_tryReadback(){const t=this._cachedRenderContext.context.gl;if(this._pbo&&this._readbackQueue&&mn(t)){const n=t.clientWaitSync(this._readbackQueue.sync,0,0);if(n===t.WAIT_FAILED)return d.w("WebGL2 clientWaitSync failed."),this._readbackQueue=null,void(this._lastReadbackFrame=this._updateCount);if(n===t.TIMEOUT_EXPIRED)return;t.bindBuffer(t.PIXEL_PACK_BUFFER,this._pbo),t.getBufferSubData(t.PIXEL_PACK_BUFFER,0,this._resultBuffer,0,4),t.bindBuffer(t.PIXEL_PACK_BUFFER,null)}else this._bindFramebuffer(),t.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,this._resultBuffer);this._readbackQueue=null,this._measuredError=As._parseRGBA8float(this._resultBuffer),this._lastReadbackFrame=this._updateCount}static _parseRGBA8float(t){let n=0;return n+=t[0]/256,n+=t[1]/65536,n+=t[2]/16777216,t[3]<127&&(n=-n),n/128}}const nn=d.a5/128;function fl(_,t){const n=_.granularity!==void 0?Math.max(_.granularity,1):1,A=n+(_.generateBorders?2:0),h=n+(_.extendToNorthPole||_.generateBorders?1:0)+(_.extendToSouthPole||_.generateBorders?1:0),y=A+1,b=h+1,M=_.generateBorders?-1:0,I=_.generateBorders||_.extendToNorthPole?-1:0,D=n+(_.generateBorders?1:0),B=n+(_.generateBorders||_.extendToSouthPole?1:0),V=y*b,O=A*h*6,U=y*b>65536;if(U&&t==="16bit")throw new Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");const X=U||t==="32bit",ie=new Int16Array(2*V);let se=0;for(let ge=I;ge<=B;ge++)for(let Ae=M;Ae<=D;Ae++){let de=Ae/n*d.a5;Ae===-1&&(de=-nn),Ae===n+1&&(de=d.a5+nn);let ye=ge/n*d.a5;ge===-1&&(ye=_.extendToNorthPole?d.br:-nn),ge===n+1&&(ye=_.extendToSouthPole?d.bs:d.a5+nn),ie[se++]=de,ie[se++]=ye}const ne=X?new Uint32Array(O):new Uint16Array(O);let ce=0;for(let ge=0;ge<h;ge++)for(let Ae=0;Ae<A;Ae++){const de=Ae+1+ge*y,ye=Ae+(ge+1)*y,fe=Ae+1+(ge+1)*y;ne[ce++]=Ae+ge*y,ne[ce++]=ye,ne[ce++]=de,ne[ce++]=de,ne[ce++]=ye,ne[ce++]=fe}return{vertices:ie.buffer.slice(0),indices:ne.buffer.slice(0),uses32bitIndices:X}}const Eo=new d.aV({fill:new d.bt(128,2),line:new d.bt(512,0),tile:new d.bt(128,32),stencil:new d.bt(128,1),circle:3});class Io{constructor(){this._tileMeshCache={},this._errorCorrectionUsable=0,this._errorMeasurementLastValue=0,this._errorCorrectionPreviousValue=0,this._errorMeasurementLastChangeTime=-1e3}get name(){return"vertical-perspective"}get transitionState(){return 1}get useSubdivision(){return!0}get shaderVariantName(){return"globe"}get shaderDefine(){return"#define GLOBE"}get shaderPreludeCode(){return Cr.projectionGlobe}get vertexShaderPreludeCode(){return Cr.projectionMercator.vertexSource}get subdivisionGranularity(){return Eo}get useGlobeControls(){return!0}get latitudeErrorCorrectionRadians(){return this._errorCorrectionUsable}destroy(){this._errorMeasurement&&this._errorMeasurement.destroy()}updateGPUdependent(t){this._errorMeasurement||(this._errorMeasurement=new As(t));const n=d.X(this._errorQueryLatitudeDegrees),A=2*Math.atan(Math.exp(Math.PI-n*Math.PI*2))-.5*Math.PI,h=this._errorMeasurement.updateErrorLoop(n,A),y=Ar();h!==this._errorMeasurementLastValue&&(this._errorCorrectionPreviousValue=this._errorCorrectionUsable,this._errorMeasurementLastValue=h,this._errorMeasurementLastChangeTime=y);const b=Math.min(Math.max((y-this._errorMeasurementLastChangeTime)/1e3/.5,0),1);this._errorCorrectionUsable=d.bu(this._errorCorrectionPreviousValue,-this._errorMeasurementLastValue,d.bv(b))}_getMeshKey(t){return`${t.granularity.toString(36)}_${t.generateBorders?"b":""}${t.extendToNorthPole?"n":""}${t.extendToSouthPole?"s":""}`}getMeshFromTileID(t,n,A,h,y){const b=(y==="stencil"?Eo.stencil:Eo.tile).getGranularityForZoomLevel(n.z);return this._getMesh(t,{granularity:b,generateBorders:A,extendToNorthPole:n.y===0&&h,extendToSouthPole:n.y===(1<<n.z)-1&&h})}_getMesh(t,n){const A=this._getMeshKey(n);if(A in this._tileMeshCache)return this._tileMeshCache[A];const h=(function(y,b){const M=fl(b,"16bit"),I=d.aW.deserialize({arrayBuffer:M.vertices,length:M.vertices.byteLength/2/2}),D=d.aY.deserialize({arrayBuffer:M.indices,length:M.indices.byteLength/2/3});return new Er(y.createVertexBuffer(I,Is.members),y.createIndexBuffer(D),d.aX.simpleSegment(0,0,I.length,D.length))})(t,n);return this._tileMeshCache[A]=h,h}recalculate(t){}hasTransition(){const t=Ar();let n=!1;return n=n||(t-this._errorMeasurementLastChangeTime)/1e3<.7,n=n||this._errorMeasurement&&this._errorMeasurement.awaitingQuery,n}setErrorQueryLatitudeDegrees(t){this._errorQueryLatitudeDegrees=t}}const to=new d.t({type:new d.D(d.u.projection.type)});class us extends d.E{constructor(t){super(),this._transitionable=new d.x(to,void 0),this.setProjection(t),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new d.H(0)),this._mercatorProjection=new $i,this._verticalPerspectiveProjection=new Io}get transitionState(){const t=this.properties.get("type");if(typeof t=="string"&&t==="mercator")return 0;if(typeof t=="string"&&t==="vertical-perspective")return 1;if(t instanceof d.bw){if(t.from==="vertical-perspective"&&t.to==="mercator")return 1-t.transition;if(t.from==="mercator"&&t.to==="vertical-perspective")return t.transition}return 1}get useGlobeRendering(){return this.transitionState>0}get latitudeErrorCorrectionRadians(){return this._verticalPerspectiveProjection.latitudeErrorCorrectionRadians}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return"globe"}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy()}updateGPUdependent(t){this._mercatorProjection.updateGPUdependent(t),this._verticalPerspectiveProjection.updateGPUdependent(t)}getMeshFromTileID(t,n,A,h,y){return this.currentProjection.getMeshFromTileID(t,n,A,h,y)}setProjection(t){this._transitionable.setValue("type",(t==null?void 0:t.type)||"mercator")}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}setErrorQueryLatitudeDegrees(t){this._verticalPerspectiveProjection.setErrorQueryLatitudeDegrees(t),this._mercatorProjection.setErrorQueryLatitudeDegrees(t)}}function ki(_){const t=ro(_.worldSize,_.center.lat);return 2*Math.PI*t}function Vn(_,t,n,A,h){const y=1/(1<<h),b=t/d.a5*y+A*y,M=d.by((_/d.a5*y+n*y)*Math.PI*2+Math.PI,2*Math.PI),I=2*Math.atan(Math.exp(Math.PI-b*Math.PI*2))-.5*Math.PI,D=Math.cos(I),B=new Float64Array(3);return B[0]=Math.sin(M)*D,B[1]=Math.sin(I),B[2]=Math.cos(M)*D,B}function Sr(_){return(function(t,n){const A=Math.cos(n),h=new Float64Array(3);return h[0]=Math.sin(t)*A,h[1]=Math.sin(n),h[2]=Math.cos(t)*A,h})(_.lng*Math.PI/180,_.lat*Math.PI/180)}function ro(_,t){return _/(2*Math.PI)/Math.cos(t*Math.PI/180)}function dl(_){const t=Math.asin(_[1])/Math.PI*180,n=Math.sqrt(_[0]*_[0]+_[2]*_[2]);if(n>1e-6){const A=_[0]/n,h=Math.acos(_[2]/n),y=(A>0?h:-h)/Math.PI*180;return new d.V(d.W(y,-180,180),t)}return new d.V(0,t)}function So(_){return Math.cos(_*Math.PI/180)}function $r(_,t){const n=So(_),A=So(t);return d.at(A/n)}function oA(_,t){const n=_.rotate(t.bearingInRadians),A=t.zoom+$r(t.center.lat,0),h=d.bu(1/So(t.center.lat),1/So(Math.min(Math.abs(t.center.lat),60)),d.bx(A,7,3,0,1)),y=360/ki({worldSize:t.worldSize,center:{lat:t.center.lat}});return new d.V(t.center.lng-n.x*y*h,d.an(t.center.lat+n.y*y,-d.ao,d.ao))}function ml(_){const t=.5*_,n=Math.sin(t),A=Math.cos(t);return Math.log(n+A)-Math.log(A-n)}function aA(_,t,n,A){const h=_.lat+n*A;if(Math.abs(n)>1){const y=(Math.sign(_.lat+n)!==Math.sign(_.lat)?-Math.abs(_.lat):Math.abs(_.lat))*Math.PI/180,b=Math.abs(_.lat+n)*Math.PI/180,M=ml(y+A*(b-y)),I=ml(y),D=ml(b);return new d.V(_.lng+t*((M-I)/(D-I)),h)}return new d.V(_.lng+t*A,h)}class ou{constructor(t){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._boundingVolumeFactory=t}swapBuffers(){if(!this._hadAnyChanges)return;const t=this._cachePrevious;this._cachePrevious=this._cache,this._cache=t,this._cache.clear(),this._hadAnyChanges=!1}getTileBoundingVolume(t,n,A,h){const y=`${t.z}_${t.x}_${t.y}_${h!=null&&h.terrain?"t":""}`,b=this._cache.get(y);if(b)return b;const M=this._cachePrevious.get(y);if(M)return this._cache.set(y,M),M;const I=this._boundingVolumeFactory(t,n,A,h);return this._cache.set(y,I),this._hadAnyChanges=!0,I}}class io{constructor(t,n,A,h){this.min=A,this.max=h,this.points=t,this.planes=n}static fromAabb(t,n){const A=[];for(let h=0;h<8;h++)A.push([1&~h?t[0]:n[0],(h>>1&1)==1?n[1]:t[1],(h>>2&1)==1?n[2]:t[2]]);return new io(A,[[-1,0,0,n[0]],[1,0,0,-t[0]],[0,-1,0,n[1]],[0,1,0,-t[1]],[0,0,-1,n[2]],[0,0,1,-t[2]]],t,n)}static fromCenterSizeAngles(t,n,A){const h=d.bB([],A[0],A[1],A[2]),y=d.bC([],[n[0],0,0],h),b=d.bC([],[0,n[1],0],h),M=d.bC([],[0,0,n[2]],h),I=[...t],D=[...t];for(let V=0;V<8;V++)for(let O=0;O<3;O++){const U=t[O]+y[O]*(1&~V?-1:1)+b[O]*((V>>1&1)==1?1:-1)+M[O]*((V>>2&1)==1?1:-1);I[O]=Math.min(I[O],U),D[O]=Math.max(D[O],U)}const B=[];for(let V=0;V<8;V++){const O=[...t];d.b0(O,O,d.a$([],y,1&~V?-1:1)),d.b0(O,O,d.a$([],b,(V>>1&1)==1?1:-1)),d.b0(O,O,d.a$([],M,(V>>2&1)==1?1:-1)),B.push(O)}return new io(B,[[...y,-d.b5(y,B[0])],[...b,-d.b5(b,B[0])],[...M,-d.b5(M,B[0])],[-y[0],-y[1],-y[2],-d.b5(y,B[7])],[-b[0],-b[1],-b[2],-d.b5(b,B[7])],[-M[0],-M[1],-M[2],-d.b5(M,B[7])]],I,D)}intersectsFrustum(t){let n=!0;const A=this.points.length,h=this.planes.length,y=t.planes.length,b=t.points.length;for(let M=0;M<y;M++){const I=t.planes[M];let D=0;for(let B=0;B<A;B++){const V=this.points[B];I[0]*V[0]+I[1]*V[1]+I[2]*V[2]+I[3]>=0&&D++}if(D===0)return 0;D<A&&(n=!1)}if(n)return 2;for(let M=0;M<h;M++){const I=this.planes[M];let D=0;for(let B=0;B<b;B++){const V=t.points[B];I[0]*V[0]+I[1]*V[1]+I[2]*V[2]+I[3]>=0&&D++}if(D===0)return 0}return 1}intersectsPlane(t){const n=this.points.length;let A=0;for(let h=0;h<n;h++){const y=this.points[h];t[0]*y[0]+t[1]*y[1]+t[2]*y[2]+t[3]>=0&&A++}return A===n?2:A===0?0:1}}function Oa(_,t,n){const A=_-t;return A<0?-A:Math.max(0,A-n)}function Co(_,t,n,A,h){const y=_-n;let b;return b=y<0?Math.min(-y,1+y-h):y>1?Math.min(Math.max(y-h,0),1-y):0,Math.max(b,Oa(t,A,h))}class Do{constructor(){this._boundingVolumeCache=new ou(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(t,n,A,h){const y=1<<A.z,b=1/y,M=A.x/y,I=A.y/y;let D=2;return D=Math.min(D,Co(t,n,M,I,b)),D=Math.min(D,Co(t,n,M+.5,-I-b,b)),D=Math.min(D,Co(t,n,M+.5,2-I-b,b)),D}getWrap(t,n,A){const h=1<<n.z,y=1/h,b=n.x/h,M=Oa(t.x,b,y),I=Oa(t.x,b-1,y),D=Oa(t.x,b+1,y),B=Math.min(M,I,D);return B===D?1:B===I?-1:0}allowVariableZoom(t,n){return Pr(t,n)>4}allowWorldCopies(){return!1}getTileBoundingVolume(t,n,A,h){return this._boundingVolumeCache.getTileBoundingVolume(t,n,A,h)}_computeTileBoundingVolume(t,n,A,h){var y,b;let M=0,I=0;if(h!=null&&h.terrain){const D=new d.a2(t.z,n,t.z,t.x,t.y),B=h.terrain.getMinMaxElevation(D);M=(y=B.minElevation)!==null&&y!==void 0?y:Math.min(0,A),I=(b=B.maxElevation)!==null&&b!==void 0?b:Math.max(0,A)}if(M/=d.bE,I/=d.bE,M+=1,I+=1,t.z<=0)return io.fromAabb([-I,-I,-I],[I,I,I]);if(t.z===1)return io.fromAabb([t.x===0?-I:0,t.y===0?0:-I,-I],[t.x===0?0:I,t.y===0?I:0,I]);{const D=[Vn(0,0,t.x,t.y,t.z),Vn(d.a5,0,t.x,t.y,t.z),Vn(d.a5,d.a5,t.x,t.y,t.z),Vn(0,d.a5,t.x,t.y,t.z)],B=[];for(const Oe of D)B.push(d.a$([],Oe,I));if(I!==M)for(const Oe of D)B.push(d.a$([],Oe,M));t.y===0&&B.push([0,1,0]),t.y===(1<<t.z)-1&&B.push([0,-1,0]);const V=[1,1,1],O=[-1,-1,-1];for(const Oe of B)for(let Ve=0;Ve<3;Ve++)V[Ve]=Math.min(V[Ve],Oe[Ve]),O[Ve]=Math.max(O[Ve],Oe[Ve]);const U=Vn(d.a5/2,d.a5/2,t.x,t.y,t.z),X=d.b4([],[0,1,0],U);d.b3(X,X);const ie=d.b4([],U,X);d.b3(ie,ie);const se=d.b4([],D[2],D[1]);d.b3(se,se);const ne=d.b4([],D[0],D[3]);d.b3(ne,ne),B.push(d.a$([],U,I)),t.y>=(1<<t.z)/2&&B.push(d.a$([],Vn(d.a5/2,0,t.x,t.y,t.z),I)),t.y<(1<<t.z)/2&&B.push(d.a$([],Vn(d.a5/2,d.a5,t.x,t.y,t.z),I));const ce=fa(U,B),ge=fa(ie,B),Ae=[-U[0],-U[1],-U[2],ce.max],de=[U[0],U[1],U[2],-ce.min],ye=[-ie[0],-ie[1],-ie[2],ge.max],fe=[ie[0],ie[1],ie[2],-ge.min],Me=[...se,0],Ge=[...ne,0],Fe=[];return t.y===0?Fe.push(d.bD(Ge,Me,Ae),d.bD(Ge,Me,de)):Fe.push(d.bD(ye,Me,Ae),d.bD(ye,Me,de),d.bD(ye,Ge,Ae),d.bD(ye,Ge,de)),t.y===(1<<t.z)-1?Fe.push(d.bD(Ge,Me,Ae),d.bD(Ge,Me,de)):Fe.push(d.bD(fe,Me,Ae),d.bD(fe,Me,de),d.bD(fe,Ge,Ae),d.bD(fe,Ge,de)),new io(Fe,[Ae,de,ye,fe,Me,Ge],V,O)}}}function fa(_,t){let n=1/0,A=-1/0;for(const h of t){const y=d.b5(_,h);n=Math.min(n,y),A=Math.max(A,y)}return{min:n,max:A}}class ko{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,n,A){return this._helper.interpolatePadding(t,n,A)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,n){this._helper.resize(t,n)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}setConstrainOverride(t){this._helper.setConstrainOverride(t)}overrideNearFarZ(t,n){this._helper.overrideNearFarZ(t,n)}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=d.bF(),this._projectionMatrix=d.bj(),this._globeViewProjMatrix32f=d.bi(),this._globeViewProjMatrixNoCorrection=d.bj(),this._globeViewProjMatrixNoCorrectionInverted=d.bj(),this._globeProjMatrixInverted=d.bj(),this._cameraPosition=d.bz(),this._globeLatitudeErrorCorrectionRadians=0,this.defaultConstrain=(n,A)=>{const h=d.an(n.lat,-d.ao,d.ao),y=d.an(+A,this.minZoom+$r(0,h),this.maxZoom);return{center:new d.V(n.lng,h),zoom:y}},this.applyConstrain=(n,A)=>this._helper.applyConstrain(n,A),this._helper=new Cs({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(n,A)=>this.defaultConstrain(n,A)},t),this._coveringTilesDetailsProvider=new Do}clone(){const t=new ko;return t.apply(this,!1),t}apply(t,n,A){this._globeLatitudeErrorCorrectionRadians=A||0,this._helper.apply(t,n)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){const t=d.bz();return t[0]=this._cameraPosition[0],t[1]=this._cameraPosition[1],t[2]=this._cameraPosition[2],t}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(t){const{overscaledTileID:n,applyGlobeMatrix:A}=t,h=this._helper.getMercatorTileCoordinates(n);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:h,clippingPlane:this._cachedClippingPlane,projectionTransition:A?1:0,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(t){const n=this.pitchInRadians,A=this.cameraToCenterDistance/t,h=Math.sin(n)*A,y=Math.cos(n)*A+1,b=1/Math.sqrt(h*h+y*y)*1;let M=-h,I=y;const D=Math.sqrt(M*M+I*I);M/=D,I/=D;const B=[0,M,I];d.bG(B,B,[0,0,0],-this.bearingInRadians),d.bH(B,B,[0,0,0],-1*this.center.lat*Math.PI/180),d.bI(B,B,[0,0,0],this.center.lng*Math.PI/180);const V=1/d.b7(B);return d.a$(B,B,V),[...B,-b*V]}isLocationOccluded(t){return!this.isSurfacePointVisible(Sr(t))}transformLightDirection(t){const n=this._helper._center.lng*Math.PI/180,A=this._helper._center.lat*Math.PI/180,h=Math.cos(A),y=[Math.sin(n)*h,Math.sin(A),Math.cos(n)*h],b=[y[2],0,-y[0]],M=[0,0,0];d.b4(M,b,y),d.b3(b,b),d.b3(M,M);const I=[0,0,0];return d.b3(I,[b[0]*t[0]+M[0]*t[1]+y[0]*t[2],b[1]*t[0]+M[1]*t[1]+y[1]*t[2],b[2]*t[0]+M[2]*t[1]+y[2]*t[2]]),I}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,n,A){const h=(function(M,I,D){const B=1/(1<<D.z);return new d.a9(M/d.a5*B+D.x*B,I/d.a5*B+D.y*B)})(t,n,A.canonical),y=(b=h.y,[d.by(h.x*Math.PI*2+Math.PI,2*Math.PI),2*Math.atan(Math.exp(Math.PI-b*Math.PI*2))-.5*Math.PI]);var b;return this.getCircleRadiusCorrection()/Math.cos(y[1])}projectTileCoordinates(t,n,A,h){const y=A.canonical,b=Vn(t,n,y.x,y.y,y.z),M=1+(h?h(t,n):0)/d.bE,I=[b[0]*M,b[1]*M,b[2]*M,1];d.aH(I,I,this._globeViewProjMatrixNoCorrection);const D=this._cachedClippingPlane,B=D[0]*b[0]+D[1]*b[1]+D[2]*b[2]+D[3]<0;return{point:new d.P(I[0]/I[3],I[1]/I[3]),signedDistanceFromCamera:I[3],isOccluded:B}}_calcMatrices(){if(!this._helper._width||!this._helper._height)return;const t=ro(this.worldSize,this.center.lat),n=d.bk(),A=d.bk();this._helper.autoCalculateNearFarZ&&(this._helper._nearZ=.5,this._helper._farZ=this.cameraToCenterDistance+2*t),d.be(n,this.fovInRadians,this.width/this.height,this._helper._nearZ,this._helper._farZ);const h=this.centerOffset;n[8]=2*-h.x/this._helper._width,n[9]=2*h.y/this._helper._height,this._projectionMatrix=d.bf(n),this._globeProjMatrixInverted=d.bk(),d.aB(this._globeProjMatrixInverted,n),d.O(n,n,[0,0,-this.cameraToCenterDistance]),d.bg(n,n,this.rollInRadians),d.bh(n,n,-this.pitchInRadians),d.bg(n,n,this.bearingInRadians),d.O(n,n,[0,0,-t]);const y=d.bz();y[0]=t,y[1]=t,y[2]=t,d.bh(A,n,this.center.lat*Math.PI/180),d.bJ(A,A,-this.center.lng*Math.PI/180),d.Q(A,A,y),this._globeViewProjMatrixNoCorrection=A,d.bh(n,n,this.center.lat*Math.PI/180-this._globeLatitudeErrorCorrectionRadians),d.bJ(n,n,-this.center.lng*Math.PI/180),d.Q(n,n,y),this._globeViewProjMatrix32f=new Float32Array(n),this._globeViewProjMatrixNoCorrectionInverted=d.bk(),d.aB(this._globeViewProjMatrixNoCorrectionInverted,A);const b=d.bz();this._cameraPosition=d.bz(),this._cameraPosition[2]=this.cameraToCenterDistance/t,d.bG(this._cameraPosition,this._cameraPosition,b,-this.rollInRadians),d.bH(this._cameraPosition,this._cameraPosition,b,this.pitchInRadians),d.bG(this._cameraPosition,this._cameraPosition,b,-this.bearingInRadians),d.b0(this._cameraPosition,this._cameraPosition,[0,0,1]),d.bH(this._cameraPosition,this._cameraPosition,b,-this.center.lat*Math.PI/180),d.bI(this._cameraPosition,this._cameraPosition,b,this.center.lng*Math.PI/180),this._cachedClippingPlane=this._computeClippingPlane(t);const M=d.bf(this._globeViewProjMatrixNoCorrectionInverted);d.Q(M,M,[1,1,-1]),this._cachedFrustum=rn.fromInvProjectionMatrix(M,1,0,this._cachedClippingPlane,!0)}calculateFogMatrix(t){d.w("calculateFogMatrix is not supported on globe projection.");const n=d.bk();return d.ar(n),n}getVisibleUnwrappedCoordinates(t){return[new d.bc(0,t)]}getCameraFrustum(){return this._cachedFrustum}getClippingPlane(){return this._cachedClippingPlane}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(t){t&&d.w("terrain is not fully supported on vertical perspective projection."),this._helper.recalculateZoomAndCenter(0)}maxPitchScaleFactor(){return 1}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(t,n){if(!this._globeViewProjMatrixNoCorrection)return 1;const A=Sr(t);d.a$(A,A,1+n/d.bE);const h=d.bF();return d.aH(h,[A[0],A[1],A[2],1],this._globeViewProjMatrixNoCorrection),h[2]/h[3]}populateCache(t){}getBounds(){const t=.5*this.width,n=.5*this.height,A=[new d.P(0,0),new d.P(t,0),new d.P(this.width,0),new d.P(this.width,n),new d.P(this.width,this.height),new d.P(t,this.height),new d.P(0,this.height),new d.P(0,n)],h=[];for(const V of A)h.push(this.unprojectScreenPoint(V));let y=0,b=0,M=0,I=0;const D=this.center;for(const V of h){const O=d.bK(D.lng,V.lng),U=d.bK(D.lat,V.lat);O<b&&(b=O),O>y&&(y=O),U<I&&(I=U),U>M&&(M=U)}const B=[D.lng+b,D.lat+I,D.lng+y,D.lat+M];return this.isSurfacePointOnScreen([0,1,0])&&(B[3]=90,B[0]=-180,B[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(B[1]=-90,B[0]=-180,B[2]=180),new xr(B)}calculateCenterFromCameraLngLatAlt(t,n,A,h){return this._helper.calculateCenterFromCameraLngLatAlt(t,n,A,h)}setLocationAtPoint(t,n){const A=Sr(this.unprojectScreenPoint(n)),h=Sr(t),y=d.bz();d.bL(y);const b=d.bz();d.bI(b,A,y,-this.center.lng*Math.PI/180),d.bH(b,b,y,this.center.lat*Math.PI/180);const M=h[0]*h[0]+h[2]*h[2],I=b[0]*b[0];if(M<I)return;const D=Math.sqrt(M-I),B=-D,V=d.bM(h[0],h[2],b[0],D),O=d.bM(h[0],h[2],b[0],B),U=d.bz();d.bI(U,h,y,-V);const X=d.bM(U[1],U[2],b[1],b[2]),ie=d.bz();d.bI(ie,h,y,-O);const se=d.bM(ie[1],ie[2],b[1],b[2]),ne=.5*Math.PI,ce=X>=-ne&&X<=ne,ge=se>=-ne&&se<=ne;let Ae,de;if(ce&&ge){const Ge=this.center.lng*Math.PI/180,Fe=this.center.lat*Math.PI/180;d.bN(V,Ge)+d.bN(X,Fe)<d.bN(O,Ge)+d.bN(se,Fe)?(Ae=V,de=X):(Ae=O,de=se)}else if(ce)Ae=V,de=X;else{if(!ge)return;Ae=O,de=se}const ye=Ae/Math.PI*180,fe=de/Math.PI*180,Me=this.center.lat;this.setCenter(new d.V(ye,d.an(fe,-90,90))),this.setZoom(this.zoom+$r(Me,this.center.lat))}locationToScreenPoint(t,n){const A=Sr(t);if(n){const h=n.getElevationForLngLatZoom(t,this._helper._tileZoom);d.a$(A,A,1+h/d.bE)}return this._projectSurfacePointToScreen(A)}_projectSurfacePointToScreen(t){const n=d.bF();return d.aH(n,[...t,1],this._globeViewProjMatrixNoCorrection),n[0]/=n[3],n[1]/=n[3],new d.P((.5*n[0]+.5)*this.width,(.5*-n[1]+.5)*this.height)}screenPointToMercatorCoordinate(t,n){if(n){const A=n.pointCoordinate(t);if(A)return A}return d.a9.fromLngLat(this.unprojectScreenPoint(t))}screenPointToLocation(t,n){var A;return(A=this.screenPointToMercatorCoordinate(t,n))===null||A===void 0?void 0:A.toLngLat()}isPointOnMapSurface(t,n){const A=this._cameraPosition,h=this.getRayDirectionFromPixel(t);return!!this.rayPlanetIntersection(A,h)}getRayDirectionFromPixel(t){const n=d.bF();n[0]=t.x/this.width*2-1,n[1]=-1*(t.y/this.height*2-1),n[2]=1,n[3]=1,d.aH(n,n,this._globeViewProjMatrixNoCorrectionInverted),n[0]/=n[3],n[1]/=n[3],n[2]/=n[3];const A=d.bz();A[0]=n[0]-this._cameraPosition[0],A[1]=n[1]-this._cameraPosition[1],A[2]=n[2]-this._cameraPosition[2];const h=d.bz();return d.b3(h,A),h}isSurfacePointVisible(t){const n=this._cachedClippingPlane;return n[0]*t[0]+n[1]*t[1]+n[2]*t[2]+n[3]>=0}isSurfacePointOnScreen(t){if(!this.isSurfacePointVisible(t))return!1;const n=d.bF();return d.aH(n,[...t,1],this._globeViewProjMatrixNoCorrection),n[0]/=n[3],n[1]/=n[3],n[2]/=n[3],n[0]>-1&&n[0]<1&&n[1]>-1&&n[1]<1&&n[2]>-1&&n[2]<1}rayPlanetIntersection(t,n){const A=d.b5(t,n),h=d.bz(),y=d.bz();d.a$(y,n,A),d.b2(h,t,y);const b=1-d.b5(h,h);if(b<0)return null;const M=d.b5(t,t)-1,I=-A+(A<0?1:-1)*Math.sqrt(b),D=M/I,B=I;return{tMin:Math.min(D,B),tMax:Math.max(D,B)}}unprojectScreenPoint(t){const n=this._cameraPosition,A=this.getRayDirectionFromPixel(t),h=this.rayPlanetIntersection(n,A);if(h){const B=d.bz();d.b0(B,n,[A[0]*h.tMin,A[1]*h.tMin,A[2]*h.tMin]);const V=d.bz();return d.b3(V,B),dl(V)}const y=this._cachedClippingPlane,b=y[0]*A[0]+y[1]*A[1]+y[2]*A[2],M=-d.bb(y,n)/b,I=d.bz();if(M>0)d.b0(I,n,[A[0]*M,A[1]*M,A[2]*M]);else{const B=d.bz();d.b0(B,n,[2*A[0],2*A[1],2*A[2]]);const V=d.bb(this._cachedClippingPlane,B);d.b2(I,B,[this._cachedClippingPlane[0]*V,this._cachedClippingPlane[1]*V,this._cachedClippingPlane[2]*V])}const D=(function(B){const V=d.bz();return V[0]=B[0]*-B[3],V[1]=B[1]*-B[3],V[2]=B[2]*-B[3],{center:V,radius:Math.sqrt(1-B[3]*B[3])}})(y);return dl((function(B,V,O){const U=d.bz();d.b2(U,O,B);const X=d.bz();return d.bA(X,B,U,V/d.b9(U)),X})(D.center,D.radius,I))}getMatrixForModel(t,n){const A=d.V.convert(t),h=1/d.bE,y=d.bj();return d.bJ(y,y,A.lng/180*Math.PI),d.bh(y,y,-A.lat/180*Math.PI),d.O(y,y,[0,0,1+n/d.bE]),d.bh(y,y,.5*Math.PI),d.Q(y,y,[h,h,h]),y}getProjectionDataForCustomLayer(t=!0){const n=this.getProjectionData({overscaledTileID:new d.a2(0,0,0,0,0),applyGlobeMatrix:t});return n.tileMercatorCoords=[0,0,1,1],n}getFastPathSimpleProjectionMatrix(t){}}class zo{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,n,A){return this._helper.interpolatePadding(t,n,A)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,n,A=!0){this._helper.resize(t,n,A)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}setConstrainOverride(t){this._helper.setConstrainOverride(t)}overrideNearFarZ(t,n){this._helper.overrideNearFarZ(t,n)}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,n){this._globeness=t,this._globeLatitudeErrorCorrectionRadians=n,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().prepareNextFrame(),this._mercatorTransform.getCoveringTilesDetailsProvider().prepareNextFrame()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(t){this._globeLatitudeErrorCorrectionRadians=0,this._globeness=1,this.defaultConstrain=(n,A)=>this.currentTransform.defaultConstrain(n,A),this.applyConstrain=(n,A)=>this._helper.applyConstrain(n,A),this._helper=new Cs({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(n,A)=>this.defaultConstrain(n,A)},t),this._globeness=1,this._mercatorTransform=new eo,this._verticalPerspectiveTransform=new ko}clone(){const t=new zo;return t._globeness=this._globeness,t._globeLatitudeErrorCorrectionRadians=this._globeLatitudeErrorCorrectionRadians,t.apply(this,!1),t}apply(t,n){this._helper.apply(t,n),this._mercatorTransform.apply(this,!1),this._verticalPerspectiveTransform.apply(this,!1,this._globeLatitudeErrorCorrectionRadians)}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(t){const n=this._mercatorTransform.getProjectionData(t),A=this._verticalPerspectiveTransform.getProjectionData(t);return{mainMatrix:this.isGlobeRendering?A.mainMatrix:n.mainMatrix,clippingPlane:A.clippingPlane,tileMercatorCoords:A.tileMercatorCoords,projectionTransition:t.applyGlobeMatrix?this._globeness:0,fallbackMatrix:n.fallbackMatrix}}isLocationOccluded(t){return this.currentTransform.isLocationOccluded(t)}transformLightDirection(t){return this.currentTransform.transformLightDirection(t)}getPixelScale(){return d.bu(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return d.bu(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(t,n,A){const h=this._mercatorTransform.getPitchedTextCorrection(t,n,A),y=this._verticalPerspectiveTransform.getPitchedTextCorrection(t,n,A);return d.bu(h,y,this._globeness)}projectTileCoordinates(t,n,A,h){return this.currentTransform.projectTileCoordinates(t,n,A,h)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform.apply(this,!1,this._globeLatitudeErrorCorrectionRadians),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ)}calculateFogMatrix(t){return this.currentTransform.calculateFogMatrix(t)}getVisibleUnwrappedCoordinates(t){return this.currentTransform.getVisibleUnwrappedCoordinates(t)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(t){this._mercatorTransform.recalculateZoomAndCenter(t),this._verticalPerspectiveTransform.recalculateZoomAndCenter(t)}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(t,n){return this.currentTransform.lngLatToCameraDepth(t,n)}populateCache(t){this._mercatorTransform.populateCache(t),this._verticalPerspectiveTransform.populateCache(t)}getBounds(){return this.currentTransform.getBounds()}calculateCenterFromCameraLngLatAlt(t,n,A,h){return this._helper.calculateCenterFromCameraLngLatAlt(t,n,A,h)}setLocationAtPoint(t,n){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(t,n),void this.apply(this._mercatorTransform,!1);this._verticalPerspectiveTransform.setLocationAtPoint(t,n),this.apply(this._verticalPerspectiveTransform,!1)}locationToScreenPoint(t,n){return this.currentTransform.locationToScreenPoint(t,n)}screenPointToMercatorCoordinate(t,n){return this.currentTransform.screenPointToMercatorCoordinate(t,n)}screenPointToLocation(t,n){return this.currentTransform.screenPointToLocation(t,n)}isPointOnMapSurface(t,n){return this.currentTransform.isPointOnMapSurface(t,n)}getRayDirectionFromPixel(t){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(t)}getMatrixForModel(t,n){return this.currentTransform.getMatrixForModel(t,n)}getProjectionDataForCustomLayer(t=!0){const n=this._mercatorTransform.getProjectionDataForCustomLayer(t);if(!this.isGlobeRendering)return n;const A=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(t);return A.fallbackMatrix=n.mainMatrix,A}getFastPathSimpleProjectionMatrix(t){return this.currentTransform.getFastPathSimpleProjectionMatrix(t)}}class Nr{get useGlobeControls(){return!0}handlePanInertia(t,n){const A=oA(t,n);return Math.abs(A.lng-n.center.lng)>180&&(A.lng=n.center.lng+179.5*Math.sign(A.lng-n.center.lng)),{easingCenter:A,easingOffset:new d.P(0,0)}}handleMapControlsRollPitchBearingZoom(t,n){const A=t.around,h=n.screenPointToLocation(A);t.bearingDelta&&n.setBearing(n.bearing+t.bearingDelta),t.pitchDelta&&n.setPitch(n.pitch+t.pitchDelta),t.rollDelta&&n.setRoll(n.roll+t.rollDelta);const y=n.zoom;t.zoomDelta&&n.setZoom(n.zoom+t.zoomDelta);const b=n.zoom-y;if(b===0)return;const M=d.bK(n.center.lng,h.lng),I=M/(Math.abs(M/180)+1),D=d.bK(n.center.lat,h.lat),B=n.getRayDirectionFromPixel(A),V=n.cameraPosition,O=-1*d.b5(V,B),U=d.bz();d.b0(U,V,[B[0]*O,B[1]*O,B[2]*O]);const X=d.b7(U)-1,ie=Math.exp(.5*-Math.max(X-.3,0)),se=ro(n.worldSize,n.center.lat)/Math.min(n.width,n.height),ne=d.bx(se,.9,.5,1,.25),ce=(1-d.aq(-b))*Math.min(ie,ne),ge=n.center.lat,Ae=n.zoom,de=new d.V(n.center.lng+I*ce,d.an(n.center.lat+D*ce,-d.ao,d.ao));n.setLocationAtPoint(h,A);const ye=n.center,fe=d.bx(Math.abs(M),45,85,0,1),Me=d.bx(se,.75,.35,0,1),Ge=Math.pow(Math.max(fe,Me),.25),Fe=d.bK(ye.lng,de.lng),Oe=d.bK(ye.lat,de.lat);n.setCenter(new d.V(ye.lng+Fe*Ge,ye.lat+Oe*Ge).wrap()),n.setZoom(Ae+$r(ge,n.center.lat))}handleMapControlsPan(t,n,A){if(!t.panDelta)return;const h=n.center.lat,y=n.zoom;n.setCenter(oA(t.panDelta,n).wrap()),n.setZoom(y+$r(h,n.center.lat))}cameraForBoxAndBearing(t,n,A,h,y){const b=gi(t,n,A,h,y),M=n.left/y.width*2-1,I=(y.width-n.right)/y.width*2-1,D=n.top/y.height*-2+1,B=(y.height-n.bottom)/y.height*-2+1,V=d.bK(A.getWest(),A.getEast())<0,O=V?A.getEast():A.getWest(),U=V?A.getWest():A.getEast(),X=Math.max(A.getNorth(),A.getSouth()),ie=Math.min(A.getNorth(),A.getSouth()),se=O+.5*d.bK(O,U),ne=X+.5*d.bK(X,ie),ce=y.clone();ce.setCenter(b.center),ce.setBearing(b.bearing),ce.setPitch(0),ce.setRoll(0),ce.setZoom(b.zoom);const ge=ce.modelViewProjectionMatrix,Ae=[Sr(A.getNorthWest()),Sr(A.getNorthEast()),Sr(A.getSouthWest()),Sr(A.getSouthEast()),Sr(new d.V(U,ne)),Sr(new d.V(O,ne)),Sr(new d.V(se,X)),Sr(new d.V(se,ie))],de=Sr(b.center);let ye=Number.POSITIVE_INFINITY;for(const fe of Ae)M<0&&(ye=Nr.getLesserNonNegativeNonNull(ye,Nr.solveVectorScale(fe,de,ge,"x",M))),I>0&&(ye=Nr.getLesserNonNegativeNonNull(ye,Nr.solveVectorScale(fe,de,ge,"x",I))),D>0&&(ye=Nr.getLesserNonNegativeNonNull(ye,Nr.solveVectorScale(fe,de,ge,"y",D))),B<0&&(ye=Nr.getLesserNonNegativeNonNull(ye,Nr.solveVectorScale(fe,de,ge,"y",B)));if(Number.isFinite(ye)&&ye!==0)return b.zoom=ce.zoom+d.at(ye),b;ls()}handleJumpToCenterZoom(t,n){const A=t.center.lat,h=t.applyConstrain(n.center?d.V.convert(n.center):t.center,t.zoom).center;t.setCenter(h.wrap());const y=n.zoom!==void 0?+n.zoom:t.zoom+$r(A,h.lat);t.zoom!==y&&t.setZoom(y)}handleEaseTo(t,n){const A=t.zoom,h=t.center,y=t.padding,b={roll:t.roll,pitch:t.pitch,bearing:t.bearing},M={roll:n.roll===void 0?t.roll:n.roll,pitch:n.pitch===void 0?t.pitch:n.pitch,bearing:n.bearing===void 0?t.bearing:n.bearing},I=n.zoom!==void 0,D=!t.isPaddingEqual(n.padding);let B=!1;const V=n.center?d.V.convert(n.center):h,O=t.applyConstrain(V,A).center;Hn(t,O);const U=t.clone();U.setCenter(O),U.setZoom(I?+n.zoom:A+$r(h.lat,V.lat)),U.setBearing(n.bearing);const X=new d.P(d.an(t.centerPoint.x+n.offsetAsPoint.x,0,t.width),d.an(t.centerPoint.y+n.offsetAsPoint.y,0,t.height));U.setLocationAtPoint(O,X);const ie=(n.offset&&n.offsetAsPoint.mag())>0?U.center:O,se=I?+n.zoom:A+$r(h.lat,ie.lat),ne=A+$r(h.lat,0),ce=se+$r(ie.lat,0),ge=d.bK(h.lng,ie.lng),Ae=d.bK(h.lat,ie.lat),de=d.aq(ce-ne);return B=se!==A,{easeFunc:ye=>{if(d.bo(b,M)||sA({startEulerAngles:b,endEulerAngles:M,tr:t,k:ye,useSlerp:b.roll!=M.roll}),D&&t.interpolatePadding(y,n.padding,ye),n.around)d.w("Easing around a point is not supported under globe projection."),t.setLocationAtPoint(n.around,n.aroundPoint);else{const fe=ce>ne?Math.min(2,de):Math.max(.5,de),Me=Math.pow(fe,1-ye),Ge=aA(h,ge,Ae,ye*Me);t.setCenter(Ge.wrap())}if(B){const fe=d.G.number(ne,ce,ye)+$r(0,t.center.lat);t.setZoom(fe)}},isZooming:B,elevationCenter:ie}}handleFlyTo(t,n){const A=n.zoom!==void 0,h=t.center,y=t.zoom,b=t.padding,M=!t.isPaddingEqual(n.padding),I=t.applyConstrain(d.V.convert(n.center||n.locationAtOffset),y).center,D=A?+n.zoom:t.zoom+$r(t.center.lat,I.lat),B=t.clone();B.setCenter(I),B.setZoom(D),B.setBearing(n.bearing);const V=new d.P(d.an(t.centerPoint.x+n.offsetAsPoint.x,0,t.width),d.an(t.centerPoint.y+n.offsetAsPoint.y,0,t.height));B.setLocationAtPoint(I,V);const O=B.center;Hn(t,O);const U=(function(Ae,de,ye){const fe=Sr(de),Me=Sr(ye),Ge=d.b5(fe,Me),Fe=Math.acos(Ge),Oe=ki(Ae);return Fe/(2*Math.PI)*Oe})(t,h,O),X=y+$r(h.lat,0),ie=D+$r(O.lat,0),se=d.aq(ie-X);let ne;if(typeof n.minZoom=="number"){const Ae=+n.minZoom+$r(O.lat,0),de=Math.min(Ae,X,ie)+$r(0,O.lat),ye=t.applyConstrain(O,de).zoom+$r(O.lat,0);ne=d.aq(ye-X)}const ce=d.bK(h.lng,O.lng),ge=d.bK(h.lat,O.lat);return{easeFunc:(Ae,de,ye,fe)=>{const Me=aA(h,ce,ge,ye);M&&t.interpolatePadding(b,n.padding,Ae);const Ge=Ae===1?O:Me;t.setCenter(Ge.wrap());const Fe=X+d.at(de);t.setZoom(Ae===1?D:Fe+$r(0,Ge.lat))},scaleOfZoom:se,targetCenter:O,scaleOfMinZoom:ne,pixelPathLength:U}}static solveVectorScale(t,n,A,h,y){const b=h==="x"?[A[0],A[4],A[8],A[12]]:[A[1],A[5],A[9],A[13]],M=[A[3],A[7],A[11],A[15]],I=t[0]*b[0]+t[1]*b[1]+t[2]*b[2],D=t[0]*M[0]+t[1]*M[1]+t[2]*M[2],B=n[0]*b[0]+n[1]*b[1]+n[2]*b[2],V=n[0]*M[0]+n[1]*M[1]+n[2]*M[2];return B+y*D===I+y*V||M[3]*(I-B)+b[3]*(V-D)+I*V==B*D?null:(B+b[3]-y*V-y*M[3])/(B-I-y*V+y*D)}static getLesserNonNegativeNonNull(t,n){return n!==null&&n>=0&&n<t?n:t}}class lA{constructor(t){this._globe=t,this._mercatorCameraHelper=new dn,this._verticalPerspectiveCameraHelper=new Nr}get useGlobeControls(){return this._globe.useGlobeRendering}get currentHelper(){return this.useGlobeControls?this._verticalPerspectiveCameraHelper:this._mercatorCameraHelper}handlePanInertia(t,n){return this.currentHelper.handlePanInertia(t,n)}handleMapControlsRollPitchBearingZoom(t,n){return this.currentHelper.handleMapControlsRollPitchBearingZoom(t,n)}handleMapControlsPan(t,n,A){this.currentHelper.handleMapControlsPan(t,n,A)}cameraForBoxAndBearing(t,n,A,h,y){return this.currentHelper.cameraForBoxAndBearing(t,n,A,h,y)}handleJumpToCenterZoom(t,n){this.currentHelper.handleJumpToCenterZoom(t,n)}handleEaseTo(t,n){return this.currentHelper.handleEaseTo(t,n)}handleFlyTo(t,n){return this.currentHelper.handleFlyTo(t,n)}}const ks=(_,t)=>d.B(_,t&&t.filter((n=>n.identifier!=="source.canvas"))),Bo=d.bO();class Mn extends d.E{constructor(t,n={}){var A,h;super(),this._rtlPluginLoaded=()=>{for(const b in this.tileManagers){const M=this.tileManagers[b].getSource().type;M!=="vector"&&M!=="geojson"||this.tileManagers[b].reload()}},this.map=t,this.dispatcher=new zn($s(),t._getMapId()),this.dispatcher.registerMessageHandler("GG",((b,M)=>this.getGlyphs(b,M))),this.dispatcher.registerMessageHandler("GI",((b,M)=>this.getImages(b,M))),this.dispatcher.registerMessageHandler("GDA",((b,M)=>this.getDashes(b,M))),this.imageManager=new Ti,this.imageManager.setEventedParent(this);const y=((A=t._container)===null||A===void 0?void 0:A.lang)||typeof document<"u"&&((h=document.documentElement)===null||h===void 0?void 0:h.lang)||void 0;this.glyphManager=new Ui(t._requestManager,n.localIdeographFontFamily,y),this.lineAtlas=new bo(256,512),this.crossTileSymbolIndex=new en,this._setInitialValues(),this._resetUpdates(),this.dispatcher.broadcast("SR",d.bP()),Ce().on(_e,this._rtlPluginLoaded),this.on("data",(b=>{if(b.dataType!=="source"||b.sourceDataType!=="metadata")return;const M=this.tileManagers[b.sourceId];if(!M)return;const I=M.getSource();if(I&&I.vectorLayerIds)for(const D in this._layers){const B=this._layers[D];B.source===I.id&&this._validateLayer(B)}}))}_setInitialValues(){var t;this._spritesImagesIds={},this._layers={},this._order=[],this.tileManagers={},this.zoomHistory=new d.bQ,this._availableImages=[],this._globalState={},this._serializedLayers={},this.stylesheet=null,this.light=null,this.sky=null,this.projection&&(this.projection.destroy(),delete this.projection),this._loaded=!1,this._changed=!1,this._updatedLayers={},this._updatedSources={},this._changedImages={},this._glyphsDidChange=!1,this._updatedPaintProps={},this._layerOrderChanged=!1,this.crossTileSymbolIndex=new(((t=this.crossTileSymbolIndex)===null||t===void 0?void 0:t.constructor)||Object),this.pauseablePlacement=void 0,this.placement=void 0,this.z=0}setGlobalStateProperty(t,n){var A,h,y;this._checkLoaded();const b=n===null?(y=(h=(A=this.stylesheet.state)===null||A===void 0?void 0:A[t])===null||h===void 0?void 0:h.default)!==null&&y!==void 0?y:null:n;if(d.bR(b,this._globalState[t]))return this;this._globalState[t]=b,this._applyGlobalStateChanges([t])}getGlobalState(){return this._globalState}setGlobalState(t){this._checkLoaded();const n=[];for(const A in t)!d.bR(this._globalState[A],t[A].default)&&(n.push(A),this._globalState[A]=t[A].default);this._applyGlobalStateChanges(n)}_applyGlobalStateChanges(t){if(t.length===0)return;const n=new Set,A={};for(const h of t){A[h]=this._globalState[h];for(const y in this._layers){const b=this._layers[y],M=b.getLayoutAffectingGlobalStateRefs(),I=b.getPaintAffectingGlobalStateRefs(),D=b.getVisibilityAffectingGlobalStateRefs();if(M.has(h)&&n.add(b.source),I.has(h))for(const{name:B,value:V}of I.get(h))this._updatePaintProperty(b,B,V);D!=null&&D.has(h)&&(b.recalculateVisibility(),this._updateLayer(b))}}this.dispatcher.broadcast("UGS",A);for(const h in this.tileManagers)n.has(h)&&(this._reloadSource(h),this._changed=!0)}loadURL(t,n={},A){this.fire(new d.l("dataloading",{dataType:"style"})),n.validate=typeof n.validate!="boolean"||n.validate;const h=this.map._requestManager.transformRequest(t,"Style");this._loadStyleRequest=new AbortController;const y=this._loadStyleRequest;d.j(h,this._loadStyleRequest).then((b=>{this._loadStyleRequest=null,this._load(b.data,n,A)})).catch((b=>{this._loadStyleRequest=null,b&&!y.signal.aborted&&this.fire(new d.k(b))}))}loadJSON(t,n={},A){this.fire(new d.l("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,hi.frameAsync(this._frameRequest).then((()=>{this._frameRequest=null,n.validate=n.validate!==!1,this._load(t,n,A)})).catch((()=>{}))}loadEmpty(){this.fire(new d.l("dataloading",{dataType:"style"})),this._load(Bo,{validate:!1})}_load(t,n,A){var h,y;let b=n.transformStyle?n.transformStyle(A,t):t;if(!n.validate||!ks(this,d.C(b))){b=Object.assign({},b),this._loaded=!0,this.stylesheet=b;for(const M in b.sources)this.addSource(M,b.sources[M],{validate:!1});b.sprite?this._loadSprite(b.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(b.glyphs),this._createLayers(),this.light=new Zs(this.stylesheet.light),this._setProjectionInternal(((h=this.stylesheet.projection)===null||h===void 0?void 0:h.type)||"mercator"),this.sky=new os(this.stylesheet.sky),this.map.setTerrain((y=this.stylesheet.terrain)!==null&&y!==void 0?y:null),this.fire(new d.l("data",{dataType:"style"})),this.fire(new d.l("style.load"))}}_createLayers(){var t,n,A;const h=d.bS(this.stylesheet.layers);this.setGlobalState((t=this.stylesheet.state)!==null&&t!==void 0?t:null),this.dispatcher.broadcast("SL",h),this._order=h.map((y=>y.id)),this._layers={},this._serializedLayers=null;for(const y of h){const b=d.bT(y,this._globalState);if(b.setEventedParent(this,{layer:{id:y.id}}),this._layers[y.id]=b,d.bU(b)&&this.tileManagers[b.source]){const M=(A=(n=y.paint)===null||n===void 0?void 0:n["raster-fade-duration"])!==null&&A!==void 0?A:b.paint.get("raster-fade-duration");this.tileManagers[b.source].setRasterFadeDuration(M)}}}_loadSprite(t,n=!1,A=void 0){this.imageManager.setLoaded(!1);const h=new AbortController;let y;this._spriteRequest=h,(function(b,M,I,D){return d._(this,void 0,void 0,(function*(){const B=Ts(b),V=I>1?"@2x":"",O={},U={};for(const{id:X,url:ie}of B){const se=M.transformRequest(Qn(ie,V,".json"),"SpriteJSON");O[X]=d.j(se,D);const ne=M.transformRequest(Qn(ie,V,".png"),"SpriteImage");U[X]=Yi.getImage(ne,D)}return yield Promise.all([...Object.values(O),...Object.values(U)]),(function(X,ie){return d._(this,void 0,void 0,(function*(){const se={};for(const ne in X){se[ne]={};const ce=hi.getImageCanvasContext((yield ie[ne]).data),ge=(yield X[ne]).data;for(const Ae in ge){const{width:de,height:ye,x:fe,y:Me,sdf:Ge,pixelRatio:Fe,stretchX:Oe,stretchY:Ve,content:ut,textFitWidth:ht,textFitHeight:rt}=ge[Ae];se[ne][Ae]={data:null,pixelRatio:Fe,sdf:Ge,stretchX:Oe,stretchY:Ve,content:ut,textFitWidth:ht,textFitHeight:rt,spriteData:{width:de,height:ye,x:fe,y:Me,context:ce}}}}return se}))})(O,U)}))})(t,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then((b=>{if(this._spriteRequest=null,b)for(const M in b){this._spritesImagesIds[M]=[];const I=this._spritesImagesIds[M]?this._spritesImagesIds[M].filter((D=>!(D in b))):[];for(const D of I)this.imageManager.removeImage(D),this._changedImages[D]=!0;for(const D in b[M]){const B=M==="default"?D:`${M}:${D}`;this._spritesImagesIds[M].push(B),B in this.imageManager.images?this.imageManager.updateImage(B,b[M][D],!1):this.imageManager.addImage(B,b[M][D]),n&&(this._changedImages[B]=!0)}}})).catch((b=>{this._spriteRequest=null,y=b,h.signal.aborted||this.fire(new d.k(y))})).finally((()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),n&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new d.l("data",{dataType:"style"})),A&&A(y)}))}_unloadSprite(){for(const t of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(t),this._changedImages[t]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new d.l("data",{dataType:"style"}))}_validateLayer(t){const n=this.tileManagers[t.source];if(!n)return;const A=t.sourceLayer;if(!A)return;const h=n.getSource();(h.type==="geojson"||h.vectorLayerIds&&h.vectorLayerIds.indexOf(A)===-1)&&this.fire(new d.k(new Error(`Source layer "${A}" does not exist on source "${h.id}" as specified by style layer "${t.id}".`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const t in this.tileManagers)if(!this.tileManagers[t].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeByIds(t,n=!1){const A=this._serializedAllLayers();if(!t||t.length===0)return Object.values(n?d.bV(A):A);const h=[];for(const y of t)if(A[y]){const b=n?d.bV(A[y]):A[y];h.push(b)}return h}_serializedAllLayers(){let t=this._serializedLayers;if(t)return t;t=this._serializedLayers={};const n=Object.keys(this._layers);for(const A of n){const h=this._layers[A];h.type!=="custom"&&(t[A]=h.serialize())}return t}hasTransitions(){var t,n,A;if(!((t=this.light)===null||t===void 0)&&t.hasTransition()||!((n=this.sky)===null||n===void 0)&&n.hasTransition()||!((A=this.projection)===null||A===void 0)&&A.hasTransition())return!0;for(const h in this.tileManagers)if(this.tileManagers[h].hasTransition())return!0;for(const h in this._layers)if(this._layers[h].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(t){if(!this._loaded)return;const n=this._changed;if(n){const h=Object.keys(this._updatedLayers),y=Object.keys(this._removedLayers);(h.length||y.length)&&this._updateWorkerLayers(h,y);for(const b in this._updatedSources){const M=this._updatedSources[b];if(M==="reload")this._reloadSource(b);else{if(M!=="clear")throw new Error(`Invalid action ${M}`);this._clearSource(b)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const b in this._updatedPaintProps)this._layers[b].updateTransitions(t);this.light.updateTransitions(t),this.sky.updateTransitions(t),this._resetUpdates()}const A={};for(const h in this.tileManagers){const y=this.tileManagers[h];A[h]=y.used,y.used=!1}for(const h of this._order){const y=this._layers[h];y.recalculate(t,this._availableImages),!y.isHidden(t.zoom)&&y.source&&(this.tileManagers[y.source].used=!0)}for(const h in A){const y=this.tileManagers[h];!!A[h]!=!!y.used&&y.fire(new d.l("data",{sourceDataType:"visibility",dataType:"source",sourceId:h}))}this.light.recalculate(t),this.sky.recalculate(t),this.projection.recalculate(t),this.z=t.zoom,n&&this.fire(new d.l("data",{dataType:"style"}))}_updateTilesForChangedImages(){const t=Object.keys(this._changedImages);if(t.length){for(const n in this.tileManagers)this.tileManagers[n].reloadTilesForDependencies(["icons","patterns"],t);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const t in this.tileManagers)this.tileManagers[t].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(t,n){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(t,!1),removedIds:n})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(t,n={}){var A;this._checkLoaded();const h=this.serialize();if(t=n.transformStyle?n.transformStyle(h,t):t,((A=n.validate)===null||A===void 0||A)&&ks(this,d.C(t)))return!1;(t=d.bV(t)).layers=d.bS(t.layers);const y=d.bW(h,t),b=this._getOperationsToPerform(y);if(b.unimplemented.length>0)throw new Error(`Unimplemented: ${b.unimplemented.join(", ")}.`);if(b.operations.length===0)return!1;for(const M of b.operations)M();return this.stylesheet=t,this._serializedLayers=null,this.fire(new d.l("style.load",{style:this})),!0}_getOperationsToPerform(t){const n=[],A=[];for(const h of t)switch(h.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":case"setRoll":continue;case"addLayer":n.push((()=>this.addLayer.apply(this,h.args)));break;case"removeLayer":n.push((()=>this.removeLayer.apply(this,h.args)));break;case"setPaintProperty":n.push((()=>this.setPaintProperty.apply(this,h.args)));break;case"setLayoutProperty":n.push((()=>this.setLayoutProperty.apply(this,h.args)));break;case"setFilter":n.push((()=>this.setFilter.apply(this,h.args)));break;case"addSource":n.push((()=>this.addSource.apply(this,h.args)));break;case"removeSource":n.push((()=>this.removeSource.apply(this,h.args)));break;case"setLayerZoomRange":n.push((()=>this.setLayerZoomRange.apply(this,h.args)));break;case"setLight":n.push((()=>this.setLight.apply(this,h.args)));break;case"setGeoJSONSourceData":n.push((()=>this.setGeoJSONSourceData.apply(this,h.args)));break;case"setGlyphs":n.push((()=>this.setGlyphs.apply(this,h.args)));break;case"setSprite":n.push((()=>this.setSprite.apply(this,h.args)));break;case"setTerrain":n.push((()=>this.map.setTerrain.apply(this,h.args)));break;case"setSky":n.push((()=>this.setSky.apply(this,h.args)));break;case"setProjection":this.setProjection.apply(this,h.args);break;case"setGlobalState":n.push((()=>this.setGlobalState.apply(this,h.args)));break;case"setTransition":n.push((()=>{}));break;default:A.push(h.command)}return{operations:n,unimplemented:A}}addImage(t,n){if(this.getImage(t))return this.fire(new d.k(new Error(`An image named "${t}" already exists.`)));this.imageManager.addImage(t,n),this._afterImageUpdated(t)}updateImage(t,n){this.imageManager.updateImage(t,n)}getImage(t){return this.imageManager.getImage(t)}removeImage(t){if(!this.getImage(t))return this.fire(new d.k(new Error(`An image named "${t}" does not exist.`)));this.imageManager.removeImage(t),this._afterImageUpdated(t)}_afterImageUpdated(t){this._availableImages=this.imageManager.listImages(),this._changedImages[t]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new d.l("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(t,n,A={}){if(this._checkLoaded(),this.tileManagers[t]!==void 0)throw new Error(`Source "${t}" already exists.`);if(!n.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(n).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(n.type)>=0&&this._validate(d.C.source,`sources.${t}`,n,null,A))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);const h=this.tileManagers[t]=new br(t,n,this.dispatcher);h.style=this,h.setEventedParent(this,(()=>({isSourceLoaded:h.loaded(),source:h.serialize(),sourceId:t}))),h.onAdd(this.map),this._changed=!0}removeSource(t){if(this._checkLoaded(),this.tileManagers[t]===void 0)throw new Error("There is no source with this ID");for(const A in this._layers)if(this._layers[A].source===t)return this.fire(new d.k(new Error(`Source "${t}" cannot be removed while layer "${A}" is using it.`)));const n=this.tileManagers[t];delete this.tileManagers[t],delete this._updatedSources[t],n.fire(new d.l("data",{sourceDataType:"metadata",dataType:"source",sourceId:t})),n.setEventedParent(null),n.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(t,n){if(this._checkLoaded(),this.tileManagers[t]===void 0)throw new Error(`There is no source with this ID=${t}`);const A=this.tileManagers[t].getSource();if(A.type!=="geojson")throw new Error(`geojsonSource.type is ${A.type}, which is !== 'geojson`);A.setData(n),this._changed=!0}getSource(t){return this.tileManagers[t]&&this.tileManagers[t].getSource()}addLayer(t,n,A={}){this._checkLoaded();const h=t.id;if(this.getLayer(h))return void this.fire(new d.k(new Error(`Layer "${h}" already exists on this map.`)));let y;if(t.type==="custom"){if(ks(this,d.bX(t)))return;y=d.bT(t,this._globalState)}else{if("source"in t&&typeof t.source=="object"&&(this.addSource(h,t.source),t=d.bV(t),t=d.e(t,{source:h})),this._validate(d.C.layer,`layers.${h}`,t,{arrayIndex:-1},A))return;y=d.bT(t,this._globalState),this._validateLayer(y),y.setEventedParent(this,{layer:{id:h}})}const b=n?this._order.indexOf(n):this._order.length;if(n&&b===-1)this.fire(new d.k(new Error(`Cannot add layer "${h}" before non-existing layer "${n}".`)));else{if(this._order.splice(b,0,h),this._layerOrderChanged=!0,this._layers[h]=y,this._removedLayers[h]&&y.source&&y.type!=="custom"){const M=this._removedLayers[h];delete this._removedLayers[h],M.type!==y.type?this._updatedSources[y.source]="clear":(this._updatedSources[y.source]="reload",this.tileManagers[y.source].pause())}this._updateLayer(y),y.onAdd&&y.onAdd(this.map)}}moveLayer(t,n){if(this._checkLoaded(),this._changed=!0,!this._layers[t])return void this.fire(new d.k(new Error(`The layer '${t}' does not exist in the map's style and cannot be moved.`)));if(t===n)return;const A=this._order.indexOf(t);this._order.splice(A,1);const h=n?this._order.indexOf(n):this._order.length;n&&h===-1?this.fire(new d.k(new Error(`Cannot move layer "${t}" before non-existing layer "${n}".`))):(this._order.splice(h,0,t),this._layerOrderChanged=!0)}removeLayer(t){this._checkLoaded();const n=this._layers[t];if(!n)return void this.fire(new d.k(new Error(`Cannot remove non-existing layer "${t}".`)));n.setEventedParent(null);const A=this._order.indexOf(t);this._order.splice(A,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[t]=n,delete this._layers[t],this._serializedLayers&&delete this._serializedLayers[t],delete this._updatedLayers[t],delete this._updatedPaintProps[t],n.onRemove&&n.onRemove(this.map)}getLayer(t){return this._layers[t]}getLayersOrder(){return[...this._order]}hasLayer(t){return t in this._layers}setLayerZoomRange(t,n,A){this._checkLoaded();const h=this.getLayer(t);h?h.minzoom===n&&h.maxzoom===A||(n!=null&&(h.minzoom=n),A!=null&&(h.maxzoom=A),this._updateLayer(h)):this.fire(new d.k(new Error(`Cannot set the zoom range of non-existing layer "${t}".`)))}setFilter(t,n,A={}){this._checkLoaded();const h=this.getLayer(t);if(h){if(!d.bR(h.filter,n))return n==null?(h.setFilter(void 0),void this._updateLayer(h)):void(this._validate(d.C.filter,`layers.${h.id}.filter`,n,null,A)||(h.setFilter(d.bV(n)),this._updateLayer(h)))}else this.fire(new d.k(new Error(`Cannot filter non-existing layer "${t}".`)))}getFilter(t){return d.bV(this.getLayer(t).filter)}setLayoutProperty(t,n,A,h={}){this._checkLoaded();const y=this.getLayer(t);y?d.bR(y.getLayoutProperty(n),A)||(y.setLayoutProperty(n,A,h),this._updateLayer(y)):this.fire(new d.k(new Error(`Cannot style non-existing layer "${t}".`)))}getLayoutProperty(t,n){const A=this.getLayer(t);if(A)return A.getLayoutProperty(n);this.fire(new d.k(new Error(`Cannot get style of non-existing layer "${t}".`)))}setPaintProperty(t,n,A,h={}){this._checkLoaded();const y=this.getLayer(t);y?d.bR(y.getPaintProperty(n),A)||this._updatePaintProperty(y,n,A,h):this.fire(new d.k(new Error(`Cannot style non-existing layer "${t}".`)))}_updatePaintProperty(t,n,A,h={}){t.setPaintProperty(n,A,h)&&this._updateLayer(t),d.bU(t)&&n==="raster-fade-duration"&&this.tileManagers[t.source].setRasterFadeDuration(A),this._changed=!0,this._updatedPaintProps[t.id]=!0,this._serializedLayers=null}getPaintProperty(t,n){return this.getLayer(t).getPaintProperty(n)}setFeatureState(t,n){this._checkLoaded();const A=t.source,h=t.sourceLayer,y=this.tileManagers[A];if(y===void 0)return void this.fire(new d.k(new Error(`The source '${A}' does not exist in the map's style.`)));const b=y.getSource().type;b==="geojson"&&h?this.fire(new d.k(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):b!=="vector"||h?(t.id===void 0&&this.fire(new d.k(new Error("The feature id parameter must be provided."))),y.setFeatureState(h,t.id,n)):this.fire(new d.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(t,n){this._checkLoaded();const A=t.source,h=this.tileManagers[A];if(h===void 0)return void this.fire(new d.k(new Error(`The source '${A}' does not exist in the map's style.`)));const y=h.getSource().type,b=y==="vector"?t.sourceLayer:void 0;y!=="vector"||b?n&&typeof t.id!="string"&&typeof t.id!="number"?this.fire(new d.k(new Error("A feature id is required to remove its specific state property."))):h.removeFeatureState(b,t.id,n):this.fire(new d.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(t){this._checkLoaded();const n=t.source,A=t.sourceLayer,h=this.tileManagers[n];if(h!==void 0)return h.getSource().type!=="vector"||A?(t.id===void 0&&this.fire(new d.k(new Error("The feature id parameter must be provided."))),h.getFeatureState(A,t.id)):void this.fire(new d.k(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new d.k(new Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return d.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const t=d.bY(this.tileManagers,(y=>y.serialize())),n=this._serializeByIds(this._order,!0),A=this.map.getTerrain()||void 0,h=this.stylesheet;return d.bZ({version:h.version,name:h.name,metadata:h.metadata,light:h.light,sky:h.sky,center:h.center,zoom:h.zoom,bearing:h.bearing,pitch:h.pitch,sprite:h.sprite,glyphs:h.glyphs,transition:h.transition,projection:h.projection,sources:t,layers:n,terrain:A},(y=>y!==void 0))}_updateLayer(t){this._updatedLayers[t.id]=!0,t.source&&!this._updatedSources[t.source]&&this.tileManagers[t.source].getSource().type!=="raster"&&(this._updatedSources[t.source]="reload",this.tileManagers[t.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(t){const n=b=>this._layers[b].type==="fill-extrusion",A={},h=[];for(let b=this._order.length-1;b>=0;b--){const M=this._order[b];if(n(M)){A[M]=b;for(const I of t){const D=I[M];if(D)for(const B of D)h.push(B)}}}h.sort(((b,M)=>M.intersectionZ-b.intersectionZ));const y=[];for(let b=this._order.length-1;b>=0;b--){const M=this._order[b];if(n(M))for(let I=h.length-1;I>=0;I--){const D=h[I].feature;if(A[D.layer.id]<b)break;y.push(D),h.pop()}else for(const I of t){const D=I[M];if(D)for(const B of D)y.push(B.feature)}}return y}queryRenderedFeatures(t,n,A){n&&n.filter&&this._validate(d.C.filter,"queryRenderedFeatures.filter",n.filter,null,n);const h={};if(n&&n.layers){if(!(Array.isArray(n.layers)||n.layers instanceof Set))return this.fire(new d.k(new Error("parameters.layers must be an Array or a Set of strings"))),[];for(const D of n.layers){const B=this._layers[D];if(!B)return this.fire(new d.k(new Error(`The layer '${D}' does not exist in the map's style and cannot be queried for features.`))),[];h[B.source]=!0}}const y=[];n.availableImages=this._availableImages;const b=this._serializedAllLayers(),M=n.layers instanceof Set?n.layers:Array.isArray(n.layers)?new Set(n.layers):null,I=Object.assign(Object.assign({},n),{layers:M,globalState:this._globalState});for(const D in this.tileManagers)n.layers&&!h[D]||y.push(sa(this.tileManagers[D],this._layers,b,t,I,A,this.map.terrain?(B,V,O)=>this.map.terrain.getElevation(B,V,O):void 0));return this.placement&&y.push((function(D,B,V,O,U,X,ie){const se={},ne=X.queryRenderedSymbols(O),ce=[];for(const ge of Object.keys(ne).map(Number))ce.push(ie[ge]);ce.sort(di);for(const ge of ce){const Ae=ge.featureIndex.lookupSymbolFeatures(ne[ge.bucketInstanceId],B,ge.bucketIndex,ge.sourceLayerIndex,{filterSpec:U.filter,globalState:U.globalState},U.layers,U.availableImages,D);for(const de in Ae){const ye=se[de]=se[de]||[],fe=Ae[de];fe.sort(((Me,Ge)=>{const Fe=ge.featureSortOrder;if(Fe){const Oe=Fe.indexOf(Me.featureIndex);return Fe.indexOf(Ge.featureIndex)-Oe}return Ge.featureIndex-Me.featureIndex}));for(const Me of fe)ye.push(Me)}}return(function(ge,Ae,de){for(const ye in ge)for(const fe of ge[ye])wn(fe,de[Ae[ye].source]);return ge})(se,D,V)})(this._layers,b,this.tileManagers,t,I,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(y)}querySourceFeatures(t,n){n!=null&&n.filter&&this._validate(d.C.filter,"querySourceFeatures.filter",n.filter,null,n);const A=this.tileManagers[t];return A?(function(h,y){const b=h.getRenderableIds().map((D=>h.getTileByID(D))),M=[],I={};for(let D=0;D<b.length;D++){const B=b[D],V=B.tileID.canonical.key;I[V]||(I[V]=!0,B.querySourceFeatures(M,y))}return M})(A,n?Object.assign(Object.assign({},n),{globalState:this._globalState}):{globalState:this._globalState}):[]}getLight(){return this.light.getLight()}setLight(t,n={}){this._checkLoaded();const A=this.light.getLight();let h=!1;for(const b in t)if(!d.bR(t[b],A[b])){h=!0;break}if(!h)return;const y={now:Ar(),transition:d.e({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(t,n),this.light.updateTransitions(y)}getProjection(){var t;return(t=this.stylesheet)===null||t===void 0?void 0:t.projection}setProjection(t){if(this._checkLoaded(),this.projection){if(this.projection.name===t.type)return;this.projection.destroy(),delete this.projection}this.stylesheet.projection=t,this._setProjectionInternal(t.type)}getSky(){var t;return(t=this.stylesheet)===null||t===void 0?void 0:t.sky}setSky(t,n={}){this._checkLoaded();const A=this.getSky();let h=!1;if(!t&&!A)return;if(t&&!A)h=!0;else if(!t&&A)h=!0;else for(const b in t)if(!d.bR(t[b],A[b])){h=!0;break}if(!h)return;const y={now:Ar(),transition:d.e({duration:300,delay:0},this.stylesheet.transition)};this.stylesheet.sky=t,this.sky.setSky(t,n),this.sky.updateTransitions(y)}_setProjectionInternal(t){const n=(function(A,h){const y={constrainOverride:h};if(Array.isArray(A)){const b=new us({type:A});return{projection:b,transform:new zo(y),cameraHelper:new lA(b)}}switch(A){case"mercator":return{projection:new $i,transform:new eo(y),cameraHelper:new dn};case"globe":{const b=new us({type:["interpolate",["linear"],["zoom"],11,"vertical-perspective",12,"mercator"]});return{projection:b,transform:new zo(y),cameraHelper:new lA(b)}}case"vertical-perspective":return{projection:new Io,transform:new ko(y),cameraHelper:new Nr};default:return d.w(`Unknown projection name: ${A}. Falling back to mercator projection.`),{projection:new $i,transform:new eo(y),cameraHelper:new dn}}})(t,this.map.transformConstrain);this.projection=n.projection,this.map.migrateProjection(n.transform,n.cameraHelper);for(const A in this.tileManagers)this.tileManagers[A].reload()}_validate(t,n,A,h,y={}){return(!y||y.validate!==!1)&&ks(this,t.call(d.C,d.e({key:n,style:this.serialize(),value:A,styleSpec:d.u},h)))}_remove(t=!0){this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._loadStyleRequest&&(this._loadStyleRequest.abort(),this._loadStyleRequest=null),this._spriteRequest&&(this._spriteRequest.abort(),this._spriteRequest=null),Ce().off(_e,this._rtlPluginLoaded);for(const n in this._layers)this._layers[n].setEventedParent(null);for(const n in this.tileManagers){const A=this.tileManagers[n];A.setEventedParent(null),A.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null),t&&this.dispatcher.broadcast("RM",void 0),this.dispatcher.remove(t)}_clearSource(t){this.tileManagers[t].clearTiles()}_reloadSource(t){this.tileManagers[t].resume(),this.tileManagers[t].reload()}_updateSources(t){for(const n in this.tileManagers)this.tileManagers[n].update(t,this.map.terrain)}_generateCollisionBoxes(){for(const t in this.tileManagers)this._reloadSource(t)}_updatePlacement(t,n,A,h,y=!1){let b=!1,M=!1;const I={};for(const D of this._order){const B=this._layers[D];if(B.type!=="symbol")continue;if(!I[B.source]){const O=this.tileManagers[B.source];I[B.source]=O.getRenderableIds(!0).map((U=>O.getTileByID(U))).sort(((U,X)=>X.tileID.overscaledZ-U.tileID.overscaledZ||(U.tileID.isLessThan(X.tileID)?-1:1)))}const V=this.crossTileSymbolIndex.addLayer(B,I[B.source],t.center.lng);b=b||V}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((y=y||this._layerOrderChanged||A===0)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(Ar(),t.zoom))&&(this.pauseablePlacement=new yr(t,this.map.terrain,this._order,y,n,A,h,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,I),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(Ar()),M=!0),b&&this.pauseablePlacement.placement.setStale()),M||b)for(const D of this._order){const B=this._layers[D];B.type==="symbol"&&this.placement.updateLayerOpacities(B,I[B.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(Ar())}_releaseSymbolFadeTiles(){for(const t in this.tileManagers)this.tileManagers[t].releaseSymbolFadeTiles()}getImages(t,n){return d._(this,void 0,void 0,(function*(){const A=yield this.imageManager.getImages(n.icons);this._updateTilesForChangedImages();const h=this.tileManagers[n.source];return h&&h.setDependencies(n.tileID.key,n.type,n.icons),A}))}getGlyphs(t,n){return d._(this,void 0,void 0,(function*(){const A=yield this.glyphManager.getGlyphs(n.stacks),h=this.tileManagers[n.source];return h&&h.setDependencies(n.tileID.key,n.type,[""]),A}))}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(t,n={}){this._checkLoaded(),t&&this._validate(d.C.glyphs,"glyphs",t,null,n)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=t,this.glyphManager.entries={},this.glyphManager.setURL(t))}getDashes(t,n){return d._(this,void 0,void 0,(function*(){const A={};for(const[h,y]of Object.entries(n.dashes))A[h]=this.lineAtlas.getDash(y.dasharray,y.round);return A}))}addSprite(t,n,A={},h){this._checkLoaded();const y=[{id:t,url:n}],b=[...Ts(this.stylesheet.sprite),...y];this._validate(d.C.sprite,"sprite",b,null,A)||(this.stylesheet.sprite=b,this._loadSprite(y,!0,h))}removeSprite(t){this._checkLoaded();const n=Ts(this.stylesheet.sprite);if(n.find((A=>A.id===t))){if(this._spritesImagesIds[t])for(const A of this._spritesImagesIds[t])this.imageManager.removeImage(A),this._changedImages[A]=!0;n.splice(n.findIndex((A=>A.id===t)),1),this.stylesheet.sprite=n.length>0?n:void 0,delete this._spritesImagesIds[t],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new d.l("data",{dataType:"style"}))}else this.fire(new d.k(new Error(`Sprite "${t}" doesn't exists on this map.`)))}getSprite(){return Ts(this.stylesheet.sprite)}setSprite(t,n={},A){this._checkLoaded(),t&&this._validate(d.C.sprite,"sprite",t,null,n)||(this.stylesheet.sprite=t,t?this._loadSprite(t,!0,A):(this._unloadSprite(),A&&A(null)))}destroy(){this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._loadStyleRequest&&(this._loadStyleRequest.abort(),this._loadStyleRequest=null),this._spriteRequest&&(this._spriteRequest.abort(),this._spriteRequest=null);for(const t in this.tileManagers){const n=this.tileManagers[t];n.setEventedParent(null),n.onRemove(this.map)}this.tileManagers={},this.imageManager&&(this.imageManager.setEventedParent(null),this.imageManager.destroy(),this._availableImages=[],this._spritesImagesIds={}),this.glyphManager&&this.glyphManager.destroy();for(const t in this._layers){const n=this._layers[t];n.setEventedParent(null),n.onRemove&&n.onRemove(this.map)}this._setInitialValues(),this.setEventedParent(null),this.dispatcher.unregisterMessageHandler("GG"),this.dispatcher.unregisterMessageHandler("GI"),this.dispatcher.unregisterMessageHandler("GDA"),this.dispatcher.remove(!0),this._listeners={},this._oneTimeListeners={}}}var au=d.aU([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class Ro{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(t,n,A,h,y,b,M,I,D){this.context=t;let B=this.boundPaintVertexBuffers.length!==h.length;for(let V=0;!B&&V<h.length;V++)this.boundPaintVertexBuffers[V]!==h[V]&&(B=!0);!this.vao||this.boundProgram!==n||this.boundLayoutVertexBuffer!==A||B||this.boundIndexBuffer!==y||this.boundVertexOffset!==b||this.boundDynamicVertexBuffer!==M||this.boundDynamicVertexBuffer2!==I||this.boundDynamicVertexBuffer3!==D?this.freshBind(n,A,h,y,b,M,I,D):(t.bindVertexArray.set(this.vao),M&&M.bind(),y&&y.dynamicDraw&&y.bind(),I&&I.bind(),D&&D.bind())}freshBind(t,n,A,h,y,b,M,I){const D=t.numAttributes,B=this.context,V=B.gl;this.vao&&this.destroy(),this.vao=B.createVertexArray(),B.bindVertexArray.set(this.vao),this.boundProgram=t,this.boundLayoutVertexBuffer=n,this.boundPaintVertexBuffers=A,this.boundIndexBuffer=h,this.boundVertexOffset=y,this.boundDynamicVertexBuffer=b,this.boundDynamicVertexBuffer2=M,this.boundDynamicVertexBuffer3=I,n.enableAttributes(V,t);for(const O of A)O.enableAttributes(V,t);b&&b.enableAttributes(V,t),M&&M.enableAttributes(V,t),I&&I.enableAttributes(V,t),n.bind(),n.setVertexAttribPointers(V,t,y);for(const O of A)O.bind(),O.setVertexAttribPointers(V,t,y);b&&(b.bind(),b.setVertexAttribPointers(V,t,y)),h&&h.bind(),M&&(M.bind(),M.setVertexAttribPointers(V,t,y)),I&&(I.bind(),I.setVertexAttribPointers(V,t,y)),B.currentNumAttributes=D}destroy(){this.vao&&(this.context.deleteVertexArray(this.vao),this.vao=null)}}const AA=(_,t,n,A,h)=>({u_texture:0,u_ele_delta:_,u_fog_matrix:t,u_fog_color:n?n.properties.get("fog-color"):d.bp.white,u_fog_ground_blend:n?n.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:h?0:n?n.calculateFogBlendOpacity(A):0,u_horizon_color:n?n.properties.get("horizon-color"):d.bp.white,u_horizon_fog_blend:n?n.properties.get("horizon-fog-blend"):1,u_is_globe_mode:h?1:0}),Lo={mainMatrix:"u_projection_matrix",tileMercatorCoords:"u_projection_tile_mercator_coords",clippingPlane:"u_projection_clipping_plane",projectionTransition:"u_projection_transition",fallbackMatrix:"u_projection_fallback_matrix"};function da(_){const t=[];for(let n=0;n<_.length;n++){if(_[n]===null)continue;const A=_[n].split(" ");t.push(A.pop())}return t}class uA{constructor(t,n,A,h,y,b,M,I,D=[]){const B=t.gl;this.program=B.createProgram();const V=da(n.staticAttributes),O=A?A.getBinderAttributes():[],U=V.concat(O),X=Cr.prelude.staticUniforms?da(Cr.prelude.staticUniforms):[],ie=M.staticUniforms?da(M.staticUniforms):[],se=n.staticUniforms?da(n.staticUniforms):[],ne=A?A.getBinderUniforms():[],ce=X.concat(ie).concat(se).concat(ne),ge=[];for(const Fe of ce)ge.indexOf(Fe)<0&&ge.push(Fe);const Ae=A?A.defines():[];mn(B)&&Ae.unshift("#version 300 es"),y&&Ae.push("#define OVERDRAW_INSPECTOR;"),b&&Ae.push("#define TERRAIN3D;"),I&&Ae.push(I),D&&Ae.push(...D);let de=Ae.concat(Cr.prelude.fragmentSource,M.fragmentSource,n.fragmentSource).join(` 808 + `),ye=Ae.concat(Cr.prelude.vertexSource,M.vertexSource,n.vertexSource).join(` 809 + `);mn(B)||(de=(function(Fe){return Fe.replace(/\bin\s/g,"varying ").replace("out highp vec4 fragColor;","").replace(/fragColor/g,"gl_FragColor").replace(/texture\(/g,"texture2D(")})(de),ye=(function(Fe){return Fe.replace(/\bin\s/g,"attribute ").replace(/\bout\s/g,"varying ").replace(/texture\(/g,"texture2D(")})(ye));const fe=B.createShader(B.FRAGMENT_SHADER);if(B.isContextLost())return void(this.failedToCreate=!0);if(B.shaderSource(fe,de),B.compileShader(fe),!B.getShaderParameter(fe,B.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${B.getShaderInfoLog(fe)}`);B.attachShader(this.program,fe);const Me=B.createShader(B.VERTEX_SHADER);if(B.isContextLost())return void(this.failedToCreate=!0);if(B.shaderSource(Me,ye),B.compileShader(Me),!B.getShaderParameter(Me,B.COMPILE_STATUS))throw new Error(`Could not compile vertex shader: ${B.getShaderInfoLog(Me)}`);B.attachShader(this.program,Me),this.attributes={};const Ge={};this.numAttributes=U.length;for(let Fe=0;Fe<this.numAttributes;Fe++)U[Fe]&&(B.bindAttribLocation(this.program,Fe,U[Fe]),this.attributes[U[Fe]]=Fe);if(B.linkProgram(this.program),!B.getProgramParameter(this.program,B.LINK_STATUS))throw new Error(`Program failed to link: ${B.getProgramInfoLog(this.program)}`);B.deleteShader(Me),B.deleteShader(fe);for(let Fe=0;Fe<ge.length;Fe++){const Oe=ge[Fe];if(Oe&&!Ge[Oe]){const Ve=B.getUniformLocation(this.program,Oe);Ve&&(Ge[Oe]=Ve)}}this.fixedUniforms=h(t,Ge),this.terrainUniforms=((Fe,Oe)=>({u_depth:new d.b_(Fe,Oe.u_depth),u_terrain:new d.b_(Fe,Oe.u_terrain),u_terrain_dim:new d.bq(Fe,Oe.u_terrain_dim),u_terrain_matrix:new d.c0(Fe,Oe.u_terrain_matrix),u_terrain_unpack:new d.c1(Fe,Oe.u_terrain_unpack),u_terrain_exaggeration:new d.bq(Fe,Oe.u_terrain_exaggeration)}))(t,Ge),this.projectionUniforms=((Fe,Oe)=>({u_projection_matrix:new d.c0(Fe,Oe.u_projection_matrix),u_projection_tile_mercator_coords:new d.c1(Fe,Oe.u_projection_tile_mercator_coords),u_projection_clipping_plane:new d.c1(Fe,Oe.u_projection_clipping_plane),u_projection_transition:new d.bq(Fe,Oe.u_projection_transition),u_projection_fallback_matrix:new d.c0(Fe,Oe.u_projection_fallback_matrix)}))(t,Ge),this.binderUniforms=A?A.getUniforms(t,Ge):[]}draw(t,n,A,h,y,b,M,I,D,B,V,O,U,X,ie,se,ne,ce,ge){const Ae=t.gl;if(this.failedToCreate)return;if(t.program.set(this.program),t.setDepthMode(A),t.setStencilMode(h),t.setColorMode(y),t.setCullFace(b),I){t.activeTexture.set(Ae.TEXTURE2),Ae.bindTexture(Ae.TEXTURE_2D,I.depthTexture),t.activeTexture.set(Ae.TEXTURE3),Ae.bindTexture(Ae.TEXTURE_2D,I.texture);for(const ye in this.terrainUniforms)this.terrainUniforms[ye].set(I[ye])}if(D)for(const ye in D)this.projectionUniforms[Lo[ye]].set(D[ye]);if(M)for(const ye in this.fixedUniforms)this.fixedUniforms[ye].set(M[ye]);se&&se.setUniforms(t,this.binderUniforms,X,{zoom:ie});let de=0;switch(n){case Ae.LINES:de=2;break;case Ae.TRIANGLES:de=3;break;case Ae.LINE_STRIP:de=1}for(const ye of U.get()){const fe=ye.vaos||(ye.vaos={});(fe[B]||(fe[B]=new Ro)).bind(t,this,V,se?se.getPaintVertexBuffers():[],O,ye.vertexOffset,ne,ce,ge),Ae.drawElements(n,ye.primitiveLength*de,Ae.UNSIGNED_SHORT,ye.primitiveOffset*de*2)}}}function cA(_,t,n){const A=1/d.aN(n,1,t.transform.tileZoom),h=Math.pow(2,n.tileID.overscaledZ),y=n.tileSize*Math.pow(2,t.transform.tileZoom)/h,b=y*(n.tileID.canonical.x+n.tileID.wrap*h),M=y*n.tileID.canonical.y;return{u_image:0,u_texsize:n.imageAtlasTexture.size,u_scale:[A,_.fromScale,_.toScale],u_fade:_.t,u_pixel_coord_upper:[b>>16,M>>16],u_pixel_coord_lower:[65535&b,65535&M]}}const ma=(_,t,n,A)=>{const h=_.style.light,y=h.properties.get("position"),b=[y.x,y.y,y.z],M=d.c4();h.properties.get("anchor")==="viewport"&&d.c5(M,_.transform.bearingInRadians),d.c6(b,b,M);const I=_.transform.transformLightDirection(b),D=h.properties.get("color");return{u_lightpos:b,u_lightpos_globe:I,u_lightintensity:h.properties.get("intensity"),u_lightcolor:[D.r,D.g,D.b],u_vertical_gradient:+t,u_opacity:n,u_fill_translate:A}},gl=(_,t,n,A,h,y,b)=>d.e(ma(_,t,n,A),cA(y,_,b),{u_height_factor:-Math.pow(2,h.overscaledZ)/b.tileSize/8}),ga=(_,t,n,A)=>d.e(cA(t,_,n),{u_fill_translate:A}),Va=(_,t)=>({u_world:_,u_fill_translate:t}),Fo=(_,t,n,A,h)=>d.e(ga(_,t,n,h),{u_world:A}),wr=(_,t,n,A,h)=>{const y=_.transform;let b,M,I=0;if(n.paint.get("circle-pitch-alignment")==="map"){const D=d.aN(t,1,y.zoom);b=!0,M=[D,D],I=D/(d.a5*Math.pow(2,t.tileID.overscaledZ))*2*Math.PI*h}else b=!1,M=y.pixelsToGLUnits;return{u_camera_to_center_distance:y.cameraToCenterDistance,u_scale_with_map:+(n.paint.get("circle-pitch-scale")==="map"),u_pitch_with_map:+b,u_device_pixel_ratio:_.pixelRatio,u_extrude_scale:M,u_globe_extrude_scale:I,u_translate:A}},no=_=>({u_pixel_extrude_scale:[1/_.width,1/_.height]}),_l=_=>({u_viewport_size:[_.width,_.height]}),ja=(_,t=1)=>({u_color:_,u_overlay:0,u_overlay_scale:t}),Oo=(_,t,n,A)=>{const h=d.aN(_,1,t)/(d.a5*Math.pow(2,_.tileID.overscaledZ))*2*Math.PI*A;return{u_extrude_scale:d.aN(_,1,t),u_intensity:n,u_globe_extrude_scale:h}},hA=(_,t,n,A)=>{const h=d.N();d.c7(h,0,_.width,_.height,0,0,1);const y=_.context.gl;return{u_matrix:h,u_world:[y.drawingBufferWidth,y.drawingBufferHeight],u_image:n,u_color_ramp:A,u_opacity:t.paint.get("heatmap-opacity")}},Na=(_,t,n)=>{const A=n.paint.get("hillshade-accent-color");let h;switch(n.paint.get("hillshade-method")){case"basic":h=4;break;case"combined":h=1;break;case"igor":h=2;break;case"multidirectional":h=3;break;default:h=0}const y=n.getIlluminationProperties();for(let b=0;b<y.directionRadians.length;b++)n.paint.get("hillshade-illumination-anchor")==="viewport"&&(y.directionRadians[b]+=_.transform.bearingInRadians);return{u_image:0,u_latrange:sn(0,t.tileID),u_exaggeration:n.paint.get("hillshade-exaggeration"),u_altitudes:y.altitudeRadians,u_azimuths:y.directionRadians,u_accent:A,u_method:h,u_highlights:y.highlightColor,u_shadows:y.shadowColor}},lu=(_,t)=>{const n=t.stride,A=d.N();return d.c7(A,0,d.a5,-d.a5,0,0,1),d.O(A,A,[0,-d.a5,0]),{u_matrix:A,u_image:1,u_dimension:[n,n],u_zoom:_.overscaledZ,u_unpack:t.getUnpackVector()}};function sn(_,t){const n=Math.pow(2,t.canonical.z),A=t.canonical.y;return[new d.a9(0,A/n).toLngLat().lat,new d.a9(0,(A+1)/n).toLngLat().lat]}const Ga=(_,t,n=0)=>({u_image:0,u_unpack:t.getUnpackVector(),u_dimension:[t.stride,t.stride],u_elevation_stops:1,u_color_stops:4,u_color_ramp_size:n,u_opacity:_.paint.get("color-relief-opacity")}),jn=(_,t,n,A)=>{const h=_.transform;return{u_translation:Vo(_,t,n),u_ratio:A/d.aN(t,1,h.zoom),u_device_pixel_ratio:_.pixelRatio,u_units_to_pixels:[1/h.pixelsToGLUnits[0],1/h.pixelsToGLUnits[1]]}},pA=(_,t,n,A,h)=>d.e(jn(_,t,n,A),{u_image:0,u_image_height:h}),_a=(_,t,n,A,h)=>{const y=_.transform,b=gn(t,y);return{u_translation:Vo(_,t,n),u_texsize:t.imageAtlasTexture.size,u_ratio:A/d.aN(t,1,y.zoom),u_device_pixel_ratio:_.pixelRatio,u_image:0,u_scale:[b,h.fromScale,h.toScale],u_fade:h.t,u_units_to_pixels:[1/y.pixelsToGLUnits[0],1/y.pixelsToGLUnits[1]]}},fA=(_,t,n,A,h)=>{const y=gn(t,_.transform);return d.e(jn(_,t,n,A),{u_tileratio:y,u_crossfade_from:h.fromScale,u_crossfade_to:h.toScale,u_image:0,u_mix:h.t,u_lineatlas_width:_.lineAtlas.width,u_lineatlas_height:_.lineAtlas.height})},Wi=(_,t,n,A,h,y)=>{const b=gn(t,_.transform);return d.e(jn(_,t,n,A),{u_image:0,u_image_height:y,u_tileratio:b,u_crossfade_from:h.fromScale,u_crossfade_to:h.toScale,u_image_dash:1,u_mix:h.t,u_lineatlas_width:_.lineAtlas.width,u_lineatlas_height:_.lineAtlas.height})};function gn(_,t){return 1/d.aN(_,1,t.tileZoom)}function Vo(_,t,n){return d.aO(_.transform,t,n.paint.get("line-translate"),n.paint.get("line-translate-anchor"))}const zs=(_,t,n,A,h)=>{return{u_tl_parent:_,u_scale_parent:t,u_buffer_scale:1,u_fade_t:n.mix,u_opacity:n.opacity*A.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:A.paint.get("raster-brightness-min"),u_brightness_high:A.paint.get("raster-brightness-max"),u_saturation_factor:(b=A.paint.get("raster-saturation"),b>0?1-1/(1.001-b):-b),u_contrast_factor:(y=A.paint.get("raster-contrast"),y>0?1/(1-y):1+y),u_spin_weights:cs(A.paint.get("raster-hue-rotate")),u_coords_top:[h[0].x,h[0].y,h[1].x,h[1].y],u_coords_bottom:[h[3].x,h[3].y,h[2].x,h[2].y]};var y,b};function cs(_){_*=Math.PI/180;const t=Math.sin(_),n=Math.cos(_);return[(2*n+1)/3,(-Math.sqrt(3)*t-n+1)/3,(Math.sqrt(3)*t-n+1)/3]}const Bs=(_,t,n,A,h,y,b,M,I,D,B,V,O)=>{const U=b.transform;return{u_is_size_zoom_constant:+(_==="constant"||_==="source"),u_is_size_feature_constant:+(_==="constant"||_==="camera"),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:U.cameraToCenterDistance,u_pitch:U.pitch/360*2*Math.PI,u_rotate_symbol:+n,u_aspect_ratio:U.width/U.height,u_fade_change:b.options.fadeDuration?b.symbolFadeChange:1,u_label_plane_matrix:M,u_coord_matrix:I,u_is_text:+B,u_pitch_with_map:+A,u_is_along_line:h,u_is_variable_anchor:y,u_texsize:V,u_texture:0,u_translation:D,u_pitched_scale:O}},Ua=(_,t,n,A,h,y,b,M,I,D,B,V,O,U)=>{const X=b.transform;return d.e(Bs(_,t,n,A,h,y,b,M,I,D,B,V,U),{u_gamma_scale:A?Math.cos(X.pitch*Math.PI/180)*X.cameraToCenterDistance:1,u_device_pixel_ratio:b.pixelRatio,u_is_halo:1})},Rs=(_,t,n,A,h,y,b,M,I,D,B,V,O)=>d.e(Ua(_,t,n,A,h,y,b,M,I,D,!0,B,0,O),{u_texsize_icon:V,u_texture_icon:1}),yl=(_,t)=>({u_opacity:_,u_color:t}),vl=(_,t,n,A,h)=>d.e((function(y,b,M,I){const D=M.imageManager.getPattern(y.from.toString()),B=M.imageManager.getPattern(y.to.toString()),{width:V,height:O}=M.imageManager.getPixelSize(),U=Math.pow(2,I.tileID.overscaledZ),X=I.tileSize*Math.pow(2,M.transform.tileZoom)/U,ie=X*(I.tileID.canonical.x+I.tileID.wrap*U),se=X*I.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:D.tl,u_pattern_br_a:D.br,u_pattern_tl_b:B.tl,u_pattern_br_b:B.br,u_texsize:[V,O],u_mix:b.t,u_pattern_size_a:D.displaySize,u_pattern_size_b:B.displaySize,u_scale_a:b.fromScale,u_scale_b:b.toScale,u_tile_units_to_pixels:1/d.aN(I,1,M.transform.tileZoom),u_pixel_coord_upper:[ie>>16,se>>16],u_pixel_coord_lower:[65535&ie,65535&se]}})(n,h,t,A),{u_opacity:_}),dA=(_,t)=>{},Au={fillExtrusion:(_,t)=>({u_lightpos:new d.c2(_,t.u_lightpos),u_lightpos_globe:new d.c2(_,t.u_lightpos_globe),u_lightintensity:new d.bq(_,t.u_lightintensity),u_lightcolor:new d.c2(_,t.u_lightcolor),u_vertical_gradient:new d.bq(_,t.u_vertical_gradient),u_opacity:new d.bq(_,t.u_opacity),u_fill_translate:new d.c3(_,t.u_fill_translate)}),fillExtrusionPattern:(_,t)=>({u_lightpos:new d.c2(_,t.u_lightpos),u_lightpos_globe:new d.c2(_,t.u_lightpos_globe),u_lightintensity:new d.bq(_,t.u_lightintensity),u_lightcolor:new d.c2(_,t.u_lightcolor),u_vertical_gradient:new d.bq(_,t.u_vertical_gradient),u_height_factor:new d.bq(_,t.u_height_factor),u_opacity:new d.bq(_,t.u_opacity),u_fill_translate:new d.c3(_,t.u_fill_translate),u_image:new d.b_(_,t.u_image),u_texsize:new d.c3(_,t.u_texsize),u_pixel_coord_upper:new d.c3(_,t.u_pixel_coord_upper),u_pixel_coord_lower:new d.c3(_,t.u_pixel_coord_lower),u_scale:new d.c2(_,t.u_scale),u_fade:new d.bq(_,t.u_fade)}),fill:(_,t)=>({u_fill_translate:new d.c3(_,t.u_fill_translate)}),fillPattern:(_,t)=>({u_image:new d.b_(_,t.u_image),u_texsize:new d.c3(_,t.u_texsize),u_pixel_coord_upper:new d.c3(_,t.u_pixel_coord_upper),u_pixel_coord_lower:new d.c3(_,t.u_pixel_coord_lower),u_scale:new d.c2(_,t.u_scale),u_fade:new d.bq(_,t.u_fade),u_fill_translate:new d.c3(_,t.u_fill_translate)}),fillOutline:(_,t)=>({u_world:new d.c3(_,t.u_world),u_fill_translate:new d.c3(_,t.u_fill_translate)}),fillOutlinePattern:(_,t)=>({u_world:new d.c3(_,t.u_world),u_image:new d.b_(_,t.u_image),u_texsize:new d.c3(_,t.u_texsize),u_pixel_coord_upper:new d.c3(_,t.u_pixel_coord_upper),u_pixel_coord_lower:new d.c3(_,t.u_pixel_coord_lower),u_scale:new d.c2(_,t.u_scale),u_fade:new d.bq(_,t.u_fade),u_fill_translate:new d.c3(_,t.u_fill_translate)}),circle:(_,t)=>({u_camera_to_center_distance:new d.bq(_,t.u_camera_to_center_distance),u_scale_with_map:new d.b_(_,t.u_scale_with_map),u_pitch_with_map:new d.b_(_,t.u_pitch_with_map),u_extrude_scale:new d.c3(_,t.u_extrude_scale),u_device_pixel_ratio:new d.bq(_,t.u_device_pixel_ratio),u_globe_extrude_scale:new d.bq(_,t.u_globe_extrude_scale),u_translate:new d.c3(_,t.u_translate)}),collisionBox:(_,t)=>({u_pixel_extrude_scale:new d.c3(_,t.u_pixel_extrude_scale)}),collisionCircle:(_,t)=>({u_viewport_size:new d.c3(_,t.u_viewport_size)}),debug:(_,t)=>({u_color:new d.b$(_,t.u_color),u_overlay:new d.b_(_,t.u_overlay),u_overlay_scale:new d.bq(_,t.u_overlay_scale)}),depth:dA,clippingMask:dA,heatmap:(_,t)=>({u_extrude_scale:new d.bq(_,t.u_extrude_scale),u_intensity:new d.bq(_,t.u_intensity),u_globe_extrude_scale:new d.bq(_,t.u_globe_extrude_scale)}),heatmapTexture:(_,t)=>({u_matrix:new d.c0(_,t.u_matrix),u_world:new d.c3(_,t.u_world),u_image:new d.b_(_,t.u_image),u_color_ramp:new d.b_(_,t.u_color_ramp),u_opacity:new d.bq(_,t.u_opacity)}),hillshade:(_,t)=>({u_image:new d.b_(_,t.u_image),u_latrange:new d.c3(_,t.u_latrange),u_exaggeration:new d.bq(_,t.u_exaggeration),u_altitudes:new d.c9(_,t.u_altitudes),u_azimuths:new d.c9(_,t.u_azimuths),u_accent:new d.b$(_,t.u_accent),u_method:new d.b_(_,t.u_method),u_shadows:new d.c8(_,t.u_shadows),u_highlights:new d.c8(_,t.u_highlights)}),hillshadePrepare:(_,t)=>({u_matrix:new d.c0(_,t.u_matrix),u_image:new d.b_(_,t.u_image),u_dimension:new d.c3(_,t.u_dimension),u_zoom:new d.bq(_,t.u_zoom),u_unpack:new d.c1(_,t.u_unpack)}),colorRelief:(_,t)=>({u_image:new d.b_(_,t.u_image),u_unpack:new d.c1(_,t.u_unpack),u_dimension:new d.c3(_,t.u_dimension),u_elevation_stops:new d.b_(_,t.u_elevation_stops),u_color_stops:new d.b_(_,t.u_color_stops),u_color_ramp_size:new d.b_(_,t.u_color_ramp_size),u_opacity:new d.bq(_,t.u_opacity)}),line:(_,t)=>({u_translation:new d.c3(_,t.u_translation),u_ratio:new d.bq(_,t.u_ratio),u_device_pixel_ratio:new d.bq(_,t.u_device_pixel_ratio),u_units_to_pixels:new d.c3(_,t.u_units_to_pixels)}),lineGradient:(_,t)=>({u_translation:new d.c3(_,t.u_translation),u_ratio:new d.bq(_,t.u_ratio),u_device_pixel_ratio:new d.bq(_,t.u_device_pixel_ratio),u_units_to_pixels:new d.c3(_,t.u_units_to_pixels),u_image:new d.b_(_,t.u_image),u_image_height:new d.bq(_,t.u_image_height)}),linePattern:(_,t)=>({u_translation:new d.c3(_,t.u_translation),u_texsize:new d.c3(_,t.u_texsize),u_ratio:new d.bq(_,t.u_ratio),u_device_pixel_ratio:new d.bq(_,t.u_device_pixel_ratio),u_image:new d.b_(_,t.u_image),u_units_to_pixels:new d.c3(_,t.u_units_to_pixels),u_scale:new d.c2(_,t.u_scale),u_fade:new d.bq(_,t.u_fade)}),lineSDF:(_,t)=>({u_translation:new d.c3(_,t.u_translation),u_ratio:new d.bq(_,t.u_ratio),u_device_pixel_ratio:new d.bq(_,t.u_device_pixel_ratio),u_units_to_pixels:new d.c3(_,t.u_units_to_pixels),u_image:new d.b_(_,t.u_image),u_mix:new d.bq(_,t.u_mix),u_tileratio:new d.bq(_,t.u_tileratio),u_crossfade_from:new d.bq(_,t.u_crossfade_from),u_crossfade_to:new d.bq(_,t.u_crossfade_to),u_lineatlas_width:new d.bq(_,t.u_lineatlas_width),u_lineatlas_height:new d.bq(_,t.u_lineatlas_height)}),lineGradientSDF:(_,t)=>({u_translation:new d.c3(_,t.u_translation),u_ratio:new d.bq(_,t.u_ratio),u_device_pixel_ratio:new d.bq(_,t.u_device_pixel_ratio),u_units_to_pixels:new d.c3(_,t.u_units_to_pixels),u_image:new d.b_(_,t.u_image),u_image_height:new d.bq(_,t.u_image_height),u_tileratio:new d.bq(_,t.u_tileratio),u_crossfade_from:new d.bq(_,t.u_crossfade_from),u_crossfade_to:new d.bq(_,t.u_crossfade_to),u_image_dash:new d.b_(_,t.u_image_dash),u_mix:new d.bq(_,t.u_mix),u_lineatlas_width:new d.bq(_,t.u_lineatlas_width),u_lineatlas_height:new d.bq(_,t.u_lineatlas_height)}),raster:(_,t)=>({u_tl_parent:new d.c3(_,t.u_tl_parent),u_scale_parent:new d.bq(_,t.u_scale_parent),u_buffer_scale:new d.bq(_,t.u_buffer_scale),u_fade_t:new d.bq(_,t.u_fade_t),u_opacity:new d.bq(_,t.u_opacity),u_image0:new d.b_(_,t.u_image0),u_image1:new d.b_(_,t.u_image1),u_brightness_low:new d.bq(_,t.u_brightness_low),u_brightness_high:new d.bq(_,t.u_brightness_high),u_saturation_factor:new d.bq(_,t.u_saturation_factor),u_contrast_factor:new d.bq(_,t.u_contrast_factor),u_spin_weights:new d.c2(_,t.u_spin_weights),u_coords_top:new d.c1(_,t.u_coords_top),u_coords_bottom:new d.c1(_,t.u_coords_bottom)}),symbolIcon:(_,t)=>({u_is_size_zoom_constant:new d.b_(_,t.u_is_size_zoom_constant),u_is_size_feature_constant:new d.b_(_,t.u_is_size_feature_constant),u_size_t:new d.bq(_,t.u_size_t),u_size:new d.bq(_,t.u_size),u_camera_to_center_distance:new d.bq(_,t.u_camera_to_center_distance),u_pitch:new d.bq(_,t.u_pitch),u_rotate_symbol:new d.b_(_,t.u_rotate_symbol),u_aspect_ratio:new d.bq(_,t.u_aspect_ratio),u_fade_change:new d.bq(_,t.u_fade_change),u_label_plane_matrix:new d.c0(_,t.u_label_plane_matrix),u_coord_matrix:new d.c0(_,t.u_coord_matrix),u_is_text:new d.b_(_,t.u_is_text),u_pitch_with_map:new d.b_(_,t.u_pitch_with_map),u_is_along_line:new d.b_(_,t.u_is_along_line),u_is_variable_anchor:new d.b_(_,t.u_is_variable_anchor),u_texsize:new d.c3(_,t.u_texsize),u_texture:new d.b_(_,t.u_texture),u_translation:new d.c3(_,t.u_translation),u_pitched_scale:new d.bq(_,t.u_pitched_scale)}),symbolSDF:(_,t)=>({u_is_size_zoom_constant:new d.b_(_,t.u_is_size_zoom_constant),u_is_size_feature_constant:new d.b_(_,t.u_is_size_feature_constant),u_size_t:new d.bq(_,t.u_size_t),u_size:new d.bq(_,t.u_size),u_camera_to_center_distance:new d.bq(_,t.u_camera_to_center_distance),u_pitch:new d.bq(_,t.u_pitch),u_rotate_symbol:new d.b_(_,t.u_rotate_symbol),u_aspect_ratio:new d.bq(_,t.u_aspect_ratio),u_fade_change:new d.bq(_,t.u_fade_change),u_label_plane_matrix:new d.c0(_,t.u_label_plane_matrix),u_coord_matrix:new d.c0(_,t.u_coord_matrix),u_is_text:new d.b_(_,t.u_is_text),u_pitch_with_map:new d.b_(_,t.u_pitch_with_map),u_is_along_line:new d.b_(_,t.u_is_along_line),u_is_variable_anchor:new d.b_(_,t.u_is_variable_anchor),u_texsize:new d.c3(_,t.u_texsize),u_texture:new d.b_(_,t.u_texture),u_gamma_scale:new d.bq(_,t.u_gamma_scale),u_device_pixel_ratio:new d.bq(_,t.u_device_pixel_ratio),u_is_halo:new d.b_(_,t.u_is_halo),u_translation:new d.c3(_,t.u_translation),u_pitched_scale:new d.bq(_,t.u_pitched_scale)}),symbolTextAndIcon:(_,t)=>({u_is_size_zoom_constant:new d.b_(_,t.u_is_size_zoom_constant),u_is_size_feature_constant:new d.b_(_,t.u_is_size_feature_constant),u_size_t:new d.bq(_,t.u_size_t),u_size:new d.bq(_,t.u_size),u_camera_to_center_distance:new d.bq(_,t.u_camera_to_center_distance),u_pitch:new d.bq(_,t.u_pitch),u_rotate_symbol:new d.b_(_,t.u_rotate_symbol),u_aspect_ratio:new d.bq(_,t.u_aspect_ratio),u_fade_change:new d.bq(_,t.u_fade_change),u_label_plane_matrix:new d.c0(_,t.u_label_plane_matrix),u_coord_matrix:new d.c0(_,t.u_coord_matrix),u_is_text:new d.b_(_,t.u_is_text),u_pitch_with_map:new d.b_(_,t.u_pitch_with_map),u_is_along_line:new d.b_(_,t.u_is_along_line),u_is_variable_anchor:new d.b_(_,t.u_is_variable_anchor),u_texsize:new d.c3(_,t.u_texsize),u_texsize_icon:new d.c3(_,t.u_texsize_icon),u_texture:new d.b_(_,t.u_texture),u_texture_icon:new d.b_(_,t.u_texture_icon),u_gamma_scale:new d.bq(_,t.u_gamma_scale),u_device_pixel_ratio:new d.bq(_,t.u_device_pixel_ratio),u_is_halo:new d.b_(_,t.u_is_halo),u_translation:new d.c3(_,t.u_translation),u_pitched_scale:new d.bq(_,t.u_pitched_scale)}),background:(_,t)=>({u_opacity:new d.bq(_,t.u_opacity),u_color:new d.b$(_,t.u_color)}),backgroundPattern:(_,t)=>({u_opacity:new d.bq(_,t.u_opacity),u_image:new d.b_(_,t.u_image),u_pattern_tl_a:new d.c3(_,t.u_pattern_tl_a),u_pattern_br_a:new d.c3(_,t.u_pattern_br_a),u_pattern_tl_b:new d.c3(_,t.u_pattern_tl_b),u_pattern_br_b:new d.c3(_,t.u_pattern_br_b),u_texsize:new d.c3(_,t.u_texsize),u_mix:new d.bq(_,t.u_mix),u_pattern_size_a:new d.c3(_,t.u_pattern_size_a),u_pattern_size_b:new d.c3(_,t.u_pattern_size_b),u_scale_a:new d.bq(_,t.u_scale_a),u_scale_b:new d.bq(_,t.u_scale_b),u_pixel_coord_upper:new d.c3(_,t.u_pixel_coord_upper),u_pixel_coord_lower:new d.c3(_,t.u_pixel_coord_lower),u_tile_units_to_pixels:new d.bq(_,t.u_tile_units_to_pixels)}),terrain:(_,t)=>({u_texture:new d.b_(_,t.u_texture),u_ele_delta:new d.bq(_,t.u_ele_delta),u_fog_matrix:new d.c0(_,t.u_fog_matrix),u_fog_color:new d.b$(_,t.u_fog_color),u_fog_ground_blend:new d.bq(_,t.u_fog_ground_blend),u_fog_ground_blend_opacity:new d.bq(_,t.u_fog_ground_blend_opacity),u_horizon_color:new d.b$(_,t.u_horizon_color),u_horizon_fog_blend:new d.bq(_,t.u_horizon_fog_blend),u_is_globe_mode:new d.bq(_,t.u_is_globe_mode)}),terrainDepth:(_,t)=>({u_ele_delta:new d.bq(_,t.u_ele_delta)}),terrainCoords:(_,t)=>({u_texture:new d.b_(_,t.u_texture),u_terrain_coords_id:new d.bq(_,t.u_terrain_coords_id),u_ele_delta:new d.bq(_,t.u_ele_delta)}),projectionErrorMeasurement:(_,t)=>({u_input:new d.bq(_,t.u_input),u_output_expected:new d.bq(_,t.u_output_expected)}),atmosphere:(_,t)=>({u_sun_pos:new d.c2(_,t.u_sun_pos),u_atmosphere_blend:new d.bq(_,t.u_atmosphere_blend),u_globe_position:new d.c2(_,t.u_globe_position),u_globe_radius:new d.bq(_,t.u_globe_radius),u_inv_proj_matrix:new d.c0(_,t.u_inv_proj_matrix)}),sky:(_,t)=>({u_sky_color:new d.b$(_,t.u_sky_color),u_horizon_color:new d.b$(_,t.u_horizon_color),u_horizon:new d.c3(_,t.u_horizon),u_horizon_normal:new d.c3(_,t.u_horizon_normal),u_sky_horizon_blend:new d.bq(_,t.u_sky_horizon_blend),u_sky_blend:new d.bq(_,t.u_sky_blend)})};class xl{constructor(t,n,A){this.context=t;const h=t.gl;this.buffer=h.createBuffer(),this.dynamicDraw=!!A,this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),h.bufferData(h.ELEMENT_ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?h.DYNAMIC_DRAW:h.STATIC_DRAW),this.dynamicDraw||delete n.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){const n=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),n.bufferSubData(n.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const bl={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class wl{constructor(t,n,A,h){this.length=n.length,this.attributes=A,this.itemSize=n.bytesPerElement,this.dynamicDraw=h,this.context=t;const y=t.gl;this.buffer=y.createBuffer(),t.bindVertexBuffer.set(this.buffer),y.bufferData(y.ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?y.DYNAMIC_DRAW:y.STATIC_DRAW),this.dynamicDraw||delete n.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(t){if(t.length!==this.length)throw new Error(`Length of new data is ${t.length}, which doesn't match current length of ${this.length}`);const n=this.context.gl;this.bind(),n.bufferSubData(n.ARRAY_BUFFER,0,t.arrayBuffer)}enableAttributes(t,n){for(let A=0;A<this.attributes.length;A++){const h=n.attributes[this.attributes[A].name];h!==void 0&&t.enableVertexAttribArray(h)}}setVertexAttribPointers(t,n,A){for(let h=0;h<this.attributes.length;h++){const y=this.attributes[h],b=n.attributes[y.name];b!==void 0&&t.vertexAttribPointer(b,y.components,t[bl[y.type]],!1,this.itemSize,y.offset+this.itemSize*(A||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class lr{constructor(t){this.gl=t.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(t){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class hs extends lr{getDefault(){return d.bp.transparent}set(t){const n=this.current;(t.r!==n.r||t.g!==n.g||t.b!==n.b||t.a!==n.a||this.dirty)&&(this.gl.clearColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class zi extends lr{getDefault(){return 1}set(t){(t!==this.current||this.dirty)&&(this.gl.clearDepth(t),this.current=t,this.dirty=!1)}}class qa extends lr{getDefault(){return 0}set(t){(t!==this.current||this.dirty)&&(this.gl.clearStencil(t),this.current=t,this.dirty=!1)}}class so extends lr{getDefault(){return[!0,!0,!0,!0]}set(t){const n=this.current;(t[0]!==n[0]||t[1]!==n[1]||t[2]!==n[2]||t[3]!==n[3]||this.dirty)&&(this.gl.colorMask(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class oo extends lr{getDefault(){return!0}set(t){(t!==this.current||this.dirty)&&(this.gl.depthMask(t),this.current=t,this.dirty=!1)}}class ya extends lr{getDefault(){return 255}set(t){(t!==this.current||this.dirty)&&(this.gl.stencilMask(t),this.current=t,this.dirty=!1)}}class jo extends lr{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(t){const n=this.current;(t.func!==n.func||t.ref!==n.ref||t.mask!==n.mask||this.dirty)&&(this.gl.stencilFunc(t.func,t.ref,t.mask),this.current=t,this.dirty=!1)}}class _n extends lr{getDefault(){const t=this.gl;return[t.KEEP,t.KEEP,t.KEEP]}set(t){const n=this.current;(t[0]!==n[0]||t[1]!==n[1]||t[2]!==n[2]||this.dirty)&&(this.gl.stencilOp(t[0],t[1],t[2]),this.current=t,this.dirty=!1)}}class mA extends lr{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;t?n.enable(n.STENCIL_TEST):n.disable(n.STENCIL_TEST),this.current=t,this.dirty=!1}}class gA extends lr{getDefault(){return[0,1]}set(t){const n=this.current;(t[0]!==n[0]||t[1]!==n[1]||this.dirty)&&(this.gl.depthRange(t[0],t[1]),this.current=t,this.dirty=!1)}}class Tl extends lr{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;t?n.enable(n.DEPTH_TEST):n.disable(n.DEPTH_TEST),this.current=t,this.dirty=!1}}class Xn extends lr{getDefault(){return this.gl.LESS}set(t){(t!==this.current||this.dirty)&&(this.gl.depthFunc(t),this.current=t,this.dirty=!1)}}class va extends lr{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;t?n.enable(n.BLEND):n.disable(n.BLEND),this.current=t,this.dirty=!1}}class No extends lr{getDefault(){const t=this.gl;return[t.ONE,t.ZERO]}set(t){const n=this.current;(t[0]!==n[0]||t[1]!==n[1]||this.dirty)&&(this.gl.blendFunc(t[0],t[1]),this.current=t,this.dirty=!1)}}class xa extends lr{getDefault(){return d.bp.transparent}set(t){const n=this.current;(t.r!==n.r||t.g!==n.g||t.b!==n.b||t.a!==n.a||this.dirty)&&(this.gl.blendColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class Za extends lr{getDefault(){return this.gl.FUNC_ADD}set(t){(t!==this.current||this.dirty)&&(this.gl.blendEquation(t),this.current=t,this.dirty=!1)}}class _A extends lr{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;t?n.enable(n.CULL_FACE):n.disable(n.CULL_FACE),this.current=t,this.dirty=!1}}class Go extends lr{getDefault(){return this.gl.BACK}set(t){(t!==this.current||this.dirty)&&(this.gl.cullFace(t),this.current=t,this.dirty=!1)}}class Uo extends lr{getDefault(){return this.gl.CCW}set(t){(t!==this.current||this.dirty)&&(this.gl.frontFace(t),this.current=t,this.dirty=!1)}}class yA extends lr{getDefault(){return null}set(t){(t!==this.current||this.dirty)&&(this.gl.useProgram(t),this.current=t,this.dirty=!1)}}class Pl extends lr{getDefault(){return this.gl.TEXTURE0}set(t){(t!==this.current||this.dirty)&&(this.gl.activeTexture(t),this.current=t,this.dirty=!1)}}class tr extends lr{getDefault(){const t=this.gl;return[0,0,t.drawingBufferWidth,t.drawingBufferHeight]}set(t){const n=this.current;(t[0]!==n[0]||t[1]!==n[1]||t[2]!==n[2]||t[3]!==n[3]||this.dirty)&&(this.gl.viewport(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class Qa extends lr{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.bindFramebuffer(n.FRAMEBUFFER,t),this.current=t,this.dirty=!1}}class vA extends lr{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.bindRenderbuffer(n.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class Yn extends lr{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.bindTexture(n.TEXTURE_2D,t),this.current=t,this.dirty=!1}}class qo extends lr{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.bindBuffer(n.ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class uu extends lr{getDefault(){return null}set(t){const n=this.gl;n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class cu extends lr{getDefault(){return null}set(t){var n;if(t===this.current&&!this.dirty)return;const A=this.gl;mn(A)?A.bindVertexArray(t):(n=A.getExtension("OES_vertex_array_object"))===null||n===void 0||n.bindVertexArrayOES(t),this.current=t,this.dirty=!1}}class xA extends lr{getDefault(){return 4}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.pixelStorei(n.UNPACK_ALIGNMENT,t),this.current=t,this.dirty=!1}}class hu extends lr{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t),this.current=t,this.dirty=!1}}class Ml extends lr{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,t),this.current=t,this.dirty=!1}}class yn extends lr{constructor(t,n){super(t),this.context=t,this.parent=n}getDefault(){return null}}class ao extends yn{setDirty(){this.dirty=!0}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const n=this.gl;n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,t,0),this.current=t,this.dirty=!1}}class $a extends yn{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const n=this.gl;n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class Zo extends yn{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const n=this.gl;n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,t),this.current=t,this.dirty=!1}}const Wa="Framebuffer is not complete";class Ha{constructor(t,n,A,h,y){this.context=t,this.width=n,this.height=A;const b=t.gl,M=this.framebuffer=b.createFramebuffer();if(this.colorAttachment=new ao(t,M),h)this.depthAttachment=y?new Zo(t,M):new $a(t,M);else if(y)throw new Error("Stencil cannot be set without depth");if(b.checkFramebufferStatus(b.FRAMEBUFFER)!==b.FRAMEBUFFER_COMPLETE)throw new Error(Wa)}destroy(){const t=this.context.gl,n=this.colorAttachment.get();if(n&&t.deleteTexture(n),this.depthAttachment){const A=this.depthAttachment.get();A&&t.deleteRenderbuffer(A)}t.deleteFramebuffer(this.framebuffer)}}class Xa{constructor(t){var n,A;if(this.gl=t,this.clearColor=new hs(this),this.clearDepth=new zi(this),this.clearStencil=new qa(this),this.colorMask=new so(this),this.depthMask=new oo(this),this.stencilMask=new ya(this),this.stencilFunc=new jo(this),this.stencilOp=new _n(this),this.stencilTest=new mA(this),this.depthRange=new gA(this),this.depthTest=new Tl(this),this.depthFunc=new Xn(this),this.blend=new va(this),this.blendFunc=new No(this),this.blendColor=new xa(this),this.blendEquation=new Za(this),this.cullFace=new _A(this),this.cullFaceSide=new Go(this),this.frontFace=new Uo(this),this.program=new yA(this),this.activeTexture=new Pl(this),this.viewport=new tr(this),this.bindFramebuffer=new Qa(this),this.bindRenderbuffer=new vA(this),this.bindTexture=new Yn(this),this.bindVertexBuffer=new qo(this),this.bindElementBuffer=new uu(this),this.bindVertexArray=new cu(this),this.pixelStoreUnpack=new xA(this),this.pixelStoreUnpackPremultiplyAlpha=new hu(this),this.pixelStoreUnpackFlipY=new Ml(this),this.extTextureFilterAnisotropic=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_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),mn(t)){this.HALF_FLOAT=t.HALF_FLOAT;const h=t.getExtension("EXT_color_buffer_half_float");this.RGBA16F=(n=t.RGBA16F)!==null&&n!==void 0?n:h==null?void 0:h.RGBA16F_EXT,this.RGB16F=(A=t.RGB16F)!==null&&A!==void 0?A:h==null?void 0:h.RGB16F_EXT,t.getExtension("EXT_color_buffer_float")}else{t.getExtension("EXT_color_buffer_half_float"),t.getExtension("OES_texture_half_float_linear");const h=t.getExtension("OES_texture_half_float");this.HALF_FLOAT=h==null?void 0:h.HALF_FLOAT_OES}}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArray.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(t,n){return new xl(this,t,n)}createVertexBuffer(t,n,A){return new wl(this,t,n,A)}createRenderbuffer(t,n,A){const h=this.gl,y=h.createRenderbuffer();return this.bindRenderbuffer.set(y),h.renderbufferStorage(h.RENDERBUFFER,t,n,A),this.bindRenderbuffer.set(null),y}createFramebuffer(t,n,A,h){return new Ha(this,t,n,A,h)}clear({color:t,depth:n,stencil:A}){const h=this.gl;let y=0;t&&(y|=h.COLOR_BUFFER_BIT,this.clearColor.set(t),this.colorMask.set([!0,!0,!0,!0])),n!==void 0&&(y|=h.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(n),this.depthMask.set(!0)),A!==void 0&&(y|=h.STENCIL_BUFFER_BIT,this.clearStencil.set(A),this.stencilMask.set(255)),h.clear(y)}setCullFace(t){t.enable===!1?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){d.bR(t.blendFunction,rr.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(t.blendFunction),this.blendColor.set(t.blendColor)),this.colorMask.set(t.mask)}createVertexArray(){var t;return mn(this.gl)?this.gl.createVertexArray():(t=this.gl.getExtension("OES_vertex_array_object"))===null||t===void 0?void 0:t.createVertexArrayOES()}deleteVertexArray(t){var n;return mn(this.gl)?this.gl.deleteVertexArray(t):(n=this.gl.getExtension("OES_vertex_array_object"))===null||n===void 0?void 0:n.deleteVertexArrayOES(t)}unbindVAO(){this.bindVertexArray.set(null)}}let En;function Ls(_,t,n,A,h){const y=_.context,b=_.transform,M=y.gl,I=_.useProgram("collisionBox"),D=[];let B=0,V=0;for(let ne=0;ne<A.length;ne++){const ce=A[ne],ge=t.getTile(ce).getBucket(n);if(!ge)continue;const Ae=h?ge.textCollisionBox:ge.iconCollisionBox,de=ge.collisionCircleArray;de.length>0&&(D.push({circleArray:de,circleOffset:V,coord:ce}),B+=de.length/4,V=B),Ae&&I.draw(y,M.LINES,Zt.disabled,ur.disabled,_.colorModeForRenderPass(),or.disabled,no(_.transform),_.style.map.terrain&&_.style.map.terrain.getTerrainData(ce),b.getProjectionData({overscaledTileID:ce,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),n.id,Ae.layoutVertexBuffer,Ae.indexBuffer,Ae.segments,null,_.transform.zoom,null,null,Ae.collisionVertexBuffer)}if(!h||!D.length)return;const O=_.useProgram("collisionCircle"),U=new d.ca;U.resize(4*B),U._trim();let X=0;for(const ne of D)for(let ce=0;ce<ne.circleArray.length/4;ce++){const ge=4*ce,Ae=ne.circleArray[ge+0],de=ne.circleArray[ge+1],ye=ne.circleArray[ge+2],fe=ne.circleArray[ge+3];U.emplace(X++,Ae,de,ye,fe,0),U.emplace(X++,Ae,de,ye,fe,1),U.emplace(X++,Ae,de,ye,fe,2),U.emplace(X++,Ae,de,ye,fe,3)}(!En||En.length<2*B)&&(En=(function(ne){const ce=2*ne,ge=new d.cc;ge.resize(ce),ge._trim();for(let Ae=0;Ae<ce;Ae++){const de=6*Ae;ge.uint16[de+0]=4*Ae+0,ge.uint16[de+1]=4*Ae+1,ge.uint16[de+2]=4*Ae+2,ge.uint16[de+3]=4*Ae+2,ge.uint16[de+4]=4*Ae+3,ge.uint16[de+5]=4*Ae+0}return ge})(B));const ie=y.createIndexBuffer(En,!0),se=y.createVertexBuffer(U,d.cb.members,!0);for(const ne of D){const ce=_l(_.transform);O.draw(y,M.TRIANGLES,Zt.disabled,ur.disabled,_.colorModeForRenderPass(),or.disabled,ce,_.style.map.terrain&&_.style.map.terrain.getTerrainData(ne.coord),null,n.id,se,ie,d.aX.simpleSegment(0,2*ne.circleOffset,ne.circleArray.length,ne.circleArray.length/2),null,_.transform.zoom,null,null,null)}se.destroy(),ie.destroy()}const lo=d.ar(new Float32Array(16));function El(_,t,n,A,h,y){const{horizontalAlign:b,verticalAlign:M}=d.aS(_);return new d.P((-(b-.5)*t/h+A[0])*y,(-(M-.5)*n/h+A[1])*y)}function Ao(_,t,n,A,h,y){const b=t.tileAnchorPoint.add(new d.P(t.translation[0],t.translation[1]));if(t.pitchWithMap){let M=A.mult(y);n||(M=M.rotate(-h));const I=b.add(M);return qt(I.x,I.y,t.pitchedLabelPlaneMatrix,t.getElevation).point}if(n){const M=Pt(t.tileAnchorPoint.x+1,t.tileAnchorPoint.y,t).point.sub(_),I=Math.atan(M.y/M.x)+(M.x<0?Math.PI:0);return _.add(A.rotate(I))}return _.add(A)}function bA(_,t,n,A,h,y,b,M,I,D,B,V){const O=_.text.placedSymbolArray,U=_.text.dynamicLayoutVertexArray,X=_.icon.dynamicLayoutVertexArray,ie={};U.clear();for(let se=0;se<O.length;se++){const ne=O.get(se),ce=ne.hidden||!ne.crossTileID||_.allowVerticalPlacement&&!ne.placedOrientation?null:A[ne.crossTileID];if(ce){const ge=new d.P(ne.anchorX,ne.anchorY),Ae={getElevation:V,width:h.width,height:h.height,pitchedLabelPlaneMatrix:y,pitchWithMap:n,transform:h,tileAnchorPoint:ge,translation:D,unwrappedTileID:B},de=n?zt(ge.x,ge.y,Ae):Pt(ge.x,ge.y,Ae),ye=oa(h.cameraToCenterDistance,de.signedDistanceFromCamera);let fe=d.aA(_.textSizeData,M,ne)*ye/d.aM;n&&(fe*=_.tilePixelRatio/b);const{width:Me,height:Ge,anchor:Fe,textOffset:Oe,textBoxScale:Ve}=ce,ut=El(Fe,Me,Ge,Oe,Ve,fe),ht=h.getPitchedTextCorrection(ge.x+D[0],ge.y+D[1],B),rt=Ao(de.point,Ae,t,ut,-h.bearingInRadians,ht),ft=_.allowVerticalPlacement&&ne.placedOrientation===d.az.vertical?Math.PI/2:0;for(let Wt=0;Wt<ne.numGlyphs;Wt++)d.aG(U,rt,ft);I&&ne.associatedIconIndex>=0&&(ie[ne.associatedIconIndex]={shiftedAnchor:rt,angle:ft})}else Ks(ne.numGlyphs,U)}if(I){X.clear();const se=_.icon.placedSymbolArray;for(let ne=0;ne<se.length;ne++){const ce=se.get(ne);if(ce.hidden)Ks(ce.numGlyphs,X);else{const ge=ie[ne];if(ge)for(let Ae=0;Ae<ce.numGlyphs;Ae++)d.aG(X,ge.shiftedAnchor,ge.angle);else Ks(ce.numGlyphs,X)}}_.icon.dynamicLayoutVertexBuffer.updateData(X)}_.text.dynamicLayoutVertexBuffer.updateData(U)}function ba(_,t,n){return n.iconsInText&&t?"symbolTextAndIcon":_?"symbolSDF":"symbolIcon"}function Qo(_,t,n,A,h,y,b,M,I,D,B,V,O){const U=_.context,X=U.gl,ie=_.transform,se=M==="map",ne=I==="map",ce=M!=="viewport"&&n.layout.get("symbol-placement")!=="point",ge=se&&!ne&&!ce,Ae=!n.layout.get("symbol-sort-key").isConstant();let de=!1;const ye=_.getDepthModeForSublayer(0,Zt.ReadOnly),fe=n._unevaluatedLayout.hasValue("text-variable-anchor")||n._unevaluatedLayout.hasValue("text-variable-anchor-offset"),Me=[],Ge=ie.getCircleRadiusCorrection();for(const Fe of A){const Oe=t.getTile(Fe),Ve=Oe.getBucket(n);if(!Ve)continue;const ut=h?Ve.text:Ve.icon;if(!ut||!ut.segments.get().length||!ut.hasVisibleVertices)continue;const ht=ut.programConfigurations.get(n.id),rt=h||Ve.sdfIcons,ft=h?Ve.textSizeData:Ve.iconSizeData,Wt=ne||ie.pitch!==0,Tr=_.useProgram(ba(rt,h,Ve),ht),Ur=d.ay(ft,ie.zoom),Dr=_.style.map.terrain&&_.style.map.terrain.getTerrainData(Fe);let Wr,kr,ri,Hr,Li=[0,0],pi=null;if(h)kr=Oe.glyphAtlasTexture,ri=X.LINEAR,Wr=Oe.glyphAtlasTexture.size,Ve.iconsInText&&(Li=Oe.imageAtlasTexture.size,pi=Oe.imageAtlasTexture,Hr=Wt||_.options.rotating||_.options.zooming||ft.kind==="composite"||ft.kind==="camera"?X.LINEAR:X.NEAREST);else{const Fr=n.layout.get("icon-size").constantOr(0)!==1||Ve.iconsNeedLinear;kr=Oe.imageAtlasTexture,ri=rt||_.options.rotating||_.options.zooming||Fr||Wt?X.LINEAR:X.NEAREST,Wr=Oe.imageAtlasTexture.size}const ui=d.aN(Oe,1,_.transform.zoom),Hi=Jt(se,_.transform,ui),Xo=d.N();d.aB(Xo,Hi);const ho=Yt(ne,se,_.transform,ui),Os=d.aO(ie,Oe,y,b),Sn=ie.getProjectionData({overscaledTileID:Fe,applyGlobeMatrix:!O,applyTerrainMatrix:!0}),Sa=fe&&Ve.hasTextData(),Nl=n.layout.get("icon-text-fit")!=="none"&&Sa&&Ve.hasIconData();if(ce){const Fr=_.style.map.terrain?(Mi,Ei)=>_.style.map.terrain.getElevation(Fe,Mi,Ei):null,zr=n.layout.get("text-rotation-alignment")==="map";Zi(Ve,_,h,Hi,Xo,ne,D,zr,Fe.toUnwrapped(),ie.width,ie.height,Os,Fr)}const Ca=h&&fe||Nl,ts=ce||Ca?lo:ne?Hi:_.transform.clipSpaceToPixelsMatrix,Vs=rt&&n.paint.get(h?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let ms;ms=rt?Ve.iconsInText?Rs(ft.kind,Ur,ge,ne,ce,Ca,_,ts,ho,Os,Wr,Li,Ge):Ua(ft.kind,Ur,ge,ne,ce,Ca,_,ts,ho,Os,h,Wr,0,Ge):Bs(ft.kind,Ur,ge,ne,ce,Ca,_,ts,ho,Os,h,Wr,Ge);const gs={program:Tr,buffers:ut,uniformValues:ms,projectionData:Sn,atlasTexture:kr,atlasTextureIcon:pi,atlasInterpolation:ri,atlasInterpolationIcon:Hr,isSDF:rt,hasHalo:Vs};if(Ae&&Ve.canOverlap){de=!0;const Fr=ut.segments.get();for(const zr of Fr)Me.push({segments:new d.aX([zr]),sortKey:zr.sortKey,state:gs,terrainData:Dr})}else Me.push({segments:ut.segments,sortKey:0,state:gs,terrainData:Dr})}de&&Me.sort(((Fe,Oe)=>Fe.sortKey-Oe.sortKey));for(const Fe of Me){const Oe=Fe.state;if(U.activeTexture.set(X.TEXTURE0),Oe.atlasTexture.bind(Oe.atlasInterpolation,X.CLAMP_TO_EDGE),Oe.atlasTextureIcon&&(U.activeTexture.set(X.TEXTURE1),Oe.atlasTextureIcon&&Oe.atlasTextureIcon.bind(Oe.atlasInterpolationIcon,X.CLAMP_TO_EDGE)),Oe.isSDF){const Ve=Oe.uniformValues;Oe.hasHalo&&(Ve.u_is_halo=1,Ya(Oe.buffers,Fe.segments,n,_,Oe.program,ye,B,V,Ve,Oe.projectionData,Fe.terrainData)),Ve.u_is_halo=0}Ya(Oe.buffers,Fe.segments,n,_,Oe.program,ye,B,V,Oe.uniformValues,Oe.projectionData,Fe.terrainData)}}function Ya(_,t,n,A,h,y,b,M,I,D,B){const V=A.context;h.draw(V,V.gl.TRIANGLES,y,b,M,or.backCCW,I,B,D,n.id,_.layoutVertexBuffer,_.indexBuffer,t,n.paint,A.transform.zoom,_.programConfigurations.get(n.id),_.dynamicLayoutVertexBuffer,_.opacityVertexBuffer)}function wA(_,t,n,A,h){const y=_.context,b=y.gl,M=ur.disabled,I=new rr([b.ONE,b.ONE],d.bp.transparent,[!0,!0,!0,!0]),D=t.getBucket(n);if(!D)return;const B=A.key;let V=n.heatmapFbos.get(B);V||(V=wa(y,t.tileSize,t.tileSize),n.heatmapFbos.set(B,V)),y.bindFramebuffer.set(V.framebuffer),y.viewport.set([0,0,t.tileSize,t.tileSize]),y.clear({color:d.bp.transparent});const O=D.programConfigurations.get(n.id),U=_.useProgram("heatmap",O,!h),X=_.transform.getProjectionData({overscaledTileID:t.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),ie=_.style.map.terrain.getTerrainData(A);U.draw(y,b.TRIANGLES,Zt.disabled,M,I,or.disabled,Oo(t,_.transform.zoom,n.paint.get("heatmap-intensity"),1),ie,X,n.id,D.layoutVertexBuffer,D.indexBuffer,D.segments,n.paint,_.transform.zoom,O)}function TA(_,t,n,A,h){const y=_.context,b=y.gl,M=_.transform;y.setColorMode(_.colorModeForRenderPass());const I=Ka(y,t),D=n.key,B=t.heatmapFbos.get(D);if(!B)return;y.activeTexture.set(b.TEXTURE0),b.bindTexture(b.TEXTURE_2D,B.colorAttachment.get()),y.activeTexture.set(b.TEXTURE1),I.bind(b.LINEAR,b.CLAMP_TO_EDGE);const V=M.getProjectionData({overscaledTileID:n,applyTerrainMatrix:h,applyGlobeMatrix:!A});_.useProgram("heatmapTexture").draw(y,b.TRIANGLES,Zt.disabled,ur.disabled,_.colorModeForRenderPass(),or.disabled,hA(_,t,0,1),null,V,t.id,_.rasterBoundsBuffer,_.quadTriangleIndexBuffer,_.rasterBoundsSegments,t.paint,M.zoom),B.destroy(),t.heatmapFbos.delete(D)}function wa(_,t,n){var A,h;const y=_.gl,b=y.createTexture();y.bindTexture(y.TEXTURE_2D,b),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_WRAP_S,y.CLAMP_TO_EDGE),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_WRAP_T,y.CLAMP_TO_EDGE),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_MIN_FILTER,y.LINEAR),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_MAG_FILTER,y.LINEAR);const M=(A=_.HALF_FLOAT)!==null&&A!==void 0?A:y.UNSIGNED_BYTE,I=(h=_.RGBA16F)!==null&&h!==void 0?h:y.RGBA;y.texImage2D(y.TEXTURE_2D,0,I,t,n,0,y.RGBA,M,null);const D=_.createFramebuffer(t,n,!1,!1);return D.colorAttachment.set(b),D}function Ka(_,t){return t.colorRampTexture||(t.colorRampTexture=new d.T(_,t.colorRamp,_.gl.RGBA)),t.colorRampTexture}function PA(_,t,n,A,h,y,b,M){let I=256;if(h.stepInterpolant){const D=t.getSource().maxzoom,B=b.canonical.z===D?Math.ceil(1<<_.transform.maxZoom-b.canonical.z):1;I=d.an(d.ce(y.maxLineLength/d.a5*1024*B),256,n.maxTextureSize)}return M.gradient=d.cf({expression:h.gradientExpression(),evaluationKey:"lineProgress",resolution:I,image:M.gradient||void 0,clips:y.lineClipsArray}),M.texture?M.texture.update(M.gradient):M.texture=new d.T(n,M.gradient,A.RGBA),M.version=h.gradientVersion,M.texture}function MA(_,t,n,A,h){_.activeTexture.set(t.TEXTURE0),n.imageAtlasTexture.bind(t.LINEAR,t.CLAMP_TO_EDGE),A.updatePaintBuffers(h)}function Jr(_,t,n,A,h,y){(h||_.lineAtlas.dirty)&&(t.activeTexture.set(n.TEXTURE0),_.lineAtlas.bind(t)),A.updatePaintBuffers(y)}function uo(_,t,n,A,h,y,b){const M=y.gradients[h.id];let I=M.texture;h.gradientVersion!==M.version&&(I=PA(_,t,n,A,h,y,b,M)),n.activeTexture.set(A.TEXTURE0),I.bind(h.stepInterpolant?A.NEAREST:A.LINEAR,A.CLAMP_TO_EDGE)}function on(_,t,n,A,h,y,b,M,I){const D=y.gradients[h.id];let B=D.texture;h.gradientVersion!==D.version&&(B=PA(_,t,n,A,h,y,b,D)),n.activeTexture.set(A.TEXTURE0),B.bind(h.stepInterpolant?A.NEAREST:A.LINEAR,A.CLAMP_TO_EDGE),n.activeTexture.set(A.TEXTURE1),_.lineAtlas.bind(n),M.updatePaintBuffers(I)}function Ta(_,t,n,A,h){if(!n||!A||!A.imageAtlas)return;const y=A.imageAtlas.patternPositions;let b=y[n.to.toString()],M=y[n.from.toString()];if(!b&&M&&(b=M),!M&&b&&(M=b),!b||!M){const I=h.getPaintProperty(t);b=y[I],M=y[I]}b&&M&&_.setConstantPatternPositions(b,M)}function Gr(_,t,n,A,h,y,b,M){const I=_.context.gl,D="fill-pattern",B=n.paint.get(D),V=B&&B.constantOr(1),O=n.getCrossfadeParameters();let U,X,ie,se,ne;const ce=_.transform,ge=n.paint.get("fill-translate"),Ae=n.paint.get("fill-translate-anchor");b?(X=V&&!n.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",U=I.LINES):(X=V?"fillPattern":"fill",U=I.TRIANGLES);const de=B.constantOr(null);for(const ye of A){const fe=t.getTile(ye);if(V&&!fe.patternsLoaded())continue;const Me=fe.getBucket(n);if(!Me)continue;const Ge=Me.programConfigurations.get(n.id),Fe=_.useProgram(X,Ge),Oe=_.style.map.terrain&&_.style.map.terrain.getTerrainData(ye);V&&(_.context.activeTexture.set(I.TEXTURE0),fe.imageAtlasTexture.bind(I.LINEAR,I.CLAMP_TO_EDGE),Ge.updatePaintBuffers(O)),Ta(Ge,D,de,fe,n);const Ve=ce.getProjectionData({overscaledTileID:ye,applyGlobeMatrix:!M,applyTerrainMatrix:!0}),ut=d.aO(ce,fe,ge,Ae);if(b){se=Me.indexBuffer2,ne=Me.segments2;const rt=[I.drawingBufferWidth,I.drawingBufferHeight];ie=X==="fillOutlinePattern"&&V?Fo(_,O,fe,rt,ut):Va(rt,ut)}else se=Me.indexBuffer,ne=Me.segments,ie=V?ga(_,O,fe,ut):{u_fill_translate:ut};const ht=_.stencilModeForClipping(ye);Fe.draw(_.context,U,h,ht,y,or.backCCW,ie,Oe,Ve,n.id,Me.layoutVertexBuffer,se,ne,n.paint,_.transform.zoom,Ge)}}function Ja(_,t,n,A,h,y,b,M){const I=_.context,D=I.gl,B="fill-extrusion-pattern",V=n.paint.get(B),O=V.constantOr(1),U=n.getCrossfadeParameters(),X=n.paint.get("fill-extrusion-opacity"),ie=V.constantOr(null),se=_.transform;for(const ne of A){const ce=t.getTile(ne),ge=ce.getBucket(n);if(!ge)continue;const Ae=_.style.map.terrain&&_.style.map.terrain.getTerrainData(ne),de=ge.programConfigurations.get(n.id),ye=_.useProgram(O?"fillExtrusionPattern":"fillExtrusion",de);O&&(_.context.activeTexture.set(D.TEXTURE0),ce.imageAtlasTexture.bind(D.LINEAR,D.CLAMP_TO_EDGE),de.updatePaintBuffers(U));const fe=se.getProjectionData({overscaledTileID:ne,applyGlobeMatrix:!M,applyTerrainMatrix:!0});Ta(de,B,ie,ce,n);const Me=d.aO(se,ce,n.paint.get("fill-extrusion-translate"),n.paint.get("fill-extrusion-translate-anchor")),Ge=n.paint.get("fill-extrusion-vertical-gradient"),Fe=O?gl(_,Ge,X,Me,ne,U,ce):ma(_,Ge,X,Me);ye.draw(I,I.gl.TRIANGLES,h,y,b,or.backCCW,Fe,Ae,fe,n.id,ge.layoutVertexBuffer,ge.indexBuffer,ge.segments,n.paint,_.transform.zoom,de,_.style.map.terrain&&ge.centroidVertexBuffer)}}function Fs(_,t,n,A,h,y,b,M,I){var D;const B=_.style.projection,V=_.context,O=_.transform,U=V.gl,X=[`#define NUM_ILLUMINATION_SOURCES ${n.paint.get("hillshade-highlight-color").values.length}`],ie=_.useProgram("hillshade",null,!1,X),se=!_.options.moving;for(const ne of A){const ce=t.getTile(ne),ge=ce.fbo;if(!ge)continue;const Ae=B.getMeshFromTileID(V,ne.canonical,M,!0,"raster"),de=(D=_.style.map.terrain)===null||D===void 0?void 0:D.getTerrainData(ne);V.activeTexture.set(U.TEXTURE0),U.bindTexture(U.TEXTURE_2D,ge.colorAttachment.get());const ye=O.getProjectionData({overscaledTileID:ne,aligned:se,applyGlobeMatrix:!I,applyTerrainMatrix:!0});ie.draw(V,U.TRIANGLES,y,h[ne.overscaledZ],b,or.backCCW,Na(_,ce,n),de,ye,n.id,Ae.vertexBuffer,Ae.indexBuffer,Ae.segments)}}function ps(_,t,n,A,h,y,b,M,I){var D;const B=_.style.projection,V=_.context,O=_.transform,U=V.gl,X=_.useProgram("colorRelief"),ie=!_.options.moving;let se=!0,ne=0;for(const ce of A){const ge=t.getTile(ce),Ae=ge.dem;if(se){const Fe=U.getParameter(U.MAX_TEXTURE_SIZE),{elevationTexture:Oe,colorTexture:Ve}=n.getColorRampTextures(V,Fe,Ae.getUnpackVector());V.activeTexture.set(U.TEXTURE1),Oe.bind(U.NEAREST,U.CLAMP_TO_EDGE),V.activeTexture.set(U.TEXTURE4),Ve.bind(U.LINEAR,U.CLAMP_TO_EDGE),se=!1,ne=Oe.size[0]}if(!Ae||!Ae.data)continue;const de=Ae.stride,ye=Ae.getPixels();if(V.activeTexture.set(U.TEXTURE0),V.pixelStoreUnpackPremultiplyAlpha.set(!1),ge.demTexture=ge.demTexture||_.getTileTexture(de),ge.demTexture){const Fe=ge.demTexture;Fe.update(ye,{premultiply:!1}),Fe.bind(U.LINEAR,U.CLAMP_TO_EDGE)}else ge.demTexture=new d.T(V,ye,U.RGBA,{premultiply:!1}),ge.demTexture.bind(U.LINEAR,U.CLAMP_TO_EDGE);const fe=B.getMeshFromTileID(V,ce.canonical,M,!0,"raster"),Me=(D=_.style.map.terrain)===null||D===void 0?void 0:D.getTerrainData(ce),Ge=O.getProjectionData({overscaledTileID:ce,aligned:ie,applyGlobeMatrix:!I,applyTerrainMatrix:!0});X.draw(V,U.TRIANGLES,y,h[ce.overscaledZ],b,or.backCCW,Ga(n,ge.dem,ne),Me,Ge,n.id,fe.vertexBuffer,fe.indexBuffer,fe.segments)}}const _i=[new d.P(0,0),new d.P(d.a5,0),new d.P(d.a5,d.a5),new d.P(0,d.a5)];function $o(_,t,n,A,h,y,b,M,I=!1,D=!1){const B=A[A.length-1].overscaledZ,V=_.context,O=V.gl,U=_.useProgram("raster"),X=_.transform,ie=_.style.projection,se=_.colorModeForRenderPass(),ne=!_.options.moving,ce=n.paint.get("raster-opacity"),ge=n.paint.get("raster-resampling"),Ae=n.paint.get("raster-fade-duration"),de=!!_.style.map.terrain;for(const ye of A){const fe=_.getDepthModeForSublayer(ye.overscaledZ-B,ce===1?Zt.ReadWrite:Zt.ReadOnly,O.LESS),Me=t.getTile(ye),Ge=ge==="nearest"?O.NEAREST:O.LINEAR;V.activeTexture.set(O.TEXTURE0),Me.texture.bind(Ge,O.CLAMP_TO_EDGE,O.LINEAR_MIPMAP_NEAREST),V.activeTexture.set(O.TEXTURE1);const{parentTile:Fe,parentScaleBy:Oe,parentTopLeft:Ve,fadeValues:ut}=EA(Me,t,Ae,de);Me.fadeOpacity=ut.tileOpacity,Fe?(Fe.fadeOpacity=ut.parentTileOpacity,Fe.texture.bind(Ge,O.CLAMP_TO_EDGE,O.LINEAR_MIPMAP_NEAREST)):Me.texture.bind(Ge,O.CLAMP_TO_EDGE,O.LINEAR_MIPMAP_NEAREST),Me.texture.useMipmap&&V.extTextureFilterAnisotropic&&_.transform.pitch>20&&O.texParameterf(O.TEXTURE_2D,V.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,V.extTextureFilterAnisotropicMax);const ht=_.style.map.terrain&&_.style.map.terrain.getTerrainData(ye),rt=X.getProjectionData({overscaledTileID:ye,aligned:ne,applyGlobeMatrix:!D,applyTerrainMatrix:!0}),ft=zs(Ve,Oe,ut.fadeMix,n,M),Wt=ie.getMeshFromTileID(V,ye.canonical,y,b,"raster");U.draw(V,O.TRIANGLES,fe,h?h[ye.overscaledZ]:ur.disabled,se,I?or.frontCCW:or.backCCW,ft,ht,rt,n.id,Wt.vertexBuffer,Wt.indexBuffer,Wt.segments)}}function EA(_,t,n,A){const h={parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:{tileOpacity:1,parentTileOpacity:1,fadeMix:{opacity:1,mix:0}}};if(n===0||A)return h;if(_.fadingParentID){const y=t.getLoadedTile(_.fadingParentID);if(!y)return h;const b=Math.pow(2,y.tileID.overscaledZ-_.tileID.overscaledZ),M=[_.tileID.canonical.x*b%1,_.tileID.canonical.y*b%1],I=(function(D,B,V){const O=Ar(),U=(O-B.timeAdded)/V,X=D.fadingDirection===je.Incoming,ie=d.an((O-D.timeAdded)/V,0,1),se=d.an(1-U,0,1),ne=X?ie:se;return{tileOpacity:ne,parentTileOpacity:X?se:ie,fadeMix:{opacity:1,mix:1-ne}}})(_,y,n);return{parentTile:y,parentScaleBy:b,parentTopLeft:M,fadeValues:I}}if(_.selfFading){const y=(function(b,M){const I=(Ar()-b.timeAdded)/M,D=d.an(I,0,1);return{tileOpacity:D,fadeMix:{opacity:D,mix:0}}})(_,n);return{parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:y}}return h}const Il=new d.bp(1,0,0,1),Sl=new d.bp(0,1,0,1),Cl=new d.bp(0,0,1,1),Dl=new d.bp(1,0,1,1),fs=new d.bp(0,1,1,1);function kl(_,t,n,A){Pa(_,0,t+n/2,_.transform.width,n,A)}function zl(_,t,n,A){Pa(_,t-n/2,0,n,_.transform.height,A)}function Pa(_,t,n,A,h,y){const b=_.context,M=b.gl;M.enable(M.SCISSOR_TEST),M.scissor(t*_.pixelRatio,n*_.pixelRatio,A*_.pixelRatio,h*_.pixelRatio),b.clear({color:y}),M.disable(M.SCISSOR_TEST)}function IA(_,t,n){const A=_.context,h=A.gl,y=_.useProgram("debug"),b=Zt.disabled,M=ur.disabled,I=_.colorModeForRenderPass(),D="$debug",B=_.style.map.terrain&&_.style.map.terrain.getTerrainData(n);A.activeTexture.set(h.TEXTURE0);const V=t.getTileByID(n.key).latestRawTileData,O=Math.floor((V&&V.byteLength||0)/1024),U=t.getTile(n).tileSize,X=512/Math.min(U,512)*(n.overscaledZ/_.transform.zoom)*.5;let ie=n.canonical.toString();n.overscaledZ!==n.canonical.z&&(ie+=` => ${n.overscaledZ}`),(function(ne,ce){ne.initDebugOverlayCanvas();const ge=ne.debugOverlayCanvas,Ae=ne.context.gl,de=ne.debugOverlayCanvas.getContext("2d");de.clearRect(0,0,ge.width,ge.height),de.shadowColor="white",de.shadowBlur=2,de.lineWidth=1.5,de.strokeStyle="white",de.textBaseline="top",de.font="bold 36px Open Sans, sans-serif",de.fillText(ce,5,5),de.strokeText(ce,5,5),ne.debugOverlayTexture.update(ge),ne.debugOverlayTexture.bind(Ae.LINEAR,Ae.CLAMP_TO_EDGE)})(_,`${ie} ${O}kB`);const se=_.transform.getProjectionData({overscaledTileID:n,applyGlobeMatrix:!0,applyTerrainMatrix:!0});y.draw(A,h.TRIANGLES,b,M,rr.alphaBlended,or.disabled,ja(d.bp.transparent,X),null,se,D,_.debugBuffer,_.quadTriangleIndexBuffer,_.debugSegments),y.draw(A,h.LINE_STRIP,b,M,I,or.disabled,ja(d.bp.red),B,se,D,_.debugBuffer,_.tileBorderIndexBuffer,_.debugSegments)}function Kn(_,t,n,A){const{isRenderingGlobe:h}=A,y=_.context,b=y.gl,M=_.transform,I=_.colorModeForRenderPass(),D=_.getDepthModeFor3D(),B=_.useProgram("terrain");y.bindFramebuffer.set(null),y.viewport.set([0,0,_.width,_.height]);for(const V of n){const O=t.getTerrainMesh(V.tileID),U=_.renderToTexture.getTexture(V),X=t.getTerrainData(V.tileID);y.activeTexture.set(b.TEXTURE0),b.bindTexture(b.TEXTURE_2D,U.texture);const ie=t.getMeshFrameDelta(M.zoom),se=M.calculateFogMatrix(V.tileID.toUnwrapped()),ne=AA(ie,se,_.style.sky,M.pitch,h),ce=M.getProjectionData({overscaledTileID:V.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});B.draw(y,b.TRIANGLES,D,ur.disabled,I,or.backCCW,ne,X,ce,"terrain",O.vertexBuffer,O.indexBuffer,O.segments)}}function In(_,t){if(!t.mesh){const n=new d.aW;n.emplaceBack(-1,-1),n.emplaceBack(1,-1),n.emplaceBack(1,1),n.emplaceBack(-1,1);const A=new d.aY;A.emplaceBack(0,1,2),A.emplaceBack(0,2,3),t.mesh=new Er(_.createVertexBuffer(n,Is.members),_.createIndexBuffer(A),d.aX.simpleSegment(0,0,n.length,A.length))}return t.mesh}class kt{constructor(t,n){this.context=new Xa(t),this.transform=n,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:d.ar(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=br.maxOverzooming+br.maxUnderzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new en}resize(t,n,A){if(this.width=Math.floor(t*A),this.height=Math.floor(n*A),this.pixelRatio=A,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const h of this.style._order)this.style._layers[h].resize()}setup(){const t=this.context,n=new d.aW;n.emplaceBack(0,0),n.emplaceBack(d.a5,0),n.emplaceBack(0,d.a5),n.emplaceBack(d.a5,d.a5),this.tileExtentBuffer=t.createVertexBuffer(n,Is.members),this.tileExtentSegments=d.aX.simpleSegment(0,0,4,2);const A=new d.aW;A.emplaceBack(0,0),A.emplaceBack(d.a5,0),A.emplaceBack(0,d.a5),A.emplaceBack(d.a5,d.a5),this.debugBuffer=t.createVertexBuffer(A,Is.members),this.debugSegments=d.aX.simpleSegment(0,0,4,5);const h=new d.ch;h.emplaceBack(0,0,0,0),h.emplaceBack(d.a5,0,d.a5,0),h.emplaceBack(0,d.a5,0,d.a5),h.emplaceBack(d.a5,d.a5,d.a5,d.a5),this.rasterBoundsBuffer=t.createVertexBuffer(h,au.members),this.rasterBoundsSegments=d.aX.simpleSegment(0,0,4,2);const y=new d.aW;y.emplaceBack(0,0),y.emplaceBack(d.a5,0),y.emplaceBack(0,d.a5),y.emplaceBack(d.a5,d.a5),this.rasterBoundsBufferPosOnly=t.createVertexBuffer(y,Is.members),this.rasterBoundsSegmentsPosOnly=d.aX.simpleSegment(0,0,4,5);const b=new d.aW;b.emplaceBack(0,0),b.emplaceBack(1,0),b.emplaceBack(0,1),b.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(b,Is.members),this.viewportSegments=d.aX.simpleSegment(0,0,4,2);const M=new d.ci;M.emplaceBack(0),M.emplaceBack(1),M.emplaceBack(3),M.emplaceBack(2),M.emplaceBack(0),this.tileBorderIndexBuffer=t.createIndexBuffer(M);const I=new d.aY;I.emplaceBack(1,0,2),I.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(I);const D=this.context.gl;this.stencilClearMode=new ur({func:D.ALWAYS,mask:0},0,255,D.ZERO,D.ZERO,D.ZERO),this.tileExtentMesh=new Er(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){const t=this.context,n=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const A=d.N();d.c7(A,0,this.width,this.height,0,0,1),d.Q(A,A,[n.drawingBufferWidth,n.drawingBufferHeight,0]);const h={mainMatrix:A,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:A};this.useProgram("clippingMask",null,!0).draw(t,n.TRIANGLES,Zt.disabled,this.stencilClearMode,rr.disabled,or.disabled,null,null,h,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(t,n,A){if(this.currentStencilSource===t.source||!t.isTileClipped()||!n||!n.length)return;this.currentStencilSource=t.source,this.nextStencilID+n.length>256&&this.clearStencil();const h=this.context;h.setColorMode(rr.disabled),h.setDepthMode(Zt.disabled);const y={};for(const b of n)y[b.key]=this.nextStencilID++;this._renderTileMasks(y,n,A,!0),this._renderTileMasks(y,n,A,!1),this._tileClippingMaskIDs=y}_renderTileMasks(t,n,A,h){const y=this.context,b=y.gl,M=this.style.projection,I=this.transform,D=this.useProgram("clippingMask");for(const B of n){const V=t[B.key],O=this.style.map.terrain&&this.style.map.terrain.getTerrainData(B),U=M.getMeshFromTileID(this.context,B.canonical,h,!0,"stencil"),X=I.getProjectionData({overscaledTileID:B,applyGlobeMatrix:!A,applyTerrainMatrix:!0});D.draw(y,b.TRIANGLES,Zt.disabled,new ur({func:b.ALWAYS,mask:0},V,255,b.KEEP,b.KEEP,b.REPLACE),rr.disabled,A?or.disabled:or.backCCW,null,O,X,"$clipping",U.vertexBuffer,U.indexBuffer,U.segments)}}_renderTilesDepthBuffer(){const t=this.context,n=t.gl,A=this.style.projection,h=this.transform,y=this.useProgram("depth"),b=this.getDepthModeFor3D(),M=Mr(h,{tileSize:h.tileSize});for(const I of M){const D=this.style.map.terrain&&this.style.map.terrain.getTerrainData(I),B=A.getMeshFromTileID(this.context,I.canonical,!0,!0,"raster"),V=h.getProjectionData({overscaledTileID:I,applyGlobeMatrix:!0,applyTerrainMatrix:!0});y.draw(t,n.TRIANGLES,b,ur.disabled,rr.disabled,or.backCCW,null,D,V,"$clipping",B.vertexBuffer,B.indexBuffer,B.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const t=this.nextStencilID++,n=this.context.gl;return new ur({func:n.NOTEQUAL,mask:255},t,255,n.KEEP,n.KEEP,n.REPLACE)}stencilModeForClipping(t){const n=this.context.gl;return new ur({func:n.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,n.KEEP,n.KEEP,n.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(t){const n=this.context.gl,A=t.sort(((b,M)=>M.overscaledZ-b.overscaledZ)),h=A[A.length-1].overscaledZ,y=A[0].overscaledZ-h+1;if(y>1){this.currentStencilSource=void 0,this.nextStencilID+y>256&&this.clearStencil();const b={};for(let M=0;M<y;M++)b[M+h]=new ur({func:n.GEQUAL,mask:255},M+this.nextStencilID,255,n.KEEP,n.KEEP,n.REPLACE);return this.nextStencilID+=y,[b,A]}return[{[h]:ur.disabled},A]}stencilConfigForOverlapTwoPass(t){const n=this.context.gl,A=t.sort(((b,M)=>M.overscaledZ-b.overscaledZ)),h=A[A.length-1].overscaledZ,y=A[0].overscaledZ-h+1;if(this.clearStencil(),y>1){const b={},M={};for(let I=0;I<y;I++)b[I+h]=new ur({func:n.GREATER,mask:255},y+1+I,255,n.KEEP,n.KEEP,n.REPLACE),M[I+h]=new ur({func:n.GREATER,mask:255},1+I,255,n.KEEP,n.KEEP,n.REPLACE);return this.nextStencilID=2*y+1,[b,M,A]}return this.nextStencilID=3,[{[h]:new ur({func:n.GREATER,mask:255},2,255,n.KEEP,n.KEEP,n.REPLACE)},{[h]:new ur({func:n.GREATER,mask:255},1,255,n.KEEP,n.KEEP,n.REPLACE)},A]}colorModeForRenderPass(){const t=this.context.gl;return this._showOverdrawInspector?new rr([t.CONSTANT_COLOR,t.ONE],new d.bp(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?rr.unblended:rr.alphaBlended}getDepthModeForSublayer(t,n,A){if(!this.opaquePassEnabledForLayer())return Zt.disabled;const h=1-((1+this.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new Zt(A||this.context.gl.LEQUAL,n,[h,h])}getDepthModeFor3D(){return new Zt(this.context.gl.LEQUAL,Zt.ReadWrite,this.depthRangeFor3D)}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(t,n){var A,h;this.style=t,this.options=n,this.lineAtlas=t.lineAtlas,this.imageManager=t.imageManager,this.glyphManager=t.glyphManager,this.symbolFadeChange=t.placement.symbolFadeChange(Ar()),this.imageManager.beginFrame();const y=this.style._order,b=this.style.tileManagers,M={},I={},D={},B={isRenderingToTexture:!1,isRenderingGlobe:((A=t.projection)===null||A===void 0?void 0:A.transitionState)>0};for(const O in b){const U=b[O];U.used&&U.prepare(this.context),M[O]=U.getVisibleCoordinates(!1),I[O]=M[O].slice().reverse(),D[O]=U.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let O=0;O<y.length;O++)if(this.style._layers[y[O]].is3D()){this.opaquePassCutoff=O;break}this.maybeDrawDepthAndCoords(!1),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0),this.renderPass="offscreen";for(const O of y){const U=this.style._layers[O];if(!U.hasOffscreenPass()||U.isHidden(this.transform.zoom))continue;const X=I[U.source];(U.type==="custom"||X.length)&&this.renderLayer(this,b[U.source],U,X,B)}if((h=this.style.projection)===null||h===void 0||h.updateGPUdependent({context:this.context,useProgram:O=>this.useProgram(O)}),this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:n.showOverdrawInspector?d.bp.black:d.bp.transparent,depth:1}),this.clearStencil(),this.style.sky&&(function(O,U){const X=O.context,ie=X.gl,se=((ye,fe,Me)=>{const Ge=Math.cos(fe.rollInRadians),Fe=Math.sin(fe.rollInRadians),Oe=gr(fe),Ve=fe.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return{u_sky_color:ye.properties.get("sky-color"),u_horizon_color:ye.properties.get("horizon-color"),u_horizon:[(fe.width/2-Oe*Fe)*Me,(fe.height/2+Oe*Ge)*Me],u_horizon_normal:[-Fe,Ge],u_sky_horizon_blend:ye.properties.get("sky-horizon-blend")*fe.height/2*Me,u_sky_blend:Ve}})(U,O.style.map.transform,O.pixelRatio),ne=new Zt(ie.LEQUAL,Zt.ReadWrite,[0,1]),ce=ur.disabled,ge=O.colorModeForRenderPass(),Ae=O.useProgram("sky"),de=In(X,U);Ae.draw(X,ie.TRIANGLES,ne,ce,ge,or.disabled,se,null,void 0,"sky",de.vertexBuffer,de.indexBuffer,de.segments)})(this,this.style.sky),this._showOverdrawInspector=n.showOverdrawInspector,this.depthRangeFor3D=[0,1-(t._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=y.length-1;this.currentLayer>=0;this.currentLayer--){const O=this.style._layers[y[this.currentLayer]],U=b[O.source],X=M[O.source];this._renderTileClippingMasks(O,X,!1),this.renderLayer(this,U,O,X,B)}this.renderPass="translucent";let V=!1;for(this.currentLayer=0;this.currentLayer<y.length;this.currentLayer++){const O=this.style._layers[y[this.currentLayer]],U=b[O.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(O,B))continue;this.opaquePassEnabledForLayer()||V||(V=!0,B.isRenderingGlobe&&!this.style.map.terrain&&this._renderTilesDepthBuffer());const X=(O.type==="symbol"?D:I)[O.source];this._renderTileClippingMasks(O,M[O.source],!!this.renderToTexture),this.renderLayer(this,U,O,X,B)}if(B.isRenderingGlobe&&(function(O,U,X){const ie=O.context,se=ie.gl,ne=O.useProgram("atmosphere"),ce=new Zt(se.LEQUAL,Zt.ReadOnly,[0,1]),ge=O.transform,Ae=(function(Ve,ut){const ht=Ve.properties.get("position"),rt=[-ht.x,-ht.y,-ht.z],ft=d.ar(new Float64Array(16));return Ve.properties.get("anchor")==="map"&&(d.bg(ft,ft,ut.rollInRadians),d.bh(ft,ft,-ut.pitchInRadians),d.bg(ft,ft,ut.bearingInRadians),d.bh(ft,ft,ut.center.lat*Math.PI/180),d.bJ(ft,ft,-ut.center.lng*Math.PI/180)),d.cg(rt,rt,ft),rt})(X,O.transform),de=ge.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),ye=U.properties.get("atmosphere-blend")*de.projectionTransition;if(ye===0)return;const fe=ro(ge.worldSize,ge.center.lat),Me=ge.inverseProjectionMatrix,Ge=new Float64Array(4);Ge[3]=1,d.aH(Ge,Ge,ge.modelViewProjectionMatrix),Ge[0]/=Ge[3],Ge[1]/=Ge[3],Ge[2]/=Ge[3],Ge[3]=1,d.aH(Ge,Ge,Me),Ge[0]/=Ge[3],Ge[1]/=Ge[3],Ge[2]/=Ge[3],Ge[3]=1;const Fe=((Ve,ut,ht,rt,ft)=>({u_sun_pos:Ve,u_atmosphere_blend:ut,u_globe_position:ht,u_globe_radius:rt,u_inv_proj_matrix:ft}))(Ae,ye,[Ge[0],Ge[1],Ge[2]],fe,Me),Oe=In(ie,U);ne.draw(ie,se.TRIANGLES,ce,ur.disabled,rr.alphaBlended,or.disabled,Fe,null,null,"atmosphere",Oe.vertexBuffer,Oe.indexBuffer,Oe.segments)})(this,this.style.sky,this.style.light),this.options.showTileBoundaries){const O=(function(U,X){let ie=null;const se=Object.values(U._layers).flatMap((Ae=>Ae.source&&!Ae.isHidden(X)?[U.tileManagers[Ae.source]]:[])),ne=se.filter((Ae=>Ae.getSource().type==="vector")),ce=se.filter((Ae=>Ae.getSource().type!=="vector")),ge=Ae=>{(!ie||ie.getSource().maxzoom<Ae.getSource().maxzoom)&&(ie=Ae)};return ne.forEach((Ae=>ge(Ae))),ie||ce.forEach((Ae=>ge(Ae))),ie})(this.style,this.transform.zoom);O&&(function(U,X,ie){for(let se=0;se<ie.length;se++)IA(U,X,ie[se])})(this,O,O.getVisibleCoordinates())}this.options.showPadding&&(function(O){const U=O.transform.padding;kl(O,O.transform.height-(U.top||0),3,Il),kl(O,U.bottom||0,3,Sl),zl(O,U.left||0,3,Cl),zl(O,O.transform.width-(U.right||0),3,Dl);const X=O.transform.centerPoint;(function(ie,se,ne,ce){Pa(ie,se-1,ne-10,2,20,ce),Pa(ie,se-10,ne-1,20,2,ce)})(O,X.x,O.transform.height-X.y,fs)})(this),this.context.setDefault()}maybeDrawDepthAndCoords(t){if(!this.style||!this.style.map||!this.style.map.terrain)return;const n=this.terrainFacilitator.matrix,A=this.transform.modelViewProjectionMatrix;let h=this.terrainFacilitator.dirty;h||(h=t?!d.cj(n,A):!d.ck(n,A)),h||(h=this.style.map.terrain.tileManager.anyTilesAfterTime(this.terrainFacilitator.renderTime)),h&&(d.cl(n,A),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,(function(y,b){const M=y.context,I=M.gl,D=y.transform,B=rr.unblended,V=new Zt(I.LEQUAL,Zt.ReadWrite,[0,1]),O=b.tileManager.getRenderableTiles(),U=y.useProgram("terrainDepth");M.bindFramebuffer.set(b.getFramebuffer("depth").framebuffer),M.viewport.set([0,0,y.width/devicePixelRatio,y.height/devicePixelRatio]),M.clear({color:d.bp.transparent,depth:1});for(const X of O){const ie=b.getTerrainMesh(X.tileID),se=b.getTerrainData(X.tileID),ne=D.getProjectionData({overscaledTileID:X.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0}),ce={u_ele_delta:b.getMeshFrameDelta(D.zoom)};U.draw(M,I.TRIANGLES,V,ur.disabled,B,or.backCCW,ce,se,ne,"terrain",ie.vertexBuffer,ie.indexBuffer,ie.segments)}M.bindFramebuffer.set(null),M.viewport.set([0,0,y.width,y.height])})(this,this.style.map.terrain),(function(y,b){const M=y.context,I=M.gl,D=y.transform,B=rr.unblended,V=new Zt(I.LEQUAL,Zt.ReadWrite,[0,1]),O=b.getCoordsTexture(),U=b.tileManager.getRenderableTiles(),X=y.useProgram("terrainCoords");M.bindFramebuffer.set(b.getFramebuffer("coords").framebuffer),M.viewport.set([0,0,y.width/devicePixelRatio,y.height/devicePixelRatio]),M.clear({color:d.bp.transparent,depth:1}),b.coordsIndex=[];for(const ie of U){const se=b.getTerrainMesh(ie.tileID),ne=b.getTerrainData(ie.tileID);M.activeTexture.set(I.TEXTURE0),I.bindTexture(I.TEXTURE_2D,O.texture);const ce={u_terrain_coords_id:(255-b.coordsIndex.length)/255,u_texture:0,u_ele_delta:b.getMeshFrameDelta(D.zoom)},ge=D.getProjectionData({overscaledTileID:ie.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});X.draw(M,I.TRIANGLES,V,ur.disabled,B,or.backCCW,ce,ne,ge,"terrain",se.vertexBuffer,se.indexBuffer,se.segments),b.coordsIndex.push(ie.tileID.key)}M.bindFramebuffer.set(null),M.viewport.set([0,0,y.width,y.height])})(this,this.style.map.terrain))}renderLayer(t,n,A,h,y){A.isHidden(this.transform.zoom)||(A.type==="background"||A.type==="custom"||(h||[]).length)&&(this.id=A.id,d.cm(A)?(function(b,M,I,D,B,V){if(b.renderPass!=="translucent")return;const{isRenderingToTexture:O}=V,U=ur.disabled,X=b.colorModeForRenderPass();(I._unevaluatedLayout.hasValue("text-variable-anchor")||I._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&(function(ie,se,ne,ce,ge,Ae,de,ye,fe){const Me=se.transform,Ge=se.style.map.terrain,Fe=ge==="map",Oe=Ae==="map";for(const Ve of ie){const ut=ce.getTile(Ve),ht=ut.getBucket(ne);if(!ht||!ht.text||!ht.text.segments.get().length)continue;const rt=d.ay(ht.textSizeData,Me.zoom),ft=d.aN(ut,1,se.transform.zoom),Wt=Jt(Fe,se.transform,ft),Tr=ne.layout.get("icon-text-fit")!=="none"&&ht.hasIconData();if(rt){const Ur=Math.pow(2,Me.zoom-ut.tileID.overscaledZ),Dr=Ge?(Wr,kr)=>Ge.getElevation(Ve,Wr,kr):null;bA(ht,Fe,Oe,fe,Me,Wt,Ur,rt,Tr,d.aO(Me,ut,de,ye),Ve.toUnwrapped(),Dr)}}})(D,b,I,M,I.layout.get("text-rotation-alignment"),I.layout.get("text-pitch-alignment"),I.paint.get("text-translate"),I.paint.get("text-translate-anchor"),B),I.paint.get("icon-opacity").constantOr(1)!==0&&Qo(b,M,I,D,!1,I.paint.get("icon-translate"),I.paint.get("icon-translate-anchor"),I.layout.get("icon-rotation-alignment"),I.layout.get("icon-pitch-alignment"),I.layout.get("icon-keep-upright"),U,X,O),I.paint.get("text-opacity").constantOr(1)!==0&&Qo(b,M,I,D,!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"),U,X,O),M.map.showCollisionBoxes&&(Ls(b,M,I,D,!0),Ls(b,M,I,D,!1))})(t,n,A,h,this.style.placement.variableOffsets,y):d.cn(A)?(function(b,M,I,D,B){if(b.renderPass!=="translucent")return;const{isRenderingToTexture:V}=B,O=I.paint.get("circle-opacity"),U=I.paint.get("circle-stroke-width"),X=I.paint.get("circle-stroke-opacity"),ie=!I.layout.get("circle-sort-key").isConstant();if(O.constantOr(1)===0&&(U.constantOr(1)===0||X.constantOr(1)===0))return;const se=b.context,ne=se.gl,ce=b.transform,ge=b.getDepthModeForSublayer(0,Zt.ReadOnly),Ae=ur.disabled,de=b.colorModeForRenderPass(),ye=[],fe=ce.getCircleRadiusCorrection();for(let Me=0;Me<D.length;Me++){const Ge=D[Me],Fe=M.getTile(Ge),Oe=Fe.getBucket(I);if(!Oe)continue;const Ve=I.paint.get("circle-translate"),ut=I.paint.get("circle-translate-anchor"),ht=d.aO(ce,Fe,Ve,ut),rt=Oe.programConfigurations.get(I.id),ft=b.useProgram("circle",rt),Wt=Oe.layoutVertexBuffer,Tr=Oe.indexBuffer,Ur=b.style.map.terrain&&b.style.map.terrain.getTerrainData(Ge),Dr={programConfiguration:rt,program:ft,layoutVertexBuffer:Wt,indexBuffer:Tr,uniformValues:wr(b,Fe,I,ht,fe),terrainData:Ur,projectionData:ce.getProjectionData({overscaledTileID:Ge,applyGlobeMatrix:!V,applyTerrainMatrix:!0})};if(ie){const Wr=Oe.segments.get();for(const kr of Wr)ye.push({segments:new d.aX([kr]),sortKey:kr.sortKey,state:Dr})}else ye.push({segments:Oe.segments,sortKey:0,state:Dr})}ie&&ye.sort(((Me,Ge)=>Me.sortKey-Ge.sortKey));for(const Me of ye){const{programConfiguration:Ge,program:Fe,layoutVertexBuffer:Oe,indexBuffer:Ve,uniformValues:ut,terrainData:ht,projectionData:rt}=Me.state;Fe.draw(se,ne.TRIANGLES,ge,Ae,de,or.backCCW,ut,ht,rt,I.id,Oe,Ve,Me.segments,I.paint,b.transform.zoom,Ge)}})(t,n,A,h,y):d.co(A)?(function(b,M,I,D,B){if(I.paint.get("heatmap-opacity")===0)return;const V=b.context,{isRenderingToTexture:O,isRenderingGlobe:U}=B;if(b.style.map.terrain){for(const X of D){const ie=M.getTile(X);M.hasRenderableParent(X)||(b.renderPass==="offscreen"?wA(b,ie,I,X,U):b.renderPass==="translucent"&&TA(b,I,X,O,U))}V.viewport.set([0,0,b.width,b.height])}else b.renderPass==="offscreen"?(function(X,ie,se,ne){const ce=X.context,ge=ce.gl,Ae=X.transform,de=ur.disabled,ye=new rr([ge.ONE,ge.ONE],d.bp.transparent,[!0,!0,!0,!0]);(function(fe,Me,Ge){const Fe=fe.gl;fe.activeTexture.set(Fe.TEXTURE1),fe.viewport.set([0,0,Me.width/4,Me.height/4]);let Oe=Ge.heatmapFbos.get(d.cd);Oe?(Fe.bindTexture(Fe.TEXTURE_2D,Oe.colorAttachment.get()),fe.bindFramebuffer.set(Oe.framebuffer)):(Oe=wa(fe,Me.width/4,Me.height/4),Ge.heatmapFbos.set(d.cd,Oe))})(ce,X,se),ce.clear({color:d.bp.transparent});for(let fe=0;fe<ne.length;fe++){const Me=ne[fe];if(ie.hasRenderableParent(Me))continue;const Ge=ie.getTile(Me),Fe=Ge.getBucket(se);if(!Fe)continue;const Oe=Fe.programConfigurations.get(se.id),Ve=X.useProgram("heatmap",Oe),ut=Ae.getProjectionData({overscaledTileID:Me,applyGlobeMatrix:!0,applyTerrainMatrix:!1}),ht=Ae.getCircleRadiusCorrection();Ve.draw(ce,ge.TRIANGLES,Zt.disabled,de,ye,or.backCCW,Oo(Ge,Ae.zoom,se.paint.get("heatmap-intensity"),ht),null,ut,se.id,Fe.layoutVertexBuffer,Fe.indexBuffer,Fe.segments,se.paint,Ae.zoom,Oe)}ce.viewport.set([0,0,X.width,X.height])})(b,M,I,D):b.renderPass==="translucent"&&(function(X,ie){const se=X.context,ne=se.gl;se.setColorMode(X.colorModeForRenderPass());const ce=ie.heatmapFbos.get(d.cd);ce&&(se.activeTexture.set(ne.TEXTURE0),ne.bindTexture(ne.TEXTURE_2D,ce.colorAttachment.get()),se.activeTexture.set(ne.TEXTURE1),Ka(se,ie).bind(ne.LINEAR,ne.CLAMP_TO_EDGE),X.useProgram("heatmapTexture").draw(se,ne.TRIANGLES,Zt.disabled,ur.disabled,X.colorModeForRenderPass(),or.disabled,hA(X,ie,0,1),null,null,ie.id,X.viewportBuffer,X.quadTriangleIndexBuffer,X.viewportSegments,ie.paint,X.transform.zoom))})(b,I)})(t,n,A,h,y):d.cp(A)?(function(b,M,I,D,B){if(b.renderPass!=="translucent")return;const{isRenderingToTexture:V}=B,O=I.paint.get("line-opacity"),U=I.paint.get("line-width");if(O.constantOr(1)===0||U.constantOr(1)===0)return;const X=b.getDepthModeForSublayer(0,Zt.ReadOnly),ie=b.colorModeForRenderPass(),se=I.paint.get("line-dasharray"),ne=se.constantOr(1),ce=I.paint.get("line-pattern"),ge=ce.constantOr(1),Ae=I.paint.get("line-gradient"),de=I.getCrossfadeParameters();let ye;ye=ge?"linePattern":ne&&Ae?"lineGradientSDF":ne?"lineSDF":Ae?"lineGradient":"line";const fe=b.context,Me=fe.gl,Ge=b.transform;let Fe=!0;for(const Oe of D){const Ve=M.getTile(Oe);if(ge&&!Ve.patternsLoaded())continue;const ut=Ve.getBucket(I);if(!ut)continue;const ht=ut.programConfigurations.get(I.id),rt=b.context.program.get(),ft=b.useProgram(ye,ht),Wt=Fe||ft.program!==rt,Tr=b.style.map.terrain&&b.style.map.terrain.getTerrainData(Oe),Ur=ce.constantOr(null),Dr=se&&se.constantOr(null);if(Ur&&Ve.imageAtlas){const Li=Ve.imageAtlas,pi=Li.patternPositions[Ur.to.toString()],ui=Li.patternPositions[Ur.from.toString()];pi&&ui&&ht.setConstantPatternPositions(pi,ui)}else if(Dr){const Li=I.layout.get("line-cap")==="round",pi=b.lineAtlas.getDash(Dr.to,Li),ui=b.lineAtlas.getDash(Dr.from,Li);ht.setConstantDashPositions(pi,ui)}const Wr=Ge.getProjectionData({overscaledTileID:Oe,applyGlobeMatrix:!V,applyTerrainMatrix:!0}),kr=Ge.getPixelScale();let ri;ge?(ri=_a(b,Ve,I,kr,de),MA(fe,Me,Ve,ht,de)):ne&&Ae?(ri=Wi(b,Ve,I,kr,de,ut.lineClipsArray.length),on(b,M,fe,Me,I,ut,Oe,ht,de)):ne?(ri=fA(b,Ve,I,kr,de),Jr(b,fe,Me,ht,Wt,de)):Ae?(ri=pA(b,Ve,I,kr,ut.lineClipsArray.length),uo(b,M,fe,Me,I,ut,Oe)):ri=jn(b,Ve,I,kr);const Hr=b.stencilModeForClipping(Oe);ft.draw(fe,Me.TRIANGLES,X,Hr,ie,or.disabled,ri,Tr,Wr,I.id,ut.layoutVertexBuffer,ut.indexBuffer,ut.segments,I.paint,b.transform.zoom,ht,ut.layoutVertexBuffer2),Fe=!1}})(t,n,A,h,y):d.cq(A)?(function(b,M,I,D,B){const V=I.paint.get("fill-color"),O=I.paint.get("fill-opacity");if(O.constantOr(1)===0)return;const{isRenderingToTexture:U}=B,X=b.colorModeForRenderPass(),ie=I.paint.get("fill-pattern"),se=b.opaquePassEnabledForLayer()&&!ie.constantOr(1)&&V.constantOr(d.bp.transparent).a===1&&O.constantOr(0)===1?"opaque":"translucent";if(b.renderPass===se){const ne=b.getDepthModeForSublayer(1,b.renderPass==="opaque"?Zt.ReadWrite:Zt.ReadOnly);Gr(b,M,I,D,ne,X,!1,U)}if(b.renderPass==="translucent"&&I.paint.get("fill-antialias")){const ne=b.getDepthModeForSublayer(I.getPaintProperty("fill-outline-color")?2:0,Zt.ReadOnly);Gr(b,M,I,D,ne,X,!0,U)}})(t,n,A,h,y):d.cr(A)?(function(b,M,I,D,B){const V=I.paint.get("fill-extrusion-opacity");if(V===0)return;const{isRenderingToTexture:O}=B;if(b.renderPass==="translucent"){const U=new Zt(b.context.gl.LEQUAL,Zt.ReadWrite,b.depthRangeFor3D);if(V!==1||I.paint.get("fill-extrusion-pattern").constantOr(1))Ja(b,M,I,D,U,ur.disabled,rr.disabled,O),Ja(b,M,I,D,U,b.stencilModeFor3D(),b.colorModeForRenderPass(),O);else{const X=b.colorModeForRenderPass();Ja(b,M,I,D,U,ur.disabled,X,O)}}})(t,n,A,h,y):d.cs(A)?(function(b,M,I,D,B){if(b.renderPass!=="offscreen"&&b.renderPass!=="translucent")return;const{isRenderingToTexture:V}=B,O=b.context,U=b.style.projection.useSubdivision,X=b.getDepthModeForSublayer(0,Zt.ReadOnly),ie=b.colorModeForRenderPass();if(b.renderPass==="offscreen")(function(se,ne,ce,ge,Ae,de,ye){const fe=se.context,Me=fe.gl;for(const Ge of ce){const Fe=ne.getTile(Ge),Oe=Fe.dem;if(!Oe||!Oe.data||!Fe.needsHillshadePrepare)continue;const Ve=Oe.dim,ut=Oe.stride,ht=Oe.getPixels();if(fe.activeTexture.set(Me.TEXTURE1),fe.pixelStoreUnpackPremultiplyAlpha.set(!1),Fe.demTexture=Fe.demTexture||se.getTileTexture(ut),Fe.demTexture){const ft=Fe.demTexture;ft.update(ht,{premultiply:!1}),ft.bind(Me.NEAREST,Me.CLAMP_TO_EDGE)}else Fe.demTexture=new d.T(fe,ht,Me.RGBA,{premultiply:!1}),Fe.demTexture.bind(Me.NEAREST,Me.CLAMP_TO_EDGE);fe.activeTexture.set(Me.TEXTURE0);let rt=Fe.fbo;if(!rt){const ft=new d.T(fe,{width:Ve,height:Ve,data:null},Me.RGBA);ft.bind(Me.LINEAR,Me.CLAMP_TO_EDGE),rt=Fe.fbo=fe.createFramebuffer(Ve,Ve,!0,!1),rt.colorAttachment.set(ft.texture)}fe.bindFramebuffer.set(rt.framebuffer),fe.viewport.set([0,0,Ve,Ve]),se.useProgram("hillshadePrepare").draw(fe,Me.TRIANGLES,Ae,de,ye,or.disabled,lu(Fe.tileID,Oe),null,null,ge.id,se.rasterBoundsBuffer,se.quadTriangleIndexBuffer,se.rasterBoundsSegments),Fe.needsHillshadePrepare=!1}})(b,M,D,I,X,ur.disabled,ie),O.viewport.set([0,0,b.width,b.height]);else if(b.renderPass==="translucent")if(U){const[se,ne,ce]=b.stencilConfigForOverlapTwoPass(D);Fs(b,M,I,ce,se,X,ie,!1,V),Fs(b,M,I,ce,ne,X,ie,!0,V)}else{const[se,ne]=b.getStencilConfigForOverlapAndUpdateStencilID(D);Fs(b,M,I,ne,se,X,ie,!1,V)}})(t,n,A,h,y):d.ct(A)?(function(b,M,I,D,B){if(b.renderPass!=="translucent"||!D.length)return;const{isRenderingToTexture:V}=B,O=b.style.projection.useSubdivision,U=b.getDepthModeForSublayer(0,Zt.ReadOnly),X=b.colorModeForRenderPass();if(O){const[ie,se,ne]=b.stencilConfigForOverlapTwoPass(D);ps(b,M,I,ne,ie,U,X,!1,V),ps(b,M,I,ne,se,U,X,!0,V)}else{const[ie,se]=b.getStencilConfigForOverlapAndUpdateStencilID(D);ps(b,M,I,se,ie,U,X,!1,V)}})(t,n,A,h,y):d.bU(A)?(function(b,M,I,D,B){if(b.renderPass!=="translucent"||I.paint.get("raster-opacity")===0||!D.length)return;const{isRenderingToTexture:V}=B,O=M.getSource(),U=b.style.projection.useSubdivision;if(O instanceof Di)$o(b,M,I,D,null,!1,!1,O.tileCoords,O.flippedWindingOrder,V);else if(U){const[X,ie,se]=b.stencilConfigForOverlapTwoPass(D);$o(b,M,I,se,X,!1,!0,_i,!1,V),$o(b,M,I,se,ie,!0,!0,_i,!1,V)}else{const[X,ie]=b.getStencilConfigForOverlapAndUpdateStencilID(D);$o(b,M,I,ie,X,!1,!0,_i,!1,V)}})(t,n,A,h,y):d.cu(A)?(function(b,M,I,D,B){const V=I.paint.get("background-color"),O=I.paint.get("background-opacity");if(O===0)return;const{isRenderingToTexture:U}=B,X=b.context,ie=X.gl,se=b.style.projection,ne=b.transform,ce=ne.tileSize,ge=I.paint.get("background-pattern");if(b.isPatternMissing(ge))return;const Ae=!ge&&V.a===1&&O===1&&b.opaquePassEnabledForLayer()?"opaque":"translucent";if(b.renderPass!==Ae)return;const de=ur.disabled,ye=b.getDepthModeForSublayer(0,Ae==="opaque"?Zt.ReadWrite:Zt.ReadOnly),fe=b.colorModeForRenderPass(),Me=b.useProgram(ge?"backgroundPattern":"background"),Ge=D||Mr(ne,{tileSize:ce,terrain:b.style.map.terrain});ge&&(X.activeTexture.set(ie.TEXTURE0),b.imageManager.bind(b.context));const Fe=I.getCrossfadeParameters();for(const Oe of Ge){const Ve=ne.getProjectionData({overscaledTileID:Oe,applyGlobeMatrix:!U,applyTerrainMatrix:!0}),ut=ge?vl(O,b,ge,{tileID:Oe,tileSize:ce},Fe):yl(O,V),ht=b.style.map.terrain&&b.style.map.terrain.getTerrainData(Oe),rt=se.getMeshFromTileID(X,Oe.canonical,!1,!0,"raster");Me.draw(X,ie.TRIANGLES,ye,de,fe,or.backCCW,ut,ht,Ve,I.id,rt.vertexBuffer,rt.indexBuffer,rt.segments)}})(t,0,A,h,y):d.cv(A)&&(function(b,M,I,D){const{isRenderingGlobe:B}=D,V=b.context,O=I.implementation,U=b.style.projection,X=b.transform,ie=X.getProjectionDataForCustomLayer(B),se={farZ:X.farZ,nearZ:X.nearZ,fov:X.fov*Math.PI/180,modelViewProjectionMatrix:X.modelViewProjectionMatrix,projectionMatrix:X.projectionMatrix,shaderData:{variantName:U.shaderVariantName,vertexShaderPrelude:`const float PI = 3.141592653589793; 810 + uniform mat4 u_projection_matrix; 811 + ${U.shaderPreludeCode.vertexSource}`,define:U.shaderDefine},defaultProjectionData:ie},ne=O.renderingMode?O.renderingMode:"2d";if(b.renderPass==="offscreen"){const ce=O.prerender;ce&&(b.setCustomLayerDefaults(),V.setColorMode(b.colorModeForRenderPass()),ce.call(O,V.gl,se),V.setDirty(),b.setBaseState())}else if(b.renderPass==="translucent"){b.setCustomLayerDefaults(),V.setColorMode(b.colorModeForRenderPass()),V.setStencilMode(ur.disabled);const ce=ne==="3d"?b.getDepthModeFor3D():b.getDepthModeForSublayer(0,Zt.ReadOnly);V.setDepthMode(ce),O.render(V.gl,se),V.setDirty(),b.setBaseState(),V.bindFramebuffer.set(null)}})(t,0,A,y))}saveTileTexture(t){const n=this._tileTextures[t.size[0]];n?n.push(t):this._tileTextures[t.size[0]]=[t]}getTileTexture(t){const n=this._tileTextures[t];return n&&n.length>0?n.pop():null}isPatternMissing(t){if(!t)return!1;if(!t.from||!t.to)return!0;const n=this.imageManager.getPattern(t.from.toString()),A=this.imageManager.getPattern(t.to.toString());return!n||!A}useProgram(t,n,A=!1,h=[]){this.cache=this.cache||{};const y=!!this.style.map.terrain,b=this.style.projection,M=A?Cr.projectionMercator:b.shaderPreludeCode,I=A?Qi:b.shaderDefine,D=t+(n?n.cacheKey:"")+`/${A?tn:b.shaderVariantName}`+(this._showOverdrawInspector?"/overdraw":"")+(y?"/terrain":"")+(h?`/${h.join("/")}`:"");return this.cache[D]||(this.cache[D]=new uA(this.context,Cr[t],n,Au[t],this._showOverdrawInspector,y,M,I,h)),this.cache[D]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const t=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(t.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new d.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){var t,n;if(this._tileTextures){for(const A in this._tileTextures){const h=this._tileTextures[A];if(h)for(const y of h)y.destroy()}this._tileTextures={}}if(this.tileExtentBuffer&&this.tileExtentBuffer.destroy(),this.debugBuffer&&this.debugBuffer.destroy(),this.rasterBoundsBuffer&&this.rasterBoundsBuffer.destroy(),this.rasterBoundsBufferPosOnly&&this.rasterBoundsBufferPosOnly.destroy(),this.viewportBuffer&&this.viewportBuffer.destroy(),this.tileBorderIndexBuffer&&this.tileBorderIndexBuffer.destroy(),this.quadTriangleIndexBuffer&&this.quadTriangleIndexBuffer.destroy(),this.tileExtentMesh&&((t=this.tileExtentMesh.vertexBuffer)===null||t===void 0||t.destroy()),this.tileExtentMesh&&((n=this.tileExtentMesh.indexBuffer)===null||n===void 0||n.destroy()),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.cache){for(const A in this.cache){const h=this.cache[A];h&&h.program&&this.context.gl.deleteProgram(h.program)}this.cache={}}this.context&&this.context.setDefault()}overLimit(){const{drawingBufferWidth:t,drawingBufferHeight:n}=this.context.gl;return this.width!==t||this.height!==n}}function Bi(_,t){let n,A=!1,h=null,y=null;const b=()=>{h=null,A&&(_.apply(y,n),h=setTimeout(b,t),A=!1)};return(...M)=>(A=!0,y=this,n=M,h||b(),h)}class Dt{constructor(t){this._getCurrentHash=()=>{const n=window.location.hash.replace("#","");if(this._hashName){let A;return n.split("&").map((h=>h.split("="))).forEach((h=>{h[0]===this._hashName&&(A=h)})),(A&&A[1]||"").split("/")}return n.split("/")},this._onHashChange=()=>{const n=this._getCurrentHash();if(!this._isValidHash(n))return!1;const A=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(n[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+n[2],+n[1]],zoom:+n[0],bearing:A,pitch:+(n[4]||0)}),!0},this._updateHashUnthrottled=()=>{const n=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,n)},this._removeHash=()=>{const n=this._getCurrentHash();if(n.length===0)return;const A=n.join("/");let h=A;h.split("&").length>0&&(h=h.split("&")[0]),this._hashName&&(h=`${this._hashName}=${A}`);let y=window.location.hash.replace(h,"");y.startsWith("#&")?y=y.slice(0,1)+y.slice(2):y==="#"&&(y="");let b=window.location.href.replace(/(#.+)?$/,y);b=b.replace("&&","&"),window.history.replaceState(window.history.state,null,b)},this._updateHash=Bi(this._updateHashUnthrottled,300),this._hashName=t&&encodeURIComponent(t)}addTo(t){return this._map=t,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(t){const n=this._map.getCenter(),A=Math.round(100*this._map.getZoom())/100,h=Math.ceil((A*Math.LN2+Math.log(512/360/.5))/Math.LN10),y=Math.pow(10,h),b=Math.round(n.lng*y)/y,M=Math.round(n.lat*y)/y,I=this._map.getBearing(),D=this._map.getPitch();let B="";if(B+=t?`/${b}/${M}/${A}`:`${A}/${M}/${b}`,(I||D)&&(B+="/"+Math.round(10*I)/10),D&&(B+=`/${Math.round(D)}`),this._hashName){const V=this._hashName;let O=!1;const U=window.location.hash.slice(1).split("&").map((X=>{const ie=X.split("=")[0];return ie===V?(O=!0,`${ie}=${B}`):X})).filter((X=>X));return O||U.push(`${V}=${B}`),`#${U.join("&")}`}return`#${B}`}_isValidHash(t){if(t.length<3||t.some(isNaN))return!1;try{new d.V(+t[2],+t[1])}catch{return!1}const n=+t[0],A=+(t[3]||0),h=+(t[4]||0);return n>=this._map.getMinZoom()&&n<=this._map.getMaxZoom()&&A>=-180&&A<=180&&h>=this._map.getMinPitch()&&h<=this._map.getMaxPitch()}}const Lr={linearity:.3,easing:d.cw(0,0,.3,1)},Bl=d.e({deceleration:2500,maxSpeed:1400},Lr),an=d.e({deceleration:20,maxSpeed:1400},Lr),yi=d.e({deceleration:1e3,maxSpeed:360},Lr),SA=d.e({deceleration:1e3,maxSpeed:90},Lr),Ir=d.e({deceleration:1e3,maxSpeed:360},Lr);class Wo{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:Ar(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,n=Ar();for(;t.length>0&&n-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const n={zoom:0,bearing:0,pitch:0,roll:0,pan:new d.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:y}of this._inertiaBuffer)n.zoom+=y.zoomDelta||0,n.bearing+=y.bearingDelta||0,n.pitch+=y.pitchDelta||0,n.roll+=y.rollDelta||0,y.panDelta&&n.pan._add(y.panDelta),y.around&&(n.around=y.around),y.pinchAround&&(n.pinchAround=y.pinchAround);const A=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,h={};if(n.pan.mag()){const y=Ho(n.pan.mag(),A,d.e({},Bl,t||{})),b=n.pan.mult(y.amount/n.pan.mag()),M=this._map.cameraHelper.handlePanInertia(b,this._map.transform);h.center=M.easingCenter,h.offset=M.easingOffset,Jn(h,y)}if(n.zoom){const y=Ho(n.zoom,A,an);h.zoom=this._map.transform.zoom+y.amount,Jn(h,y)}if(n.bearing){const y=Ho(n.bearing,A,yi);h.bearing=this._map.transform.bearing+d.an(y.amount,-179,179),Jn(h,y)}if(n.pitch){const y=Ho(n.pitch,A,SA);h.pitch=this._map.transform.pitch+y.amount,Jn(h,y)}if(n.roll){const y=Ho(n.roll,A,Ir);h.roll=this._map.transform.roll+d.an(y.amount,-179,179),Jn(h,y)}if(h.zoom||h.bearing){const y=n.pinchAround===void 0?n.around:n.pinchAround;h.around=y?this._map.unproject(y):this._map.getCenter()}return this.clear(),d.e(h,{noMoveStart:!0})}}function Jn(_,t){(!_.duration||_.duration<t.duration)&&(_.duration=t.duration,_.easing=t.easing)}function Ho(_,t,n){const{maxSpeed:A,linearity:h,deceleration:y}=n,b=d.an(_*h/(t/1e3),-A,A),M=Math.abs(b)/(y*h);return{easing:n.easing,duration:1e3*M,amount:b*(M/2)}}class Ye extends d.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n,A,h={}){A=A instanceof MouseEvent?A:new MouseEvent(t,A);const y=Ze.mousePos(n.getCanvas(),A),b=n.unproject(y);super(t,d.e({point:y,lngLat:b,originalEvent:A},h)),this._defaultPrevented=!1,this.target=n}}class lt extends d.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n,A){const h=t==="touchend"?A.changedTouches:A.touches,y=Ze.touchPos(n.getCanvasContainer(),h),b=y.map((I=>n.unproject(I))),M=y.reduce(((I,D,B,V)=>I.add(D.div(V.length))),new d.P(0,0));super(t,{points:y,point:M,lngLats:b,lngLat:n.unproject(M),originalEvent:A}),this._defaultPrevented=!1}}class el extends d.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n,A){super(t,{originalEvent:A}),this._defaultPrevented=!1}}class CA{constructor(t,n){this._map=t,this._clickTolerance=n.clickTolerance}reset(){delete this._mousedownPos}wheel(t){return this._firePreventable(new el(t.type,this._map,t))}mousedown(t,n){return this._mousedownPos=n,this._firePreventable(new Ye(t.type,this._map,t))}mouseup(t){this._map.fire(new Ye(t.type,this._map,t))}click(t,n){this._mousedownPos&&this._mousedownPos.dist(n)>=this._clickTolerance||this._map.fire(new Ye(t.type,this._map,t))}dblclick(t){return this._firePreventable(new Ye(t.type,this._map,t))}mouseover(t){this._map.fire(new Ye(t.type,this._map,t))}mouseout(t){this._map.fire(new Ye(t.type,this._map,t))}touchstart(t){return this._firePreventable(new lt(t.type,this._map,t))}touchmove(t){this._map.fire(new lt(t.type,this._map,t))}touchend(t){this._map.fire(new lt(t.type,this._map,t))}touchcancel(t){this._map.fire(new lt(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class tl{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(t){this._map.fire(new Ye(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Ye("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._ignoreContextMenu||this._map.fire(new Ye(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class ds{constructor(t){this._map=t}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(t){return this.transform.screenPointToLocation(d.P.convert(t),this._map.terrain)}}class Nn{constructor(t,n){this._map=t,this._tr=new ds(t),this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=n.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(t,n){this.isEnabled()&&t.shiftKey&&t.button===0&&(Ze.disableDrag(),this._startPos=this._lastPos=n,this._active=!0)}mousemoveWindow(t,n){if(!this._active)return;const A=n;if(this._lastPos.equals(A)||!this._box&&A.dist(this._startPos)<this._clickTolerance)return;const h=this._startPos;this._lastPos=A,this._box||(this._box=Ze.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",t));const y=Math.min(h.x,A.x),b=Math.max(h.x,A.x),M=Math.min(h.y,A.y),I=Math.max(h.y,A.y);Ze.setTransform(this._box,`translate(${y}px,${M}px)`),this._box.style.width=b-y+"px",this._box.style.height=I-M+"px"}mouseupWindow(t,n){if(!this._active||t.button!==0)return;const A=this._startPos,h=n;if(this.reset(),Ze.suppressClick(),A.x!==h.x||A.y!==h.y)return this._map.fire(new d.l("boxzoomend",{originalEvent:t})),{cameraAnimation:y=>y.fitScreenCoordinates(A,h,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",t)}keydown(t){this._active&&t.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",t))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(Ze.remove(this._box),this._box=null),Ze.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(t,n){return this._map.fire(new d.l(t,{originalEvent:n}))}}function vi(_,t){if(_.length!==t.length)throw new Error(`The number of touches and points are not equal - touches ${_.length}, points ${t.length}`);const n={};for(let A=0;A<_.length;A++)n[_[A].identifier]=t[A];return n}class yt{constructor(t){this.reset(),this.numTouches=t.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(t,n,A){(this.centroid||A.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=t.timeStamp),A.length===this.numTouches&&(this.centroid=(function(h){const y=new d.P(0,0);for(const b of h)y._add(b);return y.div(h.length)})(n),this.touches=vi(A,n)))}touchmove(t,n,A){if(this.aborted||!this.centroid)return;const h=vi(A,n);for(const y in this.touches){const b=h[y];(!b||b.dist(this.touches[y])>30)&&(this.aborted=!0)}}touchend(t,n,A){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),A.length===0){const h=!this.aborted&&this.centroid;if(this.reset(),h)return h}}}class Gn{constructor(t){this.singleTap=new yt(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(t,n,A){this.singleTap.touchstart(t,n,A)}touchmove(t,n,A){this.singleTap.touchmove(t,n,A)}touchend(t,n,A){const h=this.singleTap.touchend(t,n,A);if(h){const y=t.timeStamp-this.lastTime<500,b=!this.lastTap||this.lastTap.dist(h)<30;if(y&&b||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=h,this.count===this.numTaps)return this.reset(),h}}}class l{constructor(t){this._tr=new ds(t),this._zoomIn=new Gn({numTouches:1,numTaps:2}),this._zoomOut=new Gn({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,n,A){this._zoomIn.touchstart(t,n,A),this._zoomOut.touchstart(t,n,A)}touchmove(t,n,A){this._zoomIn.touchmove(t,n,A),this._zoomOut.touchmove(t,n,A)}touchend(t,n,A){const h=this._zoomIn.touchend(t,n,A),y=this._zoomOut.touchend(t,n,A),b=this._tr;return h?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:M=>M.easeTo({duration:300,zoom:b.zoom+1,around:b.unproject(h)},{originalEvent:t})}):y?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:M=>M.easeTo({duration:300,zoom:b.zoom-1,around:b.unproject(y)},{originalEvent:t})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class a{constructor(t){this._enabled=!!t.enable,this._moveStateManager=t.moveStateManager,this._clickTolerance=t.clickTolerance||1,this._moveFunction=t.move,this._activateOnStart=!!t.activateOnStart,t.assignEvents(this),this.reset()}reset(t){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(t)}_move(...t){const n=this._moveFunction(...t);if(n.bearingDelta||n.pitchDelta||n.rollDelta||n.around||n.panDelta)return this._active=!0,n}dragStart(t,n){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(t)&&(this._moveStateManager.startMove(t),this._lastPoint=Array.isArray(n)?n[0]:n,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(t,n){if(!this.isEnabled())return;const A=this._lastPoint;if(!A)return;if(t.preventDefault(),!this._moveStateManager.isValidMoveEvent(t))return void this.reset(t);const h=Array.isArray(n)?n[0]:n;return!this._moved&&h.dist(A)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=h,this._move(A,h))}dragEnd(t){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(t)&&(this._moved&&Ze.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 u=0,f=2,g={[u]:1,[f]:2};class x{constructor(t){this._correctEvent=t.checkCorrectEvent}startMove(t){const n=Ze.mouseButton(t);this._eventButton=n}endMove(t){delete this._eventButton}isValidStartEvent(t){return this._correctEvent(t)}isValidMoveEvent(t){return!(function(n,A){const h=g[A];return n.buttons===void 0||(n.buttons&h)!==h})(t,this._eventButton)}isValidEndEvent(t){return Ze.mouseButton(t)===this._eventButton}}class w{constructor(){this._firstTouch=void 0}_isOneFingerTouch(t){return t.targetTouches.length===1}_isSameTouchEvent(t){return t.targetTouches[0].identifier===this._firstTouch}startMove(t){this._firstTouch=t.targetTouches[0].identifier}endMove(t){delete this._firstTouch}isValidStartEvent(t){return this._isOneFingerTouch(t)}isValidMoveEvent(t){return this._isOneFingerTouch(t)&&this._isSameTouchEvent(t)}isValidEndEvent(t){return this._isOneFingerTouch(t)&&this._isSameTouchEvent(t)}}class P{constructor(t=new x({checkCorrectEvent:()=>!0}),n=new w){this.mouseMoveStateManager=t,this.oneFingerTouchMoveStateManager=n}_executeRelevantHandler(t,n,A){return t instanceof MouseEvent?n(t):typeof TouchEvent<"u"&&t instanceof TouchEvent?A(t):void 0}startMove(t){this._executeRelevantHandler(t,(n=>this.mouseMoveStateManager.startMove(n)),(n=>this.oneFingerTouchMoveStateManager.startMove(n)))}endMove(t){this._executeRelevantHandler(t,(n=>this.mouseMoveStateManager.endMove(n)),(n=>this.oneFingerTouchMoveStateManager.endMove(n)))}isValidStartEvent(t){return this._executeRelevantHandler(t,(n=>this.mouseMoveStateManager.isValidStartEvent(n)),(n=>this.oneFingerTouchMoveStateManager.isValidStartEvent(n)))}isValidMoveEvent(t){return this._executeRelevantHandler(t,(n=>this.mouseMoveStateManager.isValidMoveEvent(n)),(n=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(n)))}isValidEndEvent(t){return this._executeRelevantHandler(t,(n=>this.mouseMoveStateManager.isValidEndEvent(n)),(n=>this.oneFingerTouchMoveStateManager.isValidEndEvent(n)))}}const C=_=>{_.mousedown=_.dragStart,_.mousemoveWindow=_.dragMove,_.mouseup=_.dragEnd,_.contextmenu=t=>{t.preventDefault()}};class z{constructor(t,n){this._clickTolerance=t.clickTolerance||1,this._map=n,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new d.P(0,0)}_shouldBePrevented(t){return t<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(t,n,A){return this._calculateTransform(t,n,A)}touchmove(t,n,A){if(this._active){if(!this._shouldBePrevented(A.length))return t.preventDefault(),this._calculateTransform(t,n,A);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",t)}}touchend(t,n,A){this._calculateTransform(t,n,A),this._active&&this._shouldBePrevented(A.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(t,n,A){A.length>0&&(this._active=!0);const h=vi(A,n),y=new d.P(0,0),b=new d.P(0,0);let M=0;for(const D in h){const B=h[D],V=this._touches[D];V&&(y._add(B),b._add(B.sub(V)),M++,h[D]=B)}if(this._touches=h,this._shouldBePrevented(M)||!b.mag())return;const I=b.div(M);return this._sum._add(I),this._sum.mag()<this._clickTolerance?void 0:{around:y.div(M),panDelta:I}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class F{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(t,n,A){this._firstTwoTouches||A.length<2||(this._firstTwoTouches=[A[0].identifier,A[1].identifier],this._start([n[0],n[1]]))}touchmove(t,n,A){if(!this._firstTwoTouches)return;t.preventDefault();const[h,y]=this._firstTwoTouches,b=K(A,n,h),M=K(A,n,y);if(!b||!M)return;const I=this._aroundCenter?null:b.add(M).div(2);return this._move([b,M],I,t)}touchend(t,n,A){if(!this._firstTwoTouches)return;const[h,y]=this._firstTwoTouches,b=K(A,n,h),M=K(A,n,y);b&&M||(this._active&&Ze.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(t){this._enabled=!0,this._aroundCenter=!!t&&t.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}}function K(_,t,n){for(let A=0;A<_.length;A++)if(_[A].identifier===n)return t[A]}function ae(_,t){return Math.log(_/t)/Math.LN2}class oe extends F{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(t){this._startDistance=this._distance=t[0].dist(t[1])}_move(t,n){const A=this._distance;if(this._distance=t[0].dist(t[1]),this._active||!(Math.abs(ae(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:ae(this._distance,A),pinchAround:n}}}function le(_,t){return 180*_.angleWith(t)/Math.PI}class xe extends F{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,n,A){const h=this._vector;if(this._vector=t[0].sub(t[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:le(this._vector,h),pinchAround:n}}_isBelowThreshold(t){this._minDiameter=Math.min(this._minDiameter,t.mag());const n=25/(Math.PI*this._minDiameter)*360,A=le(t,this._startVector);return Math.abs(A)<n}}function Ee(_){return Math.abs(_.y)>Math.abs(_.x)}class Ue extends F{constructor(t){super(),this._currentTouchCount=0,this._map=t}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(t,n,A){super.touchstart(t,n,A),this._currentTouchCount=A.length}_start(t){this._lastPoints=t,Ee(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,n,A){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const h=t[0].sub(this._lastPoints[0]),y=t[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(h,y,A.timeStamp),this._valid?(this._lastPoints=t,this._active=!0,{pitchDelta:(h.y+y.y)/2*-.5}):void 0}gestureBeginsVertically(t,n,A){if(this._valid!==void 0)return this._valid;const h=t.mag()>=2,y=n.mag()>=2;if(!h&&!y)return;if(!h||!y)return this._firstMove===void 0&&(this._firstMove=A),A-this._firstMove<100&&void 0;const b=t.y>0==n.y>0;return Ee(t)&&Ee(n)&&b}}const Se={panStep:100,bearingStep:15,pitchStep:10};class Pe{constructor(t){this._tr=new ds(t);const n=Se;this._panStep=n.panStep,this._bearingStep=n.bearingStep,this._pitchStep=n.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let n=0,A=0,h=0,y=0,b=0;switch(t.keyCode){case 61:case 107:case 171:case 187:n=1;break;case 189:case 109:case 173:n=-1;break;case 37:t.shiftKey?A=-1:(t.preventDefault(),y=-1);break;case 39:t.shiftKey?A=1:(t.preventDefault(),y=1);break;case 38:t.shiftKey?h=1:(t.preventDefault(),b=-1);break;case 40:t.shiftKey?h=-1:(t.preventDefault(),b=1);break;default:return}return this._rotationDisabled&&(A=0,h=0),{cameraAnimation:M=>{const I=this._tr;M.easeTo({duration:300,easeId:"keyboardHandler",easing:we,zoom:n?Math.round(I.zoom)+n*(t.shiftKey?2:1):I.zoom,bearing:I.bearing+A*this._bearingStep,pitch:I.pitch+h*this._pitchStep,offset:[-y*this._panStep,-b*this._panStep],center:I.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 we(_){return _*(2-_)}const ct=4.000244140625,St=1/450;class Mt{constructor(t,n){this._onTimeout=A=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(A)},this._map=t,this._tr=new ds(t),this._triggerRenderFrame=n,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=St}setZoomRate(t){this._defaultZoomRate=t}setWheelZoomRate(t){this._wheelZoomRate=t}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!t&&t.around==="center")}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 n=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const A=Ar(),h=A-(this._lastWheelEventTime||0);this._lastWheelEventTime=A,n!==0&&n%ct==0?this._type="wheel":n!==0&&Math.abs(n)<4?this._type="trackpad":h>400?(this._type=null,this._lastValue=n,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(h*n)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,n+=this._lastValue)),t.shiftKey&&n&&(n/=4),this._type&&(this._lastWheelEvent=t,this._delta-=n,this._active||this._start(t)),t.preventDefault()}_start(t){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const n=Ze.mousePos(this._map.getCanvas(),t),A=this._tr;this._aroundPoint=this._aroundCenter?A.transform.locationToScreenPoint(d.V.convert(A.center)):n,this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const t=this._tr.transform;if(typeof this._lastExpectedZoom=="number"){const M=t.zoom-this._lastExpectedZoom;typeof this._startZoom=="number"&&(this._startZoom+=M),typeof this._targetZoom=="number"&&(this._targetZoom+=M)}if(this._delta!==0){const M=this._type==="wheel"&&Math.abs(this._delta)>ct?this._wheelZoomRate:this._defaultZoomRate;let I=2/(1+Math.exp(-Math.abs(this._delta*M)));this._delta<0&&I!==0&&(I=1/I);const D=typeof this._targetZoom!="number"?t.scale:d.aq(this._targetZoom);this._targetZoom=t.applyConstrain(t.getCameraLngLat(),d.at(D*I)).zoom,this._type==="wheel"&&(this._startZoom=t.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const n=typeof this._targetZoom!="number"?t.zoom:this._targetZoom,A=this._startZoom,h=this._easing;let y,b=!1;if(this._type==="wheel"&&A&&h){const M=Ar()-this._lastWheelEventTime,I=Math.min((M+5)/200,1),D=h(I);y=d.G.number(A,n,D),I<1?this._frameId||(this._frameId=!0):b=!0}else y=n,b=!0;return this._active=!0,b&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout}),200)),this._lastExpectedZoom=y,{noInertia:!0,needsRenderFrame:!b,zoomDelta:y-t.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let n=d.cy;if(this._prevEase){const A=this._prevEase,h=(Ar()-A.start)/A.duration,y=A.easing(h+.01)-A.easing(h),b=.27/Math.sqrt(y*y+1e-4)*.01,M=Math.sqrt(.0729-b*b);n=d.cw(b,M,.25,1)}return this._prevEase={start:Ar(),duration:t,easing:n},n}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class jt{constructor(t,n){this._clickZoom=t,this._tapZoom=n}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class $t{constructor(t){this._tr=new ds(t),this.reset()}reset(){this._active=!1}dblclick(t,n){return t.preventDefault(),{cameraAnimation:A=>{A.easeTo({duration:300,zoom:this._tr.zoom+(t.shiftKey?-1:1),around:this._tr.unproject(n)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class ir{constructor(){this._tap=new Gn({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(t,n,A){if(!this._swipePoint)if(this._tapTime){const h=n[0],y=t.timeStamp-this._tapTime<500,b=this._tapPoint.dist(h)<30;y&&b?A.length>0&&(this._swipePoint=h,this._swipeTouch=A[0].identifier):this.reset()}else this._tap.touchstart(t,n,A)}touchmove(t,n,A){if(this._tapTime){if(this._swipePoint){if(A[0].identifier!==this._swipeTouch)return;const h=n[0],y=h.y-this._swipePoint.y;return this._swipePoint=h,t.preventDefault(),this._active=!0,{zoomDelta:y/128}}}else this._tap.touchmove(t,n,A)}touchend(t,n,A){if(this._tapTime)this._swipePoint&&A.length===0&&this.reset();else{const h=this._tap.touchend(t,n,A);h&&(this._tapTime=t.timeStamp,this._tapPoint=h)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Rt{constructor(t,n,A){this._el=t,this._mousePan=n,this._touchPan=A}enable(t){this._inertiaOptions=t||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Et{constructor(t,n,A,h){this._pitchWithRotate=t.pitchWithRotate,this._rollEnabled=t.rollEnabled,this._mouseRotate=n,this._mousePitch=A,this._mouseRoll=h}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}}class At{constructor(t,n,A,h){this._el=t,this._touchZoom=n,this._touchRotate=A,this._tapDragZoom=h,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()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}class at{constructor(t,n){this._bypassKey=navigator.userAgent.indexOf("Mac")!==-1?"metaKey":"ctrlKey",this._map=t,this._options=n,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;const t=this._map.getCanvasContainer();t.classList.add("maplibregl-cooperative-gestures"),this._container=Ze.create("div","maplibregl-cooperative-gesture-screen",t);let n=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(n=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const A=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),h=document.createElement("div");h.className="maplibregl-desktop-message",h.textContent=n,this._container.appendChild(h);const y=document.createElement("div");y.className="maplibregl-mobile-message",y.textContent=A,this._container.appendChild(y),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(Ze.remove(this._container),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,n){this._enabled&&(this._map.fire(new d.l("cooperativegestureprevented",{gestureType:t,originalEvent:n})),this._container.classList.add("maplibregl-show"),setTimeout((()=>{this._container.classList.remove("maplibregl-show")}),100))}}const dt=_=>_.zoom||_.drag||_.roll||_.pitch||_.rotate;class Nt extends d.l{}function fr(_){return _.panDelta&&_.panDelta.mag()||_.zoomDelta||_.bearingDelta||_.pitchDelta||_.rollDelta}class xi{constructor(t,n){this.handleWindowEvent=h=>{this.handleEvent(h,`${h.type}Window`)},this.handleEvent=(h,y)=>{if(h.type==="blur")return void this.stop(!0);this._updatingCamera=!0;const b=h.type==="renderFrame"?void 0:h,M={needsRenderFrame:!1},I={},D={};for(const{handlerName:O,handler:U,allowed:X}of this._handlers){if(!U.isEnabled())continue;let ie;if(this._blockedByActive(D,X,O))U.reset();else if(U[y||h.type]){if(d.cz(h,y||h.type)){const se=Ze.mousePos(this._map.getCanvas(),h);ie=U[y||h.type](h,se)}else if(d.cA(h,y||h.type)){const se=this._getMapTouches(h.touches),ne=Ze.touchPos(this._map.getCanvas(),se);ie=U[y||h.type](h,ne,se)}else d.cB(y||h.type)||(ie=U[y||h.type](h));this.mergeHandlerResult(M,I,ie,O,b),ie&&ie.needsRenderFrame&&this._triggerRenderFrame()}(ie||U.isActive())&&(D[O]=U)}const B={};for(const O in this._previousActiveHandlers)D[O]||(B[O]=b);this._previousActiveHandlers=D,(Object.keys(B).length||fr(M))&&(this._changes.push([M,I,B]),this._triggerRenderFrame()),(Object.keys(D).length||fr(M))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:V}=M;V&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],V(this._map))},this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Wo(t),this._bearingSnap=n.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(n);const A=this._el;this._listeners=[[A,"touchstart",{passive:!0}],[A,"touchmove",{passive:!1}],[A,"touchend",void 0],[A,"touchcancel",void 0],[A,"mousedown",void 0],[A,"mousemove",void 0],[A,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[A,"mouseover",void 0],[A,"mouseout",void 0],[A,"dblclick",void 0],[A,"click",void 0],[A,"keydown",{capture:!1}],[A,"keyup",void 0],[A,"wheel",{passive:!1}],[A,"contextmenu",void 0],[window,"blur",void 0]];for(const[h,y,b]of this._listeners)Ze.addEventListener(h,y,h===document?this.handleWindowEvent:this.handleEvent,b)}destroy(){for(const[t,n,A]of this._listeners)Ze.removeEventListener(t,n,t===document?this.handleWindowEvent:this.handleEvent,A)}_addDefaultHandlers(t){const n=this._map,A=n.getCanvasContainer();this._add("mapEvent",new CA(n,t));const h=n.boxZoom=new Nn(n,t);this._add("boxZoom",h),t.interactive&&t.boxZoom&&h.enable();const y=n.cooperativeGestures=new at(n,t.cooperativeGestures);this._add("cooperativeGestures",y),t.cooperativeGestures&&y.enable();const b=new l(n),M=new $t(n);n.doubleClickZoom=new jt(M,b),this._add("tapZoom",b),this._add("clickZoom",M),t.interactive&&t.doubleClickZoom&&n.doubleClickZoom.enable();const I=new ir;this._add("tapDragZoom",I);const D=n.touchPitch=new Ue(n);this._add("touchPitch",D),t.interactive&&t.touchPitch&&n.touchPitch.enable(t.touchPitch);const B=()=>n.project(n.getCenter()),V=(function({enable:Ae,clickTolerance:de,aroundCenter:ye=!0,minPixelCenterThreshold:fe=100,rotateDegreesPerPixelMoved:Me=.8},Ge){const Fe=new x({checkCorrectEvent:Oe=>Ze.mouseButton(Oe)===0&&Oe.ctrlKey||Ze.mouseButton(Oe)===2&&!Oe.ctrlKey});return new a({clickTolerance:de,move:(Oe,Ve)=>{const ut=Ge();if(ye&&Math.abs(ut.y-Oe.y)>fe)return{bearingDelta:d.cx(new d.P(Oe.x,Ve.y),Ve,ut)};let ht=(Ve.x-Oe.x)*Me;return ye&&Ve.y<ut.y&&(ht=-ht),{bearingDelta:ht}},moveStateManager:Fe,enable:Ae,assignEvents:C})})(t,B),O=(function({enable:Ae,clickTolerance:de,pitchDegreesPerPixelMoved:ye=-.5}){const fe=new x({checkCorrectEvent:Me=>Ze.mouseButton(Me)===0&&Me.ctrlKey||Ze.mouseButton(Me)===2});return new a({clickTolerance:de,move:(Me,Ge)=>({pitchDelta:(Ge.y-Me.y)*ye}),moveStateManager:fe,enable:Ae,assignEvents:C})})(t),U=(function({enable:Ae,clickTolerance:de,rollDegreesPerPixelMoved:ye=.3},fe){const Me=new x({checkCorrectEvent:Ge=>Ze.mouseButton(Ge)===2&&Ge.ctrlKey});return new a({clickTolerance:de,move:(Ge,Fe)=>{const Oe=fe();let Ve=(Fe.x-Ge.x)*ye;return Fe.y<Oe.y&&(Ve=-Ve),{rollDelta:Ve}},moveStateManager:Me,enable:Ae,assignEvents:C})})(t,B);n.dragRotate=new Et(t,V,O,U),this._add("mouseRotate",V,["mousePitch"]),this._add("mousePitch",O,["mouseRotate","mouseRoll"]),this._add("mouseRoll",U,["mousePitch"]),t.interactive&&t.dragRotate&&n.dragRotate.enable();const X=(function({enable:Ae,clickTolerance:de}){const ye=new x({checkCorrectEvent:fe=>Ze.mouseButton(fe)===0&&!fe.ctrlKey});return new a({clickTolerance:de,move:(fe,Me)=>({around:Me,panDelta:Me.sub(fe)}),activateOnStart:!0,moveStateManager:ye,enable:Ae,assignEvents:C})})(t),ie=new z(t,n);n.dragPan=new Rt(A,X,ie),this._add("mousePan",X),this._add("touchPan",ie,["touchZoom","touchRotate"]),t.interactive&&t.dragPan&&n.dragPan.enable(t.dragPan);const se=new xe,ne=new oe;n.touchZoomRotate=new At(A,ne,se,I),this._add("touchRotate",se,["touchPan","touchZoom"]),this._add("touchZoom",ne,["touchPan","touchRotate"]),t.interactive&&t.touchZoomRotate&&n.touchZoomRotate.enable(t.touchZoomRotate),this._add("blockableMapEvent",new tl(n));const ce=n.scrollZoom=new Mt(n,(()=>this._triggerRenderFrame()));this._add("scrollZoom",ce,["mousePan"]),t.interactive&&t.scrollZoom&&n.scrollZoom.enable(t.scrollZoom);const ge=n.keyboard=new Pe(n);this._add("keyboard",ge),t.interactive&&t.keyboard&&n.keyboard.enable()}_add(t,n,A){this._handlers.push({handlerName:t,handler:n,allowed:A}),this._handlersById[t]=n}stop(t){if(!this._updatingCamera){for(const{handler:n}of this._handlers)n.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[]}}isActive(){for(const{handler:t}of this._handlers)if(t.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!dt(this._eventsInProgress)||this.isZooming()}_blockedByActive(t,n,A){for(const h in t)if(h!==A&&(!n||n.indexOf(h)<0))return!0;return!1}_getMapTouches(t){const n=[];for(const A of t)this._el.contains(A.target)&&n.push(A);return n}mergeHandlerResult(t,n,A,h,y){if(!A)return;d.e(t,A);const b={handlerName:h,originalEvent:A.originalEvent||y};A.zoomDelta!==void 0&&(n.zoom=b),A.panDelta!==void 0&&(n.drag=b),A.rollDelta!==void 0&&(n.roll=b),A.pitchDelta!==void 0&&(n.pitch=b),A.bearingDelta!==void 0&&(n.rotate=b)}_applyChanges(){const t={},n={},A={};for(const[h,y,b]of this._changes)h.panDelta&&(t.panDelta=(t.panDelta||new d.P(0,0))._add(h.panDelta)),h.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+h.zoomDelta),h.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+h.bearingDelta),h.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+h.pitchDelta),h.rollDelta&&(t.rollDelta=(t.rollDelta||0)+h.rollDelta),h.around!==void 0&&(t.around=h.around),h.pinchAround!==void 0&&(t.pinchAround=h.pinchAround),h.noInertia&&(t.noInertia=h.noInertia),d.e(n,y),d.e(A,b);this._updateMapTransform(t,n,A),this._changes=[]}_updateMapTransform(t,n,A){const h=this._map,y=h._getTransformForUpdate(),b=h.terrain;if(!(fr(t)||b&&this._terrainMovement))return this._fireEvents(n,A,!0);h._stop(!0);let{panDelta:M,zoomDelta:I,bearingDelta:D,pitchDelta:B,rollDelta:V,around:O,pinchAround:U}=t;U!==void 0&&(O=U),O=O||h.transform.centerPoint,b&&!y.isPointOnMapSurface(O)&&(O=y.centerPoint);const X={panDelta:M,zoomDelta:I,rollDelta:V,pitchDelta:B,bearingDelta:D,around:O};this._map.cameraHelper.useGlobeControls&&!y.isPointOnMapSurface(O)&&(O=y.centerPoint);const ie=O.distSqr(y.centerPoint)<.01?y.center:y.screenPointToLocation(M?O.sub(M):O);this._handleMapControls({terrain:b,tr:y,deltasForHelper:X,preZoomAroundLoc:ie,combinedEventsInProgress:n,panDelta:M}),h._applyUpdatedTransform(y),this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(n,A,!0)}_handleMapControls({terrain:t,tr:n,deltasForHelper:A,preZoomAroundLoc:h,combinedEventsInProgress:y,panDelta:b}){const M=this._map.cameraHelper;if(M.handleMapControlsRollPitchBearingZoom(A,n),t)return M.useGlobeControls?(this._terrainMovement||!y.drag&&!y.zoom||(this._terrainMovement=!0,this._map._elevationFreeze=!0),void M.handleMapControlsPan(A,n,h)):this._terrainMovement||!y.drag&&!y.zoom?void(y.drag&&this._terrainMovement&&b?n.setCenter(n.screenPointToLocation(n.centerPoint.sub(b))):M.handleMapControlsPan(A,n,h)):(this._terrainMovement=!0,this._map._elevationFreeze=!0,void M.handleMapControlsPan(A,n,h));M.handleMapControlsPan(A,n,h)}_fireEvents(t,n,A){const h=dt(this._eventsInProgress),y=dt(t),b={};for(const V in t){const{originalEvent:O}=t[V];this._eventsInProgress[V]||(b[`${V}start`]=O),this._eventsInProgress[V]=t[V]}!h&&y&&this._fireEvent("movestart",y.originalEvent);for(const V in b)this._fireEvent(V,b[V]);y&&this._fireEvent("move",y.originalEvent);for(const V in t){const{originalEvent:O}=t[V];this._fireEvent(V,O)}const M={};let I;for(const V in this._eventsInProgress){const{handlerName:O,originalEvent:U}=this._eventsInProgress[V];this._handlersById[O].isActive()||(delete this._eventsInProgress[V],I=n[O]||U,M[`${V}end`]=I)}for(const V in M)this._fireEvent(V,M[V]);const D=dt(this._eventsInProgress),B=(h||y)&&!D;if(B&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const V=this._map._getTransformForUpdate();this._map.getCenterClampedToGround()&&V.recalculateZoomAndCenter(this._map.terrain),this._map._applyUpdatedTransform(V)}if(A&&B){this._updatingCamera=!0;const V=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),O=U=>U!==0&&-this._bearingSnap<U&&U<this._bearingSnap;!V||!V.essential&&hi.prefersReducedMotion?(this._map.fire(new d.l("moveend",{originalEvent:I})),O(this._map.getBearing())&&this._map.resetNorth()):(O(V.bearing||this._map.getBearing())&&(V.bearing=0),V.freezeElevation=!0,this._map.easeTo(V,{originalEvent:I})),this._updatingCamera=!1}}_fireEvent(t,n){this._map.fire(new d.l(t,n?{originalEvent:n}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add((t=>{delete this._frameId,this.handleEvent(new Nt("renderFrame",{timeStamp:t})),this._applyChanges()}))}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class Ri extends d.E{constructor(t,n,A){super(),this._renderFrameCallback=()=>{const h=Math.min((Ar()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(h)),h<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=A.bearingSnap,this.cameraHelper=n,this.on("moveend",(()=>{delete this._requestedCameraState}))}migrateProjection(t,n){t.apply(this.transform,!0),this.transform=t,this.cameraHelper=n}getCenter(){return new d.V(this.transform.center.lng,this.transform.center.lat)}setCenter(t,n){return this.jumpTo({center:t},n)}getCenterElevation(){return this.transform.elevation}setCenterElevation(t,n){return this.jumpTo({elevation:t},n),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(t){this._centerClampedToGround=t}panBy(t,n,A){return t=d.P.convert(t).mult(-1),this.panTo(this.transform.center,d.e({offset:t},n),A)}panTo(t,n,A){return this.easeTo(d.e({center:t},n),A)}getZoom(){return this.transform.zoom}setZoom(t,n){return this.jumpTo({zoom:t},n),this}zoomTo(t,n,A){return this.easeTo(d.e({zoom:t},n),A)}zoomIn(t,n){return this.zoomTo(this.getZoom()+1,t,n),this}zoomOut(t,n){return this.zoomTo(this.getZoom()-1,t,n),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(t,n){return t!=this.transform.fov&&(this.transform.setFov(t),this.fire(new d.l("movestart",n)).fire(new d.l("move",n)).fire(new d.l("moveend",n))),this}getBearing(){return this.transform.bearing}setBearing(t,n){return this.jumpTo({bearing:t},n),this}getPadding(){return this.transform.padding}setPadding(t,n){return this.jumpTo({padding:t},n),this}rotateTo(t,n,A){return this.easeTo(d.e({bearing:t},n),A)}resetNorth(t,n){return this.rotateTo(0,d.e({duration:1e3},t),n),this}resetNorthPitch(t,n){return this.easeTo(d.e({bearing:0,pitch:0,roll:0,duration:1e3},t),n),this}snapToNorth(t,n){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(t,n):this}getPitch(){return this.transform.pitch}setPitch(t,n){return this.jumpTo({pitch:t},n),this}getRoll(){return this.transform.roll}setRoll(t,n){return this.jumpTo({roll:t},n),this}cameraForBounds(t,n){t=xr.convert(t).adjustAntiMeridian();const A=n&&n.bearing||0;return this._cameraForBoxAndBearing(t.getNorthWest(),t.getSouthEast(),A,n)}_cameraForBoxAndBearing(t,n,A,h){const y={top:0,bottom:0,right:0,left:0};if(typeof(h=d.e({padding:y,offset:[0,0],maxZoom:this.transform.maxZoom},h)).padding=="number"){const D=h.padding;h.padding={top:D,bottom:D,right:D,left:D}}const b=d.e(y,h.padding);h.padding=b;const M=this.transform,I=new xr(t,n);return this.cameraHelper.cameraForBoxAndBearing(h,b,I,A,M)}fitBounds(t,n,A){return this._fitInternal(this.cameraForBounds(t,n),n,A)}fitScreenCoordinates(t,n,A,h,y){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.screenPointToLocation(d.P.convert(t)),this.transform.screenPointToLocation(d.P.convert(n)),A,h),h,y)}_fitInternal(t,n,A){return t?(delete(n=d.e(t,n)).padding,n.linear?this.easeTo(n,A):this.flyTo(n,A)):this}jumpTo(t,n){this.stop();const A=this._getTransformForUpdate();let h=!1,y=!1,b=!1;const M=A.zoom;this.cameraHelper.handleJumpToCenterZoom(A,t);const I=A.zoom!==M;return"elevation"in t&&A.elevation!==+t.elevation&&A.setElevation(+t.elevation),"bearing"in t&&A.bearing!==+t.bearing&&(h=!0,A.setBearing(+t.bearing)),"pitch"in t&&A.pitch!==+t.pitch&&(y=!0,A.setPitch(+t.pitch)),"roll"in t&&A.roll!==+t.roll&&(b=!0,A.setRoll(+t.roll)),t.padding==null||A.isPaddingEqual(t.padding)||A.setPadding(t.padding),this._applyUpdatedTransform(A),this.fire(new d.l("movestart",n)).fire(new d.l("move",n)),I&&this.fire(new d.l("zoomstart",n)).fire(new d.l("zoom",n)).fire(new d.l("zoomend",n)),h&&this.fire(new d.l("rotatestart",n)).fire(new d.l("rotate",n)).fire(new d.l("rotateend",n)),y&&this.fire(new d.l("pitchstart",n)).fire(new d.l("pitch",n)).fire(new d.l("pitchend",n)),b&&this.fire(new d.l("rollstart",n)).fire(new d.l("roll",n)).fire(new d.l("rollend",n)),this.fire(new d.l("moveend",n))}calculateCameraOptionsFromTo(t,n,A,h=0){const y=d.a9.fromLngLat(t,n),b=d.a9.fromLngLat(A,h),M=b.x-y.x,I=b.y-y.y,D=b.z-y.z,B=Math.hypot(M,I,D);if(B===0)throw new Error("Can't calculate camera options with same From and To");const V=Math.hypot(M,I),O=d.at(this.transform.cameraToCenterDistance/B/this.transform.tileSize),U=180*Math.atan2(M,-I)/Math.PI;let X=180*Math.acos(V/B)/Math.PI;return X=D<0?90-X:90+X,{center:b.toLngLat(),elevation:h,zoom:O,pitch:X,bearing:U}}calculateCameraOptionsFromCameraLngLatAltRotation(t,n,A,h,y){const b=this.transform.calculateCenterFromCameraLngLatAlt(t,n,A,h);return{center:b.center,elevation:b.elevation,zoom:b.zoom,bearing:A,pitch:h,roll:y}}easeTo(t,n){this._stop(!1,t.easeId),((t=d.e({offset:[0,0],duration:500,easing:d.cy},t)).animate===!1||!t.essential&&hi.prefersReducedMotion)&&(t.duration=0);const A=this._getTransformForUpdate(),h=this.getBearing(),y=A.pitch,b=A.roll,M="bearing"in t?this._normalizeBearing(t.bearing,h):h,I="pitch"in t?+t.pitch:y,D="roll"in t?this._normalizeBearing(t.roll,b):b,B="padding"in t?t.padding:A.padding,V=d.P.convert(t.offset);let O,U;t.around&&(O=d.V.convert(t.around),U=A.locationToScreenPoint(O));const X={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching,rolling:this._rolling},ie=this.cameraHelper.handleEaseTo(A,{bearing:M,pitch:I,roll:D,padding:B,around:O,aroundPoint:U,offsetAsPoint:V,offset:t.offset,zoom:t.zoom,center:t.center});return this._rotating=this._rotating||h!==M,this._pitching=this._pitching||I!==y,this._rolling=this._rolling||D!==b,this._padding=!A.isPaddingEqual(B),this._zooming=this._zooming||ie.isZooming,this._easeId=t.easeId,this._prepareEase(n,t.noMoveStart,X),this.terrain&&this._prepareElevation(ie.elevationCenter),this._ease((se=>{ie.easeFunc(se),this.terrain&&!t.freezeElevation&&this._updateElevation(se),this._applyUpdatedTransform(A),this._fireMoveEvents(n)}),(se=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(n,se)}),t),this}_prepareEase(t,n,A={}){this._moving=!0,n||A.moving||this.fire(new d.l("movestart",t)),this._zooming&&!A.zooming&&this.fire(new d.l("zoomstart",t)),this._rotating&&!A.rotating&&this.fire(new d.l("rotatestart",t)),this._pitching&&!A.pitching&&this.fire(new d.l("pitchstart",t)),this._rolling&&!A.rolling&&this.fire(new d.l("rollstart",t))}_prepareElevation(t){this._elevationCenter=t,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(t,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(t){this._elevationStart!==void 0&&this._elevationCenter!==void 0||this._prepareElevation(this.transform.center),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));const n=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(t<1&&n!==this._elevationTarget){const A=this._elevationTarget-this._elevationStart;this._elevationStart+=t*(A-(n-(A*t+this._elevationStart))/(1-t)),this._elevationTarget=n}this.transform.setElevation(d.G.number(this._elevationStart,this._elevationTarget,t))}_finalizeElevation(){this._elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(t){if(!this.terrain&&t.elevation>=0&&t.pitch<=90)return{};const n=t.getCameraLngLat(),A=t.getCameraAltitude(),h=this.terrain?this.terrain.getElevationForLngLatZoom(n,t.zoom):0;if(A<h){const y=this.calculateCameraOptionsFromTo(n,h,t.center,t.elevation);return{pitch:y.pitch,zoom:y.zoom}}return{}}_applyUpdatedTransform(t){const n=[];if(n.push((h=>this._elevateCameraIfInsideTerrain(h))),this.transformCameraUpdate&&n.push((h=>this.transformCameraUpdate(h))),!n.length)return;const A=t.clone();for(const h of n){const y=A.clone(),{center:b,zoom:M,roll:I,pitch:D,bearing:B,elevation:V}=h(y);b&&y.setCenter(b),V!==void 0&&y.setElevation(V),M!==void 0&&y.setZoom(M),I!==void 0&&y.setRoll(I),D!==void 0&&y.setPitch(D),B!==void 0&&y.setBearing(B),A.apply(y,!1)}this.transform.apply(A,!1)}_fireMoveEvents(t){this.fire(new d.l("move",t)),this._zooming&&this.fire(new d.l("zoom",t)),this._rotating&&this.fire(new d.l("rotate",t)),this._pitching&&this.fire(new d.l("pitch",t)),this._rolling&&this.fire(new d.l("roll",t))}_afterEase(t,n){if(this._easeId&&n&&this._easeId===n)return;delete this._easeId;const A=this._zooming,h=this._rotating,y=this._pitching,b=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,A&&this.fire(new d.l("zoomend",t)),h&&this.fire(new d.l("rotateend",t)),y&&this.fire(new d.l("pitchend",t)),b&&this.fire(new d.l("rollend",t)),this.fire(new d.l("moveend",t))}flyTo(t,n){if(!t.essential&&hi.prefersReducedMotion){const Ve=d.U(t,["center","zoom","bearing","pitch","roll","elevation","padding"]);return this.jumpTo(Ve,n)}this.stop(),t=d.e({offset:[0,0],speed:1.2,curve:1.42,easing:d.cy},t);const A=this._getTransformForUpdate(),h=A.bearing,y=A.pitch,b=A.roll,M=A.padding,I="bearing"in t?this._normalizeBearing(t.bearing,h):h,D="pitch"in t?+t.pitch:y,B="roll"in t?this._normalizeBearing(t.roll,b):b,V="padding"in t?t.padding:A.padding,O=d.P.convert(t.offset);let U=A.centerPoint.add(O);const X=A.screenPointToLocation(U),ie=this.cameraHelper.handleFlyTo(A,{bearing:I,pitch:D,roll:B,padding:V,locationAtOffset:X,offsetAsPoint:O,center:t.center,minZoom:t.minZoom,zoom:t.zoom});let se=t.curve;const ne=Math.max(A.width,A.height),ce=ne/ie.scaleOfZoom,ge=ie.pixelPathLength;typeof ie.scaleOfMinZoom=="number"&&(se=Math.sqrt(ne/ie.scaleOfMinZoom/ge*2));const Ae=se*se;function de(Ve){const ut=(ce*ce-ne*ne+(Ve?-1:1)*Ae*Ae*ge*ge)/(2*(Ve?ce:ne)*Ae*ge);return Math.log(Math.sqrt(ut*ut+1)-ut)}function ye(Ve){return(Math.exp(Ve)-Math.exp(-Ve))/2}function fe(Ve){return(Math.exp(Ve)+Math.exp(-Ve))/2}const Me=de(!1);let Ge=function(Ve){return fe(Me)/fe(Me+se*Ve)},Fe=function(Ve){return ne*((fe(Me)*(ye(ut=Me+se*Ve)/fe(ut))-ye(Me))/Ae)/ge;var ut},Oe=(de(!0)-Me)/se;if(Math.abs(ge)<2e-6||!isFinite(Oe)){if(Math.abs(ne-ce)<1e-6)return this.easeTo(t,n);const Ve=ce<ne?-1:1;Oe=Math.abs(Math.log(ce/ne))/se,Fe=()=>0,Ge=ut=>Math.exp(Ve*se*ut)}return t.duration="duration"in t?+t.duration:1e3*Oe/("screenSpeed"in t?+t.screenSpeed/se:+t.speed),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0),this._zooming=!0,this._rotating=h!==I,this._pitching=D!==y,this._rolling=B!==b,this._padding=!A.isPaddingEqual(V),this._prepareEase(n,!1),this.terrain&&this._prepareElevation(ie.targetCenter),this._ease((Ve=>{const ut=Ve*Oe,ht=1/Ge(ut),rt=Fe(ut);this._rotating&&A.setBearing(d.G.number(h,I,Ve)),this._pitching&&A.setPitch(d.G.number(y,D,Ve)),this._rolling&&A.setRoll(d.G.number(b,B,Ve)),this._padding&&(A.interpolatePadding(M,V,Ve),U=A.centerPoint.add(O)),ie.easeFunc(Ve,ht,rt,U),this.terrain&&!t.freezeElevation&&this._updateElevation(Ve),this._applyUpdatedTransform(A),this._fireMoveEvents(n)}),(()=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(n)}),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(t,n){var A;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const h=this._onEaseEnd;delete this._onEaseEnd,h.call(this,n)}return t||(A=this.handlers)===null||A===void 0||A.stop(!1),this}_ease(t,n,A){A.animate===!1||A.duration===0?(t(1),n()):(this._easeStart=Ar(),this._easeOptions=A,this._onEaseFrame=t,this._onEaseEnd=n,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(t,n){t=d.W(t,-180,180);const A=Math.abs(t-n);return Math.abs(t-360-n)<A&&(t-=360),Math.abs(t+360-n)<A&&(t+=360),t}queryTerrainElevation(t){return this.terrain?this.terrain.getElevationForLngLat(d.V.convert(t),this.transform):null}}const es={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};class pu{constructor(t=es){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=n=>{!n||n.sourceDataType!=="metadata"&&n.sourceDataType!=="visibility"&&n.dataType!=="style"&&n.type!=="terrain"||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact===!1?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=Ze.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=Ze.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=Ze.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(){Ze.remove(this._container),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,n){const A=this._map._getUIString(`AttributionControl.${n}`);t.title=A,t.setAttribute("aria-label",A)}_updateAttributions(){if(!this._map.style)return;let t=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=t.concat(this.options.customAttribution.map((h=>typeof h!="string"?"":h))):typeof this.options.customAttribution=="string"&&t.push(this.options.customAttribution)),this._map.style.stylesheet){const h=this._map.style.stylesheet;this.styleOwner=h.owner,this.styleId=h.id}const n=this._map.style.tileManagers;for(const h in n){const y=n[h];if(y.used||y.usedForTerrain){const b=y.getSource();b.attribution&&t.indexOf(b.attribution)<0&&t.push(b.attribution)}}t=t.filter((h=>String(h).trim())),t.sort(((h,y)=>h.length-y.length)),t=t.filter(((h,y)=>{for(let b=y+1;b<t.length;b++)if(t[b].indexOf(h)>=0)return!1;return!0}));const A=t.join(" | ");A!==this._attribHTML&&(this._attribHTML=A,t.length?(this._innerContainer.innerHTML=Ze.sanitize(A),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class Qu{constructor(t={}){this._updateCompact=()=>{const n=this._container.children;if(n.length){const A=n[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&A.classList.add("maplibregl-compact"):A.classList.remove("maplibregl-compact")}},this.options=t}getDefaultPosition(){return"bottom-left"}onAdd(t){this._map=t,this._compact=this.options&&this.options.compact,this._container=Ze.create("div","maplibregl-ctrl");const n=Ze.create("a","maplibregl-ctrl-logo");return n.target="_blank",n.rel="noopener nofollow",n.href="https://maplibre.org/",n.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),n.setAttribute("rel","noopener nofollow"),this._container.appendChild(n),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){Ze.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class Ic{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){const n=++this._id;return this._queue.push({callback:t,id:n,cancelled:!1}),n}remove(t){const n=this._currentlyRunning,A=n?this._queue.concat(n):this._queue;for(const h of A)if(h.id===t)return void(h.cancelled=!0)}run(t=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const n=this._currentlyRunning=this._queue;this._queue=[];for(const A of n)if(!A.cancelled&&(A.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var Sc=d.aU([{name:"a_pos3d",type:"Int16",components:3}]);class Rl extends d.E{constructor(t){super(),this._lastTilesetChange=Ar(),this.tileManager=t,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=t._source.tileSize*2**this.deltaZoom,t.usedForTerrain=!0,t.tileSize=this.tileSize}destruct(){this.tileManager.usedForTerrain=!1,this.tileManager.tileSize=null}getSource(){return this.tileManager._source}update(t,n){this.tileManager.update(t,n),this._renderableTilesKeys=[];const A={};for(const h of Mr(t,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:n,calculateTileZoom:this.tileManager._source.calculateTileZoom}))A[h.key]=!0,this._renderableTilesKeys.push(h.key),this._tiles[h.key]||(h.terrainRttPosMatrix32f=new Float64Array(16),d.c7(h.terrainRttPosMatrix32f,0,d.a5,d.a5,0,0,1),this._tiles[h.key]=new tt(h,this.tileSize),this._lastTilesetChange=Ar());for(const h in this._tiles)A[h]||delete this._tiles[h]}freeRtt(t){for(const n in this._tiles){const A=this._tiles[n];(!t||A.tileID.equals(t)||A.tileID.isChildOf(t)||t.isChildOf(A.tileID))&&(A.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map((t=>this.getTileByID(t)))}getTileByID(t){return this._tiles[t]}getTerrainCoords(t,n){return n?this._getTerrainCoordsForTileRanges(t,n):this._getTerrainCoordsForRegularTile(t)}_getTerrainCoordsForRegularTile(t){const n={};for(const A of this._renderableTilesKeys){const h=this._tiles[A].tileID,y=t.clone(),b=d.bk();if(h.canonical.equals(t.canonical))d.c7(b,0,d.a5,d.a5,0,0,1);else if(h.canonical.isChildOf(t.canonical)){const M=h.canonical.z-t.canonical.z,I=h.canonical.x-(h.canonical.x>>M<<M),D=h.canonical.y-(h.canonical.y>>M<<M),B=d.a5>>M;d.c7(b,0,B,B,0,0,1),d.O(b,b,[-I*B,-D*B,0])}else{if(!t.canonical.isChildOf(h.canonical))continue;{const M=t.canonical.z-h.canonical.z,I=t.canonical.x-(t.canonical.x>>M<<M),D=t.canonical.y-(t.canonical.y>>M<<M),B=d.a5>>M;d.c7(b,0,d.a5,d.a5,0,0,1),d.O(b,b,[I*B,D*B,0]),d.Q(b,b,[1/2**M,1/2**M,0])}}y.terrainRttPosMatrix32f=new Float32Array(b),n[A]=y}return n}_getTerrainCoordsForTileRanges(t,n){const A={};for(const h of this._renderableTilesKeys){const y=this._tiles[h].tileID;if(!this._isWithinTileRanges(y,n))continue;const b=t.clone(),M=d.bk();if(y.canonical.z===t.canonical.z){const I=t.canonical.x-y.canonical.x+t.wrap*(1<<t.canonical.z),D=t.canonical.y-y.canonical.y;d.c7(M,0,d.a5,d.a5,0,0,1),d.O(M,M,[I*d.a5,D*d.a5,0])}else if(y.canonical.z>t.canonical.z){const I=y.canonical.z-t.canonical.z,D=y.canonical.x-(y.canonical.x>>I<<I)+t.wrap*(1<<y.canonical.z),B=y.canonical.y-(y.canonical.y>>I<<I),V=t.canonical.x-(y.canonical.x>>I),O=t.canonical.y-(y.canonical.y>>I),U=d.a5>>I;d.c7(M,0,U,U,0,0,1),d.O(M,M,[-D*U+V*d.a5,-B*U+O*d.a5,0])}else{const I=t.canonical.z-y.canonical.z,D=t.canonical.x-(t.canonical.x>>I<<I)+t.wrap*(1<<t.canonical.z),B=t.canonical.y-(t.canonical.y>>I<<I),V=(t.canonical.x>>I)-y.canonical.x,O=(t.canonical.y>>I)-y.canonical.y,U=d.a5<<I;d.c7(M,0,U,U,0,0,1),d.O(M,M,[D*d.a5+V*U,B*d.a5+O*U,0])}b.terrainRttPosMatrix32f=new Float32Array(M),A[h]=b}return A}getSourceTile(t,n){const A=this.tileManager._source;let h=t.overscaledZ-this.deltaZoom;if(h>A.maxzoom&&(h=A.maxzoom),h<A.minzoom)return;this._sourceTileCache[t.key]||(this._sourceTileCache[t.key]=t.scaledTo(h).key);let y=this.findTileInCaches(this._sourceTileCache[t.key]);if(!(y!=null&&y.dem)&&n)for(;h>=A.minzoom&&!(y!=null&&y.dem);)y=this.findTileInCaches(t.scaledTo(h--).key);return y}findTileInCaches(t){let n=this.tileManager.getTileByID(t);return n||(n=this.tileManager._outOfViewCache.getByKey(t),n)}anyTilesAfterTime(t=Date.now()){return this._lastTilesetChange>=t}_isWithinTileRanges(t,n){const A=n[t.canonical.z];return!!A&&(t.wrap>A.minWrap||t.wrap<A.maxWrap||t.canonical.x>=A.minTileXWrapped&&t.canonical.x<=A.maxTileXWrapped&&t.canonical.y>=A.minTileY&&t.canonical.y<=A.maxTileY)}}class ei{constructor(t,n,A){this._meshCache={},this.painter=t,this.tileManager=new Rl(n),this.options=A,this.exaggeration=typeof A.exaggeration=="number"?A.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(t,n,A,h=d.a5){var y;if(!(n>=0&&n<h&&A>=0&&A<h))return 0;const b=this.getTerrainData(t),M=(y=b.tile)===null||y===void 0?void 0:y.dem;if(!M)return 0;const I=d.cC([],[n/h*d.a5,A/h*d.a5],b.u_terrain_matrix),D=[I[0]*M.dim,I[1]*M.dim],B=Math.floor(D[0]),V=Math.floor(D[1]),O=D[0]-B,U=D[1]-V;return M.get(B,V)*(1-O)*(1-U)+M.get(B+1,V)*O*(1-U)+M.get(B,V+1)*(1-O)*U+M.get(B+1,V+1)*O*U}getElevationForLngLatZoom(t,n){if(!d.cD(n,t.wrap()))return 0;const{tileID:A,mercatorX:h,mercatorY:y}=this._getOverscaledTileIDFromLngLatZoom(t,n);return this.getElevation(A,h%d.a5,y%d.a5,d.a5)}getElevationForLngLat(t,n){const A=Mr(n,{maxzoom:this.tileManager.maxzoom,minzoom:this.tileManager.minzoom,tileSize:512,terrain:this});let h=0;for(const y of A)y.canonical.z>h&&(h=Math.min(y.canonical.z,this.tileManager.maxzoom));return this.getElevationForLngLatZoom(t,h)}getElevation(t,n,A,h=d.a5){return this.getDEMElevation(t,n,A,h)*this.exaggeration}getTerrainData(t){if(!this._emptyDemTexture){const h=this.painter.context,y=new d.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new d.T(h,y,h.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new d.T(h,new d.R({width:1,height:1}),h.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(h.gl.NEAREST,h.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=d.ar([])}const n=this.tileManager.getSourceTile(t,!0);if(n&&n.dem&&(!n.demTexture||n.needsTerrainPrepare)){const h=this.painter.context;n.demTexture=this.painter.getTileTexture(n.dem.stride),n.demTexture?n.demTexture.update(n.dem.getPixels(),{premultiply:!1}):n.demTexture=new d.T(h,n.dem.getPixels(),h.gl.RGBA,{premultiply:!1}),n.demTexture.bind(h.gl.NEAREST,h.gl.CLAMP_TO_EDGE),n.needsTerrainPrepare=!1}const A=n&&n.toString()+n.tileID.key+t.key;if(A&&!this._demMatrixCache[A]){const h=this.tileManager.getSource().maxzoom;let y=t.canonical.z-n.tileID.canonical.z;t.overscaledZ>t.canonical.z&&(t.canonical.z>=h?y=t.canonical.z-h:d.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const b=t.canonical.x-(t.canonical.x>>y<<y),M=t.canonical.y-(t.canonical.y>>y<<y),I=d.cE(new Float64Array(16),[1/(d.a5<<y),1/(d.a5<<y),0]);d.O(I,I,[b*d.a5,M*d.a5,0]),this._demMatrixCache[t.key]={matrix:I,coord:t}}return{u_depth:2,u_terrain:3,u_terrain_dim:n&&n.dem&&n.dem.dim||1,u_terrain_matrix:A?this._demMatrixCache[t.key].matrix:this._emptyDemMatrix,u_terrain_unpack:n&&n.dem&&n.dem.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(n&&n.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:n}}getFramebuffer(t){const n=this.painter,A=n.width/devicePixelRatio,h=n.height/devicePixelRatio;return!this._fbo||this._fbo.width===A&&this._fbo.height===h||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new d.T(n.context,{width:A,height:h,data:null},n.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(n.context.gl.NEAREST,n.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new d.T(n.context,{width:A,height:h,data:null},n.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(n.context.gl.NEAREST,n.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=n.context.createFramebuffer(A,h,!0,!1),this._fbo.depthAttachment.set(n.context.createRenderbuffer(n.context.gl.DEPTH_COMPONENT16,A,h))),this._fbo.colorAttachment.set(t==="coords"?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){const t=this.painter.context;if(this._coordsTexture)return this._coordsTexture;const n=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let y=0,b=0;y<this._coordsTextureSize;y++)for(let M=0;M<this._coordsTextureSize;M++,b+=4)n[b+0]=255&M,n[b+1]=255&y,n[b+2]=M>>8<<4|y>>8,n[b+3]=0;const A=new d.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(n.buffer)),h=new d.T(t,A,t.gl.RGBA,{premultiply:!1});return h.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._coordsTexture=h,h}pointCoordinate(t){this.painter.maybeDrawDepthAndCoords(!0);const n=new Uint8Array(4),A=this.painter.context,h=A.gl,y=Math.round(t.x*this.painter.pixelRatio/devicePixelRatio),b=Math.round(t.y*this.painter.pixelRatio/devicePixelRatio),M=Math.round(this.painter.height/devicePixelRatio);A.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),h.readPixels(y,M-b-1,1,1,h.RGBA,h.UNSIGNED_BYTE,n),A.bindFramebuffer.set(null);const I=n[0]+(n[2]>>4<<8),D=n[1]+((15&n[2])<<8),B=this.coordsIndex[255-n[3]],V=B&&this.tileManager.getTileByID(B);if(!V)return null;const O=this._coordsTextureSize,U=(1<<V.tileID.canonical.z)*O;return new d.a9((V.tileID.canonical.x*O+I)/U+V.tileID.wrap,(V.tileID.canonical.y*O+D)/U,this.getElevation(V.tileID,I,D,O))}depthAtPoint(t){const n=new Uint8Array(4),A=this.painter.context,h=A.gl;return A.bindFramebuffer.set(this.getFramebuffer("depth").framebuffer),h.readPixels(t.x,this.painter.height/devicePixelRatio-t.y-1,1,1,h.RGBA,h.UNSIGNED_BYTE,n),A.bindFramebuffer.set(null),(n[0]/16777216+n[1]/65536+n[2]/256+n[3])/256}getTerrainMesh(t){var n;const A=((n=this.painter.style.projection)===null||n===void 0?void 0:n.transitionState)>0,h=A&&t.canonical.y===0,y=A&&t.canonical.y===(1<<t.canonical.z)-1,b=`m_${h?"n":""}_${y?"s":""}`;if(this._meshCache[b])return this._meshCache[b];const M=this.painter.context,I=new d.cF,D=new d.aY,B=this.meshSize,V=d.a5/B,O=B*B;for(let fe=0;fe<=B;fe++)for(let Me=0;Me<=B;Me++)I.emplaceBack(Me*V,fe*V,0);for(let fe=0;fe<O;fe+=B+1)for(let Me=0;Me<B;Me++)D.emplaceBack(Me+fe,B+Me+fe+1,B+Me+fe+2),D.emplaceBack(Me+fe,B+Me+fe+2,Me+fe+1);const U=I.length,X=U+(B+1),ie=(B+1)*B,se=h?d.br:0,ne=h?0:1,ce=y?d.bs:d.a5,ge=y?0:1;for(let fe=0;fe<=B;fe++)I.emplaceBack(fe*V,se,ne);for(let fe=0;fe<=B;fe++)I.emplaceBack(fe*V,ce,ge);for(let fe=0;fe<B;fe++)D.emplaceBack(ie+fe,X+fe,X+fe+1),D.emplaceBack(ie+fe,X+fe+1,ie+fe+1),D.emplaceBack(0+fe,U+fe+1,U+fe),D.emplaceBack(0+fe,0+fe+1,U+fe+1);const Ae=I.length,de=Ae+2*(B+1);for(const fe of[0,1])for(let Me=0;Me<=B;Me++)for(const Ge of[0,1])I.emplaceBack(fe*d.a5,Me*V,Ge);for(let fe=0;fe<2*B;fe+=2)D.emplaceBack(Ae+fe,Ae+fe+1,Ae+fe+3),D.emplaceBack(Ae+fe,Ae+fe+3,Ae+fe+2),D.emplaceBack(de+fe,de+fe+3,de+fe+1),D.emplaceBack(de+fe,de+fe+2,de+fe+3);const ye=new Er(M.createVertexBuffer(I,Sc.members),M.createIndexBuffer(D),d.aX.simpleSegment(0,0,I.length,D.length));return this._meshCache[b]=ye,ye}getMeshFrameDelta(t){return 2*Math.PI*d.bE/Math.pow(2,Math.max(t,0))/5}getMinTileElevationForLngLatZoom(t,n){var A;if(!d.cD(n,t.wrap()))return 0;const{tileID:h}=this._getOverscaledTileIDFromLngLatZoom(t,n);return(A=this.getMinMaxElevation(h).minElevation)!==null&&A!==void 0?A:0}getMinMaxElevation(t){const n=this.getTerrainData(t).tile,A={minElevation:null,maxElevation:null};return n&&n.dem&&(A.minElevation=n.dem.min*this.exaggeration,A.maxElevation=n.dem.max*this.exaggeration),A}_getOverscaledTileIDFromLngLatZoom(t,n){const A=d.a9.fromLngLat(t.wrap()),h=(1<<n)*d.a5,y=A.x*h,b=A.y*h,M=Math.floor(y/d.a5),I=Math.floor(b/d.a5);return{tileID:new d.a2(n,0,n,M,I),mercatorX:y,mercatorY:b}}}class Ai{constructor(t,n,A){this._context=t,this._size=n,this._tileSize=A,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(const t of this._objects)t.texture.destroy(),t.fbo.destroy()}_createObject(t){const n=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),A=new d.T(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return A.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),this._context.extTextureFilterAnisotropic&&this._context.gl.texParameterf(this._context.gl.TEXTURE_2D,this._context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this._context.extTextureFilterAnisotropicMax),n.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),n.colorAttachment.set(A.texture),{id:t,fbo:n,texture:A,stamp:-1,inUse:!1}}getObjectForId(t){return this._objects[t]}useObject(t){t.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter((n=>t.id!==n)),this._recentlyUsed.push(t.id)}stampObject(t){t.stamp=++this._stamp}getOrCreateFreeObject(){for(const n of this._recentlyUsed)if(!this._objects[n].inUse)return this._objects[n];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const t=this._createObject(this._objects.length);return this._objects.push(t),t}freeObject(t){t.inUse=!1}freeAllObjects(){for(const t of this._objects)this.freeObject(t)}isFull(){return!(this._objects.length<this._size)&&this._objects.some((t=>!t.inUse))===!1}}const Ma={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};class Ll{constructor(t,n){this.painter=t,this.terrain=n,this.pool=new Ai(t.context,30,n.tileManager.tileSize*n.qualityFactor)}destruct(){this.pool.destruct()}getTexture(t){return this.pool.getObjectForId(t.rtt[this._stacks.length-1].id).texture}prepareForRender(t,n){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.tileManager.getRenderableTiles(),this._renderableLayerIds=t._order.filter((A=>!t._layers[A].isHidden(n))),this._coordsAscending={};for(const A in t.tileManagers){this._coordsAscending[A]={};const h=t.tileManagers[A].getVisibleCoordinates(),y=t.tileManagers[A].getSource(),b=y instanceof Di?y.terrainTileRanges:null;for(const M of h){const I=this.terrain.tileManager.getTerrainCoords(M,b);for(const D in I)this._coordsAscending[A][D]||(this._coordsAscending[A][D]=[]),this._coordsAscending[A][D].push(I[D])}}this._coordsAscendingStr={};for(const A of t._order){const h=t._layers[A],y=h.source;if(Ma[h.type]&&!this._coordsAscendingStr[y]){this._coordsAscendingStr[y]={};for(const b in this._coordsAscending[y])this._coordsAscendingStr[y][b]=this._coordsAscending[y][b].map((M=>M.key)).sort().join()}}for(const A of this._renderableTiles)for(const h in this._coordsAscendingStr){const y=this._coordsAscendingStr[h][A.tileID.key];y&&y!==A.rttCoords[h]&&(A.rtt=[])}}renderLayer(t,n){if(t.isHidden(this.painter.transform.zoom))return!1;const A=Object.assign(Object.assign({},n),{isRenderingToTexture:!0}),h=t.type,y=this.painter,b=this._renderableLayerIds[this._renderableLayerIds.length-1]===t.id;if(Ma[h]&&(this._prevType&&Ma[this._prevType]||this._stacks.push([]),this._prevType=h,this._stacks[this._stacks.length-1].push(t.id),!b))return!0;if(Ma[this._prevType]||Ma[h]&&b){this._prevType=h;const M=this._stacks.length-1,I=this._stacks[M]||[];for(const D of this._renderableTiles){if(this.pool.isFull()&&(Kn(this.painter,this.terrain,this._rttTiles,A),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(D),D.rtt[M]){const V=this.pool.getObjectForId(D.rtt[M].id);if(V.stamp===D.rtt[M].stamp){this.pool.useObject(V);continue}}const B=this.pool.getOrCreateFreeObject();this.pool.useObject(B),this.pool.stampObject(B),D.rtt[M]={id:B.id,stamp:B.stamp},y.context.bindFramebuffer.set(B.fbo.framebuffer),y.context.clear({color:d.bp.transparent,stencil:0}),y.currentStencilSource=void 0;for(let V=0;V<I.length;V++){const O=y.style._layers[I[V]],U=O.source?this._coordsAscending[O.source][D.tileID.key]:[D.tileID];y.context.viewport.set([0,0,B.fbo.width,B.fbo.height]),y._renderTileClippingMasks(O,U,!0),y.renderLayer(y,y.style.tileManagers[O.source],O,U,A),O.source&&(D.rttCoords[O.source]=this._coordsAscendingStr[O.source][D.tileID.key])}}return Kn(this.painter,this.terrain,this._rttTiles,A),this._rttTiles=[],this.pool.freeAllObjects(),Ma[h]}return!1}}const DA={"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":"Reset bearing to 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"},fu=nt,kA={hash:!1,interactive:!0,bearingSnap:7,attributionControl:es,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:d.c.MAX_TILE_CACHE_ZOOM_LEVELS,transformRequest:null,transformCameraUpdate:null,transformConstrain:null,fadeDuration:300,crossSourceCollisions:!0,clickTolerance:3,localIdeographFontFamily:"sans-serif",pitchWithRotate:!0,rollEnabled:!1,reduceMotion:void 0,validateStyle:!0,maxCanvasSize:[4096,4096],cancelPendingTileRequestsWhileZooming:!0,centerClampedToGround:!0,experimentalZoomLevelsToOverscale:void 0},du={showCompass:!0,showZoom:!0,visualizePitch:!1,visualizeRoll:!0};class Fl{constructor(t,n,A=!1){this.mousedown=y=>{this.startMove(y,Ze.mousePos(this.element,y)),Ze.addEventListener(window,"mousemove",this.mousemove),Ze.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=y=>{this.move(y,Ze.mousePos(this.element,y))},this.mouseup=y=>{this._rotatePitchHandler.dragEnd(y),this.offTemp()},this.touchstart=y=>{y.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=Ze.touchPos(this.element,y.targetTouches)[0],this.startMove(y,this._startPos),Ze.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),Ze.addEventListener(window,"touchend",this.touchend))},this.touchmove=y=>{y.targetTouches.length!==1?this.reset():(this._lastPos=Ze.touchPos(this.element,y.targetTouches)[0],this.move(y,this._lastPos))},this.touchend=y=>{y.targetTouches.length===0&&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=n;const h=new P;this._rotatePitchHandler=new a({clickTolerance:3,move:(y,b)=>{const M=n.getBoundingClientRect(),I=new d.P((M.bottom-M.top)/2,(M.right-M.left)/2);return{bearingDelta:d.cx(new d.P(y.x,b.y),b,I),pitchDelta:A?-.5*(b.y-y.y):void 0}},moveStateManager:h,enable:!0,assignEvents:()=>{}}),this.map=t,Ze.addEventListener(n,"mousedown",this.mousedown),Ze.addEventListener(n,"touchstart",this.touchstart,{passive:!1}),Ze.addEventListener(n,"touchcancel",this.reset)}startMove(t,n){this._rotatePitchHandler.dragStart(t,n),Ze.disableDrag()}move(t,n){const A=this.map,{bearingDelta:h,pitchDelta:y}=this._rotatePitchHandler.dragMove(t,n)||{};h&&A.setBearing(A.getBearing()+h),y&&A.setPitch(A.getPitch()+y)}off(){const t=this.element;Ze.removeEventListener(t,"mousedown",this.mousedown),Ze.removeEventListener(t,"touchstart",this.touchstart,{passive:!1}),Ze.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),Ze.removeEventListener(window,"touchend",this.touchend),Ze.removeEventListener(t,"touchcancel",this.reset),this.offTemp()}offTemp(){Ze.enableDrag(),Ze.removeEventListener(window,"mousemove",this.mousemove),Ze.removeEventListener(window,"mouseup",this.mouseup),Ze.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),Ze.removeEventListener(window,"touchend",this.touchend)}}let co;function zA(_,t,n,A=!1){if(A||!n.getCoveringTilesDetailsProvider().allowWorldCopies())return _==null?void 0:_.wrap();const h=new d.V(_.lng,_.lat);if(_=new d.V(_.lng,_.lat),t){const y=new d.V(_.lng-360,_.lat),b=new d.V(_.lng+360,_.lat),M=n.locationToScreenPoint(_).distSqr(t);n.locationToScreenPoint(y).distSqr(t)<M?_=y:n.locationToScreenPoint(b).distSqr(t)<M&&(_=b)}for(;Math.abs(_.lng-n.center.lng)>180;){const y=n.locationToScreenPoint(_);if(y.x>=0&&y.y>=0&&y.x<=n.width&&y.y<=n.height)break;_.lng>n.center.lng?_.lng-=360:_.lng+=360}return _.lng!==h.lng&&n.isPointOnMapSurface(n.locationToScreenPoint(_))?_:h}const Ol={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function BA(_,t,n){const A=_.classList;for(const h in Ol)A.remove(`maplibregl-${n}-anchor-${h}`);A.add(`maplibregl-${n}-anchor-${t}`)}class Vl extends d.E{constructor(t){if(super(),this._onKeyPress=n=>{const A=n.code,h=n.charCode||n.keyCode;A!=="Space"&&A!=="Enter"&&h!==32&&h!==13||this.togglePopup()},this._onMapClick=n=>{const A=n.originalEvent.target,h=this._element;this._popup&&(A===h||h.contains(A))&&this.togglePopup()},this._update=n=>{if(!this._map)return;const A=this._map.loaded()&&!this._map.isMoving();((n==null?void 0:n.type)==="terrain"||(n==null?void 0:n.type)==="render"&&!A)&&this._map.once("render",this._update),this._lngLat=zA(this._lngLat,this._flatPos,this._map.transform),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let h="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?h=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(h=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let y="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?y="rotateX(0deg)":this._pitchAlignment==="map"&&(y=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||n&&n.type!=="moveend"||(this._pos=this._pos.round()),Ze.setTransform(this._element,`${Ol[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${y} ${h}`),hi.frameAsync(new AbortController).then((()=>{this._updateOpacity(n&&n.type==="moveend")})).catch((()=>{}))},this._onMove=n=>{if(!this._isDragging){const A=this._clickTolerance||this._map._clickTolerance;this._isDragging=n.point.dist(this._pointerdownPos)>=A}this._isDragging&&(this._pos=n.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new d.l("dragstart"))),this.fire(new d.l("drag")))},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),this._state==="active"&&this.fire(new d.l("dragend")),this._state="inactive"},this._addDragHandler=n=>{this._element.contains(n.originalEvent.target)&&(n.preventDefault(),this._positionDelta=n.point.sub(this._pos).add(this._offset),this._pointerdownPos=n.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))},this._anchor=t&&t.anchor||"center",this._color=t&&t.color||"#3FB1CE",this._scale=t&&t.scale||1,this._draggable=t&&t.draggable||!1,this._clickTolerance=t&&t.clickTolerance||0,this._subpixelPositioning=t&&t.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=t&&t.rotation||0,this._rotationAlignment=t&&t.rotationAlignment||"auto",this._pitchAlignment=t&&t.pitchAlignment&&t.pitchAlignment!=="auto"?t.pitchAlignment:this._rotationAlignment,this.setOpacity(t==null?void 0:t.opacity,t==null?void 0:t.opacityWhenCovered),t&&t.element)this._element=t.element,this._offset=d.P.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=Ze.create("div");const n=Ze.createNS("http://www.w3.org/2000/svg","svg"),A=41,h=27;n.setAttributeNS(null,"display","block"),n.setAttributeNS(null,"height",`${A}px`),n.setAttributeNS(null,"width",`${h}px`),n.setAttributeNS(null,"viewBox",`0 0 ${h} ${A}`);const y=Ze.createNS("http://www.w3.org/2000/svg","g");y.setAttributeNS(null,"stroke","none"),y.setAttributeNS(null,"stroke-width","1"),y.setAttributeNS(null,"fill","none"),y.setAttributeNS(null,"fill-rule","evenodd");const b=Ze.createNS("http://www.w3.org/2000/svg","g");b.setAttributeNS(null,"fill-rule","nonzero");const M=Ze.createNS("http://www.w3.org/2000/svg","g");M.setAttributeNS(null,"transform","translate(3.0, 29.0)"),M.setAttributeNS(null,"fill","#000000");const I=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const ne of I){const ce=Ze.createNS("http://www.w3.org/2000/svg","ellipse");ce.setAttributeNS(null,"opacity","0.04"),ce.setAttributeNS(null,"cx","10.5"),ce.setAttributeNS(null,"cy","5.80029008"),ce.setAttributeNS(null,"rx",ne.rx),ce.setAttributeNS(null,"ry",ne.ry),M.appendChild(ce)}const D=Ze.createNS("http://www.w3.org/2000/svg","g");D.setAttributeNS(null,"fill",this._color);const B=Ze.createNS("http://www.w3.org/2000/svg","path");B.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),D.appendChild(B);const V=Ze.createNS("http://www.w3.org/2000/svg","g");V.setAttributeNS(null,"opacity","0.25"),V.setAttributeNS(null,"fill","#000000");const O=Ze.createNS("http://www.w3.org/2000/svg","path");O.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),V.appendChild(O);const U=Ze.createNS("http://www.w3.org/2000/svg","g");U.setAttributeNS(null,"transform","translate(6.0, 7.0)"),U.setAttributeNS(null,"fill","#FFFFFF");const X=Ze.createNS("http://www.w3.org/2000/svg","g");X.setAttributeNS(null,"transform","translate(8.0, 8.0)");const ie=Ze.createNS("http://www.w3.org/2000/svg","circle");ie.setAttributeNS(null,"fill","#000000"),ie.setAttributeNS(null,"opacity","0.25"),ie.setAttributeNS(null,"cx","5.5"),ie.setAttributeNS(null,"cy","5.5"),ie.setAttributeNS(null,"r","5.4999962");const se=Ze.createNS("http://www.w3.org/2000/svg","circle");se.setAttributeNS(null,"fill","#FFFFFF"),se.setAttributeNS(null,"cx","5.5"),se.setAttributeNS(null,"cy","5.5"),se.setAttributeNS(null,"r","5.4999962"),X.appendChild(ie),X.appendChild(se),b.appendChild(M),b.appendChild(D),b.appendChild(V),b.appendChild(U),b.appendChild(X),n.appendChild(b),n.setAttributeNS(null,"height",A*this._scale+"px"),n.setAttributeNS(null,"width",h*this._scale+"px"),this._element.appendChild(n),this._offset=d.P.convert(t&&t.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",(n=>{n.preventDefault()})),this._element.addEventListener("mousedown",(n=>{n.preventDefault()})),BA(this._element,this._anchor,"marker"),t&&t.className)for(const n of t.className.split(" "))this._element.classList.add(n);this._popup=null}addTo(t){return this.remove(),this._map=t,this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label",t._getUIString("Marker.Title")),this._element.hasAttribute("role")||this._element.setAttribute("role","button"),t.getCanvasContainer().appendChild(this._element),t.on("move",this._update),t.on("moveend",this._update),t.on("terrain",this._update),t.on("projectiontransition",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),Ze.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=d.V.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(t){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),t){if(!("offset"in t.options)){const h=Math.abs(13.5)/Math.SQRT2;t.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[h,-1*(38.1-13.5+h)],"bottom-right":[-h,-1*(38.1-13.5+h)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=t,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}setSubpixelPositioning(t){return this._subpixelPositioning=t,this}getPopup(){return this._popup}togglePopup(){const t=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:t?(t.isOpen()?t.remove():(t.setLngLat(this._lngLat),t.addTo(this._map)),this):this}_updateOpacity(t=!1){var n,A;const h=(n=this._map)===null||n===void 0?void 0:n.terrain,y=this._map.transform.isLocationOccluded(this._lngLat);if(!h||y){const U=y?this._opacityWhenCovered:this._opacity;return void(this._element.style.opacity!==U&&(this._element.style.opacity=U))}if(t)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout((()=>{this._opacityTimeout=null}),100)}const b=this._map,M=b.terrain.depthAtPoint(this._pos),I=b.terrain.getElevationForLngLat(this._lngLat,b.transform);if(b.transform.lngLatToCameraDepth(this._lngLat,I)-M<.006)return void(this._element.style.opacity=this._opacity);const D=-this._offset.y/b.transform.pixelsPerMeter,B=Math.sin(b.getPitch()*Math.PI/180)*D,V=b.terrain.depthAtPoint(new d.P(this._pos.x,this._pos.y-this._offset.y)),O=b.transform.lngLatToCameraDepth(this._lngLat,I+B)-V>.006;!((A=this._popup)===null||A===void 0)&&A.isOpen()&&O&&this._popup.remove(),this._element.style.opacity=O?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(t){return this._offset=d.P.convert(t),this._update(),this}addClassName(t){this._element.classList.add(t)}removeClassName(t){this._element.classList.remove(t)}toggleClassName(t){return this._element.classList.toggle(t)}setDraggable(t){return this._draggable=!!t,this._map&&(t?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(t){return this._rotation=t||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(t){return this._rotationAlignment=t||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(t){return this._pitchAlignment=t&&t!=="auto"?t:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(t,n){return(this._opacity===void 0||t===void 0&&n===void 0)&&(this._opacity="1",this._opacityWhenCovered="0.2"),t!==void 0&&(this._opacity=t),n!==void 0&&(this._opacityWhenCovered=n),this._map&&this._updateOpacity(!0),this}}const mu={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let rl=0,Ea=!1;const gu={maxWidth:100,unit:"metric"};function jl(_,t,n){const A=n&&n.maxWidth||100,h=_._container.clientHeight/2,y=_._container.clientWidth/2,b=_.unproject([y-A/2,h]),M=_.unproject([y+A/2,h]),I=Math.round(_.project(M).x-_.project(b).x),D=Math.min(A,I,_._container.clientWidth),B=b.distanceTo(M);if(n&&n.unit==="imperial"){const V=3.2808*B;V>5280?Ia(t,D,V/5280,_._getUIString("ScaleControl.Miles")):Ia(t,D,V,_._getUIString("ScaleControl.Feet"))}else n&&n.unit==="nautical"?Ia(t,D,B/1852,_._getUIString("ScaleControl.NauticalMiles")):B>=1e3?Ia(t,D,B/1e3,_._getUIString("ScaleControl.Kilometers")):Ia(t,D,B,_._getUIString("ScaleControl.Meters"))}function Ia(_,t,n,A){const h=(function(y){const b=Math.pow(10,`${Math.floor(y)}`.length-1);let M=y/b;return M=M>=10?10:M>=5?5:M>=3?3:M>=2?2:M>=1?1:(function(I){const D=Math.pow(10,Math.ceil(-Math.log(I)/Math.LN10));return Math.round(I*D)/D})(M),b*M})(n);_.style.width=t*(h/n)+"px",_.innerHTML=`${h}&nbsp;${A}`}const _u={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0,padding:void 0},RA=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function LA(_){if(_){if(typeof _=="number"){const t=Math.round(Math.abs(_)/Math.SQRT2);return{center:new d.P(0,0),top:new d.P(0,_),"top-left":new d.P(t,t),"top-right":new d.P(-t,t),bottom:new d.P(0,-_),"bottom-left":new d.P(t,-t),"bottom-right":new d.P(-t,-t),left:new d.P(_,0),right:new d.P(-_,0)}}if(_ instanceof d.P||Array.isArray(_)){const t=d.P.convert(_);return{center:t,top:t,"top-left":t,"top-right":t,bottom:t,"bottom-left":t,"bottom-right":t,left:t,right:t}}return{center:d.P.convert(_.center||[0,0]),top:d.P.convert(_.top||[0,0]),"top-left":d.P.convert(_["top-left"]||[0,0]),"top-right":d.P.convert(_["top-right"]||[0,0]),bottom:d.P.convert(_.bottom||[0,0]),"bottom-left":d.P.convert(_["bottom-left"]||[0,0]),"bottom-right":d.P.convert(_["bottom-right"]||[0,0]),left:d.P.convert(_.left||[0,0]),right:d.P.convert(_.right||[0,0])}}return LA(new d.P(0,0))}const yu=nt;G.AJAXError=d.cI,G.Event=d.l,G.Evented=d.E,G.LngLat=d.V,G.MercatorCoordinate=d.a9,G.Point=d.P,G.addProtocol=d.cJ,G.config=d.c,G.removeProtocol=d.cK,G.AttributionControl=pu,G.BoxZoomHandler=Nn,G.CanvasSource=W,G.CooperativeGesturesHandler=at,G.DoubleClickZoomHandler=jt,G.DragPanHandler=Rt,G.DragRotateHandler=Et,G.EdgeInsets=Ss,G.FullscreenControl=class extends d.E{constructor(_={}){super(),this._onFullscreenChange=()=>{var t;let n=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;!((t=n==null?void 0:n.shadowRoot)===null||t===void 0)&&t.fullscreenElement;)n=n.shadowRoot.fullscreenElement;n===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,_&&_.container&&(_.container instanceof HTMLElement?this._container=_.container:d.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(_){return this._map=_,this._container||(this._container=this._map.getContainer()),this._controlContainer=Ze.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){Ze.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const _=this._fullscreenButton=Ze.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);Ze.create("span","maplibregl-ctrl-icon",_).setAttribute("aria-hidden","true"),_.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const _=this._getTitle();this._fullscreenButton.setAttribute("aria-label",_),this._fullscreenButton.title=_}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new d.l("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new d.l("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},G.GeoJSONSource=Rn,G.GeolocateControl=class extends d.E{constructor(_){super(),this._onSuccess=t=>{if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new d.l("outofmaxbounds",t)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=t,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&this._watchState!=="OFF"&&this._updateMarker(t),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(t),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new d.l("geolocate",t)),this._finish()}},this._updateCamera=t=>{const n=new d.V(t.coords.longitude,t.coords.latitude),A=t.coords.accuracy,h=this._map.getBearing(),y=d.e({bearing:h},this.options.fitBoundsOptions),b=xr.fromLngLat(n,A);this._map.fitBounds(b,y,{geolocateSource:!0})},this._updateMarker=t=>{if(t){const n=new d.V(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(n).addTo(this._map),this._userLocationDotMarker.setLngLat(n).addTo(this._map),this._accuracy=t.coords.accuracy,this._updateCircleRadiusIfNeeded()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onUpdate=()=>{this._updateCircleRadiusIfNeeded()},this._onError=t=>{if(this._map){if(t.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(t.code===3&&Ea)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new d.l("error",t)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this._geolocateButton=Ze.create("button","maplibregl-ctrl-geolocate",this._container),Ze.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=t=>{if(this._map){if(t===!1){d.w("Geolocation support is not available so the GeolocateControl will be disabled.");const n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n)}else{const n=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=Ze.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Vl({element:this._dotElement}),this._circleElement=Ze.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Vl({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onUpdate),this._map.on("move",this._onUpdate),this._map.on("rotate",this._onUpdate),this._map.on("pitch",this._onUpdate)),this._geolocateButton.addEventListener("click",(()=>this.trigger())),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(n=>{const A=(n==null?void 0:n[0])instanceof ResizeObserverEntry;n.geolocateSource||this._watchState!=="ACTIVE_LOCK"||A||this._map.isZooming()||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new d.l("trackuserlocationend")),this.fire(new d.l("userlocationlostfocus")))}))}},this.options=d.e({},mu,_)}onAdd(_){return this._map=_,this._container=Ze.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),(function(){return d._(this,arguments,void 0,(function*(t=!1){if(co!==void 0&&!t)return co;if(window.navigator.permissions===void 0)return co=!!window.navigator.geolocation,co;try{co=(yield window.navigator.permissions.query({name:"geolocation"})).state!=="denied"}catch{co=!!window.navigator.geolocation}return co}))})().then((t=>this._finishSetupUI(t))),this._container}onRemove(){this._geolocationWatchID!==void 0&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),Ze.remove(this._container),this._map.off("zoom",this._onUpdate),this._map.off("move",this._onUpdate),this._map.off("rotate",this._onUpdate),this._map.off("pitch",this._onUpdate),this._map=void 0,rl=0,Ea=!1}_isOutOfMapMaxBounds(_){const t=this._map.getMaxBounds(),n=_.coords;return t&&(n.longitude<t.getWest()||n.longitude>t.getEast()||n.latitude<t.getSouth()||n.latitude>t.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":case"BACKGROUND_ERROR":case"OFF":case void 0:break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadiusIfNeeded(){const _=this._userLocationDotMarker.getLngLat();if(!(this.options.showUserLocation&&this.options.showAccuracyCircle&&this._accuracy&&_))return;const t=this._map.project(_),n=this._map.unproject([t.x+100,t.y]),A=_.distanceTo(n)/100,h=2*this._accuracy/A;this._circleElement.style.width=`${h.toFixed(2)}px`,this._circleElement.style.height=`${h.toFixed(2)}px`}trigger(){if(!this._setup)return d.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new d.l("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":rl--,Ea=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new d.l("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new d.l("trackuserlocationstart")),this.fire(new d.l("userlocationfocus"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let _;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),rl++,rl>1?(_={maximumAge:6e5,timeout:0},Ea=!0):(_=this.options.positionOptions,Ea=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,_)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},G.GlobeControl=class{constructor(){this._toggleProjection=()=>{var _;const t=(_=this._map.getProjection())===null||_===void 0?void 0:_.type;this._map.setProjection(t!=="mercator"&&t?{type:"mercator"}:{type:"globe"}),this._updateGlobeIcon()},this._updateGlobeIcon=()=>{var _;this._globeButton.classList.remove("maplibregl-ctrl-globe"),this._globeButton.classList.remove("maplibregl-ctrl-globe-enabled"),((_=this._map.getProjection())===null||_===void 0?void 0:_.type)==="globe"?(this._globeButton.classList.add("maplibregl-ctrl-globe-enabled"),this._globeButton.title=this._map._getUIString("GlobeControl.Disable")):(this._globeButton.classList.add("maplibregl-ctrl-globe"),this._globeButton.title=this._map._getUIString("GlobeControl.Enable"))}}onAdd(_){return this._map=_,this._container=Ze.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._globeButton=Ze.create("button","maplibregl-ctrl-globe",this._container),Ze.create("span","maplibregl-ctrl-icon",this._globeButton).setAttribute("aria-hidden","true"),this._globeButton.type="button",this._globeButton.addEventListener("click",this._toggleProjection),this._updateGlobeIcon(),this._map.on("styledata",this._updateGlobeIcon),this._container}onRemove(){Ze.remove(this._container),this._map.off("styledata",this._updateGlobeIcon),this._globeButton.removeEventListener("click",this._toggleProjection),this._map=void 0}},G.Hash=Dt,G.ImageSource=Di,G.KeyboardHandler=Pe,G.LngLatBounds=xr,G.LogoControl=Qu,G.Map=class extends Ri{constructor(_){var t,n;d.cG.mark(d.cH.create);const A=Object.assign(Object.assign(Object.assign({},kA),_),{canvasContextAttributes:Object.assign(Object.assign({},kA.canvasContextAttributes),_.canvasContextAttributes)});if(A.minZoom!=null&&A.maxZoom!=null&&A.minZoom>A.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(A.minPitch!=null&&A.maxPitch!=null&&A.minPitch>A.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(A.minPitch!=null&&A.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(A.maxPitch!=null&&A.maxPitch>180)throw new Error("maxPitch must be less than or equal to 180");const h=new eo,y=new dn;if(A.minZoom!==void 0&&h.setMinZoom(A.minZoom),A.maxZoom!==void 0&&h.setMaxZoom(A.maxZoom),A.minPitch!==void 0&&h.setMinPitch(A.minPitch),A.maxPitch!==void 0&&h.setMaxPitch(A.maxPitch),A.renderWorldCopies!==void 0&&h.setRenderWorldCopies(A.renderWorldCopies),A.transformConstrain!==null&&h.setConstrainOverride(A.transformConstrain),super(h,y,{bearingSnap:A.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new Ic,this._controls=[],this._mapId=d.af(),this._lostContextStyle={style:null,images:null},this._contextLost=M=>{M.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.painter.destroy();for(const I of Object.values(this.style._layers))if(I.type==="custom"&&console.warn(`Custom layer with id '${I.id}' cannot be restored after WebGL context loss. You will need to re-add it manually after context restoration.`),I._listeners)for(const[D]of Object.entries(I._listeners))console.warn(`Custom layer with id '${I.id}' had event listeners for event '${D}' which cannot be restored after WebGL context loss. You will need to re-add them manually after context restoration.`);this._lostContextStyle=this._getStyleAndImages(),this.style.destroy(),this.style=null,this.fire(new d.l("webglcontextlost",{originalEvent:M}))},this._contextRestored=M=>{this._lostContextStyle.style&&this.setStyle(this._lostContextStyle.style,{diff:!1}),this._lostContextStyle.images&&(this.style.imageManager.images=this._lostContextStyle.images),this._lostContextStyle={style:null,images:null},this._setupPainter(),this.resize(),this._update(),this._resizeInternal(),this.fire(new d.l("webglcontextrestored",{originalEvent:M}))},this._onMapScroll=M=>{if(M.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=A.interactive,this._maxTileCacheSize=A.maxTileCacheSize,this._maxTileCacheZoomLevels=A.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},A.canvasContextAttributes),this._trackResize=A.trackResize===!0,this._bearingSnap=A.bearingSnap,this._centerClampedToGround=A.centerClampedToGround,this._refreshExpiredTiles=A.refreshExpiredTiles===!0,this._fadeDuration=A.fadeDuration,this._crossSourceCollisions=A.crossSourceCollisions===!0,this._collectResourceTiming=A.collectResourceTiming===!0,this._locale=Object.assign(Object.assign({},DA),A.locale),this._clickTolerance=A.clickTolerance,this._overridePixelRatio=A.pixelRatio,this._maxCanvasSize=A.maxCanvasSize,this._zoomLevelsToOverscale=A.experimentalZoomLevelsToOverscale,this.transformCameraUpdate=A.transformCameraUpdate,this.transformConstrain=A.transformConstrain,this.cancelPendingTileRequestsWhileZooming=A.cancelPendingTileRequestsWhileZooming===!0,A.reduceMotion!==void 0&&(hi.prefersReducedMotion=A.reduceMotion),this._imageQueueHandle=Yi.addThrottleControl((()=>this.isMoving())),this._requestManager=new vo(A.transformRequest),typeof A.container=="string"){if(this._container=document.getElementById(A.container),!this._container)throw new Error(`Container '${A.container}' not found.`)}else{if(!(A.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=A.container}if(A.maxBounds&&this.setMaxBounds(A.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",(()=>this._update(!1))),this.on("moveend",(()=>this._update(!1))),this.on("zoom",(()=>this._update(!0))),this.on("terrain",(()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)})),this.once("idle",(()=>{this._idleTriggered=!0})),typeof window<"u"){addEventListener("online",this._onWindowOnline,!1);let M=!1;const I=Bi((D=>{this._trackResize&&!this._removed&&(this.resize(D),this.redraw())}),50);this._resizeObserver=new ResizeObserver((D=>{M?I(D):M=!0})),this._resizeObserver.observe(this._container)}this.handlers=new xi(this,A),this._hash=A.hash&&new Dt(typeof A.hash=="string"&&A.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:A.center,elevation:A.elevation,zoom:A.zoom,bearing:A.bearing,pitch:A.pitch,roll:A.roll}),A.bounds&&(this.resize(),this.fitBounds(A.bounds,d.e({},A.fitBoundsOptions,{duration:0}))));const b=typeof A.style=="string"||((n=(t=A.style)===null||t===void 0?void 0:t.projection)===null||n===void 0?void 0:n.type)!=="globe";this.resize(null,b),this._localIdeographFontFamily=A.localIdeographFontFamily,this._validateStyle=A.validateStyle,A.style&&this.setStyle(A.style,{localIdeographFontFamily:A.localIdeographFontFamily}),A.attributionControl&&this.addControl(new pu(typeof A.attributionControl=="boolean"?void 0:A.attributionControl)),A.maplibreLogo&&this.addControl(new Qu,A.logoPosition),this.on("style.load",(()=>{if(b||this._resizeTransform(),this.transform.unmodified){const M=d.U(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(M)}})),this.on("data",(M=>{this._update(M.dataType==="style"),this.fire(new d.l(`${M.dataType}data`,M))})),this.on("dataloading",(M=>{this.fire(new d.l(`${M.dataType}dataloading`,M))})),this.on("dataabort",(M=>{this.fire(new d.l("sourcedataabort",M))}))}_getMapId(){return this._mapId}setGlobalStateProperty(_,t){return this.style.setGlobalStateProperty(_,t),this._update(!0)}getGlobalState(){return this.style.getGlobalState()}addControl(_,t){if(t===void 0&&(t=_.getDefaultPosition?_.getDefaultPosition():"top-right"),!_||!_.onAdd)return this.fire(new d.k(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const n=_.onAdd(this);this._controls.push(_);const A=this._controlPositions[t];return t.indexOf("bottom")!==-1?A.insertBefore(n,A.firstChild):A.appendChild(n),this}removeControl(_){if(!_||!_.onRemove)return this.fire(new d.k(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const t=this._controls.indexOf(_);return t>-1&&this._controls.splice(t,1),_.onRemove(this),this}hasControl(_){return this._controls.indexOf(_)>-1}coveringTiles(_){return Mr(this.transform,_)}calculateCameraOptionsFromTo(_,t,n,A){return A==null&&this.terrain&&(A=this.terrain.getElevationForLngLat(n,this.transform)),super.calculateCameraOptionsFromTo(_,t,n,A)}resize(_,t=!0){if(this._lostContextStyle.style!==null)return this;this._resizeInternal(t);const n=!this._moving;return n&&(this.stop(),this.fire(new d.l("movestart",_)).fire(new d.l("move",_))),this.fire(new d.l("resize",_)),n&&this.fire(new d.l("moveend",_)),this}_resizeInternal(_=!0){const[t,n]=this._containerDimensions(),A=this._getClampedPixelRatio(t,n);if(this._resizeCanvas(t,n,A),this.painter.resize(t,n,A),this.painter.overLimit()){const h=this.painter.context.gl;this._maxCanvasSize=[h.drawingBufferWidth,h.drawingBufferHeight];const y=this._getClampedPixelRatio(t,n);this._resizeCanvas(t,n,y),this.painter.resize(t,n,y)}this._resizeTransform(_)}_resizeTransform(_=!0){var t;const[n,A]=this._containerDimensions();this.transform.resize(n,A,_),(t=this._requestedCameraState)===null||t===void 0||t.resize(n,A,_)}_getClampedPixelRatio(_,t){const{0:n,1:A}=this._maxCanvasSize,h=this.getPixelRatio(),y=_*h,b=t*h;return Math.min(y>n?n/y:1,b>A?A/b:1)*h}getPixelRatio(){var _;return(_=this._overridePixelRatio)!==null&&_!==void 0?_:devicePixelRatio}setPixelRatio(_){this._overridePixelRatio=_,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(_){return this.transform.setMaxBounds(xr.convert(_)),this._update()}setMinZoom(_){if((_=_??-2)>=-2&&_<=this.transform.maxZoom){const t=this._getTransformForUpdate();return t.setMinZoom(_),this._applyUpdatedTransform(t),this._update(),this}throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(_){if((_=_??22)>=this.transform.minZoom){const t=this._getTransformForUpdate();return t.setMaxZoom(_),this._applyUpdatedTransform(t),this._update(),this}throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(_){if((_=_??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(_>=0&&_<=this.transform.maxPitch)return this.transform.setMinPitch(_),this._update(),this.getPitch()<_&&this.setPitch(_),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(_){if((_=_??60)>180)throw new Error("maxPitch must be less than or equal to 180");if(_>=this.transform.minPitch)return this.transform.setMaxPitch(_),this._update(),this.getPitch()>_&&this.setPitch(_),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(_){return this.transform.setRenderWorldCopies(_),this._update()}setTransformConstrain(_){return this.transform.setConstrainOverride(_),this._update()}project(_){return this.transform.locationToScreenPoint(d.V.convert(_),this.style&&this.terrain)}unproject(_){return this.transform.screenPointToLocation(d.P.convert(_),this.terrain)}isMoving(){var _;return this._moving||((_=this.handlers)===null||_===void 0?void 0:_.isMoving())}isZooming(){var _;return this._zooming||((_=this.handlers)===null||_===void 0?void 0:_.isZooming())}isRotating(){var _;return this._rotating||((_=this.handlers)===null||_===void 0?void 0:_.isRotating())}_createDelegatedListener(_,t,n){if(_==="mouseenter"||_==="mouseover"){let A=!1;return{layers:t,listener:n,delegates:{mousemove:y=>{const b=t.filter((I=>this.getLayer(I))),M=b.length!==0?this.queryRenderedFeatures(y.point,{layers:b}):[];M.length?A||(A=!0,n.call(this,new Ye(_,this,y.originalEvent,{features:M}))):A=!1},mouseout:()=>{A=!1}}}}if(_==="mouseleave"||_==="mouseout"){let A=!1;return{layers:t,listener:n,delegates:{mousemove:b=>{const M=t.filter((I=>this.getLayer(I)));(M.length!==0?this.queryRenderedFeatures(b.point,{layers:M}):[]).length?A=!0:A&&(A=!1,n.call(this,new Ye(_,this,b.originalEvent)))},mouseout:b=>{A&&(A=!1,n.call(this,new Ye(_,this,b.originalEvent)))}}}}{const A=h=>{const y=t.filter((M=>this.getLayer(M))),b=y.length!==0?this.queryRenderedFeatures(h.point,{layers:y}):[];b.length&&(h.features=b,n.call(this,h),delete h.features)};return{layers:t,listener:n,delegates:{[_]:A}}}}_saveDelegatedListener(_,t){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[_]=this._delegatedListeners[_]||[],this._delegatedListeners[_].push(t)}_removeDelegatedListener(_,t,n){if(!this._delegatedListeners||!this._delegatedListeners[_])return;const A=this._delegatedListeners[_];for(let h=0;h<A.length;h++){const y=A[h];if(y.listener===n&&y.layers.length===t.length&&y.layers.every((b=>t.includes(b)))){for(const b in y.delegates)this.off(b,y.delegates[b]);return void A.splice(h,1)}}}on(_,t,n){if(n===void 0)return super.on(_,t);const A=typeof t=="string"?[t]:t,h=this._createDelegatedListener(_,A,n);this._saveDelegatedListener(_,h);for(const y in h.delegates)this.on(y,h.delegates[y]);return{unsubscribe:()=>{this._removeDelegatedListener(_,A,n)}}}once(_,t,n){if(n===void 0)return super.once(_,t);const A=typeof t=="string"?[t]:t,h=this._createDelegatedListener(_,A,n);for(const y in h.delegates){const b=h.delegates[y];h.delegates[y]=(...M)=>{this._removeDelegatedListener(_,A,n),b(...M)}}this._saveDelegatedListener(_,h);for(const y in h.delegates)this.once(y,h.delegates[y]);return this}off(_,t,n){return n===void 0?super.off(_,t):(this._removeDelegatedListener(_,typeof t=="string"?[t]:t,n),this)}queryRenderedFeatures(_,t){if(!this.style)return[];let n;const A=_ instanceof d.P||Array.isArray(_),h=A?_:[[0,0],[this.transform.width,this.transform.height]];if(t=t||(A?{}:_)||{},h instanceof d.P||typeof h[0]=="number")n=[d.P.convert(h)];else{const y=d.P.convert(h[0]),b=d.P.convert(h[1]);n=[y,new d.P(b.x,y.y),b,new d.P(y.x,b.y),y]}return this.style.queryRenderedFeatures(n,t,this.transform)}querySourceFeatures(_,t){return this.style.querySourceFeatures(_,t)}setStyle(_,t){return(t=d.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},t)).diff!==!1&&t.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&_?(this._diffStyle(_,t),this):(this._localIdeographFontFamily=t.localIdeographFontFamily,this._updateStyle(_,t))}setTransformRequest(_){return this._requestManager.setTransformRequest(_),this}_getUIString(_){const t=this._locale[_];if(t==null)throw new Error(`Missing UI string '${_}'`);return t}_updateStyle(_,t){var n,A;if(t.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",(()=>this._updateStyle(_,t)));const h=this.style&&t.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!_)),_?(this.style=new Mn(this,t||{}),this.style.setEventedParent(this,{style:this.style}),typeof _=="string"?this.style.loadURL(_,t,h):this.style.loadJSON(_,t,h),this):((A=(n=this.style)===null||n===void 0?void 0:n.projection)===null||A===void 0||A.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new Mn(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(_,t){if(typeof _=="string"){const n=this._requestManager.transformRequest(_,"Style");d.j(n,new AbortController).then((A=>{this._updateDiff(A.data,t)})).catch((A=>{A&&this.fire(new d.k(A))}))}else typeof _=="object"&&this._updateDiff(_,t)}_updateDiff(_,t){try{this.style.setState(_,t)&&this._update(!0)}catch(n){d.w(`Unable to perform style diff: ${n.message||n.error||n}. Rebuilding the style from scratch.`),this._updateStyle(_,t)}}getStyle(){if(this.style)return this.style.serialize()}_getStyleAndImages(){return this.style?{style:this.style.serialize(),images:this.style.imageManager.cloneImages()}:{style:null,images:{}}}isStyleLoaded(){return this.style?this.style.loaded():d.w("There is no style added to the map.")}addSource(_,t){return this._lazyInitEmptyStyle(),this.style.addSource(_,t),this._update(!0)}isSourceLoaded(_){const t=this.style&&this.style.tileManagers[_];if(t!==void 0)return t.loaded();this.fire(new d.k(new Error(`There is no tile manager with ID '${_}'`)))}setTerrain(_){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),_){const t=this.style.tileManagers[_.source];if(!t)throw new Error(`cannot load terrain, because there exists no source with ID: ${_.source}`);this.terrain===null&&t.reload();for(const n in this.style._layers){const A=this.style._layers[n];A.type==="hillshade"&&A.source===_.source&&d.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality."),A.type==="color-relief"&&A.source===_.source&&d.w("You are using the same source for a color-relief layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.")}this.terrain=new ei(this.painter,t,_),this.painter.renderToTexture=new Ll(this.painter,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._terrainDataCallback=n=>{var A;n.dataType==="style"?this.terrain.tileManager.freeRtt():n.dataType==="source"&&n.tile&&(n.sourceId!==_.source||this._elevationFreeze||(this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))),((A=n.source)===null||A===void 0?void 0:A.type)==="image"?this.terrain.tileManager.freeRtt():this.terrain.tileManager.freeRtt(n.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.tileManager.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0);return this.fire(new d.l("terrain",{terrain:_})),this}getTerrain(){var _,t;return(t=(_=this.terrain)===null||_===void 0?void 0:_.options)!==null&&t!==void 0?t:null}areTilesLoaded(){const _=this.style&&this.style.tileManagers;for(const t of Object.values(_))if(!t.areTilesLoaded())return!1;return!0}removeSource(_){return this.style.removeSource(_),this._update(!0)}getSource(_){return this.style.getSource(_)}setSourceTileLodParams(_,t,n){if(n){const A=this.getSource(n);if(!A)throw new Error(`There is no source with ID "${n}", cannot set LOD parameters`);A.calculateTileZoom=mr(Math.max(1,_),Math.max(1,t))}else for(const A in this.style.tileManagers)this.style.tileManagers[A].getSource().calculateTileZoom=mr(Math.max(1,_),Math.max(1,t));return this._update(!0),this}refreshTiles(_,t){const n=this.style.tileManagers[_];if(!n)throw new Error(`There is no tile manager with ID "${_}", cannot refresh tile`);t===void 0?n.reload(!0):n.refreshTiles(t.map((A=>new d.ac(A.z,A.x,A.y))))}addImage(_,t,n={}){const{pixelRatio:A=1,sdf:h=!1,stretchX:y,stretchY:b,content:M,textFitWidth:I,textFitHeight:D}=n;if(this._lazyInitEmptyStyle(),!(t instanceof HTMLImageElement||d.b(t))){if(t.width===void 0||t.height===void 0)return this.fire(new d.k(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:B,height:V,data:O}=t,U=t;return this.style.addImage(_,{data:new d.R({width:B,height:V},new Uint8Array(O)),pixelRatio:A,stretchX:y,stretchY:b,content:M,textFitWidth:I,textFitHeight:D,sdf:h,version:0,userImage:U}),U.onAdd&&U.onAdd(this,_),this}}{const{width:B,height:V,data:O}=hi.getImageData(t);this.style.addImage(_,{data:new d.R({width:B,height:V},O),pixelRatio:A,stretchX:y,stretchY:b,content:M,textFitWidth:I,textFitHeight:D,sdf:h,version:0})}}updateImage(_,t){const n=this.style.getImage(_);if(!n)return this.fire(new d.k(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const A=t instanceof HTMLImageElement||d.b(t)?hi.getImageData(t):t,{width:h,height:y,data:b}=A;if(h===void 0||y===void 0)return this.fire(new d.k(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(h!==n.data.width||y!==n.data.height)return this.fire(new d.k(new Error("The width and height of the updated image must be that same as the previous version of the image")));const M=!(t instanceof HTMLImageElement||d.b(t));return n.data.replace(b,M),this.style.updateImage(_,n),this}getImage(_){return this.style.getImage(_)}hasImage(_){return _?!!this.style.getImage(_):(this.fire(new d.k(new Error("Missing required image id"))),!1)}removeImage(_){this.style.removeImage(_)}loadImage(_){return Yi.getImage(this._requestManager.transformRequest(_,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(_,t){return this._lazyInitEmptyStyle(),this.style.addLayer(_,t),this._update(!0)}moveLayer(_,t){return this.style.moveLayer(_,t),this._update(!0)}removeLayer(_){return this.style.removeLayer(_),this._update(!0)}getLayer(_){return this.style.getLayer(_)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(_,t,n){return this.style.setLayerZoomRange(_,t,n),this._update(!0)}setFilter(_,t,n={}){return this.style.setFilter(_,t,n),this._update(!0)}getFilter(_){return this.style.getFilter(_)}setPaintProperty(_,t,n,A={}){return this.style.setPaintProperty(_,t,n,A),this._update(!0)}getPaintProperty(_,t){return this.style.getPaintProperty(_,t)}setLayoutProperty(_,t,n,A={}){return this.style.setLayoutProperty(_,t,n,A),this._update(!0)}getLayoutProperty(_,t){return this.style.getLayoutProperty(_,t)}setGlyphs(_,t={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(_,t),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(_,t,n={}){return this._lazyInitEmptyStyle(),this.style.addSprite(_,t,n,(A=>{A||this._update(!0)})),this}removeSprite(_){return this._lazyInitEmptyStyle(),this.style.removeSprite(_),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(_,t={}){return this._lazyInitEmptyStyle(),this.style.setSprite(_,t,(n=>{n||this._update(!0)})),this}setLight(_,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(_,t),this._update(!0)}getLight(){return this.style.getLight()}setSky(_,t={}){return this._lazyInitEmptyStyle(),this.style.setSky(_,t),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(_,t){return this.style.setFeatureState(_,t),this._update()}removeFeatureState(_,t){return this.style.removeFeatureState(_,t),this._update()}getFeatureState(_){return this.style.getFeatureState(_)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let _=0,t=0;return this._container&&(_=this._container.clientWidth||400,t=this._container.clientHeight||300),[_,t]}_setupContainer(){const _=this._container;_.classList.add("maplibregl-map");const t=this._canvasContainer=Ze.create("div","maplibregl-canvas-container",_);this._interactive&&t.classList.add("maplibregl-interactive"),this._canvas=Ze.create("canvas","maplibregl-canvas",t),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");const n=this._containerDimensions(),A=this._getClampedPixelRatio(n[0],n[1]);this._resizeCanvas(n[0],n[1],A);const h=this._controlContainer=Ze.create("div","maplibregl-control-container",_),y=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((b=>{y[b]=Ze.create("div",`maplibregl-ctrl-${b} `,h)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(_,t,n){this._canvas.width=Math.floor(n*_),this._canvas.height=Math.floor(n*t),this._canvas.style.width=`${_}px`,this._canvas.style.height=`${t}px`}_setupPainter(){const _=Object.assign(Object.assign({},this._canvasContextAttributes),{alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0});let t=null;this._canvas.addEventListener("webglcontextcreationerror",(A=>{t={requestedAttributes:_},A&&(t.statusMessage=A.statusMessage,t.type=A.type)}),{once:!0});let n=null;if(n=this._canvasContextAttributes.contextType?this._canvas.getContext(this._canvasContextAttributes.contextType,_):this._canvas.getContext("webgl2",_)||this._canvas.getContext("webgl",_),!n){const A="Failed to initialize WebGL";throw t?(t.message=A,new Error(JSON.stringify(t))):new Error(A)}this.painter=new kt(n,this.transform),Gs.testSupport(n)}migrateProjection(_,t){super.migrateProjection(_,t),this.painter.transform=_,this.fire(new d.l("projectiontransition",{newProjection:this.style.projection.name}))}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(_){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||_,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(_){return this._update(),this._renderTaskQueue.add(_)}_cancelRenderFrame(_){this._renderTaskQueue.remove(_)}_render(_){var t,n,A,h,y;const b=this._idleTriggered?this._fadeDuration:0,M=((t=this.style.projection)===null||t===void 0?void 0:t.transitionState)>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(_),this._removed)return;let I=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const V=this.transform.zoom,O=Ar();this.style.zoomHistory.update(V,O);const U=new d.H(V,{now:O,fadeDuration:b,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),X=U.crossFadingFactor();X===1&&X===this._crossFadingFactor||(I=!0,this._crossFadingFactor=X),this.style.update(U)}const D=((n=this.style.projection)===null||n===void 0?void 0:n.transitionState)>0!==M;(A=this.style.projection)===null||A===void 0||A.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState((h=this.style.projection)===null||h===void 0?void 0:h.transitionState,(y=this.style.projection)===null||y===void 0?void 0:y.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||D)&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.tileManager.update(this.transform,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),!this._elevationFreeze&&this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0)),this._placementDirty=this.style&&this.style._updatePlacement(this.transform,this.showCollisionBoxes,b,this._crossSourceCollisions,D),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:b,showPadding:this.showPadding}),this.fire(new d.l("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,d.cG.mark(d.cH.load),this.fire(new d.l("load"))),this.style&&(this.style.hasTransitions()||I)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const B=this._sourcesDirty||this._styleDirty||this._placementDirty;return B||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new d.l("idle")),!this._loaded||this._fullyLoaded||B||(this._fullyLoaded=!0,d.cG.mark(d.cH.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var _;this._hash&&this._hash.remove();for(const n of this._controls)n.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),typeof window<"u"&&removeEventListener("online",this._onWindowOnline,!1),Yi.removeThrottleControl(this._imageQueueHandle),(_=this._resizeObserver)===null||_===void 0||_.disconnect();const t=this.painter.context.gl.getExtension("WEBGL_lose_context");t!=null&&t.loseContext&&t.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),Ze.remove(this._canvasContainer),Ze.remove(this._controlContainer),this._container.removeEventListener("scroll",this._onMapScroll,!1),this._container.classList.remove("maplibregl-map"),d.cG.clearMetrics(),this._removed=!0,this.fire(new d.l("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,hi.frame(this._frameRequest,(_=>{d.cG.frame(_),this._frameRequest=null;try{this._render(_)}catch(t){if(!d.Z(t)&&!(function(n){return n.message===Wa})(t))throw t}}),(()=>{})))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(_){this._showTileBoundaries!==_&&(this._showTileBoundaries=_,this._update())}get showPadding(){return!!this._showPadding}set showPadding(_){this._showPadding!==_&&(this._showPadding=_,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(_){this._showCollisionBoxes!==_&&(this._showCollisionBoxes=_,_?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(_){this._showOverdrawInspector!==_&&(this._showOverdrawInspector=_,this._update())}get repaint(){return!!this._repaint}set repaint(_){this._repaint!==_&&(this._repaint=_,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(_){this._vertices=_,this._update()}get version(){return fu}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(_){return this._lazyInitEmptyStyle(),this.style.setProjection(_),this._update(!0)}},G.MapMouseEvent=Ye,G.MapTouchEvent=lt,G.MapWheelEvent=el,G.Marker=Vl,G.NavigationControl=class{constructor(_){this._updateZoomButtons=()=>{const t=this._map.getZoom(),n=t===this._map.getMaxZoom(),A=t===this._map.getMinZoom();this._zoomInButton.disabled=n,this._zoomOutButton.disabled=A,this._zoomInButton.setAttribute("aria-disabled",n.toString()),this._zoomOutButton.setAttribute("aria-disabled",A.toString())},this._rotateCompassArrow=()=>{this._compassIcon.style.transform=this.options.visualizePitch&&this.options.visualizeRoll?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateZ(${-this._map.transform.roll}deg) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizeRoll?`rotate(${-this._map.transform.bearing-this._map.transform.roll}deg)`:`rotate(${-this._map.transform.bearing}deg)`},this._setButtonTitle=(t,n)=>{const A=this._map._getUIString(`NavigationControl.${n}`);t.title=A,t.setAttribute("aria-label",A)},this.options=d.e({},du,_),this._container=Ze.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}))),Ze.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}))),Ze.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=Ze.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(_){return this._map=_,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.on("roll",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new Fl(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){Ze.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.off("roll",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(_,t){const n=Ze.create("button",_,this._container);return n.type="button",n.addEventListener("click",t),n}},G.Popup=class extends d.E{constructor(_){super(),this._updateOpacity=()=>{this.options.locationOccludedOpacity!==void 0&&(this._container.style.opacity=this._map.transform.isLocationOccluded(this.getLngLat())?`${this.options.locationOccludedOpacity}`:"")},this.remove=()=>(this._content&&Ze.remove(this._content),this._container&&(Ze.remove(this._container),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("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new d.l("close"))),this),this._onMouseUp=t=>{this._update(t.point)},this._onMouseMove=t=>{this._update(t.point)},this._onDrag=t=>{this._update(t.point)},this._update=t=>{if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=Ze.create("div","maplibregl-popup",this._map.getContainer()),this._tip=Ze.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const b of this.options.className.split(" "))this._container.classList.add(b);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=zA(this._lngLat,this._flatPos,this._map.transform,this._trackPointer),this._trackPointer&&!t)return;const n=this._flatPos=this._pos=this._trackPointer&&t?t:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&t?t:this._map.transform.locationToScreenPoint(this._lngLat));let A=this.options.anchor;const h=LA(this.options.offset);if(!A){const b=this._container.offsetWidth,M=this._container.offsetHeight,I=(function(B){var V,O,U,X;return B?{top:(V=B.top)!==null&&V!==void 0?V:0,right:(O=B.right)!==null&&O!==void 0?O:0,bottom:(U=B.bottom)!==null&&U!==void 0?U:0,left:(X=B.left)!==null&&X!==void 0?X:0}:{top:0,right:0,bottom:0,left:0}})(this.options.padding);let D;D=n.y+h.bottom.y<M+I.top?["top"]:n.y>this._map.transform.height-M-I.bottom?["bottom"]:[],n.x<b/2+I.left?D.push("left"):n.x>this._map.transform.width-b/2-I.right&&D.push("right"),A=D.length===0?"bottom":D.join("-")}let y=n.add(h[A]);this.options.subpixelPositioning||(y=y.round()),Ze.setTransform(this._container,`${Ol[A]} translate(${y.x}px,${y.y}px)`),BA(this._container,A,"popup"),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=d.e(Object.create(_u),_)}addTo(_){return this._map&&this.remove(),this._map=_,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._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),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 d.l("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(_){return this._lngLat=d.V.convert(_),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),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._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(_){return this.setDOMContent(document.createTextNode(_))}setHTML(_){const t=document.createDocumentFragment(),n=document.createElement("body");let A;for(n.innerHTML=_;A=n.firstChild,A;)t.appendChild(A);return this.setDOMContent(t)}getMaxWidth(){var _;return(_=this._container)===null||_===void 0?void 0:_.style.maxWidth}setMaxWidth(_){return this.options.maxWidth=_,this._update(),this}setDOMContent(_){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=Ze.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(_),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(_){return this._container&&this._container.classList.add(_),this}removeClassName(_){return this._container&&this._container.classList.remove(_),this}setOffset(_){return this.options.offset=_,this._update(),this}toggleClassName(_){if(this._container)return this._container.classList.toggle(_)}setSubpixelPositioning(_){this.options.subpixelPositioning=_}setPadding(_){this.options.padding=_,this._update()}_createCloseButton(){this.options.closeButton&&(this._closeButton=Ze.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="&#215;",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const _=this._container.querySelector(RA);_&&_.focus()}},G.RasterDEMTileSource=Ci,G.RasterTileSource=wo,G.ScaleControl=class{constructor(_){this._onMove=()=>{jl(this._map,this._container,this.options)},this.setUnit=t=>{this.options.unit=t,jl(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},gu),_)}getDefaultPosition(){return"bottom-left"}onAdd(_){return this._map=_,this._container=Ze.create("div","maplibregl-ctrl maplibregl-ctrl-scale",_.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){Ze.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},G.ScrollZoomHandler=Mt,G.Style=Mn,G.TerrainControl=class{constructor(_){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))},this.options=_}onAdd(_){return this._map=_,this._container=Ze.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=Ze.create("button","maplibregl-ctrl-terrain",this._container),Ze.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){Ze.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},G.TwoFingersTouchPitchHandler=Ue,G.TwoFingersTouchRotateHandler=xe,G.TwoFingersTouchZoomHandler=oe,G.TwoFingersTouchZoomRotateHandler=At,G.VectorTileSource=Ws,G.VideoSource=De,G.addSourceType=(_,t)=>d._(void 0,void 0,void 0,(function*(){if(te(_))throw new Error(`A source type called "${_}" already exists.`);((n,A)=>{$[n]=A})(_,t)})),G.clearPrewarmedResources=function(){const _=as;_&&(_.isPreloaded()&&_.numActive()===1?(_.release(Qs),as=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},G.createTileMesh=fl,G.getMaxParallelImageRequests=function(){return d.c.MAX_PARALLEL_IMAGE_REQUESTS},G.getRTLTextPluginStatus=function(){return Ce().getRTLTextPluginStatus()},G.getVersion=function(){return yu},G.getWorkerCount=function(){return Si.workerCount},G.getWorkerUrl=function(){return d.c.WORKER_URL},G.importScriptInWorkers=function(_){return na().broadcast("IS",_)},G.isTimeFrozen=function(){return ss.isFrozen()},G.now=Ar,G.prewarm=function(){$s().acquire(Qs)},G.restoreNow=function(){ss.restoreNow()},G.setMaxParallelImageRequests=function(_){d.c.MAX_PARALLEL_IMAGE_REQUESTS=_},G.setNow=function(_){ss.setNow(_)},G.setRTLTextPlugin=function(_,t){return Ce().setRTLTextPlugin(_,t)},G.setWorkerCount=function(_){Si.workerCount=_},G.setWorkerUrl=function(_){d.c.WORKER_URL=_}}));var it=be;return it}))})(bc)),bc.exports}var Hp=Um();const qm=Nm(Hp),__=jm({__proto__:null,default:qm},[Hp]);var qe=(function(pe){pe=pe||{};var Q=typeof pe<"u"?pe:{},be={},Ie;for(Ie in Q)Q.hasOwnProperty(Ie)&&(be[Ie]=Q[Ie]);var We="";function it(ke){return Q.locateFile?Q.locateFile(ke,We):We+ke}var G;typeof document<"u"&&document.currentScript&&(We=document.currentScript.src),We.indexOf("blob:")!==0?We=We.substr(0,We.lastIndexOf("/")+1):We="",G=function(Xe,vt,ot){var o=new XMLHttpRequest;o.open("GET",Xe,!0),o.responseType="arraybuffer",o.onload=function(){if(o.status==200||o.status==0&&o.response){vt(o.response);return}var Ut=tt(Xe);if(Ut){vt(Ut.buffer);return}ot()},o.onerror=ot,o.send(null)};var d=Q.print||console.log.bind(console),nt=Q.printErr||console.warn.bind(console);for(Ie in be)be.hasOwnProperty(Ie)&&(Q[Ie]=be[Ie]);be=null,Q.arguments&&Q.arguments;var Vr=0,si=function(ke){Vr=ke},kn=function(){return Vr},bs=8;function hi(ke,Xe,vt,ot){switch(vt=vt||"i8",vt.charAt(vt.length-1)==="*"&&(vt="i32"),vt){case"i1":Ti[ke>>0]=Xe;break;case"i8":Ti[ke>>0]=Xe;break;case"i16":qs[ke>>1]=Xe;break;case"i32":Ki[ke>>2]=Xe;break;case"i64":Di=[Xe>>>0,(Rn=Xe,+sa(Rn)>=1?Rn>0?(Wn(+wn(Rn/4294967296),4294967295)|0)>>>0:~~+di((Rn-+(~~Rn>>>0))/4294967296)>>>0:0)],Ki[ke>>2]=Di[0],Ki[ke+4>>2]=Di[1];break;case"float":xo[ke>>2]=Xe;break;case"double":Ui[ke>>3]=Xe;break;default:Mr("invalid type for setValue: "+vt)}}function ss(ke,Xe,vt){switch(Xe=Xe||"i8",Xe.charAt(Xe.length-1)==="*"&&(Xe="i32"),Xe){case"i1":return Ti[ke>>0];case"i8":return Ti[ke>>0];case"i16":return qs[ke>>1];case"i32":return Ki[ke>>2];case"i64":return Ki[ke>>2];case"float":return xo[ke>>2];case"double":return Ui[ke>>3];default:Mr("invalid type for getValue: "+Xe)}return null}var Ar=!1;function Ze(ke,Xe){ke||Mr("Assertion failed: "+Xe)}function Gs(ke){var Xe=Q["_"+ke];return Ze(Xe,"Cannot call unknown function "+ke+", make sure it is exported"),Xe}function jr(ke,Xe,vt,ot,o){var Z={string:function(Yt){var ai=0;if(Yt!=null&&Yt!==0){var qt=(Yt.length<<2)+1;ai=gr(qt),vo(Yt,ai,qt)}return ai},array:function(Yt){var ai=gr(Yt.length);return Ts(Yt,ai),ai}};function Ut(Yt){return Xe==="string"?ws(Yt):Xe==="boolean"?!!Yt:Yt}var pr=Gs(ke),br=[],Je=0;if(ot)for(var wt=0;wt<ot.length;wt++){var Ft=Z[vt[wt]];Ft?(Je===0&&(Je=Le()),br[wt]=Ft(ot[wt])):br[wt]=ot[wt]}var Jt=pr.apply(null,br);return Jt=Ut(Jt),Je!==0&&hr(Je),Jt}function Rr(ke,Xe,vt,ot){vt=vt||[];var o=vt.every(function(Ut){return Ut==="number"}),Z=Xe!=="string";return Z&&o&&!ot?Gs(ke):function(){return jr(ke,Xe,vt,arguments)}}var Us=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function yo(ke,Xe,vt){for(var ot=Xe+vt,o=Xe;ke[o]&&!(o>=ot);)++o;if(o-Xe>16&&ke.subarray&&Us)return Us.decode(ke.subarray(Xe,o));for(var Z="";Xe<o;){var Ut=ke[Xe++];if(!(Ut&128)){Z+=String.fromCharCode(Ut);continue}var pr=ke[Xe++]&63;if((Ut&224)==192){Z+=String.fromCharCode((Ut&31)<<6|pr);continue}var br=ke[Xe++]&63;if((Ut&240)==224?Ut=(Ut&15)<<12|pr<<6|br:Ut=(Ut&7)<<18|pr<<12|br<<6|ke[Xe++]&63,Ut<65536)Z+=String.fromCharCode(Ut);else{var Je=Ut-65536;Z+=String.fromCharCode(55296|Je>>10,56320|Je&1023)}}return Z}function ws(ke,Xe){return ke?yo(Gi,ke,Xe):""}function Yi(ke,Xe,vt,ot){if(!(ot>0))return 0;for(var o=vt,Z=vt+ot-1,Ut=0;Ut<ke.length;++Ut){var pr=ke.charCodeAt(Ut);if(pr>=55296&&pr<=57343){var br=ke.charCodeAt(++Ut);pr=65536+((pr&1023)<<10)|br&1023}if(pr<=127){if(vt>=Z)break;Xe[vt++]=pr}else if(pr<=2047){if(vt+1>=Z)break;Xe[vt++]=192|pr>>6,Xe[vt++]=128|pr&63}else if(pr<=65535){if(vt+2>=Z)break;Xe[vt++]=224|pr>>12,Xe[vt++]=128|pr>>6&63,Xe[vt++]=128|pr&63}else{if(vt+3>=Z)break;Xe[vt++]=240|pr>>18,Xe[vt++]=128|pr>>12&63,Xe[vt++]=128|pr>>6&63,Xe[vt++]=128|pr&63}}return Xe[vt]=0,vt-o}function vo(ke,Xe,vt){return Yi(ke,Gi,Xe,vt)}typeof TextDecoder<"u"&&new TextDecoder("utf-16le");function Ts(ke,Xe){Ti.set(ke,Xe)}function Qn(ke,Xe){return ke%Xe>0&&(ke+=Xe-ke%Xe),ke}var xn,Ti,Gi,qs,Ki,xo,Ui;function Ps(ke){xn=ke,Q.HEAP8=Ti=new Int8Array(ke),Q.HEAP16=qs=new Int16Array(ke),Q.HEAP32=Ki=new Int32Array(ke),Q.HEAPU8=Gi=new Uint8Array(ke),Q.HEAPU16=new Uint16Array(ke),Q.HEAPU32=new Uint32Array(ke),Q.HEAPF32=xo=new Float32Array(ke),Q.HEAPF64=Ui=new Float64Array(ke)}var dr=5271536,Zs=28624,$n=Q.TOTAL_MEMORY||33554432;Q.buffer?xn=Q.buffer:xn=new ArrayBuffer($n),$n=xn.byteLength,Ps(xn),Ki[Zs>>2]=dr;function os(ke){for(;ke.length>0;){var Xe=ke.shift();if(typeof Xe=="function"){Xe();continue}var vt=Xe.func;typeof vt=="number"?Xe.arg===void 0?Q.dynCall_v(vt):Q.dynCall_vi(vt,Xe.arg):vt(Xe.arg===void 0?null:Xe.arg)}}var bo=[],Qs=[],Si=[],bn=[];function as(){if(Q.preRun)for(typeof Q.preRun=="function"&&(Q.preRun=[Q.preRun]);Q.preRun.length;)na(Q.preRun.shift());os(bo)}function qi(){os(Qs)}function $s(){os(Si)}function zn(){if(Q.postRun)for(typeof Q.postRun=="function"&&(Q.postRun=[Q.postRun]);Q.postRun.length;)Bn(Q.postRun.shift());os(bn)}function na(ke){bo.unshift(ke)}function Bn(ke){bn.unshift(ke)}var sa=Math.abs,di=Math.ceil,wn=Math.floor,Wn=Math.min,xr=0,Tn=null;function Ws(ke){xr++,Q.monitorRunDependencies&&Q.monitorRunDependencies(xr)}function wo(ke){if(xr--,Q.monitorRunDependencies&&Q.monitorRunDependencies(xr),xr==0&&Tn){var Xe=Tn;Tn=null,Xe()}}Q.preloadedImages={},Q.preloadedAudios={};var Ci=null,fn="data:application/octet-stream;base64,";function Hs(ke){return String.prototype.startsWith?ke.startsWith(fn):ke.indexOf(fn)===0}var Rn,Di;Ci="data:application/octet-stream;base64,AAAAAAAAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAGAAAAAQAAAAQAAAADAAAABgAAAAUAAAACAAAAAAAAAAIAAAADAAAAAQAAAAQAAAAGAAAAAAAAAAUAAAADAAAABgAAAAQAAAAFAAAAAAAAAAEAAAACAAAABAAAAAUAAAAGAAAAAAAAAAIAAAADAAAAAQAAAAUAAAACAAAAAAAAAAEAAAADAAAABgAAAAQAAAAGAAAAAAAAAAUAAAACAAAAAQAAAAQAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAIAAAADAAAAAAAAAAAAAAACAAAAAAAAAAEAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAYAAAAAAAAABQAAAAAAAAAAAAAABAAAAAUAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAYAAAAAAAAABgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAIAAAAAAAAAAAAAAAYAAAAAAAAAAwAAAAIAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAFAAAABAAAAAAAAAABAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAYAAAAAAAAABAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAFAAAAAgAAAAQAAAADAAAACAAAAAEAAAAHAAAABgAAAAkAAAAAAAAAAwAAAAIAAAACAAAABgAAAAoAAAALAAAAAAAAAAEAAAAFAAAAAwAAAA0AAAABAAAABwAAAAQAAAAMAAAAAAAAAAQAAAB/AAAADwAAAAgAAAADAAAAAAAAAAwAAAAFAAAAAgAAABIAAAAKAAAACAAAAAAAAAAQAAAABgAAAA4AAAALAAAAEQAAAAEAAAAJAAAAAgAAAAcAAAAVAAAACQAAABMAAAADAAAADQAAAAEAAAAIAAAABQAAABYAAAAQAAAABAAAAAAAAAAPAAAACQAAABMAAAAOAAAAFAAAAAEAAAAHAAAABgAAAAoAAAALAAAAGAAAABcAAAAFAAAAAgAAABIAAAALAAAAEQAAABcAAAAZAAAAAgAAAAYAAAAKAAAADAAAABwAAAANAAAAGgAAAAQAAAAPAAAAAwAAAA0AAAAaAAAAFQAAAB0AAAADAAAADAAAAAcAAAAOAAAAfwAAABEAAAAbAAAACQAAABQAAAAGAAAADwAAABYAAAAcAAAAHwAAAAQAAAAIAAAADAAAABAAAAASAAAAIQAAAB4AAAAIAAAABQAAABYAAAARAAAACwAAAA4AAAAGAAAAIwAAABkAAAAbAAAAEgAAABgAAAAeAAAAIAAAAAUAAAAKAAAAEAAAABMAAAAiAAAAFAAAACQAAAAHAAAAFQAAAAkAAAAUAAAADgAAABMAAAAJAAAAKAAAABsAAAAkAAAAFQAAACYAAAATAAAAIgAAAA0AAAAdAAAABwAAABYAAAAQAAAAKQAAACEAAAAPAAAACAAAAB8AAAAXAAAAGAAAAAsAAAAKAAAAJwAAACUAAAAZAAAAGAAAAH8AAAAgAAAAJQAAAAoAAAAXAAAAEgAAABkAAAAXAAAAEQAAAAsAAAAtAAAAJwAAACMAAAAaAAAAKgAAAB0AAAArAAAADAAAABwAAAANAAAAGwAAACgAAAAjAAAALgAAAA4AAAAUAAAAEQAAABwAAAAfAAAAKgAAACwAAAAMAAAADwAAABoAAAAdAAAAKwAAACYAAAAvAAAADQAAABoAAAAVAAAAHgAAACAAAAAwAAAAMgAAABAAAAASAAAAIQAAAB8AAAApAAAALAAAADUAAAAPAAAAFgAAABwAAAAgAAAAHgAAABgAAAASAAAANAAAADIAAAAlAAAAIQAAAB4AAAAxAAAAMAAAABYAAAAQAAAAKQAAACIAAAATAAAAJgAAABUAAAA2AAAAJAAAADMAAAAjAAAALgAAAC0AAAA4AAAAEQAAABsAAAAZAAAAJAAAABQAAAAiAAAAEwAAADcAAAAoAAAANgAAACUAAAAnAAAANAAAADkAAAAYAAAAFwAAACAAAAAmAAAAfwAAACIAAAAzAAAAHQAAAC8AAAAVAAAAJwAAACUAAAAZAAAAFwAAADsAAAA5AAAALQAAACgAAAAbAAAAJAAAABQAAAA8AAAALgAAADcAAAApAAAAMQAAADUAAAA9AAAAFgAAACEAAAAfAAAAKgAAADoAAAArAAAAPgAAABwAAAAsAAAAGgAAACsAAAA+AAAALwAAAEAAAAAaAAAAKgAAAB0AAAAsAAAANQAAADoAAABBAAAAHAAAAB8AAAAqAAAALQAAACcAAAAjAAAAGQAAAD8AAAA7AAAAOAAAAC4AAAA8AAAAOAAAAEQAAAAbAAAAKAAAACMAAAAvAAAAJgAAACsAAAAdAAAARQAAADMAAABAAAAAMAAAADEAAAAeAAAAIQAAAEMAAABCAAAAMgAAADEAAAB/AAAAPQAAAEIAAAAhAAAAMAAAACkAAAAyAAAAMAAAACAAAAAeAAAARgAAAEMAAAA0AAAAMwAAAEUAAAA2AAAARwAAACYAAAAvAAAAIgAAADQAAAA5AAAARgAAAEoAAAAgAAAAJQAAADIAAAA1AAAAPQAAAEEAAABLAAAAHwAAACkAAAAsAAAANgAAAEcAAAA3AAAASQAAACIAAAAzAAAAJAAAADcAAAAoAAAANgAAACQAAABIAAAAPAAAAEkAAAA4AAAARAAAAD8AAABNAAAAIwAAAC4AAAAtAAAAOQAAADsAAABKAAAATgAAACUAAAAnAAAANAAAADoAAAB/AAAAPgAAAEwAAAAsAAAAQQAAACoAAAA7AAAAPwAAAE4AAABPAAAAJwAAAC0AAAA5AAAAPAAAAEgAAABEAAAAUAAAACgAAAA3AAAALgAAAD0AAAA1AAAAMQAAACkAAABRAAAASwAAAEIAAAA+AAAAKwAAADoAAAAqAAAAUgAAAEAAAABMAAAAPwAAAH8AAAA4AAAALQAAAE8AAAA7AAAATQAAAEAAAAAvAAAAPgAAACsAAABUAAAARQAAAFIAAABBAAAAOgAAADUAAAAsAAAAVgAAAEwAAABLAAAAQgAAAEMAAABRAAAAVQAAADEAAAAwAAAAPQAAAEMAAABCAAAAMgAAADAAAABXAAAAVQAAAEYAAABEAAAAOAAAADwAAAAuAAAAWgAAAE0AAABQAAAARQAAADMAAABAAAAALwAAAFkAAABHAAAAVAAAAEYAAABDAAAANAAAADIAAABTAAAAVwAAAEoAAABHAAAAWQAAAEkAAABbAAAAMwAAAEUAAAA2AAAASAAAAH8AAABJAAAANwAAAFAAAAA8AAAAWAAAAEkAAABbAAAASAAAAFgAAAA2AAAARwAAADcAAABKAAAATgAAAFMAAABcAAAANAAAADkAAABGAAAASwAAAEEAAAA9AAAANQAAAF4AAABWAAAAUQAAAEwAAABWAAAAUgAAAGAAAAA6AAAAQQAAAD4AAABNAAAAPwAAAEQAAAA4AAAAXQAAAE8AAABaAAAATgAAAEoAAAA7AAAAOQAAAF8AAABcAAAATwAAAE8AAABOAAAAPwAAADsAAABdAAAAXwAAAE0AAABQAAAARAAAAEgAAAA8AAAAYwAAAFoAAABYAAAAUQAAAFUAAABeAAAAZQAAAD0AAABCAAAASwAAAFIAAABgAAAAVAAAAGIAAAA+AAAATAAAAEAAAABTAAAAfwAAAEoAAABGAAAAZAAAAFcAAABcAAAAVAAAAEUAAABSAAAAQAAAAGEAAABZAAAAYgAAAFUAAABXAAAAZQAAAGYAAABCAAAAQwAAAFEAAABWAAAATAAAAEsAAABBAAAAaAAAAGAAAABeAAAAVwAAAFMAAABmAAAAZAAAAEMAAABGAAAAVQAAAFgAAABIAAAAWwAAAEkAAABjAAAAUAAAAGkAAABZAAAAYQAAAFsAAABnAAAARQAAAFQAAABHAAAAWgAAAE0AAABQAAAARAAAAGoAAABdAAAAYwAAAFsAAABJAAAAWQAAAEcAAABpAAAAWAAAAGcAAABcAAAAUwAAAE4AAABKAAAAbAAAAGQAAABfAAAAXQAAAE8AAABaAAAATQAAAG0AAABfAAAAagAAAF4AAABWAAAAUQAAAEsAAABrAAAAaAAAAGUAAABfAAAAXAAAAE8AAABOAAAAbQAAAGwAAABdAAAAYAAAAGgAAABiAAAAbgAAAEwAAABWAAAAUgAAAGEAAAB/AAAAYgAAAFQAAABnAAAAWQAAAG8AAABiAAAAbgAAAGEAAABvAAAAUgAAAGAAAABUAAAAYwAAAFAAAABpAAAAWAAAAGoAAABaAAAAcQAAAGQAAABmAAAAUwAAAFcAAABsAAAAcgAAAFwAAABlAAAAZgAAAGsAAABwAAAAUQAAAFUAAABeAAAAZgAAAGUAAABXAAAAVQAAAHIAAABwAAAAZAAAAGcAAABbAAAAYQAAAFkAAAB0AAAAaQAAAG8AAABoAAAAawAAAG4AAABzAAAAVgAAAF4AAABgAAAAaQAAAFgAAABnAAAAWwAAAHEAAABjAAAAdAAAAGoAAABdAAAAYwAAAFoAAAB1AAAAbQAAAHEAAABrAAAAfwAAAGUAAABeAAAAcwAAAGgAAABwAAAAbAAAAGQAAABfAAAAXAAAAHYAAAByAAAAbQAAAG0AAABsAAAAXQAAAF8AAAB1AAAAdgAAAGoAAABuAAAAYgAAAGgAAABgAAAAdwAAAG8AAABzAAAAbwAAAGEAAABuAAAAYgAAAHQAAABnAAAAdwAAAHAAAABrAAAAZgAAAGUAAAB4AAAAcwAAAHIAAABxAAAAYwAAAHQAAABpAAAAdQAAAGoAAAB5AAAAcgAAAHAAAABkAAAAZgAAAHYAAAB4AAAAbAAAAHMAAABuAAAAawAAAGgAAAB4AAAAdwAAAHAAAAB0AAAAZwAAAHcAAABvAAAAcQAAAGkAAAB5AAAAdQAAAH8AAABtAAAAdgAAAHEAAAB5AAAAagAAAHYAAAB4AAAAbAAAAHIAAAB1AAAAeQAAAG0AAAB3AAAAbwAAAHMAAABuAAAAeQAAAHQAAAB4AAAAeAAAAHMAAAByAAAAcAAAAHkAAAB3AAAAdgAAAHkAAAB0AAAAeAAAAHcAAAB1AAAAcQAAAHYAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAACAAAABQAAAAEAAAAAAAAA/////wEAAAAAAAAAAwAAAAQAAAACAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAFAAAAAQAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAAAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAEAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAUAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAABAAAAAUAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAIAAAAFAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAFAAAAAAAAAAAAAAD/////AQAAAAAAAAADAAAABAAAAAIAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAUAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAEAAAD//////////wEAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAACAAAAAAAAAAAAAAABAAAAAgAAAAYAAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAKAAAAAgAAAAAAAAAAAAAAAQAAAAEAAAAFAAAABgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAACAAAAAAAAAAAAAAABAAAAAwAAAAcAAAAGAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAADgAAAAIAAAAAAAAAAAAAAAEAAAAAAAAACQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAIAAAAAAAAAAAAAAAEAAAAEAAAACAAAAAoAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAALAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAAAAAAAAAAAAQAAAAsAAAAPAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAIAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAgAAAAAAAAAAAAAAAQAAAAwAAAAQAAAADAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAPAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAADwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAACAAAAAAAAAAAAAAABAAAACgAAABMAAAAIAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAAAAAAAAAAAAAEAAAANAAAAEQAAAA0AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAARAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA0AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAACAAAAAAAAAAAAAAABAAAADgAAABIAAAAPAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAADwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAASAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABIAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAATAAAAAgAAAAAAAAAAAAAAAQAAAP//////////EwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAASAAAAAAAAABgAAAAAAAAAIQAAAAAAAAAeAAAAAAAAACAAAAADAAAAMQAAAAEAAAAwAAAAAwAAADIAAAADAAAACAAAAAAAAAAFAAAABQAAAAoAAAAFAAAAFgAAAAAAAAAQAAAAAAAAABIAAAAAAAAAKQAAAAEAAAAhAAAAAAAAAB4AAAAAAAAABAAAAAAAAAAAAAAABQAAAAIAAAAFAAAADwAAAAEAAAAIAAAAAAAAAAUAAAAFAAAAHwAAAAEAAAAWAAAAAAAAABAAAAAAAAAAAgAAAAAAAAAGAAAAAAAAAA4AAAAAAAAACgAAAAAAAAALAAAAAAAAABEAAAADAAAAGAAAAAEAAAAXAAAAAwAAABkAAAADAAAAAAAAAAAAAAABAAAABQAAAAkAAAAFAAAABQAAAAAAAAACAAAAAAAAAAYAAAAAAAAAEgAAAAEAAAAKAAAAAAAAAAsAAAAAAAAABAAAAAEAAAADAAAABQAAAAcAAAAFAAAACAAAAAEAAAAAAAAAAAAAAAEAAAAFAAAAEAAAAAEAAAAFAAAAAAAAAAIAAAAAAAAABwAAAAAAAAAVAAAAAAAAACYAAAAAAAAACQAAAAAAAAATAAAAAAAAACIAAAADAAAADgAAAAEAAAAUAAAAAwAAACQAAAADAAAAAwAAAAAAAAANAAAABQAAAB0AAAAFAAAAAQAAAAAAAAAHAAAAAAAAABUAAAAAAAAABgAAAAEAAAAJAAAAAAAAABMAAAAAAAAABAAAAAIAAAAMAAAABQAAABoAAAAFAAAAAAAAAAEAAAADAAAAAAAAAA0AAAAFAAAAAgAAAAEAAAABAAAAAAAAAAcAAAAAAAAAGgAAAAAAAAAqAAAAAAAAADoAAAAAAAAAHQAAAAAAAAArAAAAAAAAAD4AAAADAAAAJgAAAAEAAAAvAAAAAwAAAEAAAAADAAAADAAAAAAAAAAcAAAABQAAACwAAAAFAAAADQAAAAAAAAAaAAAAAAAAACoAAAAAAAAAFQAAAAEAAAAdAAAAAAAAACsAAAAAAAAABAAAAAMAAAAPAAAABQAAAB8AAAAFAAAAAwAAAAEAAAAMAAAAAAAAABwAAAAFAAAABwAAAAEAAAANAAAAAAAAABoAAAAAAAAAHwAAAAAAAAApAAAAAAAAADEAAAAAAAAALAAAAAAAAAA1AAAAAAAAAD0AAAADAAAAOgAAAAEAAABBAAAAAwAAAEsAAAADAAAADwAAAAAAAAAWAAAABQAAACEAAAAFAAAAHAAAAAAAAAAfAAAAAAAAACkAAAAAAAAAKgAAAAEAAAAsAAAAAAAAADUAAAAAAAAABAAAAAQAAAAIAAAABQAAABAAAAAFAAAADAAAAAEAAAAPAAAAAAAAABYAAAAFAAAAGgAAAAEAAAAcAAAAAAAAAB8AAAAAAAAAMgAAAAAAAAAwAAAAAAAAADEAAAADAAAAIAAAAAAAAAAeAAAAAwAAACEAAAADAAAAGAAAAAMAAAASAAAAAwAAABAAAAADAAAARgAAAAAAAABDAAAAAAAAAEIAAAADAAAANAAAAAMAAAAyAAAAAAAAADAAAAAAAAAAJQAAAAMAAAAgAAAAAAAAAB4AAAADAAAAUwAAAAAAAABXAAAAAwAAAFUAAAADAAAASgAAAAMAAABGAAAAAAAAAEMAAAAAAAAAOQAAAAEAAAA0AAAAAwAAADIAAAAAAAAAGQAAAAAAAAAXAAAAAAAAABgAAAADAAAAEQAAAAAAAAALAAAAAwAAAAoAAAADAAAADgAAAAMAAAAGAAAAAwAAAAIAAAADAAAALQAAAAAAAAAnAAAAAAAAACUAAAADAAAAIwAAAAMAAAAZAAAAAAAAABcAAAAAAAAAGwAAAAMAAAARAAAAAAAAAAsAAAADAAAAPwAAAAAAAAA7AAAAAwAAADkAAAADAAAAOAAAAAMAAAAtAAAAAAAAACcAAAAAAAAALgAAAAMAAAAjAAAAAwAAABkAAAAAAAAAJAAAAAAAAAAUAAAAAAAAAA4AAAADAAAAIgAAAAAAAAATAAAAAwAAAAkAAAADAAAAJgAAAAMAAAAVAAAAAwAAAAcAAAADAAAANwAAAAAAAAAoAAAAAAAAABsAAAADAAAANgAAAAMAAAAkAAAAAAAAABQAAAAAAAAAMwAAAAMAAAAiAAAAAAAAABMAAAADAAAASAAAAAAAAAA8AAAAAwAAAC4AAAADAAAASQAAAAMAAAA3AAAAAAAAACgAAAAAAAAARwAAAAMAAAA2AAAAAwAAACQAAAAAAAAAQAAAAAAAAAAvAAAAAAAAACYAAAADAAAAPgAAAAAAAAArAAAAAwAAAB0AAAADAAAAOgAAAAMAAAAqAAAAAwAAABoAAAADAAAAVAAAAAAAAABFAAAAAAAAADMAAAADAAAAUgAAAAMAAABAAAAAAAAAAC8AAAAAAAAATAAAAAMAAAA+AAAAAAAAACsAAAADAAAAYQAAAAAAAABZAAAAAwAAAEcAAAADAAAAYgAAAAMAAABUAAAAAAAAAEUAAAAAAAAAYAAAAAMAAABSAAAAAwAAAEAAAAAAAAAASwAAAAAAAABBAAAAAAAAADoAAAADAAAAPQAAAAAAAAA1AAAAAwAAACwAAAADAAAAMQAAAAMAAAApAAAAAwAAAB8AAAADAAAAXgAAAAAAAABWAAAAAAAAAEwAAAADAAAAUQAAAAMAAABLAAAAAAAAAEEAAAAAAAAAQgAAAAMAAAA9AAAAAAAAADUAAAADAAAAawAAAAAAAABoAAAAAwAAAGAAAAADAAAAZQAAAAMAAABeAAAAAAAAAFYAAAAAAAAAVQAAAAMAAABRAAAAAwAAAEsAAAAAAAAAOQAAAAAAAAA7AAAAAAAAAD8AAAADAAAASgAAAAAAAABOAAAAAwAAAE8AAAADAAAAUwAAAAMAAABcAAAAAwAAAF8AAAADAAAAJQAAAAAAAAAnAAAAAwAAAC0AAAADAAAANAAAAAAAAAA5AAAAAAAAADsAAAAAAAAARgAAAAMAAABKAAAAAAAAAE4AAAADAAAAGAAAAAAAAAAXAAAAAwAAABkAAAADAAAAIAAAAAMAAAAlAAAAAAAAACcAAAADAAAAMgAAAAMAAAA0AAAAAAAAADkAAAAAAAAALgAAAAAAAAA8AAAAAAAAAEgAAAADAAAAOAAAAAAAAABEAAAAAwAAAFAAAAADAAAAPwAAAAMAAABNAAAAAwAAAFoAAAADAAAAGwAAAAAAAAAoAAAAAwAAADcAAAADAAAAIwAAAAAAAAAuAAAAAAAAADwAAAAAAAAALQAAAAMAAAA4AAAAAAAAAEQAAAADAAAADgAAAAAAAAAUAAAAAwAAACQAAAADAAAAEQAAAAMAAAAbAAAAAAAAACgAAAADAAAAGQAAAAMAAAAjAAAAAAAAAC4AAAAAAAAARwAAAAAAAABZAAAAAAAAAGEAAAADAAAASQAAAAAAAABbAAAAAwAAAGcAAAADAAAASAAAAAMAAABYAAAAAwAAAGkAAAADAAAAMwAAAAAAAABFAAAAAwAAAFQAAAADAAAANgAAAAAAAABHAAAAAAAAAFkAAAAAAAAANwAAAAMAAABJAAAAAAAAAFsAAAADAAAAJgAAAAAAAAAvAAAAAwAAAEAAAAADAAAAIgAAAAMAAAAzAAAAAAAAAEUAAAADAAAAJAAAAAMAAAA2AAAAAAAAAEcAAAAAAAAAYAAAAAAAAABoAAAAAAAAAGsAAAADAAAAYgAAAAAAAABuAAAAAwAAAHMAAAADAAAAYQAAAAMAAABvAAAAAwAAAHcAAAADAAAATAAAAAAAAABWAAAAAwAAAF4AAAADAAAAUgAAAAAAAABgAAAAAAAAAGgAAAAAAAAAVAAAAAMAAABiAAAAAAAAAG4AAAADAAAAOgAAAAAAAABBAAAAAwAAAEsAAAADAAAAPgAAAAMAAABMAAAAAAAAAFYAAAADAAAAQAAAAAMAAABSAAAAAAAAAGAAAAAAAAAAVQAAAAAAAABXAAAAAAAAAFMAAAADAAAAZQAAAAAAAABmAAAAAwAAAGQAAAADAAAAawAAAAMAAABwAAAAAwAAAHIAAAADAAAAQgAAAAAAAABDAAAAAwAAAEYAAAADAAAAUQAAAAAAAABVAAAAAAAAAFcAAAAAAAAAXgAAAAMAAABlAAAAAAAAAGYAAAADAAAAMQAAAAAAAAAwAAAAAwAAADIAAAADAAAAPQAAAAMAAABCAAAAAAAAAEMAAAADAAAASwAAAAMAAABRAAAAAAAAAFUAAAAAAAAAXwAAAAAAAABcAAAAAAAAAFMAAAAAAAAATwAAAAAAAABOAAAAAAAAAEoAAAADAAAAPwAAAAEAAAA7AAAAAwAAADkAAAADAAAAbQAAAAAAAABsAAAAAAAAAGQAAAAFAAAAXQAAAAEAAABfAAAAAAAAAFwAAAAAAAAATQAAAAEAAABPAAAAAAAAAE4AAAAAAAAAdQAAAAQAAAB2AAAABQAAAHIAAAAFAAAAagAAAAEAAABtAAAAAAAAAGwAAAAAAAAAWgAAAAEAAABdAAAAAQAAAF8AAAAAAAAAWgAAAAAAAABNAAAAAAAAAD8AAAAAAAAAUAAAAAAAAABEAAAAAAAAADgAAAADAAAASAAAAAEAAAA8AAAAAwAAAC4AAAADAAAAagAAAAAAAABdAAAAAAAAAE8AAAAFAAAAYwAAAAEAAABaAAAAAAAAAE0AAAAAAAAAWAAAAAEAAABQAAAAAAAAAEQAAAAAAAAAdQAAAAMAAABtAAAABQAAAF8AAAAFAAAAcQAAAAEAAABqAAAAAAAAAF0AAAAAAAAAaQAAAAEAAABjAAAAAQAAAFoAAAAAAAAAaQAAAAAAAABYAAAAAAAAAEgAAAAAAAAAZwAAAAAAAABbAAAAAAAAAEkAAAADAAAAYQAAAAEAAABZAAAAAwAAAEcAAAADAAAAcQAAAAAAAABjAAAAAAAAAFAAAAAFAAAAdAAAAAEAAABpAAAAAAAAAFgAAAAAAAAAbwAAAAEAAABnAAAAAAAAAFsAAAAAAAAAdQAAAAIAAABqAAAABQAAAFoAAAAFAAAAeQAAAAEAAABxAAAAAAAAAGMAAAAAAAAAdwAAAAEAAAB0AAAAAQAAAGkAAAAAAAAAdwAAAAAAAABvAAAAAAAAAGEAAAAAAAAAcwAAAAAAAABuAAAAAAAAAGIAAAADAAAAawAAAAEAAABoAAAAAwAAAGAAAAADAAAAeQAAAAAAAAB0AAAAAAAAAGcAAAAFAAAAeAAAAAEAAAB3AAAAAAAAAG8AAAAAAAAAcAAAAAEAAABzAAAAAAAAAG4AAAAAAAAAdQAAAAEAAABxAAAABQAAAGkAAAAFAAAAdgAAAAEAAAB5AAAAAAAAAHQAAAAAAAAAcgAAAAEAAAB4AAAAAQAAAHcAAAAAAAAAcgAAAAAAAABwAAAAAAAAAGsAAAAAAAAAZAAAAAAAAABmAAAAAAAAAGUAAAADAAAAUwAAAAEAAABXAAAAAwAAAFUAAAADAAAAdgAAAAAAAAB4AAAAAAAAAHMAAAAFAAAAbAAAAAEAAAByAAAAAAAAAHAAAAAAAAAAXAAAAAEAAABkAAAAAAAAAGYAAAAAAAAAdQAAAAAAAAB5AAAABQAAAHcAAAAFAAAAbQAAAAEAAAB2AAAAAAAAAHgAAAAAAAAAXwAAAAEAAABsAAAAAQAAAHIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAGAAAAAgAAAAUAAAABAAAABAAAAAAAAAAAAAAABQAAAAMAAAABAAAABgAAAAQAAAACAAAAAAAAAH6iBfbytuk/Gq6akm/58z/Xrm0Liez0P5doSdOpSwRAWs602ULg8D/dT7Rcbo/1v1N1RQHFNOM/g9Snx7HW3L8HWsP8Q3jfP6VwOLosutk/9rjk1YQcxj+gnmKMsNn6P/HDeuPFY+M/YHwDjqKhB0Ci19/fCVrbP4UxKkDWOP6/pvljWa09tL9wi7wrQXjnv/Z6yLImkM2/3yTlOzY14D+m+WNZrT20PzwKVQnrQwNA9nrIsiaQzT/g40rFrRQFwPa45NWEHMa/kbslHEZq97/xw3rjxWPjv4cLC2SMBci/otff3wla27+rKF5oIAv0P1N1RQHFNOO/iDJPGyWHBUAHWsP8Q3jfvwQf/by16gXAfqIF9vK26b8XrO0Vh0r+v9eubQuJ7PS/BxLrA0ZZ479azrTZQuDwv1MK1EuItPw/yscgV9Z6FkAwHBR2WjQMQJNRzXsQ5vY/GlUHVJYKF0DONuFv2lMNQNCGZ28QJfk/0WUwoIL36D8ggDOMQuATQNqMOeAy/wZAWFYOYM+M2z/LWC4uH3oSQDE+LyTsMgRAkJzhRGWFGEDd4soovCQQQKqk0DJMEP8/rGmNdwOLBUAW2X/9xCbjP4hu3dcqJhNAzuYItRvdB0CgzW3zJW/sPxotm/Y2TxRAQAk9XmdDDEC1Kx9MKgT3P1M+NctcghZAFVqcLlb0C0Bgzd3sB2b2P77mZDPUWhZAFROHJpUGCEDAfma5CxXtPz1DWq/zYxRAmhYY5824F0DOuQKWSbAOQNCMqrvu3fs/L6DR22K2wT9nAAxPBU8RQGiN6mW43AFAZhu25b633D8c1YgmzowSQNM25BRKWARArGS08/lNxD+LFssHwmMRQLC5aNcxBgJABL9HT0WRF0CjCmJmOGEOQHsuaVzMP/s/TWJCaGGwBUCeu1PAPLzjP9nqN9DZOBNAKE4JcydbCkCGtbd1qjPzP8dgm9U8jhVAtPeKTkVwDkCeCLss5l37P401XMPLmBdAFd29VMVQDUBg0yA55h75Pz6odcYLCRdApBM4rBrkAkDyAVWgQxbRP4XDMnK20hFAymLlF7EmzD8GUgo9XBHlP3lbK7T9COc/k+OhPthhy7+YGEpnrOvCPzBFhLs15u4/epbqB6H4uz9IuuLF5svev6lzLKY31es/CaQ0envF5z8ZY0xlUADXv7zaz7HYEuI/CfbK1sn16T8uAQfWwxLWPzKn/YuFN94/5KdbC1AFu793fyCSnlfvPzK2y4doAMY/NRg5t1/X6b/shq4QJaHDP5yNIAKPOeI/vpn7BSE30r/X4YQrO6nrv78Ziv/Thto/DqJ1Y6+y5z9l51NaxFrlv8QlA65HOLS/86dxiEc96z+Hj0+LFjneP6LzBZ8LTc2/DaJ1Y6+y579l51NaxFrlP8QlA65HOLQ/8qdxiEc967+Jj0+LFjnev6LzBZ8LTc0/1qdbC1AFuz93fyCSnlfvvzK2y4doAMa/NRg5t1/X6T/vhq4QJaHDv5yNIAKPOeK/wJn7BSE30j/W4YQrO6nrP78Ziv/Thtq/CaQ0envF578XY0xlUADXP7zaz7HYEuK/CvbK1sn16b8rAQfWwxLWvzKn/YuFN96/zWLlF7EmzL8GUgo9XBHlv3lbK7T9COe/kOOhPthhyz+cGEpnrOvCvzBFhLs15u6/c5bqB6H4u79IuuLF5sveP6lzLKY31eu/AQAAAP////8HAAAA/////zEAAAD/////VwEAAP////9hCQAA/////6dBAAD/////kcsBAP/////3kAwA/////8H2VwAAAAAAAAAAAAAAAAACAAAA/////w4AAAD/////YgAAAP////+uAgAA/////8ISAAD/////ToMAAP////8ilwMA/////+4hGQD/////gu2vAAAAAAAAAAAAAAAAAAAAAAACAAAA//////////8BAAAAAwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////AgAAAP//////////AQAAAAAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD/////////////////////AQAAAP///////////////wIAAAD///////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP///////////////////////////////wIAAAD///////////////8BAAAA/////////////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAABAAAA//////////8CAAAA//////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAAAQAAAP//////////AgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAACAAAAAAAAAAIAAAABAAAAAQAAAAIAAAACAAAAAAAAAAUAAAAFAAAAAAAAAAIAAAACAAAAAwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAgAAAAEAAAACAAAAAgAAAAIAAAAAAAAABQAAAAYAAAAAAAAAAgAAAAIAAAADAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAAAAAACAAAAAQAAAAMAAAACAAAAAgAAAAAAAAAFAAAABwAAAAAAAAACAAAAAgAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAACAAAAAAAAAAIAAAABAAAABAAAAAIAAAACAAAAAAAAAAUAAAAIAAAAAAAAAAIAAAACAAAAAwAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAIAAAAAAAAAAgAAAAEAAAAAAAAAAgAAAAIAAAAAAAAABQAAAAkAAAAAAAAAAgAAAAIAAAADAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAgAAAAIAAAAAAAAAAwAAAA4AAAACAAAAAAAAAAIAAAADAAAAAAAAAAAAAAACAAAAAgAAAAMAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAACAAAAAgAAAAAAAAADAAAACgAAAAIAAAAAAAAAAgAAAAMAAAABAAAAAAAAAAIAAAACAAAAAwAAAAcAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAIAAAACAAAAAAAAAAMAAAALAAAAAgAAAAAAAAACAAAAAwAAAAIAAAAAAAAAAgAAAAIAAAADAAAACAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAgAAAAIAAAAAAAAAAwAAAAwAAAACAAAAAAAAAAIAAAADAAAAAwAAAAAAAAACAAAAAgAAAAMAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAACAAAAAgAAAAAAAAADAAAADQAAAAIAAAAAAAAAAgAAAAMAAAAEAAAAAAAAAAIAAAACAAAAAwAAAAoAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAIAAAACAAAAAAAAAAMAAAAGAAAAAgAAAAAAAAACAAAAAwAAAA8AAAAAAAAAAgAAAAIAAAADAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAIAAAAAAAAAAwAAAAcAAAACAAAAAAAAAAIAAAADAAAAEAAAAAAAAAACAAAAAgAAAAMAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAcAAAACAAAAAgAAAAAAAAADAAAACAAAAAIAAAAAAAAAAgAAAAMAAAARAAAAAAAAAAIAAAACAAAAAwAAAA0AAAAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAACAAAAAAAAAAMAAAAJAAAAAgAAAAAAAAACAAAAAwAAABIAAAAAAAAAAgAAAAIAAAADAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAgAAAAIAAAAAAAAAAwAAAAUAAAACAAAAAAAAAAIAAAADAAAAEwAAAAAAAAACAAAAAgAAAAMAAAAPAAAAAAAAAAAAAAAAAAAAAAAAABAAAAACAAAAAAAAAAIAAAABAAAAEwAAAAIAAAACAAAAAAAAAAUAAAAKAAAAAAAAAAIAAAACAAAAAwAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAIAAAAAAAAAAgAAAAEAAAAPAAAAAgAAAAIAAAAAAAAABQAAAAsAAAAAAAAAAgAAAAIAAAADAAAAEQAAAAAAAAAAAAAAAAAAAAAAAAASAAAAAgAAAAAAAAACAAAAAQAAABAAAAACAAAAAgAAAAAAAAAFAAAADAAAAAAAAAACAAAAAgAAAAMAAAASAAAAAAAAAAAAAAAAAAAAAAAAABMAAAACAAAAAAAAAAIAAAABAAAAEQAAAAIAAAACAAAAAAAAAAUAAAANAAAAAAAAAAIAAAACAAAAAwAAABMAAAAAAAAAAAAAAAAAAAAAAAAADwAAAAIAAAAAAAAAAgAAAAEAAAASAAAAAgAAAAIAAAAAAAAABQAAAA4AAAAAAAAAAgAAAAIAAAADAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAAAAAAAAAAAAAIAAAABAAAAAAAAAAEAAAACAAAAAQAAAAAAAAACAAAAAAAAAAUAAAAEAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAQAAAAAAAAABQAAAAAAAAACAAAAAQAAAAAAAAABAAAAAgAAAAAAAAAAAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAABAAAAAAAAAAIAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAEAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAQAAAAAAAAABQAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAEAAAAAAAAAAAEAAAAAAQAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAA6B6FaUp9QQTPXMuL4myJBraiDfBwx9UBYJseitzTIQOL5if9jqZtAnXX+Z+ycb0C3pucbhRBCQG8wJBYqpRRAlWbDCzCY5z/eFWBUEve6P/+qo4Q50Y4/D9YM3iCcYT8fcA2QJSA0P4ADxu0qAAc/BNcGolVJ2j5d9FACqwquPh9z7MthtI9CSUSYJke/YUJQ/64OyjU0Qpi0+HCmFQdCm3GfIVdh2kHsJ11kAyauQYC3UDFJOoFBSJsFV1OwU0FK5fcxX4AmQWhy/zZIt/lACqaCPsBjzUDbdUNIScugQMYQlVJ4MXNANiuq8GTvRUDxTXnulxEZQFZ8QX5kpuw/qmG/JwYFlEAluh3Q6DB+QKn4vyNq0GZAKOXekas+UUB8xabXXhI6QG63C2pLtSNAdDBtyNfLDUDyOcu67ID2P0rCMvRXAeE/Ki2TSVyzyT9Dk+8Sz2uzP5J+w5ARWp0/NQAoOiMuhj9YnP+RyMJwPxgW7TvQVFk/KgsLYF0kQz9g5dAC6IwzQcgHPVvDex1B1XjppodHBkHJq3OMM9fwQNvcmJ7wddlAInGPpQs/w0BRobq5EBmtQJZ2ai7n+ZVAtv2G5E+bgECG+gIfKBlpQK5f8jdI91JAL39sL/WpPEB8rGxhDqklQK6yUf43XhBAxL9y/tK8+D86XyZpgrHiPwAAAAD/////AAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAP////8AAAAAAAAAAAAAAAABAAAAAAAAAAAAAAD/////AAAAAAAAAAABAAAAAQAAAAAAAAAAAAAA/////wAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAP////8FAAAABQAAAAAAAAAAAAAAAAAAAAAAAAD/////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////////////////////////////wAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////////////////////////////8AAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAEAAAAAAAAABQAAAAEAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAQAAAAAAAQABAAABAQAAAAAAAQAAAAEAAAABAAEAAAAAAAAAAAAAAAAAAAAAquJYWJZl+D9jaeZNtj/zPwwdI9KqaeO/qGefXwdHdz+q4lhYlmX4P+OrlPMN3PI/DB0j0qpp47+7SQLV4VIEQKriWFiWZfg/r2kma3tz8T82eQmLqNIGwMRIWXMqSvo/fcCszPux9j+jara6ozTwP6hnn18HR3c/MSoKLequ8r+SabgA2nj0P7jBLbDOHO8/1Ym/ICfH4T+6lxjvlFXHv73m373LRPU/0vXyDVxo7T+ToKRHJXMAQF/33578aPE/pAyy64tD9T8+U/hCvyruPwxv8Y7YYwLAuXYr8NAiCEB4+LDK0Sn0P1Qeuy4j+eo/OMx50n7K7L+TrGB/nyf8v5ehC2fbYPM/aXMKexiT6z8mFRIMjg/zP7yUVwGGBNw/E6opHERf8z/z0wR2g9DqPw4pBpcOhvu/NbA29uWAA8DMaTExyXzyP02biiQ+Ruk/S8jz2/FKBEB1pzZnpbb9P7pQU4wLfPI//7ZcQXeG6D9CqEQvAYoIwDB2VB6sSgRAVyv8H5We8T+EHWF8XNPmPzB2wT8Nrrg/SEi+cX+w4L8of+GtdSDxP1sjk5AdouU/6ZjOVru13r8K0obqI6bxvwVbdNXyhfA/w5GG024n5z+rwmtMzP8BwLw9pSX49QXABe/2uQxP8D+b6wCzCvXkP7uGT87fK+Q/pz/JWw4coj+qoBf2J0nwP/yE3PUo0+I/vFJeHcaC+D96luSIqvntP/bf8sHUYu8/gZNN41mL4z9bhOqVOF4FwO6lmAh1hQhAbCVxbdhk7z+1C8NdDcfiPwG36x/0OQBAx0WJ76c2+D9nlSHXANfuP2HlfZ3gqOE/EwnVlVPg9r96+oHzEH//v5bXzdT1Auw/DM3GwLsA4D9p/8uoKcr+v+U9x5DQVAPAehjSdghb7D9sc1IetODgP8MVwwB1pu6/azPk6OGe978W8t/TUc3rP+0QMvYfP+A/RsG/QpSE8D+l3uwScxzgPwQaifgujuw/k1Vti1I43z8MAwLnSh0GQH5nYnwwZgJAiGUzWC5s6j8WyyI/BbLgPw4iUapGeQJAB3W+imnp/j9BLWR4ssrpP2t+gG5Pstk/cpBsfm6DCMCOpU9dOZsFQEv8nFypHeo/ehJ6i+6S2D9jqlGEmarLv7STC5TRiOa/bC+x8WZD6D9H3yUkWpDZP8gZvmCMuQLAreY19/eRBsCoPOc8UzzpP6KI/QV+y9g/t/MoboyWzT+Hv5q3Zu3Mvy2xROCT4uY/9gQitMMg1T9abAqhWMDkv1oLTavoUfG/PMUJP9CD5j+fHRX3t6fSPz7W2gk6bvs/WRnuHwqN9D8YFturGCTmP1EZczv0b9I/5t4exabB5D/1ESLh5fTEP9X2z6SYweQ/6lv3I2zT0D9zkRGNUNMAQKoSvc4EIfs/Xggt8wQI5T+mJHHg/w/SP4lhT/9t8vQ/DrZ/DbwH7D+XlhbYZrjkP34LIpFt6c4/lwfp8fLX9L+j96CTTf76v3WdNhEv9uM/d8c3o4lV0D/vFdCHVcsFwAHeDq0F1QhApbYqcZiN5D9KoilqByXLPwX0/diA0vq/0fo0GxnxAMBbaTkvlCzjP/RrFrWXrMs/UYTrky7jA0DB9f4FiZYAQEGAk/3QzeE/r/TeqE8t0D/OqjlsnPbvvz8RKU8JOfW/smSEbK/O4T8MzuyPm3DDP/rFtctq9gZAfb1EVEaSA0Dts5dVInnhP18SFMc79MM/7y34cw6LAMDFrRJsZO0DwC2KLvLSYuA/hx5wcUHewz+49SnK/4ruPyeS0PX9a+E/ZxaaLvvZ3z8WPu5T2QS8Pygo4RIvMqa/BJ0Kqsd0279cKW4ay8jdP3b05bmZ364/10/qtdxk2r+Bcz6CDMvpv54qOw+Amdw/qLV71pW7sT/YKc80nIPUP8OfIaBJ77G/LyTuD1un2z+diYu8efWzP1wU7ACkfwjAZroyPL1yBkAmv3lKJJbbPysKSE4W+p0/dIgqY79TA8ATLTOQ3tsGwJ2zweD/Xdg/XO/jXeFUaL8VW2qLFKfov1cA9Aa6XfK/tIa7YGgI2T+f3hu/sxqPv2nXdPpf3Pc/jkw8Jbda8j+tT/z8tGPVP1yBHpJd35k/KYvYOy1s8j/yz+kCQjPrP9+agH7x59g/PZfJ9aBhpr/rDKzvYBb+PwtkiaGCt/c/vb1mVr+f1T/JIHwHc8Govw7aeF6+9vG/Xv7kD6fp979isYioQYHVP7AIQZuSFrG/3z1AdUTnAUDN3XY9O7f9P0AdQ9ljYNQ/dJANJPTOrb8kLECUiiPlP4yF7UgmStA/9xGmXxCG1T9qZzix4W2zv2SGJRJVrPe/Fh9a2M/B/b8IexzFCoPSP9y1QFD2bLe/Q86cWLJe/b+mOOfYm78BwOTjkPAGE9E/8aPCUKu/ub9pPZyLCiUGwBA7Mev/BQlALOmrlRi+0j+AMJ/dKULBv7iLtL6a6QRAEMDV/yajAUDa62dE3crJP1P70RgBUbq/38hVnR6esT/s1tG10Z/Ov/zLwalHPss/dTS9NKTXx78nMcRzCIEHQAabxDsAmQRA0tyLK3gSyT+Aui7nOhDGv5Gs58z3WgHATN3forJuBMCAui7nOhDGP9Lciyt4Esm/WAJyHQ4c7z8UP5HFIs3iP3U0vTSk18c//MvBqUc+y7+cvv8HLg/Kvy1I/mHsI+K/U/vRGAFRuj/a62dE3crJv8p+WV8KlQjAuQ/nOP43B0CAMJ/dKULBPyzpq5UYvtK/ZoU+VoLh4L9etLlRUfvtv/GjwlCrv7k/5OOQ8AYT0b9DfT9FhufXPwUX8hJp+4u/3LVAUPZstz8IexzFCoPSv9+L609E5fQ/q9Fz7X2J7T9qZzix4W2zP/cRpl8QhtW/vtNilqGX+j8MOy7QJoL0P3SQDST0zq0/QB1D2WNg1L8IIjSvGNkDwGB8Jou2GAfAsAhBm5IWsT9isYioQYHVvyS9D3zb6uy/gnwRa7uM9L/JIHwHc8GoP729Zla/n9W/CsAHJZwmAEDEW6OYT1r6Pz2XyfWgYaY/35qAfvHn2L83Tdy4lS30vxf2/gZ0jPq/XIEekl3fmb+tT/z8tGPVvybPr2zJ1/+/K7mJ0ypVAsCf3hu/sxqPPwCGu2BoCNm/5oITrpZn+r+UDUyDP+n/v1zv413hVGg/nbPB4P9d2L9MlmkxNvgCQMtZlKE85v8/KwpIThb6nb8mv3lKJJbbv8+SZsTvOOc/pQCIIOYw0j+diYu8efWzvy8k7g9bp9u/kxYDa+pKtD9XlYvA8HnVv6i1e9aVu7G/nio7D4CZ3L/WR6rNh5EGwCkgQweBkghAdvTluZnfrr9cKW4ay8jdvxbjhr1f1QVAR5C0MzivAkAWPu5T2QS8v2cWmi772d+/cKj4lzLJCEBx2QJfYrMFQIcecHFB3sO/LYou8tJi4L+jr7lhO38BwIcI0Nb7xgTAXxIUxzv0w7/ts5dVInnhv0T+l8DZLfE/MP3FoFvS5D8MzuyPm3DDv7JkhGyvzuG/tzhzRIRc0b9Ovv3/0z7mv6/03qhPLdC/m4CT/dDN4b9dwjU5VCQBQBBJX1ntCv0/9GsWtZesy79baTkvlCzjv1mjYgEz++S/oW6KnOQW8b9KoilqByXLv6W2KnGYjeS/SmaKz3Vx9z+BZB5yxGHwP3fHN6OJVdC/dZ02ES/2478PuaBjLrXaP4/JU81pPaO/fgsikW3pzr+XlhbYZrjkv4tSn7YDbP0/f2LnFKlF9z+mJHHg/w/Sv14ILfMECOW/mfg4qYhR/b+OP+RQDCACwOpb9yNs09C/1fbPpJjB5L9pN2WOVZ3wv3hHy9nxIve/URlzO/Rv0r8YFturGCTmv1d1/KKR8QPA8gsy9qzSB8CfHRX3t6fSvzzFCT/Qg+a/EYStnrzV9r/2QJqI7Lb9v/YEIrTDINW/LbFE4JPi5r/7kQEs5fEDQHunnf4GeQBAooj9BX7L2L+oPOc8Uzzpv+ydYY2SSAfAL4HK6CRTB0BH3yUkWpDZv2wvsfFmQ+i/Ik0Yzruh6T8fM3LoGoDUP3oSeovukti/S/ycXKkd6r9rEv+7UWcHQCRIQe/GfwNAa36Abk+y2b9BLWR4ssrpv9KT87qa0bM/FTyktw823L8WyyI/BbLgv4hlM1gubOq/DizMp9Ki6r8b5ckdjVrzv5NVbYtSON+/BBqJ+C6O7L/dUBFqgyXYv00Wh18r7+q/7RAy9h8/4L8W8t/TUc3rv4RM5DKx3wDAfvWIj94aBcBsc1IetODgv3oY0nYIW+y/oGcTFF54AUDkJqS/FKX6PwzNxsC7AOC/ltfN1PUC7L+5Wrz/zHnzP6688w2rNOc/YeV9neCo4b9nlSHXANfuvw9RsxKjY/s/1V8GteXE8j+1C8NdDcfiv2wlcW3YZO+/IOywaA7Q8b9bFP+4Tg36v4GTTeNZi+O/9t/ywdRi77+tRc3yFR7eP2bkcHXJkLO//ITc9SjT4r+qoBf2J0nwv2YHKoswwfm/iQcLspCjAcCb6wCzCvXkvwXv9rkMT/C/YkuwYAMXBMApCNUai9kIwMORhtNuJ+e/BVt01fKF8L+ZqWEfvIjsP6h693QZYNk/WyOTkB2i5b8of+GtdSDxvwpaaulDSwVADMQAX+lOAECEHWF8XNPmv1cr/B+VnvG/XyFG6opcCMD/mtR32/UEQP+2XEF3hui/ulBTjAt88r/imfCfRP+yP9zbvtc8XeO/TZuKJD5G6b/MaTExyXzyvxiTQeElXOO/rbJRQVGN9L/z0wR2g9DqvxOqKRxEX/O/FDGCEei99j9x8zV4VYTmP2lzCnsYk+u/l6ELZ9tg878pRXacaDT/v3k6GZRqoQXAVB67LiP56r94+LDK0Sn0vwO6pZ9b7wFAvK0nKVcc9j8+U/hCvyruv6QMsuuLQ/W/FPhKFYv46j8MyxaDTOW/v9L18g1caO2/vebfvctE9b/7GD8ZrF3xv3gx1AR9bQDAuMEtsM4c77+SabgA2nj0v5xKFIwxsATArKNSBaKsB0Cjara6ozTwv33ArMz7sfa/dF2U0FcWCcDxL357DJX/P69pJmt7c/G/quJYWJZl+L/YntVJlnrSP4sRLzXM+fe/46uU8w3c8r+q4lhYlmX4v85lu5+QRwRAsI0H/WU8479jaeZNtj/zv6riWFiWZfi/sI0H/WU847/OZbufkEcEQHAoPUBrnss/9exKzDtFtT88wM8kax+gP9OqeKeAYog/MW0ItiZvcj+ph+smvt5bP2lCaV5dEUU/StaUmQDaLz+kK9y22BMYP0O3whZuMwI/IIbgZGWE6z7UkjYaEM3UPuezxwa9cr8+LybxRMnFpz6E1N8DbPiRPsYjySMvK3s+//////8fAAj//////zMQCP////9/MiAI/////28yMAj/////YzJACP///z9iMlAI////N2IyYAj///8zYjJwCP//vzNiMoAI//+rM2IykAj/f6szYjKgCP8PqzNiMrAI/wOrM2IywAi/A6szYjLQCJ8DqzNiMuAImQOrM2Iy8Aj//////z8PCP//////Kx8I/////38pLwj/////Pyk/CP////85KU8I////PzgpXwj///8POClvCP///w44KX8I//8fDjgpjwj//w8OOCmfCP9/DQ44Ka8I/w8NDjgpvwj/DQ0OOCnPCP8MDQ44Kd8IxwwNDjgp7wjEDA0OOCn/CAcAAAAHAAAAAQAAAAIAAAAEAAAAAwAAAAAAAAAAAAAABwAAAAMAAAABAAAAAgAAAAUAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAAAAAACAAAAAQAAAAMAAAAOAAAABgAAAAsAAAACAAAABwAAAAEAAAAYAAAABQAAAAoAAAABAAAABgAAAAAAAAAmAAAABwAAAAwAAAADAAAACAAAAAIAAAAxAAAACQAAAA4AAAAAAAAABQAAAAQAAAA6AAAACAAAAA0AAAAEAAAACQAAAAMAAAA/AAAACwAAAAYAAAAPAAAACgAAABAAAABIAAAADAAAAAcAAAAQAAAACwAAABEAAABTAAAACgAAAAUAAAATAAAADgAAAA8AAABhAAAADQAAAAgAAAARAAAADAAAABIAAABrAAAADgAAAAkAAAASAAAADQAAABMAAAB1AAAADwAAABMAAAARAAAAEgAAABAAAAAGAAAAAgAAAAMAAAAFAAAABAAAAAAAAAAAAAAAAAAAAAYAAAACAAAAAwAAAAEAAAAFAAAABAAAAAAAAAAAAAAABwAAAAUAAAADAAAABAAAAAEAAAAAAAAAAgAAAAAAAAACAAAAAwAAAAEAAAAFAAAABAAAAAYAAAAAAAAAAAAAABgtRFT7Ifk/GC1EVPsh+b8YLURU+yEJQBgtRFT7IQnAYWxnb3MuYwBoM05laWdoYm9yUm90YXRpb25zAGNvb3JkaWprLmMAX3VwQXA3Q2hlY2tlZABfdXBBcDdyQ2hlY2tlZABkaXJlY3RlZEVkZ2UuYwBkaXJlY3RlZEVkZ2VUb0JvdW5kYXJ5AGFkamFjZW50RmFjZURpclt0bXBGaWprLmZhY2VdW2ZpamsuZmFjZV0gPT0gS0kAZmFjZWlqay5jAF9mYWNlSWprUGVudFRvQ2VsbEJvdW5kYXJ5AGFkamFjZW50RmFjZURpcltjZW50ZXJJSksuZmFjZV1bZmFjZTJdID09IEtJAF9mYWNlSWprVG9DZWxsQm91bmRhcnkAaDNJbmRleC5jAGNvbXBhY3RDZWxscwBsYXRMbmdUb0NlbGwAY2VsbFRvQ2hpbGRQb3MAdmFsaWRhdGVDaGlsZFBvcwBsYXRMbmcuYwBjZWxsQXJlYVJhZHMyAHBvbHlnb24tPm5leHQgPT0gTlVMTABsaW5rZWRHZW8uYwBhZGROZXdMaW5rZWRQb2x5Z29uAG5leHQgIT0gTlVMTABsb29wICE9IE5VTEwAYWRkTmV3TGlua2VkTG9vcABwb2x5Z29uLT5maXJzdCA9PSBOVUxMAGFkZExpbmtlZExvb3AAY29vcmQgIT0gTlVMTABhZGRMaW5rZWRDb29yZABsb29wLT5maXJzdCA9PSBOVUxMAGlubmVyTG9vcHMgIT0gTlVMTABub3JtYWxpemVNdWx0aVBvbHlnb24AYmJveGVzICE9IE5VTEwAY2FuZGlkYXRlcyAhPSBOVUxMAGZpbmRQb2x5Z29uRm9ySG9sZQBjYW5kaWRhdGVCQm94ZXMgIT0gTlVMTAByZXZEaXIgIT0gSU5WQUxJRF9ESUdJVABsb2NhbGlqLmMAY2VsbFRvTG9jYWxJamsAYmFzZUNlbGwgIT0gb3JpZ2luQmFzZUNlbGwAIShvcmlnaW5PblBlbnQgJiYgaW5kZXhPblBlbnQpAGJhc2VDZWxsID09IG9yaWdpbkJhc2VDZWxsAGJhc2VDZWxsICE9IElOVkFMSURfQkFTRV9DRUxMAGxvY2FsSWprVG9DZWxsACFfaXNCYXNlQ2VsbFBlbnRhZ29uKGJhc2VDZWxsKQBiYXNlQ2VsbFJvdGF0aW9ucyA+PSAwAGdyaWRQYXRoQ2VsbHMAcG9seWZpbGwuYwBpdGVyU3RlcFBvbHlnb25Db21wYWN0ADAAdmVydGV4LmMAdmVydGV4Um90YXRpb25zAGNlbGxUb1ZlcnRleABncmFwaC0+YnVja2V0cyAhPSBOVUxMAHZlcnRleEdyYXBoLmMAaW5pdFZlcnRleEdyYXBoAG5vZGUgIT0gTlVMTABhZGRWZXJ0ZXhOb2Rl";var De=28640;function W(ke,Xe,vt,ot){Mr("Assertion failed: "+ws(ke)+", at: "+[Xe?ws(Xe):"unknown filename",vt,ot?ws(ot):"unknown function"])}function $(){return Ti.length}function te(ke,Xe,vt){Gi.set(Gi.subarray(Xe,Xe+vt),ke)}function _e(ke){return Q.___errno_location&&(Ki[Q.___errno_location()>>2]=ke),ke}function ve(ke){Mr("OOM")}function Re(ke){try{var Xe=new ArrayBuffer(ke);return Xe.byteLength!=ke?void 0:(new Int8Array(Xe).set(Ti),Vt(Xe),Ps(Xe),1)}catch{}}function Ce(ke){var Xe=$(),vt=16777216,ot=2147483648-vt;if(ke>ot)return!1;for(var o=16777216,Z=Math.max(Xe,o);Z<ke;)Z<=536870912?Z=Qn(2*Z,vt):Z=Math.min(Qn((3*Z+2147483648)/4,vt),ot);var Ut=Re(Z);return!!Ut}var Te=typeof atob=="function"?atob:function(ke){var Xe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",vt="",ot,o,Z,Ut,pr,br,Je,wt=0;ke=ke.replace(/[^A-Za-z0-9\+\/\=]/g,"");do Ut=Xe.indexOf(ke.charAt(wt++)),pr=Xe.indexOf(ke.charAt(wt++)),br=Xe.indexOf(ke.charAt(wt++)),Je=Xe.indexOf(ke.charAt(wt++)),ot=Ut<<2|pr>>4,o=(pr&15)<<4|br>>2,Z=(br&3)<<6|Je,vt=vt+String.fromCharCode(ot),br!==64&&(vt=vt+String.fromCharCode(o)),Je!==64&&(vt=vt+String.fromCharCode(Z));while(wt<ke.length);return vt};function je(ke){try{for(var Xe=Te(ke),vt=new Uint8Array(Xe.length),ot=0;ot<Xe.length;++ot)vt[ot]=Xe.charCodeAt(ot);return vt}catch{throw new Error("Converting base64 string to bytes failed.")}}function tt(ke){if(Hs(ke))return je(ke.slice(fn.length))}var Ke={Math,Int8Array,Int32Array,Uint8Array,Float32Array,Float64Array},_t={b:si,c:kn,d:W,e:_e,f:$,g:te,h:Ce,i:ve,o:De,p:Zs},Be=(function(ke,Xe,vt){"almost asm";var ot=new ke.Int8Array(vt),o=new ke.Int32Array(vt);new ke.Uint8Array(vt),new ke.Float32Array(vt);var Z=new ke.Float64Array(vt),Ut=Xe.o|0,pr=Xe.p|0,br=ke.Math.floor,Je=ke.Math.abs,wt=ke.Math.sqrt,Ft=ke.Math.pow,Jt=ke.Math.cos,Yt=ke.Math.sin,ai=ke.Math.tan,qt=ke.Math.acos,oa=ke.Math.asin,Xs=ke.Math.atan,Zi=ke.Math.atan2,Ln=ke.Math.ceil,Ji=ke.Math.imul,Ms=ke.Math.min,aa=ke.Math.max,Zr=ke.Math.clz32,Pt=Xe.b,ee=Xe.c,zt=Xe.d,To=Xe.e,Ys=Xe.f,Fn=Xe.g,Kl=Xe.h,Ks=Xe.i,H=28656;function Qr(l){return ot=new Int8Array(l),o=new Int32Array(l),Z=new Float64Array(l),vt=l,!0}function Jl(l){l=l|0;var a=0;return a=H,H=H+l|0,H=H+15&-16,a|0}function eA(){return H|0}function la(l){l=l|0,H=l}function tA(l,a){l=l|0,H=l}function rA(l,a){l=l|0,a=a|0;var u=0,f=0,g=0;return(l|0)<0?(a=2,a|0):(l|0)>13780509?(a=Xn(15,a)|0,a|0):(u=((l|0)<0)<<31>>31,g=Ir(l|0,u|0,3,0)|0,f=ee()|0,u=Dt(l|0,u|0,1,0)|0,u=Ir(g|0,f|0,u|0,ee()|0)|0,u=Dt(u|0,ee()|0,1,0)|0,l=ee()|0,o[a>>2]=u,o[a+4>>2]=l,a=0,a|0)}function ul(l,a,u,f){return l=l|0,a=a|0,u=u|0,f=f|0,Aa(l,a,u,f,0)|0}function Aa(l,a,u,f,g){l=l|0,a=a|0,u=u|0,f=f|0,g=g|0;var x=0,w=0,P=0,C=0,z=0;if(C=H,H=H+16|0,w=C,!(La(l,a,u,f,g)|0))return f=0,H=C,f|0;do if((u|0)>=0){if((u|0)>13780509){if(x=Xn(15,w)|0,x|0)break;P=w,w=o[P>>2]|0,P=o[P+4>>2]|0}else x=((u|0)<0)<<31>>31,z=Ir(u|0,x|0,3,0)|0,P=ee()|0,x=Dt(u|0,x|0,1,0)|0,x=Ir(z|0,P|0,x|0,ee()|0)|0,x=Dt(x|0,ee()|0,1,0)|0,P=ee()|0,o[w>>2]=x,o[w+4>>2]=P,w=x;if(vi(f|0,0,w<<3|0)|0,g|0){vi(g|0,0,w<<2|0)|0,x=Pn(l,a,u,f,g,w,P,0)|0;break}x=Bi(w,4)|0,x?(z=Pn(l,a,u,f,x,w,P,0)|0,kt(x),x=z):x=13}else x=2;while(!1);return z=x,H=C,z|0}function La(l,a,u,f,g){l=l|0,a=a|0,u=u|0,f=f|0,g=g|0;var x=0,w=0,P=0,C=0,z=0,F=0,K=0,ae=0,oe=0,le=0,xe=0;if(xe=H,H=H+16|0,oe=xe,le=xe+8|0,ae=oe,o[ae>>2]=l,o[ae+4>>2]=a,(u|0)<0)return le=2,H=xe,le|0;if(x=f,o[x>>2]=l,o[x+4>>2]=a,x=(g|0)!=0,x&&(o[g>>2]=0),wr(l,a)|0)return le=9,H=xe,le|0;o[le>>2]=0;e:do if((u|0)>=1)if(x)for(F=1,z=0,K=0,ae=1,x=l;;){if(!(z|K)){if(x=li(x,a,4,le,oe)|0,x|0)break e;if(a=oe,x=o[a>>2]|0,a=o[a+4>>2]|0,wr(x,a)|0){x=9;break e}}if(x=li(x,a,o[26800+(K<<2)>>2]|0,le,oe)|0,x|0)break e;if(a=oe,x=o[a>>2]|0,a=o[a+4>>2]|0,l=f+(F<<3)|0,o[l>>2]=x,o[l+4>>2]=a,o[g+(F<<2)>>2]=ae,l=z+1|0,w=(l|0)==(ae|0),P=K+1|0,C=(P|0)==6,wr(x,a)|0){x=9;break e}if(ae=ae+(C&w&1)|0,(ae|0)>(u|0)){x=0;break}else F=F+1|0,z=w?0:l,K=w?C?0:P:K}else for(F=1,z=0,K=0,ae=1,x=l;;){if(!(z|K)){if(x=li(x,a,4,le,oe)|0,x|0)break e;if(a=oe,x=o[a>>2]|0,a=o[a+4>>2]|0,wr(x,a)|0){x=9;break e}}if(x=li(x,a,o[26800+(K<<2)>>2]|0,le,oe)|0,x|0)break e;if(a=oe,x=o[a>>2]|0,a=o[a+4>>2]|0,l=f+(F<<3)|0,o[l>>2]=x,o[l+4>>2]=a,l=z+1|0,w=(l|0)==(ae|0),P=K+1|0,C=(P|0)==6,wr(x,a)|0){x=9;break e}if(ae=ae+(C&w&1)|0,(ae|0)>(u|0)){x=0;break}else F=F+1|0,z=w?0:l,K=w?C?0:P:K}else x=0;while(!1);return le=x,H=xe,le|0}function Pn(l,a,u,f,g,x,w,P){l=l|0,a=a|0,u=u|0,f=f|0,g=g|0,x=x|0,w=w|0,P=P|0;var C=0,z=0,F=0,K=0,ae=0,oe=0,le=0,xe=0,Ee=0,Ue=0;if(xe=H,H=H+16|0,oe=xe+8|0,le=xe,C=Jn(l|0,a|0,x|0,w|0)|0,F=ee()|0,K=f+(C<<3)|0,Ee=K,Ue=o[Ee>>2]|0,Ee=o[Ee+4>>2]|0,z=(Ue|0)==(l|0)&(Ee|0)==(a|0),!((Ue|0)==0&(Ee|0)==0|z))do C=Dt(C|0,F|0,1,0)|0,C=Wo(C|0,ee()|0,x|0,w|0)|0,F=ee()|0,K=f+(C<<3)|0,Ue=K,Ee=o[Ue>>2]|0,Ue=o[Ue+4>>2]|0,z=(Ee|0)==(l|0)&(Ue|0)==(a|0);while(!((Ee|0)==0&(Ue|0)==0|z));if(C=g+(C<<2)|0,z&&(o[C>>2]|0)<=(P|0)||(Ue=K,o[Ue>>2]=l,o[Ue+4>>2]=a,o[C>>2]=P,(P|0)>=(u|0)))return Ue=0,H=xe,Ue|0;switch(z=P+1|0,o[oe>>2]=0,C=li(l,a,2,oe,le)|0,C|0){case 9:{ae=9;break}case 0:{C=le,C=Pn(o[C>>2]|0,o[C+4>>2]|0,u,f,g,x,w,z)|0,C||(ae=9);break}}e:do if((ae|0)==9){switch(o[oe>>2]=0,C=li(l,a,3,oe,le)|0,C|0){case 9:break;case 0:{if(C=le,C=Pn(o[C>>2]|0,o[C+4>>2]|0,u,f,g,x,w,z)|0,C|0)break e;break}default:break e}switch(o[oe>>2]=0,C=li(l,a,1,oe,le)|0,C|0){case 9:break;case 0:{if(C=le,C=Pn(o[C>>2]|0,o[C+4>>2]|0,u,f,g,x,w,z)|0,C|0)break e;break}default:break e}switch(o[oe>>2]=0,C=li(l,a,5,oe,le)|0,C|0){case 9:break;case 0:{if(C=le,C=Pn(o[C>>2]|0,o[C+4>>2]|0,u,f,g,x,w,z)|0,C|0)break e;break}default:break e}switch(o[oe>>2]=0,C=li(l,a,4,oe,le)|0,C|0){case 9:break;case 0:{if(C=le,C=Pn(o[C>>2]|0,o[C+4>>2]|0,u,f,g,x,w,z)|0,C|0)break e;break}default:break e}switch(o[oe>>2]=0,C=li(l,a,6,oe,le)|0,C|0){case 9:break;case 0:{if(C=le,C=Pn(o[C>>2]|0,o[C+4>>2]|0,u,f,g,x,w,z)|0,C|0)break e;break}default:break e}return Ue=0,H=xe,Ue|0}while(!1);return Ue=C,H=xe,Ue|0}function li(l,a,u,f,g){l=l|0,a=a|0,u=u|0,f=f|0,g=g|0;var x=0,w=0,P=0,C=0,z=0,F=0,K=0,ae=0,oe=0,le=0;if(u>>>0>6)return g=1,g|0;if(K=(o[f>>2]|0)%6|0,o[f>>2]=K,(K|0)>0){x=0;do u=to(u)|0,x=x+1|0;while((x|0)<(o[f>>2]|0))}if(K=Ye(l|0,a|0,45)|0,ee()|0,F=K&127,F>>>0>121)return g=5,g|0;C=sn(l,a)|0,x=Ye(l|0,a|0,52)|0,ee()|0,x=x&15;e:do if(!x)z=8;else{for(;;){if(w=(15-x|0)*3|0,P=Ye(l|0,a|0,w|0)|0,ee()|0,P=P&7,(P|0)==7){a=5;break}if(le=(Wi(x)|0)==0,x=x+-1|0,ae=lt(7,0,w|0)|0,a=a&~(ee()|0),oe=lt(o[(le?432:16)+(P*28|0)+(u<<2)>>2]|0,0,w|0)|0,w=ee()|0,u=o[(le?640:224)+(P*28|0)+(u<<2)>>2]|0,l=oe|l&~ae,a=w|a,!u){u=0;break e}if(!x){z=8;break e}}return a|0}while(!1);(z|0)==8&&(le=o[848+(F*28|0)+(u<<2)>>2]|0,oe=lt(le|0,0,45)|0,l=oe|l,a=ee()|0|a&-1040385,u=o[4272+(F*28|0)+(u<<2)>>2]|0,(le&127|0)==127&&(le=lt(o[848+(F*28|0)+20>>2]|0,0,45)|0,a=ee()|0|a&-1040385,u=o[4272+(F*28|0)+20>>2]|0,l=jn(le|l,a)|0,a=ee()|0,o[f>>2]=(o[f>>2]|0)+1)),P=Ye(l|0,a|0,45)|0,ee()|0,P=P&127;e:do if(yr(P)|0){t:do if((sn(l,a)|0)==1){if((F|0)!=(P|0))if(Pi(P,o[7696+(F*28|0)>>2]|0)|0){l=_a(l,a)|0,w=1,a=ee()|0;break}else zt(27795,26864,533,26872);switch(C|0){case 3:{l=jn(l,a)|0,a=ee()|0,o[f>>2]=(o[f>>2]|0)+1,w=0;break t}case 5:{l=_a(l,a)|0,a=ee()|0,o[f>>2]=(o[f>>2]|0)+5,w=0;break t}case 0:return le=9,le|0;default:return le=1,le|0}}else w=0;while(!1);if((u|0)>0){x=0;do l=Ga(l,a)|0,a=ee()|0,x=x+1|0;while((x|0)!=(u|0))}if((F|0)!=(P|0)){if(!(Kt(P)|0)){if((w|0)!=0|(sn(l,a)|0)!=5)break;o[f>>2]=(o[f>>2]|0)+1;break}switch(K&127){case 8:case 118:break e}(sn(l,a)|0)!=3&&(o[f>>2]=(o[f>>2]|0)+1)}}else if((u|0)>0){x=0;do l=jn(l,a)|0,a=ee()|0,x=x+1|0;while((x|0)!=(u|0))}while(!1);return o[f>>2]=((o[f>>2]|0)+u|0)%6|0,le=g,o[le>>2]=l,o[le+4>>2]=a,le=0,le|0}function cl(l,a,u,f){return l=l|0,a=a|0,u=u|0,f=f|0,iA(l,a,u,f)|0?(vi(f|0,0,u*48|0)|0,f=ua(l,a,u,f)|0,f|0):(f=0,f|0)}function iA(l,a,u,f){l=l|0,a=a|0,u=u|0,f=f|0;var g=0,x=0,w=0,P=0,C=0,z=0,F=0,K=0,ae=0,oe=0,le=0;if(le=H,H=H+16|0,ae=le,oe=le+8|0,K=ae,o[K>>2]=l,o[K+4>>2]=a,(u|0)<0)return oe=2,H=le,oe|0;if(!u)return oe=f,o[oe>>2]=l,o[oe+4>>2]=a,oe=0,H=le,oe|0;o[oe>>2]=0;e:do if(wr(l,a)|0)l=9;else{g=0,K=l;do{if(l=li(K,a,4,oe,ae)|0,l|0)break e;if(a=ae,K=o[a>>2]|0,a=o[a+4>>2]|0,g=g+1|0,wr(K,a)|0){l=9;break e}}while((g|0)<(u|0));F=f,o[F>>2]=K,o[F+4>>2]=a,F=u+-1|0,z=0,l=1;do{if(g=26800+(z<<2)|0,(z|0)==5)for(w=o[g>>2]|0,x=0,g=l;;){if(l=ae,l=li(o[l>>2]|0,o[l+4>>2]|0,w,oe,ae)|0,l|0)break e;if((x|0)!=(F|0))if(C=ae,P=o[C>>2]|0,C=o[C+4>>2]|0,l=f+(g<<3)|0,o[l>>2]=P,o[l+4>>2]=C,!(wr(P,C)|0))l=g+1|0;else{l=9;break e}else l=g;if(x=x+1|0,(x|0)>=(u|0))break;g=l}else for(w=ae,C=o[g>>2]|0,P=0,g=l,x=o[w>>2]|0,w=o[w+4>>2]|0;;){if(l=li(x,w,C,oe,ae)|0,l|0)break e;if(w=ae,x=o[w>>2]|0,w=o[w+4>>2]|0,l=f+(g<<3)|0,o[l>>2]=x,o[l+4>>2]=w,l=g+1|0,wr(x,w)|0){l=9;break e}if(P=P+1|0,(P|0)>=(u|0))break;g=l}z=z+1|0}while(z>>>0<6);l=ae,l=(K|0)==(o[l>>2]|0)&&(a|0)==(o[l+4>>2]|0)?0:9}while(!1);return oe=l,H=le,oe|0}function ua(l,a,u,f){l=l|0,a=a|0,u=u|0,f=f|0;var g=0,x=0,w=0,P=0,C=0,z=0,F=0,K=0,ae=0;if(K=H,H=H+16|0,w=K,!u)return o[f>>2]=l,o[f+4>>2]=a,f=0,H=K,f|0;do if((u|0)>=0){if((u|0)>13780509){if(g=Xn(15,w)|0,g|0)break;x=w,g=o[x>>2]|0,x=o[x+4>>2]|0}else g=((u|0)<0)<<31>>31,F=Ir(u|0,g|0,3,0)|0,x=ee()|0,g=Dt(u|0,g|0,1,0)|0,g=Ir(F|0,x|0,g|0,ee()|0)|0,g=Dt(g|0,ee()|0,1,0)|0,x=ee()|0,F=w,o[F>>2]=g,o[F+4>>2]=x;if(z=Bi(g,8)|0,!z)g=13;else{if(F=Bi(g,4)|0,!F){kt(z),g=13;break}if(g=Pn(l,a,u,z,F,g,x,0)|0,g|0){kt(z),kt(F);break}if(a=o[w>>2]|0,w=o[w+4>>2]|0,(w|0)>0|(w|0)==0&a>>>0>0){g=0,P=0,C=0;do l=z+(P<<3)|0,x=o[l>>2]|0,l=o[l+4>>2]|0,!((x|0)==0&(l|0)==0)&&(o[F+(P<<2)>>2]|0)==(u|0)&&(ae=f+(g<<3)|0,o[ae>>2]=x,o[ae+4>>2]=l,g=g+1|0),P=Dt(P|0,C|0,1,0)|0,C=ee()|0;while((C|0)<(w|0)|(C|0)==(w|0)&P>>>0<a>>>0)}kt(z),kt(F),g=0}}else g=2;while(!1);return ae=g,H=K,ae|0}function Po(l,a,u,f){l=l|0,a=a|0,u=u|0,f=f|0;var g=0,x=0,w=0,P=0,C=0,z=0;for(P=H,H=H+16|0,x=P,w=P+8|0,g=(wr(l,a)|0)==0,g=g?1:2;;){if(o[w>>2]=0,z=(li(l,a,g,w,x)|0)==0,C=x,z&((o[C>>2]|0)==(u|0)?(o[C+4>>2]|0)==(f|0):0)){l=4;break}if(g=g+1|0,g>>>0>=7){g=7,l=4;break}}return(l|0)==4?(H=P,g|0):0}function nA(l,a,u,f){l=l|0,a=a|0,u=u|0,f=f|0;var g=0,x=0,w=0,P=0,C=0,z=0;if(P=H,H=H+48|0,g=P+16|0,x=P+8|0,w=P,u=lo(u)|0,u|0)return w=u,H=P,w|0;if(z=l,C=o[z+4>>2]|0,u=x,o[u>>2]=o[z>>2],o[u+4>>2]=C,Ls(x,g),u=ha(g,a,w)|0,!u){if(a=o[x>>2]|0,x=o[l+8>>2]|0,(x|0)>0){g=o[l+12>>2]|0,u=0;do a=(o[g+(u<<3)>>2]|0)+a|0,u=u+1|0;while((u|0)<(x|0))}u=w,g=o[u>>2]|0,u=o[u+4>>2]|0,x=((a|0)<0)<<31>>31,(u|0)<(x|0)|(u|0)==(x|0)&g>>>0<a>>>0?(u=w,o[u>>2]=a,o[u+4>>2]=x,u=x):a=g,C=Dt(a|0,u|0,12,0)|0,z=ee()|0,u=w,o[u>>2]=C,o[u+4>>2]=z,u=f,o[u>>2]=C,o[u+4>>2]=z,u=0}return z=u,H=P,z|0}function Js(l,a,u,f,g,x,w){l=l|0,a=a|0,u=u|0,f=f|0,g=g|0,x=x|0,w=w|0;var P=0,C=0,z=0,F=0,K=0,ae=0,oe=0,le=0,xe=0,Ee=0,Ue=0,Se=0,Pe=0,we=0,ct=0,St=0,Mt=0,jt=0,$t=0,ir=0,Rt=0,Et=0,At=0,at=0,dt=0,Nt=0,fr=0,xi=0,Ri=0;if(dt=H,H=H+64|0,Rt=dt+48|0,Et=dt+32|0,At=dt+24|0,ct=dt+8|0,St=dt,C=o[l>>2]|0,(C|0)<=0)return at=0,H=dt,at|0;for(Mt=l+4|0,jt=Rt+8|0,$t=Et+8|0,ir=ct+8|0,P=0,Pe=0;;){z=o[Mt>>2]|0,Se=z+(Pe<<4)|0,o[Rt>>2]=o[Se>>2],o[Rt+4>>2]=o[Se+4>>2],o[Rt+8>>2]=o[Se+8>>2],o[Rt+12>>2]=o[Se+12>>2],(Pe|0)==(C+-1|0)?(o[Et>>2]=o[z>>2],o[Et+4>>2]=o[z+4>>2],o[Et+8>>2]=o[z+8>>2],o[Et+12>>2]=o[z+12>>2]):(Se=z+(Pe+1<<4)|0,o[Et>>2]=o[Se>>2],o[Et+4>>2]=o[Se+4>>2],o[Et+8>>2]=o[Se+8>>2],o[Et+12>>2]=o[Se+12>>2]),C=rn(Rt,Et,f,At)|0;e:do if(C)z=0,P=C;else if(C=At,z=o[C>>2]|0,C=o[C+4>>2]|0,(C|0)>0|(C|0)==0&z>>>0>0){Ue=0,Se=0;t:for(;;){if(fr=1/(+(z>>>0)+4294967296*+(C|0)),Ri=+Z[Rt>>3],C=Lr(z|0,C|0,Ue|0,Se|0)|0,xi=+(C>>>0)+4294967296*+(ee()|0),Nt=+(Ue>>>0)+4294967296*+(Se|0),Z[ct>>3]=fr*(Ri*xi)+fr*(+Z[Et>>3]*Nt),Z[ir>>3]=fr*(+Z[jt>>3]*xi)+fr*(+Z[$t>>3]*Nt),C=gn(ct,f,St)|0,C|0){P=C;break}Ee=St,xe=o[Ee>>2]|0,Ee=o[Ee+4>>2]|0,ae=Jn(xe|0,Ee|0,a|0,u|0)|0,F=ee()|0,C=w+(ae<<3)|0,K=C,z=o[K>>2]|0,K=o[K+4>>2]|0;r:do if((z|0)==0&(K|0)==0)we=C,at=16;else for(oe=0,le=0;;){if((oe|0)>(u|0)|(oe|0)==(u|0)&le>>>0>a>>>0){P=1;break t}if((z|0)==(xe|0)&(K|0)==(Ee|0))break r;if(C=Dt(ae|0,F|0,1,0)|0,ae=Wo(C|0,ee()|0,a|0,u|0)|0,F=ee()|0,le=Dt(le|0,oe|0,1,0)|0,oe=ee()|0,C=w+(ae<<3)|0,K=C,z=o[K>>2]|0,K=o[K+4>>2]|0,(z|0)==0&(K|0)==0){we=C,at=16;break}}while(!1);if((at|0)==16&&(at=0,!((xe|0)==0&(Ee|0)==0))&&(le=we,o[le>>2]=xe,o[le+4>>2]=Ee,le=x+(o[g>>2]<<3)|0,o[le>>2]=xe,o[le+4>>2]=Ee,le=g,le=Dt(o[le>>2]|0,o[le+4>>2]|0,1,0)|0,xe=ee()|0,Ee=g,o[Ee>>2]=le,o[Ee+4>>2]=xe),Ue=Dt(Ue|0,Se|0,1,0)|0,Se=ee()|0,C=At,z=o[C>>2]|0,C=o[C+4>>2]|0,!((C|0)>(Se|0)|(C|0)==(Se|0)&z>>>0>Ue>>>0)){z=1;break e}}z=0}else z=1;while(!1);if(Pe=Pe+1|0,!z){at=21;break}if(C=o[l>>2]|0,(Pe|0)>=(C|0)){P=0,at=21;break}}return(at|0)==21?(H=dt,P|0):0}function hl(l,a,u,f){l=l|0,a=a|0,u=u|0,f=f|0;var g=0,x=0,w=0,P=0,C=0,z=0,F=0,K=0,ae=0,oe=0,le=0,xe=0,Ee=0,Ue=0,Se=0,Pe=0,we=0,ct=0,St=0,Mt=0,jt=0,$t=0,ir=0,Rt=0,Et=0,At=0,at=0,dt=0,Nt=0,fr=0,xi=0;if(xi=H,H=H+112|0,at=xi+80|0,C=xi+72|0,dt=xi,Nt=xi+56|0,g=lo(u)|0,g|0)return fr=g,H=xi,fr|0;if(z=l+8|0,fr=In((o[z>>2]<<5)+32|0)|0,!fr)return fr=13,H=xi,fr|0;if(El(l,fr),g=lo(u)|0,!g){if(Et=l,At=o[Et+4>>2]|0,g=C,o[g>>2]=o[Et>>2],o[g+4>>2]=At,Ls(C,at),g=ha(at,a,dt)|0,g)Et=0,At=0;else{if(g=o[C>>2]|0,x=o[z>>2]|0,(x|0)>0){w=o[l+12>>2]|0,u=0;do g=(o[w+(u<<3)>>2]|0)+g|0,u=u+1|0;while((u|0)!=(x|0));u=g}else u=g;g=dt,x=o[g>>2]|0,g=o[g+4>>2]|0,w=((u|0)<0)<<31>>31,(g|0)<(w|0)|(g|0)==(w|0)&x>>>0<u>>>0?(g=dt,o[g>>2]=u,o[g+4>>2]=w,g=w):u=x,Et=Dt(u|0,g|0,12,0)|0,At=ee()|0,g=dt,o[g>>2]=Et,o[g+4>>2]=At,g=0}if(!g){if(u=Bi(Et,8)|0,!u)return kt(fr),fr=13,H=xi,fr|0;if(P=Bi(Et,8)|0,!P)return kt(fr),kt(u),fr=13,H=xi,fr|0;ir=at,o[ir>>2]=0,o[ir+4>>2]=0,ir=l,Rt=o[ir+4>>2]|0,g=C,o[g>>2]=o[ir>>2],o[g+4>>2]=Rt,g=Js(C,Et,At,a,at,u,P)|0;e:do if(g)kt(u),kt(P),kt(fr);else{t:do if((o[z>>2]|0)>0){for(w=l+12|0,x=0;g=Js((o[w>>2]|0)+(x<<3)|0,Et,At,a,at,u,P)|0,x=x+1|0,!(g|0);)if((x|0)>=(o[z>>2]|0))break t;kt(u),kt(P),kt(fr);break e}while(!1);(At|0)>0|(At|0)==0&Et>>>0>0&&vi(P|0,0,Et<<3|0)|0,Rt=at,ir=o[Rt+4>>2]|0;t:do if((ir|0)>0|(ir|0)==0&(o[Rt>>2]|0)>>>0>0){Mt=u,jt=P,$t=u,ir=P,Rt=u,g=u,we=u,ct=P,St=P,u=P;r:for(;;){for(Ee=0,Ue=0,Se=0,Pe=0,x=0,w=0;;){P=dt,C=P+56|0;do o[P>>2]=0,P=P+4|0;while((P|0)<(C|0));if(a=Mt+(Ee<<3)|0,z=o[a>>2]|0,a=o[a+4>>2]|0,La(z,a,1,dt,0)|0){P=dt,C=P+56|0;do o[P>>2]=0,P=P+4|0;while((P|0)<(C|0));P=Bi(7,4)|0,P|0&&(Pn(z,a,1,dt,P,7,0,0)|0,kt(P))}for(xe=0;;){le=dt+(xe<<3)|0,oe=o[le>>2]|0,le=o[le+4>>2]|0;i:do if((oe|0)==0&(le|0)==0)P=x,C=w;else{if(F=Jn(oe|0,le|0,Et|0,At|0)|0,z=ee()|0,P=f+(F<<3)|0,a=P,C=o[a>>2]|0,a=o[a+4>>2]|0,!((C|0)==0&(a|0)==0)){K=0,ae=0;do{if((K|0)>(At|0)|(K|0)==(At|0)&ae>>>0>Et>>>0)break r;if((C|0)==(oe|0)&(a|0)==(le|0)){P=x,C=w;break i}P=Dt(F|0,z|0,1,0)|0,F=Wo(P|0,ee()|0,Et|0,At|0)|0,z=ee()|0,ae=Dt(ae|0,K|0,1,0)|0,K=ee()|0,P=f+(F<<3)|0,a=P,C=o[a>>2]|0,a=o[a+4>>2]|0}while(!((C|0)==0&(a|0)==0))}if((oe|0)==0&(le|0)==0){P=x,C=w;break}cs(oe,le,Nt)|0,Ao(l,fr,Nt)|0&&(ae=Dt(x|0,w|0,1,0)|0,w=ee()|0,K=P,o[K>>2]=oe,o[K+4>>2]=le,x=jt+(x<<3)|0,o[x>>2]=oe,o[x+4>>2]=le,x=ae),P=x,C=w}while(!1);if(xe=xe+1|0,xe>>>0>=7)break;x=P,w=C}if(Ee=Dt(Ee|0,Ue|0,1,0)|0,Ue=ee()|0,Se=Dt(Se|0,Pe|0,1,0)|0,Pe=ee()|0,w=at,x=o[w>>2]|0,w=o[w+4>>2]|0,(Pe|0)<(w|0)|(Pe|0)==(w|0)&Se>>>0<x>>>0)x=P,w=C;else break}if((w|0)>0|(w|0)==0&x>>>0>0){x=0,w=0;do Pe=Mt+(x<<3)|0,o[Pe>>2]=0,o[Pe+4>>2]=0,x=Dt(x|0,w|0,1,0)|0,w=ee()|0,Pe=at,Se=o[Pe+4>>2]|0;while((w|0)<(Se|0)|((w|0)==(Se|0)?x>>>0<(o[Pe>>2]|0)>>>0:0))}if(Pe=at,o[Pe>>2]=P,o[Pe+4>>2]=C,(C|0)>0|(C|0)==0&P>>>0>0)xe=u,Ee=St,Ue=Rt,Se=ct,Pe=jt,u=we,St=g,ct=$t,we=xe,g=Ee,Rt=ir,ir=Ue,$t=Se,jt=Mt,Mt=Pe;else break t}kt($t),kt(ir),kt(fr),g=1;break e}else g=P;while(!1);kt(fr),kt(u),kt(g),g=0}while(!1);return fr=g,H=xi,fr|0}}return kt(fr),fr=g,H=xi,fr|0}function ca(l,a,u){l=l|0,a=a|0,u=u|0;var f=0,g=0,x=0,w=0,P=0,C=0,z=0,F=0;if(F=H,H=H+176|0,C=F,(a|0)<1)return Sl(u,0,0),z=0,H=F,z|0;for(P=l,P=Ye(o[P>>2]|0,o[P+4>>2]|0,52)|0,ee()|0,Sl(u,(a|0)>6?a:6,P&15),P=0;f=l+(P<<3)|0,f=Bs(o[f>>2]|0,o[f+4>>2]|0,C)|0,!(f|0);){if(f=o[C>>2]|0,(f|0)>0){w=0;do x=C+8+(w<<4)|0,w=w+1|0,f=C+8+(((w|0)%(f|0)|0)<<4)|0,g=zl(u,f,x)|0,g?fs(u,g)|0:kl(u,x,f)|0,f=o[C>>2]|0;while((w|0)<(f|0))}if(P=P+1|0,(P|0)>=(a|0)){f=0,z=13;break}}return(z|0)==13?(H=F,f|0):(Cl(u),z=f,H=F,z|0)}function Es(l,a,u){l=l|0,a=a|0,u=u|0;var f=0,g=0,x=0,w=0;if(x=H,H=H+32|0,f=x,g=x+16|0,l=ca(l,a,g)|0,l|0)return u=l,H=x,u|0;if(o[u>>2]=0,o[u+4>>2]=0,o[u+8>>2]=0,l=Dl(g)|0,l|0)do{a=yA(u)|0;do Pl(a,l)|0,w=l+16|0,o[f>>2]=o[w>>2],o[f+4>>2]=o[w+4>>2],o[f+8>>2]=o[w+8>>2],o[f+12>>2]=o[w+12>>2],fs(g,l)|0,l=Pa(g,f)|0;while((l|0)!=0);l=Dl(g)|0}while((l|0)!=0);return Cl(g),l=Qa(u)|0,l?(tr(u),w=l,H=x,w|0):(w=0,H=x,w|0)}function yr(l){return l=l|0,l>>>0>121?(l=0,l|0):(l=o[7696+(l*28|0)+16>>2]|0,l|0)}function Kt(l){return l=l|0,(l|0)==4|(l|0)==117|0}function Fa(l){return l=l|0,o[11120+((o[l>>2]|0)*216|0)+((o[l+4>>2]|0)*72|0)+((o[l+8>>2]|0)*24|0)+(o[l+12>>2]<<3)>>2]|0}function su(l){return l=l|0,o[11120+((o[l>>2]|0)*216|0)+((o[l+4>>2]|0)*72|0)+((o[l+8>>2]|0)*24|0)+(o[l+12>>2]<<3)+4>>2]|0}function pl(l,a){l=l|0,a=a|0,l=7696+(l*28|0)|0,o[a>>2]=o[l>>2],o[a+4>>2]=o[l+4>>2],o[a+8>>2]=o[l+8>>2],o[a+12>>2]=o[l+12>>2]}function en(l,a){l=l|0,a=a|0;var u=0,f=0;if(a>>>0>20)return a=-1,a|0;do if((o[11120+(a*216|0)>>2]|0)!=(l|0))if((o[11120+(a*216|0)+8>>2]|0)!=(l|0))if((o[11120+(a*216|0)+16>>2]|0)!=(l|0))if((o[11120+(a*216|0)+24>>2]|0)!=(l|0))if((o[11120+(a*216|0)+32>>2]|0)!=(l|0))if((o[11120+(a*216|0)+40>>2]|0)!=(l|0))if((o[11120+(a*216|0)+48>>2]|0)!=(l|0))if((o[11120+(a*216|0)+56>>2]|0)!=(l|0))if((o[11120+(a*216|0)+64>>2]|0)!=(l|0))if((o[11120+(a*216|0)+72>>2]|0)!=(l|0))if((o[11120+(a*216|0)+80>>2]|0)!=(l|0))if((o[11120+(a*216|0)+88>>2]|0)!=(l|0))if((o[11120+(a*216|0)+96>>2]|0)!=(l|0))if((o[11120+(a*216|0)+104>>2]|0)!=(l|0))if((o[11120+(a*216|0)+112>>2]|0)!=(l|0))if((o[11120+(a*216|0)+120>>2]|0)!=(l|0))if((o[11120+(a*216|0)+128>>2]|0)!=(l|0))if((o[11120+(a*216|0)+136>>2]|0)==(l|0))l=2,u=1,f=2;else{if((o[11120+(a*216|0)+144>>2]|0)==(l|0)){l=0,u=2,f=0;break}if((o[11120+(a*216|0)+152>>2]|0)==(l|0)){l=0,u=2,f=1;break}if((o[11120+(a*216|0)+160>>2]|0)==(l|0)){l=0,u=2,f=2;break}if((o[11120+(a*216|0)+168>>2]|0)==(l|0)){l=1,u=2,f=0;break}if((o[11120+(a*216|0)+176>>2]|0)==(l|0)){l=1,u=2,f=1;break}if((o[11120+(a*216|0)+184>>2]|0)==(l|0)){l=1,u=2,f=2;break}if((o[11120+(a*216|0)+192>>2]|0)==(l|0)){l=2,u=2,f=0;break}if((o[11120+(a*216|0)+200>>2]|0)==(l|0)){l=2,u=2,f=1;break}if((o[11120+(a*216|0)+208>>2]|0)==(l|0)){l=2,u=2,f=2;break}else l=-1;return l|0}else l=2,u=1,f=1;else l=2,u=1,f=0;else l=1,u=1,f=2;else l=1,u=1,f=1;else l=1,u=1,f=0;else l=0,u=1,f=2;else l=0,u=1,f=1;else l=0,u=1,f=0;else l=2,u=0,f=2;else l=2,u=0,f=1;else l=2,u=0,f=0;else l=1,u=0,f=2;else l=1,u=0,f=1;else l=1,u=0,f=0;else l=0,u=0,f=2;else l=0,u=0,f=1;else l=0,u=0,f=0;while(!1);return a=o[11120+(a*216|0)+(u*72|0)+(l*24|0)+(f<<3)+4>>2]|0,a|0}function Pi(l,a){return l=l|0,a=a|0,(o[7696+(l*28|0)+20>>2]|0)==(a|0)?(a=1,a|0):(a=(o[7696+(l*28|0)+24>>2]|0)==(a|0),a|0)}function Cr(l,a){return l=l|0,a=a|0,o[848+(l*28|0)+(a<<2)>>2]|0}function Bt(l,a){return l=l|0,a=a|0,(o[848+(l*28|0)>>2]|0)==(a|0)?(a=0,a|0):(o[848+(l*28|0)+4>>2]|0)==(a|0)?(a=1,a|0):(o[848+(l*28|0)+8>>2]|0)==(a|0)?(a=2,a|0):(o[848+(l*28|0)+12>>2]|0)==(a|0)?(a=3,a|0):(o[848+(l*28|0)+16>>2]|0)==(a|0)?(a=4,a|0):(o[848+(l*28|0)+20>>2]|0)==(a|0)?(a=5,a|0):((o[848+(l*28|0)+24>>2]|0)==(a|0)?6:7)|0}function Er(){return 122}function Is(l){l=l|0;var a=0,u=0,f=0;a=0;do lt(a|0,0,45)|0,f=ee()|0|134225919,u=l+(a<<3)|0,o[u>>2]=-1,o[u+4>>2]=f,a=a+1|0;while((a|0)!=122);return 0}function Qi(l){l=l|0;var a=0,u=0,f=0;return f=+Z[l+16>>3],u=+Z[l+24>>3],a=f-u,+(f<u?a+6.283185307179586:a)}function tn(l){return l=l|0,+Z[l+16>>3]<+Z[l+24>>3]|0}function $i(l){return l=l|0,+(+Z[l>>3]-+Z[l+8>>3])}function Ss(l,a){l=l|0,a=a|0;var u=0,f=0,g=0;return u=+Z[a>>3],!(u>=+Z[l+8>>3])||!(u<=+Z[l>>3])?(a=0,a|0):(f=+Z[l+16>>3],u=+Z[l+24>>3],g=+Z[a+8>>3],a=g>=u,l=g<=f&1,f<u?a&&(l=1):a||(l=0),a=(l|0)!=0,a|0)}function Hn(l,a){l=l|0,a=a|0;var u=0,f=0,g=0,x=0,w=0,P=0,C=0,z=0,F=0;return+Z[l>>3]<+Z[a+8>>3]||+Z[l+8>>3]>+Z[a>>3]?(f=0,f|0):(x=+Z[l+16>>3],u=l+24|0,F=+Z[u>>3],w=x<F,f=a+16|0,z=+Z[f>>3],g=a+24|0,C=+Z[g>>3],P=z<C,a=F-z<C-x,l=w?P|a?1:2:0,a=P?w?1:a?2:1:0,x=+zi(x,l),x<+zi(+Z[g>>3],a)||(F=+zi(+Z[u>>3],l),F>+zi(+Z[f>>3],a))?(P=0,P|0):(P=1,P|0))}function Kr(l,a,u,f){l=l|0,a=a|0,u=u|0,f=f|0;var g=0,x=0,w=0,P=0,C=0;x=+Z[l+16>>3],C=+Z[l+24>>3],l=x<C,P=+Z[a+16>>3],w=+Z[a+24>>3],g=P<w,a=C-P<w-x,o[u>>2]=l?g|a?1:2:0,o[f>>2]=g?l?1:a?2:1:0}function Cs(l,a){l=l|0,a=a|0;var u=0,f=0,g=0,x=0,w=0,P=0,C=0,z=0,F=0;return+Z[l>>3]<+Z[a>>3]||+Z[l+8>>3]>+Z[a+8>>3]?(f=0,f|0):(f=l+16|0,C=+Z[f>>3],x=+Z[l+24>>3],w=C<x,u=a+16|0,F=+Z[u>>3],g=a+24|0,z=+Z[g>>3],P=F<z,a=x-F<z-C,l=w?P|a?1:2:0,a=P?w?1:a?2:1:0,x=+zi(x,l),x<=+zi(+Z[g>>3],a)?(F=+zi(+Z[f>>3],l),P=F>=+zi(+Z[u>>3],a),P|0):(P=0,P|0))}function On(l,a){l=l|0,a=a|0;var u=0,f=0,g=0,x=0,w=0,P=0;g=H,H=H+176|0,f=g,o[f>>2]=4,P=+Z[a>>3],Z[f+8>>3]=P,x=+Z[a+16>>3],Z[f+16>>3]=x,Z[f+24>>3]=P,P=+Z[a+24>>3],Z[f+32>>3]=P,w=+Z[a+8>>3],Z[f+40>>3]=w,Z[f+48>>3]=P,Z[f+56>>3]=w,Z[f+64>>3]=x,a=f+72|0,u=a+96|0;do o[a>>2]=0,a=a+4|0;while((a|0)<(u|0));Nn(l|0,f|0,168)|0,H=g}function ha(l,a,u){l=l|0,a=a|0,u=u|0;var f=0,g=0,x=0,w=0,P=0,C=0,z=0,F=0,K=0,ae=0,oe=0,le=0,xe=0,Ee=0;le=H,H=H+288|0,F=le+264|0,K=le+96|0,z=le,P=z,C=P+96|0;do o[P>>2]=0,P=P+4|0;while((P|0)<(C|0));return a=vl(a,z)|0,a|0?(oe=a,H=le,oe|0):(C=z,z=o[C>>2]|0,C=o[C+4>>2]|0,cs(z,C,F)|0,Bs(z,C,K)|0,w=+so(F,K+8|0),Z[F>>3]=+Z[l>>3],C=F+8|0,Z[C>>3]=+Z[l+16>>3],Z[K>>3]=+Z[l+8>>3],z=K+8|0,Z[z>>3]=+Z[l+24>>3],g=+so(F,K),Ee=+Z[C>>3]-+Z[z>>3],x=+Je(+Ee),xe=+Z[F>>3]-+Z[K>>3],f=+Je(+xe),!(Ee==0|xe==0)&&(Ee=+CA(+x,+f),Ee=+Ln(+(g*g/+tl(+(Ee/+tl(+x,+f)),3)/(w*(w*2.59807621135)*.8))),Z[Ut>>3]=Ee,ae=~~Ee>>>0,oe=+Je(Ee)>=1?Ee>0?~~+Ms(+br(Ee/4294967296),4294967295)>>>0:~~+Ln((Ee-+(~~Ee>>>0))/4294967296)>>>0:0,(o[Ut+4>>2]&2146435072|0)!=2146435072)?(K=(ae|0)==0&(oe|0)==0,a=u,o[a>>2]=K?1:ae,o[a+4>>2]=K?0:oe,a=0):a=1,oe=a,H=le,oe|0)}function rn(l,a,u,f){l=l|0,a=a|0,u=u|0,f=f|0;var g=0,x=0,w=0,P=0,C=0,z=0,F=0;z=H,H=H+288|0,w=z+264|0,P=z+96|0,C=z,g=C,x=g+96|0;do o[g>>2]=0,g=g+4|0;while((g|0)<(x|0));return u=vl(u,C)|0,u|0?(f=u,H=z,f|0):(u=C,g=o[u>>2]|0,u=o[u+4>>2]|0,cs(g,u,w)|0,Bs(g,u,P)|0,F=+so(w,P+8|0),F=+Ln(+(+so(l,a)/(F*2))),Z[Ut>>3]=F,u=~~F>>>0,g=+Je(F)>=1?F>0?~~+Ms(+br(F/4294967296),4294967295)>>>0:~~+Ln((F-+(~~F>>>0))/4294967296)>>>0:0,(o[Ut+4>>2]&2146435072|0)==2146435072?(f=1,H=z,f|0):(C=(u|0)==0&(g|0)==0,o[f>>2]=C?1:u,o[f+4>>2]=C?0:g,f=0,H=z,f|0))}function eo(l,a){l=l|0,a=+a;var u=0,f=0,g=0,x=0,w=0,P=0,C=0,z=0,F=0;x=l+16|0,w=+Z[x>>3],u=l+24|0,g=+Z[u>>3],f=w-g,f=w<g?f+6.283185307179586:f,z=+Z[l>>3],P=l+8|0,C=+Z[P>>3],F=z-C,f=(f*a-f)*.5,a=(F*a-F)*.5,z=z+a,Z[l>>3]=z>1.5707963267948966?1.5707963267948966:z,a=C-a,Z[P>>3]=a<-1.5707963267948966?-1.5707963267948966:a,a=w+f,a=a>3.141592653589793?a+-6.283185307179586:a,Z[x>>3]=a<-3.141592653589793?a+6.283185307179586:a,a=g-f,a=a>3.141592653589793?a+-6.283185307179586:a,Z[u>>3]=a<-3.141592653589793?a+6.283185307179586:a}function ls(l,a,u,f){l=l|0,a=a|0,u=u|0,f=f|0,o[l>>2]=a,o[l+4>>2]=u,o[l+8>>2]=f}function sA(l,a){l=l|0,a=a|0;var u=0,f=0,g=0,x=0,w=0,P=0,C=0,z=0,F=0,K=0,ae=0;K=a+8|0,o[K>>2]=0,C=+Z[l>>3],w=+Je(+C),z=+Z[l+8>>3],P=+Je(+z)*1.1547005383792515,w=w+P*.5,u=~~w,l=~~P,w=w-+(u|0),P=P-+(l|0);do if(w<.5)if(w<.3333333333333333)if(o[a>>2]=u,P<(w+1)*.5){o[a+4>>2]=l;break}else{l=l+1|0,o[a+4>>2]=l;break}else if(ae=1-w,l=(!(P<ae)&1)+l|0,o[a+4>>2]=l,ae<=P&P<w*2){u=u+1|0,o[a>>2]=u;break}else{o[a>>2]=u;break}else{if(!(w<.6666666666666666))if(u=u+1|0,o[a>>2]=u,P<w*.5){o[a+4>>2]=l;break}else{l=l+1|0,o[a+4>>2]=l;break}if(P<1-w){if(o[a+4>>2]=l,w*2+-1<P){o[a>>2]=u;break}}else l=l+1|0,o[a+4>>2]=l;u=u+1|0,o[a>>2]=u}while(!1);do if(C<0)if(l&1){F=(l+1|0)/2|0,F=Lr(u|0,((u|0)<0)<<31>>31|0,F|0,((F|0)<0)<<31>>31|0)|0,u=~~(+(u|0)-((+(F>>>0)+4294967296*+(ee()|0))*2+1)),o[a>>2]=u;break}else{F=(l|0)/2|0,F=Lr(u|0,((u|0)<0)<<31>>31|0,F|0,((F|0)<0)<<31>>31|0)|0,u=~~(+(u|0)-(+(F>>>0)+4294967296*+(ee()|0))*2),o[a>>2]=u;break}while(!1);F=a+4|0,z<0&&(u=u-((l<<1|1|0)/2|0)|0,o[a>>2]=u,l=0-l|0,o[F>>2]=l),f=l-u|0,(u|0)<0?(g=0-u|0,o[F>>2]=f,o[K>>2]=g,o[a>>2]=0,l=f,u=0):g=0,(l|0)<0&&(u=u-l|0,o[a>>2]=u,g=g-l|0,o[K>>2]=g,o[F>>2]=0,l=0),x=u-g|0,f=l-g|0,(g|0)<0&&(o[a>>2]=x,o[F>>2]=f,o[K>>2]=0,l=f,u=x,g=0),f=(l|0)<(u|0)?l:u,f=(g|0)<(f|0)?g:f,!((f|0)<=0)&&(o[a>>2]=u-f,o[F>>2]=l-f,o[K>>2]=g-f)}function gi(l){l=l|0;var a=0,u=0,f=0,g=0,x=0,w=0;a=o[l>>2]|0,w=l+4|0,u=o[w>>2]|0,(a|0)<0&&(u=u-a|0,o[w>>2]=u,x=l+8|0,o[x>>2]=(o[x>>2]|0)-a,o[l>>2]=0,a=0),(u|0)<0?(a=a-u|0,o[l>>2]=a,x=l+8|0,g=(o[x>>2]|0)-u|0,o[x>>2]=g,o[w>>2]=0,u=0):(g=l+8|0,x=g,g=o[g>>2]|0),(g|0)<0&&(a=a-g|0,o[l>>2]=a,u=u-g|0,o[w>>2]=u,o[x>>2]=0,g=0),f=(u|0)<(a|0)?u:a,f=(g|0)<(f|0)?g:f,!((f|0)<=0)&&(o[l>>2]=a-f,o[w>>2]=u-f,o[x>>2]=g-f)}function dn(l,a){l=l|0,a=a|0;var u=0,f=0;f=o[l+8>>2]|0,u=+((o[l+4>>2]|0)-f|0),Z[a>>3]=+((o[l>>2]|0)-f|0)-u*.5,Z[a+8>>3]=u*.8660254037844386}function rr(l,a,u){l=l|0,a=a|0,u=u|0,o[u>>2]=(o[a>>2]|0)+(o[l>>2]|0),o[u+4>>2]=(o[a+4>>2]|0)+(o[l+4>>2]|0),o[u+8>>2]=(o[a+8>>2]|0)+(o[l+8>>2]|0)}function Ds(l,a,u){l=l|0,a=a|0,u=u|0,o[u>>2]=(o[l>>2]|0)-(o[a>>2]|0),o[u+4>>2]=(o[l+4>>2]|0)-(o[a+4>>2]|0),o[u+8>>2]=(o[l+8>>2]|0)-(o[a+8>>2]|0)}function or(l,a){l=l|0,a=a|0;var u=0,f=0;u=Ji(o[l>>2]|0,a)|0,o[l>>2]=u,u=l+4|0,f=Ji(o[u>>2]|0,a)|0,o[u>>2]=f,l=l+8|0,a=Ji(o[l>>2]|0,a)|0,o[l>>2]=a}function Zt(l){l=l|0;var a=0,u=0,f=0,g=0,x=0,w=0,P=0;w=o[l>>2]|0,P=(w|0)<0,f=(o[l+4>>2]|0)-(P?w:0)|0,x=(f|0)<0,g=(x?0-f|0:0)+((o[l+8>>2]|0)-(P?w:0))|0,u=(g|0)<0,l=u?0:g,a=(x?0:f)-(u?g:0)|0,g=(P?0:w)-(x?f:0)-(u?g:0)|0,u=(a|0)<(g|0)?a:g,u=(l|0)<(u|0)?l:u,f=(u|0)>0,l=l-(f?u:0)|0,a=a-(f?u:0)|0;e:do switch(g-(f?u:0)|0){case 0:switch(a|0){case 0:return P=(l|0)==0?0:(l|0)==1?1:7,P|0;case 1:return P=(l|0)==0?2:(l|0)==1?3:7,P|0;default:break e}case 1:switch(a|0){case 0:return P=(l|0)==0?4:(l|0)==1?5:7,P|0;case 1:{if(!l)l=6;else break e;return l|0}default:break e}}while(!1);return P=7,P|0}function Mo(l){l=l|0;var a=0,u=0,f=0,g=0,x=0,w=0,P=0,C=0,z=0;if(C=l+8|0,w=o[C>>2]|0,P=(o[l>>2]|0)-w|0,z=l+4|0,w=(o[z>>2]|0)-w|0,P>>>0>715827881|w>>>0>715827881){if(f=(P|0)>0,g=2147483647-P|0,x=-2147483648-P|0,(f?(g|0)<(P|0):(x|0)>(P|0))||(u=P<<1,f?(2147483647-u|0)<(P|0):(-2147483648-u|0)>(P|0))||((w|0)>0?(2147483647-w|0)<(w|0):(-2147483648-w|0)>(w|0))||(a=P*3|0,u=w<<1,(f?(g|0)<(u|0):(x|0)>(u|0))||((P|0)>-1?(a|-2147483648|0)>=(w|0):(a^-2147483648|0)<(w|0))))return z=1,z|0}else u=w<<1,a=P*3|0;return f=Kn(+(a-w|0)*.14285714285714285)|0,o[l>>2]=f,g=Kn(+(u+P|0)*.14285714285714285)|0,o[z>>2]=g,o[C>>2]=0,u=(g|0)<(f|0),a=u?f:g,u=u?g:f,(u|0)<0&&(((u|0)==-2147483648||((a|0)>0?(2147483647-a|0)<(u|0):(-2147483648-a|0)>(u|0)))&&zt(27795,26892,354,26903),((a|0)>-1?(a|-2147483648|0)>=(u|0):(a^-2147483648|0)<(u|0))&&zt(27795,26892,354,26903)),a=g-f|0,(f|0)<0?(u=0-f|0,o[z>>2]=a,o[C>>2]=u,o[l>>2]=0,f=0):(a=g,u=0),(a|0)<0&&(f=f-a|0,o[l>>2]=f,u=u-a|0,o[C>>2]=u,o[z>>2]=0,a=0),x=f-u|0,g=a-u|0,(u|0)<0?(o[l>>2]=x,o[z>>2]=g,o[C>>2]=0,a=g,g=x,u=0):g=f,f=(a|0)<(g|0)?a:g,f=(u|0)<(f|0)?u:f,(f|0)<=0?(z=0,z|0):(o[l>>2]=g-f,o[z>>2]=a-f,o[C>>2]=u-f,z=0,z|0)}function ur(l){l=l|0;var a=0,u=0,f=0,g=0,x=0,w=0,P=0,C=0;if(w=l+8|0,g=o[w>>2]|0,x=(o[l>>2]|0)-g|0,P=l+4|0,g=(o[P>>2]|0)-g|0,x>>>0>715827881|g>>>0>715827881){if(u=(x|0)>0,(u?(2147483647-x|0)<(x|0):(-2147483648-x|0)>(x|0))||(a=x<<1,f=(g|0)>0,f?(2147483647-g|0)<(g|0):(-2147483648-g|0)>(g|0)))return P=1,P|0;if(C=g<<1,(f?(2147483647-C|0)<(g|0):(-2147483648-C|0)>(g|0))||(u?(2147483647-a|0)<(g|0):(-2147483648-a|0)>(g|0))||(u=g*3|0,(g|0)>-1?(u|-2147483648|0)>=(x|0):(u^-2147483648|0)<(x|0)))return C=1,C|0}else u=g*3|0,a=x<<1;return f=Kn(+(a+g|0)*.14285714285714285)|0,o[l>>2]=f,g=Kn(+(u-x|0)*.14285714285714285)|0,o[P>>2]=g,o[w>>2]=0,u=(g|0)<(f|0),a=u?f:g,u=u?g:f,(u|0)<0&&(((u|0)==-2147483648||((a|0)>0?(2147483647-a|0)<(u|0):(-2147483648-a|0)>(u|0)))&&zt(27795,26892,402,26917),((a|0)>-1?(a|-2147483648|0)>=(u|0):(a^-2147483648|0)<(u|0))&&zt(27795,26892,402,26917)),a=g-f|0,(f|0)<0?(u=0-f|0,o[P>>2]=a,o[w>>2]=u,o[l>>2]=0,f=0):(a=g,u=0),(a|0)<0&&(f=f-a|0,o[l>>2]=f,u=u-a|0,o[w>>2]=u,o[P>>2]=0,a=0),x=f-u|0,g=a-u|0,(u|0)<0?(o[l>>2]=x,o[P>>2]=g,o[w>>2]=0,a=g,g=x,u=0):g=f,f=(a|0)<(g|0)?a:g,f=(u|0)<(f|0)?u:f,(f|0)<=0?(C=0,C|0):(o[l>>2]=g-f,o[P>>2]=a-f,o[w>>2]=u-f,C=0,C|0)}function pa(l){l=l|0;var a=0,u=0,f=0,g=0,x=0,w=0,P=0;w=l+8|0,u=o[w>>2]|0,a=(o[l>>2]|0)-u|0,P=l+4|0,u=(o[P>>2]|0)-u|0,f=Kn(+((a*3|0)-u|0)*.14285714285714285)|0,o[l>>2]=f,a=Kn(+((u<<1)+a|0)*.14285714285714285)|0,o[P>>2]=a,o[w>>2]=0,u=a-f|0,(f|0)<0?(x=0-f|0,o[P>>2]=u,o[w>>2]=x,o[l>>2]=0,a=u,f=0,u=x):u=0,(a|0)<0&&(f=f-a|0,o[l>>2]=f,u=u-a|0,o[w>>2]=u,o[P>>2]=0,a=0),x=f-u|0,g=a-u|0,(u|0)<0?(o[l>>2]=x,o[P>>2]=g,o[w>>2]=0,a=g,g=x,u=0):g=f,f=(a|0)<(g|0)?a:g,f=(u|0)<(f|0)?u:f,!((f|0)<=0)&&(o[l>>2]=g-f,o[P>>2]=a-f,o[w>>2]=u-f)}function mn(l){l=l|0;var a=0,u=0,f=0,g=0,x=0,w=0,P=0;w=l+8|0,u=o[w>>2]|0,a=(o[l>>2]|0)-u|0,P=l+4|0,u=(o[P>>2]|0)-u|0,f=Kn(+((a<<1)+u|0)*.14285714285714285)|0,o[l>>2]=f,a=Kn(+((u*3|0)-a|0)*.14285714285714285)|0,o[P>>2]=a,o[w>>2]=0,u=a-f|0,(f|0)<0?(x=0-f|0,o[P>>2]=u,o[w>>2]=x,o[l>>2]=0,a=u,f=0,u=x):u=0,(a|0)<0&&(f=f-a|0,o[l>>2]=f,u=u-a|0,o[w>>2]=u,o[P>>2]=0,a=0),x=f-u|0,g=a-u|0,(u|0)<0?(o[l>>2]=x,o[P>>2]=g,o[w>>2]=0,a=g,g=x,u=0):g=f,f=(a|0)<(g|0)?a:g,f=(u|0)<(f|0)?u:f,!((f|0)<=0)&&(o[l>>2]=g-f,o[P>>2]=a-f,o[w>>2]=u-f)}function As(l){l=l|0;var a=0,u=0,f=0,g=0,x=0,w=0,P=0;a=o[l>>2]|0,w=l+4|0,u=o[w>>2]|0,P=l+8|0,f=o[P>>2]|0,g=u+(a*3|0)|0,o[l>>2]=g,u=f+(u*3|0)|0,o[w>>2]=u,a=(f*3|0)+a|0,o[P>>2]=a,f=u-g|0,(g|0)<0?(a=a-g|0,o[w>>2]=f,o[P>>2]=a,o[l>>2]=0,u=f,f=0):f=g,(u|0)<0&&(f=f-u|0,o[l>>2]=f,a=a-u|0,o[P>>2]=a,o[w>>2]=0,u=0),x=f-a|0,g=u-a|0,(a|0)<0?(o[l>>2]=x,o[w>>2]=g,o[P>>2]=0,f=x,a=0):g=u,u=(g|0)<(f|0)?g:f,u=(a|0)<(u|0)?a:u,!((u|0)<=0)&&(o[l>>2]=f-u,o[w>>2]=g-u,o[P>>2]=a-u)}function nn(l){l=l|0;var a=0,u=0,f=0,g=0,x=0,w=0,P=0;g=o[l>>2]|0,w=l+4|0,a=o[w>>2]|0,P=l+8|0,u=o[P>>2]|0,f=(a*3|0)+g|0,g=u+(g*3|0)|0,o[l>>2]=g,o[w>>2]=f,a=(u*3|0)+a|0,o[P>>2]=a,u=f-g|0,(g|0)<0?(a=a-g|0,o[w>>2]=u,o[P>>2]=a,o[l>>2]=0,g=0):u=f,(u|0)<0&&(g=g-u|0,o[l>>2]=g,a=a-u|0,o[P>>2]=a,o[w>>2]=0,u=0),x=g-a|0,f=u-a|0,(a|0)<0?(o[l>>2]=x,o[w>>2]=f,o[P>>2]=0,g=x,a=0):f=u,u=(f|0)<(g|0)?f:g,u=(a|0)<(u|0)?a:u,!((u|0)<=0)&&(o[l>>2]=g-u,o[w>>2]=f-u,o[P>>2]=a-u)}function fl(l,a){l=l|0,a=a|0;var u=0,f=0,g=0,x=0,w=0,P=0;(a+-1|0)>>>0>=6||(g=(o[15440+(a*12|0)>>2]|0)+(o[l>>2]|0)|0,o[l>>2]=g,P=l+4|0,f=(o[15440+(a*12|0)+4>>2]|0)+(o[P>>2]|0)|0,o[P>>2]=f,w=l+8|0,a=(o[15440+(a*12|0)+8>>2]|0)+(o[w>>2]|0)|0,o[w>>2]=a,u=f-g|0,(g|0)<0?(a=a-g|0,o[P>>2]=u,o[w>>2]=a,o[l>>2]=0,f=0):(u=f,f=g),(u|0)<0&&(f=f-u|0,o[l>>2]=f,a=a-u|0,o[w>>2]=a,o[P>>2]=0,u=0),x=f-a|0,g=u-a|0,(a|0)<0?(o[l>>2]=x,o[P>>2]=g,o[w>>2]=0,f=x,a=0):g=u,u=(g|0)<(f|0)?g:f,u=(a|0)<(u|0)?a:u,!((u|0)<=0)&&(o[l>>2]=f-u,o[P>>2]=g-u,o[w>>2]=a-u))}function Eo(l){l=l|0;var a=0,u=0,f=0,g=0,x=0,w=0,P=0;g=o[l>>2]|0,w=l+4|0,a=o[w>>2]|0,P=l+8|0,u=o[P>>2]|0,f=a+g|0,g=u+g|0,o[l>>2]=g,o[w>>2]=f,a=u+a|0,o[P>>2]=a,u=f-g|0,(g|0)<0?(a=a-g|0,o[w>>2]=u,o[P>>2]=a,o[l>>2]=0,f=0):(u=f,f=g),(u|0)<0&&(f=f-u|0,o[l>>2]=f,a=a-u|0,o[P>>2]=a,o[w>>2]=0,u=0),x=f-a|0,g=u-a|0,(a|0)<0?(o[l>>2]=x,o[w>>2]=g,o[P>>2]=0,f=x,a=0):g=u,u=(g|0)<(f|0)?g:f,u=(a|0)<(u|0)?a:u,!((u|0)<=0)&&(o[l>>2]=f-u,o[w>>2]=g-u,o[P>>2]=a-u)}function Io(l){l=l|0;var a=0,u=0,f=0,g=0,x=0,w=0,P=0;a=o[l>>2]|0,w=l+4|0,f=o[w>>2]|0,P=l+8|0,u=o[P>>2]|0,g=f+a|0,o[l>>2]=g,f=u+f|0,o[w>>2]=f,a=u+a|0,o[P>>2]=a,u=f-g|0,(g|0)<0?(a=a-g|0,o[w>>2]=u,o[P>>2]=a,o[l>>2]=0,f=0):(u=f,f=g),(u|0)<0&&(f=f-u|0,o[l>>2]=f,a=a-u|0,o[P>>2]=a,o[w>>2]=0,u=0),x=f-a|0,g=u-a|0,(a|0)<0?(o[l>>2]=x,o[w>>2]=g,o[P>>2]=0,f=x,a=0):g=u,u=(g|0)<(f|0)?g:f,u=(a|0)<(u|0)?a:u,!((u|0)<=0)&&(o[l>>2]=f-u,o[w>>2]=g-u,o[P>>2]=a-u)}function to(l){switch(l=l|0,l|0){case 1:{l=5;break}case 5:{l=4;break}case 4:{l=6;break}case 6:{l=2;break}case 2:{l=3;break}case 3:{l=1;break}}return l|0}function us(l){switch(l=l|0,l|0){case 1:{l=3;break}case 3:{l=2;break}case 2:{l=6;break}case 6:{l=4;break}case 4:{l=5;break}case 5:{l=1;break}}return l|0}function ki(l){l=l|0;var a=0,u=0,f=0,g=0,x=0,w=0,P=0;a=o[l>>2]|0,w=l+4|0,u=o[w>>2]|0,P=l+8|0,f=o[P>>2]|0,g=u+(a<<1)|0,o[l>>2]=g,u=f+(u<<1)|0,o[w>>2]=u,a=(f<<1)+a|0,o[P>>2]=a,f=u-g|0,(g|0)<0?(a=a-g|0,o[w>>2]=f,o[P>>2]=a,o[l>>2]=0,u=f,f=0):f=g,(u|0)<0&&(f=f-u|0,o[l>>2]=f,a=a-u|0,o[P>>2]=a,o[w>>2]=0,u=0),x=f-a|0,g=u-a|0,(a|0)<0?(o[l>>2]=x,o[w>>2]=g,o[P>>2]=0,f=x,a=0):g=u,u=(g|0)<(f|0)?g:f,u=(a|0)<(u|0)?a:u,!((u|0)<=0)&&(o[l>>2]=f-u,o[w>>2]=g-u,o[P>>2]=a-u)}function Vn(l){l=l|0;var a=0,u=0,f=0,g=0,x=0,w=0,P=0;g=o[l>>2]|0,w=l+4|0,a=o[w>>2]|0,P=l+8|0,u=o[P>>2]|0,f=(a<<1)+g|0,g=u+(g<<1)|0,o[l>>2]=g,o[w>>2]=f,a=(u<<1)+a|0,o[P>>2]=a,u=f-g|0,(g|0)<0?(a=a-g|0,o[w>>2]=u,o[P>>2]=a,o[l>>2]=0,g=0):u=f,(u|0)<0&&(g=g-u|0,o[l>>2]=g,a=a-u|0,o[P>>2]=a,o[w>>2]=0,u=0),x=g-a|0,f=u-a|0,(a|0)<0?(o[l>>2]=x,o[w>>2]=f,o[P>>2]=0,g=x,a=0):f=u,u=(f|0)<(g|0)?f:g,u=(a|0)<(u|0)?a:u,!((u|0)<=0)&&(o[l>>2]=g-u,o[w>>2]=f-u,o[P>>2]=a-u)}function Sr(l,a){l=l|0,a=a|0;var u=0,f=0,g=0,x=0,w=0,P=0;return w=(o[l>>2]|0)-(o[a>>2]|0)|0,P=(w|0)<0,f=(o[l+4>>2]|0)-(o[a+4>>2]|0)-(P?w:0)|0,x=(f|0)<0,g=(P?0-w|0:0)+(o[l+8>>2]|0)-(o[a+8>>2]|0)+(x?0-f|0:0)|0,l=(g|0)<0,a=l?0:g,u=(x?0:f)-(l?g:0)|0,g=(P?0:w)-(x?f:0)-(l?g:0)|0,l=(u|0)<(g|0)?u:g,l=(a|0)<(l|0)?a:l,f=(l|0)>0,a=a-(f?l:0)|0,u=u-(f?l:0)|0,l=g-(f?l:0)|0,l=(l|0)>-1?l:0-l|0,u=(u|0)>-1?u:0-u|0,a=(a|0)>-1?a:0-a|0,a=(u|0)>(a|0)?u:a,((l|0)>(a|0)?l:a)|0}function ro(l,a){l=l|0,a=a|0;var u=0;u=o[l+8>>2]|0,o[a>>2]=(o[l>>2]|0)-u,o[a+4>>2]=(o[l+4>>2]|0)-u}function dl(l,a){l=l|0,a=a|0;var u=0,f=0,g=0,x=0,w=0,P=0;return f=o[l>>2]|0,o[a>>2]=f,g=o[l+4>>2]|0,w=a+4|0,o[w>>2]=g,P=a+8|0,o[P>>2]=0,u=(g|0)<(f|0),l=u?f:g,u=u?g:f,(u|0)<0&&((u|0)==-2147483648||((l|0)>0?(2147483647-l|0)<(u|0):(-2147483648-l|0)>(u|0))||((l|0)>-1?(l|-2147483648|0)>=(u|0):(l^-2147483648|0)<(u|0)))?(a=1,a|0):(l=g-f|0,(f|0)<0?(u=0-f|0,o[w>>2]=l,o[P>>2]=u,o[a>>2]=0,f=0):(l=g,u=0),(l|0)<0&&(f=f-l|0,o[a>>2]=f,u=u-l|0,o[P>>2]=u,o[w>>2]=0,l=0),x=f-u|0,g=l-u|0,(u|0)<0?(o[a>>2]=x,o[w>>2]=g,o[P>>2]=0,l=g,g=x,u=0):g=f,f=(l|0)<(g|0)?l:g,f=(u|0)<(f|0)?u:f,(f|0)<=0?(a=0,a|0):(o[a>>2]=g-f,o[w>>2]=l-f,o[P>>2]=u-f,a=0,a|0))}function So(l){l=l|0;var a=0,u=0,f=0,g=0;a=l+8|0,g=o[a>>2]|0,u=g-(o[l>>2]|0)|0,o[l>>2]=u,f=l+4|0,l=(o[f>>2]|0)-g|0,o[f>>2]=l,o[a>>2]=0-(l+u)}function $r(l){l=l|0;var a=0,u=0,f=0,g=0,x=0,w=0,P=0;u=o[l>>2]|0,a=0-u|0,o[l>>2]=a,w=l+8|0,o[w>>2]=0,P=l+4|0,f=o[P>>2]|0,g=f+u|0,(u|0)>0?(o[P>>2]=g,o[w>>2]=u,o[l>>2]=0,a=0,f=g):u=0,(f|0)<0?(x=a-f|0,o[l>>2]=x,u=u-f|0,o[w>>2]=u,o[P>>2]=0,g=x-u|0,a=0-u|0,(u|0)<0?(o[l>>2]=g,o[P>>2]=a,o[w>>2]=0,f=a,u=0):(f=0,g=x)):g=a,a=(f|0)<(g|0)?f:g,a=(u|0)<(a|0)?u:a,!((a|0)<=0)&&(o[l>>2]=g-a,o[P>>2]=f-a,o[w>>2]=u-a)}function oA(l,a,u,f,g){l=l|0,a=a|0,u=u|0,f=f|0,g=g|0;var x=0,w=0,P=0,C=0,z=0,F=0,K=0;if(K=H,H=H+64|0,F=K,P=K+56|0,!(!0&(a&2013265920|0)==134217728&(!0&(f&2013265920|0)==134217728)))return g=5,H=K,g|0;if((l|0)==(u|0)&(a|0)==(f|0))return o[g>>2]=0,g=0,H=K,g|0;if(w=Ye(l|0,a|0,52)|0,ee()|0,w=w&15,z=Ye(u|0,f|0,52)|0,ee()|0,(w|0)!=(z&15|0))return g=12,H=K,g|0;if(x=w+-1|0,w>>>0>1){Va(l,a,x,F)|0,Va(u,f,x,P)|0,z=F,C=o[z>>2]|0,z=o[z+4>>2]|0;e:do if((C|0)==(o[P>>2]|0)&&(z|0)==(o[P+4>>2]|0)){w=(w^15)*3|0,x=Ye(l|0,a|0,w|0)|0,ee()|0,x=x&7,w=Ye(u|0,f|0,w|0)|0,ee()|0,w=w&7;do if((x|0)==0|(w|0)==0)o[g>>2]=1,x=0;else if((x|0)==7)x=5;else{if((x|0)==1|(w|0)==1&&wr(C,z)|0){x=5;break}if((o[15536+(x<<2)>>2]|0)!=(w|0)&&(o[15568+(x<<2)>>2]|0)!=(w|0))break e;o[g>>2]=1,x=0}while(!1);return g=x,H=K,g|0}while(!1)}x=F,w=x+56|0;do o[x>>2]=0,x=x+4|0;while((x|0)<(w|0));return ul(l,a,1,F)|0,a=F,!((o[a>>2]|0)==(u|0)&&(o[a+4>>2]|0)==(f|0))&&(a=F+8|0,!((o[a>>2]|0)==(u|0)&&(o[a+4>>2]|0)==(f|0)))&&(a=F+16|0,!((o[a>>2]|0)==(u|0)&&(o[a+4>>2]|0)==(f|0)))&&(a=F+24|0,!((o[a>>2]|0)==(u|0)&&(o[a+4>>2]|0)==(f|0)))&&(a=F+32|0,!((o[a>>2]|0)==(u|0)&&(o[a+4>>2]|0)==(f|0)))&&(a=F+40|0,!((o[a>>2]|0)==(u|0)&&(o[a+4>>2]|0)==(f|0)))?(x=F+48|0,x=((o[x>>2]|0)==(u|0)?(o[x+4>>2]|0)==(f|0):0)&1):x=1,o[g>>2]=x,g=0,H=K,g|0}function ml(l,a,u,f,g){return l=l|0,a=a|0,u=u|0,f=f|0,g=g|0,u=Po(l,a,u,f)|0,(u|0)==7?(g=11,g|0):(f=lt(u|0,0,56)|0,a=a&-2130706433|(ee()|0)|268435456,o[g>>2]=l|f,o[g+4>>2]=a,g=0,g|0)}function aA(l,a,u){return l=l|0,a=a|0,u=u|0,!0&(a&2013265920|0)==268435456?(o[u>>2]=l,o[u+4>>2]=a&-2130706433|134217728,u=0,u|0):(u=6,u|0)}function ou(l,a,u){l=l|0,a=a|0,u=u|0;var f=0,g=0,x=0;return g=H,H=H+16|0,f=g,o[f>>2]=0,!0&(a&2013265920|0)==268435456?(x=Ye(l|0,a|0,56)|0,ee()|0,f=li(l,a&-2130706433|134217728,x&7,f,u)|0,H=g,f|0):(f=6,H=g,f|0)}function io(l,a){l=l|0,a=a|0;var u=0;switch(u=Ye(l|0,a|0,56)|0,ee()|0,u&7){case 0:case 7:return u=0,u|0}return u=a&-2130706433|134217728,!(!0&(a&2013265920|0)==268435456)||!0&(a&117440512|0)==16777216&(wr(l,u)|0)!=0?(u=0,u|0):(u=ma(l,u)|0,u|0)}function Oa(l,a,u){l=l|0,a=a|0,u=u|0;var f=0,g=0,x=0,w=0;return g=H,H=H+16|0,f=g,!0&(a&2013265920|0)==268435456?(x=a&-2130706433|134217728,w=u,o[w>>2]=l,o[w+4>>2]=x,o[f>>2]=0,a=Ye(l|0,a|0,56)|0,ee()|0,f=li(l,x,a&7,f,u+8|0)|0,H=g,f|0):(f=6,H=g,f|0)}function Co(l,a,u){l=l|0,a=a|0,u=u|0;var f=0,g=0;return g=(wr(l,a)|0)==0,a=a&-2130706433,f=u,o[f>>2]=g?l:0,o[f+4>>2]=g?a|285212672:0,f=u+8|0,o[f>>2]=l,o[f+4>>2]=a|301989888,f=u+16|0,o[f>>2]=l,o[f+4>>2]=a|318767104,f=u+24|0,o[f>>2]=l,o[f+4>>2]=a|335544320,f=u+32|0,o[f>>2]=l,o[f+4>>2]=a|352321536,u=u+40|0,o[u>>2]=l,o[u+4>>2]=a|369098752,0}function Do(l,a,u){l=l|0,a=a|0,u=u|0;var f=0,g=0,x=0,w=0;return w=H,H=H+16|0,g=w,x=a&-2130706433|134217728,!0&(a&2013265920|0)==268435456?(f=Ye(l|0,a|0,56)|0,ee()|0,f=Fs(l,x,f&7)|0,(f|0)==-1?(o[u>>2]=0,x=6,H=w,x|0):(zs(l,x,g)|0&&zt(27795,26932,282,26947),a=Ye(l|0,a|0,52)|0,ee()|0,a=a&15,wr(l,x)|0?ks(g,a,f,2,u):Ro(g,a,f,2,u),x=0,H=w,x|0)):(x=6,H=w,x|0)}function fa(l,a,u){l=l|0,a=a|0,u=u|0;var f=0,g=0;f=H,H=H+16|0,g=f,ko(l,a,u,g),sA(g,u+4|0),H=f}function ko(l,a,u,f){l=l|0,a=a|0,u=u|0,f=f|0;var g=0,x=0,w=0,P=0,C=0;if(P=H,H=H+16|0,C=P,zo(l,u,C),x=+qt(+(1-+Z[C>>3]*.5)),x<1e-16){o[f>>2]=0,o[f+4>>2]=0,o[f+8>>2]=0,o[f+12>>2]=0,H=P;return}if(C=o[u>>2]|0,g=+Z[15920+(C*24|0)>>3],g=+lr(g-+lr(+ya(15600+(C<<4)|0,l))),Wi(a)|0?w=+lr(g+-.3334731722518321):w=g,g=+ai(+x)*2.618033988749896,(a|0)>0){l=0;do g=g*2.6457513110645907,l=l+1|0;while((l|0)!=(a|0))}x=+Jt(+w)*g,Z[f>>3]=x,w=+Yt(+w)*g,Z[f+8>>3]=w,H=P}function zo(l,a,u){l=l|0,a=a|0,u=u|0;var f=0,g=0,x=0;if(x=H,H=H+32|0,g=x,Ja(l,g),o[a>>2]=0,Z[u>>3]=5,f=+Gr(16400,g),f<+Z[u>>3]&&(o[a>>2]=0,Z[u>>3]=f),f=+Gr(16424,g),f<+Z[u>>3]&&(o[a>>2]=1,Z[u>>3]=f),f=+Gr(16448,g),f<+Z[u>>3]&&(o[a>>2]=2,Z[u>>3]=f),f=+Gr(16472,g),f<+Z[u>>3]&&(o[a>>2]=3,Z[u>>3]=f),f=+Gr(16496,g),f<+Z[u>>3]&&(o[a>>2]=4,Z[u>>3]=f),f=+Gr(16520,g),f<+Z[u>>3]&&(o[a>>2]=5,Z[u>>3]=f),f=+Gr(16544,g),f<+Z[u>>3]&&(o[a>>2]=6,Z[u>>3]=f),f=+Gr(16568,g),f<+Z[u>>3]&&(o[a>>2]=7,Z[u>>3]=f),f=+Gr(16592,g),f<+Z[u>>3]&&(o[a>>2]=8,Z[u>>3]=f),f=+Gr(16616,g),f<+Z[u>>3]&&(o[a>>2]=9,Z[u>>3]=f),f=+Gr(16640,g),f<+Z[u>>3]&&(o[a>>2]=10,Z[u>>3]=f),f=+Gr(16664,g),f<+Z[u>>3]&&(o[a>>2]=11,Z[u>>3]=f),f=+Gr(16688,g),f<+Z[u>>3]&&(o[a>>2]=12,Z[u>>3]=f),f=+Gr(16712,g),f<+Z[u>>3]&&(o[a>>2]=13,Z[u>>3]=f),f=+Gr(16736,g),f<+Z[u>>3]&&(o[a>>2]=14,Z[u>>3]=f),f=+Gr(16760,g),f<+Z[u>>3]&&(o[a>>2]=15,Z[u>>3]=f),f=+Gr(16784,g),f<+Z[u>>3]&&(o[a>>2]=16,Z[u>>3]=f),f=+Gr(16808,g),f<+Z[u>>3]&&(o[a>>2]=17,Z[u>>3]=f),f=+Gr(16832,g),f<+Z[u>>3]&&(o[a>>2]=18,Z[u>>3]=f),f=+Gr(16856,g),!(f<+Z[u>>3])){H=x;return}o[a>>2]=19,Z[u>>3]=f,H=x}function Nr(l,a,u,f,g){l=l|0,a=a|0,u=u|0,f=f|0,g=g|0;var x=0,w=0,P=0;if(x=+uo(l),x<1e-16){a=15600+(a<<4)|0,o[g>>2]=o[a>>2],o[g+4>>2]=o[a+4>>2],o[g+8>>2]=o[a+8>>2],o[g+12>>2]=o[a+12>>2];return}if(w=+Zi(+ +Z[l+8>>3],+ +Z[l>>3]),(u|0)>0){l=0;do x=x*.37796447300922725,l=l+1|0;while((l|0)!=(u|0))}P=x*.3333333333333333,f?(u=(Wi(u)|0)==0,x=+Xs(+((u?P:P*.37796447300922725)*.381966011250105))):(x=+Xs(+(x*.381966011250105)),Wi(u)|0&&(w=+lr(w+.3334731722518321))),jo(15600+(a<<4)|0,+lr(+Z[15920+(a*24|0)>>3]-w),x,g)}function lA(l,a,u){l=l|0,a=a|0,u=u|0;var f=0,g=0;f=H,H=H+16|0,g=f,dn(l+4|0,g),Nr(g,o[l>>2]|0,a,0,u),H=f}function ks(l,a,u,f,g){l=l|0,a=a|0,u=u|0,f=f|0,g=g|0;var x=0,w=0,P=0,C=0,z=0,F=0,K=0,ae=0,oe=0,le=0,xe=0,Ee=0,Ue=0,Se=0,Pe=0,we=0,ct=0,St=0,Mt=0,jt=0,$t=0,ir=0,Rt=0,Et=0,At=0,at=0,dt=0,Nt=0;if(at=H,H=H+272|0,x=at+256|0,Se=at+240|0,Rt=at,Et=at+224|0,At=at+208|0,Pe=at+176|0,we=at+160|0,ct=at+192|0,St=at+144|0,Mt=at+128|0,jt=at+112|0,$t=at+96|0,ir=at+80|0,o[x>>2]=a,o[Se>>2]=o[l>>2],o[Se+4>>2]=o[l+4>>2],o[Se+8>>2]=o[l+8>>2],o[Se+12>>2]=o[l+12>>2],Bo(Se,x,Rt),o[g>>2]=0,Se=f+u+((f|0)==5&1)|0,(Se|0)<=(u|0)){H=at;return}C=o[x>>2]|0,z=Et+4|0,F=Pe+4|0,K=u+5|0,ae=16880+(C<<2)|0,oe=16960+(C<<2)|0,le=Mt+8|0,xe=jt+8|0,Ee=$t+8|0,Ue=At+4|0,P=u;e:for(;;){w=Rt+(((P|0)%5|0)<<4)|0,o[At>>2]=o[w>>2],o[At+4>>2]=o[w+4>>2],o[At+8>>2]=o[w+8>>2],o[At+12>>2]=o[w+12>>2];do;while((Mn(At,C,0,1)|0)==2);if((P|0)>(u|0)&(Wi(a)|0)!=0){if(o[Pe>>2]=o[At>>2],o[Pe+4>>2]=o[At+4>>2],o[Pe+8>>2]=o[At+8>>2],o[Pe+12>>2]=o[At+12>>2],dn(z,we),f=o[Pe>>2]|0,x=o[17040+(f*80|0)+(o[Et>>2]<<2)>>2]|0,o[Pe>>2]=o[18640+(f*80|0)+(x*20|0)>>2],w=o[18640+(f*80|0)+(x*20|0)+16>>2]|0,(w|0)>0){l=0;do Eo(F),l=l+1|0;while((l|0)<(w|0))}switch(w=18640+(f*80|0)+(x*20|0)+4|0,o[ct>>2]=o[w>>2],o[ct+4>>2]=o[w+4>>2],o[ct+8>>2]=o[w+8>>2],or(ct,(o[ae>>2]|0)*3|0),rr(F,ct,F),gi(F),dn(F,St),dt=+(o[oe>>2]|0),Z[Mt>>3]=dt*3,Z[le>>3]=0,Nt=dt*-1.5,Z[jt>>3]=Nt,Z[xe>>3]=dt*2.598076211353316,Z[$t>>3]=Nt,Z[Ee>>3]=dt*-2.598076211353316,o[17040+((o[Pe>>2]|0)*80|0)+(o[At>>2]<<2)>>2]|0){case 1:{l=jt,f=Mt;break}case 3:{l=$t,f=jt;break}case 2:{l=Mt,f=$t;break}default:{l=12;break e}}on(we,St,f,l,ir),Nr(ir,o[Pe>>2]|0,C,1,g+8+(o[g>>2]<<4)|0),o[g>>2]=(o[g>>2]|0)+1}if((P|0)<(K|0)&&(dn(Ue,Pe),Nr(Pe,o[At>>2]|0,C,1,g+8+(o[g>>2]<<4)|0),o[g>>2]=(o[g>>2]|0)+1),o[Et>>2]=o[At>>2],o[Et+4>>2]=o[At+4>>2],o[Et+8>>2]=o[At+8>>2],o[Et+12>>2]=o[At+12>>2],P=P+1|0,(P|0)>=(Se|0)){l=3;break}}if((l|0)==3){H=at;return}else(l|0)==12&&zt(26970,27017,572,27027)}function Bo(l,a,u){l=l|0,a=a|0,u=u|0;var f=0,g=0,x=0,w=0,P=0,C=0;C=H,H=H+128|0,f=C+64|0,g=C,x=f,w=20240,P=x+60|0;do o[x>>2]=o[w>>2],x=x+4|0,w=w+4|0;while((x|0)<(P|0));x=g,w=20304,P=x+60|0;do o[x>>2]=o[w>>2],x=x+4|0,w=w+4|0;while((x|0)<(P|0));P=(Wi(o[a>>2]|0)|0)==0,f=P?f:g,g=l+4|0,ki(g),Vn(g),Wi(o[a>>2]|0)|0&&(nn(g),o[a>>2]=(o[a>>2]|0)+1),o[u>>2]=o[l>>2],a=u+4|0,rr(g,f,a),gi(a),o[u+16>>2]=o[l>>2],a=u+20|0,rr(g,f+12|0,a),gi(a),o[u+32>>2]=o[l>>2],a=u+36|0,rr(g,f+24|0,a),gi(a),o[u+48>>2]=o[l>>2],a=u+52|0,rr(g,f+36|0,a),gi(a),o[u+64>>2]=o[l>>2],u=u+68|0,rr(g,f+48|0,u),gi(u),H=C}function Mn(l,a,u,f){l=l|0,a=a|0,u=u|0,f=f|0;var g=0,x=0,w=0,P=0,C=0,z=0,F=0,K=0,ae=0,oe=0,le=0;if(le=H,H=H+32|0,ae=le+12|0,P=le,oe=l+4|0,K=o[16960+(a<<2)>>2]|0,F=(f|0)!=0,K=F?K*3|0:K,g=o[oe>>2]|0,z=l+8|0,w=o[z>>2]|0,F){if(x=l+12|0,f=o[x>>2]|0,g=w+g+f|0,(g|0)==(K|0))return oe=1,H=le,oe|0;C=x}else C=l+12|0,f=o[C>>2]|0,g=w+g+f|0;if((g|0)<=(K|0))return oe=0,H=le,oe|0;do if((f|0)>0){if(f=o[l>>2]|0,(w|0)>0){x=18640+(f*80|0)+60|0,f=l;break}f=18640+(f*80|0)+40|0,u?(ls(ae,K,0,0),Ds(oe,ae,P),Io(P),rr(P,ae,oe),x=f,f=l):(x=f,f=l)}else x=18640+((o[l>>2]|0)*80|0)+20|0,f=l;while(!1);if(o[f>>2]=o[x>>2],g=x+16|0,(o[g>>2]|0)>0){f=0;do Eo(oe),f=f+1|0;while((f|0)<(o[g>>2]|0))}return l=x+4|0,o[ae>>2]=o[l>>2],o[ae+4>>2]=o[l+4>>2],o[ae+8>>2]=o[l+8>>2],a=o[16880+(a<<2)>>2]|0,or(ae,F?a*3|0:a),rr(oe,ae,oe),gi(oe),F?f=((o[z>>2]|0)+(o[oe>>2]|0)+(o[C>>2]|0)|0)==(K|0)?1:2:f=2,oe=f,H=le,oe|0}function au(l,a){l=l|0,a=a|0;var u=0;do u=Mn(l,a,0,1)|0;while((u|0)==2);return u|0}function Ro(l,a,u,f,g){l=l|0,a=a|0,u=u|0,f=f|0,g=g|0;var x=0,w=0,P=0,C=0,z=0,F=0,K=0,ae=0,oe=0,le=0,xe=0,Ee=0,Ue=0,Se=0,Pe=0,we=0,ct=0,St=0,Mt=0,jt=0,$t=0,ir=0,Rt=0;if($t=H,H=H+240|0,x=$t+224|0,ct=$t+208|0,St=$t,Mt=$t+192|0,jt=$t+176|0,Ee=$t+160|0,Ue=$t+144|0,Se=$t+128|0,Pe=$t+112|0,we=$t+96|0,o[x>>2]=a,o[ct>>2]=o[l>>2],o[ct+4>>2]=o[l+4>>2],o[ct+8>>2]=o[l+8>>2],o[ct+12>>2]=o[l+12>>2],AA(ct,x,St),o[g>>2]=0,xe=f+u+((f|0)==6&1)|0,(xe|0)<=(u|0)){H=$t;return}C=o[x>>2]|0,z=u+6|0,F=16960+(C<<2)|0,K=Ue+8|0,ae=Se+8|0,oe=Pe+8|0,le=Mt+4|0,w=0,P=u,f=-1;e:for(;;){if(x=(P|0)%6|0,l=St+(x<<4)|0,o[Mt>>2]=o[l>>2],o[Mt+4>>2]=o[l+4>>2],o[Mt+8>>2]=o[l+8>>2],o[Mt+12>>2]=o[l+12>>2],l=w,w=Mn(Mt,C,0,1)|0,(P|0)>(u|0)&(Wi(a)|0)!=0&&(l|0)!=1&&(o[Mt>>2]|0)!=(f|0)){switch(dn(St+(((x+5|0)%6|0)<<4)+4|0,jt),dn(St+(x<<4)+4|0,Ee),ir=+(o[F>>2]|0),Z[Ue>>3]=ir*3,Z[K>>3]=0,Rt=ir*-1.5,Z[Se>>3]=Rt,Z[ae>>3]=ir*2.598076211353316,Z[Pe>>3]=Rt,Z[oe>>3]=ir*-2.598076211353316,x=o[ct>>2]|0,o[17040+(x*80|0)+(((f|0)==(x|0)?o[Mt>>2]|0:f)<<2)>>2]|0){case 1:{l=Se,f=Ue;break}case 3:{l=Pe,f=Se;break}case 2:{l=Ue,f=Pe;break}default:{l=8;break e}}on(jt,Ee,f,l,we),!(Ta(jt,we)|0)&&!(Ta(Ee,we)|0)&&(Nr(we,o[ct>>2]|0,C,1,g+8+(o[g>>2]<<4)|0),o[g>>2]=(o[g>>2]|0)+1)}if((P|0)<(z|0)&&(dn(le,jt),Nr(jt,o[Mt>>2]|0,C,1,g+8+(o[g>>2]<<4)|0),o[g>>2]=(o[g>>2]|0)+1),P=P+1|0,(P|0)>=(xe|0)){l=3;break}else f=o[Mt>>2]|0}if((l|0)==3){H=$t;return}else(l|0)==8&&zt(27054,27017,737,27099)}function AA(l,a,u){l=l|0,a=a|0,u=u|0;var f=0,g=0,x=0,w=0,P=0,C=0;C=H,H=H+160|0,f=C+80|0,g=C,x=f,w=20368,P=x+72|0;do o[x>>2]=o[w>>2],x=x+4|0,w=w+4|0;while((x|0)<(P|0));x=g,w=20448,P=x+72|0;do o[x>>2]=o[w>>2],x=x+4|0,w=w+4|0;while((x|0)<(P|0));P=(Wi(o[a>>2]|0)|0)==0,f=P?f:g,g=l+4|0,ki(g),Vn(g),Wi(o[a>>2]|0)|0&&(nn(g),o[a>>2]=(o[a>>2]|0)+1),o[u>>2]=o[l>>2],a=u+4|0,rr(g,f,a),gi(a),o[u+16>>2]=o[l>>2],a=u+20|0,rr(g,f+12|0,a),gi(a),o[u+32>>2]=o[l>>2],a=u+36|0,rr(g,f+24|0,a),gi(a),o[u+48>>2]=o[l>>2],a=u+52|0,rr(g,f+36|0,a),gi(a),o[u+64>>2]=o[l>>2],a=u+68|0,rr(g,f+48|0,a),gi(a),o[u+80>>2]=o[l>>2],u=u+84|0,rr(g,f+60|0,u),gi(u),H=C}function Lo(l,a){return l=l|0,a=a|0,a=Ye(l|0,a|0,52)|0,ee()|0,a&15|0}function da(l,a){return l=l|0,a=a|0,a=Ye(l|0,a|0,45)|0,ee()|0,a&127|0}function uA(l,a,u,f){return l=l|0,a=a|0,u=u|0,f=f|0,(u+-1|0)>>>0>14?(f=4,f|0):(u=Ye(l|0,a|0,(15-u|0)*3|0)|0,ee()|0,o[f>>2]=u&7,f=0,f|0)}function cA(l,a,u,f){l=l|0,a=a|0,u=u|0,f=f|0;var g=0,x=0,w=0,P=0,C=0,z=0;if(l>>>0>15)return f=4,f|0;if(a>>>0>121)return f=17,f|0;w=lt(l|0,0,52)|0,g=ee()|0,P=lt(a|0,0,45)|0,g=g|(ee()|0)|134225919;e:do if((l|0)>=1){for(P=1,w=(ot[20528+a>>0]|0)!=0,x=-1;;){if(a=o[u+(P+-1<<2)>>2]|0,a>>>0>6){g=18,a=10;break}if(!((a|0)==0|w^1))if((a|0)==1){g=19,a=10;break}else w=0;if(z=(15-P|0)*3|0,C=lt(7,0,z|0)|0,g=g&~(ee()|0),a=lt(a|0,((a|0)<0)<<31>>31|0,z|0)|0,x=a|x&~C,g=ee()|0|g,(P|0)<(l|0))P=P+1|0;else break e}if((a|0)==10)return g|0}else x=-1;while(!1);return z=f,o[z>>2]=x,o[z+4>>2]=g,z=0,z|0}function ma(l,a){l=l|0,a=a|0;var u=0,f=0,g=0,x=0,w=0;return!(!0&(a&-16777216|0)==134217728)||(f=Ye(l|0,a|0,52)|0,ee()|0,f=f&15,u=Ye(l|0,a|0,45)|0,ee()|0,u=u&127,u>>>0>121)?(l=0,l|0):(w=(f^15)*3|0,g=Ye(l|0,a|0,w|0)|0,w=lt(g|0,ee()|0,w|0)|0,g=ee()|0,x=Lr(-1227133514,-1171,w|0,g|0)|0,!((w&613566756&x|0)==0&(g&4681&(ee()|0)|0)==0)||(w=(f*3|0)+19|0,x=lt(~l|0,~a|0,w|0)|0,w=Ye(x|0,ee()|0,w|0)|0,!((f|0)==15|(w|0)==0&(ee()|0)==0))?(w=0,w|0):!(ot[20528+u>>0]|0)||(a=a&8191,(l|0)==0&(a|0)==0)?(w=1,w|0):(w=el(l|0,a|0)|0,ee()|0,((63-w|0)%3|0|0)!=0|0))}function gl(l,a){l=l|0,a=a|0;var u=0,f=0,g=0,x=0,w=0;return!0&(a&-16777216|0)==134217728&&(f=Ye(l|0,a|0,52)|0,ee()|0,f=f&15,u=Ye(l|0,a|0,45)|0,ee()|0,u=u&127,u>>>0<=121)&&(w=(f^15)*3|0,g=Ye(l|0,a|0,w|0)|0,w=lt(g|0,ee()|0,w|0)|0,g=ee()|0,x=Lr(-1227133514,-1171,w|0,g|0)|0,(w&613566756&x|0)==0&(g&4681&(ee()|0)|0)==0)&&(w=(f*3|0)+19|0,x=lt(~l|0,~a|0,w|0)|0,w=Ye(x|0,ee()|0,w|0)|0,(f|0)==15|(w|0)==0&(ee()|0)==0)&&(!(ot[20528+u>>0]|0)||(u=a&8191,(l|0)==0&(u|0)==0)||(w=el(l|0,u|0)|0,ee()|0,(63-w|0)%3|0|0))||io(l,a)|0?(w=1,w|0):(w=(Il(l,a)|0)!=0&1,w|0)}function ga(l,a,u,f){l=l|0,a=a|0,u=u|0,f=f|0;var g=0,x=0,w=0,P=0;if(g=lt(a|0,0,52)|0,x=ee()|0,u=lt(u|0,0,45)|0,u=x|(ee()|0)|134225919,(a|0)<1){x=-1,f=u,a=l,o[a>>2]=x,l=l+4|0,o[l>>2]=f;return}for(x=1,g=-1;w=(15-x|0)*3|0,P=lt(7,0,w|0)|0,u=u&~(ee()|0),w=lt(f|0,0,w|0)|0,g=g&~P|w,u=u|(ee()|0),(x|0)!=(a|0);)x=x+1|0;P=l,w=P,o[w>>2]=g,P=P+4|0,o[P>>2]=u}function Va(l,a,u,f){l=l|0,a=a|0,u=u|0,f=f|0;var g=0,x=0;if(x=Ye(l|0,a|0,52)|0,ee()|0,x=x&15,u>>>0>15)return f=4,f|0;if((x|0)<(u|0))return f=12,f|0;if((x|0)==(u|0))return o[f>>2]=l,o[f+4>>2]=a,f=0,f|0;if(g=lt(u|0,0,52)|0,g=g|l,l=ee()|0|a&-15728641,(x|0)>(u|0))do a=lt(7,0,(14-u|0)*3|0)|0,u=u+1|0,g=a|g,l=ee()|0|l;while((u|0)<(x|0));return o[f>>2]=g,o[f+4>>2]=l,f=0,f|0}function Fo(l,a,u,f){l=l|0,a=a|0,u=u|0,f=f|0;var g=0,x=0,w=0;if(x=Ye(l|0,a|0,52)|0,ee()|0,x=x&15,!((u|0)<16&(x|0)<=(u|0)))return f=4,f|0;g=u-x|0,u=Ye(l|0,a|0,45)|0,ee()|0;e:do if(!(yr(u&127)|0))u=yn(7,0,g,((g|0)<0)<<31>>31)|0,g=ee()|0;else{t:do if(x|0){for(u=1;w=lt(7,0,(15-u|0)*3|0)|0,!!((w&l|0)==0&((ee()|0)&a|0)==0);)if(u>>>0<x>>>0)u=u+1|0;else break t;u=yn(7,0,g,((g|0)<0)<<31>>31)|0,g=ee()|0;break e}while(!1);u=yn(7,0,g,((g|0)<0)<<31>>31)|0,u=Ir(u|0,ee()|0,5,0)|0,u=Dt(u|0,ee()|0,-5,-1)|0,u=yi(u|0,ee()|0,6,0)|0,u=Dt(u|0,ee()|0,1,0)|0,g=ee()|0}while(!1);return w=f,o[w>>2]=u,o[w+4>>2]=g,w=0,w|0}function wr(l,a){l=l|0,a=a|0;var u=0,f=0,g=0;if(g=Ye(l|0,a|0,45)|0,ee()|0,!(yr(g&127)|0))return g=0,g|0;g=Ye(l|0,a|0,52)|0,ee()|0,g=g&15;e:do if(!g)u=0;else for(f=1;;){if(u=Ye(l|0,a|0,(15-f|0)*3|0)|0,ee()|0,u=u&7,u|0)break e;if(f>>>0<g>>>0)f=f+1|0;else{u=0;break}}while(!1);return g=(u|0)==0&1,g|0}function no(l,a,u,f){l=l|0,a=a|0,u=u|0,f=f|0;var g=0,x=0,w=0,P=0;if(w=H,H=H+16|0,x=w,xl(x,l,a,u),a=x,l=o[a>>2]|0,a=o[a+4>>2]|0,(l|0)==0&(a|0)==0)return H=w,0;g=0,u=0;do P=f+(g<<3)|0,o[P>>2]=l,o[P+4>>2]=a,g=Dt(g|0,u|0,1,0)|0,u=ee()|0,wl(x),P=x,l=o[P>>2]|0,a=o[P+4>>2]|0;while(!((l|0)==0&(a|0)==0));return H=w,0}function _l(l,a,u,f){return l=l|0,a=a|0,u=u|0,f=f|0,(f|0)<(u|0)?(u=a,f=l,Pt(u|0),f|0):(u=lt(-1,-1,((f-u|0)*3|0)+3|0)|0,f=lt(~u|0,~(ee()|0)|0,(15-f|0)*3|0)|0,u=~(ee()|0)&a,f=~f&l,Pt(u|0),f|0)}function ja(l,a,u,f){l=l|0,a=a|0,u=u|0,f=f|0;var g=0;return g=Ye(l|0,a|0,52)|0,ee()|0,g=g&15,(u|0)<16&(g|0)<=(u|0)?((g|0)<(u|0)&&(g=lt(-1,-1,((u+-1-g|0)*3|0)+3|0)|0,g=lt(~g|0,~(ee()|0)|0,(15-u|0)*3|0)|0,a=~(ee()|0)&a,l=~g&l),g=lt(u|0,0,52)|0,u=a&-15728641|(ee()|0),o[f>>2]=l|g,o[f+4>>2]=u,f=0,f|0):(f=4,f|0)}function Oo(l,a,u,f){l=l|0,a=a|0,u=u|0,f=f|0;var g=0,x=0,w=0,P=0,C=0,z=0,F=0,K=0,ae=0,oe=0,le=0,xe=0,Ee=0,Ue=0,Se=0,Pe=0,we=0,ct=0,St=0,Mt=0,jt=0,$t=0,ir=0,Rt=0,Et=0,At=0;if((u|0)==0&(f|0)==0)return At=0,At|0;if(g=l,x=o[g>>2]|0,g=o[g+4>>2]|0,!0&(g&15728640|0)==0){if(!((f|0)>0|(f|0)==0&u>>>0>0)||(At=a,o[At>>2]=x,o[At+4>>2]=g,(u|0)==1&(f|0)==0))return At=0,At|0;g=1,x=0;do Rt=l+(g<<3)|0,Et=o[Rt+4>>2]|0,At=a+(g<<3)|0,o[At>>2]=o[Rt>>2],o[At+4>>2]=Et,g=Dt(g|0,x|0,1,0)|0,x=ee()|0;while((x|0)<(f|0)|(x|0)==(f|0)&g>>>0<u>>>0);return g=0,g|0}if(ir=u<<3,Et=In(ir)|0,!Et)return At=13,At|0;if(Nn(Et|0,l|0,ir|0)|0,Rt=Bi(u,8)|0,!Rt)return kt(Et),At=13,At|0;e:for(;;){g=Et,z=o[g>>2]|0,g=o[g+4>>2]|0,jt=Ye(z|0,g|0,52)|0,ee()|0,jt=jt&15,$t=jt+-1|0,Mt=(jt|0)!=0,St=(f|0)>0|(f|0)==0&u>>>0>0;t:do if(Mt&St){if(Se=lt($t|0,0,52)|0,Pe=ee()|0,$t>>>0>15){if(!((z|0)==0&(g|0)==0)){At=16;break e}for(x=0,l=0;;){if(x=Dt(x|0,l|0,1,0)|0,l=ee()|0,!((l|0)<(f|0)|(l|0)==(f|0)&x>>>0<u>>>0))break t;if(w=Et+(x<<3)|0,ct=o[w>>2]|0,w=o[w+4>>2]|0,!((ct|0)==0&(w|0)==0)){g=w,At=16;break e}}}for(P=z,l=g,x=0,w=0;;){if(!((P|0)==0&(l|0)==0)){if(!(!0&(l&117440512|0)==0)){At=21;break e}if(F=Ye(P|0,l|0,52)|0,ee()|0,F=F&15,(F|0)<($t|0)){g=12,At=27;break e}if((F|0)!=($t|0)&&(P=P|Se,l=l&-15728641|Pe,F>>>0>=jt>>>0)){C=$t;do ct=lt(7,0,(14-C|0)*3|0)|0,C=C+1|0,P=ct|P,l=ee()|0|l;while(C>>>0<F>>>0)}if(ae=Jn(P|0,l|0,u|0,f|0)|0,oe=ee()|0,C=Rt+(ae<<3)|0,F=C,K=o[F>>2]|0,F=o[F+4>>2]|0,!((K|0)==0&(F|0)==0)){Ee=0,Ue=0;do{if((Ee|0)>(f|0)|(Ee|0)==(f|0)&Ue>>>0>u>>>0){At=31;break e}if((K|0)==(P|0)&(F&-117440513|0)==(l|0)){le=Ye(K|0,F|0,56)|0,ee()|0,le=le&7,xe=le+1|0,ct=Ye(K|0,F|0,45)|0,ee()|0;r:do if(!(yr(ct&127)|0))F=7;else{if(K=Ye(K|0,F|0,52)|0,ee()|0,K=K&15,!K){F=6;break}for(F=1;;){if(ct=lt(7,0,(15-F|0)*3|0)|0,!((ct&P|0)==0&((ee()|0)&l|0)==0)){F=7;break r}if(F>>>0<K>>>0)F=F+1|0;else{F=6;break}}}while(!1);if((le+2|0)>>>0>F>>>0){At=41;break e}ct=lt(xe|0,0,56)|0,l=ee()|0|l&-117440513,we=C,o[we>>2]=0,o[we+4>>2]=0,P=ct|P}else ae=Dt(ae|0,oe|0,1,0)|0,ae=Wo(ae|0,ee()|0,u|0,f|0)|0,oe=ee()|0;Ue=Dt(Ue|0,Ee|0,1,0)|0,Ee=ee()|0,C=Rt+(ae<<3)|0,F=C,K=o[F>>2]|0,F=o[F+4>>2]|0}while(!((K|0)==0&(F|0)==0))}ct=C,o[ct>>2]=P,o[ct+4>>2]=l}if(x=Dt(x|0,w|0,1,0)|0,w=ee()|0,!((w|0)<(f|0)|(w|0)==(f|0)&x>>>0<u>>>0))break t;l=Et+(x<<3)|0,P=o[l>>2]|0,l=o[l+4>>2]|0}}while(!1);if(ct=Dt(u|0,f|0,5,0)|0,we=ee()|0,we>>>0<0|(we|0)==0&ct>>>0<11){At=85;break}if(ct=yi(u|0,f|0,6,0)|0,ee()|0,ct=Bi(ct,8)|0,!ct){At=48;break}do if(St){for(xe=0,l=0,le=0,Ee=0;;){if(F=Rt+(xe<<3)|0,w=F,x=o[w>>2]|0,w=o[w+4>>2]|0,(x|0)==0&(w|0)==0)we=le;else{K=Ye(x|0,w|0,56)|0,ee()|0,K=K&7,P=K+1|0,ae=w&-117440513,we=Ye(x|0,w|0,45)|0,ee()|0;t:do if(yr(we&127)|0){if(oe=Ye(x|0,w|0,52)|0,ee()|0,oe=oe&15,oe|0)for(C=1;;){if(we=lt(7,0,(15-C|0)*3|0)|0,!((x&we|0)==0&(ae&(ee()|0)|0)==0))break t;if(C>>>0<oe>>>0)C=C+1|0;else break}w=lt(P|0,0,56)|0,x=w|x,w=ee()|0|ae,P=F,o[P>>2]=x,o[P+4>>2]=w,P=K+2|0}while(!1);(P|0)==7?(we=ct+(l<<3)|0,o[we>>2]=x,o[we+4>>2]=w&-117440513,l=Dt(l|0,le|0,1,0)|0,we=ee()|0):we=le}if(xe=Dt(xe|0,Ee|0,1,0)|0,Ee=ee()|0,(Ee|0)<(f|0)|(Ee|0)==(f|0)&xe>>>0<u>>>0)le=we;else break}if(St){if(Ue=$t>>>0>15,Se=lt($t|0,0,52)|0,Pe=ee()|0,!Mt){for(x=0,C=0,P=0,w=0;(z|0)==0&(g|0)==0||($t=a+(x<<3)|0,o[$t>>2]=z,o[$t+4>>2]=g,x=Dt(x|0,C|0,1,0)|0,C=ee()|0),P=Dt(P|0,w|0,1,0)|0,w=ee()|0,!!((w|0)<(f|0)|(w|0)==(f|0)&P>>>0<u>>>0);)g=Et+(P<<3)|0,z=o[g>>2]|0,g=o[g+4>>2]|0;g=we;break}for(x=0,C=0,w=0,P=0;;){do if(!((z|0)==0&(g|0)==0)){if(oe=Ye(z|0,g|0,52)|0,ee()|0,oe=oe&15,Ue|(oe|0)<($t|0)){At=80;break e}if((oe|0)!=($t|0)){if(F=z|Se,K=g&-15728641|Pe,oe>>>0>=jt>>>0){ae=$t;do Mt=lt(7,0,(14-ae|0)*3|0)|0,ae=ae+1|0,F=Mt|F,K=ee()|0|K;while(ae>>>0<oe>>>0)}}else F=z,K=g;le=Jn(F|0,K|0,u|0,f|0)|0,ae=0,oe=0,Ee=ee()|0;do{if((ae|0)>(f|0)|(ae|0)==(f|0)&oe>>>0>u>>>0){At=81;break e}if(Mt=Rt+(le<<3)|0,xe=o[Mt+4>>2]|0,(xe&-117440513|0)==(K|0)&&(o[Mt>>2]|0)==(F|0)){At=65;break}Mt=Dt(le|0,Ee|0,1,0)|0,le=Wo(Mt|0,ee()|0,u|0,f|0)|0,Ee=ee()|0,oe=Dt(oe|0,ae|0,1,0)|0,ae=ee()|0,Mt=Rt+(le<<3)|0}while(!((o[Mt>>2]|0)==(F|0)&&(o[Mt+4>>2]|0)==(K|0)));if((At|0)==65&&(At=0,!0&(xe&117440512|0)==100663296))break;Mt=a+(x<<3)|0,o[Mt>>2]=z,o[Mt+4>>2]=g,x=Dt(x|0,C|0,1,0)|0,C=ee()|0}while(!1);if(w=Dt(w|0,P|0,1,0)|0,P=ee()|0,!((P|0)<(f|0)|(P|0)==(f|0)&w>>>0<u>>>0))break;g=Et+(w<<3)|0,z=o[g>>2]|0,g=o[g+4>>2]|0}g=we}else x=0,g=we}else x=0,l=0,g=0;while(!1);if(vi(Rt|0,0,ir|0)|0,Nn(Et|0,ct|0,l<<3|0)|0,kt(ct),(l|0)==0&(g|0)==0){At=89;break}else a=a+(x<<3)|0,f=g,u=l}if((At|0)==16)!0&(g&117440512|0)==0?(g=4,At=27):At=21;else if((At|0)==31)zt(27795,27122,620,27132);else{if((At|0)==41)return kt(Et),kt(Rt),At=10,At|0;if((At|0)==48)return kt(Et),kt(Rt),At=13,At|0;(At|0)==80?zt(27795,27122,711,27132):(At|0)==81?zt(27795,27122,723,27132):(At|0)==85&&(Nn(a|0,Et|0,u<<3|0)|0,At=89)}return(At|0)==21?(kt(Et),kt(Rt),At=5,At|0):(At|0)==27?(kt(Et),kt(Rt),At=g,At|0):(At|0)==89?(kt(Et),kt(Rt),At=0,At|0):0}function hA(l,a,u,f,g,x,w){l=l|0,a=a|0,u=u|0,f=f|0,g=g|0,x=x|0,w=w|0;var P=0,C=0,z=0,F=0,K=0,ae=0,oe=0,le=0,xe=0;if(xe=H,H=H+16|0,le=xe,!((u|0)>0|(u|0)==0&a>>>0>0))return le=0,H=xe,le|0;if((w|0)>=16)return le=12,H=xe,le|0;ae=0,oe=0,K=0,P=0;e:for(;;){if(z=l+(ae<<3)|0,C=o[z>>2]|0,z=o[z+4>>2]|0,F=Ye(C|0,z|0,52)|0,ee()|0,(F&15|0)>(w|0)){P=12,C=11;break}if(xl(le,C,z,w),F=le,z=o[F>>2]|0,F=o[F+4>>2]|0,(z|0)==0&(F|0)==0)C=K;else{C=K;do{if(!((P|0)<(x|0)|(P|0)==(x|0)&C>>>0<g>>>0)){C=10;break e}K=f+(C<<3)|0,o[K>>2]=z,o[K+4>>2]=F,C=Dt(C|0,P|0,1,0)|0,P=ee()|0,wl(le),K=le,z=o[K>>2]|0,F=o[K+4>>2]|0}while(!((z|0)==0&(F|0)==0))}if(ae=Dt(ae|0,oe|0,1,0)|0,oe=ee()|0,(oe|0)<(u|0)|(oe|0)==(u|0)&ae>>>0<a>>>0)K=C;else{P=0,C=11;break}}return(C|0)==10?(le=14,H=xe,le|0):(C|0)==11?(H=xe,P|0):0}function Na(l,a,u,f,g){l=l|0,a=a|0,u=u|0,f=f|0,g=g|0;var x=0,w=0,P=0,C=0,z=0,F=0,K=0,ae=0;ae=H,H=H+16|0,K=ae;e:do if((u|0)>0|(u|0)==0&a>>>0>0){for(z=0,w=0,x=0,F=0;;){if(C=l+(z<<3)|0,P=o[C>>2]|0,C=o[C+4>>2]|0,!((P|0)==0&(C|0)==0)&&(C=(Fo(P,C,f,K)|0)==0,P=K,w=Dt(o[P>>2]|0,o[P+4>>2]|0,w|0,x|0)|0,x=ee()|0,!C)){x=12;break}if(z=Dt(z|0,F|0,1,0)|0,F=ee()|0,!((F|0)<(u|0)|(F|0)==(u|0)&z>>>0<a>>>0))break e}return H=ae,x|0}else w=0,x=0;while(!1);return o[g>>2]=w,o[g+4>>2]=x,g=0,H=ae,g|0}function lu(l,a){return l=l|0,a=a|0,a=Ye(l|0,a|0,52)|0,ee()|0,a&1|0}function sn(l,a){l=l|0,a=a|0;var u=0,f=0,g=0;if(g=Ye(l|0,a|0,52)|0,ee()|0,g=g&15,!g)return g=0,g|0;for(f=1;;){if(u=Ye(l|0,a|0,(15-f|0)*3|0)|0,ee()|0,u=u&7,u|0){f=5;break}if(f>>>0<g>>>0)f=f+1|0;else{u=0,f=5;break}}return(f|0)==5?u|0:0}function Ga(l,a){l=l|0,a=a|0;var u=0,f=0,g=0,x=0,w=0,P=0,C=0;if(C=Ye(l|0,a|0,52)|0,ee()|0,C=C&15,!C)return P=a,C=l,Pt(P|0),C|0;for(P=1,u=0;;){x=(15-P|0)*3|0,f=lt(7,0,x|0)|0,g=ee()|0,w=Ye(l|0,a|0,x|0)|0,ee()|0,x=lt(to(w&7)|0,0,x|0)|0,w=ee()|0,l=x|l&~f,a=w|a&~g;e:do if(!u)if((x&f|0)==0&(w&g|0)==0)u=0;else if(f=Ye(l|0,a|0,52)|0,ee()|0,f=f&15,!f)u=1;else{u=1;t:for(;;){switch(w=Ye(l|0,a|0,(15-u|0)*3|0)|0,ee()|0,w&7){case 1:break t;case 0:break;default:{u=1;break e}}if(u>>>0<f>>>0)u=u+1|0;else{u=1;break e}}for(u=1;;)if(w=(15-u|0)*3|0,g=Ye(l|0,a|0,w|0)|0,ee()|0,x=lt(7,0,w|0)|0,a=a&~(ee()|0),w=lt(to(g&7)|0,0,w|0)|0,l=l&~x|w,a=a|(ee()|0),u>>>0<f>>>0)u=u+1|0;else{u=1;break}}while(!1);if(P>>>0<C>>>0)P=P+1|0;else break}return Pt(a|0),l|0}function jn(l,a){l=l|0,a=a|0;var u=0,f=0,g=0,x=0,w=0;if(f=Ye(l|0,a|0,52)|0,ee()|0,f=f&15,!f)return u=a,f=l,Pt(u|0),f|0;for(u=1;x=(15-u|0)*3|0,w=Ye(l|0,a|0,x|0)|0,ee()|0,g=lt(7,0,x|0)|0,a=a&~(ee()|0),x=lt(to(w&7)|0,0,x|0)|0,l=x|l&~g,a=ee()|0|a,u>>>0<f>>>0;)u=u+1|0;return Pt(a|0),l|0}function pA(l,a){l=l|0,a=a|0;var u=0,f=0,g=0,x=0,w=0,P=0,C=0;if(C=Ye(l|0,a|0,52)|0,ee()|0,C=C&15,!C)return P=a,C=l,Pt(P|0),C|0;for(P=1,u=0;;){x=(15-P|0)*3|0,f=lt(7,0,x|0)|0,g=ee()|0,w=Ye(l|0,a|0,x|0)|0,ee()|0,x=lt(us(w&7)|0,0,x|0)|0,w=ee()|0,l=x|l&~f,a=w|a&~g;e:do if(!u)if((x&f|0)==0&(w&g|0)==0)u=0;else if(f=Ye(l|0,a|0,52)|0,ee()|0,f=f&15,!f)u=1;else{u=1;t:for(;;){switch(w=Ye(l|0,a|0,(15-u|0)*3|0)|0,ee()|0,w&7){case 1:break t;case 0:break;default:{u=1;break e}}if(u>>>0<f>>>0)u=u+1|0;else{u=1;break e}}for(u=1;;)if(g=(15-u|0)*3|0,x=lt(7,0,g|0)|0,w=a&~(ee()|0),a=Ye(l|0,a|0,g|0)|0,ee()|0,a=lt(us(a&7)|0,0,g|0)|0,l=l&~x|a,a=w|(ee()|0),u>>>0<f>>>0)u=u+1|0;else{u=1;break}}while(!1);if(P>>>0<C>>>0)P=P+1|0;else break}return Pt(a|0),l|0}function _a(l,a){l=l|0,a=a|0;var u=0,f=0,g=0,x=0,w=0;if(f=Ye(l|0,a|0,52)|0,ee()|0,f=f&15,!f)return u=a,f=l,Pt(u|0),f|0;for(u=1;w=(15-u|0)*3|0,x=lt(7,0,w|0)|0,g=a&~(ee()|0),a=Ye(l|0,a|0,w|0)|0,ee()|0,a=lt(us(a&7)|0,0,w|0)|0,l=a|l&~x,a=ee()|0|g,u>>>0<f>>>0;)u=u+1|0;return Pt(a|0),l|0}function fA(l,a){l=l|0,a=a|0;var u=0,f=0,g=0,x=0,w=0,P=0,C=0,z=0,F=0;if(C=H,H=H+64|0,P=C+40|0,f=C+24|0,g=C+12|0,x=C,lt(a|0,0,52)|0,u=ee()|0|134225919,!a)return(o[l+4>>2]|0)>2||(o[l+8>>2]|0)>2||(o[l+12>>2]|0)>2?(w=0,P=0,Pt(w|0),H=C,P|0):(lt(Fa(l)|0,0,45)|0,w=ee()|0|u,P=-1,Pt(w|0),H=C,P|0);if(o[P>>2]=o[l>>2],o[P+4>>2]=o[l+4>>2],o[P+8>>2]=o[l+8>>2],o[P+12>>2]=o[l+12>>2],w=P+4|0,(a|0)>0)for(l=-1;o[f>>2]=o[w>>2],o[f+4>>2]=o[w+4>>2],o[f+8>>2]=o[w+8>>2],a&1?(pa(w),o[g>>2]=o[w>>2],o[g+4>>2]=o[w+4>>2],o[g+8>>2]=o[w+8>>2],As(g)):(mn(w),o[g>>2]=o[w>>2],o[g+4>>2]=o[w+4>>2],o[g+8>>2]=o[w+8>>2],nn(g)),Ds(f,g,x),gi(x),F=(15-a|0)*3|0,z=lt(7,0,F|0)|0,u=u&~(ee()|0),F=lt(Zt(x)|0,0,F|0)|0,l=F|l&~z,u=ee()|0|u,(a|0)>1;)a=a+-1|0;else l=-1;e:do if((o[w>>2]|0)<=2&&(o[P+8>>2]|0)<=2&&(o[P+12>>2]|0)<=2){if(f=Fa(P)|0,a=lt(f|0,0,45)|0,a=a|l,l=ee()|0|u&-1040385,x=su(P)|0,!(yr(f)|0)){if((x|0)<=0)break;for(g=0;;){if(f=Ye(a|0,l|0,52)|0,ee()|0,f=f&15,f)for(u=1;F=(15-u|0)*3|0,P=Ye(a|0,l|0,F|0)|0,ee()|0,z=lt(7,0,F|0)|0,l=l&~(ee()|0),F=lt(to(P&7)|0,0,F|0)|0,a=a&~z|F,l=l|(ee()|0),u>>>0<f>>>0;)u=u+1|0;if(g=g+1|0,(g|0)==(x|0))break e}}g=Ye(a|0,l|0,52)|0,ee()|0,g=g&15;t:do if(g){u=1;r:for(;;){switch(F=Ye(a|0,l|0,(15-u|0)*3|0)|0,ee()|0,F&7){case 1:break r;case 0:break;default:break t}if(u>>>0<g>>>0)u=u+1|0;else break t}if(Pi(f,o[P>>2]|0)|0)for(u=1;P=(15-u|0)*3|0,z=lt(7,0,P|0)|0,F=l&~(ee()|0),l=Ye(a|0,l|0,P|0)|0,ee()|0,l=lt(us(l&7)|0,0,P|0)|0,a=a&~z|l,l=F|(ee()|0),u>>>0<g>>>0;)u=u+1|0;else for(u=1;F=(15-u|0)*3|0,P=Ye(a|0,l|0,F|0)|0,ee()|0,z=lt(7,0,F|0)|0,l=l&~(ee()|0),F=lt(to(P&7)|0,0,F|0)|0,a=a&~z|F,l=l|(ee()|0),u>>>0<g>>>0;)u=u+1|0}while(!1);if((x|0)>0){u=0;do a=Ga(a,l)|0,l=ee()|0,u=u+1|0;while((u|0)!=(x|0))}}else a=0,l=0;while(!1);return z=l,F=a,Pt(z|0),H=C,F|0}function Wi(l){return l=l|0,(l|0)%2|0|0}function gn(l,a,u){l=l|0,a=a|0,u=u|0;var f=0,g=0;return g=H,H=H+16|0,f=g,a>>>0>15?(f=4,H=g,f|0):(o[l+4>>2]&2146435072|0)==2146435072||(o[l+8+4>>2]&2146435072|0)==2146435072?(f=3,H=g,f|0):(fa(l,a,f),a=fA(f,a)|0,f=ee()|0,o[u>>2]=a,o[u+4>>2]=f,(a|0)==0&(f|0)==0&&zt(27795,27122,1050,27145),f=0,H=g,f|0)}function Vo(l,a,u){l=l|0,a=a|0,u=u|0;var f=0,g=0,x=0,w=0;if(g=u+4|0,x=Ye(l|0,a|0,52)|0,ee()|0,x=x&15,w=Ye(l|0,a|0,45)|0,ee()|0,f=(x|0)==0,yr(w&127)|0){if(f)return w=1,w|0;f=1}else{if(f)return w=0,w|0;(o[g>>2]|0)==0&&(o[u+8>>2]|0)==0?f=(o[u+12>>2]|0)!=0&1:f=1}for(u=1;u&1?As(g):nn(g),w=Ye(l|0,a|0,(15-u|0)*3|0)|0,ee()|0,fl(g,w&7),u>>>0<x>>>0;)u=u+1|0;return f|0}function zs(l,a,u){l=l|0,a=a|0,u=u|0;var f=0,g=0,x=0,w=0,P=0,C=0,z=0,F=0;if(F=H,H=H+16|0,C=F,z=Ye(l|0,a|0,45)|0,ee()|0,z=z&127,z>>>0>121)return o[u>>2]=0,o[u+4>>2]=0,o[u+8>>2]=0,o[u+12>>2]=0,z=5,H=F,z|0;e:do if((yr(z)|0)!=0&&(x=Ye(l|0,a|0,52)|0,ee()|0,x=x&15,(x|0)!=0)){f=1;t:for(;;){switch(P=Ye(l|0,a|0,(15-f|0)*3|0)|0,ee()|0,P&7){case 5:break t;case 0:break;default:{f=a;break e}}if(f>>>0<x>>>0)f=f+1|0;else{f=a;break e}}for(g=1,f=a;a=(15-g|0)*3|0,w=lt(7,0,a|0)|0,P=f&~(ee()|0),f=Ye(l|0,f|0,a|0)|0,ee()|0,f=lt(us(f&7)|0,0,a|0)|0,l=l&~w|f,f=P|(ee()|0),g>>>0<x>>>0;)g=g+1|0}else f=a;while(!1);if(P=7696+(z*28|0)|0,o[u>>2]=o[P>>2],o[u+4>>2]=o[P+4>>2],o[u+8>>2]=o[P+8>>2],o[u+12>>2]=o[P+12>>2],!(Vo(l,f,u)|0))return z=0,H=F,z|0;if(w=u+4|0,o[C>>2]=o[w>>2],o[C+4>>2]=o[w+4>>2],o[C+8>>2]=o[w+8>>2],x=Ye(l|0,f|0,52)|0,ee()|0,P=x&15,x&1?(nn(w),x=P+1|0):x=P,!(yr(z)|0))f=0;else{e:do if(!P)f=0;else for(a=1;;){if(g=Ye(l|0,f|0,(15-a|0)*3|0)|0,ee()|0,g=g&7,g|0){f=g;break e}if(a>>>0<P>>>0)a=a+1|0;else{f=0;break}}while(!1);f=(f|0)==4&1}if(!(Mn(u,x,f,0)|0))(x|0)!=(P|0)&&(o[w>>2]=o[C>>2],o[w+4>>2]=o[C+4>>2],o[w+8>>2]=o[C+8>>2]);else{if(yr(z)|0)do;while((Mn(u,x,0,0)|0)!=0);(x|0)!=(P|0)&&mn(w)}return z=0,H=F,z|0}function cs(l,a,u){l=l|0,a=a|0,u=u|0;var f=0,g=0,x=0;return x=H,H=H+16|0,f=x,g=zs(l,a,f)|0,g|0?(H=x,g|0):(g=Ye(l|0,a|0,52)|0,ee()|0,lA(f,g&15,u),g=0,H=x,g|0)}function Bs(l,a,u){l=l|0,a=a|0,u=u|0;var f=0,g=0,x=0,w=0,P=0;if(w=H,H=H+16|0,x=w,f=zs(l,a,x)|0,f|0)return x=f,H=w,x|0;f=Ye(l|0,a|0,45)|0,ee()|0,f=(yr(f&127)|0)==0,g=Ye(l|0,a|0,52)|0,ee()|0,g=g&15;e:do if(!f){if(g|0)for(f=1;;){if(P=lt(7,0,(15-f|0)*3|0)|0,!((P&l|0)==0&((ee()|0)&a|0)==0))break e;if(f>>>0<g>>>0)f=f+1|0;else break}return ks(x,g,0,5,u),P=0,H=w,P|0}while(!1);return Ro(x,g,0,6,u),P=0,H=w,P|0}function Ua(l,a,u){l=l|0,a=a|0,u=u|0;var f=0,g=0,x=0;if(g=Ye(l|0,a|0,45)|0,ee()|0,!(yr(g&127)|0))return g=2,o[u>>2]=g,0;if(g=Ye(l|0,a|0,52)|0,ee()|0,g=g&15,!g)return g=5,o[u>>2]=g,0;for(f=1;;){if(x=lt(7,0,(15-f|0)*3|0)|0,!((x&l|0)==0&((ee()|0)&a|0)==0)){f=2,l=6;break}if(f>>>0<g>>>0)f=f+1|0;else{f=5,l=6;break}}return(l|0)==6&&(o[u>>2]=f),0}function Rs(l,a,u){l=l|0,a=a|0,u=u|0;var f=0,g=0,x=0,w=0,P=0,C=0,z=0,F=0,K=0;K=H,H=H+128|0,z=K+112|0,x=K+96|0,F=K,g=Ye(l|0,a|0,52)|0,ee()|0,P=g&15,o[z>>2]=P,w=Ye(l|0,a|0,45)|0,ee()|0,w=w&127;e:do if(yr(w)|0){if(P|0)for(f=1;;){if(C=lt(7,0,(15-f|0)*3|0)|0,!((C&l|0)==0&((ee()|0)&a|0)==0)){g=0;break e}if(f>>>0<P>>>0)f=f+1|0;else break}if(g&1)g=1;else return C=lt(P+1|0,0,52)|0,F=ee()|0|a&-15728641,z=lt(7,0,(14-P|0)*3|0)|0,F=Rs((C|l)&~z,F&~(ee()|0),u)|0,H=K,F|0}else g=0;while(!1);if(f=zs(l,a,x)|0,!f){g?(Bo(x,z,F),C=5):(AA(x,z,F),C=6);e:do if(yr(w)|0)if(!P)l=5;else for(f=1;;){if(w=lt(7,0,(15-f|0)*3|0)|0,!((w&l|0)==0&((ee()|0)&a|0)==0)){l=2;break e}if(f>>>0<P>>>0)f=f+1|0;else{l=5;break}}else l=2;while(!1);vi(u|0,-1,l<<2|0)|0;e:do if(g)for(x=0;;){if(w=F+(x<<4)|0,au(w,o[z>>2]|0)|0,w=o[w>>2]|0,P=o[u>>2]|0,(P|0)==-1|(P|0)==(w|0))f=u;else{g=0;do{if(g=g+1|0,g>>>0>=l>>>0){f=1;break e}f=u+(g<<2)|0,P=o[f>>2]|0}while(!((P|0)==-1|(P|0)==(w|0)))}if(o[f>>2]=w,x=x+1|0,x>>>0>=C>>>0){f=0;break}}else for(x=0;;){if(w=F+(x<<4)|0,Mn(w,o[z>>2]|0,0,1)|0,w=o[w>>2]|0,P=o[u>>2]|0,(P|0)==-1|(P|0)==(w|0))f=u;else{g=0;do{if(g=g+1|0,g>>>0>=l>>>0){f=1;break e}f=u+(g<<2)|0,P=o[f>>2]|0}while(!((P|0)==-1|(P|0)==(w|0)))}if(o[f>>2]=w,x=x+1|0,x>>>0>=C>>>0){f=0;break}}while(!1)}return F=f,H=K,F|0}function yl(){return 12}function vl(l,a){l=l|0,a=a|0;var u=0,f=0,g=0,x=0,w=0,P=0,C=0;if(l>>>0>15)return P=4,P|0;if(lt(l|0,0,52)|0,P=ee()|0|134225919,!l){u=0,f=0;do yr(f)|0&&(lt(f|0,0,45)|0,w=P|(ee()|0),l=a+(u<<3)|0,o[l>>2]=-1,o[l+4>>2]=w,u=u+1|0),f=f+1|0;while((f|0)!=122);return u=0,u|0}u=0,w=0;do{if(yr(w)|0){for(lt(w|0,0,45)|0,f=1,g=-1,x=P|(ee()|0);C=lt(7,0,(15-f|0)*3|0)|0,g=g&~C,x=x&~(ee()|0),(f|0)!=(l|0);)f=f+1|0;C=a+(u<<3)|0,o[C>>2]=g,o[C+4>>2]=x,u=u+1|0}w=w+1|0}while((w|0)!=122);return u=0,u|0}function dA(l,a,u,f){l=l|0,a=a|0,u=u|0,f=f|0;var g=0,x=0,w=0,P=0,C=0,z=0,F=0,K=0,ae=0,oe=0,le=0,xe=0,Ee=0,Ue=0,Se=0;if(Se=H,H=H+16|0,Ee=Se,Ue=Ye(l|0,a|0,52)|0,ee()|0,Ue=Ue&15,u>>>0>15)return Ue=4,H=Se,Ue|0;if((Ue|0)<(u|0))return Ue=12,H=Se,Ue|0;if((Ue|0)!=(u|0))if(x=lt(u|0,0,52)|0,x=x|l,P=ee()|0|a&-15728641,(Ue|0)>(u|0)){C=u;do xe=lt(7,0,(14-C|0)*3|0)|0,C=C+1|0,x=xe|x,P=ee()|0|P;while((C|0)<(Ue|0));xe=x}else xe=x;else xe=l,P=a;le=Ye(xe|0,P|0,45)|0,ee()|0;e:do if(yr(le&127)|0){if(C=Ye(xe|0,P|0,52)|0,ee()|0,C=C&15,C|0)for(x=1;;){if(le=lt(7,0,(15-x|0)*3|0)|0,!((le&xe|0)==0&((ee()|0)&P|0)==0)){z=33;break e}if(x>>>0<C>>>0)x=x+1|0;else break}if(le=f,o[le>>2]=0,o[le+4>>2]=0,(Ue|0)>(u|0)){for(le=a&-15728641,oe=Ue;;){if(ae=oe,oe=oe+-1|0,oe>>>0>15|(Ue|0)<(oe|0)){z=19;break}if((Ue|0)!=(oe|0))if(x=lt(oe|0,0,52)|0,x=x|l,C=ee()|0|le,(Ue|0)<(ae|0))K=x;else{z=oe;do K=lt(7,0,(14-z|0)*3|0)|0,z=z+1|0,x=K|x,C=ee()|0|C;while((z|0)<(Ue|0));K=x}else K=l,C=a;if(F=Ye(K|0,C|0,45)|0,ee()|0,!(yr(F&127)|0))x=0;else{F=Ye(K|0,C|0,52)|0,ee()|0,F=F&15;t:do if(!F)x=0;else for(z=1;;){if(x=Ye(K|0,C|0,(15-z|0)*3|0)|0,ee()|0,x=x&7,x|0)break t;if(z>>>0<F>>>0)z=z+1|0;else{x=0;break}}while(!1);x=(x|0)==0&1}if(C=Ye(l|0,a|0,(15-ae|0)*3|0)|0,ee()|0,C=C&7,(C|0)==7){g=5,z=42;break}if(x=(x|0)!=0,(C|0)==1&x){g=5,z=42;break}if(K=C+(((C|0)!=0&x)<<31>>31)|0,K|0&&(z=Ue-ae|0,z=yn(7,0,z,((z|0)<0)<<31>>31)|0,F=ee()|0,x?(x=Ir(z|0,F|0,5,0)|0,x=Dt(x|0,ee()|0,-5,-1)|0,x=yi(x|0,ee()|0,6,0)|0,x=Dt(x|0,ee()|0,1,0)|0,C=ee()|0):(x=z,C=F),ae=K+-1|0,ae=Ir(z|0,F|0,ae|0,((ae|0)<0)<<31>>31|0)|0,ae=Dt(x|0,C|0,ae|0,ee()|0)|0,K=ee()|0,F=f,F=Dt(ae|0,K|0,o[F>>2]|0,o[F+4>>2]|0)|0,K=ee()|0,ae=f,o[ae>>2]=F,o[ae+4>>2]=K),(oe|0)<=(u|0)){z=37;break}}if((z|0)==19)zt(27795,27122,1367,27158);else if((z|0)==37){w=f,g=o[w+4>>2]|0,w=o[w>>2]|0;break}else if((z|0)==42)return H=Se,g|0}else g=0,w=0}else z=33;while(!1);e:do if((z|0)==33)if(le=f,o[le>>2]=0,o[le+4>>2]=0,(Ue|0)>(u|0)){for(x=Ue;;){if(g=Ye(l|0,a|0,(15-x|0)*3|0)|0,ee()|0,g=g&7,(g|0)==7){g=5;break}if(w=Ue-x|0,w=yn(7,0,w,((w|0)<0)<<31>>31)|0,g=Ir(w|0,ee()|0,g|0,0)|0,w=ee()|0,le=f,w=Dt(o[le>>2]|0,o[le+4>>2]|0,g|0,w|0)|0,g=ee()|0,le=f,o[le>>2]=w,o[le+4>>2]=g,x=x+-1|0,(x|0)<=(u|0))break e}return H=Se,g|0}else g=0,w=0;while(!1);return Fo(xe,P,Ue,Ee)|0&&zt(27795,27122,1327,27173),Ue=Ee,Ee=o[Ue+4>>2]|0,((g|0)>-1|(g|0)==-1&w>>>0>4294967295)&((Ee|0)>(g|0)|((Ee|0)==(g|0)?(o[Ue>>2]|0)>>>0>w>>>0:0))?(Ue=0,H=Se,Ue|0):(zt(27795,27122,1407,27158),0)}function Au(l,a,u,f,g,x){l=l|0,a=a|0,u=u|0,f=f|0,g=g|0,x=x|0;var w=0,P=0,C=0,z=0,F=0,K=0,ae=0,oe=0,le=0,xe=0;if(K=H,H=H+16|0,w=K,g>>>0>15)return x=4,H=K,x|0;if(P=Ye(u|0,f|0,52)|0,ee()|0,P=P&15,(P|0)>(g|0))return x=12,H=K,x|0;if(Fo(u,f,g,w)|0&&zt(27795,27122,1327,27173),F=w,z=o[F+4>>2]|0,!(((a|0)>-1|(a|0)==-1&l>>>0>4294967295)&((z|0)>(a|0)|((z|0)==(a|0)?(o[F>>2]|0)>>>0>l>>>0:0))))return x=2,H=K,x|0;F=g-P|0,g=lt(g|0,0,52)|0,C=ee()|0|f&-15728641,z=x,o[z>>2]=g|u,o[z+4>>2]=C,z=Ye(u|0,f|0,45)|0,ee()|0;e:do if(yr(z&127)|0){if(P|0)for(w=1;;){if(z=lt(7,0,(15-w|0)*3|0)|0,!((z&u|0)==0&((ee()|0)&f|0)==0))break e;if(w>>>0<P>>>0)w=w+1|0;else break}if((F|0)<1)return x=0,H=K,x|0;for(z=P^15,f=-1,C=1,w=1;;){P=F-C|0,P=yn(7,0,P,((P|0)<0)<<31>>31)|0,u=ee()|0;do if(w)if(w=Ir(P|0,u|0,5,0)|0,w=Dt(w|0,ee()|0,-5,-1)|0,w=yi(w|0,ee()|0,6,0)|0,g=ee()|0,(a|0)>(g|0)|(a|0)==(g|0)&l>>>0>w>>>0){a=Dt(l|0,a|0,-1,-1)|0,a=Lr(a|0,ee()|0,w|0,g|0)|0,w=ee()|0,ae=x,le=o[ae>>2]|0,ae=o[ae+4>>2]|0,xe=(z+f|0)*3|0,oe=lt(7,0,xe|0)|0,ae=ae&~(ee()|0),f=yi(a|0,w|0,P|0,u|0)|0,l=ee()|0,g=Dt(f|0,l|0,2,0)|0,xe=lt(g|0,ee()|0,xe|0)|0,ae=ee()|0|ae,g=x,o[g>>2]=xe|le&~oe,o[g+4>>2]=ae,l=Ir(f|0,l|0,P|0,u|0)|0,l=Lr(a|0,w|0,l|0,ee()|0)|0,w=0,a=ee()|0;break}else{xe=x,oe=o[xe>>2]|0,xe=o[xe+4>>2]|0,le=lt(7,0,(z+f|0)*3|0)|0,xe=xe&~(ee()|0),w=x,o[w>>2]=oe&~le,o[w+4>>2]=xe,w=1;break}else oe=x,g=o[oe>>2]|0,oe=o[oe+4>>2]|0,f=(z+f|0)*3|0,ae=lt(7,0,f|0)|0,oe=oe&~(ee()|0),xe=yi(l|0,a|0,P|0,u|0)|0,w=ee()|0,f=lt(xe|0,w|0,f|0)|0,oe=ee()|0|oe,le=x,o[le>>2]=f|g&~ae,o[le+4>>2]=oe,w=Ir(xe|0,w|0,P|0,u|0)|0,l=Lr(l|0,a|0,w|0,ee()|0)|0,w=0,a=ee()|0;while(!1);if((F|0)>(C|0))f=~C,C=C+1|0;else{a=0;break}}return H=K,a|0}while(!1);if((F|0)<1)return xe=0,H=K,xe|0;for(g=P^15,w=1;;)if(le=F-w|0,le=yn(7,0,le,((le|0)<0)<<31>>31)|0,xe=ee()|0,C=x,u=o[C>>2]|0,C=o[C+4>>2]|0,P=(g-w|0)*3|0,f=lt(7,0,P|0)|0,C=C&~(ee()|0),ae=yi(l|0,a|0,le|0,xe|0)|0,oe=ee()|0,P=lt(ae|0,oe|0,P|0)|0,C=ee()|0|C,z=x,o[z>>2]=P|u&~f,o[z+4>>2]=C,xe=Ir(ae|0,oe|0,le|0,xe|0)|0,l=Lr(l|0,a|0,xe|0,ee()|0)|0,a=ee()|0,(F|0)<=(w|0)){a=0;break}else w=w+1|0;return H=K,a|0}function xl(l,a,u,f){l=l|0,a=a|0,u=u|0,f=f|0;var g=0,x=0,w=0;g=Ye(a|0,u|0,52)|0,ee()|0,g=g&15,(a|0)==0&(u|0)==0|((f|0)>15|(g|0)>(f|0))?(x=-1,a=-1,u=0,g=0):(a=_l(a,u,g+1|0,f)|0,w=(ee()|0)&-15728641,u=lt(f|0,0,52)|0,u=a|u,w=w|(ee()|0),a=(wr(u,w)|0)==0,x=g,a=a?-1:f,g=w),w=l,o[w>>2]=u,o[w+4>>2]=g,o[l+8>>2]=x,o[l+12>>2]=a}function bl(l,a,u,f){l=l|0,a=a|0,u=u|0,f=f|0;var g=0,x=0;if(g=Ye(l|0,a|0,52)|0,ee()|0,g=g&15,x=f+8|0,o[x>>2]=g,(l|0)==0&(a|0)==0|((u|0)>15|(g|0)>(u|0))){u=f,o[u>>2]=0,o[u+4>>2]=0,o[x>>2]=-1,o[f+12>>2]=-1;return}if(l=_l(l,a,g+1|0,u)|0,x=(ee()|0)&-15728641,g=lt(u|0,0,52)|0,g=l|g,x=x|(ee()|0),l=f,o[l>>2]=g,o[l+4>>2]=x,l=f+12|0,wr(g,x)|0){o[l>>2]=u;return}else{o[l>>2]=-1;return}}function wl(l){l=l|0;var a=0,u=0,f=0,g=0,x=0,w=0,P=0,C=0,z=0;if(u=l,a=o[u>>2]|0,u=o[u+4>>2]|0,!((a|0)==0&(u|0)==0)&&(f=Ye(a|0,u|0,52)|0,ee()|0,f=f&15,P=lt(1,0,(f^15)*3|0)|0,a=Dt(P|0,ee()|0,a|0,u|0)|0,u=ee()|0,P=l,o[P>>2]=a,o[P+4>>2]=u,P=l+8|0,w=o[P>>2]|0,!((f|0)<(w|0)))){for(C=l+12|0,x=f;;){if((x|0)==(w|0)){f=5;break}if(z=(x|0)==(o[C>>2]|0),g=(15-x|0)*3|0,f=Ye(a|0,u|0,g|0)|0,ee()|0,f=f&7,z&((f|0)==1&!0)){f=7;break}if(!((f|0)==7&!0)){f=10;break}if(z=lt(1,0,g|0)|0,a=Dt(a|0,u|0,z|0,ee()|0)|0,u=ee()|0,z=l,o[z>>2]=a,o[z+4>>2]=u,(x|0)>(w|0))x=x+-1|0;else{f=10;break}}if((f|0)==5){z=l,o[z>>2]=0,o[z+4>>2]=0,o[P>>2]=-1,o[C>>2]=-1;return}else if((f|0)==7){w=lt(1,0,g|0)|0,w=Dt(a|0,u|0,w|0,ee()|0)|0,P=ee()|0,z=l,o[z>>2]=w,o[z+4>>2]=P,o[C>>2]=x+-1;return}else if((f|0)==10)return}}function lr(l){l=+l;var a=0;return a=l<0?l+6.283185307179586:l,+(l>=6.283185307179586?a+-6.283185307179586:a)}function hs(l,a){return l=l|0,a=a|0,+Je(+(+Z[l>>3]-+Z[a>>3]))<17453292519943298e-27?(a=+Je(+(+Z[l+8>>3]-+Z[a+8>>3]))<17453292519943298e-27,a|0):(a=0,a|0)}function zi(l,a){switch(l=+l,a=a|0,a|0){case 1:{l=l<0?l+6.283185307179586:l;break}case 2:{l=l>0?l+-6.283185307179586:l;break}}return+l}function qa(l,a){l=l|0,a=a|0;var u=0,f=0,g=0,x=0;return g=+Z[a>>3],f=+Z[l>>3],x=+Yt(+((g-f)*.5)),u=+Yt(+((+Z[a+8>>3]-+Z[l+8>>3])*.5)),u=x*x+u*(+Jt(+g)*+Jt(+f)*u),+(+Zi(+ +wt(+u),+ +wt(+(1-u)))*2)}function so(l,a){l=l|0,a=a|0;var u=0,f=0,g=0,x=0;return g=+Z[a>>3],f=+Z[l>>3],x=+Yt(+((g-f)*.5)),u=+Yt(+((+Z[a+8>>3]-+Z[l+8>>3])*.5)),u=x*x+u*(+Jt(+g)*+Jt(+f)*u),+(+Zi(+ +wt(+u),+ +wt(+(1-u)))*2*6371.007180918475)}function oo(l,a){l=l|0,a=a|0;var u=0,f=0,g=0,x=0;return g=+Z[a>>3],f=+Z[l>>3],x=+Yt(+((g-f)*.5)),u=+Yt(+((+Z[a+8>>3]-+Z[l+8>>3])*.5)),u=x*x+u*(+Jt(+g)*+Jt(+f)*u),+(+Zi(+ +wt(+u),+ +wt(+(1-u)))*2*6371.007180918475*1e3)}function ya(l,a){l=l|0,a=a|0;var u=0,f=0,g=0,x=0,w=0;return x=+Z[a>>3],f=+Jt(+x),g=+Z[a+8>>3]-+Z[l+8>>3],w=f*+Yt(+g),u=+Z[l>>3],+ +Zi(+w,+(+Yt(+x)*+Jt(+u)-+Jt(+g)*(f*+Yt(+u))))}function jo(l,a,u,f){l=l|0,a=+a,u=+u,f=f|0;var g=0,x=0,w=0,P=0;if(u<1e-16){o[f>>2]=o[l>>2],o[f+4>>2]=o[l+4>>2],o[f+8>>2]=o[l+8>>2],o[f+12>>2]=o[l+12>>2];return}x=a<0?a+6.283185307179586:a,x=a>=6.283185307179586?x+-6.283185307179586:x;do if(x<1e-16)a=+Z[l>>3]+u,Z[f>>3]=a,g=f;else{if(g=+Je(+(x+-3.141592653589793))<1e-16,a=+Z[l>>3],g){a=a-u,Z[f>>3]=a,g=f;break}if(w=+Jt(+u),u=+Yt(+u),a=w*+Yt(+a)+ +Jt(+x)*(u*+Jt(+a)),a=a>1?1:a,a=+oa(+(a<-1?-1:a)),Z[f>>3]=a,+Je(+(a+-1.5707963267948966))<1e-16){Z[f>>3]=1.5707963267948966,Z[f+8>>3]=0;return}if(+Je(+(a+1.5707963267948966))<1e-16){Z[f>>3]=-1.5707963267948966,Z[f+8>>3]=0;return}if(P=1/+Jt(+a),x=u*+Yt(+x)*P,u=+Z[l>>3],a=P*((w-+Yt(+a)*+Yt(+u))/+Jt(+u)),w=x>1?1:x,a=a>1?1:a,a=+Z[l+8>>3]+ +Zi(+(w<-1?-1:w),+(a<-1?-1:a)),a>3.141592653589793)do a=a+-6.283185307179586;while(a>3.141592653589793);if(a<-3.141592653589793)do a=a+6.283185307179586;while(a<-3.141592653589793);Z[f+8>>3]=a;return}while(!1);if(+Je(+(a+-1.5707963267948966))<1e-16){Z[g>>3]=1.5707963267948966,Z[f+8>>3]=0;return}if(+Je(+(a+1.5707963267948966))<1e-16){Z[g>>3]=-1.5707963267948966,Z[f+8>>3]=0;return}if(a=+Z[l+8>>3],a>3.141592653589793)do a=a+-6.283185307179586;while(a>3.141592653589793);if(a<-3.141592653589793)do a=a+6.283185307179586;while(a<-3.141592653589793);Z[f+8>>3]=a}function _n(l,a){return l=l|0,a=a|0,l>>>0>15?(a=4,a|0):(Z[a>>3]=+Z[20656+(l<<3)>>3],a=0,a|0)}function mA(l,a){return l=l|0,a=a|0,l>>>0>15?(a=4,a|0):(Z[a>>3]=+Z[20784+(l<<3)>>3],a=0,a|0)}function gA(l,a){return l=l|0,a=a|0,l>>>0>15?(a=4,a|0):(Z[a>>3]=+Z[20912+(l<<3)>>3],a=0,a|0)}function Tl(l,a){return l=l|0,a=a|0,l>>>0>15?(a=4,a|0):(Z[a>>3]=+Z[21040+(l<<3)>>3],a=0,a|0)}function Xn(l,a){l=l|0,a=a|0;var u=0;return l>>>0>15?(a=4,a|0):(u=yn(7,0,l,((l|0)<0)<<31>>31)|0,u=Ir(u|0,ee()|0,120,0)|0,l=ee()|0,o[a>>2]=u|2,o[a+4>>2]=l,a=0,a|0)}function va(l,a,u){l=l|0,a=a|0,u=u|0;var f=0,g=0,x=0,w=0,P=0,C=0,z=0,F=0,K=0,ae=0;return ae=+Z[a>>3],F=+Z[l>>3],C=+Yt(+((ae-F)*.5)),x=+Z[a+8>>3],z=+Z[l+8>>3],w=+Yt(+((x-z)*.5)),P=+Jt(+F),K=+Jt(+ae),w=C*C+w*(K*P*w),w=+Zi(+ +wt(+w),+ +wt(+(1-w)))*2,C=+Z[u>>3],ae=+Yt(+((C-ae)*.5)),f=+Z[u+8>>3],x=+Yt(+((f-x)*.5)),g=+Jt(+C),x=ae*ae+x*(K*g*x),x=+Zi(+ +wt(+x),+ +wt(+(1-x)))*2,C=+Yt(+((F-C)*.5)),f=+Yt(+((z-f)*.5)),f=C*C+f*(P*g*f),f=+Zi(+ +wt(+f),+ +wt(+(1-f)))*2,g=(w+x+f)*.5,+(+Xs(+ +wt(+(+ai(+(g*.5))*+ai(+((g-w)*.5))*+ai(+((g-x)*.5))*+ai(+((g-f)*.5)))))*4)}function No(l,a,u){l=l|0,a=a|0,u=u|0;var f=0,g=0,x=0,w=0,P=0;if(P=H,H=H+192|0,x=P+168|0,w=P,g=cs(l,a,x)|0,g|0)return u=g,H=P,u|0;if(Bs(l,a,w)|0&&zt(27795,27190,415,27199),a=o[w>>2]|0,(a|0)>0){if(f=+va(w+8|0,w+8+(((a|0)!=1&1)<<4)|0,x)+0,(a|0)!=1){l=1;do g=l,l=l+1|0,f=f+ +va(w+8+(g<<4)|0,w+8+(((l|0)%(a|0)|0)<<4)|0,x);while((l|0)<(a|0))}}else f=0;return Z[u>>3]=f,u=0,H=P,u|0}function xa(l,a,u){return l=l|0,a=a|0,u=u|0,l=No(l,a,u)|0,l|0||(Z[u>>3]=+Z[u>>3]*6371.007180918475*6371.007180918475),l|0}function Za(l,a,u){return l=l|0,a=a|0,u=u|0,l=No(l,a,u)|0,l|0||(Z[u>>3]=+Z[u>>3]*6371.007180918475*6371.007180918475*1e3*1e3),l|0}function _A(l,a,u){l=l|0,a=a|0,u=u|0;var f=0,g=0,x=0,w=0,P=0,C=0,z=0,F=0;if(P=H,H=H+176|0,w=P,l=Do(l,a,w)|0,l|0)return w=l,H=P,w|0;if(Z[u>>3]=0,l=o[w>>2]|0,(l|0)<=1)return w=0,H=P,w|0;a=l+-1|0,l=0,f=+Z[w+8>>3],g=+Z[w+16>>3],x=0;do l=l+1|0,z=f,f=+Z[w+8+(l<<4)>>3],F=+Yt(+((f-z)*.5)),C=g,g=+Z[w+8+(l<<4)+8>>3],C=+Yt(+((g-C)*.5)),C=F*F+C*(+Jt(+f)*+Jt(+z)*C),x=x+ +Zi(+ +wt(+C),+ +wt(+(1-C)))*2;while((l|0)<(a|0));return Z[u>>3]=x,w=0,H=P,w|0}function Go(l,a,u){l=l|0,a=a|0,u=u|0;var f=0,g=0,x=0,w=0,P=0,C=0,z=0,F=0;if(P=H,H=H+176|0,w=P,l=Do(l,a,w)|0,l|0)return w=l,x=+Z[u>>3],x=x*6371.007180918475,Z[u>>3]=x,H=P,w|0;if(Z[u>>3]=0,l=o[w>>2]|0,(l|0)<=1)return w=0,x=0,x=x*6371.007180918475,Z[u>>3]=x,H=P,w|0;a=l+-1|0,l=0,f=+Z[w+8>>3],g=+Z[w+16>>3],x=0;do l=l+1|0,z=f,f=+Z[w+8+(l<<4)>>3],F=+Yt(+((f-z)*.5)),C=g,g=+Z[w+8+(l<<4)+8>>3],C=+Yt(+((g-C)*.5)),C=F*F+C*(+Jt(+z)*+Jt(+f)*C),x=x+ +Zi(+ +wt(+C),+ +wt(+(1-C)))*2;while((l|0)!=(a|0));return Z[u>>3]=x,w=0,F=x,F=F*6371.007180918475,Z[u>>3]=F,H=P,w|0}function Uo(l,a,u){l=l|0,a=a|0,u=u|0;var f=0,g=0,x=0,w=0,P=0,C=0,z=0,F=0;if(P=H,H=H+176|0,w=P,l=Do(l,a,w)|0,l|0)return w=l,x=+Z[u>>3],x=x*6371.007180918475,x=x*1e3,Z[u>>3]=x,H=P,w|0;if(Z[u>>3]=0,l=o[w>>2]|0,(l|0)<=1)return w=0,x=0,x=x*6371.007180918475,x=x*1e3,Z[u>>3]=x,H=P,w|0;a=l+-1|0,l=0,f=+Z[w+8>>3],g=+Z[w+16>>3],x=0;do l=l+1|0,z=f,f=+Z[w+8+(l<<4)>>3],F=+Yt(+((f-z)*.5)),C=g,g=+Z[w+8+(l<<4)+8>>3],C=+Yt(+((g-C)*.5)),C=F*F+C*(+Jt(+z)*+Jt(+f)*C),x=x+ +Zi(+ +wt(+C),+ +wt(+(1-C)))*2;while((l|0)!=(a|0));return Z[u>>3]=x,w=0,F=x,F=F*6371.007180918475,F=F*1e3,Z[u>>3]=F,H=P,w|0}function yA(l){l=l|0;var a=0,u=0,f=0;return a=Bi(1,12)|0,a||zt(27280,27235,49,27293),u=l+4|0,f=o[u>>2]|0,f|0?(f=f+8|0,o[f>>2]=a,o[u>>2]=a,a|0):(o[l>>2]|0&&zt(27310,27235,61,27333),f=l,o[f>>2]=a,o[u>>2]=a,a|0)}function Pl(l,a){l=l|0,a=a|0;var u=0,f=0;return f=In(24)|0,f||zt(27347,27235,78,27361),o[f>>2]=o[a>>2],o[f+4>>2]=o[a+4>>2],o[f+8>>2]=o[a+8>>2],o[f+12>>2]=o[a+12>>2],o[f+16>>2]=0,a=l+4|0,u=o[a>>2]|0,u|0?(o[u+16>>2]=f,o[a>>2]=f,f|0):(o[l>>2]|0&&zt(27376,27235,82,27361),o[l>>2]=f,o[a>>2]=f,f|0)}function tr(l){l=l|0;var a=0,u=0,f=0,g=0;if(l)for(f=1;;){if(a=o[l>>2]|0,a|0)do{if(u=o[a>>2]|0,u|0)do g=u,u=o[u+16>>2]|0,kt(g);while((u|0)!=0);g=a,a=o[a+8>>2]|0,kt(g)}while((a|0)!=0);if(a=l,l=o[l+8>>2]|0,f||kt(a),l)f=0;else break}}function Qa(l){l=l|0;var a=0,u=0,f=0,g=0,x=0,w=0,P=0,C=0,z=0,F=0,K=0,ae=0,oe=0,le=0,xe=0,Ee=0,Ue=0,Se=0,Pe=0,we=0,ct=0,St=0,Mt=0,jt=0,$t=0,ir=0,Rt=0,Et=0,At=0,at=0,dt=0,Nt=0;if(g=l+8|0,o[g>>2]|0)return Nt=1,Nt|0;if(f=o[l>>2]|0,!f)return Nt=0,Nt|0;a=f,u=0;do u=u+1|0,a=o[a+8>>2]|0;while((a|0)!=0);if(u>>>0<2)return Nt=0,Nt|0;at=In(u<<2)|0,at||zt(27396,27235,317,27415),At=In(u<<5)|0,At||zt(27437,27235,321,27415),o[l>>2]=0,St=l+4|0,o[St>>2]=0,o[g>>2]=0,u=0,Et=0,ct=0,K=0;e:for(;;){if(F=o[f>>2]|0,F){x=0,w=F;do{if(C=+Z[w+8>>3],a=w,w=o[w+16>>2]|0,z=(w|0)==0,g=z?F:w,P=+Z[g+8>>3],+Je(+(C-P))>3.141592653589793){Nt=14;break}x=x+(P-C)*(+Z[a>>3]+ +Z[g>>3])}while(!z);if((Nt|0)==14){Nt=0,x=0,a=F;do we=+Z[a+8>>3],Rt=a+16|0,ir=o[Rt>>2]|0,ir=(ir|0)==0?F:ir,Pe=+Z[ir+8>>3],x=x+(+Z[a>>3]+ +Z[ir>>3])*((Pe<0?Pe+6.283185307179586:Pe)-(we<0?we+6.283185307179586:we)),a=o[((a|0)==0?f:Rt)>>2]|0;while((a|0)!=0)}x>0?(o[at+(Et<<2)>>2]=f,Et=Et+1|0,g=ct,a=K):Nt=19}else Nt=19;if((Nt|0)==19){Nt=0;do if(u){if(a=u+8|0,o[a>>2]|0){Nt=21;break e}if(u=Bi(1,12)|0,!u){Nt=23;break e}o[a>>2]=u,g=u+4|0,w=u,a=K}else if(K){g=St,w=K+8|0,a=f,u=l;break}else if(o[l>>2]|0){Nt=27;break e}else{g=St,w=l,a=f,u=l;break}while(!1);if(o[w>>2]=f,o[g>>2]=f,w=At+(ct<<5)|0,z=o[f>>2]|0,z){for(F=At+(ct<<5)+8|0,Z[F>>3]=17976931348623157e292,K=At+(ct<<5)+24|0,Z[K>>3]=17976931348623157e292,Z[w>>3]=-17976931348623157e292,ae=At+(ct<<5)+16|0,Z[ae>>3]=-17976931348623157e292,Ue=17976931348623157e292,Se=-17976931348623157e292,g=0,oe=z,C=17976931348623157e292,xe=17976931348623157e292,Ee=-17976931348623157e292,P=-17976931348623157e292;x=+Z[oe>>3],we=+Z[oe+8>>3],oe=o[oe+16>>2]|0,le=(oe|0)==0,Pe=+Z[(le?z:oe)+8>>3],x<C&&(Z[F>>3]=x,C=x),we<xe&&(Z[K>>3]=we,xe=we),x>Ee?Z[w>>3]=x:x=Ee,we>P&&(Z[ae>>3]=we,P=we),Ue=we>0&we<Ue?we:Ue,Se=we<0&we>Se?we:Se,g=g|+Je(+(we-Pe))>3.141592653589793,!le;)Ee=x;g&&(Z[ae>>3]=Se,Z[K>>3]=Ue)}else o[w>>2]=0,o[w+4>>2]=0,o[w+8>>2]=0,o[w+12>>2]=0,o[w+16>>2]=0,o[w+20>>2]=0,o[w+24>>2]=0,o[w+28>>2]=0;g=ct+1|0}if(Rt=f+8|0,f=o[Rt>>2]|0,o[Rt>>2]=0,f)ct=g,K=a;else{Nt=45;break}}if((Nt|0)==21)zt(27213,27235,35,27247);else if((Nt|0)==23)zt(27267,27235,37,27247);else if((Nt|0)==27)zt(27310,27235,61,27333);else if((Nt|0)==45){e:do if((Et|0)>0){for(Rt=(g|0)==0,$t=g<<2,ir=(l|0)==0,jt=0,a=0;;){if(Mt=o[at+(jt<<2)>>2]|0,Rt)Nt=73;else{if(ct=In($t)|0,!ct){Nt=50;break}if(St=In($t)|0,!St){Nt=52;break}t:do if(ir)u=0;else{for(g=0,u=0,w=l;f=At+(g<<5)|0,vA(o[w>>2]|0,f,o[Mt>>2]|0)|0?(o[ct+(u<<2)>>2]=w,o[St+(u<<2)>>2]=f,le=u+1|0):le=u,w=o[w+8>>2]|0,w;)g=g+1|0,u=le;if((le|0)>0)if(f=o[ct>>2]|0,(le|0)==1)u=f;else for(ae=0,oe=-1,u=f,K=f;;){for(z=o[K>>2]|0,f=0,w=0;g=o[o[ct+(w<<2)>>2]>>2]|0,(g|0)==(z|0)?F=f:F=f+((vA(g,o[St+(w<<2)>>2]|0,o[z>>2]|0)|0)&1)|0,w=w+1|0,(w|0)!=(le|0);)f=F;if(g=(F|0)>(oe|0),u=g?K:u,f=ae+1|0,(f|0)==(le|0))break t;ae=f,oe=g?F:oe,K=o[ct+(f<<2)>>2]|0}else u=0}while(!1);if(kt(ct),kt(St),u){if(g=u+4|0,f=o[g>>2]|0,f)u=f+8|0;else if(o[u>>2]|0){Nt=70;break}o[u>>2]=Mt,o[g>>2]=Mt}else Nt=73}if((Nt|0)==73){if(Nt=0,a=o[Mt>>2]|0,a|0)do St=a,a=o[a+16>>2]|0,kt(St);while((a|0)!=0);kt(Mt),a=1}if(jt=jt+1|0,(jt|0)>=(Et|0)){dt=a;break e}}(Nt|0)==50?zt(27452,27235,249,27471):(Nt|0)==52?zt(27490,27235,252,27471):(Nt|0)==70&&zt(27310,27235,61,27333)}else dt=0;while(!1);return kt(at),kt(At),Nt=dt,Nt|0}return 0}function vA(l,a,u){l=l|0,a=a|0,u=u|0;var f=0,g=0,x=0,w=0,P=0,C=0,z=0,F=0;if(!(Ss(a,u)|0)||(a=tn(a)|0,f=+Z[u>>3],g=+Z[u+8>>3],g=a&g<0?g+6.283185307179586:g,l=o[l>>2]|0,!l))return l=0,l|0;if(a){a=0,z=g,u=l;e:for(;;){for(;w=+Z[u>>3],g=+Z[u+8>>3],u=u+16|0,F=o[u>>2]|0,F=(F|0)==0?l:F,x=+Z[F>>3],P=+Z[F+8>>3],w>x?(C=w,w=P):(C=x,x=w,w=g,g=P),f=f==x|f==C?f+2220446049250313e-31:f,!!(f<x|f>C);)if(u=o[u>>2]|0,!u){u=22;break e}if(P=w<0?w+6.283185307179586:w,w=g<0?g+6.283185307179586:g,z=P==z|w==z?z+-2220446049250313e-31:z,C=P+(w-P)*((f-x)/(C-x)),(C<0?C+6.283185307179586:C)>z&&(a=a^1),u=o[u>>2]|0,!u){u=22;break}}if((u|0)==22)return a|0}else{a=0,z=g,u=l;e:for(;;){for(;w=+Z[u>>3],g=+Z[u+8>>3],u=u+16|0,F=o[u>>2]|0,F=(F|0)==0?l:F,x=+Z[F>>3],P=+Z[F+8>>3],w>x?(C=w,w=P):(C=x,x=w,w=g,g=P),f=f==x|f==C?f+2220446049250313e-31:f,!!(f<x|f>C);)if(u=o[u>>2]|0,!u){u=22;break e}if(z=w==z|g==z?z+-2220446049250313e-31:z,w+(g-w)*((f-x)/(C-x))>z&&(a=a^1),u=o[u>>2]|0,!u){u=22;break}}if((u|0)==22)return a|0}return 0}function Yn(l,a,u,f,g){l=l|0,a=a|0,u=u|0,f=f|0,g=g|0;var x=0,w=0,P=0,C=0,z=0,F=0,K=0,ae=0,oe=0,le=0,xe=0,Ee=0,Ue=0,Se=0;if(Se=H,H=H+32|0,Ue=Se+16|0,Ee=Se,x=Ye(l|0,a|0,52)|0,ee()|0,x=x&15,oe=Ye(u|0,f|0,52)|0,ee()|0,(x|0)!=(oe&15|0))return Ue=12,H=Se,Ue|0;if(z=Ye(l|0,a|0,45)|0,ee()|0,z=z&127,F=Ye(u|0,f|0,45)|0,ee()|0,F=F&127,z>>>0>121|F>>>0>121)return Ue=5,H=Se,Ue|0;if(oe=(z|0)!=(F|0),oe){if(P=Bt(z,F)|0,(P|0)==7)return Ue=1,H=Se,Ue|0;C=Bt(F,z)|0,(C|0)==7?zt(27514,27538,161,27548):(le=P,w=C)}else le=0,w=0;K=yr(z)|0,ae=yr(F)|0,o[Ue>>2]=0,o[Ue+4>>2]=0,o[Ue+8>>2]=0,o[Ue+12>>2]=0;do if(le){if(F=o[4272+(z*28|0)+(le<<2)>>2]|0,P=(F|0)>0,ae)if(P){z=0,C=u,P=f;do C=pA(C,P)|0,P=ee()|0,w=us(w)|0,(w|0)==1&&(w=us(1)|0),z=z+1|0;while((z|0)!=(F|0));F=w,z=C,C=P}else F=w,z=u,C=f;else if(P){z=0,C=u,P=f;do C=_a(C,P)|0,P=ee()|0,w=us(w)|0,z=z+1|0;while((z|0)!=(F|0));F=w,z=C,C=P}else F=w,z=u,C=f;if(Vo(z,C,Ue)|0,oe||zt(27563,27538,191,27548),P=(K|0)!=0,w=(ae|0)!=0,P&w&&zt(27590,27538,192,27548),P){if(w=sn(l,a)|0,(w|0)==7){x=5;break}if(ot[22e3+(w*7|0)+le>>0]|0){x=1;break}C=o[21168+(w*28|0)+(le<<2)>>2]|0,z=C}else if(w){if(w=sn(z,C)|0,(w|0)==7){x=5;break}if(ot[22e3+(w*7|0)+F>>0]|0){x=1;break}z=0,C=o[21168+(F*28|0)+(w<<2)>>2]|0}else z=0,C=0;if((z|C|0)<0)x=5;else{if((C|0)>0){P=Ue+4|0,w=0;do Io(P),w=w+1|0;while((w|0)!=(C|0))}if(o[Ee>>2]=0,o[Ee+4>>2]=0,o[Ee+8>>2]=0,fl(Ee,le),x|0)for(;Wi(x)|0?As(Ee):nn(Ee),(x|0)>1;)x=x+-1|0;if((z|0)>0){x=0;do Io(Ee),x=x+1|0;while((x|0)!=(z|0))}xe=Ue+4|0,rr(xe,Ee,xe),gi(xe),xe=51}}else if(Vo(u,f,Ue)|0,(K|0)!=0&(ae|0)!=0)if((F|0)!=(z|0)&&zt(27621,27538,261,27548),w=sn(l,a)|0,x=sn(u,f)|0,(w|0)==7|(x|0)==7)x=5;else if(ot[22e3+(w*7|0)+x>>0]|0)x=1;else if(w=o[21168+(w*28|0)+(x<<2)>>2]|0,(w|0)>0){P=Ue+4|0,x=0;do Io(P),x=x+1|0;while((x|0)!=(w|0));xe=51}else xe=51;else xe=51;while(!1);return(xe|0)==51&&(x=Ue+4|0,o[g>>2]=o[x>>2],o[g+4>>2]=o[x+4>>2],o[g+8>>2]=o[x+8>>2],x=0),Ue=x,H=Se,Ue|0}function qo(l,a,u,f){l=l|0,a=a|0,u=u|0,f=f|0;var g=0,x=0,w=0,P=0,C=0,z=0,F=0,K=0,ae=0,oe=0,le=0,xe=0,Ee=0,Ue=0,Se=0,Pe=0;if(xe=H,H=H+48|0,z=xe+36|0,w=xe+24|0,P=xe+12|0,C=xe,g=Ye(l|0,a|0,52)|0,ee()|0,g=g&15,ae=Ye(l|0,a|0,45)|0,ee()|0,ae=ae&127,ae>>>0>121)return f=5,H=xe,f|0;if(F=yr(ae)|0,lt(g|0,0,52)|0,Ee=ee()|0|134225919,x=f,o[x>>2]=-1,o[x+4>>2]=Ee,!g)return g=Zt(u)|0,(g|0)==7||(g=Cr(ae,g)|0,(g|0)==127)?(Ee=1,H=xe,Ee|0):(oe=lt(g|0,0,45)|0,le=ee()|0,ae=f,le=o[ae+4>>2]&-1040385|le,Ee=f,o[Ee>>2]=o[ae>>2]|oe,o[Ee+4>>2]=le,Ee=0,H=xe,Ee|0);for(o[z>>2]=o[u>>2],o[z+4>>2]=o[u+4>>2],o[z+8>>2]=o[u+8>>2],u=g;;){if(x=u,u=u+-1|0,o[w>>2]=o[z>>2],o[w+4>>2]=o[z+4>>2],o[w+8>>2]=o[z+8>>2],Wi(x)|0){if(g=Mo(z)|0,g|0){u=13;break}o[P>>2]=o[z>>2],o[P+4>>2]=o[z+4>>2],o[P+8>>2]=o[z+8>>2],As(P)}else{if(g=ur(z)|0,g|0){u=13;break}o[P>>2]=o[z>>2],o[P+4>>2]=o[z+4>>2],o[P+8>>2]=o[z+8>>2],nn(P)}if(Ds(w,P,C),gi(C),g=f,Se=o[g>>2]|0,g=o[g+4>>2]|0,Pe=(15-x|0)*3|0,Ue=lt(7,0,Pe|0)|0,g=g&~(ee()|0),Pe=lt(Zt(C)|0,0,Pe|0)|0,g=ee()|0|g,Ee=f,o[Ee>>2]=Pe|Se&~Ue,o[Ee+4>>2]=g,(x|0)<=1){u=14;break}}e:do if((u|0)!=13&&(u|0)==14)if((o[z>>2]|0)<=1&&(o[z+4>>2]|0)<=1&&(o[z+8>>2]|0)<=1){u=Zt(z)|0,g=Cr(ae,u)|0,(g|0)==127?C=0:C=yr(g)|0;t:do if(u){if(F){if(g=sn(l,a)|0,(g|0)==7){g=5;break e}if(x=o[21376+(g*28|0)+(u<<2)>>2]|0,(x|0)>0){g=u,u=0;do g=to(g)|0,u=u+1|0;while((u|0)!=(x|0))}else g=u;if((g|0)==1){g=9;break e}u=Cr(ae,g)|0,(u|0)==127&&zt(27648,27538,411,27678),yr(u)|0?zt(27693,27538,412,27678):(le=u,oe=x,K=g)}else le=g,oe=0,K=u;if(P=o[4272+(ae*28|0)+(K<<2)>>2]|0,(P|0)<=-1&&zt(27724,27538,419,27678),!C){if((oe|0)<0){g=5;break e}if(oe|0){x=f,g=0,u=o[x>>2]|0,x=o[x+4>>2]|0;do u=jn(u,x)|0,x=ee()|0,Pe=f,o[Pe>>2]=u,o[Pe+4>>2]=x,g=g+1|0;while((g|0)<(oe|0))}if((P|0)<=0){g=le,u=58;break}for(x=f,g=0,u=o[x>>2]|0,x=o[x+4>>2]|0;;)if(u=jn(u,x)|0,x=ee()|0,Pe=f,o[Pe>>2]=u,o[Pe+4>>2]=x,g=g+1|0,(g|0)==(P|0)){g=le,u=58;break t}}if(w=Bt(le,ae)|0,(w|0)==7&&zt(27514,27538,428,27678),g=f,u=o[g>>2]|0,g=o[g+4>>2]|0,(P|0)>0){x=0;do u=jn(u,g)|0,g=ee()|0,Pe=f,o[Pe>>2]=u,o[Pe+4>>2]=g,x=x+1|0;while((x|0)!=(P|0))}if(g=sn(u,g)|0,(g|0)==7&&zt(27795,27538,440,27678),u=Kt(le)|0,u=o[(u?21792:21584)+(w*28|0)+(g<<2)>>2]|0,(u|0)<0&&zt(27795,27538,454,27678),!u)g=le,u=58;else{w=f,g=0,x=o[w>>2]|0,w=o[w+4>>2]|0;do x=Ga(x,w)|0,w=ee()|0,Pe=f,o[Pe>>2]=x,o[Pe+4>>2]=w,g=g+1|0;while((g|0)<(u|0));g=le,u=58}}else if((F|0)!=0&(C|0)!=0){if(u=sn(l,a)|0,x=f,x=sn(o[x>>2]|0,o[x+4>>2]|0)|0,(u|0)==7|(x|0)==7){g=5;break e}if(x=o[21376+(u*28|0)+(x<<2)>>2]|0,(x|0)<0){g=5;break e}if(!x)u=59;else{P=f,u=0,w=o[P>>2]|0,P=o[P+4>>2]|0;do w=jn(w,P)|0,P=ee()|0,Pe=f,o[Pe>>2]=w,o[Pe+4>>2]=P,u=u+1|0;while((u|0)<(x|0));u=58}}else u=58;while(!1);if((u|0)==58&&C&&(u=59),(u|0)==59&&(Pe=f,(sn(o[Pe>>2]|0,o[Pe+4>>2]|0)|0)==1)){g=9;break}Pe=f,Ue=o[Pe>>2]|0,Pe=o[Pe+4>>2]&-1040385,Se=lt(g|0,0,45)|0,Pe=Pe|(ee()|0),g=f,o[g>>2]=Ue|Se,o[g+4>>2]=Pe,g=0}else g=1;while(!1);return Pe=g,H=xe,Pe|0}function uu(l,a,u,f,g,x){l=l|0,a=a|0,u=u|0,f=f|0,g=g|0,x=x|0;var w=0,P=0;return P=H,H=H+16|0,w=P,g?l=15:(l=Yn(l,a,u,f,w)|0,l||(ro(w,x),l=0)),H=P,l|0}function cu(l,a,u,f,g){l=l|0,a=a|0,u=u|0,f=f|0,g=g|0;var x=0,w=0;return w=H,H=H+16|0,x=w,f?u=15:(u=dl(u,x)|0,u||(u=qo(l,a,x,g)|0)),H=w,u|0}function xA(l,a,u,f,g){l=l|0,a=a|0,u=u|0,f=f|0,g=g|0;var x=0,w=0,P=0,C=0;return C=H,H=H+32|0,w=C+12|0,P=C,x=Yn(l,a,l,a,w)|0,x|0?(P=x,H=C,P|0):(l=Yn(l,a,u,f,P)|0,l|0?(P=l,H=C,P|0):(w=Sr(w,P)|0,P=g,o[P>>2]=w,o[P+4>>2]=((w|0)<0)<<31>>31,P=0,H=C,P|0))}function hu(l,a,u,f,g){l=l|0,a=a|0,u=u|0,f=f|0,g=g|0;var x=0,w=0,P=0,C=0;return C=H,H=H+32|0,w=C+12|0,P=C,x=Yn(l,a,l,a,w)|0,!x&&(x=Yn(l,a,u,f,P)|0,!x)?(f=Sr(w,P)|0,f=Dt(f|0,((f|0)<0)<<31>>31|0,1,0)|0,w=ee()|0,P=g,o[P>>2]=f,o[P+4>>2]=w,P=0,H=C,P|0):(P=x,H=C,P|0)}function Ml(l,a,u,f,g){l=l|0,a=a|0,u=u|0,f=f|0,g=g|0;var x=0,w=0,P=0,C=0,z=0,F=0,K=0,ae=0,oe=0,le=0,xe=0,Ee=0,Ue=0,Se=0,Pe=0,we=0,ct=0,St=0,Mt=0,jt=0;if(Mt=H,H=H+48|0,ct=Mt+24|0,w=Mt+12|0,St=Mt,x=Yn(l,a,l,a,ct)|0,!x&&(x=Yn(l,a,u,f,w)|0,!x)){Pe=Sr(ct,w)|0,we=((Pe|0)<0)<<31>>31,o[ct>>2]=0,o[ct+4>>2]=0,o[ct+8>>2]=0,o[w>>2]=0,o[w+4>>2]=0,o[w+8>>2]=0,Yn(l,a,l,a,ct)|0&&zt(27795,27538,692,27747),Yn(l,a,u,f,w)|0&&zt(27795,27538,697,27747),So(ct),So(w),F=(Pe|0)==0?0:1/+(Pe|0),u=o[ct>>2]|0,xe=F*+((o[w>>2]|0)-u|0),Ee=ct+4|0,f=o[Ee>>2]|0,Ue=F*+((o[w+4>>2]|0)-f|0),Se=ct+8|0,x=o[Se>>2]|0,F=F*+((o[w+8>>2]|0)-x|0),o[St>>2]=u,K=St+4|0,o[K>>2]=f,ae=St+8|0,o[ae>>2]=x;e:do if((Pe|0)<0)x=0;else for(oe=0,le=0;;){C=+(le>>>0)+4294967296*+(oe|0),jt=xe*C+ +(u|0),P=Ue*C+ +(f|0),C=F*C+ +(x|0),u=~~+ds(+jt),w=~~+ds(+P),x=~~+ds(+C),jt=+Je(+(+(u|0)-jt)),P=+Je(+(+(w|0)-P)),C=+Je(+(+(x|0)-C));do if(jt>P&jt>C)u=0-(w+x)|0,f=w;else if(z=0-u|0,P>C){f=z-x|0;break}else{f=w,x=z-w|0;break}while(!1);if(o[St>>2]=u,o[K>>2]=f,o[ae>>2]=x,$r(St),x=qo(l,a,St,g+(le<<3)|0)|0,x|0)break e;if(!((oe|0)<(we|0)|(oe|0)==(we|0)&le>>>0<Pe>>>0)){x=0;break e}u=Dt(le|0,oe|0,1,0)|0,f=ee()|0,oe=f,le=u,u=o[ct>>2]|0,f=o[Ee>>2]|0,x=o[Se>>2]|0}while(!1);return St=x,H=Mt,St|0}return St=x,H=Mt,St|0}function yn(l,a,u,f){l=l|0,a=a|0,u=u|0,f=f|0;var g=0,x=0,w=0;if((u|0)==0&(f|0)==0)return g=0,x=1,Pt(g|0),x|0;x=l,g=a,l=1,a=0;do w=(u&1|0)==0&!0,l=Ir((w?1:x)|0,(w?0:g)|0,l|0,a|0)|0,a=ee()|0,u=Ho(u|0,f|0,1)|0,f=ee()|0,x=Ir(x|0,g|0,x|0,g|0)|0,g=ee()|0;while(!((u|0)==0&(f|0)==0));return Pt(a|0),l|0}function ao(l,a,u,f){l=l|0,a=a|0,u=u|0,f=f|0;var g=0,x=0,w=0,P=0,C=0,z=0,F=0;P=H,H=H+16|0,x=P,w=Ye(l|0,a|0,52)|0,ee()|0,w=w&15;do if(w){if(g=cs(l,a,x)|0,!g){z=+Z[x>>3],C=1/+Jt(+z),F=+Z[25968+(w<<3)>>3],Z[u>>3]=z+F,Z[u+8>>3]=z-F,z=+Z[x+8>>3],C=F*C,Z[u+16>>3]=C+z,Z[u+24>>3]=z-C;break}return w=g,H=P,w|0}else{if(g=Ye(l|0,a|0,45)|0,ee()|0,g=g&127,g>>>0>121)return w=5,H=P,w|0;x=22064+(g<<5)|0,o[u>>2]=o[x>>2],o[u+4>>2]=o[x+4>>2],o[u+8>>2]=o[x+8>>2],o[u+12>>2]=o[x+12>>2],o[u+16>>2]=o[x+16>>2],o[u+20>>2]=o[x+20>>2],o[u+24>>2]=o[x+24>>2],o[u+28>>2]=o[x+28>>2];break}while(!1);return eo(u,f?1.4:1.1),f=26096+(w<<3)|0,(o[f>>2]|0)==(l|0)&&(o[f+4>>2]|0)==(a|0)&&(Z[u>>3]=1.5707963267948966),w=26224+(w<<3)|0,(o[w>>2]|0)==(l|0)&&(o[w+4>>2]|0)==(a|0)&&(Z[u+8>>3]=-1.5707963267948966),+Z[u>>3]!=1.5707963267948966&&+Z[u+8>>3]!=-1.5707963267948966?(w=0,H=P,w|0):(Z[u+16>>3]=3.141592653589793,Z[u+24>>3]=-3.141592653589793,w=0,H=P,w|0)}function $a(l,a,u,f){l=l|0,a=a|0,u=u|0,f=f|0;var g=0,x=0,w=0,P=0,C=0,z=0,F=0;z=H,H=H+48|0,w=z+32|0,x=z+40|0,P=z,ga(w,0,0,0),C=o[w>>2]|0,w=o[w+4>>2]|0;do if(u>>>0<=15){if(g=lo(f)|0,g|0){f=P,o[f>>2]=0,o[f+4>>2]=0,o[P+8>>2]=g,o[P+12>>2]=-1,f=P+16|0,C=P+29|0,o[f>>2]=0,o[f+4>>2]=0,o[f+8>>2]=0,ot[f+12>>0]=0,ot[C>>0]=ot[x>>0]|0,ot[C+1>>0]=ot[x+1>>0]|0,ot[C+2>>0]=ot[x+2>>0]|0;break}if(g=Bi((o[a+8>>2]|0)+1|0,32)|0,g){El(a,g),F=P,o[F>>2]=C,o[F+4>>2]=w,o[P+8>>2]=0,o[P+12>>2]=u,o[P+16>>2]=f,o[P+20>>2]=a,o[P+24>>2]=g,ot[P+28>>0]=0,C=P+29|0,ot[C>>0]=ot[x>>0]|0,ot[C+1>>0]=ot[x+1>>0]|0,ot[C+2>>0]=ot[x+2>>0]|0;break}else{f=P,o[f>>2]=0,o[f+4>>2]=0,o[P+8>>2]=13,o[P+12>>2]=-1,f=P+16|0,C=P+29|0,o[f>>2]=0,o[f+4>>2]=0,o[f+8>>2]=0,ot[f+12>>0]=0,ot[C>>0]=ot[x>>0]|0,ot[C+1>>0]=ot[x+1>>0]|0,ot[C+2>>0]=ot[x+2>>0]|0;break}}else C=P,o[C>>2]=0,o[C+4>>2]=0,o[P+8>>2]=4,o[P+12>>2]=-1,C=P+16|0,F=P+29|0,o[C>>2]=0,o[C+4>>2]=0,o[C+8>>2]=0,ot[C+12>>0]=0,ot[F>>0]=ot[x>>0]|0,ot[F+1>>0]=ot[x+1>>0]|0,ot[F+2>>0]=ot[x+2>>0]|0;while(!1);Zo(P),o[l>>2]=o[P>>2],o[l+4>>2]=o[P+4>>2],o[l+8>>2]=o[P+8>>2],o[l+12>>2]=o[P+12>>2],o[l+16>>2]=o[P+16>>2],o[l+20>>2]=o[P+20>>2],o[l+24>>2]=o[P+24>>2],o[l+28>>2]=o[P+28>>2],H=z}function Zo(l){l=l|0;var a=0,u=0,f=0,g=0,x=0,w=0,P=0,C=0,z=0,F=0,K=0,ae=0,oe=0,le=0,xe=0,Ee=0,Ue=0,Se=0,Pe=0,we=0;if(we=H,H=H+336|0,oe=we+168|0,le=we,f=l,u=o[f>>2]|0,f=o[f+4>>2]|0,(u|0)==0&(f|0)==0){H=we;return}if(a=l+28|0,ot[a>>0]|0?(u=Wa(u,f)|0,f=ee()|0):ot[a>>0]=1,Pe=l+20|0,!(o[o[Pe>>2]>>2]|0)){a=l+24|0,u=o[a>>2]|0,u|0&&kt(u),Se=l,o[Se>>2]=0,o[Se+4>>2]=0,o[l+8>>2]=0,o[Pe>>2]=0,o[l+12>>2]=-1,o[l+16>>2]=0,o[a>>2]=0,H=we;return}Se=l+16|0,a=o[Se>>2]|0,g=a&15;e:do if((u|0)==0&(f|0)==0)Ue=l+24|0;else{xe=l+12|0,K=(g|0)==3,F=a&255,C=(g|1|0)==3,ae=l+24|0,z=(g+-1|0)>>>0<3,w=(g|2|0)==3,P=le+8|0;t:for(;;){if(x=Ye(u|0,f|0,52)|0,ee()|0,x=x&15,(x|0)==(o[xe>>2]|0)){switch(F&15){case 0:case 2:case 3:{if(g=cs(u,f,oe)|0,g|0){Ee=15;break t}if(Ao(o[Pe>>2]|0,o[ae>>2]|0,oe)|0){Ee=19;break t}break}}if(C&&(g=o[(o[Pe>>2]|0)+4>>2]|0,o[oe>>2]=o[g>>2],o[oe+4>>2]=o[g+4>>2],o[oe+8>>2]=o[g+8>>2],o[oe+12>>2]=o[g+12>>2],Ss(26832,oe)|0)){if(gn(o[(o[Pe>>2]|0)+4>>2]|0,x,le)|0){Ee=25;break}if(g=le,(o[g>>2]|0)==(u|0)&&(o[g+4>>2]|0)==(f|0)){Ee=29;break}}if(z){if(g=Bs(u,f,oe)|0,g|0){Ee=32;break}if(ao(u,f,le,0)|0){Ee=36;break}if(w&&bA(o[Pe>>2]|0,o[ae>>2]|0,oe,le)|0){Ee=42;break}if(C&&Qo(o[Pe>>2]|0,o[ae>>2]|0,oe,le)|0){Ee=42;break}}if(K){if(a=ao(u,f,oe,1)|0,g=o[ae>>2]|0,a|0){Ee=45;break}if(Hn(g,oe)|0){if(On(le,oe),Cs(oe,o[ae>>2]|0)|0){Ee=53;break}if(Ao(o[Pe>>2]|0,o[ae>>2]|0,P)|0){Ee=53;break}if(Qo(o[Pe>>2]|0,o[ae>>2]|0,le,oe)|0){Ee=53;break}}}}do if((x|0)<(o[xe>>2]|0)){if(a=ao(u,f,oe,1)|0,g=o[ae>>2]|0,a|0){Ee=58;break t}if(!(Hn(g,oe)|0)){Ee=73;break}if(Cs(o[ae>>2]|0,oe)|0&&(On(le,oe),bA(o[Pe>>2]|0,o[ae>>2]|0,le,oe)|0)){Ee=65;break t}if(u=ja(u,f,x+1|0,le)|0,u|0){Ee=67;break t}f=le,u=o[f>>2]|0,f=o[f+4>>2]|0}else Ee=73;while(!1);if((Ee|0)==73&&(Ee=0,u=Wa(u,f)|0,f=ee()|0),(u|0)==0&(f|0)==0){Ue=ae;break e}}switch(Ee|0){case 15:{a=o[ae>>2]|0,a|0&&kt(a),Ee=l,o[Ee>>2]=0,o[Ee+4>>2]=0,o[Pe>>2]=0,o[xe>>2]=-1,o[Se>>2]=0,o[ae>>2]=0,o[l+8>>2]=g,Ee=20;break}case 19:{o[l>>2]=u,o[l+4>>2]=f,Ee=20;break}case 25:{zt(27795,27761,470,27772);break}case 29:{o[l>>2]=u,o[l+4>>2]=f,H=we;return}case 32:{a=o[ae>>2]|0,a|0&&kt(a),Ue=l,o[Ue>>2]=0,o[Ue+4>>2]=0,o[Pe>>2]=0,o[xe>>2]=-1,o[Se>>2]=0,o[ae>>2]=0,o[l+8>>2]=g,H=we;return}case 36:{zt(27795,27761,493,27772);break}case 42:{o[l>>2]=u,o[l+4>>2]=f,H=we;return}case 45:{g|0&&kt(g),Ee=l,o[Ee>>2]=0,o[Ee+4>>2]=0,o[Pe>>2]=0,o[xe>>2]=-1,o[Se>>2]=0,o[ae>>2]=0,o[l+8>>2]=a,Ee=55;break}case 53:{o[l>>2]=u,o[l+4>>2]=f,Ee=55;break}case 58:{g|0&&kt(g),Ee=l,o[Ee>>2]=0,o[Ee+4>>2]=0,o[Pe>>2]=0,o[xe>>2]=-1,o[Se>>2]=0,o[ae>>2]=0,o[l+8>>2]=a,Ee=71;break}case 65:{o[l>>2]=u,o[l+4>>2]=f,Ee=71;break}case 67:{a=o[ae>>2]|0,a|0&&kt(a),Ue=l,o[Ue>>2]=0,o[Ue+4>>2]=0,o[Pe>>2]=0,o[xe>>2]=-1,o[Se>>2]=0,o[ae>>2]=0,o[l+8>>2]=u,H=we;return}}if((Ee|0)==20){H=we;return}else if((Ee|0)==55){H=we;return}else if((Ee|0)==71){H=we;return}}while(!1);a=o[Ue>>2]|0,a|0&&kt(a),Ee=l,o[Ee>>2]=0,o[Ee+4>>2]=0,o[l+8>>2]=0,o[Pe>>2]=0,o[l+12>>2]=-1,o[Se>>2]=0,o[Ue>>2]=0,H=we}function Wa(l,a){l=l|0,a=a|0;var u=0,f=0,g=0,x=0,w=0,P=0,C=0,z=0,F=0,K=0;K=H,H=H+16|0,F=K,f=Ye(l|0,a|0,52)|0,ee()|0,f=f&15,u=Ye(l|0,a|0,45)|0,ee()|0;do if(f){for(;u=lt(f+4095|0,0,52)|0,g=ee()|0|a&-15728641,x=(15-f|0)*3|0,w=lt(7,0,x|0)|0,P=ee()|0,u=u|l|w,g=g|P,C=Ye(l|0,a|0,x|0)|0,ee()|0,C=C&7,f=f+-1|0,!(C>>>0<6);)if(f)a=g,l=u;else{z=4;break}if((z|0)==4){u=Ye(u|0,g|0,45)|0,ee()|0;break}return F=(C|0)==0&(wr(u,g)|0)!=0,F=lt((F?2:1)+C|0,0,x|0)|0,z=ee()|0|a&~P,F=F|l&~w,Pt(z|0),H=K,F|0}while(!1);return u=u&127,u>>>0>120?(z=0,F=0,Pt(z|0),H=K,F|0):(ga(F,0,u+1|0,0),z=o[F+4>>2]|0,F=o[F>>2]|0,Pt(z|0),H=K,F|0)}function Ha(l,a,u,f,g,x){l=l|0,a=a|0,u=u|0,f=f|0,g=g|0,x=x|0;var w=0,P=0,C=0,z=0,F=0,K=0,ae=0,oe=0,le=0,xe=0,Ee=0;Ee=H,H=H+160|0,K=Ee+80|0,P=Ee+64|0,ae=Ee+112|0,xe=Ee,$a(K,l,a,u),z=K,xl(P,o[z>>2]|0,o[z+4>>2]|0,a),z=P,C=o[z>>2]|0,z=o[z+4>>2]|0,w=o[K+8>>2]|0,oe=ae+4|0,o[oe>>2]=o[K>>2],o[oe+4>>2]=o[K+4>>2],o[oe+8>>2]=o[K+8>>2],o[oe+12>>2]=o[K+12>>2],o[oe+16>>2]=o[K+16>>2],o[oe+20>>2]=o[K+20>>2],o[oe+24>>2]=o[K+24>>2],o[oe+28>>2]=o[K+28>>2],oe=xe,o[oe>>2]=C,o[oe+4>>2]=z,oe=xe+8|0,o[oe>>2]=w,l=xe+12|0,a=ae,u=l+36|0;do o[l>>2]=o[a>>2],l=l+4|0,a=a+4|0;while((l|0)<(u|0));if(ae=xe+48|0,o[ae>>2]=o[P>>2],o[ae+4>>2]=o[P+4>>2],o[ae+8>>2]=o[P+8>>2],o[ae+12>>2]=o[P+12>>2],(C|0)==0&(z|0)==0)return xe=w,H=Ee,xe|0;u=xe+16|0,F=xe+24|0,K=xe+28|0,w=0,P=0,a=C,l=z;do{if(!((w|0)<(g|0)|(w|0)==(g|0)&P>>>0<f>>>0)){le=4;break}if(z=P,P=Dt(P|0,w|0,1,0)|0,w=ee()|0,z=x+(z<<3)|0,o[z>>2]=a,o[z+4>>2]=l,wl(ae),l=ae,a=o[l>>2]|0,l=o[l+4>>2]|0,(a|0)==0&(l|0)==0){if(Zo(u),a=u,l=o[a>>2]|0,a=o[a+4>>2]|0,(l|0)==0&(a|0)==0){le=10;break}bl(l,a,o[K>>2]|0,ae),l=ae,a=o[l>>2]|0,l=o[l+4>>2]|0}z=xe,o[z>>2]=a,o[z+4>>2]=l}while(!((a|0)==0&(l|0)==0));return(le|0)==4?(l=xe+40|0,a=o[l>>2]|0,a|0&&kt(a),le=xe+16|0,o[le>>2]=0,o[le+4>>2]=0,o[F>>2]=0,o[xe+36>>2]=0,o[K>>2]=-1,o[xe+32>>2]=0,o[l>>2]=0,bl(0,0,0,ae),o[xe>>2]=0,o[xe+4>>2]=0,o[oe>>2]=0,xe=14,H=Ee,xe|0):((le|0)==10&&(o[xe>>2]=0,o[xe+4>>2]=0,o[oe>>2]=o[F>>2]),xe=o[oe>>2]|0,H=Ee,xe|0)}function Xa(l,a,u,f){l=l|0,a=a|0,u=u|0,f=f|0;var g=0,x=0,w=0,P=0,C=0,z=0,F=0,K=0,ae=0,oe=0;if(K=H,H=H+48|0,C=K+32|0,P=K+40|0,z=K,!(o[l>>2]|0))return F=f,o[F>>2]=0,o[F+4>>2]=0,F=0,H=K,F|0;ga(C,0,0,0),w=C,g=o[w>>2]|0,w=o[w+4>>2]|0;do if(a>>>0>15)F=z,o[F>>2]=0,o[F+4>>2]=0,o[z+8>>2]=4,o[z+12>>2]=-1,F=z+16|0,u=z+29|0,o[F>>2]=0,o[F+4>>2]=0,o[F+8>>2]=0,ot[F+12>>0]=0,ot[u>>0]=ot[P>>0]|0,ot[u+1>>0]=ot[P+1>>0]|0,ot[u+2>>0]=ot[P+2>>0]|0,u=4,F=9;else{if(u=lo(u)|0,u|0){C=z,o[C>>2]=0,o[C+4>>2]=0,o[z+8>>2]=u,o[z+12>>2]=-1,C=z+16|0,F=z+29|0,o[C>>2]=0,o[C+4>>2]=0,o[C+8>>2]=0,ot[C+12>>0]=0,ot[F>>0]=ot[P>>0]|0,ot[F+1>>0]=ot[P+1>>0]|0,ot[F+2>>0]=ot[P+2>>0]|0,F=9;break}if(u=Bi((o[l+8>>2]|0)+1|0,32)|0,!u){F=z,o[F>>2]=0,o[F+4>>2]=0,o[z+8>>2]=13,o[z+12>>2]=-1,F=z+16|0,u=z+29|0,o[F>>2]=0,o[F+4>>2]=0,o[F+8>>2]=0,ot[F+12>>0]=0,ot[u>>0]=ot[P>>0]|0,ot[u+1>>0]=ot[P+1>>0]|0,ot[u+2>>0]=ot[P+2>>0]|0,u=13,F=9;break}El(l,u),oe=z,o[oe>>2]=g,o[oe+4>>2]=w,w=z+8|0,o[w>>2]=0,o[z+12>>2]=a,o[z+20>>2]=l,o[z+24>>2]=u,ot[z+28>>0]=0,g=z+29|0,ot[g>>0]=ot[P>>0]|0,ot[g+1>>0]=ot[P+1>>0]|0,ot[g+2>>0]=ot[P+2>>0]|0,o[z+16>>2]=3,ae=+$i(u),ae=ae*+Qi(u),x=+Je(+ +Z[u>>3]),x=ae/+Jt(+ +tl(+x,+ +Je(+ +Z[u+8>>3])))*6371.007180918475*6371.007180918475,g=z+12|0,u=o[g>>2]|0;e:do if((u|0)>0)do{if(_n(u+-1|0,C)|0,!(x/+Z[C>>3]>10))break e;oe=o[g>>2]|0,u=oe+-1|0,o[g>>2]=u}while((oe|0)>1);while(!1);if(Zo(z),g=f,o[g>>2]=0,o[g+4>>2]=0,g=z,u=o[g>>2]|0,g=o[g+4>>2]|0,!((u|0)==0&(g|0)==0))do Fo(u,g,a,C)|0,P=C,l=f,P=Dt(o[l>>2]|0,o[l+4>>2]|0,o[P>>2]|0,o[P+4>>2]|0)|0,l=ee()|0,oe=f,o[oe>>2]=P,o[oe+4>>2]=l,Zo(z),oe=z,u=o[oe>>2]|0,g=o[oe+4>>2]|0;while(!((u|0)==0&(g|0)==0));u=o[w>>2]|0}while(!1);return oe=u,H=K,oe|0}function En(l,a,u){l=l|0,a=a|0,u=u|0;var f=0,g=0,x=0,w=0,P=0,C=0,z=0,F=0,K=0,ae=0;if(!(Ss(a,u)|0)||(a=tn(a)|0,f=+Z[u>>3],g=+Z[u+8>>3],g=a&g<0?g+6.283185307179586:g,ae=o[l>>2]|0,(ae|0)<=0))return ae=0,ae|0;if(K=o[l+4>>2]|0,a){a=0,F=g,u=-1,l=0;e:for(;;){for(z=l;w=+Z[K+(z<<4)>>3],g=+Z[K+(z<<4)+8>>3],l=(u+2|0)%(ae|0)|0,x=+Z[K+(l<<4)>>3],P=+Z[K+(l<<4)+8>>3],w>x?(C=w,w=P):(C=x,x=w,w=g,g=P),f=f==x|f==C?f+2220446049250313e-31:f,!!(f<x|f>C);)if(u=z+1|0,(u|0)>=(ae|0)){u=22;break e}else l=z,z=u,u=l;if(P=w<0?w+6.283185307179586:w,w=g<0?g+6.283185307179586:g,F=P==F|w==F?F+-2220446049250313e-31:F,C=P+(w-P)*((f-x)/(C-x)),(C<0?C+6.283185307179586:C)>F&&(a=a^1),l=z+1|0,(l|0)>=(ae|0)){u=22;break}else u=z}if((u|0)==22)return a|0}else{a=0,F=g,u=-1,l=0;e:for(;;){for(z=l;w=+Z[K+(z<<4)>>3],g=+Z[K+(z<<4)+8>>3],l=(u+2|0)%(ae|0)|0,x=+Z[K+(l<<4)>>3],P=+Z[K+(l<<4)+8>>3],w>x?(C=w,w=P):(C=x,x=w,w=g,g=P),f=f==x|f==C?f+2220446049250313e-31:f,!!(f<x|f>C);)if(u=z+1|0,(u|0)>=(ae|0)){u=22;break e}else l=z,z=u,u=l;if(F=w==F|g==F?F+-2220446049250313e-31:F,w+(g-w)*((f-x)/(C-x))>F&&(a=a^1),l=z+1|0,(l|0)>=(ae|0)){u=22;break}else u=z}if((u|0)==22)return a|0}return 0}function Ls(l,a){l=l|0,a=a|0;var u=0,f=0,g=0,x=0,w=0,P=0,C=0,z=0,F=0,K=0,ae=0,oe=0,le=0,xe=0,Ee=0,Ue=0,Se=0;if(le=o[l>>2]|0,!le){o[a>>2]=0,o[a+4>>2]=0,o[a+8>>2]=0,o[a+12>>2]=0,o[a+16>>2]=0,o[a+20>>2]=0,o[a+24>>2]=0,o[a+28>>2]=0;return}if(xe=a+8|0,Z[xe>>3]=17976931348623157e292,Ee=a+24|0,Z[Ee>>3]=17976931348623157e292,Z[a>>3]=-17976931348623157e292,Ue=a+16|0,Z[Ue>>3]=-17976931348623157e292,!((le|0)<=0)){for(ae=o[l+4>>2]|0,z=17976931348623157e292,F=-17976931348623157e292,K=0,l=-1,x=17976931348623157e292,w=17976931348623157e292,C=-17976931348623157e292,f=-17976931348623157e292,oe=0;u=+Z[ae+(oe<<4)>>3],P=+Z[ae+(oe<<4)+8>>3],l=l+2|0,g=+Z[ae+(((l|0)==(le|0)?0:l)<<4)+8>>3],u<x&&(Z[xe>>3]=u,x=u),P<w&&(Z[Ee>>3]=P,w=P),u>C?Z[a>>3]=u:u=C,P>f&&(Z[Ue>>3]=P,f=P),z=P>0&P<z?P:z,F=P<0&P>F?P:F,K=K|+Je(+(P-g))>3.141592653589793,l=oe+1|0,(l|0)!=(le|0);)Se=oe,C=u,oe=l,l=Se;K&&(Z[Ue>>3]=F,Z[Ee>>3]=z)}}function lo(l){return l=l|0,(l>>>0<4?0:15)|0}function El(l,a){l=l|0,a=a|0;var u=0,f=0,g=0,x=0,w=0,P=0,C=0,z=0,F=0,K=0,ae=0,oe=0,le=0,xe=0,Ee=0,Ue=0,Se=0,Pe=0,we=0,ct=0,St=0,Mt=0;if(le=o[l>>2]|0,le){if(xe=a+8|0,Z[xe>>3]=17976931348623157e292,Ee=a+24|0,Z[Ee>>3]=17976931348623157e292,Z[a>>3]=-17976931348623157e292,Ue=a+16|0,Z[Ue>>3]=-17976931348623157e292,(le|0)>0){for(g=o[l+4>>2]|0,ae=17976931348623157e292,oe=-17976931348623157e292,f=0,u=-1,C=17976931348623157e292,z=17976931348623157e292,K=-17976931348623157e292,w=-17976931348623157e292,Se=0;x=+Z[g+(Se<<4)>>3],F=+Z[g+(Se<<4)+8>>3],St=u+2|0,P=+Z[g+(((St|0)==(le|0)?0:St)<<4)+8>>3],x<C&&(Z[xe>>3]=x,C=x),F<z&&(Z[Ee>>3]=F,z=F),x>K?Z[a>>3]=x:x=K,F>w&&(Z[Ue>>3]=F,w=F),ae=F>0&F<ae?F:ae,oe=F<0&F>oe?F:oe,f=f|+Je(+(F-P))>3.141592653589793,u=Se+1|0,(u|0)!=(le|0);)St=Se,K=x,Se=u,u=St;f&&(Z[Ue>>3]=oe,Z[Ee>>3]=ae)}}else o[a>>2]=0,o[a+4>>2]=0,o[a+8>>2]=0,o[a+12>>2]=0,o[a+16>>2]=0,o[a+20>>2]=0,o[a+24>>2]=0,o[a+28>>2]=0;if(St=l+8|0,u=o[St>>2]|0,!((u|0)<=0)){ct=l+12|0,we=0;do if(g=o[ct>>2]|0,f=we,we=we+1|0,Ee=a+(we<<5)|0,Ue=o[g+(f<<3)>>2]|0,Ue){if(Se=a+(we<<5)+8|0,Z[Se>>3]=17976931348623157e292,l=a+(we<<5)+24|0,Z[l>>3]=17976931348623157e292,Z[Ee>>3]=-17976931348623157e292,Pe=a+(we<<5)+16|0,Z[Pe>>3]=-17976931348623157e292,(Ue|0)>0){for(le=o[g+(f<<3)+4>>2]|0,ae=17976931348623157e292,oe=-17976931348623157e292,g=0,f=-1,xe=0,C=17976931348623157e292,z=17976931348623157e292,F=-17976931348623157e292,w=-17976931348623157e292;x=+Z[le+(xe<<4)>>3],K=+Z[le+(xe<<4)+8>>3],f=f+2|0,P=+Z[le+(((f|0)==(Ue|0)?0:f)<<4)+8>>3],x<C&&(Z[Se>>3]=x,C=x),K<z&&(Z[l>>3]=K,z=K),x>F?Z[Ee>>3]=x:x=F,K>w&&(Z[Pe>>3]=K,w=K),ae=K>0&K<ae?K:ae,oe=K<0&K>oe?K:oe,g=g|+Je(+(K-P))>3.141592653589793,f=xe+1|0,(f|0)!=(Ue|0);)Mt=xe,xe=f,F=x,f=Mt;g&&(Z[Pe>>3]=oe,Z[l>>3]=ae)}}else o[Ee>>2]=0,o[Ee+4>>2]=0,o[Ee+8>>2]=0,o[Ee+12>>2]=0,o[Ee+16>>2]=0,o[Ee+20>>2]=0,o[Ee+24>>2]=0,o[Ee+28>>2]=0,u=o[St>>2]|0;while((we|0)<(u|0))}}function Ao(l,a,u){l=l|0,a=a|0,u=u|0;var f=0,g=0,x=0;if(!(En(l,a,u)|0))return g=0,g|0;if(g=l+8|0,(o[g>>2]|0)<=0)return g=1,g|0;for(f=l+12|0,l=0;;){if(x=l,l=l+1|0,En((o[f>>2]|0)+(x<<3)|0,a+(l<<5)|0,u)|0){l=0,f=6;break}if((l|0)>=(o[g>>2]|0)){l=1,f=6;break}}return(f|0)==6?l|0:0}function bA(l,a,u,f){l=l|0,a=a|0,u=u|0,f=f|0;var g=0,x=0,w=0,P=0,C=0,z=0,F=0;if(z=H,H=H+16|0,P=z,w=u+8|0,!(En(l,a,w)|0))return C=0,H=z,C|0;C=l+8|0;e:do if((o[C>>2]|0)>0){for(x=l+12|0,g=0;;){if(F=g,g=g+1|0,En((o[x>>2]|0)+(F<<3)|0,a+(g<<5)|0,w)|0){g=0;break}if((g|0)>=(o[C>>2]|0))break e}return H=z,g|0}while(!1);if(ba(l,a,u,f)|0)return F=0,H=z,F|0;o[P>>2]=o[u>>2],o[P+4>>2]=w,g=o[C>>2]|0;e:do if((g|0)>0)for(l=l+12|0,w=0,x=g;;){if(g=o[l>>2]|0,(o[g+(w<<3)>>2]|0)>0){if(En(P,f,o[g+(w<<3)+4>>2]|0)|0){g=0;break e}if(g=w+1|0,ba((o[l>>2]|0)+(w<<3)|0,a+(g<<5)|0,u,f)|0){g=0;break e}x=o[C>>2]|0}else g=w+1|0;if((g|0)<(x|0))w=g;else{g=1;break}}else g=1;while(!1);return F=g,H=z,F|0}function ba(l,a,u,f){l=l|0,a=a|0,u=u|0,f=f|0;var g=0,x=0,w=0,P=0,C=0,z=0,F=0,K=0,ae=0,oe=0,le=0,xe=0,Ee=0,Ue=0,Se=0,Pe=0,we=0,ct=0,St=0,Mt=0,jt=0;if(St=H,H=H+176|0,Se=St+172|0,g=St+168|0,Pe=St,!(Hn(a,f)|0))return l=0,H=St,l|0;if(Kr(a,f,Se,g),Nn(Pe|0,u|0,168)|0,(o[u>>2]|0)>0){a=0;do Mt=Pe+8+(a<<4)+8|0,Ue=+zi(+Z[Mt>>3],o[g>>2]|0),Z[Mt>>3]=Ue,a=a+1|0;while((a|0)<(o[u>>2]|0))}xe=+Z[f>>3],Ee=+Z[f+8>>3],Ue=+zi(+Z[f+16>>3],o[g>>2]|0),oe=+zi(+Z[f+24>>3],o[g>>2]|0);e:do if((o[l>>2]|0)>0){if(f=l+4|0,g=o[Pe>>2]|0,(g|0)<=0){for(a=0;;)if(a=a+1|0,(a|0)>=(o[l>>2]|0)){a=0;break e}}for(u=0;;){if(a=o[f>>2]|0,ae=+Z[a+(u<<4)>>3],le=+zi(+Z[a+(u<<4)+8>>3],o[Se>>2]|0),a=o[f>>2]|0,u=u+1|0,Mt=(u|0)%(o[l>>2]|0)|0,x=+Z[a+(Mt<<4)>>3],w=+zi(+Z[a+(Mt<<4)+8>>3],o[Se>>2]|0),!(ae>=xe)|!(x>=xe)&&!(ae<=Ee)|!(x<=Ee)&&!(le<=oe)|!(w<=oe)&&!(le>=Ue)|!(w>=Ue)){K=x-ae,z=w-le,a=0;do if(jt=a,a=a+1|0,Mt=(a|0)==(g|0)?0:a,x=+Z[Pe+8+(jt<<4)+8>>3],w=+Z[Pe+8+(Mt<<4)+8>>3]-x,P=+Z[Pe+8+(jt<<4)>>3],C=+Z[Pe+8+(Mt<<4)>>3]-P,F=K*w-z*C,F!=0&&(we=le-x,ct=ae-P,C=(we*C-w*ct)/F,!(C<0|C>1))&&(F=(K*we-z*ct)/F,F>=0&F<=1)){a=1;break e}while((a|0)<(g|0))}if((u|0)>=(o[l>>2]|0)){a=0;break}}}else a=0;while(!1);return jt=a,H=St,jt|0}function Qo(l,a,u,f){l=l|0,a=a|0,u=u|0,f=f|0;var g=0,x=0,w=0;if(ba(l,a,u,f)|0)return x=1,x|0;if(x=l+8|0,(o[x>>2]|0)<=0)return x=0,x|0;for(g=l+12|0,l=0;;){if(w=l,l=l+1|0,ba((o[g>>2]|0)+(w<<3)|0,a+(l<<5)|0,u,f)|0){l=1,g=6;break}if((l|0)>=(o[x>>2]|0)){l=0,g=6;break}}return(g|0)==6?l|0:0}function Ya(){return 8}function wA(){return 16}function TA(){return 168}function wa(){return 8}function Ka(){return 16}function PA(){return 12}function MA(){return 8}function Jr(l){return l=l|0,+(+((o[l>>2]|0)>>>0)+4294967296*+(o[l+4>>2]|0))}function uo(l){l=l|0;var a=0,u=0;return u=+Z[l>>3],a=+Z[l+8>>3],+ +wt(+(u*u+a*a))}function on(l,a,u,f,g){l=l|0,a=a|0,u=u|0,f=f|0,g=g|0;var x=0,w=0,P=0,C=0,z=0,F=0,K=0,ae=0;z=+Z[l>>3],C=+Z[a>>3]-z,P=+Z[l+8>>3],w=+Z[a+8>>3]-P,K=+Z[u>>3],x=+Z[f>>3]-K,ae=+Z[u+8>>3],F=+Z[f+8>>3]-ae,x=(x*(P-ae)-(z-K)*F)/(C*F-w*x),Z[g>>3]=z+C*x,Z[g+8>>3]=P+w*x}function Ta(l,a){return l=l|0,a=a|0,+Je(+(+Z[l>>3]-+Z[a>>3]))<11920928955078125e-23?(a=+Je(+(+Z[l+8>>3]-+Z[a+8>>3]))<11920928955078125e-23,a|0):(a=0,a|0)}function Gr(l,a){l=l|0,a=a|0;var u=0,f=0,g=0;return g=+Z[l>>3]-+Z[a>>3],f=+Z[l+8>>3]-+Z[a+8>>3],u=+Z[l+16>>3]-+Z[a+16>>3],+(g*g+f*f+u*u)}function Ja(l,a){l=l|0,a=a|0;var u=0,f=0,g=0;u=+Z[l>>3],f=+Jt(+u),u=+Yt(+u),Z[a+16>>3]=u,u=+Z[l+8>>3],g=f*+Jt(+u),Z[a>>3]=g,u=f*+Yt(+u),Z[a+8>>3]=u}function Fs(l,a,u){l=l|0,a=a|0,u=u|0;var f=0,g=0,x=0;if(x=H,H=H+16|0,g=x,f=wr(l,a)|0,(u+-1|0)>>>0>5||(f=(f|0)!=0,(u|0)==1&f))return g=-1,H=x,g|0;do if(ps(l,a,g)|0)f=-1;else if(f){f=((o[26352+(u<<2)>>2]|0)+5-(o[g>>2]|0)|0)%5|0;break}else{f=((o[26384+(u<<2)>>2]|0)+6-(o[g>>2]|0)|0)%6|0;break}while(!1);return g=f,H=x,g|0}function ps(l,a,u){l=l|0,a=a|0,u=u|0;var f=0,g=0,x=0,w=0,P=0,C=0,z=0,F=0;if(F=H,H=H+32|0,P=F+16|0,C=F,f=zs(l,a,P)|0,f|0)return u=f,H=F,u|0;x=da(l,a)|0,z=sn(l,a)|0,pl(x,C),f=en(x,o[P>>2]|0)|0;do if(yr(x)|0){do switch(x|0){case 4:{g=0;break}case 14:{g=1;break}case 24:{g=2;break}case 38:{g=3;break}case 49:{g=4;break}case 58:{g=5;break}case 63:{g=6;break}case 72:{g=7;break}case 83:{g=8;break}case 97:{g=9;break}case 107:{g=10;break}case 117:{g=11;break}default:zt(27795,27797,75,27806)}while(!1);if(w=o[26416+(g*24|0)+8>>2]|0,a=o[26416+(g*24|0)+16>>2]|0,l=o[P>>2]|0,(l|0)!=(o[C>>2]|0)&&(C=Kt(x)|0,l=o[P>>2]|0,C|(l|0)==(a|0)&&(f=(f+1|0)%6|0)),(z|0)==3&(l|0)==(a|0)){f=(f+5|0)%6|0;break}(z|0)==5&(l|0)==(w|0)&&(f=(f+1|0)%6|0)}while(!1);return o[u>>2]=f,u=0,H=F,u|0}function _i(l,a,u,f){l=l|0,a=a|0,u=u|0,f=f|0;var g=0,x=0,w=0,P=0,C=0,z=0,F=0,K=0,ae=0,oe=0,le=0,xe=0,Ee=0,Ue=0,Se=0,Pe=0;if(Pe=H,H=H+32|0,Se=Pe+24|0,Ee=Pe+20|0,le=Pe+8|0,oe=Pe+16|0,ae=Pe,C=(wr(l,a)|0)==0,C=C?6:5,F=Ye(l|0,a|0,52)|0,ee()|0,F=F&15,C>>>0<=u>>>0)return f=2,H=Pe,f|0;K=(F|0)==0,!K&&(xe=lt(7,0,(F^15)*3|0)|0,(xe&l|0)==0&((ee()|0)&a|0)==0)?g=u:x=4;e:do if((x|0)==4){if(g=(wr(l,a)|0)!=0,((g?4:5)|0)<(u|0)||ps(l,a,Se)|0||(x=(o[Se>>2]|0)+u|0,g?g=26704+(((x|0)%5|0)<<2)|0:g=26736+(((x|0)%6|0)<<2)|0,xe=o[g>>2]|0,(xe|0)==7))return f=1,H=Pe,f|0;o[Ee>>2]=0,g=li(l,a,xe,Ee,le)|0;do if(!g){if(P=le,z=o[P>>2]|0,P=o[P+4>>2]|0,w=P>>>0<a>>>0|(P|0)==(a|0)&z>>>0<l>>>0,x=w?z:l,w=w?P:a,!K&&(K=lt(7,0,(F^15)*3|0)|0,(z&K|0)==0&(P&(ee()|0)|0)==0))g=u;else{if(P=(u+-1+C|0)%(C|0)|0,g=wr(l,a)|0,(P|0)<0&&zt(27795,27797,248,27822),C=(g|0)!=0,((C?4:5)|0)<(P|0)&&zt(27795,27797,248,27822),ps(l,a,Se)|0&&zt(27795,27797,248,27822),g=(o[Se>>2]|0)+P|0,C?g=26704+(((g|0)%5|0)<<2)|0:g=26736+(((g|0)%6|0)<<2)|0,P=o[g>>2]|0,(P|0)==7&&zt(27795,27797,248,27822),o[oe>>2]=0,g=li(l,a,P,oe,ae)|0,g|0)break;z=ae,C=o[z>>2]|0,z=o[z+4>>2]|0;do if(z>>>0<w>>>0|(z|0)==(w|0)&C>>>0<x>>>0){if(wr(C,z)|0?x=Po(C,z,l,a)|0:x=o[26800+((((o[oe>>2]|0)+(o[26768+(P<<2)>>2]|0)|0)%6|0)<<2)>>2]|0,g=wr(C,z)|0,(x+-1|0)>>>0>5){g=-1,x=C,w=z;break}if(g=(g|0)!=0,(x|0)==1&g){g=-1,x=C,w=z;break}do if(ps(C,z,Se)|0)g=-1;else if(g){g=((o[26352+(x<<2)>>2]|0)+5-(o[Se>>2]|0)|0)%5|0;break}else{g=((o[26384+(x<<2)>>2]|0)+6-(o[Se>>2]|0)|0)%6|0;break}while(!1);x=C,w=z}else g=u;while(!1);P=le,z=o[P>>2]|0,P=o[P+4>>2]|0}if((x|0)==(z|0)&(w|0)==(P|0)){if(C=(wr(z,P)|0)!=0,C?l=Po(z,P,l,a)|0:l=o[26800+((((o[Ee>>2]|0)+(o[26768+(xe<<2)>>2]|0)|0)%6|0)<<2)>>2]|0,g=wr(z,P)|0,(l+-1|0)>>>0<=5&&(Ue=(g|0)!=0,!((l|0)==1&Ue)))do if(ps(z,P,Se)|0)g=-1;else if(Ue){g=((o[26352+(l<<2)>>2]|0)+5-(o[Se>>2]|0)|0)%5|0;break}else{g=((o[26384+(l<<2)>>2]|0)+6-(o[Se>>2]|0)|0)%6|0;break}while(!1);else g=-1;g=g+1|0,g=(g|0)==6|C&(g|0)==5?0:g}a=w,l=x;break e}while(!1);return f=g,H=Pe,f|0}while(!1);return Ue=lt(g|0,0,56)|0,Se=ee()|0|a&-2130706433|536870912,o[f>>2]=Ue|l,o[f+4>>2]=Se,f=0,H=Pe,f|0}function $o(l,a,u){l=l|0,a=a|0,u=u|0;var f=0,g=0,x=0;return x=(wr(l,a)|0)==0,f=_i(l,a,0,u)|0,g=(f|0)==0,x?!g||(f=_i(l,a,1,u+8|0)|0,f|0)||(f=_i(l,a,2,u+16|0)|0,f|0)||(f=_i(l,a,3,u+24|0)|0,f|0)||(f=_i(l,a,4,u+32|0)|0,f)?(x=f,x|0):_i(l,a,5,u+40|0)|0:!g||(f=_i(l,a,1,u+8|0)|0,f|0)||(f=_i(l,a,2,u+16|0)|0,f|0)||(f=_i(l,a,3,u+24|0)|0,f|0)||(f=_i(l,a,4,u+32|0)|0,f|0)?(x=f,x|0):(x=u+40|0,o[x>>2]=0,o[x+4>>2]=0,x=0,x|0)}function EA(l,a,u){l=l|0,a=a|0,u=u|0;var f=0,g=0,x=0,w=0,P=0,C=0;return C=H,H=H+192|0,g=C,x=C+168|0,w=Ye(l|0,a|0,56)|0,ee()|0,w=w&7,P=a&-2130706433|134217728,f=zs(l,P,x)|0,f|0?(P=f,H=C,P|0):(a=Ye(l|0,a|0,52)|0,ee()|0,a=a&15,wr(l,P)|0?ks(x,a,w,1,g):Ro(x,a,w,1,g),P=g+8|0,o[u>>2]=o[P>>2],o[u+4>>2]=o[P+4>>2],o[u+8>>2]=o[P+8>>2],o[u+12>>2]=o[P+12>>2],P=0,H=C,P|0)}function Il(l,a){l=l|0,a=a|0;var u=0,f=0,g=0,x=0;return g=H,H=H+16|0,u=g,!(!0&(a&2013265920|0)==536870912)||(f=a&-2130706433|134217728,!(ma(l,f)|0))?(f=0,H=g,f|0):(x=Ye(l|0,a|0,56)|0,ee()|0,x=(_i(l,f,x&7,u)|0)==0,f=u,f=x&((o[f>>2]|0)==(l|0)?(o[f+4>>2]|0)==(a|0):0)&1,H=g,f|0)}function Sl(l,a,u){l=l|0,a=a|0,u=u|0;var f=0;(a|0)>0?(f=Bi(a,4)|0,o[l>>2]=f,f||zt(27835,27858,40,27872)):o[l>>2]=0,o[l+4>>2]=a,o[l+8>>2]=0,o[l+12>>2]=u}function Cl(l){l=l|0;var a=0,u=0,f=0,g=0,x=0,w=0,P=0;g=l+4|0,x=l+12|0,w=l+8|0;e:for(;;){for(u=o[g>>2]|0,a=0;;){if((a|0)>=(u|0))break e;if(f=o[l>>2]|0,P=o[f+(a<<2)>>2]|0,!P)a=a+1|0;else break}a=f+(~~(+Je(+(+Ft(10,+ +(15-(o[x>>2]|0)|0))*(+Z[P>>3]+ +Z[P+8>>3])))%+(u|0))>>>0<<2)|0,u=o[a>>2]|0;t:do if(u|0){if(f=P+32|0,(u|0)==(P|0))o[a>>2]=o[f>>2];else{if(u=u+32|0,a=o[u>>2]|0,!a)break;for(;(a|0)!=(P|0);)if(u=a+32|0,a=o[u>>2]|0,!a)break t;o[u>>2]=o[f>>2]}kt(P),o[w>>2]=(o[w>>2]|0)+-1}while(!1)}kt(o[l>>2]|0)}function Dl(l){l=l|0;var a=0,u=0,f=0;for(f=o[l+4>>2]|0,u=0;;){if((u|0)>=(f|0)){a=0,u=4;break}if(a=o[(o[l>>2]|0)+(u<<2)>>2]|0,!a)u=u+1|0;else{u=4;break}}return(u|0)==4?a|0:0}function fs(l,a){l=l|0,a=a|0;var u=0,f=0,g=0,x=0;if(u=~~(+Je(+(+Ft(10,+ +(15-(o[l+12>>2]|0)|0))*(+Z[a>>3]+ +Z[a+8>>3])))%+(o[l+4>>2]|0))>>>0,u=(o[l>>2]|0)+(u<<2)|0,f=o[u>>2]|0,!f)return x=1,x|0;x=a+32|0;do if((f|0)!=(a|0)){if(u=o[f+32>>2]|0,!u)return x=1,x|0;for(g=u;;){if((g|0)==(a|0)){g=8;break}if(u=o[g+32>>2]|0,u)f=g,g=u;else{u=1,g=10;break}}if((g|0)==8){o[f+32>>2]=o[x>>2];break}else if((g|0)==10)return u|0}else o[u>>2]=o[x>>2];while(!1);return kt(a),x=l+8|0,o[x>>2]=(o[x>>2]|0)+-1,x=0,x|0}function kl(l,a,u){l=l|0,a=a|0,u=u|0;var f=0,g=0,x=0,w=0;x=In(40)|0,x||zt(27888,27858,98,27901),o[x>>2]=o[a>>2],o[x+4>>2]=o[a+4>>2],o[x+8>>2]=o[a+8>>2],o[x+12>>2]=o[a+12>>2],g=x+16|0,o[g>>2]=o[u>>2],o[g+4>>2]=o[u+4>>2],o[g+8>>2]=o[u+8>>2],o[g+12>>2]=o[u+12>>2],o[x+32>>2]=0,g=~~(+Je(+(+Ft(10,+ +(15-(o[l+12>>2]|0)|0))*(+Z[a>>3]+ +Z[a+8>>3])))%+(o[l+4>>2]|0))>>>0,g=(o[l>>2]|0)+(g<<2)|0,f=o[g>>2]|0;do if(!f)o[g>>2]=x;else{for(;!(hs(f,a)|0&&hs(f+16|0,u)|0);)if(g=o[f+32>>2]|0,f=(g|0)==0?f:g,!(o[f+32>>2]|0)){w=10;break}if((w|0)==10){o[f+32>>2]=x;break}return kt(x),w=f,w|0}while(!1);return w=l+8|0,o[w>>2]=(o[w>>2]|0)+1,w=x,w|0}function zl(l,a,u){l=l|0,a=a|0,u=u|0;var f=0,g=0;if(g=~~(+Je(+(+Ft(10,+ +(15-(o[l+12>>2]|0)|0))*(+Z[a>>3]+ +Z[a+8>>3])))%+(o[l+4>>2]|0))>>>0,g=o[(o[l>>2]|0)+(g<<2)>>2]|0,!g)return u=0,u|0;if(!u){for(l=g;;){if(hs(l,a)|0){f=10;break}if(l=o[l+32>>2]|0,!l){l=0,f=10;break}}if((f|0)==10)return l|0}for(l=g;;){if(hs(l,a)|0&&hs(l+16|0,u)|0){f=10;break}if(l=o[l+32>>2]|0,!l){l=0,f=10;break}}return(f|0)==10?l|0:0}function Pa(l,a){l=l|0,a=a|0;var u=0;if(u=~~(+Je(+(+Ft(10,+ +(15-(o[l+12>>2]|0)|0))*(+Z[a>>3]+ +Z[a+8>>3])))%+(o[l+4>>2]|0))>>>0,l=o[(o[l>>2]|0)+(u<<2)>>2]|0,!l)return u=0,u|0;for(;;){if(hs(l,a)|0){a=5;break}if(l=o[l+32>>2]|0,!l){l=0,a=5;break}}return(a|0)==5?l|0:0}function IA(){return 27920}function Kn(l){return l=+l,~~+yt(+l)|0}function In(l){l=l|0;var a=0,u=0,f=0,g=0,x=0,w=0,P=0,C=0,z=0,F=0,K=0,ae=0,oe=0,le=0,xe=0,Ee=0,Ue=0,Se=0,Pe=0,we=0,ct=0;ct=H,H=H+16|0,ae=ct;do if(l>>>0<245){if(z=l>>>0<11?16:l+11&-8,l=z>>>3,K=o[6981]|0,u=K>>>l,u&3|0)return a=(u&1^1)+l|0,l=27964+(a<<1<<2)|0,u=l+8|0,f=o[u>>2]|0,g=f+8|0,x=o[g>>2]|0,(x|0)==(l|0)?o[6981]=K&~(1<<a):(o[x+12>>2]=l,o[u>>2]=x),we=a<<3,o[f+4>>2]=we|3,we=f+we+4|0,o[we>>2]=o[we>>2]|1,we=g,H=ct,we|0;if(F=o[6983]|0,z>>>0>F>>>0){if(u|0)return a=2<<l,a=u<<l&(a|0-a),a=(a&0-a)+-1|0,P=a>>>12&16,a=a>>>P,u=a>>>5&8,a=a>>>u,x=a>>>2&4,a=a>>>x,l=a>>>1&2,a=a>>>l,f=a>>>1&1,f=(u|P|x|l|f)+(a>>>f)|0,a=27964+(f<<1<<2)|0,l=a+8|0,x=o[l>>2]|0,P=x+8|0,u=o[P>>2]|0,(u|0)==(a|0)?(l=K&~(1<<f),o[6981]=l):(o[u+12>>2]=a,o[l>>2]=u,l=K),we=f<<3,w=we-z|0,o[x+4>>2]=z|3,g=x+z|0,o[g+4>>2]=w|1,o[x+we>>2]=w,F|0&&(f=o[6986]|0,a=F>>>3,u=27964+(a<<1<<2)|0,a=1<<a,l&a?(l=u+8|0,a=o[l>>2]|0):(o[6981]=l|a,a=u,l=u+8|0),o[l>>2]=f,o[a+12>>2]=f,o[f+8>>2]=a,o[f+12>>2]=u),o[6983]=w,o[6986]=g,we=P,H=ct,we|0;if(x=o[6982]|0,x){for(u=(x&0-x)+-1|0,g=u>>>12&16,u=u>>>g,f=u>>>5&8,u=u>>>f,w=u>>>2&4,u=u>>>w,P=u>>>1&2,u=u>>>P,C=u>>>1&1,C=o[28228+((f|g|w|P|C)+(u>>>C)<<2)>>2]|0,u=C,P=C,C=(o[C+4>>2]&-8)-z|0;l=o[u+16>>2]|0,!(!l&&(l=o[u+20>>2]|0,!l));)w=(o[l+4>>2]&-8)-z|0,g=w>>>0<C>>>0,u=l,P=g?l:P,C=g?w:C;if(w=P+z|0,w>>>0>P>>>0){g=o[P+24>>2]|0,a=o[P+12>>2]|0;do if((a|0)==(P|0)){if(l=P+20|0,a=o[l>>2]|0,!a&&(l=P+16|0,a=o[l>>2]|0,!a)){u=0;break}for(;;)if(f=a+20|0,u=o[f>>2]|0,u)a=u,l=f;else if(f=a+16|0,u=o[f>>2]|0,u)a=u,l=f;else break;o[l>>2]=0,u=a}else u=o[P+8>>2]|0,o[u+12>>2]=a,o[a+8>>2]=u,u=a;while(!1);do if(g|0){if(a=o[P+28>>2]|0,l=28228+(a<<2)|0,(P|0)==(o[l>>2]|0)){if(o[l>>2]=u,!u){o[6982]=x&~(1<<a);break}}else if(we=g+16|0,o[((o[we>>2]|0)==(P|0)?we:g+20|0)>>2]=u,!u)break;o[u+24>>2]=g,a=o[P+16>>2]|0,a|0&&(o[u+16>>2]=a,o[a+24>>2]=u),a=o[P+20>>2]|0,a|0&&(o[u+20>>2]=a,o[a+24>>2]=u)}while(!1);return C>>>0<16?(we=C+z|0,o[P+4>>2]=we|3,we=P+we+4|0,o[we>>2]=o[we>>2]|1):(o[P+4>>2]=z|3,o[w+4>>2]=C|1,o[w+C>>2]=C,F|0&&(f=o[6986]|0,a=F>>>3,u=27964+(a<<1<<2)|0,a=1<<a,a&K?(l=u+8|0,a=o[l>>2]|0):(o[6981]=a|K,a=u,l=u+8|0),o[l>>2]=f,o[a+12>>2]=f,o[f+8>>2]=a,o[f+12>>2]=u),o[6983]=C,o[6986]=w),we=P+8|0,H=ct,we|0}else K=z}else K=z}else K=z}else if(l>>>0<=4294967231)if(l=l+11|0,z=l&-8,f=o[6982]|0,f){g=0-z|0,l=l>>>8,l?z>>>0>16777215?C=31:(K=(l+1048320|0)>>>16&8,xe=l<<K,P=(xe+520192|0)>>>16&4,xe=xe<<P,C=(xe+245760|0)>>>16&2,C=14-(P|K|C)+(xe<<C>>>15)|0,C=z>>>(C+7|0)&1|C<<1):C=0,u=o[28228+(C<<2)>>2]|0;e:do if(!u)u=0,l=0,xe=61;else for(l=0,P=z<<((C|0)==31?0:25-(C>>>1)|0),x=0;;){if(w=(o[u+4>>2]&-8)-z|0,w>>>0<g>>>0)if(w)l=u,g=w;else{l=u,g=0,xe=65;break e}if(xe=o[u+20>>2]|0,u=o[u+16+(P>>>31<<2)>>2]|0,x=(xe|0)==0|(xe|0)==(u|0)?x:xe,u)P=P<<1;else{u=x,xe=61;break}}while(!1);if((xe|0)==61){if((u|0)==0&(l|0)==0){if(l=2<<C,l=(l|0-l)&f,!l){K=z;break}K=(l&0-l)+-1|0,w=K>>>12&16,K=K>>>w,x=K>>>5&8,K=K>>>x,P=K>>>2&4,K=K>>>P,C=K>>>1&2,K=K>>>C,u=K>>>1&1,l=0,u=o[28228+((x|w|P|C|u)+(K>>>u)<<2)>>2]|0}u?xe=65:(P=l,w=g)}if((xe|0)==65)for(x=u;;)if(K=(o[x+4>>2]&-8)-z|0,u=K>>>0<g>>>0,g=u?K:g,l=u?x:l,u=o[x+16>>2]|0,u||(u=o[x+20>>2]|0),u)x=u;else{P=l,w=g;break}if((P|0)!=0&&w>>>0<((o[6983]|0)-z|0)>>>0&&(F=P+z|0,F>>>0>P>>>0)){x=o[P+24>>2]|0,a=o[P+12>>2]|0;do if((a|0)==(P|0)){if(l=P+20|0,a=o[l>>2]|0,!a&&(l=P+16|0,a=o[l>>2]|0,!a)){a=0;break}for(;;)if(g=a+20|0,u=o[g>>2]|0,u)a=u,l=g;else if(g=a+16|0,u=o[g>>2]|0,u)a=u,l=g;else break;o[l>>2]=0}else we=o[P+8>>2]|0,o[we+12>>2]=a,o[a+8>>2]=we;while(!1);do if(x){if(l=o[P+28>>2]|0,u=28228+(l<<2)|0,(P|0)==(o[u>>2]|0)){if(o[u>>2]=a,!a){f=f&~(1<<l),o[6982]=f;break}}else if(we=x+16|0,o[((o[we>>2]|0)==(P|0)?we:x+20|0)>>2]=a,!a)break;o[a+24>>2]=x,l=o[P+16>>2]|0,l|0&&(o[a+16>>2]=l,o[l+24>>2]=a),l=o[P+20>>2]|0,l&&(o[a+20>>2]=l,o[l+24>>2]=a)}while(!1);e:do if(w>>>0<16)we=w+z|0,o[P+4>>2]=we|3,we=P+we+4|0,o[we>>2]=o[we>>2]|1;else{if(o[P+4>>2]=z|3,o[F+4>>2]=w|1,o[F+w>>2]=w,a=w>>>3,w>>>0<256){u=27964+(a<<1<<2)|0,l=o[6981]|0,a=1<<a,l&a?(l=u+8|0,a=o[l>>2]|0):(o[6981]=l|a,a=u,l=u+8|0),o[l>>2]=F,o[a+12>>2]=F,o[F+8>>2]=a,o[F+12>>2]=u;break}if(a=w>>>8,a?w>>>0>16777215?u=31:(Pe=(a+1048320|0)>>>16&8,we=a<<Pe,Se=(we+520192|0)>>>16&4,we=we<<Se,u=(we+245760|0)>>>16&2,u=14-(Se|Pe|u)+(we<<u>>>15)|0,u=w>>>(u+7|0)&1|u<<1):u=0,a=28228+(u<<2)|0,o[F+28>>2]=u,l=F+16|0,o[l+4>>2]=0,o[l>>2]=0,l=1<<u,!(f&l)){o[6982]=f|l,o[a>>2]=F,o[F+24>>2]=a,o[F+12>>2]=F,o[F+8>>2]=F;break}a=o[a>>2]|0;t:do if((o[a+4>>2]&-8|0)!=(w|0)){for(f=w<<((u|0)==31?0:25-(u>>>1)|0);u=a+16+(f>>>31<<2)|0,l=o[u>>2]|0,!!l;)if((o[l+4>>2]&-8|0)==(w|0)){a=l;break t}else f=f<<1,a=l;o[u>>2]=F,o[F+24>>2]=a,o[F+12>>2]=F,o[F+8>>2]=F;break e}while(!1);Pe=a+8|0,we=o[Pe>>2]|0,o[we+12>>2]=F,o[Pe>>2]=F,o[F+8>>2]=we,o[F+12>>2]=a,o[F+24>>2]=0}while(!1);return we=P+8|0,H=ct,we|0}else K=z}else K=z;else K=-1;while(!1);if(u=o[6983]|0,u>>>0>=K>>>0)return a=u-K|0,l=o[6986]|0,a>>>0>15?(we=l+K|0,o[6986]=we,o[6983]=a,o[we+4>>2]=a|1,o[l+u>>2]=a,o[l+4>>2]=K|3):(o[6983]=0,o[6986]=0,o[l+4>>2]=u|3,we=l+u+4|0,o[we>>2]=o[we>>2]|1),we=l+8|0,H=ct,we|0;if(w=o[6984]|0,w>>>0>K>>>0)return Se=w-K|0,o[6984]=Se,we=o[6987]|0,Pe=we+K|0,o[6987]=Pe,o[Pe+4>>2]=Se|1,o[we+4>>2]=K|3,we=we+8|0,H=ct,we|0;if(o[7099]|0?l=o[7101]|0:(o[7101]=4096,o[7100]=4096,o[7102]=-1,o[7103]=-1,o[7104]=0,o[7092]=0,o[7099]=ae&-16^1431655768,l=4096),P=K+48|0,C=K+47|0,x=l+C|0,g=0-l|0,z=x&g,z>>>0<=K>>>0||(l=o[7091]|0,l|0&&(F=o[7089]|0,ae=F+z|0,ae>>>0<=F>>>0|ae>>>0>l>>>0)))return we=0,H=ct,we|0;e:do if(o[7092]&4)a=0,xe=143;else{u=o[6987]|0;t:do if(u){for(f=28372;ae=o[f>>2]|0,!(ae>>>0<=u>>>0&&(ae+(o[f+4>>2]|0)|0)>>>0>u>>>0);)if(l=o[f+8>>2]|0,l)f=l;else{xe=128;break t}if(a=x-w&g,a>>>0<2147483647)if(l=Gn(a|0)|0,(l|0)==((o[f>>2]|0)+(o[f+4>>2]|0)|0)){if((l|0)!=-1){w=a,x=l,xe=145;break e}}else f=l,xe=136;else a=0}else xe=128;while(!1);do if((xe|0)==128)if(u=Gn(0)|0,(u|0)!=-1&&(a=u,oe=o[7100]|0,le=oe+-1|0,a=((le&a|0)==0?0:(le+a&0-oe)-a|0)+z|0,oe=o[7089]|0,le=a+oe|0,a>>>0>K>>>0&a>>>0<2147483647)){if(ae=o[7091]|0,ae|0&&le>>>0<=oe>>>0|le>>>0>ae>>>0){a=0;break}if(l=Gn(a|0)|0,(l|0)==(u|0)){w=a,x=u,xe=145;break e}else f=l,xe=136}else a=0;while(!1);do if((xe|0)==136){if(u=0-a|0,!(P>>>0>a>>>0&(a>>>0<2147483647&(f|0)!=-1)))if((f|0)==-1){a=0;break}else{w=a,x=f,xe=145;break e}if(l=o[7101]|0,l=C-a+l&0-l,l>>>0>=2147483647){w=a,x=f,xe=145;break e}if((Gn(l|0)|0)==-1){Gn(u|0)|0,a=0;break}else{w=l+a|0,x=f,xe=145;break e}}while(!1);o[7092]=o[7092]|4,xe=143}while(!1);if((xe|0)==143&&z>>>0<2147483647&&(Se=Gn(z|0)|0,le=Gn(0)|0,Ee=le-Se|0,Ue=Ee>>>0>(K+40|0)>>>0,!((Se|0)==-1|Ue^1|Se>>>0<le>>>0&((Se|0)!=-1&(le|0)!=-1)^1))&&(w=Ue?Ee:a,x=Se,xe=145),(xe|0)==145){a=(o[7089]|0)+w|0,o[7089]=a,a>>>0>(o[7090]|0)>>>0&&(o[7090]=a),C=o[6987]|0;e:do if(C){for(a=28372;;){if(l=o[a>>2]|0,u=o[a+4>>2]|0,(x|0)==(l+u|0)){xe=154;break}if(f=o[a+8>>2]|0,f)a=f;else break}if((xe|0)==154&&(Pe=a+4|0,(o[a+12>>2]&8|0)==0)&&x>>>0>C>>>0&l>>>0<=C>>>0){o[Pe>>2]=u+w,we=(o[6984]|0)+w|0,Se=C+8|0,Se=(Se&7|0)==0?0:0-Se&7,Pe=C+Se|0,Se=we-Se|0,o[6987]=Pe,o[6984]=Se,o[Pe+4>>2]=Se|1,o[C+we+4>>2]=40,o[6988]=o[7103];break}for(x>>>0<(o[6985]|0)>>>0&&(o[6985]=x),u=x+w|0,a=28372;;){if((o[a>>2]|0)==(u|0)){xe=162;break}if(l=o[a+8>>2]|0,l)a=l;else break}if((xe|0)==162&&(o[a+12>>2]&8|0)==0){o[a>>2]=x,F=a+4|0,o[F>>2]=(o[F>>2]|0)+w,F=x+8|0,F=x+((F&7|0)==0?0:0-F&7)|0,a=u+8|0,a=u+((a&7|0)==0?0:0-a&7)|0,z=F+K|0,P=a-F-K|0,o[F+4>>2]=K|3;t:do if((C|0)==(a|0))we=(o[6984]|0)+P|0,o[6984]=we,o[6987]=z,o[z+4>>2]=we|1;else{if((o[6986]|0)==(a|0)){we=(o[6983]|0)+P|0,o[6983]=we,o[6986]=z,o[z+4>>2]=we|1,o[z+we>>2]=we;break}if(l=o[a+4>>2]|0,(l&3|0)==1){w=l&-8,f=l>>>3;r:do if(l>>>0<256)if(l=o[a+8>>2]|0,u=o[a+12>>2]|0,(u|0)==(l|0)){o[6981]=o[6981]&~(1<<f);break}else{o[l+12>>2]=u,o[u+8>>2]=l;break}else{x=o[a+24>>2]|0,l=o[a+12>>2]|0;do if((l|0)==(a|0)){if(u=a+16|0,f=u+4|0,l=o[f>>2]|0,l)u=f;else if(l=o[u>>2]|0,!l){l=0;break}for(;;)if(g=l+20|0,f=o[g>>2]|0,f)l=f,u=g;else if(g=l+16|0,f=o[g>>2]|0,f)l=f,u=g;else break;o[u>>2]=0}else we=o[a+8>>2]|0,o[we+12>>2]=l,o[l+8>>2]=we;while(!1);if(!x)break;u=o[a+28>>2]|0,f=28228+(u<<2)|0;do if((o[f>>2]|0)!=(a|0)){if(we=x+16|0,o[((o[we>>2]|0)==(a|0)?we:x+20|0)>>2]=l,!l)break r}else{if(o[f>>2]=l,l|0)break;o[6982]=o[6982]&~(1<<u);break r}while(!1);if(o[l+24>>2]=x,u=a+16|0,f=o[u>>2]|0,f|0&&(o[l+16>>2]=f,o[f+24>>2]=l),u=o[u+4>>2]|0,!u)break;o[l+20>>2]=u,o[u+24>>2]=l}while(!1);a=a+w|0,g=w+P|0}else g=P;if(a=a+4|0,o[a>>2]=o[a>>2]&-2,o[z+4>>2]=g|1,o[z+g>>2]=g,a=g>>>3,g>>>0<256){u=27964+(a<<1<<2)|0,l=o[6981]|0,a=1<<a,l&a?(l=u+8|0,a=o[l>>2]|0):(o[6981]=l|a,a=u,l=u+8|0),o[l>>2]=z,o[a+12>>2]=z,o[z+8>>2]=a,o[z+12>>2]=u;break}a=g>>>8;do if(!a)f=0;else{if(g>>>0>16777215){f=31;break}Pe=(a+1048320|0)>>>16&8,we=a<<Pe,Se=(we+520192|0)>>>16&4,we=we<<Se,f=(we+245760|0)>>>16&2,f=14-(Se|Pe|f)+(we<<f>>>15)|0,f=g>>>(f+7|0)&1|f<<1}while(!1);if(a=28228+(f<<2)|0,o[z+28>>2]=f,l=z+16|0,o[l+4>>2]=0,o[l>>2]=0,l=o[6982]|0,u=1<<f,!(l&u)){o[6982]=l|u,o[a>>2]=z,o[z+24>>2]=a,o[z+12>>2]=z,o[z+8>>2]=z;break}a=o[a>>2]|0;r:do if((o[a+4>>2]&-8|0)!=(g|0)){for(f=g<<((f|0)==31?0:25-(f>>>1)|0);u=a+16+(f>>>31<<2)|0,l=o[u>>2]|0,!!l;)if((o[l+4>>2]&-8|0)==(g|0)){a=l;break r}else f=f<<1,a=l;o[u>>2]=z,o[z+24>>2]=a,o[z+12>>2]=z,o[z+8>>2]=z;break t}while(!1);Pe=a+8|0,we=o[Pe>>2]|0,o[we+12>>2]=z,o[Pe>>2]=z,o[z+8>>2]=we,o[z+12>>2]=a,o[z+24>>2]=0}while(!1);return we=F+8|0,H=ct,we|0}for(a=28372;l=o[a>>2]|0,!(l>>>0<=C>>>0&&(we=l+(o[a+4>>2]|0)|0,we>>>0>C>>>0));)a=o[a+8>>2]|0;g=we+-47|0,l=g+8|0,l=g+((l&7|0)==0?0:0-l&7)|0,g=C+16|0,l=l>>>0<g>>>0?C:l,a=l+8|0,u=w+-40|0,Se=x+8|0,Se=(Se&7|0)==0?0:0-Se&7,Pe=x+Se|0,Se=u-Se|0,o[6987]=Pe,o[6984]=Se,o[Pe+4>>2]=Se|1,o[x+u+4>>2]=40,o[6988]=o[7103],u=l+4|0,o[u>>2]=27,o[a>>2]=o[7093],o[a+4>>2]=o[7094],o[a+8>>2]=o[7095],o[a+12>>2]=o[7096],o[7093]=x,o[7094]=w,o[7096]=0,o[7095]=a,a=l+24|0;do Pe=a,a=a+4|0,o[a>>2]=7;while((Pe+8|0)>>>0<we>>>0);if((l|0)!=(C|0)){if(x=l-C|0,o[u>>2]=o[u>>2]&-2,o[C+4>>2]=x|1,o[l>>2]=x,a=x>>>3,x>>>0<256){u=27964+(a<<1<<2)|0,l=o[6981]|0,a=1<<a,l&a?(l=u+8|0,a=o[l>>2]|0):(o[6981]=l|a,a=u,l=u+8|0),o[l>>2]=C,o[a+12>>2]=C,o[C+8>>2]=a,o[C+12>>2]=u;break}if(a=x>>>8,a?x>>>0>16777215?f=31:(Pe=(a+1048320|0)>>>16&8,we=a<<Pe,Se=(we+520192|0)>>>16&4,we=we<<Se,f=(we+245760|0)>>>16&2,f=14-(Se|Pe|f)+(we<<f>>>15)|0,f=x>>>(f+7|0)&1|f<<1):f=0,u=28228+(f<<2)|0,o[C+28>>2]=f,o[C+20>>2]=0,o[g>>2]=0,a=o[6982]|0,l=1<<f,!(a&l)){o[6982]=a|l,o[u>>2]=C,o[C+24>>2]=u,o[C+12>>2]=C,o[C+8>>2]=C;break}a=o[u>>2]|0;t:do if((o[a+4>>2]&-8|0)!=(x|0)){for(f=x<<((f|0)==31?0:25-(f>>>1)|0);u=a+16+(f>>>31<<2)|0,l=o[u>>2]|0,!!l;)if((o[l+4>>2]&-8|0)==(x|0)){a=l;break t}else f=f<<1,a=l;o[u>>2]=C,o[C+24>>2]=a,o[C+12>>2]=C,o[C+8>>2]=C;break e}while(!1);Pe=a+8|0,we=o[Pe>>2]|0,o[we+12>>2]=C,o[Pe>>2]=C,o[C+8>>2]=we,o[C+12>>2]=a,o[C+24>>2]=0}}else we=o[6985]|0,(we|0)==0|x>>>0<we>>>0&&(o[6985]=x),o[7093]=x,o[7094]=w,o[7096]=0,o[6990]=o[7099],o[6989]=-1,o[6994]=27964,o[6993]=27964,o[6996]=27972,o[6995]=27972,o[6998]=27980,o[6997]=27980,o[7e3]=27988,o[6999]=27988,o[7002]=27996,o[7001]=27996,o[7004]=28004,o[7003]=28004,o[7006]=28012,o[7005]=28012,o[7008]=28020,o[7007]=28020,o[7010]=28028,o[7009]=28028,o[7012]=28036,o[7011]=28036,o[7014]=28044,o[7013]=28044,o[7016]=28052,o[7015]=28052,o[7018]=28060,o[7017]=28060,o[7020]=28068,o[7019]=28068,o[7022]=28076,o[7021]=28076,o[7024]=28084,o[7023]=28084,o[7026]=28092,o[7025]=28092,o[7028]=28100,o[7027]=28100,o[7030]=28108,o[7029]=28108,o[7032]=28116,o[7031]=28116,o[7034]=28124,o[7033]=28124,o[7036]=28132,o[7035]=28132,o[7038]=28140,o[7037]=28140,o[7040]=28148,o[7039]=28148,o[7042]=28156,o[7041]=28156,o[7044]=28164,o[7043]=28164,o[7046]=28172,o[7045]=28172,o[7048]=28180,o[7047]=28180,o[7050]=28188,o[7049]=28188,o[7052]=28196,o[7051]=28196,o[7054]=28204,o[7053]=28204,o[7056]=28212,o[7055]=28212,we=w+-40|0,Se=x+8|0,Se=(Se&7|0)==0?0:0-Se&7,Pe=x+Se|0,Se=we-Se|0,o[6987]=Pe,o[6984]=Se,o[Pe+4>>2]=Se|1,o[x+we+4>>2]=40,o[6988]=o[7103];while(!1);if(a=o[6984]|0,a>>>0>K>>>0)return Se=a-K|0,o[6984]=Se,we=o[6987]|0,Pe=we+K|0,o[6987]=Pe,o[Pe+4>>2]=Se|1,o[we+4>>2]=K|3,we=we+8|0,H=ct,we|0}return we=IA()|0,o[we>>2]=12,we=0,H=ct,we|0}function kt(l){l=l|0;var a=0,u=0,f=0,g=0,x=0,w=0,P=0,C=0;if(l){u=l+-8|0,g=o[6985]|0,l=o[l+-4>>2]|0,a=l&-8,C=u+a|0;do if(l&1)P=u,w=u;else{if(f=o[u>>2]|0,!(l&3)||(w=u+(0-f)|0,x=f+a|0,w>>>0<g>>>0))return;if((o[6986]|0)==(w|0)){if(l=C+4|0,a=o[l>>2]|0,(a&3|0)!=3){P=w,a=x;break}o[6983]=x,o[l>>2]=a&-2,o[w+4>>2]=x|1,o[w+x>>2]=x;return}if(u=f>>>3,f>>>0<256)if(l=o[w+8>>2]|0,a=o[w+12>>2]|0,(a|0)==(l|0)){o[6981]=o[6981]&~(1<<u),P=w,a=x;break}else{o[l+12>>2]=a,o[a+8>>2]=l,P=w,a=x;break}g=o[w+24>>2]|0,l=o[w+12>>2]|0;do if((l|0)==(w|0)){if(a=w+16|0,u=a+4|0,l=o[u>>2]|0,l)a=u;else if(l=o[a>>2]|0,!l){l=0;break}for(;;)if(f=l+20|0,u=o[f>>2]|0,u)l=u,a=f;else if(f=l+16|0,u=o[f>>2]|0,u)l=u,a=f;else break;o[a>>2]=0}else P=o[w+8>>2]|0,o[P+12>>2]=l,o[l+8>>2]=P;while(!1);if(g){if(a=o[w+28>>2]|0,u=28228+(a<<2)|0,(o[u>>2]|0)==(w|0)){if(o[u>>2]=l,!l){o[6982]=o[6982]&~(1<<a),P=w,a=x;break}}else if(P=g+16|0,o[((o[P>>2]|0)==(w|0)?P:g+20|0)>>2]=l,!l){P=w,a=x;break}o[l+24>>2]=g,a=w+16|0,u=o[a>>2]|0,u|0&&(o[l+16>>2]=u,o[u+24>>2]=l),a=o[a+4>>2]|0,a?(o[l+20>>2]=a,o[a+24>>2]=l,P=w,a=x):(P=w,a=x)}else P=w,a=x}while(!1);if(!(w>>>0>=C>>>0)&&(l=C+4|0,f=o[l>>2]|0,!!(f&1))){if(f&2)o[l>>2]=f&-2,o[P+4>>2]=a|1,o[w+a>>2]=a,g=a;else{if((o[6987]|0)==(C|0)){if(C=(o[6984]|0)+a|0,o[6984]=C,o[6987]=P,o[P+4>>2]=C|1,(P|0)!=(o[6986]|0))return;o[6986]=0,o[6983]=0;return}if((o[6986]|0)==(C|0)){C=(o[6983]|0)+a|0,o[6983]=C,o[6986]=w,o[P+4>>2]=C|1,o[w+C>>2]=C;return}g=(f&-8)+a|0,u=f>>>3;do if(f>>>0<256)if(a=o[C+8>>2]|0,l=o[C+12>>2]|0,(l|0)==(a|0)){o[6981]=o[6981]&~(1<<u);break}else{o[a+12>>2]=l,o[l+8>>2]=a;break}else{x=o[C+24>>2]|0,l=o[C+12>>2]|0;do if((l|0)==(C|0)){if(a=C+16|0,u=a+4|0,l=o[u>>2]|0,l)a=u;else if(l=o[a>>2]|0,!l){u=0;break}for(;;)if(f=l+20|0,u=o[f>>2]|0,u)l=u,a=f;else if(f=l+16|0,u=o[f>>2]|0,u)l=u,a=f;else break;o[a>>2]=0,u=l}else u=o[C+8>>2]|0,o[u+12>>2]=l,o[l+8>>2]=u,u=l;while(!1);if(x|0){if(l=o[C+28>>2]|0,a=28228+(l<<2)|0,(o[a>>2]|0)==(C|0)){if(o[a>>2]=u,!u){o[6982]=o[6982]&~(1<<l);break}}else if(f=x+16|0,o[((o[f>>2]|0)==(C|0)?f:x+20|0)>>2]=u,!u)break;o[u+24>>2]=x,l=C+16|0,a=o[l>>2]|0,a|0&&(o[u+16>>2]=a,o[a+24>>2]=u),l=o[l+4>>2]|0,l|0&&(o[u+20>>2]=l,o[l+24>>2]=u)}}while(!1);if(o[P+4>>2]=g|1,o[w+g>>2]=g,(P|0)==(o[6986]|0)){o[6983]=g;return}}if(l=g>>>3,g>>>0<256){u=27964+(l<<1<<2)|0,a=o[6981]|0,l=1<<l,a&l?(a=u+8|0,l=o[a>>2]|0):(o[6981]=a|l,l=u,a=u+8|0),o[a>>2]=P,o[l+12>>2]=P,o[P+8>>2]=l,o[P+12>>2]=u;return}l=g>>>8,l?g>>>0>16777215?f=31:(w=(l+1048320|0)>>>16&8,C=l<<w,x=(C+520192|0)>>>16&4,C=C<<x,f=(C+245760|0)>>>16&2,f=14-(x|w|f)+(C<<f>>>15)|0,f=g>>>(f+7|0)&1|f<<1):f=0,l=28228+(f<<2)|0,o[P+28>>2]=f,o[P+20>>2]=0,o[P+16>>2]=0,a=o[6982]|0,u=1<<f;e:do if(!(a&u))o[6982]=a|u,o[l>>2]=P,o[P+24>>2]=l,o[P+12>>2]=P,o[P+8>>2]=P;else{l=o[l>>2]|0;t:do if((o[l+4>>2]&-8|0)!=(g|0)){for(f=g<<((f|0)==31?0:25-(f>>>1)|0);u=l+16+(f>>>31<<2)|0,a=o[u>>2]|0,!!a;)if((o[a+4>>2]&-8|0)==(g|0)){l=a;break t}else f=f<<1,l=a;o[u>>2]=P,o[P+24>>2]=l,o[P+12>>2]=P,o[P+8>>2]=P;break e}while(!1);w=l+8|0,C=o[w>>2]|0,o[C+12>>2]=P,o[w>>2]=P,o[P+8>>2]=C,o[P+12>>2]=l,o[P+24>>2]=0}while(!1);if(C=(o[6989]|0)+-1|0,o[6989]=C,!(C|0)){for(l=28380;l=o[l>>2]|0,l;)l=l+8|0;o[6989]=-1}}}}function Bi(l,a){l=l|0,a=a|0;var u=0;return l?(u=Ji(a,l)|0,(a|l)>>>0>65535&&(u=((u>>>0)/(l>>>0)|0|0)==(a|0)?u:-1)):u=0,l=In(u)|0,!l||!(o[l+-4>>2]&3)||vi(l|0,0,u|0)|0,l|0}function Dt(l,a,u,f){return l=l|0,a=a|0,u=u|0,f=f|0,u=l+u>>>0,Pt(a+f+(u>>>0<l>>>0|0)>>>0|0),u|0|0}function Lr(l,a,u,f){return l=l|0,a=a|0,u=u|0,f=f|0,f=a-f-(u>>>0>l>>>0|0)>>>0,Pt(f|0),l-u>>>0|0|0}function Bl(l){return l=l|0,(l?31-(Zr(l^l-1)|0)|0:32)|0}function an(l,a,u,f,g){l=l|0,a=a|0,u=u|0,f=f|0,g=g|0;var x=0,w=0,P=0,C=0,z=0,F=0,K=0,ae=0,oe=0,le=0;if(F=l,C=a,z=C,w=u,ae=f,P=ae,!z)return x=(g|0)!=0,P?x?(o[g>>2]=l|0,o[g+4>>2]=a&0,ae=0,g=0,Pt(ae|0),g|0):(ae=0,g=0,Pt(ae|0),g|0):(x&&(o[g>>2]=(F>>>0)%(w>>>0),o[g+4>>2]=0),ae=0,g=(F>>>0)/(w>>>0)>>>0,Pt(ae|0),g|0);x=(P|0)==0;do if(w){if(!x){if(x=(Zr(P|0)|0)-(Zr(z|0)|0)|0,x>>>0<=31){K=x+1|0,P=31-x|0,a=x-31>>31,w=K,l=F>>>(K>>>0)&a|z<<P,a=z>>>(K>>>0)&a,x=0,P=F<<P;break}return g?(o[g>>2]=l|0,o[g+4>>2]=C|a&0,ae=0,g=0,Pt(ae|0),g|0):(ae=0,g=0,Pt(ae|0),g|0)}if(x=w-1|0,x&w|0){P=(Zr(w|0)|0)+33-(Zr(z|0)|0)|0,le=64-P|0,K=32-P|0,C=K>>31,oe=P-32|0,a=oe>>31,w=P,l=K-1>>31&z>>>(oe>>>0)|(z<<K|F>>>(P>>>0))&a,a=a&z>>>(P>>>0),x=F<<le&C,P=(z<<le|F>>>(oe>>>0))&C|F<<K&P-33>>31;break}return g|0&&(o[g>>2]=x&F,o[g+4>>2]=0),(w|0)==1?(oe=C|a&0,le=l|0|0,Pt(oe|0),le|0):(le=Bl(w|0)|0,oe=z>>>(le>>>0)|0,le=z<<32-le|F>>>(le>>>0)|0,Pt(oe|0),le|0)}else{if(x)return g|0&&(o[g>>2]=(z>>>0)%(w>>>0),o[g+4>>2]=0),oe=0,le=(z>>>0)/(w>>>0)>>>0,Pt(oe|0),le|0;if(!F)return g|0&&(o[g>>2]=0,o[g+4>>2]=(z>>>0)%(P>>>0)),oe=0,le=(z>>>0)/(P>>>0)>>>0,Pt(oe|0),le|0;if(x=P-1|0,!(x&P))return g|0&&(o[g>>2]=l|0,o[g+4>>2]=x&z|a&0),oe=0,le=z>>>((Bl(P|0)|0)>>>0),Pt(oe|0),le|0;if(x=(Zr(P|0)|0)-(Zr(z|0)|0)|0,x>>>0<=30){a=x+1|0,P=31-x|0,w=a,l=z<<P|F>>>(a>>>0),a=z>>>(a>>>0),x=0,P=F<<P;break}return g?(o[g>>2]=l|0,o[g+4>>2]=C|a&0,oe=0,le=0,Pt(oe|0),le|0):(oe=0,le=0,Pt(oe|0),le|0)}while(!1);if(!w)z=P,C=0,P=0;else{K=u|0|0,F=ae|f&0,z=Dt(K|0,F|0,-1,-1)|0,u=ee()|0,C=P,P=0;do f=C,C=x>>>31|C<<1,x=P|x<<1,f=l<<1|f>>>31|0,ae=l>>>31|a<<1|0,Lr(z|0,u|0,f|0,ae|0)|0,le=ee()|0,oe=le>>31|((le|0)<0?-1:0)<<1,P=oe&1,l=Lr(f|0,ae|0,oe&K|0,(((le|0)<0?-1:0)>>31|((le|0)<0?-1:0)<<1)&F|0)|0,a=ee()|0,w=w-1|0;while((w|0)!=0);z=C,C=0}return w=0,g|0&&(o[g>>2]=l,o[g+4>>2]=a),oe=(x|0)>>>31|(z|w)<<1|(w<<1|x>>>31)&0|C,le=(x<<1|0)&-2|P,Pt(oe|0),le|0}function yi(l,a,u,f){l=l|0,a=a|0,u=u|0,f=f|0;var g=0,x=0,w=0,P=0,C=0,z=0;return z=a>>31|((a|0)<0?-1:0)<<1,C=((a|0)<0?-1:0)>>31|((a|0)<0?-1:0)<<1,x=f>>31|((f|0)<0?-1:0)<<1,g=((f|0)<0?-1:0)>>31|((f|0)<0?-1:0)<<1,P=Lr(z^l|0,C^a|0,z|0,C|0)|0,w=ee()|0,l=x^z,a=g^C,Lr((an(P,w,Lr(x^u|0,g^f|0,x|0,g|0)|0,ee()|0,0)|0)^l|0,(ee()|0)^a|0,l|0,a|0)|0}function SA(l,a){l=l|0,a=a|0;var u=0,f=0,g=0,x=0;return x=l&65535,g=a&65535,u=Ji(g,x)|0,f=l>>>16,l=(u>>>16)+(Ji(g,f)|0)|0,g=a>>>16,a=Ji(g,x)|0,Pt((l>>>16)+(Ji(g,f)|0)+(((l&65535)+a|0)>>>16)|0),l+a<<16|u&65535|0|0}function Ir(l,a,u,f){l=l|0,a=a|0,u=u|0,f=f|0;var g=0,x=0;return g=l,x=u,u=SA(g,x)|0,l=ee()|0,Pt((Ji(a,x)|0)+(Ji(f,g)|0)+l|l&0|0),u|0|0|0}function Wo(l,a,u,f){l=l|0,a=a|0,u=u|0,f=f|0;var g=0,x=0,w=0,P=0,C=0,z=0;return g=H,H=H+16|0,P=g|0,w=a>>31|((a|0)<0?-1:0)<<1,x=((a|0)<0?-1:0)>>31|((a|0)<0?-1:0)<<1,z=f>>31|((f|0)<0?-1:0)<<1,C=((f|0)<0?-1:0)>>31|((f|0)<0?-1:0)<<1,l=Lr(w^l|0,x^a|0,w|0,x|0)|0,a=ee()|0,an(l,a,Lr(z^u|0,C^f|0,z|0,C|0)|0,ee()|0,P)|0,f=Lr(o[P>>2]^w|0,o[P+4>>2]^x|0,w|0,x|0)|0,u=ee()|0,H=g,Pt(u|0),f|0}function Jn(l,a,u,f){l=l|0,a=a|0,u=u|0,f=f|0;var g=0,x=0;return x=H,H=H+16|0,g=x|0,an(l,a,u,f,g)|0,H=x,Pt(o[g+4>>2]|0),o[g>>2]|0|0}function Ho(l,a,u){return l=l|0,a=a|0,u=u|0,(u|0)<32?(Pt(a>>u|0),l>>>u|(a&(1<<u)-1)<<32-u):(Pt(((a|0)<0?-1:0)|0),a>>u-32|0)}function Ye(l,a,u){return l=l|0,a=a|0,u=u|0,(u|0)<32?(Pt(a>>>u|0),l>>>u|(a&(1<<u)-1)<<32-u):(Pt(0),a>>>u-32|0)}function lt(l,a,u){return l=l|0,a=a|0,u=u|0,(u|0)<32?(Pt(a<<u|(l&(1<<u)-1<<32-u)>>>32-u|0),l<<u):(Pt(l<<u-32|0),0)}function el(l,a,u){return l=l|0,a=a|0,a=Zr(a)|0,(a|0)==32&&(a=a+(Zr(l)|0)|0),Pt(0),a|0}function CA(l,a){return l=+l,a=+a,l!=l?+a:a!=a?+l:+aa(+l,+a)}function tl(l,a){return l=+l,a=+a,l!=l?+a:a!=a?+l:+Ms(+l,+a)}function ds(l){return l=+l,l>=0?+br(l+.5):+Ln(l-.5)}function Nn(l,a,u){l=l|0,a=a|0,u=u|0;var f=0,g=0,x=0;if((u|0)>=8192)return Fn(l|0,a|0,u|0)|0,l|0;if(x=l|0,g=l+u|0,(l&3)==(a&3)){for(;l&3;){if(!u)return x|0;ot[l>>0]=ot[a>>0]|0,l=l+1|0,a=a+1|0,u=u-1|0}for(u=g&-4|0,f=u-64|0;(l|0)<=(f|0);)o[l>>2]=o[a>>2],o[l+4>>2]=o[a+4>>2],o[l+8>>2]=o[a+8>>2],o[l+12>>2]=o[a+12>>2],o[l+16>>2]=o[a+16>>2],o[l+20>>2]=o[a+20>>2],o[l+24>>2]=o[a+24>>2],o[l+28>>2]=o[a+28>>2],o[l+32>>2]=o[a+32>>2],o[l+36>>2]=o[a+36>>2],o[l+40>>2]=o[a+40>>2],o[l+44>>2]=o[a+44>>2],o[l+48>>2]=o[a+48>>2],o[l+52>>2]=o[a+52>>2],o[l+56>>2]=o[a+56>>2],o[l+60>>2]=o[a+60>>2],l=l+64|0,a=a+64|0;for(;(l|0)<(u|0);)o[l>>2]=o[a>>2],l=l+4|0,a=a+4|0}else for(u=g-4|0;(l|0)<(u|0);)ot[l>>0]=ot[a>>0]|0,ot[l+1>>0]=ot[a+1>>0]|0,ot[l+2>>0]=ot[a+2>>0]|0,ot[l+3>>0]=ot[a+3>>0]|0,l=l+4|0,a=a+4|0;for(;(l|0)<(g|0);)ot[l>>0]=ot[a>>0]|0,l=l+1|0,a=a+1|0;return x|0}function vi(l,a,u){l=l|0,a=a|0,u=u|0;var f=0,g=0,x=0,w=0;if(x=l+u|0,a=a&255,(u|0)>=67){for(;l&3;)ot[l>>0]=a,l=l+1|0;for(f=x&-4|0,w=a|a<<8|a<<16|a<<24,g=f-64|0;(l|0)<=(g|0);)o[l>>2]=w,o[l+4>>2]=w,o[l+8>>2]=w,o[l+12>>2]=w,o[l+16>>2]=w,o[l+20>>2]=w,o[l+24>>2]=w,o[l+28>>2]=w,o[l+32>>2]=w,o[l+36>>2]=w,o[l+40>>2]=w,o[l+44>>2]=w,o[l+48>>2]=w,o[l+52>>2]=w,o[l+56>>2]=w,o[l+60>>2]=w,l=l+64|0;for(;(l|0)<(f|0);)o[l>>2]=w,l=l+4|0}for(;(l|0)<(x|0);)ot[l>>0]=a,l=l+1|0;return x-u|0}function yt(l){return l=+l,l>=0?+br(l+.5):+Ln(l-.5)}function Gn(l){l=l|0;var a=0,u=0,f=0;return f=Ys()|0,u=o[pr>>2]|0,a=u+l|0,(l|0)>0&(a|0)<(u|0)|(a|0)<0?(Ks(a|0)|0,To(12),-1):(a|0)>(f|0)&&!(Kl(a|0)|0)?(To(12),-1):(o[pr>>2]=a,u|0)}return{___divdi3:yi,___muldi3:Ir,___remdi3:Wo,___uremdi3:Jn,_areNeighborCells:oA,_bitshift64Ashr:Ho,_bitshift64Lshr:Ye,_bitshift64Shl:lt,_calloc:Bi,_cellAreaKm2:xa,_cellAreaM2:Za,_cellAreaRads2:No,_cellToBoundary:Bs,_cellToCenterChild:ja,_cellToChildPos:dA,_cellToChildren:no,_cellToChildrenSize:Fo,_cellToLatLng:cs,_cellToLocalIj:uu,_cellToParent:Va,_cellToVertex:_i,_cellToVertexes:$o,_cellsToDirectedEdge:ml,_cellsToLinkedMultiPolygon:Es,_childPosToCell:Au,_compactCells:Oo,_constructCell:cA,_destroyLinkedMultiPolygon:tr,_directedEdgeToBoundary:Do,_directedEdgeToCells:Oa,_edgeLengthKm:Go,_edgeLengthM:Uo,_edgeLengthRads:_A,_emscripten_replace_memory:Qr,_free:kt,_getBaseCellNumber:da,_getDirectedEdgeDestination:ou,_getDirectedEdgeOrigin:aA,_getHexagonAreaAvgKm2:_n,_getHexagonAreaAvgM2:mA,_getHexagonEdgeLengthAvgKm:gA,_getHexagonEdgeLengthAvgM:Tl,_getIcosahedronFaces:Rs,_getIndexDigit:uA,_getNumCells:Xn,_getPentagons:vl,_getRes0Cells:Is,_getResolution:Lo,_greatCircleDistanceKm:so,_greatCircleDistanceM:oo,_greatCircleDistanceRads:qa,_gridDisk:ul,_gridDiskDistances:Aa,_gridDistance:xA,_gridPathCells:Ml,_gridPathCellsSize:hu,_gridRing:cl,_gridRingUnsafe:iA,_i64Add:Dt,_i64Subtract:Lr,_isPentagon:wr,_isResClassIII:lu,_isValidCell:ma,_isValidDirectedEdge:io,_isValidIndex:gl,_isValidVertex:Il,_latLngToCell:gn,_llvm_ctlz_i64:el,_llvm_maxnum_f64:CA,_llvm_minnum_f64:tl,_llvm_round_f64:ds,_localIjToCell:cu,_malloc:In,_maxFaceCount:Ua,_maxGridDiskSize:rA,_maxPolygonToCellsSize:nA,_maxPolygonToCellsSizeExperimental:Xa,_memcpy:Nn,_memset:vi,_originToDirectedEdges:Co,_pentagonCount:yl,_polygonToCells:hl,_polygonToCellsExperimental:Ha,_readInt64AsDoubleFromPointer:Jr,_res0CellCount:Er,_round:yt,_sbrk:Gn,_sizeOfCellBoundary:TA,_sizeOfCoordIJ:MA,_sizeOfGeoLoop:wa,_sizeOfGeoPolygon:Ka,_sizeOfH3Index:Ya,_sizeOfLatLng:wA,_sizeOfLinkedGeoPolygon:PA,_uncompactCells:hA,_uncompactCellsSize:Na,_vertexToLatLng:EA,establishStackSpace:tA,stackAlloc:Jl,stackRestore:la,stackSave:eA}})(Ke,_t,xn);Q.___divdi3=Be.___divdi3,Q.___muldi3=Be.___muldi3,Q.___remdi3=Be.___remdi3,Q.___uremdi3=Be.___uremdi3,Q._areNeighborCells=Be._areNeighborCells,Q._bitshift64Ashr=Be._bitshift64Ashr,Q._bitshift64Lshr=Be._bitshift64Lshr,Q._bitshift64Shl=Be._bitshift64Shl,Q._calloc=Be._calloc,Q._cellAreaKm2=Be._cellAreaKm2,Q._cellAreaM2=Be._cellAreaM2,Q._cellAreaRads2=Be._cellAreaRads2,Q._cellToBoundary=Be._cellToBoundary,Q._cellToCenterChild=Be._cellToCenterChild,Q._cellToChildPos=Be._cellToChildPos,Q._cellToChildren=Be._cellToChildren,Q._cellToChildrenSize=Be._cellToChildrenSize,Q._cellToLatLng=Be._cellToLatLng,Q._cellToLocalIj=Be._cellToLocalIj,Q._cellToParent=Be._cellToParent,Q._cellToVertex=Be._cellToVertex,Q._cellToVertexes=Be._cellToVertexes,Q._cellsToDirectedEdge=Be._cellsToDirectedEdge,Q._cellsToLinkedMultiPolygon=Be._cellsToLinkedMultiPolygon,Q._childPosToCell=Be._childPosToCell,Q._compactCells=Be._compactCells,Q._constructCell=Be._constructCell,Q._destroyLinkedMultiPolygon=Be._destroyLinkedMultiPolygon,Q._directedEdgeToBoundary=Be._directedEdgeToBoundary,Q._directedEdgeToCells=Be._directedEdgeToCells,Q._edgeLengthKm=Be._edgeLengthKm,Q._edgeLengthM=Be._edgeLengthM,Q._edgeLengthRads=Be._edgeLengthRads;var Vt=Q._emscripten_replace_memory=Be._emscripten_replace_memory;Q._free=Be._free,Q._getBaseCellNumber=Be._getBaseCellNumber,Q._getDirectedEdgeDestination=Be._getDirectedEdgeDestination,Q._getDirectedEdgeOrigin=Be._getDirectedEdgeOrigin,Q._getHexagonAreaAvgKm2=Be._getHexagonAreaAvgKm2,Q._getHexagonAreaAvgM2=Be._getHexagonAreaAvgM2,Q._getHexagonEdgeLengthAvgKm=Be._getHexagonEdgeLengthAvgKm,Q._getHexagonEdgeLengthAvgM=Be._getHexagonEdgeLengthAvgM,Q._getIcosahedronFaces=Be._getIcosahedronFaces,Q._getIndexDigit=Be._getIndexDigit,Q._getNumCells=Be._getNumCells,Q._getPentagons=Be._getPentagons,Q._getRes0Cells=Be._getRes0Cells,Q._getResolution=Be._getResolution,Q._greatCircleDistanceKm=Be._greatCircleDistanceKm,Q._greatCircleDistanceM=Be._greatCircleDistanceM,Q._greatCircleDistanceRads=Be._greatCircleDistanceRads,Q._gridDisk=Be._gridDisk,Q._gridDiskDistances=Be._gridDiskDistances,Q._gridDistance=Be._gridDistance,Q._gridPathCells=Be._gridPathCells,Q._gridPathCellsSize=Be._gridPathCellsSize,Q._gridRing=Be._gridRing,Q._gridRingUnsafe=Be._gridRingUnsafe,Q._i64Add=Be._i64Add,Q._i64Subtract=Be._i64Subtract,Q._isPentagon=Be._isPentagon,Q._isResClassIII=Be._isResClassIII,Q._isValidCell=Be._isValidCell,Q._isValidDirectedEdge=Be._isValidDirectedEdge,Q._isValidIndex=Be._isValidIndex,Q._isValidVertex=Be._isValidVertex,Q._latLngToCell=Be._latLngToCell,Q._llvm_ctlz_i64=Be._llvm_ctlz_i64,Q._llvm_maxnum_f64=Be._llvm_maxnum_f64,Q._llvm_minnum_f64=Be._llvm_minnum_f64,Q._llvm_round_f64=Be._llvm_round_f64,Q._localIjToCell=Be._localIjToCell,Q._malloc=Be._malloc,Q._maxFaceCount=Be._maxFaceCount,Q._maxGridDiskSize=Be._maxGridDiskSize,Q._maxPolygonToCellsSize=Be._maxPolygonToCellsSize,Q._maxPolygonToCellsSizeExperimental=Be._maxPolygonToCellsSizeExperimental,Q._memcpy=Be._memcpy,Q._memset=Be._memset,Q._originToDirectedEdges=Be._originToDirectedEdges,Q._pentagonCount=Be._pentagonCount,Q._polygonToCells=Be._polygonToCells,Q._polygonToCellsExperimental=Be._polygonToCellsExperimental,Q._readInt64AsDoubleFromPointer=Be._readInt64AsDoubleFromPointer,Q._res0CellCount=Be._res0CellCount,Q._round=Be._round,Q._sbrk=Be._sbrk,Q._sizeOfCellBoundary=Be._sizeOfCellBoundary,Q._sizeOfCoordIJ=Be._sizeOfCoordIJ,Q._sizeOfGeoLoop=Be._sizeOfGeoLoop,Q._sizeOfGeoPolygon=Be._sizeOfGeoPolygon,Q._sizeOfH3Index=Be._sizeOfH3Index,Q._sizeOfLatLng=Be._sizeOfLatLng,Q._sizeOfLinkedGeoPolygon=Be._sizeOfLinkedGeoPolygon,Q._uncompactCells=Be._uncompactCells,Q._uncompactCellsSize=Be._uncompactCellsSize,Q._vertexToLatLng=Be._vertexToLatLng,Q.establishStackSpace=Be.establishStackSpace;var gr=Q.stackAlloc=Be.stackAlloc,hr=Q.stackRestore=Be.stackRestore,Le=Q.stackSave=Be.stackSave;if(Q.asm=Be,Q.cwrap=Rr,Q.setValue=hi,Q.getValue=ss,Ci){Hs(Ci)||(Ci=it(Ci));{Ws();var _r=function(ke){ke.byteLength&&(ke=new Uint8Array(ke)),Gi.set(ke,bs),Q.memoryInitializerRequest&&delete Q.memoryInitializerRequest.response,wo()},mi=function(){G(Ci,_r,function(){throw"could not load memory initializer "+Ci})},Lt=tt(Ci);if(Lt)_r(Lt.buffer);else if(Q.memoryInitializerRequest){var mr=function(){var ke=Q.memoryInitializerRequest,Xe=ke.response;if(ke.status!==200&&ke.status!==0){var vt=tt(Q.memoryInitializerRequestURL);if(vt)Xe=vt.buffer;else{console.warn("a problem seems to have happened with Module.memoryInitializerRequest, status: "+ke.status+", retrying "+Ci),mi();return}}_r(Xe)};Q.memoryInitializerRequest.response?setTimeout(mr,0):Q.memoryInitializerRequest.addEventListener("load",mr)}else mi()}}var oi;Tn=function ke(){oi||Pr(),oi||(Tn=ke)};function Pr(ke){if(xr>0||(as(),xr>0))return;function Xe(){oi||(oi=!0,!Ar&&(qi(),$s(),Q.onRuntimeInitialized&&Q.onRuntimeInitialized(),zn()))}Q.setStatus?(Q.setStatus("Running..."),setTimeout(function(){setTimeout(function(){Q.setStatus("")},1),Xe()},1)):Xe()}Q.run=Pr;function Mr(ke){throw Q.onAbort&&Q.onAbort(ke),ke+="",d(ke),nt(ke),Ar=!0,"abort("+ke+"). Build with -s ASSERTIONS=1 for more info."}if(Q.abort=Mr,Q.preInit)for(typeof Q.preInit=="function"&&(Q.preInit=[Q.preInit]);Q.preInit.length>0;)Q.preInit.pop()();return Pr(),pe})(typeof qe=="object"?qe:{}),Qt="number",Gt=Qt,ru=Qt,Ht=Qt,Xt=Qt,hn=Qt,It=Qt,Zm=[["sizeOfH3Index",Qt],["sizeOfLatLng",Qt],["sizeOfCellBoundary",Qt],["sizeOfGeoLoop",Qt],["sizeOfGeoPolygon",Qt],["sizeOfLinkedGeoPolygon",Qt],["sizeOfCoordIJ",Qt],["readInt64AsDoubleFromPointer",Qt],["isValidCell",ru,[Ht,Xt]],["isValidIndex",ru,[Ht,Xt]],["latLngToCell",Gt,[Qt,Qt,hn,It]],["cellToLatLng",Gt,[Ht,Xt,It]],["cellToBoundary",Gt,[Ht,Xt,It]],["maxGridDiskSize",Gt,[Qt,It]],["gridDisk",Gt,[Ht,Xt,Qt,It]],["gridDiskDistances",Gt,[Ht,Xt,Qt,It,It]],["gridRing",Gt,[Ht,Xt,Qt,It]],["gridRingUnsafe",Gt,[Ht,Xt,Qt,It]],["maxPolygonToCellsSize",Gt,[It,hn,Qt,It]],["polygonToCells",Gt,[It,hn,Qt,It]],["maxPolygonToCellsSizeExperimental",Gt,[It,hn,Qt,It]],["polygonToCellsExperimental",Gt,[It,hn,Qt,Qt,Qt,It]],["cellsToLinkedMultiPolygon",Gt,[It,Qt,It]],["destroyLinkedMultiPolygon",null,[It]],["compactCells",Gt,[It,It,Qt,Qt]],["uncompactCells",Gt,[It,Qt,Qt,It,Qt,hn]],["uncompactCellsSize",Gt,[It,Qt,Qt,hn,It]],["isPentagon",ru,[Ht,Xt]],["isResClassIII",ru,[Ht,Xt]],["getBaseCellNumber",Qt,[Ht,Xt]],["getResolution",Qt,[Ht,Xt]],["getIndexDigit",Qt,[Ht,Xt,Qt]],["constructCell",Gt,[Qt,Qt,It,It]],["maxFaceCount",Gt,[Ht,Xt,It]],["getIcosahedronFaces",Gt,[Ht,Xt,It]],["cellToParent",Gt,[Ht,Xt,hn,It]],["cellToChildren",Gt,[Ht,Xt,hn,It]],["cellToCenterChild",Gt,[Ht,Xt,hn,It]],["cellToChildrenSize",Gt,[Ht,Xt,hn,It]],["cellToChildPos",Gt,[Ht,Xt,hn,It]],["childPosToCell",Gt,[Qt,Qt,Ht,Xt,hn,It]],["areNeighborCells",Gt,[Ht,Xt,Ht,Xt,It]],["cellsToDirectedEdge",Gt,[Ht,Xt,Ht,Xt,It]],["getDirectedEdgeOrigin",Gt,[Ht,Xt,It]],["getDirectedEdgeDestination",Gt,[Ht,Xt,It]],["isValidDirectedEdge",ru,[Ht,Xt]],["directedEdgeToCells",Gt,[Ht,Xt,It]],["originToDirectedEdges",Gt,[Ht,Xt,It]],["directedEdgeToBoundary",Gt,[Ht,Xt,It]],["gridDistance",Gt,[Ht,Xt,Ht,Xt,It]],["gridPathCells",Gt,[Ht,Xt,Ht,Xt,It]],["gridPathCellsSize",Gt,[Ht,Xt,Ht,Xt,It]],["cellToLocalIj",Gt,[Ht,Xt,Ht,Xt,Qt,It]],["localIjToCell",Gt,[Ht,Xt,It,Qt,It]],["getHexagonAreaAvgM2",Gt,[hn,It]],["getHexagonAreaAvgKm2",Gt,[hn,It]],["getHexagonEdgeLengthAvgM",Gt,[hn,It]],["getHexagonEdgeLengthAvgKm",Gt,[hn,It]],["greatCircleDistanceM",Qt,[It,It]],["greatCircleDistanceKm",Qt,[It,It]],["greatCircleDistanceRads",Qt,[It,It]],["cellAreaM2",Gt,[Ht,Xt,It]],["cellAreaKm2",Gt,[Ht,Xt,It]],["cellAreaRads2",Gt,[Ht,Xt,It]],["edgeLengthM",Gt,[Ht,Xt,It]],["edgeLengthKm",Gt,[Ht,Xt,It]],["edgeLengthRads",Gt,[Ht,Xt,It]],["getNumCells",Gt,[hn,It]],["getRes0Cells",Gt,[It]],["res0CellCount",Qt],["getPentagons",Gt,[Qt,It]],["pentagonCount",Qt],["cellToVertex",Gt,[Ht,Xt,Qt,It]],["cellToVertexes",Gt,[Ht,Xt,It]],["vertexToLatLng",Gt,[Ht,Xt,It]],["isValidVertex",ru,[Ht,Xt]]],Qm=0,$m=1,Wm=2,Hm=3,Xp=4,Yp=5,Xm=6,Ym=7,Km=8,Jm=9,eg=10,tg=11,rg=12,ig=13,ng=14,Kp=15,sg=16,og=17,Sh=18,ag=19,Ii={};Ii[Qm]="Success";Ii[$m]="The operation failed but a more specific error is not available";Ii[Wm]="Argument was outside of acceptable range";Ii[Hm]="Latitude or longitude arguments were outside of acceptable range";Ii[Xp]="Resolution argument was outside of acceptable range";Ii[Yp]="Cell argument was not valid";Ii[Xm]="Directed edge argument was not valid";Ii[Ym]="Undirected edge argument was not valid";Ii[Km]="Vertex argument was not valid";Ii[Jm]="Pentagon distortion was encountered";Ii[eg]="Duplicate input";Ii[tg]="Cell arguments were not neighbors";Ii[rg]="Cell arguments had incompatible resolutions";Ii[ig]="Memory allocation failed";Ii[ng]="Bounds of provided memory were insufficient";Ii[Kp]="Mode or flags argument was not valid";Ii[sg]="Index argument was not valid";Ii[og]="Base cell number was outside of acceptable range";Ii[Sh]="Child indexing digits invalid";Ii[ag]="Child indexing digits refer to a deleted subsequence";var nu=1e3,Jp=1001,ef=1002,Tc={};Tc[nu]="Unknown unit";Tc[Jp]="Array length out of bounds";Tc[ef]="Got unexpected null value for H3 index";var lg="Unknown error";function tf(pe,Q,be){var Ie=be&&"value"in be,We=new Error((pe[Q]||lg)+" (code: "+Q+(Ie?", value: "+be.value:"")+")");return We.code=Q,We}function qu(pe,Q){var be=arguments.length===2?{value:Q}:{};return tf(Ii,pe,be)}function Al(pe,Q){var be=arguments.length===2?{value:Q}:{};return tf(Tc,pe,be)}function Ot(pe){if(pe!==0)throw qu(pe)}var bt={};Zm.forEach(function(Q){bt[Q[0]]=qe.cwrap.apply(qe,Q)});var iu=16,Gu=0,pn=4,qp=4,xs=8,ta=8,Br=bt.sizeOfH3Index(),Zu=bt.sizeOfLatLng(),rf=bt.sizeOfCellBoundary(),Ag=bt.sizeOfGeoPolygon(),Uu=bt.sizeOfGeoLoop(),ug=bt.sizeOfLinkedGeoPolygon(),nf=bt.sizeOfCoordIJ(),is={m:"m",m2:"m2",km:"km",km2:"km2",rads:"rads",rads2:"rads2"},Nu={containmentCenter:"containmentCenter",containmentFull:"containmentFull",containmentOverlapping:"containmentOverlapping",containmentOverlappingBbox:"containmentOverlappingBbox"};function cg(pe){switch(pe){case Nu.containmentCenter:return 0;case Nu.containmentFull:return 1;case Nu.containmentOverlapping:return 2;case Nu.containmentOverlappingBbox:return 3;default:throw Al(Kp,pe)}}function Xl(pe){if(typeof pe!="number"||pe<0||pe>15||Math.floor(pe)!==pe)throw qu(Xp,pe);return pe}function ra(pe){if(!pe)throw Al(ef);return pe}var hg=Math.pow(2,32)-1;function Yl(pe){if(pe>hg)throw Al(Jp,pe);return pe}var pg=/[^0-9a-fA-F]/;function nr(pe){if(Array.isArray(pe)&&pe.length===2&&Number.isInteger(pe[0])&&Number.isInteger(pe[1]))return pe;if(typeof pe!="string"||pg.test(pe))return[0,0];var Q=parseInt(pe.substring(0,pe.length-8),iu),be=parseInt(pe.substring(pe.length-8),iu);return[be,Q]}function Zp(pe){if(pe>=0)return pe.toString(iu);pe=pe&2147483647;var Q=of(8,pe.toString(iu)),be=(parseInt(Q[0],iu)+8).toString(iu);return Q=be+Q.substring(1),Q}function sf(pe,Q){return Zp(Q)+of(8,Zp(pe))}function of(pe,Q){for(var be=pe-Q.length,Ie="",We=0;We<be;We++)Ie+="0";return Ie=Ie+Q,Ie}var fg=Math.pow(2,32);function dg(pe){return typeof pe!="number"?[0,0]:[pe|0,pe/fg|0]}function Qp(pe,Q,be){for(var Ie=pe.length,We=qe._calloc(Ie,Zu),it=be?1:0,G=be?0:1,d=0;d<Ie*2;d+=2)qe.HEAPF64.set([pe[d/2][it],pe[d/2][G]].map(Ec),We/xs+d);return qe.HEAPU32.set([Ie,We],Q/pn),Q}function af(pe,Q){var be=pe.length-1,Ie=qe._calloc(Ag),We=0,it=We+Uu,G=it+pn;Qp(pe[0],Ie+We,Q);var d;if(be>0){d=qe._calloc(be,Uu);for(var nt=0;nt<be;nt++)Qp(pe[nt+1],d+Uu*nt,Q)}return qe.setValue(Ie+it,be,"i32"),qe.setValue(Ie+G,d,"i32"),Ie}function lf(pe){var Q=0,be=Q+Uu,Ie=be+pn,We=pn;qe._free(qe.getValue(pe+Q+We,"i8*"));var it=qe.getValue(pe+be,"i32");if(it>0){for(var G=qe.getValue(pe+Ie,"i32"),d=0;d<it;d++)qe._free(qe.getValue(G+Uu*d+We,"i8*"));qe._free(G)}qe._free(pe)}function Ns(pe,Q){Q===void 0&&(Q=0);var be=qe.getValue(pe+Br*Q,"i32"),Ie=qe.getValue(pe+Br*Q+pn,"i32");return Ie?sf(be,Ie):null}function mg(pe,Q){Q===void 0&&(Q=0);var be=qe.getValue(pe+pn*Q,"i32");return!!be}function Pc(pe,Q){return Q===void 0&&(Q=0),qe.getValue(pe+xs*Q,"double")}function ia(pe){return bt.readInt64AsDoubleFromPointer(pe)}function gg(pe,Q,be){qe.HEAPU32.set(nr(pe),Q/pn+2*be)}function ns(pe,Q){for(var be=[],Ie=0;Ie<Q;Ie++){var We=Ns(pe,Ie);We!==null&&be.push(We)}return be}function Ch(pe,Q){for(var be=Q.length,Ie=0;Ie<be;Ie++)gg(Q[Ie],pe,Ie)}function $p(pe,Q){var be=qe._calloc(1,Zu);return qe.HEAPF64.set([pe,Q].map(Ec),be/xs),be}function wc(pe){return pf(qe.getValue(pe,"double"))}function Mc(pe){return[wc(pe),wc(pe+xs)]}function Af(pe){return[wc(pe+xs),wc(pe)]}function uf(pe,Q,be){for(var Ie=qe.getValue(pe,"i32"),We=pe+xs,it=[],G=Q?Af:Mc,d=0;d<Ie*2;d+=2)it.push(G(We+xs*d));return be&&it.push(it[0]),it}function _g(pe,Q){for(var be=[],Ie=Q?Af:Mc,We,it,G,d;pe;){for(be.push(We=[]),it=qe.getValue(pe,"i8*");it;){for(We.push(G=[]),d=qe.getValue(it,"i8*");d;)G.push(Ie(d)),d=qe.getValue(d+xs*2,"i8*");Q&&G.push(G[0]),it=qe.getValue(it+qp*2,"i8*")}pe=qe.getValue(pe+qp*2,"i8*")}return be}function yg(pe){return{i:qe.getValue(pe,"i32"),j:qe.getValue(pe+pn,"i32")}}function vg(pe,Q){var be=Q.i,Ie=Q.j;qe.setValue(pe,be,"i32"),qe.setValue(pe+pn,Ie,"i32")}function xg(pe,Q){for(var be=[],Ie=0;Ie<Q;Ie++){var We=qe.getValue(pe+pn*Ie,"i32");We>=0&&be.push(We)}return be}function Dh(pe){var Q=nr(pe),be=Q[0],Ie=Q[1];return!!bt.isValidCell(be,Ie)}function bg(pe){var Q=nr(pe),be=Q[0],Ie=Q[1];return!!bt.isValidIndex(be,Ie)}function wg(pe){var Q=nr(pe),be=Q[0],Ie=Q[1];return!!bt.isPentagon(be,Ie)}function Tg(pe){var Q=nr(pe),be=Q[0],Ie=Q[1];return!!bt.isResClassIII(be,Ie)}function Pg(pe){var Q=nr(pe),be=Q[0],Ie=Q[1];return bt.getBaseCellNumber(be,Ie)}function Mg(pe,Q){var be=qe._malloc(pn),Ie=nr(pe),We=Ie[0],it=Ie[1];try{return Ot(bt.getIndexDigit(We,it,Q,be)),qe.getValue(be,"i32")}finally{qe._free(be)}}function Eg(pe){var Q=nr(pe),be=Q[0],Ie=Q[1],We=qe._malloc(pn);try{Ot(bt.maxFaceCount(be,Ie,We));var it=qe.getValue(We,"i32"),G=qe._malloc(pn*it);try{return Ot(bt.getIcosahedronFaces(be,Ie,G)),xg(G,it)}finally{qe._free(G)}}finally{qe._free(We)}}function Ig(pe){var Q=nr(pe),be=Q[0],Ie=Q[1];return bt.isValidCell(be,Ie)?bt.getResolution(be,Ie):-1}function Sg(pe,Q,be){if(be===void 0&&(be=Q.length),Q.length!==be||Q.length>15)throw qu(Sh,Q.length);var Ie=qe._malloc(pn*Q.length),We=qe._malloc(Br);try{return Q.forEach(function(it,G){qe.setValue(Ie+pn*G,it,"i32")}),Ot(bt.constructCell(be,pe,Ie,We)),ra(Ns(We))}finally{qe._free(We),qe._free(Ie)}}function Cg(pe,Q,be){var Ie=qe._malloc(Zu);qe.HEAPF64.set([pe,Q].map(Ec),Ie/xs);var We=qe._malloc(Br);try{return Ot(bt.latLngToCell(Ie,be,We)),ra(Ns(We))}finally{qe._free(We),qe._free(Ie)}}function Dg(pe){var Q=qe._malloc(Zu),be=nr(pe),Ie=be[0],We=be[1];try{return Ot(bt.cellToLatLng(Ie,We,Q)),Mc(Q)}finally{qe._free(Q)}}function kg(pe,Q){var be=qe._malloc(rf),Ie=nr(pe),We=Ie[0],it=Ie[1];try{return Ot(bt.cellToBoundary(We,it,be)),uf(be,Q,Q)}finally{qe._free(be)}}function zg(pe,Q){var be=nr(pe),Ie=be[0],We=be[1],it=qe._malloc(Br);try{return Ot(bt.cellToParent(Ie,We,Q,it)),ra(Ns(it))}finally{qe._free(it)}}function Bg(pe,Q){if(!Dh(pe))return[];var be=nr(pe),Ie=be[0],We=be[1],it=Yl(cf(pe,Q)),G=qe._calloc(it,Br);try{return Ot(bt.cellToChildren(Ie,We,Q,G)),ns(G,it)}finally{qe._free(G)}}function cf(pe,Q){if(!Dh(pe))throw qu(Yp);var be=nr(pe),Ie=be[0],We=be[1],it=qe._malloc(ta);try{return Ot(bt.cellToChildrenSize(Ie,We,Q,it)),ia(it)}finally{qe._free(it)}}function Rg(pe,Q){var be=nr(pe),Ie=be[0],We=be[1],it=qe._malloc(Br);try{return Ot(bt.cellToCenterChild(Ie,We,Q,it)),ra(Ns(it))}finally{qe._free(it)}}function Lg(pe,Q){var be=nr(pe),Ie=be[0],We=be[1],it=qe._malloc(ta);try{return Ot(bt.cellToChildPos(Ie,We,Q,it)),ia(it)}finally{qe._free(it)}}function Fg(pe,Q,be){var Ie=dg(pe),We=Ie[0],it=Ie[1],G=nr(Q),d=G[0],nt=G[1],Vr=qe._malloc(Br);try{return Ot(bt.childPosToCell(We,it,d,nt,be,Vr)),ra(Ns(Vr))}finally{qe._free(Vr)}}function Og(pe,Q){var be=nr(pe),Ie=be[0],We=be[1],it=qe._malloc(ta);try{Ot(bt.maxGridDiskSize(Q,it));var G=Yl(ia(it)),d=qe._calloc(G,Br);try{return Ot(bt.gridDisk(Ie,We,Q,d)),ns(d,G)}finally{qe._free(d)}}finally{qe._free(it)}}function Vg(pe,Q){var be=nr(pe),Ie=be[0],We=be[1],it=qe._malloc(ta);try{Ot(bt.maxGridDiskSize(Q,it));var G=Yl(ia(it)),d=qe._calloc(G,Br),nt=qe._calloc(G,pn);try{Ot(bt.gridDiskDistances(Ie,We,Q,d,nt));for(var Vr=[],si=0;si<Q+1;si++)Vr.push([]);for(var kn=0;kn<G;kn++){var bs=Ns(d,kn),hi=qe.getValue(nt+pn*kn,"i32");bs!==null&&Vr[hi].push(bs)}return Vr}finally{qe._free(d),qe._free(nt)}}finally{qe._free(it)}}function jg(pe,Q){var be=Q===0?1:6*Q,Ie=qe._calloc(be,Br);try{return Ot(bt.gridRing.apply(bt,nr(pe).concat([Q],[Ie]))),ns(Ie,be)}finally{qe._free(Ie)}}function Ng(pe,Q){var be=Q===0?1:6*Q,Ie=qe._calloc(be,Br);try{return Ot(bt.gridRingUnsafe.apply(bt,nr(pe).concat([Q],[Ie]))),ns(Ie,be)}finally{qe._free(Ie)}}function Gg(pe,Q,be){if(Xl(Q),be=!!be,pe.length===0||pe[0].length===0)return[];var Ie=typeof pe[0][0]=="number"?[pe]:pe,We=af(Ie,be),it=qe._malloc(ta);try{Ot(bt.maxPolygonToCellsSize(We,Q,0,it));var G=Yl(ia(it)),d=qe._calloc(G,Br);try{return Ot(bt.polygonToCells(We,Q,0,d)),ns(d,G)}finally{qe._free(d)}}finally{qe._free(it),lf(We)}}function Ug(pe,Q,be,Ie){Xl(Q),Ie=!!Ie;var We=cg(be);if(pe.length===0||pe[0].length===0)return[];var it=typeof pe[0][0]=="number"?[pe]:pe,G=af(it,Ie),d=qe._malloc(ta);try{Ot(bt.maxPolygonToCellsSizeExperimental(G,Q,We,d));var nt=Yl(ia(d)),Vr=qe._calloc(nt,Br);try{return Ot(bt.polygonToCellsExperimental(G,Q,We,nt,Gu,Vr)),ns(Vr,nt)}finally{qe._free(Vr)}}finally{qe._free(d),lf(G)}}function qg(pe,Q){if(!pe||!pe.length)return[];var be=pe.length,Ie=qe._calloc(be,Br);Ch(Ie,pe);var We=qe._calloc(ug);try{return Ot(bt.cellsToLinkedMultiPolygon(Ie,be,We)),_g(We,Q)}finally{bt.destroyLinkedMultiPolygon(We),qe._free(We),qe._free(Ie)}}function Zg(pe){if(!pe||!pe.length)return[];var Q=pe.length,be=qe._calloc(Q,Br);Ch(be,pe);var Ie=qe._calloc(Q,Br);try{return Ot(bt.compactCells(be,Ie,Q,Gu)),ns(Ie,Q)}finally{qe._free(be),qe._free(Ie)}}function Qg(pe,Q){if(Xl(Q),!pe||!pe.length)return[];var be=pe.length,Ie=qe._calloc(be,Br);Ch(Ie,pe);var We=qe._malloc(ta);try{Ot(bt.uncompactCellsSize(Ie,be,Gu,Q,We));var it=Yl(ia(We)),G=qe._calloc(it,Br);try{return Ot(bt.uncompactCells(Ie,be,Gu,G,it,Gu,Q)),ns(G,it)}finally{qe._free(Ie),qe._free(G)}}finally{qe._free(We)}}function $g(pe,Q){var be=nr(pe),Ie=be[0],We=be[1],it=nr(Q),G=it[0],d=it[1],nt=qe._malloc(pn);try{return Ot(bt.areNeighborCells(Ie,We,G,d,nt)),mg(nt)}finally{qe._free(nt)}}function Wg(pe,Q){var be=nr(pe),Ie=be[0],We=be[1],it=nr(Q),G=it[0],d=it[1],nt=qe._malloc(Br);try{return Ot(bt.cellsToDirectedEdge(Ie,We,G,d,nt)),ra(Ns(nt))}finally{qe._free(nt)}}function Hg(pe){var Q=nr(pe),be=Q[0],Ie=Q[1],We=qe._malloc(Br);try{return Ot(bt.getDirectedEdgeOrigin(be,Ie,We)),ra(Ns(We))}finally{qe._free(We)}}function Xg(pe){var Q=nr(pe),be=Q[0],Ie=Q[1],We=qe._malloc(Br);try{return Ot(bt.getDirectedEdgeDestination(be,Ie,We)),ra(Ns(We))}finally{qe._free(We)}}function Yg(pe){var Q=nr(pe),be=Q[0],Ie=Q[1];return!!bt.isValidDirectedEdge(be,Ie)}function Kg(pe){var Q=nr(pe),be=Q[0],Ie=Q[1],We=2,it=qe._calloc(We,Br);try{return Ot(bt.directedEdgeToCells(be,Ie,it)),ns(it,We)}finally{qe._free(it)}}function Jg(pe){var Q=nr(pe),be=Q[0],Ie=Q[1],We=6,it=qe._calloc(We,Br);try{return Ot(bt.originToDirectedEdges(be,Ie,it)),ns(it,We)}finally{qe._free(it)}}function e_(pe,Q){var be=qe._malloc(rf),Ie=nr(pe),We=Ie[0],it=Ie[1];try{return Ot(bt.directedEdgeToBoundary(We,it,be)),uf(be,Q)}finally{qe._free(be)}}function t_(pe,Q){var be=nr(pe),Ie=be[0],We=be[1],it=nr(Q),G=it[0],d=it[1],nt=qe._malloc(ta);try{return Ot(bt.gridDistance(Ie,We,G,d,nt)),ia(nt)}finally{qe._free(nt)}}function r_(pe,Q){var be=nr(pe),Ie=be[0],We=be[1],it=nr(Q),G=it[0],d=it[1],nt=qe._malloc(ta);try{Ot(bt.gridPathCellsSize(Ie,We,G,d,nt));var Vr=Yl(ia(nt)),si=qe._calloc(Vr,Br);try{return bt.gridPathCells(Ie,We,G,d,si),ns(si,Vr)}finally{qe._free(si)}}finally{qe._free(nt)}}var hf=0;function i_(pe,Q){var be=qe._malloc(nf);try{return Ot(bt.cellToLocalIj.apply(bt,nr(pe).concat(nr(Q),[hf],[be]))),yg(be)}finally{qe._free(be)}}function n_(pe,Q){if(!Q||typeof Q.i!="number"||typeof Q.j!="number")throw new Error("Coordinates must be provided as an {i, j} object");var be=qe._malloc(nf),Ie=qe._malloc(Br);vg(be,Q);try{return Ot(bt.localIjToCell.apply(bt,nr(pe).concat([be],[hf],[Ie]))),ra(Ns(Ie))}finally{qe._free(be),qe._free(Ie)}}function s_(pe,Q,be){var Ie=$p(pe[0],pe[1]),We=$p(Q[0],Q[1]),it;switch(be){case is.m:it=bt.greatCircleDistanceM(Ie,We);break;case is.km:it=bt.greatCircleDistanceKm(Ie,We);break;case is.rads:it=bt.greatCircleDistanceRads(Ie,We);break;default:it=null}if(qe._free(Ie),qe._free(We),it===null)throw Al(nu,be);return it}function o_(pe,Q){var be=nr(pe),Ie=be[0],We=be[1],it=qe._malloc(xs);try{switch(Q){case is.m2:Ot(bt.cellAreaM2(Ie,We,it));break;case is.km2:Ot(bt.cellAreaKm2(Ie,We,it));break;case is.rads2:Ot(bt.cellAreaRads2(Ie,We,it));break;default:throw Al(nu,Q)}return Pc(it)}finally{qe._free(it)}}function a_(pe,Q){var be=nr(pe),Ie=be[0],We=be[1],it=qe._malloc(xs);try{switch(Q){case is.m:Ot(bt.edgeLengthM(Ie,We,it));break;case is.km:Ot(bt.edgeLengthKm(Ie,We,it));break;case is.rads:Ot(bt.edgeLengthRads(Ie,We,it));break;default:throw Al(nu,Q)}return Pc(it)}finally{qe._free(it)}}function l_(pe,Q){Xl(pe);var be=qe._malloc(xs);try{switch(Q){case is.m2:Ot(bt.getHexagonAreaAvgM2(pe,be));break;case is.km2:Ot(bt.getHexagonAreaAvgKm2(pe,be));break;default:throw Al(nu,Q)}return Pc(be)}finally{qe._free(be)}}function A_(pe,Q){Xl(pe);var be=qe._malloc(xs);try{switch(Q){case is.m:Ot(bt.getHexagonEdgeLengthAvgM(pe,be));break;case is.km:Ot(bt.getHexagonEdgeLengthAvgKm(pe,be));break;default:throw Al(nu,Q)}return Pc(be)}finally{qe._free(be)}}function u_(pe,Q){var be=nr(pe),Ie=be[0],We=be[1],it=qe._malloc(Br);try{return Ot(bt.cellToVertex(Ie,We,Q,it)),ra(Ns(it))}finally{qe._free(it)}}function c_(pe){var Q=nr(pe),be=Q[0],Ie=Q[1],We=6,it=qe._calloc(We,Br);try{return Ot(bt.cellToVertexes(be,Ie,it)),ns(it,We)}finally{qe._free(it)}}function h_(pe){var Q=qe._malloc(Zu),be=nr(pe),Ie=be[0],We=be[1];try{return Ot(bt.vertexToLatLng(Ie,We,Q)),Mc(Q)}finally{qe._free(Q)}}function p_(pe){var Q=nr(pe),be=Q[0],Ie=Q[1];return!!bt.isValidVertex(be,Ie)}function f_(pe){Xl(pe);var Q=qe._malloc(ta);try{return Ot(bt.getNumCells(pe,Q)),ia(Q)}finally{qe._free(Q)}}function d_(){var pe=bt.res0CellCount(),Q=qe._malloc(Br*pe);try{return Ot(bt.getRes0Cells(Q)),ns(Q,pe)}finally{qe._free(Q)}}function m_(pe){Xl(pe);var Q=bt.pentagonCount(),be=qe._malloc(Br*Q);try{return Ot(bt.getPentagons(pe,be)),ns(be,Q)}finally{qe._free(be)}}function Ec(pe){return pe*Math.PI/180}function pf(pe){return pe*180/Math.PI}const y_=Object.freeze(Object.defineProperty({__proto__:null,POLYGON_TO_CELLS_FLAGS:Nu,UNITS:is,areNeighborCells:$g,cellArea:o_,cellToBoundary:kg,cellToCenterChild:Rg,cellToChildPos:Lg,cellToChildren:Bg,cellToChildrenSize:cf,cellToLatLng:Dg,cellToLocalIj:i_,cellToParent:zg,cellToVertex:u_,cellToVertexes:c_,cellsToDirectedEdge:Wg,cellsToMultiPolygon:qg,childPosToCell:Fg,compactCells:Zg,constructCell:Sg,degsToRads:Ec,directedEdgeToBoundary:e_,directedEdgeToCells:Kg,edgeLength:a_,getBaseCellNumber:Pg,getDirectedEdgeDestination:Xg,getDirectedEdgeOrigin:Hg,getHexagonAreaAvg:l_,getHexagonEdgeLengthAvg:A_,getIcosahedronFaces:Eg,getIndexDigit:Mg,getNumCells:f_,getPentagons:m_,getRes0Cells:d_,getResolution:Ig,greatCircleDistance:s_,gridDisk:Og,gridDiskDistances:Vg,gridDistance:t_,gridPathCells:r_,gridRing:jg,gridRingUnsafe:Ng,h3IndexToSplitLong:nr,isPentagon:wg,isResClassIII:Tg,isValidCell:Dh,isValidDirectedEdge:Yg,isValidIndex:bg,isValidVertex:p_,latLngToCell:Cg,localIjToCell:n_,originToDirectedEdges:Jg,polygonToCells:Gg,polygonToCellsExperimental:Ug,radsToDegs:pf,splitLongToH3Index:sf,uncompactCells:Qg,vertexToLatLng:h_},Symbol.toStringTag,{value:"Module"})),v_=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{v_ as a,y_ as h,__ as m};
-814
static/js/maps-GDfHpVyJ.js
··· 1 - var Gm=Object.defineProperty;var qm=(xe,J,fe)=>J in xe?Gm(xe,J,{enumerable:!0,configurable:!0,writable:!0,value:fe}):xe[J]=fe;var Pi=(xe,J,fe)=>qm(xe,typeof J!="symbol"?J+"":J,fe);function Kd(xe,J){for(var fe=0;fe<J.length;fe++){const Re=J[fe];if(typeof Re!="string"&&!Array.isArray(Re)){for(const We in Re)if(We!=="default"&&!(We in xe)){const ct=Object.getOwnPropertyDescriptor(Re,We);ct&&Object.defineProperty(xe,We,ct.get?ct:{enumerable:!0,get:()=>Re[We]})}}}return Object.freeze(Object.defineProperty(xe,Symbol.toStringTag,{value:"Module"}))}function Jd(xe){return xe&&xe.__esModule&&Object.prototype.hasOwnProperty.call(xe,"default")?xe.default:xe}var Zh={exports:{}};/* @preserve 2 - * Leaflet 1.9.4, a JS library for interactive maps. https://leafletjs.com 3 - * (c) 2010-2023 Vladimir Agafonkin, (c) 2010-2011 CloudMade 4 - */var Hm=Zh.exports,Hd;function Wm(){return Hd||(Hd=1,(function(xe,J){(function(fe,Re){Re(J)})(Hm,(function(fe){var Re="1.9.4";function We(u){var v,E,R,q;for(E=1,R=arguments.length;E<R;E++){q=arguments[E];for(v in q)u[v]=q[v]}return u}var ct=Object.create||(function(){function u(){}return function(v){return u.prototype=v,new u}})();function W(u,v){var E=Array.prototype.slice;if(u.bind)return u.bind.apply(u,E.call(arguments,1));var R=E.call(arguments,2);return function(){return u.apply(v,R.length?R.concat(E.call(arguments)):arguments)}}var p=0;function it(u){return"_leaflet_id"in u||(u._leaflet_id=++p),u._leaflet_id}function ur(u,v,E){var R,q,ne,Ee;return Ee=function(){R=!1,q&&(ne.apply(E,q),q=!1)},ne=function(){R?q=arguments:(u.apply(E,arguments),setTimeout(Ee,v),R=!0)},ne}function fr(u,v,E){var R=v[1],q=v[0],ne=R-q;return u===R&&E?u:((u-q)%ne+ne)%ne+q}function Zi(){return!1}function un(u,v){if(v===!1)return u;var E=Math.pow(10,v===void 0?6:v);return Math.round(u*E)/E}function zr(u){return u.trim?u.trim():u.replace(/^\s+|\s+$/g,"")}function Mn(u){return zr(u).split(/\s+/)}function Gt(u,v){Object.prototype.hasOwnProperty.call(u,"options")||(u.options=u.options?ct(u.options):{});for(var E in v)u.options[E]=v[E];return u.options}function rt(u,v,E){var R=[];for(var q in u)R.push(encodeURIComponent(E?q.toUpperCase():q)+"="+encodeURIComponent(u[q]));return(!v||v.indexOf("?")===-1?"?":"&")+R.join("&")}var Fo=/\{ *([\w_ -]+) *\}/g;function hr(u,v){return u.replace(Fo,function(E,R){var q=v[R];if(q===void 0)throw new Error("No value provided for variable "+E);return typeof q=="function"&&(q=q(v)),q})}var zi=Array.isArray||function(u){return Object.prototype.toString.call(u)==="[object Array]"};function ro(u,v){for(var E=0;E<u.length;E++)if(u[E]===v)return E;return-1}var no="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=";function Ns(u){return window["webkit"+u]||window["moz"+u]||window["ms"+u]}var En=0;function Oo(u){var v=+new Date,E=Math.max(0,16-(v-En));return En=v+E,window.setTimeout(u,E)}var Vs=window.requestAnimationFrame||Ns("RequestAnimationFrame")||Oo,Cs=window.cancelAnimationFrame||Ns("CancelAnimationFrame")||Ns("CancelRequestAnimationFrame")||function(u){window.clearTimeout(u)};function cr(u,v,E){if(E&&Vs===Oo)u.call(v);else return Vs.call(window,W(u,v))}function Ji(u){u&&Cs.call(window,u)}var Sn={__proto__:null,extend:We,create:ct,bind:W,get lastId(){return p},stamp:it,throttle:ur,wrapNum:fr,falseFn:Zi,formatNum:un,trim:zr,splitWords:Mn,setOptions:Gt,getParamString:rt,template:hr,isArray:zi,indexOf:ro,emptyImageUrl:no,requestFn:Vs,cancelFn:Cs,requestAnimFrame:cr,cancelAnimFrame:Ji};function Cn(){}Cn.extend=function(u){var v=function(){Gt(this),this.initialize&&this.initialize.apply(this,arguments),this.callInitHooks()},E=v.__super__=this.prototype,R=ct(E);R.constructor=v,v.prototype=R;for(var q in this)Object.prototype.hasOwnProperty.call(this,q)&&q!=="prototype"&&q!=="__super__"&&(v[q]=this[q]);return u.statics&&We(v,u.statics),u.includes&&(Un(u.includes),We.apply(null,[R].concat(u.includes))),We(R,u),delete R.statics,delete R.includes,R.options&&(R.options=E.options?ct(E.options):{},We(R.options,u.options)),R._initHooks=[],R.callInitHooks=function(){if(!this._initHooksCalled){E.callInitHooks&&E.callInitHooks.call(this),this._initHooksCalled=!0;for(var ne=0,Ee=R._initHooks.length;ne<Ee;ne++)R._initHooks[ne].call(this)}},v},Cn.include=function(u){var v=this.prototype.options;return We(this.prototype,u),u.options&&(this.prototype.options=v,this.mergeOptions(u.options)),this},Cn.mergeOptions=function(u){return We(this.prototype.options,u),this},Cn.addInitHook=function(u){var v=Array.prototype.slice.call(arguments,1),E=typeof u=="function"?u:function(){this[u].apply(this,v)};return this.prototype._initHooks=this.prototype._initHooks||[],this.prototype._initHooks.push(E),this};function Un(u){if(!(typeof L>"u"||!L||!L.Mixin)){u=zi(u)?u:[u];for(var v=0;v<u.length;v++)u[v]===L.Mixin.Events&&console.warn("Deprecated include of L.Mixin.Events: this property will be removed in future releases, please inherit from L.Evented instead.",new Error().stack)}}var Jr={on:function(u,v,E){if(typeof u=="object")for(var R in u)this._on(R,u[R],v);else{u=Mn(u);for(var q=0,ne=u.length;q<ne;q++)this._on(u[q],v,E)}return this},off:function(u,v,E){if(!arguments.length)delete this._events;else if(typeof u=="object")for(var R in u)this._off(R,u[R],v);else{u=Mn(u);for(var q=arguments.length===1,ne=0,Ee=u.length;ne<Ee;ne++)q?this._off(u[ne]):this._off(u[ne],v,E)}return this},_on:function(u,v,E,R){if(typeof v!="function"){console.warn("wrong listener type: "+typeof v);return}if(this._listens(u,v,E)===!1){E===this&&(E=void 0);var q={fn:v,ctx:E};R&&(q.once=!0),this._events=this._events||{},this._events[u]=this._events[u]||[],this._events[u].push(q)}},_off:function(u,v,E){var R,q,ne;if(this._events&&(R=this._events[u],!!R)){if(arguments.length===1){if(this._firingCount)for(q=0,ne=R.length;q<ne;q++)R[q].fn=Zi;delete this._events[u];return}if(typeof v!="function"){console.warn("wrong listener type: "+typeof v);return}var Ee=this._listens(u,v,E);if(Ee!==!1){var Ze=R[Ee];this._firingCount&&(Ze.fn=Zi,this._events[u]=R=R.slice()),R.splice(Ee,1)}}},fire:function(u,v,E){if(!this.listens(u,E))return this;var R=We({},v,{type:u,target:this,sourceTarget:v&&v.sourceTarget||this});if(this._events){var q=this._events[u];if(q){this._firingCount=this._firingCount+1||1;for(var ne=0,Ee=q.length;ne<Ee;ne++){var Ze=q[ne],tt=Ze.fn;Ze.once&&this.off(u,tt,Ze.ctx),tt.call(Ze.ctx||this,R)}this._firingCount--}}return E&&this._propagateEvent(R),this},listens:function(u,v,E,R){typeof u!="string"&&console.warn('"string" type argument expected');var q=v;typeof v!="function"&&(R=!!v,q=void 0,E=void 0);var ne=this._events&&this._events[u];if(ne&&ne.length&&this._listens(u,q,E)!==!1)return!0;if(R){for(var Ee in this._eventParents)if(this._eventParents[Ee].listens(u,v,E,R))return!0}return!1},_listens:function(u,v,E){if(!this._events)return!1;var R=this._events[u]||[];if(!v)return!!R.length;E===this&&(E=void 0);for(var q=0,ne=R.length;q<ne;q++)if(R[q].fn===v&&R[q].ctx===E)return q;return!1},once:function(u,v,E){if(typeof u=="object")for(var R in u)this._on(R,u[R],v,!0);else{u=Mn(u);for(var q=0,ne=u.length;q<ne;q++)this._on(u[q],v,E,!0)}return this},addEventParent:function(u){return this._eventParents=this._eventParents||{},this._eventParents[it(u)]=u,this},removeEventParent:function(u){return this._eventParents&&delete this._eventParents[it(u)],this},_propagateEvent:function(u){for(var v in this._eventParents)this._eventParents[v].fire(u.type,We({layer:u.target,propagatedFrom:u.target},u),!0)}};Jr.addEventListener=Jr.on,Jr.removeEventListener=Jr.clearAllEventListeners=Jr.off,Jr.addOneTimeEventListener=Jr.once,Jr.fireEvent=Jr.fire,Jr.hasEventListeners=Jr.listens;var Hr=Cn.extend(Jr);function ti(u,v,E){this.x=E?Math.round(u):u,this.y=E?Math.round(v):v}var Oi=Math.trunc||function(u){return u>0?Math.floor(u):Math.ceil(u)};ti.prototype={clone:function(){return new ti(this.x,this.y)},add:function(u){return this.clone()._add(Yt(u))},_add:function(u){return this.x+=u.x,this.y+=u.y,this},subtract:function(u){return this.clone()._subtract(Yt(u))},_subtract:function(u){return this.x-=u.x,this.y-=u.y,this},divideBy:function(u){return this.clone()._divideBy(u)},_divideBy:function(u){return this.x/=u,this.y/=u,this},multiplyBy:function(u){return this.clone()._multiplyBy(u)},_multiplyBy:function(u){return this.x*=u,this.y*=u,this},scaleBy:function(u){return new ti(this.x*u.x,this.y*u.y)},unscaleBy:function(u){return new ti(this.x/u.x,this.y/u.y)},round:function(){return this.clone()._round()},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},floor:function(){return this.clone()._floor()},_floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.clone()._ceil()},_ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},trunc:function(){return this.clone()._trunc()},_trunc:function(){return this.x=Oi(this.x),this.y=Oi(this.y),this},distanceTo:function(u){u=Yt(u);var v=u.x-this.x,E=u.y-this.y;return Math.sqrt(v*v+E*E)},equals:function(u){return u=Yt(u),u.x===this.x&&u.y===this.y},contains:function(u){return u=Yt(u),Math.abs(u.x)<=Math.abs(this.x)&&Math.abs(u.y)<=Math.abs(this.y)},toString:function(){return"Point("+un(this.x)+", "+un(this.y)+")"}};function Yt(u,v,E){return u instanceof ti?u:zi(u)?new ti(u[0],u[1]):u==null?u:typeof u=="object"&&"x"in u&&"y"in u?new ti(u.x,u.y):new ti(u,v,E)}function Ni(u,v){if(u)for(var E=v?[u,v]:u,R=0,q=E.length;R<q;R++)this.extend(E[R])}Ni.prototype={extend:function(u){var v,E;if(!u)return this;if(u instanceof ti||typeof u[0]=="number"||"x"in u)v=E=Yt(u);else if(u=Mr(u),v=u.min,E=u.max,!v||!E)return this;return!this.min&&!this.max?(this.min=v.clone(),this.max=E.clone()):(this.min.x=Math.min(v.x,this.min.x),this.max.x=Math.max(E.x,this.max.x),this.min.y=Math.min(v.y,this.min.y),this.max.y=Math.max(E.y,this.max.y)),this},getCenter:function(u){return Yt((this.min.x+this.max.x)/2,(this.min.y+this.max.y)/2,u)},getBottomLeft:function(){return Yt(this.min.x,this.max.y)},getTopRight:function(){return Yt(this.max.x,this.min.y)},getTopLeft:function(){return this.min},getBottomRight:function(){return this.max},getSize:function(){return this.max.subtract(this.min)},contains:function(u){var v,E;return typeof u[0]=="number"||u instanceof ti?u=Yt(u):u=Mr(u),u instanceof Ni?(v=u.min,E=u.max):v=E=u,v.x>=this.min.x&&E.x<=this.max.x&&v.y>=this.min.y&&E.y<=this.max.y},intersects:function(u){u=Mr(u);var v=this.min,E=this.max,R=u.min,q=u.max,ne=q.x>=v.x&&R.x<=E.x,Ee=q.y>=v.y&&R.y<=E.y;return ne&&Ee},overlaps:function(u){u=Mr(u);var v=this.min,E=this.max,R=u.min,q=u.max,ne=q.x>v.x&&R.x<E.x,Ee=q.y>v.y&&R.y<E.y;return ne&&Ee},isValid:function(){return!!(this.min&&this.max)},pad:function(u){var v=this.min,E=this.max,R=Math.abs(v.x-E.x)*u,q=Math.abs(v.y-E.y)*u;return Mr(Yt(v.x-R,v.y-q),Yt(E.x+R,E.y+q))},equals:function(u){return u?(u=Mr(u),this.min.equals(u.getTopLeft())&&this.max.equals(u.getBottomRight())):!1}};function Mr(u,v){return!u||u instanceof Ni?u:new Ni(u,v)}function Wr(u,v){if(u)for(var E=v?[u,v]:u,R=0,q=E.length;R<q;R++)this.extend(E[R])}Wr.prototype={extend:function(u){var v=this._southWest,E=this._northEast,R,q;if(u instanceof xi)R=u,q=u;else if(u instanceof Wr){if(R=u._southWest,q=u._northEast,!R||!q)return this}else return u?this.extend(Ai(u)||or(u)):this;return!v&&!E?(this._southWest=new xi(R.lat,R.lng),this._northEast=new xi(q.lat,q.lng)):(v.lat=Math.min(R.lat,v.lat),v.lng=Math.min(R.lng,v.lng),E.lat=Math.max(q.lat,E.lat),E.lng=Math.max(q.lng,E.lng)),this},pad:function(u){var v=this._southWest,E=this._northEast,R=Math.abs(v.lat-E.lat)*u,q=Math.abs(v.lng-E.lng)*u;return new Wr(new xi(v.lat-R,v.lng-q),new xi(E.lat+R,E.lng+q))},getCenter:function(){return new xi((this._southWest.lat+this._northEast.lat)/2,(this._southWest.lng+this._northEast.lng)/2)},getSouthWest:function(){return this._southWest},getNorthEast:function(){return this._northEast},getNorthWest:function(){return new xi(this.getNorth(),this.getWest())},getSouthEast:function(){return new xi(this.getSouth(),this.getEast())},getWest:function(){return this._southWest.lng},getSouth:function(){return this._southWest.lat},getEast:function(){return this._northEast.lng},getNorth:function(){return this._northEast.lat},contains:function(u){typeof u[0]=="number"||u instanceof xi||"lat"in u?u=Ai(u):u=or(u);var v=this._southWest,E=this._northEast,R,q;return u instanceof Wr?(R=u.getSouthWest(),q=u.getNorthEast()):R=q=u,R.lat>=v.lat&&q.lat<=E.lat&&R.lng>=v.lng&&q.lng<=E.lng},intersects:function(u){u=or(u);var v=this._southWest,E=this._northEast,R=u.getSouthWest(),q=u.getNorthEast(),ne=q.lat>=v.lat&&R.lat<=E.lat,Ee=q.lng>=v.lng&&R.lng<=E.lng;return ne&&Ee},overlaps:function(u){u=or(u);var v=this._southWest,E=this._northEast,R=u.getSouthWest(),q=u.getNorthEast(),ne=q.lat>v.lat&&R.lat<E.lat,Ee=q.lng>v.lng&&R.lng<E.lng;return ne&&Ee},toBBoxString:function(){return[this.getWest(),this.getSouth(),this.getEast(),this.getNorth()].join(",")},equals:function(u,v){return u?(u=or(u),this._southWest.equals(u.getSouthWest(),v)&&this._northEast.equals(u.getNorthEast(),v)):!1},isValid:function(){return!!(this._southWest&&this._northEast)}};function or(u,v){return u instanceof Wr?u:new Wr(u,v)}function xi(u,v,E){if(isNaN(u)||isNaN(v))throw new Error("Invalid LatLng object: ("+u+", "+v+")");this.lat=+u,this.lng=+v,E!==void 0&&(this.alt=+E)}xi.prototype={equals:function(u,v){if(!u)return!1;u=Ai(u);var E=Math.max(Math.abs(this.lat-u.lat),Math.abs(this.lng-u.lng));return E<=(v===void 0?1e-9:v)},toString:function(u){return"LatLng("+un(this.lat,u)+", "+un(this.lng,u)+")"},distanceTo:function(u){return Er.distance(this,Ai(u))},wrap:function(){return Er.wrapLatLng(this)},toBounds:function(u){var v=180*u/40075017,E=v/Math.cos(Math.PI/180*this.lat);return or([this.lat-v,this.lng-E],[this.lat+v,this.lng+E])},clone:function(){return new xi(this.lat,this.lng,this.alt)}};function Ai(u,v,E){return u instanceof xi?u:zi(u)&&typeof u[0]!="object"?u.length===3?new xi(u[0],u[1],u[2]):u.length===2?new xi(u[0],u[1]):null:u==null?u:typeof u=="object"&&"lat"in u?new xi(u.lat,"lng"in u?u.lng:u.lon,u.alt):v===void 0?null:new xi(u,v,E)}var hn={latLngToPoint:function(u,v){var E=this.projection.project(u),R=this.scale(v);return this.transformation._transform(E,R)},pointToLatLng:function(u,v){var E=this.scale(v),R=this.transformation.untransform(u,E);return this.projection.unproject(R)},project:function(u){return this.projection.project(u)},unproject:function(u){return this.projection.unproject(u)},scale:function(u){return 256*Math.pow(2,u)},zoom:function(u){return Math.log(u/256)/Math.LN2},getProjectedBounds:function(u){if(this.infinite)return null;var v=this.projection.bounds,E=this.scale(u),R=this.transformation.transform(v.min,E),q=this.transformation.transform(v.max,E);return new Ni(R,q)},infinite:!1,wrapLatLng:function(u){var v=this.wrapLng?fr(u.lng,this.wrapLng,!0):u.lng,E=this.wrapLat?fr(u.lat,this.wrapLat,!0):u.lat,R=u.alt;return new xi(E,v,R)},wrapLatLngBounds:function(u){var v=u.getCenter(),E=this.wrapLatLng(v),R=v.lat-E.lat,q=v.lng-E.lng;if(R===0&&q===0)return u;var ne=u.getSouthWest(),Ee=u.getNorthEast(),Ze=new xi(ne.lat-R,ne.lng-q),tt=new xi(Ee.lat-R,Ee.lng-q);return new Wr(Ze,tt)}},Er=We({},hn,{wrapLng:[-180,180],R:6371e3,distance:function(u,v){var E=Math.PI/180,R=u.lat*E,q=v.lat*E,ne=Math.sin((v.lat-u.lat)*E/2),Ee=Math.sin((v.lng-u.lng)*E/2),Ze=ne*ne+Math.cos(R)*Math.cos(q)*Ee*Ee,tt=2*Math.atan2(Math.sqrt(Ze),Math.sqrt(1-Ze));return this.R*tt}}),yo=6378137,us={R:yo,MAX_LATITUDE:85.0511287798,project:function(u){var v=Math.PI/180,E=this.MAX_LATITUDE,R=Math.max(Math.min(E,u.lat),-E),q=Math.sin(R*v);return new ti(this.R*u.lng*v,this.R*Math.log((1+q)/(1-q))/2)},unproject:function(u){var v=180/Math.PI;return new xi((2*Math.atan(Math.exp(u.y/this.R))-Math.PI/2)*v,u.x*v/this.R)},bounds:(function(){var u=yo*Math.PI;return new Ni([-u,-u],[u,u])})()};function No(u,v,E,R){if(zi(u)){this._a=u[0],this._b=u[1],this._c=u[2],this._d=u[3];return}this._a=u,this._b=v,this._c=E,this._d=R}No.prototype={transform:function(u,v){return this._transform(u.clone(),v)},_transform:function(u,v){return v=v||1,u.x=v*(this._a*u.x+this._b),u.y=v*(this._c*u.y+this._d),u},untransform:function(u,v){return v=v||1,new ti((u.x/v-this._b)/this._a,(u.y/v-this._d)/this._c)}};function In(u,v,E,R){return new No(u,v,E,R)}var Vo=We({},Er,{code:"EPSG:3857",projection:us,transformation:(function(){var u=.5/(Math.PI*us.R);return In(u,.5,-u,.5)})()}),en=We({},Vo,{code:"EPSG:900913"});function hs(u){return document.createElementNS("http://www.w3.org/2000/svg",u)}function Is(u,v){var E="",R,q,ne,Ee,Ze,tt;for(R=0,ne=u.length;R<ne;R++){for(Ze=u[R],q=0,Ee=Ze.length;q<Ee;q++)tt=Ze[q],E+=(q?"L":"M")+tt.x+" "+tt.y;E+=v?o.svg?"z":"x":""}return E||"M0 0"}var Ui=document.documentElement.style,Dn="ActiveXObject"in window,jo=Dn&&!document.addEventListener,Zo="msLaunchUri"in navigator&&!("documentMode"in document),tn=At("webkit"),Gn=At("android"),vo=At("android 2")||At("android 3"),Ds=parseInt(/WebKit\/([0-9]+)|$/.exec(navigator.userAgent)[1],10),mn=Gn&&At("Google")&&Ds<537&&!("AudioNode"in window),Ne=!!window.opera,ee=!Zo&&At("chrome"),K=At("gecko")&&!tn&&!Ne&&!Dn,le=!ee&&At("safari"),Me=At("phantom"),Se="OTransition"in Ui,Ge=navigator.platform.indexOf("Win")===0,Fe=Dn&&"transition"in Ui,ke="WebKitCSSMatrix"in window&&"m11"in new window.WebKitCSSMatrix&&!vo,Qe="MozPerspective"in Ui,ft=!window.L_DISABLE_3D&&(Fe||ke||Qe)&&!Se&&!Me,ot=typeof orientation<"u"||At("mobile"),St=ot&&tn,je=ot&&ke,Xt=!window.PointerEvent&&window.MSPointerEvent,Gi=!!(window.PointerEvent||Xt),Bi="ontouchstart"in window||!!window.TouchEvent,qe=!window.L_NO_TOUCH&&(Bi||Gi),Hi=ot&&Ne,rn=ot&&K,Kt=(window.devicePixelRatio||window.screen.deviceXDPI/window.screen.logicalXDPI)>1,qi=(function(){var u=!1;try{var v=Object.defineProperty({},"passive",{get:function(){u=!0}});window.addEventListener("testPassiveEventSupport",Zi,v),window.removeEventListener("testPassiveEventSupport",Zi,v)}catch{}return u})(),Vr=(function(){return!!document.createElement("canvas").getContext})(),Wi=!!(document.createElementNS&&hs("svg").createSVGRect),er=!!Wi&&(function(){var u=document.createElement("div");return u.innerHTML="<svg/>",(u.firstChild&&u.firstChild.namespaceURI)==="http://www.w3.org/2000/svg"})(),Ve=!Wi&&(function(){try{var u=document.createElement("div");u.innerHTML='<v:shape adj="1"/>';var v=u.firstChild;return v.style.behavior="url(#default#VML)",v&&typeof v.adj=="object"}catch{return!1}})(),at=navigator.platform.indexOf("Mac")===0,It=navigator.platform.indexOf("Linux")===0;function At(u){return navigator.userAgent.toLowerCase().indexOf(u)>=0}var o={ie:Dn,ielt9:jo,edge:Zo,webkit:tn,android:Gn,android23:vo,androidStock:mn,opera:Ne,chrome:ee,gecko:K,safari:le,phantom:Me,opera12:Se,win:Ge,ie3d:Fe,webkit3d:ke,gecko3d:Qe,any3d:ft,mobile:ot,mobileWebkit:St,mobileWebkit3d:je,msPointer:Xt,pointer:Gi,touch:qe,touchNative:Bi,mobileOpera:Hi,mobileGecko:rn,retina:Kt,passiveEvents:qi,canvas:Vr,svg:Wi,vml:Ve,inlineSvg:er,mac:at,linux:It},X=o.msPointer?"MSPointerDown":"pointerdown",ii=o.msPointer?"MSPointerMove":"pointermove",Ri=o.msPointer?"MSPointerUp":"pointerup",Qi=o.msPointer?"MSPointerCancel":"pointercancel",ut={touchstart:X,touchmove:ii,touchend:Ri,touchcancel:Qi},zt={touchstart:Hn,touchmove:qn,touchend:qn,touchcancel:qn},$t={},fi=!1;function di(u,v,E){return v==="touchstart"&&kn(),zt[v]?(E=zt[v].bind(this,E),u.addEventListener(ut[v],E,!1),E):(console.warn("wrong event specified:",v),Zi)}function jr(u,v,E){if(!ut[v]){console.warn("wrong event specified:",v);return}u.removeEventListener(ut[v],E,!1)}function ni(u){$t[u.pointerId]=u}function Ea(u){$t[u.pointerId]&&($t[u.pointerId]=u)}function xo(u){delete $t[u.pointerId]}function kn(){fi||(document.addEventListener(X,ni,!0),document.addEventListener(ii,Ea,!0),document.addEventListener(Ri,xo,!0),document.addEventListener(Qi,xo,!0),fi=!0)}function qn(u,v){if(v.pointerType!==(v.MSPOINTER_TYPE_MOUSE||"mouse")){v.touches=[];for(var E in $t)v.touches.push($t[E]);v.changedTouches=[v],u(v)}}function Hn(u,v){v.MSPOINTER_TYPE_TOUCH&&v.pointerType===v.MSPOINTER_TYPE_TOUCH&&Si(v),qn(u,v)}function bo(u){var v={},E,R;for(R in u)E=u[R],v[R]=E&&E.bind?E.bind(u):E;return u=v,v.type="dblclick",v.detail=2,v.isTrusted=!1,v._simulated=!0,v}var Sa=200;function vr(u,v){u.addEventListener("dblclick",v);var E=0,R;function q(ne){if(ne.detail!==1){R=ne.detail;return}if(!(ne.pointerType==="mouse"||ne.sourceCapabilities&&!ne.sourceCapabilities.firesTouchEvents)){var Ee=gs(ne);if(!(Ee.some(function(tt){return tt instanceof HTMLLabelElement&&tt.attributes.for})&&!Ee.some(function(tt){return tt instanceof HTMLInputElement||tt instanceof HTMLSelectElement}))){var Ze=Date.now();Ze-E<=Sa?(R++,R===2&&v(bo(ne))):R=1,E=Ze}}}return u.addEventListener("click",q),{dblclick:v,simDblclick:q}}function Ft(u,v){u.removeEventListener("dblclick",v.dblclick),u.removeEventListener("click",v.simDblclick)}var ae=Ln(["transform","webkitTransform","OTransform","MozTransform","msTransform"]),qt=Ln(["webkitTransition","transition","OTransition","MozTransition","msTransition"]),Uo=qt==="webkitTransition"||qt==="OTransition"?qt+"End":"transitionend";function wo(u){return typeof u=="string"?document.getElementById(u):u}function zn(u,v){var E=u.style[v]||u.currentStyle&&u.currentStyle[v];if((!E||E==="auto")&&document.defaultView){var R=document.defaultView.getComputedStyle(u,null);E=R?R[v]:null}return E==="auto"?null:E}function Fi(u,v,E){var R=document.createElement(u);return R.className=v||"",E&&E.appendChild(R),R}function Xi(u){var v=u.parentNode;v&&v.removeChild(u)}function te(u){for(;u.firstChild;)u.removeChild(u.firstChild)}function tr(u){var v=u.parentNode;v&&v.lastChild!==u&&v.appendChild(u)}function Go(u){var v=u.parentNode;v&&v.firstChild!==u&&v.insertBefore(u,v.firstChild)}function Ha(u,v){if(u.classList!==void 0)return u.classList.contains(v);var E=ha(u);return E.length>0&&new RegExp("(^|\\s)"+v+"(\\s|$)").test(E)}function _i(u,v){if(u.classList!==void 0)for(var E=Mn(v),R=0,q=E.length;R<q;R++)u.classList.add(E[R]);else if(!Ha(u,v)){var ne=ha(u);Wa(u,(ne?ne+" ":"")+v)}}function Sr(u,v){u.classList!==void 0?u.classList.remove(v):Wa(u,zr((" "+ha(u)+" ").replace(" "+v+" "," ")))}function Wa(u,v){u.className.baseVal===void 0?u.className=v:u.className.baseVal=v}function ha(u){return u.correspondingElement&&(u=u.correspondingElement),u.className.baseVal===void 0?u.className:u.className.baseVal}function _n(u,v){"opacity"in u.style?u.style.opacity=v:"filter"in u.style&&Qa(u,v)}function Qa(u,v){var E=!1,R="DXImageTransform.Microsoft.Alpha";try{E=u.filters.item(R)}catch{if(v===1)return}v=Math.round(v*100),E?(E.Enabled=v!==100,E.Opacity=v):u.style.filter+=" progid:"+R+"(opacity="+v+")"}function Ln(u){for(var v=document.documentElement.style,E=0;E<u.length;E++)if(u[E]in v)return u[E];return!1}function ar(u,v,E){var R=v||new ti(0,0);u.style[ae]=(o.ie3d?"translate("+R.x+"px,"+R.y+"px)":"translate3d("+R.x+"px,"+R.y+"px,0)")+(E?" scale("+E+")":"")}function Cr(u,v){u._leaflet_pos=v,o.any3d?ar(u,v):(u.style.left=v.x+"px",u.style.top=v.y+"px")}function To(u){return u._leaflet_pos||new ti(0,0)}var so,js,$a;if("onselectstart"in document)so=function(){Ht(window,"selectstart",Si)},js=function(){Dt(window,"selectstart",Si)};else{var ks=Ln(["userSelect","WebkitUserSelect","OUserSelect","MozUserSelect","msUserSelect"]);so=function(){if(ks){var u=document.documentElement.style;$a=u[ks],u[ks]="none"}},js=function(){ks&&(document.documentElement.style[ks]=$a,$a=void 0)}}function Ca(){Ht(window,"dragstart",Si)}function qo(){Dt(window,"dragstart",Si)}var zs,Vi;function oi(u){for(;u.tabIndex===-1;)u=u.parentNode;u.style&&(Ho(),zs=u,Vi=u.style.outlineStyle,u.style.outlineStyle="none",Ht(window,"keydown",Ho))}function Ho(){zs&&(zs.style.outlineStyle=Vi,zs=void 0,Vi=void 0,Dt(window,"keydown",Ho))}function Nl(u){do u=u.parentNode;while((!u.offsetWidth||!u.offsetHeight)&&u!==document.body);return u}function Ia(u){var v=u.getBoundingClientRect();return{x:v.width/u.offsetWidth||1,y:v.height/u.offsetHeight||1,boundingClientRect:v}}var Wn={__proto__:null,TRANSFORM:ae,TRANSITION:qt,TRANSITION_END:Uo,get:wo,getStyle:zn,create:Fi,remove:Xi,empty:te,toFront:tr,toBack:Go,hasClass:Ha,addClass:_i,removeClass:Sr,setClass:Wa,getClass:ha,setOpacity:_n,testProp:Ln,setTransform:ar,setPosition:Cr,getPosition:To,get disableTextSelection(){return so},get enableTextSelection(){return js},disableImageDrag:Ca,enableImageDrag:qo,preventOutline:oi,restoreOutline:Ho,getSizedParentNode:Nl,getScale:Ia};function Ht(u,v,E,R){if(v&&typeof v=="object")for(var q in v)cn(u,q,v[q],E);else{v=Mn(v);for(var ne=0,Ee=v.length;ne<Ee;ne++)cn(u,v[ne],E,R)}return this}var Li="_leaflet_events";function Dt(u,v,E,R){if(arguments.length===1)Ki(u),delete u[Li];else if(v&&typeof v=="object")for(var q in v)gn(u,q,v[q],E);else if(v=Mn(v),arguments.length===2)Ki(u,function(Ze){return ro(v,Ze)!==-1});else for(var ne=0,Ee=v.length;ne<Ee;ne++)gn(u,v[ne],E,R);return this}function Ki(u,v){for(var E in u[Li]){var R=E.split(/\d/)[0];(!v||v(R))&&gn(u,R,null,null,E)}}var Zs={mouseenter:"mouseover",mouseleave:"mouseout",wheel:!("onwheel"in window)&&"mousewheel"};function cn(u,v,E,R){var q=v+it(E)+(R?"_"+it(R):"");if(u[Li]&&u[Li][q])return this;var ne=function(Ze){return E.call(R||u,Ze||window.event)},Ee=ne;!o.touchNative&&o.pointer&&v.indexOf("touch")===0?ne=di(u,v,ne):o.touch&&v==="dblclick"?ne=vr(u,ne):"addEventListener"in u?v==="touchstart"||v==="touchmove"||v==="wheel"||v==="mousewheel"?u.addEventListener(Zs[v]||v,ne,o.passiveEvents?{passive:!1}:!1):v==="mouseenter"||v==="mouseleave"?(ne=function(Ze){Ze=Ze||window.event,Ls(u,Ze)&&Ee(Ze)},u.addEventListener(Zs[v],ne,!1)):u.addEventListener(v,Ee,!1):u.attachEvent("on"+v,ne),u[Li]=u[Li]||{},u[Li][q]=ne}function gn(u,v,E,R,q){q=q||v+it(E)+(R?"_"+it(R):"");var ne=u[Li]&&u[Li][q];if(!ne)return this;!o.touchNative&&o.pointer&&v.indexOf("touch")===0?jr(u,v,ne):o.touch&&v==="dblclick"?Ft(u,ne):"removeEventListener"in u?u.removeEventListener(Zs[v]||v,ne,!1):u.detachEvent("on"+v,ne),u[Li][q]=null}function Lr(u){return u.stopPropagation?u.stopPropagation():u.originalEvent?u.originalEvent._stopped=!0:u.cancelBubble=!0,this}function Us(u){return cn(u,"wheel",Lr),this}function Qn(u){return Ht(u,"mousedown touchstart dblclick contextmenu",Lr),u._leaflet_disable_click=!0,this}function Si(u){return u.preventDefault?u.preventDefault():u.returnValue=!1,this}function $n(u){return Si(u),Lr(u),this}function gs(u){if(u.composedPath)return u.composedPath();for(var v=[],E=u.target;E;)v.push(E),E=E.parentNode;return v}function ca(u,v){if(!v)return new ti(u.clientX,u.clientY);var E=Ia(v),R=E.boundingClientRect;return new ti((u.clientX-R.left)/E.x-v.clientLeft,(u.clientY-R.top)/E.y-v.clientTop)}var Yn=o.linux&&o.chrome?window.devicePixelRatio:o.mac?window.devicePixelRatio*3:window.devicePixelRatio>0?2*window.devicePixelRatio:1;function Po(u){return o.edge?u.wheelDeltaY/2:u.deltaY&&u.deltaMode===0?-u.deltaY/Yn:u.deltaY&&u.deltaMode===1?-u.deltaY*20:u.deltaY&&u.deltaMode===2?-u.deltaY*60:u.deltaX||u.deltaZ?0:u.wheelDelta?(u.wheelDeltaY||u.wheelDelta)/2:u.detail&&Math.abs(u.detail)<32765?-u.detail*20:u.detail?u.detail/-32765*60:0}function Ls(u,v){var E=v.relatedTarget;if(!E)return!0;try{for(;E&&E!==u;)E=E.parentNode}catch{return!1}return E!==u}var Vl={__proto__:null,on:Ht,off:Dt,stopPropagation:Lr,disableScrollPropagation:Us,disableClickPropagation:Qn,preventDefault:Si,stop:$n,getPropagationPath:gs,getMousePosition:ca,getWheelDelta:Po,isExternalTarget:Ls,addListener:Ht,removeListener:Dt},Qr=Hr.extend({run:function(u,v,E,R){this.stop(),this._el=u,this._inProgress=!0,this._duration=E||.25,this._easeOutPower=1/Math.max(R||.5,.2),this._startPos=To(u),this._offset=v.subtract(this._startPos),this._startTime=+new Date,this.fire("start"),this._animate()},stop:function(){this._inProgress&&(this._step(!0),this._complete())},_animate:function(){this._animId=cr(this._animate,this),this._step()},_step:function(u){var v=+new Date-this._startTime,E=this._duration*1e3;v<E?this._runFrame(this._easeOut(v/E),u):(this._runFrame(1),this._complete())},_runFrame:function(u,v){var E=this._startPos.add(this._offset.multiplyBy(u));v&&E._round(),Cr(this._el,E),this.fire("step")},_complete:function(){Ji(this._animId),this._inProgress=!1,this.fire("end")},_easeOut:function(u){return 1-Math.pow(1-u,this._easeOutPower)}}),hi=Hr.extend({options:{crs:Vo,center:void 0,zoom:void 0,minZoom:void 0,maxZoom:void 0,layers:[],maxBounds:void 0,renderer:void 0,zoomAnimation:!0,zoomAnimationThreshold:4,fadeAnimation:!0,markerZoomAnimation:!0,transform3DLimit:8388608,zoomSnap:1,zoomDelta:1,trackResize:!0},initialize:function(u,v){v=Gt(this,v),this._handlers=[],this._layers={},this._zoomBoundLayers={},this._sizeChanged=!0,this._initContainer(u),this._initLayout(),this._onResize=W(this._onResize,this),this._initEvents(),v.maxBounds&&this.setMaxBounds(v.maxBounds),v.zoom!==void 0&&(this._zoom=this._limitZoom(v.zoom)),v.center&&v.zoom!==void 0&&this.setView(Ai(v.center),v.zoom,{reset:!0}),this.callInitHooks(),this._zoomAnimated=qt&&o.any3d&&!o.mobileOpera&&this.options.zoomAnimation,this._zoomAnimated&&(this._createAnimProxy(),Ht(this._proxy,Uo,this._catchTransitionEnd,this)),this._addLayers(this.options.layers)},setView:function(u,v,E){if(v=v===void 0?this._zoom:this._limitZoom(v),u=this._limitCenter(Ai(u),v,this.options.maxBounds),E=E||{},this._stop(),this._loaded&&!E.reset&&E!==!0){E.animate!==void 0&&(E.zoom=We({animate:E.animate},E.zoom),E.pan=We({animate:E.animate,duration:E.duration},E.pan));var R=this._zoom!==v?this._tryAnimatedZoom&&this._tryAnimatedZoom(u,v,E.zoom):this._tryAnimatedPan(u,E.pan);if(R)return clearTimeout(this._sizeTimer),this}return this._resetView(u,v,E.pan&&E.pan.noMoveStart),this},setZoom:function(u,v){return this._loaded?this.setView(this.getCenter(),u,{zoom:v}):(this._zoom=u,this)},zoomIn:function(u,v){return u=u||(o.any3d?this.options.zoomDelta:1),this.setZoom(this._zoom+u,v)},zoomOut:function(u,v){return u=u||(o.any3d?this.options.zoomDelta:1),this.setZoom(this._zoom-u,v)},setZoomAround:function(u,v,E){var R=this.getZoomScale(v),q=this.getSize().divideBy(2),ne=u instanceof ti?u:this.latLngToContainerPoint(u),Ee=ne.subtract(q).multiplyBy(1-1/R),Ze=this.containerPointToLatLng(q.add(Ee));return this.setView(Ze,v,{zoom:E})},_getBoundsCenterZoom:function(u,v){v=v||{},u=u.getBounds?u.getBounds():or(u);var E=Yt(v.paddingTopLeft||v.padding||[0,0]),R=Yt(v.paddingBottomRight||v.padding||[0,0]),q=this.getBoundsZoom(u,!1,E.add(R));if(q=typeof v.maxZoom=="number"?Math.min(v.maxZoom,q):q,q===1/0)return{center:u.getCenter(),zoom:q};var ne=R.subtract(E).divideBy(2),Ee=this.project(u.getSouthWest(),q),Ze=this.project(u.getNorthEast(),q),tt=this.unproject(Ee.add(Ze).divideBy(2).add(ne),q);return{center:tt,zoom:q}},fitBounds:function(u,v){if(u=or(u),!u.isValid())throw new Error("Bounds are not valid.");var E=this._getBoundsCenterZoom(u,v);return this.setView(E.center,E.zoom,v)},fitWorld:function(u){return this.fitBounds([[-90,-180],[90,180]],u)},panTo:function(u,v){return this.setView(u,this._zoom,{pan:v})},panBy:function(u,v){if(u=Yt(u).round(),v=v||{},!u.x&&!u.y)return this.fire("moveend");if(v.animate!==!0&&!this.getSize().contains(u))return this._resetView(this.unproject(this.project(this.getCenter()).add(u)),this.getZoom()),this;if(this._panAnim||(this._panAnim=new Qr,this._panAnim.on({step:this._onPanTransitionStep,end:this._onPanTransitionEnd},this)),v.noMoveStart||this.fire("movestart"),v.animate!==!1){_i(this._mapPane,"leaflet-pan-anim");var E=this._getMapPanePos().subtract(u).round();this._panAnim.run(this._mapPane,E,v.duration||.25,v.easeLinearity)}else this._rawPanBy(u),this.fire("move").fire("moveend");return this},flyTo:function(u,v,E){if(E=E||{},E.animate===!1||!o.any3d)return this.setView(u,v,E);this._stop();var R=this.project(this.getCenter()),q=this.project(u),ne=this.getSize(),Ee=this._zoom;u=Ai(u),v=v===void 0?Ee:v;var Ze=Math.max(ne.x,ne.y),tt=Ze*this.getZoomScale(Ee,v),gt=q.distanceTo(R)||1,Rt=1.42,Jt=Rt*Rt;function Ti(pr){var nr=pr?-1:1,ll=pr?tt:Ze,Co=tt*tt-Ze*Ze+nr*Jt*Jt*gt*gt,Ao=2*ll*Jt*gt,Ur=Co/Ao,ta=Math.sqrt(Ur*Ur+1)-Ur,Kl=ta<1e-9?-18:Math.log(ta);return Kl}function Zr(pr){return(Math.exp(pr)-Math.exp(-pr))/2}function Br(pr){return(Math.exp(pr)+Math.exp(-pr))/2}function ps(pr){return Zr(pr)/Br(pr)}var On=Ti(0);function Ks(pr){return Ze*(Br(On)/Br(On+Rt*pr))}function al(pr){return Ze*(Br(On)*ps(On+Rt*pr)-Zr(On))/Jt}function Yl(pr){return 1-Math.pow(1-pr,1.5)}var Xl=Date.now(),br=(Ti(1)-On)/Rt,ea=E.duration?1e3*E.duration:1e3*br*.8;function Nn(){var pr=(Date.now()-Xl)/ea,nr=Yl(pr)*br;pr<=1?(this._flyToFrame=cr(Nn,this),this._move(this.unproject(R.add(q.subtract(R).multiplyBy(al(nr)/gt)),Ee),this.getScaleZoom(Ze/Ks(nr),Ee),{flyTo:!0})):this._move(u,v)._moveEnd(!0)}return this._moveStart(!0,E.noMoveStart),Nn.call(this),this},flyToBounds:function(u,v){var E=this._getBoundsCenterZoom(u,v);return this.flyTo(E.center,E.zoom,v)},setMaxBounds:function(u){return u=or(u),this.listens("moveend",this._panInsideMaxBounds)&&this.off("moveend",this._panInsideMaxBounds),u.isValid()?(this.options.maxBounds=u,this._loaded&&this._panInsideMaxBounds(),this.on("moveend",this._panInsideMaxBounds)):(this.options.maxBounds=null,this)},setMinZoom:function(u){var v=this.options.minZoom;return this.options.minZoom=u,this._loaded&&v!==u&&(this.fire("zoomlevelschange"),this.getZoom()<this.options.minZoom)?this.setZoom(u):this},setMaxZoom:function(u){var v=this.options.maxZoom;return this.options.maxZoom=u,this._loaded&&v!==u&&(this.fire("zoomlevelschange"),this.getZoom()>this.options.maxZoom)?this.setZoom(u):this},panInsideBounds:function(u,v){this._enforcingBounds=!0;var E=this.getCenter(),R=this._limitCenter(E,this._zoom,or(u));return E.equals(R)||this.panTo(R,v),this._enforcingBounds=!1,this},panInside:function(u,v){v=v||{};var E=Yt(v.paddingTopLeft||v.padding||[0,0]),R=Yt(v.paddingBottomRight||v.padding||[0,0]),q=this.project(this.getCenter()),ne=this.project(u),Ee=this.getPixelBounds(),Ze=Mr([Ee.min.add(E),Ee.max.subtract(R)]),tt=Ze.getSize();if(!Ze.contains(ne)){this._enforcingBounds=!0;var gt=ne.subtract(Ze.getCenter()),Rt=Ze.extend(ne).getSize().subtract(tt);q.x+=gt.x<0?-Rt.x:Rt.x,q.y+=gt.y<0?-Rt.y:Rt.y,this.panTo(this.unproject(q),v),this._enforcingBounds=!1}return this},invalidateSize:function(u){if(!this._loaded)return this;u=We({animate:!1,pan:!0},u===!0?{animate:!0}:u);var v=this.getSize();this._sizeChanged=!0,this._lastCenter=null;var E=this.getSize(),R=v.divideBy(2).round(),q=E.divideBy(2).round(),ne=R.subtract(q);return!ne.x&&!ne.y?this:(u.animate&&u.pan?this.panBy(ne):(u.pan&&this._rawPanBy(ne),this.fire("move"),u.debounceMoveend?(clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(W(this.fire,this,"moveend"),200)):this.fire("moveend")),this.fire("resize",{oldSize:v,newSize:E}))},stop:function(){return this.setZoom(this._limitZoom(this._zoom)),this.options.zoomSnap||this.fire("viewreset"),this._stop()},locate:function(u){if(u=this._locateOptions=We({timeout:1e4,watch:!1},u),!("geolocation"in navigator))return this._handleGeolocationError({code:0,message:"Geolocation not supported."}),this;var v=W(this._handleGeolocationResponse,this),E=W(this._handleGeolocationError,this);return u.watch?this._locationWatchId=navigator.geolocation.watchPosition(v,E,u):navigator.geolocation.getCurrentPosition(v,E,u),this},stopLocate:function(){return navigator.geolocation&&navigator.geolocation.clearWatch&&navigator.geolocation.clearWatch(this._locationWatchId),this._locateOptions&&(this._locateOptions.setView=!1),this},_handleGeolocationError:function(u){if(this._container._leaflet_id){var v=u.code,E=u.message||(v===1?"permission denied":v===2?"position unavailable":"timeout");this._locateOptions.setView&&!this._loaded&&this.fitWorld(),this.fire("locationerror",{code:v,message:"Geolocation error: "+E+"."})}},_handleGeolocationResponse:function(u){if(this._container._leaflet_id){var v=u.coords.latitude,E=u.coords.longitude,R=new xi(v,E),q=R.toBounds(u.coords.accuracy*2),ne=this._locateOptions;if(ne.setView){var Ee=this.getBoundsZoom(q);this.setView(R,ne.maxZoom?Math.min(Ee,ne.maxZoom):Ee)}var Ze={latlng:R,bounds:q,timestamp:u.timestamp};for(var tt in u.coords)typeof u.coords[tt]=="number"&&(Ze[tt]=u.coords[tt]);this.fire("locationfound",Ze)}},addHandler:function(u,v){if(!v)return this;var E=this[u]=new v(this);return this._handlers.push(E),this.options[u]&&E.enable(),this},remove:function(){if(this._initEvents(!0),this.options.maxBounds&&this.off("moveend",this._panInsideMaxBounds),this._containerId!==this._container._leaflet_id)throw new Error("Map container is being reused by another instance");try{delete this._container._leaflet_id,delete this._containerId}catch{this._container._leaflet_id=void 0,this._containerId=void 0}this._locationWatchId!==void 0&&this.stopLocate(),this._stop(),Xi(this._mapPane),this._clearControlPos&&this._clearControlPos(),this._resizeRequest&&(Ji(this._resizeRequest),this._resizeRequest=null),this._clearHandlers(),this._loaded&&this.fire("unload");var u;for(u in this._layers)this._layers[u].remove();for(u in this._panes)Xi(this._panes[u]);return this._layers=[],this._panes=[],delete this._mapPane,delete this._renderer,this},createPane:function(u,v){var E="leaflet-pane"+(u?" leaflet-"+u.replace("Pane","")+"-pane":""),R=Fi("div",E,v||this._mapPane);return u&&(this._panes[u]=R),R},getCenter:function(){return this._checkIfLoaded(),this._lastCenter&&!this._moved()?this._lastCenter.clone():this.layerPointToLatLng(this._getCenterLayerPoint())},getZoom:function(){return this._zoom},getBounds:function(){var u=this.getPixelBounds(),v=this.unproject(u.getBottomLeft()),E=this.unproject(u.getTopRight());return new Wr(v,E)},getMinZoom:function(){return this.options.minZoom===void 0?this._layersMinZoom||0:this.options.minZoom},getMaxZoom:function(){return this.options.maxZoom===void 0?this._layersMaxZoom===void 0?1/0:this._layersMaxZoom:this.options.maxZoom},getBoundsZoom:function(u,v,E){u=or(u),E=Yt(E||[0,0]);var R=this.getZoom()||0,q=this.getMinZoom(),ne=this.getMaxZoom(),Ee=u.getNorthWest(),Ze=u.getSouthEast(),tt=this.getSize().subtract(E),gt=Mr(this.project(Ze,R),this.project(Ee,R)).getSize(),Rt=o.any3d?this.options.zoomSnap:1,Jt=tt.x/gt.x,Ti=tt.y/gt.y,Zr=v?Math.max(Jt,Ti):Math.min(Jt,Ti);return R=this.getScaleZoom(Zr,R),Rt&&(R=Math.round(R/(Rt/100))*(Rt/100),R=v?Math.ceil(R/Rt)*Rt:Math.floor(R/Rt)*Rt),Math.max(q,Math.min(ne,R))},getSize:function(){return(!this._size||this._sizeChanged)&&(this._size=new ti(this._container.clientWidth||0,this._container.clientHeight||0),this._sizeChanged=!1),this._size.clone()},getPixelBounds:function(u,v){var E=this._getTopLeftPoint(u,v);return new Ni(E,E.add(this.getSize()))},getPixelOrigin:function(){return this._checkIfLoaded(),this._pixelOrigin},getPixelWorldBounds:function(u){return this.options.crs.getProjectedBounds(u===void 0?this.getZoom():u)},getPane:function(u){return typeof u=="string"?this._panes[u]:u},getPanes:function(){return this._panes},getContainer:function(){return this._container},getZoomScale:function(u,v){var E=this.options.crs;return v=v===void 0?this._zoom:v,E.scale(u)/E.scale(v)},getScaleZoom:function(u,v){var E=this.options.crs;v=v===void 0?this._zoom:v;var R=E.zoom(u*E.scale(v));return isNaN(R)?1/0:R},project:function(u,v){return v=v===void 0?this._zoom:v,this.options.crs.latLngToPoint(Ai(u),v)},unproject:function(u,v){return v=v===void 0?this._zoom:v,this.options.crs.pointToLatLng(Yt(u),v)},layerPointToLatLng:function(u){var v=Yt(u).add(this.getPixelOrigin());return this.unproject(v)},latLngToLayerPoint:function(u){var v=this.project(Ai(u))._round();return v._subtract(this.getPixelOrigin())},wrapLatLng:function(u){return this.options.crs.wrapLatLng(Ai(u))},wrapLatLngBounds:function(u){return this.options.crs.wrapLatLngBounds(or(u))},distance:function(u,v){return this.options.crs.distance(Ai(u),Ai(v))},containerPointToLayerPoint:function(u){return Yt(u).subtract(this._getMapPanePos())},layerPointToContainerPoint:function(u){return Yt(u).add(this._getMapPanePos())},containerPointToLatLng:function(u){var v=this.containerPointToLayerPoint(Yt(u));return this.layerPointToLatLng(v)},latLngToContainerPoint:function(u){return this.layerPointToContainerPoint(this.latLngToLayerPoint(Ai(u)))},mouseEventToContainerPoint:function(u){return ca(u,this._container)},mouseEventToLayerPoint:function(u){return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(u))},mouseEventToLatLng:function(u){return this.layerPointToLatLng(this.mouseEventToLayerPoint(u))},_initContainer:function(u){var v=this._container=wo(u);if(v){if(v._leaflet_id)throw new Error("Map container is already initialized.")}else throw new Error("Map container not found.");Ht(v,"scroll",this._onScroll,this),this._containerId=it(v)},_initLayout:function(){var u=this._container;this._fadeAnimated=this.options.fadeAnimation&&o.any3d,_i(u,"leaflet-container"+(o.touch?" leaflet-touch":"")+(o.retina?" leaflet-retina":"")+(o.ielt9?" leaflet-oldie":"")+(o.safari?" leaflet-safari":"")+(this._fadeAnimated?" leaflet-fade-anim":""));var v=zn(u,"position");v!=="absolute"&&v!=="relative"&&v!=="fixed"&&v!=="sticky"&&(u.style.position="relative"),this._initPanes(),this._initControlPos&&this._initControlPos()},_initPanes:function(){var u=this._panes={};this._paneRenderers={},this._mapPane=this.createPane("mapPane",this._container),Cr(this._mapPane,new ti(0,0)),this.createPane("tilePane"),this.createPane("overlayPane"),this.createPane("shadowPane"),this.createPane("markerPane"),this.createPane("tooltipPane"),this.createPane("popupPane"),this.options.markerZoomAnimation||(_i(u.markerPane,"leaflet-zoom-hide"),_i(u.shadowPane,"leaflet-zoom-hide"))},_resetView:function(u,v,E){Cr(this._mapPane,new ti(0,0));var R=!this._loaded;this._loaded=!0,v=this._limitZoom(v),this.fire("viewprereset");var q=this._zoom!==v;this._moveStart(q,E)._move(u,v)._moveEnd(q),this.fire("viewreset"),R&&this.fire("load")},_moveStart:function(u,v){return u&&this.fire("zoomstart"),v||this.fire("movestart"),this},_move:function(u,v,E,R){v===void 0&&(v=this._zoom);var q=this._zoom!==v;return this._zoom=v,this._lastCenter=u,this._pixelOrigin=this._getNewPixelOrigin(u),R?E&&E.pinch&&this.fire("zoom",E):((q||E&&E.pinch)&&this.fire("zoom",E),this.fire("move",E)),this},_moveEnd:function(u){return u&&this.fire("zoomend"),this.fire("moveend")},_stop:function(){return Ji(this._flyToFrame),this._panAnim&&this._panAnim.stop(),this},_rawPanBy:function(u){Cr(this._mapPane,this._getMapPanePos().subtract(u))},_getZoomSpan:function(){return this.getMaxZoom()-this.getMinZoom()},_panInsideMaxBounds:function(){this._enforcingBounds||this.panInsideBounds(this.options.maxBounds)},_checkIfLoaded:function(){if(!this._loaded)throw new Error("Set map center and zoom first.")},_initEvents:function(u){this._targets={},this._targets[it(this._container)]=this;var v=u?Dt:Ht;v(this._container,"click dblclick mousedown mouseup mouseover mouseout mousemove contextmenu keypress keydown keyup",this._handleDOMEvent,this),this.options.trackResize&&v(window,"resize",this._onResize,this),o.any3d&&this.options.transform3DLimit&&(u?this.off:this.on).call(this,"moveend",this._onMoveEnd)},_onResize:function(){Ji(this._resizeRequest),this._resizeRequest=cr(function(){this.invalidateSize({debounceMoveend:!0})},this)},_onScroll:function(){this._container.scrollTop=0,this._container.scrollLeft=0},_onMoveEnd:function(){var u=this._getMapPanePos();Math.max(Math.abs(u.x),Math.abs(u.y))>=this.options.transform3DLimit&&this._resetView(this.getCenter(),this.getZoom())},_findEventTargets:function(u,v){for(var E=[],R,q=v==="mouseout"||v==="mouseover",ne=u.target||u.srcElement,Ee=!1;ne;){if(R=this._targets[it(ne)],R&&(v==="click"||v==="preclick")&&this._draggableMoved(R)){Ee=!0;break}if(R&&R.listens(v,!0)&&(q&&!Ls(ne,u)||(E.push(R),q))||ne===this._container)break;ne=ne.parentNode}return!E.length&&!Ee&&!q&&this.listens(v,!0)&&(E=[this]),E},_isClickDisabled:function(u){for(;u&&u!==this._container;){if(u._leaflet_disable_click)return!0;u=u.parentNode}},_handleDOMEvent:function(u){var v=u.target||u.srcElement;if(!(!this._loaded||v._leaflet_disable_events||u.type==="click"&&this._isClickDisabled(v))){var E=u.type;E==="mousedown"&&oi(v),this._fireDOMEvent(u,E)}},_mouseEvents:["click","dblclick","mouseover","mouseout","contextmenu"],_fireDOMEvent:function(u,v,E){if(u.type==="click"){var R=We({},u);R.type="preclick",this._fireDOMEvent(R,R.type,E)}var q=this._findEventTargets(u,v);if(E){for(var ne=[],Ee=0;Ee<E.length;Ee++)E[Ee].listens(v,!0)&&ne.push(E[Ee]);q=ne.concat(q)}if(q.length){v==="contextmenu"&&Si(u);var Ze=q[0],tt={originalEvent:u};if(u.type!=="keypress"&&u.type!=="keydown"&&u.type!=="keyup"){var gt=Ze.getLatLng&&(!Ze._radius||Ze._radius<=10);tt.containerPoint=gt?this.latLngToContainerPoint(Ze.getLatLng()):this.mouseEventToContainerPoint(u),tt.layerPoint=this.containerPointToLayerPoint(tt.containerPoint),tt.latlng=gt?Ze.getLatLng():this.layerPointToLatLng(tt.layerPoint)}for(Ee=0;Ee<q.length;Ee++)if(q[Ee].fire(v,tt,!0),tt.originalEvent._stopped||q[Ee].options.bubblingMouseEvents===!1&&ro(this._mouseEvents,v)!==-1)return}},_draggableMoved:function(u){return u=u.dragging&&u.dragging.enabled()?u:this,u.dragging&&u.dragging.moved()||this.boxZoom&&this.boxZoom.moved()},_clearHandlers:function(){for(var u=0,v=this._handlers.length;u<v;u++)this._handlers[u].disable()},whenReady:function(u,v){return this._loaded?u.call(v||this,{target:this}):this.on("load",u,v),this},_getMapPanePos:function(){return To(this._mapPane)||new ti(0,0)},_moved:function(){var u=this._getMapPanePos();return u&&!u.equals([0,0])},_getTopLeftPoint:function(u,v){var E=u&&v!==void 0?this._getNewPixelOrigin(u,v):this.getPixelOrigin();return E.subtract(this._getMapPanePos())},_getNewPixelOrigin:function(u,v){var E=this.getSize()._divideBy(2);return this.project(u,v)._subtract(E)._add(this._getMapPanePos())._round()},_latLngToNewLayerPoint:function(u,v,E){var R=this._getNewPixelOrigin(E,v);return this.project(u,v)._subtract(R)},_latLngBoundsToNewLayerBounds:function(u,v,E){var R=this._getNewPixelOrigin(E,v);return Mr([this.project(u.getSouthWest(),v)._subtract(R),this.project(u.getNorthWest(),v)._subtract(R),this.project(u.getSouthEast(),v)._subtract(R),this.project(u.getNorthEast(),v)._subtract(R)])},_getCenterLayerPoint:function(){return this.containerPointToLayerPoint(this.getSize()._divideBy(2))},_getCenterOffset:function(u){return this.latLngToLayerPoint(u).subtract(this._getCenterLayerPoint())},_limitCenter:function(u,v,E){if(!E)return u;var R=this.project(u,v),q=this.getSize().divideBy(2),ne=new Ni(R.subtract(q),R.add(q)),Ee=this._getBoundsOffset(ne,E,v);return Math.abs(Ee.x)<=1&&Math.abs(Ee.y)<=1?u:this.unproject(R.add(Ee),v)},_limitOffset:function(u,v){if(!v)return u;var E=this.getPixelBounds(),R=new Ni(E.min.add(u),E.max.add(u));return u.add(this._getBoundsOffset(R,v))},_getBoundsOffset:function(u,v,E){var R=Mr(this.project(v.getNorthEast(),E),this.project(v.getSouthWest(),E)),q=R.min.subtract(u.min),ne=R.max.subtract(u.max),Ee=this._rebound(q.x,-ne.x),Ze=this._rebound(q.y,-ne.y);return new ti(Ee,Ze)},_rebound:function(u,v){return u+v>0?Math.round(u-v)/2:Math.max(0,Math.ceil(u))-Math.max(0,Math.floor(v))},_limitZoom:function(u){var v=this.getMinZoom(),E=this.getMaxZoom(),R=o.any3d?this.options.zoomSnap:1;return R&&(u=Math.round(u/R)*R),Math.max(v,Math.min(E,u))},_onPanTransitionStep:function(){this.fire("move")},_onPanTransitionEnd:function(){Sr(this._mapPane,"leaflet-pan-anim"),this.fire("moveend")},_tryAnimatedPan:function(u,v){var E=this._getCenterOffset(u)._trunc();return(v&&v.animate)!==!0&&!this.getSize().contains(E)?!1:(this.panBy(E,v),!0)},_createAnimProxy:function(){var u=this._proxy=Fi("div","leaflet-proxy leaflet-zoom-animated");this._panes.mapPane.appendChild(u),this.on("zoomanim",function(v){var E=ae,R=this._proxy.style[E];ar(this._proxy,this.project(v.center,v.zoom),this.getZoomScale(v.zoom,1)),R===this._proxy.style[E]&&this._animatingZoom&&this._onZoomTransitionEnd()},this),this.on("load moveend",this._animMoveEnd,this),this._on("unload",this._destroyAnimProxy,this)},_destroyAnimProxy:function(){Xi(this._proxy),this.off("load moveend",this._animMoveEnd,this),delete this._proxy},_animMoveEnd:function(){var u=this.getCenter(),v=this.getZoom();ar(this._proxy,this.project(u,v),this.getZoomScale(v,1))},_catchTransitionEnd:function(u){this._animatingZoom&&u.propertyName.indexOf("transform")>=0&&this._onZoomTransitionEnd()},_nothingToAnimate:function(){return!this._container.getElementsByClassName("leaflet-zoom-animated").length},_tryAnimatedZoom:function(u,v,E){if(this._animatingZoom)return!0;if(E=E||{},!this._zoomAnimated||E.animate===!1||this._nothingToAnimate()||Math.abs(v-this._zoom)>this.options.zoomAnimationThreshold)return!1;var R=this.getZoomScale(v),q=this._getCenterOffset(u)._divideBy(1-1/R);return E.animate!==!0&&!this.getSize().contains(q)?!1:(cr(function(){this._moveStart(!0,E.noMoveStart||!1)._animateZoom(u,v,!0)},this),!0)},_animateZoom:function(u,v,E,R){this._mapPane&&(E&&(this._animatingZoom=!0,this._animateToCenter=u,this._animateToZoom=v,_i(this._mapPane,"leaflet-zoom-anim")),this.fire("zoomanim",{center:u,zoom:v,noUpdate:R}),this._tempFireZoomEvent||(this._tempFireZoomEvent=this._zoom!==this._animateToZoom),this._move(this._animateToCenter,this._animateToZoom,void 0,!0),setTimeout(W(this._onZoomTransitionEnd,this),250))},_onZoomTransitionEnd:function(){this._animatingZoom&&(this._mapPane&&Sr(this._mapPane,"leaflet-zoom-anim"),this._animatingZoom=!1,this._move(this._animateToCenter,this._animateToZoom,void 0,!0),this._tempFireZoomEvent&&this.fire("zoom"),delete this._tempFireZoomEvent,this.fire("move"),this._moveEnd(!0))}});function bi(u,v){return new hi(u,v)}var nn=Cn.extend({options:{position:"topright"},initialize:function(u){Gt(this,u)},getPosition:function(){return this.options.position},setPosition:function(u){var v=this._map;return v&&v.removeControl(this),this.options.position=u,v&&v.addControl(this),this},getContainer:function(){return this._container},addTo:function(u){this.remove(),this._map=u;var v=this._container=this.onAdd(u),E=this.getPosition(),R=u._controlCorners[E];return _i(v,"leaflet-control"),E.indexOf("bottom")!==-1?R.insertBefore(v,R.firstChild):R.appendChild(v),this._map.on("unload",this.remove,this),this},remove:function(){return this._map?(Xi(this._container),this.onRemove&&this.onRemove(this._map),this._map.off("unload",this.remove,this),this._map=null,this):this},_refocusOnMap:function(u){this._map&&u&&u.screenX>0&&u.screenY>0&&this._map.getContainer().focus()}}),wi=function(u){return new nn(u)};hi.include({addControl:function(u){return u.addTo(this),this},removeControl:function(u){return u.remove(),this},_initControlPos:function(){var u=this._controlCorners={},v="leaflet-",E=this._controlContainer=Fi("div",v+"control-container",this._container);function R(q,ne){var Ee=v+q+" "+v+ne;u[q+ne]=Fi("div",Ee,E)}R("top","left"),R("top","right"),R("bottom","left"),R("bottom","right")},_clearControlPos:function(){for(var u in this._controlCorners)Xi(this._controlCorners[u]);Xi(this._controlContainer),delete this._controlCorners,delete this._controlContainer}});var ri=nn.extend({options:{collapsed:!0,position:"topright",autoZIndex:!0,hideSingleBase:!1,sortLayers:!1,sortFunction:function(u,v,E,R){return E<R?-1:R<E?1:0}},initialize:function(u,v,E){Gt(this,E),this._layerControlInputs=[],this._layers=[],this._lastZIndex=0,this._handlingClick=!1,this._preventClick=!1;for(var R in u)this._addLayer(u[R],R);for(R in v)this._addLayer(v[R],R,!0)},onAdd:function(u){this._initLayout(),this._update(),this._map=u,u.on("zoomend",this._checkDisabledLayers,this);for(var v=0;v<this._layers.length;v++)this._layers[v].layer.on("add remove",this._onLayerChange,this);return this._container},addTo:function(u){return nn.prototype.addTo.call(this,u),this._expandIfNotCollapsed()},onRemove:function(){this._map.off("zoomend",this._checkDisabledLayers,this);for(var u=0;u<this._layers.length;u++)this._layers[u].layer.off("add remove",this._onLayerChange,this)},addBaseLayer:function(u,v){return this._addLayer(u,v),this._map?this._update():this},addOverlay:function(u,v){return this._addLayer(u,v,!0),this._map?this._update():this},removeLayer:function(u){u.off("add remove",this._onLayerChange,this);var v=this._getLayer(it(u));return v&&this._layers.splice(this._layers.indexOf(v),1),this._map?this._update():this},expand:function(){_i(this._container,"leaflet-control-layers-expanded"),this._section.style.height=null;var u=this._map.getSize().y-(this._container.offsetTop+50);return u<this._section.clientHeight?(_i(this._section,"leaflet-control-layers-scrollbar"),this._section.style.height=u+"px"):Sr(this._section,"leaflet-control-layers-scrollbar"),this._checkDisabledLayers(),this},collapse:function(){return Sr(this._container,"leaflet-control-layers-expanded"),this},_initLayout:function(){var u="leaflet-control-layers",v=this._container=Fi("div",u),E=this.options.collapsed;v.setAttribute("aria-haspopup",!0),Qn(v),Us(v);var R=this._section=Fi("section",u+"-list");E&&(this._map.on("click",this.collapse,this),Ht(v,{mouseenter:this._expandSafely,mouseleave:this.collapse},this));var q=this._layersLink=Fi("a",u+"-toggle",v);q.href="#",q.title="Layers",q.setAttribute("role","button"),Ht(q,{keydown:function(ne){ne.keyCode===13&&this._expandSafely()},click:function(ne){Si(ne),this._expandSafely()}},this),E||this.expand(),this._baseLayersList=Fi("div",u+"-base",R),this._separator=Fi("div",u+"-separator",R),this._overlaysList=Fi("div",u+"-overlays",R),v.appendChild(R)},_getLayer:function(u){for(var v=0;v<this._layers.length;v++)if(this._layers[v]&&it(this._layers[v].layer)===u)return this._layers[v]},_addLayer:function(u,v,E){this._map&&u.on("add remove",this._onLayerChange,this),this._layers.push({layer:u,name:v,overlay:E}),this.options.sortLayers&&this._layers.sort(W(function(R,q){return this.options.sortFunction(R.layer,q.layer,R.name,q.name)},this)),this.options.autoZIndex&&u.setZIndex&&(this._lastZIndex++,u.setZIndex(this._lastZIndex)),this._expandIfNotCollapsed()},_update:function(){if(!this._container)return this;te(this._baseLayersList),te(this._overlaysList),this._layerControlInputs=[];var u,v,E,R,q=0;for(E=0;E<this._layers.length;E++)R=this._layers[E],this._addItem(R),v=v||R.overlay,u=u||!R.overlay,q+=R.overlay?0:1;return this.options.hideSingleBase&&(u=u&&q>1,this._baseLayersList.style.display=u?"":"none"),this._separator.style.display=v&&u?"":"none",this},_onLayerChange:function(u){this._handlingClick||this._update();var v=this._getLayer(it(u.target)),E=v.overlay?u.type==="add"?"overlayadd":"overlayremove":u.type==="add"?"baselayerchange":null;E&&this._map.fire(E,v)},_createRadioElement:function(u,v){var E='<input type="radio" class="leaflet-control-layers-selector" name="'+u+'"'+(v?' checked="checked"':"")+"/>",R=document.createElement("div");return R.innerHTML=E,R.firstChild},_addItem:function(u){var v=document.createElement("label"),E=this._map.hasLayer(u.layer),R;u.overlay?(R=document.createElement("input"),R.type="checkbox",R.className="leaflet-control-layers-selector",R.defaultChecked=E):R=this._createRadioElement("leaflet-base-layers_"+it(this),E),this._layerControlInputs.push(R),R.layerId=it(u.layer),Ht(R,"click",this._onInputClick,this);var q=document.createElement("span");q.innerHTML=" "+u.name;var ne=document.createElement("span");v.appendChild(ne),ne.appendChild(R),ne.appendChild(q);var Ee=u.overlay?this._overlaysList:this._baseLayersList;return Ee.appendChild(v),this._checkDisabledLayers(),v},_onInputClick:function(){if(!this._preventClick){var u=this._layerControlInputs,v,E,R=[],q=[];this._handlingClick=!0;for(var ne=u.length-1;ne>=0;ne--)v=u[ne],E=this._getLayer(v.layerId).layer,v.checked?R.push(E):v.checked||q.push(E);for(ne=0;ne<q.length;ne++)this._map.hasLayer(q[ne])&&this._map.removeLayer(q[ne]);for(ne=0;ne<R.length;ne++)this._map.hasLayer(R[ne])||this._map.addLayer(R[ne]);this._handlingClick=!1,this._refocusOnMap()}},_checkDisabledLayers:function(){for(var u=this._layerControlInputs,v,E,R=this._map.getZoom(),q=u.length-1;q>=0;q--)v=u[q],E=this._getLayer(v.layerId).layer,v.disabled=E.options.minZoom!==void 0&&R<E.options.minZoom||E.options.maxZoom!==void 0&&R>E.options.maxZoom},_expandIfNotCollapsed:function(){return this._map&&!this.options.collapsed&&this.expand(),this},_expandSafely:function(){var u=this._section;this._preventClick=!0,Ht(u,"click",Si),this.expand();var v=this;setTimeout(function(){Dt(u,"click",Si),v._preventClick=!1})}}),Aa=function(u,v,E){return new ri(u,v,E)},Ci=nn.extend({options:{position:"topleft",zoomInText:'<span aria-hidden="true">+</span>',zoomInTitle:"Zoom in",zoomOutText:'<span aria-hidden="true">&#x2212;</span>',zoomOutTitle:"Zoom out"},onAdd:function(u){var v="leaflet-control-zoom",E=Fi("div",v+" leaflet-bar"),R=this.options;return this._zoomInButton=this._createButton(R.zoomInText,R.zoomInTitle,v+"-in",E,this._zoomIn),this._zoomOutButton=this._createButton(R.zoomOutText,R.zoomOutTitle,v+"-out",E,this._zoomOut),this._updateDisabled(),u.on("zoomend zoomlevelschange",this._updateDisabled,this),E},onRemove:function(u){u.off("zoomend zoomlevelschange",this._updateDisabled,this)},disable:function(){return this._disabled=!0,this._updateDisabled(),this},enable:function(){return this._disabled=!1,this._updateDisabled(),this},_zoomIn:function(u){!this._disabled&&this._map._zoom<this._map.getMaxZoom()&&this._map.zoomIn(this._map.options.zoomDelta*(u.shiftKey?3:1))},_zoomOut:function(u){!this._disabled&&this._map._zoom>this._map.getMinZoom()&&this._map.zoomOut(this._map.options.zoomDelta*(u.shiftKey?3:1))},_createButton:function(u,v,E,R,q){var ne=Fi("a",E,R);return ne.innerHTML=u,ne.href="#",ne.title=v,ne.setAttribute("role","button"),ne.setAttribute("aria-label",v),Qn(ne),Ht(ne,"click",$n),Ht(ne,"click",q,this),Ht(ne,"click",this._refocusOnMap,this),ne},_updateDisabled:function(){var u=this._map,v="leaflet-disabled";Sr(this._zoomInButton,v),Sr(this._zoomOutButton,v),this._zoomInButton.setAttribute("aria-disabled","false"),this._zoomOutButton.setAttribute("aria-disabled","false"),(this._disabled||u._zoom===u.getMinZoom())&&(_i(this._zoomOutButton,v),this._zoomOutButton.setAttribute("aria-disabled","true")),(this._disabled||u._zoom===u.getMaxZoom())&&(_i(this._zoomInButton,v),this._zoomInButton.setAttribute("aria-disabled","true"))}});hi.mergeOptions({zoomControl:!0}),hi.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new Ci,this.addControl(this.zoomControl))});var Da=function(u){return new Ci(u)},Xn=nn.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0},onAdd:function(u){var v="leaflet-control-scale",E=Fi("div",v),R=this.options;return this._addScales(R,v+"-line",E),u.on(R.updateWhenIdle?"moveend":"move",this._update,this),u.whenReady(this._update,this),E},onRemove:function(u){u.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_addScales:function(u,v,E){u.metric&&(this._mScale=Fi("div",v,E)),u.imperial&&(this._iScale=Fi("div",v,E))},_update:function(){var u=this._map,v=u.getSize().y/2,E=u.distance(u.containerPointToLatLng([0,v]),u.containerPointToLatLng([this.options.maxWidth,v]));this._updateScales(E)},_updateScales:function(u){this.options.metric&&u&&this._updateMetric(u),this.options.imperial&&u&&this._updateImperial(u)},_updateMetric:function(u){var v=this._getRoundNum(u),E=v<1e3?v+" m":v/1e3+" km";this._updateScale(this._mScale,E,v/u)},_updateImperial:function(u){var v=u*3.2808399,E,R,q;v>5280?(E=v/5280,R=this._getRoundNum(E),this._updateScale(this._iScale,R+" mi",R/E)):(q=this._getRoundNum(v),this._updateScale(this._iScale,q+" ft",q/v))},_updateScale:function(u,v,E){u.style.width=Math.round(this.options.maxWidth*E)+"px",u.innerHTML=v},_getRoundNum:function(u){var v=Math.pow(10,(Math.floor(u)+"").length-1),E=u/v;return E=E>=10?10:E>=5?5:E>=3?3:E>=2?2:1,v*E}}),oo=function(u){return new Xn(u)},Kn='<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="12" height="8" viewBox="0 0 12 8" class="leaflet-attribution-flag"><path fill="#4C7BE1" d="M0 0h12v4H0z"/><path fill="#FFD500" d="M0 4h12v3H0z"/><path fill="#E0BC00" d="M0 7h12v1H0z"/></svg>',ka=nn.extend({options:{position:"bottomright",prefix:'<a href="https://leafletjs.com" title="A JavaScript library for interactive maps">'+(o.inlineSvg?Kn+" ":"")+"Leaflet</a>"},initialize:function(u){Gt(this,u),this._attributions={}},onAdd:function(u){u.attributionControl=this,this._container=Fi("div","leaflet-control-attribution"),Qn(this._container);for(var v in u._layers)u._layers[v].getAttribution&&this.addAttribution(u._layers[v].getAttribution());return this._update(),u.on("layeradd",this._addAttribution,this),this._container},onRemove:function(u){u.off("layeradd",this._addAttribution,this)},_addAttribution:function(u){u.layer.getAttribution&&(this.addAttribution(u.layer.getAttribution()),u.layer.once("remove",function(){this.removeAttribution(u.layer.getAttribution())},this))},setPrefix:function(u){return this.options.prefix=u,this._update(),this},addAttribution:function(u){return u?(this._attributions[u]||(this._attributions[u]=0),this._attributions[u]++,this._update(),this):this},removeAttribution:function(u){return u?(this._attributions[u]&&(this._attributions[u]--,this._update()),this):this},_update:function(){if(this._map){var u=[];for(var v in this._attributions)this._attributions[v]&&u.push(v);var E=[];this.options.prefix&&E.push(this.options.prefix),u.length&&E.push(u.join(", ")),this._container.innerHTML=E.join(' <span aria-hidden="true">|</span> ')}}});hi.mergeOptions({attributionControl:!0}),hi.addInitHook(function(){this.options.attributionControl&&new ka().addTo(this)});var fa=function(u){return new ka(u)};nn.Layers=ri,nn.Zoom=Ci,nn.Scale=Xn,nn.Attribution=ka,wi.layers=Aa,wi.zoom=Da,wi.scale=oo,wi.attribution=fa;var Bn=Cn.extend({initialize:function(u){this._map=u},enable:function(){return this._enabled?this:(this._enabled=!0,this.addHooks(),this)},disable:function(){return this._enabled?(this._enabled=!1,this.removeHooks(),this):this},enabled:function(){return!!this._enabled}});Bn.addTo=function(u,v){return u.addHandler(v,this),this};var Wo={Events:Jr},Gs=o.touch?"touchstart mousedown":"mousedown",xr=Hr.extend({options:{clickTolerance:3},initialize:function(u,v,E,R){Gt(this,R),this._element=u,this._dragStartTarget=v||u,this._preventOutline=E},enable:function(){this._enabled||(Ht(this._dragStartTarget,Gs,this._onDown,this),this._enabled=!0)},disable:function(){this._enabled&&(xr._dragging===this&&this.finishDrag(!0),Dt(this._dragStartTarget,Gs,this._onDown,this),this._enabled=!1,this._moved=!1)},_onDown:function(u){if(this._enabled&&(this._moved=!1,!Ha(this._element,"leaflet-zoom-anim"))){if(u.touches&&u.touches.length!==1){xr._dragging===this&&this.finishDrag();return}if(!(xr._dragging||u.shiftKey||u.which!==1&&u.button!==1&&!u.touches)&&(xr._dragging=this,this._preventOutline&&oi(this._element),Ca(),so(),!this._moving)){this.fire("down");var v=u.touches?u.touches[0]:u,E=Nl(this._element);this._startPoint=new ti(v.clientX,v.clientY),this._startPos=To(this._element),this._parentScale=Ia(E);var R=u.type==="mousedown";Ht(document,R?"mousemove":"touchmove",this._onMove,this),Ht(document,R?"mouseup":"touchend touchcancel",this._onUp,this)}}},_onMove:function(u){if(this._enabled){if(u.touches&&u.touches.length>1){this._moved=!0;return}var v=u.touches&&u.touches.length===1?u.touches[0]:u,E=new ti(v.clientX,v.clientY)._subtract(this._startPoint);!E.x&&!E.y||Math.abs(E.x)+Math.abs(E.y)<this.options.clickTolerance||(E.x/=this._parentScale.x,E.y/=this._parentScale.y,Si(u),this._moved||(this.fire("dragstart"),this._moved=!0,_i(document.body,"leaflet-dragging"),this._lastTarget=u.target||u.srcElement,window.SVGElementInstance&&this._lastTarget instanceof window.SVGElementInstance&&(this._lastTarget=this._lastTarget.correspondingUseElement),_i(this._lastTarget,"leaflet-drag-target")),this._newPos=this._startPos.add(E),this._moving=!0,this._lastEvent=u,this._updatePosition())}},_updatePosition:function(){var u={originalEvent:this._lastEvent};this.fire("predrag",u),Cr(this._element,this._newPos),this.fire("drag",u)},_onUp:function(){this._enabled&&this.finishDrag()},finishDrag:function(u){Sr(document.body,"leaflet-dragging"),this._lastTarget&&(Sr(this._lastTarget,"leaflet-drag-target"),this._lastTarget=null),Dt(document,"mousemove touchmove",this._onMove,this),Dt(document,"mouseup touchend touchcancel",this._onUp,this),qo(),js();var v=this._moved&&this._moving;this._moving=!1,xr._dragging=!1,v&&this.fire("dragend",{noInertia:u,distance:this._newPos.distanceTo(this._startPos)})}});function ys(u,v,E){var R,q=[1,4,2,8],ne,Ee,Ze,tt,gt,Rt,Jt,Ti;for(ne=0,Rt=u.length;ne<Rt;ne++)u[ne]._code=vs(u[ne],v);for(Ze=0;Ze<4;Ze++){for(Jt=q[Ze],R=[],ne=0,Rt=u.length,Ee=Rt-1;ne<Rt;Ee=ne++)tt=u[ne],gt=u[Ee],tt._code&Jt?gt._code&Jt||(Ti=lo(gt,tt,Jt,v,E),Ti._code=vs(Ti,v),R.push(Ti)):(gt._code&Jt&&(Ti=lo(gt,tt,Jt,v,E),Ti._code=vs(Ti,v),R.push(Ti)),R.push(tt));u=R}return u}function ir(u,v){var E,R,q,ne,Ee,Ze,tt,gt,Rt;if(!u||u.length===0)throw new Error("latlngs not passed");An(u)||(console.warn("latlngs are not flat! Only the first ring will be used"),u=u[0]);var Jt=Ai([0,0]),Ti=or(u),Zr=Ti.getNorthWest().distanceTo(Ti.getSouthWest())*Ti.getNorthEast().distanceTo(Ti.getNorthWest());Zr<1700&&(Jt=ao(u));var Br=u.length,ps=[];for(E=0;E<Br;E++){var On=Ai(u[E]);ps.push(v.project(Ai([On.lat-Jt.lat,On.lng-Jt.lng])))}for(Ze=tt=gt=0,E=0,R=Br-1;E<Br;R=E++)q=ps[E],ne=ps[R],Ee=q.y*ne.x-ne.y*q.x,tt+=(q.x+ne.x)*Ee,gt+=(q.y+ne.y)*Ee,Ze+=Ee*3;Ze===0?Rt=ps[0]:Rt=[tt/Ze,gt/Ze];var Ks=v.unproject(Yt(Rt));return Ai([Ks.lat+Jt.lat,Ks.lng+Jt.lng])}function ao(u){for(var v=0,E=0,R=0,q=0;q<u.length;q++){var ne=Ai(u[q]);v+=ne.lat,E+=ne.lng,R++}return Ai([v/R,E/R])}var yl={__proto__:null,clipPolygon:ys,polygonCenter:ir,centroid:ao};function Qo(u,v){if(!v||!u.length)return u.slice();var E=v*v;return u=uu(u,E),u=vl(u,E),u}function dr(u,v,E){return Math.sqrt(qs(u,v,E,!0))}function jl(u,v,E){return qs(u,v,E)}function vl(u,v){var E=u.length,R=typeof Uint8Array<"u"?Uint8Array:Array,q=new R(E);q[0]=q[E-1]=1,Ya(u,q,v,0,E-1);var ne,Ee=[];for(ne=0;ne<E;ne++)q[ne]&&Ee.push(u[ne]);return Ee}function Ya(u,v,E,R,q){var ne=0,Ee,Ze,tt;for(Ze=R+1;Ze<=q-1;Ze++)tt=qs(u[Ze],u[R],u[q],!0),tt>ne&&(Ee=Ze,ne=tt);ne>E&&(v[Ee]=1,Ya(u,v,E,R,Ee),Ya(u,v,E,Ee,q))}function uu(u,v){for(var E=[u[0]],R=1,q=0,ne=u.length;R<ne;R++)La(u[R],u[q])>v&&(E.push(u[R]),q=R);return q<ne-1&&E.push(u[ne-1]),E}var Mo;function za(u,v,E,R,q){var ne=R?Mo:vs(u,E),Ee=vs(v,E),Ze,tt,gt;for(Mo=Ee;;){if(!(ne|Ee))return[u,v];if(ne&Ee)return!1;Ze=ne||Ee,tt=lo(u,v,Ze,E,q),gt=vs(tt,E),Ze===ne?(u=tt,ne=gt):(v=tt,Ee=gt)}}function lo(u,v,E,R,q){var ne=v.x-u.x,Ee=v.y-u.y,Ze=R.min,tt=R.max,gt,Rt;return E&8?(gt=u.x+ne*(tt.y-u.y)/Ee,Rt=tt.y):E&4?(gt=u.x+ne*(Ze.y-u.y)/Ee,Rt=Ze.y):E&2?(gt=tt.x,Rt=u.y+Ee*(tt.x-u.x)/ne):E&1&&(gt=Ze.x,Rt=u.y+Ee*(Ze.x-u.x)/ne),new ti(gt,Rt,q)}function vs(u,v){var E=0;return u.x<v.min.x?E|=1:u.x>v.max.x&&(E|=2),u.y<v.min.y?E|=4:u.y>v.max.y&&(E|=8),E}function La(u,v){var E=v.x-u.x,R=v.y-u.y;return E*E+R*R}function qs(u,v,E,R){var q=v.x,ne=v.y,Ee=E.x-q,Ze=E.y-ne,tt=Ee*Ee+Ze*Ze,gt;return tt>0&&(gt=((u.x-q)*Ee+(u.y-ne)*Ze)/tt,gt>1?(q=E.x,ne=E.y):gt>0&&(q+=Ee*gt,ne+=Ze*gt)),Ee=u.x-q,Ze=u.y-ne,R?Ee*Ee+Ze*Ze:new ti(q,ne)}function An(u){return!zi(u[0])||typeof u[0][0]!="object"&&typeof u[0][0]<"u"}function Ar(u){return console.warn("Deprecated use of _flat, please use L.LineUtil.isFlat instead."),An(u)}function xl(u,v){var E,R,q,ne,Ee,Ze,tt,gt;if(!u||u.length===0)throw new Error("latlngs not passed");An(u)||(console.warn("latlngs are not flat! Only the first ring will be used"),u=u[0]);var Rt=Ai([0,0]),Jt=or(u),Ti=Jt.getNorthWest().distanceTo(Jt.getSouthWest())*Jt.getNorthEast().distanceTo(Jt.getNorthWest());Ti<1700&&(Rt=ao(u));var Zr=u.length,Br=[];for(E=0;E<Zr;E++){var ps=Ai(u[E]);Br.push(v.project(Ai([ps.lat-Rt.lat,ps.lng-Rt.lng])))}for(E=0,R=0;E<Zr-1;E++)R+=Br[E].distanceTo(Br[E+1])/2;if(R===0)gt=Br[0];else for(E=0,ne=0;E<Zr-1;E++)if(Ee=Br[E],Ze=Br[E+1],q=Ee.distanceTo(Ze),ne+=q,ne>R){tt=(ne-R)/q,gt=[Ze.x-tt*(Ze.x-Ee.x),Ze.y-tt*(Ze.y-Ee.y)];break}var On=v.unproject(Yt(gt));return Ai([On.lat+Rt.lat,On.lng+Rt.lng])}var Eo={__proto__:null,simplify:Qo,pointToSegmentDistance:dr,closestPointOnSegment:jl,clipSegment:za,_getEdgeIntersection:lo,_getBitCode:vs,_sqClosestPointOnSegment:qs,isFlat:An,_flat:Ar,polylineCenter:xl},So={project:function(u){return new ti(u.lng,u.lat)},unproject:function(u){return new xi(u.y,u.x)},bounds:new Ni([-180,-90],[180,90])},Jn={R:6378137,R_MINOR:6356752314245179e-9,bounds:new Ni([-2003750834279e-5,-1549657073972e-5],[2003750834279e-5,1876465623138e-5]),project:function(u){var v=Math.PI/180,E=this.R,R=u.lat*v,q=this.R_MINOR/E,ne=Math.sqrt(1-q*q),Ee=ne*Math.sin(R),Ze=Math.tan(Math.PI/4-R/2)/Math.pow((1-Ee)/(1+Ee),ne/2);return R=-E*Math.log(Math.max(Ze,1e-10)),new ti(u.lng*v*E,R)},unproject:function(u){for(var v=180/Math.PI,E=this.R,R=this.R_MINOR/E,q=Math.sqrt(1-R*R),ne=Math.exp(-u.y/E),Ee=Math.PI/2-2*Math.atan(ne),Ze=0,tt=.1,gt;Ze<15&&Math.abs(tt)>1e-7;Ze++)gt=q*Math.sin(Ee),gt=Math.pow((1-gt)/(1+gt),q/2),tt=Math.PI/2-2*Math.atan(ne*gt)-Ee,Ee+=tt;return new xi(Ee*v,u.x*v/E)}},hu={__proto__:null,LonLat:So,Mercator:Jn,SphericalMercator:us},da=We({},Er,{code:"EPSG:3395",projection:Jn,transformation:(function(){var u=.5/(Math.PI*Jn.R);return In(u,.5,-u,.5)})()}),bl=We({},Er,{code:"EPSG:4326",projection:So,transformation:In(1/180,1,-1/180,.5)}),pa=We({},hn,{projection:So,transformation:In(1,0,-1,0),scale:function(u){return Math.pow(2,u)},zoom:function(u){return Math.log(u)/Math.LN2},distance:function(u,v){var E=v.lng-u.lng,R=v.lat-u.lat;return Math.sqrt(E*E+R*R)},infinite:!0});hn.Earth=Er,hn.EPSG3395=da,hn.EPSG3857=Vo,hn.EPSG900913=en,hn.EPSG4326=bl,hn.Simple=pa;var Rn=Hr.extend({options:{pane:"overlayPane",attribution:null,bubblingMouseEvents:!0},addTo:function(u){return u.addLayer(this),this},remove:function(){return this.removeFrom(this._map||this._mapToAdd)},removeFrom:function(u){return u&&u.removeLayer(this),this},getPane:function(u){return this._map.getPane(u?this.options[u]||u:this.options.pane)},addInteractiveTarget:function(u){return this._map._targets[it(u)]=this,this},removeInteractiveTarget:function(u){return delete this._map._targets[it(u)],this},getAttribution:function(){return this.options.attribution},_layerAdd:function(u){var v=u.target;if(v.hasLayer(this)){if(this._map=v,this._zoomAnimated=v._zoomAnimated,this.getEvents){var E=this.getEvents();v.on(E,this),this.once("remove",function(){v.off(E,this)},this)}this.onAdd(v),this.fire("add"),v.fire("layeradd",{layer:this})}}});hi.include({addLayer:function(u){if(!u._layerAdd)throw new Error("The provided object is not a Layer.");var v=it(u);return this._layers[v]?this:(this._layers[v]=u,u._mapToAdd=this,u.beforeAdd&&u.beforeAdd(this),this.whenReady(u._layerAdd,u),this)},removeLayer:function(u){var v=it(u);return this._layers[v]?(this._loaded&&u.onRemove(this),delete this._layers[v],this._loaded&&(this.fire("layerremove",{layer:u}),u.fire("remove")),u._map=u._mapToAdd=null,this):this},hasLayer:function(u){return it(u)in this._layers},eachLayer:function(u,v){for(var E in this._layers)u.call(v,this._layers[E]);return this},_addLayers:function(u){u=u?zi(u)?u:[u]:[];for(var v=0,E=u.length;v<E;v++)this.addLayer(u[v])},_addZoomLimit:function(u){(!isNaN(u.options.maxZoom)||!isNaN(u.options.minZoom))&&(this._zoomBoundLayers[it(u)]=u,this._updateZoomLevels())},_removeZoomLimit:function(u){var v=it(u);this._zoomBoundLayers[v]&&(delete this._zoomBoundLayers[v],this._updateZoomLevels())},_updateZoomLevels:function(){var u=1/0,v=-1/0,E=this._getZoomSpan();for(var R in this._zoomBoundLayers){var q=this._zoomBoundLayers[R].options;u=q.minZoom===void 0?u:Math.min(u,q.minZoom),v=q.maxZoom===void 0?v:Math.max(v,q.maxZoom)}this._layersMaxZoom=v===-1/0?void 0:v,this._layersMinZoom=u===1/0?void 0:u,E!==this._getZoomSpan()&&this.fire("zoomlevelschange"),this.options.maxZoom===void 0&&this._layersMaxZoom&&this.getZoom()>this._layersMaxZoom&&this.setZoom(this._layersMaxZoom),this.options.minZoom===void 0&&this._layersMinZoom&&this.getZoom()<this._layersMinZoom&&this.setZoom(this._layersMinZoom)}});var $o=Rn.extend({initialize:function(u,v){Gt(this,v),this._layers={};var E,R;if(u)for(E=0,R=u.length;E<R;E++)this.addLayer(u[E])},addLayer:function(u){var v=this.getLayerId(u);return this._layers[v]=u,this._map&&this._map.addLayer(u),this},removeLayer:function(u){var v=u in this._layers?u:this.getLayerId(u);return this._map&&this._layers[v]&&this._map.removeLayer(this._layers[v]),delete this._layers[v],this},hasLayer:function(u){var v=typeof u=="number"?u:this.getLayerId(u);return v in this._layers},clearLayers:function(){return this.eachLayer(this.removeLayer,this)},invoke:function(u){var v=Array.prototype.slice.call(arguments,1),E,R;for(E in this._layers)R=this._layers[E],R[u]&&R[u].apply(R,v);return this},onAdd:function(u){this.eachLayer(u.addLayer,u)},onRemove:function(u){this.eachLayer(u.removeLayer,u)},eachLayer:function(u,v){for(var E in this._layers)u.call(v,this._layers[E]);return this},getLayer:function(u){return this._layers[u]},getLayers:function(){var u=[];return this.eachLayer(u.push,u),u},setZIndex:function(u){return this.invoke("setZIndex",u)},getLayerId:function(u){return it(u)}}),Zl=function(u,v){return new $o(u,v)},cs=$o.extend({addLayer:function(u){return this.hasLayer(u)?this:(u.addEventParent(this),$o.prototype.addLayer.call(this,u),this.fire("layeradd",{layer:u}))},removeLayer:function(u){return this.hasLayer(u)?(u in this._layers&&(u=this._layers[u]),u.removeEventParent(this),$o.prototype.removeLayer.call(this,u),this.fire("layerremove",{layer:u})):this},setStyle:function(u){return this.invoke("setStyle",u)},bringToFront:function(){return this.invoke("bringToFront")},bringToBack:function(){return this.invoke("bringToBack")},getBounds:function(){var u=new Wr;for(var v in this._layers){var E=this._layers[v];u.extend(E.getBounds?E.getBounds():E.getLatLng())}return u}}),wl=function(u,v){return new cs(u,v)},Hs=Cn.extend({options:{popupAnchor:[0,0],tooltipAnchor:[0,0],crossOrigin:!1},initialize:function(u){Gt(this,u)},createIcon:function(u){return this._createIcon("icon",u)},createShadow:function(u){return this._createIcon("shadow",u)},_createIcon:function(u,v){var E=this._getIconUrl(u);if(!E){if(u==="icon")throw new Error("iconUrl not set in Icon options (see the docs).");return null}var R=this._createImg(E,v&&v.tagName==="IMG"?v:null);return this._setIconStyles(R,u),(this.options.crossOrigin||this.options.crossOrigin==="")&&(R.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin),R},_setIconStyles:function(u,v){var E=this.options,R=E[v+"Size"];typeof R=="number"&&(R=[R,R]);var q=Yt(R),ne=Yt(v==="shadow"&&E.shadowAnchor||E.iconAnchor||q&&q.divideBy(2,!0));u.className="leaflet-marker-"+v+" "+(E.className||""),ne&&(u.style.marginLeft=-ne.x+"px",u.style.marginTop=-ne.y+"px"),q&&(u.style.width=q.x+"px",u.style.height=q.y+"px")},_createImg:function(u,v){return v=v||document.createElement("img"),v.src=u,v},_getIconUrl:function(u){return o.retina&&this.options[u+"RetinaUrl"]||this.options[u+"Url"]}});function Xa(u){return new Hs(u)}var Ws=Hs.extend({options:{iconUrl:"marker-icon.png",iconRetinaUrl:"marker-icon-2x.png",shadowUrl:"marker-shadow.png",iconSize:[25,41],iconAnchor:[12,41],popupAnchor:[1,-34],tooltipAnchor:[16,-28],shadowSize:[41,41]},_getIconUrl:function(u){return typeof Ws.imagePath!="string"&&(Ws.imagePath=this._detectIconPath()),(this.options.imagePath||Ws.imagePath)+Hs.prototype._getIconUrl.call(this,u)},_stripUrl:function(u){var v=function(E,R,q){var ne=R.exec(E);return ne&&ne[q]};return u=v(u,/^url\((['"])?(.+)\1\)$/,2),u&&v(u,/^(.*)marker-icon\.png$/,1)},_detectIconPath:function(){var u=Fi("div","leaflet-default-icon-path",document.body),v=zn(u,"background-image")||zn(u,"backgroundImage");if(document.body.removeChild(u),v=this._stripUrl(v),v)return v;var E=document.querySelector('link[href$="leaflet.css"]');return E?E.href.substring(0,E.href.length-11-1):""}}),$i=Bn.extend({initialize:function(u){this._marker=u},addHooks:function(){var u=this._marker._icon;this._draggable||(this._draggable=new xr(u,u,!0)),this._draggable.on({dragstart:this._onDragStart,predrag:this._onPreDrag,drag:this._onDrag,dragend:this._onDragEnd},this).enable(),_i(u,"leaflet-marker-draggable")},removeHooks:function(){this._draggable.off({dragstart:this._onDragStart,predrag:this._onPreDrag,drag:this._onDrag,dragend:this._onDragEnd},this).disable(),this._marker._icon&&Sr(this._marker._icon,"leaflet-marker-draggable")},moved:function(){return this._draggable&&this._draggable._moved},_adjustPan:function(u){var v=this._marker,E=v._map,R=this._marker.options.autoPanSpeed,q=this._marker.options.autoPanPadding,ne=To(v._icon),Ee=E.getPixelBounds(),Ze=E.getPixelOrigin(),tt=Mr(Ee.min._subtract(Ze).add(q),Ee.max._subtract(Ze).subtract(q));if(!tt.contains(ne)){var gt=Yt((Math.max(tt.max.x,ne.x)-tt.max.x)/(Ee.max.x-tt.max.x)-(Math.min(tt.min.x,ne.x)-tt.min.x)/(Ee.min.x-tt.min.x),(Math.max(tt.max.y,ne.y)-tt.max.y)/(Ee.max.y-tt.max.y)-(Math.min(tt.min.y,ne.y)-tt.min.y)/(Ee.min.y-tt.min.y)).multiplyBy(R);E.panBy(gt,{animate:!1}),this._draggable._newPos._add(gt),this._draggable._startPos._add(gt),Cr(v._icon,this._draggable._newPos),this._onDrag(u),this._panRequest=cr(this._adjustPan.bind(this,u))}},_onDragStart:function(){this._oldLatLng=this._marker.getLatLng(),this._marker.closePopup&&this._marker.closePopup(),this._marker.fire("movestart").fire("dragstart")},_onPreDrag:function(u){this._marker.options.autoPan&&(Ji(this._panRequest),this._panRequest=cr(this._adjustPan.bind(this,u)))},_onDrag:function(u){var v=this._marker,E=v._shadow,R=To(v._icon),q=v._map.layerPointToLatLng(R);E&&Cr(E,R),v._latlng=q,u.latlng=q,u.oldLatLng=this._oldLatLng,v.fire("move",u).fire("drag",u)},_onDragEnd:function(u){Ji(this._panRequest),delete this._oldLatLng,this._marker.fire("moveend").fire("dragend",u)}}),Qs=Rn.extend({options:{icon:new Ws,interactive:!0,keyboard:!0,title:"",alt:"Marker",zIndexOffset:0,opacity:1,riseOnHover:!1,riseOffset:250,pane:"markerPane",shadowPane:"shadowPane",bubblingMouseEvents:!1,autoPanOnFocus:!0,draggable:!1,autoPan:!1,autoPanPadding:[50,50],autoPanSpeed:10},initialize:function(u,v){Gt(this,v),this._latlng=Ai(u)},onAdd:function(u){this._zoomAnimated=this._zoomAnimated&&u.options.markerZoomAnimation,this._zoomAnimated&&u.on("zoomanim",this._animateZoom,this),this._initIcon(),this.update()},onRemove:function(u){this.dragging&&this.dragging.enabled()&&(this.options.draggable=!0,this.dragging.removeHooks()),delete this.dragging,this._zoomAnimated&&u.off("zoomanim",this._animateZoom,this),this._removeIcon(),this._removeShadow()},getEvents:function(){return{zoom:this.update,viewreset:this.update}},getLatLng:function(){return this._latlng},setLatLng:function(u){var v=this._latlng;return this._latlng=Ai(u),this.update(),this.fire("move",{oldLatLng:v,latlng:this._latlng})},setZIndexOffset:function(u){return this.options.zIndexOffset=u,this.update()},getIcon:function(){return this.options.icon},setIcon:function(u){return this.options.icon=u,this._map&&(this._initIcon(),this.update()),this._popup&&this.bindPopup(this._popup,this._popup.options),this},getElement:function(){return this._icon},update:function(){if(this._icon&&this._map){var u=this._map.latLngToLayerPoint(this._latlng).round();this._setPos(u)}return this},_initIcon:function(){var u=this.options,v="leaflet-zoom-"+(this._zoomAnimated?"animated":"hide"),E=u.icon.createIcon(this._icon),R=!1;E!==this._icon&&(this._icon&&this._removeIcon(),R=!0,u.title&&(E.title=u.title),E.tagName==="IMG"&&(E.alt=u.alt||"")),_i(E,v),u.keyboard&&(E.tabIndex="0",E.setAttribute("role","button")),this._icon=E,u.riseOnHover&&this.on({mouseover:this._bringToFront,mouseout:this._resetZIndex}),this.options.autoPanOnFocus&&Ht(E,"focus",this._panOnFocus,this);var q=u.icon.createShadow(this._shadow),ne=!1;q!==this._shadow&&(this._removeShadow(),ne=!0),q&&(_i(q,v),q.alt=""),this._shadow=q,u.opacity<1&&this._updateOpacity(),R&&this.getPane().appendChild(this._icon),this._initInteraction(),q&&ne&&this.getPane(u.shadowPane).appendChild(this._shadow)},_removeIcon:function(){this.options.riseOnHover&&this.off({mouseover:this._bringToFront,mouseout:this._resetZIndex}),this.options.autoPanOnFocus&&Dt(this._icon,"focus",this._panOnFocus,this),Xi(this._icon),this.removeInteractiveTarget(this._icon),this._icon=null},_removeShadow:function(){this._shadow&&Xi(this._shadow),this._shadow=null},_setPos:function(u){this._icon&&Cr(this._icon,u),this._shadow&&Cr(this._shadow,u),this._zIndex=u.y+this.options.zIndexOffset,this._resetZIndex()},_updateZIndex:function(u){this._icon&&(this._icon.style.zIndex=this._zIndex+u)},_animateZoom:function(u){var v=this._map._latLngToNewLayerPoint(this._latlng,u.zoom,u.center).round();this._setPos(v)},_initInteraction:function(){if(this.options.interactive&&(_i(this._icon,"leaflet-interactive"),this.addInteractiveTarget(this._icon),$i)){var u=this.options.draggable;this.dragging&&(u=this.dragging.enabled(),this.dragging.disable()),this.dragging=new $i(this),u&&this.dragging.enable()}},setOpacity:function(u){return this.options.opacity=u,this._map&&this._updateOpacity(),this},_updateOpacity:function(){var u=this.options.opacity;this._icon&&_n(this._icon,u),this._shadow&&_n(this._shadow,u)},_bringToFront:function(){this._updateZIndex(this.options.riseOffset)},_resetZIndex:function(){this._updateZIndex(0)},_panOnFocus:function(){var u=this._map;if(u){var v=this.options.icon.options,E=v.iconSize?Yt(v.iconSize):Yt(0,0),R=v.iconAnchor?Yt(v.iconAnchor):Yt(0,0);u.panInside(this._latlng,{paddingTopLeft:R,paddingBottomRight:E.subtract(R)})}},_getPopupAnchor:function(){return this.options.icon.options.popupAnchor},_getTooltipAnchor:function(){return this.options.icon.options.tooltipAnchor}});function Tl(u,v){return new Qs(u,v)}var Bs=Rn.extend({options:{stroke:!0,color:"#3388ff",weight:3,opacity:1,lineCap:"round",lineJoin:"round",dashArray:null,dashOffset:null,fill:!1,fillColor:null,fillOpacity:.2,fillRule:"evenodd",interactive:!0,bubblingMouseEvents:!0},beforeAdd:function(u){this._renderer=u.getRenderer(this)},onAdd:function(){this._renderer._initPath(this),this._reset(),this._renderer._addPath(this)},onRemove:function(){this._renderer._removePath(this)},redraw:function(){return this._map&&this._renderer._updatePath(this),this},setStyle:function(u){return Gt(this,u),this._renderer&&(this._renderer._updateStyle(this),this.options.stroke&&u&&Object.prototype.hasOwnProperty.call(u,"weight")&&this._updateBounds()),this},bringToFront:function(){return this._renderer&&this._renderer._bringToFront(this),this},bringToBack:function(){return this._renderer&&this._renderer._bringToBack(this),this},getElement:function(){return this._path},_reset:function(){this._project(),this._update()},_clickTolerance:function(){return(this.options.stroke?this.options.weight/2:0)+(this._renderer.options.tolerance||0)}}),uo=Bs.extend({options:{fill:!0,radius:10},initialize:function(u,v){Gt(this,v),this._latlng=Ai(u),this._radius=this.options.radius},setLatLng:function(u){var v=this._latlng;return this._latlng=Ai(u),this.redraw(),this.fire("move",{oldLatLng:v,latlng:this._latlng})},getLatLng:function(){return this._latlng},setRadius:function(u){return this.options.radius=this._radius=u,this.redraw()},getRadius:function(){return this._radius},setStyle:function(u){var v=u&&u.radius||this._radius;return Bs.prototype.setStyle.call(this,u),this.setRadius(v),this},_project:function(){this._point=this._map.latLngToLayerPoint(this._latlng),this._updateBounds()},_updateBounds:function(){var u=this._radius,v=this._radiusY||u,E=this._clickTolerance(),R=[u+E,v+E];this._pxBounds=new Ni(this._point.subtract(R),this._point.add(R))},_update:function(){this._map&&this._updatePath()},_updatePath:function(){this._renderer._updateCircle(this)},_empty:function(){return this._radius&&!this._renderer._bounds.intersects(this._pxBounds)},_containsPoint:function(u){return u.distanceTo(this._point)<=this._radius+this._clickTolerance()}});function Ul(u,v){return new uo(u,v)}var ma=uo.extend({initialize:function(u,v,E){if(typeof v=="number"&&(v=We({},E,{radius:v})),Gt(this,v),this._latlng=Ai(u),isNaN(this.options.radius))throw new Error("Circle radius cannot be NaN");this._mRadius=this.options.radius},setRadius:function(u){return this._mRadius=u,this.redraw()},getRadius:function(){return this._mRadius},getBounds:function(){var u=[this._radius,this._radiusY||this._radius];return new Wr(this._map.layerPointToLatLng(this._point.subtract(u)),this._map.layerPointToLatLng(this._point.add(u)))},setStyle:Bs.prototype.setStyle,_project:function(){var u=this._latlng.lng,v=this._latlng.lat,E=this._map,R=E.options.crs;if(R.distance===Er.distance){var q=Math.PI/180,ne=this._mRadius/Er.R/q,Ee=E.project([v+ne,u]),Ze=E.project([v-ne,u]),tt=Ee.add(Ze).divideBy(2),gt=E.unproject(tt).lat,Rt=Math.acos((Math.cos(ne*q)-Math.sin(v*q)*Math.sin(gt*q))/(Math.cos(v*q)*Math.cos(gt*q)))/q;(isNaN(Rt)||Rt===0)&&(Rt=ne/Math.cos(Math.PI/180*v)),this._point=tt.subtract(E.getPixelOrigin()),this._radius=isNaN(Rt)?0:tt.x-E.project([gt,u-Rt]).x,this._radiusY=tt.y-Ee.y}else{var Jt=R.unproject(R.project(this._latlng).subtract([this._mRadius,0]));this._point=E.latLngToLayerPoint(this._latlng),this._radius=this._point.x-E.latLngToLayerPoint(Jt).x}this._updateBounds()}});function cu(u,v,E){return new ma(u,v,E)}var Ir=Bs.extend({options:{smoothFactor:1,noClip:!1},initialize:function(u,v){Gt(this,v),this._setLatLngs(u)},getLatLngs:function(){return this._latlngs},setLatLngs:function(u){return this._setLatLngs(u),this.redraw()},isEmpty:function(){return!this._latlngs.length},closestLayerPoint:function(u){for(var v=1/0,E=null,R=qs,q,ne,Ee=0,Ze=this._parts.length;Ee<Ze;Ee++)for(var tt=this._parts[Ee],gt=1,Rt=tt.length;gt<Rt;gt++){q=tt[gt-1],ne=tt[gt];var Jt=R(u,q,ne,!0);Jt<v&&(v=Jt,E=R(u,q,ne))}return E&&(E.distance=Math.sqrt(v)),E},getCenter:function(){if(!this._map)throw new Error("Must add layer to map before using getCenter()");return xl(this._defaultShape(),this._map.options.crs)},getBounds:function(){return this._bounds},addLatLng:function(u,v){return v=v||this._defaultShape(),u=Ai(u),v.push(u),this._bounds.extend(u),this.redraw()},_setLatLngs:function(u){this._bounds=new Wr,this._latlngs=this._convertLatLngs(u)},_defaultShape:function(){return An(this._latlngs)?this._latlngs:this._latlngs[0]},_convertLatLngs:function(u){for(var v=[],E=An(u),R=0,q=u.length;R<q;R++)E?(v[R]=Ai(u[R]),this._bounds.extend(v[R])):v[R]=this._convertLatLngs(u[R]);return v},_project:function(){var u=new Ni;this._rings=[],this._projectLatlngs(this._latlngs,this._rings,u),this._bounds.isValid()&&u.isValid()&&(this._rawPxBounds=u,this._updateBounds())},_updateBounds:function(){var u=this._clickTolerance(),v=new ti(u,u);this._rawPxBounds&&(this._pxBounds=new Ni([this._rawPxBounds.min.subtract(v),this._rawPxBounds.max.add(v)]))},_projectLatlngs:function(u,v,E){var R=u[0]instanceof xi,q=u.length,ne,Ee;if(R){for(Ee=[],ne=0;ne<q;ne++)Ee[ne]=this._map.latLngToLayerPoint(u[ne]),E.extend(Ee[ne]);v.push(Ee)}else for(ne=0;ne<q;ne++)this._projectLatlngs(u[ne],v,E)},_clipPoints:function(){var u=this._renderer._bounds;if(this._parts=[],!(!this._pxBounds||!this._pxBounds.intersects(u))){if(this.options.noClip){this._parts=this._rings;return}var v=this._parts,E,R,q,ne,Ee,Ze,tt;for(E=0,q=0,ne=this._rings.length;E<ne;E++)for(tt=this._rings[E],R=0,Ee=tt.length;R<Ee-1;R++)Ze=za(tt[R],tt[R+1],u,R,!0),Ze&&(v[q]=v[q]||[],v[q].push(Ze[0]),(Ze[1]!==tt[R+1]||R===Ee-2)&&(v[q].push(Ze[1]),q++))}},_simplifyPoints:function(){for(var u=this._parts,v=this.options.smoothFactor,E=0,R=u.length;E<R;E++)u[E]=Qo(u[E],v)},_update:function(){this._map&&(this._clipPoints(),this._simplifyPoints(),this._updatePath())},_updatePath:function(){this._renderer._updatePoly(this)},_containsPoint:function(u,v){var E,R,q,ne,Ee,Ze,tt=this._clickTolerance();if(!this._pxBounds||!this._pxBounds.contains(u))return!1;for(E=0,ne=this._parts.length;E<ne;E++)for(Ze=this._parts[E],R=0,Ee=Ze.length,q=Ee-1;R<Ee;q=R++)if(!(!v&&R===0)&&dr(u,Ze[q],Ze[R])<=tt)return!0;return!1}});function Ka(u,v){return new Ir(u,v)}Ir._flat=Ar;var yn=Ir.extend({options:{fill:!0},isEmpty:function(){return!this._latlngs.length||!this._latlngs[0].length},getCenter:function(){if(!this._map)throw new Error("Must add layer to map before using getCenter()");return ir(this._defaultShape(),this._map.options.crs)},_convertLatLngs:function(u){var v=Ir.prototype._convertLatLngs.call(this,u),E=v.length;return E>=2&&v[0]instanceof xi&&v[0].equals(v[E-1])&&v.pop(),v},_setLatLngs:function(u){Ir.prototype._setLatLngs.call(this,u),An(this._latlngs)&&(this._latlngs=[this._latlngs])},_defaultShape:function(){return An(this._latlngs[0])?this._latlngs[0]:this._latlngs[0][0]},_clipPoints:function(){var u=this._renderer._bounds,v=this.options.weight,E=new ti(v,v);if(u=new Ni(u.min.subtract(E),u.max.add(E)),this._parts=[],!(!this._pxBounds||!this._pxBounds.intersects(u))){if(this.options.noClip){this._parts=this._rings;return}for(var R=0,q=this._rings.length,ne;R<q;R++)ne=ys(this._rings[R],u,!0),ne.length&&this._parts.push(ne)}},_updatePath:function(){this._renderer._updatePoly(this,!0)},_containsPoint:function(u){var v=!1,E,R,q,ne,Ee,Ze,tt,gt;if(!this._pxBounds||!this._pxBounds.contains(u))return!1;for(ne=0,tt=this._parts.length;ne<tt;ne++)for(E=this._parts[ne],Ee=0,gt=E.length,Ze=gt-1;Ee<gt;Ze=Ee++)R=E[Ee],q=E[Ze],R.y>u.y!=q.y>u.y&&u.x<(q.x-R.x)*(u.y-R.y)/(q.y-R.y)+R.x&&(v=!v);return v||Ir.prototype._containsPoint.call(this,u,!0)}});function Gl(u,v){return new yn(u,v)}var As=cs.extend({initialize:function(u,v){Gt(this,v),this._layers={},u&&this.addData(u)},addData:function(u){var v=zi(u)?u:u.features,E,R,q;if(v){for(E=0,R=v.length;E<R;E++)q=v[E],(q.geometries||q.geometry||q.features||q.coordinates)&&this.addData(q);return this}var ne=this.options;if(ne.filter&&!ne.filter(u))return this;var Ee=Ba(u,ne);return Ee?(Ee.feature=Yo(u),Ee.defaultOptions=Ee.options,this.resetStyle(Ee),ne.onEachFeature&&ne.onEachFeature(u,Ee),this.addLayer(Ee)):this},resetStyle:function(u){return u===void 0?this.eachLayer(this.resetStyle,this):(u.options=We({},u.defaultOptions),this._setLayerStyle(u,this.options.style),this)},setStyle:function(u){return this.eachLayer(function(v){this._setLayerStyle(v,u)},this)},_setLayerStyle:function(u,v){u.setStyle&&(typeof v=="function"&&(v=v(u.feature)),u.setStyle(v))}});function Ba(u,v){var E=u.type==="Feature"?u.geometry:u,R=E?E.coordinates:null,q=[],ne=v&&v.pointToLayer,Ee=v&&v.coordsToLatLng||Fn,Ze,tt,gt,Rt;if(!R&&!E)return null;switch(E.type){case"Point":return Ze=Ee(R),vn(ne,u,Ze,v);case"MultiPoint":for(gt=0,Rt=R.length;gt<Rt;gt++)Ze=Ee(R[gt]),q.push(vn(ne,u,Ze,v));return new cs(q);case"LineString":case"MultiLineString":return tt=ho(R,E.type==="LineString"?0:1,Ee),new Ir(tt,v);case"Polygon":case"MultiPolygon":return tt=ho(R,E.type==="Polygon"?1:2,Ee),new yn(tt,v);case"GeometryCollection":for(gt=0,Rt=E.geometries.length;gt<Rt;gt++){var Jt=Ba({geometry:E.geometries[gt],type:"Feature",properties:u.properties},v);Jt&&q.push(Jt)}return new cs(q);case"FeatureCollection":for(gt=0,Rt=E.features.length;gt<Rt;gt++){var Ti=Ba(E.features[gt],v);Ti&&q.push(Ti)}return new cs(q);default:throw new Error("Invalid GeoJSON object.")}}function vn(u,v,E,R){return u?u(v,E):new Qs(E,R&&R.markersInheritOptions&&R)}function Fn(u){return new xi(u[1],u[0],u[2])}function ho(u,v,E){for(var R=[],q=0,ne=u.length,Ee;q<ne;q++)Ee=v?ho(u[q],v-1,E):(E||Fn)(u[q]),R.push(Ee);return R}function $s(u,v){return u=Ai(u),u.alt!==void 0?[un(u.lng,v),un(u.lat,v),un(u.alt,v)]:[un(u.lng,v),un(u.lat,v)]}function xs(u,v,E,R){for(var q=[],ne=0,Ee=u.length;ne<Ee;ne++)q.push(v?xs(u[ne],An(u[ne])?0:v-1,E,R):$s(u[ne],R));return!v&&E&&q.length>0&&q.push(q[0].slice()),q}function fs(u,v){return u.feature?We({},u.feature,{geometry:v}):Yo(v)}function Yo(u){return u.type==="Feature"||u.type==="FeatureCollection"?u:{type:"Feature",properties:{},geometry:u}}var Ys={toGeoJSON:function(u){return fs(this,{type:"Point",coordinates:$s(this.getLatLng(),u)})}};Qs.include(Ys),ma.include(Ys),uo.include(Ys),Ir.include({toGeoJSON:function(u){var v=!An(this._latlngs),E=xs(this._latlngs,v?1:0,!1,u);return fs(this,{type:(v?"Multi":"")+"LineString",coordinates:E})}}),yn.include({toGeoJSON:function(u){var v=!An(this._latlngs),E=v&&!An(this._latlngs[0]),R=xs(this._latlngs,E?2:v?1:0,!0,u);return v||(R=[R]),fs(this,{type:(E?"Multi":"")+"Polygon",coordinates:R})}}),$o.include({toMultiPoint:function(u){var v=[];return this.eachLayer(function(E){v.push(E.toGeoJSON(u).geometry.coordinates)}),fs(this,{type:"MultiPoint",coordinates:v})},toGeoJSON:function(u){var v=this.feature&&this.feature.geometry&&this.feature.geometry.type;if(v==="MultiPoint")return this.toMultiPoint(u);var E=v==="GeometryCollection",R=[];return this.eachLayer(function(q){if(q.toGeoJSON){var ne=q.toGeoJSON(u);if(E)R.push(ne.geometry);else{var Ee=Yo(ne);Ee.type==="FeatureCollection"?R.push.apply(R,Ee.features):R.push(Ee)}}}),E?fs(this,{geometries:R,type:"GeometryCollection"}):{type:"FeatureCollection",features:R}}});function Ja(u,v){return new As(u,v)}var Pl=Ja,Ra=Rn.extend({options:{opacity:1,alt:"",interactive:!1,crossOrigin:!1,errorOverlayUrl:"",zIndex:1,className:""},initialize:function(u,v,E){this._url=u,this._bounds=or(v),Gt(this,E)},onAdd:function(){this._image||(this._initImage(),this.options.opacity<1&&this._updateOpacity()),this.options.interactive&&(_i(this._image,"leaflet-interactive"),this.addInteractiveTarget(this._image)),this.getPane().appendChild(this._image),this._reset()},onRemove:function(){Xi(this._image),this.options.interactive&&this.removeInteractiveTarget(this._image)},setOpacity:function(u){return this.options.opacity=u,this._image&&this._updateOpacity(),this},setStyle:function(u){return u.opacity&&this.setOpacity(u.opacity),this},bringToFront:function(){return this._map&&tr(this._image),this},bringToBack:function(){return this._map&&Go(this._image),this},setUrl:function(u){return this._url=u,this._image&&(this._image.src=u),this},setBounds:function(u){return this._bounds=or(u),this._map&&this._reset(),this},getEvents:function(){var u={zoom:this._reset,viewreset:this._reset};return this._zoomAnimated&&(u.zoomanim=this._animateZoom),u},setZIndex:function(u){return this.options.zIndex=u,this._updateZIndex(),this},getBounds:function(){return this._bounds},getElement:function(){return this._image},_initImage:function(){var u=this._url.tagName==="IMG",v=this._image=u?this._url:Fi("img");if(_i(v,"leaflet-image-layer"),this._zoomAnimated&&_i(v,"leaflet-zoom-animated"),this.options.className&&_i(v,this.options.className),v.onselectstart=Zi,v.onmousemove=Zi,v.onload=W(this.fire,this,"load"),v.onerror=W(this._overlayOnError,this,"error"),(this.options.crossOrigin||this.options.crossOrigin==="")&&(v.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin),this.options.zIndex&&this._updateZIndex(),u){this._url=v.src;return}v.src=this._url,v.alt=this.options.alt},_animateZoom:function(u){var v=this._map.getZoomScale(u.zoom),E=this._map._latLngBoundsToNewLayerBounds(this._bounds,u.zoom,u.center).min;ar(this._image,E,v)},_reset:function(){var u=this._image,v=new Ni(this._map.latLngToLayerPoint(this._bounds.getNorthWest()),this._map.latLngToLayerPoint(this._bounds.getSouthEast())),E=v.getSize();Cr(u,v.min),u.style.width=E.x+"px",u.style.height=E.y+"px"},_updateOpacity:function(){_n(this._image,this.options.opacity)},_updateZIndex:function(){this._image&&this.options.zIndex!==void 0&&this.options.zIndex!==null&&(this._image.style.zIndex=this.options.zIndex)},_overlayOnError:function(){this.fire("error");var u=this.options.errorOverlayUrl;u&&this._url!==u&&(this._url=u,this._image.src=u)},getCenter:function(){return this._bounds.getCenter()}}),Au=function(u,v,E){return new Ra(u,v,E)},el=Ra.extend({options:{autoplay:!0,loop:!0,keepAspectRatio:!0,muted:!1,playsInline:!0},_initImage:function(){var u=this._url.tagName==="VIDEO",v=this._image=u?this._url:Fi("video");if(_i(v,"leaflet-image-layer"),this._zoomAnimated&&_i(v,"leaflet-zoom-animated"),this.options.className&&_i(v,this.options.className),v.onselectstart=Zi,v.onmousemove=Zi,v.onloadeddata=W(this.fire,this,"load"),u){for(var E=v.getElementsByTagName("source"),R=[],q=0;q<E.length;q++)R.push(E[q].src);this._url=E.length>0?R:[v.src];return}zi(this._url)||(this._url=[this._url]),!this.options.keepAspectRatio&&Object.prototype.hasOwnProperty.call(v.style,"objectFit")&&(v.style.objectFit="fill"),v.autoplay=!!this.options.autoplay,v.loop=!!this.options.loop,v.muted=!!this.options.muted,v.playsInline=!!this.options.playsInline;for(var ne=0;ne<this._url.length;ne++){var Ee=Fi("source");Ee.src=this._url[ne],v.appendChild(Ee)}}});function Ml(u,v,E){return new el(u,v,E)}var tl=Ra.extend({_initImage:function(){var u=this._image=this._url;_i(u,"leaflet-image-layer"),this._zoomAnimated&&_i(u,"leaflet-zoom-animated"),this.options.className&&_i(u,this.options.className),u.onselectstart=Zi,u.onmousemove=Zi}});function Ii(u,v,E){return new tl(u,v,E)}var sn=Rn.extend({options:{interactive:!1,offset:[0,0],className:"",pane:void 0,content:""},initialize:function(u,v){u&&(u instanceof xi||zi(u))?(this._latlng=Ai(u),Gt(this,v)):(Gt(this,u),this._source=v),this.options.content&&(this._content=this.options.content)},openOn:function(u){return u=arguments.length?u:this._source._map,u.hasLayer(this)||u.addLayer(this),this},close:function(){return this._map&&this._map.removeLayer(this),this},toggle:function(u){return this._map?this.close():(arguments.length?this._source=u:u=this._source,this._prepareOpen(),this.openOn(u._map)),this},onAdd:function(u){this._zoomAnimated=u._zoomAnimated,this._container||this._initLayout(),u._fadeAnimated&&_n(this._container,0),clearTimeout(this._removeTimeout),this.getPane().appendChild(this._container),this.update(),u._fadeAnimated&&_n(this._container,1),this.bringToFront(),this.options.interactive&&(_i(this._container,"leaflet-interactive"),this.addInteractiveTarget(this._container))},onRemove:function(u){u._fadeAnimated?(_n(this._container,0),this._removeTimeout=setTimeout(W(Xi,void 0,this._container),200)):Xi(this._container),this.options.interactive&&(Sr(this._container,"leaflet-interactive"),this.removeInteractiveTarget(this._container))},getLatLng:function(){return this._latlng},setLatLng:function(u){return this._latlng=Ai(u),this._map&&(this._updatePosition(),this._adjustPan()),this},getContent:function(){return this._content},setContent:function(u){return this._content=u,this.update(),this},getElement:function(){return this._container},update:function(){this._map&&(this._container.style.visibility="hidden",this._updateContent(),this._updateLayout(),this._updatePosition(),this._container.style.visibility="",this._adjustPan())},getEvents:function(){var u={zoom:this._updatePosition,viewreset:this._updatePosition};return this._zoomAnimated&&(u.zoomanim=this._animateZoom),u},isOpen:function(){return!!this._map&&this._map.hasLayer(this)},bringToFront:function(){return this._map&&tr(this._container),this},bringToBack:function(){return this._map&&Go(this._container),this},_prepareOpen:function(u){var v=this._source;if(!v._map)return!1;if(v instanceof cs){v=null;var E=this._source._layers;for(var R in E)if(E[R]._map){v=E[R];break}if(!v)return!1;this._source=v}if(!u)if(v.getCenter)u=v.getCenter();else if(v.getLatLng)u=v.getLatLng();else if(v.getBounds)u=v.getBounds().getCenter();else throw new Error("Unable to get source layer LatLng.");return this.setLatLng(u),this._map&&this.update(),!0},_updateContent:function(){if(this._content){var u=this._contentNode,v=typeof this._content=="function"?this._content(this._source||this):this._content;if(typeof v=="string")u.innerHTML=v;else{for(;u.hasChildNodes();)u.removeChild(u.firstChild);u.appendChild(v)}this.fire("contentupdate")}},_updatePosition:function(){if(this._map){var u=this._map.latLngToLayerPoint(this._latlng),v=Yt(this.options.offset),E=this._getAnchor();this._zoomAnimated?Cr(this._container,u.add(E)):v=v.add(u).add(E);var R=this._containerBottom=-v.y,q=this._containerLeft=-Math.round(this._containerWidth/2)+v.x;this._container.style.bottom=R+"px",this._container.style.left=q+"px"}},_getAnchor:function(){return[0,0]}});hi.include({_initOverlay:function(u,v,E,R){var q=v;return q instanceof u||(q=new u(R).setContent(v)),E&&q.setLatLng(E),q}}),Rn.include({_initOverlay:function(u,v,E,R){var q=E;return q instanceof u?(Gt(q,R),q._source=this):(q=v&&!R?v:new u(R,this),q.setContent(E)),q}});var $r=sn.extend({options:{pane:"popupPane",offset:[0,7],maxWidth:300,minWidth:50,maxHeight:null,autoPan:!0,autoPanPaddingTopLeft:null,autoPanPaddingBottomRight:null,autoPanPadding:[5,5],keepInView:!1,closeButton:!0,autoClose:!0,closeOnEscapeKey:!0,className:""},openOn:function(u){return u=arguments.length?u:this._source._map,!u.hasLayer(this)&&u._popup&&u._popup.options.autoClose&&u.removeLayer(u._popup),u._popup=this,sn.prototype.openOn.call(this,u)},onAdd:function(u){sn.prototype.onAdd.call(this,u),u.fire("popupopen",{popup:this}),this._source&&(this._source.fire("popupopen",{popup:this},!0),this._source instanceof Bs||this._source.on("preclick",Lr))},onRemove:function(u){sn.prototype.onRemove.call(this,u),u.fire("popupclose",{popup:this}),this._source&&(this._source.fire("popupclose",{popup:this},!0),this._source instanceof Bs||this._source.off("preclick",Lr))},getEvents:function(){var u=sn.prototype.getEvents.call(this);return(this.options.closeOnClick!==void 0?this.options.closeOnClick:this._map.options.closePopupOnClick)&&(u.preclick=this.close),this.options.keepInView&&(u.moveend=this._adjustPan),u},_initLayout:function(){var u="leaflet-popup",v=this._container=Fi("div",u+" "+(this.options.className||"")+" leaflet-zoom-animated"),E=this._wrapper=Fi("div",u+"-content-wrapper",v);if(this._contentNode=Fi("div",u+"-content",E),Qn(v),Us(this._contentNode),Ht(v,"contextmenu",Lr),this._tipContainer=Fi("div",u+"-tip-container",v),this._tip=Fi("div",u+"-tip",this._tipContainer),this.options.closeButton){var R=this._closeButton=Fi("a",u+"-close-button",v);R.setAttribute("role","button"),R.setAttribute("aria-label","Close popup"),R.href="#close",R.innerHTML='<span aria-hidden="true">&#215;</span>',Ht(R,"click",function(q){Si(q),this.close()},this)}},_updateLayout:function(){var u=this._contentNode,v=u.style;v.width="",v.whiteSpace="nowrap";var E=u.offsetWidth;E=Math.min(E,this.options.maxWidth),E=Math.max(E,this.options.minWidth),v.width=E+1+"px",v.whiteSpace="",v.height="";var R=u.offsetHeight,q=this.options.maxHeight,ne="leaflet-popup-scrolled";q&&R>q?(v.height=q+"px",_i(u,ne)):Sr(u,ne),this._containerWidth=this._container.offsetWidth},_animateZoom:function(u){var v=this._map._latLngToNewLayerPoint(this._latlng,u.zoom,u.center),E=this._getAnchor();Cr(this._container,v.add(E))},_adjustPan:function(){if(this.options.autoPan){if(this._map._panAnim&&this._map._panAnim.stop(),this._autopanning){this._autopanning=!1;return}var u=this._map,v=parseInt(zn(this._container,"marginBottom"),10)||0,E=this._container.offsetHeight+v,R=this._containerWidth,q=new ti(this._containerLeft,-E-this._containerBottom);q._add(To(this._container));var ne=u.layerPointToContainerPoint(q),Ee=Yt(this.options.autoPanPadding),Ze=Yt(this.options.autoPanPaddingTopLeft||Ee),tt=Yt(this.options.autoPanPaddingBottomRight||Ee),gt=u.getSize(),Rt=0,Jt=0;ne.x+R+tt.x>gt.x&&(Rt=ne.x+R-gt.x+tt.x),ne.x-Rt-Ze.x<0&&(Rt=ne.x-Ze.x),ne.y+E+tt.y>gt.y&&(Jt=ne.y+E-gt.y+tt.y),ne.y-Jt-Ze.y<0&&(Jt=ne.y-Ze.y),(Rt||Jt)&&(this.options.keepInView&&(this._autopanning=!0),u.fire("autopanstart").panBy([Rt,Jt]))}},_getAnchor:function(){return Yt(this._source&&this._source._getPopupAnchor?this._source._getPopupAnchor():[0,0])}}),il=function(u,v){return new $r(u,v)};hi.mergeOptions({closePopupOnClick:!0}),hi.include({openPopup:function(u,v,E){return this._initOverlay($r,u,v,E).openOn(this),this},closePopup:function(u){return u=arguments.length?u:this._popup,u&&u.close(),this}}),Rn.include({bindPopup:function(u,v){return this._popup=this._initOverlay($r,this._popup,u,v),this._popupHandlersAdded||(this.on({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!0),this},unbindPopup:function(){return this._popup&&(this.off({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!1,this._popup=null),this},openPopup:function(u){return this._popup&&(this instanceof cs||(this._popup._source=this),this._popup._prepareOpen(u||this._latlng)&&this._popup.openOn(this._map)),this},closePopup:function(){return this._popup&&this._popup.close(),this},togglePopup:function(){return this._popup&&this._popup.toggle(this),this},isPopupOpen:function(){return this._popup?this._popup.isOpen():!1},setPopupContent:function(u){return this._popup&&this._popup.setContent(u),this},getPopup:function(){return this._popup},_openPopup:function(u){if(!(!this._popup||!this._map)){$n(u);var v=u.layer||u.target;if(this._popup._source===v&&!(v instanceof Bs)){this._map.hasLayer(this._popup)?this.closePopup():this.openPopup(u.latlng);return}this._popup._source=v,this.openPopup(u.latlng)}},_movePopup:function(u){this._popup.setLatLng(u.latlng)},_onKeyPress:function(u){u.originalEvent.keyCode===13&&this._openPopup(u)}});var Xs=sn.extend({options:{pane:"tooltipPane",offset:[0,0],direction:"auto",permanent:!1,sticky:!1,opacity:.9},onAdd:function(u){sn.prototype.onAdd.call(this,u),this.setOpacity(this.options.opacity),u.fire("tooltipopen",{tooltip:this}),this._source&&(this.addEventParent(this._source),this._source.fire("tooltipopen",{tooltip:this},!0))},onRemove:function(u){sn.prototype.onRemove.call(this,u),u.fire("tooltipclose",{tooltip:this}),this._source&&(this.removeEventParent(this._source),this._source.fire("tooltipclose",{tooltip:this},!0))},getEvents:function(){var u=sn.prototype.getEvents.call(this);return this.options.permanent||(u.preclick=this.close),u},_initLayout:function(){var u="leaflet-tooltip",v=u+" "+(this.options.className||"")+" leaflet-zoom-"+(this._zoomAnimated?"animated":"hide");this._contentNode=this._container=Fi("div",v),this._container.setAttribute("role","tooltip"),this._container.setAttribute("id","leaflet-tooltip-"+it(this))},_updateLayout:function(){},_adjustPan:function(){},_setPosition:function(u){var v,E,R=this._map,q=this._container,ne=R.latLngToContainerPoint(R.getCenter()),Ee=R.layerPointToContainerPoint(u),Ze=this.options.direction,tt=q.offsetWidth,gt=q.offsetHeight,Rt=Yt(this.options.offset),Jt=this._getAnchor();Ze==="top"?(v=tt/2,E=gt):Ze==="bottom"?(v=tt/2,E=0):Ze==="center"?(v=tt/2,E=gt/2):Ze==="right"?(v=0,E=gt/2):Ze==="left"?(v=tt,E=gt/2):Ee.x<ne.x?(Ze="right",v=0,E=gt/2):(Ze="left",v=tt+(Rt.x+Jt.x)*2,E=gt/2),u=u.subtract(Yt(v,E,!0)).add(Rt).add(Jt),Sr(q,"leaflet-tooltip-right"),Sr(q,"leaflet-tooltip-left"),Sr(q,"leaflet-tooltip-top"),Sr(q,"leaflet-tooltip-bottom"),_i(q,"leaflet-tooltip-"+Ze),Cr(q,u)},_updatePosition:function(){var u=this._map.latLngToLayerPoint(this._latlng);this._setPosition(u)},setOpacity:function(u){this.options.opacity=u,this._container&&_n(this._container,u)},_animateZoom:function(u){var v=this._map._latLngToNewLayerPoint(this._latlng,u.zoom,u.center);this._setPosition(v)},_getAnchor:function(){return Yt(this._source&&this._source._getTooltipAnchor&&!this.options.sticky?this._source._getTooltipAnchor():[0,0])}}),Xo=function(u,v){return new Xs(u,v)};hi.include({openTooltip:function(u,v,E){return this._initOverlay(Xs,u,v,E).openOn(this),this},closeTooltip:function(u){return u.close(),this}}),Rn.include({bindTooltip:function(u,v){return this._tooltip&&this.isTooltipOpen()&&this.unbindTooltip(),this._tooltip=this._initOverlay(Xs,this._tooltip,u,v),this._initTooltipInteractions(),this._tooltip.options.permanent&&this._map&&this._map.hasLayer(this)&&this.openTooltip(),this},unbindTooltip:function(){return this._tooltip&&(this._initTooltipInteractions(!0),this.closeTooltip(),this._tooltip=null),this},_initTooltipInteractions:function(u){if(!(!u&&this._tooltipHandlersAdded)){var v=u?"off":"on",E={remove:this.closeTooltip,move:this._moveTooltip};this._tooltip.options.permanent?E.add=this._openTooltip:(E.mouseover=this._openTooltip,E.mouseout=this.closeTooltip,E.click=this._openTooltip,this._map?this._addFocusListeners():E.add=this._addFocusListeners),this._tooltip.options.sticky&&(E.mousemove=this._moveTooltip),this[v](E),this._tooltipHandlersAdded=!u}},openTooltip:function(u){return this._tooltip&&(this instanceof cs||(this._tooltip._source=this),this._tooltip._prepareOpen(u)&&(this._tooltip.openOn(this._map),this.getElement?this._setAriaDescribedByOnLayer(this):this.eachLayer&&this.eachLayer(this._setAriaDescribedByOnLayer,this))),this},closeTooltip:function(){if(this._tooltip)return this._tooltip.close()},toggleTooltip:function(){return this._tooltip&&this._tooltip.toggle(this),this},isTooltipOpen:function(){return this._tooltip.isOpen()},setTooltipContent:function(u){return this._tooltip&&this._tooltip.setContent(u),this},getTooltip:function(){return this._tooltip},_addFocusListeners:function(){this.getElement?this._addFocusListenersOnLayer(this):this.eachLayer&&this.eachLayer(this._addFocusListenersOnLayer,this)},_addFocusListenersOnLayer:function(u){var v=typeof u.getElement=="function"&&u.getElement();v&&(Ht(v,"focus",function(){this._tooltip._source=u,this.openTooltip()},this),Ht(v,"blur",this.closeTooltip,this))},_setAriaDescribedByOnLayer:function(u){var v=typeof u.getElement=="function"&&u.getElement();v&&v.setAttribute("aria-describedby",this._tooltip._container.id)},_openTooltip:function(u){if(!(!this._tooltip||!this._map)){if(this._map.dragging&&this._map.dragging.moving()&&!this._openOnceFlag){this._openOnceFlag=!0;var v=this;this._map.once("moveend",function(){v._openOnceFlag=!1,v._openTooltip(u)});return}this._tooltip._source=u.layer||u.target,this.openTooltip(this._tooltip.options.sticky?u.latlng:void 0)}},_moveTooltip:function(u){var v=u.latlng,E,R;this._tooltip.options.sticky&&u.originalEvent&&(E=this._map.mouseEventToContainerPoint(u.originalEvent),R=this._map.containerPointToLayerPoint(E),v=this._map.layerPointToLatLng(R)),this._tooltip.setLatLng(v)}});var _a=Hs.extend({options:{iconSize:[12,12],html:!1,bgPos:null,className:"leaflet-div-icon"},createIcon:function(u){var v=u&&u.tagName==="DIV"?u:document.createElement("div"),E=this.options;if(E.html instanceof Element?(te(v),v.appendChild(E.html)):v.innerHTML=E.html!==!1?E.html:"",E.bgPos){var R=Yt(E.bgPos);v.style.backgroundPosition=-R.x+"px "+-R.y+"px"}return this._setIconStyles(v,"icon"),v},createShadow:function(){return null}});function ga(u){return new _a(u)}Hs.Default=Ws;var fn=Rn.extend({options:{tileSize:256,opacity:1,updateWhenIdle:o.mobile,updateWhenZooming:!0,updateInterval:200,zIndex:1,bounds:null,minZoom:0,maxZoom:void 0,maxNativeZoom:void 0,minNativeZoom:void 0,noWrap:!1,pane:"tilePane",className:"",keepBuffer:2},initialize:function(u){Gt(this,u)},onAdd:function(){this._initContainer(),this._levels={},this._tiles={},this._resetView()},beforeAdd:function(u){u._addZoomLimit(this)},onRemove:function(u){this._removeAllTiles(),Xi(this._container),u._removeZoomLimit(this),this._container=null,this._tileZoom=void 0},bringToFront:function(){return this._map&&(tr(this._container),this._setAutoZIndex(Math.max)),this},bringToBack:function(){return this._map&&(Go(this._container),this._setAutoZIndex(Math.min)),this},getContainer:function(){return this._container},setOpacity:function(u){return this.options.opacity=u,this._updateOpacity(),this},setZIndex:function(u){return this.options.zIndex=u,this._updateZIndex(),this},isLoading:function(){return this._loading},redraw:function(){if(this._map){this._removeAllTiles();var u=this._clampZoom(this._map.getZoom());u!==this._tileZoom&&(this._tileZoom=u,this._updateLevels()),this._update()}return this},getEvents:function(){var u={viewprereset:this._invalidateAll,viewreset:this._resetView,zoom:this._resetView,moveend:this._onMoveEnd};return this.options.updateWhenIdle||(this._onMove||(this._onMove=ur(this._onMoveEnd,this.options.updateInterval,this)),u.move=this._onMove),this._zoomAnimated&&(u.zoomanim=this._animateZoom),u},createTile:function(){return document.createElement("div")},getTileSize:function(){var u=this.options.tileSize;return u instanceof ti?u:new ti(u,u)},_updateZIndex:function(){this._container&&this.options.zIndex!==void 0&&this.options.zIndex!==null&&(this._container.style.zIndex=this.options.zIndex)},_setAutoZIndex:function(u){for(var v=this.getPane().children,E=-u(-1/0,1/0),R=0,q=v.length,ne;R<q;R++)ne=v[R].style.zIndex,v[R]!==this._container&&ne&&(E=u(E,+ne));isFinite(E)&&(this.options.zIndex=E+u(-1,1),this._updateZIndex())},_updateOpacity:function(){if(this._map&&!o.ielt9){_n(this._container,this.options.opacity);var u=+new Date,v=!1,E=!1;for(var R in this._tiles){var q=this._tiles[R];if(!(!q.current||!q.loaded)){var ne=Math.min(1,(u-q.loaded)/200);_n(q.el,ne),ne<1?v=!0:(q.active?E=!0:this._onOpaqueTile(q),q.active=!0)}}E&&!this._noPrune&&this._pruneTiles(),v&&(Ji(this._fadeFrame),this._fadeFrame=cr(this._updateOpacity,this))}},_onOpaqueTile:Zi,_initContainer:function(){this._container||(this._container=Fi("div","leaflet-layer "+(this.options.className||"")),this._updateZIndex(),this.options.opacity<1&&this._updateOpacity(),this.getPane().appendChild(this._container))},_updateLevels:function(){var u=this._tileZoom,v=this.options.maxZoom;if(u!==void 0){for(var E in this._levels)E=Number(E),this._levels[E].el.children.length||E===u?(this._levels[E].el.style.zIndex=v-Math.abs(u-E),this._onUpdateLevel(E)):(Xi(this._levels[E].el),this._removeTilesAtZoom(E),this._onRemoveLevel(E),delete this._levels[E]);var R=this._levels[u],q=this._map;return R||(R=this._levels[u]={},R.el=Fi("div","leaflet-tile-container leaflet-zoom-animated",this._container),R.el.style.zIndex=v,R.origin=q.project(q.unproject(q.getPixelOrigin()),u).round(),R.zoom=u,this._setZoomTransform(R,q.getCenter(),q.getZoom()),Zi(R.el.offsetWidth),this._onCreateLevel(R)),this._level=R,R}},_onUpdateLevel:Zi,_onRemoveLevel:Zi,_onCreateLevel:Zi,_pruneTiles:function(){if(this._map){var u,v,E=this._map.getZoom();if(E>this.options.maxZoom||E<this.options.minZoom){this._removeAllTiles();return}for(u in this._tiles)v=this._tiles[u],v.retain=v.current;for(u in this._tiles)if(v=this._tiles[u],v.current&&!v.active){var R=v.coords;this._retainParent(R.x,R.y,R.z,R.z-5)||this._retainChildren(R.x,R.y,R.z,R.z+2)}for(u in this._tiles)this._tiles[u].retain||this._removeTile(u)}},_removeTilesAtZoom:function(u){for(var v in this._tiles)this._tiles[v].coords.z===u&&this._removeTile(v)},_removeAllTiles:function(){for(var u in this._tiles)this._removeTile(u)},_invalidateAll:function(){for(var u in this._levels)Xi(this._levels[u].el),this._onRemoveLevel(Number(u)),delete this._levels[u];this._removeAllTiles(),this._tileZoom=void 0},_retainParent:function(u,v,E,R){var q=Math.floor(u/2),ne=Math.floor(v/2),Ee=E-1,Ze=new ti(+q,+ne);Ze.z=+Ee;var tt=this._tileCoordsToKey(Ze),gt=this._tiles[tt];return gt&&gt.active?(gt.retain=!0,!0):(gt&&gt.loaded&&(gt.retain=!0),Ee>R?this._retainParent(q,ne,Ee,R):!1)},_retainChildren:function(u,v,E,R){for(var q=2*u;q<2*u+2;q++)for(var ne=2*v;ne<2*v+2;ne++){var Ee=new ti(q,ne);Ee.z=E+1;var Ze=this._tileCoordsToKey(Ee),tt=this._tiles[Ze];if(tt&&tt.active){tt.retain=!0;continue}else tt&&tt.loaded&&(tt.retain=!0);E+1<R&&this._retainChildren(q,ne,E+1,R)}},_resetView:function(u){var v=u&&(u.pinch||u.flyTo);this._setView(this._map.getCenter(),this._map.getZoom(),v,v)},_animateZoom:function(u){this._setView(u.center,u.zoom,!0,u.noUpdate)},_clampZoom:function(u){var v=this.options;return v.minNativeZoom!==void 0&&u<v.minNativeZoom?v.minNativeZoom:v.maxNativeZoom!==void 0&&v.maxNativeZoom<u?v.maxNativeZoom:u},_setView:function(u,v,E,R){var q=Math.round(v);this.options.maxZoom!==void 0&&q>this.options.maxZoom||this.options.minZoom!==void 0&&q<this.options.minZoom?q=void 0:q=this._clampZoom(q);var ne=this.options.updateWhenZooming&&q!==this._tileZoom;(!R||ne)&&(this._tileZoom=q,this._abortLoading&&this._abortLoading(),this._updateLevels(),this._resetGrid(),q!==void 0&&this._update(u),E||this._pruneTiles(),this._noPrune=!!E),this._setZoomTransforms(u,v)},_setZoomTransforms:function(u,v){for(var E in this._levels)this._setZoomTransform(this._levels[E],u,v)},_setZoomTransform:function(u,v,E){var R=this._map.getZoomScale(E,u.zoom),q=u.origin.multiplyBy(R).subtract(this._map._getNewPixelOrigin(v,E)).round();o.any3d?ar(u.el,q,R):Cr(u.el,q)},_resetGrid:function(){var u=this._map,v=u.options.crs,E=this._tileSize=this.getTileSize(),R=this._tileZoom,q=this._map.getPixelWorldBounds(this._tileZoom);q&&(this._globalTileRange=this._pxBoundsToTileRange(q)),this._wrapX=v.wrapLng&&!this.options.noWrap&&[Math.floor(u.project([0,v.wrapLng[0]],R).x/E.x),Math.ceil(u.project([0,v.wrapLng[1]],R).x/E.y)],this._wrapY=v.wrapLat&&!this.options.noWrap&&[Math.floor(u.project([v.wrapLat[0],0],R).y/E.x),Math.ceil(u.project([v.wrapLat[1],0],R).y/E.y)]},_onMoveEnd:function(){!this._map||this._map._animatingZoom||this._update()},_getTiledPixelBounds:function(u){var v=this._map,E=v._animatingZoom?Math.max(v._animateToZoom,v.getZoom()):v.getZoom(),R=v.getZoomScale(E,this._tileZoom),q=v.project(u,this._tileZoom).floor(),ne=v.getSize().divideBy(R*2);return new Ni(q.subtract(ne),q.add(ne))},_update:function(u){var v=this._map;if(v){var E=this._clampZoom(v.getZoom());if(u===void 0&&(u=v.getCenter()),this._tileZoom!==void 0){var R=this._getTiledPixelBounds(u),q=this._pxBoundsToTileRange(R),ne=q.getCenter(),Ee=[],Ze=this.options.keepBuffer,tt=new Ni(q.getBottomLeft().subtract([Ze,-Ze]),q.getTopRight().add([Ze,-Ze]));if(!(isFinite(q.min.x)&&isFinite(q.min.y)&&isFinite(q.max.x)&&isFinite(q.max.y)))throw new Error("Attempted to load an infinite number of tiles");for(var gt in this._tiles){var Rt=this._tiles[gt].coords;(Rt.z!==this._tileZoom||!tt.contains(new ti(Rt.x,Rt.y)))&&(this._tiles[gt].current=!1)}if(Math.abs(E-this._tileZoom)>1){this._setView(u,E);return}for(var Jt=q.min.y;Jt<=q.max.y;Jt++)for(var Ti=q.min.x;Ti<=q.max.x;Ti++){var Zr=new ti(Ti,Jt);if(Zr.z=this._tileZoom,!!this._isValidTile(Zr)){var Br=this._tiles[this._tileCoordsToKey(Zr)];Br?Br.current=!0:Ee.push(Zr)}}if(Ee.sort(function(On,Ks){return On.distanceTo(ne)-Ks.distanceTo(ne)}),Ee.length!==0){this._loading||(this._loading=!0,this.fire("loading"));var ps=document.createDocumentFragment();for(Ti=0;Ti<Ee.length;Ti++)this._addTile(Ee[Ti],ps);this._level.el.appendChild(ps)}}}},_isValidTile:function(u){var v=this._map.options.crs;if(!v.infinite){var E=this._globalTileRange;if(!v.wrapLng&&(u.x<E.min.x||u.x>E.max.x)||!v.wrapLat&&(u.y<E.min.y||u.y>E.max.y))return!1}if(!this.options.bounds)return!0;var R=this._tileCoordsToBounds(u);return or(this.options.bounds).overlaps(R)},_keyToBounds:function(u){return this._tileCoordsToBounds(this._keyToTileCoords(u))},_tileCoordsToNwSe:function(u){var v=this._map,E=this.getTileSize(),R=u.scaleBy(E),q=R.add(E),ne=v.unproject(R,u.z),Ee=v.unproject(q,u.z);return[ne,Ee]},_tileCoordsToBounds:function(u){var v=this._tileCoordsToNwSe(u),E=new Wr(v[0],v[1]);return this.options.noWrap||(E=this._map.wrapLatLngBounds(E)),E},_tileCoordsToKey:function(u){return u.x+":"+u.y+":"+u.z},_keyToTileCoords:function(u){var v=u.split(":"),E=new ti(+v[0],+v[1]);return E.z=+v[2],E},_removeTile:function(u){var v=this._tiles[u];v&&(Xi(v.el),delete this._tiles[u],this.fire("tileunload",{tile:v.el,coords:this._keyToTileCoords(u)}))},_initTile:function(u){_i(u,"leaflet-tile");var v=this.getTileSize();u.style.width=v.x+"px",u.style.height=v.y+"px",u.onselectstart=Zi,u.onmousemove=Zi,o.ielt9&&this.options.opacity<1&&_n(u,this.options.opacity)},_addTile:function(u,v){var E=this._getTilePos(u),R=this._tileCoordsToKey(u),q=this.createTile(this._wrapCoords(u),W(this._tileReady,this,u));this._initTile(q),this.createTile.length<2&&cr(W(this._tileReady,this,u,null,q)),Cr(q,E),this._tiles[R]={el:q,coords:u,current:!0},v.appendChild(q),this.fire("tileloadstart",{tile:q,coords:u})},_tileReady:function(u,v,E){v&&this.fire("tileerror",{error:v,tile:E,coords:u});var R=this._tileCoordsToKey(u);E=this._tiles[R],E&&(E.loaded=+new Date,this._map._fadeAnimated?(_n(E.el,0),Ji(this._fadeFrame),this._fadeFrame=cr(this._updateOpacity,this)):(E.active=!0,this._pruneTiles()),v||(_i(E.el,"leaflet-tile-loaded"),this.fire("tileload",{tile:E.el,coords:u})),this._noTilesToLoad()&&(this._loading=!1,this.fire("load"),o.ielt9||!this._map._fadeAnimated?cr(this._pruneTiles,this):setTimeout(W(this._pruneTiles,this),250)))},_getTilePos:function(u){return u.scaleBy(this.getTileSize()).subtract(this._level.origin)},_wrapCoords:function(u){var v=new ti(this._wrapX?fr(u.x,this._wrapX):u.x,this._wrapY?fr(u.y,this._wrapY):u.y);return v.z=u.z,v},_pxBoundsToTileRange:function(u){var v=this.getTileSize();return new Ni(u.min.unscaleBy(v).floor(),u.max.unscaleBy(v).ceil().subtract([1,1]))},_noTilesToLoad:function(){for(var u in this._tiles)if(!this._tiles[u].loaded)return!1;return!0}});function ql(u){return new fn(u)}var Ko=fn.extend({options:{minZoom:0,maxZoom:18,subdomains:"abc",errorTileUrl:"",zoomOffset:0,tms:!1,zoomReverse:!1,detectRetina:!1,crossOrigin:!1,referrerPolicy:!1},initialize:function(u,v){this._url=u,v=Gt(this,v),v.detectRetina&&o.retina&&v.maxZoom>0?(v.tileSize=Math.floor(v.tileSize/2),v.zoomReverse?(v.zoomOffset--,v.minZoom=Math.min(v.maxZoom,v.minZoom+1)):(v.zoomOffset++,v.maxZoom=Math.max(v.minZoom,v.maxZoom-1)),v.minZoom=Math.max(0,v.minZoom)):v.zoomReverse?v.minZoom=Math.min(v.maxZoom,v.minZoom):v.maxZoom=Math.max(v.minZoom,v.maxZoom),typeof v.subdomains=="string"&&(v.subdomains=v.subdomains.split("")),this.on("tileunload",this._onTileRemove)},setUrl:function(u,v){return this._url===u&&v===void 0&&(v=!0),this._url=u,v||this.redraw(),this},createTile:function(u,v){var E=document.createElement("img");return Ht(E,"load",W(this._tileOnLoad,this,v,E)),Ht(E,"error",W(this._tileOnError,this,v,E)),(this.options.crossOrigin||this.options.crossOrigin==="")&&(E.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin),typeof this.options.referrerPolicy=="string"&&(E.referrerPolicy=this.options.referrerPolicy),E.alt="",E.src=this.getTileUrl(u),E},getTileUrl:function(u){var v={r:o.retina?"@2x":"",s:this._getSubdomain(u),x:u.x,y:u.y,z:this._getZoomForUrl()};if(this._map&&!this._map.options.crs.infinite){var E=this._globalTileRange.max.y-u.y;this.options.tms&&(v.y=E),v["-y"]=E}return hr(this._url,We(v,this.options))},_tileOnLoad:function(u,v){o.ielt9?setTimeout(W(u,this,null,v),0):u(null,v)},_tileOnError:function(u,v,E){var R=this.options.errorTileUrl;R&&v.getAttribute("src")!==R&&(v.src=R),u(E,v)},_onTileRemove:function(u){u.tile.onload=null},_getZoomForUrl:function(){var u=this._tileZoom,v=this.options.maxZoom,E=this.options.zoomReverse,R=this.options.zoomOffset;return E&&(u=v-u),u+R},_getSubdomain:function(u){var v=Math.abs(u.x+u.y)%this.options.subdomains.length;return this.options.subdomains[v]},_abortLoading:function(){var u,v;for(u in this._tiles)if(this._tiles[u].coords.z!==this._tileZoom&&(v=this._tiles[u].el,v.onload=Zi,v.onerror=Zi,!v.complete)){v.src=no;var E=this._tiles[u].coords;Xi(v),delete this._tiles[u],this.fire("tileabort",{tile:v,coords:E})}},_removeTile:function(u){var v=this._tiles[u];if(v)return v.el.setAttribute("src",no),fn.prototype._removeTile.call(this,u)},_tileReady:function(u,v,E){if(!(!this._map||E&&E.getAttribute("src")===no))return fn.prototype._tileReady.call(this,u,v,E)}});function rl(u,v){return new Ko(u,v)}var Rs=Ko.extend({defaultWmsParams:{service:"WMS",request:"GetMap",layers:"",styles:"",format:"image/jpeg",transparent:!1,version:"1.1.1"},options:{crs:null,uppercase:!1},initialize:function(u,v){this._url=u;var E=We({},this.defaultWmsParams);for(var R in v)R in this.options||(E[R]=v[R]);v=Gt(this,v);var q=v.detectRetina&&o.retina?2:1,ne=this.getTileSize();E.width=ne.x*q,E.height=ne.y*q,this.wmsParams=E},onAdd:function(u){this._crs=this.options.crs||u.options.crs,this._wmsVersion=parseFloat(this.wmsParams.version);var v=this._wmsVersion>=1.3?"crs":"srs";this.wmsParams[v]=this._crs.code,Ko.prototype.onAdd.call(this,u)},getTileUrl:function(u){var v=this._tileCoordsToNwSe(u),E=this._crs,R=Mr(E.project(v[0]),E.project(v[1])),q=R.min,ne=R.max,Ee=(this._wmsVersion>=1.3&&this._crs===bl?[q.y,q.x,ne.y,ne.x]:[q.x,q.y,ne.x,ne.y]).join(","),Ze=Ko.prototype.getTileUrl.call(this,u);return Ze+rt(this.wmsParams,Ze,this.options.uppercase)+(this.options.uppercase?"&BBOX=":"&bbox=")+Ee},setParams:function(u,v){return We(this.wmsParams,u),v||this.redraw(),this}});function Fa(u,v){return new Rs(u,v)}Ko.WMS=Rs,rl.wms=Fa;var es=Rn.extend({options:{padding:.1},initialize:function(u){Gt(this,u),it(this),this._layers=this._layers||{}},onAdd:function(){this._container||(this._initContainer(),_i(this._container,"leaflet-zoom-animated")),this.getPane().appendChild(this._container),this._update(),this.on("update",this._updatePaths,this)},onRemove:function(){this.off("update",this._updatePaths,this),this._destroyContainer()},getEvents:function(){var u={viewreset:this._reset,zoom:this._onZoom,moveend:this._update,zoomend:this._onZoomEnd};return this._zoomAnimated&&(u.zoomanim=this._onAnimZoom),u},_onAnimZoom:function(u){this._updateTransform(u.center,u.zoom)},_onZoom:function(){this._updateTransform(this._map.getCenter(),this._map.getZoom())},_updateTransform:function(u,v){var E=this._map.getZoomScale(v,this._zoom),R=this._map.getSize().multiplyBy(.5+this.options.padding),q=this._map.project(this._center,v),ne=R.multiplyBy(-E).add(q).subtract(this._map._getNewPixelOrigin(u,v));o.any3d?ar(this._container,ne,E):Cr(this._container,ne)},_reset:function(){this._update(),this._updateTransform(this._center,this._zoom);for(var u in this._layers)this._layers[u]._reset()},_onZoomEnd:function(){for(var u in this._layers)this._layers[u]._project()},_updatePaths:function(){for(var u in this._layers)this._layers[u]._update()},_update:function(){var u=this.options.padding,v=this._map.getSize(),E=this._map.containerPointToLayerPoint(v.multiplyBy(-u)).round();this._bounds=new Ni(E,E.add(v.multiplyBy(1+u*2)).round()),this._center=this._map.getCenter(),this._zoom=this._map.getZoom()}}),ya=es.extend({options:{tolerance:0},getEvents:function(){var u=es.prototype.getEvents.call(this);return u.viewprereset=this._onViewPreReset,u},_onViewPreReset:function(){this._postponeUpdatePaths=!0},onAdd:function(){es.prototype.onAdd.call(this),this._draw()},_initContainer:function(){var u=this._container=document.createElement("canvas");Ht(u,"mousemove",this._onMouseMove,this),Ht(u,"click dblclick mousedown mouseup contextmenu",this._onClick,this),Ht(u,"mouseout",this._handleMouseOut,this),u._leaflet_disable_events=!0,this._ctx=u.getContext("2d")},_destroyContainer:function(){Ji(this._redrawRequest),delete this._ctx,Xi(this._container),Dt(this._container),delete this._container},_updatePaths:function(){if(!this._postponeUpdatePaths){var u;this._redrawBounds=null;for(var v in this._layers)u=this._layers[v],u._update();this._redraw()}},_update:function(){if(!(this._map._animatingZoom&&this._bounds)){es.prototype._update.call(this);var u=this._bounds,v=this._container,E=u.getSize(),R=o.retina?2:1;Cr(v,u.min),v.width=R*E.x,v.height=R*E.y,v.style.width=E.x+"px",v.style.height=E.y+"px",o.retina&&this._ctx.scale(2,2),this._ctx.translate(-u.min.x,-u.min.y),this.fire("update")}},_reset:function(){es.prototype._reset.call(this),this._postponeUpdatePaths&&(this._postponeUpdatePaths=!1,this._updatePaths())},_initPath:function(u){this._updateDashArray(u),this._layers[it(u)]=u;var v=u._order={layer:u,prev:this._drawLast,next:null};this._drawLast&&(this._drawLast.next=v),this._drawLast=v,this._drawFirst=this._drawFirst||this._drawLast},_addPath:function(u){this._requestRedraw(u)},_removePath:function(u){var v=u._order,E=v.next,R=v.prev;E?E.prev=R:this._drawLast=R,R?R.next=E:this._drawFirst=E,delete u._order,delete this._layers[it(u)],this._requestRedraw(u)},_updatePath:function(u){this._extendRedrawBounds(u),u._project(),u._update(),this._requestRedraw(u)},_updateStyle:function(u){this._updateDashArray(u),this._requestRedraw(u)},_updateDashArray:function(u){if(typeof u.options.dashArray=="string"){var v=u.options.dashArray.split(/[, ]+/),E=[],R,q;for(q=0;q<v.length;q++){if(R=Number(v[q]),isNaN(R))return;E.push(R)}u.options._dashArray=E}else u.options._dashArray=u.options.dashArray},_requestRedraw:function(u){this._map&&(this._extendRedrawBounds(u),this._redrawRequest=this._redrawRequest||cr(this._redraw,this))},_extendRedrawBounds:function(u){if(u._pxBounds){var v=(u.options.weight||0)+1;this._redrawBounds=this._redrawBounds||new Ni,this._redrawBounds.extend(u._pxBounds.min.subtract([v,v])),this._redrawBounds.extend(u._pxBounds.max.add([v,v]))}},_redraw:function(){this._redrawRequest=null,this._redrawBounds&&(this._redrawBounds.min._floor(),this._redrawBounds.max._ceil()),this._clear(),this._draw(),this._redrawBounds=null},_clear:function(){var u=this._redrawBounds;if(u){var v=u.getSize();this._ctx.clearRect(u.min.x,u.min.y,v.x,v.y)}else this._ctx.save(),this._ctx.setTransform(1,0,0,1,0,0),this._ctx.clearRect(0,0,this._container.width,this._container.height),this._ctx.restore()},_draw:function(){var u,v=this._redrawBounds;if(this._ctx.save(),v){var E=v.getSize();this._ctx.beginPath(),this._ctx.rect(v.min.x,v.min.y,E.x,E.y),this._ctx.clip()}this._drawing=!0;for(var R=this._drawFirst;R;R=R.next)u=R.layer,(!v||u._pxBounds&&u._pxBounds.intersects(v))&&u._updatePath();this._drawing=!1,this._ctx.restore()},_updatePoly:function(u,v){if(this._drawing){var E,R,q,ne,Ee=u._parts,Ze=Ee.length,tt=this._ctx;if(Ze){for(tt.beginPath(),E=0;E<Ze;E++){for(R=0,q=Ee[E].length;R<q;R++)ne=Ee[E][R],tt[R?"lineTo":"moveTo"](ne.x,ne.y);v&&tt.closePath()}this._fillStroke(tt,u)}}},_updateCircle:function(u){if(!(!this._drawing||u._empty())){var v=u._point,E=this._ctx,R=Math.max(Math.round(u._radius),1),q=(Math.max(Math.round(u._radiusY),1)||R)/R;q!==1&&(E.save(),E.scale(1,q)),E.beginPath(),E.arc(v.x,v.y/q,R,0,Math.PI*2,!1),q!==1&&E.restore(),this._fillStroke(E,u)}},_fillStroke:function(u,v){var E=v.options;E.fill&&(u.globalAlpha=E.fillOpacity,u.fillStyle=E.fillColor||E.color,u.fill(E.fillRule||"evenodd")),E.stroke&&E.weight!==0&&(u.setLineDash&&u.setLineDash(v.options&&v.options._dashArray||[]),u.globalAlpha=E.opacity,u.lineWidth=E.weight,u.strokeStyle=E.color,u.lineCap=E.lineCap,u.lineJoin=E.lineJoin,u.stroke())},_onClick:function(u){for(var v=this._map.mouseEventToLayerPoint(u),E,R,q=this._drawFirst;q;q=q.next)E=q.layer,E.options.interactive&&E._containsPoint(v)&&(!(u.type==="click"||u.type==="preclick")||!this._map._draggableMoved(E))&&(R=E);this._fireEvent(R?[R]:!1,u)},_onMouseMove:function(u){if(!(!this._map||this._map.dragging.moving()||this._map._animatingZoom)){var v=this._map.mouseEventToLayerPoint(u);this._handleMouseHover(u,v)}},_handleMouseOut:function(u){var v=this._hoveredLayer;v&&(Sr(this._container,"leaflet-interactive"),this._fireEvent([v],u,"mouseout"),this._hoveredLayer=null,this._mouseHoverThrottled=!1)},_handleMouseHover:function(u,v){if(!this._mouseHoverThrottled){for(var E,R,q=this._drawFirst;q;q=q.next)E=q.layer,E.options.interactive&&E._containsPoint(v)&&(R=E);R!==this._hoveredLayer&&(this._handleMouseOut(u),R&&(_i(this._container,"leaflet-interactive"),this._fireEvent([R],u,"mouseover"),this._hoveredLayer=R)),this._fireEvent(this._hoveredLayer?[this._hoveredLayer]:!1,u),this._mouseHoverThrottled=!0,setTimeout(W(function(){this._mouseHoverThrottled=!1},this),32)}},_fireEvent:function(u,v,E){this._map._fireDOMEvent(v,E||v.type,u)},_bringToFront:function(u){var v=u._order;if(v){var E=v.next,R=v.prev;if(E)E.prev=R;else return;R?R.next=E:E&&(this._drawFirst=E),v.prev=this._drawLast,this._drawLast.next=v,v.next=null,this._drawLast=v,this._requestRedraw(u)}},_bringToBack:function(u){var v=u._order;if(v){var E=v.next,R=v.prev;if(R)R.next=E;else return;E?E.prev=R:R&&(this._drawLast=R),v.prev=null,v.next=this._drawFirst,this._drawFirst.prev=v,this._drawFirst=v,this._requestRedraw(u)}}});function Oa(u){return o.canvas?new ya(u):null}var va=(function(){try{return document.namespaces.add("lvml","urn:schemas-microsoft-com:vml"),function(u){return document.createElement("<lvml:"+u+' class="lvml">')}}catch{}return function(u){return document.createElement("<"+u+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}})(),xa={_initContainer:function(){this._container=Fi("div","leaflet-vml-container")},_update:function(){this._map._animatingZoom||(es.prototype._update.call(this),this.fire("update"))},_initPath:function(u){var v=u._container=va("shape");_i(v,"leaflet-vml-shape "+(this.options.className||"")),v.coordsize="1 1",u._path=va("path"),v.appendChild(u._path),this._updateStyle(u),this._layers[it(u)]=u},_addPath:function(u){var v=u._container;this._container.appendChild(v),u.options.interactive&&u.addInteractiveTarget(v)},_removePath:function(u){var v=u._container;Xi(v),u.removeInteractiveTarget(v),delete this._layers[it(u)]},_updateStyle:function(u){var v=u._stroke,E=u._fill,R=u.options,q=u._container;q.stroked=!!R.stroke,q.filled=!!R.fill,R.stroke?(v||(v=u._stroke=va("stroke")),q.appendChild(v),v.weight=R.weight+"px",v.color=R.color,v.opacity=R.opacity,R.dashArray?v.dashStyle=zi(R.dashArray)?R.dashArray.join(" "):R.dashArray.replace(/( *, *)/g," "):v.dashStyle="",v.endcap=R.lineCap.replace("butt","flat"),v.joinstyle=R.lineJoin):v&&(q.removeChild(v),u._stroke=null),R.fill?(E||(E=u._fill=va("fill")),q.appendChild(E),E.color=R.fillColor||R.color,E.opacity=R.fillOpacity):E&&(q.removeChild(E),u._fill=null)},_updateCircle:function(u){var v=u._point.round(),E=Math.round(u._radius),R=Math.round(u._radiusY||E);this._setPath(u,u._empty()?"M0 0":"AL "+v.x+","+v.y+" "+E+","+R+" 0,"+65535*360)},_setPath:function(u,v){u._path.v=v},_bringToFront:function(u){tr(u._container)},_bringToBack:function(u){Go(u._container)}},co=o.vml?va:hs,ba=es.extend({_initContainer:function(){this._container=co("svg"),this._container.setAttribute("pointer-events","none"),this._rootGroup=co("g"),this._container.appendChild(this._rootGroup)},_destroyContainer:function(){Xi(this._container),Dt(this._container),delete this._container,delete this._rootGroup,delete this._svgSize},_update:function(){if(!(this._map._animatingZoom&&this._bounds)){es.prototype._update.call(this);var u=this._bounds,v=u.getSize(),E=this._container;(!this._svgSize||!this._svgSize.equals(v))&&(this._svgSize=v,E.setAttribute("width",v.x),E.setAttribute("height",v.y)),Cr(E,u.min),E.setAttribute("viewBox",[u.min.x,u.min.y,v.x,v.y].join(" ")),this.fire("update")}},_initPath:function(u){var v=u._path=co("path");u.options.className&&_i(v,u.options.className),u.options.interactive&&_i(v,"leaflet-interactive"),this._updateStyle(u),this._layers[it(u)]=u},_addPath:function(u){this._rootGroup||this._initContainer(),this._rootGroup.appendChild(u._path),u.addInteractiveTarget(u._path)},_removePath:function(u){Xi(u._path),u.removeInteractiveTarget(u._path),delete this._layers[it(u)]},_updatePath:function(u){u._project(),u._update()},_updateStyle:function(u){var v=u._path,E=u.options;v&&(E.stroke?(v.setAttribute("stroke",E.color),v.setAttribute("stroke-opacity",E.opacity),v.setAttribute("stroke-width",E.weight),v.setAttribute("stroke-linecap",E.lineCap),v.setAttribute("stroke-linejoin",E.lineJoin),E.dashArray?v.setAttribute("stroke-dasharray",E.dashArray):v.removeAttribute("stroke-dasharray"),E.dashOffset?v.setAttribute("stroke-dashoffset",E.dashOffset):v.removeAttribute("stroke-dashoffset")):v.setAttribute("stroke","none"),E.fill?(v.setAttribute("fill",E.fillColor||E.color),v.setAttribute("fill-opacity",E.fillOpacity),v.setAttribute("fill-rule",E.fillRule||"evenodd")):v.setAttribute("fill","none"))},_updatePoly:function(u,v){this._setPath(u,Is(u._parts,v))},_updateCircle:function(u){var v=u._point,E=Math.max(Math.round(u._radius),1),R=Math.max(Math.round(u._radiusY),1)||E,q="a"+E+","+R+" 0 1,0 ",ne=u._empty()?"M0 0":"M"+(v.x-E)+","+v.y+q+E*2+",0 "+q+-E*2+",0 ";this._setPath(u,ne)},_setPath:function(u,v){u._path.setAttribute("d",v)},_bringToFront:function(u){tr(u._path)},_bringToBack:function(u){Go(u._path)}});o.vml&&ba.include(xa);function nl(u){return o.svg||o.vml?new ba(u):null}hi.include({getRenderer:function(u){var v=u.options.renderer||this._getPaneRenderer(u.options.pane)||this.options.renderer||this._renderer;return v||(v=this._renderer=this._createRenderer()),this.hasLayer(v)||this.addLayer(v),v},_getPaneRenderer:function(u){if(u==="overlayPane"||u===void 0)return!1;var v=this._paneRenderers[u];return v===void 0&&(v=this._createRenderer({pane:u}),this._paneRenderers[u]=v),v},_createRenderer:function(u){return this.options.preferCanvas&&Oa(u)||nl(u)}});var gi=yn.extend({initialize:function(u,v){yn.prototype.initialize.call(this,this._boundsToLatLngs(u),v)},setBounds:function(u){return this.setLatLngs(this._boundsToLatLngs(u))},_boundsToLatLngs:function(u){return u=or(u),[u.getSouthWest(),u.getNorthWest(),u.getNorthEast(),u.getSouthEast()]}});function sl(u,v){return new gi(u,v)}ba.create=co,ba.pointsToPath=Is,As.geometryToLayer=Ba,As.coordsToLatLng=Fn,As.coordsToLatLngs=ho,As.latLngToCoords=$s,As.latLngsToCoords=xs,As.getFeature=fs,As.asFeature=Yo,hi.mergeOptions({boxZoom:!0});var El=Bn.extend({initialize:function(u){this._map=u,this._container=u._container,this._pane=u._panes.overlayPane,this._resetStateTimeout=0,u.on("unload",this._destroy,this)},addHooks:function(){Ht(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){Dt(this._container,"mousedown",this._onMouseDown,this)},moved:function(){return this._moved},_destroy:function(){Xi(this._pane),delete this._pane},_resetState:function(){this._resetStateTimeout=0,this._moved=!1},_clearDeferredResetState:function(){this._resetStateTimeout!==0&&(clearTimeout(this._resetStateTimeout),this._resetStateTimeout=0)},_onMouseDown:function(u){if(!u.shiftKey||u.which!==1&&u.button!==1)return!1;this._clearDeferredResetState(),this._resetState(),so(),Ca(),this._startPoint=this._map.mouseEventToContainerPoint(u),Ht(document,{contextmenu:$n,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseMove:function(u){this._moved||(this._moved=!0,this._box=Fi("div","leaflet-zoom-box",this._container),_i(this._container,"leaflet-crosshair"),this._map.fire("boxzoomstart")),this._point=this._map.mouseEventToContainerPoint(u);var v=new Ni(this._point,this._startPoint),E=v.getSize();Cr(this._box,v.min),this._box.style.width=E.x+"px",this._box.style.height=E.y+"px"},_finish:function(){this._moved&&(Xi(this._box),Sr(this._container,"leaflet-crosshair")),js(),qo(),Dt(document,{contextmenu:$n,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseUp:function(u){if(!(u.which!==1&&u.button!==1)&&(this._finish(),!!this._moved)){this._clearDeferredResetState(),this._resetStateTimeout=setTimeout(W(this._resetState,this),0);var v=new Wr(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point));this._map.fitBounds(v).fire("boxzoomend",{boxZoomBounds:v})}},_onKeyDown:function(u){u.keyCode===27&&(this._finish(),this._clearDeferredResetState(),this._resetState())}});hi.addInitHook("addHandler","boxZoom",El),hi.mergeOptions({doubleClickZoom:!0});var Fs=Bn.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick,this)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick,this)},_onDoubleClick:function(u){var v=this._map,E=v.getZoom(),R=v.options.zoomDelta,q=u.originalEvent.shiftKey?E-R:E+R;v.options.doubleClickZoom==="center"?v.setZoom(q):v.setZoomAround(u.containerPoint,q)}});hi.addInitHook("addHandler","doubleClickZoom",Fs),hi.mergeOptions({dragging:!0,inertia:!0,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,easeLinearity:.2,worldCopyJump:!1,maxBoundsViscosity:0});var Jo=Bn.extend({addHooks:function(){if(!this._draggable){var u=this._map;this._draggable=new xr(u._mapPane,u._container),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),this._draggable.on("predrag",this._onPreDragLimit,this),u.options.worldCopyJump&&(this._draggable.on("predrag",this._onPreDragWrap,this),u.on("zoomend",this._onZoomEnd,this),u.whenReady(this._onZoomEnd,this))}_i(this._map._container,"leaflet-grab leaflet-touch-drag"),this._draggable.enable(),this._positions=[],this._times=[]},removeHooks:function(){Sr(this._map._container,"leaflet-grab"),Sr(this._map._container,"leaflet-touch-drag"),this._draggable.disable()},moved:function(){return this._draggable&&this._draggable._moved},moving:function(){return this._draggable&&this._draggable._moving},_onDragStart:function(){var u=this._map;if(u._stop(),this._map.options.maxBounds&&this._map.options.maxBoundsViscosity){var v=or(this._map.options.maxBounds);this._offsetLimit=Mr(this._map.latLngToContainerPoint(v.getNorthWest()).multiplyBy(-1),this._map.latLngToContainerPoint(v.getSouthEast()).multiplyBy(-1).add(this._map.getSize())),this._viscosity=Math.min(1,Math.max(0,this._map.options.maxBoundsViscosity))}else this._offsetLimit=null;u.fire("movestart").fire("dragstart"),u.options.inertia&&(this._positions=[],this._times=[])},_onDrag:function(u){if(this._map.options.inertia){var v=this._lastTime=+new Date,E=this._lastPos=this._draggable._absPos||this._draggable._newPos;this._positions.push(E),this._times.push(v),this._prunePositions(v)}this._map.fire("move",u).fire("drag",u)},_prunePositions:function(u){for(;this._positions.length>1&&u-this._times[0]>50;)this._positions.shift(),this._times.shift()},_onZoomEnd:function(){var u=this._map.getSize().divideBy(2),v=this._map.latLngToLayerPoint([0,0]);this._initialWorldOffset=v.subtract(u).x,this._worldWidth=this._map.getPixelWorldBounds().getSize().x},_viscousLimit:function(u,v){return u-(u-v)*this._viscosity},_onPreDragLimit:function(){if(!(!this._viscosity||!this._offsetLimit)){var u=this._draggable._newPos.subtract(this._draggable._startPos),v=this._offsetLimit;u.x<v.min.x&&(u.x=this._viscousLimit(u.x,v.min.x)),u.y<v.min.y&&(u.y=this._viscousLimit(u.y,v.min.y)),u.x>v.max.x&&(u.x=this._viscousLimit(u.x,v.max.x)),u.y>v.max.y&&(u.y=this._viscousLimit(u.y,v.max.y)),this._draggable._newPos=this._draggable._startPos.add(u)}},_onPreDragWrap:function(){var u=this._worldWidth,v=Math.round(u/2),E=this._initialWorldOffset,R=this._draggable._newPos.x,q=(R-v+E)%u+v-E,ne=(R+v+E)%u-v-E,Ee=Math.abs(q+E)<Math.abs(ne+E)?q:ne;this._draggable._absPos=this._draggable._newPos.clone(),this._draggable._newPos.x=Ee},_onDragEnd:function(u){var v=this._map,E=v.options,R=!E.inertia||u.noInertia||this._times.length<2;if(v.fire("dragend",u),R)v.fire("moveend");else{this._prunePositions(+new Date);var q=this._lastPos.subtract(this._positions[0]),ne=(this._lastTime-this._times[0])/1e3,Ee=E.easeLinearity,Ze=q.multiplyBy(Ee/ne),tt=Ze.distanceTo([0,0]),gt=Math.min(E.inertiaMaxSpeed,tt),Rt=Ze.multiplyBy(gt/tt),Jt=gt/(E.inertiaDeceleration*Ee),Ti=Rt.multiplyBy(-Jt/2).round();!Ti.x&&!Ti.y?v.fire("moveend"):(Ti=v._limitOffset(Ti,v.options.maxBounds),cr(function(){v.panBy(Ti,{duration:Jt,easeLinearity:Ee,noMoveStart:!0,animate:!0})}))}}});hi.addInitHook("addHandler","dragging",Jo),hi.mergeOptions({keyboard:!0,keyboardPanDelta:80});var Hl=Bn.extend({keyCodes:{left:[37],right:[39],down:[40],up:[38],zoomIn:[187,107,61,171],zoomOut:[189,109,54,173]},initialize:function(u){this._map=u,this._setPanDelta(u.options.keyboardPanDelta),this._setZoomDelta(u.options.zoomDelta)},addHooks:function(){var u=this._map._container;u.tabIndex<=0&&(u.tabIndex="0"),Ht(u,{focus:this._onFocus,blur:this._onBlur,mousedown:this._onMouseDown},this),this._map.on({focus:this._addHooks,blur:this._removeHooks},this)},removeHooks:function(){this._removeHooks(),Dt(this._map._container,{focus:this._onFocus,blur:this._onBlur,mousedown:this._onMouseDown},this),this._map.off({focus:this._addHooks,blur:this._removeHooks},this)},_onMouseDown:function(){if(!this._focused){var u=document.body,v=document.documentElement,E=u.scrollTop||v.scrollTop,R=u.scrollLeft||v.scrollLeft;this._map._container.focus(),window.scrollTo(R,E)}},_onFocus:function(){this._focused=!0,this._map.fire("focus")},_onBlur:function(){this._focused=!1,this._map.fire("blur")},_setPanDelta:function(u){var v=this._panKeys={},E=this.keyCodes,R,q;for(R=0,q=E.left.length;R<q;R++)v[E.left[R]]=[-1*u,0];for(R=0,q=E.right.length;R<q;R++)v[E.right[R]]=[u,0];for(R=0,q=E.down.length;R<q;R++)v[E.down[R]]=[0,u];for(R=0,q=E.up.length;R<q;R++)v[E.up[R]]=[0,-1*u]},_setZoomDelta:function(u){var v=this._zoomKeys={},E=this.keyCodes,R,q;for(R=0,q=E.zoomIn.length;R<q;R++)v[E.zoomIn[R]]=u;for(R=0,q=E.zoomOut.length;R<q;R++)v[E.zoomOut[R]]=-u},_addHooks:function(){Ht(document,"keydown",this._onKeyDown,this)},_removeHooks:function(){Dt(document,"keydown",this._onKeyDown,this)},_onKeyDown:function(u){if(!(u.altKey||u.ctrlKey||u.metaKey)){var v=u.keyCode,E=this._map,R;if(v in this._panKeys){if(!E._panAnim||!E._panAnim._inProgress)if(R=this._panKeys[v],u.shiftKey&&(R=Yt(R).multiplyBy(3)),E.options.maxBounds&&(R=E._limitOffset(Yt(R),E.options.maxBounds)),E.options.worldCopyJump){var q=E.wrapLatLng(E.unproject(E.project(E.getCenter()).add(R)));E.panTo(q)}else E.panBy(R)}else if(v in this._zoomKeys)E.setZoom(E.getZoom()+(u.shiftKey?3:1)*this._zoomKeys[v]);else if(v===27&&E._popup&&E._popup.options.closeOnEscapeKey)E.closePopup();else return;$n(u)}}});hi.addInitHook("addHandler","keyboard",Hl),hi.mergeOptions({scrollWheelZoom:!0,wheelDebounceTime:40,wheelPxPerZoomLevel:60});var Wl=Bn.extend({addHooks:function(){Ht(this._map._container,"wheel",this._onWheelScroll,this),this._delta=0},removeHooks:function(){Dt(this._map._container,"wheel",this._onWheelScroll,this)},_onWheelScroll:function(u){var v=Po(u),E=this._map.options.wheelDebounceTime;this._delta+=v,this._lastMousePos=this._map.mouseEventToContainerPoint(u),this._startTime||(this._startTime=+new Date);var R=Math.max(E-(+new Date-this._startTime),0);clearTimeout(this._timer),this._timer=setTimeout(W(this._performZoom,this),R),$n(u)},_performZoom:function(){var u=this._map,v=u.getZoom(),E=this._map.options.zoomSnap||0;u._stop();var R=this._delta/(this._map.options.wheelPxPerZoomLevel*4),q=4*Math.log(2/(1+Math.exp(-Math.abs(R))))/Math.LN2,ne=E?Math.ceil(q/E)*E:q,Ee=u._limitZoom(v+(this._delta>0?ne:-ne))-v;this._delta=0,this._startTime=null,Ee&&(u.options.scrollWheelZoom==="center"?u.setZoom(v+Ee):u.setZoomAround(this._lastMousePos,v+Ee))}});hi.addInitHook("addHandler","scrollWheelZoom",Wl);var Ql=600;hi.mergeOptions({tapHold:o.touchNative&&o.safari&&o.mobile,tapTolerance:15});var $l=Bn.extend({addHooks:function(){Ht(this._map._container,"touchstart",this._onDown,this)},removeHooks:function(){Dt(this._map._container,"touchstart",this._onDown,this)},_onDown:function(u){if(clearTimeout(this._holdTimeout),u.touches.length===1){var v=u.touches[0];this._startPos=this._newPos=new ti(v.clientX,v.clientY),this._holdTimeout=setTimeout(W(function(){this._cancel(),this._isTapValid()&&(Ht(document,"touchend",Si),Ht(document,"touchend touchcancel",this._cancelClickPrevent),this._simulateEvent("contextmenu",v))},this),Ql),Ht(document,"touchend touchcancel contextmenu",this._cancel,this),Ht(document,"touchmove",this._onMove,this)}},_cancelClickPrevent:function u(){Dt(document,"touchend",Si),Dt(document,"touchend touchcancel",u)},_cancel:function(){clearTimeout(this._holdTimeout),Dt(document,"touchend touchcancel contextmenu",this._cancel,this),Dt(document,"touchmove",this._onMove,this)},_onMove:function(u){var v=u.touches[0];this._newPos=new ti(v.clientX,v.clientY)},_isTapValid:function(){return this._newPos.distanceTo(this._startPos)<=this._map.options.tapTolerance},_simulateEvent:function(u,v){var E=new MouseEvent(u,{bubbles:!0,cancelable:!0,view:window,screenX:v.screenX,screenY:v.screenY,clientX:v.clientX,clientY:v.clientY});E._simulated=!0,v.target.dispatchEvent(E)}});hi.addInitHook("addHandler","tapHold",$l),hi.mergeOptions({touchZoom:o.touch,bounceAtZoomLimits:!0});var ol=Bn.extend({addHooks:function(){_i(this._map._container,"leaflet-touch-zoom"),Ht(this._map._container,"touchstart",this._onTouchStart,this)},removeHooks:function(){Sr(this._map._container,"leaflet-touch-zoom"),Dt(this._map._container,"touchstart",this._onTouchStart,this)},_onTouchStart:function(u){var v=this._map;if(!(!u.touches||u.touches.length!==2||v._animatingZoom||this._zooming)){var E=v.mouseEventToContainerPoint(u.touches[0]),R=v.mouseEventToContainerPoint(u.touches[1]);this._centerPoint=v.getSize()._divideBy(2),this._startLatLng=v.containerPointToLatLng(this._centerPoint),v.options.touchZoom!=="center"&&(this._pinchStartLatLng=v.containerPointToLatLng(E.add(R)._divideBy(2))),this._startDist=E.distanceTo(R),this._startZoom=v.getZoom(),this._moved=!1,this._zooming=!0,v._stop(),Ht(document,"touchmove",this._onTouchMove,this),Ht(document,"touchend touchcancel",this._onTouchEnd,this),Si(u)}},_onTouchMove:function(u){if(!(!u.touches||u.touches.length!==2||!this._zooming)){var v=this._map,E=v.mouseEventToContainerPoint(u.touches[0]),R=v.mouseEventToContainerPoint(u.touches[1]),q=E.distanceTo(R)/this._startDist;if(this._zoom=v.getScaleZoom(q,this._startZoom),!v.options.bounceAtZoomLimits&&(this._zoom<v.getMinZoom()&&q<1||this._zoom>v.getMaxZoom()&&q>1)&&(this._zoom=v._limitZoom(this._zoom)),v.options.touchZoom==="center"){if(this._center=this._startLatLng,q===1)return}else{var ne=E._add(R)._divideBy(2)._subtract(this._centerPoint);if(q===1&&ne.x===0&&ne.y===0)return;this._center=v.unproject(v.project(this._pinchStartLatLng,this._zoom).subtract(ne),this._zoom)}this._moved||(v._moveStart(!0,!1),this._moved=!0),Ji(this._animRequest);var Ee=W(v._move,v,this._center,this._zoom,{pinch:!0,round:!1},void 0);this._animRequest=cr(Ee,this,!0),Si(u)}},_onTouchEnd:function(){if(!this._moved||!this._zooming){this._zooming=!1;return}this._zooming=!1,Ji(this._animRequest),Dt(document,"touchmove",this._onTouchMove,this),Dt(document,"touchend touchcancel",this._onTouchEnd,this),this._map.options.zoomAnimation?this._map._animateZoom(this._center,this._map._limitZoom(this._zoom),!0,this._map.options.zoomSnap):this._map._resetView(this._center,this._map._limitZoom(this._zoom))}});hi.addInitHook("addHandler","touchZoom",ol),hi.BoxZoom=El,hi.DoubleClickZoom=Fs,hi.Drag=Jo,hi.Keyboard=Hl,hi.ScrollWheelZoom=Wl,hi.TapHold=$l,hi.TouchZoom=ol,fe.Bounds=Ni,fe.Browser=o,fe.CRS=hn,fe.Canvas=ya,fe.Circle=ma,fe.CircleMarker=uo,fe.Class=Cn,fe.Control=nn,fe.DivIcon=_a,fe.DivOverlay=sn,fe.DomEvent=Vl,fe.DomUtil=Wn,fe.Draggable=xr,fe.Evented=Hr,fe.FeatureGroup=cs,fe.GeoJSON=As,fe.GridLayer=fn,fe.Handler=Bn,fe.Icon=Hs,fe.ImageOverlay=Ra,fe.LatLng=xi,fe.LatLngBounds=Wr,fe.Layer=Rn,fe.LayerGroup=$o,fe.LineUtil=Eo,fe.Map=hi,fe.Marker=Qs,fe.Mixin=Wo,fe.Path=Bs,fe.Point=ti,fe.PolyUtil=yl,fe.Polygon=yn,fe.Polyline=Ir,fe.Popup=$r,fe.PosAnimation=Qr,fe.Projection=hu,fe.Rectangle=gi,fe.Renderer=es,fe.SVG=ba,fe.SVGOverlay=tl,fe.TileLayer=Ko,fe.Tooltip=Xs,fe.Transformation=No,fe.Util=Sn,fe.VideoOverlay=el,fe.bind=W,fe.bounds=Mr,fe.canvas=Oa,fe.circle=cu,fe.circleMarker=Ul,fe.control=wi,fe.divIcon=ga,fe.extend=We,fe.featureGroup=wl,fe.geoJSON=Ja,fe.geoJson=Pl,fe.gridLayer=ql,fe.icon=Xa,fe.imageOverlay=Au,fe.latLng=Ai,fe.latLngBounds=or,fe.layerGroup=Zl,fe.map=bi,fe.marker=Tl,fe.point=Yt,fe.polygon=Gl,fe.polyline=Ka,fe.popup=il,fe.rectangle=sl,fe.setOptions=Gt,fe.stamp=it,fe.svg=nl,fe.svgOverlay=Ii,fe.tileLayer=rl,fe.tooltip=Xo,fe.transformation=In,fe.version=Re,fe.videoOverlay=Ml;var ds=window.L;fe.noConflict=function(){return window.L=ds,this},window.L=fe}))})(Zh,Zh.exports)),Zh.exports}var ep=Wm();const Qm=Jd(ep),Pg=Kd({__proto__:null,default:Qm},[ep]);var et=(function(xe){xe=xe||{};var J=typeof xe<"u"?xe:{},fe={},Re;for(Re in J)J.hasOwnProperty(Re)&&(fe[Re]=J[Re]);var We="";function ct(Ve){return J.locateFile?J.locateFile(Ve,We):We+Ve}var W;typeof document<"u"&&document.currentScript&&(We=document.currentScript.src),We.indexOf("blob:")!==0?We=We.substr(0,We.lastIndexOf("/")+1):We="",W=function(at,It,At){var o=new XMLHttpRequest;o.open("GET",at,!0),o.responseType="arraybuffer",o.onload=function(){if(o.status==200||o.status==0&&o.response){It(o.response);return}var ii=ft(at);if(ii){It(ii.buffer);return}At()},o.onerror=At,o.send(null)};var p=J.print||console.log.bind(console),it=J.printErr||console.warn.bind(console);for(Re in fe)fe.hasOwnProperty(Re)&&(J[Re]=fe[Re]);fe=null,J.arguments&&J.arguments;var ur=0,fr=function(Ve){ur=Ve},Zi=function(){return ur},un=8;function zr(Ve,at,It,At){switch(It=It||"i8",It.charAt(It.length-1)==="*"&&(It="i32"),It){case"i1":Ji[Ve>>0]=at;break;case"i8":Ji[Ve>>0]=at;break;case"i16":Cn[Ve>>1]=at;break;case"i32":Un[Ve>>2]=at;break;case"i64":mn=[at>>>0,(Ds=at,+Vo(Ds)>=1?Ds>0?(Is(+hs(Ds/4294967296),4294967295)|0)>>>0:~~+en((Ds-+(~~Ds>>>0))/4294967296)>>>0:0)],Un[Ve>>2]=mn[0],Un[Ve+4>>2]=mn[1];break;case"float":Jr[Ve>>2]=at;break;case"double":Hr[Ve>>3]=at;break;default:er("invalid type for setValue: "+It)}}function Mn(Ve,at,It){switch(at=at||"i8",at.charAt(at.length-1)==="*"&&(at="i32"),at){case"i1":return Ji[Ve>>0];case"i8":return Ji[Ve>>0];case"i16":return Cn[Ve>>1];case"i32":return Un[Ve>>2];case"i64":return Un[Ve>>2];case"float":return Jr[Ve>>2];case"double":return Hr[Ve>>3];default:er("invalid type for getValue: "+at)}return null}var Gt=!1;function rt(Ve,at){Ve||er("Assertion failed: "+at)}function Fo(Ve){var at=J["_"+Ve];return rt(at,"Cannot call unknown function "+Ve+", make sure it is exported"),at}function hr(Ve,at,It,At,o){var X={string:function(di){var jr=0;if(di!=null&&di!==0){var ni=(di.length<<2)+1;jr=Gi(ni),Oo(di,jr,ni)}return jr},array:function(di){var jr=Gi(di.length);return Vs(di,jr),jr}};function ii(di){return at==="string"?Ns(di):at==="boolean"?!!di:di}var Ri=Fo(Ve),Qi=[],ut=0;if(At)for(var zt=0;zt<At.length;zt++){var $t=X[It[zt]];$t?(ut===0&&(ut=qe()),Qi[zt]=$t(At[zt])):Qi[zt]=At[zt]}var fi=Ri.apply(null,Qi);return fi=ii(fi),ut!==0&&Bi(ut),fi}function zi(Ve,at,It,At){It=It||[];var o=It.every(function(ii){return ii==="number"}),X=at!=="string";return X&&o&&!At?Fo(Ve):function(){return hr(Ve,at,It,arguments)}}var ro=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function no(Ve,at,It){for(var At=at+It,o=at;Ve[o]&&!(o>=At);)++o;if(o-at>16&&Ve.subarray&&ro)return ro.decode(Ve.subarray(at,o));for(var X="";at<o;){var ii=Ve[at++];if(!(ii&128)){X+=String.fromCharCode(ii);continue}var Ri=Ve[at++]&63;if((ii&224)==192){X+=String.fromCharCode((ii&31)<<6|Ri);continue}var Qi=Ve[at++]&63;if((ii&240)==224?ii=(ii&15)<<12|Ri<<6|Qi:ii=(ii&7)<<18|Ri<<12|Qi<<6|Ve[at++]&63,ii<65536)X+=String.fromCharCode(ii);else{var ut=ii-65536;X+=String.fromCharCode(55296|ut>>10,56320|ut&1023)}}return X}function Ns(Ve,at){return Ve?no(Sn,Ve,at):""}function En(Ve,at,It,At){if(!(At>0))return 0;for(var o=It,X=It+At-1,ii=0;ii<Ve.length;++ii){var Ri=Ve.charCodeAt(ii);if(Ri>=55296&&Ri<=57343){var Qi=Ve.charCodeAt(++ii);Ri=65536+((Ri&1023)<<10)|Qi&1023}if(Ri<=127){if(It>=X)break;at[It++]=Ri}else if(Ri<=2047){if(It+1>=X)break;at[It++]=192|Ri>>6,at[It++]=128|Ri&63}else if(Ri<=65535){if(It+2>=X)break;at[It++]=224|Ri>>12,at[It++]=128|Ri>>6&63,at[It++]=128|Ri&63}else{if(It+3>=X)break;at[It++]=240|Ri>>18,at[It++]=128|Ri>>12&63,at[It++]=128|Ri>>6&63,at[It++]=128|Ri&63}}return at[It]=0,It-o}function Oo(Ve,at,It){return En(Ve,Sn,at,It)}typeof TextDecoder<"u"&&new TextDecoder("utf-16le");function Vs(Ve,at){Ji.set(Ve,at)}function Cs(Ve,at){return Ve%at>0&&(Ve+=at-Ve%at),Ve}var cr,Ji,Sn,Cn,Un,Jr,Hr;function ti(Ve){cr=Ve,J.HEAP8=Ji=new Int8Array(Ve),J.HEAP16=Cn=new Int16Array(Ve),J.HEAP32=Un=new Int32Array(Ve),J.HEAPU8=Sn=new Uint8Array(Ve),J.HEAPU16=new Uint16Array(Ve),J.HEAPU32=new Uint32Array(Ve),J.HEAPF32=Jr=new Float32Array(Ve),J.HEAPF64=Hr=new Float64Array(Ve)}var Oi=5271536,Yt=28624,Ni=J.TOTAL_MEMORY||33554432;J.buffer?cr=J.buffer:cr=new ArrayBuffer(Ni),Ni=cr.byteLength,ti(cr),Un[Yt>>2]=Oi;function Mr(Ve){for(;Ve.length>0;){var at=Ve.shift();if(typeof at=="function"){at();continue}var It=at.func;typeof It=="number"?at.arg===void 0?J.dynCall_v(It):J.dynCall_vi(It,at.arg):It(at.arg===void 0?null:at.arg)}}var Wr=[],or=[],xi=[],Ai=[];function hn(){if(J.preRun)for(typeof J.preRun=="function"&&(J.preRun=[J.preRun]);J.preRun.length;)No(J.preRun.shift());Mr(Wr)}function Er(){Mr(or)}function yo(){Mr(xi)}function us(){if(J.postRun)for(typeof J.postRun=="function"&&(J.postRun=[J.postRun]);J.postRun.length;)In(J.postRun.shift());Mr(Ai)}function No(Ve){Wr.unshift(Ve)}function In(Ve){Ai.unshift(Ve)}var Vo=Math.abs,en=Math.ceil,hs=Math.floor,Is=Math.min,Ui=0,Dn=null;function jo(Ve){Ui++,J.monitorRunDependencies&&J.monitorRunDependencies(Ui)}function Zo(Ve){if(Ui--,J.monitorRunDependencies&&J.monitorRunDependencies(Ui),Ui==0&&Dn){var at=Dn;Dn=null,at()}}J.preloadedImages={},J.preloadedAudios={};var tn=null,Gn="data:application/octet-stream;base64,";function vo(Ve){return String.prototype.startsWith?Ve.startsWith(Gn):Ve.indexOf(Gn)===0}var Ds,mn;tn="data:application/octet-stream;base64,AAAAAAAAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAGAAAAAQAAAAQAAAADAAAABgAAAAUAAAACAAAAAAAAAAIAAAADAAAAAQAAAAQAAAAGAAAAAAAAAAUAAAADAAAABgAAAAQAAAAFAAAAAAAAAAEAAAACAAAABAAAAAUAAAAGAAAAAAAAAAIAAAADAAAAAQAAAAUAAAACAAAAAAAAAAEAAAADAAAABgAAAAQAAAAGAAAAAAAAAAUAAAACAAAAAQAAAAQAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAIAAAADAAAAAAAAAAAAAAACAAAAAAAAAAEAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAYAAAAAAAAABQAAAAAAAAAAAAAABAAAAAUAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAYAAAAAAAAABgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAIAAAAAAAAAAAAAAAYAAAAAAAAAAwAAAAIAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAFAAAABAAAAAAAAAABAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAYAAAAAAAAABAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAFAAAAAgAAAAQAAAADAAAACAAAAAEAAAAHAAAABgAAAAkAAAAAAAAAAwAAAAIAAAACAAAABgAAAAoAAAALAAAAAAAAAAEAAAAFAAAAAwAAAA0AAAABAAAABwAAAAQAAAAMAAAAAAAAAAQAAAB/AAAADwAAAAgAAAADAAAAAAAAAAwAAAAFAAAAAgAAABIAAAAKAAAACAAAAAAAAAAQAAAABgAAAA4AAAALAAAAEQAAAAEAAAAJAAAAAgAAAAcAAAAVAAAACQAAABMAAAADAAAADQAAAAEAAAAIAAAABQAAABYAAAAQAAAABAAAAAAAAAAPAAAACQAAABMAAAAOAAAAFAAAAAEAAAAHAAAABgAAAAoAAAALAAAAGAAAABcAAAAFAAAAAgAAABIAAAALAAAAEQAAABcAAAAZAAAAAgAAAAYAAAAKAAAADAAAABwAAAANAAAAGgAAAAQAAAAPAAAAAwAAAA0AAAAaAAAAFQAAAB0AAAADAAAADAAAAAcAAAAOAAAAfwAAABEAAAAbAAAACQAAABQAAAAGAAAADwAAABYAAAAcAAAAHwAAAAQAAAAIAAAADAAAABAAAAASAAAAIQAAAB4AAAAIAAAABQAAABYAAAARAAAACwAAAA4AAAAGAAAAIwAAABkAAAAbAAAAEgAAABgAAAAeAAAAIAAAAAUAAAAKAAAAEAAAABMAAAAiAAAAFAAAACQAAAAHAAAAFQAAAAkAAAAUAAAADgAAABMAAAAJAAAAKAAAABsAAAAkAAAAFQAAACYAAAATAAAAIgAAAA0AAAAdAAAABwAAABYAAAAQAAAAKQAAACEAAAAPAAAACAAAAB8AAAAXAAAAGAAAAAsAAAAKAAAAJwAAACUAAAAZAAAAGAAAAH8AAAAgAAAAJQAAAAoAAAAXAAAAEgAAABkAAAAXAAAAEQAAAAsAAAAtAAAAJwAAACMAAAAaAAAAKgAAAB0AAAArAAAADAAAABwAAAANAAAAGwAAACgAAAAjAAAALgAAAA4AAAAUAAAAEQAAABwAAAAfAAAAKgAAACwAAAAMAAAADwAAABoAAAAdAAAAKwAAACYAAAAvAAAADQAAABoAAAAVAAAAHgAAACAAAAAwAAAAMgAAABAAAAASAAAAIQAAAB8AAAApAAAALAAAADUAAAAPAAAAFgAAABwAAAAgAAAAHgAAABgAAAASAAAANAAAADIAAAAlAAAAIQAAAB4AAAAxAAAAMAAAABYAAAAQAAAAKQAAACIAAAATAAAAJgAAABUAAAA2AAAAJAAAADMAAAAjAAAALgAAAC0AAAA4AAAAEQAAABsAAAAZAAAAJAAAABQAAAAiAAAAEwAAADcAAAAoAAAANgAAACUAAAAnAAAANAAAADkAAAAYAAAAFwAAACAAAAAmAAAAfwAAACIAAAAzAAAAHQAAAC8AAAAVAAAAJwAAACUAAAAZAAAAFwAAADsAAAA5AAAALQAAACgAAAAbAAAAJAAAABQAAAA8AAAALgAAADcAAAApAAAAMQAAADUAAAA9AAAAFgAAACEAAAAfAAAAKgAAADoAAAArAAAAPgAAABwAAAAsAAAAGgAAACsAAAA+AAAALwAAAEAAAAAaAAAAKgAAAB0AAAAsAAAANQAAADoAAABBAAAAHAAAAB8AAAAqAAAALQAAACcAAAAjAAAAGQAAAD8AAAA7AAAAOAAAAC4AAAA8AAAAOAAAAEQAAAAbAAAAKAAAACMAAAAvAAAAJgAAACsAAAAdAAAARQAAADMAAABAAAAAMAAAADEAAAAeAAAAIQAAAEMAAABCAAAAMgAAADEAAAB/AAAAPQAAAEIAAAAhAAAAMAAAACkAAAAyAAAAMAAAACAAAAAeAAAARgAAAEMAAAA0AAAAMwAAAEUAAAA2AAAARwAAACYAAAAvAAAAIgAAADQAAAA5AAAARgAAAEoAAAAgAAAAJQAAADIAAAA1AAAAPQAAAEEAAABLAAAAHwAAACkAAAAsAAAANgAAAEcAAAA3AAAASQAAACIAAAAzAAAAJAAAADcAAAAoAAAANgAAACQAAABIAAAAPAAAAEkAAAA4AAAARAAAAD8AAABNAAAAIwAAAC4AAAAtAAAAOQAAADsAAABKAAAATgAAACUAAAAnAAAANAAAADoAAAB/AAAAPgAAAEwAAAAsAAAAQQAAACoAAAA7AAAAPwAAAE4AAABPAAAAJwAAAC0AAAA5AAAAPAAAAEgAAABEAAAAUAAAACgAAAA3AAAALgAAAD0AAAA1AAAAMQAAACkAAABRAAAASwAAAEIAAAA+AAAAKwAAADoAAAAqAAAAUgAAAEAAAABMAAAAPwAAAH8AAAA4AAAALQAAAE8AAAA7AAAATQAAAEAAAAAvAAAAPgAAACsAAABUAAAARQAAAFIAAABBAAAAOgAAADUAAAAsAAAAVgAAAEwAAABLAAAAQgAAAEMAAABRAAAAVQAAADEAAAAwAAAAPQAAAEMAAABCAAAAMgAAADAAAABXAAAAVQAAAEYAAABEAAAAOAAAADwAAAAuAAAAWgAAAE0AAABQAAAARQAAADMAAABAAAAALwAAAFkAAABHAAAAVAAAAEYAAABDAAAANAAAADIAAABTAAAAVwAAAEoAAABHAAAAWQAAAEkAAABbAAAAMwAAAEUAAAA2AAAASAAAAH8AAABJAAAANwAAAFAAAAA8AAAAWAAAAEkAAABbAAAASAAAAFgAAAA2AAAARwAAADcAAABKAAAATgAAAFMAAABcAAAANAAAADkAAABGAAAASwAAAEEAAAA9AAAANQAAAF4AAABWAAAAUQAAAEwAAABWAAAAUgAAAGAAAAA6AAAAQQAAAD4AAABNAAAAPwAAAEQAAAA4AAAAXQAAAE8AAABaAAAATgAAAEoAAAA7AAAAOQAAAF8AAABcAAAATwAAAE8AAABOAAAAPwAAADsAAABdAAAAXwAAAE0AAABQAAAARAAAAEgAAAA8AAAAYwAAAFoAAABYAAAAUQAAAFUAAABeAAAAZQAAAD0AAABCAAAASwAAAFIAAABgAAAAVAAAAGIAAAA+AAAATAAAAEAAAABTAAAAfwAAAEoAAABGAAAAZAAAAFcAAABcAAAAVAAAAEUAAABSAAAAQAAAAGEAAABZAAAAYgAAAFUAAABXAAAAZQAAAGYAAABCAAAAQwAAAFEAAABWAAAATAAAAEsAAABBAAAAaAAAAGAAAABeAAAAVwAAAFMAAABmAAAAZAAAAEMAAABGAAAAVQAAAFgAAABIAAAAWwAAAEkAAABjAAAAUAAAAGkAAABZAAAAYQAAAFsAAABnAAAARQAAAFQAAABHAAAAWgAAAE0AAABQAAAARAAAAGoAAABdAAAAYwAAAFsAAABJAAAAWQAAAEcAAABpAAAAWAAAAGcAAABcAAAAUwAAAE4AAABKAAAAbAAAAGQAAABfAAAAXQAAAE8AAABaAAAATQAAAG0AAABfAAAAagAAAF4AAABWAAAAUQAAAEsAAABrAAAAaAAAAGUAAABfAAAAXAAAAE8AAABOAAAAbQAAAGwAAABdAAAAYAAAAGgAAABiAAAAbgAAAEwAAABWAAAAUgAAAGEAAAB/AAAAYgAAAFQAAABnAAAAWQAAAG8AAABiAAAAbgAAAGEAAABvAAAAUgAAAGAAAABUAAAAYwAAAFAAAABpAAAAWAAAAGoAAABaAAAAcQAAAGQAAABmAAAAUwAAAFcAAABsAAAAcgAAAFwAAABlAAAAZgAAAGsAAABwAAAAUQAAAFUAAABeAAAAZgAAAGUAAABXAAAAVQAAAHIAAABwAAAAZAAAAGcAAABbAAAAYQAAAFkAAAB0AAAAaQAAAG8AAABoAAAAawAAAG4AAABzAAAAVgAAAF4AAABgAAAAaQAAAFgAAABnAAAAWwAAAHEAAABjAAAAdAAAAGoAAABdAAAAYwAAAFoAAAB1AAAAbQAAAHEAAABrAAAAfwAAAGUAAABeAAAAcwAAAGgAAABwAAAAbAAAAGQAAABfAAAAXAAAAHYAAAByAAAAbQAAAG0AAABsAAAAXQAAAF8AAAB1AAAAdgAAAGoAAABuAAAAYgAAAGgAAABgAAAAdwAAAG8AAABzAAAAbwAAAGEAAABuAAAAYgAAAHQAAABnAAAAdwAAAHAAAABrAAAAZgAAAGUAAAB4AAAAcwAAAHIAAABxAAAAYwAAAHQAAABpAAAAdQAAAGoAAAB5AAAAcgAAAHAAAABkAAAAZgAAAHYAAAB4AAAAbAAAAHMAAABuAAAAawAAAGgAAAB4AAAAdwAAAHAAAAB0AAAAZwAAAHcAAABvAAAAcQAAAGkAAAB5AAAAdQAAAH8AAABtAAAAdgAAAHEAAAB5AAAAagAAAHYAAAB4AAAAbAAAAHIAAAB1AAAAeQAAAG0AAAB3AAAAbwAAAHMAAABuAAAAeQAAAHQAAAB4AAAAeAAAAHMAAAByAAAAcAAAAHkAAAB3AAAAdgAAAHkAAAB0AAAAeAAAAHcAAAB1AAAAcQAAAHYAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAACAAAABQAAAAEAAAAAAAAA/////wEAAAAAAAAAAwAAAAQAAAACAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAFAAAAAQAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAAAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAEAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAUAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAABAAAAAUAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAIAAAAFAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAFAAAAAAAAAAAAAAD/////AQAAAAAAAAADAAAABAAAAAIAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAUAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAEAAAD//////////wEAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAACAAAAAAAAAAAAAAABAAAAAgAAAAYAAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAKAAAAAgAAAAAAAAAAAAAAAQAAAAEAAAAFAAAABgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAACAAAAAAAAAAAAAAABAAAAAwAAAAcAAAAGAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAADgAAAAIAAAAAAAAAAAAAAAEAAAAAAAAACQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAIAAAAAAAAAAAAAAAEAAAAEAAAACAAAAAoAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAALAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAAAAAAAAAAAAQAAAAsAAAAPAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAIAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAgAAAAAAAAAAAAAAAQAAAAwAAAAQAAAADAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAPAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAADwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAACAAAAAAAAAAAAAAABAAAACgAAABMAAAAIAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAAAAAAAAAAAAAEAAAANAAAAEQAAAA0AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAARAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA0AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAACAAAAAAAAAAAAAAABAAAADgAAABIAAAAPAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAADwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAASAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABIAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAATAAAAAgAAAAAAAAAAAAAAAQAAAP//////////EwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAASAAAAAAAAABgAAAAAAAAAIQAAAAAAAAAeAAAAAAAAACAAAAADAAAAMQAAAAEAAAAwAAAAAwAAADIAAAADAAAACAAAAAAAAAAFAAAABQAAAAoAAAAFAAAAFgAAAAAAAAAQAAAAAAAAABIAAAAAAAAAKQAAAAEAAAAhAAAAAAAAAB4AAAAAAAAABAAAAAAAAAAAAAAABQAAAAIAAAAFAAAADwAAAAEAAAAIAAAAAAAAAAUAAAAFAAAAHwAAAAEAAAAWAAAAAAAAABAAAAAAAAAAAgAAAAAAAAAGAAAAAAAAAA4AAAAAAAAACgAAAAAAAAALAAAAAAAAABEAAAADAAAAGAAAAAEAAAAXAAAAAwAAABkAAAADAAAAAAAAAAAAAAABAAAABQAAAAkAAAAFAAAABQAAAAAAAAACAAAAAAAAAAYAAAAAAAAAEgAAAAEAAAAKAAAAAAAAAAsAAAAAAAAABAAAAAEAAAADAAAABQAAAAcAAAAFAAAACAAAAAEAAAAAAAAAAAAAAAEAAAAFAAAAEAAAAAEAAAAFAAAAAAAAAAIAAAAAAAAABwAAAAAAAAAVAAAAAAAAACYAAAAAAAAACQAAAAAAAAATAAAAAAAAACIAAAADAAAADgAAAAEAAAAUAAAAAwAAACQAAAADAAAAAwAAAAAAAAANAAAABQAAAB0AAAAFAAAAAQAAAAAAAAAHAAAAAAAAABUAAAAAAAAABgAAAAEAAAAJAAAAAAAAABMAAAAAAAAABAAAAAIAAAAMAAAABQAAABoAAAAFAAAAAAAAAAEAAAADAAAAAAAAAA0AAAAFAAAAAgAAAAEAAAABAAAAAAAAAAcAAAAAAAAAGgAAAAAAAAAqAAAAAAAAADoAAAAAAAAAHQAAAAAAAAArAAAAAAAAAD4AAAADAAAAJgAAAAEAAAAvAAAAAwAAAEAAAAADAAAADAAAAAAAAAAcAAAABQAAACwAAAAFAAAADQAAAAAAAAAaAAAAAAAAACoAAAAAAAAAFQAAAAEAAAAdAAAAAAAAACsAAAAAAAAABAAAAAMAAAAPAAAABQAAAB8AAAAFAAAAAwAAAAEAAAAMAAAAAAAAABwAAAAFAAAABwAAAAEAAAANAAAAAAAAABoAAAAAAAAAHwAAAAAAAAApAAAAAAAAADEAAAAAAAAALAAAAAAAAAA1AAAAAAAAAD0AAAADAAAAOgAAAAEAAABBAAAAAwAAAEsAAAADAAAADwAAAAAAAAAWAAAABQAAACEAAAAFAAAAHAAAAAAAAAAfAAAAAAAAACkAAAAAAAAAKgAAAAEAAAAsAAAAAAAAADUAAAAAAAAABAAAAAQAAAAIAAAABQAAABAAAAAFAAAADAAAAAEAAAAPAAAAAAAAABYAAAAFAAAAGgAAAAEAAAAcAAAAAAAAAB8AAAAAAAAAMgAAAAAAAAAwAAAAAAAAADEAAAADAAAAIAAAAAAAAAAeAAAAAwAAACEAAAADAAAAGAAAAAMAAAASAAAAAwAAABAAAAADAAAARgAAAAAAAABDAAAAAAAAAEIAAAADAAAANAAAAAMAAAAyAAAAAAAAADAAAAAAAAAAJQAAAAMAAAAgAAAAAAAAAB4AAAADAAAAUwAAAAAAAABXAAAAAwAAAFUAAAADAAAASgAAAAMAAABGAAAAAAAAAEMAAAAAAAAAOQAAAAEAAAA0AAAAAwAAADIAAAAAAAAAGQAAAAAAAAAXAAAAAAAAABgAAAADAAAAEQAAAAAAAAALAAAAAwAAAAoAAAADAAAADgAAAAMAAAAGAAAAAwAAAAIAAAADAAAALQAAAAAAAAAnAAAAAAAAACUAAAADAAAAIwAAAAMAAAAZAAAAAAAAABcAAAAAAAAAGwAAAAMAAAARAAAAAAAAAAsAAAADAAAAPwAAAAAAAAA7AAAAAwAAADkAAAADAAAAOAAAAAMAAAAtAAAAAAAAACcAAAAAAAAALgAAAAMAAAAjAAAAAwAAABkAAAAAAAAAJAAAAAAAAAAUAAAAAAAAAA4AAAADAAAAIgAAAAAAAAATAAAAAwAAAAkAAAADAAAAJgAAAAMAAAAVAAAAAwAAAAcAAAADAAAANwAAAAAAAAAoAAAAAAAAABsAAAADAAAANgAAAAMAAAAkAAAAAAAAABQAAAAAAAAAMwAAAAMAAAAiAAAAAAAAABMAAAADAAAASAAAAAAAAAA8AAAAAwAAAC4AAAADAAAASQAAAAMAAAA3AAAAAAAAACgAAAAAAAAARwAAAAMAAAA2AAAAAwAAACQAAAAAAAAAQAAAAAAAAAAvAAAAAAAAACYAAAADAAAAPgAAAAAAAAArAAAAAwAAAB0AAAADAAAAOgAAAAMAAAAqAAAAAwAAABoAAAADAAAAVAAAAAAAAABFAAAAAAAAADMAAAADAAAAUgAAAAMAAABAAAAAAAAAAC8AAAAAAAAATAAAAAMAAAA+AAAAAAAAACsAAAADAAAAYQAAAAAAAABZAAAAAwAAAEcAAAADAAAAYgAAAAMAAABUAAAAAAAAAEUAAAAAAAAAYAAAAAMAAABSAAAAAwAAAEAAAAAAAAAASwAAAAAAAABBAAAAAAAAADoAAAADAAAAPQAAAAAAAAA1AAAAAwAAACwAAAADAAAAMQAAAAMAAAApAAAAAwAAAB8AAAADAAAAXgAAAAAAAABWAAAAAAAAAEwAAAADAAAAUQAAAAMAAABLAAAAAAAAAEEAAAAAAAAAQgAAAAMAAAA9AAAAAAAAADUAAAADAAAAawAAAAAAAABoAAAAAwAAAGAAAAADAAAAZQAAAAMAAABeAAAAAAAAAFYAAAAAAAAAVQAAAAMAAABRAAAAAwAAAEsAAAAAAAAAOQAAAAAAAAA7AAAAAAAAAD8AAAADAAAASgAAAAAAAABOAAAAAwAAAE8AAAADAAAAUwAAAAMAAABcAAAAAwAAAF8AAAADAAAAJQAAAAAAAAAnAAAAAwAAAC0AAAADAAAANAAAAAAAAAA5AAAAAAAAADsAAAAAAAAARgAAAAMAAABKAAAAAAAAAE4AAAADAAAAGAAAAAAAAAAXAAAAAwAAABkAAAADAAAAIAAAAAMAAAAlAAAAAAAAACcAAAADAAAAMgAAAAMAAAA0AAAAAAAAADkAAAAAAAAALgAAAAAAAAA8AAAAAAAAAEgAAAADAAAAOAAAAAAAAABEAAAAAwAAAFAAAAADAAAAPwAAAAMAAABNAAAAAwAAAFoAAAADAAAAGwAAAAAAAAAoAAAAAwAAADcAAAADAAAAIwAAAAAAAAAuAAAAAAAAADwAAAAAAAAALQAAAAMAAAA4AAAAAAAAAEQAAAADAAAADgAAAAAAAAAUAAAAAwAAACQAAAADAAAAEQAAAAMAAAAbAAAAAAAAACgAAAADAAAAGQAAAAMAAAAjAAAAAAAAAC4AAAAAAAAARwAAAAAAAABZAAAAAAAAAGEAAAADAAAASQAAAAAAAABbAAAAAwAAAGcAAAADAAAASAAAAAMAAABYAAAAAwAAAGkAAAADAAAAMwAAAAAAAABFAAAAAwAAAFQAAAADAAAANgAAAAAAAABHAAAAAAAAAFkAAAAAAAAANwAAAAMAAABJAAAAAAAAAFsAAAADAAAAJgAAAAAAAAAvAAAAAwAAAEAAAAADAAAAIgAAAAMAAAAzAAAAAAAAAEUAAAADAAAAJAAAAAMAAAA2AAAAAAAAAEcAAAAAAAAAYAAAAAAAAABoAAAAAAAAAGsAAAADAAAAYgAAAAAAAABuAAAAAwAAAHMAAAADAAAAYQAAAAMAAABvAAAAAwAAAHcAAAADAAAATAAAAAAAAABWAAAAAwAAAF4AAAADAAAAUgAAAAAAAABgAAAAAAAAAGgAAAAAAAAAVAAAAAMAAABiAAAAAAAAAG4AAAADAAAAOgAAAAAAAABBAAAAAwAAAEsAAAADAAAAPgAAAAMAAABMAAAAAAAAAFYAAAADAAAAQAAAAAMAAABSAAAAAAAAAGAAAAAAAAAAVQAAAAAAAABXAAAAAAAAAFMAAAADAAAAZQAAAAAAAABmAAAAAwAAAGQAAAADAAAAawAAAAMAAABwAAAAAwAAAHIAAAADAAAAQgAAAAAAAABDAAAAAwAAAEYAAAADAAAAUQAAAAAAAABVAAAAAAAAAFcAAAAAAAAAXgAAAAMAAABlAAAAAAAAAGYAAAADAAAAMQAAAAAAAAAwAAAAAwAAADIAAAADAAAAPQAAAAMAAABCAAAAAAAAAEMAAAADAAAASwAAAAMAAABRAAAAAAAAAFUAAAAAAAAAXwAAAAAAAABcAAAAAAAAAFMAAAAAAAAATwAAAAAAAABOAAAAAAAAAEoAAAADAAAAPwAAAAEAAAA7AAAAAwAAADkAAAADAAAAbQAAAAAAAABsAAAAAAAAAGQAAAAFAAAAXQAAAAEAAABfAAAAAAAAAFwAAAAAAAAATQAAAAEAAABPAAAAAAAAAE4AAAAAAAAAdQAAAAQAAAB2AAAABQAAAHIAAAAFAAAAagAAAAEAAABtAAAAAAAAAGwAAAAAAAAAWgAAAAEAAABdAAAAAQAAAF8AAAAAAAAAWgAAAAAAAABNAAAAAAAAAD8AAAAAAAAAUAAAAAAAAABEAAAAAAAAADgAAAADAAAASAAAAAEAAAA8AAAAAwAAAC4AAAADAAAAagAAAAAAAABdAAAAAAAAAE8AAAAFAAAAYwAAAAEAAABaAAAAAAAAAE0AAAAAAAAAWAAAAAEAAABQAAAAAAAAAEQAAAAAAAAAdQAAAAMAAABtAAAABQAAAF8AAAAFAAAAcQAAAAEAAABqAAAAAAAAAF0AAAAAAAAAaQAAAAEAAABjAAAAAQAAAFoAAAAAAAAAaQAAAAAAAABYAAAAAAAAAEgAAAAAAAAAZwAAAAAAAABbAAAAAAAAAEkAAAADAAAAYQAAAAEAAABZAAAAAwAAAEcAAAADAAAAcQAAAAAAAABjAAAAAAAAAFAAAAAFAAAAdAAAAAEAAABpAAAAAAAAAFgAAAAAAAAAbwAAAAEAAABnAAAAAAAAAFsAAAAAAAAAdQAAAAIAAABqAAAABQAAAFoAAAAFAAAAeQAAAAEAAABxAAAAAAAAAGMAAAAAAAAAdwAAAAEAAAB0AAAAAQAAAGkAAAAAAAAAdwAAAAAAAABvAAAAAAAAAGEAAAAAAAAAcwAAAAAAAABuAAAAAAAAAGIAAAADAAAAawAAAAEAAABoAAAAAwAAAGAAAAADAAAAeQAAAAAAAAB0AAAAAAAAAGcAAAAFAAAAeAAAAAEAAAB3AAAAAAAAAG8AAAAAAAAAcAAAAAEAAABzAAAAAAAAAG4AAAAAAAAAdQAAAAEAAABxAAAABQAAAGkAAAAFAAAAdgAAAAEAAAB5AAAAAAAAAHQAAAAAAAAAcgAAAAEAAAB4AAAAAQAAAHcAAAAAAAAAcgAAAAAAAABwAAAAAAAAAGsAAAAAAAAAZAAAAAAAAABmAAAAAAAAAGUAAAADAAAAUwAAAAEAAABXAAAAAwAAAFUAAAADAAAAdgAAAAAAAAB4AAAAAAAAAHMAAAAFAAAAbAAAAAEAAAByAAAAAAAAAHAAAAAAAAAAXAAAAAEAAABkAAAAAAAAAGYAAAAAAAAAdQAAAAAAAAB5AAAABQAAAHcAAAAFAAAAbQAAAAEAAAB2AAAAAAAAAHgAAAAAAAAAXwAAAAEAAABsAAAAAQAAAHIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAGAAAAAgAAAAUAAAABAAAABAAAAAAAAAAAAAAABQAAAAMAAAABAAAABgAAAAQAAAACAAAAAAAAAH6iBfbytuk/Gq6akm/58z/Xrm0Liez0P5doSdOpSwRAWs602ULg8D/dT7Rcbo/1v1N1RQHFNOM/g9Snx7HW3L8HWsP8Q3jfP6VwOLosutk/9rjk1YQcxj+gnmKMsNn6P/HDeuPFY+M/YHwDjqKhB0Ci19/fCVrbP4UxKkDWOP6/pvljWa09tL9wi7wrQXjnv/Z6yLImkM2/3yTlOzY14D+m+WNZrT20PzwKVQnrQwNA9nrIsiaQzT/g40rFrRQFwPa45NWEHMa/kbslHEZq97/xw3rjxWPjv4cLC2SMBci/otff3wla27+rKF5oIAv0P1N1RQHFNOO/iDJPGyWHBUAHWsP8Q3jfvwQf/by16gXAfqIF9vK26b8XrO0Vh0r+v9eubQuJ7PS/BxLrA0ZZ479azrTZQuDwv1MK1EuItPw/yscgV9Z6FkAwHBR2WjQMQJNRzXsQ5vY/GlUHVJYKF0DONuFv2lMNQNCGZ28QJfk/0WUwoIL36D8ggDOMQuATQNqMOeAy/wZAWFYOYM+M2z/LWC4uH3oSQDE+LyTsMgRAkJzhRGWFGEDd4soovCQQQKqk0DJMEP8/rGmNdwOLBUAW2X/9xCbjP4hu3dcqJhNAzuYItRvdB0CgzW3zJW/sPxotm/Y2TxRAQAk9XmdDDEC1Kx9MKgT3P1M+NctcghZAFVqcLlb0C0Bgzd3sB2b2P77mZDPUWhZAFROHJpUGCEDAfma5CxXtPz1DWq/zYxRAmhYY5824F0DOuQKWSbAOQNCMqrvu3fs/L6DR22K2wT9nAAxPBU8RQGiN6mW43AFAZhu25b633D8c1YgmzowSQNM25BRKWARArGS08/lNxD+LFssHwmMRQLC5aNcxBgJABL9HT0WRF0CjCmJmOGEOQHsuaVzMP/s/TWJCaGGwBUCeu1PAPLzjP9nqN9DZOBNAKE4JcydbCkCGtbd1qjPzP8dgm9U8jhVAtPeKTkVwDkCeCLss5l37P401XMPLmBdAFd29VMVQDUBg0yA55h75Pz6odcYLCRdApBM4rBrkAkDyAVWgQxbRP4XDMnK20hFAymLlF7EmzD8GUgo9XBHlP3lbK7T9COc/k+OhPthhy7+YGEpnrOvCPzBFhLs15u4/epbqB6H4uz9IuuLF5svev6lzLKY31es/CaQ0envF5z8ZY0xlUADXv7zaz7HYEuI/CfbK1sn16T8uAQfWwxLWPzKn/YuFN94/5KdbC1AFu793fyCSnlfvPzK2y4doAMY/NRg5t1/X6b/shq4QJaHDP5yNIAKPOeI/vpn7BSE30r/X4YQrO6nrv78Ziv/Thto/DqJ1Y6+y5z9l51NaxFrlv8QlA65HOLS/86dxiEc96z+Hj0+LFjneP6LzBZ8LTc2/DaJ1Y6+y579l51NaxFrlP8QlA65HOLQ/8qdxiEc967+Jj0+LFjnev6LzBZ8LTc0/1qdbC1AFuz93fyCSnlfvvzK2y4doAMa/NRg5t1/X6T/vhq4QJaHDv5yNIAKPOeK/wJn7BSE30j/W4YQrO6nrP78Ziv/Thtq/CaQ0envF578XY0xlUADXP7zaz7HYEuK/CvbK1sn16b8rAQfWwxLWvzKn/YuFN96/zWLlF7EmzL8GUgo9XBHlv3lbK7T9COe/kOOhPthhyz+cGEpnrOvCvzBFhLs15u6/c5bqB6H4u79IuuLF5sveP6lzLKY31eu/AQAAAP////8HAAAA/////zEAAAD/////VwEAAP////9hCQAA/////6dBAAD/////kcsBAP/////3kAwA/////8H2VwAAAAAAAAAAAAAAAAACAAAA/////w4AAAD/////YgAAAP////+uAgAA/////8ISAAD/////ToMAAP////8ilwMA/////+4hGQD/////gu2vAAAAAAAAAAAAAAAAAAAAAAACAAAA//////////8BAAAAAwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////AgAAAP//////////AQAAAAAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD/////////////////////AQAAAP///////////////wIAAAD///////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP///////////////////////////////wIAAAD///////////////8BAAAA/////////////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAABAAAA//////////8CAAAA//////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAAAQAAAP//////////AgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAACAAAAAAAAAAIAAAABAAAAAQAAAAIAAAACAAAAAAAAAAUAAAAFAAAAAAAAAAIAAAACAAAAAwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAgAAAAEAAAACAAAAAgAAAAIAAAAAAAAABQAAAAYAAAAAAAAAAgAAAAIAAAADAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAAAAAACAAAAAQAAAAMAAAACAAAAAgAAAAAAAAAFAAAABwAAAAAAAAACAAAAAgAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAACAAAAAAAAAAIAAAABAAAABAAAAAIAAAACAAAAAAAAAAUAAAAIAAAAAAAAAAIAAAACAAAAAwAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAIAAAAAAAAAAgAAAAEAAAAAAAAAAgAAAAIAAAAAAAAABQAAAAkAAAAAAAAAAgAAAAIAAAADAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAgAAAAIAAAAAAAAAAwAAAA4AAAACAAAAAAAAAAIAAAADAAAAAAAAAAAAAAACAAAAAgAAAAMAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAACAAAAAgAAAAAAAAADAAAACgAAAAIAAAAAAAAAAgAAAAMAAAABAAAAAAAAAAIAAAACAAAAAwAAAAcAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAIAAAACAAAAAAAAAAMAAAALAAAAAgAAAAAAAAACAAAAAwAAAAIAAAAAAAAAAgAAAAIAAAADAAAACAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAgAAAAIAAAAAAAAAAwAAAAwAAAACAAAAAAAAAAIAAAADAAAAAwAAAAAAAAACAAAAAgAAAAMAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAACAAAAAgAAAAAAAAADAAAADQAAAAIAAAAAAAAAAgAAAAMAAAAEAAAAAAAAAAIAAAACAAAAAwAAAAoAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAIAAAACAAAAAAAAAAMAAAAGAAAAAgAAAAAAAAACAAAAAwAAAA8AAAAAAAAAAgAAAAIAAAADAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAIAAAAAAAAAAwAAAAcAAAACAAAAAAAAAAIAAAADAAAAEAAAAAAAAAACAAAAAgAAAAMAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAcAAAACAAAAAgAAAAAAAAADAAAACAAAAAIAAAAAAAAAAgAAAAMAAAARAAAAAAAAAAIAAAACAAAAAwAAAA0AAAAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAACAAAAAAAAAAMAAAAJAAAAAgAAAAAAAAACAAAAAwAAABIAAAAAAAAAAgAAAAIAAAADAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAgAAAAIAAAAAAAAAAwAAAAUAAAACAAAAAAAAAAIAAAADAAAAEwAAAAAAAAACAAAAAgAAAAMAAAAPAAAAAAAAAAAAAAAAAAAAAAAAABAAAAACAAAAAAAAAAIAAAABAAAAEwAAAAIAAAACAAAAAAAAAAUAAAAKAAAAAAAAAAIAAAACAAAAAwAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAIAAAAAAAAAAgAAAAEAAAAPAAAAAgAAAAIAAAAAAAAABQAAAAsAAAAAAAAAAgAAAAIAAAADAAAAEQAAAAAAAAAAAAAAAAAAAAAAAAASAAAAAgAAAAAAAAACAAAAAQAAABAAAAACAAAAAgAAAAAAAAAFAAAADAAAAAAAAAACAAAAAgAAAAMAAAASAAAAAAAAAAAAAAAAAAAAAAAAABMAAAACAAAAAAAAAAIAAAABAAAAEQAAAAIAAAACAAAAAAAAAAUAAAANAAAAAAAAAAIAAAACAAAAAwAAABMAAAAAAAAAAAAAAAAAAAAAAAAADwAAAAIAAAAAAAAAAgAAAAEAAAASAAAAAgAAAAIAAAAAAAAABQAAAA4AAAAAAAAAAgAAAAIAAAADAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAAAAAAAAAAAAAIAAAABAAAAAAAAAAEAAAACAAAAAQAAAAAAAAACAAAAAAAAAAUAAAAEAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAQAAAAAAAAABQAAAAAAAAACAAAAAQAAAAAAAAABAAAAAgAAAAAAAAAAAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAABAAAAAAAAAAIAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAEAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAQAAAAAAAAABQAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAEAAAAAAAAAAAEAAAAAAQAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAA6B6FaUp9QQTPXMuL4myJBraiDfBwx9UBYJseitzTIQOL5if9jqZtAnXX+Z+ycb0C3pucbhRBCQG8wJBYqpRRAlWbDCzCY5z/eFWBUEve6P/+qo4Q50Y4/D9YM3iCcYT8fcA2QJSA0P4ADxu0qAAc/BNcGolVJ2j5d9FACqwquPh9z7MthtI9CSUSYJke/YUJQ/64OyjU0Qpi0+HCmFQdCm3GfIVdh2kHsJ11kAyauQYC3UDFJOoFBSJsFV1OwU0FK5fcxX4AmQWhy/zZIt/lACqaCPsBjzUDbdUNIScugQMYQlVJ4MXNANiuq8GTvRUDxTXnulxEZQFZ8QX5kpuw/qmG/JwYFlEAluh3Q6DB+QKn4vyNq0GZAKOXekas+UUB8xabXXhI6QG63C2pLtSNAdDBtyNfLDUDyOcu67ID2P0rCMvRXAeE/Ki2TSVyzyT9Dk+8Sz2uzP5J+w5ARWp0/NQAoOiMuhj9YnP+RyMJwPxgW7TvQVFk/KgsLYF0kQz9g5dAC6IwzQcgHPVvDex1B1XjppodHBkHJq3OMM9fwQNvcmJ7wddlAInGPpQs/w0BRobq5EBmtQJZ2ai7n+ZVAtv2G5E+bgECG+gIfKBlpQK5f8jdI91JAL39sL/WpPEB8rGxhDqklQK6yUf43XhBAxL9y/tK8+D86XyZpgrHiPwAAAAD/////AAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAP////8AAAAAAAAAAAAAAAABAAAAAAAAAAAAAAD/////AAAAAAAAAAABAAAAAQAAAAAAAAAAAAAA/////wAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAP////8FAAAABQAAAAAAAAAAAAAAAAAAAAAAAAD/////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////////////////////////////wAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////////////////////////////8AAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAEAAAAAAAAABQAAAAEAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAQAAAAAAAQABAAABAQAAAAAAAQAAAAEAAAABAAEAAAAAAAAAAAAAAAAAAAAAquJYWJZl+D9jaeZNtj/zPwwdI9KqaeO/qGefXwdHdz+q4lhYlmX4P+OrlPMN3PI/DB0j0qpp47+7SQLV4VIEQKriWFiWZfg/r2kma3tz8T82eQmLqNIGwMRIWXMqSvo/fcCszPux9j+jara6ozTwP6hnn18HR3c/MSoKLequ8r+SabgA2nj0P7jBLbDOHO8/1Ym/ICfH4T+6lxjvlFXHv73m373LRPU/0vXyDVxo7T+ToKRHJXMAQF/33578aPE/pAyy64tD9T8+U/hCvyruPwxv8Y7YYwLAuXYr8NAiCEB4+LDK0Sn0P1Qeuy4j+eo/OMx50n7K7L+TrGB/nyf8v5ehC2fbYPM/aXMKexiT6z8mFRIMjg/zP7yUVwGGBNw/E6opHERf8z/z0wR2g9DqPw4pBpcOhvu/NbA29uWAA8DMaTExyXzyP02biiQ+Ruk/S8jz2/FKBEB1pzZnpbb9P7pQU4wLfPI//7ZcQXeG6D9CqEQvAYoIwDB2VB6sSgRAVyv8H5We8T+EHWF8XNPmPzB2wT8Nrrg/SEi+cX+w4L8of+GtdSDxP1sjk5AdouU/6ZjOVru13r8K0obqI6bxvwVbdNXyhfA/w5GG024n5z+rwmtMzP8BwLw9pSX49QXABe/2uQxP8D+b6wCzCvXkP7uGT87fK+Q/pz/JWw4coj+qoBf2J0nwP/yE3PUo0+I/vFJeHcaC+D96luSIqvntP/bf8sHUYu8/gZNN41mL4z9bhOqVOF4FwO6lmAh1hQhAbCVxbdhk7z+1C8NdDcfiPwG36x/0OQBAx0WJ76c2+D9nlSHXANfuP2HlfZ3gqOE/EwnVlVPg9r96+oHzEH//v5bXzdT1Auw/DM3GwLsA4D9p/8uoKcr+v+U9x5DQVAPAehjSdghb7D9sc1IetODgP8MVwwB1pu6/azPk6OGe978W8t/TUc3rP+0QMvYfP+A/RsG/QpSE8D+l3uwScxzgPwQaifgujuw/k1Vti1I43z8MAwLnSh0GQH5nYnwwZgJAiGUzWC5s6j8WyyI/BbLgPw4iUapGeQJAB3W+imnp/j9BLWR4ssrpP2t+gG5Pstk/cpBsfm6DCMCOpU9dOZsFQEv8nFypHeo/ehJ6i+6S2D9jqlGEmarLv7STC5TRiOa/bC+x8WZD6D9H3yUkWpDZP8gZvmCMuQLAreY19/eRBsCoPOc8UzzpP6KI/QV+y9g/t/MoboyWzT+Hv5q3Zu3Mvy2xROCT4uY/9gQitMMg1T9abAqhWMDkv1oLTavoUfG/PMUJP9CD5j+fHRX3t6fSPz7W2gk6bvs/WRnuHwqN9D8YFturGCTmP1EZczv0b9I/5t4exabB5D/1ESLh5fTEP9X2z6SYweQ/6lv3I2zT0D9zkRGNUNMAQKoSvc4EIfs/Xggt8wQI5T+mJHHg/w/SP4lhT/9t8vQ/DrZ/DbwH7D+XlhbYZrjkP34LIpFt6c4/lwfp8fLX9L+j96CTTf76v3WdNhEv9uM/d8c3o4lV0D/vFdCHVcsFwAHeDq0F1QhApbYqcZiN5D9KoilqByXLPwX0/diA0vq/0fo0GxnxAMBbaTkvlCzjP/RrFrWXrMs/UYTrky7jA0DB9f4FiZYAQEGAk/3QzeE/r/TeqE8t0D/OqjlsnPbvvz8RKU8JOfW/smSEbK/O4T8MzuyPm3DDP/rFtctq9gZAfb1EVEaSA0Dts5dVInnhP18SFMc79MM/7y34cw6LAMDFrRJsZO0DwC2KLvLSYuA/hx5wcUHewz+49SnK/4ruPyeS0PX9a+E/ZxaaLvvZ3z8WPu5T2QS8Pygo4RIvMqa/BJ0Kqsd0279cKW4ay8jdP3b05bmZ364/10/qtdxk2r+Bcz6CDMvpv54qOw+Amdw/qLV71pW7sT/YKc80nIPUP8OfIaBJ77G/LyTuD1un2z+diYu8efWzP1wU7ACkfwjAZroyPL1yBkAmv3lKJJbbPysKSE4W+p0/dIgqY79TA8ATLTOQ3tsGwJ2zweD/Xdg/XO/jXeFUaL8VW2qLFKfov1cA9Aa6XfK/tIa7YGgI2T+f3hu/sxqPv2nXdPpf3Pc/jkw8Jbda8j+tT/z8tGPVP1yBHpJd35k/KYvYOy1s8j/yz+kCQjPrP9+agH7x59g/PZfJ9aBhpr/rDKzvYBb+PwtkiaGCt/c/vb1mVr+f1T/JIHwHc8Govw7aeF6+9vG/Xv7kD6fp979isYioQYHVP7AIQZuSFrG/3z1AdUTnAUDN3XY9O7f9P0AdQ9ljYNQ/dJANJPTOrb8kLECUiiPlP4yF7UgmStA/9xGmXxCG1T9qZzix4W2zv2SGJRJVrPe/Fh9a2M/B/b8IexzFCoPSP9y1QFD2bLe/Q86cWLJe/b+mOOfYm78BwOTjkPAGE9E/8aPCUKu/ub9pPZyLCiUGwBA7Mev/BQlALOmrlRi+0j+AMJ/dKULBv7iLtL6a6QRAEMDV/yajAUDa62dE3crJP1P70RgBUbq/38hVnR6esT/s1tG10Z/Ov/zLwalHPss/dTS9NKTXx78nMcRzCIEHQAabxDsAmQRA0tyLK3gSyT+Aui7nOhDGv5Gs58z3WgHATN3forJuBMCAui7nOhDGP9Lciyt4Esm/WAJyHQ4c7z8UP5HFIs3iP3U0vTSk18c//MvBqUc+y7+cvv8HLg/Kvy1I/mHsI+K/U/vRGAFRuj/a62dE3crJv8p+WV8KlQjAuQ/nOP43B0CAMJ/dKULBPyzpq5UYvtK/ZoU+VoLh4L9etLlRUfvtv/GjwlCrv7k/5OOQ8AYT0b9DfT9FhufXPwUX8hJp+4u/3LVAUPZstz8IexzFCoPSv9+L609E5fQ/q9Fz7X2J7T9qZzix4W2zP/cRpl8QhtW/vtNilqGX+j8MOy7QJoL0P3SQDST0zq0/QB1D2WNg1L8IIjSvGNkDwGB8Jou2GAfAsAhBm5IWsT9isYioQYHVvyS9D3zb6uy/gnwRa7uM9L/JIHwHc8GoP729Zla/n9W/CsAHJZwmAEDEW6OYT1r6Pz2XyfWgYaY/35qAfvHn2L83Tdy4lS30vxf2/gZ0jPq/XIEekl3fmb+tT/z8tGPVvybPr2zJ1/+/K7mJ0ypVAsCf3hu/sxqPPwCGu2BoCNm/5oITrpZn+r+UDUyDP+n/v1zv413hVGg/nbPB4P9d2L9MlmkxNvgCQMtZlKE85v8/KwpIThb6nb8mv3lKJJbbv8+SZsTvOOc/pQCIIOYw0j+diYu8efWzvy8k7g9bp9u/kxYDa+pKtD9XlYvA8HnVv6i1e9aVu7G/nio7D4CZ3L/WR6rNh5EGwCkgQweBkghAdvTluZnfrr9cKW4ay8jdvxbjhr1f1QVAR5C0MzivAkAWPu5T2QS8v2cWmi772d+/cKj4lzLJCEBx2QJfYrMFQIcecHFB3sO/LYou8tJi4L+jr7lhO38BwIcI0Nb7xgTAXxIUxzv0w7/ts5dVInnhv0T+l8DZLfE/MP3FoFvS5D8MzuyPm3DDv7JkhGyvzuG/tzhzRIRc0b9Ovv3/0z7mv6/03qhPLdC/m4CT/dDN4b9dwjU5VCQBQBBJX1ntCv0/9GsWtZesy79baTkvlCzjv1mjYgEz++S/oW6KnOQW8b9KoilqByXLv6W2KnGYjeS/SmaKz3Vx9z+BZB5yxGHwP3fHN6OJVdC/dZ02ES/2478PuaBjLrXaP4/JU81pPaO/fgsikW3pzr+XlhbYZrjkv4tSn7YDbP0/f2LnFKlF9z+mJHHg/w/Sv14ILfMECOW/mfg4qYhR/b+OP+RQDCACwOpb9yNs09C/1fbPpJjB5L9pN2WOVZ3wv3hHy9nxIve/URlzO/Rv0r8YFturGCTmv1d1/KKR8QPA8gsy9qzSB8CfHRX3t6fSvzzFCT/Qg+a/EYStnrzV9r/2QJqI7Lb9v/YEIrTDINW/LbFE4JPi5r/7kQEs5fEDQHunnf4GeQBAooj9BX7L2L+oPOc8Uzzpv+ydYY2SSAfAL4HK6CRTB0BH3yUkWpDZv2wvsfFmQ+i/Ik0Yzruh6T8fM3LoGoDUP3oSeovukti/S/ycXKkd6r9rEv+7UWcHQCRIQe/GfwNAa36Abk+y2b9BLWR4ssrpv9KT87qa0bM/FTyktw823L8WyyI/BbLgv4hlM1gubOq/DizMp9Ki6r8b5ckdjVrzv5NVbYtSON+/BBqJ+C6O7L/dUBFqgyXYv00Wh18r7+q/7RAy9h8/4L8W8t/TUc3rv4RM5DKx3wDAfvWIj94aBcBsc1IetODgv3oY0nYIW+y/oGcTFF54AUDkJqS/FKX6PwzNxsC7AOC/ltfN1PUC7L+5Wrz/zHnzP6688w2rNOc/YeV9neCo4b9nlSHXANfuvw9RsxKjY/s/1V8GteXE8j+1C8NdDcfiv2wlcW3YZO+/IOywaA7Q8b9bFP+4Tg36v4GTTeNZi+O/9t/ywdRi77+tRc3yFR7eP2bkcHXJkLO//ITc9SjT4r+qoBf2J0nwv2YHKoswwfm/iQcLspCjAcCb6wCzCvXkvwXv9rkMT/C/YkuwYAMXBMApCNUai9kIwMORhtNuJ+e/BVt01fKF8L+ZqWEfvIjsP6h693QZYNk/WyOTkB2i5b8of+GtdSDxvwpaaulDSwVADMQAX+lOAECEHWF8XNPmv1cr/B+VnvG/XyFG6opcCMD/mtR32/UEQP+2XEF3hui/ulBTjAt88r/imfCfRP+yP9zbvtc8XeO/TZuKJD5G6b/MaTExyXzyvxiTQeElXOO/rbJRQVGN9L/z0wR2g9DqvxOqKRxEX/O/FDGCEei99j9x8zV4VYTmP2lzCnsYk+u/l6ELZ9tg878pRXacaDT/v3k6GZRqoQXAVB67LiP56r94+LDK0Sn0vwO6pZ9b7wFAvK0nKVcc9j8+U/hCvyruv6QMsuuLQ/W/FPhKFYv46j8MyxaDTOW/v9L18g1caO2/vebfvctE9b/7GD8ZrF3xv3gx1AR9bQDAuMEtsM4c77+SabgA2nj0v5xKFIwxsATArKNSBaKsB0Cjara6ozTwv33ArMz7sfa/dF2U0FcWCcDxL357DJX/P69pJmt7c/G/quJYWJZl+L/YntVJlnrSP4sRLzXM+fe/46uU8w3c8r+q4lhYlmX4v85lu5+QRwRAsI0H/WU8479jaeZNtj/zv6riWFiWZfi/sI0H/WU847/OZbufkEcEQHAoPUBrnss/9exKzDtFtT88wM8kax+gP9OqeKeAYog/MW0ItiZvcj+ph+smvt5bP2lCaV5dEUU/StaUmQDaLz+kK9y22BMYP0O3whZuMwI/IIbgZGWE6z7UkjYaEM3UPuezxwa9cr8+LybxRMnFpz6E1N8DbPiRPsYjySMvK3s+//////8fAAj//////zMQCP////9/MiAI/////28yMAj/////YzJACP///z9iMlAI////N2IyYAj///8zYjJwCP//vzNiMoAI//+rM2IykAj/f6szYjKgCP8PqzNiMrAI/wOrM2IywAi/A6szYjLQCJ8DqzNiMuAImQOrM2Iy8Aj//////z8PCP//////Kx8I/////38pLwj/////Pyk/CP////85KU8I////PzgpXwj///8POClvCP///w44KX8I//8fDjgpjwj//w8OOCmfCP9/DQ44Ka8I/w8NDjgpvwj/DQ0OOCnPCP8MDQ44Kd8IxwwNDjgp7wjEDA0OOCn/CAcAAAAHAAAAAQAAAAIAAAAEAAAAAwAAAAAAAAAAAAAABwAAAAMAAAABAAAAAgAAAAUAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAAAAAACAAAAAQAAAAMAAAAOAAAABgAAAAsAAAACAAAABwAAAAEAAAAYAAAABQAAAAoAAAABAAAABgAAAAAAAAAmAAAABwAAAAwAAAADAAAACAAAAAIAAAAxAAAACQAAAA4AAAAAAAAABQAAAAQAAAA6AAAACAAAAA0AAAAEAAAACQAAAAMAAAA/AAAACwAAAAYAAAAPAAAACgAAABAAAABIAAAADAAAAAcAAAAQAAAACwAAABEAAABTAAAACgAAAAUAAAATAAAADgAAAA8AAABhAAAADQAAAAgAAAARAAAADAAAABIAAABrAAAADgAAAAkAAAASAAAADQAAABMAAAB1AAAADwAAABMAAAARAAAAEgAAABAAAAAGAAAAAgAAAAMAAAAFAAAABAAAAAAAAAAAAAAAAAAAAAYAAAACAAAAAwAAAAEAAAAFAAAABAAAAAAAAAAAAAAABwAAAAUAAAADAAAABAAAAAEAAAAAAAAAAgAAAAAAAAACAAAAAwAAAAEAAAAFAAAABAAAAAYAAAAAAAAAAAAAABgtRFT7Ifk/GC1EVPsh+b8YLURU+yEJQBgtRFT7IQnAYWxnb3MuYwBoM05laWdoYm9yUm90YXRpb25zAGNvb3JkaWprLmMAX3VwQXA3Q2hlY2tlZABfdXBBcDdyQ2hlY2tlZABkaXJlY3RlZEVkZ2UuYwBkaXJlY3RlZEVkZ2VUb0JvdW5kYXJ5AGFkamFjZW50RmFjZURpclt0bXBGaWprLmZhY2VdW2ZpamsuZmFjZV0gPT0gS0kAZmFjZWlqay5jAF9mYWNlSWprUGVudFRvQ2VsbEJvdW5kYXJ5AGFkamFjZW50RmFjZURpcltjZW50ZXJJSksuZmFjZV1bZmFjZTJdID09IEtJAF9mYWNlSWprVG9DZWxsQm91bmRhcnkAaDNJbmRleC5jAGNvbXBhY3RDZWxscwBsYXRMbmdUb0NlbGwAY2VsbFRvQ2hpbGRQb3MAdmFsaWRhdGVDaGlsZFBvcwBsYXRMbmcuYwBjZWxsQXJlYVJhZHMyAHBvbHlnb24tPm5leHQgPT0gTlVMTABsaW5rZWRHZW8uYwBhZGROZXdMaW5rZWRQb2x5Z29uAG5leHQgIT0gTlVMTABsb29wICE9IE5VTEwAYWRkTmV3TGlua2VkTG9vcABwb2x5Z29uLT5maXJzdCA9PSBOVUxMAGFkZExpbmtlZExvb3AAY29vcmQgIT0gTlVMTABhZGRMaW5rZWRDb29yZABsb29wLT5maXJzdCA9PSBOVUxMAGlubmVyTG9vcHMgIT0gTlVMTABub3JtYWxpemVNdWx0aVBvbHlnb24AYmJveGVzICE9IE5VTEwAY2FuZGlkYXRlcyAhPSBOVUxMAGZpbmRQb2x5Z29uRm9ySG9sZQBjYW5kaWRhdGVCQm94ZXMgIT0gTlVMTAByZXZEaXIgIT0gSU5WQUxJRF9ESUdJVABsb2NhbGlqLmMAY2VsbFRvTG9jYWxJamsAYmFzZUNlbGwgIT0gb3JpZ2luQmFzZUNlbGwAIShvcmlnaW5PblBlbnQgJiYgaW5kZXhPblBlbnQpAGJhc2VDZWxsID09IG9yaWdpbkJhc2VDZWxsAGJhc2VDZWxsICE9IElOVkFMSURfQkFTRV9DRUxMAGxvY2FsSWprVG9DZWxsACFfaXNCYXNlQ2VsbFBlbnRhZ29uKGJhc2VDZWxsKQBiYXNlQ2VsbFJvdGF0aW9ucyA+PSAwAGdyaWRQYXRoQ2VsbHMAcG9seWZpbGwuYwBpdGVyU3RlcFBvbHlnb25Db21wYWN0ADAAdmVydGV4LmMAdmVydGV4Um90YXRpb25zAGNlbGxUb1ZlcnRleABncmFwaC0+YnVja2V0cyAhPSBOVUxMAHZlcnRleEdyYXBoLmMAaW5pdFZlcnRleEdyYXBoAG5vZGUgIT0gTlVMTABhZGRWZXJ0ZXhOb2Rl";var Ne=28640;function ee(Ve,at,It,At){er("Assertion failed: "+Ns(Ve)+", at: "+[at?Ns(at):"unknown filename",It,At?Ns(At):"unknown function"])}function K(){return Ji.length}function le(Ve,at,It){Sn.set(Sn.subarray(at,at+It),Ve)}function Me(Ve){return J.___errno_location&&(Un[J.___errno_location()>>2]=Ve),Ve}function Se(Ve){er("OOM")}function Ge(Ve){try{var at=new ArrayBuffer(Ve);return at.byteLength!=Ve?void 0:(new Int8Array(at).set(Ji),Xt(at),ti(at),1)}catch{}}function Fe(Ve){var at=K(),It=16777216,At=2147483648-It;if(Ve>At)return!1;for(var o=16777216,X=Math.max(at,o);X<Ve;)X<=536870912?X=Cs(2*X,It):X=Math.min(Cs((3*X+2147483648)/4,It),At);var ii=Ge(X);return!!ii}var ke=typeof atob=="function"?atob:function(Ve){var at="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",It="",At,o,X,ii,Ri,Qi,ut,zt=0;Ve=Ve.replace(/[^A-Za-z0-9\+\/\=]/g,"");do ii=at.indexOf(Ve.charAt(zt++)),Ri=at.indexOf(Ve.charAt(zt++)),Qi=at.indexOf(Ve.charAt(zt++)),ut=at.indexOf(Ve.charAt(zt++)),At=ii<<2|Ri>>4,o=(Ri&15)<<4|Qi>>2,X=(Qi&3)<<6|ut,It=It+String.fromCharCode(At),Qi!==64&&(It=It+String.fromCharCode(o)),ut!==64&&(It=It+String.fromCharCode(X));while(zt<Ve.length);return It};function Qe(Ve){try{for(var at=ke(Ve),It=new Uint8Array(at.length),At=0;At<at.length;++At)It[At]=at.charCodeAt(At);return It}catch{throw new Error("Converting base64 string to bytes failed.")}}function ft(Ve){if(vo(Ve))return Qe(Ve.slice(Gn.length))}var ot={Math,Int8Array,Int32Array,Uint8Array,Float32Array,Float64Array},St={b:fr,c:Zi,d:ee,e:Me,f:K,g:le,h:Fe,i:Se,o:Ne,p:Yt},je=(function(Ve,at,It){"almost asm";var At=new Ve.Int8Array(It),o=new Ve.Int32Array(It);new Ve.Uint8Array(It),new Ve.Float32Array(It);var X=new Ve.Float64Array(It),ii=at.o|0,Ri=at.p|0,Qi=Ve.Math.floor,ut=Ve.Math.abs,zt=Ve.Math.sqrt,$t=Ve.Math.pow,fi=Ve.Math.cos,di=Ve.Math.sin,jr=Ve.Math.tan,ni=Ve.Math.acos,Ea=Ve.Math.asin,xo=Ve.Math.atan,kn=Ve.Math.atan2,qn=Ve.Math.ceil,Hn=Ve.Math.imul,bo=Ve.Math.min,Sa=Ve.Math.max,vr=Ve.Math.clz32,Ft=at.b,ae=at.c,qt=at.d,Uo=at.e,wo=at.f,zn=at.g,Fi=at.h,Xi=at.i,te=28656;function tr(l){return At=new Int8Array(l),o=new Int32Array(l),X=new Float64Array(l),It=l,!0}function Go(l){l=l|0;var a=0;return a=te,te=te+l|0,te=te+15&-16,a|0}function Ha(){return te|0}function _i(l){l=l|0,te=l}function Sr(l,a){l=l|0,te=l}function Wa(l,a){l=l|0,a=a|0;var c=0,m=0,g=0;return(l|0)<0?(a=2,a|0):(l|0)>13780509?(a=Rs(15,a)|0,a|0):(c=((l|0)<0)<<31>>31,g=lr(l|0,c|0,3,0)|0,m=ae()|0,c=Wt(l|0,c|0,1,0)|0,c=lr(g|0,m|0,c|0,ae()|0)|0,c=Wt(c|0,ae()|0,1,0)|0,l=ae()|0,o[a>>2]=c,o[a+4>>2]=l,a=0,a|0)}function ha(l,a,c,m){return l=l|0,a=a|0,c=c|0,m=m|0,_n(l,a,c,m,0)|0}function _n(l,a,c,m,g){l=l|0,a=a|0,c=c|0,m=m|0,g=g|0;var w=0,P=0,S=0,z=0,O=0;if(z=te,te=te+16|0,P=z,!(Qa(l,a,c,m,g)|0))return m=0,te=z,m|0;do if((c|0)>=0){if((c|0)>13780509){if(w=Rs(15,P)|0,w|0)break;S=P,P=o[S>>2]|0,S=o[S+4>>2]|0}else w=((c|0)<0)<<31>>31,O=lr(c|0,w|0,3,0)|0,S=ae()|0,w=Wt(c|0,w|0,1,0)|0,w=lr(O|0,S|0,w|0,ae()|0)|0,w=Wt(w|0,ae()|0,1,0)|0,S=ae()|0,o[P>>2]=w,o[P+4>>2]=S,P=w;if(bn(m|0,0,P<<3|0)|0,g|0){bn(g|0,0,P<<2|0)|0,w=Ln(l,a,c,m,g,P,S,0)|0;break}w=ts(P,4)|0,w?(O=Ln(l,a,c,m,w,P,S,0)|0,Qt(w),w=O):w=13}else w=2;while(!1);return O=w,te=z,O|0}function Qa(l,a,c,m,g){l=l|0,a=a|0,c=c|0,m=m|0,g=g|0;var w=0,P=0,S=0,z=0,O=0,Z=0,se=0,pe=0,de=0,me=0,Ie=0;if(Ie=te,te=te+16|0,de=Ie,me=Ie+8|0,pe=de,o[pe>>2]=l,o[pe+4>>2]=a,(c|0)<0)return me=2,te=Ie,me|0;if(w=m,o[w>>2]=l,o[w+4>>2]=a,w=(g|0)!=0,w&&(o[g>>2]=0),$i(l,a)|0)return me=9,te=Ie,me|0;o[me>>2]=0;e:do if((c|0)>=1)if(w)for(Z=1,O=0,se=0,pe=1,w=l;;){if(!(O|se)){if(w=ar(w,a,4,me,de)|0,w|0)break e;if(a=de,w=o[a>>2]|0,a=o[a+4>>2]|0,$i(w,a)|0){w=9;break e}}if(w=ar(w,a,o[26800+(se<<2)>>2]|0,me,de)|0,w|0)break e;if(a=de,w=o[a>>2]|0,a=o[a+4>>2]|0,l=m+(Z<<3)|0,o[l>>2]=w,o[l+4>>2]=a,o[g+(Z<<2)>>2]=pe,l=O+1|0,P=(l|0)==(pe|0),S=se+1|0,z=(S|0)==6,$i(w,a)|0){w=9;break e}if(pe=pe+(z&P&1)|0,(pe|0)>(c|0)){w=0;break}else Z=Z+1|0,O=P?0:l,se=P?z?0:S:se}else for(Z=1,O=0,se=0,pe=1,w=l;;){if(!(O|se)){if(w=ar(w,a,4,me,de)|0,w|0)break e;if(a=de,w=o[a>>2]|0,a=o[a+4>>2]|0,$i(w,a)|0){w=9;break e}}if(w=ar(w,a,o[26800+(se<<2)>>2]|0,me,de)|0,w|0)break e;if(a=de,w=o[a>>2]|0,a=o[a+4>>2]|0,l=m+(Z<<3)|0,o[l>>2]=w,o[l+4>>2]=a,l=O+1|0,P=(l|0)==(pe|0),S=se+1|0,z=(S|0)==6,$i(w,a)|0){w=9;break e}if(pe=pe+(z&P&1)|0,(pe|0)>(c|0)){w=0;break}else Z=Z+1|0,O=P?0:l,se=P?z?0:S:se}else w=0;while(!1);return me=w,te=Ie,me|0}function Ln(l,a,c,m,g,w,P,S){l=l|0,a=a|0,c=c|0,m=m|0,g=g|0,w=w|0,P=P|0,S=S|0;var z=0,O=0,Z=0,se=0,pe=0,de=0,me=0,Ie=0,Be=0,Je=0;if(Ie=te,te=te+16|0,de=Ie+8|0,me=Ie,z=Do(l|0,a|0,w|0,P|0)|0,Z=ae()|0,se=m+(z<<3)|0,Be=se,Je=o[Be>>2]|0,Be=o[Be+4>>2]|0,O=(Je|0)==(l|0)&(Be|0)==(a|0),!((Je|0)==0&(Be|0)==0|O))do z=Wt(z|0,Z|0,1,0)|0,z=ul(z|0,ae()|0,w|0,P|0)|0,Z=ae()|0,se=m+(z<<3)|0,Je=se,Be=o[Je>>2]|0,Je=o[Je+4>>2]|0,O=(Be|0)==(l|0)&(Je|0)==(a|0);while(!((Be|0)==0&(Je|0)==0|O));if(z=g+(z<<2)|0,O&&(o[z>>2]|0)<=(S|0)||(Je=se,o[Je>>2]=l,o[Je+4>>2]=a,o[z>>2]=S,(S|0)>=(c|0)))return Je=0,te=Ie,Je|0;switch(O=S+1|0,o[de>>2]=0,z=ar(l,a,2,de,me)|0,z|0){case 9:{pe=9;break}case 0:{z=me,z=Ln(o[z>>2]|0,o[z+4>>2]|0,c,m,g,w,P,O)|0,z||(pe=9);break}}e:do if((pe|0)==9){switch(o[de>>2]=0,z=ar(l,a,3,de,me)|0,z|0){case 9:break;case 0:{if(z=me,z=Ln(o[z>>2]|0,o[z+4>>2]|0,c,m,g,w,P,O)|0,z|0)break e;break}default:break e}switch(o[de>>2]=0,z=ar(l,a,1,de,me)|0,z|0){case 9:break;case 0:{if(z=me,z=Ln(o[z>>2]|0,o[z+4>>2]|0,c,m,g,w,P,O)|0,z|0)break e;break}default:break e}switch(o[de>>2]=0,z=ar(l,a,5,de,me)|0,z|0){case 9:break;case 0:{if(z=me,z=Ln(o[z>>2]|0,o[z+4>>2]|0,c,m,g,w,P,O)|0,z|0)break e;break}default:break e}switch(o[de>>2]=0,z=ar(l,a,4,de,me)|0,z|0){case 9:break;case 0:{if(z=me,z=Ln(o[z>>2]|0,o[z+4>>2]|0,c,m,g,w,P,O)|0,z|0)break e;break}default:break e}switch(o[de>>2]=0,z=ar(l,a,6,de,me)|0,z|0){case 9:break;case 0:{if(z=me,z=Ln(o[z>>2]|0,o[z+4>>2]|0,c,m,g,w,P,O)|0,z|0)break e;break}default:break e}return Je=0,te=Ie,Je|0}while(!1);return Je=z,te=Ie,Je|0}function ar(l,a,c,m,g){l=l|0,a=a|0,c=c|0,m=m|0,g=g|0;var w=0,P=0,S=0,z=0,O=0,Z=0,se=0,pe=0,de=0,me=0;if(c>>>0>6)return g=1,g|0;if(se=(o[m>>2]|0)%6|0,o[m>>2]=se,(se|0)>0){w=0;do c=Wo(c)|0,w=w+1|0;while((w|0)<(o[m>>2]|0))}if(se=ht(l|0,a|0,45)|0,ae()|0,Z=se&127,Z>>>0>121)return g=5,g|0;z=Ir(l,a)|0,w=ht(l|0,a|0,52)|0,ae()|0,w=w&15;e:do if(!w)O=8;else{for(;;){if(P=(15-w|0)*3|0,S=ht(l|0,a|0,P|0)|0,ae()|0,S=S&7,(S|0)==7){a=5;break}if(me=(vn(w)|0)==0,w=w+-1|0,pe=yt(7,0,P|0)|0,a=a&~(ae()|0),de=yt(o[(me?432:16)+(S*28|0)+(c<<2)>>2]|0,0,P|0)|0,P=ae()|0,c=o[(me?640:224)+(S*28|0)+(c<<2)>>2]|0,l=de|l&~pe,a=P|a,!c){c=0;break e}if(!w){O=8;break e}}return a|0}while(!1);(O|0)==8&&(me=o[848+(Z*28|0)+(c<<2)>>2]|0,de=yt(me|0,0,45)|0,l=de|l,a=ae()|0|a&-1040385,c=o[4272+(Z*28|0)+(c<<2)>>2]|0,(me&127|0)==127&&(me=yt(o[848+(Z*28|0)+20>>2]|0,0,45)|0,a=ae()|0|a&-1040385,c=o[4272+(Z*28|0)+20>>2]|0,l=yn(me|l,a)|0,a=ae()|0,o[m>>2]=(o[m>>2]|0)+1)),S=ht(l|0,a|0,45)|0,ae()|0,S=S&127;e:do if(Vi(S)|0){t:do if((Ir(l,a)|0)==1){if((Z|0)!=(S|0))if(Ht(S,o[7696+(Z*28|0)>>2]|0)|0){l=As(l,a)|0,P=1,a=ae()|0;break}else qt(27795,26864,533,26872);switch(z|0){case 3:{l=yn(l,a)|0,a=ae()|0,o[m>>2]=(o[m>>2]|0)+1,P=0;break t}case 5:{l=As(l,a)|0,a=ae()|0,o[m>>2]=(o[m>>2]|0)+5,P=0;break t}case 0:return me=9,me|0;default:return me=1,me|0}}else P=0;while(!1);if((c|0)>0){w=0;do l=Ka(l,a)|0,a=ae()|0,w=w+1|0;while((w|0)!=(c|0))}if((Z|0)!=(S|0)){if(!(oi(S)|0)){if((P|0)!=0|(Ir(l,a)|0)!=5)break;o[m>>2]=(o[m>>2]|0)+1;break}switch(se&127){case 8:case 118:break e}(Ir(l,a)|0)!=3&&(o[m>>2]=(o[m>>2]|0)+1)}}else if((c|0)>0){w=0;do l=yn(l,a)|0,a=ae()|0,w=w+1|0;while((w|0)!=(c|0))}while(!1);return o[m>>2]=((o[m>>2]|0)+c|0)%6|0,me=g,o[me>>2]=l,o[me+4>>2]=a,me=0,me|0}function Cr(l,a,c,m){return l=l|0,a=a|0,c=c|0,m=m|0,To(l,a,c,m)|0?(bn(m|0,0,c*48|0)|0,m=so(l,a,c,m)|0,m|0):(m=0,m|0)}function To(l,a,c,m){l=l|0,a=a|0,c=c|0,m=m|0;var g=0,w=0,P=0,S=0,z=0,O=0,Z=0,se=0,pe=0,de=0,me=0;if(me=te,te=te+16|0,pe=me,de=me+8|0,se=pe,o[se>>2]=l,o[se+4>>2]=a,(c|0)<0)return de=2,te=me,de|0;if(!c)return de=m,o[de>>2]=l,o[de+4>>2]=a,de=0,te=me,de|0;o[de>>2]=0;e:do if($i(l,a)|0)l=9;else{g=0,se=l;do{if(l=ar(se,a,4,de,pe)|0,l|0)break e;if(a=pe,se=o[a>>2]|0,a=o[a+4>>2]|0,g=g+1|0,$i(se,a)|0){l=9;break e}}while((g|0)<(c|0));Z=m,o[Z>>2]=se,o[Z+4>>2]=a,Z=c+-1|0,O=0,l=1;do{if(g=26800+(O<<2)|0,(O|0)==5)for(P=o[g>>2]|0,w=0,g=l;;){if(l=pe,l=ar(o[l>>2]|0,o[l+4>>2]|0,P,de,pe)|0,l|0)break e;if((w|0)!=(Z|0))if(z=pe,S=o[z>>2]|0,z=o[z+4>>2]|0,l=m+(g<<3)|0,o[l>>2]=S,o[l+4>>2]=z,!($i(S,z)|0))l=g+1|0;else{l=9;break e}else l=g;if(w=w+1|0,(w|0)>=(c|0))break;g=l}else for(P=pe,z=o[g>>2]|0,S=0,g=l,w=o[P>>2]|0,P=o[P+4>>2]|0;;){if(l=ar(w,P,z,de,pe)|0,l|0)break e;if(P=pe,w=o[P>>2]|0,P=o[P+4>>2]|0,l=m+(g<<3)|0,o[l>>2]=w,o[l+4>>2]=P,l=g+1|0,$i(w,P)|0){l=9;break e}if(S=S+1|0,(S|0)>=(c|0))break;g=l}O=O+1|0}while(O>>>0<6);l=pe,l=(se|0)==(o[l>>2]|0)&&(a|0)==(o[l+4>>2]|0)?0:9}while(!1);return de=l,te=me,de|0}function so(l,a,c,m){l=l|0,a=a|0,c=c|0,m=m|0;var g=0,w=0,P=0,S=0,z=0,O=0,Z=0,se=0,pe=0;if(se=te,te=te+16|0,P=se,!c)return o[m>>2]=l,o[m+4>>2]=a,m=0,te=se,m|0;do if((c|0)>=0){if((c|0)>13780509){if(g=Rs(15,P)|0,g|0)break;w=P,g=o[w>>2]|0,w=o[w+4>>2]|0}else g=((c|0)<0)<<31>>31,Z=lr(c|0,g|0,3,0)|0,w=ae()|0,g=Wt(c|0,g|0,1,0)|0,g=lr(Z|0,w|0,g|0,ae()|0)|0,g=Wt(g|0,ae()|0,1,0)|0,w=ae()|0,Z=P,o[Z>>2]=g,o[Z+4>>2]=w;if(O=ts(g,8)|0,!O)g=13;else{if(Z=ts(g,4)|0,!Z){Qt(O),g=13;break}if(g=Ln(l,a,c,O,Z,g,w,0)|0,g|0){Qt(O),Qt(Z);break}if(a=o[P>>2]|0,P=o[P+4>>2]|0,(P|0)>0|(P|0)==0&a>>>0>0){g=0,S=0,z=0;do l=O+(S<<3)|0,w=o[l>>2]|0,l=o[l+4>>2]|0,!((w|0)==0&(l|0)==0)&&(o[Z+(S<<2)>>2]|0)==(c|0)&&(pe=m+(g<<3)|0,o[pe>>2]=w,o[pe+4>>2]=l,g=g+1|0),S=Wt(S|0,z|0,1,0)|0,z=ae()|0;while((z|0)<(P|0)|(z|0)==(P|0)&S>>>0<a>>>0)}Qt(O),Qt(Z),g=0}}else g=2;while(!1);return pe=g,te=se,pe|0}function js(l,a,c,m){l=l|0,a=a|0,c=c|0,m=m|0;var g=0,w=0,P=0,S=0,z=0,O=0;for(S=te,te=te+16|0,w=S,P=S+8|0,g=($i(l,a)|0)==0,g=g?1:2;;){if(o[P>>2]=0,O=(ar(l,a,g,P,w)|0)==0,z=w,O&((o[z>>2]|0)==(c|0)?(o[z+4>>2]|0)==(m|0):0)){l=4;break}if(g=g+1|0,g>>>0>=7){g=7,l=4;break}}return(l|0)==4?(te=S,g|0):0}function $a(l,a,c,m){l=l|0,a=a|0,c=c|0,m=m|0;var g=0,w=0,P=0,S=0,z=0,O=0;if(S=te,te=te+48|0,g=S+16|0,w=S+8|0,P=S,c=tt(c)|0,c|0)return P=c,te=S,P|0;if(O=l,z=o[O+4>>2]|0,c=w,o[c>>2]=o[O>>2],o[c+4>>2]=z,Ze(w,g),c=ca(g,a,P)|0,!c){if(a=o[w>>2]|0,w=o[l+8>>2]|0,(w|0)>0){g=o[l+12>>2]|0,c=0;do a=(o[g+(c<<3)>>2]|0)+a|0,c=c+1|0;while((c|0)<(w|0))}c=P,g=o[c>>2]|0,c=o[c+4>>2]|0,w=((a|0)<0)<<31>>31,(c|0)<(w|0)|(c|0)==(w|0)&g>>>0<a>>>0?(c=P,o[c>>2]=a,o[c+4>>2]=w,c=w):a=g,z=Wt(a|0,c|0,12,0)|0,O=ae()|0,c=P,o[c>>2]=z,o[c+4>>2]=O,c=m,o[c>>2]=z,o[c+4>>2]=O,c=0}return O=c,te=S,O|0}function ks(l,a,c,m,g,w,P){l=l|0,a=a|0,c=c|0,m=m|0,g=g|0,w=w|0,P=P|0;var S=0,z=0,O=0,Z=0,se=0,pe=0,de=0,me=0,Ie=0,Be=0,Je=0,Oe=0,ze=0,De=0,bt=0,Zt=0,Nt=0,ai=0,pi=0,Mi=0,ei=0,Vt=0,vt=0,_t=0,Mt=0,li=0,Yi=0,wn=0,is=0;if(Mt=te,te=te+64|0,ei=Mt+48|0,Vt=Mt+32|0,vt=Mt+24|0,bt=Mt+8|0,Zt=Mt,z=o[l>>2]|0,(z|0)<=0)return _t=0,te=Mt,_t|0;for(Nt=l+4|0,ai=ei+8|0,pi=Vt+8|0,Mi=bt+8|0,S=0,ze=0;;){O=o[Nt>>2]|0,Oe=O+(ze<<4)|0,o[ei>>2]=o[Oe>>2],o[ei+4>>2]=o[Oe+4>>2],o[ei+8>>2]=o[Oe+8>>2],o[ei+12>>2]=o[Oe+12>>2],(ze|0)==(z+-1|0)?(o[Vt>>2]=o[O>>2],o[Vt+4>>2]=o[O+4>>2],o[Vt+8>>2]=o[O+8>>2],o[Vt+12>>2]=o[O+12>>2]):(Oe=O+(ze+1<<4)|0,o[Vt>>2]=o[Oe>>2],o[Vt+4>>2]=o[Oe+4>>2],o[Vt+8>>2]=o[Oe+8>>2],o[Vt+12>>2]=o[Oe+12>>2]),z=Yn(ei,Vt,m,vt)|0;e:do if(z)O=0,S=z;else if(z=vt,O=o[z>>2]|0,z=o[z+4>>2]|0,(z|0)>0|(z|0)==0&O>>>0>0){Je=0,Oe=0;t:for(;;){if(Yi=1/(+(O>>>0)+4294967296*+(z|0)),is=+X[ei>>3],z=wr(O|0,z|0,Je|0,Oe|0)|0,wn=+(z>>>0)+4294967296*+(ae()|0),li=+(Je>>>0)+4294967296*+(Oe|0),X[bt>>3]=Yi*(is*wn)+Yi*(+X[Vt>>3]*li),X[Mi>>3]=Yi*(+X[ai>>3]*wn)+Yi*(+X[pi>>3]*li),z=Fn(bt,m,Zt)|0,z|0){S=z;break}Be=Zt,Ie=o[Be>>2]|0,Be=o[Be+4>>2]|0,pe=Do(Ie|0,Be|0,a|0,c|0)|0,Z=ae()|0,z=P+(pe<<3)|0,se=z,O=o[se>>2]|0,se=o[se+4>>2]|0;i:do if((O|0)==0&(se|0)==0)De=z,_t=16;else for(de=0,me=0;;){if((de|0)>(c|0)|(de|0)==(c|0)&me>>>0>a>>>0){S=1;break t}if((O|0)==(Ie|0)&(se|0)==(Be|0))break i;if(z=Wt(pe|0,Z|0,1,0)|0,pe=ul(z|0,ae()|0,a|0,c|0)|0,Z=ae()|0,me=Wt(me|0,de|0,1,0)|0,de=ae()|0,z=P+(pe<<3)|0,se=z,O=o[se>>2]|0,se=o[se+4>>2]|0,(O|0)==0&(se|0)==0){De=z,_t=16;break}}while(!1);if((_t|0)==16&&(_t=0,!((Ie|0)==0&(Be|0)==0))&&(me=De,o[me>>2]=Ie,o[me+4>>2]=Be,me=w+(o[g>>2]<<3)|0,o[me>>2]=Ie,o[me+4>>2]=Be,me=g,me=Wt(o[me>>2]|0,o[me+4>>2]|0,1,0)|0,Ie=ae()|0,Be=g,o[Be>>2]=me,o[Be+4>>2]=Ie),Je=Wt(Je|0,Oe|0,1,0)|0,Oe=ae()|0,z=vt,O=o[z>>2]|0,z=o[z+4>>2]|0,!((z|0)>(Oe|0)|(z|0)==(Oe|0)&O>>>0>Je>>>0)){O=1;break e}}O=0}else O=1;while(!1);if(ze=ze+1|0,!O){_t=21;break}if(z=o[l>>2]|0,(ze|0)>=(z|0)){S=0,_t=21;break}}return(_t|0)==21?(te=Mt,S|0):0}function Ca(l,a,c,m){l=l|0,a=a|0,c=c|0,m=m|0;var g=0,w=0,P=0,S=0,z=0,O=0,Z=0,se=0,pe=0,de=0,me=0,Ie=0,Be=0,Je=0,Oe=0,ze=0,De=0,bt=0,Zt=0,Nt=0,ai=0,pi=0,Mi=0,ei=0,Vt=0,vt=0,_t=0,Mt=0,li=0,Yi=0,wn=0;if(wn=te,te=te+112|0,_t=wn+80|0,z=wn+72|0,Mt=wn,li=wn+56|0,g=tt(c)|0,g|0)return Yi=g,te=wn,Yi|0;if(O=l+8|0,Yi=Js((o[O>>2]<<5)+32|0)|0,!Yi)return Yi=13,te=wn,Yi|0;if(gt(l,Yi),g=tt(c)|0,!g){if(Vt=l,vt=o[Vt+4>>2]|0,g=z,o[g>>2]=o[Vt>>2],o[g+4>>2]=vt,Ze(z,_t),g=ca(_t,a,Mt)|0,g)Vt=0,vt=0;else{if(g=o[z>>2]|0,w=o[O>>2]|0,(w|0)>0){P=o[l+12>>2]|0,c=0;do g=(o[P+(c<<3)>>2]|0)+g|0,c=c+1|0;while((c|0)!=(w|0));c=g}else c=g;g=Mt,w=o[g>>2]|0,g=o[g+4>>2]|0,P=((c|0)<0)<<31>>31,(g|0)<(P|0)|(g|0)==(P|0)&w>>>0<c>>>0?(g=Mt,o[g>>2]=c,o[g+4>>2]=P,g=P):c=w,Vt=Wt(c|0,g|0,12,0)|0,vt=ae()|0,g=Mt,o[g>>2]=Vt,o[g+4>>2]=vt,g=0}if(!g){if(c=ts(Vt,8)|0,!c)return Qt(Yi),Yi=13,te=wn,Yi|0;if(S=ts(Vt,8)|0,!S)return Qt(Yi),Qt(c),Yi=13,te=wn,Yi|0;Mi=_t,o[Mi>>2]=0,o[Mi+4>>2]=0,Mi=l,ei=o[Mi+4>>2]|0,g=z,o[g>>2]=o[Mi>>2],o[g+4>>2]=ei,g=ks(z,Vt,vt,a,_t,c,S)|0;e:do if(g)Qt(c),Qt(S),Qt(Yi);else{t:do if((o[O>>2]|0)>0){for(P=l+12|0,w=0;g=ks((o[P>>2]|0)+(w<<3)|0,Vt,vt,a,_t,c,S)|0,w=w+1|0,!(g|0);)if((w|0)>=(o[O>>2]|0))break t;Qt(c),Qt(S),Qt(Yi);break e}while(!1);(vt|0)>0|(vt|0)==0&Vt>>>0>0&&bn(S|0,0,Vt<<3|0)|0,ei=_t,Mi=o[ei+4>>2]|0;t:do if((Mi|0)>0|(Mi|0)==0&(o[ei>>2]|0)>>>0>0){Nt=c,ai=S,pi=c,Mi=S,ei=c,g=c,De=c,bt=S,Zt=S,c=S;i:for(;;){for(Be=0,Je=0,Oe=0,ze=0,w=0,P=0;;){S=Mt,z=S+56|0;do o[S>>2]=0,S=S+4|0;while((S|0)<(z|0));if(a=Nt+(Be<<3)|0,O=o[a>>2]|0,a=o[a+4>>2]|0,Qa(O,a,1,Mt,0)|0){S=Mt,z=S+56|0;do o[S>>2]=0,S=S+4|0;while((S|0)<(z|0));S=ts(7,4)|0,S|0&&(Ln(O,a,1,Mt,S,7,0,0)|0,Qt(S))}for(Ie=0;;){me=Mt+(Ie<<3)|0,de=o[me>>2]|0,me=o[me+4>>2]|0;r:do if((de|0)==0&(me|0)==0)S=w,z=P;else{if(Z=Do(de|0,me|0,Vt|0,vt|0)|0,O=ae()|0,S=m+(Z<<3)|0,a=S,z=o[a>>2]|0,a=o[a+4>>2]|0,!((z|0)==0&(a|0)==0)){se=0,pe=0;do{if((se|0)>(vt|0)|(se|0)==(vt|0)&pe>>>0>Vt>>>0)break i;if((z|0)==(de|0)&(a|0)==(me|0)){S=w,z=P;break r}S=Wt(Z|0,O|0,1,0)|0,Z=ul(S|0,ae()|0,Vt|0,vt|0)|0,O=ae()|0,pe=Wt(pe|0,se|0,1,0)|0,se=ae()|0,S=m+(Z<<3)|0,a=S,z=o[a>>2]|0,a=o[a+4>>2]|0}while(!((z|0)==0&(a|0)==0))}if((de|0)==0&(me|0)==0){S=w,z=P;break}xs(de,me,li)|0,Rt(l,Yi,li)|0&&(pe=Wt(w|0,P|0,1,0)|0,P=ae()|0,se=S,o[se>>2]=de,o[se+4>>2]=me,w=ai+(w<<3)|0,o[w>>2]=de,o[w+4>>2]=me,w=pe),S=w,z=P}while(!1);if(Ie=Ie+1|0,Ie>>>0>=7)break;w=S,P=z}if(Be=Wt(Be|0,Je|0,1,0)|0,Je=ae()|0,Oe=Wt(Oe|0,ze|0,1,0)|0,ze=ae()|0,P=_t,w=o[P>>2]|0,P=o[P+4>>2]|0,(ze|0)<(P|0)|(ze|0)==(P|0)&Oe>>>0<w>>>0)w=S,P=z;else break}if((P|0)>0|(P|0)==0&w>>>0>0){w=0,P=0;do ze=Nt+(w<<3)|0,o[ze>>2]=0,o[ze+4>>2]=0,w=Wt(w|0,P|0,1,0)|0,P=ae()|0,ze=_t,Oe=o[ze+4>>2]|0;while((P|0)<(Oe|0)|((P|0)==(Oe|0)?w>>>0<(o[ze>>2]|0)>>>0:0))}if(ze=_t,o[ze>>2]=S,o[ze+4>>2]=z,(z|0)>0|(z|0)==0&S>>>0>0)Ie=c,Be=Zt,Je=ei,Oe=bt,ze=ai,c=De,Zt=g,bt=pi,De=Ie,g=Be,ei=Mi,Mi=Je,pi=Oe,ai=Nt,Nt=ze;else break t}Qt(pi),Qt(Mi),Qt(Yi),g=1;break e}else g=S;while(!1);Qt(Yi),Qt(c),Qt(g),g=0}while(!1);return Yi=g,te=wn,Yi|0}}return Qt(Yi),Yi=g,te=wn,Yi|0}function qo(l,a,c){l=l|0,a=a|0,c=c|0;var m=0,g=0,w=0,P=0,S=0,z=0,O=0,Z=0;if(Z=te,te=te+176|0,z=Z,(a|0)<1)return du(c,0,0),O=0,te=Z,O|0;for(S=l,S=ht(o[S>>2]|0,o[S+4>>2]|0,52)|0,ae()|0,du(c,(a|0)>6?a:6,S&15),S=0;m=l+(S<<3)|0,m=fs(o[m>>2]|0,o[m+4>>2]|0,z)|0,!(m|0);){if(m=o[z>>2]|0,(m|0)>0){P=0;do w=z+8+(P<<4)|0,P=P+1|0,m=z+8+(((P|0)%(m|0)|0)<<4)|0,g=gu(c,m,w)|0,g?ia(c,g)|0:_u(c,w,m)|0,m=o[z>>2]|0;while((P|0)<(m|0))}if(S=S+1|0,(S|0)>=(a|0)){m=0,O=13;break}}return(O|0)==13?(te=Z,m|0):(pu(c),O=m,te=Z,O|0)}function zs(l,a,c){l=l|0,a=a|0,c=c|0;var m=0,g=0,w=0,P=0;if(w=te,te=te+32|0,m=w,g=w+16|0,l=qo(l,a,g)|0,l|0)return c=l,te=w,c|0;if(o[c>>2]=0,o[c+4>>2]=0,o[c+8>>2]=0,l=mu(g)|0,l|0)do{a=ba(c)|0;do nl(a,l)|0,P=l+16|0,o[m>>2]=o[P>>2],o[m+4>>2]=o[P+4>>2],o[m+8>>2]=o[P+8>>2],o[m+12>>2]=o[P+12>>2],ia(g,l)|0,l=Sl(g,m)|0;while((l|0)!=0);l=mu(g)|0}while((l|0)!=0);return pu(g),l=sl(c)|0,l?(gi(c),P=l,te=w,P|0):(P=0,te=w,P|0)}function Vi(l){return l=l|0,l>>>0>121?(l=0,l|0):(l=o[7696+(l*28|0)+16>>2]|0,l|0)}function oi(l){return l=l|0,(l|0)==4|(l|0)==117|0}function Ho(l){return l=l|0,o[11120+((o[l>>2]|0)*216|0)+((o[l+4>>2]|0)*72|0)+((o[l+8>>2]|0)*24|0)+(o[l+12>>2]<<3)>>2]|0}function Nl(l){return l=l|0,o[11120+((o[l>>2]|0)*216|0)+((o[l+4>>2]|0)*72|0)+((o[l+8>>2]|0)*24|0)+(o[l+12>>2]<<3)+4>>2]|0}function Ia(l,a){l=l|0,a=a|0,l=7696+(l*28|0)|0,o[a>>2]=o[l>>2],o[a+4>>2]=o[l+4>>2],o[a+8>>2]=o[l+8>>2],o[a+12>>2]=o[l+12>>2]}function Wn(l,a){l=l|0,a=a|0;var c=0,m=0;if(a>>>0>20)return a=-1,a|0;do if((o[11120+(a*216|0)>>2]|0)!=(l|0))if((o[11120+(a*216|0)+8>>2]|0)!=(l|0))if((o[11120+(a*216|0)+16>>2]|0)!=(l|0))if((o[11120+(a*216|0)+24>>2]|0)!=(l|0))if((o[11120+(a*216|0)+32>>2]|0)!=(l|0))if((o[11120+(a*216|0)+40>>2]|0)!=(l|0))if((o[11120+(a*216|0)+48>>2]|0)!=(l|0))if((o[11120+(a*216|0)+56>>2]|0)!=(l|0))if((o[11120+(a*216|0)+64>>2]|0)!=(l|0))if((o[11120+(a*216|0)+72>>2]|0)!=(l|0))if((o[11120+(a*216|0)+80>>2]|0)!=(l|0))if((o[11120+(a*216|0)+88>>2]|0)!=(l|0))if((o[11120+(a*216|0)+96>>2]|0)!=(l|0))if((o[11120+(a*216|0)+104>>2]|0)!=(l|0))if((o[11120+(a*216|0)+112>>2]|0)!=(l|0))if((o[11120+(a*216|0)+120>>2]|0)!=(l|0))if((o[11120+(a*216|0)+128>>2]|0)!=(l|0))if((o[11120+(a*216|0)+136>>2]|0)==(l|0))l=2,c=1,m=2;else{if((o[11120+(a*216|0)+144>>2]|0)==(l|0)){l=0,c=2,m=0;break}if((o[11120+(a*216|0)+152>>2]|0)==(l|0)){l=0,c=2,m=1;break}if((o[11120+(a*216|0)+160>>2]|0)==(l|0)){l=0,c=2,m=2;break}if((o[11120+(a*216|0)+168>>2]|0)==(l|0)){l=1,c=2,m=0;break}if((o[11120+(a*216|0)+176>>2]|0)==(l|0)){l=1,c=2,m=1;break}if((o[11120+(a*216|0)+184>>2]|0)==(l|0)){l=1,c=2,m=2;break}if((o[11120+(a*216|0)+192>>2]|0)==(l|0)){l=2,c=2,m=0;break}if((o[11120+(a*216|0)+200>>2]|0)==(l|0)){l=2,c=2,m=1;break}if((o[11120+(a*216|0)+208>>2]|0)==(l|0)){l=2,c=2,m=2;break}else l=-1;return l|0}else l=2,c=1,m=1;else l=2,c=1,m=0;else l=1,c=1,m=2;else l=1,c=1,m=1;else l=1,c=1,m=0;else l=0,c=1,m=2;else l=0,c=1,m=1;else l=0,c=1,m=0;else l=2,c=0,m=2;else l=2,c=0,m=1;else l=2,c=0,m=0;else l=1,c=0,m=2;else l=1,c=0,m=1;else l=1,c=0,m=0;else l=0,c=0,m=2;else l=0,c=0,m=1;else l=0,c=0,m=0;while(!1);return a=o[11120+(a*216|0)+(c*72|0)+(l*24|0)+(m<<3)+4>>2]|0,a|0}function Ht(l,a){return l=l|0,a=a|0,(o[7696+(l*28|0)+20>>2]|0)==(a|0)?(a=1,a|0):(a=(o[7696+(l*28|0)+24>>2]|0)==(a|0),a|0)}function Li(l,a){return l=l|0,a=a|0,o[848+(l*28|0)+(a<<2)>>2]|0}function Dt(l,a){return l=l|0,a=a|0,(o[848+(l*28|0)>>2]|0)==(a|0)?(a=0,a|0):(o[848+(l*28|0)+4>>2]|0)==(a|0)?(a=1,a|0):(o[848+(l*28|0)+8>>2]|0)==(a|0)?(a=2,a|0):(o[848+(l*28|0)+12>>2]|0)==(a|0)?(a=3,a|0):(o[848+(l*28|0)+16>>2]|0)==(a|0)?(a=4,a|0):(o[848+(l*28|0)+20>>2]|0)==(a|0)?(a=5,a|0):((o[848+(l*28|0)+24>>2]|0)==(a|0)?6:7)|0}function Ki(){return 122}function Zs(l){l=l|0;var a=0,c=0,m=0;a=0;do yt(a|0,0,45)|0,m=ae()|0|134225919,c=l+(a<<3)|0,o[c>>2]=-1,o[c+4>>2]=m,a=a+1|0;while((a|0)!=122);return 0}function cn(l){l=l|0;var a=0,c=0,m=0;return m=+X[l+16>>3],c=+X[l+24>>3],a=m-c,+(m<c?a+6.283185307179586:a)}function gn(l){return l=l|0,+X[l+16>>3]<+X[l+24>>3]|0}function Lr(l){return l=l|0,+(+X[l>>3]-+X[l+8>>3])}function Us(l,a){l=l|0,a=a|0;var c=0,m=0,g=0;return c=+X[a>>3],!(c>=+X[l+8>>3])||!(c<=+X[l>>3])?(a=0,a|0):(m=+X[l+16>>3],c=+X[l+24>>3],g=+X[a+8>>3],a=g>=c,l=g<=m&1,m<c?a&&(l=1):a||(l=0),a=(l|0)!=0,a|0)}function Qn(l,a){l=l|0,a=a|0;var c=0,m=0,g=0,w=0,P=0,S=0,z=0,O=0,Z=0;return+X[l>>3]<+X[a+8>>3]||+X[l+8>>3]>+X[a>>3]?(m=0,m|0):(w=+X[l+16>>3],c=l+24|0,Z=+X[c>>3],P=w<Z,m=a+16|0,O=+X[m>>3],g=a+24|0,z=+X[g>>3],S=O<z,a=Z-O<z-w,l=P?S|a?1:2:0,a=S?P?1:a?2:1:0,w=+$r(w,l),w<+$r(+X[g>>3],a)||(Z=+$r(+X[c>>3],l),Z>+$r(+X[m>>3],a))?(S=0,S|0):(S=1,S|0))}function Si(l,a,c,m){l=l|0,a=a|0,c=c|0,m=m|0;var g=0,w=0,P=0,S=0,z=0;w=+X[l+16>>3],z=+X[l+24>>3],l=w<z,S=+X[a+16>>3],P=+X[a+24>>3],g=S<P,a=z-S<P-w,o[c>>2]=l?g|a?1:2:0,o[m>>2]=g?l?1:a?2:1:0}function $n(l,a){l=l|0,a=a|0;var c=0,m=0,g=0,w=0,P=0,S=0,z=0,O=0,Z=0;return+X[l>>3]<+X[a>>3]||+X[l+8>>3]>+X[a+8>>3]?(m=0,m|0):(m=l+16|0,z=+X[m>>3],w=+X[l+24>>3],P=z<w,c=a+16|0,Z=+X[c>>3],g=a+24|0,O=+X[g>>3],S=Z<O,a=w-Z<O-z,l=P?S|a?1:2:0,a=S?P?1:a?2:1:0,w=+$r(w,l),w<=+$r(+X[g>>3],a)?(Z=+$r(+X[m>>3],l),S=Z>=+$r(+X[c>>3],a),S|0):(S=0,S|0))}function gs(l,a){l=l|0,a=a|0;var c=0,m=0,g=0,w=0,P=0,S=0;g=te,te=te+176|0,m=g,o[m>>2]=4,S=+X[a>>3],X[m+8>>3]=S,w=+X[a+16>>3],X[m+16>>3]=w,X[m+24>>3]=S,S=+X[a+24>>3],X[m+32>>3]=S,P=+X[a+8>>3],X[m+40>>3]=P,X[m+48>>3]=S,X[m+56>>3]=P,X[m+64>>3]=w,a=m+72|0,c=a+96|0;do o[a>>2]=0,a=a+4|0;while((a|0)<(c|0));fo(l|0,m|0,168)|0,te=g}function ca(l,a,c){l=l|0,a=a|0,c=c|0;var m=0,g=0,w=0,P=0,S=0,z=0,O=0,Z=0,se=0,pe=0,de=0,me=0,Ie=0,Be=0;me=te,te=te+288|0,Z=me+264|0,se=me+96|0,O=me,S=O,z=S+96|0;do o[S>>2]=0,S=S+4|0;while((S|0)<(z|0));return a=Pl(a,O)|0,a|0?(de=a,te=me,de|0):(z=O,O=o[z>>2]|0,z=o[z+4>>2]|0,xs(O,z,Z)|0,fs(O,z,se)|0,P=+Xs(Z,se+8|0),X[Z>>3]=+X[l>>3],z=Z+8|0,X[z>>3]=+X[l+16>>3],X[se>>3]=+X[l+8>>3],O=se+8|0,X[O>>3]=+X[l+24>>3],g=+Xs(Z,se),Be=+X[z>>3]-+X[O>>3],w=+ut(+Be),Ie=+X[Z>>3]-+X[se>>3],m=+ut(+Ie),!(Be==0|Ie==0)&&(Be=+Nu(+w,+m),Be=+qn(+(g*g/+eu(+(Be/+eu(+w,+m)),3)/(P*(P*2.59807621135)*.8))),X[ii>>3]=Be,pe=~~Be>>>0,de=+ut(Be)>=1?Be>0?~~+bo(+Qi(Be/4294967296),4294967295)>>>0:~~+qn((Be-+(~~Be>>>0))/4294967296)>>>0:0,(o[ii+4>>2]&2146435072|0)!=2146435072)?(se=(pe|0)==0&(de|0)==0,a=c,o[a>>2]=se?1:pe,o[a+4>>2]=se?0:de,a=0):a=1,de=a,te=me,de|0)}function Yn(l,a,c,m){l=l|0,a=a|0,c=c|0,m=m|0;var g=0,w=0,P=0,S=0,z=0,O=0,Z=0;O=te,te=te+288|0,P=O+264|0,S=O+96|0,z=O,g=z,w=g+96|0;do o[g>>2]=0,g=g+4|0;while((g|0)<(w|0));return c=Pl(c,z)|0,c|0?(m=c,te=O,m|0):(c=z,g=o[c>>2]|0,c=o[c+4>>2]|0,xs(g,c,P)|0,fs(g,c,S)|0,Z=+Xs(P,S+8|0),Z=+qn(+(+Xs(l,a)/(Z*2))),X[ii>>3]=Z,c=~~Z>>>0,g=+ut(Z)>=1?Z>0?~~+bo(+Qi(Z/4294967296),4294967295)>>>0:~~+qn((Z-+(~~Z>>>0))/4294967296)>>>0:0,(o[ii+4>>2]&2146435072|0)==2146435072?(m=1,te=O,m|0):(z=(c|0)==0&(g|0)==0,o[m>>2]=z?1:c,o[m+4>>2]=z?0:g,m=0,te=O,m|0))}function Po(l,a){l=l|0,a=+a;var c=0,m=0,g=0,w=0,P=0,S=0,z=0,O=0,Z=0;w=l+16|0,P=+X[w>>3],c=l+24|0,g=+X[c>>3],m=P-g,m=P<g?m+6.283185307179586:m,O=+X[l>>3],S=l+8|0,z=+X[S>>3],Z=O-z,m=(m*a-m)*.5,a=(Z*a-Z)*.5,O=O+a,X[l>>3]=O>1.5707963267948966?1.5707963267948966:O,a=z-a,X[S>>3]=a<-1.5707963267948966?-1.5707963267948966:a,a=P+m,a=a>3.141592653589793?a+-6.283185307179586:a,X[w>>3]=a<-3.141592653589793?a+6.283185307179586:a,a=g-m,a=a>3.141592653589793?a+-6.283185307179586:a,X[c>>3]=a<-3.141592653589793?a+6.283185307179586:a}function Ls(l,a,c,m){l=l|0,a=a|0,c=c|0,m=m|0,o[l>>2]=a,o[l+4>>2]=c,o[l+8>>2]=m}function Vl(l,a){l=l|0,a=a|0;var c=0,m=0,g=0,w=0,P=0,S=0,z=0,O=0,Z=0,se=0,pe=0;se=a+8|0,o[se>>2]=0,z=+X[l>>3],P=+ut(+z),O=+X[l+8>>3],S=+ut(+O)*1.1547005383792515,P=P+S*.5,c=~~P,l=~~S,P=P-+(c|0),S=S-+(l|0);do if(P<.5)if(P<.3333333333333333)if(o[a>>2]=c,S<(P+1)*.5){o[a+4>>2]=l;break}else{l=l+1|0,o[a+4>>2]=l;break}else if(pe=1-P,l=(!(S<pe)&1)+l|0,o[a+4>>2]=l,pe<=S&S<P*2){c=c+1|0,o[a>>2]=c;break}else{o[a>>2]=c;break}else{if(!(P<.6666666666666666))if(c=c+1|0,o[a>>2]=c,S<P*.5){o[a+4>>2]=l;break}else{l=l+1|0,o[a+4>>2]=l;break}if(S<1-P){if(o[a+4>>2]=l,P*2+-1<S){o[a>>2]=c;break}}else l=l+1|0,o[a+4>>2]=l;c=c+1|0,o[a>>2]=c}while(!1);do if(z<0)if(l&1){Z=(l+1|0)/2|0,Z=wr(c|0,((c|0)<0)<<31>>31|0,Z|0,((Z|0)<0)<<31>>31|0)|0,c=~~(+(c|0)-((+(Z>>>0)+4294967296*+(ae()|0))*2+1)),o[a>>2]=c;break}else{Z=(l|0)/2|0,Z=wr(c|0,((c|0)<0)<<31>>31|0,Z|0,((Z|0)<0)<<31>>31|0)|0,c=~~(+(c|0)-(+(Z>>>0)+4294967296*+(ae()|0))*2),o[a>>2]=c;break}while(!1);Z=a+4|0,O<0&&(c=c-((l<<1|1|0)/2|0)|0,o[a>>2]=c,l=0-l|0,o[Z>>2]=l),m=l-c|0,(c|0)<0?(g=0-c|0,o[Z>>2]=m,o[se>>2]=g,o[a>>2]=0,l=m,c=0):g=0,(l|0)<0&&(c=c-l|0,o[a>>2]=c,g=g-l|0,o[se>>2]=g,o[Z>>2]=0,l=0),w=c-g|0,m=l-g|0,(g|0)<0&&(o[a>>2]=w,o[Z>>2]=m,o[se>>2]=0,l=m,c=w,g=0),m=(l|0)<(c|0)?l:c,m=(g|0)<(m|0)?g:m,!((m|0)<=0)&&(o[a>>2]=c-m,o[Z>>2]=l-m,o[se>>2]=g-m)}function Qr(l){l=l|0;var a=0,c=0,m=0,g=0,w=0,P=0;a=o[l>>2]|0,P=l+4|0,c=o[P>>2]|0,(a|0)<0&&(c=c-a|0,o[P>>2]=c,w=l+8|0,o[w>>2]=(o[w>>2]|0)-a,o[l>>2]=0,a=0),(c|0)<0?(a=a-c|0,o[l>>2]=a,w=l+8|0,g=(o[w>>2]|0)-c|0,o[w>>2]=g,o[P>>2]=0,c=0):(g=l+8|0,w=g,g=o[g>>2]|0),(g|0)<0&&(a=a-g|0,o[l>>2]=a,c=c-g|0,o[P>>2]=c,o[w>>2]=0,g=0),m=(c|0)<(a|0)?c:a,m=(g|0)<(m|0)?g:m,!((m|0)<=0)&&(o[l>>2]=a-m,o[P>>2]=c-m,o[w>>2]=g-m)}function hi(l,a){l=l|0,a=a|0;var c=0,m=0;m=o[l+8>>2]|0,c=+((o[l+4>>2]|0)-m|0),X[a>>3]=+((o[l>>2]|0)-m|0)-c*.5,X[a+8>>3]=c*.8660254037844386}function bi(l,a,c){l=l|0,a=a|0,c=c|0,o[c>>2]=(o[a>>2]|0)+(o[l>>2]|0),o[c+4>>2]=(o[a+4>>2]|0)+(o[l+4>>2]|0),o[c+8>>2]=(o[a+8>>2]|0)+(o[l+8>>2]|0)}function nn(l,a,c){l=l|0,a=a|0,c=c|0,o[c>>2]=(o[l>>2]|0)-(o[a>>2]|0),o[c+4>>2]=(o[l+4>>2]|0)-(o[a+4>>2]|0),o[c+8>>2]=(o[l+8>>2]|0)-(o[a+8>>2]|0)}function wi(l,a){l=l|0,a=a|0;var c=0,m=0;c=Hn(o[l>>2]|0,a)|0,o[l>>2]=c,c=l+4|0,m=Hn(o[c>>2]|0,a)|0,o[c>>2]=m,l=l+8|0,a=Hn(o[l>>2]|0,a)|0,o[l>>2]=a}function ri(l){l=l|0;var a=0,c=0,m=0,g=0,w=0,P=0,S=0;P=o[l>>2]|0,S=(P|0)<0,m=(o[l+4>>2]|0)-(S?P:0)|0,w=(m|0)<0,g=(w?0-m|0:0)+((o[l+8>>2]|0)-(S?P:0))|0,c=(g|0)<0,l=c?0:g,a=(w?0:m)-(c?g:0)|0,g=(S?0:P)-(w?m:0)-(c?g:0)|0,c=(a|0)<(g|0)?a:g,c=(l|0)<(c|0)?l:c,m=(c|0)>0,l=l-(m?c:0)|0,a=a-(m?c:0)|0;e:do switch(g-(m?c:0)|0){case 0:switch(a|0){case 0:return S=(l|0)==0?0:(l|0)==1?1:7,S|0;case 1:return S=(l|0)==0?2:(l|0)==1?3:7,S|0;default:break e}case 1:switch(a|0){case 0:return S=(l|0)==0?4:(l|0)==1?5:7,S|0;case 1:{if(!l)l=6;else break e;return l|0}default:break e}}while(!1);return S=7,S|0}function Aa(l){l=l|0;var a=0,c=0,m=0,g=0,w=0,P=0,S=0,z=0,O=0;if(z=l+8|0,P=o[z>>2]|0,S=(o[l>>2]|0)-P|0,O=l+4|0,P=(o[O>>2]|0)-P|0,S>>>0>715827881|P>>>0>715827881){if(m=(S|0)>0,g=2147483647-S|0,w=-2147483648-S|0,(m?(g|0)<(S|0):(w|0)>(S|0))||(c=S<<1,m?(2147483647-c|0)<(S|0):(-2147483648-c|0)>(S|0))||((P|0)>0?(2147483647-P|0)<(P|0):(-2147483648-P|0)>(P|0))||(a=S*3|0,c=P<<1,(m?(g|0)<(c|0):(w|0)>(c|0))||((S|0)>-1?(a|-2147483648|0)>=(P|0):(a^-2147483648|0)<(P|0))))return O=1,O|0}else c=P<<1,a=S*3|0;return m=Io(+(a-P|0)*.14285714285714285)|0,o[l>>2]=m,g=Io(+(c+S|0)*.14285714285714285)|0,o[O>>2]=g,o[z>>2]=0,c=(g|0)<(m|0),a=c?m:g,c=c?g:m,(c|0)<0&&(((c|0)==-2147483648||((a|0)>0?(2147483647-a|0)<(c|0):(-2147483648-a|0)>(c|0)))&&qt(27795,26892,354,26903),((a|0)>-1?(a|-2147483648|0)>=(c|0):(a^-2147483648|0)<(c|0))&&qt(27795,26892,354,26903)),a=g-m|0,(m|0)<0?(c=0-m|0,o[O>>2]=a,o[z>>2]=c,o[l>>2]=0,m=0):(a=g,c=0),(a|0)<0&&(m=m-a|0,o[l>>2]=m,c=c-a|0,o[z>>2]=c,o[O>>2]=0,a=0),w=m-c|0,g=a-c|0,(c|0)<0?(o[l>>2]=w,o[O>>2]=g,o[z>>2]=0,a=g,g=w,c=0):g=m,m=(a|0)<(g|0)?a:g,m=(c|0)<(m|0)?c:m,(m|0)<=0?(O=0,O|0):(o[l>>2]=g-m,o[O>>2]=a-m,o[z>>2]=c-m,O=0,O|0)}function Ci(l){l=l|0;var a=0,c=0,m=0,g=0,w=0,P=0,S=0,z=0;if(P=l+8|0,g=o[P>>2]|0,w=(o[l>>2]|0)-g|0,S=l+4|0,g=(o[S>>2]|0)-g|0,w>>>0>715827881|g>>>0>715827881){if(c=(w|0)>0,(c?(2147483647-w|0)<(w|0):(-2147483648-w|0)>(w|0))||(a=w<<1,m=(g|0)>0,m?(2147483647-g|0)<(g|0):(-2147483648-g|0)>(g|0)))return S=1,S|0;if(z=g<<1,(m?(2147483647-z|0)<(g|0):(-2147483648-z|0)>(g|0))||(c?(2147483647-a|0)<(g|0):(-2147483648-a|0)>(g|0))||(c=g*3|0,(g|0)>-1?(c|-2147483648|0)>=(w|0):(c^-2147483648|0)<(w|0)))return z=1,z|0}else c=g*3|0,a=w<<1;return m=Io(+(a+g|0)*.14285714285714285)|0,o[l>>2]=m,g=Io(+(c-w|0)*.14285714285714285)|0,o[S>>2]=g,o[P>>2]=0,c=(g|0)<(m|0),a=c?m:g,c=c?g:m,(c|0)<0&&(((c|0)==-2147483648||((a|0)>0?(2147483647-a|0)<(c|0):(-2147483648-a|0)>(c|0)))&&qt(27795,26892,402,26917),((a|0)>-1?(a|-2147483648|0)>=(c|0):(a^-2147483648|0)<(c|0))&&qt(27795,26892,402,26917)),a=g-m|0,(m|0)<0?(c=0-m|0,o[S>>2]=a,o[P>>2]=c,o[l>>2]=0,m=0):(a=g,c=0),(a|0)<0&&(m=m-a|0,o[l>>2]=m,c=c-a|0,o[P>>2]=c,o[S>>2]=0,a=0),w=m-c|0,g=a-c|0,(c|0)<0?(o[l>>2]=w,o[S>>2]=g,o[P>>2]=0,a=g,g=w,c=0):g=m,m=(a|0)<(g|0)?a:g,m=(c|0)<(m|0)?c:m,(m|0)<=0?(z=0,z|0):(o[l>>2]=g-m,o[S>>2]=a-m,o[P>>2]=c-m,z=0,z|0)}function Da(l){l=l|0;var a=0,c=0,m=0,g=0,w=0,P=0,S=0;P=l+8|0,c=o[P>>2]|0,a=(o[l>>2]|0)-c|0,S=l+4|0,c=(o[S>>2]|0)-c|0,m=Io(+((a*3|0)-c|0)*.14285714285714285)|0,o[l>>2]=m,a=Io(+((c<<1)+a|0)*.14285714285714285)|0,o[S>>2]=a,o[P>>2]=0,c=a-m|0,(m|0)<0?(w=0-m|0,o[S>>2]=c,o[P>>2]=w,o[l>>2]=0,a=c,m=0,c=w):c=0,(a|0)<0&&(m=m-a|0,o[l>>2]=m,c=c-a|0,o[P>>2]=c,o[S>>2]=0,a=0),w=m-c|0,g=a-c|0,(c|0)<0?(o[l>>2]=w,o[S>>2]=g,o[P>>2]=0,a=g,g=w,c=0):g=m,m=(a|0)<(g|0)?a:g,m=(c|0)<(m|0)?c:m,!((m|0)<=0)&&(o[l>>2]=g-m,o[S>>2]=a-m,o[P>>2]=c-m)}function Xn(l){l=l|0;var a=0,c=0,m=0,g=0,w=0,P=0,S=0;P=l+8|0,c=o[P>>2]|0,a=(o[l>>2]|0)-c|0,S=l+4|0,c=(o[S>>2]|0)-c|0,m=Io(+((a<<1)+c|0)*.14285714285714285)|0,o[l>>2]=m,a=Io(+((c*3|0)-a|0)*.14285714285714285)|0,o[S>>2]=a,o[P>>2]=0,c=a-m|0,(m|0)<0?(w=0-m|0,o[S>>2]=c,o[P>>2]=w,o[l>>2]=0,a=c,m=0,c=w):c=0,(a|0)<0&&(m=m-a|0,o[l>>2]=m,c=c-a|0,o[P>>2]=c,o[S>>2]=0,a=0),w=m-c|0,g=a-c|0,(c|0)<0?(o[l>>2]=w,o[S>>2]=g,o[P>>2]=0,a=g,g=w,c=0):g=m,m=(a|0)<(g|0)?a:g,m=(c|0)<(m|0)?c:m,!((m|0)<=0)&&(o[l>>2]=g-m,o[S>>2]=a-m,o[P>>2]=c-m)}function oo(l){l=l|0;var a=0,c=0,m=0,g=0,w=0,P=0,S=0;a=o[l>>2]|0,P=l+4|0,c=o[P>>2]|0,S=l+8|0,m=o[S>>2]|0,g=c+(a*3|0)|0,o[l>>2]=g,c=m+(c*3|0)|0,o[P>>2]=c,a=(m*3|0)+a|0,o[S>>2]=a,m=c-g|0,(g|0)<0?(a=a-g|0,o[P>>2]=m,o[S>>2]=a,o[l>>2]=0,c=m,m=0):m=g,(c|0)<0&&(m=m-c|0,o[l>>2]=m,a=a-c|0,o[S>>2]=a,o[P>>2]=0,c=0),w=m-a|0,g=c-a|0,(a|0)<0?(o[l>>2]=w,o[P>>2]=g,o[S>>2]=0,m=w,a=0):g=c,c=(g|0)<(m|0)?g:m,c=(a|0)<(c|0)?a:c,!((c|0)<=0)&&(o[l>>2]=m-c,o[P>>2]=g-c,o[S>>2]=a-c)}function Kn(l){l=l|0;var a=0,c=0,m=0,g=0,w=0,P=0,S=0;g=o[l>>2]|0,P=l+4|0,a=o[P>>2]|0,S=l+8|0,c=o[S>>2]|0,m=(a*3|0)+g|0,g=c+(g*3|0)|0,o[l>>2]=g,o[P>>2]=m,a=(c*3|0)+a|0,o[S>>2]=a,c=m-g|0,(g|0)<0?(a=a-g|0,o[P>>2]=c,o[S>>2]=a,o[l>>2]=0,g=0):c=m,(c|0)<0&&(g=g-c|0,o[l>>2]=g,a=a-c|0,o[S>>2]=a,o[P>>2]=0,c=0),w=g-a|0,m=c-a|0,(a|0)<0?(o[l>>2]=w,o[P>>2]=m,o[S>>2]=0,g=w,a=0):m=c,c=(m|0)<(g|0)?m:g,c=(a|0)<(c|0)?a:c,!((c|0)<=0)&&(o[l>>2]=g-c,o[P>>2]=m-c,o[S>>2]=a-c)}function ka(l,a){l=l|0,a=a|0;var c=0,m=0,g=0,w=0,P=0,S=0;(a+-1|0)>>>0>=6||(g=(o[15440+(a*12|0)>>2]|0)+(o[l>>2]|0)|0,o[l>>2]=g,S=l+4|0,m=(o[15440+(a*12|0)+4>>2]|0)+(o[S>>2]|0)|0,o[S>>2]=m,P=l+8|0,a=(o[15440+(a*12|0)+8>>2]|0)+(o[P>>2]|0)|0,o[P>>2]=a,c=m-g|0,(g|0)<0?(a=a-g|0,o[S>>2]=c,o[P>>2]=a,o[l>>2]=0,m=0):(c=m,m=g),(c|0)<0&&(m=m-c|0,o[l>>2]=m,a=a-c|0,o[P>>2]=a,o[S>>2]=0,c=0),w=m-a|0,g=c-a|0,(a|0)<0?(o[l>>2]=w,o[S>>2]=g,o[P>>2]=0,m=w,a=0):g=c,c=(g|0)<(m|0)?g:m,c=(a|0)<(c|0)?a:c,!((c|0)<=0)&&(o[l>>2]=m-c,o[S>>2]=g-c,o[P>>2]=a-c))}function fa(l){l=l|0;var a=0,c=0,m=0,g=0,w=0,P=0,S=0;g=o[l>>2]|0,P=l+4|0,a=o[P>>2]|0,S=l+8|0,c=o[S>>2]|0,m=a+g|0,g=c+g|0,o[l>>2]=g,o[P>>2]=m,a=c+a|0,o[S>>2]=a,c=m-g|0,(g|0)<0?(a=a-g|0,o[P>>2]=c,o[S>>2]=a,o[l>>2]=0,m=0):(c=m,m=g),(c|0)<0&&(m=m-c|0,o[l>>2]=m,a=a-c|0,o[S>>2]=a,o[P>>2]=0,c=0),w=m-a|0,g=c-a|0,(a|0)<0?(o[l>>2]=w,o[P>>2]=g,o[S>>2]=0,m=w,a=0):g=c,c=(g|0)<(m|0)?g:m,c=(a|0)<(c|0)?a:c,!((c|0)<=0)&&(o[l>>2]=m-c,o[P>>2]=g-c,o[S>>2]=a-c)}function Bn(l){l=l|0;var a=0,c=0,m=0,g=0,w=0,P=0,S=0;a=o[l>>2]|0,P=l+4|0,m=o[P>>2]|0,S=l+8|0,c=o[S>>2]|0,g=m+a|0,o[l>>2]=g,m=c+m|0,o[P>>2]=m,a=c+a|0,o[S>>2]=a,c=m-g|0,(g|0)<0?(a=a-g|0,o[P>>2]=c,o[S>>2]=a,o[l>>2]=0,m=0):(c=m,m=g),(c|0)<0&&(m=m-c|0,o[l>>2]=m,a=a-c|0,o[S>>2]=a,o[P>>2]=0,c=0),w=m-a|0,g=c-a|0,(a|0)<0?(o[l>>2]=w,o[P>>2]=g,o[S>>2]=0,m=w,a=0):g=c,c=(g|0)<(m|0)?g:m,c=(a|0)<(c|0)?a:c,!((c|0)<=0)&&(o[l>>2]=m-c,o[P>>2]=g-c,o[S>>2]=a-c)}function Wo(l){switch(l=l|0,l|0){case 1:{l=5;break}case 5:{l=4;break}case 4:{l=6;break}case 6:{l=2;break}case 2:{l=3;break}case 3:{l=1;break}}return l|0}function Gs(l){switch(l=l|0,l|0){case 1:{l=3;break}case 3:{l=2;break}case 2:{l=6;break}case 6:{l=4;break}case 4:{l=5;break}case 5:{l=1;break}}return l|0}function xr(l){l=l|0;var a=0,c=0,m=0,g=0,w=0,P=0,S=0;a=o[l>>2]|0,P=l+4|0,c=o[P>>2]|0,S=l+8|0,m=o[S>>2]|0,g=c+(a<<1)|0,o[l>>2]=g,c=m+(c<<1)|0,o[P>>2]=c,a=(m<<1)+a|0,o[S>>2]=a,m=c-g|0,(g|0)<0?(a=a-g|0,o[P>>2]=m,o[S>>2]=a,o[l>>2]=0,c=m,m=0):m=g,(c|0)<0&&(m=m-c|0,o[l>>2]=m,a=a-c|0,o[S>>2]=a,o[P>>2]=0,c=0),w=m-a|0,g=c-a|0,(a|0)<0?(o[l>>2]=w,o[P>>2]=g,o[S>>2]=0,m=w,a=0):g=c,c=(g|0)<(m|0)?g:m,c=(a|0)<(c|0)?a:c,!((c|0)<=0)&&(o[l>>2]=m-c,o[P>>2]=g-c,o[S>>2]=a-c)}function ys(l){l=l|0;var a=0,c=0,m=0,g=0,w=0,P=0,S=0;g=o[l>>2]|0,P=l+4|0,a=o[P>>2]|0,S=l+8|0,c=o[S>>2]|0,m=(a<<1)+g|0,g=c+(g<<1)|0,o[l>>2]=g,o[P>>2]=m,a=(c<<1)+a|0,o[S>>2]=a,c=m-g|0,(g|0)<0?(a=a-g|0,o[P>>2]=c,o[S>>2]=a,o[l>>2]=0,g=0):c=m,(c|0)<0&&(g=g-c|0,o[l>>2]=g,a=a-c|0,o[S>>2]=a,o[P>>2]=0,c=0),w=g-a|0,m=c-a|0,(a|0)<0?(o[l>>2]=w,o[P>>2]=m,o[S>>2]=0,g=w,a=0):m=c,c=(m|0)<(g|0)?m:g,c=(a|0)<(c|0)?a:c,!((c|0)<=0)&&(o[l>>2]=g-c,o[P>>2]=m-c,o[S>>2]=a-c)}function ir(l,a){l=l|0,a=a|0;var c=0,m=0,g=0,w=0,P=0,S=0;return P=(o[l>>2]|0)-(o[a>>2]|0)|0,S=(P|0)<0,m=(o[l+4>>2]|0)-(o[a+4>>2]|0)-(S?P:0)|0,w=(m|0)<0,g=(S?0-P|0:0)+(o[l+8>>2]|0)-(o[a+8>>2]|0)+(w?0-m|0:0)|0,l=(g|0)<0,a=l?0:g,c=(w?0:m)-(l?g:0)|0,g=(S?0:P)-(w?m:0)-(l?g:0)|0,l=(c|0)<(g|0)?c:g,l=(a|0)<(l|0)?a:l,m=(l|0)>0,a=a-(m?l:0)|0,c=c-(m?l:0)|0,l=g-(m?l:0)|0,l=(l|0)>-1?l:0-l|0,c=(c|0)>-1?c:0-c|0,a=(a|0)>-1?a:0-a|0,a=(c|0)>(a|0)?c:a,((l|0)>(a|0)?l:a)|0}function ao(l,a){l=l|0,a=a|0;var c=0;c=o[l+8>>2]|0,o[a>>2]=(o[l>>2]|0)-c,o[a+4>>2]=(o[l+4>>2]|0)-c}function yl(l,a){l=l|0,a=a|0;var c=0,m=0,g=0,w=0,P=0,S=0;return m=o[l>>2]|0,o[a>>2]=m,g=o[l+4>>2]|0,P=a+4|0,o[P>>2]=g,S=a+8|0,o[S>>2]=0,c=(g|0)<(m|0),l=c?m:g,c=c?g:m,(c|0)<0&&((c|0)==-2147483648||((l|0)>0?(2147483647-l|0)<(c|0):(-2147483648-l|0)>(c|0))||((l|0)>-1?(l|-2147483648|0)>=(c|0):(l^-2147483648|0)<(c|0)))?(a=1,a|0):(l=g-m|0,(m|0)<0?(c=0-m|0,o[P>>2]=l,o[S>>2]=c,o[a>>2]=0,m=0):(l=g,c=0),(l|0)<0&&(m=m-l|0,o[a>>2]=m,c=c-l|0,o[S>>2]=c,o[P>>2]=0,l=0),w=m-c|0,g=l-c|0,(c|0)<0?(o[a>>2]=w,o[P>>2]=g,o[S>>2]=0,l=g,g=w,c=0):g=m,m=(l|0)<(g|0)?l:g,m=(c|0)<(m|0)?c:m,(m|0)<=0?(a=0,a|0):(o[a>>2]=g-m,o[P>>2]=l-m,o[S>>2]=c-m,a=0,a|0))}function Qo(l){l=l|0;var a=0,c=0,m=0,g=0;a=l+8|0,g=o[a>>2]|0,c=g-(o[l>>2]|0)|0,o[l>>2]=c,m=l+4|0,l=(o[m>>2]|0)-g|0,o[m>>2]=l,o[a>>2]=0-(l+c)}function dr(l){l=l|0;var a=0,c=0,m=0,g=0,w=0,P=0,S=0;c=o[l>>2]|0,a=0-c|0,o[l>>2]=a,P=l+8|0,o[P>>2]=0,S=l+4|0,m=o[S>>2]|0,g=m+c|0,(c|0)>0?(o[S>>2]=g,o[P>>2]=c,o[l>>2]=0,a=0,m=g):c=0,(m|0)<0?(w=a-m|0,o[l>>2]=w,c=c-m|0,o[P>>2]=c,o[S>>2]=0,g=w-c|0,a=0-c|0,(c|0)<0?(o[l>>2]=g,o[S>>2]=a,o[P>>2]=0,m=a,c=0):(m=0,g=w)):g=a,a=(m|0)<(g|0)?m:g,a=(c|0)<(a|0)?c:a,!((a|0)<=0)&&(o[l>>2]=g-a,o[S>>2]=m-a,o[P>>2]=c-a)}function jl(l,a,c,m,g){l=l|0,a=a|0,c=c|0,m=m|0,g=g|0;var w=0,P=0,S=0,z=0,O=0,Z=0,se=0;if(se=te,te=te+64|0,Z=se,S=se+56|0,!(!0&(a&2013265920|0)==134217728&(!0&(m&2013265920|0)==134217728)))return g=5,te=se,g|0;if((l|0)==(c|0)&(a|0)==(m|0))return o[g>>2]=0,g=0,te=se,g|0;if(P=ht(l|0,a|0,52)|0,ae()|0,P=P&15,O=ht(c|0,m|0,52)|0,ae()|0,(P|0)!=(O&15|0))return g=12,te=se,g|0;if(w=P+-1|0,P>>>0>1){Xa(l,a,w,Z)|0,Xa(c,m,w,S)|0,O=Z,z=o[O>>2]|0,O=o[O+4>>2]|0;e:do if((z|0)==(o[S>>2]|0)&&(O|0)==(o[S+4>>2]|0)){P=(P^15)*3|0,w=ht(l|0,a|0,P|0)|0,ae()|0,w=w&7,P=ht(c|0,m|0,P|0)|0,ae()|0,P=P&7;do if((w|0)==0|(P|0)==0)o[g>>2]=1,w=0;else if((w|0)==7)w=5;else{if((w|0)==1|(P|0)==1&&$i(z,O)|0){w=5;break}if((o[15536+(w<<2)>>2]|0)!=(P|0)&&(o[15568+(w<<2)>>2]|0)!=(P|0))break e;o[g>>2]=1,w=0}while(!1);return g=w,te=se,g|0}while(!1)}w=Z,P=w+56|0;do o[w>>2]=0,w=w+4|0;while((w|0)<(P|0));return ha(l,a,1,Z)|0,a=Z,!((o[a>>2]|0)==(c|0)&&(o[a+4>>2]|0)==(m|0))&&(a=Z+8|0,!((o[a>>2]|0)==(c|0)&&(o[a+4>>2]|0)==(m|0)))&&(a=Z+16|0,!((o[a>>2]|0)==(c|0)&&(o[a+4>>2]|0)==(m|0)))&&(a=Z+24|0,!((o[a>>2]|0)==(c|0)&&(o[a+4>>2]|0)==(m|0)))&&(a=Z+32|0,!((o[a>>2]|0)==(c|0)&&(o[a+4>>2]|0)==(m|0)))&&(a=Z+40|0,!((o[a>>2]|0)==(c|0)&&(o[a+4>>2]|0)==(m|0)))?(w=Z+48|0,w=((o[w>>2]|0)==(c|0)?(o[w+4>>2]|0)==(m|0):0)&1):w=1,o[g>>2]=w,g=0,te=se,g|0}function vl(l,a,c,m,g){return l=l|0,a=a|0,c=c|0,m=m|0,g=g|0,c=js(l,a,c,m)|0,(c|0)==7?(g=11,g|0):(m=yt(c|0,0,56)|0,a=a&-2130706433|(ae()|0)|268435456,o[g>>2]=l|m,o[g+4>>2]=a,g=0,g|0)}function Ya(l,a,c){return l=l|0,a=a|0,c=c|0,!0&(a&2013265920|0)==268435456?(o[c>>2]=l,o[c+4>>2]=a&-2130706433|134217728,c=0,c|0):(c=6,c|0)}function uu(l,a,c){l=l|0,a=a|0,c=c|0;var m=0,g=0,w=0;return g=te,te=te+16|0,m=g,o[m>>2]=0,!0&(a&2013265920|0)==268435456?(w=ht(l|0,a|0,56)|0,ae()|0,m=ar(l,a&-2130706433|134217728,w&7,m,c)|0,te=g,m|0):(m=6,te=g,m|0)}function Mo(l,a){l=l|0,a=a|0;var c=0;switch(c=ht(l|0,a|0,56)|0,ae()|0,c&7){case 0:case 7:return c=0,c|0}return c=a&-2130706433|134217728,!(!0&(a&2013265920|0)==268435456)||!0&(a&117440512|0)==16777216&($i(l,c)|0)!=0?(c=0,c|0):(c=cs(l,c)|0,c|0)}function za(l,a,c){l=l|0,a=a|0,c=c|0;var m=0,g=0,w=0,P=0;return g=te,te=te+16|0,m=g,!0&(a&2013265920|0)==268435456?(w=a&-2130706433|134217728,P=c,o[P>>2]=l,o[P+4>>2]=w,o[m>>2]=0,a=ht(l|0,a|0,56)|0,ae()|0,m=ar(l,w,a&7,m,c+8|0)|0,te=g,m|0):(m=6,te=g,m|0)}function lo(l,a,c){l=l|0,a=a|0,c=c|0;var m=0,g=0;return g=($i(l,a)|0)==0,a=a&-2130706433,m=c,o[m>>2]=g?l:0,o[m+4>>2]=g?a|285212672:0,m=c+8|0,o[m>>2]=l,o[m+4>>2]=a|301989888,m=c+16|0,o[m>>2]=l,o[m+4>>2]=a|318767104,m=c+24|0,o[m>>2]=l,o[m+4>>2]=a|335544320,m=c+32|0,o[m>>2]=l,o[m+4>>2]=a|352321536,c=c+40|0,o[c>>2]=l,o[c+4>>2]=a|369098752,0}function vs(l,a,c){l=l|0,a=a|0,c=c|0;var m=0,g=0,w=0,P=0;return P=te,te=te+16|0,g=P,w=a&-2130706433|134217728,!0&(a&2013265920|0)==268435456?(m=ht(l|0,a|0,56)|0,ae()|0,m=Co(l,w,m&7)|0,(m|0)==-1?(o[c>>2]=0,w=6,te=P,w|0):($s(l,w,g)|0&&qt(27795,26932,282,26947),a=ht(l|0,a|0,52)|0,ae()|0,a=a&15,$i(l,w)|0?Eo(g,a,m,2,c):da(g,a,m,2,c),w=0,te=P,w|0)):(w=6,te=P,w|0)}function La(l,a,c){l=l|0,a=a|0,c=c|0;var m=0,g=0;m=te,te=te+16|0,g=m,qs(l,a,c,g),Vl(g,c+4|0),te=m}function qs(l,a,c,m){l=l|0,a=a|0,c=c|0,m=m|0;var g=0,w=0,P=0,S=0,z=0;if(S=te,te=te+16|0,z=S,An(l,c,z),w=+ni(+(1-+X[z>>3]*.5)),w<1e-16){o[m>>2]=0,o[m+4>>2]=0,o[m+8>>2]=0,o[m+12>>2]=0,te=S;return}if(z=o[c>>2]|0,g=+X[15920+(z*24|0)>>3],g=+Ii(g-+Ii(+_a(15600+(z<<4)|0,l))),vn(a)|0?P=+Ii(g+-.3334731722518321):P=g,g=+jr(+w)*2.618033988749896,(a|0)>0){l=0;do g=g*2.6457513110645907,l=l+1|0;while((l|0)!=(a|0))}w=+fi(+P)*g,X[m>>3]=w,P=+di(+P)*g,X[m+8>>3]=P,te=S}function An(l,a,c){l=l|0,a=a|0,c=c|0;var m=0,g=0,w=0;if(w=te,te=te+32|0,g=w,ll(l,g),o[a>>2]=0,X[c>>3]=5,m=+nr(16400,g),m<+X[c>>3]&&(o[a>>2]=0,X[c>>3]=m),m=+nr(16424,g),m<+X[c>>3]&&(o[a>>2]=1,X[c>>3]=m),m=+nr(16448,g),m<+X[c>>3]&&(o[a>>2]=2,X[c>>3]=m),m=+nr(16472,g),m<+X[c>>3]&&(o[a>>2]=3,X[c>>3]=m),m=+nr(16496,g),m<+X[c>>3]&&(o[a>>2]=4,X[c>>3]=m),m=+nr(16520,g),m<+X[c>>3]&&(o[a>>2]=5,X[c>>3]=m),m=+nr(16544,g),m<+X[c>>3]&&(o[a>>2]=6,X[c>>3]=m),m=+nr(16568,g),m<+X[c>>3]&&(o[a>>2]=7,X[c>>3]=m),m=+nr(16592,g),m<+X[c>>3]&&(o[a>>2]=8,X[c>>3]=m),m=+nr(16616,g),m<+X[c>>3]&&(o[a>>2]=9,X[c>>3]=m),m=+nr(16640,g),m<+X[c>>3]&&(o[a>>2]=10,X[c>>3]=m),m=+nr(16664,g),m<+X[c>>3]&&(o[a>>2]=11,X[c>>3]=m),m=+nr(16688,g),m<+X[c>>3]&&(o[a>>2]=12,X[c>>3]=m),m=+nr(16712,g),m<+X[c>>3]&&(o[a>>2]=13,X[c>>3]=m),m=+nr(16736,g),m<+X[c>>3]&&(o[a>>2]=14,X[c>>3]=m),m=+nr(16760,g),m<+X[c>>3]&&(o[a>>2]=15,X[c>>3]=m),m=+nr(16784,g),m<+X[c>>3]&&(o[a>>2]=16,X[c>>3]=m),m=+nr(16808,g),m<+X[c>>3]&&(o[a>>2]=17,X[c>>3]=m),m=+nr(16832,g),m<+X[c>>3]&&(o[a>>2]=18,X[c>>3]=m),m=+nr(16856,g),!(m<+X[c>>3])){te=w;return}o[a>>2]=19,X[c>>3]=m,te=w}function Ar(l,a,c,m,g){l=l|0,a=a|0,c=c|0,m=m|0,g=g|0;var w=0,P=0,S=0;if(w=+ea(l),w<1e-16){a=15600+(a<<4)|0,o[g>>2]=o[a>>2],o[g+4>>2]=o[a+4>>2],o[g+8>>2]=o[a+8>>2],o[g+12>>2]=o[a+12>>2];return}if(P=+kn(+ +X[l+8>>3],+ +X[l>>3]),(c|0)>0){l=0;do w=w*.37796447300922725,l=l+1|0;while((l|0)!=(c|0))}S=w*.3333333333333333,m?(c=(vn(c)|0)==0,w=+xo(+((c?S:S*.37796447300922725)*.381966011250105))):(w=+xo(+(w*.381966011250105)),vn(c)|0&&(P=+Ii(P+.3334731722518321))),ga(15600+(a<<4)|0,+Ii(+X[15920+(a*24|0)>>3]-P),w,g)}function xl(l,a,c){l=l|0,a=a|0,c=c|0;var m=0,g=0;m=te,te=te+16|0,g=m,hi(l+4|0,g),Ar(g,o[l>>2]|0,a,0,c),te=m}function Eo(l,a,c,m,g){l=l|0,a=a|0,c=c|0,m=m|0,g=g|0;var w=0,P=0,S=0,z=0,O=0,Z=0,se=0,pe=0,de=0,me=0,Ie=0,Be=0,Je=0,Oe=0,ze=0,De=0,bt=0,Zt=0,Nt=0,ai=0,pi=0,Mi=0,ei=0,Vt=0,vt=0,_t=0,Mt=0,li=0;if(_t=te,te=te+272|0,w=_t+256|0,Oe=_t+240|0,ei=_t,Vt=_t+224|0,vt=_t+208|0,ze=_t+176|0,De=_t+160|0,bt=_t+192|0,Zt=_t+144|0,Nt=_t+128|0,ai=_t+112|0,pi=_t+96|0,Mi=_t+80|0,o[w>>2]=a,o[Oe>>2]=o[l>>2],o[Oe+4>>2]=o[l+4>>2],o[Oe+8>>2]=o[l+8>>2],o[Oe+12>>2]=o[l+12>>2],So(Oe,w,ei),o[g>>2]=0,Oe=m+c+((m|0)==5&1)|0,(Oe|0)<=(c|0)){te=_t;return}z=o[w>>2]|0,O=Vt+4|0,Z=ze+4|0,se=c+5|0,pe=16880+(z<<2)|0,de=16960+(z<<2)|0,me=Nt+8|0,Ie=ai+8|0,Be=pi+8|0,Je=vt+4|0,S=c;e:for(;;){P=ei+(((S|0)%5|0)<<4)|0,o[vt>>2]=o[P>>2],o[vt+4>>2]=o[P+4>>2],o[vt+8>>2]=o[P+8>>2],o[vt+12>>2]=o[P+12>>2];do;while((Jn(vt,z,0,1)|0)==2);if((S|0)>(c|0)&(vn(a)|0)!=0){if(o[ze>>2]=o[vt>>2],o[ze+4>>2]=o[vt+4>>2],o[ze+8>>2]=o[vt+8>>2],o[ze+12>>2]=o[vt+12>>2],hi(O,De),m=o[ze>>2]|0,w=o[17040+(m*80|0)+(o[Vt>>2]<<2)>>2]|0,o[ze>>2]=o[18640+(m*80|0)+(w*20|0)>>2],P=o[18640+(m*80|0)+(w*20|0)+16>>2]|0,(P|0)>0){l=0;do fa(Z),l=l+1|0;while((l|0)<(P|0))}switch(P=18640+(m*80|0)+(w*20|0)+4|0,o[bt>>2]=o[P>>2],o[bt+4>>2]=o[P+4>>2],o[bt+8>>2]=o[P+8>>2],wi(bt,(o[pe>>2]|0)*3|0),bi(Z,bt,Z),Qr(Z),hi(Z,Zt),Mt=+(o[de>>2]|0),X[Nt>>3]=Mt*3,X[me>>3]=0,li=Mt*-1.5,X[ai>>3]=li,X[Ie>>3]=Mt*2.598076211353316,X[pi>>3]=li,X[Be>>3]=Mt*-2.598076211353316,o[17040+((o[ze>>2]|0)*80|0)+(o[vt>>2]<<2)>>2]|0){case 1:{l=ai,m=Nt;break}case 3:{l=pi,m=ai;break}case 2:{l=Nt,m=pi;break}default:{l=12;break e}}Nn(De,Zt,m,l,Mi),Ar(Mi,o[ze>>2]|0,z,1,g+8+(o[g>>2]<<4)|0),o[g>>2]=(o[g>>2]|0)+1}if((S|0)<(se|0)&&(hi(Je,ze),Ar(ze,o[vt>>2]|0,z,1,g+8+(o[g>>2]<<4)|0),o[g>>2]=(o[g>>2]|0)+1),o[Vt>>2]=o[vt>>2],o[Vt+4>>2]=o[vt+4>>2],o[Vt+8>>2]=o[vt+8>>2],o[Vt+12>>2]=o[vt+12>>2],S=S+1|0,(S|0)>=(Oe|0)){l=3;break}}if((l|0)==3){te=_t;return}else(l|0)==12&&qt(26970,27017,572,27027)}function So(l,a,c){l=l|0,a=a|0,c=c|0;var m=0,g=0,w=0,P=0,S=0,z=0;z=te,te=te+128|0,m=z+64|0,g=z,w=m,P=20240,S=w+60|0;do o[w>>2]=o[P>>2],w=w+4|0,P=P+4|0;while((w|0)<(S|0));w=g,P=20304,S=w+60|0;do o[w>>2]=o[P>>2],w=w+4|0,P=P+4|0;while((w|0)<(S|0));S=(vn(o[a>>2]|0)|0)==0,m=S?m:g,g=l+4|0,xr(g),ys(g),vn(o[a>>2]|0)|0&&(Kn(g),o[a>>2]=(o[a>>2]|0)+1),o[c>>2]=o[l>>2],a=c+4|0,bi(g,m,a),Qr(a),o[c+16>>2]=o[l>>2],a=c+20|0,bi(g,m+12|0,a),Qr(a),o[c+32>>2]=o[l>>2],a=c+36|0,bi(g,m+24|0,a),Qr(a),o[c+48>>2]=o[l>>2],a=c+52|0,bi(g,m+36|0,a),Qr(a),o[c+64>>2]=o[l>>2],c=c+68|0,bi(g,m+48|0,c),Qr(c),te=z}function Jn(l,a,c,m){l=l|0,a=a|0,c=c|0,m=m|0;var g=0,w=0,P=0,S=0,z=0,O=0,Z=0,se=0,pe=0,de=0,me=0;if(me=te,te=te+32|0,pe=me+12|0,S=me,de=l+4|0,se=o[16960+(a<<2)>>2]|0,Z=(m|0)!=0,se=Z?se*3|0:se,g=o[de>>2]|0,O=l+8|0,P=o[O>>2]|0,Z){if(w=l+12|0,m=o[w>>2]|0,g=P+g+m|0,(g|0)==(se|0))return de=1,te=me,de|0;z=w}else z=l+12|0,m=o[z>>2]|0,g=P+g+m|0;if((g|0)<=(se|0))return de=0,te=me,de|0;do if((m|0)>0){if(m=o[l>>2]|0,(P|0)>0){w=18640+(m*80|0)+60|0,m=l;break}m=18640+(m*80|0)+40|0,c?(Ls(pe,se,0,0),nn(de,pe,S),Bn(S),bi(S,pe,de),w=m,m=l):(w=m,m=l)}else w=18640+((o[l>>2]|0)*80|0)+20|0,m=l;while(!1);if(o[m>>2]=o[w>>2],g=w+16|0,(o[g>>2]|0)>0){m=0;do fa(de),m=m+1|0;while((m|0)<(o[g>>2]|0))}return l=w+4|0,o[pe>>2]=o[l>>2],o[pe+4>>2]=o[l+4>>2],o[pe+8>>2]=o[l+8>>2],a=o[16880+(a<<2)>>2]|0,wi(pe,Z?a*3|0:a),bi(de,pe,de),Qr(de),Z?m=((o[O>>2]|0)+(o[de>>2]|0)+(o[z>>2]|0)|0)==(se|0)?1:2:m=2,de=m,te=me,de|0}function hu(l,a){l=l|0,a=a|0;var c=0;do c=Jn(l,a,0,1)|0;while((c|0)==2);return c|0}function da(l,a,c,m,g){l=l|0,a=a|0,c=c|0,m=m|0,g=g|0;var w=0,P=0,S=0,z=0,O=0,Z=0,se=0,pe=0,de=0,me=0,Ie=0,Be=0,Je=0,Oe=0,ze=0,De=0,bt=0,Zt=0,Nt=0,ai=0,pi=0,Mi=0,ei=0;if(pi=te,te=te+240|0,w=pi+224|0,bt=pi+208|0,Zt=pi,Nt=pi+192|0,ai=pi+176|0,Be=pi+160|0,Je=pi+144|0,Oe=pi+128|0,ze=pi+112|0,De=pi+96|0,o[w>>2]=a,o[bt>>2]=o[l>>2],o[bt+4>>2]=o[l+4>>2],o[bt+8>>2]=o[l+8>>2],o[bt+12>>2]=o[l+12>>2],bl(bt,w,Zt),o[g>>2]=0,Ie=m+c+((m|0)==6&1)|0,(Ie|0)<=(c|0)){te=pi;return}z=o[w>>2]|0,O=c+6|0,Z=16960+(z<<2)|0,se=Je+8|0,pe=Oe+8|0,de=ze+8|0,me=Nt+4|0,P=0,S=c,m=-1;e:for(;;){if(w=(S|0)%6|0,l=Zt+(w<<4)|0,o[Nt>>2]=o[l>>2],o[Nt+4>>2]=o[l+4>>2],o[Nt+8>>2]=o[l+8>>2],o[Nt+12>>2]=o[l+12>>2],l=P,P=Jn(Nt,z,0,1)|0,(S|0)>(c|0)&(vn(a)|0)!=0&&(l|0)!=1&&(o[Nt>>2]|0)!=(m|0)){switch(hi(Zt+(((w+5|0)%6|0)<<4)+4|0,ai),hi(Zt+(w<<4)+4|0,Be),Mi=+(o[Z>>2]|0),X[Je>>3]=Mi*3,X[se>>3]=0,ei=Mi*-1.5,X[Oe>>3]=ei,X[pe>>3]=Mi*2.598076211353316,X[ze>>3]=ei,X[de>>3]=Mi*-2.598076211353316,w=o[bt>>2]|0,o[17040+(w*80|0)+(((m|0)==(w|0)?o[Nt>>2]|0:m)<<2)>>2]|0){case 1:{l=Oe,m=Je;break}case 3:{l=ze,m=Oe;break}case 2:{l=Je,m=ze;break}default:{l=8;break e}}Nn(ai,Be,m,l,De),!(pr(ai,De)|0)&&!(pr(Be,De)|0)&&(Ar(De,o[bt>>2]|0,z,1,g+8+(o[g>>2]<<4)|0),o[g>>2]=(o[g>>2]|0)+1)}if((S|0)<(O|0)&&(hi(me,ai),Ar(ai,o[Nt>>2]|0,z,1,g+8+(o[g>>2]<<4)|0),o[g>>2]=(o[g>>2]|0)+1),S=S+1|0,(S|0)>=(Ie|0)){l=3;break}else m=o[Nt>>2]|0}if((l|0)==3){te=pi;return}else(l|0)==8&&qt(27054,27017,737,27099)}function bl(l,a,c){l=l|0,a=a|0,c=c|0;var m=0,g=0,w=0,P=0,S=0,z=0;z=te,te=te+160|0,m=z+80|0,g=z,w=m,P=20368,S=w+72|0;do o[w>>2]=o[P>>2],w=w+4|0,P=P+4|0;while((w|0)<(S|0));w=g,P=20448,S=w+72|0;do o[w>>2]=o[P>>2],w=w+4|0,P=P+4|0;while((w|0)<(S|0));S=(vn(o[a>>2]|0)|0)==0,m=S?m:g,g=l+4|0,xr(g),ys(g),vn(o[a>>2]|0)|0&&(Kn(g),o[a>>2]=(o[a>>2]|0)+1),o[c>>2]=o[l>>2],a=c+4|0,bi(g,m,a),Qr(a),o[c+16>>2]=o[l>>2],a=c+20|0,bi(g,m+12|0,a),Qr(a),o[c+32>>2]=o[l>>2],a=c+36|0,bi(g,m+24|0,a),Qr(a),o[c+48>>2]=o[l>>2],a=c+52|0,bi(g,m+36|0,a),Qr(a),o[c+64>>2]=o[l>>2],a=c+68|0,bi(g,m+48|0,a),Qr(a),o[c+80>>2]=o[l>>2],c=c+84|0,bi(g,m+60|0,c),Qr(c),te=z}function pa(l,a){return l=l|0,a=a|0,a=ht(l|0,a|0,52)|0,ae()|0,a&15|0}function Rn(l,a){return l=l|0,a=a|0,a=ht(l|0,a|0,45)|0,ae()|0,a&127|0}function $o(l,a,c,m){return l=l|0,a=a|0,c=c|0,m=m|0,(c+-1|0)>>>0>14?(m=4,m|0):(c=ht(l|0,a|0,(15-c|0)*3|0)|0,ae()|0,o[m>>2]=c&7,m=0,m|0)}function Zl(l,a,c,m){l=l|0,a=a|0,c=c|0,m=m|0;var g=0,w=0,P=0,S=0,z=0,O=0;if(l>>>0>15)return m=4,m|0;if(a>>>0>121)return m=17,m|0;P=yt(l|0,0,52)|0,g=ae()|0,S=yt(a|0,0,45)|0,g=g|(ae()|0)|134225919;e:do if((l|0)>=1){for(S=1,P=(At[20528+a>>0]|0)!=0,w=-1;;){if(a=o[c+(S+-1<<2)>>2]|0,a>>>0>6){g=18,a=10;break}if(!((a|0)==0|P^1))if((a|0)==1){g=19,a=10;break}else P=0;if(O=(15-S|0)*3|0,z=yt(7,0,O|0)|0,g=g&~(ae()|0),a=yt(a|0,((a|0)<0)<<31>>31|0,O|0)|0,w=a|w&~z,g=ae()|0|g,(S|0)<(l|0))S=S+1|0;else break e}if((a|0)==10)return g|0}else w=-1;while(!1);return O=m,o[O>>2]=w,o[O+4>>2]=g,O=0,O|0}function cs(l,a){l=l|0,a=a|0;var c=0,m=0,g=0,w=0,P=0;return!(!0&(a&-16777216|0)==134217728)||(m=ht(l|0,a|0,52)|0,ae()|0,m=m&15,c=ht(l|0,a|0,45)|0,ae()|0,c=c&127,c>>>0>121)?(l=0,l|0):(P=(m^15)*3|0,g=ht(l|0,a|0,P|0)|0,P=yt(g|0,ae()|0,P|0)|0,g=ae()|0,w=wr(-1227133514,-1171,P|0,g|0)|0,!((P&613566756&w|0)==0&(g&4681&(ae()|0)|0)==0)||(P=(m*3|0)+19|0,w=yt(~l|0,~a|0,P|0)|0,P=ht(w|0,ae()|0,P|0)|0,!((m|0)==15|(P|0)==0&(ae()|0)==0))?(P=0,P|0):!(At[20528+c>>0]|0)||(a=a&8191,(l|0)==0&(a|0)==0)?(P=1,P|0):(P=Jl(l|0,a|0)|0,ae()|0,((63-P|0)%3|0|0)!=0|0))}function wl(l,a){l=l|0,a=a|0;var c=0,m=0,g=0,w=0,P=0;return!0&(a&-16777216|0)==134217728&&(m=ht(l|0,a|0,52)|0,ae()|0,m=m&15,c=ht(l|0,a|0,45)|0,ae()|0,c=c&127,c>>>0<=121)&&(P=(m^15)*3|0,g=ht(l|0,a|0,P|0)|0,P=yt(g|0,ae()|0,P|0)|0,g=ae()|0,w=wr(-1227133514,-1171,P|0,g|0)|0,(P&613566756&w|0)==0&(g&4681&(ae()|0)|0)==0)&&(P=(m*3|0)+19|0,w=yt(~l|0,~a|0,P|0)|0,P=ht(w|0,ae()|0,P|0)|0,(m|0)==15|(P|0)==0&(ae()|0)==0)&&(!(At[20528+c>>0]|0)||(c=a&8191,(l|0)==0&(c|0)==0)||(P=Jl(l|0,c|0)|0,ae()|0,(63-P|0)%3|0|0))||Mo(l,a)|0?(P=1,P|0):(P=(fu(l,a)|0)!=0&1,P|0)}function Hs(l,a,c,m){l=l|0,a=a|0,c=c|0,m=m|0;var g=0,w=0,P=0,S=0;if(g=yt(a|0,0,52)|0,w=ae()|0,c=yt(c|0,0,45)|0,c=w|(ae()|0)|134225919,(a|0)<1){w=-1,m=c,a=l,o[a>>2]=w,l=l+4|0,o[l>>2]=m;return}for(w=1,g=-1;P=(15-w|0)*3|0,S=yt(7,0,P|0)|0,c=c&~(ae()|0),P=yt(m|0,0,P|0)|0,g=g&~S|P,c=c|(ae()|0),(w|0)!=(a|0);)w=w+1|0;S=l,P=S,o[P>>2]=g,S=S+4|0,o[S>>2]=c}function Xa(l,a,c,m){l=l|0,a=a|0,c=c|0,m=m|0;var g=0,w=0;if(w=ht(l|0,a|0,52)|0,ae()|0,w=w&15,c>>>0>15)return m=4,m|0;if((w|0)<(c|0))return m=12,m|0;if((w|0)==(c|0))return o[m>>2]=l,o[m+4>>2]=a,m=0,m|0;if(g=yt(c|0,0,52)|0,g=g|l,l=ae()|0|a&-15728641,(w|0)>(c|0))do a=yt(7,0,(14-c|0)*3|0)|0,c=c+1|0,g=a|g,l=ae()|0|l;while((c|0)<(w|0));return o[m>>2]=g,o[m+4>>2]=l,m=0,m|0}function Ws(l,a,c,m){l=l|0,a=a|0,c=c|0,m=m|0;var g=0,w=0,P=0;if(w=ht(l|0,a|0,52)|0,ae()|0,w=w&15,!((c|0)<16&(w|0)<=(c|0)))return m=4,m|0;g=c-w|0,c=ht(l|0,a|0,45)|0,ae()|0;e:do if(!(Vi(c&127)|0))c=ds(7,0,g,((g|0)<0)<<31>>31)|0,g=ae()|0;else{t:do if(w|0){for(c=1;P=yt(7,0,(15-c|0)*3|0)|0,!!((P&l|0)==0&((ae()|0)&a|0)==0);)if(c>>>0<w>>>0)c=c+1|0;else break t;c=ds(7,0,g,((g|0)<0)<<31>>31)|0,g=ae()|0;break e}while(!1);c=ds(7,0,g,((g|0)<0)<<31>>31)|0,c=lr(c|0,ae()|0,5,0)|0,c=Wt(c|0,ae()|0,-5,-1)|0,c=xn(c|0,ae()|0,6,0)|0,c=Wt(c|0,ae()|0,1,0)|0,g=ae()|0}while(!1);return P=m,o[P>>2]=c,o[P+4>>2]=g,P=0,P|0}function $i(l,a){l=l|0,a=a|0;var c=0,m=0,g=0;if(g=ht(l|0,a|0,45)|0,ae()|0,!(Vi(g&127)|0))return g=0,g|0;g=ht(l|0,a|0,52)|0,ae()|0,g=g&15;e:do if(!g)c=0;else for(m=1;;){if(c=ht(l|0,a|0,(15-m|0)*3|0)|0,ae()|0,c=c&7,c|0)break e;if(m>>>0<g>>>0)m=m+1|0;else{c=0;break}}while(!1);return g=(c|0)==0&1,g|0}function Qs(l,a,c,m){l=l|0,a=a|0,c=c|0,m=m|0;var g=0,w=0,P=0,S=0;if(P=te,te=te+16|0,w=P,el(w,l,a,c),a=w,l=o[a>>2]|0,a=o[a+4>>2]|0,(l|0)==0&(a|0)==0)return te=P,0;g=0,c=0;do S=m+(g<<3)|0,o[S>>2]=l,o[S+4>>2]=a,g=Wt(g|0,c|0,1,0)|0,c=ae()|0,tl(w),S=w,l=o[S>>2]|0,a=o[S+4>>2]|0;while(!((l|0)==0&(a|0)==0));return te=P,0}function Tl(l,a,c,m){return l=l|0,a=a|0,c=c|0,m=m|0,(m|0)<(c|0)?(c=a,m=l,Ft(c|0),m|0):(c=yt(-1,-1,((m-c|0)*3|0)+3|0)|0,m=yt(~c|0,~(ae()|0)|0,(15-m|0)*3|0)|0,c=~(ae()|0)&a,m=~m&l,Ft(c|0),m|0)}function Bs(l,a,c,m){l=l|0,a=a|0,c=c|0,m=m|0;var g=0;return g=ht(l|0,a|0,52)|0,ae()|0,g=g&15,(c|0)<16&(g|0)<=(c|0)?((g|0)<(c|0)&&(g=yt(-1,-1,((c+-1-g|0)*3|0)+3|0)|0,g=yt(~g|0,~(ae()|0)|0,(15-c|0)*3|0)|0,a=~(ae()|0)&a,l=~g&l),g=yt(c|0,0,52)|0,c=a&-15728641|(ae()|0),o[m>>2]=l|g,o[m+4>>2]=c,m=0,m|0):(m=4,m|0)}function uo(l,a,c,m){l=l|0,a=a|0,c=c|0,m=m|0;var g=0,w=0,P=0,S=0,z=0,O=0,Z=0,se=0,pe=0,de=0,me=0,Ie=0,Be=0,Je=0,Oe=0,ze=0,De=0,bt=0,Zt=0,Nt=0,ai=0,pi=0,Mi=0,ei=0,Vt=0,vt=0;if((c|0)==0&(m|0)==0)return vt=0,vt|0;if(g=l,w=o[g>>2]|0,g=o[g+4>>2]|0,!0&(g&15728640|0)==0){if(!((m|0)>0|(m|0)==0&c>>>0>0)||(vt=a,o[vt>>2]=w,o[vt+4>>2]=g,(c|0)==1&(m|0)==0))return vt=0,vt|0;g=1,w=0;do ei=l+(g<<3)|0,Vt=o[ei+4>>2]|0,vt=a+(g<<3)|0,o[vt>>2]=o[ei>>2],o[vt+4>>2]=Vt,g=Wt(g|0,w|0,1,0)|0,w=ae()|0;while((w|0)<(m|0)|(w|0)==(m|0)&g>>>0<c>>>0);return g=0,g|0}if(Mi=c<<3,Vt=Js(Mi)|0,!Vt)return vt=13,vt|0;if(fo(Vt|0,l|0,Mi|0)|0,ei=ts(c,8)|0,!ei)return Qt(Vt),vt=13,vt|0;e:for(;;){g=Vt,O=o[g>>2]|0,g=o[g+4>>2]|0,ai=ht(O|0,g|0,52)|0,ae()|0,ai=ai&15,pi=ai+-1|0,Nt=(ai|0)!=0,Zt=(m|0)>0|(m|0)==0&c>>>0>0;t:do if(Nt&Zt){if(Oe=yt(pi|0,0,52)|0,ze=ae()|0,pi>>>0>15){if(!((O|0)==0&(g|0)==0)){vt=16;break e}for(w=0,l=0;;){if(w=Wt(w|0,l|0,1,0)|0,l=ae()|0,!((l|0)<(m|0)|(l|0)==(m|0)&w>>>0<c>>>0))break t;if(P=Vt+(w<<3)|0,bt=o[P>>2]|0,P=o[P+4>>2]|0,!((bt|0)==0&(P|0)==0)){g=P,vt=16;break e}}}for(S=O,l=g,w=0,P=0;;){if(!((S|0)==0&(l|0)==0)){if(!(!0&(l&117440512|0)==0)){vt=21;break e}if(Z=ht(S|0,l|0,52)|0,ae()|0,Z=Z&15,(Z|0)<(pi|0)){g=12,vt=27;break e}if((Z|0)!=(pi|0)&&(S=S|Oe,l=l&-15728641|ze,Z>>>0>=ai>>>0)){z=pi;do bt=yt(7,0,(14-z|0)*3|0)|0,z=z+1|0,S=bt|S,l=ae()|0|l;while(z>>>0<Z>>>0)}if(pe=Do(S|0,l|0,c|0,m|0)|0,de=ae()|0,z=ei+(pe<<3)|0,Z=z,se=o[Z>>2]|0,Z=o[Z+4>>2]|0,!((se|0)==0&(Z|0)==0)){Be=0,Je=0;do{if((Be|0)>(m|0)|(Be|0)==(m|0)&Je>>>0>c>>>0){vt=31;break e}if((se|0)==(S|0)&(Z&-117440513|0)==(l|0)){me=ht(se|0,Z|0,56)|0,ae()|0,me=me&7,Ie=me+1|0,bt=ht(se|0,Z|0,45)|0,ae()|0;i:do if(!(Vi(bt&127)|0))Z=7;else{if(se=ht(se|0,Z|0,52)|0,ae()|0,se=se&15,!se){Z=6;break}for(Z=1;;){if(bt=yt(7,0,(15-Z|0)*3|0)|0,!((bt&S|0)==0&((ae()|0)&l|0)==0)){Z=7;break i}if(Z>>>0<se>>>0)Z=Z+1|0;else{Z=6;break}}}while(!1);if((me+2|0)>>>0>Z>>>0){vt=41;break e}bt=yt(Ie|0,0,56)|0,l=ae()|0|l&-117440513,De=z,o[De>>2]=0,o[De+4>>2]=0,S=bt|S}else pe=Wt(pe|0,de|0,1,0)|0,pe=ul(pe|0,ae()|0,c|0,m|0)|0,de=ae()|0;Je=Wt(Je|0,Be|0,1,0)|0,Be=ae()|0,z=ei+(pe<<3)|0,Z=z,se=o[Z>>2]|0,Z=o[Z+4>>2]|0}while(!((se|0)==0&(Z|0)==0))}bt=z,o[bt>>2]=S,o[bt+4>>2]=l}if(w=Wt(w|0,P|0,1,0)|0,P=ae()|0,!((P|0)<(m|0)|(P|0)==(m|0)&w>>>0<c>>>0))break t;l=Vt+(w<<3)|0,S=o[l>>2]|0,l=o[l+4>>2]|0}}while(!1);if(bt=Wt(c|0,m|0,5,0)|0,De=ae()|0,De>>>0<0|(De|0)==0&bt>>>0<11){vt=85;break}if(bt=xn(c|0,m|0,6,0)|0,ae()|0,bt=ts(bt,8)|0,!bt){vt=48;break}do if(Zt){for(Ie=0,l=0,me=0,Be=0;;){if(Z=ei+(Ie<<3)|0,P=Z,w=o[P>>2]|0,P=o[P+4>>2]|0,(w|0)==0&(P|0)==0)De=me;else{se=ht(w|0,P|0,56)|0,ae()|0,se=se&7,S=se+1|0,pe=P&-117440513,De=ht(w|0,P|0,45)|0,ae()|0;t:do if(Vi(De&127)|0){if(de=ht(w|0,P|0,52)|0,ae()|0,de=de&15,de|0)for(z=1;;){if(De=yt(7,0,(15-z|0)*3|0)|0,!((w&De|0)==0&(pe&(ae()|0)|0)==0))break t;if(z>>>0<de>>>0)z=z+1|0;else break}P=yt(S|0,0,56)|0,w=P|w,P=ae()|0|pe,S=Z,o[S>>2]=w,o[S+4>>2]=P,S=se+2|0}while(!1);(S|0)==7?(De=bt+(l<<3)|0,o[De>>2]=w,o[De+4>>2]=P&-117440513,l=Wt(l|0,me|0,1,0)|0,De=ae()|0):De=me}if(Ie=Wt(Ie|0,Be|0,1,0)|0,Be=ae()|0,(Be|0)<(m|0)|(Be|0)==(m|0)&Ie>>>0<c>>>0)me=De;else break}if(Zt){if(Je=pi>>>0>15,Oe=yt(pi|0,0,52)|0,ze=ae()|0,!Nt){for(w=0,z=0,S=0,P=0;(O|0)==0&(g|0)==0||(pi=a+(w<<3)|0,o[pi>>2]=O,o[pi+4>>2]=g,w=Wt(w|0,z|0,1,0)|0,z=ae()|0),S=Wt(S|0,P|0,1,0)|0,P=ae()|0,!!((P|0)<(m|0)|(P|0)==(m|0)&S>>>0<c>>>0);)g=Vt+(S<<3)|0,O=o[g>>2]|0,g=o[g+4>>2]|0;g=De;break}for(w=0,z=0,P=0,S=0;;){do if(!((O|0)==0&(g|0)==0)){if(de=ht(O|0,g|0,52)|0,ae()|0,de=de&15,Je|(de|0)<(pi|0)){vt=80;break e}if((de|0)!=(pi|0)){if(Z=O|Oe,se=g&-15728641|ze,de>>>0>=ai>>>0){pe=pi;do Nt=yt(7,0,(14-pe|0)*3|0)|0,pe=pe+1|0,Z=Nt|Z,se=ae()|0|se;while(pe>>>0<de>>>0)}}else Z=O,se=g;me=Do(Z|0,se|0,c|0,m|0)|0,pe=0,de=0,Be=ae()|0;do{if((pe|0)>(m|0)|(pe|0)==(m|0)&de>>>0>c>>>0){vt=81;break e}if(Nt=ei+(me<<3)|0,Ie=o[Nt+4>>2]|0,(Ie&-117440513|0)==(se|0)&&(o[Nt>>2]|0)==(Z|0)){vt=65;break}Nt=Wt(me|0,Be|0,1,0)|0,me=ul(Nt|0,ae()|0,c|0,m|0)|0,Be=ae()|0,de=Wt(de|0,pe|0,1,0)|0,pe=ae()|0,Nt=ei+(me<<3)|0}while(!((o[Nt>>2]|0)==(Z|0)&&(o[Nt+4>>2]|0)==(se|0)));if((vt|0)==65&&(vt=0,!0&(Ie&117440512|0)==100663296))break;Nt=a+(w<<3)|0,o[Nt>>2]=O,o[Nt+4>>2]=g,w=Wt(w|0,z|0,1,0)|0,z=ae()|0}while(!1);if(P=Wt(P|0,S|0,1,0)|0,S=ae()|0,!((S|0)<(m|0)|(S|0)==(m|0)&P>>>0<c>>>0))break;g=Vt+(P<<3)|0,O=o[g>>2]|0,g=o[g+4>>2]|0}g=De}else w=0,g=De}else w=0,l=0,g=0;while(!1);if(bn(ei|0,0,Mi|0)|0,fo(Vt|0,bt|0,l<<3|0)|0,Qt(bt),(l|0)==0&(g|0)==0){vt=89;break}else a=a+(w<<3)|0,m=g,c=l}if((vt|0)==16)!0&(g&117440512|0)==0?(g=4,vt=27):vt=21;else if((vt|0)==31)qt(27795,27122,620,27132);else{if((vt|0)==41)return Qt(Vt),Qt(ei),vt=10,vt|0;if((vt|0)==48)return Qt(Vt),Qt(ei),vt=13,vt|0;(vt|0)==80?qt(27795,27122,711,27132):(vt|0)==81?qt(27795,27122,723,27132):(vt|0)==85&&(fo(a|0,Vt|0,c<<3|0)|0,vt=89)}return(vt|0)==21?(Qt(Vt),Qt(ei),vt=5,vt|0):(vt|0)==27?(Qt(Vt),Qt(ei),vt=g,vt|0):(vt|0)==89?(Qt(Vt),Qt(ei),vt=0,vt|0):0}function Ul(l,a,c,m,g,w,P){l=l|0,a=a|0,c=c|0,m=m|0,g=g|0,w=w|0,P=P|0;var S=0,z=0,O=0,Z=0,se=0,pe=0,de=0,me=0,Ie=0;if(Ie=te,te=te+16|0,me=Ie,!((c|0)>0|(c|0)==0&a>>>0>0))return me=0,te=Ie,me|0;if((P|0)>=16)return me=12,te=Ie,me|0;pe=0,de=0,se=0,S=0;e:for(;;){if(O=l+(pe<<3)|0,z=o[O>>2]|0,O=o[O+4>>2]|0,Z=ht(z|0,O|0,52)|0,ae()|0,(Z&15|0)>(P|0)){S=12,z=11;break}if(el(me,z,O,P),Z=me,O=o[Z>>2]|0,Z=o[Z+4>>2]|0,(O|0)==0&(Z|0)==0)z=se;else{z=se;do{if(!((S|0)<(w|0)|(S|0)==(w|0)&z>>>0<g>>>0)){z=10;break e}se=m+(z<<3)|0,o[se>>2]=O,o[se+4>>2]=Z,z=Wt(z|0,S|0,1,0)|0,S=ae()|0,tl(me),se=me,O=o[se>>2]|0,Z=o[se+4>>2]|0}while(!((O|0)==0&(Z|0)==0))}if(pe=Wt(pe|0,de|0,1,0)|0,de=ae()|0,(de|0)<(c|0)|(de|0)==(c|0)&pe>>>0<a>>>0)se=z;else{S=0,z=11;break}}return(z|0)==10?(me=14,te=Ie,me|0):(z|0)==11?(te=Ie,S|0):0}function ma(l,a,c,m,g){l=l|0,a=a|0,c=c|0,m=m|0,g=g|0;var w=0,P=0,S=0,z=0,O=0,Z=0,se=0,pe=0;pe=te,te=te+16|0,se=pe;e:do if((c|0)>0|(c|0)==0&a>>>0>0){for(O=0,P=0,w=0,Z=0;;){if(z=l+(O<<3)|0,S=o[z>>2]|0,z=o[z+4>>2]|0,!((S|0)==0&(z|0)==0)&&(z=(Ws(S,z,m,se)|0)==0,S=se,P=Wt(o[S>>2]|0,o[S+4>>2]|0,P|0,w|0)|0,w=ae()|0,!z)){w=12;break}if(O=Wt(O|0,Z|0,1,0)|0,Z=ae()|0,!((Z|0)<(c|0)|(Z|0)==(c|0)&O>>>0<a>>>0))break e}return te=pe,w|0}else P=0,w=0;while(!1);return o[g>>2]=P,o[g+4>>2]=w,g=0,te=pe,g|0}function cu(l,a){return l=l|0,a=a|0,a=ht(l|0,a|0,52)|0,ae()|0,a&1|0}function Ir(l,a){l=l|0,a=a|0;var c=0,m=0,g=0;if(g=ht(l|0,a|0,52)|0,ae()|0,g=g&15,!g)return g=0,g|0;for(m=1;;){if(c=ht(l|0,a|0,(15-m|0)*3|0)|0,ae()|0,c=c&7,c|0){m=5;break}if(m>>>0<g>>>0)m=m+1|0;else{c=0,m=5;break}}return(m|0)==5?c|0:0}function Ka(l,a){l=l|0,a=a|0;var c=0,m=0,g=0,w=0,P=0,S=0,z=0;if(z=ht(l|0,a|0,52)|0,ae()|0,z=z&15,!z)return S=a,z=l,Ft(S|0),z|0;for(S=1,c=0;;){w=(15-S|0)*3|0,m=yt(7,0,w|0)|0,g=ae()|0,P=ht(l|0,a|0,w|0)|0,ae()|0,w=yt(Wo(P&7)|0,0,w|0)|0,P=ae()|0,l=w|l&~m,a=P|a&~g;e:do if(!c)if((w&m|0)==0&(P&g|0)==0)c=0;else if(m=ht(l|0,a|0,52)|0,ae()|0,m=m&15,!m)c=1;else{c=1;t:for(;;){switch(P=ht(l|0,a|0,(15-c|0)*3|0)|0,ae()|0,P&7){case 1:break t;case 0:break;default:{c=1;break e}}if(c>>>0<m>>>0)c=c+1|0;else{c=1;break e}}for(c=1;;)if(P=(15-c|0)*3|0,g=ht(l|0,a|0,P|0)|0,ae()|0,w=yt(7,0,P|0)|0,a=a&~(ae()|0),P=yt(Wo(g&7)|0,0,P|0)|0,l=l&~w|P,a=a|(ae()|0),c>>>0<m>>>0)c=c+1|0;else{c=1;break}}while(!1);if(S>>>0<z>>>0)S=S+1|0;else break}return Ft(a|0),l|0}function yn(l,a){l=l|0,a=a|0;var c=0,m=0,g=0,w=0,P=0;if(m=ht(l|0,a|0,52)|0,ae()|0,m=m&15,!m)return c=a,m=l,Ft(c|0),m|0;for(c=1;w=(15-c|0)*3|0,P=ht(l|0,a|0,w|0)|0,ae()|0,g=yt(7,0,w|0)|0,a=a&~(ae()|0),w=yt(Wo(P&7)|0,0,w|0)|0,l=w|l&~g,a=ae()|0|a,c>>>0<m>>>0;)c=c+1|0;return Ft(a|0),l|0}function Gl(l,a){l=l|0,a=a|0;var c=0,m=0,g=0,w=0,P=0,S=0,z=0;if(z=ht(l|0,a|0,52)|0,ae()|0,z=z&15,!z)return S=a,z=l,Ft(S|0),z|0;for(S=1,c=0;;){w=(15-S|0)*3|0,m=yt(7,0,w|0)|0,g=ae()|0,P=ht(l|0,a|0,w|0)|0,ae()|0,w=yt(Gs(P&7)|0,0,w|0)|0,P=ae()|0,l=w|l&~m,a=P|a&~g;e:do if(!c)if((w&m|0)==0&(P&g|0)==0)c=0;else if(m=ht(l|0,a|0,52)|0,ae()|0,m=m&15,!m)c=1;else{c=1;t:for(;;){switch(P=ht(l|0,a|0,(15-c|0)*3|0)|0,ae()|0,P&7){case 1:break t;case 0:break;default:{c=1;break e}}if(c>>>0<m>>>0)c=c+1|0;else{c=1;break e}}for(c=1;;)if(g=(15-c|0)*3|0,w=yt(7,0,g|0)|0,P=a&~(ae()|0),a=ht(l|0,a|0,g|0)|0,ae()|0,a=yt(Gs(a&7)|0,0,g|0)|0,l=l&~w|a,a=P|(ae()|0),c>>>0<m>>>0)c=c+1|0;else{c=1;break}}while(!1);if(S>>>0<z>>>0)S=S+1|0;else break}return Ft(a|0),l|0}function As(l,a){l=l|0,a=a|0;var c=0,m=0,g=0,w=0,P=0;if(m=ht(l|0,a|0,52)|0,ae()|0,m=m&15,!m)return c=a,m=l,Ft(c|0),m|0;for(c=1;P=(15-c|0)*3|0,w=yt(7,0,P|0)|0,g=a&~(ae()|0),a=ht(l|0,a|0,P|0)|0,ae()|0,a=yt(Gs(a&7)|0,0,P|0)|0,l=a|l&~w,a=ae()|0|g,c>>>0<m>>>0;)c=c+1|0;return Ft(a|0),l|0}function Ba(l,a){l=l|0,a=a|0;var c=0,m=0,g=0,w=0,P=0,S=0,z=0,O=0,Z=0;if(z=te,te=te+64|0,S=z+40|0,m=z+24|0,g=z+12|0,w=z,yt(a|0,0,52)|0,c=ae()|0|134225919,!a)return(o[l+4>>2]|0)>2||(o[l+8>>2]|0)>2||(o[l+12>>2]|0)>2?(P=0,S=0,Ft(P|0),te=z,S|0):(yt(Ho(l)|0,0,45)|0,P=ae()|0|c,S=-1,Ft(P|0),te=z,S|0);if(o[S>>2]=o[l>>2],o[S+4>>2]=o[l+4>>2],o[S+8>>2]=o[l+8>>2],o[S+12>>2]=o[l+12>>2],P=S+4|0,(a|0)>0)for(l=-1;o[m>>2]=o[P>>2],o[m+4>>2]=o[P+4>>2],o[m+8>>2]=o[P+8>>2],a&1?(Da(P),o[g>>2]=o[P>>2],o[g+4>>2]=o[P+4>>2],o[g+8>>2]=o[P+8>>2],oo(g)):(Xn(P),o[g>>2]=o[P>>2],o[g+4>>2]=o[P+4>>2],o[g+8>>2]=o[P+8>>2],Kn(g)),nn(m,g,w),Qr(w),Z=(15-a|0)*3|0,O=yt(7,0,Z|0)|0,c=c&~(ae()|0),Z=yt(ri(w)|0,0,Z|0)|0,l=Z|l&~O,c=ae()|0|c,(a|0)>1;)a=a+-1|0;else l=-1;e:do if((o[P>>2]|0)<=2&&(o[S+8>>2]|0)<=2&&(o[S+12>>2]|0)<=2){if(m=Ho(S)|0,a=yt(m|0,0,45)|0,a=a|l,l=ae()|0|c&-1040385,w=Nl(S)|0,!(Vi(m)|0)){if((w|0)<=0)break;for(g=0;;){if(m=ht(a|0,l|0,52)|0,ae()|0,m=m&15,m)for(c=1;Z=(15-c|0)*3|0,S=ht(a|0,l|0,Z|0)|0,ae()|0,O=yt(7,0,Z|0)|0,l=l&~(ae()|0),Z=yt(Wo(S&7)|0,0,Z|0)|0,a=a&~O|Z,l=l|(ae()|0),c>>>0<m>>>0;)c=c+1|0;if(g=g+1|0,(g|0)==(w|0))break e}}g=ht(a|0,l|0,52)|0,ae()|0,g=g&15;t:do if(g){c=1;i:for(;;){switch(Z=ht(a|0,l|0,(15-c|0)*3|0)|0,ae()|0,Z&7){case 1:break i;case 0:break;default:break t}if(c>>>0<g>>>0)c=c+1|0;else break t}if(Ht(m,o[S>>2]|0)|0)for(c=1;S=(15-c|0)*3|0,O=yt(7,0,S|0)|0,Z=l&~(ae()|0),l=ht(a|0,l|0,S|0)|0,ae()|0,l=yt(Gs(l&7)|0,0,S|0)|0,a=a&~O|l,l=Z|(ae()|0),c>>>0<g>>>0;)c=c+1|0;else for(c=1;Z=(15-c|0)*3|0,S=ht(a|0,l|0,Z|0)|0,ae()|0,O=yt(7,0,Z|0)|0,l=l&~(ae()|0),Z=yt(Wo(S&7)|0,0,Z|0)|0,a=a&~O|Z,l=l|(ae()|0),c>>>0<g>>>0;)c=c+1|0}while(!1);if((w|0)>0){c=0;do a=Ka(a,l)|0,l=ae()|0,c=c+1|0;while((c|0)!=(w|0))}}else a=0,l=0;while(!1);return O=l,Z=a,Ft(O|0),te=z,Z|0}function vn(l){return l=l|0,(l|0)%2|0|0}function Fn(l,a,c){l=l|0,a=a|0,c=c|0;var m=0,g=0;return g=te,te=te+16|0,m=g,a>>>0>15?(m=4,te=g,m|0):(o[l+4>>2]&2146435072|0)==2146435072||(o[l+8+4>>2]&2146435072|0)==2146435072?(m=3,te=g,m|0):(La(l,a,m),a=Ba(m,a)|0,m=ae()|0,o[c>>2]=a,o[c+4>>2]=m,(a|0)==0&(m|0)==0&&qt(27795,27122,1050,27145),m=0,te=g,m|0)}function ho(l,a,c){l=l|0,a=a|0,c=c|0;var m=0,g=0,w=0,P=0;if(g=c+4|0,w=ht(l|0,a|0,52)|0,ae()|0,w=w&15,P=ht(l|0,a|0,45)|0,ae()|0,m=(w|0)==0,Vi(P&127)|0){if(m)return P=1,P|0;m=1}else{if(m)return P=0,P|0;(o[g>>2]|0)==0&&(o[c+8>>2]|0)==0?m=(o[c+12>>2]|0)!=0&1:m=1}for(c=1;c&1?oo(g):Kn(g),P=ht(l|0,a|0,(15-c|0)*3|0)|0,ae()|0,ka(g,P&7),c>>>0<w>>>0;)c=c+1|0;return m|0}function $s(l,a,c){l=l|0,a=a|0,c=c|0;var m=0,g=0,w=0,P=0,S=0,z=0,O=0,Z=0;if(Z=te,te=te+16|0,z=Z,O=ht(l|0,a|0,45)|0,ae()|0,O=O&127,O>>>0>121)return o[c>>2]=0,o[c+4>>2]=0,o[c+8>>2]=0,o[c+12>>2]=0,O=5,te=Z,O|0;e:do if((Vi(O)|0)!=0&&(w=ht(l|0,a|0,52)|0,ae()|0,w=w&15,(w|0)!=0)){m=1;t:for(;;){switch(S=ht(l|0,a|0,(15-m|0)*3|0)|0,ae()|0,S&7){case 5:break t;case 0:break;default:{m=a;break e}}if(m>>>0<w>>>0)m=m+1|0;else{m=a;break e}}for(g=1,m=a;a=(15-g|0)*3|0,P=yt(7,0,a|0)|0,S=m&~(ae()|0),m=ht(l|0,m|0,a|0)|0,ae()|0,m=yt(Gs(m&7)|0,0,a|0)|0,l=l&~P|m,m=S|(ae()|0),g>>>0<w>>>0;)g=g+1|0}else m=a;while(!1);if(S=7696+(O*28|0)|0,o[c>>2]=o[S>>2],o[c+4>>2]=o[S+4>>2],o[c+8>>2]=o[S+8>>2],o[c+12>>2]=o[S+12>>2],!(ho(l,m,c)|0))return O=0,te=Z,O|0;if(P=c+4|0,o[z>>2]=o[P>>2],o[z+4>>2]=o[P+4>>2],o[z+8>>2]=o[P+8>>2],w=ht(l|0,m|0,52)|0,ae()|0,S=w&15,w&1?(Kn(P),w=S+1|0):w=S,!(Vi(O)|0))m=0;else{e:do if(!S)m=0;else for(a=1;;){if(g=ht(l|0,m|0,(15-a|0)*3|0)|0,ae()|0,g=g&7,g|0){m=g;break e}if(a>>>0<S>>>0)a=a+1|0;else{m=0;break}}while(!1);m=(m|0)==4&1}if(!(Jn(c,w,m,0)|0))(w|0)!=(S|0)&&(o[P>>2]=o[z>>2],o[P+4>>2]=o[z+4>>2],o[P+8>>2]=o[z+8>>2]);else{if(Vi(O)|0)do;while((Jn(c,w,0,0)|0)!=0);(w|0)!=(S|0)&&Xn(P)}return O=0,te=Z,O|0}function xs(l,a,c){l=l|0,a=a|0,c=c|0;var m=0,g=0,w=0;return w=te,te=te+16|0,m=w,g=$s(l,a,m)|0,g|0?(te=w,g|0):(g=ht(l|0,a|0,52)|0,ae()|0,xl(m,g&15,c),g=0,te=w,g|0)}function fs(l,a,c){l=l|0,a=a|0,c=c|0;var m=0,g=0,w=0,P=0,S=0;if(P=te,te=te+16|0,w=P,m=$s(l,a,w)|0,m|0)return w=m,te=P,w|0;m=ht(l|0,a|0,45)|0,ae()|0,m=(Vi(m&127)|0)==0,g=ht(l|0,a|0,52)|0,ae()|0,g=g&15;e:do if(!m){if(g|0)for(m=1;;){if(S=yt(7,0,(15-m|0)*3|0)|0,!((S&l|0)==0&((ae()|0)&a|0)==0))break e;if(m>>>0<g>>>0)m=m+1|0;else break}return Eo(w,g,0,5,c),S=0,te=P,S|0}while(!1);return da(w,g,0,6,c),S=0,te=P,S|0}function Yo(l,a,c){l=l|0,a=a|0,c=c|0;var m=0,g=0,w=0;if(g=ht(l|0,a|0,45)|0,ae()|0,!(Vi(g&127)|0))return g=2,o[c>>2]=g,0;if(g=ht(l|0,a|0,52)|0,ae()|0,g=g&15,!g)return g=5,o[c>>2]=g,0;for(m=1;;){if(w=yt(7,0,(15-m|0)*3|0)|0,!((w&l|0)==0&((ae()|0)&a|0)==0)){m=2,l=6;break}if(m>>>0<g>>>0)m=m+1|0;else{m=5,l=6;break}}return(l|0)==6&&(o[c>>2]=m),0}function Ys(l,a,c){l=l|0,a=a|0,c=c|0;var m=0,g=0,w=0,P=0,S=0,z=0,O=0,Z=0,se=0;se=te,te=te+128|0,O=se+112|0,w=se+96|0,Z=se,g=ht(l|0,a|0,52)|0,ae()|0,S=g&15,o[O>>2]=S,P=ht(l|0,a|0,45)|0,ae()|0,P=P&127;e:do if(Vi(P)|0){if(S|0)for(m=1;;){if(z=yt(7,0,(15-m|0)*3|0)|0,!((z&l|0)==0&((ae()|0)&a|0)==0)){g=0;break e}if(m>>>0<S>>>0)m=m+1|0;else break}if(g&1)g=1;else return z=yt(S+1|0,0,52)|0,Z=ae()|0|a&-15728641,O=yt(7,0,(14-S|0)*3|0)|0,Z=Ys((z|l)&~O,Z&~(ae()|0),c)|0,te=se,Z|0}else g=0;while(!1);if(m=$s(l,a,w)|0,!m){g?(So(w,O,Z),z=5):(bl(w,O,Z),z=6);e:do if(Vi(P)|0)if(!S)l=5;else for(m=1;;){if(P=yt(7,0,(15-m|0)*3|0)|0,!((P&l|0)==0&((ae()|0)&a|0)==0)){l=2;break e}if(m>>>0<S>>>0)m=m+1|0;else{l=5;break}}else l=2;while(!1);bn(c|0,-1,l<<2|0)|0;e:do if(g)for(w=0;;){if(P=Z+(w<<4)|0,hu(P,o[O>>2]|0)|0,P=o[P>>2]|0,S=o[c>>2]|0,(S|0)==-1|(S|0)==(P|0))m=c;else{g=0;do{if(g=g+1|0,g>>>0>=l>>>0){m=1;break e}m=c+(g<<2)|0,S=o[m>>2]|0}while(!((S|0)==-1|(S|0)==(P|0)))}if(o[m>>2]=P,w=w+1|0,w>>>0>=z>>>0){m=0;break}}else for(w=0;;){if(P=Z+(w<<4)|0,Jn(P,o[O>>2]|0,0,1)|0,P=o[P>>2]|0,S=o[c>>2]|0,(S|0)==-1|(S|0)==(P|0))m=c;else{g=0;do{if(g=g+1|0,g>>>0>=l>>>0){m=1;break e}m=c+(g<<2)|0,S=o[m>>2]|0}while(!((S|0)==-1|(S|0)==(P|0)))}if(o[m>>2]=P,w=w+1|0,w>>>0>=z>>>0){m=0;break}}while(!1)}return Z=m,te=se,Z|0}function Ja(){return 12}function Pl(l,a){l=l|0,a=a|0;var c=0,m=0,g=0,w=0,P=0,S=0,z=0;if(l>>>0>15)return S=4,S|0;if(yt(l|0,0,52)|0,S=ae()|0|134225919,!l){c=0,m=0;do Vi(m)|0&&(yt(m|0,0,45)|0,P=S|(ae()|0),l=a+(c<<3)|0,o[l>>2]=-1,o[l+4>>2]=P,c=c+1|0),m=m+1|0;while((m|0)!=122);return c=0,c|0}c=0,P=0;do{if(Vi(P)|0){for(yt(P|0,0,45)|0,m=1,g=-1,w=S|(ae()|0);z=yt(7,0,(15-m|0)*3|0)|0,g=g&~z,w=w&~(ae()|0),(m|0)!=(l|0);)m=m+1|0;z=a+(c<<3)|0,o[z>>2]=g,o[z+4>>2]=w,c=c+1|0}P=P+1|0}while((P|0)!=122);return c=0,c|0}function Ra(l,a,c,m){l=l|0,a=a|0,c=c|0,m=m|0;var g=0,w=0,P=0,S=0,z=0,O=0,Z=0,se=0,pe=0,de=0,me=0,Ie=0,Be=0,Je=0,Oe=0;if(Oe=te,te=te+16|0,Be=Oe,Je=ht(l|0,a|0,52)|0,ae()|0,Je=Je&15,c>>>0>15)return Je=4,te=Oe,Je|0;if((Je|0)<(c|0))return Je=12,te=Oe,Je|0;if((Je|0)!=(c|0))if(w=yt(c|0,0,52)|0,w=w|l,S=ae()|0|a&-15728641,(Je|0)>(c|0)){z=c;do Ie=yt(7,0,(14-z|0)*3|0)|0,z=z+1|0,w=Ie|w,S=ae()|0|S;while((z|0)<(Je|0));Ie=w}else Ie=w;else Ie=l,S=a;me=ht(Ie|0,S|0,45)|0,ae()|0;e:do if(Vi(me&127)|0){if(z=ht(Ie|0,S|0,52)|0,ae()|0,z=z&15,z|0)for(w=1;;){if(me=yt(7,0,(15-w|0)*3|0)|0,!((me&Ie|0)==0&((ae()|0)&S|0)==0)){O=33;break e}if(w>>>0<z>>>0)w=w+1|0;else break}if(me=m,o[me>>2]=0,o[me+4>>2]=0,(Je|0)>(c|0)){for(me=a&-15728641,de=Je;;){if(pe=de,de=de+-1|0,de>>>0>15|(Je|0)<(de|0)){O=19;break}if((Je|0)!=(de|0))if(w=yt(de|0,0,52)|0,w=w|l,z=ae()|0|me,(Je|0)<(pe|0))se=w;else{O=de;do se=yt(7,0,(14-O|0)*3|0)|0,O=O+1|0,w=se|w,z=ae()|0|z;while((O|0)<(Je|0));se=w}else se=l,z=a;if(Z=ht(se|0,z|0,45)|0,ae()|0,!(Vi(Z&127)|0))w=0;else{Z=ht(se|0,z|0,52)|0,ae()|0,Z=Z&15;t:do if(!Z)w=0;else for(O=1;;){if(w=ht(se|0,z|0,(15-O|0)*3|0)|0,ae()|0,w=w&7,w|0)break t;if(O>>>0<Z>>>0)O=O+1|0;else{w=0;break}}while(!1);w=(w|0)==0&1}if(z=ht(l|0,a|0,(15-pe|0)*3|0)|0,ae()|0,z=z&7,(z|0)==7){g=5,O=42;break}if(w=(w|0)!=0,(z|0)==1&w){g=5,O=42;break}if(se=z+(((z|0)!=0&w)<<31>>31)|0,se|0&&(O=Je-pe|0,O=ds(7,0,O,((O|0)<0)<<31>>31)|0,Z=ae()|0,w?(w=lr(O|0,Z|0,5,0)|0,w=Wt(w|0,ae()|0,-5,-1)|0,w=xn(w|0,ae()|0,6,0)|0,w=Wt(w|0,ae()|0,1,0)|0,z=ae()|0):(w=O,z=Z),pe=se+-1|0,pe=lr(O|0,Z|0,pe|0,((pe|0)<0)<<31>>31|0)|0,pe=Wt(w|0,z|0,pe|0,ae()|0)|0,se=ae()|0,Z=m,Z=Wt(pe|0,se|0,o[Z>>2]|0,o[Z+4>>2]|0)|0,se=ae()|0,pe=m,o[pe>>2]=Z,o[pe+4>>2]=se),(de|0)<=(c|0)){O=37;break}}if((O|0)==19)qt(27795,27122,1367,27158);else if((O|0)==37){P=m,g=o[P+4>>2]|0,P=o[P>>2]|0;break}else if((O|0)==42)return te=Oe,g|0}else g=0,P=0}else O=33;while(!1);e:do if((O|0)==33)if(me=m,o[me>>2]=0,o[me+4>>2]=0,(Je|0)>(c|0)){for(w=Je;;){if(g=ht(l|0,a|0,(15-w|0)*3|0)|0,ae()|0,g=g&7,(g|0)==7){g=5;break}if(P=Je-w|0,P=ds(7,0,P,((P|0)<0)<<31>>31)|0,g=lr(P|0,ae()|0,g|0,0)|0,P=ae()|0,me=m,P=Wt(o[me>>2]|0,o[me+4>>2]|0,g|0,P|0)|0,g=ae()|0,me=m,o[me>>2]=P,o[me+4>>2]=g,w=w+-1|0,(w|0)<=(c|0))break e}return te=Oe,g|0}else g=0,P=0;while(!1);return Ws(Ie,S,Je,Be)|0&&qt(27795,27122,1327,27173),Je=Be,Be=o[Je+4>>2]|0,((g|0)>-1|(g|0)==-1&P>>>0>4294967295)&((Be|0)>(g|0)|((Be|0)==(g|0)?(o[Je>>2]|0)>>>0>P>>>0:0))?(Je=0,te=Oe,Je|0):(qt(27795,27122,1407,27158),0)}function Au(l,a,c,m,g,w){l=l|0,a=a|0,c=c|0,m=m|0,g=g|0,w=w|0;var P=0,S=0,z=0,O=0,Z=0,se=0,pe=0,de=0,me=0,Ie=0;if(se=te,te=te+16|0,P=se,g>>>0>15)return w=4,te=se,w|0;if(S=ht(c|0,m|0,52)|0,ae()|0,S=S&15,(S|0)>(g|0))return w=12,te=se,w|0;if(Ws(c,m,g,P)|0&&qt(27795,27122,1327,27173),Z=P,O=o[Z+4>>2]|0,!(((a|0)>-1|(a|0)==-1&l>>>0>4294967295)&((O|0)>(a|0)|((O|0)==(a|0)?(o[Z>>2]|0)>>>0>l>>>0:0))))return w=2,te=se,w|0;Z=g-S|0,g=yt(g|0,0,52)|0,z=ae()|0|m&-15728641,O=w,o[O>>2]=g|c,o[O+4>>2]=z,O=ht(c|0,m|0,45)|0,ae()|0;e:do if(Vi(O&127)|0){if(S|0)for(P=1;;){if(O=yt(7,0,(15-P|0)*3|0)|0,!((O&c|0)==0&((ae()|0)&m|0)==0))break e;if(P>>>0<S>>>0)P=P+1|0;else break}if((Z|0)<1)return w=0,te=se,w|0;for(O=S^15,m=-1,z=1,P=1;;){S=Z-z|0,S=ds(7,0,S,((S|0)<0)<<31>>31)|0,c=ae()|0;do if(P)if(P=lr(S|0,c|0,5,0)|0,P=Wt(P|0,ae()|0,-5,-1)|0,P=xn(P|0,ae()|0,6,0)|0,g=ae()|0,(a|0)>(g|0)|(a|0)==(g|0)&l>>>0>P>>>0){a=Wt(l|0,a|0,-1,-1)|0,a=wr(a|0,ae()|0,P|0,g|0)|0,P=ae()|0,pe=w,me=o[pe>>2]|0,pe=o[pe+4>>2]|0,Ie=(O+m|0)*3|0,de=yt(7,0,Ie|0)|0,pe=pe&~(ae()|0),m=xn(a|0,P|0,S|0,c|0)|0,l=ae()|0,g=Wt(m|0,l|0,2,0)|0,Ie=yt(g|0,ae()|0,Ie|0)|0,pe=ae()|0|pe,g=w,o[g>>2]=Ie|me&~de,o[g+4>>2]=pe,l=lr(m|0,l|0,S|0,c|0)|0,l=wr(a|0,P|0,l|0,ae()|0)|0,P=0,a=ae()|0;break}else{Ie=w,de=o[Ie>>2]|0,Ie=o[Ie+4>>2]|0,me=yt(7,0,(O+m|0)*3|0)|0,Ie=Ie&~(ae()|0),P=w,o[P>>2]=de&~me,o[P+4>>2]=Ie,P=1;break}else de=w,g=o[de>>2]|0,de=o[de+4>>2]|0,m=(O+m|0)*3|0,pe=yt(7,0,m|0)|0,de=de&~(ae()|0),Ie=xn(l|0,a|0,S|0,c|0)|0,P=ae()|0,m=yt(Ie|0,P|0,m|0)|0,de=ae()|0|de,me=w,o[me>>2]=m|g&~pe,o[me+4>>2]=de,P=lr(Ie|0,P|0,S|0,c|0)|0,l=wr(l|0,a|0,P|0,ae()|0)|0,P=0,a=ae()|0;while(!1);if((Z|0)>(z|0))m=~z,z=z+1|0;else{a=0;break}}return te=se,a|0}while(!1);if((Z|0)<1)return Ie=0,te=se,Ie|0;for(g=S^15,P=1;;)if(me=Z-P|0,me=ds(7,0,me,((me|0)<0)<<31>>31)|0,Ie=ae()|0,z=w,c=o[z>>2]|0,z=o[z+4>>2]|0,S=(g-P|0)*3|0,m=yt(7,0,S|0)|0,z=z&~(ae()|0),pe=xn(l|0,a|0,me|0,Ie|0)|0,de=ae()|0,S=yt(pe|0,de|0,S|0)|0,z=ae()|0|z,O=w,o[O>>2]=S|c&~m,o[O+4>>2]=z,Ie=lr(pe|0,de|0,me|0,Ie|0)|0,l=wr(l|0,a|0,Ie|0,ae()|0)|0,a=ae()|0,(Z|0)<=(P|0)){a=0;break}else P=P+1|0;return te=se,a|0}function el(l,a,c,m){l=l|0,a=a|0,c=c|0,m=m|0;var g=0,w=0,P=0;g=ht(a|0,c|0,52)|0,ae()|0,g=g&15,(a|0)==0&(c|0)==0|((m|0)>15|(g|0)>(m|0))?(w=-1,a=-1,c=0,g=0):(a=Tl(a,c,g+1|0,m)|0,P=(ae()|0)&-15728641,c=yt(m|0,0,52)|0,c=a|c,P=P|(ae()|0),a=($i(c,P)|0)==0,w=g,a=a?-1:m,g=P),P=l,o[P>>2]=c,o[P+4>>2]=g,o[l+8>>2]=w,o[l+12>>2]=a}function Ml(l,a,c,m){l=l|0,a=a|0,c=c|0,m=m|0;var g=0,w=0;if(g=ht(l|0,a|0,52)|0,ae()|0,g=g&15,w=m+8|0,o[w>>2]=g,(l|0)==0&(a|0)==0|((c|0)>15|(g|0)>(c|0))){c=m,o[c>>2]=0,o[c+4>>2]=0,o[w>>2]=-1,o[m+12>>2]=-1;return}if(l=Tl(l,a,g+1|0,c)|0,w=(ae()|0)&-15728641,g=yt(c|0,0,52)|0,g=l|g,w=w|(ae()|0),l=m,o[l>>2]=g,o[l+4>>2]=w,l=m+12|0,$i(g,w)|0){o[l>>2]=c;return}else{o[l>>2]=-1;return}}function tl(l){l=l|0;var a=0,c=0,m=0,g=0,w=0,P=0,S=0,z=0,O=0;if(c=l,a=o[c>>2]|0,c=o[c+4>>2]|0,!((a|0)==0&(c|0)==0)&&(m=ht(a|0,c|0,52)|0,ae()|0,m=m&15,S=yt(1,0,(m^15)*3|0)|0,a=Wt(S|0,ae()|0,a|0,c|0)|0,c=ae()|0,S=l,o[S>>2]=a,o[S+4>>2]=c,S=l+8|0,P=o[S>>2]|0,!((m|0)<(P|0)))){for(z=l+12|0,w=m;;){if((w|0)==(P|0)){m=5;break}if(O=(w|0)==(o[z>>2]|0),g=(15-w|0)*3|0,m=ht(a|0,c|0,g|0)|0,ae()|0,m=m&7,O&((m|0)==1&!0)){m=7;break}if(!((m|0)==7&!0)){m=10;break}if(O=yt(1,0,g|0)|0,a=Wt(a|0,c|0,O|0,ae()|0)|0,c=ae()|0,O=l,o[O>>2]=a,o[O+4>>2]=c,(w|0)>(P|0))w=w+-1|0;else{m=10;break}}if((m|0)==5){O=l,o[O>>2]=0,o[O+4>>2]=0,o[S>>2]=-1,o[z>>2]=-1;return}else if((m|0)==7){P=yt(1,0,g|0)|0,P=Wt(a|0,c|0,P|0,ae()|0)|0,S=ae()|0,O=l,o[O>>2]=P,o[O+4>>2]=S,o[z>>2]=w+-1;return}else if((m|0)==10)return}}function Ii(l){l=+l;var a=0;return a=l<0?l+6.283185307179586:l,+(l>=6.283185307179586?a+-6.283185307179586:a)}function sn(l,a){return l=l|0,a=a|0,+ut(+(+X[l>>3]-+X[a>>3]))<17453292519943298e-27?(a=+ut(+(+X[l+8>>3]-+X[a+8>>3]))<17453292519943298e-27,a|0):(a=0,a|0)}function $r(l,a){switch(l=+l,a=a|0,a|0){case 1:{l=l<0?l+6.283185307179586:l;break}case 2:{l=l>0?l+-6.283185307179586:l;break}}return+l}function il(l,a){l=l|0,a=a|0;var c=0,m=0,g=0,w=0;return g=+X[a>>3],m=+X[l>>3],w=+di(+((g-m)*.5)),c=+di(+((+X[a+8>>3]-+X[l+8>>3])*.5)),c=w*w+c*(+fi(+g)*+fi(+m)*c),+(+kn(+ +zt(+c),+ +zt(+(1-c)))*2)}function Xs(l,a){l=l|0,a=a|0;var c=0,m=0,g=0,w=0;return g=+X[a>>3],m=+X[l>>3],w=+di(+((g-m)*.5)),c=+di(+((+X[a+8>>3]-+X[l+8>>3])*.5)),c=w*w+c*(+fi(+g)*+fi(+m)*c),+(+kn(+ +zt(+c),+ +zt(+(1-c)))*2*6371.007180918475)}function Xo(l,a){l=l|0,a=a|0;var c=0,m=0,g=0,w=0;return g=+X[a>>3],m=+X[l>>3],w=+di(+((g-m)*.5)),c=+di(+((+X[a+8>>3]-+X[l+8>>3])*.5)),c=w*w+c*(+fi(+g)*+fi(+m)*c),+(+kn(+ +zt(+c),+ +zt(+(1-c)))*2*6371.007180918475*1e3)}function _a(l,a){l=l|0,a=a|0;var c=0,m=0,g=0,w=0,P=0;return w=+X[a>>3],m=+fi(+w),g=+X[a+8>>3]-+X[l+8>>3],P=m*+di(+g),c=+X[l>>3],+ +kn(+P,+(+di(+w)*+fi(+c)-+fi(+g)*(m*+di(+c))))}function ga(l,a,c,m){l=l|0,a=+a,c=+c,m=m|0;var g=0,w=0,P=0,S=0;if(c<1e-16){o[m>>2]=o[l>>2],o[m+4>>2]=o[l+4>>2],o[m+8>>2]=o[l+8>>2],o[m+12>>2]=o[l+12>>2];return}w=a<0?a+6.283185307179586:a,w=a>=6.283185307179586?w+-6.283185307179586:w;do if(w<1e-16)a=+X[l>>3]+c,X[m>>3]=a,g=m;else{if(g=+ut(+(w+-3.141592653589793))<1e-16,a=+X[l>>3],g){a=a-c,X[m>>3]=a,g=m;break}if(P=+fi(+c),c=+di(+c),a=P*+di(+a)+ +fi(+w)*(c*+fi(+a)),a=a>1?1:a,a=+Ea(+(a<-1?-1:a)),X[m>>3]=a,+ut(+(a+-1.5707963267948966))<1e-16){X[m>>3]=1.5707963267948966,X[m+8>>3]=0;return}if(+ut(+(a+1.5707963267948966))<1e-16){X[m>>3]=-1.5707963267948966,X[m+8>>3]=0;return}if(S=1/+fi(+a),w=c*+di(+w)*S,c=+X[l>>3],a=S*((P-+di(+a)*+di(+c))/+fi(+c)),P=w>1?1:w,a=a>1?1:a,a=+X[l+8>>3]+ +kn(+(P<-1?-1:P),+(a<-1?-1:a)),a>3.141592653589793)do a=a+-6.283185307179586;while(a>3.141592653589793);if(a<-3.141592653589793)do a=a+6.283185307179586;while(a<-3.141592653589793);X[m+8>>3]=a;return}while(!1);if(+ut(+(a+-1.5707963267948966))<1e-16){X[g>>3]=1.5707963267948966,X[m+8>>3]=0;return}if(+ut(+(a+1.5707963267948966))<1e-16){X[g>>3]=-1.5707963267948966,X[m+8>>3]=0;return}if(a=+X[l+8>>3],a>3.141592653589793)do a=a+-6.283185307179586;while(a>3.141592653589793);if(a<-3.141592653589793)do a=a+6.283185307179586;while(a<-3.141592653589793);X[m+8>>3]=a}function fn(l,a){return l=l|0,a=a|0,l>>>0>15?(a=4,a|0):(X[a>>3]=+X[20656+(l<<3)>>3],a=0,a|0)}function ql(l,a){return l=l|0,a=a|0,l>>>0>15?(a=4,a|0):(X[a>>3]=+X[20784+(l<<3)>>3],a=0,a|0)}function Ko(l,a){return l=l|0,a=a|0,l>>>0>15?(a=4,a|0):(X[a>>3]=+X[20912+(l<<3)>>3],a=0,a|0)}function rl(l,a){return l=l|0,a=a|0,l>>>0>15?(a=4,a|0):(X[a>>3]=+X[21040+(l<<3)>>3],a=0,a|0)}function Rs(l,a){l=l|0,a=a|0;var c=0;return l>>>0>15?(a=4,a|0):(c=ds(7,0,l,((l|0)<0)<<31>>31)|0,c=lr(c|0,ae()|0,120,0)|0,l=ae()|0,o[a>>2]=c|2,o[a+4>>2]=l,a=0,a|0)}function Fa(l,a,c){l=l|0,a=a|0,c=c|0;var m=0,g=0,w=0,P=0,S=0,z=0,O=0,Z=0,se=0,pe=0;return pe=+X[a>>3],Z=+X[l>>3],z=+di(+((pe-Z)*.5)),w=+X[a+8>>3],O=+X[l+8>>3],P=+di(+((w-O)*.5)),S=+fi(+Z),se=+fi(+pe),P=z*z+P*(se*S*P),P=+kn(+ +zt(+P),+ +zt(+(1-P)))*2,z=+X[c>>3],pe=+di(+((z-pe)*.5)),m=+X[c+8>>3],w=+di(+((m-w)*.5)),g=+fi(+z),w=pe*pe+w*(se*g*w),w=+kn(+ +zt(+w),+ +zt(+(1-w)))*2,z=+di(+((Z-z)*.5)),m=+di(+((O-m)*.5)),m=z*z+m*(S*g*m),m=+kn(+ +zt(+m),+ +zt(+(1-m)))*2,g=(P+w+m)*.5,+(+xo(+ +zt(+(+jr(+(g*.5))*+jr(+((g-P)*.5))*+jr(+((g-w)*.5))*+jr(+((g-m)*.5)))))*4)}function es(l,a,c){l=l|0,a=a|0,c=c|0;var m=0,g=0,w=0,P=0,S=0;if(S=te,te=te+192|0,w=S+168|0,P=S,g=xs(l,a,w)|0,g|0)return c=g,te=S,c|0;if(fs(l,a,P)|0&&qt(27795,27190,415,27199),a=o[P>>2]|0,(a|0)>0){if(m=+Fa(P+8|0,P+8+(((a|0)!=1&1)<<4)|0,w)+0,(a|0)!=1){l=1;do g=l,l=l+1|0,m=m+ +Fa(P+8+(g<<4)|0,P+8+(((l|0)%(a|0)|0)<<4)|0,w);while((l|0)<(a|0))}}else m=0;return X[c>>3]=m,c=0,te=S,c|0}function ya(l,a,c){return l=l|0,a=a|0,c=c|0,l=es(l,a,c)|0,l|0||(X[c>>3]=+X[c>>3]*6371.007180918475*6371.007180918475),l|0}function Oa(l,a,c){return l=l|0,a=a|0,c=c|0,l=es(l,a,c)|0,l|0||(X[c>>3]=+X[c>>3]*6371.007180918475*6371.007180918475*1e3*1e3),l|0}function va(l,a,c){l=l|0,a=a|0,c=c|0;var m=0,g=0,w=0,P=0,S=0,z=0,O=0,Z=0;if(S=te,te=te+176|0,P=S,l=vs(l,a,P)|0,l|0)return P=l,te=S,P|0;if(X[c>>3]=0,l=o[P>>2]|0,(l|0)<=1)return P=0,te=S,P|0;a=l+-1|0,l=0,m=+X[P+8>>3],g=+X[P+16>>3],w=0;do l=l+1|0,O=m,m=+X[P+8+(l<<4)>>3],Z=+di(+((m-O)*.5)),z=g,g=+X[P+8+(l<<4)+8>>3],z=+di(+((g-z)*.5)),z=Z*Z+z*(+fi(+m)*+fi(+O)*z),w=w+ +kn(+ +zt(+z),+ +zt(+(1-z)))*2;while((l|0)<(a|0));return X[c>>3]=w,P=0,te=S,P|0}function xa(l,a,c){l=l|0,a=a|0,c=c|0;var m=0,g=0,w=0,P=0,S=0,z=0,O=0,Z=0;if(S=te,te=te+176|0,P=S,l=vs(l,a,P)|0,l|0)return P=l,w=+X[c>>3],w=w*6371.007180918475,X[c>>3]=w,te=S,P|0;if(X[c>>3]=0,l=o[P>>2]|0,(l|0)<=1)return P=0,w=0,w=w*6371.007180918475,X[c>>3]=w,te=S,P|0;a=l+-1|0,l=0,m=+X[P+8>>3],g=+X[P+16>>3],w=0;do l=l+1|0,O=m,m=+X[P+8+(l<<4)>>3],Z=+di(+((m-O)*.5)),z=g,g=+X[P+8+(l<<4)+8>>3],z=+di(+((g-z)*.5)),z=Z*Z+z*(+fi(+O)*+fi(+m)*z),w=w+ +kn(+ +zt(+z),+ +zt(+(1-z)))*2;while((l|0)!=(a|0));return X[c>>3]=w,P=0,Z=w,Z=Z*6371.007180918475,X[c>>3]=Z,te=S,P|0}function co(l,a,c){l=l|0,a=a|0,c=c|0;var m=0,g=0,w=0,P=0,S=0,z=0,O=0,Z=0;if(S=te,te=te+176|0,P=S,l=vs(l,a,P)|0,l|0)return P=l,w=+X[c>>3],w=w*6371.007180918475,w=w*1e3,X[c>>3]=w,te=S,P|0;if(X[c>>3]=0,l=o[P>>2]|0,(l|0)<=1)return P=0,w=0,w=w*6371.007180918475,w=w*1e3,X[c>>3]=w,te=S,P|0;a=l+-1|0,l=0,m=+X[P+8>>3],g=+X[P+16>>3],w=0;do l=l+1|0,O=m,m=+X[P+8+(l<<4)>>3],Z=+di(+((m-O)*.5)),z=g,g=+X[P+8+(l<<4)+8>>3],z=+di(+((g-z)*.5)),z=Z*Z+z*(+fi(+O)*+fi(+m)*z),w=w+ +kn(+ +zt(+z),+ +zt(+(1-z)))*2;while((l|0)!=(a|0));return X[c>>3]=w,P=0,Z=w,Z=Z*6371.007180918475,Z=Z*1e3,X[c>>3]=Z,te=S,P|0}function ba(l){l=l|0;var a=0,c=0,m=0;return a=ts(1,12)|0,a||qt(27280,27235,49,27293),c=l+4|0,m=o[c>>2]|0,m|0?(m=m+8|0,o[m>>2]=a,o[c>>2]=a,a|0):(o[l>>2]|0&&qt(27310,27235,61,27333),m=l,o[m>>2]=a,o[c>>2]=a,a|0)}function nl(l,a){l=l|0,a=a|0;var c=0,m=0;return m=Js(24)|0,m||qt(27347,27235,78,27361),o[m>>2]=o[a>>2],o[m+4>>2]=o[a+4>>2],o[m+8>>2]=o[a+8>>2],o[m+12>>2]=o[a+12>>2],o[m+16>>2]=0,a=l+4|0,c=o[a>>2]|0,c|0?(o[c+16>>2]=m,o[a>>2]=m,m|0):(o[l>>2]|0&&qt(27376,27235,82,27361),o[l>>2]=m,o[a>>2]=m,m|0)}function gi(l){l=l|0;var a=0,c=0,m=0,g=0;if(l)for(m=1;;){if(a=o[l>>2]|0,a|0)do{if(c=o[a>>2]|0,c|0)do g=c,c=o[c+16>>2]|0,Qt(g);while((c|0)!=0);g=a,a=o[a+8>>2]|0,Qt(g)}while((a|0)!=0);if(a=l,l=o[l+8>>2]|0,m||Qt(a),l)m=0;else break}}function sl(l){l=l|0;var a=0,c=0,m=0,g=0,w=0,P=0,S=0,z=0,O=0,Z=0,se=0,pe=0,de=0,me=0,Ie=0,Be=0,Je=0,Oe=0,ze=0,De=0,bt=0,Zt=0,Nt=0,ai=0,pi=0,Mi=0,ei=0,Vt=0,vt=0,_t=0,Mt=0,li=0;if(g=l+8|0,o[g>>2]|0)return li=1,li|0;if(m=o[l>>2]|0,!m)return li=0,li|0;a=m,c=0;do c=c+1|0,a=o[a+8>>2]|0;while((a|0)!=0);if(c>>>0<2)return li=0,li|0;_t=Js(c<<2)|0,_t||qt(27396,27235,317,27415),vt=Js(c<<5)|0,vt||qt(27437,27235,321,27415),o[l>>2]=0,Zt=l+4|0,o[Zt>>2]=0,o[g>>2]=0,c=0,Vt=0,bt=0,se=0;e:for(;;){if(Z=o[m>>2]|0,Z){w=0,P=Z;do{if(z=+X[P+8>>3],a=P,P=o[P+16>>2]|0,O=(P|0)==0,g=O?Z:P,S=+X[g+8>>3],+ut(+(z-S))>3.141592653589793){li=14;break}w=w+(S-z)*(+X[a>>3]+ +X[g>>3])}while(!O);if((li|0)==14){li=0,w=0,a=Z;do De=+X[a+8>>3],ei=a+16|0,Mi=o[ei>>2]|0,Mi=(Mi|0)==0?Z:Mi,ze=+X[Mi+8>>3],w=w+(+X[a>>3]+ +X[Mi>>3])*((ze<0?ze+6.283185307179586:ze)-(De<0?De+6.283185307179586:De)),a=o[((a|0)==0?m:ei)>>2]|0;while((a|0)!=0)}w>0?(o[_t+(Vt<<2)>>2]=m,Vt=Vt+1|0,g=bt,a=se):li=19}else li=19;if((li|0)==19){li=0;do if(c){if(a=c+8|0,o[a>>2]|0){li=21;break e}if(c=ts(1,12)|0,!c){li=23;break e}o[a>>2]=c,g=c+4|0,P=c,a=se}else if(se){g=Zt,P=se+8|0,a=m,c=l;break}else if(o[l>>2]|0){li=27;break e}else{g=Zt,P=l,a=m,c=l;break}while(!1);if(o[P>>2]=m,o[g>>2]=m,P=vt+(bt<<5)|0,O=o[m>>2]|0,O){for(Z=vt+(bt<<5)+8|0,X[Z>>3]=17976931348623157e292,se=vt+(bt<<5)+24|0,X[se>>3]=17976931348623157e292,X[P>>3]=-17976931348623157e292,pe=vt+(bt<<5)+16|0,X[pe>>3]=-17976931348623157e292,Je=17976931348623157e292,Oe=-17976931348623157e292,g=0,de=O,z=17976931348623157e292,Ie=17976931348623157e292,Be=-17976931348623157e292,S=-17976931348623157e292;w=+X[de>>3],De=+X[de+8>>3],de=o[de+16>>2]|0,me=(de|0)==0,ze=+X[(me?O:de)+8>>3],w<z&&(X[Z>>3]=w,z=w),De<Ie&&(X[se>>3]=De,Ie=De),w>Be?X[P>>3]=w:w=Be,De>S&&(X[pe>>3]=De,S=De),Je=De>0&De<Je?De:Je,Oe=De<0&De>Oe?De:Oe,g=g|+ut(+(De-ze))>3.141592653589793,!me;)Be=w;g&&(X[pe>>3]=Oe,X[se>>3]=Je)}else o[P>>2]=0,o[P+4>>2]=0,o[P+8>>2]=0,o[P+12>>2]=0,o[P+16>>2]=0,o[P+20>>2]=0,o[P+24>>2]=0,o[P+28>>2]=0;g=bt+1|0}if(ei=m+8|0,m=o[ei>>2]|0,o[ei>>2]=0,m)bt=g,se=a;else{li=45;break}}if((li|0)==21)qt(27213,27235,35,27247);else if((li|0)==23)qt(27267,27235,37,27247);else if((li|0)==27)qt(27310,27235,61,27333);else if((li|0)==45){e:do if((Vt|0)>0){for(ei=(g|0)==0,pi=g<<2,Mi=(l|0)==0,ai=0,a=0;;){if(Nt=o[_t+(ai<<2)>>2]|0,ei)li=73;else{if(bt=Js(pi)|0,!bt){li=50;break}if(Zt=Js(pi)|0,!Zt){li=52;break}t:do if(Mi)c=0;else{for(g=0,c=0,P=l;m=vt+(g<<5)|0,El(o[P>>2]|0,m,o[Nt>>2]|0)|0?(o[bt+(c<<2)>>2]=P,o[Zt+(c<<2)>>2]=m,me=c+1|0):me=c,P=o[P+8>>2]|0,P;)g=g+1|0,c=me;if((me|0)>0)if(m=o[bt>>2]|0,(me|0)==1)c=m;else for(pe=0,de=-1,c=m,se=m;;){for(O=o[se>>2]|0,m=0,P=0;g=o[o[bt+(P<<2)>>2]>>2]|0,(g|0)==(O|0)?Z=m:Z=m+((El(g,o[Zt+(P<<2)>>2]|0,o[O>>2]|0)|0)&1)|0,P=P+1|0,(P|0)!=(me|0);)m=Z;if(g=(Z|0)>(de|0),c=g?se:c,m=pe+1|0,(m|0)==(me|0))break t;pe=m,de=g?Z:de,se=o[bt+(m<<2)>>2]|0}else c=0}while(!1);if(Qt(bt),Qt(Zt),c){if(g=c+4|0,m=o[g>>2]|0,m)c=m+8|0;else if(o[c>>2]|0){li=70;break}o[c>>2]=Nt,o[g>>2]=Nt}else li=73}if((li|0)==73){if(li=0,a=o[Nt>>2]|0,a|0)do Zt=a,a=o[a+16>>2]|0,Qt(Zt);while((a|0)!=0);Qt(Nt),a=1}if(ai=ai+1|0,(ai|0)>=(Vt|0)){Mt=a;break e}}(li|0)==50?qt(27452,27235,249,27471):(li|0)==52?qt(27490,27235,252,27471):(li|0)==70&&qt(27310,27235,61,27333)}else Mt=0;while(!1);return Qt(_t),Qt(vt),li=Mt,li|0}return 0}function El(l,a,c){l=l|0,a=a|0,c=c|0;var m=0,g=0,w=0,P=0,S=0,z=0,O=0,Z=0;if(!(Us(a,c)|0)||(a=gn(a)|0,m=+X[c>>3],g=+X[c+8>>3],g=a&g<0?g+6.283185307179586:g,l=o[l>>2]|0,!l))return l=0,l|0;if(a){a=0,O=g,c=l;e:for(;;){for(;P=+X[c>>3],g=+X[c+8>>3],c=c+16|0,Z=o[c>>2]|0,Z=(Z|0)==0?l:Z,w=+X[Z>>3],S=+X[Z+8>>3],P>w?(z=P,P=S):(z=w,w=P,P=g,g=S),m=m==w|m==z?m+2220446049250313e-31:m,!!(m<w|m>z);)if(c=o[c>>2]|0,!c){c=22;break e}if(S=P<0?P+6.283185307179586:P,P=g<0?g+6.283185307179586:g,O=S==O|P==O?O+-2220446049250313e-31:O,z=S+(P-S)*((m-w)/(z-w)),(z<0?z+6.283185307179586:z)>O&&(a=a^1),c=o[c>>2]|0,!c){c=22;break}}if((c|0)==22)return a|0}else{a=0,O=g,c=l;e:for(;;){for(;P=+X[c>>3],g=+X[c+8>>3],c=c+16|0,Z=o[c>>2]|0,Z=(Z|0)==0?l:Z,w=+X[Z>>3],S=+X[Z+8>>3],P>w?(z=P,P=S):(z=w,w=P,P=g,g=S),m=m==w|m==z?m+2220446049250313e-31:m,!!(m<w|m>z);)if(c=o[c>>2]|0,!c){c=22;break e}if(O=P==O|g==O?O+-2220446049250313e-31:O,P+(g-P)*((m-w)/(z-w))>O&&(a=a^1),c=o[c>>2]|0,!c){c=22;break}}if((c|0)==22)return a|0}return 0}function Fs(l,a,c,m,g){l=l|0,a=a|0,c=c|0,m=m|0,g=g|0;var w=0,P=0,S=0,z=0,O=0,Z=0,se=0,pe=0,de=0,me=0,Ie=0,Be=0,Je=0,Oe=0;if(Oe=te,te=te+32|0,Je=Oe+16|0,Be=Oe,w=ht(l|0,a|0,52)|0,ae()|0,w=w&15,de=ht(c|0,m|0,52)|0,ae()|0,(w|0)!=(de&15|0))return Je=12,te=Oe,Je|0;if(O=ht(l|0,a|0,45)|0,ae()|0,O=O&127,Z=ht(c|0,m|0,45)|0,ae()|0,Z=Z&127,O>>>0>121|Z>>>0>121)return Je=5,te=Oe,Je|0;if(de=(O|0)!=(Z|0),de){if(S=Dt(O,Z)|0,(S|0)==7)return Je=1,te=Oe,Je|0;z=Dt(Z,O)|0,(z|0)==7?qt(27514,27538,161,27548):(me=S,P=z)}else me=0,P=0;se=Vi(O)|0,pe=Vi(Z)|0,o[Je>>2]=0,o[Je+4>>2]=0,o[Je+8>>2]=0,o[Je+12>>2]=0;do if(me){if(Z=o[4272+(O*28|0)+(me<<2)>>2]|0,S=(Z|0)>0,pe)if(S){O=0,z=c,S=m;do z=Gl(z,S)|0,S=ae()|0,P=Gs(P)|0,(P|0)==1&&(P=Gs(1)|0),O=O+1|0;while((O|0)!=(Z|0));Z=P,O=z,z=S}else Z=P,O=c,z=m;else if(S){O=0,z=c,S=m;do z=As(z,S)|0,S=ae()|0,P=Gs(P)|0,O=O+1|0;while((O|0)!=(Z|0));Z=P,O=z,z=S}else Z=P,O=c,z=m;if(ho(O,z,Je)|0,de||qt(27563,27538,191,27548),S=(se|0)!=0,P=(pe|0)!=0,S&P&&qt(27590,27538,192,27548),S){if(P=Ir(l,a)|0,(P|0)==7){w=5;break}if(At[22e3+(P*7|0)+me>>0]|0){w=1;break}z=o[21168+(P*28|0)+(me<<2)>>2]|0,O=z}else if(P){if(P=Ir(O,z)|0,(P|0)==7){w=5;break}if(At[22e3+(P*7|0)+Z>>0]|0){w=1;break}O=0,z=o[21168+(Z*28|0)+(P<<2)>>2]|0}else O=0,z=0;if((O|z|0)<0)w=5;else{if((z|0)>0){S=Je+4|0,P=0;do Bn(S),P=P+1|0;while((P|0)!=(z|0))}if(o[Be>>2]=0,o[Be+4>>2]=0,o[Be+8>>2]=0,ka(Be,me),w|0)for(;vn(w)|0?oo(Be):Kn(Be),(w|0)>1;)w=w+-1|0;if((O|0)>0){w=0;do Bn(Be),w=w+1|0;while((w|0)!=(O|0))}Ie=Je+4|0,bi(Ie,Be,Ie),Qr(Ie),Ie=51}}else if(ho(c,m,Je)|0,(se|0)!=0&(pe|0)!=0)if((Z|0)!=(O|0)&&qt(27621,27538,261,27548),P=Ir(l,a)|0,w=Ir(c,m)|0,(P|0)==7|(w|0)==7)w=5;else if(At[22e3+(P*7|0)+w>>0]|0)w=1;else if(P=o[21168+(P*28|0)+(w<<2)>>2]|0,(P|0)>0){S=Je+4|0,w=0;do Bn(S),w=w+1|0;while((w|0)!=(P|0));Ie=51}else Ie=51;else Ie=51;while(!1);return(Ie|0)==51&&(w=Je+4|0,o[g>>2]=o[w>>2],o[g+4>>2]=o[w+4>>2],o[g+8>>2]=o[w+8>>2],w=0),Je=w,te=Oe,Je|0}function Jo(l,a,c,m){l=l|0,a=a|0,c=c|0,m=m|0;var g=0,w=0,P=0,S=0,z=0,O=0,Z=0,se=0,pe=0,de=0,me=0,Ie=0,Be=0,Je=0,Oe=0,ze=0;if(Ie=te,te=te+48|0,O=Ie+36|0,P=Ie+24|0,S=Ie+12|0,z=Ie,g=ht(l|0,a|0,52)|0,ae()|0,g=g&15,pe=ht(l|0,a|0,45)|0,ae()|0,pe=pe&127,pe>>>0>121)return m=5,te=Ie,m|0;if(Z=Vi(pe)|0,yt(g|0,0,52)|0,Be=ae()|0|134225919,w=m,o[w>>2]=-1,o[w+4>>2]=Be,!g)return g=ri(c)|0,(g|0)==7||(g=Li(pe,g)|0,(g|0)==127)?(Be=1,te=Ie,Be|0):(de=yt(g|0,0,45)|0,me=ae()|0,pe=m,me=o[pe+4>>2]&-1040385|me,Be=m,o[Be>>2]=o[pe>>2]|de,o[Be+4>>2]=me,Be=0,te=Ie,Be|0);for(o[O>>2]=o[c>>2],o[O+4>>2]=o[c+4>>2],o[O+8>>2]=o[c+8>>2],c=g;;){if(w=c,c=c+-1|0,o[P>>2]=o[O>>2],o[P+4>>2]=o[O+4>>2],o[P+8>>2]=o[O+8>>2],vn(w)|0){if(g=Aa(O)|0,g|0){c=13;break}o[S>>2]=o[O>>2],o[S+4>>2]=o[O+4>>2],o[S+8>>2]=o[O+8>>2],oo(S)}else{if(g=Ci(O)|0,g|0){c=13;break}o[S>>2]=o[O>>2],o[S+4>>2]=o[O+4>>2],o[S+8>>2]=o[O+8>>2],Kn(S)}if(nn(P,S,z),Qr(z),g=m,Oe=o[g>>2]|0,g=o[g+4>>2]|0,ze=(15-w|0)*3|0,Je=yt(7,0,ze|0)|0,g=g&~(ae()|0),ze=yt(ri(z)|0,0,ze|0)|0,g=ae()|0|g,Be=m,o[Be>>2]=ze|Oe&~Je,o[Be+4>>2]=g,(w|0)<=1){c=14;break}}e:do if((c|0)!=13&&(c|0)==14)if((o[O>>2]|0)<=1&&(o[O+4>>2]|0)<=1&&(o[O+8>>2]|0)<=1){c=ri(O)|0,g=Li(pe,c)|0,(g|0)==127?z=0:z=Vi(g)|0;t:do if(c){if(Z){if(g=Ir(l,a)|0,(g|0)==7){g=5;break e}if(w=o[21376+(g*28|0)+(c<<2)>>2]|0,(w|0)>0){g=c,c=0;do g=Wo(g)|0,c=c+1|0;while((c|0)!=(w|0))}else g=c;if((g|0)==1){g=9;break e}c=Li(pe,g)|0,(c|0)==127&&qt(27648,27538,411,27678),Vi(c)|0?qt(27693,27538,412,27678):(me=c,de=w,se=g)}else me=g,de=0,se=c;if(S=o[4272+(pe*28|0)+(se<<2)>>2]|0,(S|0)<=-1&&qt(27724,27538,419,27678),!z){if((de|0)<0){g=5;break e}if(de|0){w=m,g=0,c=o[w>>2]|0,w=o[w+4>>2]|0;do c=yn(c,w)|0,w=ae()|0,ze=m,o[ze>>2]=c,o[ze+4>>2]=w,g=g+1|0;while((g|0)<(de|0))}if((S|0)<=0){g=me,c=58;break}for(w=m,g=0,c=o[w>>2]|0,w=o[w+4>>2]|0;;)if(c=yn(c,w)|0,w=ae()|0,ze=m,o[ze>>2]=c,o[ze+4>>2]=w,g=g+1|0,(g|0)==(S|0)){g=me,c=58;break t}}if(P=Dt(me,pe)|0,(P|0)==7&&qt(27514,27538,428,27678),g=m,c=o[g>>2]|0,g=o[g+4>>2]|0,(S|0)>0){w=0;do c=yn(c,g)|0,g=ae()|0,ze=m,o[ze>>2]=c,o[ze+4>>2]=g,w=w+1|0;while((w|0)!=(S|0))}if(g=Ir(c,g)|0,(g|0)==7&&qt(27795,27538,440,27678),c=oi(me)|0,c=o[(c?21792:21584)+(P*28|0)+(g<<2)>>2]|0,(c|0)<0&&qt(27795,27538,454,27678),!c)g=me,c=58;else{P=m,g=0,w=o[P>>2]|0,P=o[P+4>>2]|0;do w=Ka(w,P)|0,P=ae()|0,ze=m,o[ze>>2]=w,o[ze+4>>2]=P,g=g+1|0;while((g|0)<(c|0));g=me,c=58}}else if((Z|0)!=0&(z|0)!=0){if(c=Ir(l,a)|0,w=m,w=Ir(o[w>>2]|0,o[w+4>>2]|0)|0,(c|0)==7|(w|0)==7){g=5;break e}if(w=o[21376+(c*28|0)+(w<<2)>>2]|0,(w|0)<0){g=5;break e}if(!w)c=59;else{S=m,c=0,P=o[S>>2]|0,S=o[S+4>>2]|0;do P=yn(P,S)|0,S=ae()|0,ze=m,o[ze>>2]=P,o[ze+4>>2]=S,c=c+1|0;while((c|0)<(w|0));c=58}}else c=58;while(!1);if((c|0)==58&&z&&(c=59),(c|0)==59&&(ze=m,(Ir(o[ze>>2]|0,o[ze+4>>2]|0)|0)==1)){g=9;break}ze=m,Je=o[ze>>2]|0,ze=o[ze+4>>2]&-1040385,Oe=yt(g|0,0,45)|0,ze=ze|(ae()|0),g=m,o[g>>2]=Je|Oe,o[g+4>>2]=ze,g=0}else g=1;while(!1);return ze=g,te=Ie,ze|0}function Hl(l,a,c,m,g,w){l=l|0,a=a|0,c=c|0,m=m|0,g=g|0,w=w|0;var P=0,S=0;return S=te,te=te+16|0,P=S,g?l=15:(l=Fs(l,a,c,m,P)|0,l||(ao(P,w),l=0)),te=S,l|0}function Wl(l,a,c,m,g){l=l|0,a=a|0,c=c|0,m=m|0,g=g|0;var w=0,P=0;return P=te,te=te+16|0,w=P,m?c=15:(c=yl(c,w)|0,c||(c=Jo(l,a,w,g)|0)),te=P,c|0}function Ql(l,a,c,m,g){l=l|0,a=a|0,c=c|0,m=m|0,g=g|0;var w=0,P=0,S=0,z=0;return z=te,te=te+32|0,P=z+12|0,S=z,w=Fs(l,a,l,a,P)|0,w|0?(S=w,te=z,S|0):(l=Fs(l,a,c,m,S)|0,l|0?(S=l,te=z,S|0):(P=ir(P,S)|0,S=g,o[S>>2]=P,o[S+4>>2]=((P|0)<0)<<31>>31,S=0,te=z,S|0))}function $l(l,a,c,m,g){l=l|0,a=a|0,c=c|0,m=m|0,g=g|0;var w=0,P=0,S=0,z=0;return z=te,te=te+32|0,P=z+12|0,S=z,w=Fs(l,a,l,a,P)|0,!w&&(w=Fs(l,a,c,m,S)|0,!w)?(m=ir(P,S)|0,m=Wt(m|0,((m|0)<0)<<31>>31|0,1,0)|0,P=ae()|0,S=g,o[S>>2]=m,o[S+4>>2]=P,S=0,te=z,S|0):(S=w,te=z,S|0)}function ol(l,a,c,m,g){l=l|0,a=a|0,c=c|0,m=m|0,g=g|0;var w=0,P=0,S=0,z=0,O=0,Z=0,se=0,pe=0,de=0,me=0,Ie=0,Be=0,Je=0,Oe=0,ze=0,De=0,bt=0,Zt=0,Nt=0,ai=0;if(Nt=te,te=te+48|0,bt=Nt+24|0,P=Nt+12|0,Zt=Nt,w=Fs(l,a,l,a,bt)|0,!w&&(w=Fs(l,a,c,m,P)|0,!w)){ze=ir(bt,P)|0,De=((ze|0)<0)<<31>>31,o[bt>>2]=0,o[bt+4>>2]=0,o[bt+8>>2]=0,o[P>>2]=0,o[P+4>>2]=0,o[P+8>>2]=0,Fs(l,a,l,a,bt)|0&&qt(27795,27538,692,27747),Fs(l,a,c,m,P)|0&&qt(27795,27538,697,27747),Qo(bt),Qo(P),Z=(ze|0)==0?0:1/+(ze|0),c=o[bt>>2]|0,Ie=Z*+((o[P>>2]|0)-c|0),Be=bt+4|0,m=o[Be>>2]|0,Je=Z*+((o[P+4>>2]|0)-m|0),Oe=bt+8|0,w=o[Oe>>2]|0,Z=Z*+((o[P+8>>2]|0)-w|0),o[Zt>>2]=c,se=Zt+4|0,o[se>>2]=m,pe=Zt+8|0,o[pe>>2]=w;e:do if((ze|0)<0)w=0;else for(de=0,me=0;;){z=+(me>>>0)+4294967296*+(de|0),ai=Ie*z+ +(c|0),S=Je*z+ +(m|0),z=Z*z+ +(w|0),c=~~+ra(+ai),P=~~+ra(+S),w=~~+ra(+z),ai=+ut(+(+(c|0)-ai)),S=+ut(+(+(P|0)-S)),z=+ut(+(+(w|0)-z));do if(ai>S&ai>z)c=0-(P+w)|0,m=P;else if(O=0-c|0,S>z){m=O-w|0;break}else{m=P,w=O-P|0;break}while(!1);if(o[Zt>>2]=c,o[se>>2]=m,o[pe>>2]=w,dr(Zt),w=Jo(l,a,Zt,g+(me<<3)|0)|0,w|0)break e;if(!((de|0)<(De|0)|(de|0)==(De|0)&me>>>0<ze>>>0)){w=0;break e}c=Wt(me|0,de|0,1,0)|0,m=ae()|0,de=m,me=c,c=o[bt>>2]|0,m=o[Be>>2]|0,w=o[Oe>>2]|0}while(!1);return Zt=w,te=Nt,Zt|0}return Zt=w,te=Nt,Zt|0}function ds(l,a,c,m){l=l|0,a=a|0,c=c|0,m=m|0;var g=0,w=0,P=0;if((c|0)==0&(m|0)==0)return g=0,w=1,Ft(g|0),w|0;w=l,g=a,l=1,a=0;do P=(c&1|0)==0&!0,l=lr((P?1:w)|0,(P?0:g)|0,l|0,a|0)|0,a=ae()|0,c=hl(c|0,m|0,1)|0,m=ae()|0,w=lr(w|0,g|0,w|0,g|0)|0,g=ae()|0;while(!((c|0)==0&(m|0)==0));return Ft(a|0),l|0}function u(l,a,c,m){l=l|0,a=a|0,c=c|0,m=m|0;var g=0,w=0,P=0,S=0,z=0,O=0,Z=0;S=te,te=te+16|0,w=S,P=ht(l|0,a|0,52)|0,ae()|0,P=P&15;do if(P){if(g=xs(l,a,w)|0,!g){O=+X[w>>3],z=1/+fi(+O),Z=+X[25968+(P<<3)>>3],X[c>>3]=O+Z,X[c+8>>3]=O-Z,O=+X[w+8>>3],z=Z*z,X[c+16>>3]=z+O,X[c+24>>3]=O-z;break}return P=g,te=S,P|0}else{if(g=ht(l|0,a|0,45)|0,ae()|0,g=g&127,g>>>0>121)return P=5,te=S,P|0;w=22064+(g<<5)|0,o[c>>2]=o[w>>2],o[c+4>>2]=o[w+4>>2],o[c+8>>2]=o[w+8>>2],o[c+12>>2]=o[w+12>>2],o[c+16>>2]=o[w+16>>2],o[c+20>>2]=o[w+20>>2],o[c+24>>2]=o[w+24>>2],o[c+28>>2]=o[w+28>>2];break}while(!1);return Po(c,m?1.4:1.1),m=26096+(P<<3)|0,(o[m>>2]|0)==(l|0)&&(o[m+4>>2]|0)==(a|0)&&(X[c>>3]=1.5707963267948966),P=26224+(P<<3)|0,(o[P>>2]|0)==(l|0)&&(o[P+4>>2]|0)==(a|0)&&(X[c+8>>3]=-1.5707963267948966),+X[c>>3]!=1.5707963267948966&&+X[c+8>>3]!=-1.5707963267948966?(P=0,te=S,P|0):(X[c+16>>3]=3.141592653589793,X[c+24>>3]=-3.141592653589793,P=0,te=S,P|0)}function v(l,a,c,m){l=l|0,a=a|0,c=c|0,m=m|0;var g=0,w=0,P=0,S=0,z=0,O=0,Z=0;O=te,te=te+48|0,P=O+32|0,w=O+40|0,S=O,Hs(P,0,0,0),z=o[P>>2]|0,P=o[P+4>>2]|0;do if(c>>>0<=15){if(g=tt(m)|0,g|0){m=S,o[m>>2]=0,o[m+4>>2]=0,o[S+8>>2]=g,o[S+12>>2]=-1,m=S+16|0,z=S+29|0,o[m>>2]=0,o[m+4>>2]=0,o[m+8>>2]=0,At[m+12>>0]=0,At[z>>0]=At[w>>0]|0,At[z+1>>0]=At[w+1>>0]|0,At[z+2>>0]=At[w+2>>0]|0;break}if(g=ts((o[a+8>>2]|0)+1|0,32)|0,g){gt(a,g),Z=S,o[Z>>2]=z,o[Z+4>>2]=P,o[S+8>>2]=0,o[S+12>>2]=c,o[S+16>>2]=m,o[S+20>>2]=a,o[S+24>>2]=g,At[S+28>>0]=0,z=S+29|0,At[z>>0]=At[w>>0]|0,At[z+1>>0]=At[w+1>>0]|0,At[z+2>>0]=At[w+2>>0]|0;break}else{m=S,o[m>>2]=0,o[m+4>>2]=0,o[S+8>>2]=13,o[S+12>>2]=-1,m=S+16|0,z=S+29|0,o[m>>2]=0,o[m+4>>2]=0,o[m+8>>2]=0,At[m+12>>0]=0,At[z>>0]=At[w>>0]|0,At[z+1>>0]=At[w+1>>0]|0,At[z+2>>0]=At[w+2>>0]|0;break}}else z=S,o[z>>2]=0,o[z+4>>2]=0,o[S+8>>2]=4,o[S+12>>2]=-1,z=S+16|0,Z=S+29|0,o[z>>2]=0,o[z+4>>2]=0,o[z+8>>2]=0,At[z+12>>0]=0,At[Z>>0]=At[w>>0]|0,At[Z+1>>0]=At[w+1>>0]|0,At[Z+2>>0]=At[w+2>>0]|0;while(!1);E(S),o[l>>2]=o[S>>2],o[l+4>>2]=o[S+4>>2],o[l+8>>2]=o[S+8>>2],o[l+12>>2]=o[S+12>>2],o[l+16>>2]=o[S+16>>2],o[l+20>>2]=o[S+20>>2],o[l+24>>2]=o[S+24>>2],o[l+28>>2]=o[S+28>>2],te=O}function E(l){l=l|0;var a=0,c=0,m=0,g=0,w=0,P=0,S=0,z=0,O=0,Z=0,se=0,pe=0,de=0,me=0,Ie=0,Be=0,Je=0,Oe=0,ze=0,De=0;if(De=te,te=te+336|0,de=De+168|0,me=De,m=l,c=o[m>>2]|0,m=o[m+4>>2]|0,(c|0)==0&(m|0)==0){te=De;return}if(a=l+28|0,At[a>>0]|0?(c=R(c,m)|0,m=ae()|0):At[a>>0]=1,ze=l+20|0,!(o[o[ze>>2]>>2]|0)){a=l+24|0,c=o[a>>2]|0,c|0&&Qt(c),Oe=l,o[Oe>>2]=0,o[Oe+4>>2]=0,o[l+8>>2]=0,o[ze>>2]=0,o[l+12>>2]=-1,o[l+16>>2]=0,o[a>>2]=0,te=De;return}Oe=l+16|0,a=o[Oe>>2]|0,g=a&15;e:do if((c|0)==0&(m|0)==0)Je=l+24|0;else{Ie=l+12|0,se=(g|0)==3,Z=a&255,z=(g|1|0)==3,pe=l+24|0,O=(g+-1|0)>>>0<3,P=(g|2|0)==3,S=me+8|0;t:for(;;){if(w=ht(c|0,m|0,52)|0,ae()|0,w=w&15,(w|0)==(o[Ie>>2]|0)){switch(Z&15){case 0:case 2:case 3:{if(g=xs(c,m,de)|0,g|0){Be=15;break t}if(Rt(o[ze>>2]|0,o[pe>>2]|0,de)|0){Be=19;break t}break}}if(z&&(g=o[(o[ze>>2]|0)+4>>2]|0,o[de>>2]=o[g>>2],o[de+4>>2]=o[g+4>>2],o[de+8>>2]=o[g+8>>2],o[de+12>>2]=o[g+12>>2],Us(26832,de)|0)){if(Fn(o[(o[ze>>2]|0)+4>>2]|0,w,me)|0){Be=25;break}if(g=me,(o[g>>2]|0)==(c|0)&&(o[g+4>>2]|0)==(m|0)){Be=29;break}}if(O){if(g=fs(c,m,de)|0,g|0){Be=32;break}if(u(c,m,me,0)|0){Be=36;break}if(P&&Jt(o[ze>>2]|0,o[pe>>2]|0,de,me)|0){Be=42;break}if(z&&Zr(o[ze>>2]|0,o[pe>>2]|0,de,me)|0){Be=42;break}}if(se){if(a=u(c,m,de,1)|0,g=o[pe>>2]|0,a|0){Be=45;break}if(Qn(g,de)|0){if(gs(me,de),$n(de,o[pe>>2]|0)|0){Be=53;break}if(Rt(o[ze>>2]|0,o[pe>>2]|0,S)|0){Be=53;break}if(Zr(o[ze>>2]|0,o[pe>>2]|0,me,de)|0){Be=53;break}}}}do if((w|0)<(o[Ie>>2]|0)){if(a=u(c,m,de,1)|0,g=o[pe>>2]|0,a|0){Be=58;break t}if(!(Qn(g,de)|0)){Be=73;break}if($n(o[pe>>2]|0,de)|0&&(gs(me,de),Jt(o[ze>>2]|0,o[pe>>2]|0,me,de)|0)){Be=65;break t}if(c=Bs(c,m,w+1|0,me)|0,c|0){Be=67;break t}m=me,c=o[m>>2]|0,m=o[m+4>>2]|0}else Be=73;while(!1);if((Be|0)==73&&(Be=0,c=R(c,m)|0,m=ae()|0),(c|0)==0&(m|0)==0){Je=pe;break e}}switch(Be|0){case 15:{a=o[pe>>2]|0,a|0&&Qt(a),Be=l,o[Be>>2]=0,o[Be+4>>2]=0,o[ze>>2]=0,o[Ie>>2]=-1,o[Oe>>2]=0,o[pe>>2]=0,o[l+8>>2]=g,Be=20;break}case 19:{o[l>>2]=c,o[l+4>>2]=m,Be=20;break}case 25:{qt(27795,27761,470,27772);break}case 29:{o[l>>2]=c,o[l+4>>2]=m,te=De;return}case 32:{a=o[pe>>2]|0,a|0&&Qt(a),Je=l,o[Je>>2]=0,o[Je+4>>2]=0,o[ze>>2]=0,o[Ie>>2]=-1,o[Oe>>2]=0,o[pe>>2]=0,o[l+8>>2]=g,te=De;return}case 36:{qt(27795,27761,493,27772);break}case 42:{o[l>>2]=c,o[l+4>>2]=m,te=De;return}case 45:{g|0&&Qt(g),Be=l,o[Be>>2]=0,o[Be+4>>2]=0,o[ze>>2]=0,o[Ie>>2]=-1,o[Oe>>2]=0,o[pe>>2]=0,o[l+8>>2]=a,Be=55;break}case 53:{o[l>>2]=c,o[l+4>>2]=m,Be=55;break}case 58:{g|0&&Qt(g),Be=l,o[Be>>2]=0,o[Be+4>>2]=0,o[ze>>2]=0,o[Ie>>2]=-1,o[Oe>>2]=0,o[pe>>2]=0,o[l+8>>2]=a,Be=71;break}case 65:{o[l>>2]=c,o[l+4>>2]=m,Be=71;break}case 67:{a=o[pe>>2]|0,a|0&&Qt(a),Je=l,o[Je>>2]=0,o[Je+4>>2]=0,o[ze>>2]=0,o[Ie>>2]=-1,o[Oe>>2]=0,o[pe>>2]=0,o[l+8>>2]=c,te=De;return}}if((Be|0)==20){te=De;return}else if((Be|0)==55){te=De;return}else if((Be|0)==71){te=De;return}}while(!1);a=o[Je>>2]|0,a|0&&Qt(a),Be=l,o[Be>>2]=0,o[Be+4>>2]=0,o[l+8>>2]=0,o[ze>>2]=0,o[l+12>>2]=-1,o[Oe>>2]=0,o[Je>>2]=0,te=De}function R(l,a){l=l|0,a=a|0;var c=0,m=0,g=0,w=0,P=0,S=0,z=0,O=0,Z=0,se=0;se=te,te=te+16|0,Z=se,m=ht(l|0,a|0,52)|0,ae()|0,m=m&15,c=ht(l|0,a|0,45)|0,ae()|0;do if(m){for(;c=yt(m+4095|0,0,52)|0,g=ae()|0|a&-15728641,w=(15-m|0)*3|0,P=yt(7,0,w|0)|0,S=ae()|0,c=c|l|P,g=g|S,z=ht(l|0,a|0,w|0)|0,ae()|0,z=z&7,m=m+-1|0,!(z>>>0<6);)if(m)a=g,l=c;else{O=4;break}if((O|0)==4){c=ht(c|0,g|0,45)|0,ae()|0;break}return Z=(z|0)==0&($i(c,g)|0)!=0,Z=yt((Z?2:1)+z|0,0,w|0)|0,O=ae()|0|a&~S,Z=Z|l&~P,Ft(O|0),te=se,Z|0}while(!1);return c=c&127,c>>>0>120?(O=0,Z=0,Ft(O|0),te=se,Z|0):(Hs(Z,0,c+1|0,0),O=o[Z+4>>2]|0,Z=o[Z>>2]|0,Ft(O|0),te=se,Z|0)}function q(l,a,c,m,g,w){l=l|0,a=a|0,c=c|0,m=m|0,g=g|0,w=w|0;var P=0,S=0,z=0,O=0,Z=0,se=0,pe=0,de=0,me=0,Ie=0,Be=0;Be=te,te=te+160|0,se=Be+80|0,S=Be+64|0,pe=Be+112|0,Ie=Be,v(se,l,a,c),O=se,el(S,o[O>>2]|0,o[O+4>>2]|0,a),O=S,z=o[O>>2]|0,O=o[O+4>>2]|0,P=o[se+8>>2]|0,de=pe+4|0,o[de>>2]=o[se>>2],o[de+4>>2]=o[se+4>>2],o[de+8>>2]=o[se+8>>2],o[de+12>>2]=o[se+12>>2],o[de+16>>2]=o[se+16>>2],o[de+20>>2]=o[se+20>>2],o[de+24>>2]=o[se+24>>2],o[de+28>>2]=o[se+28>>2],de=Ie,o[de>>2]=z,o[de+4>>2]=O,de=Ie+8|0,o[de>>2]=P,l=Ie+12|0,a=pe,c=l+36|0;do o[l>>2]=o[a>>2],l=l+4|0,a=a+4|0;while((l|0)<(c|0));if(pe=Ie+48|0,o[pe>>2]=o[S>>2],o[pe+4>>2]=o[S+4>>2],o[pe+8>>2]=o[S+8>>2],o[pe+12>>2]=o[S+12>>2],(z|0)==0&(O|0)==0)return Ie=P,te=Be,Ie|0;c=Ie+16|0,Z=Ie+24|0,se=Ie+28|0,P=0,S=0,a=z,l=O;do{if(!((P|0)<(g|0)|(P|0)==(g|0)&S>>>0<m>>>0)){me=4;break}if(O=S,S=Wt(S|0,P|0,1,0)|0,P=ae()|0,O=w+(O<<3)|0,o[O>>2]=a,o[O+4>>2]=l,tl(pe),l=pe,a=o[l>>2]|0,l=o[l+4>>2]|0,(a|0)==0&(l|0)==0){if(E(c),a=c,l=o[a>>2]|0,a=o[a+4>>2]|0,(l|0)==0&(a|0)==0){me=10;break}Ml(l,a,o[se>>2]|0,pe),l=pe,a=o[l>>2]|0,l=o[l+4>>2]|0}O=Ie,o[O>>2]=a,o[O+4>>2]=l}while(!((a|0)==0&(l|0)==0));return(me|0)==4?(l=Ie+40|0,a=o[l>>2]|0,a|0&&Qt(a),me=Ie+16|0,o[me>>2]=0,o[me+4>>2]=0,o[Z>>2]=0,o[Ie+36>>2]=0,o[se>>2]=-1,o[Ie+32>>2]=0,o[l>>2]=0,Ml(0,0,0,pe),o[Ie>>2]=0,o[Ie+4>>2]=0,o[de>>2]=0,Ie=14,te=Be,Ie|0):((me|0)==10&&(o[Ie>>2]=0,o[Ie+4>>2]=0,o[de>>2]=o[Z>>2]),Ie=o[de>>2]|0,te=Be,Ie|0)}function ne(l,a,c,m){l=l|0,a=a|0,c=c|0,m=m|0;var g=0,w=0,P=0,S=0,z=0,O=0,Z=0,se=0,pe=0,de=0;if(se=te,te=te+48|0,z=se+32|0,S=se+40|0,O=se,!(o[l>>2]|0))return Z=m,o[Z>>2]=0,o[Z+4>>2]=0,Z=0,te=se,Z|0;Hs(z,0,0,0),P=z,g=o[P>>2]|0,P=o[P+4>>2]|0;do if(a>>>0>15)Z=O,o[Z>>2]=0,o[Z+4>>2]=0,o[O+8>>2]=4,o[O+12>>2]=-1,Z=O+16|0,c=O+29|0,o[Z>>2]=0,o[Z+4>>2]=0,o[Z+8>>2]=0,At[Z+12>>0]=0,At[c>>0]=At[S>>0]|0,At[c+1>>0]=At[S+1>>0]|0,At[c+2>>0]=At[S+2>>0]|0,c=4,Z=9;else{if(c=tt(c)|0,c|0){z=O,o[z>>2]=0,o[z+4>>2]=0,o[O+8>>2]=c,o[O+12>>2]=-1,z=O+16|0,Z=O+29|0,o[z>>2]=0,o[z+4>>2]=0,o[z+8>>2]=0,At[z+12>>0]=0,At[Z>>0]=At[S>>0]|0,At[Z+1>>0]=At[S+1>>0]|0,At[Z+2>>0]=At[S+2>>0]|0,Z=9;break}if(c=ts((o[l+8>>2]|0)+1|0,32)|0,!c){Z=O,o[Z>>2]=0,o[Z+4>>2]=0,o[O+8>>2]=13,o[O+12>>2]=-1,Z=O+16|0,c=O+29|0,o[Z>>2]=0,o[Z+4>>2]=0,o[Z+8>>2]=0,At[Z+12>>0]=0,At[c>>0]=At[S>>0]|0,At[c+1>>0]=At[S+1>>0]|0,At[c+2>>0]=At[S+2>>0]|0,c=13,Z=9;break}gt(l,c),de=O,o[de>>2]=g,o[de+4>>2]=P,P=O+8|0,o[P>>2]=0,o[O+12>>2]=a,o[O+20>>2]=l,o[O+24>>2]=c,At[O+28>>0]=0,g=O+29|0,At[g>>0]=At[S>>0]|0,At[g+1>>0]=At[S+1>>0]|0,At[g+2>>0]=At[S+2>>0]|0,o[O+16>>2]=3,pe=+Lr(c),pe=pe*+cn(c),w=+ut(+ +X[c>>3]),w=pe/+fi(+ +eu(+w,+ +ut(+ +X[c+8>>3])))*6371.007180918475*6371.007180918475,g=O+12|0,c=o[g>>2]|0;e:do if((c|0)>0)do{if(fn(c+-1|0,z)|0,!(w/+X[z>>3]>10))break e;de=o[g>>2]|0,c=de+-1|0,o[g>>2]=c}while((de|0)>1);while(!1);if(E(O),g=m,o[g>>2]=0,o[g+4>>2]=0,g=O,c=o[g>>2]|0,g=o[g+4>>2]|0,!((c|0)==0&(g|0)==0))do Ws(c,g,a,z)|0,S=z,l=m,S=Wt(o[l>>2]|0,o[l+4>>2]|0,o[S>>2]|0,o[S+4>>2]|0)|0,l=ae()|0,de=m,o[de>>2]=S,o[de+4>>2]=l,E(O),de=O,c=o[de>>2]|0,g=o[de+4>>2]|0;while(!((c|0)==0&(g|0)==0));c=o[P>>2]|0}while(!1);return de=c,te=se,de|0}function Ee(l,a,c){l=l|0,a=a|0,c=c|0;var m=0,g=0,w=0,P=0,S=0,z=0,O=0,Z=0,se=0,pe=0;if(!(Us(a,c)|0)||(a=gn(a)|0,m=+X[c>>3],g=+X[c+8>>3],g=a&g<0?g+6.283185307179586:g,pe=o[l>>2]|0,(pe|0)<=0))return pe=0,pe|0;if(se=o[l+4>>2]|0,a){a=0,Z=g,c=-1,l=0;e:for(;;){for(O=l;P=+X[se+(O<<4)>>3],g=+X[se+(O<<4)+8>>3],l=(c+2|0)%(pe|0)|0,w=+X[se+(l<<4)>>3],S=+X[se+(l<<4)+8>>3],P>w?(z=P,P=S):(z=w,w=P,P=g,g=S),m=m==w|m==z?m+2220446049250313e-31:m,!!(m<w|m>z);)if(c=O+1|0,(c|0)>=(pe|0)){c=22;break e}else l=O,O=c,c=l;if(S=P<0?P+6.283185307179586:P,P=g<0?g+6.283185307179586:g,Z=S==Z|P==Z?Z+-2220446049250313e-31:Z,z=S+(P-S)*((m-w)/(z-w)),(z<0?z+6.283185307179586:z)>Z&&(a=a^1),l=O+1|0,(l|0)>=(pe|0)){c=22;break}else c=O}if((c|0)==22)return a|0}else{a=0,Z=g,c=-1,l=0;e:for(;;){for(O=l;P=+X[se+(O<<4)>>3],g=+X[se+(O<<4)+8>>3],l=(c+2|0)%(pe|0)|0,w=+X[se+(l<<4)>>3],S=+X[se+(l<<4)+8>>3],P>w?(z=P,P=S):(z=w,w=P,P=g,g=S),m=m==w|m==z?m+2220446049250313e-31:m,!!(m<w|m>z);)if(c=O+1|0,(c|0)>=(pe|0)){c=22;break e}else l=O,O=c,c=l;if(Z=P==Z|g==Z?Z+-2220446049250313e-31:Z,P+(g-P)*((m-w)/(z-w))>Z&&(a=a^1),l=O+1|0,(l|0)>=(pe|0)){c=22;break}else c=O}if((c|0)==22)return a|0}return 0}function Ze(l,a){l=l|0,a=a|0;var c=0,m=0,g=0,w=0,P=0,S=0,z=0,O=0,Z=0,se=0,pe=0,de=0,me=0,Ie=0,Be=0,Je=0,Oe=0;if(me=o[l>>2]|0,!me){o[a>>2]=0,o[a+4>>2]=0,o[a+8>>2]=0,o[a+12>>2]=0,o[a+16>>2]=0,o[a+20>>2]=0,o[a+24>>2]=0,o[a+28>>2]=0;return}if(Ie=a+8|0,X[Ie>>3]=17976931348623157e292,Be=a+24|0,X[Be>>3]=17976931348623157e292,X[a>>3]=-17976931348623157e292,Je=a+16|0,X[Je>>3]=-17976931348623157e292,!((me|0)<=0)){for(pe=o[l+4>>2]|0,O=17976931348623157e292,Z=-17976931348623157e292,se=0,l=-1,w=17976931348623157e292,P=17976931348623157e292,z=-17976931348623157e292,m=-17976931348623157e292,de=0;c=+X[pe+(de<<4)>>3],S=+X[pe+(de<<4)+8>>3],l=l+2|0,g=+X[pe+(((l|0)==(me|0)?0:l)<<4)+8>>3],c<w&&(X[Ie>>3]=c,w=c),S<P&&(X[Be>>3]=S,P=S),c>z?X[a>>3]=c:c=z,S>m&&(X[Je>>3]=S,m=S),O=S>0&S<O?S:O,Z=S<0&S>Z?S:Z,se=se|+ut(+(S-g))>3.141592653589793,l=de+1|0,(l|0)!=(me|0);)Oe=de,z=c,de=l,l=Oe;se&&(X[Je>>3]=Z,X[Be>>3]=O)}}function tt(l){return l=l|0,(l>>>0<4?0:15)|0}function gt(l,a){l=l|0,a=a|0;var c=0,m=0,g=0,w=0,P=0,S=0,z=0,O=0,Z=0,se=0,pe=0,de=0,me=0,Ie=0,Be=0,Je=0,Oe=0,ze=0,De=0,bt=0,Zt=0,Nt=0;if(me=o[l>>2]|0,me){if(Ie=a+8|0,X[Ie>>3]=17976931348623157e292,Be=a+24|0,X[Be>>3]=17976931348623157e292,X[a>>3]=-17976931348623157e292,Je=a+16|0,X[Je>>3]=-17976931348623157e292,(me|0)>0){for(g=o[l+4>>2]|0,pe=17976931348623157e292,de=-17976931348623157e292,m=0,c=-1,z=17976931348623157e292,O=17976931348623157e292,se=-17976931348623157e292,P=-17976931348623157e292,Oe=0;w=+X[g+(Oe<<4)>>3],Z=+X[g+(Oe<<4)+8>>3],Zt=c+2|0,S=+X[g+(((Zt|0)==(me|0)?0:Zt)<<4)+8>>3],w<z&&(X[Ie>>3]=w,z=w),Z<O&&(X[Be>>3]=Z,O=Z),w>se?X[a>>3]=w:w=se,Z>P&&(X[Je>>3]=Z,P=Z),pe=Z>0&Z<pe?Z:pe,de=Z<0&Z>de?Z:de,m=m|+ut(+(Z-S))>3.141592653589793,c=Oe+1|0,(c|0)!=(me|0);)Zt=Oe,se=w,Oe=c,c=Zt;m&&(X[Je>>3]=de,X[Be>>3]=pe)}}else o[a>>2]=0,o[a+4>>2]=0,o[a+8>>2]=0,o[a+12>>2]=0,o[a+16>>2]=0,o[a+20>>2]=0,o[a+24>>2]=0,o[a+28>>2]=0;if(Zt=l+8|0,c=o[Zt>>2]|0,!((c|0)<=0)){bt=l+12|0,De=0;do if(g=o[bt>>2]|0,m=De,De=De+1|0,Be=a+(De<<5)|0,Je=o[g+(m<<3)>>2]|0,Je){if(Oe=a+(De<<5)+8|0,X[Oe>>3]=17976931348623157e292,l=a+(De<<5)+24|0,X[l>>3]=17976931348623157e292,X[Be>>3]=-17976931348623157e292,ze=a+(De<<5)+16|0,X[ze>>3]=-17976931348623157e292,(Je|0)>0){for(me=o[g+(m<<3)+4>>2]|0,pe=17976931348623157e292,de=-17976931348623157e292,g=0,m=-1,Ie=0,z=17976931348623157e292,O=17976931348623157e292,Z=-17976931348623157e292,P=-17976931348623157e292;w=+X[me+(Ie<<4)>>3],se=+X[me+(Ie<<4)+8>>3],m=m+2|0,S=+X[me+(((m|0)==(Je|0)?0:m)<<4)+8>>3],w<z&&(X[Oe>>3]=w,z=w),se<O&&(X[l>>3]=se,O=se),w>Z?X[Be>>3]=w:w=Z,se>P&&(X[ze>>3]=se,P=se),pe=se>0&se<pe?se:pe,de=se<0&se>de?se:de,g=g|+ut(+(se-S))>3.141592653589793,m=Ie+1|0,(m|0)!=(Je|0);)Nt=Ie,Ie=m,Z=w,m=Nt;g&&(X[ze>>3]=de,X[l>>3]=pe)}}else o[Be>>2]=0,o[Be+4>>2]=0,o[Be+8>>2]=0,o[Be+12>>2]=0,o[Be+16>>2]=0,o[Be+20>>2]=0,o[Be+24>>2]=0,o[Be+28>>2]=0,c=o[Zt>>2]|0;while((De|0)<(c|0))}}function Rt(l,a,c){l=l|0,a=a|0,c=c|0;var m=0,g=0,w=0;if(!(Ee(l,a,c)|0))return g=0,g|0;if(g=l+8|0,(o[g>>2]|0)<=0)return g=1,g|0;for(m=l+12|0,l=0;;){if(w=l,l=l+1|0,Ee((o[m>>2]|0)+(w<<3)|0,a+(l<<5)|0,c)|0){l=0,m=6;break}if((l|0)>=(o[g>>2]|0)){l=1,m=6;break}}return(m|0)==6?l|0:0}function Jt(l,a,c,m){l=l|0,a=a|0,c=c|0,m=m|0;var g=0,w=0,P=0,S=0,z=0,O=0,Z=0;if(O=te,te=te+16|0,S=O,P=c+8|0,!(Ee(l,a,P)|0))return z=0,te=O,z|0;z=l+8|0;e:do if((o[z>>2]|0)>0){for(w=l+12|0,g=0;;){if(Z=g,g=g+1|0,Ee((o[w>>2]|0)+(Z<<3)|0,a+(g<<5)|0,P)|0){g=0;break}if((g|0)>=(o[z>>2]|0))break e}return te=O,g|0}while(!1);if(Ti(l,a,c,m)|0)return Z=0,te=O,Z|0;o[S>>2]=o[c>>2],o[S+4>>2]=P,g=o[z>>2]|0;e:do if((g|0)>0)for(l=l+12|0,P=0,w=g;;){if(g=o[l>>2]|0,(o[g+(P<<3)>>2]|0)>0){if(Ee(S,m,o[g+(P<<3)+4>>2]|0)|0){g=0;break e}if(g=P+1|0,Ti((o[l>>2]|0)+(P<<3)|0,a+(g<<5)|0,c,m)|0){g=0;break e}w=o[z>>2]|0}else g=P+1|0;if((g|0)<(w|0))P=g;else{g=1;break}}else g=1;while(!1);return Z=g,te=O,Z|0}function Ti(l,a,c,m){l=l|0,a=a|0,c=c|0,m=m|0;var g=0,w=0,P=0,S=0,z=0,O=0,Z=0,se=0,pe=0,de=0,me=0,Ie=0,Be=0,Je=0,Oe=0,ze=0,De=0,bt=0,Zt=0,Nt=0,ai=0;if(Zt=te,te=te+176|0,Oe=Zt+172|0,g=Zt+168|0,ze=Zt,!(Qn(a,m)|0))return l=0,te=Zt,l|0;if(Si(a,m,Oe,g),fo(ze|0,c|0,168)|0,(o[c>>2]|0)>0){a=0;do Nt=ze+8+(a<<4)+8|0,Je=+$r(+X[Nt>>3],o[g>>2]|0),X[Nt>>3]=Je,a=a+1|0;while((a|0)<(o[c>>2]|0))}Ie=+X[m>>3],Be=+X[m+8>>3],Je=+$r(+X[m+16>>3],o[g>>2]|0),de=+$r(+X[m+24>>3],o[g>>2]|0);e:do if((o[l>>2]|0)>0){if(m=l+4|0,g=o[ze>>2]|0,(g|0)<=0){for(a=0;;)if(a=a+1|0,(a|0)>=(o[l>>2]|0)){a=0;break e}}for(c=0;;){if(a=o[m>>2]|0,pe=+X[a+(c<<4)>>3],me=+$r(+X[a+(c<<4)+8>>3],o[Oe>>2]|0),a=o[m>>2]|0,c=c+1|0,Nt=(c|0)%(o[l>>2]|0)|0,w=+X[a+(Nt<<4)>>3],P=+$r(+X[a+(Nt<<4)+8>>3],o[Oe>>2]|0),!(pe>=Ie)|!(w>=Ie)&&!(pe<=Be)|!(w<=Be)&&!(me<=de)|!(P<=de)&&!(me>=Je)|!(P>=Je)){se=w-pe,O=P-me,a=0;do if(ai=a,a=a+1|0,Nt=(a|0)==(g|0)?0:a,w=+X[ze+8+(ai<<4)+8>>3],P=+X[ze+8+(Nt<<4)+8>>3]-w,S=+X[ze+8+(ai<<4)>>3],z=+X[ze+8+(Nt<<4)>>3]-S,Z=se*P-O*z,Z!=0&&(De=me-w,bt=pe-S,z=(De*z-P*bt)/Z,!(z<0|z>1))&&(Z=(se*De-O*bt)/Z,Z>=0&Z<=1)){a=1;break e}while((a|0)<(g|0))}if((c|0)>=(o[l>>2]|0)){a=0;break}}}else a=0;while(!1);return ai=a,te=Zt,ai|0}function Zr(l,a,c,m){l=l|0,a=a|0,c=c|0,m=m|0;var g=0,w=0,P=0;if(Ti(l,a,c,m)|0)return w=1,w|0;if(w=l+8|0,(o[w>>2]|0)<=0)return w=0,w|0;for(g=l+12|0,l=0;;){if(P=l,l=l+1|0,Ti((o[g>>2]|0)+(P<<3)|0,a+(l<<5)|0,c,m)|0){l=1,g=6;break}if((l|0)>=(o[w>>2]|0)){l=0,g=6;break}}return(g|0)==6?l|0:0}function Br(){return 8}function ps(){return 16}function On(){return 168}function Ks(){return 8}function al(){return 16}function Yl(){return 12}function Xl(){return 8}function br(l){return l=l|0,+(+((o[l>>2]|0)>>>0)+4294967296*+(o[l+4>>2]|0))}function ea(l){l=l|0;var a=0,c=0;return c=+X[l>>3],a=+X[l+8>>3],+ +zt(+(c*c+a*a))}function Nn(l,a,c,m,g){l=l|0,a=a|0,c=c|0,m=m|0,g=g|0;var w=0,P=0,S=0,z=0,O=0,Z=0,se=0,pe=0;O=+X[l>>3],z=+X[a>>3]-O,S=+X[l+8>>3],P=+X[a+8>>3]-S,se=+X[c>>3],w=+X[m>>3]-se,pe=+X[c+8>>3],Z=+X[m+8>>3]-pe,w=(w*(S-pe)-(O-se)*Z)/(z*Z-P*w),X[g>>3]=O+z*w,X[g+8>>3]=S+P*w}function pr(l,a){return l=l|0,a=a|0,+ut(+(+X[l>>3]-+X[a>>3]))<11920928955078125e-23?(a=+ut(+(+X[l+8>>3]-+X[a+8>>3]))<11920928955078125e-23,a|0):(a=0,a|0)}function nr(l,a){l=l|0,a=a|0;var c=0,m=0,g=0;return g=+X[l>>3]-+X[a>>3],m=+X[l+8>>3]-+X[a+8>>3],c=+X[l+16>>3]-+X[a+16>>3],+(g*g+m*m+c*c)}function ll(l,a){l=l|0,a=a|0;var c=0,m=0,g=0;c=+X[l>>3],m=+fi(+c),c=+di(+c),X[a+16>>3]=c,c=+X[l+8>>3],g=m*+fi(+c),X[a>>3]=g,c=m*+di(+c),X[a+8>>3]=c}function Co(l,a,c){l=l|0,a=a|0,c=c|0;var m=0,g=0,w=0;if(w=te,te=te+16|0,g=w,m=$i(l,a)|0,(c+-1|0)>>>0>5||(m=(m|0)!=0,(c|0)==1&m))return g=-1,te=w,g|0;do if(Ao(l,a,g)|0)m=-1;else if(m){m=((o[26352+(c<<2)>>2]|0)+5-(o[g>>2]|0)|0)%5|0;break}else{m=((o[26384+(c<<2)>>2]|0)+6-(o[g>>2]|0)|0)%6|0;break}while(!1);return g=m,te=w,g|0}function Ao(l,a,c){l=l|0,a=a|0,c=c|0;var m=0,g=0,w=0,P=0,S=0,z=0,O=0,Z=0;if(Z=te,te=te+32|0,S=Z+16|0,z=Z,m=$s(l,a,S)|0,m|0)return c=m,te=Z,c|0;w=Rn(l,a)|0,O=Ir(l,a)|0,Ia(w,z),m=Wn(w,o[S>>2]|0)|0;do if(Vi(w)|0){do switch(w|0){case 4:{g=0;break}case 14:{g=1;break}case 24:{g=2;break}case 38:{g=3;break}case 49:{g=4;break}case 58:{g=5;break}case 63:{g=6;break}case 72:{g=7;break}case 83:{g=8;break}case 97:{g=9;break}case 107:{g=10;break}case 117:{g=11;break}default:qt(27795,27797,75,27806)}while(!1);if(P=o[26416+(g*24|0)+8>>2]|0,a=o[26416+(g*24|0)+16>>2]|0,l=o[S>>2]|0,(l|0)!=(o[z>>2]|0)&&(z=oi(w)|0,l=o[S>>2]|0,z|(l|0)==(a|0)&&(m=(m+1|0)%6|0)),(O|0)==3&(l|0)==(a|0)){m=(m+5|0)%6|0;break}(O|0)==5&(l|0)==(P|0)&&(m=(m+1|0)%6|0)}while(!1);return o[c>>2]=m,c=0,te=Z,c|0}function Ur(l,a,c,m){l=l|0,a=a|0,c=c|0,m=m|0;var g=0,w=0,P=0,S=0,z=0,O=0,Z=0,se=0,pe=0,de=0,me=0,Ie=0,Be=0,Je=0,Oe=0,ze=0;if(ze=te,te=te+32|0,Oe=ze+24|0,Be=ze+20|0,me=ze+8|0,de=ze+16|0,pe=ze,z=($i(l,a)|0)==0,z=z?6:5,Z=ht(l|0,a|0,52)|0,ae()|0,Z=Z&15,z>>>0<=c>>>0)return m=2,te=ze,m|0;se=(Z|0)==0,!se&&(Ie=yt(7,0,(Z^15)*3|0)|0,(Ie&l|0)==0&((ae()|0)&a|0)==0)?g=c:w=4;e:do if((w|0)==4){if(g=($i(l,a)|0)!=0,((g?4:5)|0)<(c|0)||Ao(l,a,Oe)|0||(w=(o[Oe>>2]|0)+c|0,g?g=26704+(((w|0)%5|0)<<2)|0:g=26736+(((w|0)%6|0)<<2)|0,Ie=o[g>>2]|0,(Ie|0)==7))return m=1,te=ze,m|0;o[Be>>2]=0,g=ar(l,a,Ie,Be,me)|0;do if(!g){if(S=me,O=o[S>>2]|0,S=o[S+4>>2]|0,P=S>>>0<a>>>0|(S|0)==(a|0)&O>>>0<l>>>0,w=P?O:l,P=P?S:a,!se&&(se=yt(7,0,(Z^15)*3|0)|0,(O&se|0)==0&(S&(ae()|0)|0)==0))g=c;else{if(S=(c+-1+z|0)%(z|0)|0,g=$i(l,a)|0,(S|0)<0&&qt(27795,27797,248,27822),z=(g|0)!=0,((z?4:5)|0)<(S|0)&&qt(27795,27797,248,27822),Ao(l,a,Oe)|0&&qt(27795,27797,248,27822),g=(o[Oe>>2]|0)+S|0,z?g=26704+(((g|0)%5|0)<<2)|0:g=26736+(((g|0)%6|0)<<2)|0,S=o[g>>2]|0,(S|0)==7&&qt(27795,27797,248,27822),o[de>>2]=0,g=ar(l,a,S,de,pe)|0,g|0)break;O=pe,z=o[O>>2]|0,O=o[O+4>>2]|0;do if(O>>>0<P>>>0|(O|0)==(P|0)&z>>>0<w>>>0){if($i(z,O)|0?w=js(z,O,l,a)|0:w=o[26800+((((o[de>>2]|0)+(o[26768+(S<<2)>>2]|0)|0)%6|0)<<2)>>2]|0,g=$i(z,O)|0,(w+-1|0)>>>0>5){g=-1,w=z,P=O;break}if(g=(g|0)!=0,(w|0)==1&g){g=-1,w=z,P=O;break}do if(Ao(z,O,Oe)|0)g=-1;else if(g){g=((o[26352+(w<<2)>>2]|0)+5-(o[Oe>>2]|0)|0)%5|0;break}else{g=((o[26384+(w<<2)>>2]|0)+6-(o[Oe>>2]|0)|0)%6|0;break}while(!1);w=z,P=O}else g=c;while(!1);S=me,O=o[S>>2]|0,S=o[S+4>>2]|0}if((w|0)==(O|0)&(P|0)==(S|0)){if(z=($i(O,S)|0)!=0,z?l=js(O,S,l,a)|0:l=o[26800+((((o[Be>>2]|0)+(o[26768+(Ie<<2)>>2]|0)|0)%6|0)<<2)>>2]|0,g=$i(O,S)|0,(l+-1|0)>>>0<=5&&(Je=(g|0)!=0,!((l|0)==1&Je)))do if(Ao(O,S,Oe)|0)g=-1;else if(Je){g=((o[26352+(l<<2)>>2]|0)+5-(o[Oe>>2]|0)|0)%5|0;break}else{g=((o[26384+(l<<2)>>2]|0)+6-(o[Oe>>2]|0)|0)%6|0;break}while(!1);else g=-1;g=g+1|0,g=(g|0)==6|z&(g|0)==5?0:g}a=P,l=w;break e}while(!1);return m=g,te=ze,m|0}while(!1);return Je=yt(g|0,0,56)|0,Oe=ae()|0|a&-2130706433|536870912,o[m>>2]=Je|l,o[m+4>>2]=Oe,m=0,te=ze,m|0}function ta(l,a,c){l=l|0,a=a|0,c=c|0;var m=0,g=0,w=0;return w=($i(l,a)|0)==0,m=Ur(l,a,0,c)|0,g=(m|0)==0,w?!g||(m=Ur(l,a,1,c+8|0)|0,m|0)||(m=Ur(l,a,2,c+16|0)|0,m|0)||(m=Ur(l,a,3,c+24|0)|0,m|0)||(m=Ur(l,a,4,c+32|0)|0,m)?(w=m,w|0):Ur(l,a,5,c+40|0)|0:!g||(m=Ur(l,a,1,c+8|0)|0,m|0)||(m=Ur(l,a,2,c+16|0)|0,m|0)||(m=Ur(l,a,3,c+24|0)|0,m|0)||(m=Ur(l,a,4,c+32|0)|0,m|0)?(w=m,w|0):(w=c+40|0,o[w>>2]=0,o[w+4>>2]=0,w=0,w|0)}function Kl(l,a,c){l=l|0,a=a|0,c=c|0;var m=0,g=0,w=0,P=0,S=0,z=0;return z=te,te=te+192|0,g=z,w=z+168|0,P=ht(l|0,a|0,56)|0,ae()|0,P=P&7,S=a&-2130706433|134217728,m=$s(l,S,w)|0,m|0?(S=m,te=z,S|0):(a=ht(l|0,a|0,52)|0,ae()|0,a=a&15,$i(l,S)|0?Eo(w,a,P,1,g):da(w,a,P,1,g),S=g+8|0,o[c>>2]=o[S>>2],o[c+4>>2]=o[S+4>>2],o[c+8>>2]=o[S+8>>2],o[c+12>>2]=o[S+12>>2],S=0,te=z,S|0)}function fu(l,a){l=l|0,a=a|0;var c=0,m=0,g=0,w=0;return g=te,te=te+16|0,c=g,!(!0&(a&2013265920|0)==536870912)||(m=a&-2130706433|134217728,!(cs(l,m)|0))?(m=0,te=g,m|0):(w=ht(l|0,a|0,56)|0,ae()|0,w=(Ur(l,m,w&7,c)|0)==0,m=c,m=w&((o[m>>2]|0)==(l|0)?(o[m+4>>2]|0)==(a|0):0)&1,te=g,m|0)}function du(l,a,c){l=l|0,a=a|0,c=c|0;var m=0;(a|0)>0?(m=ts(a,4)|0,o[l>>2]=m,m||qt(27835,27858,40,27872)):o[l>>2]=0,o[l+4>>2]=a,o[l+8>>2]=0,o[l+12>>2]=c}function pu(l){l=l|0;var a=0,c=0,m=0,g=0,w=0,P=0,S=0;g=l+4|0,w=l+12|0,P=l+8|0;e:for(;;){for(c=o[g>>2]|0,a=0;;){if((a|0)>=(c|0))break e;if(m=o[l>>2]|0,S=o[m+(a<<2)>>2]|0,!S)a=a+1|0;else break}a=m+(~~(+ut(+(+$t(10,+ +(15-(o[w>>2]|0)|0))*(+X[S>>3]+ +X[S+8>>3])))%+(c|0))>>>0<<2)|0,c=o[a>>2]|0;t:do if(c|0){if(m=S+32|0,(c|0)==(S|0))o[a>>2]=o[m>>2];else{if(c=c+32|0,a=o[c>>2]|0,!a)break;for(;(a|0)!=(S|0);)if(c=a+32|0,a=o[c>>2]|0,!a)break t;o[c>>2]=o[m>>2]}Qt(S),o[P>>2]=(o[P>>2]|0)+-1}while(!1)}Qt(o[l>>2]|0)}function mu(l){l=l|0;var a=0,c=0,m=0;for(m=o[l+4>>2]|0,c=0;;){if((c|0)>=(m|0)){a=0,c=4;break}if(a=o[(o[l>>2]|0)+(c<<2)>>2]|0,!a)c=c+1|0;else{c=4;break}}return(c|0)==4?a|0:0}function ia(l,a){l=l|0,a=a|0;var c=0,m=0,g=0,w=0;if(c=~~(+ut(+(+$t(10,+ +(15-(o[l+12>>2]|0)|0))*(+X[a>>3]+ +X[a+8>>3])))%+(o[l+4>>2]|0))>>>0,c=(o[l>>2]|0)+(c<<2)|0,m=o[c>>2]|0,!m)return w=1,w|0;w=a+32|0;do if((m|0)!=(a|0)){if(c=o[m+32>>2]|0,!c)return w=1,w|0;for(g=c;;){if((g|0)==(a|0)){g=8;break}if(c=o[g+32>>2]|0,c)m=g,g=c;else{c=1,g=10;break}}if((g|0)==8){o[m+32>>2]=o[w>>2];break}else if((g|0)==10)return c|0}else o[c>>2]=o[w>>2];while(!1);return Qt(a),w=l+8|0,o[w>>2]=(o[w>>2]|0)+-1,w=0,w|0}function _u(l,a,c){l=l|0,a=a|0,c=c|0;var m=0,g=0,w=0,P=0;w=Js(40)|0,w||qt(27888,27858,98,27901),o[w>>2]=o[a>>2],o[w+4>>2]=o[a+4>>2],o[w+8>>2]=o[a+8>>2],o[w+12>>2]=o[a+12>>2],g=w+16|0,o[g>>2]=o[c>>2],o[g+4>>2]=o[c+4>>2],o[g+8>>2]=o[c+8>>2],o[g+12>>2]=o[c+12>>2],o[w+32>>2]=0,g=~~(+ut(+(+$t(10,+ +(15-(o[l+12>>2]|0)|0))*(+X[a>>3]+ +X[a+8>>3])))%+(o[l+4>>2]|0))>>>0,g=(o[l>>2]|0)+(g<<2)|0,m=o[g>>2]|0;do if(!m)o[g>>2]=w;else{for(;!(sn(m,a)|0&&sn(m+16|0,c)|0);)if(g=o[m+32>>2]|0,m=(g|0)==0?m:g,!(o[m+32>>2]|0)){P=10;break}if((P|0)==10){o[m+32>>2]=w;break}return Qt(w),P=m,P|0}while(!1);return P=l+8|0,o[P>>2]=(o[P>>2]|0)+1,P=w,P|0}function gu(l,a,c){l=l|0,a=a|0,c=c|0;var m=0,g=0;if(g=~~(+ut(+(+$t(10,+ +(15-(o[l+12>>2]|0)|0))*(+X[a>>3]+ +X[a+8>>3])))%+(o[l+4>>2]|0))>>>0,g=o[(o[l>>2]|0)+(g<<2)>>2]|0,!g)return c=0,c|0;if(!c){for(l=g;;){if(sn(l,a)|0){m=10;break}if(l=o[l+32>>2]|0,!l){l=0,m=10;break}}if((m|0)==10)return l|0}for(l=g;;){if(sn(l,a)|0&&sn(l+16|0,c)|0){m=10;break}if(l=o[l+32>>2]|0,!l){l=0,m=10;break}}return(m|0)==10?l|0:0}function Sl(l,a){l=l|0,a=a|0;var c=0;if(c=~~(+ut(+(+$t(10,+ +(15-(o[l+12>>2]|0)|0))*(+X[a>>3]+ +X[a+8>>3])))%+(o[l+4>>2]|0))>>>0,l=o[(o[l>>2]|0)+(c<<2)>>2]|0,!l)return c=0,c|0;for(;;){if(sn(l,a)|0){a=5;break}if(l=o[l+32>>2]|0,!l){l=0,a=5;break}}return(a|0)==5?l|0:0}function Fu(){return 27920}function Io(l){return l=+l,~~+kt(+l)|0}function Js(l){l=l|0;var a=0,c=0,m=0,g=0,w=0,P=0,S=0,z=0,O=0,Z=0,se=0,pe=0,de=0,me=0,Ie=0,Be=0,Je=0,Oe=0,ze=0,De=0,bt=0;bt=te,te=te+16|0,pe=bt;do if(l>>>0<245){if(O=l>>>0<11?16:l+11&-8,l=O>>>3,se=o[6981]|0,c=se>>>l,c&3|0)return a=(c&1^1)+l|0,l=27964+(a<<1<<2)|0,c=l+8|0,m=o[c>>2]|0,g=m+8|0,w=o[g>>2]|0,(w|0)==(l|0)?o[6981]=se&~(1<<a):(o[w+12>>2]=l,o[c>>2]=w),De=a<<3,o[m+4>>2]=De|3,De=m+De+4|0,o[De>>2]=o[De>>2]|1,De=g,te=bt,De|0;if(Z=o[6983]|0,O>>>0>Z>>>0){if(c|0)return a=2<<l,a=c<<l&(a|0-a),a=(a&0-a)+-1|0,S=a>>>12&16,a=a>>>S,c=a>>>5&8,a=a>>>c,w=a>>>2&4,a=a>>>w,l=a>>>1&2,a=a>>>l,m=a>>>1&1,m=(c|S|w|l|m)+(a>>>m)|0,a=27964+(m<<1<<2)|0,l=a+8|0,w=o[l>>2]|0,S=w+8|0,c=o[S>>2]|0,(c|0)==(a|0)?(l=se&~(1<<m),o[6981]=l):(o[c+12>>2]=a,o[l>>2]=c,l=se),De=m<<3,P=De-O|0,o[w+4>>2]=O|3,g=w+O|0,o[g+4>>2]=P|1,o[w+De>>2]=P,Z|0&&(m=o[6986]|0,a=Z>>>3,c=27964+(a<<1<<2)|0,a=1<<a,l&a?(l=c+8|0,a=o[l>>2]|0):(o[6981]=l|a,a=c,l=c+8|0),o[l>>2]=m,o[a+12>>2]=m,o[m+8>>2]=a,o[m+12>>2]=c),o[6983]=P,o[6986]=g,De=S,te=bt,De|0;if(w=o[6982]|0,w){for(c=(w&0-w)+-1|0,g=c>>>12&16,c=c>>>g,m=c>>>5&8,c=c>>>m,P=c>>>2&4,c=c>>>P,S=c>>>1&2,c=c>>>S,z=c>>>1&1,z=o[28228+((m|g|P|S|z)+(c>>>z)<<2)>>2]|0,c=z,S=z,z=(o[z+4>>2]&-8)-O|0;l=o[c+16>>2]|0,!(!l&&(l=o[c+20>>2]|0,!l));)P=(o[l+4>>2]&-8)-O|0,g=P>>>0<z>>>0,c=l,S=g?l:S,z=g?P:z;if(P=S+O|0,P>>>0>S>>>0){g=o[S+24>>2]|0,a=o[S+12>>2]|0;do if((a|0)==(S|0)){if(l=S+20|0,a=o[l>>2]|0,!a&&(l=S+16|0,a=o[l>>2]|0,!a)){c=0;break}for(;;)if(m=a+20|0,c=o[m>>2]|0,c)a=c,l=m;else if(m=a+16|0,c=o[m>>2]|0,c)a=c,l=m;else break;o[l>>2]=0,c=a}else c=o[S+8>>2]|0,o[c+12>>2]=a,o[a+8>>2]=c,c=a;while(!1);do if(g|0){if(a=o[S+28>>2]|0,l=28228+(a<<2)|0,(S|0)==(o[l>>2]|0)){if(o[l>>2]=c,!c){o[6982]=w&~(1<<a);break}}else if(De=g+16|0,o[((o[De>>2]|0)==(S|0)?De:g+20|0)>>2]=c,!c)break;o[c+24>>2]=g,a=o[S+16>>2]|0,a|0&&(o[c+16>>2]=a,o[a+24>>2]=c),a=o[S+20>>2]|0,a|0&&(o[c+20>>2]=a,o[a+24>>2]=c)}while(!1);return z>>>0<16?(De=z+O|0,o[S+4>>2]=De|3,De=S+De+4|0,o[De>>2]=o[De>>2]|1):(o[S+4>>2]=O|3,o[P+4>>2]=z|1,o[P+z>>2]=z,Z|0&&(m=o[6986]|0,a=Z>>>3,c=27964+(a<<1<<2)|0,a=1<<a,a&se?(l=c+8|0,a=o[l>>2]|0):(o[6981]=a|se,a=c,l=c+8|0),o[l>>2]=m,o[a+12>>2]=m,o[m+8>>2]=a,o[m+12>>2]=c),o[6983]=z,o[6986]=P),De=S+8|0,te=bt,De|0}else se=O}else se=O}else se=O}else if(l>>>0<=4294967231)if(l=l+11|0,O=l&-8,m=o[6982]|0,m){g=0-O|0,l=l>>>8,l?O>>>0>16777215?z=31:(se=(l+1048320|0)>>>16&8,Ie=l<<se,S=(Ie+520192|0)>>>16&4,Ie=Ie<<S,z=(Ie+245760|0)>>>16&2,z=14-(S|se|z)+(Ie<<z>>>15)|0,z=O>>>(z+7|0)&1|z<<1):z=0,c=o[28228+(z<<2)>>2]|0;e:do if(!c)c=0,l=0,Ie=61;else for(l=0,S=O<<((z|0)==31?0:25-(z>>>1)|0),w=0;;){if(P=(o[c+4>>2]&-8)-O|0,P>>>0<g>>>0)if(P)l=c,g=P;else{l=c,g=0,Ie=65;break e}if(Ie=o[c+20>>2]|0,c=o[c+16+(S>>>31<<2)>>2]|0,w=(Ie|0)==0|(Ie|0)==(c|0)?w:Ie,c)S=S<<1;else{c=w,Ie=61;break}}while(!1);if((Ie|0)==61){if((c|0)==0&(l|0)==0){if(l=2<<z,l=(l|0-l)&m,!l){se=O;break}se=(l&0-l)+-1|0,P=se>>>12&16,se=se>>>P,w=se>>>5&8,se=se>>>w,S=se>>>2&4,se=se>>>S,z=se>>>1&2,se=se>>>z,c=se>>>1&1,l=0,c=o[28228+((w|P|S|z|c)+(se>>>c)<<2)>>2]|0}c?Ie=65:(S=l,P=g)}if((Ie|0)==65)for(w=c;;)if(se=(o[w+4>>2]&-8)-O|0,c=se>>>0<g>>>0,g=c?se:g,l=c?w:l,c=o[w+16>>2]|0,c||(c=o[w+20>>2]|0),c)w=c;else{S=l,P=g;break}if((S|0)!=0&&P>>>0<((o[6983]|0)-O|0)>>>0&&(Z=S+O|0,Z>>>0>S>>>0)){w=o[S+24>>2]|0,a=o[S+12>>2]|0;do if((a|0)==(S|0)){if(l=S+20|0,a=o[l>>2]|0,!a&&(l=S+16|0,a=o[l>>2]|0,!a)){a=0;break}for(;;)if(g=a+20|0,c=o[g>>2]|0,c)a=c,l=g;else if(g=a+16|0,c=o[g>>2]|0,c)a=c,l=g;else break;o[l>>2]=0}else De=o[S+8>>2]|0,o[De+12>>2]=a,o[a+8>>2]=De;while(!1);do if(w){if(l=o[S+28>>2]|0,c=28228+(l<<2)|0,(S|0)==(o[c>>2]|0)){if(o[c>>2]=a,!a){m=m&~(1<<l),o[6982]=m;break}}else if(De=w+16|0,o[((o[De>>2]|0)==(S|0)?De:w+20|0)>>2]=a,!a)break;o[a+24>>2]=w,l=o[S+16>>2]|0,l|0&&(o[a+16>>2]=l,o[l+24>>2]=a),l=o[S+20>>2]|0,l&&(o[a+20>>2]=l,o[l+24>>2]=a)}while(!1);e:do if(P>>>0<16)De=P+O|0,o[S+4>>2]=De|3,De=S+De+4|0,o[De>>2]=o[De>>2]|1;else{if(o[S+4>>2]=O|3,o[Z+4>>2]=P|1,o[Z+P>>2]=P,a=P>>>3,P>>>0<256){c=27964+(a<<1<<2)|0,l=o[6981]|0,a=1<<a,l&a?(l=c+8|0,a=o[l>>2]|0):(o[6981]=l|a,a=c,l=c+8|0),o[l>>2]=Z,o[a+12>>2]=Z,o[Z+8>>2]=a,o[Z+12>>2]=c;break}if(a=P>>>8,a?P>>>0>16777215?c=31:(ze=(a+1048320|0)>>>16&8,De=a<<ze,Oe=(De+520192|0)>>>16&4,De=De<<Oe,c=(De+245760|0)>>>16&2,c=14-(Oe|ze|c)+(De<<c>>>15)|0,c=P>>>(c+7|0)&1|c<<1):c=0,a=28228+(c<<2)|0,o[Z+28>>2]=c,l=Z+16|0,o[l+4>>2]=0,o[l>>2]=0,l=1<<c,!(m&l)){o[6982]=m|l,o[a>>2]=Z,o[Z+24>>2]=a,o[Z+12>>2]=Z,o[Z+8>>2]=Z;break}a=o[a>>2]|0;t:do if((o[a+4>>2]&-8|0)!=(P|0)){for(m=P<<((c|0)==31?0:25-(c>>>1)|0);c=a+16+(m>>>31<<2)|0,l=o[c>>2]|0,!!l;)if((o[l+4>>2]&-8|0)==(P|0)){a=l;break t}else m=m<<1,a=l;o[c>>2]=Z,o[Z+24>>2]=a,o[Z+12>>2]=Z,o[Z+8>>2]=Z;break e}while(!1);ze=a+8|0,De=o[ze>>2]|0,o[De+12>>2]=Z,o[ze>>2]=Z,o[Z+8>>2]=De,o[Z+12>>2]=a,o[Z+24>>2]=0}while(!1);return De=S+8|0,te=bt,De|0}else se=O}else se=O;else se=-1;while(!1);if(c=o[6983]|0,c>>>0>=se>>>0)return a=c-se|0,l=o[6986]|0,a>>>0>15?(De=l+se|0,o[6986]=De,o[6983]=a,o[De+4>>2]=a|1,o[l+c>>2]=a,o[l+4>>2]=se|3):(o[6983]=0,o[6986]=0,o[l+4>>2]=c|3,De=l+c+4|0,o[De>>2]=o[De>>2]|1),De=l+8|0,te=bt,De|0;if(P=o[6984]|0,P>>>0>se>>>0)return Oe=P-se|0,o[6984]=Oe,De=o[6987]|0,ze=De+se|0,o[6987]=ze,o[ze+4>>2]=Oe|1,o[De+4>>2]=se|3,De=De+8|0,te=bt,De|0;if(o[7099]|0?l=o[7101]|0:(o[7101]=4096,o[7100]=4096,o[7102]=-1,o[7103]=-1,o[7104]=0,o[7092]=0,o[7099]=pe&-16^1431655768,l=4096),S=se+48|0,z=se+47|0,w=l+z|0,g=0-l|0,O=w&g,O>>>0<=se>>>0||(l=o[7091]|0,l|0&&(Z=o[7089]|0,pe=Z+O|0,pe>>>0<=Z>>>0|pe>>>0>l>>>0)))return De=0,te=bt,De|0;e:do if(o[7092]&4)a=0,Ie=143;else{c=o[6987]|0;t:do if(c){for(m=28372;pe=o[m>>2]|0,!(pe>>>0<=c>>>0&&(pe+(o[m+4>>2]|0)|0)>>>0>c>>>0);)if(l=o[m+8>>2]|0,l)m=l;else{Ie=128;break t}if(a=w-P&g,a>>>0<2147483647)if(l=po(a|0)|0,(l|0)==((o[m>>2]|0)+(o[m+4>>2]|0)|0)){if((l|0)!=-1){P=a,w=l,Ie=145;break e}}else m=l,Ie=136;else a=0}else Ie=128;while(!1);do if((Ie|0)==128)if(c=po(0)|0,(c|0)!=-1&&(a=c,de=o[7100]|0,me=de+-1|0,a=((me&a|0)==0?0:(me+a&0-de)-a|0)+O|0,de=o[7089]|0,me=a+de|0,a>>>0>se>>>0&a>>>0<2147483647)){if(pe=o[7091]|0,pe|0&&me>>>0<=de>>>0|me>>>0>pe>>>0){a=0;break}if(l=po(a|0)|0,(l|0)==(c|0)){P=a,w=c,Ie=145;break e}else m=l,Ie=136}else a=0;while(!1);do if((Ie|0)==136){if(c=0-a|0,!(S>>>0>a>>>0&(a>>>0<2147483647&(m|0)!=-1)))if((m|0)==-1){a=0;break}else{P=a,w=m,Ie=145;break e}if(l=o[7101]|0,l=z-a+l&0-l,l>>>0>=2147483647){P=a,w=m,Ie=145;break e}if((po(l|0)|0)==-1){po(c|0)|0,a=0;break}else{P=l+a|0,w=m,Ie=145;break e}}while(!1);o[7092]=o[7092]|4,Ie=143}while(!1);if((Ie|0)==143&&O>>>0<2147483647&&(Oe=po(O|0)|0,me=po(0)|0,Be=me-Oe|0,Je=Be>>>0>(se+40|0)>>>0,!((Oe|0)==-1|Je^1|Oe>>>0<me>>>0&((Oe|0)!=-1&(me|0)!=-1)^1))&&(P=Je?Be:a,w=Oe,Ie=145),(Ie|0)==145){a=(o[7089]|0)+P|0,o[7089]=a,a>>>0>(o[7090]|0)>>>0&&(o[7090]=a),z=o[6987]|0;e:do if(z){for(a=28372;;){if(l=o[a>>2]|0,c=o[a+4>>2]|0,(w|0)==(l+c|0)){Ie=154;break}if(m=o[a+8>>2]|0,m)a=m;else break}if((Ie|0)==154&&(ze=a+4|0,(o[a+12>>2]&8|0)==0)&&w>>>0>z>>>0&l>>>0<=z>>>0){o[ze>>2]=c+P,De=(o[6984]|0)+P|0,Oe=z+8|0,Oe=(Oe&7|0)==0?0:0-Oe&7,ze=z+Oe|0,Oe=De-Oe|0,o[6987]=ze,o[6984]=Oe,o[ze+4>>2]=Oe|1,o[z+De+4>>2]=40,o[6988]=o[7103];break}for(w>>>0<(o[6985]|0)>>>0&&(o[6985]=w),c=w+P|0,a=28372;;){if((o[a>>2]|0)==(c|0)){Ie=162;break}if(l=o[a+8>>2]|0,l)a=l;else break}if((Ie|0)==162&&(o[a+12>>2]&8|0)==0){o[a>>2]=w,Z=a+4|0,o[Z>>2]=(o[Z>>2]|0)+P,Z=w+8|0,Z=w+((Z&7|0)==0?0:0-Z&7)|0,a=c+8|0,a=c+((a&7|0)==0?0:0-a&7)|0,O=Z+se|0,S=a-Z-se|0,o[Z+4>>2]=se|3;t:do if((z|0)==(a|0))De=(o[6984]|0)+S|0,o[6984]=De,o[6987]=O,o[O+4>>2]=De|1;else{if((o[6986]|0)==(a|0)){De=(o[6983]|0)+S|0,o[6983]=De,o[6986]=O,o[O+4>>2]=De|1,o[O+De>>2]=De;break}if(l=o[a+4>>2]|0,(l&3|0)==1){P=l&-8,m=l>>>3;i:do if(l>>>0<256)if(l=o[a+8>>2]|0,c=o[a+12>>2]|0,(c|0)==(l|0)){o[6981]=o[6981]&~(1<<m);break}else{o[l+12>>2]=c,o[c+8>>2]=l;break}else{w=o[a+24>>2]|0,l=o[a+12>>2]|0;do if((l|0)==(a|0)){if(c=a+16|0,m=c+4|0,l=o[m>>2]|0,l)c=m;else if(l=o[c>>2]|0,!l){l=0;break}for(;;)if(g=l+20|0,m=o[g>>2]|0,m)l=m,c=g;else if(g=l+16|0,m=o[g>>2]|0,m)l=m,c=g;else break;o[c>>2]=0}else De=o[a+8>>2]|0,o[De+12>>2]=l,o[l+8>>2]=De;while(!1);if(!w)break;c=o[a+28>>2]|0,m=28228+(c<<2)|0;do if((o[m>>2]|0)!=(a|0)){if(De=w+16|0,o[((o[De>>2]|0)==(a|0)?De:w+20|0)>>2]=l,!l)break i}else{if(o[m>>2]=l,l|0)break;o[6982]=o[6982]&~(1<<c);break i}while(!1);if(o[l+24>>2]=w,c=a+16|0,m=o[c>>2]|0,m|0&&(o[l+16>>2]=m,o[m+24>>2]=l),c=o[c+4>>2]|0,!c)break;o[l+20>>2]=c,o[c+24>>2]=l}while(!1);a=a+P|0,g=P+S|0}else g=S;if(a=a+4|0,o[a>>2]=o[a>>2]&-2,o[O+4>>2]=g|1,o[O+g>>2]=g,a=g>>>3,g>>>0<256){c=27964+(a<<1<<2)|0,l=o[6981]|0,a=1<<a,l&a?(l=c+8|0,a=o[l>>2]|0):(o[6981]=l|a,a=c,l=c+8|0),o[l>>2]=O,o[a+12>>2]=O,o[O+8>>2]=a,o[O+12>>2]=c;break}a=g>>>8;do if(!a)m=0;else{if(g>>>0>16777215){m=31;break}ze=(a+1048320|0)>>>16&8,De=a<<ze,Oe=(De+520192|0)>>>16&4,De=De<<Oe,m=(De+245760|0)>>>16&2,m=14-(Oe|ze|m)+(De<<m>>>15)|0,m=g>>>(m+7|0)&1|m<<1}while(!1);if(a=28228+(m<<2)|0,o[O+28>>2]=m,l=O+16|0,o[l+4>>2]=0,o[l>>2]=0,l=o[6982]|0,c=1<<m,!(l&c)){o[6982]=l|c,o[a>>2]=O,o[O+24>>2]=a,o[O+12>>2]=O,o[O+8>>2]=O;break}a=o[a>>2]|0;i:do if((o[a+4>>2]&-8|0)!=(g|0)){for(m=g<<((m|0)==31?0:25-(m>>>1)|0);c=a+16+(m>>>31<<2)|0,l=o[c>>2]|0,!!l;)if((o[l+4>>2]&-8|0)==(g|0)){a=l;break i}else m=m<<1,a=l;o[c>>2]=O,o[O+24>>2]=a,o[O+12>>2]=O,o[O+8>>2]=O;break t}while(!1);ze=a+8|0,De=o[ze>>2]|0,o[De+12>>2]=O,o[ze>>2]=O,o[O+8>>2]=De,o[O+12>>2]=a,o[O+24>>2]=0}while(!1);return De=Z+8|0,te=bt,De|0}for(a=28372;l=o[a>>2]|0,!(l>>>0<=z>>>0&&(De=l+(o[a+4>>2]|0)|0,De>>>0>z>>>0));)a=o[a+8>>2]|0;g=De+-47|0,l=g+8|0,l=g+((l&7|0)==0?0:0-l&7)|0,g=z+16|0,l=l>>>0<g>>>0?z:l,a=l+8|0,c=P+-40|0,Oe=w+8|0,Oe=(Oe&7|0)==0?0:0-Oe&7,ze=w+Oe|0,Oe=c-Oe|0,o[6987]=ze,o[6984]=Oe,o[ze+4>>2]=Oe|1,o[w+c+4>>2]=40,o[6988]=o[7103],c=l+4|0,o[c>>2]=27,o[a>>2]=o[7093],o[a+4>>2]=o[7094],o[a+8>>2]=o[7095],o[a+12>>2]=o[7096],o[7093]=w,o[7094]=P,o[7096]=0,o[7095]=a,a=l+24|0;do ze=a,a=a+4|0,o[a>>2]=7;while((ze+8|0)>>>0<De>>>0);if((l|0)!=(z|0)){if(w=l-z|0,o[c>>2]=o[c>>2]&-2,o[z+4>>2]=w|1,o[l>>2]=w,a=w>>>3,w>>>0<256){c=27964+(a<<1<<2)|0,l=o[6981]|0,a=1<<a,l&a?(l=c+8|0,a=o[l>>2]|0):(o[6981]=l|a,a=c,l=c+8|0),o[l>>2]=z,o[a+12>>2]=z,o[z+8>>2]=a,o[z+12>>2]=c;break}if(a=w>>>8,a?w>>>0>16777215?m=31:(ze=(a+1048320|0)>>>16&8,De=a<<ze,Oe=(De+520192|0)>>>16&4,De=De<<Oe,m=(De+245760|0)>>>16&2,m=14-(Oe|ze|m)+(De<<m>>>15)|0,m=w>>>(m+7|0)&1|m<<1):m=0,c=28228+(m<<2)|0,o[z+28>>2]=m,o[z+20>>2]=0,o[g>>2]=0,a=o[6982]|0,l=1<<m,!(a&l)){o[6982]=a|l,o[c>>2]=z,o[z+24>>2]=c,o[z+12>>2]=z,o[z+8>>2]=z;break}a=o[c>>2]|0;t:do if((o[a+4>>2]&-8|0)!=(w|0)){for(m=w<<((m|0)==31?0:25-(m>>>1)|0);c=a+16+(m>>>31<<2)|0,l=o[c>>2]|0,!!l;)if((o[l+4>>2]&-8|0)==(w|0)){a=l;break t}else m=m<<1,a=l;o[c>>2]=z,o[z+24>>2]=a,o[z+12>>2]=z,o[z+8>>2]=z;break e}while(!1);ze=a+8|0,De=o[ze>>2]|0,o[De+12>>2]=z,o[ze>>2]=z,o[z+8>>2]=De,o[z+12>>2]=a,o[z+24>>2]=0}}else De=o[6985]|0,(De|0)==0|w>>>0<De>>>0&&(o[6985]=w),o[7093]=w,o[7094]=P,o[7096]=0,o[6990]=o[7099],o[6989]=-1,o[6994]=27964,o[6993]=27964,o[6996]=27972,o[6995]=27972,o[6998]=27980,o[6997]=27980,o[7e3]=27988,o[6999]=27988,o[7002]=27996,o[7001]=27996,o[7004]=28004,o[7003]=28004,o[7006]=28012,o[7005]=28012,o[7008]=28020,o[7007]=28020,o[7010]=28028,o[7009]=28028,o[7012]=28036,o[7011]=28036,o[7014]=28044,o[7013]=28044,o[7016]=28052,o[7015]=28052,o[7018]=28060,o[7017]=28060,o[7020]=28068,o[7019]=28068,o[7022]=28076,o[7021]=28076,o[7024]=28084,o[7023]=28084,o[7026]=28092,o[7025]=28092,o[7028]=28100,o[7027]=28100,o[7030]=28108,o[7029]=28108,o[7032]=28116,o[7031]=28116,o[7034]=28124,o[7033]=28124,o[7036]=28132,o[7035]=28132,o[7038]=28140,o[7037]=28140,o[7040]=28148,o[7039]=28148,o[7042]=28156,o[7041]=28156,o[7044]=28164,o[7043]=28164,o[7046]=28172,o[7045]=28172,o[7048]=28180,o[7047]=28180,o[7050]=28188,o[7049]=28188,o[7052]=28196,o[7051]=28196,o[7054]=28204,o[7053]=28204,o[7056]=28212,o[7055]=28212,De=P+-40|0,Oe=w+8|0,Oe=(Oe&7|0)==0?0:0-Oe&7,ze=w+Oe|0,Oe=De-Oe|0,o[6987]=ze,o[6984]=Oe,o[ze+4>>2]=Oe|1,o[w+De+4>>2]=40,o[6988]=o[7103];while(!1);if(a=o[6984]|0,a>>>0>se>>>0)return Oe=a-se|0,o[6984]=Oe,De=o[6987]|0,ze=De+se|0,o[6987]=ze,o[ze+4>>2]=Oe|1,o[De+4>>2]=se|3,De=De+8|0,te=bt,De|0}return De=Fu()|0,o[De>>2]=12,De=0,te=bt,De|0}function Qt(l){l=l|0;var a=0,c=0,m=0,g=0,w=0,P=0,S=0,z=0;if(l){c=l+-8|0,g=o[6985]|0,l=o[l+-4>>2]|0,a=l&-8,z=c+a|0;do if(l&1)S=c,P=c;else{if(m=o[c>>2]|0,!(l&3)||(P=c+(0-m)|0,w=m+a|0,P>>>0<g>>>0))return;if((o[6986]|0)==(P|0)){if(l=z+4|0,a=o[l>>2]|0,(a&3|0)!=3){S=P,a=w;break}o[6983]=w,o[l>>2]=a&-2,o[P+4>>2]=w|1,o[P+w>>2]=w;return}if(c=m>>>3,m>>>0<256)if(l=o[P+8>>2]|0,a=o[P+12>>2]|0,(a|0)==(l|0)){o[6981]=o[6981]&~(1<<c),S=P,a=w;break}else{o[l+12>>2]=a,o[a+8>>2]=l,S=P,a=w;break}g=o[P+24>>2]|0,l=o[P+12>>2]|0;do if((l|0)==(P|0)){if(a=P+16|0,c=a+4|0,l=o[c>>2]|0,l)a=c;else if(l=o[a>>2]|0,!l){l=0;break}for(;;)if(m=l+20|0,c=o[m>>2]|0,c)l=c,a=m;else if(m=l+16|0,c=o[m>>2]|0,c)l=c,a=m;else break;o[a>>2]=0}else S=o[P+8>>2]|0,o[S+12>>2]=l,o[l+8>>2]=S;while(!1);if(g){if(a=o[P+28>>2]|0,c=28228+(a<<2)|0,(o[c>>2]|0)==(P|0)){if(o[c>>2]=l,!l){o[6982]=o[6982]&~(1<<a),S=P,a=w;break}}else if(S=g+16|0,o[((o[S>>2]|0)==(P|0)?S:g+20|0)>>2]=l,!l){S=P,a=w;break}o[l+24>>2]=g,a=P+16|0,c=o[a>>2]|0,c|0&&(o[l+16>>2]=c,o[c+24>>2]=l),a=o[a+4>>2]|0,a?(o[l+20>>2]=a,o[a+24>>2]=l,S=P,a=w):(S=P,a=w)}else S=P,a=w}while(!1);if(!(P>>>0>=z>>>0)&&(l=z+4|0,m=o[l>>2]|0,!!(m&1))){if(m&2)o[l>>2]=m&-2,o[S+4>>2]=a|1,o[P+a>>2]=a,g=a;else{if((o[6987]|0)==(z|0)){if(z=(o[6984]|0)+a|0,o[6984]=z,o[6987]=S,o[S+4>>2]=z|1,(S|0)!=(o[6986]|0))return;o[6986]=0,o[6983]=0;return}if((o[6986]|0)==(z|0)){z=(o[6983]|0)+a|0,o[6983]=z,o[6986]=P,o[S+4>>2]=z|1,o[P+z>>2]=z;return}g=(m&-8)+a|0,c=m>>>3;do if(m>>>0<256)if(a=o[z+8>>2]|0,l=o[z+12>>2]|0,(l|0)==(a|0)){o[6981]=o[6981]&~(1<<c);break}else{o[a+12>>2]=l,o[l+8>>2]=a;break}else{w=o[z+24>>2]|0,l=o[z+12>>2]|0;do if((l|0)==(z|0)){if(a=z+16|0,c=a+4|0,l=o[c>>2]|0,l)a=c;else if(l=o[a>>2]|0,!l){c=0;break}for(;;)if(m=l+20|0,c=o[m>>2]|0,c)l=c,a=m;else if(m=l+16|0,c=o[m>>2]|0,c)l=c,a=m;else break;o[a>>2]=0,c=l}else c=o[z+8>>2]|0,o[c+12>>2]=l,o[l+8>>2]=c,c=l;while(!1);if(w|0){if(l=o[z+28>>2]|0,a=28228+(l<<2)|0,(o[a>>2]|0)==(z|0)){if(o[a>>2]=c,!c){o[6982]=o[6982]&~(1<<l);break}}else if(m=w+16|0,o[((o[m>>2]|0)==(z|0)?m:w+20|0)>>2]=c,!c)break;o[c+24>>2]=w,l=z+16|0,a=o[l>>2]|0,a|0&&(o[c+16>>2]=a,o[a+24>>2]=c),l=o[l+4>>2]|0,l|0&&(o[c+20>>2]=l,o[l+24>>2]=c)}}while(!1);if(o[S+4>>2]=g|1,o[P+g>>2]=g,(S|0)==(o[6986]|0)){o[6983]=g;return}}if(l=g>>>3,g>>>0<256){c=27964+(l<<1<<2)|0,a=o[6981]|0,l=1<<l,a&l?(a=c+8|0,l=o[a>>2]|0):(o[6981]=a|l,l=c,a=c+8|0),o[a>>2]=S,o[l+12>>2]=S,o[S+8>>2]=l,o[S+12>>2]=c;return}l=g>>>8,l?g>>>0>16777215?m=31:(P=(l+1048320|0)>>>16&8,z=l<<P,w=(z+520192|0)>>>16&4,z=z<<w,m=(z+245760|0)>>>16&2,m=14-(w|P|m)+(z<<m>>>15)|0,m=g>>>(m+7|0)&1|m<<1):m=0,l=28228+(m<<2)|0,o[S+28>>2]=m,o[S+20>>2]=0,o[S+16>>2]=0,a=o[6982]|0,c=1<<m;e:do if(!(a&c))o[6982]=a|c,o[l>>2]=S,o[S+24>>2]=l,o[S+12>>2]=S,o[S+8>>2]=S;else{l=o[l>>2]|0;t:do if((o[l+4>>2]&-8|0)!=(g|0)){for(m=g<<((m|0)==31?0:25-(m>>>1)|0);c=l+16+(m>>>31<<2)|0,a=o[c>>2]|0,!!a;)if((o[a+4>>2]&-8|0)==(g|0)){l=a;break t}else m=m<<1,l=a;o[c>>2]=S,o[S+24>>2]=l,o[S+12>>2]=S,o[S+8>>2]=S;break e}while(!1);P=l+8|0,z=o[P>>2]|0,o[z+12>>2]=S,o[P>>2]=S,o[S+8>>2]=z,o[S+12>>2]=l,o[S+24>>2]=0}while(!1);if(z=(o[6989]|0)+-1|0,o[6989]=z,!(z|0)){for(l=28380;l=o[l>>2]|0,l;)l=l+8|0;o[6989]=-1}}}}function ts(l,a){l=l|0,a=a|0;var c=0;return l?(c=Hn(a,l)|0,(a|l)>>>0>65535&&(c=((c>>>0)/(l>>>0)|0|0)==(a|0)?c:-1)):c=0,l=Js(c)|0,!l||!(o[l+-4>>2]&3)||bn(l|0,0,c|0)|0,l|0}function Wt(l,a,c,m){return l=l|0,a=a|0,c=c|0,m=m|0,c=l+c>>>0,Ft(a+m+(c>>>0<l>>>0|0)>>>0|0),c|0|0}function wr(l,a,c,m){return l=l|0,a=a|0,c=c|0,m=m|0,m=a-m-(c>>>0>l>>>0|0)>>>0,Ft(m|0),l-c>>>0|0|0}function yu(l){return l=l|0,(l?31-(vr(l^l-1)|0)|0:32)|0}function bs(l,a,c,m,g){l=l|0,a=a|0,c=c|0,m=m|0,g=g|0;var w=0,P=0,S=0,z=0,O=0,Z=0,se=0,pe=0,de=0,me=0;if(Z=l,z=a,O=z,P=c,pe=m,S=pe,!O)return w=(g|0)!=0,S?w?(o[g>>2]=l|0,o[g+4>>2]=a&0,pe=0,g=0,Ft(pe|0),g|0):(pe=0,g=0,Ft(pe|0),g|0):(w&&(o[g>>2]=(Z>>>0)%(P>>>0),o[g+4>>2]=0),pe=0,g=(Z>>>0)/(P>>>0)>>>0,Ft(pe|0),g|0);w=(S|0)==0;do if(P){if(!w){if(w=(vr(S|0)|0)-(vr(O|0)|0)|0,w>>>0<=31){se=w+1|0,S=31-w|0,a=w-31>>31,P=se,l=Z>>>(se>>>0)&a|O<<S,a=O>>>(se>>>0)&a,w=0,S=Z<<S;break}return g?(o[g>>2]=l|0,o[g+4>>2]=z|a&0,pe=0,g=0,Ft(pe|0),g|0):(pe=0,g=0,Ft(pe|0),g|0)}if(w=P-1|0,w&P|0){S=(vr(P|0)|0)+33-(vr(O|0)|0)|0,me=64-S|0,se=32-S|0,z=se>>31,de=S-32|0,a=de>>31,P=S,l=se-1>>31&O>>>(de>>>0)|(O<<se|Z>>>(S>>>0))&a,a=a&O>>>(S>>>0),w=Z<<me&z,S=(O<<me|Z>>>(de>>>0))&z|Z<<se&S-33>>31;break}return g|0&&(o[g>>2]=w&Z,o[g+4>>2]=0),(P|0)==1?(de=z|a&0,me=l|0|0,Ft(de|0),me|0):(me=yu(P|0)|0,de=O>>>(me>>>0)|0,me=O<<32-me|Z>>>(me>>>0)|0,Ft(de|0),me|0)}else{if(w)return g|0&&(o[g>>2]=(O>>>0)%(P>>>0),o[g+4>>2]=0),de=0,me=(O>>>0)/(P>>>0)>>>0,Ft(de|0),me|0;if(!Z)return g|0&&(o[g>>2]=0,o[g+4>>2]=(O>>>0)%(S>>>0)),de=0,me=(O>>>0)/(S>>>0)>>>0,Ft(de|0),me|0;if(w=S-1|0,!(w&S))return g|0&&(o[g>>2]=l|0,o[g+4>>2]=w&O|a&0),de=0,me=O>>>((yu(S|0)|0)>>>0),Ft(de|0),me|0;if(w=(vr(S|0)|0)-(vr(O|0)|0)|0,w>>>0<=30){a=w+1|0,S=31-w|0,P=a,l=O<<S|Z>>>(a>>>0),a=O>>>(a>>>0),w=0,S=Z<<S;break}return g?(o[g>>2]=l|0,o[g+4>>2]=z|a&0,de=0,me=0,Ft(de|0),me|0):(de=0,me=0,Ft(de|0),me|0)}while(!1);if(!P)O=S,z=0,S=0;else{se=c|0|0,Z=pe|m&0,O=Wt(se|0,Z|0,-1,-1)|0,c=ae()|0,z=S,S=0;do m=z,z=w>>>31|z<<1,w=S|w<<1,m=l<<1|m>>>31|0,pe=l>>>31|a<<1|0,wr(O|0,c|0,m|0,pe|0)|0,me=ae()|0,de=me>>31|((me|0)<0?-1:0)<<1,S=de&1,l=wr(m|0,pe|0,de&se|0,(((me|0)<0?-1:0)>>31|((me|0)<0?-1:0)<<1)&Z|0)|0,a=ae()|0,P=P-1|0;while((P|0)!=0);O=z,z=0}return P=0,g|0&&(o[g>>2]=l,o[g+4>>2]=a),de=(w|0)>>>31|(O|P)<<1|(P<<1|w>>>31)&0|z,me=(w<<1|0)&-2|S,Ft(de|0),me|0}function xn(l,a,c,m){l=l|0,a=a|0,c=c|0,m=m|0;var g=0,w=0,P=0,S=0,z=0,O=0;return O=a>>31|((a|0)<0?-1:0)<<1,z=((a|0)<0?-1:0)>>31|((a|0)<0?-1:0)<<1,w=m>>31|((m|0)<0?-1:0)<<1,g=((m|0)<0?-1:0)>>31|((m|0)<0?-1:0)<<1,S=wr(O^l|0,z^a|0,O|0,z|0)|0,P=ae()|0,l=w^O,a=g^z,wr((bs(S,P,wr(w^c|0,g^m|0,w|0,g|0)|0,ae()|0,0)|0)^l|0,(ae()|0)^a|0,l|0,a|0)|0}function Ou(l,a){l=l|0,a=a|0;var c=0,m=0,g=0,w=0;return w=l&65535,g=a&65535,c=Hn(g,w)|0,m=l>>>16,l=(c>>>16)+(Hn(g,m)|0)|0,g=a>>>16,a=Hn(g,w)|0,Ft((l>>>16)+(Hn(g,m)|0)+(((l&65535)+a|0)>>>16)|0),l+a<<16|c&65535|0|0}function lr(l,a,c,m){l=l|0,a=a|0,c=c|0,m=m|0;var g=0,w=0;return g=l,w=c,c=Ou(g,w)|0,l=ae()|0,Ft((Hn(a,w)|0)+(Hn(m,g)|0)+l|l&0|0),c|0|0|0}function ul(l,a,c,m){l=l|0,a=a|0,c=c|0,m=m|0;var g=0,w=0,P=0,S=0,z=0,O=0;return g=te,te=te+16|0,S=g|0,P=a>>31|((a|0)<0?-1:0)<<1,w=((a|0)<0?-1:0)>>31|((a|0)<0?-1:0)<<1,O=m>>31|((m|0)<0?-1:0)<<1,z=((m|0)<0?-1:0)>>31|((m|0)<0?-1:0)<<1,l=wr(P^l|0,w^a|0,P|0,w|0)|0,a=ae()|0,bs(l,a,wr(O^c|0,z^m|0,O|0,z|0)|0,ae()|0,S)|0,m=wr(o[S>>2]^P|0,o[S+4>>2]^w|0,P|0,w|0)|0,c=ae()|0,te=g,Ft(c|0),m|0}function Do(l,a,c,m){l=l|0,a=a|0,c=c|0,m=m|0;var g=0,w=0;return w=te,te=te+16|0,g=w|0,bs(l,a,c,m,g)|0,te=w,Ft(o[g+4>>2]|0),o[g>>2]|0|0}function hl(l,a,c){return l=l|0,a=a|0,c=c|0,(c|0)<32?(Ft(a>>c|0),l>>>c|(a&(1<<c)-1)<<32-c):(Ft(((a|0)<0?-1:0)|0),a>>c-32|0)}function ht(l,a,c){return l=l|0,a=a|0,c=c|0,(c|0)<32?(Ft(a>>>c|0),l>>>c|(a&(1<<c)-1)<<32-c):(Ft(0),a>>>c-32|0)}function yt(l,a,c){return l=l|0,a=a|0,c=c|0,(c|0)<32?(Ft(a<<c|(l&(1<<c)-1<<32-c)>>>32-c|0),l<<c):(Ft(l<<c-32|0),0)}function Jl(l,a,c){return l=l|0,a=a|0,a=vr(a)|0,(a|0)==32&&(a=a+(vr(l)|0)|0),Ft(0),a|0}function Nu(l,a){return l=+l,a=+a,l!=l?+a:a!=a?+l:+Sa(+l,+a)}function eu(l,a){return l=+l,a=+a,l!=l?+a:a!=a?+l:+bo(+l,+a)}function ra(l){return l=+l,l>=0?+Qi(l+.5):+qn(l-.5)}function fo(l,a,c){l=l|0,a=a|0,c=c|0;var m=0,g=0,w=0;if((c|0)>=8192)return zn(l|0,a|0,c|0)|0,l|0;if(w=l|0,g=l+c|0,(l&3)==(a&3)){for(;l&3;){if(!c)return w|0;At[l>>0]=At[a>>0]|0,l=l+1|0,a=a+1|0,c=c-1|0}for(c=g&-4|0,m=c-64|0;(l|0)<=(m|0);)o[l>>2]=o[a>>2],o[l+4>>2]=o[a+4>>2],o[l+8>>2]=o[a+8>>2],o[l+12>>2]=o[a+12>>2],o[l+16>>2]=o[a+16>>2],o[l+20>>2]=o[a+20>>2],o[l+24>>2]=o[a+24>>2],o[l+28>>2]=o[a+28>>2],o[l+32>>2]=o[a+32>>2],o[l+36>>2]=o[a+36>>2],o[l+40>>2]=o[a+40>>2],o[l+44>>2]=o[a+44>>2],o[l+48>>2]=o[a+48>>2],o[l+52>>2]=o[a+52>>2],o[l+56>>2]=o[a+56>>2],o[l+60>>2]=o[a+60>>2],l=l+64|0,a=a+64|0;for(;(l|0)<(c|0);)o[l>>2]=o[a>>2],l=l+4|0,a=a+4|0}else for(c=g-4|0;(l|0)<(c|0);)At[l>>0]=At[a>>0]|0,At[l+1>>0]=At[a+1>>0]|0,At[l+2>>0]=At[a+2>>0]|0,At[l+3>>0]=At[a+3>>0]|0,l=l+4|0,a=a+4|0;for(;(l|0)<(g|0);)At[l>>0]=At[a>>0]|0,l=l+1|0,a=a+1|0;return w|0}function bn(l,a,c){l=l|0,a=a|0,c=c|0;var m=0,g=0,w=0,P=0;if(w=l+c|0,a=a&255,(c|0)>=67){for(;l&3;)At[l>>0]=a,l=l+1|0;for(m=w&-4|0,P=a|a<<8|a<<16|a<<24,g=m-64|0;(l|0)<=(g|0);)o[l>>2]=P,o[l+4>>2]=P,o[l+8>>2]=P,o[l+12>>2]=P,o[l+16>>2]=P,o[l+20>>2]=P,o[l+24>>2]=P,o[l+28>>2]=P,o[l+32>>2]=P,o[l+36>>2]=P,o[l+40>>2]=P,o[l+44>>2]=P,o[l+48>>2]=P,o[l+52>>2]=P,o[l+56>>2]=P,o[l+60>>2]=P,l=l+64|0;for(;(l|0)<(m|0);)o[l>>2]=P,l=l+4|0}for(;(l|0)<(w|0);)At[l>>0]=a,l=l+1|0;return w-c|0}function kt(l){return l=+l,l>=0?+Qi(l+.5):+qn(l-.5)}function po(l){l=l|0;var a=0,c=0,m=0;return m=wo()|0,c=o[Ri>>2]|0,a=c+l|0,(l|0)>0&(a|0)<(c|0)|(a|0)<0?(Xi(a|0)|0,Uo(12),-1):(a|0)>(m|0)&&!(Fi(a|0)|0)?(Uo(12),-1):(o[Ri>>2]=a,c|0)}return{___divdi3:xn,___muldi3:lr,___remdi3:ul,___uremdi3:Do,_areNeighborCells:jl,_bitshift64Ashr:hl,_bitshift64Lshr:ht,_bitshift64Shl:yt,_calloc:ts,_cellAreaKm2:ya,_cellAreaM2:Oa,_cellAreaRads2:es,_cellToBoundary:fs,_cellToCenterChild:Bs,_cellToChildPos:Ra,_cellToChildren:Qs,_cellToChildrenSize:Ws,_cellToLatLng:xs,_cellToLocalIj:Hl,_cellToParent:Xa,_cellToVertex:Ur,_cellToVertexes:ta,_cellsToDirectedEdge:vl,_cellsToLinkedMultiPolygon:zs,_childPosToCell:Au,_compactCells:uo,_constructCell:Zl,_destroyLinkedMultiPolygon:gi,_directedEdgeToBoundary:vs,_directedEdgeToCells:za,_edgeLengthKm:xa,_edgeLengthM:co,_edgeLengthRads:va,_emscripten_replace_memory:tr,_free:Qt,_getBaseCellNumber:Rn,_getDirectedEdgeDestination:uu,_getDirectedEdgeOrigin:Ya,_getHexagonAreaAvgKm2:fn,_getHexagonAreaAvgM2:ql,_getHexagonEdgeLengthAvgKm:Ko,_getHexagonEdgeLengthAvgM:rl,_getIcosahedronFaces:Ys,_getIndexDigit:$o,_getNumCells:Rs,_getPentagons:Pl,_getRes0Cells:Zs,_getResolution:pa,_greatCircleDistanceKm:Xs,_greatCircleDistanceM:Xo,_greatCircleDistanceRads:il,_gridDisk:ha,_gridDiskDistances:_n,_gridDistance:Ql,_gridPathCells:ol,_gridPathCellsSize:$l,_gridRing:Cr,_gridRingUnsafe:To,_i64Add:Wt,_i64Subtract:wr,_isPentagon:$i,_isResClassIII:cu,_isValidCell:cs,_isValidDirectedEdge:Mo,_isValidIndex:wl,_isValidVertex:fu,_latLngToCell:Fn,_llvm_ctlz_i64:Jl,_llvm_maxnum_f64:Nu,_llvm_minnum_f64:eu,_llvm_round_f64:ra,_localIjToCell:Wl,_malloc:Js,_maxFaceCount:Yo,_maxGridDiskSize:Wa,_maxPolygonToCellsSize:$a,_maxPolygonToCellsSizeExperimental:ne,_memcpy:fo,_memset:bn,_originToDirectedEdges:lo,_pentagonCount:Ja,_polygonToCells:Ca,_polygonToCellsExperimental:q,_readInt64AsDoubleFromPointer:br,_res0CellCount:Ki,_round:kt,_sbrk:po,_sizeOfCellBoundary:On,_sizeOfCoordIJ:Xl,_sizeOfGeoLoop:Ks,_sizeOfGeoPolygon:al,_sizeOfH3Index:Br,_sizeOfLatLng:ps,_sizeOfLinkedGeoPolygon:Yl,_uncompactCells:Ul,_uncompactCellsSize:ma,_vertexToLatLng:Kl,establishStackSpace:Sr,stackAlloc:Go,stackRestore:_i,stackSave:Ha}})(ot,St,cr);J.___divdi3=je.___divdi3,J.___muldi3=je.___muldi3,J.___remdi3=je.___remdi3,J.___uremdi3=je.___uremdi3,J._areNeighborCells=je._areNeighborCells,J._bitshift64Ashr=je._bitshift64Ashr,J._bitshift64Lshr=je._bitshift64Lshr,J._bitshift64Shl=je._bitshift64Shl,J._calloc=je._calloc,J._cellAreaKm2=je._cellAreaKm2,J._cellAreaM2=je._cellAreaM2,J._cellAreaRads2=je._cellAreaRads2,J._cellToBoundary=je._cellToBoundary,J._cellToCenterChild=je._cellToCenterChild,J._cellToChildPos=je._cellToChildPos,J._cellToChildren=je._cellToChildren,J._cellToChildrenSize=je._cellToChildrenSize,J._cellToLatLng=je._cellToLatLng,J._cellToLocalIj=je._cellToLocalIj,J._cellToParent=je._cellToParent,J._cellToVertex=je._cellToVertex,J._cellToVertexes=je._cellToVertexes,J._cellsToDirectedEdge=je._cellsToDirectedEdge,J._cellsToLinkedMultiPolygon=je._cellsToLinkedMultiPolygon,J._childPosToCell=je._childPosToCell,J._compactCells=je._compactCells,J._constructCell=je._constructCell,J._destroyLinkedMultiPolygon=je._destroyLinkedMultiPolygon,J._directedEdgeToBoundary=je._directedEdgeToBoundary,J._directedEdgeToCells=je._directedEdgeToCells,J._edgeLengthKm=je._edgeLengthKm,J._edgeLengthM=je._edgeLengthM,J._edgeLengthRads=je._edgeLengthRads;var Xt=J._emscripten_replace_memory=je._emscripten_replace_memory;J._free=je._free,J._getBaseCellNumber=je._getBaseCellNumber,J._getDirectedEdgeDestination=je._getDirectedEdgeDestination,J._getDirectedEdgeOrigin=je._getDirectedEdgeOrigin,J._getHexagonAreaAvgKm2=je._getHexagonAreaAvgKm2,J._getHexagonAreaAvgM2=je._getHexagonAreaAvgM2,J._getHexagonEdgeLengthAvgKm=je._getHexagonEdgeLengthAvgKm,J._getHexagonEdgeLengthAvgM=je._getHexagonEdgeLengthAvgM,J._getIcosahedronFaces=je._getIcosahedronFaces,J._getIndexDigit=je._getIndexDigit,J._getNumCells=je._getNumCells,J._getPentagons=je._getPentagons,J._getRes0Cells=je._getRes0Cells,J._getResolution=je._getResolution,J._greatCircleDistanceKm=je._greatCircleDistanceKm,J._greatCircleDistanceM=je._greatCircleDistanceM,J._greatCircleDistanceRads=je._greatCircleDistanceRads,J._gridDisk=je._gridDisk,J._gridDiskDistances=je._gridDiskDistances,J._gridDistance=je._gridDistance,J._gridPathCells=je._gridPathCells,J._gridPathCellsSize=je._gridPathCellsSize,J._gridRing=je._gridRing,J._gridRingUnsafe=je._gridRingUnsafe,J._i64Add=je._i64Add,J._i64Subtract=je._i64Subtract,J._isPentagon=je._isPentagon,J._isResClassIII=je._isResClassIII,J._isValidCell=je._isValidCell,J._isValidDirectedEdge=je._isValidDirectedEdge,J._isValidIndex=je._isValidIndex,J._isValidVertex=je._isValidVertex,J._latLngToCell=je._latLngToCell,J._llvm_ctlz_i64=je._llvm_ctlz_i64,J._llvm_maxnum_f64=je._llvm_maxnum_f64,J._llvm_minnum_f64=je._llvm_minnum_f64,J._llvm_round_f64=je._llvm_round_f64,J._localIjToCell=je._localIjToCell,J._malloc=je._malloc,J._maxFaceCount=je._maxFaceCount,J._maxGridDiskSize=je._maxGridDiskSize,J._maxPolygonToCellsSize=je._maxPolygonToCellsSize,J._maxPolygonToCellsSizeExperimental=je._maxPolygonToCellsSizeExperimental,J._memcpy=je._memcpy,J._memset=je._memset,J._originToDirectedEdges=je._originToDirectedEdges,J._pentagonCount=je._pentagonCount,J._polygonToCells=je._polygonToCells,J._polygonToCellsExperimental=je._polygonToCellsExperimental,J._readInt64AsDoubleFromPointer=je._readInt64AsDoubleFromPointer,J._res0CellCount=je._res0CellCount,J._round=je._round,J._sbrk=je._sbrk,J._sizeOfCellBoundary=je._sizeOfCellBoundary,J._sizeOfCoordIJ=je._sizeOfCoordIJ,J._sizeOfGeoLoop=je._sizeOfGeoLoop,J._sizeOfGeoPolygon=je._sizeOfGeoPolygon,J._sizeOfH3Index=je._sizeOfH3Index,J._sizeOfLatLng=je._sizeOfLatLng,J._sizeOfLinkedGeoPolygon=je._sizeOfLinkedGeoPolygon,J._uncompactCells=je._uncompactCells,J._uncompactCellsSize=je._uncompactCellsSize,J._vertexToLatLng=je._vertexToLatLng,J.establishStackSpace=je.establishStackSpace;var Gi=J.stackAlloc=je.stackAlloc,Bi=J.stackRestore=je.stackRestore,qe=J.stackSave=je.stackSave;if(J.asm=je,J.cwrap=zi,J.setValue=zr,J.getValue=Mn,tn){vo(tn)||(tn=ct(tn));{jo();var Hi=function(Ve){Ve.byteLength&&(Ve=new Uint8Array(Ve)),Sn.set(Ve,un),J.memoryInitializerRequest&&delete J.memoryInitializerRequest.response,Zo()},rn=function(){W(tn,Hi,function(){throw"could not load memory initializer "+tn})},Kt=ft(tn);if(Kt)Hi(Kt.buffer);else if(J.memoryInitializerRequest){var qi=function(){var Ve=J.memoryInitializerRequest,at=Ve.response;if(Ve.status!==200&&Ve.status!==0){var It=ft(J.memoryInitializerRequestURL);if(It)at=It.buffer;else{console.warn("a problem seems to have happened with Module.memoryInitializerRequest, status: "+Ve.status+", retrying "+tn),rn();return}}Hi(at)};J.memoryInitializerRequest.response?setTimeout(qi,0):J.memoryInitializerRequest.addEventListener("load",qi)}else rn()}}var Vr;Dn=function Ve(){Vr||Wi(),Vr||(Dn=Ve)};function Wi(Ve){if(Ui>0||(hn(),Ui>0))return;function at(){Vr||(Vr=!0,!Gt&&(Er(),yo(),J.onRuntimeInitialized&&J.onRuntimeInitialized(),us()))}J.setStatus?(J.setStatus("Running..."),setTimeout(function(){setTimeout(function(){J.setStatus("")},1),at()},1)):at()}J.run=Wi;function er(Ve){throw J.onAbort&&J.onAbort(Ve),Ve+="",p(Ve),it(Ve),Gt=!0,"abort("+Ve+"). Build with -s ASSERTIONS=1 for more info."}if(J.abort=er,J.preInit)for(typeof J.preInit=="function"&&(J.preInit=[J.preInit]);J.preInit.length>0;)J.preInit.pop()();return Wi(),xe})(typeof et=="object"?et:{}),ci="number",ui=ci,ch=ci,yi=ci,vi=ci,Es=ci,jt=ci,$m=[["sizeOfH3Index",ci],["sizeOfLatLng",ci],["sizeOfCellBoundary",ci],["sizeOfGeoLoop",ci],["sizeOfGeoPolygon",ci],["sizeOfLinkedGeoPolygon",ci],["sizeOfCoordIJ",ci],["readInt64AsDoubleFromPointer",ci],["isValidCell",ch,[yi,vi]],["isValidIndex",ch,[yi,vi]],["latLngToCell",ui,[ci,ci,Es,jt]],["cellToLatLng",ui,[yi,vi,jt]],["cellToBoundary",ui,[yi,vi,jt]],["maxGridDiskSize",ui,[ci,jt]],["gridDisk",ui,[yi,vi,ci,jt]],["gridDiskDistances",ui,[yi,vi,ci,jt,jt]],["gridRing",ui,[yi,vi,ci,jt]],["gridRingUnsafe",ui,[yi,vi,ci,jt]],["maxPolygonToCellsSize",ui,[jt,Es,ci,jt]],["polygonToCells",ui,[jt,Es,ci,jt]],["maxPolygonToCellsSizeExperimental",ui,[jt,Es,ci,jt]],["polygonToCellsExperimental",ui,[jt,Es,ci,ci,ci,jt]],["cellsToLinkedMultiPolygon",ui,[jt,ci,jt]],["destroyLinkedMultiPolygon",null,[jt]],["compactCells",ui,[jt,jt,ci,ci]],["uncompactCells",ui,[jt,ci,ci,jt,ci,Es]],["uncompactCellsSize",ui,[jt,ci,ci,Es,jt]],["isPentagon",ch,[yi,vi]],["isResClassIII",ch,[yi,vi]],["getBaseCellNumber",ci,[yi,vi]],["getResolution",ci,[yi,vi]],["getIndexDigit",ci,[yi,vi,ci]],["constructCell",ui,[ci,ci,jt,jt]],["maxFaceCount",ui,[yi,vi,jt]],["getIcosahedronFaces",ui,[yi,vi,jt]],["cellToParent",ui,[yi,vi,Es,jt]],["cellToChildren",ui,[yi,vi,Es,jt]],["cellToCenterChild",ui,[yi,vi,Es,jt]],["cellToChildrenSize",ui,[yi,vi,Es,jt]],["cellToChildPos",ui,[yi,vi,Es,jt]],["childPosToCell",ui,[ci,ci,yi,vi,Es,jt]],["areNeighborCells",ui,[yi,vi,yi,vi,jt]],["cellsToDirectedEdge",ui,[yi,vi,yi,vi,jt]],["getDirectedEdgeOrigin",ui,[yi,vi,jt]],["getDirectedEdgeDestination",ui,[yi,vi,jt]],["isValidDirectedEdge",ch,[yi,vi]],["directedEdgeToCells",ui,[yi,vi,jt]],["originToDirectedEdges",ui,[yi,vi,jt]],["directedEdgeToBoundary",ui,[yi,vi,jt]],["gridDistance",ui,[yi,vi,yi,vi,jt]],["gridPathCells",ui,[yi,vi,yi,vi,jt]],["gridPathCellsSize",ui,[yi,vi,yi,vi,jt]],["cellToLocalIj",ui,[yi,vi,yi,vi,ci,jt]],["localIjToCell",ui,[yi,vi,jt,ci,jt]],["getHexagonAreaAvgM2",ui,[Es,jt]],["getHexagonAreaAvgKm2",ui,[Es,jt]],["getHexagonEdgeLengthAvgM",ui,[Es,jt]],["getHexagonEdgeLengthAvgKm",ui,[Es,jt]],["greatCircleDistanceM",ci,[jt,jt]],["greatCircleDistanceKm",ci,[jt,jt]],["greatCircleDistanceRads",ci,[jt,jt]],["cellAreaM2",ui,[yi,vi,jt]],["cellAreaKm2",ui,[yi,vi,jt]],["cellAreaRads2",ui,[yi,vi,jt]],["edgeLengthM",ui,[yi,vi,jt]],["edgeLengthKm",ui,[yi,vi,jt]],["edgeLengthRads",ui,[yi,vi,jt]],["getNumCells",ui,[Es,jt]],["getRes0Cells",ui,[jt]],["res0CellCount",ci],["getPentagons",ui,[ci,jt]],["pentagonCount",ci],["cellToVertex",ui,[yi,vi,ci,jt]],["cellToVertexes",ui,[yi,vi,jt]],["vertexToLatLng",ui,[yi,vi,jt]],["isValidVertex",ch,[yi,vi]]],Ym=0,Xm=1,Km=2,Jm=3,tp=4,ip=5,e_=6,t_=7,i_=8,r_=9,n_=10,s_=11,o_=12,a_=13,l_=14,rp=15,u_=16,h_=17,DA=18,c_=19,Zn={};Zn[Ym]="Success";Zn[Xm]="The operation failed but a more specific error is not available";Zn[Km]="Argument was outside of acceptable range";Zn[Jm]="Latitude or longitude arguments were outside of acceptable range";Zn[tp]="Resolution argument was outside of acceptable range";Zn[ip]="Cell argument was not valid";Zn[e_]="Directed edge argument was not valid";Zn[t_]="Undirected edge argument was not valid";Zn[i_]="Vertex argument was not valid";Zn[r_]="Pentagon distortion was encountered";Zn[n_]="Duplicate input";Zn[s_]="Cell arguments were not neighbors";Zn[o_]="Cell arguments had incompatible resolutions";Zn[a_]="Memory allocation failed";Zn[l_]="Bounds of provided memory were insufficient";Zn[rp]="Mode or flags argument was not valid";Zn[u_]="Index argument was not valid";Zn[h_]="Base cell number was outside of acceptable range";Zn[DA]="Child indexing digits invalid";Zn[c_]="Child indexing digits refer to a deleted subsequence";var fh=1e3,np=1001,sp=1002,Mc={};Mc[fh]="Unknown unit";Mc[np]="Array length out of bounds";Mc[sp]="Got unexpected null value for H3 index";var A_="Unknown error";function op(xe,J,fe){var Re=fe&&"value"in fe,We=new Error((xe[J]||A_)+" (code: "+J+(Re?", value: "+fe.value:"")+")");return We.code=J,We}function Hh(xe,J){var fe=arguments.length===2?{value:J}:{};return op(Zn,xe,fe)}function lu(xe,J){var fe=arguments.length===2?{value:J}:{};return op(Mc,xe,fe)}function si(xe){if(xe!==0)throw Hh(xe)}var Bt={};$m.forEach(function(J){Bt[J[0]]=et.cwrap.apply(et,J)});var Ah=16,Gh=0,Ss=4,Wd=4,ua=8,ml=8,yr=Bt.sizeOfH3Index(),Wh=Bt.sizeOfLatLng(),ap=Bt.sizeOfCellBoundary(),f_=Bt.sizeOfGeoPolygon(),qh=Bt.sizeOfGeoLoop(),d_=Bt.sizeOfLinkedGeoPolygon(),lp=Bt.sizeOfCoordIJ(),Bo={m:"m",m2:"m2",km:"km",km2:"km2",rads:"rads",rads2:"rads2"},Uh={containmentCenter:"containmentCenter",containmentFull:"containmentFull",containmentOverlapping:"containmentOverlapping",containmentOverlappingBbox:"containmentOverlappingBbox"};function p_(xe){switch(xe){case Uh.containmentCenter:return 0;case Uh.containmentFull:return 1;case Uh.containmentOverlapping:return 2;case Uh.containmentOverlappingBbox:return 3;default:throw lu(rp,xe)}}function Bu(xe){if(typeof xe!="number"||xe<0||xe>15||Math.floor(xe)!==xe)throw Hh(tp,xe);return xe}function _l(xe){if(!xe)throw lu(sp);return xe}var m_=Math.pow(2,32)-1;function Ru(xe){if(xe>m_)throw lu(np,xe);return xe}var __=/[^0-9a-fA-F]/;function Ei(xe){if(Array.isArray(xe)&&xe.length===2&&Number.isInteger(xe[0])&&Number.isInteger(xe[1]))return xe;if(typeof xe!="string"||__.test(xe))return[0,0];var J=parseInt(xe.substring(0,xe.length-8),Ah),fe=parseInt(xe.substring(xe.length-8),Ah);return[fe,J]}function Qd(xe){if(xe>=0)return xe.toString(Ah);xe=xe&2147483647;var J=hp(8,xe.toString(Ah)),fe=(parseInt(J[0],Ah)+8).toString(Ah);return J=fe+J.substring(1),J}function up(xe,J){return Qd(J)+hp(8,Qd(xe))}function hp(xe,J){for(var fe=xe-J.length,Re="",We=0;We<fe;We++)Re+="0";return Re=Re+J,Re}var g_=Math.pow(2,32);function y_(xe){return typeof xe!="number"?[0,0]:[xe|0,xe/g_|0]}function $d(xe,J,fe){for(var Re=xe.length,We=et._calloc(Re,Wh),ct=fe?1:0,W=fe?0:1,p=0;p<Re*2;p+=2)et.HEAPF64.set([xe[p/2][ct],xe[p/2][W]].map(Cc),We/ua+p);return et.HEAPU32.set([Re,We],J/Ss),J}function cp(xe,J){var fe=xe.length-1,Re=et._calloc(f_),We=0,ct=We+qh,W=ct+Ss;$d(xe[0],Re+We,J);var p;if(fe>0){p=et._calloc(fe,qh);for(var it=0;it<fe;it++)$d(xe[it+1],p+qh*it,J)}return et.setValue(Re+ct,fe,"i32"),et.setValue(Re+W,p,"i32"),Re}function Ap(xe){var J=0,fe=J+qh,Re=fe+Ss,We=Ss;et._free(et.getValue(xe+J+We,"i8*"));var ct=et.getValue(xe+fe,"i32");if(ct>0){for(var W=et.getValue(xe+Re,"i32"),p=0;p<ct;p++)et._free(et.getValue(W+qh*p+We,"i8*"));et._free(W)}et._free(xe)}function Ma(xe,J){J===void 0&&(J=0);var fe=et.getValue(xe+yr*J,"i32"),Re=et.getValue(xe+yr*J+Ss,"i32");return Re?up(fe,Re):null}function v_(xe,J){J===void 0&&(J=0);var fe=et.getValue(xe+Ss*J,"i32");return!!fe}function Ec(xe,J){return J===void 0&&(J=0),et.getValue(xe+ua*J,"double")}function gl(xe){return Bt.readInt64AsDoubleFromPointer(xe)}function x_(xe,J,fe){et.HEAPU32.set(Ei(xe),J/Ss+2*fe)}function Ro(xe,J){for(var fe=[],Re=0;Re<J;Re++){var We=Ma(xe,Re);We!==null&&fe.push(We)}return fe}function kA(xe,J){for(var fe=J.length,Re=0;Re<fe;Re++)x_(J[Re],xe,Re)}function Yd(xe,J){var fe=et._calloc(1,Wh);return et.HEAPF64.set([xe,J].map(Cc),fe/ua),fe}function Pc(xe){return _p(et.getValue(xe,"double"))}function Sc(xe){return[Pc(xe),Pc(xe+ua)]}function fp(xe){return[Pc(xe+ua),Pc(xe)]}function dp(xe,J,fe){for(var Re=et.getValue(xe,"i32"),We=xe+ua,ct=[],W=J?fp:Sc,p=0;p<Re*2;p+=2)ct.push(W(We+ua*p));return fe&&ct.push(ct[0]),ct}function b_(xe,J){for(var fe=[],Re=J?fp:Sc,We,ct,W,p;xe;){for(fe.push(We=[]),ct=et.getValue(xe,"i8*");ct;){for(We.push(W=[]),p=et.getValue(ct,"i8*");p;)W.push(Re(p)),p=et.getValue(p+ua*2,"i8*");J&&W.push(W[0]),ct=et.getValue(ct+Wd*2,"i8*")}xe=et.getValue(xe+Wd*2,"i8*")}return fe}function w_(xe){return{i:et.getValue(xe,"i32"),j:et.getValue(xe+Ss,"i32")}}function T_(xe,J){var fe=J.i,Re=J.j;et.setValue(xe,fe,"i32"),et.setValue(xe+Ss,Re,"i32")}function P_(xe,J){for(var fe=[],Re=0;Re<J;Re++){var We=et.getValue(xe+Ss*Re,"i32");We>=0&&fe.push(We)}return fe}function zA(xe){var J=Ei(xe),fe=J[0],Re=J[1];return!!Bt.isValidCell(fe,Re)}function M_(xe){var J=Ei(xe),fe=J[0],Re=J[1];return!!Bt.isValidIndex(fe,Re)}function E_(xe){var J=Ei(xe),fe=J[0],Re=J[1];return!!Bt.isPentagon(fe,Re)}function S_(xe){var J=Ei(xe),fe=J[0],Re=J[1];return!!Bt.isResClassIII(fe,Re)}function C_(xe){var J=Ei(xe),fe=J[0],Re=J[1];return Bt.getBaseCellNumber(fe,Re)}function I_(xe,J){var fe=et._malloc(Ss),Re=Ei(xe),We=Re[0],ct=Re[1];try{return si(Bt.getIndexDigit(We,ct,J,fe)),et.getValue(fe,"i32")}finally{et._free(fe)}}function D_(xe){var J=Ei(xe),fe=J[0],Re=J[1],We=et._malloc(Ss);try{si(Bt.maxFaceCount(fe,Re,We));var ct=et.getValue(We,"i32"),W=et._malloc(Ss*ct);try{return si(Bt.getIcosahedronFaces(fe,Re,W)),P_(W,ct)}finally{et._free(W)}}finally{et._free(We)}}function k_(xe){var J=Ei(xe),fe=J[0],Re=J[1];return Bt.isValidCell(fe,Re)?Bt.getResolution(fe,Re):-1}function z_(xe,J,fe){if(fe===void 0&&(fe=J.length),J.length!==fe||J.length>15)throw Hh(DA,J.length);var Re=et._malloc(Ss*J.length),We=et._malloc(yr);try{return J.forEach(function(ct,W){et.setValue(Re+Ss*W,ct,"i32")}),si(Bt.constructCell(fe,xe,Re,We)),_l(Ma(We))}finally{et._free(We),et._free(Re)}}function L_(xe,J,fe){var Re=et._malloc(Wh);et.HEAPF64.set([xe,J].map(Cc),Re/ua);var We=et._malloc(yr);try{return si(Bt.latLngToCell(Re,fe,We)),_l(Ma(We))}finally{et._free(We),et._free(Re)}}function B_(xe){var J=et._malloc(Wh),fe=Ei(xe),Re=fe[0],We=fe[1];try{return si(Bt.cellToLatLng(Re,We,J)),Sc(J)}finally{et._free(J)}}function R_(xe,J){var fe=et._malloc(ap),Re=Ei(xe),We=Re[0],ct=Re[1];try{return si(Bt.cellToBoundary(We,ct,fe)),dp(fe,J,J)}finally{et._free(fe)}}function F_(xe,J){var fe=Ei(xe),Re=fe[0],We=fe[1],ct=et._malloc(yr);try{return si(Bt.cellToParent(Re,We,J,ct)),_l(Ma(ct))}finally{et._free(ct)}}function O_(xe,J){if(!zA(xe))return[];var fe=Ei(xe),Re=fe[0],We=fe[1],ct=Ru(pp(xe,J)),W=et._calloc(ct,yr);try{return si(Bt.cellToChildren(Re,We,J,W)),Ro(W,ct)}finally{et._free(W)}}function pp(xe,J){if(!zA(xe))throw Hh(ip);var fe=Ei(xe),Re=fe[0],We=fe[1],ct=et._malloc(ml);try{return si(Bt.cellToChildrenSize(Re,We,J,ct)),gl(ct)}finally{et._free(ct)}}function N_(xe,J){var fe=Ei(xe),Re=fe[0],We=fe[1],ct=et._malloc(yr);try{return si(Bt.cellToCenterChild(Re,We,J,ct)),_l(Ma(ct))}finally{et._free(ct)}}function V_(xe,J){var fe=Ei(xe),Re=fe[0],We=fe[1],ct=et._malloc(ml);try{return si(Bt.cellToChildPos(Re,We,J,ct)),gl(ct)}finally{et._free(ct)}}function j_(xe,J,fe){var Re=y_(xe),We=Re[0],ct=Re[1],W=Ei(J),p=W[0],it=W[1],ur=et._malloc(yr);try{return si(Bt.childPosToCell(We,ct,p,it,fe,ur)),_l(Ma(ur))}finally{et._free(ur)}}function Z_(xe,J){var fe=Ei(xe),Re=fe[0],We=fe[1],ct=et._malloc(ml);try{si(Bt.maxGridDiskSize(J,ct));var W=Ru(gl(ct)),p=et._calloc(W,yr);try{return si(Bt.gridDisk(Re,We,J,p)),Ro(p,W)}finally{et._free(p)}}finally{et._free(ct)}}function U_(xe,J){var fe=Ei(xe),Re=fe[0],We=fe[1],ct=et._malloc(ml);try{si(Bt.maxGridDiskSize(J,ct));var W=Ru(gl(ct)),p=et._calloc(W,yr),it=et._calloc(W,Ss);try{si(Bt.gridDiskDistances(Re,We,J,p,it));for(var ur=[],fr=0;fr<J+1;fr++)ur.push([]);for(var Zi=0;Zi<W;Zi++){var un=Ma(p,Zi),zr=et.getValue(it+Ss*Zi,"i32");un!==null&&ur[zr].push(un)}return ur}finally{et._free(p),et._free(it)}}finally{et._free(ct)}}function G_(xe,J){var fe=J===0?1:6*J,Re=et._calloc(fe,yr);try{return si(Bt.gridRing.apply(Bt,Ei(xe).concat([J],[Re]))),Ro(Re,fe)}finally{et._free(Re)}}function q_(xe,J){var fe=J===0?1:6*J,Re=et._calloc(fe,yr);try{return si(Bt.gridRingUnsafe.apply(Bt,Ei(xe).concat([J],[Re]))),Ro(Re,fe)}finally{et._free(Re)}}function H_(xe,J,fe){if(Bu(J),fe=!!fe,xe.length===0||xe[0].length===0)return[];var Re=typeof xe[0][0]=="number"?[xe]:xe,We=cp(Re,fe),ct=et._malloc(ml);try{si(Bt.maxPolygonToCellsSize(We,J,0,ct));var W=Ru(gl(ct)),p=et._calloc(W,yr);try{return si(Bt.polygonToCells(We,J,0,p)),Ro(p,W)}finally{et._free(p)}}finally{et._free(ct),Ap(We)}}function W_(xe,J,fe,Re){Bu(J),Re=!!Re;var We=p_(fe);if(xe.length===0||xe[0].length===0)return[];var ct=typeof xe[0][0]=="number"?[xe]:xe,W=cp(ct,Re),p=et._malloc(ml);try{si(Bt.maxPolygonToCellsSizeExperimental(W,J,We,p));var it=Ru(gl(p)),ur=et._calloc(it,yr);try{return si(Bt.polygonToCellsExperimental(W,J,We,it,Gh,ur)),Ro(ur,it)}finally{et._free(ur)}}finally{et._free(p),Ap(W)}}function Q_(xe,J){if(!xe||!xe.length)return[];var fe=xe.length,Re=et._calloc(fe,yr);kA(Re,xe);var We=et._calloc(d_);try{return si(Bt.cellsToLinkedMultiPolygon(Re,fe,We)),b_(We,J)}finally{Bt.destroyLinkedMultiPolygon(We),et._free(We),et._free(Re)}}function $_(xe){if(!xe||!xe.length)return[];var J=xe.length,fe=et._calloc(J,yr);kA(fe,xe);var Re=et._calloc(J,yr);try{return si(Bt.compactCells(fe,Re,J,Gh)),Ro(Re,J)}finally{et._free(fe),et._free(Re)}}function Y_(xe,J){if(Bu(J),!xe||!xe.length)return[];var fe=xe.length,Re=et._calloc(fe,yr);kA(Re,xe);var We=et._malloc(ml);try{si(Bt.uncompactCellsSize(Re,fe,Gh,J,We));var ct=Ru(gl(We)),W=et._calloc(ct,yr);try{return si(Bt.uncompactCells(Re,fe,Gh,W,ct,Gh,J)),Ro(W,ct)}finally{et._free(Re),et._free(W)}}finally{et._free(We)}}function X_(xe,J){var fe=Ei(xe),Re=fe[0],We=fe[1],ct=Ei(J),W=ct[0],p=ct[1],it=et._malloc(Ss);try{return si(Bt.areNeighborCells(Re,We,W,p,it)),v_(it)}finally{et._free(it)}}function K_(xe,J){var fe=Ei(xe),Re=fe[0],We=fe[1],ct=Ei(J),W=ct[0],p=ct[1],it=et._malloc(yr);try{return si(Bt.cellsToDirectedEdge(Re,We,W,p,it)),_l(Ma(it))}finally{et._free(it)}}function J_(xe){var J=Ei(xe),fe=J[0],Re=J[1],We=et._malloc(yr);try{return si(Bt.getDirectedEdgeOrigin(fe,Re,We)),_l(Ma(We))}finally{et._free(We)}}function eg(xe){var J=Ei(xe),fe=J[0],Re=J[1],We=et._malloc(yr);try{return si(Bt.getDirectedEdgeDestination(fe,Re,We)),_l(Ma(We))}finally{et._free(We)}}function tg(xe){var J=Ei(xe),fe=J[0],Re=J[1];return!!Bt.isValidDirectedEdge(fe,Re)}function ig(xe){var J=Ei(xe),fe=J[0],Re=J[1],We=2,ct=et._calloc(We,yr);try{return si(Bt.directedEdgeToCells(fe,Re,ct)),Ro(ct,We)}finally{et._free(ct)}}function rg(xe){var J=Ei(xe),fe=J[0],Re=J[1],We=6,ct=et._calloc(We,yr);try{return si(Bt.originToDirectedEdges(fe,Re,ct)),Ro(ct,We)}finally{et._free(ct)}}function ng(xe,J){var fe=et._malloc(ap),Re=Ei(xe),We=Re[0],ct=Re[1];try{return si(Bt.directedEdgeToBoundary(We,ct,fe)),dp(fe,J)}finally{et._free(fe)}}function sg(xe,J){var fe=Ei(xe),Re=fe[0],We=fe[1],ct=Ei(J),W=ct[0],p=ct[1],it=et._malloc(ml);try{return si(Bt.gridDistance(Re,We,W,p,it)),gl(it)}finally{et._free(it)}}function og(xe,J){var fe=Ei(xe),Re=fe[0],We=fe[1],ct=Ei(J),W=ct[0],p=ct[1],it=et._malloc(ml);try{si(Bt.gridPathCellsSize(Re,We,W,p,it));var ur=Ru(gl(it)),fr=et._calloc(ur,yr);try{return Bt.gridPathCells(Re,We,W,p,fr),Ro(fr,ur)}finally{et._free(fr)}}finally{et._free(it)}}var mp=0;function ag(xe,J){var fe=et._malloc(lp);try{return si(Bt.cellToLocalIj.apply(Bt,Ei(xe).concat(Ei(J),[mp],[fe]))),w_(fe)}finally{et._free(fe)}}function lg(xe,J){if(!J||typeof J.i!="number"||typeof J.j!="number")throw new Error("Coordinates must be provided as an {i, j} object");var fe=et._malloc(lp),Re=et._malloc(yr);T_(fe,J);try{return si(Bt.localIjToCell.apply(Bt,Ei(xe).concat([fe],[mp],[Re]))),_l(Ma(Re))}finally{et._free(fe),et._free(Re)}}function ug(xe,J,fe){var Re=Yd(xe[0],xe[1]),We=Yd(J[0],J[1]),ct;switch(fe){case Bo.m:ct=Bt.greatCircleDistanceM(Re,We);break;case Bo.km:ct=Bt.greatCircleDistanceKm(Re,We);break;case Bo.rads:ct=Bt.greatCircleDistanceRads(Re,We);break;default:ct=null}if(et._free(Re),et._free(We),ct===null)throw lu(fh,fe);return ct}function hg(xe,J){var fe=Ei(xe),Re=fe[0],We=fe[1],ct=et._malloc(ua);try{switch(J){case Bo.m2:si(Bt.cellAreaM2(Re,We,ct));break;case Bo.km2:si(Bt.cellAreaKm2(Re,We,ct));break;case Bo.rads2:si(Bt.cellAreaRads2(Re,We,ct));break;default:throw lu(fh,J)}return Ec(ct)}finally{et._free(ct)}}function cg(xe,J){var fe=Ei(xe),Re=fe[0],We=fe[1],ct=et._malloc(ua);try{switch(J){case Bo.m:si(Bt.edgeLengthM(Re,We,ct));break;case Bo.km:si(Bt.edgeLengthKm(Re,We,ct));break;case Bo.rads:si(Bt.edgeLengthRads(Re,We,ct));break;default:throw lu(fh,J)}return Ec(ct)}finally{et._free(ct)}}function Ag(xe,J){Bu(xe);var fe=et._malloc(ua);try{switch(J){case Bo.m2:si(Bt.getHexagonAreaAvgM2(xe,fe));break;case Bo.km2:si(Bt.getHexagonAreaAvgKm2(xe,fe));break;default:throw lu(fh,J)}return Ec(fe)}finally{et._free(fe)}}function fg(xe,J){Bu(xe);var fe=et._malloc(ua);try{switch(J){case Bo.m:si(Bt.getHexagonEdgeLengthAvgM(xe,fe));break;case Bo.km:si(Bt.getHexagonEdgeLengthAvgKm(xe,fe));break;default:throw lu(fh,J)}return Ec(fe)}finally{et._free(fe)}}function dg(xe,J){var fe=Ei(xe),Re=fe[0],We=fe[1],ct=et._malloc(yr);try{return si(Bt.cellToVertex(Re,We,J,ct)),_l(Ma(ct))}finally{et._free(ct)}}function pg(xe){var J=Ei(xe),fe=J[0],Re=J[1],We=6,ct=et._calloc(We,yr);try{return si(Bt.cellToVertexes(fe,Re,ct)),Ro(ct,We)}finally{et._free(ct)}}function mg(xe){var J=et._malloc(Wh),fe=Ei(xe),Re=fe[0],We=fe[1];try{return si(Bt.vertexToLatLng(Re,We,J)),Sc(J)}finally{et._free(J)}}function _g(xe){var J=Ei(xe),fe=J[0],Re=J[1];return!!Bt.isValidVertex(fe,Re)}function gg(xe){Bu(xe);var J=et._malloc(ml);try{return si(Bt.getNumCells(xe,J)),gl(J)}finally{et._free(J)}}function yg(){var xe=Bt.res0CellCount(),J=et._malloc(yr*xe);try{return si(Bt.getRes0Cells(J)),Ro(J,xe)}finally{et._free(J)}}function vg(xe){Bu(xe);var J=Bt.pentagonCount(),fe=et._malloc(yr*J);try{return si(Bt.getPentagons(xe,fe)),Ro(fe,J)}finally{et._free(fe)}}function Cc(xe){return xe*Math.PI/180}function _p(xe){return xe*180/Math.PI}const Mg=Object.freeze(Object.defineProperty({__proto__:null,POLYGON_TO_CELLS_FLAGS:Uh,UNITS:Bo,areNeighborCells:X_,cellArea:hg,cellToBoundary:R_,cellToCenterChild:N_,cellToChildPos:V_,cellToChildren:O_,cellToChildrenSize:pp,cellToLatLng:B_,cellToLocalIj:ag,cellToParent:F_,cellToVertex:dg,cellToVertexes:pg,cellsToDirectedEdge:K_,cellsToMultiPolygon:Q_,childPosToCell:j_,compactCells:$_,constructCell:z_,degsToRads:Cc,directedEdgeToBoundary:ng,directedEdgeToCells:ig,edgeLength:cg,getBaseCellNumber:C_,getDirectedEdgeDestination:eg,getDirectedEdgeOrigin:J_,getHexagonAreaAvg:Ag,getHexagonEdgeLengthAvg:fg,getIcosahedronFaces:D_,getIndexDigit:I_,getNumCells:gg,getPentagons:vg,getRes0Cells:yg,getResolution:k_,greatCircleDistance:ug,gridDisk:Z_,gridDiskDistances:U_,gridDistance:sg,gridPathCells:og,gridRing:G_,gridRingUnsafe:q_,h3IndexToSplitLong:Ei,isPentagon:E_,isResClassIII:S_,isValidCell:zA,isValidDirectedEdge:tg,isValidIndex:M_,isValidVertex:_g,latLngToCell:L_,localIjToCell:lg,originToDirectedEdges:rg,polygonToCells:H_,polygonToCellsExperimental:W_,radsToDegs:_p,splitLongToH3Index:up,uncompactCells:Y_,vertexToLatLng:mg},Symbol.toStringTag,{value:"Module"})),Eg=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));var Tc={exports:{}};/** 5 - * MapLibre GL JS 6 - * @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v5.16.0/LICENSE.txt 7 - */var xg=Tc.exports,Xd;function bg(){return Xd||(Xd=1,(function(xe,J){(function(fe,Re){xe.exports=Re()})(xg,(function(){var fe={},Re={};function We(W,p,it){if(Re[W]=it,W==="index"){var ur="var sharedModule = {}; ("+Re.shared+")(sharedModule); ("+Re.worker+")(sharedModule);",fr={};return Re.shared(fr),Re.index(fe,fr),typeof window<"u"&&fe.setWorkerUrl(window.URL.createObjectURL(new Blob([ur],{type:"text/javascript"}))),fe}}We("shared",["exports"],(function(W){function p(r,e,i,s){return new(i||(i=Promise))((function(A,d){function _(I){try{M(s.next(I))}catch(k){d(k)}}function b(I){try{M(s.throw(I))}catch(k){d(k)}}function M(I){var k;I.done?A(I.value):(k=I.value,k instanceof i?k:new i((function(F){F(k)}))).then(_,b)}M((s=s.apply(r,e||[])).next())}))}function it(r,e){this.x=r,this.y=e}function ur(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var fr,Zi;typeof SuppressedError=="function"&&SuppressedError,it.prototype={clone(){return new it(this.x,this.y)},add(r){return this.clone()._add(r)},sub(r){return this.clone()._sub(r)},multByPoint(r){return this.clone()._multByPoint(r)},divByPoint(r){return this.clone()._divByPoint(r)},mult(r){return this.clone()._mult(r)},div(r){return this.clone()._div(r)},rotate(r){return this.clone()._rotate(r)},rotateAround(r,e){return this.clone()._rotateAround(r,e)},matMult(r){return this.clone()._matMult(r)},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(r){return this.x===r.x&&this.y===r.y},dist(r){return Math.sqrt(this.distSqr(r))},distSqr(r){const e=r.x-this.x,i=r.y-this.y;return e*e+i*i},angle(){return Math.atan2(this.y,this.x)},angleTo(r){return Math.atan2(this.y-r.y,this.x-r.x)},angleWith(r){return this.angleWithSep(r.x,r.y)},angleWithSep(r,e){return Math.atan2(this.x*e-this.y*r,this.x*r+this.y*e)},_matMult(r){const e=r[2]*this.x+r[3]*this.y;return this.x=r[0]*this.x+r[1]*this.y,this.y=e,this},_add(r){return this.x+=r.x,this.y+=r.y,this},_sub(r){return this.x-=r.x,this.y-=r.y,this},_mult(r){return this.x*=r,this.y*=r,this},_div(r){return this.x/=r,this.y/=r,this},_multByPoint(r){return this.x*=r.x,this.y*=r.y,this},_divByPoint(r){return this.x/=r.x,this.y/=r.y,this},_unit(){return this._div(this.mag()),this},_perp(){const r=this.y;return this.y=this.x,this.x=-r,this},_rotate(r){const e=Math.cos(r),i=Math.sin(r),s=i*this.x+e*this.y;return this.x=e*this.x-i*this.y,this.y=s,this},_rotateAround(r,e){const i=Math.cos(r),s=Math.sin(r),A=e.y+s*(this.x-e.x)+i*(this.y-e.y);return this.x=e.x+i*(this.x-e.x)-s*(this.y-e.y),this.y=A,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:it},it.convert=function(r){if(r instanceof it)return r;if(Array.isArray(r))return new it(+r[0],+r[1]);if(r.x!==void 0&&r.y!==void 0)return new it(+r.x,+r.y);throw new Error("Expected [x, y] or {x, y} point format")};var un=(function(){if(Zi)return fr;function r(e,i,s,A){this.cx=3*e,this.bx=3*(s-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*i,this.by=3*(A-i)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=i,this.p2x=s,this.p2y=A}return Zi=1,fr=r,r.prototype={sampleCurveX:function(e){return((this.ax*e+this.bx)*e+this.cx)*e},sampleCurveY:function(e){return((this.ay*e+this.by)*e+this.cy)*e},sampleCurveDerivativeX:function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},solveCurveX:function(e,i){if(i===void 0&&(i=1e-6),e<0)return 0;if(e>1)return 1;for(var s=e,A=0;A<8;A++){var d=this.sampleCurveX(s)-e;if(Math.abs(d)<i)return s;var _=this.sampleCurveDerivativeX(s);if(Math.abs(_)<1e-6)break;s-=d/_}var b=0,M=1;for(s=e,A=0;A<20&&(d=this.sampleCurveX(s),!(Math.abs(d-e)<i));A++)e>d?b=s:M=s,s=.5*(M-b)+b;return s},solve:function(e,i){return this.sampleCurveY(this.solveCurveX(e,i))}},fr})(),zr=ur(un);let Mn,Gt;function rt(){return Mn==null&&(Mn=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")&&typeof createImageBitmap=="function"),Mn}function Fo(){if(Gt==null&&(Gt=!1,rt())){const e=new OffscreenCanvas(5,5).getContext("2d",{willReadFrequently:!0});if(e){for(let s=0;s<25;s++){const A=4*s;e.fillStyle=`rgb(${A},${A+1},${A+2})`,e.fillRect(s%5,Math.floor(s/5),1,1)}const i=e.getImageData(0,0,5,5).data;for(let s=0;s<100;s++)if(s%4!=3&&i[s]!==s){Gt=!0;break}}}return Gt||!1}var hr=1e-6,zi=typeof Float32Array<"u"?Float32Array:Array;function ro(){var r=new zi(9);return zi!=Float32Array&&(r[1]=0,r[2]=0,r[3]=0,r[5]=0,r[6]=0,r[7]=0),r[0]=1,r[4]=1,r[8]=1,r}function no(r){return r[0]=1,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=1,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=1,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r}function Ns(){var r=new zi(3);return zi!=Float32Array&&(r[0]=0,r[1]=0,r[2]=0),r}function En(r){var e=r[0],i=r[1],s=r[2];return Math.sqrt(e*e+i*i+s*s)}function Oo(r,e,i){var s=new zi(3);return s[0]=r,s[1]=e,s[2]=i,s}function Vs(r,e,i){return r[0]=e[0]+i[0],r[1]=e[1]+i[1],r[2]=e[2]+i[2],r}function Cs(r,e,i){return r[0]=e[0]*i,r[1]=e[1]*i,r[2]=e[2]*i,r}function cr(r,e,i){var s=e[0],A=e[1],d=e[2],_=i[0],b=i[1],M=i[2];return r[0]=A*M-d*b,r[1]=d*_-s*M,r[2]=s*b-A*_,r}var Ji,Sn=En;function Cn(r,e,i){var s=e[0],A=e[1],d=e[2],_=e[3];return r[0]=i[0]*s+i[4]*A+i[8]*d+i[12]*_,r[1]=i[1]*s+i[5]*A+i[9]*d+i[13]*_,r[2]=i[2]*s+i[6]*A+i[10]*d+i[14]*_,r[3]=i[3]*s+i[7]*A+i[11]*d+i[15]*_,r}function Un(){var r=new zi(4);return zi!=Float32Array&&(r[0]=0,r[1]=0,r[2]=0),r[3]=1,r}function Jr(r,e,i,s){var A=arguments.length>4&&arguments[4]!==void 0?arguments[4]:"zyx",d=Math.PI/360;e*=d,s*=d,i*=d;var _=Math.sin(e),b=Math.cos(e),M=Math.sin(i),I=Math.cos(i),k=Math.sin(s),F=Math.cos(s);switch(A){case"xyz":r[0]=_*I*F+b*M*k,r[1]=b*M*F-_*I*k,r[2]=b*I*k+_*M*F,r[3]=b*I*F-_*M*k;break;case"xzy":r[0]=_*I*F-b*M*k,r[1]=b*M*F-_*I*k,r[2]=b*I*k+_*M*F,r[3]=b*I*F+_*M*k;break;case"yxz":r[0]=_*I*F+b*M*k,r[1]=b*M*F-_*I*k,r[2]=b*I*k-_*M*F,r[3]=b*I*F+_*M*k;break;case"yzx":r[0]=_*I*F+b*M*k,r[1]=b*M*F+_*I*k,r[2]=b*I*k-_*M*F,r[3]=b*I*F-_*M*k;break;case"zxy":r[0]=_*I*F-b*M*k,r[1]=b*M*F+_*I*k,r[2]=b*I*k+_*M*F,r[3]=b*I*F-_*M*k;break;case"zyx":r[0]=_*I*F-b*M*k,r[1]=b*M*F+_*I*k,r[2]=b*I*k-_*M*F,r[3]=b*I*F+_*M*k;break;default:throw new Error("Unknown angle order "+A)}return r}function Hr(){var r=new zi(2);return zi!=Float32Array&&(r[0]=0,r[1]=0),r}function ti(r,e){var i=new zi(2);return i[0]=r,i[1]=e,i}Ns(),Ji=new zi(4),zi!=Float32Array&&(Ji[0]=0,Ji[1]=0,Ji[2]=0,Ji[3]=0),Ns(),Oo(1,0,0),Oo(0,1,0),Un(),Un(),ro(),Hr();const Oi=8192;function Yt(r,e,i){return e*(Oi/(r.tileSize*Math.pow(2,i-r.tileID.overscaledZ)))}function Ni(r,e){return(r%e+e)%e}function Mr(r,e,i){return r*(1-i)+e*i}function Wr(r){if(r<=0)return 0;if(r>=1)return 1;const e=r*r,i=e*r;return 4*(r<.5?i:3*(r-e)+i-.75)}function or(r,e,i,s){const A=new zr(r,e,i,s);return d=>A.solve(d)}const xi=or(.25,.1,.25,1);function Ai(r,e,i){return Math.min(i,Math.max(e,r))}function hn(r,e,i){const s=i-e,A=((r-e)%s+s)%s+e;return A===e?i:A}function Er(r,...e){for(const i of e)for(const s in i)r[s]=i[s];return r}let yo=1;function us(r,e,i){const s={};for(const A in r)s[A]=e.call(this,r[A],A,r);return s}function No(r,e,i){const s={};for(const A in r)e.call(this,r[A],A,r)&&(s[A]=r[A]);return s}function In(r){return Array.isArray(r)?r.map(In):typeof r=="object"&&r?us(r,In):r}const Vo={};function en(r){Vo[r]||(typeof console<"u"&&console.warn(r),Vo[r]=!0)}function hs(r,e,i){return(i.y-r.y)*(e.x-r.x)>(e.y-r.y)*(i.x-r.x)}function Is(r){return typeof WorkerGlobalScope<"u"&&r!==void 0&&r instanceof WorkerGlobalScope}let Ui=null;function Dn(r){return typeof ImageBitmap<"u"&&r instanceof ImageBitmap}const jo="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function Zo(r,e,i,s,A){return p(this,void 0,void 0,(function*(){if(typeof VideoFrame>"u")throw new Error("VideoFrame not supported");const d=new VideoFrame(r,{timestamp:0});try{const _=d==null?void 0:d.format;if(!_||!_.startsWith("BGR")&&!_.startsWith("RGB"))throw new Error(`Unrecognized format ${_}`);const b=_.startsWith("BGR"),M=new Uint8ClampedArray(s*A*4);if(yield d.copyTo(M,(function(I,k,F,V,j){const H=4*Math.max(-k,0),Q=(Math.max(0,F)-F)*V*4+H,Y=4*V,re=Math.max(0,k),ge=Math.max(0,F);return{rect:{x:re,y:ge,width:Math.min(I.width,k+V)-re,height:Math.min(I.height,F+j)-ge},layout:[{offset:Q,stride:Y}]}})(r,e,i,s,A)),b)for(let I=0;I<M.length;I+=4){const k=M[I];M[I]=M[I+2],M[I+2]=k}return M}finally{d.close()}}))}let tn,Gn;function vo(r,e,i,s){return r.addEventListener(e,i,s),{unsubscribe:()=>{r.removeEventListener(e,i,s)}}}function Ds(r){return r*Math.PI/180}function mn(r){return r/Math.PI*180}const Ne={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},ee={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0},K="AbortError";class le extends Error{constructor(e=K){super(e instanceof Error?e.message:e),this.name=K,e instanceof Error&&e.stack&&(this.stack=e.stack)}}function Me(r){return r.name===K}const Se={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function Ge(r){return Se.REGISTERED_PROTOCOLS[r.substring(0,r.indexOf("://"))]}const Fe="global-dispatcher";class ke extends Error{constructor(e,i,s,A){super(`AJAXError: ${i} (${e}): ${s}`),this.status=e,this.statusText=i,this.url=s,this.body=A}}const Qe=()=>Is(self)?self.worker&&self.worker.referrer:(window.location.protocol==="blob:"?window.parent:window).location.href,ft=function(r,e){if(/:\/\//.test(r.url)&&!/^https?:|^file:/.test(r.url)){const s=Ge(r.url);if(s)return s(r,e);if(Is(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:r,targetMapId:Fe},e)}if(!(/^file:/.test(i=r.url)||/^file:/.test(Qe())&&!/^\w+:/.test(i))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return(function(s,A){return p(this,void 0,void 0,(function*(){const d=new Request(s.url,{method:s.method||"GET",body:s.body,credentials:s.credentials,headers:s.headers,cache:s.cache,referrer:Qe(),signal:A.signal});let _,b;s.type!=="json"||d.headers.has("Accept")||d.headers.set("Accept","application/json");try{_=yield fetch(d)}catch(I){throw Me(I)?I:new ke(0,I.message,s.url,new Blob)}if(!_.ok){const I=yield _.blob();throw new ke(_.status,_.statusText,s.url,I)}b=s.type==="arrayBuffer"||s.type==="image"?_.arrayBuffer():s.type==="json"?_.json():_.text();const M=yield b;return A.signal.throwIfAborted(),{data:M,cacheControl:_.headers.get("Cache-Control"),expires:_.headers.get("Expires")}}))})(r,e);if(Is(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:r,mustQueue:!0,targetMapId:Fe},e)}var i;return(function(s,A){return new Promise(((d,_)=>{var b;const M=new XMLHttpRequest;M.open(s.method||"GET",s.url,!0),s.type!=="arrayBuffer"&&s.type!=="image"||(M.responseType="arraybuffer");for(const I in s.headers)M.setRequestHeader(I,s.headers[I]);s.type==="json"&&(M.responseType="text",!((b=s.headers)===null||b===void 0)&&b.Accept||M.setRequestHeader("Accept","application/json")),M.withCredentials=s.credentials==="include",M.onerror=()=>{_(new Error(M.statusText))},M.onload=()=>{if(!A.signal.aborted)if((M.status>=200&&M.status<300||M.status===0)&&M.response!==null){let I=M.response;if(s.type==="json")try{I=JSON.parse(M.response)}catch(k){return void _(k)}d({data:I,cacheControl:M.getResponseHeader("Cache-Control"),expires:M.getResponseHeader("Expires")})}else{const I=new Blob([M.response],{type:M.getResponseHeader("Content-Type")});_(new ke(M.status,M.statusText,s.url,I))}},A.signal.addEventListener("abort",(()=>{M.abort(),_(new le(A.signal.reason))})),M.send(s.body)}))})(r,e)};function ot(r){if(!r||r.indexOf("://")<=0||r.indexOf("data:image/")===0||r.indexOf("blob:")===0)return!0;const e=new URL(r),i=window.location;return e.protocol===i.protocol&&e.host===i.host}function St(r,e,i){i[r]&&i[r].indexOf(e)!==-1||(i[r]=i[r]||[],i[r].push(e))}function je(r,e,i){if(i&&i[r]){const s=i[r].indexOf(e);s!==-1&&i[r].splice(s,1)}}class Xt{constructor(e,i={}){Er(this,i),this.type=e}}class Gi extends Xt{constructor(e,i={}){super("error",Er({error:e},i))}}class Bi{on(e,i){return this._listeners=this._listeners||{},St(e,i,this._listeners),{unsubscribe:()=>{this.off(e,i)}}}off(e,i){return je(e,i,this._listeners),je(e,i,this._oneTimeListeners),this}once(e,i){return i?(this._oneTimeListeners=this._oneTimeListeners||{},St(e,i,this._oneTimeListeners),this):new Promise((s=>this.once(e,s)))}fire(e,i){typeof e=="string"&&(e=new Xt(e,i||{}));const s=e.type;if(this.listens(s)){e.target=this;const A=this._listeners&&this._listeners[s]?this._listeners[s].slice():[];for(const b of A)b.call(this,e);const d=this._oneTimeListeners&&this._oneTimeListeners[s]?this._oneTimeListeners[s].slice():[];for(const b of d)je(s,b,this._oneTimeListeners),b.call(this,e);const _=this._eventedParent;_&&(Er(e,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),_.fire(e))}else e instanceof Gi&&console.error(e.error);return this}listens(e){return this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e)}setEventedParent(e,i){return this._eventedParent=e,this._eventedParentData=i,this}}var qe={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number",length:2},centerAltitude:{type:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},roll:{type:"number",default:0,units:"degrees"},state:{type:"state",default:{}},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},"font-faces":{type:"fontFaces"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},encoding:{type:"enum",values:{mvt:{},mlt:{}},default:"mvt"},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"filter"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},"color-relief":{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_color-relief","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"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"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},"layout_color-relief":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},filter:{type:"boolean",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"expression_name",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"projectionDefinition",default:"mercator","property-type":"data-constant",transition:!1,expression:{interpolated:!0,parameters:["zoom"]}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_color-relief","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"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"}},"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"}},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 Hi=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function rn(r,e){const i={};for(const s in r)s!=="ref"&&(i[s]=r[s]);return Hi.forEach((s=>{s in e&&(i[s]=e[s])})),i}function Kt(r,e){if(Array.isArray(r)){if(!Array.isArray(e)||r.length!==e.length)return!1;for(let i=0;i<r.length;i++)if(!Kt(r[i],e[i]))return!1;return!0}if(typeof r=="object"&&r!==null&&e!==null){if(typeof e!="object"||Object.keys(r).length!==Object.keys(e).length)return!1;for(const i in r)if(!Kt(r[i],e[i]))return!1;return!0}return r===e}function qi(r,e){r.push(e)}function Vr(r,e,i){qi(i,{command:"addSource",args:[r,e[r]]})}function Wi(r,e,i){qi(e,{command:"removeSource",args:[r]}),i[r]=!0}function er(r,e,i,s){Wi(r,i,s),Vr(r,e,i)}function Ve(r,e,i){let s;for(s in r[i])if(Object.prototype.hasOwnProperty.call(r[i],s)&&s!=="data"&&!Kt(r[i][s],e[i][s]))return!1;for(s in e[i])if(Object.prototype.hasOwnProperty.call(e[i],s)&&s!=="data"&&!Kt(r[i][s],e[i][s]))return!1;return!0}function at(r,e,i,s,A,d){r=r||{},e=e||{};for(const _ in r)Object.prototype.hasOwnProperty.call(r,_)&&(Kt(r[_],e[_])||i.push({command:d,args:[s,_,e[_],A]}));for(const _ in e)Object.prototype.hasOwnProperty.call(e,_)&&!Object.prototype.hasOwnProperty.call(r,_)&&(Kt(r[_],e[_])||i.push({command:d,args:[s,_,e[_],A]}))}function It(r){return r.id}function At(r,e){return r[e.id]=e,r}class o{constructor(e,i,s,A){this.message=(e?`${e}: `:"")+s,A&&(this.identifier=A),i!=null&&i.__line__&&(this.line=i.__line__)}}function X(r,...e){for(const i of e)for(const s in i)r[s]=i[s];return r}class ii extends Error{constructor(e,i){super(i),this.message=i,this.key=e}}class Ri{constructor(e,i=[]){this.parent=e,this.bindings={};for(const[s,A]of i)this.bindings[s]=A}concat(e){return new Ri(this,e)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw new Error(`${e} not found in scope.`)}has(e){return!!this.bindings[e]||!!this.parent&&this.parent.has(e)}}const Qi={kind:"null"},ut={kind:"number"},zt={kind:"string"},$t={kind:"boolean"},fi={kind:"color"},di={kind:"projectionDefinition"},jr={kind:"object"},ni={kind:"value"},Ea={kind:"collator"},xo={kind:"formatted"},kn={kind:"padding"},qn={kind:"colorArray"},Hn={kind:"numberArray"},bo={kind:"resolvedImage"},Sa={kind:"variableAnchorOffsetCollection"};function vr(r,e){return{kind:"array",itemType:r,N:e}}function Ft(r){if(r.kind==="array"){const e=Ft(r.itemType);return typeof r.N=="number"?`array<${e}, ${r.N}>`:r.itemType.kind==="value"?"array":`array<${e}>`}return r.kind}const ae=[Qi,ut,zt,$t,fi,di,xo,jr,vr(ni),kn,Hn,qn,bo,Sa];function qt(r,e){if(e.kind==="error")return null;if(r.kind==="array"){if(e.kind==="array"&&(e.N===0&&e.itemType.kind==="value"||!qt(r.itemType,e.itemType))&&(typeof r.N!="number"||r.N===e.N))return null}else{if(r.kind===e.kind)return null;if(r.kind==="value"){for(const i of ae)if(!qt(i,e))return null}}return`Expected ${Ft(r)} but found ${Ft(e)} instead.`}function Uo(r,e){return e.some((i=>i.kind===r.kind))}function wo(r,e){return e.some((i=>i==="null"?r===null:i==="array"?Array.isArray(r):i==="object"?r&&!Array.isArray(r)&&typeof r=="object":i===typeof r))}function zn(r,e){return r.kind==="array"&&e.kind==="array"?r.itemType.kind===e.itemType.kind&&typeof r.N=="number":r.kind===e.kind}const Fi=.96422,Xi=.82521,te=4/29,tr=6/29,Go=3*tr*tr,Ha=tr*tr*tr,_i=Math.PI/180,Sr=180/Math.PI;function Wa(r){return(r%=360)<0&&(r+=360),r}function ha([r,e,i,s]){let A,d;const _=Qa((.2225045*(r=_n(r))+.7168786*(e=_n(e))+.0606169*(i=_n(i)))/1);r===e&&e===i?A=d=_:(A=Qa((.4360747*r+.3850649*e+.1430804*i)/Fi),d=Qa((.0139322*r+.0971045*e+.7141733*i)/Xi));const b=116*_-16;return[b<0?0:b,500*(A-_),200*(_-d),s]}function _n(r){return r<=.04045?r/12.92:Math.pow((r+.055)/1.055,2.4)}function Qa(r){return r>Ha?Math.pow(r,1/3):r/Go+te}function Ln([r,e,i,s]){let A=(r+16)/116,d=isNaN(e)?A:A+e/500,_=isNaN(i)?A:A-i/200;return A=1*Cr(A),d=Fi*Cr(d),_=Xi*Cr(_),[ar(3.1338561*d-1.6168667*A-.4906146*_),ar(-.9787684*d+1.9161415*A+.033454*_),ar(.0719453*d-.2289914*A+1.4052427*_),s]}function ar(r){return(r=r<=.00304?12.92*r:1.055*Math.pow(r,1/2.4)-.055)<0?0:r>1?1:r}function Cr(r){return r>tr?r*r*r:Go*(r-te)}const To=Object.hasOwn||function(r,e){return Object.prototype.hasOwnProperty.call(r,e)};function so(r,e){return To(r,e)?r[e]:void 0}function js(r){return parseInt(r.padEnd(2,r),16)/255}function $a(r,e){return ks(e?r/100:r,0,1)}function ks(r,e,i){return Math.min(Math.max(e,r),i)}function Ca(r){return!r.some(Number.isNaN)}const qo={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 zs(r,e,i){return r+i*(e-r)}function Vi(r,e,i){return r.map(((s,A)=>zs(s,e[A],i)))}class oi{constructor(e,i,s,A=1,d=!0){this.r=e,this.g=i,this.b=s,this.a=A,d||(this.r*=A,this.g*=A,this.b*=A,A||this.overwriteGetter("rgb",[e,i,s,A]))}static parse(e){if(e instanceof oi)return e;if(typeof e!="string")return;const i=(function(s){if((s=s.toLowerCase().trim())==="transparent")return[0,0,0,0];const A=so(qo,s);if(A){const[_,b,M]=A;return[_/255,b/255,M/255,1]}if(s.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(s)){const _=s.length<6?1:2;let b=1;return[js(s.slice(b,b+=_)),js(s.slice(b,b+=_)),js(s.slice(b,b+=_)),js(s.slice(b,b+_)||"ff")]}if(s.startsWith("rgb")){const _=s.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(_){const[b,M,I,k,F,V,j,H,Q,Y,re,ge]=_,oe=[k||" ",j||" ",Y].join("");if(oe===" "||oe===" /"||oe===",,"||oe===",,,"){const ue=[I,V,Q].join(""),ve=ue==="%%%"?100:ue===""?255:0;if(ve){const Te=[ks(+M/ve,0,1),ks(+F/ve,0,1),ks(+H/ve,0,1),re?$a(+re,ge):1];if(Ca(Te))return Te}}return}}const d=s.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(d){const[_,b,M,I,k,F,V,j,H]=d,Q=[M||" ",k||" ",V].join("");if(Q===" "||Q===" /"||Q===",,"||Q===",,,"){const Y=[+b,ks(+I,0,100),ks(+F,0,100),j?$a(+j,H):1];if(Ca(Y))return(function([re,ge,oe,ue]){function ve(Te){const Ue=(Te+re/30)%12,lt=ge*Math.min(oe,1-oe);return oe-lt*Math.max(-1,Math.min(Ue-3,9-Ue,1))}return re=Wa(re),ge/=100,oe/=100,[ve(0),ve(8),ve(4),ue]})(Y)}}})(e);return i?new oi(...i,!1):void 0}get rgb(){const{r:e,g:i,b:s,a:A}=this,d=A||1/0;return this.overwriteGetter("rgb",[e/d,i/d,s/d,A])}get hcl(){return this.overwriteGetter("hcl",(function(e){const[i,s,A,d]=ha(e),_=Math.sqrt(s*s+A*A);return[Math.round(1e4*_)?Wa(Math.atan2(A,s)*Sr):NaN,_,i,d]})(this.rgb))}get lab(){return this.overwriteGetter("lab",ha(this.rgb))}overwriteGetter(e,i){return Object.defineProperty(this,e,{value:i}),i}toString(){const[e,i,s,A]=this.rgb;return`rgba(${[e,i,s].map((d=>Math.round(255*d))).join(",")},${A})`}static interpolate(e,i,s,A="rgb"){switch(A){case"rgb":{const[d,_,b,M]=Vi(e.rgb,i.rgb,s);return new oi(d,_,b,M,!1)}case"hcl":{const[d,_,b,M]=e.hcl,[I,k,F,V]=i.hcl;let j,H;if(isNaN(d)||isNaN(I))isNaN(d)?isNaN(I)?j=NaN:(j=I,b!==1&&b!==0||(H=k)):(j=d,F!==1&&F!==0||(H=_));else{let oe=I-d;I>d&&oe>180?oe-=360:I<d&&d-I>180&&(oe+=360),j=d+s*oe}const[Q,Y,re,ge]=(function([oe,ue,ve,Te]){return oe=isNaN(oe)?0:oe*_i,Ln([ve,Math.cos(oe)*ue,Math.sin(oe)*ue,Te])})([j,H??zs(_,k,s),zs(b,F,s),zs(M,V,s)]);return new oi(Q,Y,re,ge,!1)}case"lab":{const[d,_,b,M]=Ln(Vi(e.lab,i.lab,s));return new oi(d,_,b,M,!1)}}}}oi.black=new oi(0,0,0,1),oi.white=new oi(1,1,1,1),oi.transparent=new oi(0,0,0,0),oi.red=new oi(1,0,0,1);class Ho{constructor(e,i,s){this.sensitivity=e?i?"variant":"case":i?"accent":"base",this.locale=s,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,i){return this.collator.compare(e,i)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}const Nl=["bottom","center","top"];class Ia{constructor(e,i,s,A,d,_){this.text=e,this.image=i,this.scale=s,this.fontStack=A,this.textColor=d,this.verticalAlign=_}}class Wn{constructor(e){this.sections=e}static fromString(e){return new Wn([new Ia(e,null,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some((e=>e.text.length!==0||e.image&&e.image.name.length!==0))}static factory(e){return e instanceof Wn?e:Wn.fromString(e)}toString(){return this.sections.length===0?"":this.sections.map((e=>e.text)).join("")}}class Ht{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Ht)return e;if(typeof e=="number")return new Ht([e,e,e,e]);if(Array.isArray(e)&&!(e.length<1||e.length>4)){for(const i of e)if(typeof i!="number")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 Ht(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,i,s){return new Ht(Vi(e.values,i.values,s))}}class Li{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Li)return e;if(typeof e=="number")return new Li([e]);if(Array.isArray(e)){for(const i of e)if(typeof i!="number")return;return new Li(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,i,s){return new Li(Vi(e.values,i.values,s))}}class Dt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Dt)return e;if(typeof e=="string"){const s=oi.parse(e);return s?new Dt([s]):void 0}if(!Array.isArray(e))return;const i=[];for(const s of e){if(typeof s!="string")return;const A=oi.parse(s);if(!A)return;i.push(A)}return new Dt(i)}toString(){return JSON.stringify(this.values)}static interpolate(e,i,s,A="rgb"){const d=[];if(e.values.length!=i.values.length)throw new Error(`colorArray: Arrays have mismatched length (${e.values.length} vs. ${i.values.length}), cannot interpolate.`);for(let _=0;_<e.values.length;_++)d.push(oi.interpolate(e.values[_],i.values[_],s,A));return new Dt(d)}}class Ki extends Error{constructor(e){super(e),this.name="RuntimeError"}toJSON(){return this.message}}const Zs=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class cn{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof cn)return e;if(Array.isArray(e)&&!(e.length<1)&&e.length%2==0){for(let i=0;i<e.length;i+=2){const s=e[i],A=e[i+1];if(typeof s!="string"||!Zs.has(s)||!Array.isArray(A)||A.length!==2||typeof A[0]!="number"||typeof A[1]!="number")return}return new cn(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,i,s){const A=e.values,d=i.values;if(A.length!==d.length)throw new Ki(`Cannot interpolate values of different length. from: ${e.toString()}, to: ${i.toString()}`);const _=[];for(let b=0;b<A.length;b+=2){if(A[b]!==d[b])throw new Ki(`Cannot interpolate values containing mismatched anchors. from[${b}]: ${A[b]}, to[${b}]: ${d[b]}`);_.push(A[b]);const[M,I]=A[b+1],[k,F]=d[b+1];_.push([zs(M,k,s),zs(I,F,s)])}return new cn(_)}}class gn{constructor(e){this.name=e.name,this.available=e.available}toString(){return this.name}static fromString(e){return e?new gn({name:e,available:!1}):null}}class Lr{constructor(e,i,s){this.from=e,this.to=i,this.transition=s}static interpolate(e,i,s){return new Lr(e,i,s)}static parse(e){return e instanceof Lr?e:Array.isArray(e)&&e.length===3&&typeof e[0]=="string"&&typeof e[1]=="string"&&typeof e[2]=="number"?new Lr(e[0],e[1],e[2]):typeof e=="object"&&typeof e.from=="string"&&typeof e.to=="string"&&typeof e.transition=="number"?new Lr(e.from,e.to,e.transition):typeof e=="string"?new Lr(e,e,1):void 0}}function Us(r,e,i,s){return typeof r=="number"&&r>=0&&r<=255&&typeof e=="number"&&e>=0&&e<=255&&typeof i=="number"&&i>=0&&i<=255?s===void 0||typeof s=="number"&&s>=0&&s<=1?null:`Invalid rgba value [${[r,e,i,s].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof s=="number"?[r,e,i,s]:[r,e,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Qn(r){if(r===null||typeof r=="string"||typeof r=="boolean"||typeof r=="number"||r instanceof Lr||r instanceof oi||r instanceof Ho||r instanceof Wn||r instanceof Ht||r instanceof Li||r instanceof Dt||r instanceof cn||r instanceof gn)return!0;if(Array.isArray(r)){for(const e of r)if(!Qn(e))return!1;return!0}if(typeof r=="object"){for(const e in r)if(!Qn(r[e]))return!1;return!0}return!1}function Si(r){if(r===null)return Qi;if(typeof r=="string")return zt;if(typeof r=="boolean")return $t;if(typeof r=="number")return ut;if(r instanceof oi)return fi;if(r instanceof Lr)return di;if(r instanceof Ho)return Ea;if(r instanceof Wn)return xo;if(r instanceof Ht)return kn;if(r instanceof Li)return Hn;if(r instanceof Dt)return qn;if(r instanceof cn)return Sa;if(r instanceof gn)return bo;if(Array.isArray(r)){const e=r.length;let i;for(const s of r){const A=Si(s);if(i){if(i===A)continue;i=ni;break}i=A}return vr(i||ni,e)}return jr}function $n(r){const e=typeof r;return r===null?"":e==="string"||e==="number"||e==="boolean"?String(r):r instanceof oi||r instanceof Lr||r instanceof Wn||r instanceof Ht||r instanceof Li||r instanceof Dt||r instanceof cn||r instanceof gn?r.toString():JSON.stringify(r)}class gs{constructor(e,i){this.type=e,this.value=i}static parse(e,i){if(e.length!==2)return i.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!Qn(e[1]))return i.error("invalid value");const s=e[1];let A=Si(s);const d=i.expectedType;return A.kind!=="array"||A.N!==0||!d||d.kind!=="array"||typeof d.N=="number"&&d.N!==0||(A=d),new gs(A,s)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}const ca={string:zt,number:ut,boolean:$t,object:jr};class Yn{constructor(e,i){this.type=e,this.args=i}static parse(e,i){if(e.length<2)return i.error("Expected at least one argument.");let s,A=1;const d=e[0];if(d==="array"){let b,M;if(e.length>2){const I=e[1];if(typeof I!="string"||!(I in ca)||I==="object")return i.error('The item type argument of "array" must be one of string, number, boolean',1);b=ca[I],A++}else b=ni;if(e.length>3){if(e[2]!==null&&(typeof e[2]!="number"||e[2]<0||e[2]!==Math.floor(e[2])))return i.error('The length argument to "array" must be a positive integer literal',2);M=e[2],A++}s=vr(b,M)}else{if(!ca[d])throw new Error(`Types doesn't contain name = ${d}`);s=ca[d]}const _=[];for(;A<e.length;A++){const b=i.parse(e[A],A,ni);if(!b)return null;_.push(b)}return new Yn(s,_)}evaluate(e){for(let i=0;i<this.args.length;i++){const s=this.args[i].evaluate(e);if(!qt(this.type,Si(s)))return s;if(i===this.args.length-1)throw new Ki(`Expected value to be of type ${Ft(this.type)}, but found ${Ft(Si(s))} instead.`)}throw new Error}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}const Po={"to-boolean":$t,"to-color":fi,"to-number":ut,"to-string":zt};class Ls{constructor(e,i){this.type=e,this.args=i}static parse(e,i){if(e.length<2)return i.error("Expected at least one argument.");const s=e[0];if(!Po[s])throw new Error(`Can't parse ${s} as it is not part of the known types`);if((s==="to-boolean"||s==="to-string")&&e.length!==2)return i.error("Expected one argument.");const A=Po[s],d=[];for(let _=1;_<e.length;_++){const b=i.parse(e[_],_,ni);if(!b)return null;d.push(b)}return new Ls(A,d)}evaluate(e){switch(this.type.kind){case"boolean":return!!this.args[0].evaluate(e);case"color":{let i,s;for(const A of this.args){if(i=A.evaluate(e),s=null,i instanceof oi)return i;if(typeof i=="string"){const d=e.parseColor(i);if(d)return d}else if(Array.isArray(i)&&(s=i.length<3||i.length>4?`Invalid rgba value ${JSON.stringify(i)}: expected an array containing either three or four numeric values.`:Us(i[0],i[1],i[2],i[3]),!s))return new oi(i[0]/255,i[1]/255,i[2]/255,i[3])}throw new Ki(s||`Could not parse color from value '${typeof i=="string"?i:JSON.stringify(i)}'`)}case"padding":{let i;for(const s of this.args){i=s.evaluate(e);const A=Ht.parse(i);if(A)return A}throw new Ki(`Could not parse padding from value '${typeof i=="string"?i:JSON.stringify(i)}'`)}case"numberArray":{let i;for(const s of this.args){i=s.evaluate(e);const A=Li.parse(i);if(A)return A}throw new Ki(`Could not parse numberArray from value '${typeof i=="string"?i:JSON.stringify(i)}'`)}case"colorArray":{let i;for(const s of this.args){i=s.evaluate(e);const A=Dt.parse(i);if(A)return A}throw new Ki(`Could not parse colorArray from value '${typeof i=="string"?i:JSON.stringify(i)}'`)}case"variableAnchorOffsetCollection":{let i;for(const s of this.args){i=s.evaluate(e);const A=cn.parse(i);if(A)return A}throw new Ki(`Could not parse variableAnchorOffsetCollection from value '${typeof i=="string"?i:JSON.stringify(i)}'`)}case"number":{let i=null;for(const s of this.args){if(i=s.evaluate(e),i===null)return 0;const A=Number(i);if(!isNaN(A))return A}throw new Ki(`Could not convert ${JSON.stringify(i)} to number.`)}case"formatted":return Wn.fromString($n(this.args[0].evaluate(e)));case"resolvedImage":return gn.fromString($n(this.args[0].evaluate(e)));case"projectionDefinition":return this.args[0].evaluate(e);default:return $n(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}const Vl=["Unknown","Point","LineString","Polygon"];class Qr{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?typeof this.feature.type=="number"?Vl[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(e){let i=this._parseColorCache.get(e);return i||(i=oi.parse(e),this._parseColorCache.set(e,i)),i}}class hi{constructor(e,i,s=[],A,d=new Ri,_=[]){this.registry=e,this.path=s,this.key=s.map((b=>`[${b}]`)).join(""),this.scope=d,this.errors=_,this.expectedType=A,this._isConstant=i}parse(e,i,s,A,d={}){return i?this.concat(i,s,A)._parse(e,d):this._parse(e,d)}_parse(e,i){function s(A,d,_){return _==="assert"?new Yn(d,[A]):_==="coerce"?new Ls(d,[A]):A}if(e!==null&&typeof e!="string"&&typeof e!="boolean"&&typeof e!="number"||(e=["literal",e]),Array.isArray(e)){if(e.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const A=e[0];if(typeof A!="string")return this.error(`Expression name must be a string, but found ${typeof A} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const d=this.registry[A];if(d){let _=d.parse(e,this);if(!_)return null;if(this.expectedType){const b=this.expectedType,M=_.type;if(b.kind!=="string"&&b.kind!=="number"&&b.kind!=="boolean"&&b.kind!=="object"&&b.kind!=="array"||M.kind!=="value"){if(b.kind==="projectionDefinition"&&["string","array"].includes(M.kind)||["color","formatted","resolvedImage"].includes(b.kind)&&["value","string"].includes(M.kind)||["padding","numberArray"].includes(b.kind)&&["value","number","array"].includes(M.kind)||b.kind==="colorArray"&&["value","string","array"].includes(M.kind)||b.kind==="variableAnchorOffsetCollection"&&["value","array"].includes(M.kind))_=s(_,b,i.typeAnnotation||"coerce");else if(this.checkSubtype(b,M))return null}else _=s(_,b,i.typeAnnotation||"assert")}if(!(_ instanceof gs)&&_.type.kind!=="resolvedImage"&&this._isConstant(_)){const b=new Qr;try{_=new gs(_.type,_.evaluate(b))}catch(M){return this.error(M.message),null}}return _}return this.error(`Unknown expression "${A}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(e===void 0?"'undefined' value invalid. Use null instead.":typeof e=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,i,s){const A=typeof e=="number"?this.path.concat(e):this.path,d=s?this.scope.concat(s):this.scope;return new hi(this.registry,this._isConstant,A,i||null,d,this.errors)}error(e,...i){const s=`${this.key}${i.map((A=>`[${A}]`)).join("")}`;this.errors.push(new ii(s,e))}checkSubtype(e,i){const s=qt(e,i);return s&&this.error(s),s}}class bi{constructor(e,i){this.type=i.type,this.bindings=[].concat(e),this.result=i}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const i of this.bindings)e(i[1]);e(this.result)}static parse(e,i){if(e.length<4)return i.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const s=[];for(let d=1;d<e.length-1;d+=2){const _=e[d];if(typeof _!="string")return i.error(`Expected string, but found ${typeof _} instead.`,d);if(/[^a-zA-Z0-9_]/.test(_))return i.error("Variable names must contain only alphanumeric characters or '_'.",d);const b=i.parse(e[d+1],d+1);if(!b)return null;s.push([_,b])}const A=i.parse(e[e.length-1],e.length-1,i.expectedType,s);return A?new bi(s,A):null}outputDefined(){return this.result.outputDefined()}}class nn{constructor(e,i){this.type=i.type,this.name=e,this.boundExpression=i}static parse(e,i){if(e.length!==2||typeof e[1]!="string")return i.error("'var' expression requires exactly one string literal argument.");const s=e[1];return i.scope.has(s)?new nn(s,i.scope.get(s)):i.error(`Unknown variable "${s}". Make sure "${s}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}}class wi{constructor(e,i,s){this.type=e,this.index=i,this.input=s}static parse(e,i){if(e.length!==3)return i.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const s=i.parse(e[1],1,ut),A=i.parse(e[2],2,vr(i.expectedType||ni));return s&&A?new wi(A.type.itemType,s,A):null}evaluate(e){const i=this.index.evaluate(e),s=this.input.evaluate(e);if(i<0)throw new Ki(`Array index out of bounds: ${i} < 0.`);if(i>=s.length)throw new Ki(`Array index out of bounds: ${i} > ${s.length-1}.`);if(i!==Math.floor(i))throw new Ki(`Array index must be an integer, but found ${i} instead.`);return s[i]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}}class ri{constructor(e,i){this.type=$t,this.needle=e,this.haystack=i}static parse(e,i){if(e.length!==3)return i.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const s=i.parse(e[1],1,ni),A=i.parse(e[2],2,ni);return s&&A?Uo(s.type,[$t,zt,ut,Qi,ni])?new ri(s,A):i.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ft(s.type)} instead`):null}evaluate(e){const i=this.needle.evaluate(e),s=this.haystack.evaluate(e);if(!s)return!1;if(!wo(i,["boolean","string","number","null"]))throw new Ki(`Expected first argument to be of type boolean, string, number or null, but found ${Ft(Si(i))} instead.`);if(!wo(s,["string","array"]))throw new Ki(`Expected second argument to be of type array or string, but found ${Ft(Si(s))} instead.`);return s.indexOf(i)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class Aa{constructor(e,i,s){this.type=ut,this.needle=e,this.haystack=i,this.fromIndex=s}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.`);const s=i.parse(e[1],1,ni),A=i.parse(e[2],2,ni);if(!s||!A)return null;if(!Uo(s.type,[$t,zt,ut,Qi,ni]))return i.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ft(s.type)} instead`);if(e.length===4){const d=i.parse(e[3],3,ut);return d?new Aa(s,A,d):null}return new Aa(s,A)}evaluate(e){const i=this.needle.evaluate(e),s=this.haystack.evaluate(e);if(!wo(i,["boolean","string","number","null"]))throw new Ki(`Expected first argument to be of type boolean, string, number or null, but found ${Ft(Si(i))} instead.`);let A;if(this.fromIndex&&(A=this.fromIndex.evaluate(e)),wo(s,["string"])){const d=s.indexOf(i,A);return d===-1?-1:[...s.slice(0,d)].length}if(wo(s,["array"]))return s.indexOf(i,A);throw new Ki(`Expected second argument to be of type array or string, but found ${Ft(Si(s))} instead.`)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class Ci{constructor(e,i,s,A,d,_){this.inputType=e,this.type=i,this.input=s,this.cases=A,this.outputs=d,this.otherwise=_}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 s,A;i.expectedType&&i.expectedType.kind!=="value"&&(A=i.expectedType);const d={},_=[];for(let I=2;I<e.length-1;I+=2){let k=e[I];const F=e[I+1];Array.isArray(k)||(k=[k]);const V=i.concat(I);if(k.length===0)return V.error("Expected at least one branch label.");for(const H of k){if(typeof H!="number"&&typeof H!="string")return V.error("Branch labels must be numbers or strings.");if(typeof H=="number"&&Math.abs(H)>Number.MAX_SAFE_INTEGER)return V.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof H=="number"&&Math.floor(H)!==H)return V.error("Numeric branch labels must be integer values.");if(s){if(V.checkSubtype(s,Si(H)))return null}else s=Si(H);if(d[String(H)]!==void 0)return V.error("Branch labels must be unique.");d[String(H)]=_.length}const j=i.parse(F,I,A);if(!j)return null;A=A||j.type,_.push(j)}const b=i.parse(e[1],1,ni);if(!b)return null;const M=i.parse(e[e.length-1],e.length-1,A);return M?b.type.kind!=="value"&&i.concat(1).checkSubtype(s,b.type)?null:new Ci(s,A,b,d,_,M):null}evaluate(e){const i=this.input.evaluate(e);return(Si(i)===this.inputType&&this.outputs[this.cases[i]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))&&this.otherwise.outputDefined()}}class Da{constructor(e,i,s){this.type=e,this.branches=i,this.otherwise=s}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 s;i.expectedType&&i.expectedType.kind!=="value"&&(s=i.expectedType);const A=[];for(let _=1;_<e.length-1;_+=2){const b=i.parse(e[_],_,$t);if(!b)return null;const M=i.parse(e[_+1],_+1,s);if(!M)return null;A.push([b,M]),s=s||M.type}const d=i.parse(e[e.length-1],e.length-1,s);if(!d)return null;if(!s)throw new Error("Can't infer output type");return new Da(s,A,d)}evaluate(e){for(const[i,s]of this.branches)if(i.evaluate(e))return s.evaluate(e);return this.otherwise.evaluate(e)}eachChild(e){for(const[i,s]of this.branches)e(i),e(s);e(this.otherwise)}outputDefined(){return this.branches.every((([e,i])=>i.outputDefined()))&&this.otherwise.outputDefined()}}class Xn{constructor(e,i,s,A){this.type=e,this.input=i,this.beginIndex=s,this.endIndex=A}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.`);const s=i.parse(e[1],1,ni),A=i.parse(e[2],2,ut);if(!s||!A)return null;if(!Uo(s.type,[vr(ni),zt,ni]))return i.error(`Expected first argument to be of type array or string, but found ${Ft(s.type)} instead`);if(e.length===4){const d=i.parse(e[3],3,ut);return d?new Xn(s.type,s,A,d):null}return new Xn(s.type,s,A)}evaluate(e){const i=this.input.evaluate(e),s=this.beginIndex.evaluate(e);let A;if(this.endIndex&&(A=this.endIndex.evaluate(e)),wo(i,["string"]))return[...i].slice(s,A).join("");if(wo(i,["array"]))return i.slice(s,A);throw new Ki(`Expected first argument to be of type array or string, but found ${Ft(Si(i))} instead.`)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function oo(r,e){const i=r.length-1;let s,A,d=0,_=i,b=0;for(;d<=_;)if(b=Math.floor((d+_)/2),s=r[b],A=r[b+1],s<=e){if(b===i||e<A)return b;d=b+1}else{if(!(s>e))throw new Ki("Input is not a number.");_=b-1}return 0}class Kn{constructor(e,i,s){this.type=e,this.input=i,this.labels=[],this.outputs=[];for(const[A,d]of s)this.labels.push(A),this.outputs.push(d)}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.");const s=i.parse(e[1],1,ut);if(!s)return null;const A=[];let d=null;i.expectedType&&i.expectedType.kind!=="value"&&(d=i.expectedType);for(let _=1;_<e.length;_+=2){const b=_===1?-1/0:e[_],M=e[_+1],I=_,k=_+1;if(typeof b!="number")return i.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',I);if(A.length&&A[A.length-1][0]>=b)return i.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',I);const F=i.parse(M,k,d);if(!F)return null;d=d||F.type,A.push([b,F])}return new Kn(d,s,A)}evaluate(e){const i=this.labels,s=this.outputs;if(i.length===1)return s[0].evaluate(e);const A=this.input.evaluate(e);if(A<=i[0])return s[0].evaluate(e);const d=i.length;return A>=i[d-1]?s[d-1].evaluate(e):s[oo(i,A)].evaluate(e)}eachChild(e){e(this.input);for(const i of this.outputs)e(i)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function ka(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var fa,Bn,Wo=(function(){if(Bn)return fa;function r(e,i,s,A){this.cx=3*e,this.bx=3*(s-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*i,this.by=3*(A-i)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=i,this.p2x=s,this.p2y=A}return Bn=1,fa=r,r.prototype={sampleCurveX:function(e){return((this.ax*e+this.bx)*e+this.cx)*e},sampleCurveY:function(e){return((this.ay*e+this.by)*e+this.cy)*e},sampleCurveDerivativeX:function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},solveCurveX:function(e,i){if(i===void 0&&(i=1e-6),e<0)return 0;if(e>1)return 1;for(var s=e,A=0;A<8;A++){var d=this.sampleCurveX(s)-e;if(Math.abs(d)<i)return s;var _=this.sampleCurveDerivativeX(s);if(Math.abs(_)<1e-6)break;s-=d/_}var b=0,M=1;for(s=e,A=0;A<20&&(d=this.sampleCurveX(s),!(Math.abs(d-e)<i));A++)e>d?b=s:M=s,s=.5*(M-b)+b;return s},solve:function(e,i){return this.sampleCurveY(this.solveCurveX(e,i))}},fa})(),Gs=ka(Wo);class xr{constructor(e,i,s,A,d){this.type=e,this.operator=i,this.interpolation=s,this.input=A,this.labels=[],this.outputs=[];for(const[_,b]of d)this.labels.push(_),this.outputs.push(b)}static interpolationFactor(e,i,s,A){let d=0;if(e.name==="exponential")d=ys(i,e.base,s,A);else if(e.name==="linear")d=ys(i,1,s,A);else if(e.name==="cubic-bezier"){const _=e.controlPoints;d=new Gs(_[0],_[1],_[2],_[3]).solve(ys(i,1,s,A))}return d}static parse(e,i){let[s,A,d,..._]=e;if(!Array.isArray(A)||A.length===0)return i.error("Expected an interpolation type expression.",1);if(A[0]==="linear")A={name:"linear"};else if(A[0]==="exponential"){const I=A[1];if(typeof I!="number")return i.error("Exponential interpolation requires a numeric base.",1,1);A={name:"exponential",base:I}}else{if(A[0]!=="cubic-bezier")return i.error(`Unknown interpolation type ${String(A[0])}`,1,0);{const I=A.slice(1);if(I.length!==4||I.some((k=>typeof k!="number"||k<0||k>1)))return i.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);A={name:"cubic-bezier",controlPoints: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.");if(d=i.parse(d,2,ut),!d)return null;const b=[];let M=null;s!=="interpolate-hcl"&&s!=="interpolate-lab"||i.expectedType==qn?i.expectedType&&i.expectedType.kind!=="value"&&(M=i.expectedType):M=fi;for(let I=0;I<_.length;I+=2){const k=_[I],F=_[I+1],V=I+3,j=I+4;if(typeof k!="number")return i.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',V);if(b.length&&b[b.length-1][0]>=k)return i.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',V);const H=i.parse(F,j,M);if(!H)return null;M=M||H.type,b.push([k,H])}return zn(M,ut)||zn(M,di)||zn(M,fi)||zn(M,kn)||zn(M,Hn)||zn(M,qn)||zn(M,Sa)||zn(M,vr(ut))?new xr(M,s,A,d,b):i.error(`Type ${Ft(M)} is not interpolatable.`)}evaluate(e){const i=this.labels,s=this.outputs;if(i.length===1)return s[0].evaluate(e);const A=this.input.evaluate(e);if(A<=i[0])return s[0].evaluate(e);const d=i.length;if(A>=i[d-1])return s[d-1].evaluate(e);const _=oo(i,A),b=xr.interpolationFactor(this.interpolation,A,i[_],i[_+1]),M=s[_].evaluate(e),I=s[_+1].evaluate(e);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return zs(M,I,b);case"color":return oi.interpolate(M,I,b);case"padding":return Ht.interpolate(M,I,b);case"colorArray":return Dt.interpolate(M,I,b);case"numberArray":return Li.interpolate(M,I,b);case"variableAnchorOffsetCollection":return cn.interpolate(M,I,b);case"array":return Vi(M,I,b);case"projectionDefinition":return Lr.interpolate(M,I,b)}case"interpolate-hcl":switch(this.type.kind){case"color":return oi.interpolate(M,I,b,"hcl");case"colorArray":return Dt.interpolate(M,I,b,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return oi.interpolate(M,I,b,"lab");case"colorArray":return Dt.interpolate(M,I,b,"lab")}}}eachChild(e){e(this.input);for(const i of this.outputs)e(i)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function ys(r,e,i,s){const A=s-i,d=r-i;return A===0?0:e===1?d/A:(Math.pow(e,d)-1)/(Math.pow(e,A)-1)}const ir={color:oi.interpolate,number:zs,padding:Ht.interpolate,numberArray:Li.interpolate,colorArray:Dt.interpolate,variableAnchorOffsetCollection:cn.interpolate,array:Vi};class ao{constructor(e,i){this.type=e,this.args=i}static parse(e,i){if(e.length<2)return i.error("Expected at least one argument.");let s=null;const A=i.expectedType;A&&A.kind!=="value"&&(s=A);const d=[];for(const b of e.slice(1)){const M=i.parse(b,1+d.length,s,void 0,{typeAnnotation:"omit"});if(!M)return null;s=s||M.type,d.push(M)}if(!s)throw new Error("No output type");const _=A&&d.some((b=>qt(A,b.type)));return new ao(_?ni:s,d)}evaluate(e){let i,s=null,A=0;for(const d of this.args)if(A++,s=d.evaluate(e),s&&s instanceof gn&&!s.available&&(i||(i=s.name),s=null,A===this.args.length&&(s=i)),s!==null)break;return s}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}function yl(r,e){return r==="=="||r==="!="?e.kind==="boolean"||e.kind==="string"||e.kind==="number"||e.kind==="null"||e.kind==="value":e.kind==="string"||e.kind==="number"||e.kind==="value"}function Qo(r,e,i,s){return s.compare(e,i)===0}function dr(r,e,i){const s=r!=="=="&&r!=="!=";return class gp{constructor(d,_,b){this.type=$t,this.lhs=d,this.rhs=_,this.collator=b,this.hasUntypedArgument=d.type.kind==="value"||_.type.kind==="value"}static parse(d,_){if(d.length!==3&&d.length!==4)return _.error("Expected two or three arguments.");const b=d[0];let M=_.parse(d[1],1,ni);if(!M)return null;if(!yl(b,M.type))return _.concat(1).error(`"${b}" comparisons are not supported for type '${Ft(M.type)}'.`);let I=_.parse(d[2],2,ni);if(!I)return null;if(!yl(b,I.type))return _.concat(2).error(`"${b}" comparisons are not supported for type '${Ft(I.type)}'.`);if(M.type.kind!==I.type.kind&&M.type.kind!=="value"&&I.type.kind!=="value")return _.error(`Cannot compare types '${Ft(M.type)}' and '${Ft(I.type)}'.`);s&&(M.type.kind==="value"&&I.type.kind!=="value"?M=new Yn(I.type,[M]):M.type.kind!=="value"&&I.type.kind==="value"&&(I=new Yn(M.type,[I])));let k=null;if(d.length===4){if(M.type.kind!=="string"&&I.type.kind!=="string"&&M.type.kind!=="value"&&I.type.kind!=="value")return _.error("Cannot use collator to compare non-string types.");if(k=_.parse(d[3],3,Ea),!k)return null}return new gp(M,I,k)}evaluate(d){const _=this.lhs.evaluate(d),b=this.rhs.evaluate(d);if(s&&this.hasUntypedArgument){const M=Si(_),I=Si(b);if(M.kind!==I.kind||M.kind!=="string"&&M.kind!=="number")throw new Ki(`Expected arguments for "${r}" to be (string, string) or (number, number), but found (${M.kind}, ${I.kind}) instead.`)}if(this.collator&&!s&&this.hasUntypedArgument){const M=Si(_),I=Si(b);if(M.kind!=="string"||I.kind!=="string")return e(d,_,b)}return this.collator?i(d,_,b,this.collator.evaluate(d)):e(d,_,b)}eachChild(d){d(this.lhs),d(this.rhs),this.collator&&d(this.collator)}outputDefined(){return!0}}}const jl=dr("==",(function(r,e,i){return e===i}),Qo),vl=dr("!=",(function(r,e,i){return e!==i}),(function(r,e,i,s){return!Qo(0,e,i,s)})),Ya=dr("<",(function(r,e,i){return e<i}),(function(r,e,i,s){return s.compare(e,i)<0})),uu=dr(">",(function(r,e,i){return e>i}),(function(r,e,i,s){return s.compare(e,i)>0})),Mo=dr("<=",(function(r,e,i){return e<=i}),(function(r,e,i,s){return s.compare(e,i)<=0})),za=dr(">=",(function(r,e,i){return e>=i}),(function(r,e,i,s){return s.compare(e,i)>=0}));class lo{constructor(e,i,s){this.type=Ea,this.locale=s,this.caseSensitive=e,this.diacriticSensitive=i}static parse(e,i){if(e.length!==2)return i.error("Expected one argument.");const s=e[1];if(typeof s!="object"||Array.isArray(s))return i.error("Collator options argument must be an object.");const A=i.parse(s["case-sensitive"]!==void 0&&s["case-sensitive"],1,$t);if(!A)return null;const d=i.parse(s["diacritic-sensitive"]!==void 0&&s["diacritic-sensitive"],1,$t);if(!d)return null;let _=null;return s.locale&&(_=i.parse(s.locale,1,zt),!_)?null:new lo(A,d,_)}evaluate(e){return new Ho(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}}class vs{constructor(e,i,s,A,d){this.type=zt,this.number=e,this.locale=i,this.currency=s,this.minFractionDigits=A,this.maxFractionDigits=d}static parse(e,i){if(e.length!==3)return i.error("Expected two arguments.");const s=i.parse(e[1],1,ut);if(!s)return null;const A=e[2];if(typeof A!="object"||Array.isArray(A))return i.error("NumberFormat options argument must be an object.");let d=null;if(A.locale&&(d=i.parse(A.locale,1,zt),!d))return null;let _=null;if(A.currency&&(_=i.parse(A.currency,1,zt),!_))return null;let b=null;if(A["min-fraction-digits"]&&(b=i.parse(A["min-fraction-digits"],1,ut),!b))return null;let M=null;return A["max-fraction-digits"]&&(M=i.parse(A["max-fraction-digits"],1,ut),!M)?null:new vs(s,d,_,b,M)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}}class La{constructor(e){this.type=xo,this.sections=e}static parse(e,i){if(e.length<2)return i.error("Expected at least one argument.");const s=e[1];if(!Array.isArray(s)&&typeof s=="object")return i.error("First argument must be an image or text section.");const A=[];let d=!1;for(let _=1;_<=e.length-1;++_){const b=e[_];if(d&&typeof b=="object"&&!Array.isArray(b)){d=!1;let M=null;if(b["font-scale"]&&(M=i.parse(b["font-scale"],1,ut),!M))return null;let I=null;if(b["text-font"]&&(I=i.parse(b["text-font"],1,vr(zt)),!I))return null;let k=null;if(b["text-color"]&&(k=i.parse(b["text-color"],1,fi),!k))return null;let F=null;if(b["vertical-align"]){if(typeof b["vertical-align"]=="string"&&!Nl.includes(b["vertical-align"]))return i.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${b["vertical-align"]}' instead.`);if(F=i.parse(b["vertical-align"],1,zt),!F)return null}const V=A[A.length-1];V.scale=M,V.font=I,V.textColor=k,V.verticalAlign=F}else{const M=i.parse(e[_],1,ni);if(!M)return null;const I=M.type.kind;if(I!=="string"&&I!=="value"&&I!=="null"&&I!=="resolvedImage")return i.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");d=!0,A.push({content:M,scale:null,font:null,textColor:null,verticalAlign:null})}}return new La(A)}evaluate(e){return new Wn(this.sections.map((i=>{const s=i.content.evaluate(e);return Si(s)===bo?new Ia("",s,null,null,null,i.verticalAlign?i.verticalAlign.evaluate(e):null):new Ia($n(s),null,i.scale?i.scale.evaluate(e):null,i.font?i.font.evaluate(e).join(","):null,i.textColor?i.textColor.evaluate(e):null,i.verticalAlign?i.verticalAlign.evaluate(e):null)})))}eachChild(e){for(const i of this.sections)e(i.content),i.scale&&e(i.scale),i.font&&e(i.font),i.textColor&&e(i.textColor),i.verticalAlign&&e(i.verticalAlign)}outputDefined(){return!1}}class qs{constructor(e){this.type=bo,this.input=e}static parse(e,i){if(e.length!==2)return i.error("Expected two arguments.");const s=i.parse(e[1],1,zt);return s?new qs(s):i.error("No image name provided.")}evaluate(e){const i=this.input.evaluate(e),s=gn.fromString(i);return s&&e.availableImages&&(s.available=e.availableImages.indexOf(i)>-1),s}eachChild(e){e(this.input)}outputDefined(){return!1}}class An{constructor(e){this.type=ut,this.input=e}static parse(e,i){if(e.length!==2)return i.error(`Expected 1 argument, but found ${e.length-1} instead.`);const s=i.parse(e[1],1);return s?s.type.kind!=="array"&&s.type.kind!=="string"&&s.type.kind!=="value"?i.error(`Expected argument of type string or array, but found ${Ft(s.type)} instead.`):new An(s):null}evaluate(e){const i=this.input.evaluate(e);if(typeof i=="string")return[...i].length;if(Array.isArray(i))return i.length;throw new Ki(`Expected value to be of type string or array, but found ${Ft(Si(i))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}const Ar=8192;function xl(r,e){const i=(180+r[0])/360,s=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+r[1]*Math.PI/360)))/360,A=Math.pow(2,e.z);return[Math.round(i*A*Ar),Math.round(s*A*Ar)]}function Eo(r,e){const i=Math.pow(2,e.z);return[(A=(r[0]/Ar+e.x)/i,360*A-180),(s=(r[1]/Ar+e.y)/i,360/Math.PI*Math.atan(Math.exp((180-360*s)*Math.PI/180))-90)];var s,A}function So(r,e){r[0]=Math.min(r[0],e[0]),r[1]=Math.min(r[1],e[1]),r[2]=Math.max(r[2],e[0]),r[3]=Math.max(r[3],e[1])}function Jn(r,e){return!(r[0]<=e[0]||r[2]>=e[2]||r[1]<=e[1]||r[3]>=e[3])}function hu(r,e,i){const s=r[0]-e[0],A=r[1]-e[1],d=r[0]-i[0],_=r[1]-i[1];return s*_-d*A==0&&s*d<=0&&A*_<=0}function da(r,e,i,s){return(A=[s[0]-i[0],s[1]-i[1]])[0]*(d=[e[0]-r[0],e[1]-r[1]])[1]-A[1]*d[0]!=0&&!(!cs(r,e,i,s)||!cs(i,s,r,e));var A,d}function bl(r,e,i){for(const s of i)for(let A=0;A<s.length-1;++A)if(da(r,e,s[A],s[A+1]))return!0;return!1}function pa(r,e,i=!1){let s=!1;for(const b of e)for(let M=0;M<b.length-1;M++){if(hu(r,b[M],b[M+1]))return i;(d=b[M])[1]>(A=r)[1]!=(_=b[M+1])[1]>A[1]&&A[0]<(_[0]-d[0])*(A[1]-d[1])/(_[1]-d[1])+d[0]&&(s=!s)}var A,d,_;return s}function Rn(r,e){for(const i of e)if(pa(r,i))return!0;return!1}function $o(r,e){for(const i of r)if(!pa(i,e))return!1;for(let i=0;i<r.length-1;++i)if(bl(r[i],r[i+1],e))return!1;return!0}function Zl(r,e){for(const i of e)if($o(r,i))return!0;return!1}function cs(r,e,i,s){const A=s[0]-i[0],d=s[1]-i[1],_=(r[0]-i[0])*d-A*(r[1]-i[1]),b=(e[0]-i[0])*d-A*(e[1]-i[1]);return _>0&&b<0||_<0&&b>0}function wl(r,e,i){const s=[];for(let A=0;A<r.length;A++){const d=[];for(let _=0;_<r[A].length;_++){const b=xl(r[A][_],i);So(e,b),d.push(b)}s.push(d)}return s}function Hs(r,e,i){const s=[];for(let A=0;A<r.length;A++){const d=wl(r[A],e,i);s.push(d)}return s}function Xa(r,e,i,s){if(r[0]<i[0]||r[0]>i[2]){const A=.5*s;let d=r[0]-i[0]>A?-s:i[0]-r[0]>A?s:0;d===0&&(d=r[0]-i[2]>A?-s:i[2]-r[0]>A?s:0),r[0]+=d}So(e,r)}function Ws(r,e,i,s){const A=Math.pow(2,s.z)*Ar,d=[s.x*Ar,s.y*Ar],_=[];for(const b of r)for(const M of b){const I=[M.x+d[0],M.y+d[1]];Xa(I,e,i,A),_.push(I)}return _}function $i(r,e,i,s){const A=Math.pow(2,s.z)*Ar,d=[s.x*Ar,s.y*Ar],_=[];for(const M of r){const I=[];for(const k of M){const F=[k.x+d[0],k.y+d[1]];So(e,F),I.push(F)}_.push(I)}if(e[2]-e[0]<=A/2){(b=e)[0]=b[1]=1/0,b[2]=b[3]=-1/0;for(const M of _)for(const I of M)Xa(I,e,i,A)}var b;return _}class Qs{constructor(e,i){this.type=$t,this.geojson=e,this.geometries=i}static parse(e,i){if(e.length!==2)return i.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Qn(e[1])){const s=e[1];if(s.type==="FeatureCollection"){const A=[];for(const d of s.features){const{type:_,coordinates:b}=d.geometry;_==="Polygon"&&A.push(b),_==="MultiPolygon"&&A.push(...b)}if(A.length)return new Qs(s,{type:"MultiPolygon",coordinates:A})}else if(s.type==="Feature"){const A=s.geometry.type;if(A==="Polygon"||A==="MultiPolygon")return new Qs(s,s.geometry)}else if(s.type==="Polygon"||s.type==="MultiPolygon")return new Qs(s,s)}return i.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(e.geometry()!=null&&e.canonicalID()!=null){if(e.geometryType()==="Point")return(function(i,s){const A=[1/0,1/0,-1/0,-1/0],d=[1/0,1/0,-1/0,-1/0],_=i.canonicalID();if(s.type==="Polygon"){const b=wl(s.coordinates,d,_),M=Ws(i.geometry(),A,d,_);if(!Jn(A,d))return!1;for(const I of M)if(!pa(I,b))return!1}if(s.type==="MultiPolygon"){const b=Hs(s.coordinates,d,_),M=Ws(i.geometry(),A,d,_);if(!Jn(A,d))return!1;for(const I of M)if(!Rn(I,b))return!1}return!0})(e,this.geometries);if(e.geometryType()==="LineString")return(function(i,s){const A=[1/0,1/0,-1/0,-1/0],d=[1/0,1/0,-1/0,-1/0],_=i.canonicalID();if(s.type==="Polygon"){const b=wl(s.coordinates,d,_),M=$i(i.geometry(),A,d,_);if(!Jn(A,d))return!1;for(const I of M)if(!$o(I,b))return!1}if(s.type==="MultiPolygon"){const b=Hs(s.coordinates,d,_),M=$i(i.geometry(),A,d,_);if(!Jn(A,d))return!1;for(const I of M)if(!Zl(I,b))return!1}return!0})(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let Tl=class{constructor(r=[],e=(i,s)=>i<s?-1:i>s?1:0){if(this.data=r,this.length=this.data.length,this.compare=e,this.length>0)for(let i=(this.length>>1)-1;i>=0;i--)this._down(i)}push(r){this.data.push(r),this._up(this.length++)}pop(){if(this.length===0)return;const r=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),r}peek(){return this.data[0]}_up(r){const{data:e,compare:i}=this,s=e[r];for(;r>0;){const A=r-1>>1,d=e[A];if(i(s,d)>=0)break;e[r]=d,r=A}e[r]=s}_down(r){const{data:e,compare:i}=this,s=this.length>>1,A=e[r];for(;r<s;){let d=1+(r<<1);const _=d+1;if(_<this.length&&i(e[_],e[d])<0&&(d=_),i(e[d],A)>=0)break;e[r]=e[d],r=d}e[r]=A}};function Bs(r,e,i=0,s=r.length-1,A=Ul){for(;s>i;){if(s-i>600){const M=s-i+1,I=e-i+1,k=Math.log(M),F=.5*Math.exp(2*k/3),V=.5*Math.sqrt(k*F*(M-F)/M)*(I-M/2<0?-1:1);Bs(r,e,Math.max(i,Math.floor(e-I*F/M+V)),Math.min(s,Math.floor(e+(M-I)*F/M+V)),A)}const d=r[e];let _=i,b=s;for(uo(r,i,e),A(r[s],d)>0&&uo(r,i,s);_<b;){for(uo(r,_,b),_++,b--;A(r[_],d)<0;)_++;for(;A(r[b],d)>0;)b--}A(r[i],d)===0?uo(r,i,b):(b++,uo(r,b,s)),b<=e&&(i=b+1),e<=b&&(s=b-1)}}function uo(r,e,i){const s=r[e];r[e]=r[i],r[i]=s}function Ul(r,e){return r<e?-1:r>e?1:0}function ma(r,e){if(r.length<=1)return[r];const i=[];let s,A;for(const d of r){const _=Ir(d);_!==0&&(d.area=Math.abs(_),A===void 0&&(A=_<0),A===_<0?(s&&i.push(s),s=[d]):s.push(d))}if(s&&i.push(s),e>1)for(let d=0;d<i.length;d++)i[d].length<=e||(Bs(i[d],e,1,i[d].length-1,cu),i[d]=i[d].slice(0,e));return i}function cu(r,e){return e.area-r.area}function Ir(r){let e=0;for(let i,s,A=0,d=r.length,_=d-1;A<d;_=A++)i=r[A],s=r[_],e+=(s.x-i.x)*(i.y+s.y);return e}const Ka=1/298.257223563,yn=Ka*(2-Ka),Gl=Math.PI/180;class As{constructor(e){const i=6378.137*Gl*1e3,s=Math.cos(e*Gl),A=1/(1-yn*(1-s*s)),d=Math.sqrt(A);this.kx=i*d*s,this.ky=i*d*A*(1-yn)}distance(e,i){const s=this.wrap(e[0]-i[0])*this.kx,A=(e[1]-i[1])*this.ky;return Math.sqrt(s*s+A*A)}pointOnLine(e,i){let s,A,d,_,b=1/0;for(let M=0;M<e.length-1;M++){let I=e[M][0],k=e[M][1],F=this.wrap(e[M+1][0]-I)*this.kx,V=(e[M+1][1]-k)*this.ky,j=0;F===0&&V===0||(j=(this.wrap(i[0]-I)*this.kx*F+(i[1]-k)*this.ky*V)/(F*F+V*V),j>1?(I=e[M+1][0],k=e[M+1][1]):j>0&&(I+=F/this.kx*j,k+=V/this.ky*j)),F=this.wrap(i[0]-I)*this.kx,V=(i[1]-k)*this.ky;const H=F*F+V*V;H<b&&(b=H,s=I,A=k,d=M,_=j)}return{point:[s,A],index:d,t:Math.max(0,Math.min(1,_))}}wrap(e){for(;e<-180;)e+=360;for(;e>180;)e-=360;return e}}function Ba(r,e){return e[0]-r[0]}function vn(r){return r[1]-r[0]+1}function Fn(r,e){return r[1]>=r[0]&&r[1]<e}function ho(r,e){if(r[0]>r[1])return[null,null];const i=vn(r);if(e){if(i===2)return[r,null];const A=Math.floor(i/2);return[[r[0],r[0]+A],[r[0]+A,r[1]]]}if(i===1)return[r,null];const s=Math.floor(i/2)-1;return[[r[0],r[0]+s],[r[0]+s+1,r[1]]]}function $s(r,e){if(!Fn(e,r.length))return[1/0,1/0,-1/0,-1/0];const i=[1/0,1/0,-1/0,-1/0];for(let s=e[0];s<=e[1];++s)So(i,r[s]);return i}function xs(r){const e=[1/0,1/0,-1/0,-1/0];for(const i of r)for(const s of i)So(e,s);return e}function fs(r){return r[0]!==-1/0&&r[1]!==-1/0&&r[2]!==1/0&&r[3]!==1/0}function Yo(r,e,i){if(!fs(r)||!fs(e))return NaN;let s=0,A=0;return r[2]<e[0]&&(s=e[0]-r[2]),r[0]>e[2]&&(s=r[0]-e[2]),r[1]>e[3]&&(A=r[1]-e[3]),r[3]<e[1]&&(A=e[1]-r[3]),i.distance([0,0],[s,A])}function Ys(r,e,i){const s=i.pointOnLine(e,r);return i.distance(r,s.point)}function Ja(r,e,i,s,A){const d=Math.min(Ys(r,[i,s],A),Ys(e,[i,s],A)),_=Math.min(Ys(i,[r,e],A),Ys(s,[r,e],A));return Math.min(d,_)}function Pl(r,e,i,s,A){if(!Fn(e,r.length)||!Fn(s,i.length))return 1/0;let d=1/0;for(let _=e[0];_<e[1];++_){const b=r[_],M=r[_+1];for(let I=s[0];I<s[1];++I){const k=i[I],F=i[I+1];if(da(b,M,k,F))return 0;d=Math.min(d,Ja(b,M,k,F,A))}}return d}function Ra(r,e,i,s,A){if(!Fn(e,r.length)||!Fn(s,i.length))return NaN;let d=1/0;for(let _=e[0];_<=e[1];++_)for(let b=s[0];b<=s[1];++b)if(d=Math.min(d,A.distance(r[_],i[b])),d===0)return d;return d}function Au(r,e,i){if(pa(r,e,!0))return 0;let s=1/0;for(const A of e){const d=A[0],_=A[A.length-1];if(d!==_&&(s=Math.min(s,Ys(r,[_,d],i)),s===0))return s;const b=i.pointOnLine(A,r);if(s=Math.min(s,i.distance(r,b.point)),s===0)return s}return s}function el(r,e,i,s){if(!Fn(e,r.length))return NaN;for(let d=e[0];d<=e[1];++d)if(pa(r[d],i,!0))return 0;let A=1/0;for(let d=e[0];d<e[1];++d){const _=r[d],b=r[d+1];for(const M of i)for(let I=0,k=M.length,F=k-1;I<k;F=I++){const V=M[F],j=M[I];if(da(_,b,V,j))return 0;A=Math.min(A,Ja(_,b,V,j,s))}}return A}function Ml(r,e){for(const i of r)for(const s of i)if(pa(s,e,!0))return!0;return!1}function tl(r,e,i,s=1/0){const A=xs(r),d=xs(e);if(s!==1/0&&Yo(A,d,i)>=s)return s;if(Jn(A,d)){if(Ml(r,e))return 0}else if(Ml(e,r))return 0;let _=1/0;for(const b of r)for(let M=0,I=b.length,k=I-1;M<I;k=M++){const F=b[k],V=b[M];for(const j of e)for(let H=0,Q=j.length,Y=Q-1;H<Q;Y=H++){const re=j[Y],ge=j[H];if(da(F,V,re,ge))return 0;_=Math.min(_,Ja(F,V,re,ge,i))}}return _}function Ii(r,e,i,s,A,d){if(!d)return;const _=Yo($s(s,d),A,i);_<e&&r.push([_,d,[0,0]])}function sn(r,e,i,s,A,d,_){if(!d||!_)return;const b=Yo($s(s,d),$s(A,_),i);b<e&&r.push([b,d,_])}function $r(r,e,i,s,A=1/0){let d=Math.min(s.distance(r[0],i[0][0]),A);if(d===0)return d;const _=new Tl([[0,[0,r.length-1],[0,0]]],Ba),b=xs(i);for(;_.length>0;){const M=_.pop();if(M[0]>=d)continue;const I=M[1],k=e?50:100;if(vn(I)<=k){if(!Fn(I,r.length))return NaN;if(e){const F=el(r,I,i,s);if(isNaN(F)||F===0)return F;d=Math.min(d,F)}else for(let F=I[0];F<=I[1];++F){const V=Au(r[F],i,s);if(d=Math.min(d,V),d===0)return 0}}else{const F=ho(I,e);Ii(_,d,s,r,b,F[0]),Ii(_,d,s,r,b,F[1])}}return d}function il(r,e,i,s,A,d=1/0){let _=Math.min(d,A.distance(r[0],i[0]));if(_===0)return _;const b=new Tl([[0,[0,r.length-1],[0,i.length-1]]],Ba);for(;b.length>0;){const M=b.pop();if(M[0]>=_)continue;const I=M[1],k=M[2],F=e?50:100,V=s?50:100;if(vn(I)<=F&&vn(k)<=V){if(!Fn(I,r.length)&&Fn(k,i.length))return NaN;let j;if(e&&s)j=Pl(r,I,i,k,A),_=Math.min(_,j);else if(e&&!s){const H=r.slice(I[0],I[1]+1);for(let Q=k[0];Q<=k[1];++Q)if(j=Ys(i[Q],H,A),_=Math.min(_,j),_===0)return _}else if(!e&&s){const H=i.slice(k[0],k[1]+1);for(let Q=I[0];Q<=I[1];++Q)if(j=Ys(r[Q],H,A),_=Math.min(_,j),_===0)return _}else j=Ra(r,I,i,k,A),_=Math.min(_,j)}else{const j=ho(I,e),H=ho(k,s);sn(b,_,A,r,i,j[0],H[0]),sn(b,_,A,r,i,j[0],H[1]),sn(b,_,A,r,i,j[1],H[0]),sn(b,_,A,r,i,j[1],H[1])}}return _}function Xs(r){return r.type==="MultiPolygon"?r.coordinates.map((e=>({type:"Polygon",coordinates:e}))):r.type==="MultiLineString"?r.coordinates.map((e=>({type:"LineString",coordinates:e}))):r.type==="MultiPoint"?r.coordinates.map((e=>({type:"Point",coordinates:e}))):[r]}class Xo{constructor(e,i){this.type=ut,this.geojson=e,this.geometries=i}static parse(e,i){if(e.length!==2)return i.error(`'distance' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Qn(e[1])){const s=e[1];if(s.type==="FeatureCollection")return new Xo(s,s.features.map((A=>Xs(A.geometry))).flat());if(s.type==="Feature")return new Xo(s,Xs(s.geometry));if("type"in s&&"coordinates"in s)return new Xo(s,Xs(s))}return i.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(e.geometry()!=null&&e.canonicalID()!=null){if(e.geometryType()==="Point")return(function(i,s){const A=i.geometry(),d=A.flat().map((M=>Eo([M.x,M.y],i.canonical)));if(A.length===0)return NaN;const _=new As(d[0][1]);let b=1/0;for(const M of s){switch(M.type){case"Point":b=Math.min(b,il(d,!1,[M.coordinates],!1,_,b));break;case"LineString":b=Math.min(b,il(d,!1,M.coordinates,!0,_,b));break;case"Polygon":b=Math.min(b,$r(d,!1,M.coordinates,_,b))}if(b===0)return b}return b})(e,this.geometries);if(e.geometryType()==="LineString")return(function(i,s){const A=i.geometry(),d=A.flat().map((M=>Eo([M.x,M.y],i.canonical)));if(A.length===0)return NaN;const _=new As(d[0][1]);let b=1/0;for(const M of s){switch(M.type){case"Point":b=Math.min(b,il(d,!0,[M.coordinates],!1,_,b));break;case"LineString":b=Math.min(b,il(d,!0,M.coordinates,!0,_,b));break;case"Polygon":b=Math.min(b,$r(d,!0,M.coordinates,_,b))}if(b===0)return b}return b})(e,this.geometries);if(e.geometryType()==="Polygon")return(function(i,s){const A=i.geometry();if(A.length===0||A[0].length===0)return NaN;const d=ma(A,0).map((M=>M.map((I=>I.map((k=>Eo([k.x,k.y],i.canonical))))))),_=new As(d[0][0][0][1]);let b=1/0;for(const M of s)for(const I of d){switch(M.type){case"Point":b=Math.min(b,$r([M.coordinates],!1,I,_,b));break;case"LineString":b=Math.min(b,$r(M.coordinates,!0,I,_,b));break;case"Polygon":b=Math.min(b,tl(I,M.coordinates,_,b))}if(b===0)return b}return b})(e,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}class _a{constructor(e){this.type=ni,this.key=e}static parse(e,i){if(e.length!==2)return i.error(`Expected 1 argument, but found ${e.length-1} instead.`);const s=e[1];return s==null?i.error("Global state property must be defined."):typeof s!="string"?i.error(`Global state property must be string, but found ${typeof e[1]} instead.`):new _a(s)}evaluate(e){var i;const s=(i=e.globals)===null||i===void 0?void 0:i.globalState;return s&&Object.keys(s).length!==0?so(s,this.key):null}eachChild(){}outputDefined(){return!1}}const ga={"==":jl,"!=":vl,">":uu,"<":Ya,">=":za,"<=":Mo,array:Yn,at:wi,boolean:Yn,case:Da,coalesce:ao,collator:lo,format:La,image:qs,in:ri,"index-of":Aa,interpolate:xr,"interpolate-hcl":xr,"interpolate-lab":xr,length:An,let:bi,literal:gs,match:Ci,number:Yn,"number-format":vs,object:Yn,slice:Xn,step:Kn,string:Yn,"to-boolean":Ls,"to-color":Ls,"to-number":Ls,"to-string":Ls,var:nn,within:Qs,distance:Xo,"global-state":_a};class fn{constructor(e,i,s,A){this.name=e,this.type=i,this._evaluate=s,this.args=A}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(e,i){const s=e[0],A=fn.definitions[s];if(!A)return i.error(`Unknown expression "${s}". If you wanted a literal array, use ["literal", [...]].`,0);const d=Array.isArray(A)?A[0]:A.type,_=Array.isArray(A)?[[A[1],A[2]]]:A.overloads,b=_.filter((([I])=>!Array.isArray(I)||I.length===e.length-1));let M=null;for(const[I,k]of b){M=new hi(i.registry,Fa,i.path,null,i.scope);const F=[];let V=!1;for(let j=1;j<e.length;j++){const H=e[j],Q=Array.isArray(I)?I[j-1]:I.type,Y=M.parse(H,1+F.length,Q);if(!Y){V=!0;break}F.push(Y)}if(!V)if(Array.isArray(I)&&I.length!==F.length)M.error(`Expected ${I.length} arguments, but found ${F.length} instead.`);else{for(let j=0;j<F.length;j++){const H=Array.isArray(I)?I[j]:I.type,Q=F[j];M.concat(j+1).checkSubtype(H,Q.type)}if(M.errors.length===0)return new fn(s,d,k,F)}}if(b.length===1)i.errors.push(...M.errors);else{const I=(b.length?b:_).map((([F])=>{return V=F,Array.isArray(V)?`(${V.map(Ft).join(", ")})`:`(${Ft(V.type)}...)`;var V})).join(" | "),k=[];for(let F=1;F<e.length;F++){const V=i.parse(e[F],1+k.length);if(!V)return null;k.push(Ft(V.type))}i.error(`Expected arguments of type ${I}, but found (${k.join(", ")}) instead.`)}return null}static register(e,i){fn.definitions=i;for(const s in i)e[s]=fn}}function ql(r,[e,i,s,A]){e=e.evaluate(r),i=i.evaluate(r),s=s.evaluate(r);const d=A?A.evaluate(r):1,_=Us(e,i,s,d);if(_)throw new Ki(_);return new oi(e/255,i/255,s/255,d,!1)}function Ko(r,e){return r in e}function rl(r,e){const i=e[r];return i===void 0?null:i}function Rs(r){return{type:r}}function Fa(r){if(r instanceof nn)return Fa(r.boundExpression);if(r instanceof fn&&r.name==="error"||r instanceof lo||r instanceof Qs||r instanceof Xo||r instanceof _a)return!1;const e=r instanceof Ls||r instanceof Yn;let i=!0;return r.eachChild((s=>{i=e?i&&Fa(s):i&&s instanceof gs})),!!i&&es(r)&&Oa(r,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"])}function es(r){if(r instanceof fn&&(r.name==="get"&&r.args.length===1||r.name==="feature-state"||r.name==="has"&&r.args.length===1||r.name==="properties"||r.name==="geometry-type"||r.name==="id"||/^filter-/.test(r.name))||r instanceof Qs||r instanceof Xo)return!1;let e=!0;return r.eachChild((i=>{e&&!es(i)&&(e=!1)})),e}function ya(r){if(r instanceof fn&&r.name==="feature-state")return!1;let e=!0;return r.eachChild((i=>{e&&!ya(i)&&(e=!1)})),e}function Oa(r,e){if(r instanceof fn&&e.indexOf(r.name)>=0)return!1;let i=!0;return r.eachChild((s=>{i&&!Oa(s,e)&&(i=!1)})),i}function va(r){return{result:"success",value:r}}function xa(r){return{result:"error",value:r}}function co(r){return r["property-type"]==="data-driven"||r["property-type"]==="cross-faded-data-driven"}function ba(r){return!!r.expression&&r.expression.parameters.indexOf("zoom")>-1}function nl(r){return!!r.expression&&r.expression.interpolated}function gi(r){return r instanceof Number?"number":r instanceof String?"string":r instanceof Boolean?"boolean":Array.isArray(r)?"array":r===null?"null":typeof r}function sl(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)&&Si(r)===jr}function El(r){return r}function Fs(r,e){const i=r.stops&&typeof r.stops[0][0]=="object",s=i||!(i||r.property!==void 0),A=r.type||(nl(e)?"exponential":"interval"),d=(function(k){switch(k.type){case"color":return oi.parse;case"padding":return Ht.parse;case"numberArray":return Li.parse;case"colorArray":return Dt.parse;default:return null}})(e);if(d&&((r=X({},r)).stops&&(r.stops=r.stops.map((k=>[k[0],d(k[1])]))),r.default=d(r.default?r.default:e.default)),r.colorSpace&&(_=r.colorSpace)!=="rgb"&&_!=="hcl"&&_!=="lab")throw new Error(`Unknown color space: "${r.colorSpace}"`);var _;const b=(function(k){switch(k){case"exponential":return Ql;case"interval":return Wl;case"categorical":return Hl;case"identity":return $l;default:throw new Error(`Unknown function type "${k}"`)}})(A);let M,I;if(A==="categorical"){M=Object.create(null);for(const k of r.stops)M[k[0]]=k[1];I=typeof r.stops[0][0]}if(i){const k={},F=[];for(let H=0;H<r.stops.length;H++){const Q=r.stops[H],Y=Q[0].zoom;k[Y]===void 0&&(k[Y]={zoom:Y,type:r.type,property:r.property,default:r.default,stops:[]},F.push(Y)),k[Y].stops.push([Q[0].value,Q[1]])}const V=[];for(const H of F)V.push([k[H].zoom,Fs(k[H],e)]);const j={name:"linear"};return{kind:"composite",interpolationType:j,interpolationFactor:xr.interpolationFactor.bind(void 0,j),zoomStops:V.map((H=>H[0])),evaluate:({zoom:H},Q)=>Ql({stops:V,base:r.base},e,H).evaluate(H,Q)}}if(s){const k=A==="exponential"?{name:"exponential",base:r.base!==void 0?r.base:1}:null;return{kind:"camera",interpolationType:k,interpolationFactor:xr.interpolationFactor.bind(void 0,k),zoomStops:r.stops.map((F=>F[0])),evaluate:({zoom:F})=>b(r,e,F,M,I)}}return{kind:"source",evaluate(k,F){const V=F&&F.properties?F.properties[r.property]:void 0;return V===void 0?Jo(r.default,e.default):b(r,e,V,M,I)}}}function Jo(r,e,i){return r!==void 0?r:e!==void 0?e:i!==void 0?i:void 0}function Hl(r,e,i,s,A){return Jo(typeof i===A?s[i]:void 0,r.default,e.default)}function Wl(r,e,i){if(gi(i)!=="number")return Jo(r.default,e.default);const s=r.stops.length;if(s===1||i<=r.stops[0][0])return r.stops[0][1];if(i>=r.stops[s-1][0])return r.stops[s-1][1];const A=oo(r.stops.map((d=>d[0])),i);return r.stops[A][1]}function Ql(r,e,i){const s=r.base!==void 0?r.base:1;if(gi(i)!=="number")return Jo(r.default,e.default);const A=r.stops.length;if(A===1||i<=r.stops[0][0])return r.stops[0][1];if(i>=r.stops[A-1][0])return r.stops[A-1][1];const d=oo(r.stops.map((k=>k[0])),i),_=(function(k,F,V,j){const H=j-V,Q=k-V;return H===0?0:F===1?Q/H:(Math.pow(F,Q)-1)/(Math.pow(F,H)-1)})(i,s,r.stops[d][0],r.stops[d+1][0]),b=r.stops[d][1],M=r.stops[d+1][1],I=ir[e.type]||El;return typeof b.evaluate=="function"?{evaluate(...k){const F=b.evaluate.apply(void 0,k),V=M.evaluate.apply(void 0,k);if(F!==void 0&&V!==void 0)return I(F,V,_,r.colorSpace)}}:I(b,M,_,r.colorSpace)}function $l(r,e,i){switch(e.type){case"color":i=oi.parse(i);break;case"formatted":i=Wn.fromString(i.toString());break;case"resolvedImage":i=gn.fromString(i.toString());break;case"padding":i=Ht.parse(i);break;case"colorArray":i=Dt.parse(i);break;case"numberArray":i=Li.parse(i);break;default:gi(i)===e.type||e.type==="enum"&&e.values[i]||(i=void 0)}return Jo(i,r.default,e.default)}fn.register(ga,{error:[{kind:"error"},[zt],(r,[e])=>{throw new Ki(e.evaluate(r))}],typeof:[zt,[ni],(r,[e])=>Ft(Si(e.evaluate(r)))],"to-rgba":[vr(ut,4),[fi],(r,[e])=>{const[i,s,A,d]=e.evaluate(r).rgb;return[255*i,255*s,255*A,d]}],rgb:[fi,[ut,ut,ut],ql],rgba:[fi,[ut,ut,ut,ut],ql],has:{type:$t,overloads:[[[zt],(r,[e])=>Ko(e.evaluate(r),r.properties())],[[zt,jr],(r,[e,i])=>Ko(e.evaluate(r),i.evaluate(r))]]},get:{type:ni,overloads:[[[zt],(r,[e])=>rl(e.evaluate(r),r.properties())],[[zt,jr],(r,[e,i])=>rl(e.evaluate(r),i.evaluate(r))]]},"feature-state":[ni,[zt],(r,[e])=>rl(e.evaluate(r),r.featureState||{})],properties:[jr,[],r=>r.properties()],"geometry-type":[zt,[],r=>r.geometryType()],id:[ni,[],r=>r.id()],zoom:[ut,[],r=>r.globals.zoom],"heatmap-density":[ut,[],r=>r.globals.heatmapDensity||0],elevation:[ut,[],r=>r.globals.elevation||0],"line-progress":[ut,[],r=>r.globals.lineProgress||0],accumulated:[ni,[],r=>r.globals.accumulated===void 0?null:r.globals.accumulated],"+":[ut,Rs(ut),(r,e)=>{let i=0;for(const s of e)i+=s.evaluate(r);return i}],"*":[ut,Rs(ut),(r,e)=>{let i=1;for(const s of e)i*=s.evaluate(r);return i}],"-":{type:ut,overloads:[[[ut,ut],(r,[e,i])=>e.evaluate(r)-i.evaluate(r)],[[ut],(r,[e])=>-e.evaluate(r)]]},"/":[ut,[ut,ut],(r,[e,i])=>e.evaluate(r)/i.evaluate(r)],"%":[ut,[ut,ut],(r,[e,i])=>e.evaluate(r)%i.evaluate(r)],ln2:[ut,[],()=>Math.LN2],pi:[ut,[],()=>Math.PI],e:[ut,[],()=>Math.E],"^":[ut,[ut,ut],(r,[e,i])=>Math.pow(e.evaluate(r),i.evaluate(r))],sqrt:[ut,[ut],(r,[e])=>Math.sqrt(e.evaluate(r))],log10:[ut,[ut],(r,[e])=>Math.log(e.evaluate(r))/Math.LN10],ln:[ut,[ut],(r,[e])=>Math.log(e.evaluate(r))],log2:[ut,[ut],(r,[e])=>Math.log(e.evaluate(r))/Math.LN2],sin:[ut,[ut],(r,[e])=>Math.sin(e.evaluate(r))],cos:[ut,[ut],(r,[e])=>Math.cos(e.evaluate(r))],tan:[ut,[ut],(r,[e])=>Math.tan(e.evaluate(r))],asin:[ut,[ut],(r,[e])=>Math.asin(e.evaluate(r))],acos:[ut,[ut],(r,[e])=>Math.acos(e.evaluate(r))],atan:[ut,[ut],(r,[e])=>Math.atan(e.evaluate(r))],min:[ut,Rs(ut),(r,e)=>Math.min(...e.map((i=>i.evaluate(r))))],max:[ut,Rs(ut),(r,e)=>Math.max(...e.map((i=>i.evaluate(r))))],abs:[ut,[ut],(r,[e])=>Math.abs(e.evaluate(r))],round:[ut,[ut],(r,[e])=>{const i=e.evaluate(r);return i<0?-Math.round(-i):Math.round(i)}],floor:[ut,[ut],(r,[e])=>Math.floor(e.evaluate(r))],ceil:[ut,[ut],(r,[e])=>Math.ceil(e.evaluate(r))],"filter-==":[$t,[zt,ni],(r,[e,i])=>r.properties()[e.value]===i.value],"filter-id-==":[$t,[ni],(r,[e])=>r.id()===e.value],"filter-type-==":[$t,[zt],(r,[e])=>r.geometryType()===e.value],"filter-<":[$t,[zt,ni],(r,[e,i])=>{const s=r.properties()[e.value],A=i.value;return typeof s==typeof A&&s<A}],"filter-id-<":[$t,[ni],(r,[e])=>{const i=r.id(),s=e.value;return typeof i==typeof s&&i<s}],"filter->":[$t,[zt,ni],(r,[e,i])=>{const s=r.properties()[e.value],A=i.value;return typeof s==typeof A&&s>A}],"filter-id->":[$t,[ni],(r,[e])=>{const i=r.id(),s=e.value;return typeof i==typeof s&&i>s}],"filter-<=":[$t,[zt,ni],(r,[e,i])=>{const s=r.properties()[e.value],A=i.value;return typeof s==typeof A&&s<=A}],"filter-id-<=":[$t,[ni],(r,[e])=>{const i=r.id(),s=e.value;return typeof i==typeof s&&i<=s}],"filter->=":[$t,[zt,ni],(r,[e,i])=>{const s=r.properties()[e.value],A=i.value;return typeof s==typeof A&&s>=A}],"filter-id->=":[$t,[ni],(r,[e])=>{const i=r.id(),s=e.value;return typeof i==typeof s&&i>=s}],"filter-has":[$t,[ni],(r,[e])=>e.value in r.properties()],"filter-has-id":[$t,[],r=>r.id()!==null&&r.id()!==void 0],"filter-type-in":[$t,[vr(zt)],(r,[e])=>e.value.indexOf(r.geometryType())>=0],"filter-id-in":[$t,[vr(ni)],(r,[e])=>e.value.indexOf(r.id())>=0],"filter-in-small":[$t,[zt,vr(ni)],(r,[e,i])=>i.value.indexOf(r.properties()[e.value])>=0],"filter-in-large":[$t,[zt,vr(ni)],(r,[e,i])=>(function(s,A,d,_){for(;d<=_;){const b=d+_>>1;if(A[b]===s)return!0;A[b]>s?_=b-1:d=b+1}return!1})(r.properties()[e.value],i.value,0,i.value.length-1)],all:{type:$t,overloads:[[[$t,$t],(r,[e,i])=>e.evaluate(r)&&i.evaluate(r)],[Rs($t),(r,e)=>{for(const i of e)if(!i.evaluate(r))return!1;return!0}]]},any:{type:$t,overloads:[[[$t,$t],(r,[e,i])=>e.evaluate(r)||i.evaluate(r)],[Rs($t),(r,e)=>{for(const i of e)if(i.evaluate(r))return!0;return!1}]]},"!":[$t,[$t],(r,[e])=>!e.evaluate(r)],"is-supported-script":[$t,[zt],(r,[e])=>{const i=r.globals&&r.globals.isSupportedScript;return!i||i(e.evaluate(r))}],upcase:[zt,[zt],(r,[e])=>e.evaluate(r).toUpperCase()],downcase:[zt,[zt],(r,[e])=>e.evaluate(r).toLowerCase()],concat:[zt,Rs(ni),(r,e)=>e.map((i=>$n(i.evaluate(r)))).join("")],"resolved-locale":[zt,[Ea],(r,[e])=>e.evaluate(r).resolvedLocale()]});class ol{constructor(e,i,s){this.expression=e,this._warningHistory={},this._evaluator=new Qr,this._defaultValue=i?(function(A){if(A.type==="color"&&sl(A.default))return new oi(0,0,0,0);switch(A.type){case"color":return oi.parse(A.default)||null;case"padding":return Ht.parse(A.default)||null;case"numberArray":return Li.parse(A.default)||null;case"colorArray":return Dt.parse(A.default)||null;case"variableAnchorOffsetCollection":return cn.parse(A.default)||null;case"projectionDefinition":return Lr.parse(A.default)||null;default:return A.default===void 0?null:A.default}})(i):null,this._enumValues=i&&i.type==="enum"?i.values:null,this._globalState=s}evaluateWithoutErrorHandling(e,i,s,A,d,_){return this._globalState&&(e=Ze(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=i,this._evaluator.featureState=s,this._evaluator.canonical=A,this._evaluator.availableImages=d||null,this._evaluator.formattedSection=_,this.expression.evaluate(this._evaluator)}evaluate(e,i,s,A,d,_){this._globalState&&(e=Ze(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=i||null,this._evaluator.featureState=s||null,this._evaluator.canonical=A,this._evaluator.availableImages=d||null,this._evaluator.formattedSection=_||null;try{const b=this.expression.evaluate(this._evaluator);if(b==null||typeof b=="number"&&b!=b)return this._defaultValue;if(this._enumValues&&!(b in this._enumValues))throw new Ki(`Expected value to be one of ${Object.keys(this._enumValues).map((M=>JSON.stringify(M))).join(", ")}, but found ${JSON.stringify(b)} instead.`);return b}catch(b){return this._warningHistory[b.message]||(this._warningHistory[b.message]=!0,typeof console<"u"&&console.warn(b.message)),this._defaultValue}}}function ds(r){return Array.isArray(r)&&r.length>0&&typeof r[0]=="string"&&r[0]in ga}function u(r,e,i){const s=new hi(ga,Fa,[],e?(function(d){const _={color:fi,string:zt,number:ut,enum:zt,boolean:$t,formatted:xo,padding:kn,numberArray:Hn,colorArray:qn,projectionDefinition:di,resolvedImage:bo,variableAnchorOffsetCollection:Sa};return d.type==="array"?vr(_[d.value]||ni,d.length):_[d.type]})(e):void 0),A=s.parse(r,void 0,void 0,void 0,e&&e.type==="string"?{typeAnnotation:"coerce"}:void 0);return A?va(new ol(A,e,i)):xa(s.errors)}class v{constructor(e,i,s){this.kind=e,this._styleExpression=i,this.isStateDependent=e!=="constant"&&!ya(i.expression),this.globalStateRefs=Ee(i.expression),this._globalState=s}evaluateWithoutErrorHandling(e,i,s,A,d,_){return this._globalState&&(e=Ze(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,i,s,A,d,_)}evaluate(e,i,s,A,d,_){return this._globalState&&(e=Ze(e,this._globalState)),this._styleExpression.evaluate(e,i,s,A,d,_)}}class E{constructor(e,i,s,A,d){this.kind=e,this.zoomStops=s,this._styleExpression=i,this.isStateDependent=e!=="camera"&&!ya(i.expression),this.globalStateRefs=Ee(i.expression),this.interpolationType=A,this._globalState=d}evaluateWithoutErrorHandling(e,i,s,A,d,_){return this._globalState&&(e=Ze(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,i,s,A,d,_)}evaluate(e,i,s,A,d,_){return this._globalState&&(e=Ze(e,this._globalState)),this._styleExpression.evaluate(e,i,s,A,d,_)}interpolationFactor(e,i,s){return this.interpolationType?xr.interpolationFactor(this.interpolationType,e,i,s):0}}function R(r,e,i){const s=u(r,e,i);if(s.result==="error")return s;const A=s.value.expression,d=es(A);if(!d&&!co(e))return xa([new ii("","data expressions not supported")]);const _=Oa(A,["zoom"]);if(!_&&!ba(e))return xa([new ii("","zoom expressions not supported")]);const b=ne(A);return b||_?b instanceof ii?xa([b]):b instanceof xr&&!nl(e)?xa([new ii("",'"interpolate" expressions cannot be used with this property')]):va(b?new E(d?"camera":"composite",s.value,b.labels,b instanceof xr?b.interpolation:void 0,i):new v(d?"constant":"source",s.value,i)):xa([new ii("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class q{constructor(e,i){this._parameters=e,this._specification=i,X(this,Fs(this._parameters,this._specification))}static deserialize(e){return new q(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function ne(r){let e=null;if(r instanceof bi)e=ne(r.result);else if(r instanceof ao){for(const i of r.args)if(e=ne(i),e)break}else(r instanceof Kn||r instanceof xr)&&r.input instanceof fn&&r.input.name==="zoom"&&(e=r);return e instanceof ii||r.eachChild((i=>{const s=ne(i);s instanceof ii?e=s:!e&&s?e=new ii("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&s&&e!==s&&(e=new ii("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}function Ee(r,e=new Set){return r instanceof _a&&e.add(r.key),r.eachChild((i=>{Ee(i,e)})),e}function Ze(r,e){const{zoom:i,heatmapDensity:s,elevation:A,lineProgress:d,isSupportedScript:_,accumulated:b}=r??{};return{zoom:i,heatmapDensity:s,elevation:A,lineProgress:d,isSupportedScript:_,accumulated:b,globalState:e}}function tt(r){if(r===!0||r===!1)return!0;if(!Array.isArray(r)||r.length===0)return!1;switch(r[0]){case"has":return r.length>=2&&r[1]!=="$id"&&r[1]!=="$type";case"in":return r.length>=3&&(typeof r[1]!="string"||Array.isArray(r[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return r.length!==3||Array.isArray(r[1])||Array.isArray(r[2]);case"any":case"all":for(const e of r.slice(1))if(!tt(e)&&typeof e!="boolean")return!1;return!0;default:return!0}}const gt={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function Rt(r,e){if(r==null)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};tt(r)||(r=Zr(r));const i=u(r,gt,e);if(i.result==="error")throw new Error(i.value.map((s=>`${s.key}: ${s.message}`)).join(", "));return{filter:(s,A,d)=>i.value.evaluate(s,A,{},d),needGeometry:Ti(r),getGlobalStateRefs:()=>Ee(i.value.expression)}}function Jt(r,e){return r<e?-1:r>e?1:0}function Ti(r){if(!Array.isArray(r))return!1;if(r[0]==="within"||r[0]==="distance")return!0;for(let e=1;e<r.length;e++)if(Ti(r[e]))return!0;return!1}function Zr(r){if(!r)return!0;const e=r[0];return r.length<=1?e!=="any":e==="=="?Br(r[1],r[2],"=="):e==="!="?Ks(Br(r[1],r[2],"==")):e==="<"||e===">"||e==="<="||e===">="?Br(r[1],r[2],e):e==="any"?(i=r.slice(1),["any"].concat(i.map(Zr))):e==="all"?["all"].concat(r.slice(1).map(Zr)):e==="none"?["all"].concat(r.slice(1).map(Zr).map(Ks)):e==="in"?ps(r[1],r.slice(2)):e==="!in"?Ks(ps(r[1],r.slice(2))):e==="has"?On(r[1]):e!=="!has"||Ks(On(r[1]));var i}function Br(r,e,i){switch(r){case"$type":return[`filter-type-${i}`,e];case"$id":return[`filter-id-${i}`,e];default:return[`filter-${i}`,r,e]}}function ps(r,e){if(e.length===0)return!1;switch(r){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((i=>typeof i!=typeof e[0]))?["filter-in-large",r,["literal",e.sort(Jt)]]:["filter-in-small",r,["literal",e]]}}function On(r){switch(r){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",r]}}function Ks(r){return["!",r]}function al(r){const e=typeof r;if(e==="number"||e==="boolean"||e==="string"||r==null)return JSON.stringify(r);if(Array.isArray(r)){let A="[";for(const d of r)A+=`${al(d)},`;return`${A}]`}const i=Object.keys(r).sort();let s="{";for(let A=0;A<i.length;A++)s+=`${JSON.stringify(i[A])}:${al(r[i[A]])},`;return`${s}}`}function Yl(r){let e="";for(const i of Hi)e+=`/${al(r[i])}`;return e}function Xl(r){const e=r.value;return e?[new o(r.key,e,"constants have been deprecated as of v8")]:[]}function br(r){return r instanceof Number||r instanceof String||r instanceof Boolean?r.valueOf():r}function ea(r){if(Array.isArray(r))return r.map(ea);if(r instanceof Object&&!(r instanceof Number||r instanceof String||r instanceof Boolean)){const e={};for(const i in r)e[i]=ea(r[i]);return e}return br(r)}function Nn(r){const e=r.key,i=r.value,s=r.valueSpec||{},A=r.objectElementValidators||{},d=r.style,_=r.styleSpec,b=r.validateSpec;let M=[];const I=gi(i);if(I!=="object")return[new o(e,i,`object expected, ${I} found`)];for(const k in i){const F=k.split(".")[0],V=so(s,F)||s["*"];let j;if(so(A,F))j=A[F];else if(so(s,F)){if(i[k]===void 0)continue;j=b}else if(A["*"])j=A["*"];else{if(!s["*"]){M.push(new o(e,i[k],`unknown property "${k}"`));continue}j=b}M=M.concat(j({key:(e&&`${e}.`)+k,value:i[k],valueSpec:V,style:d,styleSpec:_,object:i,objectKey:k,validateSpec:b},i))}for(const k in s)A[k]||s[k].required&&s[k].default===void 0&&i[k]===void 0&&M.push(new o(e,i,`missing required property "${k}"`));return M}function pr(r){const e=r.value,i=r.valueSpec,s=r.style,A=r.styleSpec,d=r.key,_=r.arrayElementValidator||r.validateSpec;if(gi(e)!=="array")return[new o(d,e,`array expected, ${gi(e)} found`)];if(i.length&&e.length!==i.length)return[new o(d,e,`array length ${i.length} expected, length ${e.length} found`)];let b={type:i.value,values:i.values};A.$version<7&&(b.function=i.function),gi(i.value)==="object"&&(b=i.value);let M=[];for(let I=0;I<e.length;I++)M=M.concat(_({array:e,arrayIndex:I,value:e[I],valueSpec:b,validateSpec:r.validateSpec,style:s,styleSpec:A,key:`${d}[${I}]`}));return M}function nr(r){const e=r.key,i=r.value,s=r.valueSpec;let A=gi(i);return A==="number"&&i!=i&&(A="NaN"),A!=="number"?[new o(e,i,`number expected, ${A} found`)]:"minimum"in s&&i<s.minimum?[new o(e,i,`${i} is less than the minimum value ${s.minimum}`)]:"maximum"in s&&i>s.maximum?[new o(e,i,`${i} is greater than the maximum value ${s.maximum}`)]:[]}function ll(r){const e=r.valueSpec,i=br(r.value.type);let s,A,d,_={};const b=i!=="categorical"&&r.value.property===void 0,M=!b,I=gi(r.value.stops)==="array"&&gi(r.value.stops[0])==="array"&&gi(r.value.stops[0][0])==="object",k=Nn({key:r.key,value:r.value,valueSpec:r.styleSpec.function,validateSpec:r.validateSpec,style:r.style,styleSpec:r.styleSpec,objectElementValidators:{stops:function(j){if(i==="identity")return[new o(j.key,j.value,'identity function may not have a "stops" property')];let H=[];const Q=j.value;return H=H.concat(pr({key:j.key,value:Q,valueSpec:j.valueSpec,validateSpec:j.validateSpec,style:j.style,styleSpec:j.styleSpec,arrayElementValidator:F})),gi(Q)==="array"&&Q.length===0&&H.push(new o(j.key,Q,"array must have at least one stop")),H},default:function(j){return j.validateSpec({key:j.key,value:j.value,valueSpec:e,validateSpec:j.validateSpec,style:j.style,styleSpec:j.styleSpec})}}});return i==="identity"&&b&&k.push(new o(r.key,r.value,'missing required property "property"')),i==="identity"||r.value.stops||k.push(new o(r.key,r.value,'missing required property "stops"')),i==="exponential"&&r.valueSpec.expression&&!nl(r.valueSpec)&&k.push(new o(r.key,r.value,"exponential functions not supported")),r.styleSpec.$version>=8&&(M&&!co(r.valueSpec)?k.push(new o(r.key,r.value,"property functions not supported")):b&&!ba(r.valueSpec)&&k.push(new o(r.key,r.value,"zoom functions not supported"))),i!=="categorical"&&!I||r.value.property!==void 0||k.push(new o(r.key,r.value,'"property" property is required')),k;function F(j){let H=[];const Q=j.value,Y=j.key;if(gi(Q)!=="array")return[new o(Y,Q,`array expected, ${gi(Q)} found`)];if(Q.length!==2)return[new o(Y,Q,`array length 2 expected, length ${Q.length} found`)];if(I){if(gi(Q[0])!=="object")return[new o(Y,Q,`object expected, ${gi(Q[0])} found`)];if(Q[0].zoom===void 0)return[new o(Y,Q,"object stop key must have zoom")];if(Q[0].value===void 0)return[new o(Y,Q,"object stop key must have value")];if(d&&d>br(Q[0].zoom))return[new o(Y,Q[0].zoom,"stop zoom values must appear in ascending order")];br(Q[0].zoom)!==d&&(d=br(Q[0].zoom),A=void 0,_={}),H=H.concat(Nn({key:`${Y}[0]`,value:Q[0],valueSpec:{zoom:{}},validateSpec:j.validateSpec,style:j.style,styleSpec:j.styleSpec,objectElementValidators:{zoom:nr,value:V}}))}else H=H.concat(V({key:`${Y}[0]`,value:Q[0],validateSpec:j.validateSpec,style:j.style,styleSpec:j.styleSpec},Q));return ds(ea(Q[1]))?H.concat([new o(`${Y}[1]`,Q[1],"expressions are not allowed in function stops.")]):H.concat(j.validateSpec({key:`${Y}[1]`,value:Q[1],valueSpec:e,validateSpec:j.validateSpec,style:j.style,styleSpec:j.styleSpec}))}function V(j,H){const Q=gi(j.value),Y=br(j.value),re=j.value!==null?j.value:H;if(s){if(Q!==s)return[new o(j.key,re,`${Q} stop domain type must match previous stop domain type ${s}`)]}else s=Q;if(Q!=="number"&&Q!=="string"&&Q!=="boolean")return[new o(j.key,re,"stop domain value must be a number, string, or boolean")];if(Q!=="number"&&i!=="categorical"){let ge=`number expected, ${Q} found`;return co(e)&&i===void 0&&(ge+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new o(j.key,re,ge)]}return i!=="categorical"||Q!=="number"||isFinite(Y)&&Math.floor(Y)===Y?i!=="categorical"&&Q==="number"&&A!==void 0&&Y<A?[new o(j.key,re,"stop domain values must appear in ascending order")]:(A=Y,i==="categorical"&&Y in _?[new o(j.key,re,"stop domain values must be unique")]:(_[Y]=!0,[])):[new o(j.key,re,`integer expected, found ${Y}`)]}}function Co(r){const e=(r.expressionContext==="property"?R:u)(ea(r.value),r.valueSpec);if(e.result==="error")return e.value.map((s=>new o(`${r.key}${s.key}`,r.value,s.message)));const i=e.value.expression||e.value._styleExpression.expression;if(r.expressionContext==="property"&&r.propertyKey==="text-font"&&!i.outputDefined())return[new o(r.key,r.value,`Invalid data expression for "${r.propertyKey}". Output values must be contained as literals within the expression.`)];if(r.expressionContext==="property"&&r.propertyType==="layout"&&!ya(i))return[new o(r.key,r.value,'"feature-state" data expressions are not supported with layout properties.')];if(r.expressionContext==="filter"&&!ya(i))return[new o(r.key,r.value,'"feature-state" data expressions are not supported with filters.')];if(r.expressionContext&&r.expressionContext.indexOf("cluster")===0){if(!Oa(i,["zoom","feature-state"]))return[new o(r.key,r.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(r.expressionContext==="cluster-initial"&&!es(i))return[new o(r.key,r.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Ao(r){const e=r.key,i=r.value,s=gi(i);return s!=="string"?[new o(e,i,`color expected, ${s} found`)]:oi.parse(String(i))?[]:[new o(e,i,`color expected, "${i}" found`)]}function Ur(r){const e=r.key,i=r.value,s=r.valueSpec,A=[];return Array.isArray(s.values)?s.values.indexOf(br(i))===-1&&A.push(new o(e,i,`expected one of [${s.values.join(", ")}], ${JSON.stringify(i)} found`)):Object.keys(s.values).indexOf(br(i))===-1&&A.push(new o(e,i,`expected one of [${Object.keys(s.values).join(", ")}], ${JSON.stringify(i)} found`)),A}function ta(r){return tt(ea(r.value))?Co(X({},r,{expressionContext:"filter",valueSpec:{value:"boolean"}})):Kl(r)}function Kl(r){const e=r.value,i=r.key;if(gi(e)!=="array")return[new o(i,e,`array expected, ${gi(e)} found`)];const s=r.styleSpec;let A,d=[];if(e.length<1)return[new o(i,e,"filter array must have at least 1 element")];switch(d=d.concat(Ur({key:`${i}[0]`,value:e[0],valueSpec:s.filter_operator,style:r.style,styleSpec:r.styleSpec})),br(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&br(e[1])==="$type"&&d.push(new o(i,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":e.length!==3&&d.push(new o(i,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(A=gi(e[1]),A!=="string"&&d.push(new o(`${i}[1]`,e[1],`string expected, ${A} found`)));for(let _=2;_<e.length;_++)A=gi(e[_]),br(e[1])==="$type"?d=d.concat(Ur({key:`${i}[${_}]`,value:e[_],valueSpec:s.geometry_type,style:r.style,styleSpec:r.styleSpec})):A!=="string"&&A!=="number"&&A!=="boolean"&&d.push(new o(`${i}[${_}]`,e[_],`string, number, or boolean expected, ${A} found`));break;case"any":case"all":case"none":for(let _=1;_<e.length;_++)d=d.concat(Kl({key:`${i}[${_}]`,value:e[_],style:r.style,styleSpec:r.styleSpec}));break;case"has":case"!has":A=gi(e[1]),e.length!==2?d.push(new o(i,e,`filter array for "${e[0]}" operator must have 2 elements`)):A!=="string"&&d.push(new o(`${i}[1]`,e[1],`string expected, ${A} found`))}return d}function fu(r,e){const i=r.key,s=r.validateSpec,A=r.style,d=r.styleSpec,_=r.value,b=r.objectKey,M=d[`${e}_${r.layerType}`];if(!M)return[];const I=b.match(/^(.*)-transition$/);if(e==="paint"&&I&&M[I[1]]&&M[I[1]].transition)return s({key:i,value:_,valueSpec:d.transition,style:A,styleSpec:d});const k=r.valueSpec||M[b];if(!k)return[new o(i,_,`unknown property "${b}"`)];let F;if(gi(_)==="string"&&co(k)&&!k.tokens&&(F=/^{([^}]+)}$/.exec(_)))return[new o(i,_,`"${b}" does not support interpolation syntax 8 - Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(F[1])} }\`.`)];const V=[];return r.layerType==="symbol"&&b==="text-font"&&sl(ea(_))&&br(_.type)==="identity"&&V.push(new o(i,_,'"text-font" does not support identity functions')),V.concat(s({key:r.key,value:_,valueSpec:k,style:A,styleSpec:d,expressionContext:"property",propertyType:e,propertyKey:b}))}function du(r){return fu(r,"paint")}function pu(r){return fu(r,"layout")}function mu(r){let e=[];const i=r.value,s=r.key,A=r.style,d=r.styleSpec;if(gi(i)!=="object")return[new o(s,i,`object expected, ${gi(i)} found`)];i.type||i.ref||e.push(new o(s,i,'either "type" or "ref" is required'));let _=br(i.type);const b=br(i.ref);if(i.id){const M=br(i.id);for(let I=0;I<r.arrayIndex;I++){const k=A.layers[I];br(k.id)===M&&e.push(new o(s,i.id,`duplicate layer id "${i.id}", previously used at line ${k.id.__line__}`))}}if("ref"in i){let M;["type","source","source-layer","filter","layout"].forEach((I=>{I in i&&e.push(new o(s,i[I],`"${I}" is prohibited for ref layers`))})),A.layers.forEach((I=>{br(I.id)===b&&(M=I)})),M?M.ref?e.push(new o(s,i.ref,"ref cannot reference another ref layer")):_=br(M.type):e.push(new o(s,i.ref,`ref layer "${b}" not found`))}else if(_!=="background")if(i.source){const M=A.sources&&A.sources[i.source],I=M&&br(M.type);M?I==="vector"&&_==="raster"?e.push(new o(s,i.source,`layer "${i.id}" requires a raster source`)):I!=="raster-dem"&&_==="hillshade"||I!=="raster-dem"&&_==="color-relief"?e.push(new o(s,i.source,`layer "${i.id}" requires a raster-dem source`)):I==="raster"&&_!=="raster"?e.push(new o(s,i.source,`layer "${i.id}" requires a vector source`)):I!=="vector"||i["source-layer"]?I==="raster-dem"&&_!=="hillshade"&&_!=="color-relief"?e.push(new o(s,i.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):_!=="line"||!i.paint||!i.paint["line-gradient"]||I==="geojson"&&M.lineMetrics||e.push(new o(s,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new o(s,i,`layer "${i.id}" must specify a "source-layer"`)):e.push(new o(s,i.source,`source "${i.source}" not found`))}else e.push(new o(s,i,'missing required property "source"'));return e=e.concat(Nn({key:s,value:i,valueSpec:d.layer,style:r.style,styleSpec:r.styleSpec,validateSpec:r.validateSpec,objectElementValidators:{"*":()=>[],type:()=>r.validateSpec({key:`${s}.type`,value:i.type,valueSpec:d.layer.type,style:r.style,styleSpec:r.styleSpec,validateSpec:r.validateSpec,object:i,objectKey:"type"}),filter:ta,layout:M=>Nn({layer:i,key:M.key,value:M.value,style:M.style,styleSpec:M.styleSpec,validateSpec:M.validateSpec,objectElementValidators:{"*":I=>pu(X({layerType:_},I))}}),paint:M=>Nn({layer:i,key:M.key,value:M.value,style:M.style,styleSpec:M.styleSpec,validateSpec:M.validateSpec,objectElementValidators:{"*":I=>du(X({layerType:_},I))}})}})),e}function ia(r){const e=r.value,i=r.key,s=gi(e);return s!=="string"?[new o(i,e,`string expected, ${s} found`)]:[]}const _u={promoteId:function({key:r,value:e}){if(gi(e)==="string")return ia({key:r,value:e});{const i=[];for(const s in e)i.push(...ia({key:`${r}.${s}`,value:e[s]}));return i}}};function gu(r){const e=r.value,i=r.key,s=r.styleSpec,A=r.style,d=r.validateSpec;if(!e.type)return[new o(i,e,'"type" is required')];const _=br(e.type);let b;switch(_){case"vector":case"raster":return b=Nn({key:i,value:e,valueSpec:s[`source_${_.replace("-","_")}`],style:r.style,styleSpec:s,objectElementValidators:_u,validateSpec:d}),b;case"raster-dem":return b=(function(M){var I;const k=(I=M.sourceName)!==null&&I!==void 0?I:"",F=M.value,V=M.styleSpec,j=V.source_raster_dem,H=M.style;let Q=[];const Y=gi(F);if(F===void 0)return Q;if(Y!=="object")return Q.push(new o("source_raster_dem",F,`object expected, ${Y} found`)),Q;const re=br(F.encoding)==="custom",ge=["redFactor","greenFactor","blueFactor","baseShift"],oe=M.value.encoding?`"${M.value.encoding}"`:"Default";for(const ue in F)!re&&ge.includes(ue)?Q.push(new o(ue,F[ue],`In "${k}": "${ue}" is only valid when "encoding" is set to "custom". ${oe} encoding found`)):j[ue]?Q=Q.concat(M.validateSpec({key:ue,value:F[ue],valueSpec:j[ue],validateSpec:M.validateSpec,style:H,styleSpec:V})):Q.push(new o(ue,F[ue],`unknown property "${ue}"`));return Q})({sourceName:i,value:e,style:r.style,styleSpec:s,validateSpec:d}),b;case"geojson":if(b=Nn({key:i,value:e,valueSpec:s.source_geojson,style:A,styleSpec:s,validateSpec:d,objectElementValidators:_u}),e.cluster)for(const M in e.clusterProperties){const[I,k]=e.clusterProperties[M],F=typeof I=="string"?[I,["accumulated"],["get",M]]:I;b.push(...Co({key:`${i}.${M}.map`,value:k,expressionContext:"cluster-map"})),b.push(...Co({key:`${i}.${M}.reduce`,value:F,expressionContext:"cluster-reduce"}))}return b;case"video":return Nn({key:i,value:e,valueSpec:s.source_video,style:A,validateSpec:d,styleSpec:s});case"image":return Nn({key:i,value:e,valueSpec:s.source_image,style:A,validateSpec:d,styleSpec:s});case"canvas":return[new o(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Ur({key:`${i}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function Sl(r){const e=r.value,i=r.styleSpec,s=i.light,A=r.style;let d=[];const _=gi(e);if(e===void 0)return d;if(_!=="object")return d=d.concat([new o("light",e,`object expected, ${_} found`)]),d;for(const b in e){const M=b.match(/^(.*)-transition$/);d=d.concat(M&&s[M[1]]&&s[M[1]].transition?r.validateSpec({key:b,value:e[b],valueSpec:i.transition,validateSpec:r.validateSpec,style:A,styleSpec:i}):s[b]?r.validateSpec({key:b,value:e[b],valueSpec:s[b],validateSpec:r.validateSpec,style:A,styleSpec:i}):[new o(b,e[b],`unknown property "${b}"`)])}return d}function Fu(r){const e=r.value,i=r.styleSpec,s=i.sky,A=r.style,d=gi(e);if(e===void 0)return[];if(d!=="object")return[new o("sky",e,`object expected, ${d} found`)];let _=[];for(const b in e)_=_.concat(s[b]?r.validateSpec({key:b,value:e[b],valueSpec:s[b],style:A,styleSpec:i}):[new o(b,e[b],`unknown property "${b}"`)]);return _}function Io(r){const e=r.value,i=r.styleSpec,s=i.terrain,A=r.style;let d=[];const _=gi(e);if(e===void 0)return d;if(_!=="object")return d=d.concat([new o("terrain",e,`object expected, ${_} found`)]),d;for(const b in e)d=d.concat(s[b]?r.validateSpec({key:b,value:e[b],valueSpec:s[b],validateSpec:r.validateSpec,style:A,styleSpec:i}):[new o(b,e[b],`unknown property "${b}"`)]);return d}function Js(r){let e=[];const i=r.value,s=r.key;if(Array.isArray(i)){const A=[],d=[];for(const _ in i)i[_].id&&A.includes(i[_].id)&&e.push(new o(s,i,`all the sprites' ids must be unique, but ${i[_].id} is duplicated`)),A.push(i[_].id),i[_].url&&d.includes(i[_].url)&&e.push(new o(s,i,`all the sprites' URLs must be unique, but ${i[_].url} is duplicated`)),d.push(i[_].url),e=e.concat(Nn({key:`${s}[${_}]`,value:i[_],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:r.validateSpec}));return e}return ia({key:s,value:i})}function Qt(r){return!!r&&r.constructor===Object}function ts(r){return Qt(r.value)?[]:[new o(r.key,r.value,`object expected, ${gi(r.value)} found`)]}const Wt={"*":()=>[],array:pr,boolean:function(r){const e=r.value,i=r.key,s=gi(e);return s!=="boolean"?[new o(i,e,`boolean expected, ${s} found`)]:[]},number:nr,color:Ao,constants:Xl,enum:Ur,filter:ta,function:ll,layer:mu,object:Nn,source:gu,light:Sl,sky:Fu,terrain:Io,projection:function(r){const e=r.value,i=r.styleSpec,s=i.projection,A=r.style,d=gi(e);if(e===void 0)return[];if(d!=="object")return[new o("projection",e,`object expected, ${d} found`)];let _=[];for(const b in e)_=_.concat(s[b]?r.validateSpec({key:b,value:e[b],valueSpec:s[b],style:A,styleSpec:i}):[new o(b,e[b],`unknown property "${b}"`)]);return _},projectionDefinition:function(r){const e=r.key;let i=r.value;i=i instanceof String?i.valueOf():i;const s=gi(i);return s!=="array"||(function(A){return Array.isArray(A)&&A.length===3&&typeof A[0]=="string"&&typeof A[1]=="string"&&typeof A[2]=="number"})(i)||(function(A){return!!["interpolate","step","literal"].includes(A[0])})(i)?["array","string"].includes(s)?[]:[new o(e,i,`projection expected, invalid type "${s}" found`)]:[new o(e,i,`projection expected, invalid array ${JSON.stringify(i)} found`)]},string:ia,formatted:function(r){return ia(r).length===0?[]:Co(r)},resolvedImage:function(r){return ia(r).length===0?[]:Co(r)},padding:function(r){const e=r.key,i=r.value;if(gi(i)==="array"){if(i.length<1||i.length>4)return[new o(e,i,`padding requires 1 to 4 values; ${i.length} values found`)];const s={type:"number"};let A=[];for(let d=0;d<i.length;d++)A=A.concat(r.validateSpec({key:`${e}[${d}]`,value:i[d],validateSpec:r.validateSpec,valueSpec:s}));return A}return nr({key:e,value:i,valueSpec:{}})},numberArray:function(r){const e=r.key,i=r.value;if(gi(i)==="array"){const s={type:"number"};if(i.length<1)return[new o(e,i,"array length at least 1 expected, length 0 found")];let A=[];for(let d=0;d<i.length;d++)A=A.concat(r.validateSpec({key:`${e}[${d}]`,value:i[d],validateSpec:r.validateSpec,valueSpec:s}));return A}return nr({key:e,value:i,valueSpec:{}})},colorArray:function(r){const e=r.key,i=r.value;if(gi(i)==="array"){if(i.length<1)return[new o(e,i,"array length at least 1 expected, length 0 found")];let s=[];for(let A=0;A<i.length;A++)s=s.concat(Ao({key:`${e}[${A}]`,value:i[A]}));return s}return Ao({key:e,value:i})},variableAnchorOffsetCollection:function(r){const e=r.key,i=r.value,s=gi(i),A=r.styleSpec;if(s!=="array"||i.length<1||i.length%2!=0)return[new o(e,i,"variableAnchorOffsetCollection requires a non-empty array of even length")];let d=[];for(let _=0;_<i.length;_+=2)d=d.concat(Ur({key:`${e}[${_}]`,value:i[_],valueSpec:A.layout_symbol["text-anchor"]})),d=d.concat(pr({key:`${e}[${_+1}]`,value:i[_+1],valueSpec:{length:2,value:"number"},validateSpec:r.validateSpec,style:r.style,styleSpec:A}));return d},sprite:Js,state:ts,fontFaces:function(r){const e=r.key,i=r.value,s=r.validateSpec,A=r.styleSpec,d=r.style;if(!Qt(i))return[new o(e,i,`object expected, ${gi(i)} found`)];const _=[];for(const b in i){const M=i[b],I=gi(M);if(I==="string")_.push(...ia({key:`${e}.${b}`,value:M}));else if(I==="array"){const k={url:{type:"string",required:!0},"unicode-range":{type:"array",value:"string"}};for(const[F,V]of M.entries())_.push(...Nn({key:`${e}.${b}[${F}]`,value:V,valueSpec:k,styleSpec:A,style:d,validateSpec:s}))}else _.push(new o(`${e}.${b}`,M,`string or array expected, ${I} found`))}return _}};function wr(r){const e=r.value,i=r.valueSpec,s=r.styleSpec;return r.validateSpec=wr,i.expression&&sl(br(e))?ll(r):i.expression&&ds(ea(e))?Co(r):i.type&&Wt[i.type]?Wt[i.type](r):Nn(X({},r,{valueSpec:i.type?s[i.type]:i}))}function yu(r){const e=r.value,i=r.key,s=ia(r);return s.length||(e.indexOf("{fontstack}")===-1&&s.push(new o(i,e,'"glyphs" url must include a "{fontstack}" token')),e.indexOf("{range}")===-1&&s.push(new o(i,e,'"glyphs" url must include a "{range}" token'))),s}function bs(r,e=qe){let i=[];return i=i.concat(wr({key:"",value:r,valueSpec:e.$root,styleSpec:e,style:r,validateSpec:wr,objectElementValidators:{glyphs:yu,"*":()=>[]}})),r.constants&&(i=i.concat(Xl({key:"constants",value:r.constants}))),Ou(i)}function xn(r){return function(e){return r(Object.assign({},e,{validateSpec:wr}))}}function Ou(r){return[].concat(r).sort(((e,i)=>e.line-i.line))}function lr(r){return function(...e){return Ou(r.apply(this,e))}}bs.source=lr(xn(gu)),bs.sprite=lr(xn(Js)),bs.glyphs=lr(xn(yu)),bs.light=lr(xn(Sl)),bs.sky=lr(xn(Fu)),bs.terrain=lr(xn(Io)),bs.state=lr(xn(ts)),bs.layer=lr(xn(mu)),bs.filter=lr(xn(ta)),bs.paintProperty=lr(xn(du)),bs.layoutProperty=lr(xn(pu));const ul={type:"enum","property-type":"data-constant",expression:{interpolated:!1,parameters:["global-state"]},values:{visible:{},none:{}},transition:!1,default:"visible"};class Do{constructor(e,i){this._globalState=i,this.setValue(e)}evaluate(){var e;return(e=this._literalValue)!==null&&e!==void 0?e:this._compiledValue.evaluate({})}setValue(e){if(e==null||e==="visible"||e==="none")return this._literalValue=e==="none"?"none":"visible",this._compiledValue=void 0,void(this._globalStateRefs=new Set);const i=u(e,ul,this._globalState);if(i.result==="error")throw this._literalValue="visible",this._compiledValue=void 0,new Error(i.value.map((s=>`${s.key}: ${s.message}`)).join(", "));this._literalValue=void 0,this._compiledValue=i.value,this._globalStateRefs=Ee(i.value.expression)}getGlobalStateRefs(){return this._globalStateRefs}}const hl=qe,ht=bs,yt=ht.light,Jl=ht.sky,Nu=ht.paintProperty,eu=ht.layoutProperty;function ra(r,e){let i=!1;if(e&&e.length)for(const s of e)r.fire(new Gi(new Error(s.message))),i=!0;return i}class fo{constructor(e,i,s){const A=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;const _=new Int32Array(this.arrayBuffer);e=_[0],this.d=(i=_[1])+2*(s=_[2]);for(let M=0;M<this.d*this.d;M++){const I=_[3+M],k=_[3+M+1];A.push(I===k?null:_.subarray(I,k))}const b=_[3+A.length+1];this.keys=_.subarray(_[3+A.length],b),this.bboxes=_.subarray(b),this.insert=this._insertReadonly}else{this.d=i+2*s;for(let _=0;_<this.d*this.d;_++)A.push([]);this.keys=[],this.bboxes=[]}this.n=i,this.extent=e,this.padding=s,this.scale=i/e,this.uid=0;const d=s/i*e;this.min=-d,this.max=e+d}insert(e,i,s,A,d){this._forEachCell(i,s,A,d,this._insertCell,this.uid++,void 0,void 0),this.keys.push(e),this.bboxes.push(i),this.bboxes.push(s),this.bboxes.push(A),this.bboxes.push(d)}_insertReadonly(){throw new Error("Cannot insert into a GridIndex created from an ArrayBuffer.")}_insertCell(e,i,s,A,d,_){this.cells[d].push(_)}query(e,i,s,A,d){const _=this.min,b=this.max;if(e<=_&&i<=_&&b<=s&&b<=A&&!d)return Array.prototype.slice.call(this.keys);{const M=[];return this._forEachCell(e,i,s,A,this._queryCell,M,{},d),M}}_queryCell(e,i,s,A,d,_,b,M){const I=this.cells[d];if(I!==null){const k=this.keys,F=this.bboxes;for(let V=0;V<I.length;V++){const j=I[V];if(b[j]===void 0){const H=4*j;(M?M(F[H+0],F[H+1],F[H+2],F[H+3]):e<=F[H+2]&&i<=F[H+3]&&s>=F[H+0]&&A>=F[H+1])?(b[j]=!0,_.push(k[j])):b[j]=!1}}}}_forEachCell(e,i,s,A,d,_,b,M){const I=this._convertToCellCoord(e),k=this._convertToCellCoord(i),F=this._convertToCellCoord(s),V=this._convertToCellCoord(A);for(let j=I;j<=F;j++)for(let H=k;H<=V;H++){const Q=this.d*H+j;if((!M||M(this._convertFromCellCoord(j),this._convertFromCellCoord(H),this._convertFromCellCoord(j+1),this._convertFromCellCoord(H+1)))&&d.call(this,e,i,s,A,Q,_,b,M))return}}_convertFromCellCoord(e){return(e-this.padding)/this.scale}_convertToCellCoord(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const e=this.cells,i=3+this.cells.length+1+1;let s=0;for(let _=0;_<this.cells.length;_++)s+=this.cells[_].length;const A=new Int32Array(i+s+this.keys.length+this.bboxes.length);A[0]=this.extent,A[1]=this.n,A[2]=this.padding;let d=i;for(let _=0;_<e.length;_++){const b=e[_];A[3+_]=d,A.set(b,d),d+=b.length}return A[3+e.length]=d,A.set(this.keys,d),d+=this.keys.length,A[3+e.length+1]=d,A.set(this.bboxes,d),d+=this.bboxes.length,A.buffer}static serialize(e,i){const s=e.toArrayBuffer();return i&&i.push(s),{buffer:s}}static deserialize(e){return new fo(e.buffer)}}const bn={};function kt(r,e,i={}){if(bn[r])throw new Error(`${r} is already registered.`);Object.defineProperty(e,"_classRegistryKey",{value:r,writeable:!1}),bn[r]={klass:e,omit:i.omit||[],shallow:i.shallow||[]}}kt("Object",Object),kt("Set",Set),kt("TransferableGridIndex",fo),kt("Color",oi),kt("Error",Error),kt("AJAXError",ke),kt("ResolvedImage",gn),kt("StylePropertyFunction",q),kt("StyleExpression",ol,{omit:["_evaluator"]}),kt("ZoomDependentExpression",E),kt("ZoomConstantExpression",v),kt("CompoundExpression",fn,{omit:["_evaluate"]});for(const r in ga)ga[r]._classRegistryKey||kt(`Expression_${r}`,ga[r]);function po(r){return r&&typeof ArrayBuffer<"u"&&(r instanceof ArrayBuffer||r.constructor&&r.constructor.name==="ArrayBuffer")}function l(r){return r.$name||r.constructor._classRegistryKey}function a(r){return!(function(e){if(e===null||typeof e!="object")return!1;const i=l(e);return!(!i||i==="Object")})(r)&&(r==null||typeof r=="boolean"||typeof r=="number"||typeof r=="string"||r instanceof Boolean||r instanceof Number||r instanceof String||r instanceof Date||r instanceof RegExp||r instanceof Blob||r instanceof Error||po(r)||Dn(r)||ArrayBuffer.isView(r)||r instanceof ImageData)}function c(r,e){if(a(r))return(po(r)||Dn(r))&&e&&e.push(r),ArrayBuffer.isView(r)&&e&&e.push(r.buffer),r instanceof ImageData&&e&&e.push(r.data.buffer),r;if(Array.isArray(r)){const d=[];for(const _ of r)d.push(c(_,e));return d}if(typeof r!="object")throw new Error("can't serialize object of type "+typeof r);const i=l(r);if(!i)throw new Error(`can't serialize object of unregistered class ${r.constructor.name}`);if(!bn[i])throw new Error(`${i} is not registered.`);const{klass:s}=bn[i],A=s.serialize?s.serialize(r,e):{};if(s.serialize){if(e&&A===e[e.length-1])throw new Error("statically serialized object won't survive transfer of $name property")}else{for(const d in r){if(!r.hasOwnProperty(d)||bn[i].omit.indexOf(d)>=0)continue;const _=r[d];A[d]=bn[i].shallow.indexOf(d)>=0?_:c(_,e)}r instanceof Error&&(A.message=r.message)}if(A.$name)throw new Error("$name property is reserved for worker serialization logic.");return i!=="Object"&&(A.$name=i),A}function m(r){if(a(r))return r;if(Array.isArray(r))return r.map(m);if(typeof r!="object")throw new Error("can't deserialize object of type "+typeof r);const e=l(r)||"Object";if(!bn[e])throw new Error(`can't deserialize unregistered class ${e}`);const{klass:i}=bn[e];if(!i)throw new Error(`can't deserialize unregistered class ${e}`);if(i.deserialize)return i.deserialize(r);const s=Object.create(i.prototype);for(const A of Object.keys(r)){if(A==="$name")continue;const d=r[A];s[A]=bn[e].shallow.indexOf(A)>=0?d:m(d)}return s}class g{constructor(){this.first=!0}update(e,i){const s=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=s,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=s,!0):(this.lastFloorZoom>s?(this.lastIntegerZoom=s+1,this.lastIntegerZoomTime=i):this.lastFloorZoom<s&&(this.lastIntegerZoom=s,this.lastIntegerZoomTime=i),e!==this.lastZoom&&(this.lastZoom=e,this.lastFloorZoom=s,!0))}}function w(r){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(r))}function P(r){return/[\u02EA\u02EB\u1100-\u11FF\u1400-\u167F\u18B0-\u18F5\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u3007\u3012\u3013\u3020-\u302F\u3031-\u303F\u3041-\u3096\u309D-\u30FB\u30FD-\u30FF\u3105-\u312F\u3131-\u318E\u3190-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE48\uFE50-\uFE57\uFE5F-\uFE62\uFE67-\uFE6F\uFF00-\uFF07\uFF0A-\uFF0C\uFF0E-\uFF19\uFF1F-\uFF3A\uFF3C\uFF3E\uFF40-\uFF5A\uFFE0-\uFFE2\uFFE4-\uFFE7]|\uD802[\uDD80-\uDD9F]|\uD805[\uDD80-\uDDFF]|\uD806[\uDE00-\uDEBF]|\uD811[\uDC00-\uDE7F]|\uD81B[\uDFE0-\uDFE4\uDFF0-\uDFF6]|[\uD81C-\uD822\uD83D\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD30-\uDEFB]|\uD833[\uDEC0-\uDFCF]|\uD834[\uDC00-\uDDFF\uDEE0-\uDF7F]|\uD836[\uDC00-\uDEAF]|\uD83C[\uDC00-\uDE00\uDF00-\uDFFF]|\uD83E[\uDD00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(r))}function S(r){return/\s/u.test(String.fromCodePoint(r))}function z(r){for(const e of r)if(P(e.codePointAt(0)))return!0;return!1}function O(r){for(const e of r)if(!pe(e.codePointAt(0)))return!1;return!0}function Z(r){const e=r.map((i=>{try{return new RegExp(`\\p{sc=${i}}`,"u").source}catch{return null}})).filter((i=>i));return new RegExp(e.join("|"),"u")}const se=Z(["Arab","Dupl","Mong","Ougr","Syrc"]);function pe(r){return!se.test(String.fromCodePoint(r))}function de(r){return!(P(r)||(e=r,/[\xA7\xA9\xAE\xB1\xBC-\xBE\xD7\xF7\u2016\u2020\u2021\u2030\u2031\u203B\u203C\u2042\u2047-\u2049\u2051\u2100-\u218F\u221E\u2234\u2235\u2300-\u2307\u230C-\u231F\u2324-\u2328\u232B\u237D-\u239A\u23BE-\u23CD\u23CF\u23D1-\u23DB\u23E2-\u2422\u2424-\u24FF\u25A0-\u2619\u2620-\u2767\u2776-\u2793\u2B12-\u2B2F\u2B50-\u2B59\u2BB8-\u2BEB\u3000-\u303F\u30A0-\u30FF\uE000-\uF8FF\uFE30-\uFE6F\uFF00-\uFFEF\uFFFC\uFFFD]|[\uDB80-\uDBFF][\uDC00-\uDFFF]/gim.test(String.fromCodePoint(e))));var e}const me=Z(["Adlm","Arab","Armi","Avst","Chrs","Cprt","Egyp","Elym","Gara","Hatr","Hebr","Hung","Khar","Lydi","Mand","Mani","Mend","Merc","Mero","Narb","Nbat","Nkoo","Orkh","Palm","Phli","Phlp","Phnx","Prti","Rohg","Samr","Sarb","Sogo","Syrc","Thaa","Todr","Yezi"]);function Ie(r){return me.test(String.fromCodePoint(r))}function Be(r,e){return!(!e&&Ie(r)||/[\u0900-\u0DFF\u0F00-\u109F\u1780-\u17FF]/gim.test(String.fromCodePoint(r)))}function Je(r){for(const e of r)if(Ie(e.codePointAt(0)))return!0;return!1}const Oe=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null,this.loadScriptResolve=()=>{}}setState(r){this.pluginStatus=r.pluginStatus,this.pluginURL=r.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(r){if(Oe.isParsed())throw new Error("RTL text plugin already registered.");this.applyArabicShaping=r.applyArabicShaping,this.processBidirectionalText=r.processBidirectionalText,this.processStyledBidirectionalText=r.processStyledBidirectionalText,this.loadScriptResolve()}isParsed(){return this.applyArabicShaping!=null&&this.processBidirectionalText!=null&&this.processStyledBidirectionalText!=null}getRTLTextPluginStatus(){return this.pluginStatus}syncState(r,e){return p(this,void 0,void 0,(function*(){if(this.isParsed())return this.getState();if(r.pluginStatus!=="loading")return this.setState(r),r;const i=r.pluginURL,s=new Promise((d=>{this.loadScriptResolve=d}));e(i);const A=new Promise((d=>setTimeout((()=>d()),this.TIMEOUT)));if(yield Promise.race([s,A]),this.isParsed()){const d={pluginStatus:"loaded",pluginURL:i};return this.setState(d),d}throw this.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${i}`)}))}};class ze{constructor(e,i){this.isSupportedScript=De,this.zoom=e,i?(this.now=i.now||0,this.fadeDuration=i.fadeDuration||0,this.zoomHistory=i.zoomHistory||new g,this.transition=i.transition||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new g,this.transition={})}crossFadingFactor(){return this.fadeDuration===0?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const e=this.zoom,i=e-Math.floor(e),s=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:i+(1-i)*s}:{fromScale:.5,toScale:1,t:1-(1-s)*i}}}function De(r){return(function(e,i){for(const s of e)if(!Be(s.codePointAt(0),i))return!1;return!0})(r,Oe.getRTLTextPluginStatus()==="loaded")}const bt="-transition";class Zt{constructor(e,i,s){this.property=e,this.value=i,this.expression=(function(A,d,_){if(sl(A))return new q(A,d);if(ds(A)){const b=R(A,d,_);if(b.result==="error")throw new Error(b.value.map((M=>`${M.key}: ${M.message}`)).join(", "));return b.value}{let b=A;return d.type==="color"&&typeof A=="string"?b=oi.parse(A):d.type!=="padding"||typeof A!="number"&&!Array.isArray(A)?d.type!=="numberArray"||typeof A!="number"&&!Array.isArray(A)?d.type!=="colorArray"||typeof A!="string"&&!Array.isArray(A)?d.type==="variableAnchorOffsetCollection"&&Array.isArray(A)?b=cn.parse(A):d.type==="projectionDefinition"&&typeof A=="string"&&(b=Lr.parse(A)):b=Dt.parse(A):b=Li.parse(A):b=Ht.parse(A),{globalStateRefs:new Set,_globalState:null,kind:"constant",evaluate:()=>b}}})(i===void 0?e.specification.default:i,e.specification,s)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}getGlobalStateRefs(){return this.expression.globalStateRefs||new Set}possiblyEvaluate(e,i,s){return this.property.possiblyEvaluate(this,e,i,s)}}class Nt{constructor(e,i){this.property=e,this.value=new Zt(e,void 0,i)}transitioned(e,i){return new pi(this.property,this.value,i,Er({},e.transition,this.transition),e.now)}untransitioned(){return new pi(this.property,this.value,null,{},0)}}class ai{constructor(e,i){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._globalState=i}getValue(e){return In(this._values[e].value.value)}setValue(e,i){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Nt(this._values[e].property,this._globalState)),this._values[e].value=new Zt(this._values[e].property,i===null?void 0:In(i),this._globalState)}getTransition(e){return In(this._values[e].transition)}setTransition(e,i){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Nt(this._values[e].property,this._globalState)),this._values[e].transition=In(i)||void 0}serialize(){const e={};for(const i of Object.keys(this._values)){const s=this.getValue(i);s!==void 0&&(e[i]=s);const A=this.getTransition(i);A!==void 0&&(e[`${i}${bt}`]=A)}return e}transitioned(e,i){const s=new Mi(this._properties);for(const A of Object.keys(this._values))s._values[A]=this._values[A].transitioned(e,i._values[A]);return s}untransitioned(){const e=new Mi(this._properties);for(const i of Object.keys(this._values))e._values[i]=this._values[i].untransitioned();return e}}class pi{constructor(e,i,s,A,d){this.property=e,this.value=i,this.begin=d+A.delay||0,this.end=this.begin+A.duration||0,e.specification.transition&&(A.delay||A.duration)&&(this.prior=s)}possiblyEvaluate(e,i,s){const A=e.now||0,d=this.value.possiblyEvaluate(e,i,s),_=this.prior;if(_){if(A>this.end)return this.prior=null,d;if(this.value.isDataDriven())return this.prior=null,d;if(A<this.begin)return _.possiblyEvaluate(e,i,s);{const b=(A-this.begin)/(this.end-this.begin);return this.property.interpolate(_.possiblyEvaluate(e,i,s),d,Wr(b))}}return d}}class Mi{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,i,s){const A=new vt(this._properties);for(const d of Object.keys(this._values))A._values[d]=this._values[d].possiblyEvaluate(e,i,s);return A}hasTransition(){for(const e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class ei{constructor(e,i){this._properties=e,this._values=Object.create(e.defaultPropertyValues),this._globalState=i}hasValue(e){return this._values[e].value!==void 0}getValue(e){return In(this._values[e].value)}setValue(e,i){this._values[e]=new Zt(this._values[e].property,i===null?void 0:In(i),this._globalState)}serialize(){const e={};for(const i of Object.keys(this._values)){const s=this.getValue(i);s!==void 0&&(e[i]=s)}return e}possiblyEvaluate(e,i,s){const A=new vt(this._properties);for(const d of Object.keys(this._values))A._values[d]=this._values[d].possiblyEvaluate(e,i,s);return A}}class Vt{constructor(e,i,s){this.property=e,this.value=i,this.parameters=s}isConstant(){return this.value.kind==="constant"}constantOr(e){return this.value.kind==="constant"?this.value.value:e}evaluate(e,i,s,A){return this.property.evaluate(this.value,this.parameters,e,i,s,A)}}class vt{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class _t{constructor(e){this.specification=e}possiblyEvaluate(e,i){if(e.isDataDriven())throw new Error("Value should not be data driven");return e.expression.evaluate(i)}interpolate(e,i,s){const A=ir[this.specification.type];return A?A(e,i,s):e}}class Mt{constructor(e,i){this.specification=e,this.overrides=i}possiblyEvaluate(e,i,s,A){return new Vt(this,e.expression.kind==="constant"||e.expression.kind==="camera"?{kind:"constant",value:e.expression.evaluate(i,null,{},s,A)}:e.expression,i)}interpolate(e,i,s){if(e.value.kind!=="constant"||i.value.kind!=="constant")return e;if(e.value.value===void 0||i.value.value===void 0)return new Vt(this,{kind:"constant",value:void 0},e.parameters);const A=ir[this.specification.type];if(A){const d=A(e.value.value,i.value.value,s);return new Vt(this,{kind:"constant",value:d},e.parameters)}return e}evaluate(e,i,s,A,d,_){return e.kind==="constant"?e.value:e.evaluate(i,s,A,d,_)}}class li extends Mt{possiblyEvaluate(e,i,s,A){if(e.value===void 0)return new Vt(this,{kind:"constant",value:void 0},i);if(e.expression.kind==="constant"){const d=e.expression.evaluate(i,null,{},s,A),_=e.property.specification.type==="resolvedImage"&&typeof d!="string"?d.name:d,b=this._calculate(_,_,_,i);return new Vt(this,{kind:"constant",value:b},i)}if(e.expression.kind==="camera"){const d=this._calculate(e.expression.evaluate({zoom:i.zoom-1}),e.expression.evaluate({zoom:i.zoom}),e.expression.evaluate({zoom:i.zoom+1}),i);return new Vt(this,{kind:"constant",value:d},i)}return new Vt(this,e.expression,i)}evaluate(e,i,s,A,d,_){if(e.kind==="source"){const b=e.evaluate(i,s,A,d,_);return this._calculate(b,b,b,i)}return e.kind==="composite"?this._calculate(e.evaluate({zoom:Math.floor(i.zoom)-1},s,A),e.evaluate({zoom:Math.floor(i.zoom)},s,A),e.evaluate({zoom:Math.floor(i.zoom)+1},s,A),i):e.value}_calculate(e,i,s,A){return A.zoom>A.zoomHistory.lastIntegerZoom?{from:e,to:i}:{from:s,to:i}}interpolate(e){return e}}class Yi{constructor(e){this.specification=e}possiblyEvaluate(e,i,s,A){if(e.value!==void 0){if(e.expression.kind==="constant"){const d=e.expression.evaluate(i,null,{},s,A);return this._calculate(d,d,d,i)}return this._calculate(e.expression.evaluate(new ze(Math.floor(i.zoom-1),i)),e.expression.evaluate(new ze(Math.floor(i.zoom),i)),e.expression.evaluate(new ze(Math.floor(i.zoom+1),i)),i)}}_calculate(e,i,s,A){return A.zoom>A.zoomHistory.lastIntegerZoom?{from:e,to:i}:{from:s,to:i}}interpolate(e){return e}}class wn{constructor(e){this.specification=e}possiblyEvaluate(e,i,s,A){return!!e.expression.evaluate(i,null,{},s,A)}interpolate(){return!1}}class is{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const i in e){const s=e[i];s.specification.overridable&&this.overridableProperties.push(i);const A=this.defaultPropertyValues[i]=new Zt(s,void 0,void 0),d=this.defaultTransitionablePropertyValues[i]=new Nt(s,void 0);this.defaultTransitioningPropertyValues[i]=d.untransitioned(),this.defaultPossiblyEvaluatedValues[i]=A.possiblyEvaluate({})}}}kt("DataDrivenProperty",Mt),kt("DataConstantProperty",_t),kt("CrossFadedDataDrivenProperty",li),kt("CrossFadedProperty",Yi),kt("ColorRampProperty",wn);class ko extends Bi{constructor(e,i,s){if(super(),this.id=e.id,this.type=e.type,this._globalState=s,this._featureFilter={filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set},this._visibilityExpression=(function(A,d){return new Do(A,d)})(this.visibility,s),e.type!=="custom"&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,e.type!=="background"&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter,this._featureFilter=Rt(e.filter,s)),i.layout&&(this._unevaluatedLayout=new ei(i.layout,s)),i.paint)){this._transitionablePaint=new ai(i.paint,s);for(const A in e.paint)this.setPaintProperty(A,e.paint[A],{validate:!1});for(const A in e.layout)this.setLayoutProperty(A,e.layout[A],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new vt(i.paint)}}setFilter(e){this.filter=e,this._featureFilter=Rt(e,this._globalState)}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){return e==="visibility"?this.visibility:this._unevaluatedLayout.getValue(e)}getLayoutAffectingGlobalStateRefs(){const e=new Set;for(const i of this._visibilityExpression.getGlobalStateRefs())e.add(i);if(this._unevaluatedLayout)for(const i in this._unevaluatedLayout._values){const s=this._unevaluatedLayout._values[i];for(const A of s.getGlobalStateRefs())e.add(A)}for(const i of this._featureFilter.getGlobalStateRefs())e.add(i);return e}getPaintAffectingGlobalStateRefs(){var e;const i=new globalThis.Map;if(this._transitionablePaint)for(const s in this._transitionablePaint._values){const A=this._transitionablePaint._values[s].value;for(const d of A.getGlobalStateRefs()){const _=(e=i.get(d))!==null&&e!==void 0?e:[];_.push({name:s,value:A.value}),i.set(d,_)}}return i}getVisibilityAffectingGlobalStateRefs(){return this._visibilityExpression.getGlobalStateRefs()}setLayoutProperty(e,i,s={}){if(i==null||!this._validate(eu,`layers.${this.id}.layout.${e}`,e,i,s))return e==="visibility"?(this.visibility=i,this._visibilityExpression.setValue(i),void this.recalculateVisibility()):void this._unevaluatedLayout.setValue(e,i)}getPaintProperty(e){return e.endsWith(bt)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,i,s={}){if(i!=null&&this._validate(Nu,`layers.${this.id}.paint.${e}`,e,i,s))return!1;if(e.endsWith(bt))return this._transitionablePaint.setTransition(e.slice(0,-11),i||void 0),!1;{const A=this._transitionablePaint._values[e],d=A.property.specification["property-type"]==="cross-faded-data-driven",_=A.value.isDataDriven(),b=A.value;this._transitionablePaint.setValue(e,i),this._handleSpecialPaintPropertyUpdate(e);const M=this._transitionablePaint._values[e].value;return M.isDataDriven()||_||d||this._handleOverridablePaintPropertyUpdate(e,b,M)}}_handleSpecialPaintPropertyUpdate(e){}_handleOverridablePaintPropertyUpdate(e,i,s){return!1}isHidden(e=this.minzoom,i=!1){return!!(this.minzoom&&e<(i?Math.floor(this.minzoom):this.minzoom))||!!(this.maxzoom&&e>=this.maxzoom)||this._evaluatedVisibility==="none"}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculateVisibility(){this._evaluatedVisibility=this._visibilityExpression.evaluate()}recalculate(e,i){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,i)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,i)}serialize(){const e={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&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(e.layout=e.layout||{},e.layout.visibility=this.visibility),No(e,((i,s)=>!(i===void 0||s==="layout"&&!Object.keys(i).length||s==="paint"&&!Object.keys(i).length)))}_validate(e,i,s,A,d={}){return(!d||d.validate!==!1)&&ra(this,e.call(ht,{key:i,layerType:this.type,objectKey:s,value:A,styleSpec:qe,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const e in this.paint._values){const i=this.paint.get(e);if(i instanceof Vt&&co(i.property.specification)&&(i.value.kind==="source"||i.value.kind==="composite")&&i.value.isStateDependent)return!0}return!1}}let dh;var Qh={get paint(){return dh=dh||new is({"raster-opacity":new _t(qe.paint_raster["raster-opacity"]),"raster-hue-rotate":new _t(qe.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new _t(qe.paint_raster["raster-brightness-min"]),"raster-brightness-max":new _t(qe.paint_raster["raster-brightness-max"]),"raster-saturation":new _t(qe.paint_raster["raster-saturation"]),"raster-contrast":new _t(qe.paint_raster["raster-contrast"]),"raster-resampling":new _t(qe.paint_raster["raster-resampling"]),"raster-fade-duration":new _t(qe.paint_raster["raster-fade-duration"])})}};class Ic extends ko{constructor(e,i){super(e,Qh,i)}}const Dc={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class vu{constructor(e,i){this._structArray=e,this._pos1=i*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class Gr{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,i){return e._trim(),i&&(e.isTransferred=!0,i.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const i=Object.create(this.prototype);return i.arrayBuffer=e.arrayBuffer,i.length=e.length,i.capacity=e.arrayBuffer.byteLength/i.bytesPerElement,i._refreshViews(),i}_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(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const i=this.uint8;this._refreshViews(),i&&this.uint8.set(i)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function on(r,e=1){let i=0,s=0;return{members:r.map((A=>{const d=Dc[A.type].BYTES_PER_ELEMENT,_=i=Cl(i,Math.max(e,d)),b=A.components||1;return s=Math.max(s,d),i+=d*b,{name:A.name,type:A.type,components:b,offset:_}})),size:Cl(i,Math.max(s,e)),alignment:e}}function Cl(r,e){return Math.ceil(r/e)*e}class xu extends Gr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i){const s=this.length;return this.resize(s+1),this.emplace(s,e,i)}emplace(e,i,s){const A=2*e;return this.int16[A+0]=i,this.int16[A+1]=s,e}}xu.prototype.bytesPerElement=4,kt("StructArrayLayout2i4",xu);class Vu extends Gr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,s){const A=this.length;return this.resize(A+1),this.emplace(A,e,i,s)}emplace(e,i,s,A){const d=3*e;return this.int16[d+0]=i,this.int16[d+1]=s,this.int16[d+2]=A,e}}Vu.prototype.bytesPerElement=6,kt("StructArrayLayout3i6",Vu);class ph extends Gr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,s,A){const d=this.length;return this.resize(d+1),this.emplace(d,e,i,s,A)}emplace(e,i,s,A,d){const _=4*e;return this.int16[_+0]=i,this.int16[_+1]=s,this.int16[_+2]=A,this.int16[_+3]=d,e}}ph.prototype.bytesPerElement=8,kt("StructArrayLayout4i8",ph);class ju extends Gr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,s,A,d,_){const b=this.length;return this.resize(b+1),this.emplace(b,e,i,s,A,d,_)}emplace(e,i,s,A,d,_,b){const M=6*e;return this.int16[M+0]=i,this.int16[M+1]=s,this.int16[M+2]=A,this.int16[M+3]=d,this.int16[M+4]=_,this.int16[M+5]=b,e}}ju.prototype.bytesPerElement=12,kt("StructArrayLayout2i4i12",ju);class mh extends Gr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,s,A,d,_){const b=this.length;return this.resize(b+1),this.emplace(b,e,i,s,A,d,_)}emplace(e,i,s,A,d,_,b){const M=4*e,I=8*e;return this.int16[M+0]=i,this.int16[M+1]=s,this.uint8[I+4]=A,this.uint8[I+5]=d,this.uint8[I+6]=_,this.uint8[I+7]=b,e}}mh.prototype.bytesPerElement=8,kt("StructArrayLayout2i4ub8",mh);class bu extends Gr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i){const s=this.length;return this.resize(s+1),this.emplace(s,e,i)}emplace(e,i,s){const A=2*e;return this.float32[A+0]=i,this.float32[A+1]=s,e}}bu.prototype.bytesPerElement=8,kt("StructArrayLayout2f8",bu);class Na extends Gr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,s,A,d,_,b,M,I,k){const F=this.length;return this.resize(F+1),this.emplace(F,e,i,s,A,d,_,b,M,I,k)}emplace(e,i,s,A,d,_,b,M,I,k,F){const V=10*e;return this.uint16[V+0]=i,this.uint16[V+1]=s,this.uint16[V+2]=A,this.uint16[V+3]=d,this.uint16[V+4]=_,this.uint16[V+5]=b,this.uint16[V+6]=M,this.uint16[V+7]=I,this.uint16[V+8]=k,this.uint16[V+9]=F,e}}Na.prototype.bytesPerElement=20,kt("StructArrayLayout10ui20",Na);class Zu extends Gr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,s,A,d,_,b,M){const I=this.length;return this.resize(I+1),this.emplace(I,e,i,s,A,d,_,b,M)}emplace(e,i,s,A,d,_,b,M,I){const k=8*e;return this.uint16[k+0]=i,this.uint16[k+1]=s,this.uint16[k+2]=A,this.uint16[k+3]=d,this.uint16[k+4]=_,this.uint16[k+5]=b,this.uint16[k+6]=M,this.uint16[k+7]=I,e}}Zu.prototype.bytesPerElement=16,kt("StructArrayLayout8ui16",Zu);class wu extends Gr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,s,A,d,_,b,M,I,k,F,V){const j=this.length;return this.resize(j+1),this.emplace(j,e,i,s,A,d,_,b,M,I,k,F,V)}emplace(e,i,s,A,d,_,b,M,I,k,F,V,j){const H=12*e;return this.int16[H+0]=i,this.int16[H+1]=s,this.int16[H+2]=A,this.int16[H+3]=d,this.uint16[H+4]=_,this.uint16[H+5]=b,this.uint16[H+6]=M,this.uint16[H+7]=I,this.int16[H+8]=k,this.int16[H+9]=F,this.int16[H+10]=V,this.int16[H+11]=j,e}}wu.prototype.bytesPerElement=24,kt("StructArrayLayout4i4ui4i24",wu);class Uu extends Gr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,s){const A=this.length;return this.resize(A+1),this.emplace(A,e,i,s)}emplace(e,i,s,A){const d=3*e;return this.float32[d+0]=i,this.float32[d+1]=s,this.float32[d+2]=A,e}}Uu.prototype.bytesPerElement=12,kt("StructArrayLayout3f12",Uu);class Tu extends Gr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const i=this.length;return this.resize(i+1),this.emplace(i,e)}emplace(e,i){return this.uint32[1*e+0]=i,e}}Tu.prototype.bytesPerElement=4,kt("StructArrayLayout1ul4",Tu);class _h extends Gr{_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(e,i,s,A,d,_,b,M,I){const k=this.length;return this.resize(k+1),this.emplace(k,e,i,s,A,d,_,b,M,I)}emplace(e,i,s,A,d,_,b,M,I,k){const F=10*e,V=5*e;return this.int16[F+0]=i,this.int16[F+1]=s,this.int16[F+2]=A,this.int16[F+3]=d,this.int16[F+4]=_,this.int16[F+5]=b,this.uint32[V+3]=M,this.uint16[F+8]=I,this.uint16[F+9]=k,e}}_h.prototype.bytesPerElement=20,kt("StructArrayLayout6i1ul2ui20",_h);class tu extends Gr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,s,A,d,_){const b=this.length;return this.resize(b+1),this.emplace(b,e,i,s,A,d,_)}emplace(e,i,s,A,d,_,b){const M=6*e;return this.int16[M+0]=i,this.int16[M+1]=s,this.int16[M+2]=A,this.int16[M+3]=d,this.int16[M+4]=_,this.int16[M+5]=b,e}}tu.prototype.bytesPerElement=12,kt("StructArrayLayout2i2i2i12",tu);class Il extends Gr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,s,A,d){const _=this.length;return this.resize(_+1),this.emplace(_,e,i,s,A,d)}emplace(e,i,s,A,d,_){const b=4*e,M=8*e;return this.float32[b+0]=i,this.float32[b+1]=s,this.float32[b+2]=A,this.int16[M+6]=d,this.int16[M+7]=_,e}}Il.prototype.bytesPerElement=16,kt("StructArrayLayout2f1f2i16",Il);class gh extends Gr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,s,A,d,_){const b=this.length;return this.resize(b+1),this.emplace(b,e,i,s,A,d,_)}emplace(e,i,s,A,d,_,b){const M=16*e,I=4*e,k=8*e;return this.uint8[M+0]=i,this.uint8[M+1]=s,this.float32[I+1]=A,this.float32[I+2]=d,this.int16[k+6]=_,this.int16[k+7]=b,e}}gh.prototype.bytesPerElement=16,kt("StructArrayLayout2ub2f2i16",gh);class Pu extends Gr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,s){const A=this.length;return this.resize(A+1),this.emplace(A,e,i,s)}emplace(e,i,s,A){const d=3*e;return this.uint16[d+0]=i,this.uint16[d+1]=s,this.uint16[d+2]=A,e}}Pu.prototype.bytesPerElement=6,kt("StructArrayLayout3ui6",Pu);class Dl extends Gr{_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(e,i,s,A,d,_,b,M,I,k,F,V,j,H,Q,Y,re){const ge=this.length;return this.resize(ge+1),this.emplace(ge,e,i,s,A,d,_,b,M,I,k,F,V,j,H,Q,Y,re)}emplace(e,i,s,A,d,_,b,M,I,k,F,V,j,H,Q,Y,re,ge){const oe=24*e,ue=12*e,ve=48*e;return this.int16[oe+0]=i,this.int16[oe+1]=s,this.uint16[oe+2]=A,this.uint16[oe+3]=d,this.uint32[ue+2]=_,this.uint32[ue+3]=b,this.uint32[ue+4]=M,this.uint16[oe+10]=I,this.uint16[oe+11]=k,this.uint16[oe+12]=F,this.float32[ue+7]=V,this.float32[ue+8]=j,this.uint8[ve+36]=H,this.uint8[ve+37]=Q,this.uint8[ve+38]=Y,this.uint32[ue+10]=re,this.int16[oe+22]=ge,e}}Dl.prototype.bytesPerElement=48,kt("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",Dl);class yh extends Gr{_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(e,i,s,A,d,_,b,M,I,k,F,V,j,H,Q,Y,re,ge,oe,ue,ve,Te,Ue,lt,nt,dt,Tt,mt){const st=this.length;return this.resize(st+1),this.emplace(st,e,i,s,A,d,_,b,M,I,k,F,V,j,H,Q,Y,re,ge,oe,ue,ve,Te,Ue,lt,nt,dt,Tt,mt)}emplace(e,i,s,A,d,_,b,M,I,k,F,V,j,H,Q,Y,re,ge,oe,ue,ve,Te,Ue,lt,nt,dt,Tt,mt,st){const Xe=32*e,Lt=16*e;return this.int16[Xe+0]=i,this.int16[Xe+1]=s,this.int16[Xe+2]=A,this.int16[Xe+3]=d,this.int16[Xe+4]=_,this.int16[Xe+5]=b,this.int16[Xe+6]=M,this.int16[Xe+7]=I,this.uint16[Xe+8]=k,this.uint16[Xe+9]=F,this.uint16[Xe+10]=V,this.uint16[Xe+11]=j,this.uint16[Xe+12]=H,this.uint16[Xe+13]=Q,this.uint16[Xe+14]=Y,this.uint16[Xe+15]=re,this.uint16[Xe+16]=ge,this.uint16[Xe+17]=oe,this.uint16[Xe+18]=ue,this.uint16[Xe+19]=ve,this.uint16[Xe+20]=Te,this.uint16[Xe+21]=Ue,this.uint16[Xe+22]=lt,this.uint32[Lt+12]=nt,this.float32[Lt+13]=dt,this.float32[Lt+14]=Tt,this.uint16[Xe+30]=mt,this.uint16[Xe+31]=st,e}}yh.prototype.bytesPerElement=64,kt("StructArrayLayout8i15ui1ul2f2ui64",yh);class Gu extends Gr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const i=this.length;return this.resize(i+1),this.emplace(i,e)}emplace(e,i){return this.float32[1*e+0]=i,e}}Gu.prototype.bytesPerElement=4,kt("StructArrayLayout1f4",Gu);class qu extends Gr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,s){const A=this.length;return this.resize(A+1),this.emplace(A,e,i,s)}emplace(e,i,s,A){const d=3*e;return this.uint16[6*e+0]=i,this.float32[d+1]=s,this.float32[d+2]=A,e}}qu.prototype.bytesPerElement=12,kt("StructArrayLayout1ui2f12",qu);class vh extends Gr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,s){const A=this.length;return this.resize(A+1),this.emplace(A,e,i,s)}emplace(e,i,s,A){const d=4*e;return this.uint32[2*e+0]=i,this.uint16[d+2]=s,this.uint16[d+3]=A,e}}vh.prototype.bytesPerElement=8,kt("StructArrayLayout1ul2ui8",vh);class y extends Gr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i){const s=this.length;return this.resize(s+1),this.emplace(s,e,i)}emplace(e,i,s){const A=2*e;return this.uint16[A+0]=i,this.uint16[A+1]=s,e}}y.prototype.bytesPerElement=4,kt("StructArrayLayout2ui4",y);class t extends Gr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const i=this.length;return this.resize(i+1),this.emplace(i,e)}emplace(e,i){return this.uint16[1*e+0]=i,e}}t.prototype.bytesPerElement=2,kt("StructArrayLayout1ui2",t);class n extends Gr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,s,A){const d=this.length;return this.resize(d+1),this.emplace(d,e,i,s,A)}emplace(e,i,s,A,d){const _=4*e;return this.float32[_+0]=i,this.float32[_+1]=s,this.float32[_+2]=A,this.float32[_+3]=d,e}}n.prototype.bytesPerElement=16,kt("StructArrayLayout4f16",n);class h extends vu{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 it(this.anchorPointX,this.anchorPointY)}}h.prototype.size=20;class f extends _h{get(e){return new h(this,e)}}kt("CollisionBoxArray",f);class x extends vu{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(e){this._structArray.uint8[this._pos1+37]=e}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(e){this._structArray.uint8[this._pos1+38]=e}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(e){this._structArray.uint32[this._pos4+10]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}x.prototype.size=48;class T extends Dl{get(e){return new x(this,e)}}kt("PlacedSymbolArray",T);class C extends vu{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(e){this._structArray.uint32[this._pos4+12]=e}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]}}C.prototype.size=64;class D extends yh{get(e){return new C(this,e)}}kt("SymbolInstanceArray",D);class B extends Gu{getoffsetX(e){return this.float32[1*e+0]}}kt("GlyphOffsetArray",B);class N extends Vu{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}kt("SymbolLineVertexArray",N);class G extends vu{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]}}G.prototype.size=12;class U extends qu{get(e){return new G(this,e)}}kt("TextAnchorOffsetArray",U);class $ extends vu{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]}}$.prototype.size=8;class ie extends vh{get(e){return new $(this,e)}}kt("FeatureIndexArray",ie);class he extends xu{}class Ae extends xu{}class ce extends xu{}class ye extends ju{}class Pe extends mh{}class _e extends bu{}class we extends Na{}class Ce extends Zu{}class be extends wu{}class Le extends Uu{}class Ke extends Tu{}class He extends tu{}class $e extends gh{}class Ye extends Pu{}class xt extends y{}const wt=on([{name:"a_pos",components:2,type:"Int16"}],4),{members:pt}=wt;class Pt{constructor(e=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=e}prepareSegment(e,i,s,A){const d=this.segments[this.segments.length-1];return e>Pt.MAX_VERTEX_ARRAY_LENGTH&&en(`Max vertices per segment is ${Pt.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${Pt.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!d||d.vertexLength+e>Pt.MAX_VERTEX_ARRAY_LENGTH||d.sortKey!==A?this.createNewSegment(i,s,A):d}createNewSegment(e,i,s){const A={vertexOffset:e.length,primitiveOffset:i.length,vertexLength:0,primitiveLength:0,vaos:{}};return s!==void 0&&(A.sortKey=s),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(A),A}getOrCreateLatestSegment(e,i,s){return this.prepareSegment(0,e,i,s)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}get(){return this.segments}destroy(){for(const e of this.segments)for(const i in e.vaos)e.vaos[i].destroy()}static simpleSegment(e,i,s,A){return new Pt([{vertexOffset:e,primitiveOffset:i,vertexLength:s,primitiveLength:A,vaos:{},sortKey:0}])}}function mi(r,e){return 256*(r=Ai(Math.floor(r),0,255))+Ai(Math.floor(e),0,255)}Pt.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,kt("SegmentVector",Pt);const sr=on([{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"}]),Dr=on([{name:"a_dasharray_from",components:4,type:"Uint16"},{name:"a_dasharray_to",components:4,type:"Uint16"}]);var mr,Rr,_r,Yr={exports:{}},Fr={exports:{}},rs={exports:{}},dn=(function(){if(_r)return Yr.exports;_r=1;var r=(mr||(mr=1,Fr.exports=function(i,s){var A,d,_,b,M,I,k,F;for(d=i.length-(A=3&i.length),_=s,M=3432918353,I=461845907,F=0;F<d;)k=255&i.charCodeAt(F)|(255&i.charCodeAt(++F))<<8|(255&i.charCodeAt(++F))<<16|(255&i.charCodeAt(++F))<<24,++F,_=27492+(65535&(b=5*(65535&(_=(_^=k=(65535&(k=(k=(65535&k)*M+(((k>>>16)*M&65535)<<16)&4294967295)<<15|k>>>17))*I+(((k>>>16)*I&65535)<<16)&4294967295)<<13|_>>>19))+((5*(_>>>16)&65535)<<16)&4294967295))+((58964+(b>>>16)&65535)<<16);switch(k=0,A){case 3:k^=(255&i.charCodeAt(F+2))<<16;case 2:k^=(255&i.charCodeAt(F+1))<<8;case 1:_^=k=(65535&(k=(k=(65535&(k^=255&i.charCodeAt(F)))*M+(((k>>>16)*M&65535)<<16)&4294967295)<<15|k>>>17))*I+(((k>>>16)*I&65535)<<16)&4294967295}return _^=i.length,_=2246822507*(65535&(_^=_>>>16))+((2246822507*(_>>>16)&65535)<<16)&4294967295,_=3266489909*(65535&(_^=_>>>13))+((3266489909*(_>>>16)&65535)<<16)&4294967295,(_^=_>>>16)>>>0}),Fr.exports),e=(Rr||(Rr=1,rs.exports=function(i,s){for(var A,d=i.length,_=s^d,b=0;d>=4;)A=1540483477*(65535&(A=255&i.charCodeAt(b)|(255&i.charCodeAt(++b))<<8|(255&i.charCodeAt(++b))<<16|(255&i.charCodeAt(++b))<<24))+((1540483477*(A>>>16)&65535)<<16),_=1540483477*(65535&_)+((1540483477*(_>>>16)&65535)<<16)^(A=1540483477*(65535&(A^=A>>>24))+((1540483477*(A>>>16)&65535)<<16)),d-=4,++b;switch(d){case 3:_^=(255&i.charCodeAt(b+2))<<16;case 2:_^=(255&i.charCodeAt(b+1))<<8;case 1:_=1540483477*(65535&(_^=255&i.charCodeAt(b)))+((1540483477*(_>>>16)&65535)<<16)}return _=1540483477*(65535&(_^=_>>>13))+((1540483477*(_>>>16)&65535)<<16),(_^=_>>>15)>>>0}),rs.exports);return Yr.exports=r,Yr.exports.murmur3=r,Yr.exports.murmur2=e,Yr.exports})(),an=ur(dn);class ms{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,i,s,A){this.ids.push(cl(e)),this.positions.push(i,s,A)}getPositions(e){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const i=cl(e);let s=0,A=this.ids.length-1;for(;s<A;){const _=s+A>>1;this.ids[_]>=i?A=_:s=_+1}const d=[];for(;this.ids[s]===i;)d.push({index:this.positions[3*s],start:this.positions[3*s+1],end:this.positions[3*s+2]}),s++;return d}static serialize(e,i){const s=new Float64Array(e.ids),A=new Uint32Array(e.positions);return Va(s,A,0,s.length-1),i&&i.push(s.buffer,A.buffer),{ids:s,positions:A}}static deserialize(e){const i=new ms;return i.ids=e.ids,i.positions=e.positions,i.indexed=!0,i}}function cl(r){const e=+r;return!isNaN(e)&&e<=Number.MAX_SAFE_INTEGER?e:an(String(r))}function Va(r,e,i,s){for(;i<s;){const A=r[i+s>>1];let d=i-1,_=s+1;for(;;){do d++;while(r[d]<A);do _--;while(r[_]>A);if(d>=_)break;wa(r,d,_),wa(e,3*d,3*_),wa(e,3*d+1,3*_+1),wa(e,3*d+2,3*_+2)}_-i<s-_?(Va(r,e,i,_),i=_+1):(Va(r,e,_+1,s),s=_)}}function wa(r,e,i){const s=r[e];r[e]=r[i],r[i]=s}kt("FeaturePositionMap",ms);class eo{constructor(e,i){this.gl=e.gl,this.location=i}}class kl extends eo{constructor(e,i){super(e,i),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1f(this.location,e))}}class Mu extends eo{constructor(e,i){super(e,i),this.current=[0,0,0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]&&e[2]===this.current[2]&&e[3]===this.current[3]||(this.current=e,this.gl.uniform4f(this.location,e[0],e[1],e[2],e[3]))}}class zl extends eo{constructor(e,i){super(e,i),this.current=oi.transparent}set(e){e.r===this.current.r&&e.g===this.current.g&&e.b===this.current.b&&e.a===this.current.a||(this.current=e,this.gl.uniform4f(this.location,e.r,e.g,e.b,e.a))}}const zo=new Float32Array(16);function Ta(r){return[mi(255*r.r,255*r.g),mi(255*r.b,255*r.a)]}class na{constructor(e,i,s){this.value=e,this.uniformNames=i.map((A=>`u_${A}`)),this.type=s}setUniform(e,i,s){e.set(s.constantOr(this.value))}getBinding(e,i,s){return this.type==="color"?new zl(e,i):new kl(e,i)}}class sa{constructor(e,i){this.uniformNames=i.map((s=>`u_${s}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,i){this.pixelRatioFrom=i.pixelRatio,this.pixelRatioTo=e.pixelRatio,this.patternFrom=i.tlbr,this.patternTo=e.tlbr}setConstantDashPositions(e,i){this.dashTo=[0,e.y,e.height,e.width],this.dashFrom=[0,i.y,i.height,i.width]}setUniform(e,i,s,A){let d=null;A==="u_pattern_to"?d=this.patternTo:A==="u_pattern_from"?d=this.patternFrom:A==="u_dasharray_to"?d=this.dashTo:A==="u_dasharray_from"?d=this.dashFrom:A==="u_pixel_ratio_to"?d=this.pixelRatioTo:A==="u_pixel_ratio_from"&&(d=this.pixelRatioFrom),d!==null&&e.set(d)}getBinding(e,i,s){return s.substr(0,9)==="u_pattern"||s.substr(0,12)==="u_dasharray_"?new Mu(e,i):new kl(e,i)}}class Tr{constructor(e,i,s,A){this.expression=e,this.type=s,this.maxValue=0,this.paintVertexAttributes=i.map((d=>({name:`a_${d}`,type:"Float32",components:s==="color"?2:1,offset:0}))),this.paintVertexArray=new A}populatePaintArray(e,i,s){const A=this.paintVertexArray.length,d=this.expression.evaluate(new ze(0,s),i,{},s.canonical,[],s.formattedSection);this.paintVertexArray.resize(e),this._setPaintValue(A,e,d)}updatePaintArray(e,i,s,A,d){const _=this.expression.evaluate(new ze(0,d),s,A);this._setPaintValue(e,i,_)}_setPaintValue(e,i,s){if(this.type==="color"){const A=Ta(s);for(let d=e;d<i;d++)this.paintVertexArray.emplace(d,A[0],A[1])}else{for(let A=e;A<i;A++)this.paintVertexArray.emplace(A,s);this.maxValue=Math.max(this.maxValue,Math.abs(s))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class gr{constructor(e,i,s,A,d,_){this.expression=e,this.uniformNames=i.map((b=>`u_${b}_t`)),this.type=s,this.useIntegerZoom=A,this.zoom=d,this.maxValue=0,this.paintVertexAttributes=i.map((b=>({name:`a_${b}`,type:"Float32",components:s==="color"?4:2,offset:0}))),this.paintVertexArray=new _}populatePaintArray(e,i,s){const A=this.expression.evaluate(new ze(this.zoom,s),i,{},s.canonical,[],s.formattedSection),d=this.expression.evaluate(new ze(this.zoom+1,s),i,{},s.canonical,[],s.formattedSection),_=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(_,e,A,d)}updatePaintArray(e,i,s,A,d){const _=this.expression.evaluate(new ze(this.zoom,d),s,A),b=this.expression.evaluate(new ze(this.zoom+1,d),s,A);this._setPaintValue(e,i,_,b)}_setPaintValue(e,i,s,A){if(this.type==="color"){const d=Ta(s),_=Ta(A);for(let b=e;b<i;b++)this.paintVertexArray.emplace(b,d[0],d[1],_[0],_[1])}else{for(let d=e;d<i;d++)this.paintVertexArray.emplace(d,s,A);this.maxValue=Math.max(this.maxValue,Math.abs(s),Math.abs(A))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(e,i){const s=this.useIntegerZoom?Math.floor(i.zoom):i.zoom,A=Ai(this.expression.interpolationFactor(s,this.zoom,this.zoom+1),0,1);e.set(A)}getBinding(e,i,s){return new kl(e,i)}}class Vn{constructor(e,i,s,A,d,_){this.expression=e,this.type=i,this.useIntegerZoom=s,this.zoom=A,this.layerId=_,this.zoomInPaintVertexArray=new d,this.zoomOutPaintVertexArray=new d}populatePaintArray(e,i,s){const A=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(e),this.zoomOutPaintVertexArray.resize(e),this._setPaintValues(A,e,this.getPositionIds(i),s)}updatePaintArray(e,i,s,A,d){this._setPaintValues(e,i,this.getPositionIds(s),d)}_setPaintValues(e,i,s,A){const d=this.getPositions(A);if(!d||!s)return;const _=d[s.min],b=d[s.mid],M=d[s.max];if(_&&b&&M)for(let I=e;I<i;I++)this.emplace(this.zoomInPaintVertexArray,I,b,_),this.emplace(this.zoomOutPaintVertexArray,I,b,M)}upload(e){if(this.zoomInPaintVertexArray&&this.zoomInPaintVertexArray.arrayBuffer&&this.zoomOutPaintVertexArray&&this.zoomOutPaintVertexArray.arrayBuffer){const i=this.getVertexAttributes();this.zoomInPaintVertexBuffer=e.createVertexBuffer(this.zoomInPaintVertexArray,i,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=e.createVertexBuffer(this.zoomOutPaintVertexArray,i,this.expression.isStateDependent)}}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class jn extends Vn{getPositions(e){return e.imagePositions}getPositionIds(e){return e.patterns&&e.patterns[this.layerId]}getVertexAttributes(){return sr.members}emplace(e,i,s,A){e.emplace(i,s.tlbr[0],s.tlbr[1],s.tlbr[2],s.tlbr[3],A.tlbr[0],A.tlbr[1],A.tlbr[2],A.tlbr[3],s.pixelRatio,A.pixelRatio)}}class $h extends Vn{getPositions(e){return e.dashPositions}getPositionIds(e){return e.dashes&&e.dashes[this.layerId]}getVertexAttributes(){return Dr.members}emplace(e,i,s,A){e.emplace(i,0,s.y,s.height,s.width,0,A.y,A.height,A.width)}}class Yh{constructor(e,i,s){this.binders={},this._buffers=[];const A=[];for(const d in e.paint._values){if(!s(d))continue;const _=e.paint.get(d);if(!(_ instanceof Vt&&co(_.property.specification)))continue;const b=kc(d,e.type),M=_.value,I=_.property.specification.type,k=_.property.useIntegerZoom,F=_.property.specification["property-type"],V=F==="cross-faded"||F==="cross-faded-data-driven";if(M.kind==="constant")this.binders[d]=V?new sa(M.value,b):new na(M.value,b,I),A.push(`/u_${d}`);else if(M.kind==="source"||V){const j=Xh(d,I,"source");this.binders[d]=V?d==="line-dasharray"?new $h(M,I,k,i,j,e.id):new jn(M,I,k,i,j,e.id):new Tr(M,b,I,j),A.push(`/a_${d}`)}else{const j=Xh(d,I,"composite");this.binders[d]=new gr(M,b,I,k,i,j),A.push(`/z_${d}`)}}this.cacheKey=A.sort().join("")}getMaxValue(e){const i=this.binders[e];return i instanceof Tr||i instanceof gr?i.maxValue:0}populatePaintArrays(e,i,s){for(const A in this.binders){const d=this.binders[A];(d instanceof Tr||d instanceof gr||d instanceof Vn)&&d.populatePaintArray(e,i,s)}}setConstantPatternPositions(e,i){for(const s in this.binders){const A=this.binders[s];A instanceof sa&&A.setConstantPatternPositions(e,i)}}setConstantDashPositions(e,i){for(const s in this.binders){const A=this.binders[s];A instanceof sa&&A.setConstantDashPositions(e,i)}}updatePaintArrays(e,i,s,A,d){let _=!1;for(const b in e){const M=i.getPositions(b);for(const I of M){const k=s.feature(I.index);for(const F in this.binders){const V=this.binders[F];if((V instanceof Tr||V instanceof gr||V instanceof Vn)&&V.expression.isStateDependent===!0){const j=A.paint.get(F);V.expression=j.value,V.updatePaintArray(I.start,I.end,k,e[b],d),_=!0}}}}return _}defines(){const e=[];for(const i in this.binders){const s=this.binders[i];(s instanceof na||s instanceof sa)&&e.push(...s.uniformNames.map((A=>`#define HAS_UNIFORM_${A}`)))}return e}getBinderAttributes(){const e=[];for(const i in this.binders){const s=this.binders[i];if(s instanceof Tr||s instanceof gr)for(let A=0;A<s.paintVertexAttributes.length;A++)e.push(s.paintVertexAttributes[A].name);else if(s instanceof Vn){const A=s.getVertexAttributes();for(const d of A)e.push(d.name)}}return e}getBinderUniforms(){const e=[];for(const i in this.binders){const s=this.binders[i];if(s instanceof na||s instanceof sa||s instanceof gr)for(const A of s.uniformNames)e.push(A)}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e,i){const s=[];for(const A in this.binders){const d=this.binders[A];if(d instanceof na||d instanceof sa||d instanceof gr){for(const _ of d.uniformNames)if(i[_]){const b=d.getBinding(e,i[_],_);s.push({name:_,property:A,binding:b})}}}return s}setUniforms(e,i,s,A){for(const{name:d,property:_,binding:b}of i)this.binders[_].setUniform(b,A,s.get(_),d)}updatePaintBuffers(e){this._buffers=[];for(const i in this.binders){const s=this.binders[i];if(e&&s instanceof Vn){const A=e.fromScale===2?s.zoomInPaintVertexBuffer:s.zoomOutPaintVertexBuffer;A&&this._buffers.push(A)}else(s instanceof Tr||s instanceof gr)&&s.paintVertexBuffer&&this._buffers.push(s.paintVertexBuffer)}}upload(e){for(const i in this.binders){const s=this.binders[i];(s instanceof Tr||s instanceof gr||s instanceof Vn)&&s.upload(e)}this.updatePaintBuffers()}destroy(){for(const e in this.binders){const i=this.binders[e];(i instanceof Tr||i instanceof gr||i instanceof Vn)&&i.destroy()}}}class Ll{constructor(e,i,s=()=>!0){this.programConfigurations={};for(const A of e)this.programConfigurations[A.id]=new Yh(A,i,s);this.needsUpload=!1,this._featureMap=new ms,this._bufferOffset=0}populatePaintArrays(e,i,s,A){for(const d in this.programConfigurations)this.programConfigurations[d].populatePaintArrays(e,i,A);i.id!==void 0&&this._featureMap.add(i.id,s,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,i,s,A){for(const d of s)this.needsUpload=this.programConfigurations[d.id].updatePaintArrays(e,this._featureMap,i,d,A)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const i in this.programConfigurations)this.programConfigurations[i].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}}function kc(r,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"]}[r]||[r.replace(`${e}-`,"").replace(/-/g,"_")]}function Xh(r,e,i){const s={color:{source:bu,composite:n},number:{source:Gu,composite:bu}},A=(function(d){return{"line-pattern":{source:we,composite:we},"fill-pattern":{source:we,composite:we},"fill-extrusion-pattern":{source:we,composite:we},"line-dasharray":{source:Ce,composite:Ce}}[d]})(r);return A&&A[i]||s[e][i]}kt("ConstantBinder",na),kt("CrossFadedConstantBinder",sa),kt("SourceExpressionBinder",Tr),kt("CrossFadedPatternBinder",jn),kt("CrossFadedDasharrayBinder",$h),kt("CompositeExpressionBinder",gr),kt("ProgramConfiguration",Yh,{omit:["_buffers"]}),kt("ProgramConfigurationSet",Ll);const xh=Math.pow(2,14)-1,Al=-xh-1;function fl(r){const e=Oi/r.extent,i=r.loadGeometry();for(let s=0;s<i.length;s++){const A=i[s];for(let d=0;d<A.length;d++){const _=A[d],b=Math.round(_.x*e),M=Math.round(_.y*e);_.x=Ai(b,Al,xh),_.y=Ai(M,Al,xh),(b<_.x||b>_.x+1||M<_.y||M>_.y+1)&&en("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return i}function dl(r,e){return{type:r.type,id:r.id,properties:r.properties,geometry:e?fl(r):[]}}const bh=-32768;function wh(r,e,i,s,A){r.emplaceBack(bh+8*e+s,bh+8*i+A)}class Hu{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((i=>i.id)),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new Ae,this.indexArray=new Ye,this.segments=new Pt,this.programConfigurations=new Ll(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter((i=>i.isStateDependent())).map((i=>i.id))}populate(e,i,s){const A=this.layers[0],d=[];let _=null,b=!1,M=A.type==="heatmap";if(A.type==="circle"){const k=A;_=k.layout.get("circle-sort-key"),b=!_.isConstant(),M=M||k.paint.get("circle-pitch-alignment")==="map"}const I=M?i.subdivisionGranularity.circle:1;for(const{feature:k,id:F,index:V,sourceLayerIndex:j}of e){const H=this.layers[0]._featureFilter.needGeometry,Q=dl(k,H);if(!this.layers[0]._featureFilter.filter(new ze(this.zoom),Q,s))continue;const Y=b?_.evaluate(Q,{},s):void 0,re={id:F,properties:k.properties,type:k.type,sourceLayerIndex:j,index:V,geometry:H?Q.geometry:fl(k),patterns:{},sortKey:Y};d.push(re)}b&&d.sort(((k,F)=>k.sortKey-F.sortKey));for(const k of d){const{geometry:F,index:V,sourceLayerIndex:j}=k,H=e[V].feature;this.addFeature(k,F,V,s,I),i.featureIndex.insert(H,F,V,j,this.index)}}update(e,i,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,i,this.stateDependentLayers,{imagePositions:s})}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,pt),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,i,s,A,d=1){let _;switch(d){case 1:_=[0,7];break;case 3:_=[0,2,5,7];break;case 5:_=[0,1,3,4,6,7];break;case 7:_=[0,1,2,3,4,5,6,7];break;default:throw new Error(`Invalid circle bucket granularity: ${d}; valid values are 1, 3, 5, 7.`)}const b=_.length;for(const M of i)for(const I of M){const k=I.x,F=I.y;if(k<0||k>=Oi||F<0||F>=Oi)continue;const V=this.segments.prepareSegment(b*b,this.layoutVertexArray,this.indexArray,e.sortKey),j=V.vertexLength;for(let H=0;H<b;H++)for(let Q=0;Q<b;Q++)wh(this.layoutVertexArray,k,F,_[Q],_[H]);for(let H=0;H<b-1;H++)for(let Q=0;Q<b-1;Q++){const Y=j+H*b+Q,re=j+(H+1)*b+Q;this.indexArray.emplaceBack(Y,re+1,Y+1),this.indexArray.emplaceBack(Y,re,re+1)}V.vertexLength+=b*b,V.primitiveLength+=(b-1)*(b-1)*2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,s,{imagePositions:{},canonical:A})}}function Wu(r,e){for(let i=0;i<r.length;i++)if(Qu(e,r[i]))return!0;for(let i=0;i<e.length;i++)if(Qu(r,e[i]))return!0;return!!zc(r,e)}function Kh(r,e,i){return!!Qu(r,e)||!!Lc(e,r,i)}function LA(r,e){if(r.length===1)return RA(e,r[0]);for(let i=0;i<e.length;i++){const s=e[i];for(let A=0;A<s.length;A++)if(Qu(r,s[A]))return!0}for(let i=0;i<r.length;i++)if(RA(e,r[i]))return!0;for(let i=0;i<e.length;i++)if(zc(r,e[i]))return!0;return!1}function vp(r,e,i){if(r.length>1){if(zc(r,e))return!0;for(let s=0;s<e.length;s++)if(Lc(e[s],r,i))return!0}for(let s=0;s<r.length;s++)if(Lc(r[s],e,i))return!0;return!1}function zc(r,e){if(r.length===0||e.length===0)return!1;for(let i=0;i<r.length-1;i++){const s=r[i],A=r[i+1];for(let d=0;d<e.length-1;d++)if(xp(s,A,e[d],e[d+1]))return!0}return!1}function xp(r,e,i,s){return hs(r,i,s)!==hs(e,i,s)&&hs(r,e,i)!==hs(r,e,s)}function Lc(r,e,i){const s=i*i;if(e.length===1)return r.distSqr(e[0])<s;for(let A=1;A<e.length;A++)if(BA(r,e[A-1],e[A])<s)return!0;return!1}function BA(r,e,i){const s=e.distSqr(i);if(s===0)return r.distSqr(e);const A=((r.x-e.x)*(i.x-e.x)+(r.y-e.y)*(i.y-e.y))/s;return r.distSqr(A<0?e:A>1?i:i.sub(e)._mult(A)._add(e))}function RA(r,e){let i,s,A,d=!1;for(let _=0;_<r.length;_++){i=r[_];for(let b=0,M=i.length-1;b<i.length;M=b++)s=i[b],A=i[M],s.y>e.y!=A.y>e.y&&e.x<(A.x-s.x)*(e.y-s.y)/(A.y-s.y)+s.x&&(d=!d)}return d}function Qu(r,e){let i=!1;for(let s=0,A=r.length-1;s<r.length;A=s++){const d=r[s],_=r[A];d.y>e.y!=_.y>e.y&&e.x<(_.x-d.x)*(e.y-d.y)/(_.y-d.y)+d.x&&(i=!i)}return i}function bp(r,e,i){const s=i[0],A=i[2];if(r.x<s.x&&e.x<s.x||r.x>A.x&&e.x>A.x||r.y<s.y&&e.y<s.y||r.y>A.y&&e.y>A.y)return!1;const d=hs(r,e,i[0]);return d!==hs(r,e,i[1])||d!==hs(r,e,i[2])||d!==hs(r,e,i[3])}function $u(r,e,i){const s=e.paint.get(r).value;return s.kind==="constant"?s.value:i.programConfigurations.get(e.id).getMaxValue(r)}function Jh(r){return Math.sqrt(r[0]*r[0]+r[1]*r[1])}function ec(r,e,i,s,A){if(!e[0]&&!e[1])return r;const d=it.convert(e)._mult(A);i==="viewport"&&d._rotate(-s);const _=[];for(let b=0;b<r.length;b++)_.push(r[b].sub(d));return _}function wp(r){const e=[];for(let i=0;i<r.length;i++){const s=r[i],A=e.at(-1);(i===0||A&&!s.equals(A))&&e.push(s)}return e}function Tp({queryGeometry:r,size:e},i){return Kh(r,i,e)}function Pp({queryGeometry:r,size:e,transform:i,unwrappedTileID:s,getElevation:A},d){return Kh(r,d,e*(i.projectTileCoordinates(d.x,d.y,s,A).signedDistanceFromCamera/i.cameraToCenterDistance))}function Mp({queryGeometry:r,size:e,transform:i,unwrappedTileID:s,getElevation:A},d){const _=i.projectTileCoordinates(d.x,d.y,s,A).signedDistanceFromCamera,b=e*(i.cameraToCenterDistance/_);return Kh(r,Bc(d,i,s,A),b)}function Ep({queryGeometry:r,size:e,transform:i,unwrappedTileID:s,getElevation:A},d){return Kh(r,Bc(d,i,s,A),e)}function FA({queryGeometry:r,size:e,transform:i,unwrappedTileID:s,getElevation:A,pitchAlignment:d="map",pitchScale:_="map"},b){const M=d==="map"?_==="map"?Tp:Pp:_==="map"?Mp:Ep,I={queryGeometry:r,size:e,transform:i,unwrappedTileID:s,getElevation:A};for(const k of b)for(const F of k)if(M(I,F))return!0;return!1}function Bc(r,e,i,s){const A=e.projectTileCoordinates(r.x,r.y,i,s).point;return new it((.5*A.x+.5)*e.width,(.5*-A.y+.5)*e.height)}let OA,NA;kt("CircleBucket",Hu,{omit:["layers"]});var Sp={get paint(){return NA=NA||new is({"circle-radius":new Mt(qe.paint_circle["circle-radius"]),"circle-color":new Mt(qe.paint_circle["circle-color"]),"circle-blur":new Mt(qe.paint_circle["circle-blur"]),"circle-opacity":new Mt(qe.paint_circle["circle-opacity"]),"circle-translate":new _t(qe.paint_circle["circle-translate"]),"circle-translate-anchor":new _t(qe.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new _t(qe.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new _t(qe.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new Mt(qe.paint_circle["circle-stroke-width"]),"circle-stroke-color":new Mt(qe.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new Mt(qe.paint_circle["circle-stroke-opacity"])})},get layout(){return OA=OA||new is({"circle-sort-key":new Mt(qe.layout_circle["circle-sort-key"])})}};class Cp extends ko{constructor(e,i){super(e,Sp,i)}createBucket(e){return new Hu(e)}queryRadius(e){const i=e;return $u("circle-radius",this,i)+$u("circle-stroke-width",this,i)+Jh(this.paint.get("circle-translate"))}queryIntersectsFeature({queryGeometry:e,feature:i,featureState:s,geometry:A,transform:d,pixelsToTileUnits:_,unwrappedTileID:b,getElevation:M}){const I=ec(e,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),-d.bearingInRadians,_),k=this.paint.get("circle-radius").evaluate(i,s)+this.paint.get("circle-stroke-width").evaluate(i,s),F=this.paint.get("circle-pitch-scale"),V=this.paint.get("circle-pitch-alignment");let j,H;return V==="map"?(j=I,H=k*_):(j=(function(Q,Y,re,ge){return Q.map((oe=>Bc(oe,Y,re,ge)))})(I,d,b,M),H=k),FA({queryGeometry:j,size:H,transform:d,unwrappedTileID:b,getElevation:M,pitchAlignment:V,pitchScale:F},A)}}class VA extends Hu{}let jA;kt("HeatmapBucket",VA,{omit:["layers"]});var Ip={get paint(){return jA=jA||new is({"heatmap-radius":new Mt(qe.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Mt(qe.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new _t(qe.paint_heatmap["heatmap-intensity"]),"heatmap-color":new wn(qe.paint_heatmap["heatmap-color"]),"heatmap-opacity":new _t(qe.paint_heatmap["heatmap-opacity"])})}};function Rc(r,{width:e,height:i},s,A){if(A){if(A instanceof Uint8ClampedArray)A=new Uint8Array(A.buffer);else if(A.length!==e*i*s)throw new RangeError(`mismatched image size. expected: ${A.length} but got: ${e*i*s}`)}else A=new Uint8Array(e*i*s);return r.width=e,r.height=i,r.data=A,r}function ZA(r,{width:e,height:i},s){if(e===r.width&&i===r.height)return;const A=Rc({},{width:e,height:i},s);Fc(r,A,{x:0,y:0},{x:0,y:0},{width:Math.min(r.width,e),height:Math.min(r.height,i)},s),r.width=e,r.height=i,r.data=A.data}function Fc(r,e,i,s,A,d){if(A.width===0||A.height===0)return e;if(A.width>r.width||A.height>r.height||i.x>r.width-A.width||i.y>r.height-A.height)throw new RangeError("out of range source coordinates for image copy");if(A.width>e.width||A.height>e.height||s.x>e.width-A.width||s.y>e.height-A.height)throw new RangeError("out of range destination coordinates for image copy");const _=r.data,b=e.data;if(_===b)throw new Error("srcData equals dstData, so image is already copied");for(let M=0;M<A.height;M++){const I=((i.y+M)*r.width+i.x)*d,k=((s.y+M)*e.width+s.x)*d;for(let F=0;F<A.width*d;F++)b[k+F]=_[I+F]}return e}class Th{constructor(e,i){Rc(this,e,1,i)}resize(e){ZA(this,e,1)}clone(){return new Th({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,i,s,A,d){Fc(e,i,s,A,d,1)}}class mo{constructor(e,i){Rc(this,e,4,i)}resize(e){ZA(this,e,4)}replace(e,i){i?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e}clone(){return new mo({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,i,s,A,d){Fc(e,i,s,A,d,4)}setPixel(e,i,s){const A=4*(e*this.width+i);this.data[A+0]=Math.round(255*s.r/s.a),this.data[A+1]=Math.round(255*s.g/s.a),this.data[A+2]=Math.round(255*s.b/s.a),this.data[A+3]=Math.round(255*s.a)}}function UA(r){const e={},i=r.resolution||256,s=r.clips?r.clips.length:1,A=r.image||new mo({width:i,height:s});if(Math.log(i)/Math.LN2%1!=0)throw new Error(`width is not a power of 2 - ${i}`);const d=(_,b,M)=>{e[r.evaluationKey]=M;const I=r.expression.evaluate(e);A.setPixel(_/4/i,b/4,I)};if(r.clips)for(let _=0,b=0;_<s;++_,b+=4*i)for(let M=0,I=0;M<i;M++,I+=4){const k=M/(i-1),{start:F,end:V}=r.clips[_];d(b,I,F*(1-k)+V*k)}else for(let _=0,b=0;_<i;_++,b+=4)d(0,b,_/(i-1));return A}kt("AlphaImage",Th),kt("RGBAImage",mo);const Oc="big-fb";class Dp extends ko{createBucket(e){return new VA(e)}constructor(e,i){super(e,Ip,i),this.heatmapFbos=new Map,this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){e==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=UA({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbos.has(Oc)&&this.heatmapFbos.delete(Oc)}queryRadius(e){return $u("heatmap-radius",this,e)}queryIntersectsFeature({queryGeometry:e,feature:i,featureState:s,geometry:A,transform:d,pixelsToTileUnits:_,unwrappedTileID:b,getElevation:M}){return FA({queryGeometry:e,size:this.paint.get("heatmap-radius").evaluate(i,s)*_,transform:d,unwrappedTileID:b,getElevation:M},A)}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&!this.isHidden()}}let GA;var kp={get paint(){return GA=GA||new is({"hillshade-illumination-direction":new _t(qe.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-altitude":new _t(qe.paint_hillshade["hillshade-illumination-altitude"]),"hillshade-illumination-anchor":new _t(qe.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new _t(qe.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new _t(qe.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new _t(qe.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new _t(qe.paint_hillshade["hillshade-accent-color"]),"hillshade-method":new _t(qe.paint_hillshade["hillshade-method"])})}};class zp extends ko{constructor(e,i){super(e,kp,i),this.recalculate({zoom:0,zoomHistory:{}},void 0)}getIlluminationProperties(){let e=this.paint.get("hillshade-illumination-direction").values,i=this.paint.get("hillshade-illumination-altitude").values,s=this.paint.get("hillshade-highlight-color").values,A=this.paint.get("hillshade-shadow-color").values;const d=Math.max(e.length,i.length,s.length,A.length);e=e.concat(Array(d-e.length).fill(e.at(-1))),i=i.concat(Array(d-i.length).fill(i.at(-1))),s=s.concat(Array(d-s.length).fill(s.at(-1))),A=A.concat(Array(d-A.length).fill(A.at(-1)));const _=i.map(Ds);return{directionRadians:e.map(Ds),altitudeRadians:_,shadowColor:A,highlightColor:s}}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&!this.isHidden()}}let qA;var Lp={get paint(){return qA=qA||new is({"color-relief-opacity":new _t(qe["paint_color-relief"]["color-relief-opacity"]),"color-relief-color":new wn(qe["paint_color-relief"]["color-relief-color"])})}};class Nc{constructor(e,i,s,A){this.context=e,this.format=s,this.texture=e.gl.createTexture(),this.update(i,A)}update(e,i,s){const{width:A,height:d}=e,_=!(this.size&&this.size[0]===A&&this.size[1]===d||s),{context:b}=this,{gl:M}=b;if(this.useMipmap=!!(i&&i.useMipmap),M.bindTexture(M.TEXTURE_2D,this.texture),b.pixelStoreUnpackFlipY.set(!1),b.pixelStoreUnpack.set(1),b.pixelStoreUnpackPremultiplyAlpha.set(this.format===M.RGBA&&(!i||i.premultiply!==!1)),_)this.size=[A,d],e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||Dn(e)?M.texImage2D(M.TEXTURE_2D,0,this.format,this.format,M.UNSIGNED_BYTE,e):M.texImage2D(M.TEXTURE_2D,0,this.format,A,d,0,this.format,M.UNSIGNED_BYTE,e.data);else{const{x:I,y:k}=s||{x:0,y:0};e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||Dn(e)?M.texSubImage2D(M.TEXTURE_2D,0,I,k,M.RGBA,M.UNSIGNED_BYTE,e):M.texSubImage2D(M.TEXTURE_2D,0,I,k,A,d,M.RGBA,M.UNSIGNED_BYTE,e.data)}this.useMipmap&&this.isSizePowerOfTwo()&&M.generateMipmap(M.TEXTURE_2D),b.pixelStoreUnpackFlipY.setDefault(),b.pixelStoreUnpack.setDefault(),b.pixelStoreUnpackPremultiplyAlpha.setDefault()}bind(e,i,s){const{context:A}=this,{gl:d}=A;d.bindTexture(d.TEXTURE_2D,this.texture),s!==d.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(s=d.LINEAR),e!==this.filter&&(d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,e),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,s||e),this.filter=e),i!==this.wrap&&(d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,i),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,i),this.wrap=i)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}class HA{constructor(e,i,s,A=1,d=1,_=1,b=0){if(this.uid=e,i.height!==i.width)throw new RangeError("DEM tiles must be square");if(s&&!["mapbox","terrarium","custom"].includes(s))return void en(`"${s}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);this.stride=i.height;const M=this.dim=i.height-2;switch(this.data=new Uint32Array(i.data.buffer),s){case"terrarium":this.redFactor=256,this.greenFactor=1,this.blueFactor=1/256,this.baseShift=32768;break;case"custom":this.redFactor=A,this.greenFactor=d,this.blueFactor=_,this.baseShift=b;break;default:this.redFactor=6553.6,this.greenFactor=25.6,this.blueFactor=.1,this.baseShift=1e4}for(let I=0;I<M;I++)this.data[this._idx(-1,I)]=this.data[this._idx(0,I)],this.data[this._idx(M,I)]=this.data[this._idx(M-1,I)],this.data[this._idx(I,-1)]=this.data[this._idx(I,0)],this.data[this._idx(I,M)]=this.data[this._idx(I,M-1)];this.data[this._idx(-1,-1)]=this.data[this._idx(0,0)],this.data[this._idx(M,-1)]=this.data[this._idx(M-1,0)],this.data[this._idx(-1,M)]=this.data[this._idx(0,M-1)],this.data[this._idx(M,M)]=this.data[this._idx(M-1,M-1)],this.min=Number.MAX_SAFE_INTEGER,this.max=Number.MIN_SAFE_INTEGER;for(let I=0;I<M;I++)for(let k=0;k<M;k++){const F=this.get(I,k);F>this.max&&(this.max=F),F<this.min&&(this.min=F)}}get(e,i){const s=new Uint8Array(this.data.buffer),A=4*this._idx(e,i);return this.unpack(s[A],s[A+1],s[A+2])}getUnpackVector(){return[this.redFactor,this.greenFactor,this.blueFactor,this.baseShift]}_idx(e,i){if(e<-1||e>=this.dim+1||i<-1||i>=this.dim+1)throw new RangeError(`Out of range source coordinates for DEM data. x: ${e}, y: ${i}, dim: ${this.dim}`);return(i+1)*this.stride+(e+1)}unpack(e,i,s){return e*this.redFactor+i*this.greenFactor+s*this.blueFactor-this.baseShift}pack(e){return WA(e,this.getUnpackVector())}getPixels(){return new mo({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(e,i,s){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let A=i*this.dim,d=i*this.dim+this.dim,_=s*this.dim,b=s*this.dim+this.dim;switch(i){case-1:A=d-1;break;case 1:d=A+1}switch(s){case-1:_=b-1;break;case 1:b=_+1}const M=-i*this.dim,I=-s*this.dim;for(let k=_;k<b;k++)for(let F=A;F<d;F++)this.data[this._idx(F,k)]=e.data[this._idx(F+M,k+I)]}}function WA(r,e){const i=e[0],s=e[1],A=e[2],d=e[3],_=Math.min(i,s,A),b=Math.round((r+d)/_);return{r:Math.floor(b*_/i)%256,g:Math.floor(b*_/s)%256,b:Math.floor(b*_/A)%256}}kt("DEMData",HA);class Bp extends ko{constructor(e,i){super(e,Lp,i)}_createColorRamp(e){const i={elevationStops:[],colorStops:[]},s=this._transitionablePaint._values["color-relief-color"].value.expression;if(s instanceof v&&s._styleExpression.expression instanceof xr){this.colorRampExpression=s;const _=s._styleExpression.expression;i.elevationStops=_.labels,i.colorStops=[];for(const b of i.elevationStops)i.colorStops.push(_.evaluate({globals:{elevation:b}}))}if(i.elevationStops.length<1&&(i.elevationStops=[0],i.colorStops=[oi.transparent]),i.elevationStops.length<2&&(i.elevationStops.push(i.elevationStops[0]+1),i.colorStops.push(i.colorStops[0])),i.elevationStops.length<=e)return i;const A={elevationStops:[],colorStops:[]},d=(i.elevationStops.length-1)/(e-1);for(let _=0;_<i.elevationStops.length-.5;_+=d)A.elevationStops.push(i.elevationStops[Math.round(_)]),A.colorStops.push(i.colorStops[Math.round(_)]);return en(`Too many colors in specification of ${this.id} color-relief layer, may not render properly. Max possible colors: ${e}, provided: ${i.elevationStops.length}`),A}_colorRampChanged(){return this.colorRampExpression!=this._transitionablePaint._values["color-relief-color"].value.expression}getColorRampTextures(e,i,s){if(this.colorRampTextures&&!this._colorRampChanged())return this.colorRampTextures;const A=this._createColorRamp(i),d=new mo({width:A.colorStops.length,height:1}),_=new mo({width:A.colorStops.length,height:1});for(let b=0;b<A.elevationStops.length;b++){const M=WA(A.elevationStops[b],s);_.setPixel(0,b,new oi(M.r/255,M.g/255,M.b/255,1)),d.setPixel(0,b,A.colorStops[b])}return this.colorRampTextures={elevationTexture:new Nc(e,_,e.gl.RGBA),colorTexture:new Nc(e,d,e.gl.RGBA)},this.colorRampTextures}hasOffscreenPass(){return!this.isHidden()&&!!this.colorRampTextures}}const Rp=on([{name:"a_pos",components:2,type:"Int16"}],4),{members:Fp}=Rp;function tc(r,e,i){const s=i.patternDependencies;let A=!1;for(const d of e){const _=d.paint.get(`${r}-pattern`);_.isConstant()||(A=!0);const b=_.constantOr(null);b&&(A=!0,s[b.to]=!0,s[b.from]=!0)}return A}function Vc(r,e,i,s,A){const{zoom:d}=s,_=A.patternDependencies;for(const b of e){const M=b.paint.get(`${r}-pattern`).value;if(M.kind!=="constant"){let I=M.evaluate({zoom:d-1},i,{},A.availableImages),k=M.evaluate({zoom:d},i,{},A.availableImages),F=M.evaluate({zoom:d+1},i,{},A.availableImages);I=I&&I.name?I.name:I,k=k&&k.name?k.name:k,F=F&&F.name?F.name:F,_[I]=!0,_[k]=!0,_[F]=!0,i.patterns[b.id]={min:I,mid:k,max:F}}}return i}function QA(r,e,i,s,A){let d;if(A===(function(_,b,M,I){let k=0;for(let F=b,V=M-I;F<M;F+=I)k+=(_[V]-_[F])*(_[F+1]+_[V+1]),V=F;return k})(r,e,i,s)>0)for(let _=e;_<i;_+=s)d=KA(_/s|0,r[_],r[_+1],d);else for(let _=i-s;_>=e;_-=s)d=KA(_/s|0,r[_],r[_+1],d);return d&&Yu(d,d.next)&&(Sh(d),d=d.next),d}function Eu(r,e){if(!r)return r;e||(e=r);let i,s=r;do if(i=!1,s.steiner||!Yu(s,s.next)&&pn(s.prev,s,s.next)!==0)s=s.next;else{if(Sh(s),s=e=s.prev,s===s.next)break;i=!0}while(i||s!==e);return e}function Ph(r,e,i,s,A,d,_){if(!r)return;!_&&d&&(function(M,I,k,F){let V=M;do V.z===0&&(V.z=jc(V.x,V.y,I,k,F)),V.prevZ=V.prev,V.nextZ=V.next,V=V.next;while(V!==M);V.prevZ.nextZ=null,V.prevZ=null,(function(j){let H,Q=1;do{let Y,re=j;j=null;let ge=null;for(H=0;re;){H++;let oe=re,ue=0;for(let Te=0;Te<Q&&(ue++,oe=oe.nextZ,oe);Te++);let ve=Q;for(;ue>0||ve>0&&oe;)ue!==0&&(ve===0||!oe||re.z<=oe.z)?(Y=re,re=re.nextZ,ue--):(Y=oe,oe=oe.nextZ,ve--),ge?ge.nextZ=Y:j=Y,Y.prevZ=ge,ge=Y;re=oe}ge.nextZ=null,Q*=2}while(H>1)})(V)})(r,s,A,d);let b=r;for(;r.prev!==r.next;){const M=r.prev,I=r.next;if(d?Np(r,s,A,d):Op(r))e.push(M.i,r.i,I.i),Sh(r),r=I.next,b=I.next;else if((r=I)===b){_?_===1?Ph(r=Vp(Eu(r),e),e,i,s,A,d,2):_===2&&jp(r,e,i,s,A,d):Ph(Eu(r),e,i,s,A,d,1);break}}}function Op(r){const e=r.prev,i=r,s=r.next;if(pn(e,i,s)>=0)return!1;const A=e.x,d=i.x,_=s.x,b=e.y,M=i.y,I=s.y,k=Math.min(A,d,_),F=Math.min(b,M,I),V=Math.max(A,d,_),j=Math.max(b,M,I);let H=s.next;for(;H!==e;){if(H.x>=k&&H.x<=V&&H.y>=F&&H.y<=j&&Mh(A,b,d,M,_,I,H.x,H.y)&&pn(H.prev,H,H.next)>=0)return!1;H=H.next}return!0}function Np(r,e,i,s){const A=r.prev,d=r,_=r.next;if(pn(A,d,_)>=0)return!1;const b=A.x,M=d.x,I=_.x,k=A.y,F=d.y,V=_.y,j=Math.min(b,M,I),H=Math.min(k,F,V),Q=Math.max(b,M,I),Y=Math.max(k,F,V),re=jc(j,H,e,i,s),ge=jc(Q,Y,e,i,s);let oe=r.prevZ,ue=r.nextZ;for(;oe&&oe.z>=re&&ue&&ue.z<=ge;){if(oe.x>=j&&oe.x<=Q&&oe.y>=H&&oe.y<=Y&&oe!==A&&oe!==_&&Mh(b,k,M,F,I,V,oe.x,oe.y)&&pn(oe.prev,oe,oe.next)>=0||(oe=oe.prevZ,ue.x>=j&&ue.x<=Q&&ue.y>=H&&ue.y<=Y&&ue!==A&&ue!==_&&Mh(b,k,M,F,I,V,ue.x,ue.y)&&pn(ue.prev,ue,ue.next)>=0))return!1;ue=ue.nextZ}for(;oe&&oe.z>=re;){if(oe.x>=j&&oe.x<=Q&&oe.y>=H&&oe.y<=Y&&oe!==A&&oe!==_&&Mh(b,k,M,F,I,V,oe.x,oe.y)&&pn(oe.prev,oe,oe.next)>=0)return!1;oe=oe.prevZ}for(;ue&&ue.z<=ge;){if(ue.x>=j&&ue.x<=Q&&ue.y>=H&&ue.y<=Y&&ue!==A&&ue!==_&&Mh(b,k,M,F,I,V,ue.x,ue.y)&&pn(ue.prev,ue,ue.next)>=0)return!1;ue=ue.nextZ}return!0}function Vp(r,e){let i=r;do{const s=i.prev,A=i.next.next;!Yu(s,A)&&YA(s,i,i.next,A)&&Eh(s,A)&&Eh(A,s)&&(e.push(s.i,i.i,A.i),Sh(i),Sh(i.next),i=r=A),i=i.next}while(i!==r);return Eu(i)}function jp(r,e,i,s,A,d){let _=r;do{let b=_.next.next;for(;b!==_.prev;){if(_.i!==b.i&&Hp(_,b)){let M=XA(_,b);return _=Eu(_,_.next),M=Eu(M,M.next),Ph(_,e,i,s,A,d,0),void Ph(M,e,i,s,A,d,0)}b=b.next}_=_.next}while(_!==r)}function Zp(r,e){let i=r.x-e.x;return i===0&&(i=r.y-e.y,i===0)&&(i=(r.next.y-r.y)/(r.next.x-r.x)-(e.next.y-e.y)/(e.next.x-e.x)),i}function Up(r,e){const i=(function(A,d){let _=d;const b=A.x,M=A.y;let I,k=-1/0;if(Yu(A,_))return _;do{if(Yu(A,_.next))return _.next;if(M<=_.y&&M>=_.next.y&&_.next.y!==_.y){const Q=_.x+(M-_.y)*(_.next.x-_.x)/(_.next.y-_.y);if(Q<=b&&Q>k&&(k=Q,I=_.x<_.next.x?_:_.next,Q===b))return I}_=_.next}while(_!==d);if(!I)return null;const F=I,V=I.x,j=I.y;let H=1/0;_=I;do{if(b>=_.x&&_.x>=V&&b!==_.x&&$A(M<j?b:k,M,V,j,M<j?k:b,M,_.x,_.y)){const Q=Math.abs(M-_.y)/(b-_.x);Eh(_,A)&&(Q<H||Q===H&&(_.x>I.x||_.x===I.x&&Gp(I,_)))&&(I=_,H=Q)}_=_.next}while(_!==F);return I})(r,e);if(!i)return e;const s=XA(i,r);return Eu(s,s.next),Eu(i,i.next)}function Gp(r,e){return pn(r.prev,r,e.prev)<0&&pn(e.next,r,r.next)<0}function jc(r,e,i,s,A){return(r=1431655765&((r=858993459&((r=252645135&((r=16711935&((r=(r-i)*A|0)|r<<8))|r<<4))|r<<2))|r<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-s)*A|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function qp(r){let e=r,i=r;do(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next;while(e!==r);return i}function $A(r,e,i,s,A,d,_,b){return(A-_)*(e-b)>=(r-_)*(d-b)&&(r-_)*(s-b)>=(i-_)*(e-b)&&(i-_)*(d-b)>=(A-_)*(s-b)}function Mh(r,e,i,s,A,d,_,b){return!(r===_&&e===b)&&$A(r,e,i,s,A,d,_,b)}function Hp(r,e){return r.next.i!==e.i&&r.prev.i!==e.i&&!(function(i,s){let A=i;do{if(A.i!==i.i&&A.next.i!==i.i&&A.i!==s.i&&A.next.i!==s.i&&YA(A,A.next,i,s))return!0;A=A.next}while(A!==i);return!1})(r,e)&&(Eh(r,e)&&Eh(e,r)&&(function(i,s){let A=i,d=!1;const _=(i.x+s.x)/2,b=(i.y+s.y)/2;do A.y>b!=A.next.y>b&&A.next.y!==A.y&&_<(A.next.x-A.x)*(b-A.y)/(A.next.y-A.y)+A.x&&(d=!d),A=A.next;while(A!==i);return d})(r,e)&&(pn(r.prev,r,e.prev)||pn(r,e.prev,e))||Yu(r,e)&&pn(r.prev,r,r.next)>0&&pn(e.prev,e,e.next)>0)}function pn(r,e,i){return(e.y-r.y)*(i.x-e.x)-(e.x-r.x)*(i.y-e.y)}function Yu(r,e){return r.x===e.x&&r.y===e.y}function YA(r,e,i,s){const A=rc(pn(r,e,i)),d=rc(pn(r,e,s)),_=rc(pn(i,s,r)),b=rc(pn(i,s,e));return A!==d&&_!==b||!(A!==0||!ic(r,i,e))||!(d!==0||!ic(r,s,e))||!(_!==0||!ic(i,r,s))||!(b!==0||!ic(i,e,s))}function ic(r,e,i){return e.x<=Math.max(r.x,i.x)&&e.x>=Math.min(r.x,i.x)&&e.y<=Math.max(r.y,i.y)&&e.y>=Math.min(r.y,i.y)}function rc(r){return r>0?1:r<0?-1:0}function Eh(r,e){return pn(r.prev,r,r.next)<0?pn(r,e,r.next)>=0&&pn(r,r.prev,e)>=0:pn(r,e,r.prev)<0||pn(r,r.next,e)<0}function XA(r,e){const i=Zc(r.i,r.x,r.y),s=Zc(e.i,e.x,e.y),A=r.next,d=e.prev;return r.next=e,e.prev=r,i.next=A,A.prev=i,s.next=i,i.prev=s,d.next=s,s.prev=d,s}function KA(r,e,i,s){const A=Zc(r,e,i);return s?(A.next=s.next,A.prev=s,s.next.prev=A,s.next=A):(A.prev=A,A.next=A),A}function Sh(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function Zc(r,e,i){return{i:r,x:e,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class Xu{constructor(e,i){if(i>e)throw new Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=e,this._minGranularity=i}getGranularityForZoomLevel(e){return Math.max(Math.floor(this._baseZoomGranularity/(1<<e)),this._minGranularity,1)}}class nc{constructor(e){this.fill=e.fill,this.line=e.line,this.tile=e.tile,this.stencil=e.stencil,this.circle=e.circle}}nc.noSubdivision=new nc({fill:new Xu(0,0),line:new Xu(0,0),tile:new Xu(0,0),stencil:new Xu(0,0),circle:1}),kt("SubdivisionGranularityExpression",Xu),kt("SubdivisionGranularitySetting",nc);const Ku=-32768,Ch=32767;class Wp{constructor(e,i){this._vertexBuffer=[],this._vertexDictionary=new Map,this._used=!1,this._granularity=e,this._granularityCellSize=Oi/e,this._canonical=i}_getKey(e,i){return(e+=32768)<<16|i+32768}_vertexToIndex(e,i){if(e<-32768||i<-32768||e>32767||i>32767)throw new Error("Vertex coordinates are out of signed 16 bit integer range.");const s=0|Math.round(e),A=0|Math.round(i),d=this._getKey(s,A);if(this._vertexDictionary.has(d))return this._vertexDictionary.get(d);const _=this._vertexBuffer.length/2;return this._vertexDictionary.set(d,_),this._vertexBuffer.push(s,A),_}_subdivideTrianglesScanline(e){if(this._granularity<2)return(function(A,d){const _=[];for(let b=0;b<d.length;b+=3){const M=d[b],I=d[b+1],k=d[b+2],F=A[2*M],V=A[2*M+1];(A[2*I]-F)*(A[2*k+1]-V)-(A[2*I+1]-V)*(A[2*k]-F)>0?(_.push(M),_.push(k),_.push(I)):(_.push(M),_.push(I),_.push(k))}return _})(this._vertexBuffer,e);const i=[],s=e.length;for(let A=0;A<s;A+=3){const d=[e[A+0],e[A+1],e[A+2]],_=[this._vertexBuffer[2*e[A+0]+0],this._vertexBuffer[2*e[A+0]+1],this._vertexBuffer[2*e[A+1]+0],this._vertexBuffer[2*e[A+1]+1],this._vertexBuffer[2*e[A+2]+0],this._vertexBuffer[2*e[A+2]+1]];let b=1/0,M=1/0,I=-1/0,k=-1/0;for(let Q=0;Q<3;Q++){const Y=_[2*Q],re=_[2*Q+1];b=Math.min(b,Y),I=Math.max(I,Y),M=Math.min(M,re),k=Math.max(k,re)}if(b===I||M===k)continue;const F=Math.floor(b/this._granularityCellSize),V=Math.ceil(I/this._granularityCellSize),j=Math.floor(M/this._granularityCellSize),H=Math.ceil(k/this._granularityCellSize);if(F!==V||j!==H)for(let Q=j;Q<H;Q++){const Y=this._scanlineGenerateVertexRingForCellRow(Q,_,d);Qp(this._vertexBuffer,Y,i)}else i.push(...d)}return i}_scanlineGenerateVertexRingForCellRow(e,i,s){const A=e*this._granularityCellSize,d=A+this._granularityCellSize,_=[];for(let b=0;b<3;b++){const M=i[2*b],I=i[2*b+1],k=i[2*(b+1)%6],F=i[(2*(b+1)+1)%6],V=i[2*(b+2)%6],j=i[(2*(b+2)+1)%6],H=k-M,Q=F-I,Y=H===0,re=Q===0,ge=(A-I)/Q,oe=(d-I)/Q,ue=Math.min(ge,oe),ve=Math.max(ge,oe);if(!re&&(ue>=1||ve<=0)||re&&(I<A||I>d)){F>=A&&F<=d&&_.push(s[(b+1)%3]);continue}!re&&ue>0&&_.push(this._vertexToIndex(M+H*ue,I+Q*ue));const Te=M+H*Math.max(ue,0),Ue=M+H*Math.min(ve,1);Y||this._generateIntraEdgeVertices(_,M,I,k,F,Te,Ue),!re&&ve<1&&_.push(this._vertexToIndex(M+H*ve,I+Q*ve)),(re||F>=A&&F<=d)&&_.push(s[(b+1)%3]),!re&&(F<=A||F>=d)&&this._generateInterEdgeVertices(_,M,I,k,F,V,j,Ue,A,d)}return _}_generateIntraEdgeVertices(e,i,s,A,d,_,b){const M=A-i,I=d-s,k=I===0,F=k?Math.min(i,A):Math.min(_,b),V=k?Math.max(i,A):Math.max(_,b),j=Math.floor(F/this._granularityCellSize)+1,H=Math.ceil(V/this._granularityCellSize)-1;if(k?i<A:_<b)for(let Q=j;Q<=H;Q++){const Y=Q*this._granularityCellSize;e.push(this._vertexToIndex(Y,s+I*(Y-i)/M))}else for(let Q=H;Q>=j;Q--){const Y=Q*this._granularityCellSize;e.push(this._vertexToIndex(Y,s+I*(Y-i)/M))}}_generateInterEdgeVertices(e,i,s,A,d,_,b,M,I,k){const F=d-s,V=_-A,j=b-d,H=(I-d)/j,Q=(k-d)/j,Y=Math.min(H,Q),re=Math.max(H,Q),ge=A+V*Y;let oe=Math.floor(Math.min(ge,M)/this._granularityCellSize)+1,ue=Math.ceil(Math.max(ge,M)/this._granularityCellSize)-1,ve=M<ge;const Te=j===0;if(Te&&(b===I||b===k))return;if(Te||Y>=1||re<=0){const lt=s-b,nt=_+(i-_)*Math.min((I-b)/lt,(k-b)/lt);oe=Math.floor(Math.min(nt,M)/this._granularityCellSize)+1,ue=Math.ceil(Math.max(nt,M)/this._granularityCellSize)-1,ve=M<nt}const Ue=F>0?k:I;if(ve)for(let lt=oe;lt<=ue;lt++)e.push(this._vertexToIndex(lt*this._granularityCellSize,Ue));else for(let lt=ue;lt>=oe;lt--)e.push(this._vertexToIndex(lt*this._granularityCellSize,Ue))}_generateOutline(e){const i=[];for(const s of e){const A=Su(s,this._granularity,!0),d=this._pointArrayToIndices(A),_=[];for(let b=1;b<d.length;b++)_.push(d[b-1]),_.push(d[b]);i.push(_)}return i}_handlePoles(e){let i=!1,s=!1;this._canonical&&(this._canonical.y===0&&(i=!0),this._canonical.y===(1<<this._canonical.z)-1&&(s=!0)),(i||s)&&this._fillPoles(e,i,s)}_ensureNoPoleVertices(){const e=this._vertexBuffer;for(let i=0;i<e.length;i+=2){const s=e[i+1];s===Ku&&(e[i+1]=-32767),s===Ch&&(e[i+1]=32766)}}_generatePoleQuad(e,i,s,A,d,_){A>d!=(_===Ku)?(e.push(i),e.push(s),e.push(this._vertexToIndex(A,_)),e.push(s),e.push(this._vertexToIndex(d,_)),e.push(this._vertexToIndex(A,_))):(e.push(s),e.push(i),e.push(this._vertexToIndex(A,_)),e.push(this._vertexToIndex(d,_)),e.push(s),e.push(this._vertexToIndex(A,_)))}_fillPoles(e,i,s){const A=this._vertexBuffer,d=Oi,_=e.length;for(let b=2;b<_;b+=3){const M=e[b-2],I=e[b-1],k=e[b],F=A[2*M],V=A[2*M+1],j=A[2*I],H=A[2*I+1],Q=A[2*k],Y=A[2*k+1];i&&(V===0&&H===0&&this._generatePoleQuad(e,M,I,F,j,Ku),H===0&&Y===0&&this._generatePoleQuad(e,I,k,j,Q,Ku),Y===0&&V===0&&this._generatePoleQuad(e,k,M,Q,F,Ku)),s&&(V===d&&H===d&&this._generatePoleQuad(e,M,I,F,j,Ch),H===d&&Y===d&&this._generatePoleQuad(e,I,k,j,Q,Ch),Y===d&&V===d&&this._generatePoleQuad(e,k,M,Q,F,Ch))}}_initializeVertices(e){for(let i=0;i<e.length;i+=2)this._vertexToIndex(e[i],e[i+1])}subdividePolygonInternal(e,i){if(this._used)throw new Error("Subdivision: multiple use not allowed.");this._used=!0;const{flattened:s,holeIndices:A}=(function(b){const M=[],I=[];for(const k of b)if(k.length!==0){k!==b[0]&&M.push(I.length/2);for(let F=0;F<k.length;F++)I.push(k[F].x),I.push(k[F].y)}return{flattened:I,holeIndices:M}})(e);let d;this._initializeVertices(s);try{const b=(function(I,k,F=2){const V=k&&k.length,j=V?k[0]*F:I.length;let H=QA(I,0,j,F,!0);const Q=[];if(!H||H.next===H.prev)return Q;let Y,re,ge;if(V&&(H=(function(oe,ue,ve,Te){const Ue=[];for(let lt=0,nt=ue.length;lt<nt;lt++){const dt=QA(oe,ue[lt]*Te,lt<nt-1?ue[lt+1]*Te:oe.length,Te,!1);dt===dt.next&&(dt.steiner=!0),Ue.push(qp(dt))}Ue.sort(Zp);for(let lt=0;lt<Ue.length;lt++)ve=Up(Ue[lt],ve);return ve})(I,k,H,F)),I.length>80*F){Y=I[0],re=I[1];let oe=Y,ue=re;for(let ve=F;ve<j;ve+=F){const Te=I[ve],Ue=I[ve+1];Te<Y&&(Y=Te),Ue<re&&(re=Ue),Te>oe&&(oe=Te),Ue>ue&&(ue=Ue)}ge=Math.max(oe-Y,ue-re),ge=ge!==0?32767/ge:0}return Ph(H,Q,F,Y,re,ge,0),Q})(s,A),M=this._convertIndices(s,b);d=this._subdivideTrianglesScanline(M)}catch(b){console.error(b)}let _=[];return i&&(_=this._generateOutline(e)),this._ensureNoPoleVertices(),this._handlePoles(d),{verticesFlattened:this._vertexBuffer,indicesTriangles:d,indicesLineList:_}}_convertIndices(e,i){const s=[];for(let A=0;A<i.length;A++)s.push(this._vertexToIndex(e[2*i[A]],e[2*i[A]+1]));return s}_pointArrayToIndices(e){const i=[];for(let s=0;s<e.length;s++){const A=e[s];i.push(this._vertexToIndex(A.x,A.y))}return i}}function JA(r,e,i,s=!0){return new Wp(i,e).subdividePolygonInternal(r,s)}function Su(r,e,i=!1){if(!r||r.length<1)return[];if(r.length<2)return[];const s=r[0],A=r[r.length-1],d=i&&(s.x!==A.x||s.y!==A.y);if(e<2)return d?[...r,r[0]]:[...r];const _=Math.floor(Oi/e),b=[];b.push(new it(r[0].x,r[0].y));const M=r.length,I=d?M:M-1;for(let k=0;k<I;k++){const F=r[k],V=k<M-1?r[k+1]:r[0],j=F.x,H=F.y,Q=V.x,Y=V.y,re=j!==Q,ge=H!==Y;if(!re&&!ge)continue;const oe=Q-j,ue=Y-H,ve=Math.abs(oe),Te=Math.abs(ue);let Ue=j,lt=H;for(;;){const dt=oe>0?(Math.floor(Ue/_)+1)*_:(Math.ceil(Ue/_)-1)*_,Tt=ue>0?(Math.floor(lt/_)+1)*_:(Math.ceil(lt/_)-1)*_,mt=Math.abs(Ue-dt),st=Math.abs(lt-Tt),Xe=Math.abs(Ue-Q),Lt=Math.abs(lt-Y),Ct=re?mt/ve:Number.POSITIVE_INFINITY,Ot=ge?st/Te:Number.POSITIVE_INFINITY;if((Xe<=mt||!re)&&(Lt<=st||!ge))break;if(Ct<Ot&&re||!ge){Ue=dt,lt+=ue*Ct;const Et=new it(Ue,Math.round(lt));b[b.length-1].x===Et.x&&b[b.length-1].y===Et.y||b.push(Et)}else{Ue+=oe*Ot,lt=Tt;const Et=new it(Math.round(Ue),lt);b[b.length-1].x===Et.x&&b[b.length-1].y===Et.y||b.push(Et)}}const nt=new it(Q,Y);b[b.length-1].x===nt.x&&b[b.length-1].y===nt.y||b.push(nt)}return b}function Qp(r,e,i){if(e.length===0)throw new Error("Subdivision vertex ring is empty.");let s=0,A=r[2*e[0]];for(let M=1;M<e.length;M++){const I=r[2*e[M]];I<A&&(A=I,s=M)}const d=e.length;let _=s,b=(_+1)%d;for(;;){const M=_-1>=0?_-1:d-1,I=(b+1)%d,k=r[2*e[M]],F=r[2*e[I]],V=r[2*e[_]],j=r[2*e[_]+1],H=r[2*e[b]+1];let Q=!1;if(k<F)Q=!0;else if(k>F)Q=!1;else{const Y=H-j,re=-(r[2*e[b]]-V),ge=j<H?1:-1;((k-V)*Y+(r[2*e[M]+1]-j)*re)*ge>((F-V)*Y+(r[2*e[I]+1]-j)*re)*ge&&(Q=!0)}if(Q){const Y=e[M],re=e[_],ge=e[b];Y!==re&&Y!==ge&&re!==ge&&i.push(ge,re,Y),_--,_<0&&(_=d-1)}else{const Y=e[I],re=e[_],ge=e[b];Y!==re&&Y!==ge&&re!==ge&&i.push(ge,re,Y),b++,b>=d&&(b=0)}if(M===I)break}}function ef(r,e,i,s,A,d,_,b,M){const I=A.length/2,k=_&&b&&M;if(I<Pt.MAX_VERTEX_ARRAY_LENGTH){const F=e.prepareSegment(I,i,s),V=F.vertexLength;for(let Q=0;Q<d.length;Q+=3)s.emplaceBack(V+d[Q],V+d[Q+1],V+d[Q+2]);let j,H;F.vertexLength+=I,F.primitiveLength+=d.length/3,k&&(H=_.prepareSegment(I,i,b),j=H.vertexLength,H.vertexLength+=I);for(let Q=0;Q<A.length;Q+=2)r(A[Q],A[Q+1]);if(k)for(let Q=0;Q<M.length;Q++){const Y=M[Q];for(let re=1;re<Y.length;re+=2)b.emplaceBack(j+Y[re-1],j+Y[re]);H.primitiveLength+=Y.length/2}}else(function(F,V,j,H,Q,Y){const re=[];for(let Te=0;Te<H.length/2;Te++)re.push(-1);const ge={count:0};let oe=0,ue=F.getOrCreateLatestSegment(V,j),ve=ue.vertexLength;for(let Te=2;Te<Q.length;Te+=3){const Ue=Q[Te-2],lt=Q[Te-1],nt=Q[Te];let dt=re[Ue]<oe,Tt=re[lt]<oe,mt=re[nt]<oe;ue.vertexLength+((dt?1:0)+(Tt?1:0)+(mt?1:0))>Pt.MAX_VERTEX_ARRAY_LENGTH&&(ue=F.createNewSegment(V,j),oe=ge.count,dt=!0,Tt=!0,mt=!0,ve=0);const st=Ih(re,H,Y,ge,Ue,dt,ue),Xe=Ih(re,H,Y,ge,lt,Tt,ue),Lt=Ih(re,H,Y,ge,nt,mt,ue);j.emplaceBack(ve+st-oe,ve+Xe-oe,ve+Lt-oe),ue.primitiveLength++}})(e,i,s,A,d,r),k&&(function(F,V,j,H,Q,Y){const re=[];for(let Te=0;Te<H.length/2;Te++)re.push(-1);const ge={count:0};let oe=0,ue=F.getOrCreateLatestSegment(V,j),ve=ue.vertexLength;for(let Te=0;Te<Q.length;Te++){const Ue=Q[Te];for(let lt=1;lt<Q[Te].length;lt+=2){const nt=Ue[lt-1],dt=Ue[lt];let Tt=re[nt]<oe,mt=re[dt]<oe;ue.vertexLength+((Tt?1:0)+(mt?1:0))>Pt.MAX_VERTEX_ARRAY_LENGTH&&(ue=F.createNewSegment(V,j),oe=ge.count,Tt=!0,mt=!0,ve=0);const st=Ih(re,H,Y,ge,nt,Tt,ue),Xe=Ih(re,H,Y,ge,dt,mt,ue);j.emplaceBack(ve+st-oe,ve+Xe-oe),ue.primitiveLength++}}})(_,i,b,A,M,r),e.forceNewSegmentOnNextPrepare(),_==null||_.forceNewSegmentOnNextPrepare()}function Ih(r,e,i,s,A,d,_){if(d){const b=s.count;return i(e[2*A],e[2*A+1]),r[A]=s.count,s.count++,_.vertexLength++,b}return r[A]}class Uc{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((i=>i.id)),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.layoutVertexArray=new ce,this.indexArray=new Ye,this.indexArray2=new xt,this.programConfigurations=new Ll(e.layers,e.zoom),this.segments=new Pt,this.segments2=new Pt,this.stateDependentLayerIds=this.layers.filter((i=>i.isStateDependent())).map((i=>i.id))}populate(e,i,s){this.hasDependencies=tc("fill",this.layers,i);const A=this.layers[0].layout.get("fill-sort-key"),d=!A.isConstant(),_=[];for(const{feature:b,id:M,index:I,sourceLayerIndex:k}of e){const F=this.layers[0]._featureFilter.needGeometry,V=dl(b,F);if(!this.layers[0]._featureFilter.filter(new ze(this.zoom),V,s))continue;const j=d?A.evaluate(V,{},s,i.availableImages):void 0,H={id:M,properties:b.properties,type:b.type,sourceLayerIndex:k,index:I,geometry:F?V.geometry:fl(b),patterns:{},sortKey:j};_.push(H)}d&&_.sort(((b,M)=>b.sortKey-M.sortKey));for(const b of _){const{geometry:M,index:I,sourceLayerIndex:k}=b;if(this.hasDependencies){const F=Vc("fill",this.layers,b,{zoom:this.zoom},i);this.patternFeatures.push(F)}else this.addFeature(b,M,I,s,{},i.subdivisionGranularity);i.featureIndex.insert(e[I].feature,M,I,k,this.index)}}update(e,i,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,i,this.stateDependentLayers,{imagePositions:s})}addFeatures(e,i,s){for(const A of this.patternFeatures)this.addFeature(A,A.geometry,A.index,i,s,e.subdivisionGranularity)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Fp),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),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(e,i,s,A,d,_){for(const b of ma(i,500)){const M=JA(b,A,_.fill.getGranularityForZoomLevel(A.z)),I=this.layoutVertexArray;ef(((k,F)=>{I.emplaceBack(k,F)}),this.segments,this.layoutVertexArray,this.indexArray,M.verticesFlattened,M.indicesTriangles,this.segments2,this.indexArray2,M.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,s,{imagePositions:d,canonical:A})}}let tf,rf;kt("FillBucket",Uc,{omit:["layers","patternFeatures"]});var $p={get paint(){return rf=rf||new is({"fill-antialias":new _t(qe.paint_fill["fill-antialias"]),"fill-opacity":new Mt(qe.paint_fill["fill-opacity"]),"fill-color":new Mt(qe.paint_fill["fill-color"]),"fill-outline-color":new Mt(qe.paint_fill["fill-outline-color"]),"fill-translate":new _t(qe.paint_fill["fill-translate"]),"fill-translate-anchor":new _t(qe.paint_fill["fill-translate-anchor"]),"fill-pattern":new li(qe.paint_fill["fill-pattern"])})},get layout(){return tf=tf||new is({"fill-sort-key":new Mt(qe.layout_fill["fill-sort-key"])})}};class Yp extends ko{constructor(e,i){super(e,$p,i)}recalculate(e,i){super.recalculate(e,i);const s=this.paint._values["fill-outline-color"];s.value.kind==="constant"&&s.value.value===void 0&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(e){return new Uc(e)}queryRadius(){return Jh(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:e,geometry:i,transform:s,pixelsToTileUnits:A}){return LA(ec(e,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-s.bearingInRadians,A),i)}isTileClipped(){return!0}}const Xp=on([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),Kp=on([{name:"a_centroid",components:2,type:"Int16"}],4),{members:Jp}=Xp;class Dh{constructor(e,i,s,A,d){this.properties={},this.extent=s,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=A,this._values=d,e.readFields(e0,this,i)}loadGeometry(){const e=this._pbf;e.pos=this._geometry;const i=e.readVarint()+e.pos,s=[];let A,d=1,_=0,b=0,M=0;for(;e.pos<i;){if(_<=0){const I=e.readVarint();d=7&I,_=I>>3}if(_--,d===1||d===2)b+=e.readSVarint(),M+=e.readSVarint(),d===1&&(A&&s.push(A),A=[]),A&&A.push(new it(b,M));else{if(d!==7)throw new Error(`unknown command ${d}`);A&&A.push(A[0].clone())}}return A&&s.push(A),s}bbox(){const e=this._pbf;e.pos=this._geometry;const i=e.readVarint()+e.pos;let s=1,A=0,d=0,_=0,b=1/0,M=-1/0,I=1/0,k=-1/0;for(;e.pos<i;){if(A<=0){const F=e.readVarint();s=7&F,A=F>>3}if(A--,s===1||s===2)d+=e.readSVarint(),_+=e.readSVarint(),d<b&&(b=d),d>M&&(M=d),_<I&&(I=_),_>k&&(k=_);else if(s!==7)throw new Error(`unknown command ${s}`)}return[b,I,M,k]}toGeoJSON(e,i,s){const A=this.extent*Math.pow(2,s),d=this.extent*e,_=this.extent*i,b=this.loadGeometry();function M(V){return[360*(V.x+d)/A-180,360/Math.PI*Math.atan(Math.exp((1-2*(V.y+_)/A)*Math.PI))-90]}function I(V){return V.map(M)}let k;if(this.type===1){const V=[];for(const H of b)V.push(H[0]);const j=I(V);k=V.length===1?{type:"Point",coordinates:j[0]}:{type:"MultiPoint",coordinates:j}}else if(this.type===2){const V=b.map(I);k=V.length===1?{type:"LineString",coordinates:V[0]}:{type:"MultiLineString",coordinates:V}}else{if(this.type!==3)throw new Error("unknown feature type");{const V=nf(b),j=[];for(const H of V)j.push(H.map(I));k=j.length===1?{type:"Polygon",coordinates:j[0]}:{type:"MultiPolygon",coordinates:j}}}const F={type:"Feature",geometry:k,properties:this.properties};return this.id!=null&&(F.id=this.id),F}}function e0(r,e,i){r===1?e.id=i.readVarint():r===2?(function(s,A){const d=s.readVarint()+s.pos;for(;s.pos<d;){const _=A._keys[s.readVarint()],b=A._values[s.readVarint()];A.properties[_]=b}})(i,e):r===3?e.type=i.readVarint():r===4&&(e._geometry=i.pos)}function nf(r){const e=r.length;if(e<=1)return[r];const i=[];let s,A;for(let d=0;d<e;d++){const _=t0(r[d]);_!==0&&(A===void 0&&(A=_<0),A===_<0?(s&&i.push(s),s=[r[d]]):s&&s.push(r[d]))}return s&&i.push(s),i}function t0(r){let e=0;for(let i,s,A=0,d=r.length,_=d-1;A<d;_=A++)i=r[A],s=r[_],e+=(s.x-i.x)*(i.y+s.y);return e}Dh.types=["Unknown","Point","LineString","Polygon"];class i0{constructor(e,i){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],e.readFields(r0,this,i),this.length=this._features.length}feature(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];const i=this._pbf.readVarint()+this._pbf.pos;return new Dh(this._pbf,i,this.extent,this._keys,this._values)}}function r0(r,e,i){r===15?e.version=i.readVarint():r===1?e.name=i.readString():r===5?e.extent=i.readVarint():r===2?e._features.push(i.pos):r===3?e._keys.push(i.readString()):r===4&&e._values.push((function(s){let A=null;const d=s.readVarint()+s.pos;for(;s.pos<d;){const _=s.readVarint()>>3;A=_===1?s.readString():_===2?s.readFloat():_===3?s.readDouble():_===4?s.readVarint64():_===5?s.readVarint():_===6?s.readSVarint():_===7?s.readBoolean():null}if(A==null)throw new Error("unknown feature value");return A})(i))}class sf{constructor(e,i){this.layers=e.readFields(n0,{},i)}}function n0(r,e,i){if(r===3){const s=new i0(i,i.readVarint()+i.pos);s.length&&(e[s.name]=s)}}const Gc=Math.pow(2,13);function kh(r,e,i,s,A,d,_,b){r.emplaceBack(e,i,2*Math.floor(s*Gc)+_,A*Gc*2,d*Gc*2,Math.round(b))}class qc{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((i=>i.id)),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new ye,this.centroidVertexArray=new he,this.indexArray=new Ye,this.programConfigurations=new Ll(e.layers,e.zoom),this.segments=new Pt,this.stateDependentLayerIds=this.layers.filter((i=>i.isStateDependent())).map((i=>i.id))}populate(e,i,s){this.features=[],this.hasDependencies=tc("fill-extrusion",this.layers,i);for(const{feature:A,id:d,index:_,sourceLayerIndex:b}of e){const M=this.layers[0]._featureFilter.needGeometry,I=dl(A,M);if(!this.layers[0]._featureFilter.filter(new ze(this.zoom),I,s))continue;const k={id:d,sourceLayerIndex:b,index:_,geometry:M?I.geometry:fl(A),properties:A.properties,type:A.type,patterns:{}};this.hasDependencies?this.features.push(Vc("fill-extrusion",this.layers,k,{zoom:this.zoom},i)):this.addFeature(k,k.geometry,_,s,{},i.subdivisionGranularity),i.featureIndex.insert(A,k.geometry,_,b,this.index,!0)}}addFeatures(e,i,s){for(const A of this.features){const{geometry:d}=A;this.addFeature(A,d,A.index,i,s,e.subdivisionGranularity)}}update(e,i,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,i,this.stateDependentLayers,{imagePositions:s})}isEmpty(){return this.layoutVertexArray.length===0&&this.centroidVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Jp),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,Kp.members,!0),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(e,i,s,A,d,_){for(const b of ma(i,500)){const M={x:0,y:0,sampleCount:0},I=this.layoutVertexArray.length;this.processPolygon(M,A,e,b,_);const k=this.layoutVertexArray.length-I,F=Math.floor(M.x/M.sampleCount),V=Math.floor(M.y/M.sampleCount);for(let j=0;j<k;j++)this.centroidVertexArray.emplaceBack(F,V)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,s,{imagePositions:d,canonical:A})}processPolygon(e,i,s,A,d){if(A.length<1||of(A[0]))return;for(const F of A)F.length!==0&&s0(e,F);const _={segment:this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray)},b=d.fill.getGranularityForZoomLevel(i.z),M=Dh.types[s.type]==="Polygon";for(const F of A){if(F.length===0||of(F))continue;const V=Su(F,b,M);this._generateSideFaces(V,_)}if(!M)return;const I=JA(A,i,b,!1),k=this.layoutVertexArray;ef(((F,V)=>{kh(k,F,V,0,0,1,1,0)}),this.segments,this.layoutVertexArray,this.indexArray,I.verticesFlattened,I.indicesTriangles)}_generateSideFaces(e,i){let s=0;for(let A=1;A<e.length;A++){const d=e[A],_=e[A-1];if(o0(d,_))continue;i.segment.vertexLength+4>Pt.MAX_VERTEX_ARRAY_LENGTH&&(i.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const b=d.sub(_)._perp()._unit(),M=_.dist(d);s+M>32768&&(s=0),kh(this.layoutVertexArray,d.x,d.y,b.x,b.y,0,0,s),kh(this.layoutVertexArray,d.x,d.y,b.x,b.y,0,1,s),s+=M,kh(this.layoutVertexArray,_.x,_.y,b.x,b.y,0,0,s),kh(this.layoutVertexArray,_.x,_.y,b.x,b.y,0,1,s);const I=i.segment.vertexLength;this.indexArray.emplaceBack(I,I+2,I+1),this.indexArray.emplaceBack(I+1,I+2,I+3),i.segment.vertexLength+=4,i.segment.primitiveLength+=2}}}function s0(r,e){for(let i=0;i<e.length;i++){const s=e[i];i===e.length-1&&e[0].x===s.x&&e[0].y===s.y||(r.x+=s.x,r.y+=s.y,r.sampleCount++)}}function o0(r,e){return r.x===e.x&&(r.x<0||r.x>Oi)||r.y===e.y&&(r.y<0||r.y>Oi)}function of(r){return r.every((e=>e.x<0))||r.every((e=>e.x>Oi))||r.every((e=>e.y<0))||r.every((e=>e.y>Oi))}let af;kt("FillExtrusionBucket",qc,{omit:["layers","features"]});var a0={get paint(){return af=af||new is({"fill-extrusion-opacity":new _t(qe["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Mt(qe["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new _t(qe["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new _t(qe["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new li(qe["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Mt(qe["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Mt(qe["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new _t(qe["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class l0 extends ko{constructor(e,i){super(e,a0,i)}createBucket(e){return new qc(e)}queryRadius(){return Jh(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:e,feature:i,featureState:s,geometry:A,transform:d,pixelsToTileUnits:_,pixelPosMatrix:b}){const M=ec(e,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-d.bearingInRadians,_),I=this.paint.get("fill-extrusion-height").evaluate(i,s),k=this.paint.get("fill-extrusion-base").evaluate(i,s),F=(function(j,H){const Q=[];for(const Y of j){const re=[Y.x,Y.y,0,1];Cn(re,re,H),Q.push(new it(re[0]/re[3],re[1]/re[3]))}return Q})(M,b),V=(function(j,H,Q,Y){const re=[],ge=[],oe=Y[8]*H,ue=Y[9]*H,ve=Y[10]*H,Te=Y[11]*H,Ue=Y[8]*Q,lt=Y[9]*Q,nt=Y[10]*Q,dt=Y[11]*Q;for(const Tt of j){const mt=[],st=[];for(const Xe of Tt){const Lt=Xe.x,Ct=Xe.y,Ot=Y[0]*Lt+Y[4]*Ct+Y[12],Et=Y[1]*Lt+Y[5]*Ct+Y[13],Ut=Y[2]*Lt+Y[6]*Ct+Y[14],ji=Y[3]*Lt+Y[7]*Ct+Y[15],Di=Ut+ve,Or=ji+Te,Ps=Ot+Ue,Tn=Et+lt,Nr=Ut+nt,kr=ji+dt,rr=new it((Ot+oe)/Or,(Et+ue)/Or);rr.z=Di/Or,mt.push(rr);const Xr=new it(Ps/kr,Tn/kr);Xr.z=Nr/kr,st.push(Xr)}re.push(mt),ge.push(st)}return[re,ge]})(A,k,I,b);return(function(j,H,Q){let Y=1/0;LA(Q,H)&&(Y=lf(Q,H[0]));for(let re=0;re<H.length;re++){const ge=H[re],oe=j[re];for(let ue=0;ue<ge.length-1;ue++){const ve=ge[ue],Te=[ve,ge[ue+1],oe[ue+1],oe[ue],ve];Wu(Q,Te)&&(Y=Math.min(Y,lf(Q,Te)))}}return Y!==1/0&&Y})(V[0],V[1],F)}}function zh(r,e){return r.x*e.x+r.y*e.y}function lf(r,e){if(r.length===1){let i=0;const s=e[i++];let A;for(;!A||s.equals(A);)if(A=e[i++],!A)return 1/0;for(;i<e.length;i++){const d=e[i],_=r[0],b=A.sub(s),M=d.sub(s),I=_.sub(s),k=zh(b,b),F=zh(b,M),V=zh(M,M),j=zh(I,b),H=zh(I,M),Q=k*V-F*F,Y=(V*j-F*H)/Q,re=(k*H-F*j)/Q,ge=s.z*(1-Y-re)+A.z*Y+d.z*re;if(isFinite(ge))return ge}return 1/0}{let i=1/0;for(const s of e)i=Math.min(i,s.z);return i}}const u0=on([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"}],4),{members:h0}=u0,c0=on([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]),{members:A0}=c0,f0=Math.cos(Math.PI/180*37.5),uf=Math.pow(2,14)/.5;class Hc{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((i=>i.id)),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((i=>{this.gradients[i.id]={}})),this.layoutVertexArray=new Pe,this.layoutVertexArray2=new _e,this.indexArray=new Ye,this.programConfigurations=new Ll(e.layers,e.zoom),this.segments=new Pt,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((i=>i.isStateDependent())).map((i=>i.id))}populate(e,i,s){this.hasDependencies=tc("line",this.layers,i)||this.hasLineDasharray(this.layers);const A=this.layers[0].layout.get("line-sort-key"),d=!A.isConstant(),_=[];for(const{feature:b,id:M,index:I,sourceLayerIndex:k}of e){const F=this.layers[0]._featureFilter.needGeometry,V=dl(b,F);if(!this.layers[0]._featureFilter.filter(new ze(this.zoom),V,s))continue;const j=d?A.evaluate(V,{},s):void 0,H={id:M,properties:b.properties,type:b.type,sourceLayerIndex:k,index:I,geometry:F?V.geometry:fl(b),patterns:{},dashes:{},sortKey:j};_.push(H)}d&&_.sort(((b,M)=>b.sortKey-M.sortKey));for(const b of _){const{geometry:M,index:I,sourceLayerIndex:k}=b;this.hasDependencies?(tc("line",this.layers,i)?Vc("line",this.layers,b,{zoom:this.zoom},i):this.hasLineDasharray(this.layers)&&this.addLineDashDependencies(this.layers,b,this.zoom,i),this.patternFeatures.push(b)):this.addFeature(b,M,I,s,{},{},i.subdivisionGranularity),i.featureIndex.insert(e[I].feature,M,I,k,this.index)}}update(e,i,s,A){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,i,this.stateDependentLayers,{imagePositions:s,dashPositions:A})}addFeatures(e,i,s,A){for(const d of this.patternFeatures)this.addFeature(d,d.geometry,d.index,i,s,A,e.subdivisionGranularity)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,A0)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,h0),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,i,s,A,d,_,b){const M=this.layers[0].layout,I=M.get("line-join").evaluate(e,{}),k=M.get("line-cap"),F=M.get("line-miter-limit"),V=M.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const j of i)this.addLine(j,e,I,k,F,V,A,b);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,s,{imagePositions:d,dashPositions:_,canonical:A})}addLine(e,i,s,A,d,_,b,M){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,e=Su(e,b?M.line.getGranularityForZoomLevel(b.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let oe=0;oe<e.length-1;oe++)this.totalDistance+=e[oe].dist(e[oe+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const I=Dh.types[i.type]==="Polygon";let k=e.length;for(;k>=2&&e[k-1].equals(e[k-2]);)k--;let F=0;for(;F<k-1&&e[F].equals(e[F+1]);)F++;if(k<(I?3:2))return;s==="bevel"&&(d=1.05);const V=this.overscaling<=16?122880/(512*this.overscaling):0,j=this.segments.prepareSegment(10*k,this.layoutVertexArray,this.indexArray);let H,Q,Y,re,ge;this.e1=this.e2=-1,I&&(H=e[k-2],ge=e[F].sub(H)._unit()._perp());for(let oe=F;oe<k;oe++){if(Y=oe===k-1?I?e[F+1]:void 0:e[oe+1],Y&&e[oe].equals(Y))continue;ge&&(re=ge),H&&(Q=H),H=e[oe],ge=Y?Y.sub(H)._unit()._perp():re,re=re||ge;let ue=re.add(ge);ue.x===0&&ue.y===0||ue._unit();const ve=re.x*ge.x+re.y*ge.y,Te=ue.x*ge.x+ue.y*ge.y,Ue=Te!==0?1/Te:1/0,lt=2*Math.sqrt(2-2*Te),nt=Te<f0&&Q&&Y,dt=re.x*ge.y-re.y*ge.x>0;if(nt&&oe>F){const st=H.dist(Q);if(st>2*V){const Xe=H.sub(H.sub(Q)._mult(V/st)._round());this.updateDistance(Q,Xe),this.addCurrentVertex(Xe,re,0,0,j),Q=Xe}}const Tt=Q&&Y;let mt=Tt?s:I?"butt":A;if(Tt&&mt==="round"&&(Ue<_?mt="miter":Ue<=2&&(mt="fakeround")),mt==="miter"&&Ue>d&&(mt="bevel"),mt==="bevel"&&(Ue>2&&(mt="flipbevel"),Ue<d&&(mt="miter")),Q&&this.updateDistance(Q,H),mt==="miter")ue._mult(Ue),this.addCurrentVertex(H,ue,0,0,j);else if(mt==="flipbevel"){if(Ue>100)ue=ge.mult(-1);else{const st=Ue*re.add(ge).mag()/re.sub(ge).mag();ue._perp()._mult(st*(dt?-1:1))}this.addCurrentVertex(H,ue,0,0,j),this.addCurrentVertex(H,ue.mult(-1),0,0,j)}else if(mt==="bevel"||mt==="fakeround"){const st=-Math.sqrt(Ue*Ue-1),Xe=dt?st:0,Lt=dt?0:st;if(Q&&this.addCurrentVertex(H,re,Xe,Lt,j),mt==="fakeround"){const Ct=Math.round(180*lt/Math.PI/20);for(let Ot=1;Ot<Ct;Ot++){let Et=Ot/Ct;if(Et!==.5){const ji=Et-.5;Et+=Et*ji*(Et-1)*((1.0904+ve*(ve*(3.55645-1.43519*ve)-3.2452))*ji*ji+(.848013+ve*(.215638*ve-1.06021)))}const Ut=ge.sub(re)._mult(Et)._add(re)._unit()._mult(dt?-1:1);this.addHalfVertex(H,Ut.x,Ut.y,!1,dt,0,j)}}Y&&this.addCurrentVertex(H,ge,-Xe,-Lt,j)}else if(mt==="butt")this.addCurrentVertex(H,ue,0,0,j);else if(mt==="square"){const st=Q?1:-1;this.addCurrentVertex(H,ue,st,st,j)}else mt==="round"&&(Q&&(this.addCurrentVertex(H,re,0,0,j),this.addCurrentVertex(H,re,1,1,j,!0)),Y&&(this.addCurrentVertex(H,ge,-1,-1,j,!0),this.addCurrentVertex(H,ge,0,0,j)));if(nt&&oe<k-1){const st=H.dist(Y);if(st>2*V){const Xe=H.add(Y.sub(H)._mult(V/st)._round());this.updateDistance(H,Xe),this.addCurrentVertex(Xe,ge,0,0,j),H=Xe}}}}addCurrentVertex(e,i,s,A,d,_=!1){const b=i.y*A-i.x,M=-i.y-i.x*A;this.addHalfVertex(e,i.x+i.y*s,i.y-i.x*s,_,!1,s,d),this.addHalfVertex(e,b,M,_,!0,-A,d),this.distance>uf/2&&this.totalDistance===0&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,i,s,A,d,_))}addHalfVertex({x:e,y:i},s,A,d,_,b,M){const I=.5*(this.lineClips?this.scaledDistance*(uf-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((e<<1)+(d?1:0),(i<<1)+(_?1:0),Math.round(63*s)+128,Math.round(63*A)+128,1+(b===0?0:b<0?-1:1)|(63&I)<<2,I>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const k=M.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,k,this.e2),M.primitiveLength++),_?this.e2=k:this.e1=k}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(e,i){this.distance+=e.dist(i),this.updateScaledDistance()}hasLineDasharray(e){for(const i of e){const s=i.paint.get("line-dasharray");if(s&&!s.isConstant())return!0}return!1}addLineDashDependencies(e,i,s,A){for(const d of e){const _=d.paint.get("line-dasharray");if(!_||_.value.kind==="constant")continue;const b=d.layout.get("line-cap")==="round",M={dasharray:_.value.evaluate({zoom:s-1},i,{}),round:b},I={dasharray:_.value.evaluate({zoom:s},i,{}),round:b},k={dasharray:_.value.evaluate({zoom:s+1},i,{}),round:b},F=`${M.dasharray.join(",")},${M.round}`,V=`${I.dasharray.join(",")},${I.round}`,j=`${k.dasharray.join(",")},${k.round}`;A.dashDependencies[F]=M,A.dashDependencies[V]=I,A.dashDependencies[j]=k,i.dashes[d.id]={min:F,mid:V,max:j}}}}let hf,cf;kt("LineBucket",Hc,{omit:["layers","patternFeatures"]});var Af={get paint(){return cf=cf||new is({"line-opacity":new Mt(qe.paint_line["line-opacity"]),"line-color":new Mt(qe.paint_line["line-color"]),"line-translate":new _t(qe.paint_line["line-translate"]),"line-translate-anchor":new _t(qe.paint_line["line-translate-anchor"]),"line-width":new Mt(qe.paint_line["line-width"]),"line-gap-width":new Mt(qe.paint_line["line-gap-width"]),"line-offset":new Mt(qe.paint_line["line-offset"]),"line-blur":new Mt(qe.paint_line["line-blur"]),"line-dasharray":new li(qe.paint_line["line-dasharray"]),"line-pattern":new li(qe.paint_line["line-pattern"]),"line-gradient":new wn(qe.paint_line["line-gradient"])})},get layout(){return hf=hf||new is({"line-cap":new _t(qe.layout_line["line-cap"]),"line-join":new Mt(qe.layout_line["line-join"]),"line-miter-limit":new _t(qe.layout_line["line-miter-limit"]),"line-round-limit":new _t(qe.layout_line["line-round-limit"]),"line-sort-key":new Mt(qe.layout_line["line-sort-key"])})}};class d0 extends Mt{possiblyEvaluate(e,i){return i=new ze(Math.floor(i.zoom),{now:i.now,fadeDuration:i.fadeDuration,zoomHistory:i.zoomHistory,transition:i.transition}),super.possiblyEvaluate(e,i)}evaluate(e,i,s,A){return i=Er({},i,{zoom:Math.floor(i.zoom)}),super.evaluate(e,i,s,A)}}let sc;class p0 extends ko{constructor(e,i){super(e,Af,i),this.gradientVersion=0,sc||(sc=new d0(Af.paint.properties["line-width"].specification),sc.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(e){if(e==="line-gradient"){const i=this.gradientExpression();this.stepInterpolant=!!(function(s){return s._styleExpression!==void 0})(i)&&i._styleExpression.expression instanceof Kn,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(e,i){super.recalculate(e,i),this.paint._values["line-floorwidth"]=sc.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new Hc(e)}queryRadius(e){const i=e,s=ff($u("line-width",this,i),$u("line-gap-width",this,i)),A=$u("line-offset",this,i);return s/2+Math.abs(A)+Jh(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:e,feature:i,featureState:s,geometry:A,transform:d,pixelsToTileUnits:_}){const b=ec(e,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-d.bearingInRadians,_),M=_/2*ff(this.paint.get("line-width").evaluate(i,s),this.paint.get("line-gap-width").evaluate(i,s)),I=this.paint.get("line-offset").evaluate(i,s);return I&&(A=(function(k,F){const V=[];for(let j=0;j<k.length;j++){const H=wp(k[j]),Q=[];for(let Y=0;Y<H.length;Y++){const re=H[Y],ge=H[Y-1],oe=H[Y+1],ue=Y===0?new it(0,0):re.sub(ge)._unit()._perp(),ve=Y===H.length-1?new it(0,0):oe.sub(re)._unit()._perp(),Te=ue._add(ve)._unit(),Ue=Te.x*ve.x+Te.y*ve.y;Ue!==0&&Te._mult(1/Ue),Q.push(Te._mult(F)._add(re))}V.push(Q)}return V})(A,I*_)),(function(k,F,V){for(let j=0;j<F.length;j++){const H=F[j];if(k.length>=3){for(let Q=0;Q<H.length;Q++)if(Qu(k,H[Q]))return!0}if(vp(k,H,V))return!0}return!1})(b,A,M)}isTileClipped(){return!0}}function ff(r,e){return e>0?e+2*r:r}const m0=on([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),_0=on([{name:"a_projected_pos",components:3,type:"Float32"}],4);on([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const g0=on([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);on([{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 df=on([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),y0=on([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function v0(r,e,i){return r.sections.forEach((s=>{s.text=(function(A,d,_){const b=d.layout.get("text-transform").evaluate(_,{});return b==="uppercase"?A=A.toLocaleUpperCase():b==="lowercase"&&(A=A.toLocaleLowerCase()),Oe.applyArabicShaping&&(A=Oe.applyArabicShaping(A)),A})(s.text,e,i)})),r}on([{name:"triangle",components:3,type:"Uint16"}]),on([{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"}]),on([{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"}]),on([{type:"Float32",name:"offsetX"}]),on([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),on([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);var ns=24;const Lh={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","⋯":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"},x0={10:!0,32:!0,38:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0},b0={40:!0};function pf(r,e,i,s,A,d){if("fontStack"in e){const _=i[e.fontStack],b=_&&_[r];return b?b.metrics.advance*e.scale+A:0}{const _=s[e.imageName];return _?_.displaySize[0]*e.scale*ns/d+A:0}}function mf(r,e,i,s){const A=Math.pow(r-e,2);return s?r<e?A/2:2*A:A+Math.abs(i)*i}function w0(r,e,i){let s=0;return r===10&&(s-=1e4),i&&(s+=150),r!==40&&r!==65288||(s+=50),e!==41&&e!==65289||(s+=50),s}function _f(r,e,i,s,A,d){let _=null,b=mf(e,i,A,d);for(const M of s){const I=mf(e-M.x,i,A,d)+M.badness;I<=b&&(_=M,b=I)}return{index:r,x:e,priorBreak:_,badness:b}}function gf(r){return r?gf(r.priorBreak).concat(r.index):[]}class Ju{constructor(e="",i=[],s=[]){this.text=e,this.sections=i,this.sectionIndex=s,this.imageSectionID=null}static fromFeature(e,i){const s=new Ju;for(let A=0;A<e.sections.length;A++){const d=e.sections[A];d.image?s.addImageSection(d):s.addTextSection(d,i)}return s}length(){return[...this.text].length}getSection(e){return this.sections[this.sectionIndex[e]]}getSectionIndex(e){return this.sectionIndex[e]}verticalizePunctuation(){this.text=(function(e){let i="",s={premature:!0,value:void 0};const A=e[Symbol.iterator]();let d=A.next();const _=e[Symbol.iterator]();_.next();let b=_.next();for(;!d.done;)i+=!b.done&&de(b.value.codePointAt(0))&&!Lh[b.value]||!s.premature&&de(s.value.codePointAt(0))&&!Lh[s.value]||!Lh[d.value]?d.value:Lh[d.value],s={value:d.value,premature:!1},d=A.next(),b=_.next();return i})(this.text)}hasZeroWidthSpaces(){return this.text.includes("​")}trim(){const e=this.text.match(/^\s*/),i=e?e[0].length:0,s=this.text.match(/\S\s*$/),A=s?s[0].length-1:0;this.text=this.text.substring(i,this.text.length-A),this.sectionIndex=this.sectionIndex.slice(i,this.sectionIndex.length-A)}substring(e,i){const s=[...this.text].slice(e,i).join(""),A=this.sectionIndex.slice(e,i);return new Ju(s,this.sections,A)}toCodeUnitIndex(e){return[...this.text].slice(0,e).join("").length}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((e,i)=>Math.max(e,this.sections[i].scale)),0)}getMaxImageSize(e){let i=0,s=0;for(let A=0;A<this.length();A++){const d=this.getSection(A);if("imageName"in d){const _=e[d.imageName];if(!_)continue;const b=_.displaySize;i=Math.max(i,b[0]),s=Math.max(s,b[1])}}return{maxImageWidth:i,maxImageHeight:s}}addTextSection(e,i){this.text+=e.text,this.sections.push({scale:e.scale||1,verticalAlign:e.verticalAlign||"bottom",fontStack:e.fontStack||i});const s=this.sections.length-1;this.sectionIndex.push(...[...e.text].map((()=>s)))}addImageSection(e){const i=e.image?e.image.name:"";if(i.length===0)return void en("Can't add FormattedSection with an empty image.");const s=this.getNextImageSectionCharCode();s?(this.text+=String.fromCharCode(s),this.sections.push({scale:1,verticalAlign:e.verticalAlign||"bottom",imageName:i}),this.sectionIndex.push(this.sections.length-1)):en("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}determineLineBreaks(e,i,s,A,d){const _=[],b=this.determineAverageLineWidth(e,i,s,A,d),M=this.hasZeroWidthSpaces();let I=0,k=0;const F=this.text[Symbol.iterator]();let V=F.next();const j=this.text[Symbol.iterator]();j.next();let H=j.next();const Q=this.text[Symbol.iterator]();Q.next(),Q.next();let Y=Q.next();for(;!V.done;){const re=this.getSection(k),ge=V.value.codePointAt(0);if(S(ge)||(I+=pf(ge,re,s,A,e,d)),!H.done){const oe=w(ge),ue=H.value.codePointAt(0);(x0[ge]||oe||"imageName"in re||!Y.done&&b0[ue])&&_.push(_f(k+1,I,b,_,w0(ge,ue,oe&&M),!1))}k++,V=F.next(),H=j.next(),Y=Q.next()}return gf(_f(this.length(),I,b,_,0,!0))}determineAverageLineWidth(e,i,s,A,d){let _=0,b=0;for(const M of this.text){const I=this.getSection(b);_+=pf(M.codePointAt(0),I,s,A,e,d),b++}return _/Math.max(1,Math.ceil(_/i))}}const Wc=4294967296,yf=1/Wc,vf=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");class oc{constructor(e=new Uint8Array(16)){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(e,i,s=this.length){for(;this.pos<s;){const A=this.readVarint(),d=A>>3,_=this.pos;this.type=7&A,e(d,i,this),this.pos===_&&this.skip(A)}return i}readMessage(e,i){return this.readFields(e,i,this.readVarint()+this.pos)}readFixed32(){const e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){const e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*Wc;return this.pos+=8,e}readSFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Wc;return this.pos+=8,e}readFloat(){const e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){const e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){const i=this.buf;let s,A;return A=i[this.pos++],s=127&A,A<128?s:(A=i[this.pos++],s|=(127&A)<<7,A<128?s:(A=i[this.pos++],s|=(127&A)<<14,A<128?s:(A=i[this.pos++],s|=(127&A)<<21,A<128?s:(A=i[this.pos],s|=(15&A)<<28,(function(d,_,b){const M=b.buf;let I,k;if(k=M[b.pos++],I=(112&k)>>4,k<128||(k=M[b.pos++],I|=(127&k)<<3,k<128)||(k=M[b.pos++],I|=(127&k)<<10,k<128)||(k=M[b.pos++],I|=(127&k)<<17,k<128)||(k=M[b.pos++],I|=(127&k)<<24,k<128)||(k=M[b.pos++],I|=(1&k)<<31,k<128))return eh(d,I,_);throw new Error("Expected varint not more than 10 bytes")})(s,e,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const e=this.readVarint();return e%2==1?(e+1)/-2:e/2}readBoolean(){return!!this.readVarint()}readString(){const e=this.readVarint()+this.pos,i=this.pos;return this.pos=e,e-i>=12&&vf?vf.decode(this.buf.subarray(i,e)):(function(s,A,d){let _="",b=A;for(;b<d;){const M=s[b];let I,k,F,V=null,j=M>239?4:M>223?3:M>191?2:1;if(b+j>d)break;j===1?M<128&&(V=M):j===2?(I=s[b+1],(192&I)==128&&(V=(31&M)<<6|63&I,V<=127&&(V=null))):j===3?(I=s[b+1],k=s[b+2],(192&I)==128&&(192&k)==128&&(V=(15&M)<<12|(63&I)<<6|63&k,(V<=2047||V>=55296&&V<=57343)&&(V=null))):j===4&&(I=s[b+1],k=s[b+2],F=s[b+3],(192&I)==128&&(192&k)==128&&(192&F)==128&&(V=(15&M)<<18|(63&I)<<12|(63&k)<<6|63&F,(V<=65535||V>=1114112)&&(V=null))),V===null?(V=65533,j=1):V>65535&&(V-=65536,_+=String.fromCharCode(V>>>10&1023|55296),V=56320|1023&V),_+=String.fromCharCode(V),b+=j}return _})(this.buf,i,e)}readBytes(){const e=this.readVarint()+this.pos,i=this.buf.subarray(this.pos,e);return this.pos=e,i}readPackedVarint(e=[],i){const s=this.readPackedEnd();for(;this.pos<s;)e.push(this.readVarint(i));return e}readPackedSVarint(e=[]){const i=this.readPackedEnd();for(;this.pos<i;)e.push(this.readSVarint());return e}readPackedBoolean(e=[]){const i=this.readPackedEnd();for(;this.pos<i;)e.push(this.readBoolean());return e}readPackedFloat(e=[]){const i=this.readPackedEnd();for(;this.pos<i;)e.push(this.readFloat());return e}readPackedDouble(e=[]){const i=this.readPackedEnd();for(;this.pos<i;)e.push(this.readDouble());return e}readPackedFixed32(e=[]){const i=this.readPackedEnd();for(;this.pos<i;)e.push(this.readFixed32());return e}readPackedSFixed32(e=[]){const i=this.readPackedEnd();for(;this.pos<i;)e.push(this.readSFixed32());return e}readPackedFixed64(e=[]){const i=this.readPackedEnd();for(;this.pos<i;)e.push(this.readFixed64());return e}readPackedSFixed64(e=[]){const i=this.readPackedEnd();for(;this.pos<i;)e.push(this.readSFixed64());return e}readPackedEnd(){return this.type===2?this.readVarint()+this.pos:this.pos+1}skip(e){const i=7&e;if(i===0)for(;this.buf[this.pos++]>127;);else if(i===2)this.pos=this.readVarint()+this.pos;else if(i===5)this.pos+=4;else{if(i!==1)throw new Error(`Unimplemented type: ${i}`);this.pos+=8}}writeTag(e,i){this.writeVarint(e<<3|i)}realloc(e){let i=this.length||16;for(;i<this.pos+e;)i*=2;if(i!==this.length){const s=new Uint8Array(i);s.set(this.buf),this.buf=s,this.dataView=new DataView(s.buffer),this.length=i}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}writeFixed32(e){this.realloc(4),this.dataView.setInt32(this.pos,e,!0),this.pos+=4}writeSFixed32(e){this.realloc(4),this.dataView.setInt32(this.pos,e,!0),this.pos+=4}writeFixed64(e){this.realloc(8),this.dataView.setInt32(this.pos,-1&e,!0),this.dataView.setInt32(this.pos+4,Math.floor(e*yf),!0),this.pos+=8}writeSFixed64(e){this.realloc(8),this.dataView.setInt32(this.pos,-1&e,!0),this.dataView.setInt32(this.pos+4,Math.floor(e*yf),!0),this.pos+=8}writeVarint(e){(e=+e||0)>268435455||e<0?(function(i,s){let A,d;if(i>=0?(A=i%4294967296|0,d=i/4294967296|0):(A=~(-i%4294967296),d=~(-i/4294967296),4294967295^A?A=A+1|0:(A=0,d=d+1|0)),i>=18446744073709552e3||i<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");s.realloc(10),(function(_,b,M){M.buf[M.pos++]=127&_|128,_>>>=7,M.buf[M.pos++]=127&_|128,_>>>=7,M.buf[M.pos++]=127&_|128,_>>>=7,M.buf[M.pos++]=127&_|128,M.buf[M.pos]=127&(_>>>=7)})(A,0,s),(function(_,b){const M=(7&_)<<4;b.buf[b.pos++]|=M|((_>>>=3)?128:0),_&&(b.buf[b.pos++]=127&_|((_>>>=7)?128:0),_&&(b.buf[b.pos++]=127&_|((_>>>=7)?128:0),_&&(b.buf[b.pos++]=127&_|((_>>>=7)?128:0),_&&(b.buf[b.pos++]=127&_|((_>>>=7)?128:0),_&&(b.buf[b.pos++]=127&_)))))})(d,s)})(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))))}writeSVarint(e){this.writeVarint(e<0?2*-e-1:2*e)}writeBoolean(e){this.writeVarint(+e)}writeString(e){e=String(e),this.realloc(4*e.length),this.pos++;const i=this.pos;this.pos=(function(A,d,_){for(let b,M,I=0;I<d.length;I++){if(b=d.charCodeAt(I),b>55295&&b<57344){if(!M){b>56319||I+1===d.length?(A[_++]=239,A[_++]=191,A[_++]=189):M=b;continue}if(b<56320){A[_++]=239,A[_++]=191,A[_++]=189,M=b;continue}b=M-55296<<10|b-56320|65536,M=null}else M&&(A[_++]=239,A[_++]=191,A[_++]=189,M=null);b<128?A[_++]=b:(b<2048?A[_++]=b>>6|192:(b<65536?A[_++]=b>>12|224:(A[_++]=b>>18|240,A[_++]=b>>12&63|128),A[_++]=b>>6&63|128),A[_++]=63&b|128)}return _})(this.buf,e,this.pos);const s=this.pos-i;s>=128&&xf(i,s,this),this.pos=i-1,this.writeVarint(s),this.pos+=s}writeFloat(e){this.realloc(4),this.dataView.setFloat32(this.pos,e,!0),this.pos+=4}writeDouble(e){this.realloc(8),this.dataView.setFloat64(this.pos,e,!0),this.pos+=8}writeBytes(e){const i=e.length;this.writeVarint(i),this.realloc(i);for(let s=0;s<i;s++)this.buf[this.pos++]=e[s]}writeRawMessage(e,i){this.pos++;const s=this.pos;e(i,this);const A=this.pos-s;A>=128&&xf(s,A,this),this.pos=s-1,this.writeVarint(A),this.pos+=A}writeMessage(e,i,s){this.writeTag(e,2),this.writeRawMessage(i,s)}writePackedVarint(e,i){i.length&&this.writeMessage(e,T0,i)}writePackedSVarint(e,i){i.length&&this.writeMessage(e,P0,i)}writePackedBoolean(e,i){i.length&&this.writeMessage(e,S0,i)}writePackedFloat(e,i){i.length&&this.writeMessage(e,M0,i)}writePackedDouble(e,i){i.length&&this.writeMessage(e,E0,i)}writePackedFixed32(e,i){i.length&&this.writeMessage(e,C0,i)}writePackedSFixed32(e,i){i.length&&this.writeMessage(e,I0,i)}writePackedFixed64(e,i){i.length&&this.writeMessage(e,D0,i)}writePackedSFixed64(e,i){i.length&&this.writeMessage(e,k0,i)}writeBytesField(e,i){this.writeTag(e,2),this.writeBytes(i)}writeFixed32Field(e,i){this.writeTag(e,5),this.writeFixed32(i)}writeSFixed32Field(e,i){this.writeTag(e,5),this.writeSFixed32(i)}writeFixed64Field(e,i){this.writeTag(e,1),this.writeFixed64(i)}writeSFixed64Field(e,i){this.writeTag(e,1),this.writeSFixed64(i)}writeVarintField(e,i){this.writeTag(e,0),this.writeVarint(i)}writeSVarintField(e,i){this.writeTag(e,0),this.writeSVarint(i)}writeStringField(e,i){this.writeTag(e,2),this.writeString(i)}writeFloatField(e,i){this.writeTag(e,5),this.writeFloat(i)}writeDoubleField(e,i){this.writeTag(e,1),this.writeDouble(i)}writeBooleanField(e,i){this.writeVarintField(e,+i)}}function eh(r,e,i){return i?4294967296*e+(r>>>0):4294967296*(e>>>0)+(r>>>0)}function xf(r,e,i){const s=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));i.realloc(s);for(let A=i.pos-1;A>=r;A--)i.buf[A+s]=i.buf[A]}function T0(r,e){for(let i=0;i<r.length;i++)e.writeVarint(r[i])}function P0(r,e){for(let i=0;i<r.length;i++)e.writeSVarint(r[i])}function M0(r,e){for(let i=0;i<r.length;i++)e.writeFloat(r[i])}function E0(r,e){for(let i=0;i<r.length;i++)e.writeDouble(r[i])}function S0(r,e){for(let i=0;i<r.length;i++)e.writeBoolean(r[i])}function C0(r,e){for(let i=0;i<r.length;i++)e.writeFixed32(r[i])}function I0(r,e){for(let i=0;i<r.length;i++)e.writeSFixed32(r[i])}function D0(r,e){for(let i=0;i<r.length;i++)e.writeFixed64(r[i])}function k0(r,e){for(let i=0;i<r.length;i++)e.writeSFixed64(r[i])}function z0(r,e,i){r===1&&i.readMessage(L0,e)}function L0(r,e,i){if(r===3){const{id:s,bitmap:A,width:d,height:_,left:b,top:M,advance:I}=i.readMessage(B0,{});e.push({id:s,bitmap:new Th({width:d+6,height:_+6},A),metrics:{width:d,height:_,left:b,top:M,advance:I}})}}function B0(r,e,i){r===1?e.id=i.readVarint():r===2?e.bitmap=i.readBytes():r===3?e.width=i.readVarint():r===4?e.height=i.readVarint():r===5?e.left=i.readSVarint():r===6?e.top=i.readSVarint():r===7&&(e.advance=i.readVarint())}function bf(r){let e=0,i=0;for(const _ of r)e+=_.w*_.h,i=Math.max(i,_.w);r.sort(((_,b)=>b.h-_.h));const s=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let A=0,d=0;for(const _ of r)for(let b=s.length-1;b>=0;b--){const M=s[b];if(!(_.w>M.w||_.h>M.h)){if(_.x=M.x,_.y=M.y,d=Math.max(d,_.y+_.h),A=Math.max(A,_.x+_.w),_.w===M.w&&_.h===M.h){const I=s.pop();I&&b<s.length&&(s[b]=I)}else _.h===M.h?(M.x+=_.w,M.w-=_.w):_.w===M.w?(M.y+=_.h,M.h-=_.h):(s.push({x:M.x+_.w,y:M.y,w:M.w-_.w,h:_.h}),M.y+=_.h,M.h-=_.h);break}}return{w:A,h:d,fill:e/(A*d)||0}}class Qc{constructor(e,{pixelRatio:i,version:s,stretchX:A,stretchY:d,content:_,textFitWidth:b,textFitHeight:M}){this.paddedRect=e,this.pixelRatio=i,this.stretchX=A,this.stretchY=d,this.content=_,this.version=s,this.textFitWidth=b,this.textFitHeight=M}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]}get tlbr(){return this.tl.concat(this.br)}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}}class wf{constructor(e,i){const s={},A={};this.haveRenderCallbacks=[];const d=[];this.addImages(e,s,d),this.addImages(i,A,d);const{w:_,h:b}=bf(d),M=new mo({width:_||1,height:b||1});for(const I in e){const k=e[I],F=s[I].paddedRect;mo.copy(k.data,M,{x:0,y:0},{x:F.x+1,y:F.y+1},k.data)}for(const I in i){const k=i[I],F=A[I].paddedRect,V=F.x+1,j=F.y+1,H=k.data.width,Q=k.data.height;mo.copy(k.data,M,{x:0,y:0},{x:V,y:j},k.data),mo.copy(k.data,M,{x:0,y:Q-1},{x:V,y:j-1},{width:H,height:1}),mo.copy(k.data,M,{x:0,y:0},{x:V,y:j+Q},{width:H,height:1}),mo.copy(k.data,M,{x:H-1,y:0},{x:V-1,y:j},{width:1,height:Q}),mo.copy(k.data,M,{x:0,y:0},{x:V+H,y:j},{width:1,height:Q})}this.image=M,this.iconPositions=s,this.patternPositions=A}addImages(e,i,s){for(const A in e){const d=e[A],_={x:0,y:0,w:d.data.width+2,h:d.data.height+2};s.push(_),i[A]=new Qc(_,d),d.hasRenderCallback&&this.haveRenderCallbacks.push(A)}}patchUpdatedImages(e,i){e.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const s in e.updatedImages)this.patchUpdatedImage(this.iconPositions[s],e.getImage(s),i),this.patchUpdatedImage(this.patternPositions[s],e.getImage(s),i)}patchUpdatedImage(e,i,s){if(!e||!i||e.version===i.version)return;e.version=i.version;const[A,d]=e.tl;s.update(i.data,void 0,{x:A,y:d})}}var iu;function ac(r,e,i,s,A,d,_,b,M,I,k,F,V,j,H){const Q=Ju.fromFeature(r,A);let Y;F===W.az.vertical&&Q.verticalizePunctuation();let re=Q.determineLineBreaks(I,d,e,s,j);const{processBidirectionalText:ge,processStyledBidirectionalText:oe}=Oe;if(ge&&Q.sections.length===1){Y=[],re=re.map((Ue=>Q.toCodeUnitIndex(Ue)));const Te=ge(Q.toString(),re);for(const Ue of Te){const lt=[...Ue].map((()=>0));Y.push(new Ju(Ue,Q.sections,lt))}}else if(oe){Y=[],re=re.map((nt=>Q.toCodeUnitIndex(nt)));let Te=0;const Ue=[];for(const nt of Q.text)Ue.push(...Array(nt.length).fill(Q.sectionIndex[Te])),Te++;const lt=oe(Q.text,Ue,re);for(const nt of lt){const dt=[];let Tt="";for(const mt of nt[0])dt.push(nt[1][Tt.length]),Tt+=mt;Y.push(new Ju(nt[0],Q.sections,dt))}}else Y=(function(Te,Ue){const lt=[];let nt=0;for(const dt of Ue)lt.push(Te.substring(nt,dt)),nt=dt;return nt<Te.length()&&lt.push(Te.substring(nt,Te.length())),lt})(Q,re);const ue=[],ve={positionedLines:ue,text:Q.toString(),top:k[1],bottom:k[1],left:k[0],right:k[0],writingMode:F,iconsInText:!1,verticalizable:!1};return(function(Te,Ue,lt,nt,dt,Tt,mt,st,Xe,Lt,Ct,Ot){let Et=0,Ut=0,ji=0,Di=0;const Or=st==="right"?1:st==="left"?0:.5,Ps=ns/Ot;let Tn=0;for(const rr of dt){rr.trim();const Xr=rr.getMaxScale(),ln={positionedGlyphs:[],lineOffset:0};Te.positionedLines[Tn]=ln;const Pr=ln.positionedGlyphs;let _o=0;if(!rr.length()){Ut+=Tt,++Tn;continue}const Ms=R0(nt,rr,Ps);let go=0;for(const as of rr.text){const qr=rr.getSection(go),Pn=as.codePointAt(0),Kr=F0(Xe,Ct,Pn),ls={glyph:Pn,imageName:null,x:Et,y:Ut+-17,vertical:Kr,scale:1,fontStack:"",sectionIndex:rr.getSectionIndex(go),metrics:null,rect:null};let Fl;if("fontStack"in qr){if(Fl=O0(qr,Pn,Kr,Ms,Ue,lt),!Fl)continue;ls.fontStack=qr.fontStack}else{if(Te.iconsInText=!0,qr.scale*=Ps,Fl=N0(qr,Kr,Xr,Ms,nt),!Fl)continue;_o=Math.max(_o,Fl.imageOffset),ls.imageName=qr.imageName}const{rect:Ua,metrics:jh,baselineOffset:au}=Fl;ls.y+=au,ls.scale=qr.scale,ls.metrics=jh,ls.rect=Ua,Pr.push(ls),Kr?(Te.verticalizable=!0,Et+=("imageName"in qr?jh.advance:ns)*qr.scale+Lt):Et+=jh.advance*qr.scale+Lt,go++}Pr.length!==0&&(ji=Math.max(Et-Lt,ji),V0(Pr,0,Pr.length-1,Or)),Et=0,ln.lineOffset=Math.max(_o,(Xr-1)*ns);const Pa=Tt*Xr+_o;Ut+=Pa,Di=Math.max(Pa,Di),++Tn}const{horizontalAlign:Nr,verticalAlign:kr}=$c(mt);(function(rr,Xr,ln,Pr,_o,Ms,go,Pa,as){const qr=(Xr-ln)*_o;let Pn=0;Pn=Ms!==go?-Pa*Pr- -17:-Pr*as*go+.5*go;for(const Kr of rr)for(const ls of Kr.positionedGlyphs)ls.x+=qr,ls.y+=Pn})(Te.positionedLines,Or,Nr,kr,ji,Di,Tt,Ut,dt.length),Te.top+=-kr*Ut,Te.bottom=Te.top+Ut,Te.left+=-Nr*ji,Te.right=Te.left+ji})(ve,e,i,s,Y,_,b,M,F,I,V,H),!(function(Te){for(const Ue of Te)if(Ue.positionedGlyphs.length!==0)return!1;return!0})(ue)&&ve}function $c(r){let e=.5,i=.5;switch(r){case"right":case"top-right":case"bottom-right":e=1;break;case"left":case"top-left":case"bottom-left":e=0}switch(r){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 R0(r,e,i){const s=e.getMaxScale()*ns,{maxImageWidth:A,maxImageHeight:d}=e.getMaxImageSize(r),_=Math.max(s,d*i);return{verticalLineContentWidth:Math.max(s,A*i),horizontalLineContentHeight:_}}function Tf(r){switch(r){case"top":return 0;case"center":return .5;default:return 1}}function F0(r,e,i){return!(r===W.az.horizontal||!e&&!P(i)||e&&(S(i)||(s=i,new RegExp("\\p{sc=Arab}","u").test(String.fromCodePoint(s)))));var s}function O0(r,e,i,s,A,d){const _=d[r.fontStack],b=(function(I,k,F,V){if(I&&I.rect)return I;const j=k[F.fontStack],H=j&&j[V];return H?{rect:null,metrics:H.metrics}:null})(_&&_[e],A,r,e);if(b===null)return null;let M;if(i)M=s.verticalLineContentWidth-r.scale*ns;else{const I=Tf(r.verticalAlign);M=(s.horizontalLineContentHeight-r.scale*ns)*I}return{rect:b.rect,metrics:b.metrics,baselineOffset:M}}function N0(r,e,i,s,A){const d=A[r.imageName];if(!d)return null;const _=d.paddedRect,b=d.displaySize,M={width:b[0],height:b[1],left:1,top:-3,advance:e?b[1]:b[0]};let I;if(e)I=s.verticalLineContentWidth-b[1]*r.scale;else{const k=Tf(r.verticalAlign);I=(s.horizontalLineContentHeight-b[1]*r.scale)*k}return{rect:_,metrics:M,baselineOffset:I,imageOffset:(e?b[0]:b[1])*r.scale-ns*i}}function V0(r,e,i,s){if(s===0)return;const A=r[i],d=(r[i].x+A.metrics.advance*A.scale)*s;for(let _=e;_<=i;_++)r[_].x-=d}function j0(r,e,i){const{horizontalAlign:s,verticalAlign:A}=$c(i),d=e[0]-r.displaySize[0]*s,_=e[1]-r.displaySize[1]*A;return{image:r,top:_,bottom:_+r.displaySize[1],left:d,right:d+r.displaySize[0]}}function Pf(r){var e,i;let s=r.left,A=r.top,d=r.right-s,_=r.bottom-A;const b=(e=r.image.textFitWidth)!==null&&e!==void 0?e:"stretchOrShrink",M=(i=r.image.textFitHeight)!==null&&i!==void 0?i:"stretchOrShrink",I=(r.image.content[2]-r.image.content[0])/(r.image.content[3]-r.image.content[1]);if(M==="proportional"){if(b==="stretchOnly"&&d/_<I||b==="proportional"){const k=Math.ceil(_*I);s*=k/d,d=k}}else if(b==="proportional"&&M==="stretchOnly"&&I!==0&&d/_>I){const k=Math.ceil(d/I);A*=k/_,_=k}return{x1:s,y1:A,x2:s+d,y2:A+_}}function Mf(r,e,i,s,A,d){const _=r.image;let b;if(_.content){const Y=_.content,re=_.pixelRatio||1;b=[Y[0]/re,Y[1]/re,_.displaySize[0]-Y[2]/re,_.displaySize[1]-Y[3]/re]}const M=e.left*d,I=e.right*d;let k,F,V,j;i==="width"||i==="both"?(j=A[0]+M-s[3],F=A[0]+I+s[1]):(j=A[0]+(M+I-_.displaySize[0])/2,F=j+_.displaySize[0]);const H=e.top*d,Q=e.bottom*d;return i==="height"||i==="both"?(k=A[1]+H-s[0],V=A[1]+Q+s[2]):(k=A[1]+(H+Q-_.displaySize[1])/2,V=k+_.displaySize[1]),{image:_,top:k,right:F,bottom:V,left:j,collisionPadding:b}}kt("ImagePosition",Qc),kt("ImageAtlas",wf),W.az=void 0,(iu=W.az||(W.az={}))[iu.none=0]="none",iu[iu.horizontal=1]="horizontal",iu[iu.vertical=2]="vertical",iu[iu.horizontalOnly=3]="horizontalOnly";const Bl=128,ru=32640;function Ef(r,e){const{expression:i}=e;if(i.kind==="constant")return{kind:"constant",layoutSize:i.evaluate(new ze(r+1))};if(i.kind==="source")return{kind:"source"};{const{zoomStops:s,interpolationType:A}=i;let d=0;for(;d<s.length&&s[d]<=r;)d++;d=Math.max(0,d-1);let _=d;for(;_<s.length&&s[_]<r+1;)_++;_=Math.min(s.length-1,_);const b=s[d],M=s[_];return i.kind==="composite"?{kind:"composite",minZoom:b,maxZoom:M,interpolationType:A}:{kind:"camera",minZoom:b,maxZoom:M,minSize:i.evaluate(new ze(b)),maxSize:i.evaluate(new ze(M)),interpolationType:A}}}function Yc(r,e,i){let s="never";const A=r.get(e);return A?s=A:r.get(i)&&(s="always"),s}const Z0=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function lc(r,e,i,s,A,d,_,b,M,I,k,F,V){const j=b?Math.min(ru,Math.round(b[0])):0,H=b?Math.min(ru,Math.round(b[1])):0;r.emplaceBack(e,i,Math.round(32*s),Math.round(32*A),d,_,(j<<1)+(M?1:0),H,16*I,16*k,256*F,256*V)}function Xc(r,e,i){r.emplaceBack(e.x,e.y,i),r.emplaceBack(e.x,e.y,i),r.emplaceBack(e.x,e.y,i),r.emplaceBack(e.x,e.y,i)}function U0(r){for(const e of r.sections)if(Je(e.text))return!0;return!1}class Kc{constructor(e){this.layoutVertexArray=new be,this.indexArray=new Ye,this.programConfigurations=e,this.segments=new Pt,this.dynamicLayoutVertexArray=new Le,this.opacityVertexArray=new Ke,this.hasVisibleVertices=!1,this.placedSymbolArray=new T}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0}upload(e,i,s,A){this.isEmpty()||(s&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,m0.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,i),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,_0.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,Z0,!0),this.opacityVertexBuffer.itemSize=1),(s||A)&&this.programConfigurations.upload(e))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}kt("SymbolBuffers",Kc);class Jc{constructor(e,i,s){this.layoutVertexArray=new e,this.layoutAttributes=i,this.indexArray=new s,this.segments=new Pt,this.collisionVertexArray=new $e}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,g0.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}}kt("CollisionBuffers",Jc);class th{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((_=>_.id)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasDependencies=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Ef(this.zoom,i["text-size"]),this.iconSizeData=Ef(this.zoom,i["icon-size"]);const s=this.layers[0].layout,A=s.get("symbol-sort-key"),d=s.get("symbol-z-order");this.canOverlap=Yc(s,"text-overlap","text-allow-overlap")!=="never"||Yc(s,"icon-overlap","icon-allow-overlap")!=="never"||s.get("text-ignore-placement")||s.get("icon-ignore-placement"),this.sortFeaturesByKey=d!=="viewport-y"&&!A.isConstant(),this.sortFeaturesByY=(d==="viewport-y"||d==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,s.get("symbol-placement")==="point"&&(this.writingModes=s.get("text-writing-mode").map((_=>W.az[_]))),this.stateDependentLayerIds=this.layers.filter((_=>_.isStateDependent())).map((_=>_.id)),this.sourceID=e.sourceID}createArrays(){this.text=new Kc(new Ll(this.layers,this.zoom,(e=>/^text/.test(e)))),this.icon=new Kc(new Ll(this.layers,this.zoom,(e=>/^icon/.test(e)))),this.glyphOffsetArray=new B,this.lineVertexArray=new N,this.symbolInstances=new D,this.textAnchorOffsets=new U}calculateGlyphDependencies(e,i,s,A,d){for(const _ of e)if(i[_.codePointAt(0)]=!0,(s||A)&&d){const b=Lh[_];b&&(i[b.codePointAt(0)]=!0)}}populate(e,i,s){const A=this.layers[0],d=A.layout,_=d.get("text-font"),b=d.get("text-field"),M=d.get("icon-image"),I=(b.value.kind!=="constant"||b.value.value instanceof Wn&&!b.value.value.isEmpty()||b.value.value.toString().length>0)&&(_.value.kind!=="constant"||_.value.value.length>0),k=M.value.kind!=="constant"||!!M.value.value||Object.keys(M.parameters).length>0,F=d.get("symbol-sort-key");if(this.features=[],!I&&!k)return;const V=i.iconDependencies,j=i.glyphDependencies,H=i.availableImages,Q=new ze(this.zoom);for(const{feature:Y,id:re,index:ge,sourceLayerIndex:oe}of e){const ue=A._featureFilter.needGeometry,ve=dl(Y,ue);if(!A._featureFilter.filter(Q,ve,s))continue;let Te,Ue;if(ue||(ve.geometry=fl(Y)),I){const nt=A.getValueAndResolveTokens("text-field",ve,s,H),dt=Wn.factory(nt),Tt=this.hasRTLText=this.hasRTLText||U0(dt);(!Tt||Oe.getRTLTextPluginStatus()==="unavailable"||Tt&&Oe.isParsed())&&(Te=v0(dt,A,ve))}if(k){const nt=A.getValueAndResolveTokens("icon-image",ve,s,H);Ue=nt instanceof gn?nt:gn.fromString(nt)}if(!Te&&!Ue)continue;const lt=this.sortFeaturesByKey?F.evaluate(ve,{},s):void 0;if(this.features.push({id:re,text:Te,icon:Ue,index:ge,sourceLayerIndex:oe,geometry:ve.geometry,properties:Y.properties,type:Dh.types[Y.type],sortKey:lt}),Ue&&(V[Ue.name]=!0),Te){const nt=_.evaluate(ve,{},s).join(","),dt=d.get("text-rotation-alignment")!=="viewport"&&d.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(W.az.vertical)>=0;for(const Tt of Te.sections)if(Tt.image)V[Tt.image.name]=!0;else{const mt=z(Te.toString()),st=Tt.fontStack||nt,Xe=j[st]=j[st]||{};this.calculateGlyphDependencies(Tt.text,Xe,dt,this.allowVerticalPlacement,mt)}}}d.get("symbol-placement")==="line"&&(this.features=(function(Y){const re={},ge={},oe=[];let ue=0;function ve(nt){oe.push(Y[nt]),ue++}function Te(nt,dt,Tt){const mt=ge[nt];return delete ge[nt],ge[dt]=mt,oe[mt].geometry[0].pop(),oe[mt].geometry[0]=oe[mt].geometry[0].concat(Tt[0]),mt}function Ue(nt,dt,Tt){const mt=re[dt];return delete re[dt],re[nt]=mt,oe[mt].geometry[0].shift(),oe[mt].geometry[0]=Tt[0].concat(oe[mt].geometry[0]),mt}function lt(nt,dt,Tt){const mt=Tt?dt[0][dt[0].length-1]:dt[0][0];return`${nt}:${mt.x}:${mt.y}`}for(let nt=0;nt<Y.length;nt++){const dt=Y[nt],Tt=dt.geometry,mt=dt.text?dt.text.toString():null;if(!mt){ve(nt);continue}const st=lt(mt,Tt),Xe=lt(mt,Tt,!0);if(st in ge&&Xe in re&&ge[st]!==re[Xe]){const Lt=Ue(st,Xe,Tt),Ct=Te(st,Xe,oe[Lt].geometry);delete re[st],delete ge[Xe],ge[lt(mt,oe[Ct].geometry,!0)]=Ct,oe[Lt].geometry=null}else st in ge?Te(st,Xe,Tt):Xe in re?Ue(st,Xe,Tt):(ve(nt),re[st]=ue-1,ge[Xe]=ue-1)}return oe.filter((nt=>nt.geometry))})(this.features)),this.sortFeaturesByKey&&this.features.sort(((Y,re)=>Y.sortKey-re.sortKey))}update(e,i,s){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,i,this.layers,{imagePositions:s}),this.icon.programConfigurations.updatePaintArrays(e,i,this.layers,{imagePositions:s}))}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,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(e,i){const s=this.lineVertexArray.length;if(e.segment!==void 0){let A=e.dist(i[e.segment+1]),d=e.dist(i[e.segment]);const _={};for(let b=e.segment+1;b<i.length;b++)_[b]={x:i[b].x,y:i[b].y,tileUnitDistanceFromAnchor:A},b<i.length-1&&(A+=i[b+1].dist(i[b]));for(let b=e.segment||0;b>=0;b--)_[b]={x:i[b].x,y:i[b].y,tileUnitDistanceFromAnchor:d},b>0&&(d+=i[b-1].dist(i[b]));for(let b=0;b<i.length;b++){const M=_[b];this.lineVertexArray.emplaceBack(M.x,M.y,M.tileUnitDistanceFromAnchor)}}return{lineStartIndex:s,lineLength:this.lineVertexArray.length-s}}addSymbols(e,i,s,A,d,_,b,M,I,k,F,V){const j=e.indexArray,H=e.layoutVertexArray,Q=e.segments.prepareSegment(4*i.length,H,j,this.canOverlap?_.sortKey:void 0),Y=this.glyphOffsetArray.length,re=Q.vertexLength,ge=this.allowVerticalPlacement&&b===W.az.vertical?Math.PI/2:0,oe=_.text&&_.text.sections;for(let ue=0;ue<i.length;ue++){const{tl:ve,tr:Te,bl:Ue,br:lt,tex:nt,pixelOffsetTL:dt,pixelOffsetBR:Tt,minFontScaleX:mt,minFontScaleY:st,glyphOffset:Xe,isSDF:Lt,sectionIndex:Ct}=i[ue],Ot=Q.vertexLength,Et=Xe[1];lc(H,M.x,M.y,ve.x,Et+ve.y,nt.x,nt.y,s,Lt,dt.x,dt.y,mt,st),lc(H,M.x,M.y,Te.x,Et+Te.y,nt.x+nt.w,nt.y,s,Lt,Tt.x,dt.y,mt,st),lc(H,M.x,M.y,Ue.x,Et+Ue.y,nt.x,nt.y+nt.h,s,Lt,dt.x,Tt.y,mt,st),lc(H,M.x,M.y,lt.x,Et+lt.y,nt.x+nt.w,nt.y+nt.h,s,Lt,Tt.x,Tt.y,mt,st),Xc(e.dynamicLayoutVertexArray,M,ge),j.emplaceBack(Ot,Ot+2,Ot+1),j.emplaceBack(Ot+1,Ot+2,Ot+3),Q.vertexLength+=4,Q.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(Xe[0]),ue!==i.length-1&&Ct===i[ue+1].sectionIndex||e.programConfigurations.populatePaintArrays(H.length,_,_.index,{imagePositions:{},canonical:V,formattedSection:oe&&oe[Ct]})}e.placedSymbolArray.emplaceBack(M.x,M.y,Y,this.glyphOffsetArray.length-Y,re,I,k,M.segment,s?s[0]:0,s?s[1]:0,A[0],A[1],b,0,!1,0,F)}_addCollisionDebugVertex(e,i,s,A,d,_){return i.emplaceBack(0,0),e.emplaceBack(s.x,s.y,A,d,Math.round(_.x),Math.round(_.y))}addCollisionDebugVertices(e,i,s,A,d,_,b){const M=d.segments.prepareSegment(4,d.layoutVertexArray,d.indexArray),I=M.vertexLength,k=d.layoutVertexArray,F=d.collisionVertexArray,V=b.anchorX,j=b.anchorY;this._addCollisionDebugVertex(k,F,_,V,j,new it(e,i)),this._addCollisionDebugVertex(k,F,_,V,j,new it(s,i)),this._addCollisionDebugVertex(k,F,_,V,j,new it(s,A)),this._addCollisionDebugVertex(k,F,_,V,j,new it(e,A)),M.vertexLength+=4;const H=d.indexArray;H.emplaceBack(I,I+1),H.emplaceBack(I+1,I+2),H.emplaceBack(I+2,I+3),H.emplaceBack(I+3,I),M.primitiveLength+=4}addDebugCollisionBoxes(e,i,s,A){for(let d=e;d<i;d++){const _=this.collisionBoxArray.get(d);this.addCollisionDebugVertices(_.x1,_.y1,_.x2,_.y2,A?this.textCollisionBox:this.iconCollisionBox,_.anchorPoint,s)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new Jc(He,df.members,xt),this.iconCollisionBox=new Jc(He,df.members,xt);for(let e=0;e<this.symbolInstances.length;e++){const i=this.symbolInstances.get(e);this.addDebugCollisionBoxes(i.textBoxStartIndex,i.textBoxEndIndex,i,!0),this.addDebugCollisionBoxes(i.verticalTextBoxStartIndex,i.verticalTextBoxEndIndex,i,!0),this.addDebugCollisionBoxes(i.iconBoxStartIndex,i.iconBoxEndIndex,i,!1),this.addDebugCollisionBoxes(i.verticalIconBoxStartIndex,i.verticalIconBoxEndIndex,i,!1)}}_deserializeCollisionBoxesForSymbol(e,i,s,A,d,_,b,M,I){const k={};for(let F=i;F<s;F++){const V=e.get(F);k.textBox={x1:V.x1,y1:V.y1,x2:V.x2,y2:V.y2,anchorPointX:V.anchorPointX,anchorPointY:V.anchorPointY},k.textFeatureIndex=V.featureIndex;break}for(let F=A;F<d;F++){const V=e.get(F);k.verticalTextBox={x1:V.x1,y1:V.y1,x2:V.x2,y2:V.y2,anchorPointX:V.anchorPointX,anchorPointY:V.anchorPointY},k.verticalTextFeatureIndex=V.featureIndex;break}for(let F=_;F<b;F++){const V=e.get(F);k.iconBox={x1:V.x1,y1:V.y1,x2:V.x2,y2:V.y2,anchorPointX:V.anchorPointX,anchorPointY:V.anchorPointY},k.iconFeatureIndex=V.featureIndex;break}for(let F=M;F<I;F++){const V=e.get(F);k.verticalIconBox={x1:V.x1,y1:V.y1,x2:V.x2,y2:V.y2,anchorPointX:V.anchorPointX,anchorPointY:V.anchorPointY},k.verticalIconFeatureIndex=V.featureIndex;break}return k}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let i=0;i<this.symbolInstances.length;i++){const s=this.symbolInstances.get(i);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(e,s.textBoxStartIndex,s.textBoxEndIndex,s.verticalTextBoxStartIndex,s.verticalTextBoxEndIndex,s.iconBoxStartIndex,s.iconBoxEndIndex,s.verticalIconBoxStartIndex,s.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(e,i){const s=e.placedSymbolArray.get(i),A=s.vertexStartIndex+4*s.numGlyphs;for(let d=s.vertexStartIndex;d<A;d+=4)e.indexArray.emplaceBack(d,d+2,d+1),e.indexArray.emplaceBack(d+1,d+2,d+3)}getSortedSymbolIndexes(e){if(this.sortedAngle===e&&this.symbolInstanceIndexes!==void 0)return this.symbolInstanceIndexes;const i=Math.sin(e),s=Math.cos(e),A=[],d=[],_=[];for(let b=0;b<this.symbolInstances.length;++b){_.push(b);const M=this.symbolInstances.get(b);A.push(0|Math.round(i*M.anchorX+s*M.anchorY)),d.push(M.featureIndex)}return _.sort(((b,M)=>A[b]-A[M]||d[M]-d[b])),_}addToSortKeyRanges(e,i){const s=this.sortKeyRanges[this.sortKeyRanges.length-1];s&&s.sortKey===i?s.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:i,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const i of this.symbolInstanceIndexes){const s=this.symbolInstances.get(i);this.featureSortOrder.push(s.featureIndex),[s.rightJustifiedTextSymbolIndex,s.centerJustifiedTextSymbolIndex,s.leftJustifiedTextSymbolIndex].forEach(((A,d,_)=>{A>=0&&_.indexOf(A)===d&&this.addIndicesForPlacedSymbol(this.text,A)})),s.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,s.verticalPlacedTextSymbolIndex),s.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,s.placedIconSymbolIndex),s.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,s.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let Sf,Cf;kt("SymbolBucket",th,{omit:["layers","collisionBoxArray","features","compareText"]}),th.MAX_GLYPHS=65535,th.addDynamicAttributes=Xc;var eA={get paint(){return Cf=Cf||new is({"icon-opacity":new Mt(qe.paint_symbol["icon-opacity"]),"icon-color":new Mt(qe.paint_symbol["icon-color"]),"icon-halo-color":new Mt(qe.paint_symbol["icon-halo-color"]),"icon-halo-width":new Mt(qe.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Mt(qe.paint_symbol["icon-halo-blur"]),"icon-translate":new _t(qe.paint_symbol["icon-translate"]),"icon-translate-anchor":new _t(qe.paint_symbol["icon-translate-anchor"]),"text-opacity":new Mt(qe.paint_symbol["text-opacity"]),"text-color":new Mt(qe.paint_symbol["text-color"],{runtimeType:fi,getOverride:r=>r.textColor,hasOverride:r=>!!r.textColor}),"text-halo-color":new Mt(qe.paint_symbol["text-halo-color"]),"text-halo-width":new Mt(qe.paint_symbol["text-halo-width"]),"text-halo-blur":new Mt(qe.paint_symbol["text-halo-blur"]),"text-translate":new _t(qe.paint_symbol["text-translate"]),"text-translate-anchor":new _t(qe.paint_symbol["text-translate-anchor"])})},get layout(){return Sf=Sf||new is({"symbol-placement":new _t(qe.layout_symbol["symbol-placement"]),"symbol-spacing":new _t(qe.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new _t(qe.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Mt(qe.layout_symbol["symbol-sort-key"]),"symbol-z-order":new _t(qe.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new _t(qe.layout_symbol["icon-allow-overlap"]),"icon-overlap":new _t(qe.layout_symbol["icon-overlap"]),"icon-ignore-placement":new _t(qe.layout_symbol["icon-ignore-placement"]),"icon-optional":new _t(qe.layout_symbol["icon-optional"]),"icon-rotation-alignment":new _t(qe.layout_symbol["icon-rotation-alignment"]),"icon-size":new Mt(qe.layout_symbol["icon-size"]),"icon-text-fit":new _t(qe.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new _t(qe.layout_symbol["icon-text-fit-padding"]),"icon-image":new Mt(qe.layout_symbol["icon-image"]),"icon-rotate":new Mt(qe.layout_symbol["icon-rotate"]),"icon-padding":new Mt(qe.layout_symbol["icon-padding"]),"icon-keep-upright":new _t(qe.layout_symbol["icon-keep-upright"]),"icon-offset":new Mt(qe.layout_symbol["icon-offset"]),"icon-anchor":new Mt(qe.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new _t(qe.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new _t(qe.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new _t(qe.layout_symbol["text-rotation-alignment"]),"text-field":new Mt(qe.layout_symbol["text-field"]),"text-font":new Mt(qe.layout_symbol["text-font"]),"text-size":new Mt(qe.layout_symbol["text-size"]),"text-max-width":new Mt(qe.layout_symbol["text-max-width"]),"text-line-height":new _t(qe.layout_symbol["text-line-height"]),"text-letter-spacing":new Mt(qe.layout_symbol["text-letter-spacing"]),"text-justify":new Mt(qe.layout_symbol["text-justify"]),"text-radial-offset":new Mt(qe.layout_symbol["text-radial-offset"]),"text-variable-anchor":new _t(qe.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new Mt(qe.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new Mt(qe.layout_symbol["text-anchor"]),"text-max-angle":new _t(qe.layout_symbol["text-max-angle"]),"text-writing-mode":new _t(qe.layout_symbol["text-writing-mode"]),"text-rotate":new Mt(qe.layout_symbol["text-rotate"]),"text-padding":new _t(qe.layout_symbol["text-padding"]),"text-keep-upright":new _t(qe.layout_symbol["text-keep-upright"]),"text-transform":new Mt(qe.layout_symbol["text-transform"]),"text-offset":new Mt(qe.layout_symbol["text-offset"]),"text-allow-overlap":new _t(qe.layout_symbol["text-allow-overlap"]),"text-overlap":new _t(qe.layout_symbol["text-overlap"]),"text-ignore-placement":new _t(qe.layout_symbol["text-ignore-placement"]),"text-optional":new _t(qe.layout_symbol["text-optional"])})}};class If{constructor(e){if(e.property.overrides===void 0)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=e.property.overrides?e.property.overrides.runtimeType:Qi,this.defaultValue=e}evaluate(e){if(e.formattedSection){const i=this.defaultValue.property.overrides;if(i&&i.hasOverride(e.formattedSection))return i.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}kt("FormatSectionOverride",If,{omit:["defaultValue"]});class uc extends ko{constructor(e,i){super(e,eA,i)}recalculate(e,i){if(super.recalculate(e,i),this.layout.get("icon-rotation-alignment")==="auto"&&(this.layout._values["icon-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-rotation-alignment")==="auto"&&(this.layout._values["text-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-pitch-alignment")==="auto"&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")==="map"?"map":"viewport"),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),this.layout.get("symbol-placement")==="point"){const s=this.layout.get("text-writing-mode");if(s){const A=[];for(const d of s)A.indexOf(d)<0&&A.push(d);this.layout._values["text-writing-mode"]=A}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(e,i,s,A){const d=this.layout.get(e).evaluate(i,{},s,A),_=this._unevaluatedLayout._values[e];return _.isDataDriven()||ds(_.value)||!d?d:(function(b,M){return M.replace(/{([^{}]+)}/g,((I,k)=>b&&k in b?String(b[k]):""))})(i.properties,d)}createBucket(e){return new th(e)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const e of eA.paint.overridableProperties){if(!uc.hasPaintOverride(this.layout,e))continue;const i=this.paint.get(e),s=new If(i),A=new ol(s,i.property.specification);let d=null;d=i.value.kind==="constant"||i.value.kind==="source"?new v("source",A):new E("composite",A,i.value.zoomStops),this.paint._values[e]=new Vt(i.property,d,i.parameters)}}_handleOverridablePaintPropertyUpdate(e,i,s){return!(!this.layout||i.isDataDriven()||s.isDataDriven())&&uc.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,i){const s=e.get("text-field"),A=eA.paint.properties[i];let d=!1;const _=b=>{for(const M of b)if(A.overrides&&A.overrides.hasOverride(M))return void(d=!0)};if(s.value.kind==="constant"&&s.value.value instanceof Wn)_(s.value.value.sections);else if(s.value.kind==="source"||s.value.kind==="composite"){const b=I=>{d||(I instanceof gs&&Si(I.value)===xo?_(I.value.sections):I instanceof La?_(I.sections):I.eachChild(b))},M=s.value;M._styleExpression&&b(M._styleExpression.expression)}return d}}let Df;var G0={get paint(){return Df=Df||new is({"background-color":new _t(qe.paint_background["background-color"]),"background-pattern":new Yi(qe.paint_background["background-pattern"]),"background-opacity":new _t(qe.paint_background["background-opacity"])})}};class q0 extends ko{constructor(e,i){super(e,G0,i)}}class H0 extends ko{constructor(e,i){super(e,{},i),this.onAdd=s=>{this.implementation.onAdd&&this.implementation.onAdd(s,s.painter.context.gl)},this.onRemove=s=>{this.implementation.onRemove&&this.implementation.onRemove(s,s.painter.context.gl)},this.implementation=e}is3D(){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}class W0{constructor(e){this._methodToThrottle=e,this._triggered=!1,typeof MessageChannel<"u"&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._methodToThrottle()}),0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}}const Q0={once:!0},tA=63710088e-1;class nu{constructor(e,i){if(isNaN(e)||isNaN(i))throw new Error(`Invalid LngLat object: (${e}, ${i})`);if(this.lng=+e,this.lat=+i,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new nu(hn(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const i=Math.PI/180,s=this.lat*i,A=e.lat*i,d=Math.sin(s)*Math.sin(A)+Math.cos(s)*Math.cos(A)*Math.cos((e.lng-this.lng)*i);return tA*Math.acos(Math.min(d,1))}static convert(e){if(e instanceof nu)return e;if(Array.isArray(e)&&(e.length===2||e.length===3))return new nu(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e=="object"&&e!==null)return new nu(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}const kf=2*Math.PI*tA;function zf(r){return kf*Math.cos(r*Math.PI/180)}function Lf(r){return(180+r)/360}function Bf(r){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+r*Math.PI/360)))/360}function Rf(r,e){return r/zf(e)}function Ff(r){return 360*r-180}function hc(r){return 360/Math.PI*Math.atan(Math.exp((180-360*r)*Math.PI/180))-90}function Of(r,e){return r*zf(hc(e))}class Bh{constructor(e,i,s=0){this.x=+e,this.y=+i,this.z=+s}static fromLngLat(e,i=0){const s=nu.convert(e);return new Bh(Lf(s.lng),Bf(s.lat),Rf(i,s.lat))}toLngLat(){return new nu(Ff(this.x),hc(this.y))}toAltitude(){return Of(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/kf*(e=hc(this.y),1/Math.cos(e*Math.PI/180));var e}}function Nf(r,e,i){var s=2*Math.PI*6378137/256/Math.pow(2,i);return[r*s-2*Math.PI*6378137/2,e*s-2*Math.PI*6378137/2]}class iA{constructor(e,i,s){if(!(function(A,d,_){return!(A<0||A>25||_<0||_>=Math.pow(2,A)||d<0||d>=Math.pow(2,A))})(e,i,s))throw new Error(`x=${i}, y=${s}, z=${e} outside of bounds. 0<=x<${Math.pow(2,e)}, 0<=y<${Math.pow(2,e)} 0<=z<=25 `);this.z=e,this.x=i,this.y=s,this.key=ih(0,e,e,i,s)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,i,s){const A=(function(_,b,M){var I=Nf(256*_,256*(b=Math.pow(2,M)-b-1),M),k=Nf(256*(_+1),256*(b+1),M);return I[0]+","+I[1]+","+k[0]+","+k[1]})(this.x,this.y,this.z),d=(function(_,b,M){let I,k="";for(let F=_;F>0;F--)I=1<<F-1,k+=(b&I?1:0)+(M&I?2:0);return k})(this.z,this.x,this.y);return e[(this.x+this.y)%e.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(s==="tms"?Math.pow(2,this.z)-this.y-1:this.y)).replace(/{ratio}/g,i>1?"@2x":"").replace(/{quadkey}/g,d).replace(/{bbox-epsg-3857}/g,A)}isChildOf(e){const i=this.z-e.z;return i>0&&e.x===this.x>>i&&e.y===this.y>>i}getTilePoint(e){const i=Math.pow(2,this.z);return new it((e.x*i-this.x)*Oi,(e.y*i-this.y)*Oi)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Vf{constructor(e,i){this.wrap=e,this.canonical=i,this.key=ih(e,i.z,i.z,i.x,i.y)}}class oa{constructor(e,i,s,A,d){if(this.terrainRttPosMatrix32f=null,e<s)throw new Error(`overscaledZ should be >= z; overscaledZ = ${e}; z = ${s}`);this.overscaledZ=e,this.wrap=i,this.canonical=new iA(s,+A,+d),this.key=ih(i,e,s,A,d)}clone(){return new oa(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const i=this.canonical.z-e;return e>this.canonical.z?new oa(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new oa(e,this.wrap,e,this.canonical.x>>i,this.canonical.y>>i)}isOverscaled(){return this.overscaledZ>this.canonical.z}calculateScaledKey(e,i){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const s=this.canonical.z-e;return e>this.canonical.z?ih(this.wrap*+i,e,this.canonical.z,this.canonical.x,this.canonical.y):ih(this.wrap*+i,e,e,this.canonical.x>>s,this.canonical.y>>s)}isChildOf(e){if(e.wrap!==this.wrap||this.overscaledZ-e.overscaledZ<=0)return!1;if(e.overscaledZ===0)return this.overscaledZ>0;const i=this.canonical.z-e.canonical.z;return!(i<0)&&e.canonical.x===this.canonical.x>>i&&e.canonical.y===this.canonical.y>>i}children(e){if(this.overscaledZ>=e)return[new oa(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const i=this.canonical.z+1,s=2*this.canonical.x,A=2*this.canonical.y;return[new oa(i,this.wrap,i,s,A),new oa(i,this.wrap,i,s+1,A),new oa(i,this.wrap,i,s,A+1),new oa(i,this.wrap,i,s+1,A+1)]}isLessThan(e){return this.wrap<e.wrap||!(this.wrap>e.wrap)&&(this.overscaledZ<e.overscaledZ||!(this.overscaledZ>e.overscaledZ)&&(this.canonical.x<e.canonical.x||!(this.canonical.x>e.canonical.x)&&this.canonical.y<e.canonical.y))}wrapped(){return new oa(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new oa(this.overscaledZ,e,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new Vf(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(e){return this.canonical.getTilePoint(new Bh(e.x-this.wrap,e.y))}}function ih(r,e,i,s,A){(r*=2)<0&&(r=-1*r-1);const d=1<<i;return(d*d*r+d*A+s).toString(36)+i.toString(36)+e.toString(36)}function rA(r,e){return e?r.properties[e]:r.id}function $0(r,e){const i={id:r.id};if(e.removeAllProperties&&(delete r.removeProperties,delete r.addOrUpdateProperties,delete e.removeProperties),e.removeProperties)for(const s of e.removeProperties){const A=r.addOrUpdateProperties.findIndex((d=>d.key===s));A>-1&&r.addOrUpdateProperties.splice(A,1)}return(r.removeAllProperties||e.removeAllProperties)&&(i.removeAllProperties=!0),(r.removeProperties||e.removeProperties)&&(i.removeProperties=[...r.removeProperties||[],...e.removeProperties||[]]),(r.addOrUpdateProperties||e.addOrUpdateProperties)&&(i.addOrUpdateProperties=[...r.addOrUpdateProperties||[],...e.addOrUpdateProperties||[]]),(r.newGeometry||e.newGeometry)&&(i.newGeometry=e.newGeometry||r.newGeometry),i}function jf(r){var e,i;if(!r)return{};const s={};return s.removeAll=r.removeAll,s.remove=new Set(r.remove||[]),s.add=new Map((e=r.add)===null||e===void 0?void 0:e.map((A=>[A.id,A]))),s.update=new Map((i=r.update)===null||i===void 0?void 0:i.map((A=>[A.id,A]))),s}kt("CanonicalTileID",iA),kt("OverscaledTileID",oa,{omit:["terrainRttPosMatrix32f"]});class Cu{constructor(){this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0}extend(e){return this.minX=Math.min(this.minX,e.x),this.minY=Math.min(this.minY,e.y),this.maxX=Math.max(this.maxX,e.x),this.maxY=Math.max(this.maxY,e.y),this}expandBy(e){return this.minX-=e,this.minY-=e,this.maxX+=e,this.maxY+=e,(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(e){return this.expandBy(-e)}map(e){const i=new Cu;return i.extend(e(new it(this.minX,this.minY))),i.extend(e(new it(this.maxX,this.minY))),i.extend(e(new it(this.minX,this.maxY))),i.extend(e(new it(this.maxX,this.maxY))),i}static fromPoints(e){const i=new Cu;for(const s of e)i.extend(s);return i}contains(e){return e.x>=this.minX&&e.x<=this.maxX&&e.y>=this.minY&&e.y<=this.maxY}empty(){return this.minX>this.maxX}width(){return this.maxX-this.minX}height(){return this.maxY-this.minY}covers(e){return!this.empty()&&!e.empty()&&e.minX>=this.minX&&e.maxX<=this.maxX&&e.minY>=this.minY&&e.maxY<=this.maxY}intersects(e){return!this.empty()&&!e.empty()&&e.minX<=this.maxX&&e.maxX>=this.minX&&e.minY<=this.maxY&&e.maxY>=this.minY}}class Zf{constructor(e){this._stringToNumber={},this._numberToString=[];for(let i=0;i<e.length;i++){const s=e[i];this._stringToNumber[s]=i,this._numberToString[i]=s}}encode(e){return this._stringToNumber[e]}decode(e){if(e>=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${e} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[e]}}class Uf{constructor(e,i,s,A,d){this.type="Feature",this._vectorTileFeature=e,this._x=s,this._y=A,this._z=i,this.properties=e.properties,this.id=d}projectPoint(e,i,s,A){return[360*(e.x+i)/A-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+s)/A)*Math.PI))-90]}projectLine(e,i,s,A){return e.map((d=>this.projectPoint(d,i,s,A)))}get geometry(){if(this._geometry)return this._geometry;const e=this._vectorTileFeature,i=e.extent*Math.pow(2,this._z),s=e.extent*this._x,A=e.extent*this._y,d=e.loadGeometry();switch(e.type){case 1:{const _=[];for(const M of d)_.push(M[0]);const b=this.projectLine(_,s,A,i);this._geometry=_.length===1?{type:"Point",coordinates:b[0]}:{type:"MultiPoint",coordinates:b};break}case 2:{const _=d.map((b=>this.projectLine(b,s,A,i)));this._geometry=_.length===1?{type:"LineString",coordinates:_[0]}:{type:"MultiLineString",coordinates:_};break}case 3:{const _=nf(d),b=[];for(const M of _)b.push(M.map((I=>this.projectLine(I,s,A,i))));this._geometry=b.length===1?{type:"Polygon",coordinates:b[0]}:{type:"MultiPolygon",coordinates:b};break}default:throw new Error(`unknown feature type: ${e.type}`)}return this._geometry}set geometry(e){this._geometry=e}toJSON(){const e={geometry:this.geometry};for(const i in this)i!=="_geometry"&&i!=="_vectorTileFeature"&&i!=="_x"&&i!=="_y"&&i!=="_z"&&(e[i]=this[i]);return e}}class rh{constructor(e,i,s){Pi(this,"_name");Pi(this,"dataBuffer");Pi(this,"nullabilityBuffer");Pi(this,"_size");this._name=e,this.dataBuffer=i,typeof s=="number"?this._size=s:(this.nullabilityBuffer=s,this._size=s.size())}getValue(e){return this.nullabilityBuffer&&!this.nullabilityBuffer.get(e)?null:this.getValueFromBuffer(e)}has(e){return this.nullabilityBuffer&&this.nullabilityBuffer.get(e)||!this.nullabilityBuffer}get name(){return this._name}get size(){return this._size}}class cc extends rh{}class nA extends cc{getValueFromBuffer(e){return this.dataBuffer[e]}}class sA extends cc{getValueFromBuffer(e){return this.dataBuffer[e]}}class Gf extends rh{constructor(i,s,A,d){super(i,s,d);Pi(this,"delta");this.delta=A}}class oA extends Gf{constructor(e,i,s,A){super(e,Int32Array.of(i),s,A)}getValueFromBuffer(e){return this.dataBuffer[0]+e*this.delta}}class aA extends rh{constructor(e,i,s){super(e,Int32Array.of(i),s)}getValueFromBuffer(e){return this.dataBuffer[0]}}class Y0{constructor(e,i,s,A,d=4096){Pi(this,"_name");Pi(this,"_geometryVector");Pi(this,"_idVector");Pi(this,"_propertyVectors");Pi(this,"_extent");Pi(this,"propertyVectorsMap");this._name=e,this._geometryVector=i,this._idVector=s,this._propertyVectors=A,this._extent=d}get name(){return this._name}get idVector(){return this._idVector}get geometryVector(){return this._geometryVector}get propertyVectors(){return this._propertyVectors}getPropertyVector(e){return this.propertyVectorsMap||(this.propertyVectorsMap=new Map(this._propertyVectors.map((i=>[i.name,i])))),this.propertyVectorsMap.get(e)}*[Symbol.iterator](){const e=this.geometryVector[Symbol.iterator]();let i=0;for(;i<this.numFeatures;){let s;this.idVector&&(s=this.containsMaxSaveIntegerValues(this.idVector)?Number(this.idVector.getValue(i)):this.idVector.getValue(i));const A=e==null?void 0:e.next().value,d={};for(const _ of this.propertyVectors){if(!_)continue;const b=_.name,M=_.getValue(i);M!==null&&(d[b]=M)}i++,yield{id:s,geometry:A,properties:d}}}get numFeatures(){return this.geometryVector.numGeometries}get extent(){return this._extent}getFeatures(){const e=[],i=this.geometryVector.getGeometries();for(let s=0;s<this.numFeatures;s++){let A;this.idVector&&(A=this.containsMaxSaveIntegerValues(this.idVector)?Number(this.idVector.getValue(s)):this.idVector.getValue(s));const d={coordinates:i[s],type:this.geometryVector.geometryType(s)},_={};for(const b of this.propertyVectors){if(!b)continue;const M=b.name,I=b.getValue(s);I!==null&&(_[M]=I)}e.push({id:A,geometry:d,properties:_})}return e}containsMaxSaveIntegerValues(e){return e instanceof nA||e instanceof aA&&e instanceof oA||e instanceof sA}}class X0{constructor(e){Pi(this,"value");this.value=e}get(){return this.value}set(e){this.value=e}increment(){return this.value++}add(e){this.value+=e}}var ki,Rl,ws,ja,Iu,Lo,ss,os,qf,aa;function _s(r,e,i){const s=new Int32Array(i);let A=0,d=e.get();for(let _=0;_<s.length;_++){let b=r[d++],M=127&b;b<128||(b=r[d++],M|=(127&b)<<7,b<128||(b=r[d++],M|=(127&b)<<14,b<128||(b=r[d++],M|=(127&b)<<21,b<128||(b=r[d++],M|=(15&b)<<28)))),s[A++]=M}return e.set(d),s}function Ac(r,e,i){const s=new BigInt64Array(i);for(let A=0;A<s.length;A++)s[A]=J0(r,e);return s}function K0(r,e){let i,s;return s=r[e.get()],e.increment(),i=127&s,s<128?i:(s=r[e.get()],e.increment(),i|=(127&s)<<7,s<128?i:(s=r[e.get()],e.increment(),i|=(127&s)<<14,s<128?i:(s=r[e.get()],e.increment(),i|=(127&s)<<21,s<128?i:(s=r[e.get()],i|=(15&s)<<28,(function(A,d,_){let b,M;if(M=d[_.get()],_.increment(),b=(112&M)>>4,M<128||(M=d[_.get()],_.increment(),b|=(127&M)<<3,M<128)||(M=d[_.get()],_.increment(),b|=(127&M)<<10,M<128)||(M=d[_.get()],_.increment(),b|=(127&M)<<17,M<128)||(M=d[_.get()],_.increment(),b|=(127&M)<<24,M<128)||(M=d[_.get()],_.increment(),b|=(1&M)<<31,M<128))return 4294967296*b+(A>>>0);throw new Error("Expected varint not more than 10 bytes")})(i,r,e)))))}function Hf(r,e,i,s){throw new Error("FastPFor is not implemented yet.")}function Du(r){return r>>>1^-(1&r)}function nh(r){return r>>1n^-(1n&r)}function J0(r,e){let i=0n,s=0,A=e.get();for(;A<r.length;){const d=r[A++];if(i|=BigInt(127&d)<<BigInt(s),!(128&d))break;if(s+=7,s>=64)throw new Error("Varint too long")}return e.set(A),i}function Wf(r,e,i){const s=new Int32Array(i);let A=0;for(let d=0;d<e;d++){const _=r[d];s.fill(r[d+e],A,A+_),A+=_}return s}function Qf(r,e,i){const s=new BigInt64Array(i);let A=0;for(let d=0;d<e;d++){const _=Number(r[d]);s.fill(r[d+e],A,A+_),A+=_}return s}function $f(r,e,i){const s=new Float64Array(i);let A=0;for(let d=0;d<e;d++){const _=r[d];s.fill(r[d+e],A,A+_),A+=_}return s}function lA(r){const e=r.length/4*4;let i=1;if(e>=4)for(let s=r[0];i<e-4;i+=4)s=r[i]+=s,s=r[i+1]+=s,s=r[i+2]+=s,s=r[i+3]+=s;for(;i!=r.length;)r[i]+=r[i-1],++i}function Yf(r){r[0]=r[0]>>>1^-(1&r[0]),r[1]=r[1]>>>1^-(1&r[1]);const e=r.length/4*4;let i=2;if(e>=4)for(;i<e-4;i+=4){const s=r[i],A=r[i+1],d=r[i+2],_=r[i+3];r[i]=(s>>>1^-(1&s))+r[i-2],r[i+1]=(A>>>1^-(1&A))+r[i-1],r[i+2]=(d>>>1^-(1&d))+r[i],r[i+3]=(_>>>1^-(1&_))+r[i+1]}for(;i!=r.length;i+=2)r[i]=(r[i]>>>1^-(1&r[i]))+r[i-2],r[i+1]=(r[i+1]>>>1^-(1&r[i+1]))+r[i-1]}(function(r){r.NONE="NONE",r.DELTA="DELTA",r.COMPONENTWISE_DELTA="COMPONENTWISE_DELTA",r.RLE="RLE",r.MORTON="MORTON",r.PDE="PDE"})(ki||(ki={})),(function(r){r.NONE="NONE",r.FAST_PFOR="FAST_PFOR",r.VARINT="VARINT",r.ALP="ALP"})(Rl||(Rl={})),(function(r){r.PRESENT="PRESENT",r.DATA="DATA",r.OFFSET="OFFSET",r.LENGTH="LENGTH"})(ws||(ws={}));class uA{constructor(e,i,s){Pi(this,"_dictionaryType");Pi(this,"_offsetType");Pi(this,"_lengthType");this._dictionaryType=e,this._offsetType=i,this._lengthType=s}get dictionaryType(){return this._dictionaryType}get offsetType(){return this._offsetType}get lengthType(){return this._lengthType}}function to(r,e){const i=(function(s,A){const d=s[A.get()],_=Object.values(ws)[d>>4];let b=null;switch(_){case ws.DATA:b=new uA(Object.values(ja)[15&d]);break;case ws.OFFSET:b=new uA(null,Object.values(Iu)[15&d]);break;case ws.LENGTH:b=new uA(null,null,Object.values(Lo)[15&d])}A.increment();const M=s[A.get()],I=Object.values(ki)[M>>5],k=Object.values(ki)[M>>2&7],F=Object.values(Rl)[3&M];A.increment();const V=_s(s,A,2),j=V[0];return{physicalStreamType:_,logicalStreamType:b,logicalLevelTechnique1:I,logicalLevelTechnique2:k,physicalLevelTechnique:F,numValues:j,byteLength:V[1],decompressedCount:j}})(r,e);return i.logicalLevelTechnique1===ki.MORTON?(function(s,A,d){const _=_s(A,d,2);return{physicalStreamType:s.physicalStreamType,logicalStreamType:s.logicalStreamType,logicalLevelTechnique1:s.logicalLevelTechnique1,logicalLevelTechnique2:s.logicalLevelTechnique2,physicalLevelTechnique:s.physicalLevelTechnique,numValues:s.numValues,byteLength:s.byteLength,decompressedCount:s.decompressedCount,numBits:_[0],coordinateShift:_[1]}})(i,r,e):ki.RLE!==i.logicalLevelTechnique1&&ki.RLE!==i.logicalLevelTechnique2||Rl.NONE===i.physicalLevelTechnique?i:(function(s,A,d){const _=_s(A,d,2);return{physicalStreamType:s.physicalStreamType,logicalStreamType:s.logicalStreamType,logicalLevelTechnique1:s.logicalLevelTechnique1,logicalLevelTechnique2:s.logicalLevelTechnique2,physicalLevelTechnique:s.physicalLevelTechnique,numValues:s.numValues,byteLength:s.byteLength,decompressedCount:_[1],runs:_[0],numRleValues:_[1]}})(i,r,e)}(function(r){r.NONE="NONE",r.SINGLE="SINGLE",r.SHARED="SHARED",r.VERTEX="VERTEX",r.MORTON="MORTON",r.FSST="FSST"})(ja||(ja={})),(function(r){r.VERTEX="VERTEX",r.INDEX="INDEX",r.STRING="STRING",r.KEY="KEY"})(Iu||(Iu={})),(function(r){r.VAR_BINARY="VAR_BINARY",r.GEOMETRIES="GEOMETRIES",r.PARTS="PARTS",r.RINGS="RINGS",r.TRIANGLES="TRIANGLES",r.SYMBOL="SYMBOL",r.DICTIONARY="DICTIONARY"})(Lo||(Lo={})),(function(r){r[r.FLAT=0]="FLAT",r[r.CONST=1]="CONST",r[r.SEQUENCE=2]="SEQUENCE",r[r.DICTIONARY=3]="DICTIONARY",r[r.FSST_DICTIONARY=4]="FSST_DICTIONARY"})(ss||(ss={}));class Za{constructor(e,i){Pi(this,"values");Pi(this,"_size");this.values=e,this._size=i}get(e){const i=Math.floor(e/8);return(this.values[i]>>e%8&1)==1}set(e,i){const s=Math.floor(e/8);this.values[s]=this.values[s]|(i?1:0)<<e%8}getInt(e){const i=Math.floor(e/8);return this.values[i]>>e%8&1}size(){return this._size}getBuffer(){return this.values}}function io(r,e,i,s,A){return(function(d,_,b){switch(_.logicalLevelTechnique1){case ki.DELTA:return _.logicalLevelTechnique2===ki.RLE?(function(M,I,k){const F=new Int32Array(k);let V=0,j=0;for(let H=0;H<I;H++){const Q=M[H],Y=Du(M[H+I]);for(let re=0;re<Q;re++)j+=Y,F[V++]=j}return F})(d,_.runs,_.numRleValues):((function(M){M[0]=M[0]>>>1^-(1&M[0]);const I=M.length/4*4;let k=1;if(I>=4)for(;k<I-4;k+=4){const F=M[k],V=M[k+1],j=M[k+2],H=M[k+3];M[k]=(F>>>1^-(1&F))+M[k-1],M[k+1]=(V>>>1^-(1&V))+M[k],M[k+2]=(j>>>1^-(1&j))+M[k+1],M[k+3]=(H>>>1^-(1&H))+M[k+2]}for(;k!=M.length;++k)M[k]=(M[k]>>>1^-(1&M[k]))+M[k-1]})(d),d);case ki.RLE:return(function(M,I,k){return k?(function(F,V,j){const H=new Int32Array(j);let Q=0;for(let Y=0;Y<V;Y++){const re=F[Y];let ge=F[Y+V];ge=ge>>>1^-(1&ge),H.fill(ge,Q,Q+re),Q+=re}return H})(M,I.runs,I.numRleValues):Wf(M,I.runs,I.numRleValues)})(d,_,b);case ki.MORTON:return lA(d),d;case ki.COMPONENTWISE_DELTA:return Yf(d),d;case ki.NONE:return b&&(function(M){for(let I=0;I<M.length;I++){const k=M[I];M[I]=k>>>1^-(1&k)}})(d),d;default:throw new Error(`The specified Logical level technique is not supported: ${_.logicalLevelTechnique1}`)}})(fc(r,e,i),i,s)}function su(r,e,i){return(function(s,A){if(A.logicalLevelTechnique1===ki.DELTA&&A.logicalLevelTechnique2===ki.NONE)return(function(_){const b=new Int32Array(_.length+1);b[0]=0,b[1]=Du(_[0]);let M=b[1],I=2;for(;I!=b.length;++I){const k=_[I-1];M+=k>>>1^-(1&k),b[I]=b[I-1]+M}return b})(s);if(A.logicalLevelTechnique1===ki.RLE&&A.logicalLevelTechnique2===ki.NONE)return(function(_,b,M){const I=new Int32Array(M+1);I[0]=0;let k=1,F=I[0];for(let V=0;V<b;V++){const j=_[V],H=_[V+b];for(let Q=k;Q<k+j;Q++)I[Q]=H+F,F=I[Q];k+=j}return I})(s,A.runs,A.numRleValues);if(A.logicalLevelTechnique1===ki.NONE&&A.logicalLevelTechnique2===ki.NONE){(function(_){let b=0;for(let M=0;M<_.length;M++)_[M]+=b,b=_[M]})(s);const d=new Int32Array(A.numValues+1);return d[0]=0,d.set(s,1),d}if(A.logicalLevelTechnique1===ki.DELTA&&A.logicalLevelTechnique2===ki.RLE){const d=(function(_,b,M){const I=new Int32Array(M+1);I[0]=0;let k=1,F=I[0];for(let V=0;V<b;V++){const j=_[V];let H=_[V+b];H=H>>>1^-(1&H);for(let Q=k;Q<k+j;Q++)I[Q]=H+F,F=I[Q];k+=j}return I})(s,A.runs,A.numRleValues);return lA(d),d}throw new Error("Only delta encoding is supported for transforming length to offset streams yet.")})(fc(r,e,i),i)}function fc(r,e,i){const s=i.physicalLevelTechnique;if(s===Rl.FAST_PFOR)return Hf();if(s===Rl.VARINT)return _s(r,e,i.numValues);if(s===Rl.NONE){const A=e.get();e.add(i.byteLength);const d=r.subarray(A,e.get());return new Int32Array(d)}throw new Error("Specified physicalLevelTechnique is not supported (yet).")}function hA(r,e,i,s){const A=fc(r,e,i);if(A.length===1){const d=A[0];return s?Du(d):d}return s?(function(d){return Du(d[1])})(A):(function(d){return d[1]})(A)}function Xf(r,e,i){return(function(s){if(s.length==2){const A=Du(s[1]);return[A,A]}return[Du(s[2]),Du(s[3])]})(fc(r,e,i))}function Kf(r,e,i){return(function(s){if(s.length==2){const A=nh(s[1]);return[A,A]}return[nh(s[2]),nh(s[3])]})(Ac(r,e,i.numValues))}function Jf(r,e,i,s){return(function(A,d,_){switch(d.logicalLevelTechnique1){case ki.DELTA:return d.logicalLevelTechnique2===ki.RLE?(function(b,M,I){const k=new BigInt64Array(I);let F=0,V=0n;for(let j=0;j<M;j++){const H=Number(b[j]),Q=nh(b[j+M]);for(let Y=0;Y<H;Y++)V+=Q,k[F++]=V}return k})(A,d.runs,d.numRleValues):((function(b){b[0]=b[0]>>1n^-(1n&b[0]);const M=b.length/4*4;let I=1;if(M>=4)for(;I<M-4;I+=4){const k=b[I],F=b[I+1],V=b[I+2],j=b[I+3];b[I]=(k>>1n^-(1n&k))+b[I-1],b[I+1]=(F>>1n^-(1n&F))+b[I],b[I+2]=(V>>1n^-(1n&V))+b[I+1],b[I+3]=(j>>1n^-(1n&j))+b[I+2]}for(;I!=b.length;++I)b[I]=(b[I]>>1n^-(1n&b[I]))+b[I-1]})(A),A);case ki.RLE:return(function(b,M,I){return I?(function(k,F,V){const j=new BigInt64Array(V);let H=0;for(let Q=0;Q<F;Q++){const Y=Number(k[Q]);let re=k[Q+F];re=re>>1n^-(1n&re),j.fill(re,H,H+Y),H+=Y}return j})(b,M.runs,M.numRleValues):Qf(b,M.runs,M.numRleValues)})(A,d,_);case ki.NONE:return _&&(function(b){for(let M=0;M<b.length;M++){const I=b[M];b[M]=I>>1n^-(1n&I)}})(A),A;default:throw new Error(`The specified Logical level technique is not supported: ${d.logicalLevelTechnique1}`)}})(Ac(r,e,i.numValues),i,s)}function ed(r,e,i,s){const A=Ac(r,e,i.numValues);if(A.length===1){const d=A[0];return s?nh(d):d}return s?(function(d){return nh(d[1])})(A):(function(d){return d[1]})(A)}function cA(r,e,i,s,A){return(function(d,_,b,M){switch(_.logicalLevelTechnique1){case ki.DELTA:return _.logicalLevelTechnique2===ki.RLE&&(d=Wf(d,_.runs,_.numRleValues)),(function(I,k){const F=new Int32Array(I.size());let V=0;I.get(0)?(F[0]=I.get(0)?k[0]>>>1^-(1&k[0]):0,V=1):F[0]=0;let j=1;for(;j!=F.length;++j)F[j]=I.get(j)?F[j-1]+(k[V]>>>1^-(1&k[V++])):F[j-1];return F})(M,d);case ki.RLE:return(function(I,k,F,V){const j=k;return F?(function(H,Q,Y){const re=new Int32Array(H.size());let ge=0;for(let oe=0;oe<Y;oe++){const ue=Q[oe];let ve=Q[oe+Y];ve=ve>>>1^-(1&ve);for(let Te=ge;Te<ge+ue;Te++)H.get(Te)?re[Te]=ve:(re[Te]=0,ge++);ge+=ue}return re})(V,I,j.runs):(function(H,Q,Y){const re=new Int32Array(H.size());let ge=0;for(let oe=0;oe<Y;oe++){const ue=Q[oe],ve=Q[oe+Y];for(let Te=ge;Te<ge+ue;Te++)H.get(Te)?re[Te]=ve:(re[Te]=0,ge++);ge+=ue}return re})(V,I,j.runs)})(d,_,b,M);case ki.MORTON:return lA(d),d;case ki.COMPONENTWISE_DELTA:return Yf(d),d;case ki.NONE:return d=b?(function(I,k){const F=new Int32Array(I.size());let V=0,j=0;for(;j!=F.length;++j)if(I.get(j)){const H=k[V++];F[j]=H>>>1^-(1&H)}else F[j]=0;return F})(M,d):(function(I,k){const F=new Int32Array(I.size());let V=0,j=0;for(;j!=F.length;++j)F[j]=I.get(j)?k[V++]:0;return F})(M,d),d;default:throw new Error("The specified Logical level technique is not supported")}})(i.physicalLevelTechnique===Rl.FAST_PFOR?Hf():_s(r,e,i.numValues),i,s,A)}function dc(r,e,i,s){const A=r.logicalLevelTechnique1;if(A===ki.RLE)return r.runs===1?ss.CONST:ss.FLAT;const d=e instanceof Za?e.size():e;if(A===ki.DELTA&&r.logicalLevelTechnique2===ki.RLE){const _=r.runs,b=2;if(r.numRleValues!==d)return ss.FLAT;if(_===1)return ss.SEQUENCE;if(_===2){const M=s.get();let I;if(r.physicalLevelTechnique===Rl.VARINT)I=_s(i,s,4);else{const k=s.get();I=new Int32Array(i.buffer,i.byteOffset+k,4)}if(s.set(M),I[2]===b&&I[3]===b)return ss.SEQUENCE}}return r.numValues===1?ss.CONST:ss.FLAT}class td extends cc{getValueFromBuffer(e){return this.dataBuffer[e]}}class id extends Gf{constructor(e,i,s,A){super(e,BigInt64Array.of(i),s,A)}getValueFromBuffer(e){return this.dataBuffer[0]+BigInt(e)*this.delta}}class sh{constructor(e,i,s){Pi(this,"_geometryOffsets");Pi(this,"_partOffsets");Pi(this,"_ringOffsets");this._geometryOffsets=e,this._partOffsets=i,this._ringOffsets=s}get geometryOffsets(){return this._geometryOffsets}get partOffsets(){return this._partOffsets}get ringOffsets(){return this._ringOffsets}}function AA(r,e,i){return{x:rd(r,e)-i,y:rd(r>>1,e)-i}}function rd(r,e){let i=0;for(let s=0;s<e;s++)i|=(r&1<<2*s)>>s;return i}(function(r){r[r.POINT=0]="POINT",r[r.LINESTRING=1]="LINESTRING",r[r.POLYGON=2]="POLYGON",r[r.MULTIPOINT=3]="MULTIPOINT",r[r.MULTILINESTRING=4]="MULTILINESTRING",r[r.MULTIPOLYGON=5]="MULTIPOLYGON"})(os||(os={})),(function(r){r[r.POINT=0]="POINT",r[r.LINESTRING=1]="LINESTRING",r[r.POLYGON=2]="POLYGON"})(qf||(qf={})),(function(r){r[r.MORTON=0]="MORTON",r[r.VEC_2=1]="VEC_2",r[r.VEC_3=2]="VEC_3"})(aa||(aa={}));class em{createPoint(e){return[[e]]}createMultiPoint(e){return e.map((i=>[i]))}createLineString(e){return[e]}createMultiLineString(e){return e}createPolygon(e,i){return[e].concat(i)}createMultiPolygon(e){return e.flat()}}function nd(r){const e=new Array(r.numGeometries);let i=1,s=1,A=1,d=0;const _=new em;let b=0,M=0;const I=r.mortonSettings,k=r.topologyVector,F=k.geometryOffsets,V=k.partOffsets,j=k.ringOffsets,H=r.vertexOffsets,Q=r.containsPolygonGeometry(),Y=r.vertexBuffer;for(let re=0;re<r.numGeometries;re++){const ge=r.geometryType(re);if(ge===os.POINT){if(H&&H.length!==0)if(r.vertexBufferType===aa.VEC_2){const oe=2*H[M++],ue=new it(Y[oe],Y[oe+1]);e[d++]=_.createPoint(ue)}else{const oe=AA(Y[H[M++]],I.numBits,I.coordinateShift),ue=new it(oe.x,oe.y);e[d++]=_.createPoint(ue)}else{const oe=new it(Y[b++],Y[b++]);e[d++]=_.createPoint(oe)}F&&A++,V&&i++,j&&s++}else if(ge===os.MULTIPOINT){const oe=F[A]-F[A-1];A++;const ue=new Array(oe);if(H&&H.length!==0){for(let ve=0;ve<oe;ve++){const Te=2*H[M++];ue[ve]=new it(Y[Te],Y[Te+1])}e[d++]=_.createMultiPoint(ue)}else{for(let ve=0;ve<oe;ve++){const Te=Y[b++],Ue=Y[b++];ue[ve]=new it(Te,Ue)}e[d++]=_.createMultiPoint(ue)}}else if(ge===os.LINESTRING){let oe,ue=0;Q?(ue=j[s]-j[s-1],s++):ue=V[i]-V[i-1],i++,H&&H.length!==0?(oe=r.vertexBufferType===aa.VEC_2?dA(Y,H,M,ue,!1):pA(Y,H,M,ue,!1,I),M+=ue):(oe=fA(Y,b,ue,!1),b+=2*ue),e[d++]=_.createLineString(oe),F&&A++}else if(ge===os.POLYGON){const oe=V[i]-V[i-1];i++;const ue=new Array(oe-1);let ve=j[s]-j[s-1];if(s++,H&&H.length!==0){const Te=r.vertexBufferType===aa.VEC_2?mc(Y,H,M,ve):_c(Y,H,M,ve,0,I);M+=ve;for(let Ue=0;Ue<ue.length;Ue++)ve=j[s]-j[s-1],s++,ue[Ue]=r.vertexBufferType===aa.VEC_2?mc(Y,H,M,ve):_c(Y,H,M,ve,0,I),M+=ve;e[d++]=_.createPolygon(Te,ue)}else{const Te=pc(Y,b,ve);b+=2*ve;for(let Ue=0;Ue<ue.length;Ue++)ve=j[s]-j[s-1],s++,ue[Ue]=pc(Y,b,ve),b+=2*ve;e[d++]=_.createPolygon(Te,ue)}F&&A++}else if(ge===os.MULTILINESTRING){const oe=F[A]-F[A-1];A++;const ue=new Array(oe);if(H&&H.length!==0){for(let ve=0;ve<oe;ve++){let Te=0;Q?(Te=j[s]-j[s-1],s++):Te=V[i]-V[i-1],i++;const Ue=r.vertexBufferType===aa.VEC_2?dA(Y,H,M,Te,!1):pA(Y,H,M,Te,!1,I);ue[ve]=Ue,M+=Te}e[d++]=_.createMultiLineString(ue)}else{for(let ve=0;ve<oe;ve++){let Te=0;Q?(Te=j[s]-j[s-1],s++):Te=V[i]-V[i-1],i++,ue[ve]=fA(Y,b,Te,!1),b+=2*Te}e[d++]=_.createMultiLineString(ue)}}else{if(ge!==os.MULTIPOLYGON)throw new Error("The specified geometry type is currently not supported.");{const oe=F[A]-F[A-1];A++;const ue=new Array(oe);let ve=0;if(H&&H.length!==0){for(let Te=0;Te<oe;Te++){const Ue=V[i]-V[i-1];i++;const lt=new Array(Ue-1);ve=j[s]-j[s-1],s++;const nt=r.vertexBufferType===aa.VEC_2?mc(Y,H,M,ve):_c(Y,H,M,ve,0,I);M+=ve;for(let dt=0;dt<lt.length;dt++)ve=j[s]-j[s-1],s++,lt[dt]=r.vertexBufferType===aa.VEC_2?mc(Y,H,M,ve):_c(Y,H,M,ve,0,I),M+=ve;ue[Te]=_.createPolygon(nt,lt)}e[d++]=_.createMultiPolygon(ue)}else{for(let Te=0;Te<oe;Te++){const Ue=V[i]-V[i-1];i++;const lt=new Array(Ue-1);ve=j[s]-j[s-1],s++;const nt=pc(Y,b,ve);b+=2*ve;for(let dt=0;dt<lt.length;dt++){const Tt=j[s]-j[s-1];s++,lt[dt]=pc(Y,b,Tt),b+=2*Tt}ue[Te]=_.createPolygon(nt,lt)}e[d++]=_.createMultiPolygon(ue)}}}}return e}function pc(r,e,i){return fA(r,e,i,!0)}function mc(r,e,i,s){return dA(r,e,i,s,!0)}function _c(r,e,i,s,A,d){return pA(r,e,i,s,!0,d)}function fA(r,e,i,s){const A=new Array(s?i+1:i);for(let d=0;d<2*i;d+=2)A[d/2]=new it(r[e+d],r[e+d+1]);return s&&(A[A.length-1]=A[0]),A}function dA(r,e,i,s,A){const d=new Array(A?s+1:s);for(let _=0;_<2*s;_+=2){const b=2*e[i+_/2];d[_/2]=new it(r[b],r[b+1])}return A&&(d[d.length-1]=d[0]),d}function pA(r,e,i,s,A,d){const _=new Array(A?s+1:s);for(let b=0;b<s;b++){const M=AA(r[e[i+b]],d.numBits,d.coordinateShift);_[b]=new it(M.x,M.y)}return A&&(_[_.length-1]=_[0]),_}class sd{constructor(e,i,s,A,d){Pi(this,"_vertexBufferType");Pi(this,"_topologyVector");Pi(this,"_vertexOffsets");Pi(this,"_vertexBuffer");Pi(this,"_mortonSettings");this._vertexBufferType=e,this._topologyVector=i,this._vertexOffsets=s,this._vertexBuffer=A,this._mortonSettings=d}get vertexBufferType(){return this._vertexBufferType}get topologyVector(){return this._topologyVector}get vertexOffsets(){return this._vertexOffsets}get vertexBuffer(){return this._vertexBuffer}*[Symbol.iterator](){const e=nd(this);let i=0;for(;i<this.numGeometries;)yield{coordinates:e[i],type:this.geometryType(i)},i++}getSimpleEncodedVertex(e){const i=this.vertexOffsets?2*this.vertexOffsets[e]:2*e;return[this.vertexBuffer[i],this.vertexBuffer[i+1]]}getVertex(e){if(this.vertexOffsets&&this.mortonSettings){const s=AA(this.vertexBuffer[this.vertexOffsets[e]],this.mortonSettings.numBits,this.mortonSettings.coordinateShift);return[s.x,s.y]}const i=this.vertexOffsets?2*this.vertexOffsets[e]:2*e;return[this.vertexBuffer[i],this.vertexBuffer[i+1]]}getGeometries(){return nd(this)}get mortonSettings(){return this._mortonSettings}}class od extends sd{constructor(i,s,A,d,_,b,M){super(A,d,_,b,M);Pi(this,"_numGeometries");Pi(this,"_geometryType");this._numGeometries=i,this._geometryType=s}geometryType(i){return this._geometryType}get numGeometries(){return this._numGeometries}containsPolygonGeometry(){return this._geometryType===os.POLYGON||this._geometryType===os.MULTIPOLYGON}containsSingleGeometryType(){return!0}}class ad extends sd{constructor(i,s,A,d,_,b){super(i,A,d,_,b);Pi(this,"_geometryTypes");this._geometryTypes=s}geometryType(i){return this._geometryTypes[i]}get numGeometries(){return this._geometryTypes.length}containsPolygonGeometry(){for(let i=0;i<this.numGeometries;i++)if(this.geometryType(i)===os.POLYGON||this.geometryType(i)===os.MULTIPOLYGON)return!0;return!1}containsSingleGeometryType(){return!1}}class ld{constructor(e,i,s,A){Pi(this,"_triangleOffsets");Pi(this,"_indexBuffer");Pi(this,"_vertexBuffer");Pi(this,"_topologyVector");this._triangleOffsets=e,this._indexBuffer=i,this._vertexBuffer=s,this._topologyVector=A}get triangleOffsets(){return this._triangleOffsets}get indexBuffer(){return this._indexBuffer}get vertexBuffer(){return this._vertexBuffer}get topologyVector(){return this._topologyVector}getGeometries(){if(!this._topologyVector)throw new Error("Cannot convert GpuVector to coordinates without topology information");const e=new Array(this.numGeometries),i=this._topologyVector,s=i.partOffsets,A=i.ringOffsets,d=i.geometryOffsets;let _=0,b=1,M=1,I=1;for(let k=0;k<this.numGeometries;k++)switch(this.geometryType(k)){case os.POLYGON:{const F=s[b]-s[b-1];b++;const V=[];for(let j=0;j<F;j++){const H=A[M]-A[M-1];M++;const Q=[];for(let Y=0;Y<H;Y++){const re=this._vertexBuffer[_++],ge=this._vertexBuffer[_++];Q.push(new it(re,ge))}Q.length>0&&Q.push(Q[0]),V.push(Q)}e[k]=V,d&&I++}break;case os.MULTIPOLYGON:{const F=d[I]-d[I-1];I++;const V=[];for(let j=0;j<F;j++){const H=s[b]-s[b-1];b++;for(let Q=0;Q<H;Q++){const Y=A[M]-A[M-1];M++;const re=[];for(let ge=0;ge<Y;ge++){const oe=this._vertexBuffer[_++],ue=this._vertexBuffer[_++];re.push(new it(oe,ue))}re.length>0&&re.push(re[0]),V.push(re)}}e[k]=V}}return e}[Symbol.iterator](){return null}}function ud(r,e,i,s,A,d){return new tm(r,e,i,s,A,d)}class tm extends ld{constructor(i,s,A,d,_,b){super(A,d,_,b);Pi(this,"_numGeometries");Pi(this,"_geometryType");this._numGeometries=i,this._geometryType=s}geometryType(i){return this._geometryType}get numGeometries(){return this._numGeometries}containsSingleGeometryType(){return!0}}function hd(r,e,i,s,A){return new im(r,e,i,s,A)}class im extends ld{constructor(i,s,A,d,_){super(s,A,d,_);Pi(this,"_geometryTypes");this._geometryTypes=i}geometryType(i){return this._geometryTypes[i]}get numGeometries(){return this._geometryTypes.length}containsSingleGeometryType(){return!1}}function rm(r,e,i,s,A){const d=to(r,i);let _=null,b=null,M=null,I=null,k=null,F=null,V=null,j=null;if(dc(d,s,r,i)===ss.CONST){const Q=hA(r,i,d,!1);for(let Y=0;Y<e-1;Y++){const re=to(r,i);switch(re.physicalStreamType){case ws.LENGTH:switch(re.logicalStreamType.lengthType){case Lo.GEOMETRIES:_=su(r,i,re);break;case Lo.PARTS:b=su(r,i,re);break;case Lo.RINGS:M=su(r,i,re);break;case Lo.TRIANGLES:V=su(r,i,re)}break;case ws.OFFSET:switch(re.logicalStreamType.offsetType){case Iu.VERTEX:I=io(r,i,re,!1);break;case Iu.INDEX:j=io(r,i,re,!1)}break;case ws.DATA:ja.VERTEX===re.logicalStreamType.dictionaryType?k=io(r,i,re,!0):(F={numBits:re.numBits,coordinateShift:re.coordinateShift},k=io(r,i,re,!1))}}return j!==null?_!=null||b!=null?ud(s,Q,V,j,k,new sh(_,b,M)):ud(s,Q,V,j,k):F===null?(function(Y,re,ge,oe,ue){return new od(Y,re,aa.VEC_2,ge,oe,ue)})(s,Q,new sh(_,b,M),I,k):(function(Y,re,ge,oe,ue,ve){return new od(Y,re,aa.MORTON,ge,oe,ue,ve)})(s,Q,new sh(_,b,M),I,k,F)}const H=io(r,i,d,!1);for(let Q=0;Q<e-1;Q++){const Y=to(r,i);switch(Y.physicalStreamType){case ws.LENGTH:switch(Y.logicalStreamType.lengthType){case Lo.GEOMETRIES:_=io(r,i,Y,!1);break;case Lo.PARTS:b=io(r,i,Y,!1);break;case Lo.RINGS:M=io(r,i,Y,!1);break;case Lo.TRIANGLES:V=su(r,i,Y)}break;case ws.OFFSET:switch(Y.logicalStreamType.offsetType){case Iu.VERTEX:I=io(r,i,Y,!1);break;case Iu.INDEX:j=io(r,i,Y,!1)}break;case ws.DATA:ja.VERTEX===Y.logicalStreamType.dictionaryType?k=io(r,i,Y,!0):(F={numBits:Y.numBits,coordinateShift:Y.coordinateShift},k=io(r,i,Y,!1))}}return j!==null&&b===null?hd(H,V,j,k):(_!==null?(_=mA(H,_,2),b!==null&&M!==null?(b=cd(H,_,b,!1),M=(function(Q,Y,re,ge){const oe=new Int32Array(re[re.length-1]+1);let ue=0;oe[0]=ue;let ve=1,Te=1,Ue=0;for(let lt=0;lt<Q.length;lt++){const nt=Q[lt],dt=Y[lt+1]-Y[lt];if(nt!==0&&nt!==3)for(let Tt=0;Tt<dt;Tt++){const mt=re[ve]-re[ve-1];ve++;for(let st=0;st<mt;st++)ue=oe[Te++]=ue+ge[Ue++]}else for(let Tt=0;Tt<dt;Tt++)oe[Te++]=++ue,ve++}return oe})(H,_,b,M)):b!==null&&(b=(function(Q,Y,re){const ge=new Int32Array(Y[Y.length-1]+1);let oe=0;ge[0]=oe;let ue=1,ve=0;for(let Te=0;Te<Q.length;Te++){const Ue=Q[Te],lt=Y[Te+1]-Y[Te];if(Ue===4||Ue===1)for(let nt=0;nt<lt;nt++)oe=ge[ue++]=oe+re[ve++];else for(let nt=0;nt<lt;nt++)ge[ue++]=++oe}return ge})(H,_,b))):b!==null&&M!==null?(b=mA(H,b,1),M=cd(H,b,M,!0)):b!==null&&(b=mA(H,b,0)),j!==null?hd(H,V,j,k,new sh(_,b,M)):F===null?(function(Q,Y,re,ge){return new ad(aa.VEC_2,Q,Y,re,ge)})(H,new sh(_,b,M),I,k):(function(Q,Y,re,ge,oe){return new ad(aa.MORTON,Q,Y,re,ge,oe)})(H,new sh(_,b,M),I,k,F))}function mA(r,e,i){const s=new Int32Array(r.length+1);let A=0;s[0]=A;let d=0;for(let _=0;_<r.length;_++)A=s[_+1]=A+(r[_]>i?e[d++]:1);return s}function cd(r,e,i,s){const A=new Int32Array(e[e.length-1]+1);let d=0;A[0]=d;let _=1,b=0;for(let M=0;M<r.length;M++){const I=r[M],k=e[M+1]-e[M];if(I===5||I===2||s&&(I===4||I===1))for(let F=0;F<k;F++)d=A[_++]=d+i[b++];else for(let F=0;F<k;F++)A[_++]=++d}return A}class nm extends rh{constructor(i,s,A){super(i,s.getBuffer(),A);Pi(this,"dataVector");this.dataVector=s}getValueFromBuffer(i){return this.dataVector.get(i)}}class sm extends cc{getValueFromBuffer(e){return this.dataBuffer[e]}}class Ad extends rh{constructor(e,i,s){super(e,BigInt64Array.of(i),s)}getValueFromBuffer(e){return this.dataBuffer[0]}}function Rh(r,e,i){return fd(r,Math.ceil(e/8),i)}function fd(r,e,i){const s=new Uint8Array(e);let A=0;for(;A<e;){const d=r[i.increment()];if(d<=127){const _=d+3,b=r[i.increment()],M=A+_;s.fill(b,A,M),A=M}else{const _=256-d;for(let b=0;b<_;b++)s[A++]=r[i.increment()]}}return s}const om=new TextDecoder;function _A(r,e,i){return i-e>=12?om.decode(r.subarray(e,i)):(function(s,A,d){let _="",b=A;for(;b<d;){const M=s[b];let I,k,F,V=null,j=M>239?4:M>223?3:M>191?2:1;if(b+j>d)break;j===1?M<128&&(V=M):j===2?(I=s[b+1],(192&I)==128&&(V=(31&M)<<6|63&I,V<=127&&(V=null))):j===3?(I=s[b+1],k=s[b+2],(192&I)==128&&(192&k)==128&&(V=(15&M)<<12|(63&I)<<6|63&k,(V<=2047||V>=55296&&V<=57343)&&(V=null))):j===4&&(I=s[b+1],k=s[b+2],F=s[b+3],(192&I)==128&&(192&k)==128&&(192&F)==128&&(V=(15&M)<<18|(63&I)<<12|(63&k)<<6|63&F,(V<=65535||V>=1114112)&&(V=null))),V===null?(V=65533,j=1):V>65535&&(V-=65536,_+=String.fromCharCode(V>>>10&1023|55296),V=56320|1023&V),_+=String.fromCharCode(V),b+=j}return _})(r,e,i)}class gA extends rh{constructor(i,s,A,d){super(i,A,d);Pi(this,"offsetBuffer");this.offsetBuffer=s}}class dd extends gA{constructor(i,s,A,d){super(i,s,A,d??s.length-1);Pi(this,"textEncoder");this.textEncoder=new TextEncoder}getValueFromBuffer(i){return _A(this.dataBuffer,this.offsetBuffer[i],this.offsetBuffer[i+1])}}class oh extends gA{constructor(i,s,A,d,_){super(i,A,d,_??s.length);Pi(this,"indexBuffer");Pi(this,"textEncoder");this.indexBuffer=s,this.indexBuffer=s,this.textEncoder=new TextEncoder}getValueFromBuffer(i){const s=this.indexBuffer[i];return _A(this.dataBuffer,this.offsetBuffer[s],this.offsetBuffer[s+1])}}class pd extends gA{constructor(i,s,A,d,_,b,M){super(i,A,d,M);Pi(this,"indexBuffer");Pi(this,"symbolOffsetBuffer");Pi(this,"symbolTableBuffer");Pi(this,"textEncoder");Pi(this,"symbolLengthBuffer");Pi(this,"lengthBuffer");Pi(this,"decodedDictionary");this.indexBuffer=s,this.symbolOffsetBuffer=_,this.symbolTableBuffer=b,this.textEncoder=new TextEncoder}getValueFromBuffer(i){this.decodedDictionary==null&&(this.symbolLengthBuffer==null&&(this.symbolLengthBuffer=this.offsetToLengthBuffer(this.symbolOffsetBuffer),this.lengthBuffer=this.offsetToLengthBuffer(this.offsetBuffer)),this.decodedDictionary=(function(A,d,_){const b=[],M=new Array(d.length).fill(0);for(let I=1;I<d.length;I++)M[I]=M[I-1]+d[I-1];for(let I=0;I<_.length;I++)if(_[I]===255)b.push(_[++I]);else{const k=d[_[I]],F=M[_[I]];for(let V=0;V<k;V++)b.push(A[F+V])}return new Uint8Array(b)})(this.symbolTableBuffer,this.symbolLengthBuffer,this.dataBuffer));const s=this.indexBuffer[i];return _A(this.decodedDictionary,this.offsetBuffer[s],this.offsetBuffer[s+1])}offsetToLengthBuffer(i){const s=new Uint32Array(i.length-1);let A=i[0];for(let d=1;d<i.length;d++){const _=i[d];s[d-1]=_-A,A=_}return s}}function am(r,e,i,s,A,d){return i.type==="scalarType"?(function(_,b,M,I,k,F){let V=null,j=0;if(_===0)return null;if(F.nullable){const Q=to(b,M);j=Q.numValues;const Y=M.get(),re=Rh(b,j,M);M.set(Y+Q.byteLength),V=new Za(re,Q.numValues)}const H=V??I;switch(k.physicalType){case 4:case 3:return(function(Q,Y,re,ge,oe){const ue=to(Q,Y),ve=dc(ue,oe,Q,Y),Te=ge.physicalType===3;if(ve===ss.FLAT){const Ue=Fh(oe)?cA(Q,Y,ue,Te,oe):io(Q,Y,ue,Te);return new nA(re.name,Ue,oe)}if(ve===ss.SEQUENCE){const Ue=Xf(Q,Y,ue);return new oA(re.name,Ue[0],Ue[1],ue.numRleValues)}{const Ue=hA(Q,Y,ue,Te);return new aA(re.name,Ue,oe)}})(b,M,F,k,H);case 9:return(function(Q,Y,re,ge,oe){let ue=null,ve=null,Te=null,Ue=null,lt=null,nt=null,dt=null,Tt=null;for(let mt=0;mt<ge;mt++){const st=to(Y,re);if(st.byteLength!==0)switch(st.physicalStreamType){case ws.PRESENT:{const Xe=Rh(Y,st.numValues,re);nt=new Za(Xe,st.numValues);break}case ws.OFFSET:ve=oe!=null||nt!=null?cA(Y,re,st,!1,oe??nt):io(Y,re,st,!1);break;case ws.LENGTH:{const Xe=su(Y,re,st);Lo.DICTIONARY===st.logicalStreamType.lengthType?ue=Xe:Lo.SYMBOL===st.logicalStreamType.lengthType?Ue=Xe:dt=Xe;break}case ws.DATA:{const Xe=Y.subarray(re.get(),re.get()+st.byteLength);re.add(st.byteLength);const Lt=st.logicalStreamType.dictionaryType;ja.FSST===Lt?lt=Xe:ja.SINGLE===Lt||ja.SHARED===Lt?Te=Xe:ja.NONE===Lt&&(Tt=Xe);break}}}return(function(mt,st,Xe,Lt,Ct,Ot,Et){return st?new pd(mt,Xe,Lt,Ct,Ot,st,Et):null})(Q,lt,ve,ue,Te,Ue,oe??nt)??(function(mt,st,Xe,Lt,Ct){return st?Ct?new oh(mt,Xe,Lt,st,Ct):new oh(mt,Xe,Lt,st):null})(Q,Te,ve,ue,oe??nt)??(function(mt,st,Xe,Lt,Ct){if(!st||!Xe)return null;if(Lt)return Ct?new oh(mt,Lt,st,Xe,Ct):new oh(mt,Lt,st,Xe);if(Ct&&Ct.size()!==st.length-1){const Ot=new Int32Array(Ct.size());let Et=0;for(let Ut=0;Ut<Ct.size();Ut++)Ot[Ut]=Ct.get(Ut)?Et++:0;return new oh(mt,Ot,st,Xe,Ct)}return Ct?new dd(mt,st,Xe,Ct):new dd(mt,st,Xe)})(Q,dt,Tt,ve,oe??nt)})(F.name,b,M,F.nullable?_-1:_,V);case 0:return(function(Q,Y,re,ge,oe){const ue=to(Q,Y),ve=ue.numValues,Te=Y.get(),Ue=Fh(oe)?(function(nt,dt,Tt,mt){const st=fd(nt,Math.ceil(dt/8),Tt),Xe=new Za(st,dt),Lt=mt.size(),Ct=new Za(new Uint8Array(Lt),Lt);let Ot=0;for(let Et=0;Et<mt.size();Et++){const Ut=!!mt.get(Et)&&Xe.get(Ot++);Ct.set(Et,Ut)}return Ct.getBuffer()})(Q,ve,Y,oe):Rh(Q,ve,Y);Y.set(Te+ue.byteLength);const lt=new Za(Ue,ve);return new nm(re.name,lt,oe)})(b,M,F,0,H);case 6:case 5:return(function(Q,Y,re,ge,oe){const ue=to(Q,Y),ve=dc(ue,ge,Q,Y),Te=oe.physicalType===5;if(ve===ss.FLAT){const Ue=Fh(ge)?(function(lt,nt,dt,Tt,mt){return(function(st,Xe,Lt,Ct){switch(Xe.logicalLevelTechnique1){case ki.DELTA:return Xe.logicalLevelTechnique2===ki.RLE&&(st=Qf(st,Xe.runs,Xe.numRleValues)),(function(Ot,Et){const Ut=new BigInt64Array(Ot.size());let ji=0;Ot.get(0)?(Ut[0]=Ot.get(0)?Et[0]>>1n^-(1n&Et[0]):0n,ji=1):Ut[0]=0n;let Di=1;for(;Di!=Ut.length;++Di)Ut[Di]=Ot.get(Di)?Ut[Di-1]+(Et[ji]>>1n^-(1n&Et[ji++])):Ut[Di-1];return Ut})(Ct,st);case ki.RLE:return(function(Ot,Et,Ut,ji){const Di=Et;return Ut?(function(Or,Ps,Tn){const Nr=new BigInt64Array(Or.size());let kr=0;for(let rr=0;rr<Tn;rr++){const Xr=Number(Ps[rr]);let ln=Ps[rr+Tn];ln=ln>>1n^-(1n&ln);for(let Pr=kr;Pr<kr+Xr;Pr++)Or.get(Pr)?Nr[Pr]=ln:(Nr[Pr]=0n,kr++);kr+=Xr}return Nr})(ji,Ot,Di.runs):(function(Or,Ps,Tn){const Nr=new BigInt64Array(Or.size());let kr=0;for(let rr=0;rr<Tn;rr++){const Xr=Number(Ps[rr]),ln=Ps[rr+Tn];for(let Pr=kr;Pr<kr+Xr;Pr++)Or.get(Pr)?Nr[Pr]=ln:(Nr[Pr]=0n,kr++);kr+=Xr}return Nr})(ji,Ot,Di.runs)})(st,Xe,Lt,Ct);case ki.NONE:return st=Lt?(function(Ot,Et){const Ut=new BigInt64Array(Ot.size());let ji=0,Di=0;for(;Di!=Ut.length;++Di)if(Ot.get(Di)){const Or=Et[ji++];Ut[Di]=Or>>1n^-(1n&Or)}else Ut[Di]=0n;return Ut})(Ct,st):(function(Ot,Et){const Ut=new BigInt64Array(Ot.size());let ji=0,Di=0;for(;Di!=Ut.length;++Di)Ut[Di]=Ot.get(Di)?Et[ji++]:0n;return Ut})(Ct,st),st;default:throw new Error("The specified Logical level technique is not supported")}})(Ac(lt,nt,dt.numValues),dt,Tt,mt)})(Q,Y,ue,Te,ge):Jf(Q,Y,ue,Te);return new td(re.name,Ue,ge)}if(ve===ss.SEQUENCE){const Ue=Kf(Q,Y,ue);return new id(re.name,Ue[0],Ue[1],ue.numRleValues)}{const Ue=ed(Q,Y,ue,Te);return new Ad(re.name,Ue,ge)}})(b,M,F,H,k);case 7:return(function(Q,Y,re,ge){const oe=to(Q,Y),ue=Fh(ge)?(function(ve,Te,Ue,lt){const nt=Te.get(),dt=nt+lt*Float32Array.BYTES_PER_ELEMENT,Tt=new Uint8Array(ve.subarray(nt,dt)).buffer,mt=new Float32Array(Tt);Te.set(dt);const st=Ue.size(),Xe=new Float32Array(st);let Lt=0;for(let Ct=0;Ct<st;Ct++)Xe[Ct]=Ue.get(Ct)?mt[Lt++]:0;return Xe})(Q,Y,ge,oe.numValues):(function(ve,Te,Ue){const lt=Te.get(),nt=lt+Ue*Float32Array.BYTES_PER_ELEMENT,dt=new Uint8Array(ve.subarray(lt,nt)).buffer,Tt=new Float32Array(dt);return Te.set(nt),Tt})(Q,Y,oe.numValues);return new sm(re.name,ue,ge)})(b,M,F,H);case 8:return(function(Q,Y,re,ge){const oe=to(Q,Y),ue=Fh(ge)?(function(ve,Te,Ue,lt){const nt=Te.get(),dt=nt+lt*Float64Array.BYTES_PER_ELEMENT,Tt=new Uint8Array(ve.subarray(nt,dt)).buffer,mt=new Float64Array(Tt);Te.set(dt);const st=Ue.size(),Xe=new Float64Array(st);let Lt=0;for(let Ct=0;Ct<st;Ct++)Xe[Ct]=Ue.get(Ct)?mt[Lt++]:0;return Xe})(Q,Y,ge,oe.numValues):(function(ve,Te,Ue){const lt=Te.get(),nt=lt+Ue*Float64Array.BYTES_PER_ELEMENT,dt=new Uint8Array(ve.subarray(lt,nt)).buffer,Tt=new Float64Array(dt);return Te.set(nt),Tt})(Q,Y,oe.numValues);return new sA(re.name,ue,ge)})(b,M,F,H);default:throw new Error(`The specified data type for the field is currently not supported: ${k}`)}})(s,r,e,A,i.scalarType,i):s!=1?null:(function(_,b,M,I){let k=null,F=null,V=null,j=null,H=!1;for(;!H;){const ge=to(_,b);switch(ge.physicalStreamType){case ws.LENGTH:Lo.DICTIONARY===ge.logicalStreamType.lengthType?k=su(_,b,ge):V=su(_,b,ge);break;case ws.DATA:ja.SINGLE===ge.logicalStreamType.dictionaryType||ja.SHARED===ge.logicalStreamType.dictionaryType?(F=_.subarray(b.get(),b.get()+ge.byteLength),H=!0):j=_.subarray(b.get(),b.get()+ge.byteLength),b.add(ge.byteLength)}}const Q=M.complexType.children,Y=[];let re=0;for(const ge of Q){const oe=_s(_,b,1)[0];if(oe==0)continue;const ue=`${M.name}${ge.name==="default"?"":":"+ge.name}`;if(oe!==2||ge.type!=="scalarField"||ge.scalarField.physicalType!==9)throw new Error("Currently only optional string fields are implemented for a struct.");const ve=to(_,b),Te=Rh(_,ve.numValues,b),Ue=to(_,b),lt=Ue.decompressedCount!==I?cA(_,b,Ue,!1,new Za(Te,ve.numValues)):io(_,b,Ue,!1);Y[re++]=j?new pd(ue,lt,k,F,V,j,new Za(Te,ve.numValues)):new oh(ue,lt,k,F,new Za(Te,ve.numValues))}return Y})(r,e,i,A)}function Fh(r){return r instanceof Za}function lm(r){if(r.name==="id")return!1;if(r.type==="scalarType"){const e=r.scalarType;if(e.type==="physicalType")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}else if(e.type==="logicalType")return!1}else if(r.type==="complexType"){const e=r.complexType;if(e.type==="physicalType")switch(e.physicalType){case 0:case 1:return!0;default:return!1}}return console.warn("Unexpected column type in hasStreamCount",r),!1}const um=new TextDecoder;function md(r,e){const i=_s(r,e,1)[0];if(i===0)return"";const s=e.get(),A=r.subarray(s,s+i);return e.add(i),um.decode(A)}function _d(r,e){const i=_s(r,e,1)[0]>>>0,s=!!(4&i),A=!!(2&i),d=_s(r,e,1)[0]>>>0,_={};if(1&i&&(_.nullable=!0),A){const b={};if(s?(b.type="logicalType",b.logicalType=d):(b.type="physicalType",b.physicalType=d),8&i){const M=_s(r,e,1)[0]>>>0;b.children=new Array(M);for(let I=0;I<M;I++)b.children[I]=_d(r,e)}_.type="complexField",_.complexField=b}else{const b={};s?(b.type="logicalType",b.logicalType=d):(b.type="physicalType",b.physicalType=d),_.type="scalarField",_.scalarField=b}return _}function hm(r,e){const i=_s(r,e,1)[0]>>>0,s=(function(A){switch(A){case 0:case 1:case 2:case 3:{const d={};d.nullable=!!(1&A),d.columnScope=0;const _={};return _.physicalType=A>1?6:4,_.type="physicalType",d.scalarType=_,d.type="scalarType",d}case 4:{const d={nullable:!1,columnScope:0},_={type:"physicalType",physicalType:0};return d.type="complexType",d.complexType=_,d}case 30:{const d={nullable:!1,columnScope:0},_={type:"physicalType",physicalType:1};return d.type="complexType",d.complexType=_,d}default:return(function(d){let _=null;switch(d){case 10:case 11:_=0;break;case 12:case 13:_=1;break;case 14:case 15:_=2;break;case 16:case 17:_=3;break;case 18:case 19:_=4;break;case 20:case 21:_=5;break;case 22:case 23:_=6;break;case 24:case 25:_=7;break;case 26:case 27:_=8;break;case 28:case 29:_=9;break;default:return null}const b={};b.nullable=!!(1&d),b.columnScope=0;const M={type:"physicalType"};return M.physicalType=_,b.type="scalarType",b.scalarType=M,b})(A)}})(i);if(!s)throw new Error(`Unsupported column type code: ${i}`);if((function(A){return A>=10})(i)?s.name=md(r,e):i>=0&&i<=3?s.name="id":i===4&&(s.name="geometry"),(function(A){return A===30})(i)){const A=_s(r,e,1)[0]>>>0,d=s.complexType;d.children=new Array(A);for(let _=0;_<A;_++)d.children[_]=_d(r,e)}return s}function cm(r,e){const i={featureTables:[]},s={};s.name=md(r,e);const A=_s(r,e,1)[0]>>>0,d=_s(r,e,1)[0]>>>0;s.columns=new Array(d);for(let _=0;_<d;_++)s.columns[_]=hm(r,e);return i.featureTables.push(s),[i,A]}function Am(r,e,i,s,A,d,_=!1){const b=e.scalarType.physicalType,M=dc(A,d,r,i);if(b===4)switch(M){case ss.FLAT:{const I=io(r,i,A,!1);return new nA(s,I,d)}case ss.SEQUENCE:{const I=Xf(r,i,A);return new oA(s,I[0],I[1],A.numRleValues)}case ss.CONST:{const I=hA(r,i,A,!1);return new aA(s,I,d)}}else switch(M){case ss.FLAT:{if(_){const k=(function(F,V,j,H){const Q=(function(Y,re,ge){const oe=new Float64Array(re);for(let ue=0;ue<re;ue++)oe[ue]=K0(Y,ge);return oe})(F,j.numValues,V);return(function(Y,re,ge){switch(re.logicalLevelTechnique1){case ki.DELTA:return re.logicalLevelTechnique2===ki.RLE&&(Y=$f(Y,re.runs,re.numRleValues)),(function(oe){oe[0]=oe[0]%2==1?(oe[0]+1)/-2:oe[0]/2;const ue=oe.length/4*4;let ve=1;if(ue>=4)for(;ve<ue-4;ve+=4){const Te=oe[ve],Ue=oe[ve+1],lt=oe[ve+2],nt=oe[ve+3];oe[ve]=(Te%2==1?(Te+1)/-2:Te/2)+oe[ve-1],oe[ve+1]=(Ue%2==1?(Ue+1)/-2:Ue/2)+oe[ve],oe[ve+2]=(lt%2==1?(lt+1)/-2:lt/2)+oe[ve+1],oe[ve+3]=(nt%2==1?(nt+1)/-2:nt/2)+oe[ve+2]}for(;ve!=oe.length;++ve)oe[ve]=(oe[ve]%2==1?(oe[ve]+1)/-2:oe[ve]/2)+oe[ve-1]})(Y),Y;case ki.RLE:return(function(oe,ue,ve){return $f(oe,ue.runs,ue.numRleValues)})(Y,re);case ki.NONE:return Y;default:throw new Error(`The specified Logical level technique is not supported: ${re.logicalLevelTechnique1}`)}})(Q,j)})(r,i,A);return new sA(s,k,d)}const I=Jf(r,i,A,!1);return new td(s,I,d)}case ss.SEQUENCE:{const I=Kf(r,i,A);return new id(s,I[0],I[1],A.numRleValues)}case ss.CONST:{const I=ed(r,i,A,!1);return new Ad(s,I,d)}}throw new Error("Vector type not supported for id column.")}class fm{constructor(e,i){var s;switch(this._featureData=e,this.properties=this._featureData.properties||{},(s=this._featureData.geometry)===null||s===void 0?void 0:s.type){case os.POINT:case os.MULTIPOINT:this.type=1;break;case os.LINESTRING:case os.MULTILINESTRING:this.type=2;break;case os.POLYGON:case os.MULTIPOLYGON:this.type=3;break;default:this.type=0}this.extent=i,this.id=Number(this._featureData.id)}loadGeometry(){const e=[];for(const i of this._featureData.geometry.coordinates){const s=[];for(const A of i)s.push(new it(A.x,A.y));e.push(s)}return e}}class dm{constructor(e){this.features=[],this.featureTable=e,this.name=e.name,this.extent=e.extent,this.version=2,this.features=e.getFeatures(),this.length=this.features.length}feature(e){return new fm(this.features[e],this.extent)}}class gd{constructor(e){this.layers={};const i=(function(s,A,d=!0){const _=new X0(0),b=[];for(;_.get()<s.length;){const M=_s(s,_,1)[0]>>>0,I=_.get()+M;if(I>s.length)throw new Error(`Block overruns tile: ${I} > ${s.length}`);if(_s(s,_,1)[0]>>>0!=1){_.set(I);continue}const k=cm(s,_),F=k[1],V=k[0].featureTables[0];let j=null,H=null;const Q=[];let Y=0;for(const ge of V.columns){const oe=ge.name;if(oe==="id"){let ue=null;if(ge.nullable){const Te=to(s,_),Ue=_.get(),lt=Rh(s,Te.numValues,_);_.set(Ue+Te.byteLength),ue=new Za(lt,Te.numValues)}const ve=to(s,_);Y=ve.decompressedCount,j=Am(s,ge,_,oe,ve,ue??Y,d)}else if(oe==="geometry"){const ue=_s(s,_,1)[0];if(Y===0){const ve=_.get();Y=to(s,_).decompressedCount,_.set(ve)}H=rm(s,ue,_,Y)}else{const ue=lm(ge)?_s(s,_,1)[0]:1;if(ue===0&&ge.type==="scalarType")continue;const ve=am(s,_,ge,ue,Y);if(ve)if(Array.isArray(ve))for(const Te of ve)Q.push(Te);else Q.push(ve)}}const re=new Y0(V.name,H,j,Q,F);b.push(re),_.set(I)}return b})(new Uint8Array(e));this.layers=i.reduce(((s,A)=>Object.assign(Object.assign({},s),{[A.name]:new dm(A)})),{})}}class pm{constructor(e,i){this.feature=e,this.type=e.type,this.properties=e.tags?e.tags:{},this.extent=i,"id"in e&&(typeof e.id=="string"?this.id=parseInt(e.id,10):typeof e.id!="number"||isNaN(e.id)||(this.id=e.id))}loadGeometry(){const e=[],i=this.feature.type===1?[this.feature.geometry]:this.feature.geometry;for(const s of i){const A=[];for(const d of s)A.push(new it(d[0],d[1]));e.push(A)}return e}}const Oh="_geojsonTileLayer";function mm(r,e){e.writeVarintField(15,r.version||1),e.writeStringField(1,r.name||""),e.writeVarintField(5,r.extent||4096);const i={keys:[],values:[],keycache:{},valuecache:{}};for(let d=0;d<r.length;d++)i.feature=r.feature(d),e.writeMessage(2,_m,i);const s=i.keys;for(const d of s)e.writeStringField(3,d);const A=i.values;for(const d of A)e.writeMessage(4,vm,d)}function _m(r,e){if(!r.feature)return;const i=r.feature;i.id!==void 0&&e.writeVarintField(1,i.id),e.writeMessage(2,gm,r),e.writeVarintField(3,i.type),e.writeMessage(4,ym,i)}function gm(r,e){var i;for(const s in(i=r.feature)==null?void 0:i.properties){let A=r.feature.properties[s],d=r.keycache[s];if(A==null)continue;d===void 0&&(r.keys.push(s),d=r.keys.length-1,r.keycache[s]=d),e.writeVarint(d),typeof A!="string"&&typeof A!="boolean"&&typeof A!="number"&&(A=JSON.stringify(A));const _=typeof A+":"+A;let b=r.valuecache[_];b===void 0&&(r.values.push(A),b=r.values.length-1,r.valuecache[_]=b),e.writeVarint(b)}}function yA(r,e){return(e<<3)+(7&r)}function yd(r){return r<<1^r>>31}function ym(r,e){const i=r.loadGeometry(),s=r.type;let A=0,d=0;for(const _ of i){let b=1;s===1&&(b=_.length),e.writeVarint(yA(1,b));const M=s===3?_.length-1:_.length;for(let I=0;I<M;I++){I===1&&s!==1&&e.writeVarint(yA(2,M-1));const k=_[I].x-A,F=_[I].y-d;e.writeVarint(yd(k)),e.writeVarint(yd(F)),A+=k,d+=F}r.type===3&&e.writeVarint(yA(7,1))}}function vm(r,e){const i=typeof r;i==="string"?e.writeStringField(1,r):i==="boolean"?e.writeBooleanField(7,r):i==="number"&&(r%1!=0?e.writeDoubleField(3,r):r<0?e.writeSVarintField(6,r):e.writeVarintField(5,r))}class vd{constructor(e,i){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new fo(Oi,16,0),this.grid3D=new fo(Oi,16,0),this.featureIndexArray=new ie,this.promoteId=i}insert(e,i,s,A,d,_){const b=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(s,A,d);const M=_?this.grid3D:this.grid;for(let I=0;I<i.length;I++){const k=i[I],F=[1/0,1/0,-1/0,-1/0];for(let V=0;V<k.length;V++){const j=k[V];F[0]=Math.min(F[0],j.x),F[1]=Math.min(F[1],j.y),F[2]=Math.max(F[2],j.x),F[3]=Math.max(F[3],j.y)}F[0]<Oi&&F[1]<Oi&&F[2]>=0&&F[3]>=0&&M.insert(b,F[0],F[1],F[2],F[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=this.encoding!=="mlt"?new sf(new oc(this.rawTileData)).layers:new gd(this.rawTileData).layers,this.sourceLayerCoder=new Zf(this.vtLayers?Object.keys(this.vtLayers).sort():[Oh])),this.vtLayers}query(e,i,s,A){this.loadVTLayers();const d=e.params,_=Oi/e.tileSize/e.scale,b=Rt(d.filter,d.globalState),M=e.queryGeometry,I=e.queryPadding*_,k=Cu.fromPoints(M),F=this.grid.query(k.minX-I,k.minY-I,k.maxX+I,k.maxY+I),V=Cu.fromPoints(e.cameraQueryGeometry).expandBy(I),j=this.grid3D.query(V.minX,V.minY,V.maxX,V.maxY,((Y,re,ge,oe)=>(function(ue,ve,Te,Ue,lt){for(const dt of ue)if(ve<=dt.x&&Te<=dt.y&&Ue>=dt.x&&lt>=dt.y)return!0;const nt=[new it(ve,Te),new it(ve,lt),new it(Ue,lt),new it(Ue,Te)];if(ue.length>2){for(const dt of nt)if(Qu(ue,dt))return!0}for(let dt=0;dt<ue.length-1;dt++)if(bp(ue[dt],ue[dt+1],nt))return!0;return!1})(e.cameraQueryGeometry,Y-I,re-I,ge+I,oe+I)));for(const Y of j)F.push(Y);F.sort(xm);const H={};let Q;for(let Y=0;Y<F.length;Y++){const re=F[Y];if(re===Q)continue;Q=re;const ge=this.featureIndexArray.get(re);let oe=null;this.loadMatchingFeature(H,ge.bucketIndex,ge.sourceLayerIndex,ge.featureIndex,b,d.layers,d.availableImages,i,s,A,((ue,ve,Te)=>(oe||(oe=fl(ue)),ve.queryIntersectsFeature({queryGeometry:M,feature:ue,featureState:Te,geometry:oe,zoom:this.z,transform:e.transform,pixelsToTileUnits:_,pixelPosMatrix:e.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:e.getElevation}))))}return H}loadMatchingFeature(e,i,s,A,d,_,b,M,I,k,F){const V=this.bucketLayerIDs[i];if(_&&!V.some((Y=>_.has(Y))))return;const j=this.sourceLayerCoder.decode(s),H=this.vtLayers[j].feature(A);if(d.needGeometry){const Y=dl(H,!0);if(!d.filter(new ze(this.tileID.overscaledZ),Y,this.tileID.canonical))return}else if(!d.filter(new ze(this.tileID.overscaledZ),H))return;const Q=this.getId(H,j);for(let Y=0;Y<V.length;Y++){const re=V[Y];if(_&&!_.has(re))continue;const ge=M[re];if(!ge)continue;let oe={};Q&&k&&(oe=k.getState(ge.sourceLayer||Oh,Q));const ue=Er({},I[re]);ue.paint=xd(ue.paint,ge.paint,H,oe,b),ue.layout=xd(ue.layout,ge.layout,H,oe,b);const ve=!F||F(H,ge,oe);if(!ve)continue;const Te=new Uf(H,this.z,this.x,this.y,Q);Te.layer=ue;let Ue=e[re];Ue===void 0&&(Ue=e[re]=[]),Ue.push({featureIndex:A,feature:Te,intersectionZ:ve})}}lookupSymbolFeatures(e,i,s,A,d,_,b,M){const I={};this.loadVTLayers();const k=Rt(d.filterSpec,d.globalState);for(const F of e)this.loadMatchingFeature(I,s,A,F,k,_,b,M,i);return I}hasLayer(e){for(const i of this.bucketLayerIDs)for(const s of i)if(e===s)return!0;return!1}getId(e,i){var s;let A=e.id;return this.promoteId&&(A=e.properties[typeof this.promoteId=="string"?this.promoteId:this.promoteId[i]],typeof A=="boolean"&&(A=Number(A)),A===void 0&&(!((s=e.properties)===null||s===void 0)&&s.cluster)&&this.promoteId&&(A=Number(e.properties.cluster_id))),A}}function xd(r,e,i,s,A){return us(r,((d,_)=>{const b=e instanceof vt?e.get(_):null;return b&&b.evaluate?b.evaluate(i,s,A):b}))}function xm(r,e){return e-r}function bd(r,e,i,s,A){const d=[];for(let _=0;_<r.length;_++){const b=r[_];let M;for(let I=0;I<b.length-1;I++){let k=b[I],F=b[I+1];k.x<e&&F.x<e||(k.x<e?k=new it(e,k.y+(e-k.x)/(F.x-k.x)*(F.y-k.y))._round():F.x<e&&(F=new it(e,k.y+(e-k.x)/(F.x-k.x)*(F.y-k.y))._round()),k.y<i&&F.y<i||(k.y<i?k=new it(k.x+(i-k.y)/(F.y-k.y)*(F.x-k.x),i)._round():F.y<i&&(F=new it(k.x+(i-k.y)/(F.y-k.y)*(F.x-k.x),i)._round()),k.x>=s&&F.x>=s||(k.x>=s?k=new it(s,k.y+(s-k.x)/(F.x-k.x)*(F.y-k.y))._round():F.x>=s&&(F=new it(s,k.y+(s-k.x)/(F.x-k.x)*(F.y-k.y))._round()),k.y>=A&&F.y>=A||(k.y>=A?k=new it(k.x+(A-k.y)/(F.y-k.y)*(F.x-k.x),A)._round():F.y>=A&&(F=new it(k.x+(A-k.y)/(F.y-k.y)*(F.x-k.x),A)._round()),M&&k.equals(M[M.length-1])||(M=[k],d.push(M)),M.push(F)))))}}return d}function wd(r,e,i,s,A){switch(e){case 1:return(function(d,_,b,M){const I=[];for(const k of d)for(const F of k){const V=M===0?F.x:F.y;V>=_&&V<=b&&I.push([F])}return I})(r,i,s,A);case 2:return Td(r,i,s,A,!1);case 3:return Td(r,i,s,A,!0)}return[]}function bm(r,e,i,s,A){const d=s===0?wm:Tm;let _=[];const b=[];for(let k=0;k<r.length-1;k++){const F=r[k],V=r[k+1],j=s===0?F.x:F.y,H=s===0?V.x:V.y;let Q=!1;j<e?H>e&&_.push(d(F,V,e)):j>i?H<i&&_.push(d(F,V,i)):_.push(F),H<e&&j>=e&&(_.push(d(F,V,e)),Q=!0),H>i&&j<=i&&(_.push(d(F,V,i)),Q=!0),!A&&Q&&(b.push(_),_=[])}const M=r.length-1,I=s===0?r[M].x:r[M].y;return I>=e&&I<=i&&_.push(r[M]),A&&_.length>0&&!_[0].equals(_[_.length-1])&&_.push(new it(_[0].x,_[0].y)),_.length>0&&b.push(_),b}function Td(r,e,i,s,A){const d=[];for(const _ of r){const b=bm(_,e,i,s,A);b.length>0&&d.push(...b)}return d}function wm(r,e,i){return new it(i,r.y+(i-r.x)/(e.x-r.x)*(e.y-r.y))}function Tm(r,e,i){return new it(r.x+(i-r.y)/(e.y-r.y)*(e.x-r.x),i)}kt("FeatureIndex",vd,{omit:["rawTileData","sourceLayerCoder"]});class ou extends it{constructor(e,i,s,A){super(e,i),this.angle=s,A!==void 0&&(this.segment=A)}clone(){return new ou(this.x,this.y,this.angle,this.segment)}}function Pd(r,e,i,s,A){if(e.segment===void 0||i===0)return!0;let d=e,_=e.segment+1,b=0;for(;b>-i/2;){if(_--,_<0)return!1;b-=r[_].dist(d),d=r[_]}b+=r[_].dist(r[_+1]),_++;const M=[];let I=0;for(;b<i/2;){const k=r[_],F=r[_+1];if(!F)return!1;let V=r[_-1].angleTo(k)-k.angleTo(F);for(V=Math.abs((V+3*Math.PI)%(2*Math.PI)-Math.PI),M.push({distance:b,angleDelta:V}),I+=V;b-M[0].distance>s;)I-=M.shift().angleDelta;if(I>A)return!1;_++,b+=k.dist(F)}return!0}function Md(r){let e=0;for(let i=0;i<r.length-1;i++)e+=r[i].dist(r[i+1]);return e}function Ed(r,e,i){return r?.6*e*i:0}function Sd(r,e){return Math.max(r?r.right-r.left:0,e?e.right-e.left:0)}function Pm(r,e,i,s,A,d){const _=Ed(i,A,d),b=Sd(i,s)*d;let M=0;const I=Md(r)/2;for(let k=0;k<r.length-1;k++){const F=r[k],V=r[k+1],j=F.dist(V);if(M+j>I){const H=(I-M)/j,Q=ir.number(F.x,V.x,H),Y=ir.number(F.y,V.y,H),re=new ou(Q,Y,V.angleTo(F),k);return re._round(),!_||Pd(r,re,b,_,e)?re:void 0}M+=j}}function Mm(r,e,i,s,A,d,_,b,M){const I=Ed(s,d,_),k=Sd(s,A),F=k*_,V=r[0].x===0||r[0].x===M||r[0].y===0||r[0].y===M;return e-F<e/4&&(e=F+e/4),Cd(r,V?e/2*b%e:(k/2+2*d)*_*b%e,e,I,i,F,V,!1,M)}function Cd(r,e,i,s,A,d,_,b,M){const I=d/2,k=Md(r);let F=0,V=e-i,j=[];for(let H=0;H<r.length-1;H++){const Q=r[H],Y=r[H+1],re=Q.dist(Y),ge=Y.angleTo(Q);for(;V+i<F+re;){V+=i;const oe=(V-F)/re,ue=ir.number(Q.x,Y.x,oe),ve=ir.number(Q.y,Y.y,oe);if(ue>=0&&ue<M&&ve>=0&&ve<M&&V-I>=0&&V+I<=k){const Te=new ou(ue,ve,ge,H);Te._round(),s&&!Pd(r,Te,d,s,A)||j.push(Te)}}F+=re}return b||j.length||_||(j=Cd(r,F/2,i,s,A,d,_,!0,M)),j}function Id(r,e,i,s){const A=[],d=r.image,_=d.pixelRatio,b=d.paddedRect.w-2,M=d.paddedRect.h-2;let I={x1:r.left,y1:r.top,x2:r.right,y2:r.bottom};const k=d.stretchX||[[0,b]],F=d.stretchY||[[0,M]],V=(Xe,Lt)=>Xe+Lt[1]-Lt[0],j=k.reduce(V,0),H=F.reduce(V,0),Q=b-j,Y=M-H;let re=0,ge=j,oe=0,ue=H,ve=0,Te=Q,Ue=0,lt=Y;if(d.content&&s){const Xe=d.content,Lt=Xe[2]-Xe[0],Ct=Xe[3]-Xe[1];(d.textFitWidth||d.textFitHeight)&&(I=Pf(r)),re=gc(k,0,Xe[0]),oe=gc(F,0,Xe[1]),ge=gc(k,Xe[0],Xe[2]),ue=gc(F,Xe[1],Xe[3]),ve=Xe[0]-re,Ue=Xe[1]-oe,Te=Lt-ge,lt=Ct-ue}const nt=I.x1,dt=I.y1,Tt=I.x2-nt,mt=I.y2-dt,st=(Xe,Lt,Ct,Ot)=>{const Et=yc(Xe.stretch-re,ge,Tt,nt),Ut=vc(Xe.fixed-ve,Te,Xe.stretch,j),ji=yc(Lt.stretch-oe,ue,mt,dt),Di=vc(Lt.fixed-Ue,lt,Lt.stretch,H),Or=yc(Ct.stretch-re,ge,Tt,nt),Ps=vc(Ct.fixed-ve,Te,Ct.stretch,j),Tn=yc(Ot.stretch-oe,ue,mt,dt),Nr=vc(Ot.fixed-Ue,lt,Ot.stretch,H),kr=new it(Et,ji),rr=new it(Or,ji),Xr=new it(Or,Tn),ln=new it(Et,Tn),Pr=new it(Ut/_,Di/_),_o=new it(Ps/_,Nr/_),Ms=e*Math.PI/180;if(Ms){const as=Math.sin(Ms),qr=Math.cos(Ms),Pn=[qr,-as,as,qr];kr._matMult(Pn),rr._matMult(Pn),ln._matMult(Pn),Xr._matMult(Pn)}const go=Xe.stretch+Xe.fixed,Pa=Lt.stretch+Lt.fixed;return{tl:kr,tr:rr,bl:ln,br:Xr,tex:{x:d.paddedRect.x+1+go,y:d.paddedRect.y+1+Pa,w:Ct.stretch+Ct.fixed-go,h:Ot.stretch+Ot.fixed-Pa},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:Pr,pixelOffsetBR:_o,minFontScaleX:Te/_/Tt,minFontScaleY:lt/_/mt,isSDF:i}};if(s&&(d.stretchX||d.stretchY)){const Xe=Dd(k,Q,j),Lt=Dd(F,Y,H);for(let Ct=0;Ct<Xe.length-1;Ct++){const Ot=Xe[Ct],Et=Xe[Ct+1];for(let Ut=0;Ut<Lt.length-1;Ut++)A.push(st(Ot,Lt[Ut],Et,Lt[Ut+1]))}}else A.push(st({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:b+1},{fixed:0,stretch:M+1}));return A}function gc(r,e,i){let s=0;for(const A of r)s+=Math.max(e,Math.min(i,A[1]))-Math.max(e,Math.min(i,A[0]));return s}function Dd(r,e,i){const s=[{fixed:-1,stretch:0}];for(const[A,d]of r){const _=s[s.length-1];s.push({fixed:A-_.stretch,stretch:_.stretch}),s.push({fixed:A-_.stretch,stretch:_.stretch+(d-A)})}return s.push({fixed:e+1,stretch:i}),s}function yc(r,e,i,s){return r/e*i+s}function vc(r,e,i,s){return r-e*i/s}kt("Anchor",ou);class xc{constructor(e,i,s,A,d,_,b,M,I,k){var F;if(this.boxStartIndex=e.length,I){let V=_.top,j=_.bottom;const H=_.collisionPadding;H&&(V-=H[1],j+=H[3]);let Q=j-V;Q>0&&(Q=Math.max(10,Q),this.circleDiameter=Q)}else{const V=!((F=_.image)===null||F===void 0)&&F.content&&(_.image.textFitWidth||_.image.textFitHeight)?Pf(_):{x1:_.left,y1:_.top,x2:_.right,y2:_.bottom};V.y1=V.y1*b-M[0],V.y2=V.y2*b+M[2],V.x1=V.x1*b-M[3],V.x2=V.x2*b+M[1];const j=_.collisionPadding;if(j&&(V.x1-=j[0]*b,V.y1-=j[1]*b,V.x2+=j[2]*b,V.y2+=j[3]*b),k){const H=new it(V.x1,V.y1),Q=new it(V.x2,V.y1),Y=new it(V.x1,V.y2),re=new it(V.x2,V.y2),ge=k*Math.PI/180;H._rotate(ge),Q._rotate(ge),Y._rotate(ge),re._rotate(ge),V.x1=Math.min(H.x,Q.x,Y.x,re.x),V.x2=Math.max(H.x,Q.x,Y.x,re.x),V.y1=Math.min(H.y,Q.y,Y.y,re.y),V.y2=Math.max(H.y,Q.y,Y.y,re.y)}e.emplaceBack(i.x,i.y,V.x1,V.y1,V.x2,V.y2,s,A,d)}this.boxEndIndex=e.length}}class Em{constructor(e=[],i=(s,A)=>s<A?-1:s>A?1:0){if(this.data=e,this.length=this.data.length,this.compare=i,this.length>0)for(let s=(this.length>>1)-1;s>=0;s--)this._down(s)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(this.length===0)return;const e=this.data[0],i=this.data.pop();return--this.length>0&&(this.data[0]=i,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:i,compare:s}=this,A=i[e];for(;e>0;){const d=e-1>>1,_=i[d];if(s(A,_)>=0)break;i[e]=_,e=d}i[e]=A}_down(e){const{data:i,compare:s}=this,A=this.length>>1,d=i[e];for(;e<A;){let _=1+(e<<1);const b=_+1;if(b<this.length&&s(i[b],i[_])<0&&(_=b),s(i[_],d)>=0)break;i[e]=i[_],e=_}i[e]=d}}function Sm(r,e=1,i=!1){const s=Cu.fromPoints(r[0]),A=Math.min(s.width(),s.height());let d=A/2;const _=new Em([],Cm),{minX:b,minY:M,maxX:I,maxY:k}=s;if(A===0)return new it(b,M);for(let j=b;j<I;j+=A)for(let H=M;H<k;H+=A)_.push(new ah(j+d,H+d,d,r));let F=(function(j){let H=0,Q=0,Y=0;const re=j[0];for(let ge=0,oe=re.length,ue=oe-1;ge<oe;ue=ge++){const ve=re[ge],Te=re[ue],Ue=ve.x*Te.y-Te.x*ve.y;Q+=(ve.x+Te.x)*Ue,Y+=(ve.y+Te.y)*Ue,H+=3*Ue}return new ah(Q/H,Y/H,0,j)})(r),V=_.length;for(;_.length;){const j=_.pop();(j.d>F.d||!F.d)&&(F=j,i&&console.log("found best %d after %d probes",Math.round(1e4*j.d)/1e4,V)),j.max-F.d<=e||(d=j.h/2,_.push(new ah(j.p.x-d,j.p.y-d,d,r)),_.push(new ah(j.p.x+d,j.p.y-d,d,r)),_.push(new ah(j.p.x-d,j.p.y+d,d,r)),_.push(new ah(j.p.x+d,j.p.y+d,d,r)),V+=4)}return i&&(console.log(`num probes: ${V}`),console.log(`best distance: ${F.d}`)),F.p}function Cm(r,e){return e.max-r.max}function ah(r,e,i,s){this.p=new it(r,e),this.h=i,this.d=(function(A,d){let _=!1,b=1/0;for(let M=0;M<d.length;M++){const I=d[M];for(let k=0,F=I.length,V=F-1;k<F;V=k++){const j=I[k],H=I[V];j.y>A.y!=H.y>A.y&&A.x<(H.x-j.x)*(A.y-j.y)/(H.y-j.y)+j.x&&(_=!_),b=Math.min(b,BA(A,j,H))}}return(_?1:-1)*Math.sqrt(b)})(this.p,s),this.max=this.d+this.h*Math.SQRT2}var Ts;W.aP=void 0,(Ts=W.aP||(W.aP={}))[Ts.center=1]="center",Ts[Ts.left=2]="left",Ts[Ts.right=3]="right",Ts[Ts.top=4]="top",Ts[Ts.bottom=5]="bottom",Ts[Ts["top-left"]=6]="top-left",Ts[Ts["top-right"]=7]="top-right",Ts[Ts["bottom-left"]=8]="bottom-left",Ts[Ts["bottom-right"]=9]="bottom-right";const vA=Number.POSITIVE_INFINITY;function kd(r,e){return e[1]!==vA?(function(i,s,A){let d=0,_=0;switch(s=Math.abs(s),A=Math.abs(A),i){case"top-right":case"top-left":case"top":_=A-7;break;case"bottom-right":case"bottom-left":case"bottom":_=7-A}switch(i){case"top-right":case"bottom-right":case"right":d=-s;break;case"top-left":case"bottom-left":case"left":d=s}return[d,_]})(r,e[0],e[1]):(function(i,s){let A=0,d=0;s<0&&(s=0);const _=s/Math.SQRT2;switch(i){case"top-right":case"top-left":d=_-7;break;case"bottom-right":case"bottom-left":d=7-_;break;case"bottom":d=7-s;break;case"top":d=s-7}switch(i){case"top-right":case"bottom-right":A=-_;break;case"top-left":case"bottom-left":A=_;break;case"left":A=s;break;case"right":A=-s}return[A,d]})(r,e[0])}function zd(r,e,i){var s;const A=r.layout,d=(s=A.get("text-variable-anchor-offset"))===null||s===void 0?void 0:s.evaluate(e,{},i);if(d){const b=d.values,M=[];for(let I=0;I<b.length;I+=2){const k=M[I]=b[I],F=b[I+1].map((V=>V*ns));k.startsWith("top")?F[1]-=7:k.startsWith("bottom")&&(F[1]+=7),M[I+1]=F}return new cn(M)}const _=A.get("text-variable-anchor");if(_){let b;b=r._unevaluatedLayout.getValue("text-radial-offset")!==void 0?[A.get("text-radial-offset").evaluate(e,{},i)*ns,vA]:A.get("text-offset").evaluate(e,{},i).map((I=>I*ns));const M=[];for(const I of _)M.push(I,kd(I,b));return new cn(M)}return null}function xA(r){switch(r){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function Im(r,e,i,s,A,d,_,b,M,I,k,F){let V=d.textMaxSize.evaluate(e,{});V===void 0&&(V=_);const j=r.layers[0].layout,H=j.get("icon-offset").evaluate(e,{},k),Q=Bd(i.horizontal),Y=_/24,re=r.tilePixelRatio*Y,ge=r.tilePixelRatio*V/24,oe=r.tilePixelRatio*b,ue=r.tilePixelRatio*j.get("symbol-spacing"),ve=j.get("text-padding")*r.tilePixelRatio,Te=(function(Ct,Ot,Et,Ut=1){const ji=Ct.get("icon-padding").evaluate(Ot,{},Et),Di=ji&&ji.values;return[Di[0]*Ut,Di[1]*Ut,Di[2]*Ut,Di[3]*Ut]})(j,e,k,r.tilePixelRatio),Ue=j.get("text-max-angle")/180*Math.PI,lt=j.get("text-rotation-alignment")!=="viewport"&&j.get("symbol-placement")!=="point",nt=j.get("icon-rotation-alignment")==="map"&&j.get("symbol-placement")!=="point",dt=j.get("symbol-placement"),Tt=ue/2,mt=j.get("icon-text-fit");let st;s&&mt!=="none"&&(r.allowVerticalPlacement&&i.vertical&&(st=Mf(s,i.vertical,mt,j.get("icon-text-fit-padding"),H,Y)),Q&&(s=Mf(s,Q,mt,j.get("icon-text-fit-padding"),H,Y)));const Xe=k?F.line.getGranularityForZoomLevel(k.z):1,Lt=(Ct,Ot)=>{Ot.x<0||Ot.x>=Oi||Ot.y<0||Ot.y>=Oi||(function(Et,Ut,ji,Di,Or,Ps,Tn,Nr,kr,rr,Xr,ln,Pr,_o,Ms,go,Pa,as,qr,Pn,Kr,ls,Fl,Ua,jh){const au=Et.addToLineVertexArray(Ut,ji);let ku,lh,uh,hh,Nd=0,Vd=0,jd=0,Zd=0,CA=-1,IA=-1;const Ol={};let Ud=an("");if(Et.allowVerticalPlacement&&Di.vertical){const Os=Nr.layout.get("text-rotate").evaluate(Kr,{},Ua)+90;uh=new xc(kr,Ut,rr,Xr,ln,Di.vertical,Pr,_o,Ms,Os),Tn&&(hh=new xc(kr,Ut,rr,Xr,ln,Tn,Pa,as,Ms,Os))}if(Or){const Os=Nr.layout.get("icon-rotate").evaluate(Kr,{}),la=Nr.layout.get("icon-text-fit")!=="none",zu=Id(Or,Os,Fl,la),qa=Tn?Id(Tn,Os,Fl,la):void 0;lh=new xc(kr,Ut,rr,Xr,ln,Or,Pa,as,!1,Os),Nd=4*zu.length;const Lu=Et.iconSizeData;let pl=null;Lu.kind==="source"?(pl=[Bl*Nr.layout.get("icon-size").evaluate(Kr,{})],pl[0]>ru&&en(`${Et.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):Lu.kind==="composite"&&(pl=[Bl*ls.compositeIconSizes[0].evaluate(Kr,{},Ua),Bl*ls.compositeIconSizes[1].evaluate(Kr,{},Ua)],(pl[0]>ru||pl[1]>ru)&&en(`${Et.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),Et.addSymbols(Et.icon,zu,pl,Pn,qr,Kr,W.az.none,Ut,au.lineStartIndex,au.lineLength,-1,Ua),CA=Et.icon.placedSymbolArray.length-1,qa&&(Vd=4*qa.length,Et.addSymbols(Et.icon,qa,pl,Pn,qr,Kr,W.az.vertical,Ut,au.lineStartIndex,au.lineLength,-1,Ua),IA=Et.icon.placedSymbolArray.length-1)}const Gd=Object.keys(Di.horizontal);for(const Os of Gd){const la=Di.horizontal[Os];if(!ku){Ud=an(la.text);const qa=Nr.layout.get("text-rotate").evaluate(Kr,{},Ua);ku=new xc(kr,Ut,rr,Xr,ln,la,Pr,_o,Ms,qa)}const zu=la.positionedLines.length===1;if(jd+=Ld(Et,Ut,la,Ps,Nr,Ms,Kr,go,au,Di.vertical?W.az.horizontal:W.az.horizontalOnly,zu?Gd:[Os],Ol,CA,ls,Ua),zu)break}Di.vertical&&(Zd+=Ld(Et,Ut,Di.vertical,Ps,Nr,Ms,Kr,go,au,W.az.vertical,["vertical"],Ol,IA,ls,Ua));const zm=ku?ku.boxStartIndex:Et.collisionBoxArray.length,Lm=ku?ku.boxEndIndex:Et.collisionBoxArray.length,Bm=uh?uh.boxStartIndex:Et.collisionBoxArray.length,Rm=uh?uh.boxEndIndex:Et.collisionBoxArray.length,Fm=lh?lh.boxStartIndex:Et.collisionBoxArray.length,Om=lh?lh.boxEndIndex:Et.collisionBoxArray.length,Nm=hh?hh.boxStartIndex:Et.collisionBoxArray.length,Vm=hh?hh.boxEndIndex:Et.collisionBoxArray.length;let Ga=-1;const wc=(Os,la)=>Os&&Os.circleDiameter?Math.max(Os.circleDiameter,la):la;Ga=wc(ku,Ga),Ga=wc(uh,Ga),Ga=wc(lh,Ga),Ga=wc(hh,Ga);const qd=Ga>-1?1:0;qd&&(Ga*=jh/ns),Et.glyphOffsetArray.length>=th.MAX_GLYPHS&&en("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),Kr.sortKey!==void 0&&Et.addToSortKeyRanges(Et.symbolInstances.length,Kr.sortKey);const jm=zd(Nr,Kr,Ua),[Zm,Um]=(function(Os,la){const zu=Os.length,qa=la==null?void 0:la.values;if((qa==null?void 0:qa.length)>0)for(let Lu=0;Lu<qa.length;Lu+=2){const pl=qa[Lu+1];Os.emplaceBack(W.aP[qa[Lu]],pl[0],pl[1])}return[zu,Os.length]})(Et.textAnchorOffsets,jm);Et.symbolInstances.emplaceBack(Ut.x,Ut.y,Ol.right>=0?Ol.right:-1,Ol.center>=0?Ol.center:-1,Ol.left>=0?Ol.left:-1,Ol.vertical||-1,CA,IA,Ud,zm,Lm,Bm,Rm,Fm,Om,Nm,Vm,rr,jd,Zd,Nd,Vd,qd,0,Pr,Ga,Zm,Um)})(r,Ot,Ct,i,s,A,st,r.layers[0],r.collisionBoxArray,e.index,e.sourceLayerIndex,r.index,re,[ve,ve,ve,ve],lt,M,oe,Te,nt,H,e,d,I,k,_)};if(dt==="line")for(const Ct of bd(e.geometry,0,0,Oi,Oi)){const Ot=Su(Ct,Xe),Et=Mm(Ot,ue,Ue,i.vertical||Q,s,24,ge,r.overscaling,Oi);for(const Ut of Et)Q&&Dm(r,Q.text,Tt,Ut)||Lt(Ot,Ut)}else if(dt==="line-center"){for(const Ct of e.geometry)if(Ct.length>1){const Ot=Su(Ct,Xe),Et=Pm(Ot,Ue,i.vertical||Q,s,24,ge);Et&&Lt(Ot,Et)}}else if(e.type==="Polygon")for(const Ct of ma(e.geometry,0)){const Ot=Sm(Ct,16);Lt(Su(Ct[0],Xe,!0),new ou(Ot.x,Ot.y,0))}else if(e.type==="LineString")for(const Ct of e.geometry){const Ot=Su(Ct,Xe);Lt(Ot,new ou(Ot[0].x,Ot[0].y,0))}else if(e.type==="Point")for(const Ct of e.geometry)for(const Ot of Ct)Lt([Ot],new ou(Ot.x,Ot.y,0))}function Ld(r,e,i,s,A,d,_,b,M,I,k,F,V,j,H){const Q=(function(ge,oe,ue,ve,Te,Ue,lt,nt){const dt=ve.layout.get("text-rotate").evaluate(Ue,{})*Math.PI/180,Tt=[];for(const mt of oe.positionedLines)for(const st of mt.positionedGlyphs){if(!st.rect)continue;const Xe=st.rect||{};let Lt=4,Ct=!0,Ot=1,Et=0;const Ut=(Te||nt)&&st.vertical,ji=st.metrics.advance*st.scale/2;if(nt&&oe.verticalizable&&(Et=mt.lineOffset/2-(st.imageName?-(ns-st.metrics.width*st.scale)/2:(st.scale-1)*ns)),st.imageName){const as=lt[st.imageName];Ct=as.sdf,Ot=as.pixelRatio,Lt=1/Ot}const Di=Te?[st.x+ji,st.y]:[0,0];let Or=Te?[0,0]:[st.x+ji+ue[0],st.y+ue[1]-Et],Ps=[0,0];Ut&&(Ps=Or,Or=[0,0]);const Tn=st.metrics.isDoubleResolution?2:1,Nr=(st.metrics.left-Lt)*st.scale-ji+Or[0],kr=(-st.metrics.top-Lt)*st.scale+Or[1],rr=Nr+Xe.w/Tn*st.scale/Ot,Xr=kr+Xe.h/Tn*st.scale/Ot,ln=new it(Nr,kr),Pr=new it(rr,kr),_o=new it(Nr,Xr),Ms=new it(rr,Xr);if(Ut){const as=new it(-ji,ji- -17),qr=-Math.PI/2,Pn=12-ji,Kr=new it(22-Pn,-(st.imageName?Pn:0)),ls=new it(...Ps);ln._rotateAround(qr,as)._add(Kr)._add(ls),Pr._rotateAround(qr,as)._add(Kr)._add(ls),_o._rotateAround(qr,as)._add(Kr)._add(ls),Ms._rotateAround(qr,as)._add(Kr)._add(ls)}if(dt){const as=Math.sin(dt),qr=Math.cos(dt),Pn=[qr,-as,as,qr];ln._matMult(Pn),Pr._matMult(Pn),_o._matMult(Pn),Ms._matMult(Pn)}const go=new it(0,0),Pa=new it(0,0);Tt.push({tl:ln,tr:Pr,bl:_o,br:Ms,tex:Xe,writingMode:oe.writingMode,glyphOffset:Di,sectionIndex:st.sectionIndex,isSDF:Ct,pixelOffsetTL:go,pixelOffsetBR:Pa,minFontScaleX:0,minFontScaleY:0})}return Tt})(0,i,b,A,d,_,s,r.allowVerticalPlacement),Y=r.textSizeData;let re=null;Y.kind==="source"?(re=[Bl*A.layout.get("text-size").evaluate(_,{})],re[0]>ru&&en(`${r.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):Y.kind==="composite"&&(re=[Bl*j.compositeTextSizes[0].evaluate(_,{},H),Bl*j.compositeTextSizes[1].evaluate(_,{},H)],(re[0]>ru||re[1]>ru)&&en(`${r.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),r.addSymbols(r.text,Q,re,b,d,_,I,e,M.lineStartIndex,M.lineLength,V,H);for(const ge of k)F[ge]=r.text.placedSymbolArray.length-1;return 4*Q.length}function Bd(r){for(const e in r)return r[e];return null}function Dm(r,e,i,s){const A=r.compareText;if(e in A){const d=A[e];for(let _=d.length-1;_>=0;_--)if(s.dist(d[_])<i)return!0}else A[e]=[];return A[e].push(s),!1}const Rd=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class bA{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[i,s]=new Uint8Array(e,0,2);if(i!==219)throw new Error("Data does not appear to be in a KDBush format.");const A=s>>4;if(A!==1)throw new Error(`Got v${A} data when expected v1.`);const d=Rd[15&s];if(!d)throw new Error("Unrecognized array type.");const[_]=new Uint16Array(e,2,1),[b]=new Uint32Array(e,4,1);return new bA(b,_,d,e)}constructor(e,i=64,s=Float64Array,A){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+i,2),65535),this.ArrayType=s,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const d=Rd.indexOf(this.ArrayType),_=2*e*this.ArrayType.BYTES_PER_ELEMENT,b=e*this.IndexArrayType.BYTES_PER_ELEMENT,M=(8-b%8)%8;if(d<0)throw new Error(`Unexpected typed array class: ${s}.`);A&&A instanceof ArrayBuffer?(this.data=A,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+b+M,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+_+b+M),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+b+M,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+d]),new Uint16Array(this.data,2,1)[0]=i,new Uint32Array(this.data,4,1)[0]=e)}add(e,i){const s=this._pos>>1;return this.ids[s]=s,this.coords[this._pos++]=e,this.coords[this._pos++]=i,s}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return wA(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,i,s,A){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:d,coords:_,nodeSize:b}=this,M=[0,d.length-1,0],I=[];for(;M.length;){const k=M.pop()||0,F=M.pop()||0,V=M.pop()||0;if(F-V<=b){for(let Y=V;Y<=F;Y++){const re=_[2*Y],ge=_[2*Y+1];re>=e&&re<=s&&ge>=i&&ge<=A&&I.push(d[Y])}continue}const j=V+F>>1,H=_[2*j],Q=_[2*j+1];H>=e&&H<=s&&Q>=i&&Q<=A&&I.push(d[j]),(k===0?e<=H:i<=Q)&&(M.push(V),M.push(j-1),M.push(1-k)),(k===0?s>=H:A>=Q)&&(M.push(j+1),M.push(F),M.push(1-k))}return I}within(e,i,s){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:A,coords:d,nodeSize:_}=this,b=[0,A.length-1,0],M=[],I=s*s;for(;b.length;){const k=b.pop()||0,F=b.pop()||0,V=b.pop()||0;if(F-V<=_){for(let Y=V;Y<=F;Y++)Od(d[2*Y],d[2*Y+1],e,i)<=I&&M.push(A[Y]);continue}const j=V+F>>1,H=d[2*j],Q=d[2*j+1];Od(H,Q,e,i)<=I&&M.push(A[j]),(k===0?e-s<=H:i-s<=Q)&&(b.push(V),b.push(j-1),b.push(1-k)),(k===0?e+s>=H:i+s>=Q)&&(b.push(j+1),b.push(F),b.push(1-k))}return M}}function wA(r,e,i,s,A,d){if(A-s<=i)return;const _=s+A>>1;Fd(r,e,_,s,A,d),wA(r,e,i,s,_-1,1-d),wA(r,e,i,_+1,A,1-d)}function Fd(r,e,i,s,A,d){for(;A>s;){if(A-s>600){const I=A-s+1,k=i-s+1,F=Math.log(I),V=.5*Math.exp(2*F/3),j=.5*Math.sqrt(F*V*(I-V)/I)*(k-I/2<0?-1:1);Fd(r,e,i,Math.max(s,Math.floor(i-k*V/I+j)),Math.min(A,Math.floor(i+(I-k)*V/I+j)),d)}const _=e[2*i+d];let b=s,M=A;for(Nh(r,e,s,i),e[2*A+d]>_&&Nh(r,e,s,A);b<M;){for(Nh(r,e,b,M),b++,M--;e[2*b+d]<_;)b++;for(;e[2*M+d]>_;)M--}e[2*s+d]===_?Nh(r,e,s,M):(M++,Nh(r,e,M,A)),M<=i&&(s=M+1),i<=M&&(A=M-1)}}function Nh(r,e,i,s){TA(r,i,s),TA(e,2*i,2*s),TA(e,2*i+1,2*s+1)}function TA(r,e,i){const s=r[e];r[e]=r[i],r[i]=s}function Od(r,e,i,s){const A=r-i,d=e-s;return A*A+d*d}var PA;W.cH=void 0,(PA=W.cH||(W.cH={})).create="create",PA.load="load",PA.fullLoad="fullLoad";let bc=null,Vh=[];const MA=1e3/60,EA="loadTime",SA="fullLoadTime",km={mark(r){performance.mark(r)},frame(r){const e=r;bc!=null&&Vh.push(e-bc),bc=e},clearMetrics(){bc=null,Vh=[],performance.clearMeasures(EA),performance.clearMeasures(SA);for(const r in W.cH)performance.clearMarks(W.cH[r])},getPerformanceMetrics(){performance.measure(EA,W.cH.create,W.cH.load),performance.measure(SA,W.cH.create,W.cH.fullLoad);const r=performance.getEntriesByName(EA)[0].duration,e=performance.getEntriesByName(SA)[0].duration,i=Vh.length,s=1/(Vh.reduce(((d,_)=>d+_),0)/i/1e3),A=Vh.filter((d=>d>MA)).reduce(((d,_)=>d+(_-MA)/MA),0);return{loadTime:r,fullLoadTime:e,fps:s,percentDroppedFrames:A/(i+A)*100,totalFrames:i}}};W.$=rt,W.A=zi,W.B=ra,W.C=ht,W.D=_t,W.E=Bi,W.F=function([r,e,i]){return e+=90,e*=Math.PI/180,i*=Math.PI/180,{x:r*Math.cos(e)*Math.sin(i),y:r*Math.sin(e)*Math.sin(i),z:r*Math.cos(i)}},W.G=ir,W.H=ze,W.I=Qc,W.J=Jl,W.K=function(r){if(Ui==null){const e=r.navigator?r.navigator.userAgent:null;Ui=!!r.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return Ui},W.L=class{constructor(r,e){this.target=r,this.mapId=e,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new W0((()=>this.process())),this.subscription=vo(this.target,"message",(i=>this.receive(i)),!1),this.globalScope=Is(self)?r:window}registerMessageHandler(r,e){this.messageHandlers[r]=e}unregisterMessageHandler(r){delete this.messageHandlers[r]}sendAsync(r,e){return new Promise(((i,s)=>{const A=Math.round(1e18*Math.random()).toString(36).substring(0,10),d=e?vo(e.signal,"abort",(()=>{d==null||d.unsubscribe(),delete this.resolveRejects[A];const M={id:A,type:"<cancel>",origin:location.origin,targetMapId:r.targetMapId,sourceMapId:this.mapId};this.target.postMessage(M)}),Q0):null;this.resolveRejects[A]={resolve:M=>{d==null||d.unsubscribe(),i(M)},reject:M=>{d==null||d.unsubscribe(),s(M)}};const _=[],b=Object.assign(Object.assign({},r),{id:A,sourceMapId:this.mapId,origin:location.origin,data:c(r.data,_)});this.target.postMessage(b,{transfer:_})}))}receive(r){const e=r.data,i=e.id;if(!(e.origin!=="file://"&&location.origin!=="file://"&&e.origin!=="resource://android"&&location.origin!=="resource://android"&&e.origin!==location.origin||e.targetMapId&&this.mapId!==e.targetMapId)){if(e.type==="<cancel>"){delete this.tasks[i];const s=this.abortControllers[i];return delete this.abortControllers[i],void(s&&s.abort())}if(Is(self)||e.mustQueue)return this.tasks[i]=e,this.taskQueue.push(i),void this.invoker.trigger();this.processTask(i,e)}}process(){if(this.taskQueue.length===0)return;const r=this.taskQueue.shift(),e=this.tasks[r];delete this.tasks[r],this.taskQueue.length>0&&this.invoker.trigger(),e&&this.processTask(r,e)}processTask(r,e){return p(this,void 0,void 0,(function*(){if(e.type==="<response>"){const A=this.resolveRejects[r];return delete this.resolveRejects[r],A?void(e.error?A.reject(m(e.error)):A.resolve(m(e.data))):void 0}if(!this.messageHandlers[e.type])return void this.completeTask(r,new Error(`Could not find a registered handler for ${e.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const i=m(e.data),s=new AbortController;this.abortControllers[r]=s;try{const A=yield this.messageHandlers[e.type](e.sourceMapId,i,s);this.completeTask(r,null,A)}catch(A){this.completeTask(r,A)}}))}completeTask(r,e,i){const s=[];delete this.abortControllers[r];const A={id:r,type:"<response>",sourceMapId:this.mapId,origin:location.origin,error:e?c(e):null,data:c(i,s)};this.target.postMessage(A,{transfer:s})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},W.M=Fe,W.N=function(){var r=new zi(16);return zi!=Float32Array&&(r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[11]=0,r[12]=0,r[13]=0,r[14]=0),r[0]=1,r[5]=1,r[10]=1,r[15]=1,r},W.O=function(r,e,i){var s,A,d,_,b,M,I,k,F,V,j,H,Q=i[0],Y=i[1],re=i[2];return e===r?(r[12]=e[0]*Q+e[4]*Y+e[8]*re+e[12],r[13]=e[1]*Q+e[5]*Y+e[9]*re+e[13],r[14]=e[2]*Q+e[6]*Y+e[10]*re+e[14],r[15]=e[3]*Q+e[7]*Y+e[11]*re+e[15]):(A=e[1],d=e[2],_=e[3],b=e[4],M=e[5],I=e[6],k=e[7],F=e[8],V=e[9],j=e[10],H=e[11],r[0]=s=e[0],r[1]=A,r[2]=d,r[3]=_,r[4]=b,r[5]=M,r[6]=I,r[7]=k,r[8]=F,r[9]=V,r[10]=j,r[11]=H,r[12]=s*Q+b*Y+F*re+e[12],r[13]=A*Q+M*Y+V*re+e[13],r[14]=d*Q+I*Y+j*re+e[14],r[15]=_*Q+k*Y+H*re+e[15]),r},W.P=it,W.Q=function(r,e,i){var s=i[0],A=i[1],d=i[2];return r[0]=e[0]*s,r[1]=e[1]*s,r[2]=e[2]*s,r[3]=e[3]*s,r[4]=e[4]*A,r[5]=e[5]*A,r[6]=e[6]*A,r[7]=e[7]*A,r[8]=e[8]*d,r[9]=e[9]*d,r[10]=e[10]*d,r[11]=e[11]*d,r[12]=e[12],r[13]=e[13],r[14]=e[14],r[15]=e[15],r},W.R=mo,W.S=function(r,e,i){var s=e[0],A=e[1],d=e[2],_=e[3],b=e[4],M=e[5],I=e[6],k=e[7],F=e[8],V=e[9],j=e[10],H=e[11],Q=e[12],Y=e[13],re=e[14],ge=e[15],oe=i[0],ue=i[1],ve=i[2],Te=i[3];return r[0]=oe*s+ue*b+ve*F+Te*Q,r[1]=oe*A+ue*M+ve*V+Te*Y,r[2]=oe*d+ue*I+ve*j+Te*re,r[3]=oe*_+ue*k+ve*H+Te*ge,r[4]=(oe=i[4])*s+(ue=i[5])*b+(ve=i[6])*F+(Te=i[7])*Q,r[5]=oe*A+ue*M+ve*V+Te*Y,r[6]=oe*d+ue*I+ve*j+Te*re,r[7]=oe*_+ue*k+ve*H+Te*ge,r[8]=(oe=i[8])*s+(ue=i[9])*b+(ve=i[10])*F+(Te=i[11])*Q,r[9]=oe*A+ue*M+ve*V+Te*Y,r[10]=oe*d+ue*I+ve*j+Te*re,r[11]=oe*_+ue*k+ve*H+Te*ge,r[12]=(oe=i[12])*s+(ue=i[13])*b+(ve=i[14])*F+(Te=i[15])*Q,r[13]=oe*A+ue*M+ve*V+Te*Y,r[14]=oe*d+ue*I+ve*j+Te*re,r[15]=oe*_+ue*k+ve*H+Te*ge,r},W.T=Nc,W.U=function(r,e){const i={};for(let s=0;s<e.length;s++){const A=e[s];A in r&&(i[A]=r[A])}return i},W.V=nu,W.W=hn,W.X=Bf,W.Y=Lf,W.Z=Me,W._=p,W.a=le,W.a$=Cs,W.a0=Fo,W.a1=Zo,W.a2=oa,W.a3=Ff,W.a4=hc,W.a5=Oi,W.a6=function(r,e,i){if(!r)return e||{};if(!e)return r||{};const s=jf(r),A=jf(e);(function(_,b){b.removeAll&&(_.add.clear(),_.update.clear(),_.remove.clear(),b.remove.clear());for(const M of b.remove)_.add.delete(M),_.update.delete(M);for(const[M,I]of b.update){const k=_.update.get(M);k&&(b.update.set(M,$0(k,I)),_.update.delete(M))}})(s,A);const d={};if((s.removeAll||A.removeAll)&&(d.removeAll=!0),d.remove=new Set([...s.remove,...A.remove]),d.add=new Map([...s.add,...A.add]),d.update=new Map([...s.update,...A.update]),d.remove.size&&d.add.size)for(const _ of d.add.keys())d.remove.delete(_);return(function(_){const b={};return _.removeAll&&(b.removeAll=_.removeAll),_.remove&&(b.remove=Array.from(_.remove)),_.add&&(b.add=Array.from(_.add.values())),_.update&&(b.update=Array.from(_.update.values())),b})(d)},W.a7=function(r,e){const i=new Map;if(r==null||r.type==null)return i;if(r.type==="Feature"){const s=rA(r,e);return s==null?void 0:(i.set(s,r),i)}if(r.type==="FeatureCollection"){const s=new Set;for(const A of r.features){const d=rA(A,e);if(d==null||s.has(d))return;s.add(d),i.set(d,A)}return i}},W.a8=function(r,e,i){var s,A;const d=[];if(e.removeAll)r.clear();else if(e.remove)for(const _ of e.remove){const b=r.get(_);b&&(d.push(b.geometry),r.delete(_))}if(e.add)for(const _ of e.add){const b=rA(_,i);if(b==null)continue;const M=r.get(b);M&&d.push(M.geometry),d.push(_.geometry),r.set(b,_)}if(e.update)for(const _ of e.update){const b=r.get(_.id);if(!b)continue;const M=!!_.newGeometry,I=_.removeAllProperties||((s=_.removeProperties)===null||s===void 0?void 0:s.length)>0||((A=_.addOrUpdateProperties)===null||A===void 0?void 0:A.length)>0;if(!M&&!I)continue;d.push(b.geometry);const k=Object.assign({},b);if(r.set(_.id,k),M&&(d.push(_.newGeometry),k.geometry=_.newGeometry),I){if(k.properties=_.removeAllProperties?{}:Object.assign({},k.properties||{}),_.removeProperties)for(const F of _.removeProperties)delete k.properties[F];if(_.addOrUpdateProperties)for(const{key:F,value:V}of _.addOrUpdateProperties)k.properties[F]=V}}return d},W.a9=Bh,W.aA=function(r,{uSize:e,uSizeT:i},{lowerSize:s,upperSize:A}){return r.kind==="source"?s/Bl:r.kind==="composite"?ir.number(s/Bl,A/Bl,i):e},W.aB=function(r,e){var i=e[0],s=e[1],A=e[2],d=e[3],_=e[4],b=e[5],M=e[6],I=e[7],k=e[8],F=e[9],V=e[10],j=e[11],H=e[12],Q=e[13],Y=e[14],re=e[15],ge=i*b-s*_,oe=i*M-A*_,ue=i*I-d*_,ve=s*M-A*b,Te=s*I-d*b,Ue=A*I-d*M,lt=k*Q-F*H,nt=k*Y-V*H,dt=k*re-j*H,Tt=F*Y-V*Q,mt=F*re-j*Q,st=V*re-j*Y,Xe=ge*st-oe*mt+ue*Tt+ve*dt-Te*nt+Ue*lt;return Xe?(r[0]=(b*st-M*mt+I*Tt)*(Xe=1/Xe),r[1]=(A*mt-s*st-d*Tt)*Xe,r[2]=(Q*Ue-Y*Te+re*ve)*Xe,r[3]=(V*Te-F*Ue-j*ve)*Xe,r[4]=(M*dt-_*st-I*nt)*Xe,r[5]=(i*st-A*dt+d*nt)*Xe,r[6]=(Y*ue-H*Ue-re*oe)*Xe,r[7]=(k*Ue-V*ue+j*oe)*Xe,r[8]=(_*mt-b*dt+I*lt)*Xe,r[9]=(s*dt-i*mt-d*lt)*Xe,r[10]=(H*Te-Q*ue+re*ge)*Xe,r[11]=(F*ue-k*Te-j*ge)*Xe,r[12]=(b*nt-_*Tt-M*lt)*Xe,r[13]=(i*Tt-s*nt+A*lt)*Xe,r[14]=(Q*oe-H*ve-Y*ge)*Xe,r[15]=(k*ve-F*oe+V*ge)*Xe,r):null},W.aC=Hr,W.aD=function(r){var e=r[0],i=r[1];return Math.sqrt(e*e+i*i)},W.aE=function(r){return r[0]=0,r[1]=0,r},W.aF=function(r,e,i){return r[0]=e[0]*i,r[1]=e[1]*i,r},W.aG=Xc,W.aH=Cn,W.aI=function(r,e,i,s){const A=e.y-r.y,d=e.x-r.x,_=s.y-i.y,b=s.x-i.x,M=_*d-b*A;if(M===0)return null;const I=(b*(r.y-i.y)-_*(r.x-i.x))/M;return new it(r.x+I*d,r.y+I*A)},W.aJ=bd,W.aK=Wu,W.aL=function(r){let e=1/0,i=1/0,s=-1/0,A=-1/0;for(const d of r)e=Math.min(e,d.x),i=Math.min(i,d.y),s=Math.max(s,d.x),A=Math.max(A,d.y);return[e,i,s,A]},W.aM=ns,W.aN=Yt,W.aO=function(r,e,i,s,A=!1){if(!i[0]&&!i[1])return[0,0];const d=A?s==="map"?-r.bearingInRadians:0:s==="viewport"?r.bearingInRadians:0;if(d){const _=Math.sin(d),b=Math.cos(d);i=[i[0]*b-i[1]*_,i[0]*_+i[1]*b]}return[A?i[0]:Yt(e,i[0],r.zoom),A?i[1]:Yt(e,i[1],r.zoom)]},W.aQ=Yc,W.aR=xA,W.aS=$c,W.aT=bA,W.aU=on,W.aV=nc,W.aW=he,W.aX=Pt,W.aY=Ye,W.aZ=mn,W.a_=Of,W.aa=Cu,W.ab=25,W.ac=iA,W.ad=r=>{const e=window.document.createElement("video");return e.muted=!0,new Promise((i=>{e.onloadstart=()=>{i(e)};for(const s of r){const A=window.document.createElement("source");ot(s)||(e.crossOrigin="Anonymous"),A.src=s,e.appendChild(A)}}))},W.ae=o,W.af=function(){return yo++},W.ag=f,W.ah=th,W.ai=Oh,W.aj=Rt,W.ak=dl,W.al=Uf,W.am=function(r){const e={};if(r.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((i,s,A,d)=>{const _=A||d;return e[s]=!_||_.toLowerCase(),""})),e["max-age"]){const i=parseInt(e["max-age"],10);isNaN(i)?delete e["max-age"]:e["max-age"]=i}return e},W.an=Ai,W.ao=85.051129,W.ap=Ds,W.aq=function(r){return Math.pow(2,r)},W.ar=no,W.as=Rf,W.at=function(r){return Math.log(r)/Math.LN2},W.au=function(r){var e=r[0],i=r[1];return e*e+i*i},W.av=function(r){if(!r.length)return new Set;const e=Math.max(...r.map((M=>M.canonical.z)));let i=1/0,s=-1/0,A=1/0,d=-1/0;const _=[];for(const M of r){const{x:I,y:k,z:F}=M.canonical,V=Math.pow(2,e-F),j=I*V,H=k*V;_.push({id:M,x:j,y:H}),j<i&&(i=j),j>s&&(s=j),H<A&&(A=H),H>d&&(d=H)}const b=new Set;for(const M of _)M.x!==i&&M.x!==s&&M.y!==A&&M.y!==d||b.add(M.id);return b},W.aw=function(r,e){const i=Math.abs(2*r.wrap)-+(r.wrap<0),s=Math.abs(2*e.wrap)-+(e.wrap<0);return r.overscaledZ-e.overscaledZ||s-i||e.canonical.y-r.canonical.y||e.canonical.x-r.canonical.x},W.ax=class{constructor(r,e){this.max=r,this.onRemove=e,this.reset()}reset(){for(const r in this.data)for(const e of this.data[r])e.timeout&&clearTimeout(e.timeout),this.onRemove(e.value);return this.data={},this.order=[],this}add(r,e,i){const s=r.wrapped().key;this.data[s]===void 0&&(this.data[s]=[]);const A={value:e,timeout:void 0};if(i!==void 0&&(A.timeout=setTimeout((()=>{this.remove(r,A)}),i)),this.data[s].push(A),this.order.push(s),this.order.length>this.max){const d=this._getAndRemoveByKey(this.order[0]);d&&this.onRemove(d)}return this}has(r){return r.wrapped().key in this.data}getAndRemove(r){return this.has(r)?this._getAndRemoveByKey(r.wrapped().key):null}_getAndRemoveByKey(r){const e=this.data[r].shift();return e.timeout&&clearTimeout(e.timeout),this.data[r].length===0&&delete this.data[r],this.order.splice(this.order.indexOf(r),1),e.value}getByKey(r){const e=this.data[r];return e?e[0].value:null}get(r){return this.has(r)?this.data[r.wrapped().key][0].value:null}remove(r,e){if(!this.has(r))return this;const i=r.wrapped().key,s=e===void 0?0:this.data[i].indexOf(e),A=this.data[i][s];return this.data[i].splice(s,1),A.timeout&&clearTimeout(A.timeout),this.data[i].length===0&&delete this.data[i],this.onRemove(A.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(r){for(this.max=r;this.order.length>this.max;){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}filter(r){const e=[];for(const i in this.data)for(const s of this.data[i])r(s.value)||e.push(s);for(const i of e)this.remove(i.value.tileID,i)}},W.ay=function(r,e){let i=0,s=0;if(r.kind==="constant")s=r.layoutSize;else if(r.kind!=="source"){const{interpolationType:A,minZoom:d,maxZoom:_}=r,b=A?Ai(xr.interpolationFactor(A,e,d,_),0,1):0;r.kind==="camera"?s=ir.number(r.minSize,r.maxSize,b):i=b}return{uSizeT:i,uSize:s}},W.b=Dn,W.b$=zl,W.b0=Vs,W.b1=function(r){var e=new zi(3);return e[0]=r[0],e[1]=r[1],e[2]=r[2],e},W.b2=function(r,e,i){return r[0]=e[0]-i[0],r[1]=e[1]-i[1],r[2]=e[2]-i[2],r},W.b3=function(r,e){var i=e[0],s=e[1],A=e[2],d=i*i+s*s+A*A;return d>0&&(d=1/Math.sqrt(d)),r[0]=e[0]*d,r[1]=e[1]*d,r[2]=e[2]*d,r},W.b4=cr,W.b5=function(r,e){return r[0]*e[0]+r[1]*e[1]+r[2]*e[2]},W.b6=function(r,e,i){return r[0]=e[0]*i[0],r[1]=e[1]*i[1],r[2]=e[2]*i[2],r[3]=e[3]*i[3],r},W.b7=En,W.b8=function(r,e,i){const s=e[0]*i[0]+e[1]*i[1]+e[2]*i[2];return s===0?null:(-(r[0]*i[0]+r[1]*i[1]+r[2]*i[2])-i[3])/s},W.b9=Sn,W.bA=function(r,e,i,s){return r[0]=e[0]+i[0]*s,r[1]=e[1]+i[1]*s,r[2]=e[2]+i[2]*s,r},W.bB=Jr,W.bC=function(r,e,i){var s=i[0],A=i[1],d=i[2],_=i[3],b=e[0],M=e[1],I=e[2],k=A*I-d*M,F=d*b-s*I,V=s*M-A*b;return r[0]=b+_*(k+=k)+A*(V+=V)-d*(F+=F),r[1]=M+_*F+d*k-s*V,r[2]=I+_*V+s*F-A*k,r},W.bD=function(r,e,i){const s=(function(M){var I=M[3],k=M[4],F=M[5],V=M[6],j=M[7],H=M[8];return M[0]*(H*k-F*j)+M[1]*(-H*I+F*V)+M[2]*(j*I-k*V)})([r[0],r[1],r[2],e[0],e[1],e[2],i[0],i[1],i[2]]);if(s===0)return null;const A=cr([],[e[0],e[1],e[2]],[i[0],i[1],i[2]]),d=cr([],[i[0],i[1],i[2]],[r[0],r[1],r[2]]),_=cr([],[r[0],r[1],r[2]],[e[0],e[1],e[2]]),b=Cs([],A,-r[3]);return Vs(b,b,Cs([],d,-e[3])),Vs(b,b,Cs([],_,-i[3])),Cs(b,b,1/s),b},W.bE=tA,W.bF=function(){return new Float64Array(4)},W.bG=function(r,e,i,s){var A=[],d=[];return A[0]=e[0]-i[0],A[1]=e[1]-i[1],A[2]=e[2]-i[2],d[0]=A[0]*Math.cos(s)-A[1]*Math.sin(s),d[1]=A[0]*Math.sin(s)+A[1]*Math.cos(s),d[2]=A[2],r[0]=d[0]+i[0],r[1]=d[1]+i[1],r[2]=d[2]+i[2],r},W.bH=function(r,e,i,s){var A=[],d=[];return A[0]=e[0]-i[0],A[1]=e[1]-i[1],A[2]=e[2]-i[2],d[0]=A[0],d[1]=A[1]*Math.cos(s)-A[2]*Math.sin(s),d[2]=A[1]*Math.sin(s)+A[2]*Math.cos(s),r[0]=d[0]+i[0],r[1]=d[1]+i[1],r[2]=d[2]+i[2],r},W.bI=function(r,e,i,s){var A=[],d=[];return A[0]=e[0]-i[0],A[1]=e[1]-i[1],A[2]=e[2]-i[2],d[0]=A[2]*Math.sin(s)+A[0]*Math.cos(s),d[1]=A[1],d[2]=A[2]*Math.cos(s)-A[0]*Math.sin(s),r[0]=d[0]+i[0],r[1]=d[1]+i[1],r[2]=d[2]+i[2],r},W.bJ=function(r,e,i){var s=Math.sin(i),A=Math.cos(i),d=e[0],_=e[1],b=e[2],M=e[3],I=e[8],k=e[9],F=e[10],V=e[11];return e!==r&&(r[4]=e[4],r[5]=e[5],r[6]=e[6],r[7]=e[7],r[12]=e[12],r[13]=e[13],r[14]=e[14],r[15]=e[15]),r[0]=d*A-I*s,r[1]=_*A-k*s,r[2]=b*A-F*s,r[3]=M*A-V*s,r[8]=d*s+I*A,r[9]=_*s+k*A,r[10]=b*s+F*A,r[11]=M*s+V*A,r},W.bK=function(r,e){const i=Ni(r,360),s=Ni(e,360),A=s-i,d=s>i?A-360:A+360;return Math.abs(A)<Math.abs(d)?A:d},W.bL=function(r){return r[0]=0,r[1]=0,r[2]=0,r},W.bM=function(r,e,i,s){const A=Math.sqrt(r*r+e*e),d=Math.sqrt(i*i+s*s);r/=A,e/=A,i/=d,s/=d;const _=Math.acos(r*i+e*s);return-e*i+r*s>0?_:-_},W.bN=function(r,e){const i=Ni(r,2*Math.PI),s=Ni(e,2*Math.PI);return Math.min(Math.abs(i-s),Math.abs(i-s+2*Math.PI),Math.abs(i-s-2*Math.PI))},W.bO=function(){const r={},e=qe.$version;for(const i in qe.$root){const s=qe.$root[i];if(s.required){let A=null;A=i==="version"?e:s.type==="array"?[]:{},A!=null&&(r[i]=A)}}return r},W.bP=Qe,W.bQ=g,W.bR=function r(e,i){if(Array.isArray(e)){if(!Array.isArray(i)||e.length!==i.length)return!1;for(let s=0;s<e.length;s++)if(!r(e[s],i[s]))return!1;return!0}if(typeof e=="object"&&e!==null&&i!==null){if(typeof i!="object"||Object.keys(e).length!==Object.keys(i).length)return!1;for(const s in e)if(!r(e[s],i[s]))return!1;return!0}return e===i},W.bS=function(r){r=r.slice();const e=Object.create(null);for(let i=0;i<r.length;i++)e[r[i].id]=r[i];for(let i=0;i<r.length;i++)"ref"in r[i]&&(r[i]=rn(r[i],e[r[i].ref]));return r},W.bT=function(r,e){if(r.type==="custom")return new H0(r,e);switch(r.type){case"background":return new q0(r,e);case"circle":return new Cp(r,e);case"color-relief":return new Bp(r,e);case"fill":return new Yp(r,e);case"fill-extrusion":return new l0(r,e);case"heatmap":return new Dp(r,e);case"hillshade":return new zp(r,e);case"line":return new p0(r,e);case"raster":return new Ic(r,e);case"symbol":return new uc(r,e)}},W.bU=r=>r.type==="raster",W.bV=In,W.bW=function(r,e){if(!r)return[{command:"setStyle",args:[e]}];let i=[];try{if(!Kt(r.version,e.version))return[{command:"setStyle",args:[e]}];Kt(r.center,e.center)||i.push({command:"setCenter",args:[e.center]}),Kt(r.state,e.state)||i.push({command:"setGlobalState",args:[e.state]}),Kt(r.centerAltitude,e.centerAltitude)||i.push({command:"setCenterAltitude",args:[e.centerAltitude]}),Kt(r.zoom,e.zoom)||i.push({command:"setZoom",args:[e.zoom]}),Kt(r.bearing,e.bearing)||i.push({command:"setBearing",args:[e.bearing]}),Kt(r.pitch,e.pitch)||i.push({command:"setPitch",args:[e.pitch]}),Kt(r.roll,e.roll)||i.push({command:"setRoll",args:[e.roll]}),Kt(r.sprite,e.sprite)||i.push({command:"setSprite",args:[e.sprite]}),Kt(r.glyphs,e.glyphs)||i.push({command:"setGlyphs",args:[e.glyphs]}),Kt(r.transition,e.transition)||i.push({command:"setTransition",args:[e.transition]}),Kt(r.light,e.light)||i.push({command:"setLight",args:[e.light]}),Kt(r.terrain,e.terrain)||i.push({command:"setTerrain",args:[e.terrain]}),Kt(r.sky,e.sky)||i.push({command:"setSky",args:[e.sky]}),Kt(r.projection,e.projection)||i.push({command:"setProjection",args:[e.projection]});const s={},A=[];(function(_,b,M,I){let k;for(k in b=b||{},_=_||{})Object.prototype.hasOwnProperty.call(_,k)&&(Object.prototype.hasOwnProperty.call(b,k)||Wi(k,M,I));for(k in b)Object.prototype.hasOwnProperty.call(b,k)&&(Object.prototype.hasOwnProperty.call(_,k)?Kt(_[k],b[k])||(_[k].type==="geojson"&&b[k].type==="geojson"&&Ve(_,b,k)?qi(M,{command:"setGeoJSONSourceData",args:[k,b[k].data]}):er(k,b,M,I)):Vr(k,b,M))})(r.sources,e.sources,A,s);const d=[];r.layers&&r.layers.forEach((_=>{"source"in _&&s[_.source]?i.push({command:"removeLayer",args:[_.id]}):d.push(_)})),i=i.concat(A),(function(_,b,M){b=b||[];const I=(_=_||[]).map(It),k=b.map(It),F=_.reduce(At,{}),V=b.reduce(At,{}),j=I.slice(),H=Object.create(null);let Q,Y,re,ge,oe;for(let ue=0,ve=0;ue<I.length;ue++)Q=I[ue],Object.prototype.hasOwnProperty.call(V,Q)?ve++:(qi(M,{command:"removeLayer",args:[Q]}),j.splice(j.indexOf(Q,ve),1));for(let ue=0,ve=0;ue<k.length;ue++)Q=k[k.length-1-ue],j[j.length-1-ue]!==Q&&(Object.prototype.hasOwnProperty.call(F,Q)?(qi(M,{command:"removeLayer",args:[Q]}),j.splice(j.lastIndexOf(Q,j.length-ve),1)):ve++,ge=j[j.length-ue],qi(M,{command:"addLayer",args:[V[Q],ge]}),j.splice(j.length-ue,0,Q),H[Q]=!0);for(let ue=0;ue<k.length;ue++)if(Q=k[ue],Y=F[Q],re=V[Q],!H[Q]&&!Kt(Y,re))if(Kt(Y.source,re.source)&&Kt(Y["source-layer"],re["source-layer"])&&Kt(Y.type,re.type)){for(oe in at(Y.layout,re.layout,M,Q,null,"setLayoutProperty"),at(Y.paint,re.paint,M,Q,null,"setPaintProperty"),Kt(Y.filter,re.filter)||qi(M,{command:"setFilter",args:[Q,re.filter]}),Kt(Y.minzoom,re.minzoom)&&Kt(Y.maxzoom,re.maxzoom)||qi(M,{command:"setLayerZoomRange",args:[Q,re.minzoom,re.maxzoom]}),Y)Object.prototype.hasOwnProperty.call(Y,oe)&&oe!=="layout"&&oe!=="paint"&&oe!=="filter"&&oe!=="metadata"&&oe!=="minzoom"&&oe!=="maxzoom"&&(oe.indexOf("paint.")===0?at(Y[oe],re[oe],M,Q,oe.slice(6),"setPaintProperty"):Kt(Y[oe],re[oe])||qi(M,{command:"setLayerProperty",args:[Q,oe,re[oe]]}));for(oe in re)Object.prototype.hasOwnProperty.call(re,oe)&&!Object.prototype.hasOwnProperty.call(Y,oe)&&oe!=="layout"&&oe!=="paint"&&oe!=="filter"&&oe!=="metadata"&&oe!=="minzoom"&&oe!=="maxzoom"&&(oe.indexOf("paint.")===0?at(Y[oe],re[oe],M,Q,oe.slice(6),"setPaintProperty"):Kt(Y[oe],re[oe])||qi(M,{command:"setLayerProperty",args:[Q,oe,re[oe]]}))}else qi(M,{command:"removeLayer",args:[Q]}),ge=j[j.lastIndexOf(Q)+1],qi(M,{command:"addLayer",args:[re,ge]})})(d,e.layers,i)}catch(s){console.warn("Unable to compute style diff:",s),i=[{command:"setStyle",args:[e]}]}return i},W.bX=function(r){const e=[],i=r.id;return i===void 0&&e.push({message:`layers.${i}: missing required property "id"`}),r.render===void 0&&e.push({message:`layers.${i}: missing required method "render"`}),r.renderingMode&&r.renderingMode!=="2d"&&r.renderingMode!=="3d"&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},W.bY=us,W.bZ=No,W.b_=class extends eo{constructor(r,e){super(r,e),this.current=0}set(r){this.current!==r&&(this.current=r,this.gl.uniform1i(this.location,r))}},W.ba=function(r,e,i){return r[0]=e[0]*i,r[1]=e[1]*i,r[2]=e[2]*i,r[3]=e[3]*i,r},W.bb=function(r,e){return r[0]*e[0]+r[1]*e[1]+r[2]*e[2]+r[3]},W.bc=Vf,W.bd=ih,W.be=function(r,e,i,s,A){var d=1/Math.tan(e/2);if(r[0]=d/i,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=d,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[11]=-1,r[12]=0,r[13]=0,r[15]=0,A!=null&&A!==1/0){var _=1/(s-A);r[10]=(A+s)*_,r[14]=2*A*s*_}else r[10]=-1,r[14]=-2*s;return r},W.bf=function(r){var e=new zi(16);return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],e[9]=r[9],e[10]=r[10],e[11]=r[11],e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15],e},W.bg=function(r,e,i){var s=Math.sin(i),A=Math.cos(i),d=e[0],_=e[1],b=e[2],M=e[3],I=e[4],k=e[5],F=e[6],V=e[7];return e!==r&&(r[8]=e[8],r[9]=e[9],r[10]=e[10],r[11]=e[11],r[12]=e[12],r[13]=e[13],r[14]=e[14],r[15]=e[15]),r[0]=d*A+I*s,r[1]=_*A+k*s,r[2]=b*A+F*s,r[3]=M*A+V*s,r[4]=I*A-d*s,r[5]=k*A-_*s,r[6]=F*A-b*s,r[7]=V*A-M*s,r},W.bh=function(r,e,i){var s=Math.sin(i),A=Math.cos(i),d=e[4],_=e[5],b=e[6],M=e[7],I=e[8],k=e[9],F=e[10],V=e[11];return e!==r&&(r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=e[3],r[12]=e[12],r[13]=e[13],r[14]=e[14],r[15]=e[15]),r[4]=d*A+I*s,r[5]=_*A+k*s,r[6]=b*A+F*s,r[7]=M*A+V*s,r[8]=I*A-d*s,r[9]=k*A-_*s,r[10]=F*A-b*s,r[11]=V*A-M*s,r},W.bi=function(){const r=new Float32Array(16);return no(r),r},W.bj=function(){const r=new Float64Array(16);return no(r),r},W.bk=function(){return new Float64Array(16)},W.bl=function(r,e,i){const s=new Float64Array(4);return Jr(s,r,e-90,i),s},W.bm=function(r,e,i,s){var A,d,_,b,M,I=e[0],k=e[1],F=e[2],V=e[3],j=i[0],H=i[1],Q=i[2],Y=i[3];return(d=I*j+k*H+F*Q+V*Y)<0&&(d=-d,j=-j,H=-H,Q=-Q,Y=-Y),1-d>hr?(A=Math.acos(d),_=Math.sin(A),b=Math.sin((1-s)*A)/_,M=Math.sin(s*A)/_):(b=1-s,M=s),r[0]=b*I+M*j,r[1]=b*k+M*H,r[2]=b*F+M*Q,r[3]=b*V+M*Y,r},W.bn=function(r){const e=new Float64Array(9);(function(d,_){var b=_[0],M=_[1],I=_[2],k=_[3],F=b+b,V=M+M,j=I+I,H=b*F,Q=M*F,Y=M*V,re=I*F,ge=I*V,oe=I*j,ue=k*F,ve=k*V,Te=k*j;d[0]=1-Y-oe,d[3]=Q-Te,d[6]=re+ve,d[1]=Q+Te,d[4]=1-H-oe,d[7]=ge-ue,d[2]=re-ve,d[5]=ge+ue,d[8]=1-H-Y})(e,r);const i=mn(-Math.asin(Ai(e[2],-1,1)));let s,A;return Math.hypot(e[5],e[8])<.001?(s=0,A=-mn(Math.atan2(e[3],e[4]))):(s=mn(e[5]===0&&e[8]===0?0:Math.atan2(e[5],e[8])),A=mn(e[1]===0&&e[0]===0?0:Math.atan2(e[1],e[0]))),{roll:s,pitch:i+90,bearing:A}},W.bo=function(r,e){return r.roll==e.roll&&r.pitch==e.pitch&&r.bearing==e.bearing},W.bp=oi,W.bq=kl,W.br=Ku,W.bs=Ch,W.bt=Xu,W.bu=Mr,W.bv=Wr,W.bw=Lr,W.bx=function(r,e,i,s,A){return Mr(s,A,Ai((r-e)/(i-e),0,1))},W.by=Ni,W.bz=function(){return new Float64Array(3)},W.c=Se,W.c$=function(r,e,i,s,A){return p(this,void 0,void 0,(function*(){if(Fo())try{return yield Zo(r,e,i,s,A)}catch{}return(function(d,_,b,M,I){const k=d.width,F=d.height;tn&&Gn||(tn=new OffscreenCanvas(k,F),Gn=tn.getContext("2d",{willReadFrequently:!0})),tn.width=k,tn.height=F,Gn.drawImage(d,0,0,k,F);const V=Gn.getImageData(_,b,M,I);return Gn.clearRect(0,0,k,F),V.data})(r,e,i,s,A)}))},W.c0=class extends eo{constructor(r,e){super(r,e),this.current=zo}set(r){if(r[12]!==this.current[12]||r[0]!==this.current[0])return this.current=r,void this.gl.uniformMatrix4fv(this.location,!1,r);for(let e=1;e<16;e++)if(r[e]!==this.current[e]){this.current=r,this.gl.uniformMatrix4fv(this.location,!1,r);break}}},W.c1=Mu,W.c2=class extends eo{constructor(r,e){super(r,e),this.current=[0,0,0]}set(r){r[0]===this.current[0]&&r[1]===this.current[1]&&r[2]===this.current[2]||(this.current=r,this.gl.uniform3f(this.location,r[0],r[1],r[2]))}},W.c3=class extends eo{constructor(r,e){super(r,e),this.current=[0,0]}set(r){r[0]===this.current[0]&&r[1]===this.current[1]||(this.current=r,this.gl.uniform2f(this.location,r[0],r[1]))}},W.c4=ro,W.c5=function(r,e){var i=Math.sin(e),s=Math.cos(e);return r[0]=s,r[1]=i,r[2]=0,r[3]=-i,r[4]=s,r[5]=0,r[6]=0,r[7]=0,r[8]=1,r},W.c6=function(r,e,i){var s=e[0],A=e[1],d=e[2];return r[0]=s*i[0]+A*i[3]+d*i[6],r[1]=s*i[1]+A*i[4]+d*i[7],r[2]=s*i[2]+A*i[5]+d*i[8],r},W.c7=function(r,e,i,s,A,d,_){var b=1/(e-i),M=1/(s-A),I=1/(d-_);return r[0]=-2*b,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=-2*M,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=2*I,r[11]=0,r[12]=(e+i)*b,r[13]=(A+s)*M,r[14]=(_+d)*I,r[15]=1,r},W.c8=class extends eo{constructor(r,e){super(r,e),this.current=new Array}set(r){if(r!=this.current){this.current=r;const e=new Float32Array(4*r.length);for(let i=0;i<r.length;i++)e[4*i]=r[i].r,e[4*i+1]=r[i].g,e[4*i+2]=r[i].b,e[4*i+3]=r[i].a;this.gl.uniform4fv(this.location,e)}}},W.c9=class extends eo{constructor(r,e){super(r,e),this.current=new Array}set(r){if(r!=this.current){this.current=r;const e=new Float32Array(r);this.gl.uniform1fv(this.location,e)}}},W.cA=function(r,e){return Ne[e]&&"touches"in r},W.cB=function(r){return Ne[r]||ee[r]},W.cC=function(r,e,i){var s=e[0],A=e[1];return r[0]=i[0]*s+i[4]*A+i[12],r[1]=i[1]*s+i[5]*A+i[13],r},W.cD=function(r,e){const{x:i,y:s}=Bh.fromLngLat(e);return!(r<0||r>25||s<0||s>=1||i<0||i>=1)},W.cE=function(r,e){return r[0]=e[0],r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=e[1],r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=e[2],r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r},W.cF=class extends Vu{},W.cG=km,W.cI=ke,W.cJ=function(r,e){Se.REGISTERED_PROTOCOLS[r]=e},W.cK=function(r){delete Se.REGISTERED_PROTOCOLS[r]},W.cL=function(r,e){const i={};for(let A=0;A<r.length;A++){const d=e&&e[r[A].id]||Yl(r[A]);e&&(e[r[A].id]=d);let _=i[d];_||(_=i[d]=[]),_.push(r[A])}const s=[];for(const A in i)s.push(i[A]);return s},W.cM=kt,W.cN=Zf,W.cO=vd,W.cP=wf,W.cQ=function(r){r.bucket.createArrays(),r.bucket.tilePixelRatio=Oi/(512*r.bucket.overscaling),r.bucket.compareText={},r.bucket.iconsNeedLinear=!1;const e=r.bucket.layers[0],i=e.layout,s=e._unevaluatedLayout._values,A={layoutIconSize:s["icon-size"].possiblyEvaluate(new ze(r.bucket.zoom+1),r.canonical),layoutTextSize:s["text-size"].possiblyEvaluate(new ze(r.bucket.zoom+1),r.canonical),textMaxSize:s["text-size"].possiblyEvaluate(new ze(18))};if(r.bucket.textSizeData.kind==="composite"){const{minZoom:I,maxZoom:k}=r.bucket.textSizeData;A.compositeTextSizes=[s["text-size"].possiblyEvaluate(new ze(I),r.canonical),s["text-size"].possiblyEvaluate(new ze(k),r.canonical)]}if(r.bucket.iconSizeData.kind==="composite"){const{minZoom:I,maxZoom:k}=r.bucket.iconSizeData;A.compositeIconSizes=[s["icon-size"].possiblyEvaluate(new ze(I),r.canonical),s["icon-size"].possiblyEvaluate(new ze(k),r.canonical)]}const d=i.get("text-line-height")*ns,_=i.get("text-rotation-alignment")!=="viewport"&&i.get("symbol-placement")!=="point",b=i.get("text-keep-upright"),M=i.get("text-size");for(const I of r.bucket.features){const k=i.get("text-font").evaluate(I,{},r.canonical).join(","),F=M.evaluate(I,{},r.canonical),V=A.layoutTextSize.evaluate(I,{},r.canonical),j=A.layoutIconSize.evaluate(I,{},r.canonical),H={horizontal:{},vertical:void 0},Q=I.text;let Y,re=[0,0];if(Q){const ue=Q.toString(),ve=i.get("text-letter-spacing").evaluate(I,{},r.canonical)*ns,Te=O(ue)?ve:0,Ue=i.get("text-anchor").evaluate(I,{},r.canonical),lt=zd(e,I,r.canonical);if(!lt){const mt=i.get("text-radial-offset").evaluate(I,{},r.canonical);re=mt?kd(Ue,[mt*ns,vA]):i.get("text-offset").evaluate(I,{},r.canonical).map((st=>st*ns))}let nt=_?"center":i.get("text-justify").evaluate(I,{},r.canonical);const dt=i.get("symbol-placement")==="point"?i.get("text-max-width").evaluate(I,{},r.canonical)*ns:1/0,Tt=()=>{r.bucket.allowVerticalPlacement&&z(ue)&&(H.vertical=ac(Q,r.glyphMap,r.glyphPositions,r.imagePositions,k,dt,d,Ue,"left",Te,re,W.az.vertical,!0,V,F))};if(!_&&lt){const mt=new Set;if(nt==="auto")for(let Xe=0;Xe<lt.values.length;Xe+=2)mt.add(xA(lt.values[Xe]));else mt.add(nt);let st=!1;for(const Xe of mt)if(!H.horizontal[Xe])if(st)H.horizontal[Xe]=H.horizontal[0];else{const Lt=ac(Q,r.glyphMap,r.glyphPositions,r.imagePositions,k,dt,d,"center",Xe,Te,re,W.az.horizontal,!1,V,F);Lt&&(H.horizontal[Xe]=Lt,st=Lt.positionedLines.length===1)}Tt()}else{nt==="auto"&&(nt=xA(Ue));const mt=ac(Q,r.glyphMap,r.glyphPositions,r.imagePositions,k,dt,d,Ue,nt,Te,re,W.az.horizontal,!1,V,F);mt&&(H.horizontal[nt]=mt),Tt(),z(ue)&&_&&b&&(H.vertical=ac(Q,r.glyphMap,r.glyphPositions,r.imagePositions,k,dt,d,Ue,nt,Te,re,W.az.vertical,!1,V,F))}}let ge=!1;if(I.icon&&I.icon.name){const ue=r.imageMap[I.icon.name];ue&&(Y=j0(r.imagePositions[I.icon.name],i.get("icon-offset").evaluate(I,{},r.canonical),i.get("icon-anchor").evaluate(I,{},r.canonical)),ge=!!ue.sdf,r.bucket.sdfIcons===void 0?r.bucket.sdfIcons=ge:r.bucket.sdfIcons!==ge&&en("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(ue.pixelRatio!==r.bucket.pixelRatio||i.get("icon-rotate").constantOr(1)!==0)&&(r.bucket.iconsNeedLinear=!0))}const oe=Bd(H.horizontal)||H.vertical;r.bucket.iconsInText=!!oe&&oe.iconsInText,(oe||Y)&&Im(r.bucket,I,H,Y,r.imageMap,A,V,j,re,ge,r.canonical,r.subdivisionGranularity)}r.showCollisionBoxes&&r.bucket.generateCollisionDebugBuffers()},W.cR=Uc,W.cS=qc,W.cT=Hc,W.cU=function(r){const e=new oc;return(function(i,s){for(const A in i.layers)s.writeMessage(3,mm,i.layers[A])})(r,e),e.finish()},W.cV=function(r,e,i,s,A,d){let _=wd(r,e,i,A,0);return _=wd(_,e,s,d,1),_},W.cW=class{constructor(r){this.maxEntries=r,this.map=new Map}get(r){const e=this.map.get(r);return e!==void 0&&(this.map.delete(r),this.map.set(r,e)),e}set(r,e){if(this.map.has(r))this.map.delete(r);else if(this.map.size>=this.maxEntries){const i=this.map.keys().next().value;this.map.delete(i)}this.map.set(r,e)}clear(){this.map.clear()}},W.cX=sf,W.cY=oc,W.cZ=gd,W.c_=class{constructor(r){this._marks={start:[r.url,"start"].join("#"),end:[r.url,"end"].join("#"),measure:r.url.toString()},performance.mark(this._marks.start)}finish(){performance.mark(this._marks.end);let r=performance.getEntriesByName(this._marks.measure);return r.length===0&&(performance.measure(this._marks.measure,this._marks.start,this._marks.end),r=performance.getEntriesByName(this._marks.measure),performance.clearMarks(this._marks.start),performance.clearMarks(this._marks.end),performance.clearMeasures(this._marks.measure)),r}},W.ca=class extends Il{},W.cb=y0,W.cc=class extends Pu{},W.cd=Oc,W.ce=function(r){return r<=1?1:Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))},W.cf=UA,W.cg=function(r,e,i){var s=e[0],A=e[1],d=e[2],_=i[3]*s+i[7]*A+i[11]*d+i[15];return r[0]=(i[0]*s+i[4]*A+i[8]*d+i[12])/(_=_||1),r[1]=(i[1]*s+i[5]*A+i[9]*d+i[13])/_,r[2]=(i[2]*s+i[6]*A+i[10]*d+i[14])/_,r},W.ch=class extends ph{},W.ci=class extends t{},W.cj=function(r,e){return r[0]===e[0]&&r[1]===e[1]&&r[2]===e[2]&&r[3]===e[3]&&r[4]===e[4]&&r[5]===e[5]&&r[6]===e[6]&&r[7]===e[7]&&r[8]===e[8]&&r[9]===e[9]&&r[10]===e[10]&&r[11]===e[11]&&r[12]===e[12]&&r[13]===e[13]&&r[14]===e[14]&&r[15]===e[15]},W.ck=function(r,e){var i=r[0],s=r[1],A=r[2],d=r[3],_=r[4],b=r[5],M=r[6],I=r[7],k=r[8],F=r[9],V=r[10],j=r[11],H=r[12],Q=r[13],Y=r[14],re=r[15],ge=e[0],oe=e[1],ue=e[2],ve=e[3],Te=e[4],Ue=e[5],lt=e[6],nt=e[7],dt=e[8],Tt=e[9],mt=e[10],st=e[11],Xe=e[12],Lt=e[13],Ct=e[14],Ot=e[15];return Math.abs(i-ge)<=hr*Math.max(1,Math.abs(i),Math.abs(ge))&&Math.abs(s-oe)<=hr*Math.max(1,Math.abs(s),Math.abs(oe))&&Math.abs(A-ue)<=hr*Math.max(1,Math.abs(A),Math.abs(ue))&&Math.abs(d-ve)<=hr*Math.max(1,Math.abs(d),Math.abs(ve))&&Math.abs(_-Te)<=hr*Math.max(1,Math.abs(_),Math.abs(Te))&&Math.abs(b-Ue)<=hr*Math.max(1,Math.abs(b),Math.abs(Ue))&&Math.abs(M-lt)<=hr*Math.max(1,Math.abs(M),Math.abs(lt))&&Math.abs(I-nt)<=hr*Math.max(1,Math.abs(I),Math.abs(nt))&&Math.abs(k-dt)<=hr*Math.max(1,Math.abs(k),Math.abs(dt))&&Math.abs(F-Tt)<=hr*Math.max(1,Math.abs(F),Math.abs(Tt))&&Math.abs(V-mt)<=hr*Math.max(1,Math.abs(V),Math.abs(mt))&&Math.abs(j-st)<=hr*Math.max(1,Math.abs(j),Math.abs(st))&&Math.abs(H-Xe)<=hr*Math.max(1,Math.abs(H),Math.abs(Xe))&&Math.abs(Q-Lt)<=hr*Math.max(1,Math.abs(Q),Math.abs(Lt))&&Math.abs(Y-Ct)<=hr*Math.max(1,Math.abs(Y),Math.abs(Ct))&&Math.abs(re-Ot)<=hr*Math.max(1,Math.abs(re),Math.abs(Ot))},W.cl=function(r,e){return r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=e[3],r[4]=e[4],r[5]=e[5],r[6]=e[6],r[7]=e[7],r[8]=e[8],r[9]=e[9],r[10]=e[10],r[11]=e[11],r[12]=e[12],r[13]=e[13],r[14]=e[14],r[15]=e[15],r},W.cm=r=>r.type==="symbol",W.cn=r=>r.type==="circle",W.co=r=>r.type==="heatmap",W.cp=r=>r.type==="line",W.cq=r=>r.type==="fill",W.cr=r=>r.type==="fill-extrusion",W.cs=r=>r.type==="hillshade",W.ct=r=>r.type==="color-relief",W.cu=r=>r.type==="background",W.cv=r=>r.type==="custom",W.cw=or,W.cx=function(r,e,i){const s=ti(e.x-i.x,e.y-i.y),A=ti(r.x-i.x,r.y-i.y),d=Math.atan2(s[0]*A[1]-s[1]*A[0],(function(_,b){return _[0]*b[0]+_[1]*b[1]})(s,A));return mn(d)},W.cy=xi,W.cz=function(r,e){return ee[e]&&(r instanceof MouseEvent||r instanceof WheelEvent)},W.d=ot,W.d0=HA,W.d1=ur,W.d2=class{constructor(r,e){this.layers={[Oh]:this},this.name=Oh,this.version=e?e.version:1,this.extent=e?e.extent:4096,this.length=r.length,this.features=r}feature(r){return new pm(this.features[r],this.extent)}},W.d3=u,W.d4=Oe,W.e=Er,W.f=r=>p(void 0,void 0,void 0,(function*(){if(r.byteLength===0)return createImageBitmap(new ImageData(1,1));const e=new Blob([new Uint8Array(r)],{type:"image/png"});try{return createImageBitmap(e)}catch(i){throw new Error(`Could not load image because of ${i.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}})),W.g=Ge,W.h=r=>new Promise(((e,i)=>{const s=new Image;s.onload=()=>{e(s),URL.revokeObjectURL(s.src),s.onload=null,window.requestAnimationFrame((()=>{s.src=jo}))},s.onerror=()=>i(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const A=new Blob([new Uint8Array(r)],{type:"image/png"});s.src=r.byteLength?URL.createObjectURL(A):jo})),W.i=Is,W.j=(r,e)=>ft(Er(r,{type:"json"}),e),W.k=Gi,W.l=Xt,W.m=ft,W.n=(r,e)=>ft(Er(r,{type:"arrayBuffer"}),e),W.o=function(r){return new oc(r).readFields(z0,[])},W.p=bf,W.q=function(r){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(r))},W.r=Th,W.s=vo,W.t=is,W.u=qe,W.v=hl,W.w=en,W.x=ai,W.y=yt,W.z=bt})),We("worker",["./shared"],(function(W){class p{constructor(ee,K){this.keyCache={},ee&&this.replace(ee,K)}replace(ee,K){this._layerConfigs={},this._layers={},this.update(ee,[],K)}update(ee,K,le){for(const Se of ee){this._layerConfigs[Se.id]=Se;const Ge=this._layers[Se.id]=W.bT(Se,le);Ge._featureFilter=W.aj(Ge.filter,le),this.keyCache[Se.id]&&delete this.keyCache[Se.id]}for(const Se of K)delete this.keyCache[Se],delete this._layerConfigs[Se],delete this._layers[Se];this.familiesBySource={};const Me=W.cL(Object.values(this._layerConfigs),this.keyCache);for(const Se of Me){const Ge=Se.map((St=>this._layers[St.id])),Fe=Ge[0];if(Fe.isHidden())continue;const ke=Fe.source||"";let Qe=this.familiesBySource[ke];Qe||(Qe=this.familiesBySource[ke]={});const ft=Fe.sourceLayer||W.ai;let ot=Qe[ft];ot||(ot=Qe[ft]=[]),ot.push(Ge)}}}class it{constructor(ee){const K={},le=[];for(const Fe in ee){const ke=ee[Fe],Qe=K[Fe]={};for(const ft in ke){const ot=ke[+ft];if(!ot||ot.bitmap.width===0||ot.bitmap.height===0)continue;const St={x:0,y:0,w:ot.bitmap.width+2,h:ot.bitmap.height+2};le.push(St),Qe[ft]={rect:St,metrics:ot.metrics}}}const{w:Me,h:Se}=W.p(le),Ge=new W.r({width:Me||1,height:Se||1});for(const Fe in ee){const ke=ee[Fe];for(const Qe in ke){const ft=ke[+Qe];if(!ft||ft.bitmap.width===0||ft.bitmap.height===0)continue;const ot=K[Fe][Qe].rect;W.r.copy(ft.bitmap,Ge,{x:0,y:0},{x:ot.x+1,y:ot.y+1},ft.bitmap)}}this.image=Ge,this.positions=K}}W.cM("GlyphAtlas",it);class ur{constructor(ee){this.tileID=new W.a2(ee.tileID.overscaledZ,ee.tileID.wrap,ee.tileID.canonical.z,ee.tileID.canonical.x,ee.tileID.canonical.y),this.uid=ee.uid,this.zoom=ee.zoom,this.pixelRatio=ee.pixelRatio,this.tileSize=ee.tileSize,this.source=ee.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=ee.showCollisionBoxes,this.collectResourceTiming=!!ee.collectResourceTiming,this.returnDependencies=!!ee.returnDependencies,this.promoteId=ee.promoteId,this.inFlightDependencies=[]}parse(ee,K,le,Me,Se){return W._(this,void 0,void 0,(function*(){this.status="parsing",this.data=ee,this.collisionBoxArray=new W.ag;const Ge=new W.cN(Object.keys(ee.layers).sort()),Fe=new W.cO(this.tileID,this.promoteId);Fe.bucketLayerIDs=[];const ke={},Qe={featureIndex:Fe,iconDependencies:{},patternDependencies:{},glyphDependencies:{},dashDependencies:{},availableImages:le,subdivisionGranularity:Se},ft=K.familiesBySource[this.source];for(const Ve in ft){const at=ee.layers[Ve];if(!at)continue;at.version===1&&W.w(`Vector tile source "${this.source}" layer "${Ve}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const It=Ge.encode(Ve),At=[];for(let o=0;o<at.length;o++){const X=at.feature(o),ii=Fe.getId(X,Ve);At.push({feature:X,id:ii,index:o,sourceLayerIndex:It})}for(const o of ft[Ve]){const X=o[0];X.source!==this.source&&W.w(`layer.source = ${X.source} does not equal this.source = ${this.source}`),X.isHidden(this.zoom,!0)||(fr(o,this.zoom,le),(ke[X.id]=X.createBucket({index:Fe.bucketLayerIDs.length,layers:o,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:It,sourceID:this.source})).populate(At,Qe,this.tileID.canonical),Fe.bucketLayerIDs.push(o.map((ii=>ii.id))))}}const ot=W.bY(Qe.glyphDependencies,(Ve=>Object.keys(Ve).map(Number)));this.inFlightDependencies.forEach((Ve=>Ve==null?void 0:Ve.abort())),this.inFlightDependencies=[];let St=Promise.resolve({});if(Object.keys(ot).length){const Ve=new AbortController;this.inFlightDependencies.push(Ve),St=Me.sendAsync({type:"GG",data:{stacks:ot,source:this.source,tileID:this.tileID,type:"glyphs"}},Ve)}const je=Object.keys(Qe.iconDependencies);let Xt=Promise.resolve({});if(je.length){const Ve=new AbortController;this.inFlightDependencies.push(Ve),Xt=Me.sendAsync({type:"GI",data:{icons:je,source:this.source,tileID:this.tileID,type:"icons"}},Ve)}const Gi=Object.keys(Qe.patternDependencies);let Bi=Promise.resolve({});if(Gi.length){const Ve=new AbortController;this.inFlightDependencies.push(Ve),Bi=Me.sendAsync({type:"GI",data:{icons:Gi,source:this.source,tileID:this.tileID,type:"patterns"}},Ve)}const qe=Qe.dashDependencies;let Hi=Promise.resolve({});if(Object.keys(qe).length){const Ve=new AbortController;this.inFlightDependencies.push(Ve),Hi=Me.sendAsync({type:"GDA",data:{dashes:qe}},Ve)}const[rn,Kt,qi,Vr]=yield Promise.all([St,Xt,Bi,Hi]),Wi=new it(rn),er=new W.cP(Kt,qi);for(const Ve in ke){const at=ke[Ve];at instanceof W.ah?(fr(at.layers,this.zoom,le),W.cQ({bucket:at,glyphMap:rn,glyphPositions:Wi.positions,imageMap:Kt,imagePositions:er.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:Qe.subdivisionGranularity})):at.hasDependencies&&(at instanceof W.cR||at instanceof W.cS||at instanceof W.cT)&&(fr(at.layers,this.zoom,le),at.addFeatures(Qe,this.tileID.canonical,er.patternPositions,Vr))}return this.status="done",{buckets:Object.values(ke).filter((Ve=>!Ve.isEmpty())),featureIndex:Fe,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:Wi.image,imageAtlas:er,dashPositions:Vr,glyphMap:this.returnDependencies?rn:null,iconMap:this.returnDependencies?Kt:null,glyphPositions:this.returnDependencies?Wi.positions:null}}))}}function fr(Ne,ee,K){const le=new W.H(ee);for(const Me of Ne)Me.recalculate(le,K)}class Zi{constructor(ee,K,le,Me,Se){this.type=ee,this.properties=le||{},this.extent=Se,this.pointsArray=K,this.id=Me}loadGeometry(){return this.pointsArray.map((ee=>ee.map((K=>new W.P(K.x,K.y)))))}}class un{constructor(ee,K,le){this.version=2,this._myFeatures=ee,this.name=K,this.length=ee.length,this.extent=le}feature(ee){return this._myFeatures[ee]}}class zr{constructor(){this.layers={}}addLayer(ee){this.layers[ee.name]=ee}}function Mn(Ne){let ee=W.cU(Ne);return ee.byteOffset===0&&ee.byteLength===ee.buffer.byteLength||(ee=new Uint8Array(ee)),{vectorTile:Ne,rawData:ee.buffer}}function Gt(Ne,ee,K){const{extent:le}=Ne,Me=Math.pow(2,K.z-ee.z),Se=(K.x-ee.x*Me)*le,Ge=(K.y-ee.y*Me)*le,Fe=[];for(let ke=0;ke<Ne.length;ke++){const Qe=Ne.feature(ke);let ft=Qe.loadGeometry();for(const St of ft)for(const je of St)je.x=je.x*Me-Se,je.y=je.y*Me-Ge;const ot=128;ft=W.cV(ft,Qe.type,-ot,-ot,le+ot,le+ot),ft.length!==0&&Fe.push(new Zi(Qe.type,ft,Qe.properties,Qe.id,le))}return new un(Fe,Ne.name,le)}class rt{constructor(ee,K,le){this.actor=ee,this.layerIndex=K,this.availableImages=le,this.fetching={},this.loading={},this.loaded={},this.overzoomedTileResultCache=new W.cW(1e3)}loadVectorTile(ee,K){return W._(this,void 0,void 0,(function*(){const le=yield W.n(ee.request,K);try{return{vectorTile:ee.encoding!=="mlt"?new W.cX(new W.cY(le.data)):new W.cZ(le.data),rawData:le.data,cacheControl:le.cacheControl,expires:le.expires}}catch(Me){const Se=new Uint8Array(le.data);let Ge=`Unable to parse the tile at ${ee.request.url}, `;throw Ge+=Se[0]===31&&Se[1]===139?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${Me.message}`,new Error(Ge)}}))}loadTile(ee){return W._(this,void 0,void 0,(function*(){const{uid:K,overzoomParameters:le}=ee;le&&(ee.request=le.overzoomRequest);const Me=!!(ee&&ee.request&&ee.request.collectResourceTiming)&&new W.c_(ee.request),Se=new ur(ee);this.loading[K]=Se;const Ge=new AbortController;Se.abort=Ge;try{const Fe=yield this.loadVectorTile(ee,Ge);if(delete this.loading[K],!Fe)return null;if(le){const St=this._getOverzoomTile(ee,Fe.vectorTile);Fe.rawData=St.rawData,Fe.vectorTile=St.vectorTile}const ke=Fe.rawData,Qe={};Fe.expires&&(Qe.expires=Fe.expires),Fe.cacheControl&&(Qe.cacheControl=Fe.cacheControl);const ft={};if(Me){const St=Me.finish();St&&(ft.resourceTiming=JSON.parse(JSON.stringify(St)))}Se.vectorTile=Fe.vectorTile;const ot=Se.parse(Fe.vectorTile,this.layerIndex,this.availableImages,this.actor,ee.subdivisionGranularity);this.loaded[K]=Se,this.fetching[K]={rawTileData:ke,cacheControl:Qe,resourceTiming:ft};try{const St=yield ot;return W.e({rawTileData:ke.slice(0),encoding:ee.encoding},St,Qe,ft)}finally{delete this.fetching[K]}}catch(Fe){throw delete this.loading[K],Se.status="done",this.loaded[K]=Se,Fe}}))}_getOverzoomTile(ee,K){const{tileID:le,source:Me,overzoomParameters:Se}=ee,{maxZoomTileID:Ge}=Se,Fe=`${Ge.key}_${le.key}`,ke=this.overzoomedTileResultCache.get(Fe);if(ke)return ke;const Qe=new zr,ft=this.layerIndex.familiesBySource[Me];for(const St in ft){const je=K.layers[St];if(!je)continue;const Xt=Gt(je,Ge,le.canonical);Xt.length>0&&Qe.addLayer(Xt)}const ot=Mn(Qe);return this.overzoomedTileResultCache.set(Fe,ot),ot}reloadTile(ee){return W._(this,void 0,void 0,(function*(){const K=ee.uid;if(!this.loaded||!this.loaded[K])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");const le=this.loaded[K];if(le.showCollisionBoxes=ee.showCollisionBoxes,le.status==="parsing"){const Me=yield le.parse(le.vectorTile,this.layerIndex,this.availableImages,this.actor,ee.subdivisionGranularity);let Se;if(this.fetching[K]){const{rawTileData:Ge,cacheControl:Fe,resourceTiming:ke}=this.fetching[K];delete this.fetching[K],Se=W.e({rawTileData:Ge.slice(0),encoding:ee.encoding},Me,Fe,ke)}else Se=Me;return Se}if(le.status==="done"&&le.vectorTile)return le.parse(le.vectorTile,this.layerIndex,this.availableImages,this.actor,ee.subdivisionGranularity)}))}abortTile(ee){return W._(this,void 0,void 0,(function*(){const K=this.loading,le=ee.uid;K&&K[le]&&K[le].abort&&(K[le].abort.abort(),delete K[le])}))}removeTile(ee){return W._(this,void 0,void 0,(function*(){this.loaded&&this.loaded[ee.uid]&&delete this.loaded[ee.uid]}))}}class Fo{constructor(){this.loaded={}}loadTile(ee){return W._(this,void 0,void 0,(function*(){const{uid:K,encoding:le,rawImageData:Me,redFactor:Se,greenFactor:Ge,blueFactor:Fe,baseShift:ke}=ee,Qe=Me.width+2,ft=Me.height+2,ot=W.b(Me)?new W.R({width:Qe,height:ft},yield W.c$(Me,-1,-1,Qe,ft)):Me,St=new W.d0(K,ot,le,Se,Ge,Fe,ke);return this.loaded=this.loaded||{},this.loaded[K]=St,St}))}removeTile(ee){const K=this.loaded,le=ee.uid;K&&K[le]&&delete K[le]}}var hr,zi,ro=(function(){if(zi)return hr;function Ne(K,le){if(K.length!==0){ee(K[0],le);for(var Me=1;Me<K.length;Me++)ee(K[Me],!le)}}function ee(K,le){for(var Me=0,Se=0,Ge=0,Fe=K.length,ke=Fe-1;Ge<Fe;ke=Ge++){var Qe=(K[Ge][0]-K[ke][0])*(K[ke][1]+K[Ge][1]),ft=Me+Qe;Se+=Math.abs(Me)>=Math.abs(Qe)?Me-ft+Qe:Qe-ft+Me,Me=ft}Me+Se>=0!=!!le&&K.reverse()}return zi=1,hr=function K(le,Me){var Se,Ge=le&&le.type;if(Ge==="FeatureCollection")for(Se=0;Se<le.features.length;Se++)K(le.features[Se],Me);else if(Ge==="GeometryCollection")for(Se=0;Se<le.geometries.length;Se++)K(le.geometries[Se],Me);else if(Ge==="Feature")K(le.geometry,Me);else if(Ge==="Polygon")Ne(le.coordinates,Me);else if(Ge==="MultiPolygon")for(Se=0;Se<le.coordinates.length;Se++)Ne(le.coordinates[Se],Me);return le}})(),no=W.d1(ro);const Ns={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:Ne=>Ne},En=Math.fround||(Oo=new Float32Array(1),Ne=>(Oo[0]=+Ne,Oo[0]));var Oo;class Vs{constructor(ee){this.options=Object.assign(Object.create(Ns),ee),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(ee){const{log:K,minZoom:le,maxZoom:Me}=this.options;K&&console.time("total time");const Se=`prepare ${ee.length} points`;K&&console.time(Se),this.points=ee;const Ge=[];for(let ke=0;ke<ee.length;ke++){const Qe=ee[ke];if(!Qe.geometry)continue;const[ft,ot]=Qe.geometry.coordinates,St=En(Ji(ft)),je=En(Sn(ot));Ge.push(St,je,1/0,ke,-1,1),this.options.reduce&&Ge.push(0)}let Fe=this.trees[Me+1]=this._createTree(Ge);K&&console.timeEnd(Se);for(let ke=Me;ke>=le;ke--){const Qe=+Date.now();Fe=this.trees[ke]=this._createTree(this._cluster(Fe,ke)),K&&console.log("z%d: %d clusters in %dms",ke,Fe.numItems,+Date.now()-Qe)}return K&&console.timeEnd("total time"),this}getClusters(ee,K){let le=((ee[0]+180)%360+360)%360-180;const Me=Math.max(-90,Math.min(90,ee[1]));let Se=ee[2]===180?180:((ee[2]+180)%360+360)%360-180;const Ge=Math.max(-90,Math.min(90,ee[3]));if(ee[2]-ee[0]>=360)le=-180,Se=180;else if(le>Se){const ot=this.getClusters([le,Me,180,Ge],K),St=this.getClusters([-180,Me,Se,Ge],K);return ot.concat(St)}const Fe=this.trees[this._limitZoom(K)],ke=Fe.range(Ji(le),Sn(Ge),Ji(Se),Sn(Me)),Qe=Fe.data,ft=[];for(const ot of ke){const St=this.stride*ot;ft.push(Qe[St+5]>1?Cs(Qe,St,this.clusterProps):this.points[Qe[St+3]])}return ft}getChildren(ee){const K=this._getOriginId(ee),le=this._getOriginZoom(ee),Me="No cluster with the specified id.",Se=this.trees[le];if(!Se)throw new Error(Me);const Ge=Se.data;if(K*this.stride>=Ge.length)throw new Error(Me);const Fe=this.options.radius/(this.options.extent*Math.pow(2,le-1)),ke=Se.within(Ge[K*this.stride],Ge[K*this.stride+1],Fe),Qe=[];for(const ft of ke){const ot=ft*this.stride;Ge[ot+4]===ee&&Qe.push(Ge[ot+5]>1?Cs(Ge,ot,this.clusterProps):this.points[Ge[ot+3]])}if(Qe.length===0)throw new Error(Me);return Qe}getLeaves(ee,K,le){const Me=[];return this._appendLeaves(Me,ee,K=K||10,le=le||0,0),Me}getTile(ee,K,le){const Me=this.trees[this._limitZoom(ee)],Se=Math.pow(2,ee),{extent:Ge,radius:Fe}=this.options,ke=Fe/Ge,Qe=(le-ke)/Se,ft=(le+1+ke)/Se,ot={features:[]};return this._addTileFeatures(Me.range((K-ke)/Se,Qe,(K+1+ke)/Se,ft),Me.data,K,le,Se,ot),K===0&&this._addTileFeatures(Me.range(1-ke/Se,Qe,1,ft),Me.data,Se,le,Se,ot),K===Se-1&&this._addTileFeatures(Me.range(0,Qe,ke/Se,ft),Me.data,-1,le,Se,ot),ot.features.length?ot:null}getClusterExpansionZoom(ee){let K=this._getOriginZoom(ee)-1;for(;K<=this.options.maxZoom;){const le=this.getChildren(ee);if(K++,le.length!==1)break;ee=le[0].properties.cluster_id}return K}_appendLeaves(ee,K,le,Me,Se){const Ge=this.getChildren(K);for(const Fe of Ge){const ke=Fe.properties;if(ke&&ke.cluster?Se+ke.point_count<=Me?Se+=ke.point_count:Se=this._appendLeaves(ee,ke.cluster_id,le,Me,Se):Se<Me?Se++:ee.push(Fe),ee.length===le)break}return Se}_createTree(ee){const K=new W.aT(ee.length/this.stride|0,this.options.nodeSize,Float32Array);for(let le=0;le<ee.length;le+=this.stride)K.add(ee[le],ee[le+1]);return K.finish(),K.data=ee,K}_addTileFeatures(ee,K,le,Me,Se,Ge){for(const Fe of ee){const ke=Fe*this.stride,Qe=K[ke+5]>1;let ft,ot,St;if(Qe)ft=cr(K,ke,this.clusterProps),ot=K[ke],St=K[ke+1];else{const Gi=this.points[K[ke+3]];ft=Gi.properties;const[Bi,qe]=Gi.geometry.coordinates;ot=Ji(Bi),St=Sn(qe)}const je={type:1,geometry:[[Math.round(this.options.extent*(ot*Se-le)),Math.round(this.options.extent*(St*Se-Me))]],tags:ft};let Xt;Xt=Qe||this.options.generateId?K[ke+3]:this.points[K[ke+3]].id,Xt!==void 0&&(je.id=Xt),Ge.features.push(je)}}_limitZoom(ee){return Math.max(this.options.minZoom,Math.min(Math.floor(+ee),this.options.maxZoom+1))}_cluster(ee,K){const{radius:le,extent:Me,reduce:Se,minPoints:Ge}=this.options,Fe=le/(Me*Math.pow(2,K)),ke=ee.data,Qe=[],ft=this.stride;for(let ot=0;ot<ke.length;ot+=ft){if(ke[ot+2]<=K)continue;ke[ot+2]=K;const St=ke[ot],je=ke[ot+1],Xt=ee.within(ke[ot],ke[ot+1],Fe),Gi=ke[ot+5];let Bi=Gi;for(const qe of Xt){const Hi=qe*ft;ke[Hi+2]>K&&(Bi+=ke[Hi+5])}if(Bi>Gi&&Bi>=Ge){let qe,Hi=St*Gi,rn=je*Gi,Kt=-1;const qi=(ot/ft<<5)+(K+1)+this.points.length;for(const Vr of Xt){const Wi=Vr*ft;if(ke[Wi+2]<=K)continue;ke[Wi+2]=K;const er=ke[Wi+5];Hi+=ke[Wi]*er,rn+=ke[Wi+1]*er,ke[Wi+4]=qi,Se&&(qe||(qe=this._map(ke,ot,!0),Kt=this.clusterProps.length,this.clusterProps.push(qe)),Se(qe,this._map(ke,Wi)))}ke[ot+4]=qi,Qe.push(Hi/Bi,rn/Bi,1/0,qi,-1,Bi),Se&&Qe.push(Kt)}else{for(let qe=0;qe<ft;qe++)Qe.push(ke[ot+qe]);if(Bi>1)for(const qe of Xt){const Hi=qe*ft;if(!(ke[Hi+2]<=K)){ke[Hi+2]=K;for(let rn=0;rn<ft;rn++)Qe.push(ke[Hi+rn])}}}}return Qe}_getOriginId(ee){return ee-this.points.length>>5}_getOriginZoom(ee){return(ee-this.points.length)%32}_map(ee,K,le){if(ee[K+5]>1){const Ge=this.clusterProps[ee[K+6]];return le?Object.assign({},Ge):Ge}const Me=this.points[ee[K+3]].properties,Se=this.options.map(Me);return le&&Se===Me?Object.assign({},Se):Se}}function Cs(Ne,ee,K){return{type:"Feature",id:Ne[ee+3],properties:cr(Ne,ee,K),geometry:{type:"Point",coordinates:[(le=Ne[ee],360*(le-.5)),Cn(Ne[ee+1])]}};var le}function cr(Ne,ee,K){const le=Ne[ee+5],Me=le>=1e4?`${Math.round(le/1e3)}k`:le>=1e3?Math.round(le/100)/10+"k":le,Se=Ne[ee+6],Ge=Se===-1?{}:Object.assign({},K[Se]);return Object.assign(Ge,{cluster:!0,cluster_id:Ne[ee+3],point_count:le,point_count_abbreviated:Me})}function Ji(Ne){return Ne/360+.5}function Sn(Ne){const ee=Math.sin(Ne*Math.PI/180),K=.5-.25*Math.log((1+ee)/(1-ee))/Math.PI;return K<0?0:K>1?1:K}function Cn(Ne){const ee=(180-360*Ne)*Math.PI/180;return 360*Math.atan(Math.exp(ee))/Math.PI-90}function Un(Ne,ee,K,le){let Me=le;const Se=ee+(K-ee>>1);let Ge,Fe=K-ee;const ke=Ne[ee],Qe=Ne[ee+1],ft=Ne[K],ot=Ne[K+1];for(let St=ee+3;St<K;St+=3){const je=Jr(Ne[St],Ne[St+1],ke,Qe,ft,ot);if(je>Me)Ge=St,Me=je;else if(je===Me){const Xt=Math.abs(St-Se);Xt<Fe&&(Ge=St,Fe=Xt)}}Me>le&&(Ge-ee>3&&Un(Ne,ee,Ge,le),Ne[Ge+2]=Me,K-Ge>3&&Un(Ne,Ge,K,le))}function Jr(Ne,ee,K,le,Me,Se){let Ge=Me-K,Fe=Se-le;if(Ge!==0||Fe!==0){const ke=((Ne-K)*Ge+(ee-le)*Fe)/(Ge*Ge+Fe*Fe);ke>1?(K=Me,le=Se):ke>0&&(K+=Ge*ke,le+=Fe*ke)}return Ge=Ne-K,Fe=ee-le,Ge*Ge+Fe*Fe}function Hr(Ne,ee,K,le){const Me={id:Ne??null,type:ee,geometry:K,tags:le,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(ee==="Point"||ee==="MultiPoint"||ee==="LineString")ti(Me,K);else if(ee==="Polygon")ti(Me,K[0]);else if(ee==="MultiLineString")for(const Se of K)ti(Me,Se);else if(ee==="MultiPolygon")for(const Se of K)ti(Me,Se[0]);return Me}function ti(Ne,ee){for(let K=0;K<ee.length;K+=3)Ne.minX=Math.min(Ne.minX,ee[K]),Ne.minY=Math.min(Ne.minY,ee[K+1]),Ne.maxX=Math.max(Ne.maxX,ee[K]),Ne.maxY=Math.max(Ne.maxY,ee[K+1])}function Oi(Ne,ee,K,le){if(!ee.geometry)return;const Me=ee.geometry.coordinates;if(Me&&Me.length===0)return;const Se=ee.geometry.type,Ge=Math.pow(K.tolerance/((1<<K.maxZoom)*K.extent),2);let Fe=[],ke=ee.id;if(K.promoteId?ke=ee.properties[K.promoteId]:K.generateId&&(ke=le||0),Se==="Point")Yt(Me,Fe);else if(Se==="MultiPoint")for(const Qe of Me)Yt(Qe,Fe);else if(Se==="LineString")Ni(Me,Fe,Ge,!1);else if(Se==="MultiLineString"){if(K.lineMetrics){for(const Qe of Me)Fe=[],Ni(Qe,Fe,Ge,!1),Ne.push(Hr(ke,"LineString",Fe,ee.properties));return}Mr(Me,Fe,Ge,!1)}else if(Se==="Polygon")Mr(Me,Fe,Ge,!0);else{if(Se!=="MultiPolygon"){if(Se==="GeometryCollection"){for(const Qe of ee.geometry.geometries)Oi(Ne,{id:ke,geometry:Qe,properties:ee.properties},K,le);return}throw new Error("Input data is not a valid GeoJSON object.")}for(const Qe of Me){const ft=[];Mr(Qe,ft,Ge,!0),Fe.push(ft)}}Ne.push(Hr(ke,Se,Fe,ee.properties))}function Yt(Ne,ee){ee.push(Wr(Ne[0]),or(Ne[1]),0)}function Ni(Ne,ee,K,le){let Me,Se,Ge=0;for(let ke=0;ke<Ne.length;ke++){const Qe=Wr(Ne[ke][0]),ft=or(Ne[ke][1]);ee.push(Qe,ft,0),ke>0&&(Ge+=le?(Me*ft-Qe*Se)/2:Math.sqrt(Math.pow(Qe-Me,2)+Math.pow(ft-Se,2))),Me=Qe,Se=ft}const Fe=ee.length-3;ee[2]=1,Un(ee,0,Fe,K),ee[Fe+2]=1,ee.size=Math.abs(Ge),ee.start=0,ee.end=ee.size}function Mr(Ne,ee,K,le){for(let Me=0;Me<Ne.length;Me++){const Se=[];Ni(Ne[Me],Se,K,le),ee.push(Se)}}function Wr(Ne){return Ne/360+.5}function or(Ne){const ee=Math.sin(Ne*Math.PI/180),K=.5-.25*Math.log((1+ee)/(1-ee))/Math.PI;return K<0?0:K>1?1:K}function xi(Ne,ee,K,le,Me,Se,Ge,Fe){if(le/=ee,Se>=(K/=ee)&&Ge<le)return Ne;if(Ge<K||Se>=le)return null;const ke=[];for(const Qe of Ne){const ft=Qe.geometry;let ot=Qe.type;const St=Me===0?Qe.minX:Qe.minY,je=Me===0?Qe.maxX:Qe.maxY;if(St>=K&&je<le){ke.push(Qe);continue}if(je<K||St>=le)continue;let Xt=[];if(ot==="Point"||ot==="MultiPoint")Ai(ft,Xt,K,le,Me);else if(ot==="LineString")hn(ft,Xt,K,le,Me,!1,Fe.lineMetrics);else if(ot==="MultiLineString")yo(ft,Xt,K,le,Me,!1);else if(ot==="Polygon")yo(ft,Xt,K,le,Me,!0);else if(ot==="MultiPolygon")for(const Gi of ft){const Bi=[];yo(Gi,Bi,K,le,Me,!0),Bi.length&&Xt.push(Bi)}if(Xt.length){if(Fe.lineMetrics&&ot==="LineString"){for(const Gi of Xt)ke.push(Hr(Qe.id,ot,Gi,Qe.tags));continue}ot!=="LineString"&&ot!=="MultiLineString"||(Xt.length===1?(ot="LineString",Xt=Xt[0]):ot="MultiLineString"),ot!=="Point"&&ot!=="MultiPoint"||(ot=Xt.length===3?"Point":"MultiPoint"),ke.push(Hr(Qe.id,ot,Xt,Qe.tags))}}return ke.length?ke:null}function Ai(Ne,ee,K,le,Me){for(let Se=0;Se<Ne.length;Se+=3){const Ge=Ne[Se+Me];Ge>=K&&Ge<=le&&us(ee,Ne[Se],Ne[Se+1],Ne[Se+2])}}function hn(Ne,ee,K,le,Me,Se,Ge){let Fe=Er(Ne);const ke=Me===0?No:In;let Qe,ft,ot=Ne.start;for(let Bi=0;Bi<Ne.length-3;Bi+=3){const qe=Ne[Bi],Hi=Ne[Bi+1],rn=Ne[Bi+2],Kt=Ne[Bi+3],qi=Ne[Bi+4],Vr=Me===0?qe:Hi,Wi=Me===0?Kt:qi;let er=!1;Ge&&(Qe=Math.sqrt(Math.pow(qe-Kt,2)+Math.pow(Hi-qi,2))),Vr<K?Wi>K&&(ft=ke(Fe,qe,Hi,Kt,qi,K),Ge&&(Fe.start=ot+Qe*ft)):Vr>le?Wi<le&&(ft=ke(Fe,qe,Hi,Kt,qi,le),Ge&&(Fe.start=ot+Qe*ft)):us(Fe,qe,Hi,rn),Wi<K&&Vr>=K&&(ft=ke(Fe,qe,Hi,Kt,qi,K),er=!0),Wi>le&&Vr<=le&&(ft=ke(Fe,qe,Hi,Kt,qi,le),er=!0),!Se&&er&&(Ge&&(Fe.end=ot+Qe*ft),ee.push(Fe),Fe=Er(Ne)),Ge&&(ot+=Qe)}let St=Ne.length-3;const je=Ne[St],Xt=Ne[St+1],Gi=Me===0?je:Xt;Gi>=K&&Gi<=le&&us(Fe,je,Xt,Ne[St+2]),St=Fe.length-3,Se&&St>=3&&(Fe[St]!==Fe[0]||Fe[St+1]!==Fe[1])&&us(Fe,Fe[0],Fe[1],Fe[2]),Fe.length&&ee.push(Fe)}function Er(Ne){const ee=[];return ee.size=Ne.size,ee.start=Ne.start,ee.end=Ne.end,ee}function yo(Ne,ee,K,le,Me,Se){for(const Ge of Ne)hn(Ge,ee,K,le,Me,Se,!1)}function us(Ne,ee,K,le){Ne.push(ee,K,le)}function No(Ne,ee,K,le,Me,Se){const Ge=(Se-ee)/(le-ee);return us(Ne,Se,K+(Me-K)*Ge,1),Ge}function In(Ne,ee,K,le,Me,Se){const Ge=(Se-K)/(Me-K);return us(Ne,ee+(le-ee)*Ge,Se,1),Ge}function Vo(Ne,ee){const K=[];for(let le=0;le<Ne.length;le++){const Me=Ne[le],Se=Me.type;let Ge;if(Se==="Point"||Se==="MultiPoint"||Se==="LineString")Ge=en(Me.geometry,ee);else if(Se==="MultiLineString"||Se==="Polygon"){Ge=[];for(const Fe of Me.geometry)Ge.push(en(Fe,ee))}else if(Se==="MultiPolygon"){Ge=[];for(const Fe of Me.geometry){const ke=[];for(const Qe of Fe)ke.push(en(Qe,ee));Ge.push(ke)}}K.push(Hr(Me.id,Se,Ge,Me.tags))}return K}function en(Ne,ee){const K=[];K.size=Ne.size,Ne.start!==void 0&&(K.start=Ne.start,K.end=Ne.end);for(let le=0;le<Ne.length;le+=3)K.push(Ne[le]+ee,Ne[le+1],Ne[le+2]);return K}function hs(Ne,ee){if(Ne.transformed)return Ne;const K=1<<Ne.z,le=Ne.x,Me=Ne.y;for(const Se of Ne.features){const Ge=Se.geometry,Fe=Se.type;if(Se.geometry=[],Fe===1)for(let ke=0;ke<Ge.length;ke+=2)Se.geometry.push(Is(Ge[ke],Ge[ke+1],ee,K,le,Me));else for(let ke=0;ke<Ge.length;ke++){const Qe=[];for(let ft=0;ft<Ge[ke].length;ft+=2)Qe.push(Is(Ge[ke][ft],Ge[ke][ft+1],ee,K,le,Me));Se.geometry.push(Qe)}}return Ne.transformed=!0,Ne}function Is(Ne,ee,K,le,Me,Se){return[Math.round(K*(Ne*le-Me)),Math.round(K*(ee*le-Se))]}function Ui(Ne,ee,K,le,Me){const Se=ee===Me.maxZoom?0:Me.tolerance/((1<<ee)*Me.extent),Ge={features:[],numPoints:0,numSimplified:0,numFeatures:Ne.length,source:null,x:K,y:le,z:ee,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0};for(const Fe of Ne)Dn(Ge,Fe,Se,Me);return Ge}function Dn(Ne,ee,K,le){const Me=ee.geometry,Se=ee.type,Ge=[];if(Ne.minX=Math.min(Ne.minX,ee.minX),Ne.minY=Math.min(Ne.minY,ee.minY),Ne.maxX=Math.max(Ne.maxX,ee.maxX),Ne.maxY=Math.max(Ne.maxY,ee.maxY),Se==="Point"||Se==="MultiPoint")for(let Fe=0;Fe<Me.length;Fe+=3)Ge.push(Me[Fe],Me[Fe+1]),Ne.numPoints++,Ne.numSimplified++;else if(Se==="LineString")jo(Ge,Me,Ne,K,!1,!1);else if(Se==="MultiLineString"||Se==="Polygon")for(let Fe=0;Fe<Me.length;Fe++)jo(Ge,Me[Fe],Ne,K,Se==="Polygon",Fe===0);else if(Se==="MultiPolygon")for(let Fe=0;Fe<Me.length;Fe++){const ke=Me[Fe];for(let Qe=0;Qe<ke.length;Qe++)jo(Ge,ke[Qe],Ne,K,!0,Qe===0)}if(Ge.length){let Fe=ee.tags||null;if(Se==="LineString"&&le.lineMetrics){Fe={};for(const Qe in ee.tags)Fe[Qe]=ee.tags[Qe];Fe.mapbox_clip_start=Me.start/Me.size,Fe.mapbox_clip_end=Me.end/Me.size}const ke={geometry:Ge,type:Se==="Polygon"||Se==="MultiPolygon"?3:Se==="LineString"||Se==="MultiLineString"?2:1,tags:Fe};ee.id!==null&&(ke.id=ee.id),Ne.features.push(ke)}}function jo(Ne,ee,K,le,Me,Se){const Ge=le*le;if(le>0&&ee.size<(Me?Ge:le))return void(K.numPoints+=ee.length/3);const Fe=[];for(let ke=0;ke<ee.length;ke+=3)(le===0||ee[ke+2]>Ge)&&(K.numSimplified++,Fe.push(ee[ke],ee[ke+1])),K.numPoints++;Me&&(function(ke,Qe){let ft=0;for(let ot=0,St=ke.length,je=St-2;ot<St;je=ot,ot+=2)ft+=(ke[ot]-ke[je])*(ke[ot+1]+ke[je+1]);if(ft>0===Qe)for(let ot=0,St=ke.length;ot<St/2;ot+=2){const je=ke[ot],Xt=ke[ot+1];ke[ot]=ke[St-2-ot],ke[ot+1]=ke[St-1-ot],ke[St-2-ot]=je,ke[St-1-ot]=Xt}})(Fe,Se),Ne.push(Fe)}const Zo={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0};class tn{constructor(ee,K){const le=(K=this.options=(function(Se,Ge){for(const Fe in Ge)Se[Fe]=Ge[Fe];return Se})(Object.create(Zo),K)).debug;if(le&&console.time("preprocess data"),K.maxZoom<0||K.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(K.promoteId&&K.generateId)throw new Error("promoteId and generateId cannot be used together.");let Me=(function(Se,Ge){const Fe=[];if(Se.type==="FeatureCollection")for(let ke=0;ke<Se.features.length;ke++)Oi(Fe,Se.features[ke],Ge,ke);else Oi(Fe,Se.type==="Feature"?Se:{geometry:Se},Ge);return Fe})(ee,K);this.tiles={},this.tileCoords=[],le&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",K.indexMaxZoom,K.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),Me=(function(Se,Ge){const Fe=Ge.buffer/Ge.extent;let ke=Se;const Qe=xi(Se,1,-1-Fe,Fe,0,-1,2,Ge),ft=xi(Se,1,1-Fe,2+Fe,0,-1,2,Ge);return(Qe||ft)&&(ke=xi(Se,1,-Fe,1+Fe,0,-1,2,Ge)||[],Qe&&(ke=Vo(Qe,1).concat(ke)),ft&&(ke=ke.concat(Vo(ft,-1)))),ke})(Me,K),Me.length&&this.splitTile(Me,0,0,0),le&&(Me.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}splitTile(ee,K,le,Me,Se,Ge,Fe){const ke=[ee,K,le,Me],Qe=this.options,ft=Qe.debug;for(;ke.length;){Me=ke.pop(),le=ke.pop(),K=ke.pop(),ee=ke.pop();const ot=1<<K,St=Gn(K,le,Me);let je=this.tiles[St];if(!je&&(ft>1&&console.time("creation"),je=this.tiles[St]=Ui(ee,K,le,Me,Qe),this.tileCoords.push({z:K,x:le,y:Me}),ft)){ft>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",K,le,Me,je.numFeatures,je.numPoints,je.numSimplified),console.timeEnd("creation"));const er=`z${K}`;this.stats[er]=(this.stats[er]||0)+1,this.total++}if(je.source=ee,Se==null){if(K===Qe.indexMaxZoom||je.numPoints<=Qe.indexMaxPoints)continue}else{if(K===Qe.maxZoom||K===Se)continue;if(Se!=null){const er=Se-K;if(le!==Ge>>er||Me!==Fe>>er)continue}}if(je.source=null,ee.length===0)continue;ft>1&&console.time("clipping");const Xt=.5*Qe.buffer/Qe.extent,Gi=.5-Xt,Bi=.5+Xt,qe=1+Xt;let Hi=null,rn=null,Kt=null,qi=null,Vr=xi(ee,ot,le-Xt,le+Bi,0,je.minX,je.maxX,Qe),Wi=xi(ee,ot,le+Gi,le+qe,0,je.minX,je.maxX,Qe);ee=null,Vr&&(Hi=xi(Vr,ot,Me-Xt,Me+Bi,1,je.minY,je.maxY,Qe),rn=xi(Vr,ot,Me+Gi,Me+qe,1,je.minY,je.maxY,Qe),Vr=null),Wi&&(Kt=xi(Wi,ot,Me-Xt,Me+Bi,1,je.minY,je.maxY,Qe),qi=xi(Wi,ot,Me+Gi,Me+qe,1,je.minY,je.maxY,Qe),Wi=null),ft>1&&console.timeEnd("clipping"),ke.push(Hi||[],K+1,2*le,2*Me),ke.push(rn||[],K+1,2*le,2*Me+1),ke.push(Kt||[],K+1,2*le+1,2*Me),ke.push(qi||[],K+1,2*le+1,2*Me+1)}}getTile(ee,K,le){ee=+ee,K=+K,le=+le;const Me=this.options,{extent:Se,debug:Ge}=Me;if(ee<0||ee>24)return null;const Fe=1<<ee,ke=Gn(ee,K=K+Fe&Fe-1,le);if(this.tiles[ke])return hs(this.tiles[ke],Se);Ge>1&&console.log("drilling down to z%d-%d-%d",ee,K,le);let Qe,ft=ee,ot=K,St=le;for(;!Qe&&ft>0;)ft--,ot>>=1,St>>=1,Qe=this.tiles[Gn(ft,ot,St)];return Qe&&Qe.source?(Ge>1&&(console.log("found parent tile z%d-%d-%d",ft,ot,St),console.time("drilling down")),this.splitTile(Qe.source,ft,ot,St,ee,K,le),Ge>1&&console.timeEnd("drilling down"),this.tiles[ke]?hs(this.tiles[ke],Se):null):null}}function Gn(Ne,ee,K){return 32*((1<<Ne)*K+ee)+Ne}class vo extends rt{constructor(ee,K,le,Me=Ds){super(ee,K,le),this._dataUpdateable=new Map,this._createGeoJSONIndex=Me}loadVectorTile(ee,K){return W._(this,void 0,void 0,(function*(){const le=ee.tileID.canonical;if(!this._geoJSONIndex)throw new Error("Unable to parse the data into a cluster or geojson");const Me=this._geoJSONIndex.getTile(le.z,le.x,le.y);return Me?Mn(new W.d2(Me.features,{version:2,extent:W.a5})):null}))}loadData(ee){return W._(this,void 0,void 0,(function*(){var K;(K=this._pendingRequest)===null||K===void 0||K.abort();const le=this._startPerformance(ee);this._pendingRequest=new AbortController;try{(!this._pendingData||ee.request||ee.data||ee.dataDiff)&&(this._pendingData=this.loadAndProcessGeoJSON(ee,this._pendingRequest));const Me=yield this._pendingData;this._geoJSONIndex=this._createGeoJSONIndex(Me,ee),this.loaded={};const Se={};return ee.request&&(Se.data=Me),this._finishPerformance(le,ee,Se),Se}catch(Me){if(delete this._pendingRequest,W.Z(Me))return{abandoned:!0};throw Me}}))}_startPerformance(ee){var K;if(!((K=ee==null?void 0:ee.request)===null||K===void 0)&&K.collectResourceTiming)return new W.c_(ee.request)}_finishPerformance(ee,K,le){if(!ee)return;const Me=ee.finish();Me&&(le.resourceTiming={},le.resourceTiming[K.source]=JSON.parse(JSON.stringify(Me)))}getData(){return W._(this,void 0,void 0,(function*(){return this._pendingData}))}reloadTile(ee){const K=this.loaded;return K&&K[ee.uid]?super.reloadTile(ee):this.loadTile(ee)}loadAndProcessGeoJSON(ee,K){return W._(this,void 0,void 0,(function*(){let le;if(ee.request?le=yield this.loadGeoJSONFromUrl(ee.request,ee.promoteId,K):ee.data?le=this._loadGeoJSONFromObject(ee.data,ee.promoteId):ee.dataDiff&&(le=this._loadGeoJSONFromDiff(ee.dataDiff,ee.promoteId,ee.source)),delete this._pendingRequest,typeof le!="object")throw new Error(`Input data given to '${ee.source}' is not a valid GeoJSON object.`);return no(le,!0),ee.filter&&(le=this._filterGeoJSON(le,ee.filter)),le}))}loadGeoJSONFromUrl(ee,K,le){return W._(this,void 0,void 0,(function*(){const Me=yield W.j(ee,le);return this._dataUpdateable=W.a7(Me.data,K),Me.data}))}_loadGeoJSONFromObject(ee,K){return this._dataUpdateable=W.a7(ee,K),ee}_loadGeoJSONFromDiff(ee,K,le){if(!this._dataUpdateable)throw new Error(`Cannot update existing geojson data in ${le}`);W.a8(this._dataUpdateable,ee,K);const Me=Array.from(this._dataUpdateable.values());return this._toFeatureCollection(Me)}_filterGeoJSON(ee,K){const le=W.d3(K,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(le.result==="error")throw new Error(le.value.map((Se=>`${Se.key}: ${Se.message}`)).join(", "));const Me=ee.features.filter((Se=>le.value.evaluate({zoom:0},Se)));return this._toFeatureCollection(Me)}_toFeatureCollection(ee){return{type:"FeatureCollection",features:ee}}removeSource(ee){return W._(this,void 0,void 0,(function*(){this._pendingRequest&&this._pendingRequest.abort()}))}getClusterExpansionZoom(ee){return this._geoJSONIndex.getClusterExpansionZoom(ee.clusterId)}getClusterChildren(ee){return this._geoJSONIndex.getChildren(ee.clusterId)}getClusterLeaves(ee){return this._geoJSONIndex.getLeaves(ee.clusterId,ee.limit,ee.offset)}}function Ds(Ne,ee){return ee.cluster?new Vs((function({superclusterOptions:K,clusterProperties:le}){if(!le||!K)return K;const Me={},Se={},Ge={accumulated:null,zoom:0},Fe={properties:null},ke=Object.keys(le);for(const Qe of ke){const[ft,ot]=le[Qe],St=W.d3(ot),je=W.d3(typeof ft=="string"?[ft,["accumulated"],["get",Qe]]:ft);Me[Qe]=St.value,Se[Qe]=je.value}return K.map=Qe=>{Fe.properties=Qe;const ft={};for(const ot of ke)ft[ot]=Me[ot].evaluate(Ge,Fe);return ft},K.reduce=(Qe,ft)=>{Fe.properties=ft;for(const ot of ke)Ge.accumulated=Qe[ot],Qe[ot]=Se[ot].evaluate(Ge,Fe)},K})(ee)).load(Ne.features):(function(K,le){return new tn(K,le)})(Ne,ee.geojsonVtOptions)}class mn{constructor(ee){this.self=ee,this.actor=new W.L(ee),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.globalStates=new Map,this.self.registerWorkerSource=(K,le)=>{if(this.externalWorkerSourceTypes[K])throw new Error(`Worker source with name "${K}" already registered.`);this.externalWorkerSourceTypes[K]=le},this.self.addProtocol=W.cJ,this.self.removeProtocol=W.cK,this.self.registerRTLTextPlugin=K=>{W.d4.setMethods(K)},this.actor.registerMessageHandler("LDT",((K,le)=>this._getDEMWorkerSource(K,le.source).loadTile(le))),this.actor.registerMessageHandler("RDT",((K,le)=>W._(this,void 0,void 0,(function*(){this._getDEMWorkerSource(K,le.source).removeTile(le)})))),this.actor.registerMessageHandler("GCEZ",((K,le)=>W._(this,void 0,void 0,(function*(){return this._getWorkerSource(K,le.type,le.source).getClusterExpansionZoom(le)})))),this.actor.registerMessageHandler("GCC",((K,le)=>W._(this,void 0,void 0,(function*(){return this._getWorkerSource(K,le.type,le.source).getClusterChildren(le)})))),this.actor.registerMessageHandler("GCL",((K,le)=>W._(this,void 0,void 0,(function*(){return this._getWorkerSource(K,le.type,le.source).getClusterLeaves(le)})))),this.actor.registerMessageHandler("LD",((K,le)=>this._getWorkerSource(K,le.type,le.source).loadData(le))),this.actor.registerMessageHandler("GD",((K,le)=>this._getWorkerSource(K,le.type,le.source).getData())),this.actor.registerMessageHandler("LT",((K,le)=>this._getWorkerSource(K,le.type,le.source).loadTile(le))),this.actor.registerMessageHandler("RT",((K,le)=>this._getWorkerSource(K,le.type,le.source).reloadTile(le))),this.actor.registerMessageHandler("AT",((K,le)=>this._getWorkerSource(K,le.type,le.source).abortTile(le))),this.actor.registerMessageHandler("RMT",((K,le)=>this._getWorkerSource(K,le.type,le.source).removeTile(le))),this.actor.registerMessageHandler("RS",((K,le)=>W._(this,void 0,void 0,(function*(){if(!this.workerSources[K]||!this.workerSources[K][le.type]||!this.workerSources[K][le.type][le.source])return;const Me=this.workerSources[K][le.type][le.source];delete this.workerSources[K][le.type][le.source],Me.removeSource!==void 0&&Me.removeSource(le)})))),this.actor.registerMessageHandler("RM",(K=>W._(this,void 0,void 0,(function*(){delete this.layerIndexes[K],delete this.availableImages[K],delete this.workerSources[K],delete this.demWorkerSources[K],this.globalStates.delete(K)})))),this.actor.registerMessageHandler("SR",((K,le)=>W._(this,void 0,void 0,(function*(){this.referrer=le})))),this.actor.registerMessageHandler("SRPS",((K,le)=>this._syncRTLPluginState(K,le))),this.actor.registerMessageHandler("IS",((K,le)=>W._(this,void 0,void 0,(function*(){this.self.importScripts(le)})))),this.actor.registerMessageHandler("SI",((K,le)=>this._setImages(K,le))),this.actor.registerMessageHandler("UL",((K,le)=>W._(this,void 0,void 0,(function*(){this._getLayerIndex(K).update(le.layers,le.removedIds,this._getGlobalState(K))})))),this.actor.registerMessageHandler("UGS",((K,le)=>W._(this,void 0,void 0,(function*(){const Me=this._getGlobalState(K);for(const Se in le)Me[Se]=le[Se]})))),this.actor.registerMessageHandler("SL",((K,le)=>W._(this,void 0,void 0,(function*(){this._getLayerIndex(K).replace(le,this._getGlobalState(K))}))))}_getGlobalState(ee){let K=this.globalStates.get(ee);return K||(K={},this.globalStates.set(ee,K)),K}_setImages(ee,K){return W._(this,void 0,void 0,(function*(){this.availableImages[ee]=K;for(const le in this.workerSources[ee]){const Me=this.workerSources[ee][le];for(const Se in Me)Me[Se].availableImages=K}}))}_syncRTLPluginState(ee,K){return W._(this,void 0,void 0,(function*(){return yield W.d4.syncState(K,this.self.importScripts)}))}_getAvailableImages(ee){let K=this.availableImages[ee];return K||(K=[]),K}_getLayerIndex(ee){let K=this.layerIndexes[ee];return K||(K=this.layerIndexes[ee]=new p),K}_getWorkerSource(ee,K,le){if(this.workerSources[ee]||(this.workerSources[ee]={}),this.workerSources[ee][K]||(this.workerSources[ee][K]={}),!this.workerSources[ee][K][le]){const Me={sendAsync:(Se,Ge)=>(Se.targetMapId=ee,this.actor.sendAsync(Se,Ge))};switch(K){case"vector":this.workerSources[ee][K][le]=new rt(Me,this._getLayerIndex(ee),this._getAvailableImages(ee));break;case"geojson":this.workerSources[ee][K][le]=new vo(Me,this._getLayerIndex(ee),this._getAvailableImages(ee));break;default:this.workerSources[ee][K][le]=new this.externalWorkerSourceTypes[K](Me,this._getLayerIndex(ee),this._getAvailableImages(ee))}}return this.workerSources[ee][K][le]}_getDEMWorkerSource(ee,K){return this.demWorkerSources[ee]||(this.demWorkerSources[ee]={}),this.demWorkerSources[ee][K]||(this.demWorkerSources[ee][K]=new Fo),this.demWorkerSources[ee][K]}}return W.i(self)&&(self.worker=new mn(self)),mn})),We("index",["exports","./shared"],(function(W,p){var it="5.16.0";function ur(){var y=new p.A(4);return p.A!=Float32Array&&(y[1]=0,y[2]=0),y[0]=1,y[3]=1,y}let fr,Zi,un;const zr={frame(y,t,n){const h=requestAnimationFrame((x=>{f(),t(x)})),{unsubscribe:f}=p.s(y.signal,"abort",(()=>{f(),cancelAnimationFrame(h),n(new p.a(y.signal.reason))}),!1)},frameAsync(y){return new Promise(((t,n)=>{this.frame(y,t,n)}))},getImageData(y,t=0){return this.getImageCanvasContext(y).getImageData(-t,-t,y.width+2*t,y.height+2*t)},getImageCanvasContext(y){const t=window.document.createElement("canvas"),n=t.getContext("2d",{willReadFrequently:!0});if(!n)throw new Error("failed to create canvas 2d context");return t.width=y.width,t.height=y.height,n.drawImage(y,0,0,y.width,y.height),n},resolveURL:y=>(fr||(fr=document.createElement("a")),fr.href=y,fr.href),hardwareConcurrency:typeof navigator<"u"&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return un!==void 0?un:!!matchMedia&&(Zi==null&&(Zi=matchMedia("(prefers-reduced-motion: reduce)")),Zi.matches)},set prefersReducedMotion(y){un=y}},Mn=new class{constructor(){this._realTime=typeof performance<"u"&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),this._frozenAt=null}getCurrentTime(){return this._frozenAt!==null?this._frozenAt:this._realTime()}setNow(y){this._frozenAt=y}restoreNow(){this._frozenAt=null}isFrozen(){return this._frozenAt!==null}};function Gt(){return Mn.getCurrentTime()}class rt{static testProp(t){if(!rt.docStyle)return t[0];for(let n=0;n<t.length;n++)if(t[n]in rt.docStyle)return t[n];return t[0]}static create(t,n,h){const f=window.document.createElement(t);return n!==void 0&&(f.className=n),h&&h.appendChild(f),f}static createNS(t,n){return window.document.createElementNS(t,n)}static disableDrag(){rt.docStyle&&rt.selectProp&&(rt.userSelect=rt.docStyle[rt.selectProp],rt.docStyle[rt.selectProp]="none")}static enableDrag(){rt.docStyle&&rt.selectProp&&(rt.docStyle[rt.selectProp]=rt.userSelect)}static setTransform(t,n){t.style[rt.transformProp]=n}static addEventListener(t,n,h,f={}){t.addEventListener(n,h,"passive"in f?f:f.capture)}static removeEventListener(t,n,h,f={}){t.removeEventListener(n,h,"passive"in f?f:f.capture)}static suppressClickInternal(t){t.preventDefault(),t.stopPropagation(),window.removeEventListener("click",rt.suppressClickInternal,!0)}static suppressClick(){window.addEventListener("click",rt.suppressClickInternal,!0),window.setTimeout((()=>{window.removeEventListener("click",rt.suppressClickInternal,!0)}),0)}static getScale(t){const n=t.getBoundingClientRect();return{x:n.width/t.offsetWidth||1,y:n.height/t.offsetHeight||1,boundingClientRect:n}}static getPoint(t,n,h){const f=n.boundingClientRect;return new p.P((h.clientX-f.left)/n.x-t.clientLeft,(h.clientY-f.top)/n.y-t.clientTop)}static mousePos(t,n){const h=rt.getScale(t);return rt.getPoint(t,h,n)}static touchPos(t,n){const h=[],f=rt.getScale(t);for(let x=0;x<n.length;x++)h.push(rt.getPoint(t,f,n[x]));return h}static mouseButton(t){return t.button}static remove(t){t.parentNode&&t.parentNode.removeChild(t)}static sanitize(t){const n=new DOMParser().parseFromString(t,"text/html").body||document.createElement("body"),h=n.querySelectorAll("script");for(const f of h)f.remove();return rt.clean(n),n.innerHTML}static isPossiblyDangerous(t,n){const h=n.replace(/\s+/g,"").toLowerCase();return!(!["src","href","xlink:href"].includes(t)||!h.includes("javascript:")&&!h.includes("data:"))||!!t.startsWith("on")||void 0}static clean(t){const n=t.children;for(const h of n)rt.removeAttributes(h),rt.clean(h)}static removeAttributes(t){for(const{name:n,value:h}of t.attributes)rt.isPossiblyDangerous(n,h)&&t.removeAttribute(n)}}rt.docStyle=typeof window<"u"&&window.document&&window.document.documentElement.style,rt.selectProp=rt.testProp(["userSelect","MozUserSelect","WebkitUserSelect","msUserSelect"]),rt.transformProp=rt.testProp(["transform","WebkitTransform"]);const Fo={supported:!1,testSupport:function(y){!ro&&zi&&(no?Ns(y):hr=y)}};let hr,zi,ro=!1,no=!1;function Ns(y){const t=y.createTexture();y.bindTexture(y.TEXTURE_2D,t);try{if(y.texImage2D(y.TEXTURE_2D,0,y.RGBA,y.RGBA,y.UNSIGNED_BYTE,zi),y.isContextLost())return;Fo.supported=!0}catch{}y.deleteTexture(t),ro=!0}var En;typeof document<"u"&&(zi=document.createElement("img"),zi.onload=()=>{hr&&Ns(hr),hr=null,no=!0},zi.onerror=()=>{ro=!0,hr=null},zi.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),(function(y){let t,n,h,f;y.resetRequestQueue=()=>{t=[],n=0,h=0,f={}},y.addThrottleControl=D=>{const B=h++;return f[B]=D,B},y.removeThrottleControl=D=>{delete f[D],T()},y.getImage=(D,B,N=!0)=>new Promise(((G,U)=>{Fo.supported&&(D.headers||(D.headers={}),D.headers.accept="image/webp,*/*"),p.e(D,{type:"image"}),t.push({abortController:B,requestParameters:D,supportImageRefresh:N,state:"queued",onError:$=>{U($)},onSuccess:$=>{G($)}}),T()}));const x=D=>p._(this,void 0,void 0,(function*(){D.state="running";const{requestParameters:B,supportImageRefresh:N,onError:G,onSuccess:U,abortController:$}=D,ie=N===!1&&!p.i(self)&&!p.g(B.url)&&(!B.headers||Object.keys(B.headers).reduce(((ce,ye)=>ce&&ye==="accept"),!0));n++;const he=ie?C(B,$):p.m(B,$);try{const ce=yield he;delete D.abortController,D.state="completed",ce.data instanceof HTMLImageElement||p.b(ce.data)?U(ce):ce.data&&U({data:yield(Ae=ce.data,typeof createImageBitmap=="function"?p.f(Ae):p.h(Ae)),cacheControl:ce.cacheControl,expires:ce.expires})}catch(ce){delete D.abortController,G(ce)}finally{n--,T()}var Ae})),T=()=>{const D=(()=>{for(const B of Object.keys(f))if(f[B]())return!0;return!1})()?p.c.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:p.c.MAX_PARALLEL_IMAGE_REQUESTS;for(let B=n;B<D&&t.length>0;B++){const N=t.shift();N.abortController.signal.aborted?B--:x(N)}},C=(D,B)=>new Promise(((N,G)=>{const U=new Image,$=D.url,ie=D.credentials;ie&&ie==="include"?U.crossOrigin="use-credentials":(ie&&ie==="same-origin"||!p.d($))&&(U.crossOrigin="anonymous"),B.signal.addEventListener("abort",(()=>{U.src="",G(new p.a(B.signal.reason))})),U.fetchPriority="high",U.onload=()=>{U.onerror=U.onload=null,N({data:U})},U.onerror=()=>{U.onerror=U.onload=null,B.signal.aborted||G(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."))},U.src=$}))})(En||(En={})),En.resetRequestQueue();class Oo{constructor(t){this._transformRequestFn=t??null}transformRequest(t,n){return this._transformRequestFn&&this._transformRequestFn(t,n)||{url:t}}setTransformRequest(t){this._transformRequestFn=t}}function Vs(y){const t=[];if(typeof y=="string")t.push({id:"default",url:y});else if(y&&y.length>0){const n=[];for(const{id:h,url:f}of y){const x=`${h}${f}`;n.indexOf(x)===-1&&(n.push(x),t.push({id:h,url:f}))}}return t}function Cs(y,t,n){try{const h=new URL(y);return h.pathname+=`${t}${n}`,h.toString()}catch{throw new Error(`Invalid sprite URL "${y}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}function cr(y){const{userImage:t}=y;return!!(t&&t.render&&t.render())&&(y.data.replace(new Uint8Array(t.data.buffer)),!0)}class Ji extends p.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new p.R({width:1,height:1}),this.dirty=!0}destroy(){this.atlasTexture&&(this.atlasTexture.destroy(),this.atlasTexture=null);for(const t of Object.keys(this.images))this.removeImage(t);this.patterns={},this.atlasImage=new p.R({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(t){if(this.loaded!==t&&(this.loaded=t,t)){for(const{ids:n,promiseResolve:h}of this.requestors)h(this._getImagesForIds(n));this.requestors=[]}}getImage(t){const n=this.images[t];if(n&&!n.data&&n.spriteData){const h=n.spriteData;n.data=new p.R({width:h.width,height:h.height},h.context.getImageData(h.x,h.y,h.width,h.height).data),n.spriteData=null}return n}addImage(t,n){if(this.images[t])throw new Error(`Image id ${t} already exist, use updateImage instead`);this._validate(t,n)&&(this.images[t]=n)}_validate(t,n){let h=!0;const f=n.data||n.spriteData;return this._validateStretch(n.stretchX,f&&f.width)||(this.fire(new p.k(new Error(`Image "${t}" has invalid "stretchX" value`))),h=!1),this._validateStretch(n.stretchY,f&&f.height)||(this.fire(new p.k(new Error(`Image "${t}" has invalid "stretchY" value`))),h=!1),this._validateContent(n.content,n)||(this.fire(new p.k(new Error(`Image "${t}" has invalid "content" value`))),h=!1),h}_validateStretch(t,n){if(!t)return!0;let h=0;for(const f of t){if(f[0]<h||f[1]<f[0]||n<f[1])return!1;h=f[1]}return!0}_validateContent(t,n){if(!t)return!0;if(t.length!==4)return!1;const h=n.spriteData,f=h&&h.width||n.data.width,x=h&&h.height||n.data.height;return!(t[0]<0||f<t[0]||t[1]<0||x<t[1]||t[2]<0||f<t[2]||t[3]<0||x<t[3]||t[2]<t[0]||t[3]<t[1])}updateImage(t,n,h=!0){const f=this.getImage(t);if(h&&(f.data.width!==n.data.width||f.data.height!==n.data.height))throw new Error(`size mismatch between old image (${f.data.width}x${f.data.height}) and new image (${n.data.width}x${n.data.height}).`);n.version=f.version+1,this.images[t]=n,this.updatedImages[t]=!0}removeImage(t){const n=this.images[t];delete this.images[t],delete this.patterns[t],n.userImage&&n.userImage.onRemove&&n.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(t){return new Promise(((n,h)=>{let f=!0;if(!this.isLoaded())for(const x of t)this.images[x]||(f=!1);this.isLoaded()||f?n(this._getImagesForIds(t)):this.requestors.push({ids:t,promiseResolve:n})}))}_getImagesForIds(t){const n={};for(const h of t){let f=this.getImage(h);f||(this.fire(new p.l("styleimagemissing",{id:h})),f=this.getImage(h)),f?n[h]={data:f.data.clone(),pixelRatio:f.pixelRatio,sdf:f.sdf,version:f.version,stretchX:f.stretchX,stretchY:f.stretchY,content:f.content,textFitWidth:f.textFitWidth,textFitHeight:f.textFitHeight,hasRenderCallback:!!(f.userImage&&f.userImage.render)}:p.w(`Image "${h}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}return n}getPixelSize(){const{width:t,height:n}=this.atlasImage;return{width:t,height:n}}getPattern(t){const n=this.patterns[t],h=this.getImage(t);if(!h)return null;if(n&&n.position.version===h.version)return n.position;if(n)n.position.version=h.version;else{const f={w:h.data.width+2,h:h.data.height+2,x:0,y:0},x=new p.I(f,h);this.patterns[t]={bin:f,position:x}}return this._updatePatternAtlas(),this.patterns[t].position}bind(t){const n=t.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new p.T(t,this.atlasImage,n.RGBA),this.atlasTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE)}_updatePatternAtlas(){const t=[];for(const x in this.patterns)t.push(this.patterns[x].bin);const{w:n,h}=p.p(t),f=this.atlasImage;f.resize({width:n||1,height:h||1});for(const x in this.patterns){const{bin:T}=this.patterns[x],C=T.x+1,D=T.y+1,B=this.getImage(x).data,N=B.width,G=B.height;p.R.copy(B,f,{x:0,y:0},{x:C,y:D},{width:N,height:G}),p.R.copy(B,f,{x:0,y:G-1},{x:C,y:D-1},{width:N,height:1}),p.R.copy(B,f,{x:0,y:0},{x:C,y:D+G},{width:N,height:1}),p.R.copy(B,f,{x:N-1,y:0},{x:C-1,y:D},{width:1,height:G}),p.R.copy(B,f,{x:0,y:0},{x:C+N,y:D},{width:1,height:G})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(t){for(const n of t){if(this.callbackDispatchedThisFrame[n])continue;this.callbackDispatchedThisFrame[n]=!0;const h=this.getImage(n);h||p.w(`Image with ID: "${n}" was not found`),cr(h)&&this.updateImage(n,h)}}cloneImages(){const t={};for(const n in this.images){const h=this.images[n];t[n]=Object.assign(Object.assign({},h),{data:h.data?h.data.clone():null})}return t}}const Sn=1e20;function Cn(y,t,n,h,f,x,T,C,D){for(let B=t;B<t+h;B++)Un(y,n*x+B,x,f,T,C,D);for(let B=n;B<n+f;B++)Un(y,B*x+t,1,h,T,C,D)}function Un(y,t,n,h,f,x,T){x[0]=0,T[0]=-Sn,T[1]=Sn,f[0]=y[t];for(let C=1,D=0,B=0;C<h;C++){f[C]=y[t+C*n];const N=C*C;do{const G=x[D];B=(f[C]-f[G]+N-G*G)/(C-G)/2}while(B<=T[D]&&--D>-1);D++,x[D]=C,T[D]=B,T[D+1]=Sn}for(let C=0,D=0;C<h;C++){for(;T[D+1]<C;)D++;const B=x[D],N=C-B;y[t+C*n]=f[B]+N*N}}const Jr=p.v.layout_symbol["text-font"].default.join(",");class Hr{constructor(t,n,h){this.requestManager=t,this.localIdeographFontFamily=n,this.entries={},this.lang=h}setURL(t){this.url=t}getGlyphs(t){return p._(this,void 0,void 0,(function*(){const n=[];for(const x in t)for(const T of t[x])n.push(this._getAndCacheGlyphsPromise(x,T));const h=yield Promise.all(n),f={};for(const{stack:x,id:T,glyph:C}of h)f[x]||(f[x]={}),f[x][T]=C&&{id:C.id,bitmap:C.bitmap.clone(),metrics:C.metrics};return f}))}_getAndCacheGlyphsPromise(t,n){return p._(this,void 0,void 0,(function*(){let h=this.entries[t];h||(h=this.entries[t]={glyphs:{},requests:{},ranges:{}});let f=h.glyphs[n];return f!==void 0?{stack:t,id:n,glyph:f}:!this.url||this._charUsesLocalIdeographFontFamily(n)?(f=h.glyphs[n]=this._drawGlyph(h,t,n),{stack:t,id:n,glyph:f}):yield this._downloadAndCacheRangePromise(t,n)}))}_downloadAndCacheRangePromise(t,n){return p._(this,void 0,void 0,(function*(){const h=this.entries[t],f=Math.floor(n/256);if(h.ranges[f])return{stack:t,id:n,glyph:null};if(!h.requests[f]){const x=Hr.loadGlyphRange(t,f,this.url,this.requestManager);h.requests[f]=x}try{const x=yield h.requests[f];for(const T in x)h.glyphs[+T]=x[+T];return h.ranges[f]=!0,{stack:t,id:n,glyph:x[n]||null}}catch(x){const T=h.glyphs[n]=this._drawGlyph(h,t,n);return this._warnOnMissingGlyphRange(T,f,n,x),{stack:t,id:n,glyph:T}}}))}_warnOnMissingGlyphRange(t,n,h,f){const x=256*n,T=x+255,C=h.toString(16).padStart(4,"0").toUpperCase();p.w(`Unable to load glyph range ${n}, ${x}-${T}. Rendering codepoint U+${C} locally instead. ${f}`)}_charUsesLocalIdeographFontFamily(t){return!!this.localIdeographFontFamily&&p.q(t)}_drawGlyph(t,n,h){const f=n===Jr&&this.localIdeographFontFamily!==""&&this._charUsesLocalIdeographFontFamily(h),x=f?"ideographTinySDF":"tinySDF";t[x]||(t[x]=this._createTinySDF(f?this.localIdeographFontFamily:n));const T=t[x].draw(String.fromCodePoint(h)),C=new RegExp("^\\p{gc=Cf}+$","u").test(String.fromCodePoint(h));return{id:h,bitmap:new p.r({width:T.width||60,height:T.height||60},T.data),metrics:{width:C?0:T.glyphWidth/2||24,height:T.glyphHeight/2||24,left:T.glyphLeft/2+.5||0,top:T.glyphTop/2-27.5||-8,advance:C?0:T.glyphAdvance/2||24,isDoubleResolution:!0}}}_createTinySDF(t){const n=t?t.split(","):[];n.push("sans-serif");const h=n.map((f=>/[-\w]+/.test(f)?f:`'${CSS.escape(f)}'`)).join(",");return new Hr.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:h,fontWeight:this._fontWeight(n[0]),fontStyle:this._fontStyle(n[0]),lang:this.lang})}_fontStyle(t){return/italic/i.test(t)?"italic":/oblique/i.test(t)?"oblique":"normal"}_fontWeight(t){const n={thin:100,hairline:100,"extra light":200,"ultra light":200,light:300,normal:400,regular:400,medium:500,semibold:600,demibold:600,bold:700,"extra bold":800,"ultra bold":800,black:900,heavy:900,"extra black":950,"ultra black":950};let h;for(const[f,x]of Object.entries(n))new RegExp(`\\b${f}\\b`,"i").test(t)&&(h=`${x}`);return h}destroy(){for(const t in this.entries){const n=this.entries[t];n.tinySDF&&(n.tinySDF=null),n.ideographTinySDF&&(n.ideographTinySDF=null),n.glyphs={},n.requests={},n.ranges={}}this.entries={}}}Hr.loadGlyphRange=function(y,t,n,h){return p._(this,void 0,void 0,(function*(){const f=256*t,x=f+255,T=h.transformRequest(n.replace("{fontstack}",y).replace("{range}",`${f}-${x}`),"Glyphs"),C=yield p.n(T,new AbortController);if(!C||!C.data)throw new Error(`Could not load glyph range. range: ${t}, ${f}-${x}`);const D={};for(const B of p.o(C.data))D[B.id]=B;return D}))},Hr.TinySDF=class{constructor({fontSize:y=24,buffer:t=3,radius:n=8,cutoff:h=.25,fontFamily:f="sans-serif",fontWeight:x="normal",fontStyle:T="normal",lang:C=null}={}){this.buffer=t,this.cutoff=h,this.radius=n,this.lang=C;const D=this.size=y+4*t,B=this._createCanvas(D),N=this.ctx=B.getContext("2d",{willReadFrequently:!0});N.font=`${T} ${x} ${y}px ${f}`,N.textBaseline="alphabetic",N.textAlign="left",N.fillStyle="black",this.gridOuter=new Float64Array(D*D),this.gridInner=new Float64Array(D*D),this.f=new Float64Array(D),this.z=new Float64Array(D+1),this.v=new Uint16Array(D)}_createCanvas(y){const t=document.createElement("canvas");return t.width=t.height=y,t}draw(y){const{width:t,actualBoundingBoxAscent:n,actualBoundingBoxDescent:h,actualBoundingBoxLeft:f,actualBoundingBoxRight:x}=this.ctx.measureText(y),T=Math.ceil(n),C=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(x-f))),D=Math.min(this.size-this.buffer,T+Math.ceil(h)),B=C+2*this.buffer,N=D+2*this.buffer,G=Math.max(B*N,0),U=new Uint8ClampedArray(G),$={data:U,width:B,height:N,glyphWidth:C,glyphHeight:D,glyphTop:T,glyphLeft:0,glyphAdvance:t};if(C===0||D===0)return $;const{ctx:ie,buffer:he,gridInner:Ae,gridOuter:ce}=this;this.lang&&(ie.lang=this.lang),ie.clearRect(he,he,C,D),ie.fillText(y,he,he+T);const ye=ie.getImageData(he,he,C,D);ce.fill(Sn,0,G),Ae.fill(0,0,G);for(let Pe=0;Pe<D;Pe++)for(let _e=0;_e<C;_e++){const we=ye.data[4*(Pe*C+_e)+3]/255;if(we===0)continue;const Ce=(Pe+he)*B+_e+he;if(we===1)ce[Ce]=0,Ae[Ce]=Sn;else{const be=.5-we;ce[Ce]=be>0?be*be:0,Ae[Ce]=be<0?be*be:0}}Cn(ce,0,0,B,N,B,this.f,this.v,this.z),Cn(Ae,he,he,C,D,B,this.f,this.v,this.z);for(let Pe=0;Pe<G;Pe++){const _e=Math.sqrt(ce[Pe])-Math.sqrt(Ae[Pe]);U[Pe]=Math.round(255-255*(_e/this.radius+this.cutoff))}return $}};class ti{constructor(){this.specification=p.u.light.position}possiblyEvaluate(t,n){return p.F(t.expression.evaluate(n))}interpolate(t,n,h){return{x:p.G.number(t.x,n.x,h),y:p.G.number(t.y,n.y,h),z:p.G.number(t.z,n.z,h)}}}let Oi;class Yt extends p.E{constructor(t){super(),Oi=Oi||new p.t({anchor:new p.D(p.u.light.anchor),position:new ti,color:new p.D(p.u.light.color),intensity:new p.D(p.u.light.intensity)}),this._transitionable=new p.x(Oi,void 0),this.setLight(t),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(t,n={}){if(!this._validate(p.y,t,n))for(const h in t){const f=t[h];h.endsWith(p.z)?this._transitionable.setTransition(h.slice(0,-p.z.length),f):this._transitionable.setValue(h,f)}}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,n,h){return(!h||h.validate!==!1)&&p.B(this,t.call(p.C,{value:n,style:{glyphs:!0,sprite:!0},styleSpec:p.u}))}}const Ni=new p.t({"sky-color":new p.D(p.u.sky["sky-color"]),"horizon-color":new p.D(p.u.sky["horizon-color"]),"fog-color":new p.D(p.u.sky["fog-color"]),"fog-ground-blend":new p.D(p.u.sky["fog-ground-blend"]),"horizon-fog-blend":new p.D(p.u.sky["horizon-fog-blend"]),"sky-horizon-blend":new p.D(p.u.sky["sky-horizon-blend"]),"atmosphere-blend":new p.D(p.u.sky["atmosphere-blend"])});class Mr extends p.E{constructor(t){super(),this._transitionable=new p.x(Ni,void 0),this.setSky(t),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new p.H(0))}setSky(t,n={}){if(!this._validate(p.J,t,n)){t||(t={"sky-color":"transparent","horizon-color":"transparent","fog-color":"transparent","fog-ground-blend":1,"atmosphere-blend":0});for(const h in t){const f=t[h];h.endsWith(p.z)?this._transitionable.setTransition(h.slice(0,-p.z.length),f):this._transitionable.setValue(h,f)}}}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,n,h={}){return(h==null?void 0:h.validate)!==!1&&p.B(this,t.call(p.C,p.e({value:n,style:{glyphs:!0,sprite:!0},styleSpec:p.u})))}calculateFogBlendOpacity(t){return t<60?0:t<70?(t-60)/10:1}}class Wr{constructor(t,n){this.width=t,this.height=n,this.nextRow=0,this.data=new Uint8Array(this.width*this.height),this.dashEntry={}}getDash(t,n){const h=t.join(",")+String(n);return this.dashEntry[h]||(this.dashEntry[h]=this.addDash(t,n)),this.dashEntry[h]}getDashRanges(t,n,h){const f=[];let x=t.length%2==1?-t[t.length-1]*h:0,T=t[0]*h,C=!0;f.push({left:x,right:T,isDash:C,zeroLength:t[0]===0});let D=t[0];for(let B=1;B<t.length;B++){C=!C;const N=t[B];x=D*h,D+=N,T=D*h,f.push({left:x,right:T,isDash:C,zeroLength:N===0})}return f}addRoundDash(t,n,h){const f=n/2;for(let x=-h;x<=h;x++){const T=this.width*(this.nextRow+h+x);let C=0,D=t[C];for(let B=0;B<this.width;B++){B/D.right>1&&(D=t[++C]);const N=Math.abs(B-D.left),G=Math.abs(B-D.right),U=Math.min(N,G);let $;const ie=x/h*(f+1);if(D.isDash){const he=f-Math.abs(ie);$=Math.sqrt(U*U+he*he)}else $=f-Math.sqrt(U*U+ie*ie);this.data[T+B]=Math.max(0,Math.min(255,$+128))}}}addRegularDash(t){for(let C=t.length-1;C>=0;--C){const D=t[C],B=t[C+1];D.zeroLength?t.splice(C,1):B&&B.isDash===D.isDash&&(B.left=D.left,t.splice(C,1))}const n=t[0],h=t[t.length-1];n.isDash===h.isDash&&(n.left=h.left-this.width,h.right=n.right+this.width);const f=this.width*this.nextRow;let x=0,T=t[x];for(let C=0;C<this.width;C++){C/T.right>1&&(T=t[++x]);const D=Math.abs(C-T.left),B=Math.abs(C-T.right),N=Math.min(D,B);this.data[f+C]=Math.max(0,Math.min(255,(T.isDash?N:-N)+128))}}addDash(t,n){const h=n?7:0,f=2*h+1;if(this.nextRow+f>this.height)return p.w("LineAtlas out of space"),null;let x=0;for(let C=0;C<t.length;C++)x+=t[C];if(x!==0){const C=this.width/x,D=this.getDashRanges(t,this.width,C);n?this.addRoundDash(D,C,h):this.addRegularDash(D)}const T={y:this.nextRow+h,height:2*h,width:x};return this.nextRow+=f,this.dirty=!0,T}bind(t){const n=t.gl;this.texture?(n.bindTexture(n.TEXTURE_2D,this.texture),this.dirty&&(this.dirty=!1,n.texSubImage2D(n.TEXTURE_2D,0,0,0,this.width,this.height,n.ALPHA,n.UNSIGNED_BYTE,this.data))):(this.texture=n.createTexture(),n.bindTexture(n.TEXTURE_2D,this.texture),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.REPEAT),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.REPEAT),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),n.texImage2D(n.TEXTURE_2D,0,n.ALPHA,this.width,this.height,0,n.ALPHA,n.UNSIGNED_BYTE,this.data))}}const or="maplibre_preloaded_worker_pool";class xi{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length<xi.workerCount;)this.workers.push(new Worker(p.c.WORKER_URL));return this.active[t]=!0,this.workers.slice()}release(t){delete this.active[t],this.numActive()===0&&(this.workers.forEach((n=>{n.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[or]}numActive(){return Object.keys(this.active).length}}const Ai=Math.floor(zr.hardwareConcurrency/2);let hn,Er;function yo(){return hn||(hn=new xi),hn}xi.workerCount=p.K(globalThis)?Math.max(Math.min(Ai,3),1):1;class us{constructor(t,n){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=n;const h=this.workerPool.acquire(n);for(let f=0;f<h.length;f++){const x=new p.L(h[f],n);x.name=`Worker ${f}`,this.actors.push(x)}if(!this.actors.length)throw new Error("No actors found")}broadcast(t,n){const h=[];for(const f of this.actors)h.push(f.sendAsync({type:t,data:n}));return Promise.all(h)}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(t=!0){this.actors.forEach((n=>{n.remove()})),this.actors=[],t&&this.workerPool.release(this.id)}registerMessageHandler(t,n){for(const h of this.actors)h.registerMessageHandler(t,n)}unregisterMessageHandler(t){for(const n of this.actors)n.unregisterMessageHandler(t)}}function No(){return Er||(Er=new us(yo(),p.M),Er.registerMessageHandler("GR",((y,t,n)=>p.m(t,n)))),Er}function In(y,t){const n=p.N();return p.O(n,n,[1,1,0]),p.Q(n,n,[.5*y.width,.5*y.height,1]),y.calculatePosMatrix?p.S(n,n,y.calculatePosMatrix(t.toUnwrapped())):n}function Vo(y,t,n,h,f,x,T){var C;const D=(function(U,$,ie){if(U)for(const he of U){const Ae=$[he];if(Ae&&Ae.source===ie&&Ae.type==="fill-extrusion")return!0}else for(const he in $){const Ae=$[he];if(Ae.source===ie&&Ae.type==="fill-extrusion")return!0}return!1})((C=f==null?void 0:f.layers)!==null&&C!==void 0?C:null,t,y.id),B=x.maxPitchScaleFactor(),N=y.tilesIn(h,B,D);N.sort(en);const G=[];for(const U of N)G.push({wrappedTileID:U.tileID.wrapped().key,queryResults:U.tile.queryRenderedFeatures(t,n,y.getState(),U.queryGeometry,U.cameraQueryGeometry,U.scale,f,x,B,In(x,U.tileID),T?($,ie)=>T(U.tileID,$,ie):void 0)});return(function(U,$){for(const ie in U)for(const he of U[ie])hs(he,$);return U})((function(U){const $={},ie={};for(const he of U){const Ae=he.queryResults,ce=he.wrappedTileID,ye=ie[ce]=ie[ce]||{};for(const Pe in Ae){const _e=Ae[Pe],we=ye[Pe]=ye[Pe]||{},Ce=$[Pe]=$[Pe]||[];for(const be of _e)we[be.featureIndex]||(we[be.featureIndex]=!0,Ce.push(be))}}return $})(G),y)}function en(y,t){const n=y.tileID,h=t.tileID;return n.overscaledZ-h.overscaledZ||n.canonical.y-h.canonical.y||n.wrap-h.wrap||n.canonical.x-h.canonical.x}function hs(y,t){const n=y.feature,h=t.getFeatureState(n.layer["source-layer"],n.id);n.source=n.layer.source,n.layer["source-layer"]&&(n.sourceLayer=n.layer["source-layer"]),n.state=h}function Is(y,t,n){return p._(this,void 0,void 0,(function*(){let h=y;if(y.url?h=(yield p.j(t.transformRequest(y.url,"Source"),n)).data:yield zr.frameAsync(n),!h)return null;const f=p.U(p.e(h,y),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in h&&h.vector_layers&&(f.vectorLayerIds=h.vector_layers.map((x=>x.id))),f}))}class Ui{constructor(t,n){t&&(n?this.setSouthWest(t).setNorthEast(n):Array.isArray(t)&&(t.length===4?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 p.V?new p.V(t.lng,t.lat):p.V.convert(t),this}setSouthWest(t){return this._sw=t instanceof p.V?new p.V(t.lng,t.lat):p.V.convert(t),this}extend(t){const n=this._sw,h=this._ne;let f,x;if(t instanceof p.V)f=t,x=t;else{if(!(t instanceof Ui))return Array.isArray(t)?t.length===4||t.every(Array.isArray)?this.extend(Ui.convert(t)):this.extend(p.V.convert(t)):t&&("lng"in t||"lon"in t)&&"lat"in t?this.extend(p.V.convert(t)):this;if(f=t._sw,x=t._ne,!f||!x)return this}return n||h?(n.lng=Math.min(f.lng,n.lng),n.lat=Math.min(f.lat,n.lat),h.lng=Math.max(x.lng,h.lng),h.lat=Math.max(x.lat,h.lat)):(this._sw=new p.V(f.lng,f.lat),this._ne=new p.V(x.lng,x.lat)),this}getCenter(){return new p.V((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 p.V(this.getWest(),this.getNorth())}getSouthEast(){return new p.V(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(t){const{lng:n,lat:h}=p.V.convert(t);let f=this._sw.lng<=n&&n<=this._ne.lng;return this._sw.lng>this._ne.lng&&(f=this._sw.lng>=n&&n>=this._ne.lng),this._sw.lat<=h&&h<=this._ne.lat&&f}intersects(t){if(!((t=Ui.convert(t)).getNorth()>=this.getSouth()&&t.getSouth()<=this.getNorth()))return!1;const n=Math.abs(this.getEast()-this.getWest()),h=Math.abs(t.getEast()-t.getWest());if(n>=360||h>=360)return!0;const f=p.W(this.getWest(),-180,180),x=p.W(this.getEast(),-180,180),T=p.W(t.getWest(),-180,180),C=p.W(t.getEast(),-180,180),D=f>=x,B=T>=C;return!(!D||!B)||(D?C>=f||T<=x:B?x>=T||f<=C:T<=x&&C>=f)}static convert(t){return t instanceof Ui?t:t&&new Ui(t)}static fromLngLat(t,n=0){const h=360*n/40075017,f=h/Math.cos(Math.PI/180*t.lat);return new Ui(new p.V(t.lng-f,t.lat-h),new p.V(t.lng+f,t.lat+h))}adjustAntiMeridian(){const t=new p.V(this._sw.lng,this._sw.lat),n=new p.V(this._ne.lng,this._ne.lat);return new Ui(t,t.lng>n.lng?new p.V(n.lng+360,n.lat):n)}}class Dn{constructor(t,n,h){this.bounds=Ui.convert(this.validateBounds(t)),this.minzoom=n||0,this.maxzoom=h||24}validateBounds(t){return Array.isArray(t)&&t.length===4?[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]:[-180,-90,180,90]}contains(t){const n=Math.pow(2,t.z),h=Math.floor(p.Y(this.bounds.getWest())*n),f=Math.floor(p.X(this.bounds.getNorth())*n),x=Math.ceil(p.Y(this.bounds.getEast())*n),T=Math.ceil(p.X(this.bounds.getSouth())*n);return t.x>=h&&t.x<x&&t.y>=f&&t.y<T}}class jo extends p.E{constructor(t,n,h,f){if(super(),this.id=t,this.dispatcher=h,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,p.e(this,p.U(n,["url","scheme","tileSize","promoteId","encoding"])),this._options=p.e({type:"vector"},n),this._collectResourceTiming=n.collectResourceTiming,this.tileSize!==512)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(f)}load(){return p._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new p.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const t=yield Is(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,this.map.style.tileManagers[this.id].clearTiles(),t&&(p.e(this,t),t.bounds&&(this.tileBounds=new Dn(t.bounds,this.minzoom,this.maxzoom)),this.fire(new p.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new p.l("data",{dataType:"source",sourceDataType:"content"})))}catch(t){this._tileJSONRequest=null,this._loaded=!0,p.Z(t)||this.fire(new p.k(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()}setTiles(t){return this.setSourceProperty((()=>{this._options.tiles=t})),this}setUrl(t){return this.setSourceProperty((()=>{this.url=t,this._options.url=t})),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}serialize(){return p.e({},this._options)}loadTile(t){return p._(this,void 0,void 0,(function*(){const n=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),h={request:this.map._requestManager.transformRequest(n,"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:this._getOverzoomParameters(t)};h.request.collectResourceTiming=this._collectResourceTiming;let f="RT";if(t.actor&&t.state!=="expired"){if(t.state==="loading")return new Promise(((x,T)=>{t.reloadPromise={resolve:x,reject:T}}))}else t.actor=this.dispatcher.getActor(),f="LT";t.abortController=new AbortController;try{const x=yield t.actor.sendAsync({type:f,data:h},t.abortController);if(delete t.abortController,t.aborted)return;this._afterTileLoadWorkerResponse(t,x)}catch(x){if(delete t.abortController,t.aborted)return;if(x&&x.status!==404)throw x;this._afterTileLoadWorkerResponse(t,null)}}))}_getOverzoomParameters(t){if(t.tileID.canonical.z<=this.maxzoom||this.map._zoomLevelsToOverscale===void 0)return;const n=t.tileID.scaledTo(this.maxzoom).canonical,h=n.url(this.tiles,this.map.getPixelRatio(),this.scheme);return{maxZoomTileID:n,overzoomRequest:this.map._requestManager.transformRequest(h,"Tile")}}_afterTileLoadWorkerResponse(t,n){if(n&&n.resourceTiming&&(t.resourceTiming=n.resourceTiming),n&&this.map._refreshExpiredTiles&&t.setExpiryData(n),t.loadVectorData(n,this.map.painter),t.reloadPromise){const h=t.reloadPromise;t.reloadPromise=null,this.loadTile(t).then(h.resolve).catch(h.reject)}}abortTile(t){return p._(this,void 0,void 0,(function*(){t.abortController&&(t.abortController.abort(),delete t.abortController),t.actor&&(yield t.actor.sendAsync({type:"AT",data:{uid:t.uid,type:this.type,source:this.id}}))}))}unloadTile(t){return p._(this,void 0,void 0,(function*(){t.unloadVectorData(),t.actor&&(yield t.actor.sendAsync({type:"RMT",data:{uid:t.uid,type:this.type,source:this.id}}))}))}hasTransition(){return!1}}class Zo extends p.E{constructor(t,n,h,f){super(),this.id=t,this.dispatcher=h,this.setEventedParent(f),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=p.e({type:"raster"},n),p.e(this,p.U(n,["url","scheme","tileSize"]))}load(){return p._(this,arguments,void 0,(function*(t=!1){this._loaded=!1,this.fire(new p.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const n=yield Is(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,n&&(p.e(this,n),n.bounds&&(this.tileBounds=new Dn(n.bounds,this.minzoom,this.maxzoom)),this.fire(new p.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new p.l("data",{dataType:"source",sourceDataType:"content",sourceDataChanged:t})))}catch(n){this._tileJSONRequest=null,this._loaded=!0,p.Z(n)||this.fire(new p.k(n))}}))}loaded(){return this._loaded}onAdd(t){this.map=t,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}setSourceProperty(t){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),t(),this.load(!0)}setTiles(t){return this.setSourceProperty((()=>{this._options.tiles=t})),this}setUrl(t){return this.setSourceProperty((()=>{this.url=t,this._options.url=t})),this}serialize(){return p.e({},this._options)}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(t){return p._(this,void 0,void 0,(function*(){const n=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);t.abortController=new AbortController;try{const h=yield En.getImage(this.map._requestManager.transformRequest(n,"Tile"),t.abortController,this.map._refreshExpiredTiles);if(delete t.abortController,t.aborted)return void(t.state="unloaded");if(h&&h.data){this.map._refreshExpiredTiles&&(h.cacheControl||h.expires)&&t.setExpiryData({cacheControl:h.cacheControl,expires:h.expires});const f=this.map.painter.context,x=f.gl,T=h.data;t.texture=this.map.painter.getTileTexture(T.width),t.texture?t.texture.update(T,{useMipmap:!0}):(t.texture=new p.T(f,T,x.RGBA,{useMipmap:!0}),t.texture.bind(x.LINEAR,x.CLAMP_TO_EDGE,x.LINEAR_MIPMAP_NEAREST)),t.state="loaded"}}catch(h){if(delete t.abortController,t.aborted)t.state="unloaded";else if(h)throw t.state="errored",h}}))}abortTile(t){return p._(this,void 0,void 0,(function*(){t.abortController&&(t.abortController.abort(),delete t.abortController)}))}unloadTile(t){return p._(this,void 0,void 0,(function*(){t.texture&&this.map.painter.saveTileTexture(t.texture)}))}hasTransition(){return!1}}class tn extends Zo{constructor(t,n,h,f){super(t,n,h,f),this.type="raster-dem",this.maxzoom=22,this._options=p.e({type:"raster-dem"},n),this.encoding=n.encoding||"mapbox",this.redFactor=n.redFactor,this.greenFactor=n.greenFactor,this.blueFactor=n.blueFactor,this.baseShift=n.baseShift}loadTile(t){return p._(this,void 0,void 0,(function*(){const n=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),h=this.map._requestManager.transformRequest(n,"Tile");t.neighboringTiles=this._getNeighboringTiles(t.tileID),t.abortController=new AbortController;try{const f=yield En.getImage(h,t.abortController,this.map._refreshExpiredTiles);if(delete t.abortController,t.aborted)return void(t.state="unloaded");if(f&&f.data){const x=f.data;this.map._refreshExpiredTiles&&(f.cacheControl||f.expires)&&t.setExpiryData({cacheControl:f.cacheControl,expires:f.expires});const T=p.b(x)&&p.$()?x:yield this.readImageNow(x),C={type:this.type,uid:t.uid,source:this.id,rawImageData:T,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!t.actor||t.state==="expired"){t.actor=this.dispatcher.getActor();const D=yield t.actor.sendAsync({type:"LDT",data:C});t.dem=D,t.needsHillshadePrepare=!0,t.needsTerrainPrepare=!0,t.state="loaded"}}}catch(f){if(delete t.abortController,t.aborted)t.state="unloaded";else if(f)throw t.state="errored",f}}))}readImageNow(t){return p._(this,void 0,void 0,(function*(){if(typeof VideoFrame<"u"&&p.a0()){const n=t.width+2,h=t.height+2;try{return new p.R({width:n,height:h},yield p.a1(t,-1,-1,n,h))}catch{}}return zr.getImageData(t,1)}))}_getNeighboringTiles(t){const n=t.canonical,h=Math.pow(2,n.z),f=(n.x-1+h)%h,x=n.x===0?t.wrap-1:t.wrap,T=(n.x+1+h)%h,C=n.x+1===h?t.wrap+1:t.wrap,D={};return D[new p.a2(t.overscaledZ,x,n.z,f,n.y).key]={backfilled:!1},D[new p.a2(t.overscaledZ,C,n.z,T,n.y).key]={backfilled:!1},n.y>0&&(D[new p.a2(t.overscaledZ,x,n.z,f,n.y-1).key]={backfilled:!1},D[new p.a2(t.overscaledZ,t.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},D[new p.a2(t.overscaledZ,C,n.z,T,n.y-1).key]={backfilled:!1}),n.y+1<h&&(D[new p.a2(t.overscaledZ,x,n.z,f,n.y+1).key]={backfilled:!1},D[new p.a2(t.overscaledZ,t.wrap,n.z,n.x,n.y+1).key]={backfilled:!1},D[new p.a2(t.overscaledZ,C,n.z,T,n.y+1).key]={backfilled:!1}),D}unloadTile(t){return p._(this,void 0,void 0,(function*(){t.demTexture&&this.map.painter.saveTileTexture(t.demTexture),t.fbo&&(t.fbo.destroy(),delete t.fbo),t.dem&&delete t.dem,delete t.neighboringTiles,t.state="unloaded",t.actor&&(yield t.actor.sendAsync({type:"RDT",data:{type:this.type,uid:t.uid,source:this.id}}))}))}}function Gn(y){return y.type==="GeometryCollection"?y.geometries.map((t=>t.coordinates)).flat(1/0):y.coordinates.flat(1/0)}function vo(y){const t=new Ui;let n;switch(y.type){case"FeatureCollection":n=y.features.map((h=>Gn(h.geometry))).flat(1/0);break;case"Feature":n=Gn(y.geometry);break;default:n=Gn(y)}if(n.length==0)return t;for(let h=0;h<n.length-1;h+=2)t.extend([n[h],n[h+1]]);return t}class Ds extends p.E{constructor(t,n,h,f){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:n.data},this.actor=h.getActor(),this.setEventedParent(f),this._data=typeof n.data=="string"?{url:n.data}:{geojson:n.data},this._options=p.e({},n),this._collectResourceTiming=n.collectResourceTiming,n.maxzoom!==void 0&&(this.maxzoom=n.maxzoom),n.type&&(this.type=n.type),n.attribution&&(this.attribution=n.attribution),this.promoteId=n.promoteId,n.clusterMaxZoom!==void 0&&this.maxzoom<=n.clusterMaxZoom&&p.w(`The maxzoom value "${this.maxzoom}" is expected to be greater than the clusterMaxZoom value "${n.clusterMaxZoom}".`),this.workerOptions=p.e({source:this.id,cluster:n.cluster||!1,geojsonVtOptions:{buffer:this._pixelsToTileUnits(n.buffer!==void 0?n.buffer:128),tolerance:this._pixelsToTileUnits(n.tolerance!==void 0?n.tolerance:.375),extent:p.a5,maxZoom:this.maxzoom,lineMetrics:n.lineMetrics||!1,generateId:n.generateId||!1},superclusterOptions:{maxZoom:this._getClusterMaxZoom(n.clusterMaxZoom),minPoints:Math.max(2,n.clusterMinPoints||2),extent:p.a5,radius:this._pixelsToTileUnits(n.clusterRadius||50),log:!1,generateId:n.generateId||!1},clusterProperties:n.clusterProperties,filter:n.filter},n.workerOptions),typeof this.promoteId=="string"&&(this.workerOptions.promoteId=this.promoteId)}_hasPendingWorkerUpdate(){return this._pendingWorkerUpdate.data!==void 0||this._pendingWorkerUpdate.diff!==void 0||this._pendingWorkerUpdate.optionsChanged}_pixelsToTileUnits(t){return t*(p.a5/this.tileSize)}_getClusterMaxZoom(t){const n=t?Math.round(t):this.maxzoom-1;return Number.isInteger(t)||t===void 0||p.w(`Integer expected for option 'clusterMaxZoom': provided value "${t}" rounded to "${n}"`),n}load(){return p._(this,void 0,void 0,(function*(){yield this._updateWorkerData()}))}onAdd(t){this.map=t,this.load()}setData(t,n){this._data=typeof t=="string"?{url:t}:{geojson:t},this._pendingWorkerUpdate={data:t};const h=this._updateWorkerData();return n?h:this}updateData(t,n){this._pendingWorkerUpdate.diff=p.a6(this._pendingWorkerUpdate.diff,t);const h=this._updateWorkerData();return n?h:this}getData(){return p._(this,void 0,void 0,(function*(){const t=p.e({type:this.type},this.workerOptions);return this.actor.sendAsync({type:"GD",data:t})}))}getBounds(){return p._(this,void 0,void 0,(function*(){return vo(yield this.getData())}))}setClusterOptions(t){return this.workerOptions.cluster=t.cluster,t.clusterRadius!==void 0&&(this.workerOptions.superclusterOptions.radius=this._pixelsToTileUnits(t.clusterRadius)),t.clusterMaxZoom!==void 0&&(this.workerOptions.superclusterOptions.maxZoom=this._getClusterMaxZoom(t.clusterMaxZoom)),this._pendingWorkerUpdate.optionsChanged=!0,this._updateWorkerData(),this}getClusterExpansionZoom(t){return this.actor.sendAsync({type:"GCEZ",data:{type:this.type,clusterId:t,source:this.id}})}getClusterChildren(t){return this.actor.sendAsync({type:"GCC",data:{type:this.type,clusterId:t,source:this.id}})}getClusterLeaves(t,n,h){return this.actor.sendAsync({type:"GCL",data:{type:this.type,source:this.id,clusterId:t,limit:n,offset:h}})}_updateWorkerData(){return p._(this,void 0,void 0,(function*(){if(this._isUpdatingWorker)return;if(!this._hasPendingWorkerUpdate())return void p.w(`No pending worker updates for GeoJSONSource ${this.id}.`);const{data:t,diff:n}=this._pendingWorkerUpdate,h=p.e({type:this.type},this.workerOptions);t!==void 0?(typeof t=="string"?(h.request=this.map._requestManager.transformRequest(zr.resolveURL(t),"Source"),h.request.collectResourceTiming=this._collectResourceTiming):h.data=t,this._pendingWorkerUpdate.data=void 0):n&&(h.dataDiff=n,this._pendingWorkerUpdate.diff=void 0),this._pendingWorkerUpdate.optionsChanged=void 0,this._isUpdatingWorker=!0,this.fire(new p.l("dataloading",{dataType:"source"}));try{const f=yield this.actor.sendAsync({type:"LD",data:h});if(this._isUpdatingWorker=!1,this._removed||f.abandoned)return void this.fire(new p.l("dataabort",{dataType:"source"}));f.data&&(this._data={geojson:f.data});const x=this._applyDiffToSource(n),T=this._getShouldReloadTileOptions(x);let C=null;f.resourceTiming&&f.resourceTiming[this.id]&&(C=f.resourceTiming[this.id].slice(0));const D={dataType:"source"};this._collectResourceTiming&&C&&C.length>0&&p.e(D,{resourceTiming:C}),this.fire(new p.l("data",Object.assign(Object.assign({},D),{sourceDataType:"metadata"}))),this.fire(new p.l("data",Object.assign(Object.assign({},D),{sourceDataType:"content",shouldReloadTileOptions:T})))}catch(f){if(this._isUpdatingWorker=!1,this._removed)return void this.fire(new p.l("dataabort",{dataType:"source"}));this.fire(new p.k(f))}finally{this._hasPendingWorkerUpdate()&&this._updateWorkerData()}}))}_applyDiffToSource(t){if(!t)return;const n=typeof this.promoteId=="string"?this.promoteId:void 0;if(!this._data.url&&!this._data.updateable){const f=p.a7(this._data.geojson,n);if(!f)throw new Error(`GeoJSONSource "${this.id}": GeoJSON data is not compatible with updateData`);this._data={updateable:f}}if(!this._data.updateable)return;const h=p.a8(this._data.updateable,t,n);return t.removeAll||this._options.cluster?void 0:h}_getShouldReloadTileOptions(t){if(t)return{affectedBounds:t.filter(Boolean).map((n=>vo(n)))}}shouldReloadTile(t,{affectedBounds:n}){if(t.state==="loading")return!0;if(t.state==="unloaded")return!1;const{buffer:h,extent:f}=this.workerOptions.geojsonVtOptions,x=(function({x:T,y:C,z:D},B=0){const N=p.a3((T-B)/Math.pow(2,D)),G=p.a4((C+1+B)/Math.pow(2,D)),U=p.a3((T+1+B)/Math.pow(2,D)),$=p.a4((C-B)/Math.pow(2,D));return new Ui([N,G],[U,$])})(t.tileID.canonical,h/f);for(const T of n)if(x.intersects(T))return!0;return!1}loaded(){return!this._isUpdatingWorker&&!this._hasPendingWorkerUpdate()}loadTile(t){return p._(this,void 0,void 0,(function*(){const n=t.actor?"RT":"LT";t.actor=this.actor;const h={type:this.type,uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity};t.abortController=new AbortController;const f=yield this.actor.sendAsync({type:n,data:h},t.abortController);delete t.abortController,t.unloadVectorData(),t.aborted||t.loadVectorData(f,this.map.painter,n==="RT")}))}abortTile(t){return p._(this,void 0,void 0,(function*(){t.abortController&&(t.abortController.abort(),delete t.abortController),t.aborted=!0}))}unloadTile(t){return p._(this,void 0,void 0,(function*(){t.unloadVectorData(),yield this.actor.sendAsync({type:"RMT",data:{uid:t.uid,type:this.type,source:this.id}})}))}onRemove(){this._removed=!0,this.actor.sendAsync({type:"RS",data:{type:this.type,source:this.id}})}serialize(){return p.e({},this._options,{type:this.type,data:this._data.updateable?{type:"FeatureCollection",features:Array.from(this._data.updateable.values())}:this._data.url||this._data.geojson})}hasTransition(){return!1}}class mn extends p.E{constructor(t,n,h,f){super(),this.flippedWindingOrder=!1,this.id=t,this.dispatcher=h,this.coordinates=n.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(f),this.options=n}load(t){return p._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new p.l("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{const n=yield En.getImage(this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,n&&n.data&&(this.image=n.data,t&&(this.coordinates=t),this._finishLoading())}catch(n){this._request=null,this._loaded=!0,p.Z(n)||this.fire(new p.k(n))}}))}loaded(){return this._loaded}updateImage(t){return t.url?(this._request&&(this._request.abort(),this._request=null),this.options.url=t.url,this.load(t.coordinates).finally((()=>{this.texture=null})),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new p.l("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(){this._request&&(this._request.abort(),this._request=null)}setCoordinates(t){this.coordinates=t;const n=t.map(p.a9.fromLngLat);var h;return this.tileID=(function(f){const x=p.aa.fromPoints(f),T=x.width(),C=x.height(),D=Math.max(T,C),B=Math.max(0,Math.floor(-Math.log(D)/Math.LN2)),N=Math.pow(2,B);return new p.ac(B,Math.floor((x.minX+x.maxX)/2*N),Math.floor((x.minY+x.maxY)/2*N))})(n),this.terrainTileRanges=this._getOverlappingTileRanges(n),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=n.map((f=>this.tileID.getTilePoint(f)._round())),this.flippedWindingOrder=((h=this.tileCoords)[1].x-h[0].x)*(h[2].y-h[0].y)-(h[1].y-h[0].y)*(h[2].x-h[0].x)<0,this.fire(new p.l("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;const t=this.map.painter.context,n=t.gl;this.texture||(this.texture=new p.T(t,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));let h=!1;for(const f in this.tiles){const x=this.tiles[f];x.state!=="loaded"&&(x.state="loaded",x.texture=this.texture,h=!0)}h&&this.fire(new p.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(t){return p._(this,void 0,void 0,(function*(){this.tileID&&this.tileID.equals(t.tileID.canonical)?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={}):t.state="errored"}))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}_getOverlappingTileRanges(t){const{minX:n,minY:h,maxX:f,maxY:x}=p.aa.fromPoints(t),T={};for(let C=0;C<=p.ab;C++){const D=Math.pow(2,C),B=Math.floor(n*D),N=Math.floor(h*D),G=Math.floor(f*D),U=Math.floor(x*D),$=(B%D+D)%D,ie=G%D,he=Math.floor(B/D),Ae=Math.floor(G/D);T[C]={minWrap:he,maxWrap:Ae,minTileXWrapped:$,maxTileXWrapped:ie,minTileY:N,maxTileY:U}}return T}}class Ne extends mn{constructor(t,n,h,f){super(t,n,h,f),this.roundZoom=!0,this.type="video",this.options=n}load(){return p._(this,void 0,void 0,(function*(){this._loaded=!1;const t=this.options;this.urls=[];for(const n of t.urls)this.urls.push(this.map._requestManager.transformRequest(n,"Source").url);try{const n=yield p.ad(this.urls);if(this._loaded=!0,!n)return;this.video=n,this.video.loop=!0,this.video.addEventListener("playing",(()=>{this.map.triggerRepaint()})),this.map&&this.video.play(),this._finishLoading()}catch(n){this.fire(new p.k(n))}}))}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(t){if(this.video){const n=this.video.seekable;t<n.start(0)||t>n.end(0)?this.fire(new p.k(new p.ae(`sources.${this.id}`,null,`Playback for this video can be set only between the ${n.start(0)} and ${n.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)))}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;const t=this.map.painter.context,n=t.gl;this.texture?this.video.paused||(this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,this.video)):(this.texture=new p.T(t,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));let h=!1;for(const f in this.tiles){const x=this.tiles[f];x.state!=="loaded"&&(x.state="loaded",x.texture=this.texture,h=!0)}h&&this.fire(new p.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class ee extends mn{constructor(t,n,h,f){super(t,n,h,f),n.coordinates?Array.isArray(n.coordinates)&&n.coordinates.length===4&&!n.coordinates.some((x=>!Array.isArray(x)||x.length!==2||x.some((T=>typeof T!="number"))))||this.fire(new p.k(new p.ae(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new p.k(new p.ae(`sources.${t}`,null,'missing required property "coordinates"'))),n.animate&&typeof n.animate!="boolean"&&this.fire(new p.k(new p.ae(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),n.canvas?typeof n.canvas=="string"||n.canvas instanceof HTMLCanvasElement||this.fire(new p.k(new p.ae(`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 p.k(new p.ae(`sources.${t}`,null,'missing required property "canvas"'))),this.options=n,this.animate=n.animate===void 0||n.animate}load(){return p._(this,void 0,void 0,(function*(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new p.k(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}))}getCanvas(){return this.canvas}onAdd(t){this.map=t,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const n=this.map.painter.context,h=n.gl;this.texture?(t||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):(this.texture=new p.T(n,this.canvas,h.RGBA,{premultiply:!0}),this.texture.bind(h.LINEAR,h.CLAMP_TO_EDGE));let f=!1;for(const x in this.tiles){const T=this.tiles[x];T.state!=="loaded"&&(T.state="loaded",T.texture=this.texture,f=!0)}f&&this.fire(new p.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"canvas",animate:this.animate,canvas:this.options.canvas,coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const t of[this.canvas.width,this.canvas.height])if(isNaN(t)||t<=0)return!0;return!1}}const K={},le=y=>{switch(y){case"geojson":return Ds;case"image":return mn;case"raster":return Zo;case"raster-dem":return tn;case"vector":return jo;case"video":return Ne;case"canvas":return ee}return K[y]},Me="RTLPluginLoaded";class Se extends p.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=No()}_syncState(t){return this.status=t,this.dispatcher.broadcast("SRPS",{pluginStatus:t,pluginURL:this.url}).catch((n=>{throw this.status="error",n}))}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null}setRTLTextPlugin(t){return p._(this,arguments,void 0,(function*(n,h=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=zr.resolveURL(n),!this.url)throw new Error(`requested url ${n} is invalid`);if(this.status==="unavailable"){if(!h)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if(this.status==="requested")return this._requestImport()}))}_requestImport(){return p._(this,void 0,void 0,(function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new p.l(Me))}))}lazyLoad(){this.status==="unavailable"?this.status="requested":this.status==="deferred"&&this._requestImport()}}let Ge=null;function Fe(){return Ge||(Ge=new Se),Ge}var ke,Qe;(function(y){y[y.Base=0]="Base",y[y.Parent=1]="Parent"})(ke||(ke={})),(function(y){y[y.Departing=0]="Departing",y[y.Incoming=1]="Incoming"})(Qe||(Qe={}));class ft{constructor(t,n){this.timeAdded=0,this.fadeEndTime=0,this.fadeOpacity=1,this.tileID=t,this.uid=p.af(),this.uses=0,this.tileSize=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading"}isRenderable(t){return this.hasData()&&(!this.fadeEndTime||this.fadeOpacity>0)&&(t||!this.holdingForSymbolFade())}setCrossFadeLogic({fadingRole:t,fadingDirection:n,fadingParentID:h,fadeEndTime:f}){this.resetFadeLogic(),this.fadingRole=t,this.fadingDirection=n,this.fadingParentID=h,this.fadeEndTime=f}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=Gt(),this.fadeEndTime=0,this.fadeOpacity=1}wasRequested(){return this.state==="errored"||this.state==="loaded"||this.state==="reloading"}clearTextures(t){this.demTexture&&t.saveTileTexture(this.demTexture),this.demTexture=null}loadVectorData(t,n,h){if(this.hasData()&&this.unloadVectorData(),this.state="loaded",t){t.featureIndex&&(this.latestFeatureIndex=t.featureIndex,t.rawTileData?(this.latestRawTileData=t.rawTileData,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(f,x){const T={};if(!x)return T;for(const C of f){const D=C.layerIds.map((B=>x.getLayer(B))).filter(Boolean);if(D.length!==0){C.layers=D,C.stateDependentLayerIds&&(C.stateDependentLayers=C.stateDependentLayerIds.map((B=>D.filter((N=>N.id===B))[0])));for(const B of D)T[B.id]=C}}return T})(t.buckets,n==null?void 0:n.style),this.hasSymbolBuckets=!1;for(const f in this.buckets){const x=this.buckets[f];if(x instanceof p.ah){if(this.hasSymbolBuckets=!0,!h)break;x.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const f in this.buckets){const x=this.buckets[f];if(x instanceof p.ah&&x.hasRTLText){this.hasRTLText=!0,Fe().lazyLoad();break}}this.queryPadding=0;for(const f in this.buckets){const x=this.buckets[f];this.queryPadding=Math.max(this.queryPadding,n.style.getLayer(f).queryRadius(x))}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),this.dashPositions=t.dashPositions}else this.collisionBoxArray=new p.ag}unloadVectorData(){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.dashPositions&&(this.dashPositions=null),this.latestFeatureIndex=null,this.state="unloaded"}getBucket(t){return this.buckets[t.id]}upload(t){for(const h in this.buckets){const f=this.buckets[h];f.uploadPending()&&f.upload(t)}const n=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new p.T(t,this.imageAtlas.image,n.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new p.T(t,this.glyphAtlasImage,n.ALPHA),this.glyphAtlasImage=null)}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture)}queryRenderedFeatures(t,n,h,f,x,T,C,D,B,N,G){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:f,cameraQueryGeometry:x,scale:T,tileSize:this.tileSize,pixelPosMatrix:N,transform:D,params:C,queryPadding:this.queryPadding*B,getElevation:G},t,n,h):{}}querySourceFeatures(t,n){const h=this.latestFeatureIndex;if(!h||!h.rawTileData)return;const f=h.loadVTLayers(),x=n&&n.sourceLayer?n.sourceLayer:"",T=f[p.ai]||f[x];if(!T)return;const C=p.aj(n==null?void 0:n.filter,n==null?void 0:n.globalState),{z:D,x:B,y:N}=this.tileID.canonical,G={z:D,x:B,y:N};for(let U=0;U<T.length;U++){const $=T.feature(U);if(C.needGeometry){const Ae=p.ak($,!0);if(!C.filter(new p.H(this.tileID.overscaledZ),Ae,this.tileID.canonical))continue}else if(!C.filter(new p.H(this.tileID.overscaledZ),$))continue;const ie=h.getId($,x),he=new p.al($,D,B,N,ie);he.tile=G,t.push(he)}}hasData(){return this.state==="loaded"||this.state==="reloading"||this.state==="expired"}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(t){const n=this.expirationTime;if(t.cacheControl){const h=p.am(t.cacheControl);h["max-age"]&&(this.expirationTime=Date.now()+1e3*h["max-age"])}else t.expires&&(this.expirationTime=new Date(t.expires).getTime());if(this.expirationTime){const h=Date.now();let f=!1;if(this.expirationTime>h)f=!1;else if(n)if(this.expirationTime<n)f=!0;else{const x=this.expirationTime-n;x?this.expirationTime=h+Math.max(x,3e4):f=!0}else f=!0;f?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-new Date().getTime(),Math.pow(2,31)-1)}setFeatureState(t,n){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData||Object.keys(t).length===0)return;const h=this.latestFeatureIndex.loadVTLayers();for(const f in this.buckets){if(!n.style.hasLayer(f))continue;const x=this.buckets[f],T=x.layers[0].sourceLayer||p.ai,C=h[T],D=t[T];if(!C||!D||Object.keys(D).length===0)continue;x.update(D,C,this.imageAtlas&&this.imageAtlas.patternPositions||{},this.dashPositions||{});const B=n&&n.style&&n.style.getLayer(f);B&&(this.queryPadding=Math.max(this.queryPadding,B.queryRadius(x)))}}holdingForSymbolFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<Gt()}clearSymbolFadeHold(){this.symbolFadeHoldUntil=void 0}setSymbolHoldDuration(t){this.symbolFadeHoldUntil=Gt()+t}setDependencies(t,n){const h={};for(const f of n)h[f]=!0;this.dependencies[t]=h}hasDependency(t,n){for(const h of t){const f=this.dependencies[h];if(f){for(const x of n)if(f[x])return!0}}return!1}}class ot{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,n,h){const f=String(n);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][f]=this.stateChanges[t][f]||{},p.e(this.stateChanges[t][f],h),this.deletedStates[t]===null){this.deletedStates[t]={};for(const x in this.state[t])x!==f&&(this.deletedStates[t][x]=null)}else if(this.deletedStates[t]&&this.deletedStates[t][f]===null){this.deletedStates[t][f]={};for(const x in this.state[t][f])h[x]||(this.deletedStates[t][f][x]=null)}else for(const x in h)this.deletedStates[t]&&this.deletedStates[t][f]&&this.deletedStates[t][f][x]===null&&delete this.deletedStates[t][f][x]}removeFeatureState(t,n,h){if(this.deletedStates[t]===null)return;const f=String(n);if(this.deletedStates[t]=this.deletedStates[t]||{},h&&n!==void 0)this.deletedStates[t][f]!==null&&(this.deletedStates[t][f]=this.deletedStates[t][f]||{},this.deletedStates[t][f][h]=null);else if(n!==void 0)if(this.stateChanges[t]&&this.stateChanges[t][f])for(h in this.deletedStates[t][f]={},this.stateChanges[t][f])this.deletedStates[t][f][h]=null;else this.deletedStates[t][f]=null;else this.deletedStates[t]=null}getState(t,n){const h=String(n),f=p.e({},(this.state[t]||{})[h],(this.stateChanges[t]||{})[h]);if(this.deletedStates[t]===null)return{};if(this.deletedStates[t]){const x=this.deletedStates[t][n];if(x===null)return{};for(const T in x)delete f[T]}return f}initializeTileState(t,n){t.setFeatureState(this.state,n)}coalesceChanges(t,n){const h={};for(const f in this.stateChanges){this.state[f]=this.state[f]||{};const x={};for(const T in this.stateChanges[f])this.state[f][T]||(this.state[f][T]={}),p.e(this.state[f][T],this.stateChanges[f][T]),x[T]=this.state[f][T];h[f]=x}for(const f in this.deletedStates){this.state[f]=this.state[f]||{};const x={};if(this.deletedStates[f]===null)for(const T in this.state[f])x[T]={},this.state[f][T]={};else for(const T in this.deletedStates[f]){if(this.deletedStates[f][T]===null)this.state[f][T]={};else for(const C of Object.keys(this.deletedStates[f][T]))delete this.state[f][T][C];x[T]=this.state[f][T]}h[f]=h[f]||{},p.e(h[f],x)}this.stateChanges={},this.deletedStates={},Object.keys(h).length!==0&&t.setFeatureState(h,n)}}const St=89.25;function je(y,t){const n=p.an(t.lat,-p.ao,p.ao);return new p.P(p.Y(t.lng)*y,p.X(n)*y)}function Xt(y,t){return new p.a9(t.x/y,t.y/y).toLngLat()}function Gi(y){return y.cameraToCenterDistance*Math.min(.85*Math.tan(p.ap(90-y.pitch)),Math.tan(p.ap(St-y.pitch)))}function Bi(y,t){const n=y.canonical,h=t/p.aq(n.z),f=n.x+Math.pow(2,n.z)*y.wrap,x=p.ar(new Float64Array(16));return p.O(x,x,[f*h,n.y*h,0]),p.Q(x,x,[h/p.a5,h/p.a5,1]),x}function qe(y,t,n,h,f){const x=p.a9.fromLngLat(y,t),T=f*p.as(1,y.lat),{x:C,y:D,z:B}=Hi(n,h);return new p.a9(x.x+T*-C,x.y+T*-D,x.z+T*-B)}function Hi(y,t){const n=p.ap(y),h=p.ap(t),f=Math.cos(-n),x=Math.sin(n);return{x:x*Math.sin(h),y:-x*Math.cos(h),z:f}}function rn(y,t,n){const h=t.intersectsFrustum(y);if(!n||h===0)return h;const f=t.intersectsPlane(n);return f===0?0:h===2&&f===2?2:1}function Kt(y,t,n){let h=0;const f=(n-t)/10;for(let x=0;x<10;x++)h+=f*Math.pow(Math.cos(t+(x+.5)/10*(n-t)),y);return h}function qi(y,t){return function(n,h,f,x,T){const C=2*((y-1)/p.at(Math.cos(p.ap(St-T))/Math.cos(p.ap(St)))-1),D=Math.acos(f/x),B=2*Kt(C-1,0,p.ap(T/2)),N=Math.min(p.ap(St),D+p.ap(T/2)),G=Kt(C-1,Math.min(N,D-p.ap(T/2)),N),U=Math.atan(h/f),$=Math.hypot(h,f);let ie=n;return ie+=p.at(x/$/Math.max(.5,Math.cos(p.ap(T/2)))),ie+=C*p.at(Math.cos(U))/2,ie-=p.at(Math.max(1,G/B/t))/2,ie}}const Vr=qi(9.314,3);function Wi(y,t){const n=(t.roundZoom?Math.round:Math.floor)(y.zoom+p.at(y.tileSize/t.tileSize));return Math.max(0,n)}function er(y,t){const n=y.getCameraFrustum(),h=y.getClippingPlane(),f=y.screenPointToMercatorCoordinate(y.getCameraPoint()),x=p.a9.fromLngLat(y.center,y.elevation);f.z=x.z+Math.cos(y.pitchInRadians)*y.cameraToCenterDistance/y.worldSize;const T=y.getCoveringTilesDetailsProvider(),C=T.allowVariableZoom(y,t),D=Wi(y,t),B=t.minzoom||0,N=t.maxzoom!==void 0?t.maxzoom:y.maxZoom,G=Math.min(Math.max(0,D),N),U=Math.pow(2,G),$=[U*f.x,U*f.y,0],ie=[U*x.x,U*x.y,0],he=Math.hypot(x.x-f.x,x.y-f.y),Ae=Math.abs(x.z-f.z),ce=Math.hypot(he,Ae),ye=we=>({zoom:0,x:0,y:0,wrap:we,fullyVisible:!1}),Pe=[],_e=[];if(y.renderWorldCopies&&T.allowWorldCopies())for(let we=1;we<=3;we++)Pe.push(ye(-we)),Pe.push(ye(we));for(Pe.push(ye(0));Pe.length>0;){const we=Pe.pop(),Ce=we.x,be=we.y;let Le=we.fullyVisible;const Ke={x:Ce,y:be,z:we.zoom},He=T.getTileBoundingVolume(Ke,we.wrap,y.elevation,t);if(!Le){const wt=rn(n,He,h);if(wt===0)continue;Le=wt===2}const $e=T.distanceToTile2d(f.x,f.y,Ke,He);let Ye=D;C&&(Ye=(t.calculateTileZoom||Vr)(y.zoom+p.at(y.tileSize/t.tileSize),$e,Ae,ce,y.fov)),Ye=(t.roundZoom?Math.round:Math.floor)(Ye),Ye=Math.max(0,Ye);const xt=Math.min(Ye,N);if(we.wrap=T.getWrap(x,Ke,we.wrap),we.zoom>=xt){if(we.zoom<B)continue;const wt=G-we.zoom,pt=$[0]-.5-(Ce<<wt),Pt=$[1]-.5-(be<<wt),mi=t.reparseOverscaled?Math.max(we.zoom,Ye):we.zoom;_e.push({tileID:new p.a2(we.zoom===N?mi:we.zoom,we.wrap,we.zoom,Ce,be),distanceSq:p.au([ie[0]-.5-Ce,ie[1]-.5-be]),tileDistanceToCamera:Math.sqrt(pt*pt+Pt*Pt)})}else for(let wt=0;wt<4;wt++)Pe.push({zoom:we.zoom+1,x:(Ce<<1)+wt%2,y:(be<<1)+(wt>>1),wrap:we.wrap,fullyVisible:Le})}return _e.sort(((we,Ce)=>we.distanceSq-Ce.distanceSq)).map((we=>we.tileID))}const Ve=p.aa.fromPoints([new p.P(0,0),new p.P(p.a5,p.a5)]);function at(y){return y==="raster"||y==="image"||y==="video"}function It(y,t,n,h,f,x,T){if(!t.hasData())return!1;const{tileID:C,fadingRole:D,fadingDirection:B,fadingParentID:N}=t;if(D===ke.Base&&B===Qe.Incoming&&N)return n[N.key]=N,!0;const G=Math.max(C.overscaledZ-f,x);for(let U=C.overscaledZ-1;U>=G;U--){const $=C.scaledTo(U),ie=y.getLoadedTile($);if(ie)return t.setCrossFadeLogic({fadingRole:ke.Base,fadingDirection:Qe.Incoming,fadingParentID:ie.tileID,fadeEndTime:h+T}),ie.setCrossFadeLogic({fadingRole:ke.Parent,fadingDirection:Qe.Departing,fadeEndTime:h+T}),n[$.key]=$,!0}return!1}function At(y,t,n,h,f,x){if(!t.hasData())return!1;const T=t.tileID.children(f);let C=o(y,t,T,n,h,f,x);if(C)return!0;for(const D of T)o(y,t,D.children(f),n,h,f,x)&&(C=!0);return C}function o(y,t,n,h,f,x,T){if(n[0].overscaledZ>=x)return!1;let C=!1;for(const D of n){const B=y.getLoadedTile(D);if(!B)continue;const{fadingRole:N,fadingDirection:G,fadingParentID:U}=B;N===ke.Base&&G===Qe.Departing&&U||(B.setCrossFadeLogic({fadingRole:ke.Base,fadingDirection:Qe.Departing,fadingParentID:t.tileID,fadeEndTime:f+T}),t.setCrossFadeLogic({fadingRole:ke.Parent,fadingDirection:Qe.Incoming,fadeEndTime:f+T})),h[D.key]=D,C=!0}return C}function X(y,t,n,h){const f=y.tileID;return!!y.selfFading||!y.hasData()&&!!t.has(f)&&(y.setSelfFadeLogic(n+h),!0)}function ii(y,t){var n;y.needsHillshadePrepare=!0,y.needsTerrainPrepare=!0;let h=t.tileID.canonical.x-y.tileID.canonical.x;const f=t.tileID.canonical.y-y.tileID.canonical.y,x=Math.pow(2,y.tileID.canonical.z),T=t.tileID.key;h===0&&f===0||Math.abs(f)>1||(Math.abs(h)>1&&(Math.abs(h+x)===1?h+=x:Math.abs(h-x)===1&&(h-=x)),t.dem&&y.dem&&(y.dem.backfillBorder(t.dem,h,f),!((n=y.neighboringTiles)===null||n===void 0)&&n[T]&&(y.neighboringTiles[T].backfilled=!0)))}class Ri{constructor(){this._tiles={}}handleWrapJump(t){const n={};for(const h in this._tiles){const f=this._tiles[h];f.tileID=f.tileID.unwrapTo(f.tileID.wrap+t),n[f.tileID.key]=f}this._tiles=n}setFeatureState(t,n){for(const h in this._tiles)this._tiles[h].setFeatureState(t,n)}getAllTiles(){return Object.values(this._tiles)}getAllIds(t=!1){return t?Object.values(this._tiles).map((n=>n.tileID)).sort(p.aw).map((n=>n.key)):Object.keys(this._tiles)}getTileById(t){return this._tiles[t]}setTile(t,n){this._tiles[t]=n}deleteTileById(t){delete this._tiles[t]}getLoadedTile(t){const n=this.getTileById(t.key);return n!=null&&n.hasData()?n:null}isIdRenderable(t,n=!1){var h;return(h=this.getTileById(t))===null||h===void 0?void 0:h.isRenderable(n)}getRenderableIds(t=0,n){const h=[];for(const f of this.getAllIds())this.isIdRenderable(f,n)&&h.push(this.getTileById(f));return n?h.sort(((f,x)=>{const T=f.tileID,C=x.tileID,D=new p.P(T.canonical.x,T.canonical.y)._rotate(-t),B=new p.P(C.canonical.x,C.canonical.y)._rotate(-t);return T.overscaledZ-C.overscaledZ||B.y-D.y||B.x-D.x})).map((f=>f.tileID.key)):h.map((f=>f.tileID)).sort(p.aw).map((f=>f.key))}}class Qi extends p.E{constructor(t,n,h){super(),this.id=t,this.dispatcher=h,this.on("data",(f=>this._dataHandler(f))),this.on("dataloading",(()=>{this._sourceErrored=!1})),this.on("error",(()=>{this._sourceErrored=this._source.loaded()})),this._source=((f,x,T,C)=>{const D=new(le(x.type))(f,x,T,C);if(D.id!==f)throw new Error(`Expected Source id to be ${f} instead of ${D.id}`);return D})(t,n,h,this),this._inViewTiles=new Ri,this._outOfViewCache=new p.ax(0,(f=>this._unloadTile(f))),this._timers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._rasterFadeDuration=0,this._maxFadingAncestorLevels=5,this._state=new ot,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&&this._source.onAdd&&this._source.onAdd(t)}onRemove(t){for(const n of this._inViewTiles.getAllTiles())n.unloadVectorData();this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(t),this._inViewTiles=new Ri}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;if(!(this.used===void 0&&this.usedForTerrain===void 0||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(const t of this._inViewTiles.getAllTiles())if(t.state!=="loaded"&&t.state!=="errored")return!1;return!0}getSource(){return this._source}getState(){return this._state}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}_loadTile(t,n,h){return p._(this,void 0,void 0,(function*(){try{yield this._source.loadTile(t),this._tileLoaded(t,n,h)}catch(f){t.state="errored",f.status!==404?this._source.fire(new p.k(f,{tile:t})):this.update(this.transform,this.terrain)}}))}_unloadTile(t){this._source.unloadTile&&this._source.unloadTile(t)}_abortTile(t){this._source.abortTile&&this._source.abortTile(t),this._source.fire(new p.l("dataabort",{tile:t,coord:t.tileID,dataType:"source"}))}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._inViewTiles,this.map?this.map.painter:null);for(const n of this._inViewTiles.getAllTiles())n.upload(t),n.prepare(this.map.style.imageManager)}getIds(){return this._inViewTiles.getAllIds(!0)}getRenderableIds(t){var n;return this._inViewTiles.getRenderableIds((n=this.transform)===null||n===void 0?void 0:n.bearingInRadians,t)}hasRenderableParent(t){const n=t.overscaledZ-1;if(n>=this._source.minzoom){const h=this.getLoadedTile(t.scaledTo(n));if(h)return this._inViewTiles.isIdRenderable(h.tileID.key)}return!1}reload(t,n=void 0){if(this._paused)this._shouldReloadOnResume=!0;else{this._outOfViewCache.reset();for(const h of this._inViewTiles.getAllIds()){const f=this._inViewTiles.getTileById(h);n&&!this._source.shouldReloadTile(f,n)||(t?this._reloadTile(h,"expired"):f.state!=="errored"&&this._reloadTile(h,"reloading"))}}}_reloadTile(t,n){return p._(this,void 0,void 0,(function*(){const h=this._inViewTiles.getTileById(t);h&&(h.state!=="loading"&&(h.state=n),yield this._loadTile(h,t,n))}))}_tileLoaded(t,n,h){t.timeAdded=Gt(),t.selfFading&&(t.fadeEndTime=t.timeAdded+this._rasterFadeDuration),h==="expired"&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(n,t),this.getSource().type==="raster-dem"&&t.dem&&(function(f,x){var T,C;const D=x.getRenderableIds();for(const B of D){if(!f.neighboringTiles||!f.neighboringTiles[B])continue;const N=x.getTileById(B);f.neighboringTiles[B].backfilled||ii(f,N),!((C=(T=N.neighboringTiles)===null||T===void 0?void 0:T[f.tileID.key])===null||C===void 0)&&C.backfilled||ii(N,f)}})(t,this._inViewTiles),this._state.initializeTileState(t,this.map?this.map.painter:null),t.aborted||this._source.fire(new p.l("data",{dataType:"source",tile:t,coord:t.tileID}))}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._inViewTiles.getTileById(t)}_retainLoadedChildren(t,n){const h=this._getLoadedDescendents(n),f=new Set;for(const x of n){const T=h[x.key];if(!(T!=null&&T.length)){f.add(x);continue}const C=x.overscaledZ+Qi.maxOverzooming,D=T.filter((G=>G.tileID.overscaledZ<=C));if(!D.length){f.add(x);continue}const B=Math.min(...D.map((G=>G.tileID.overscaledZ))),N=D.filter((G=>G.tileID.overscaledZ===B)).map((G=>G.tileID));for(const G of N)t[G.key]=G;this._areDescendentsComplete(N,B,x.overscaledZ)||f.add(x)}return f}_getLoadedDescendents(t){var n;const h={};for(const f of this._inViewTiles.getAllTiles().filter((x=>x.hasData())))for(const x of t)f.tileID.isChildOf(x)&&(h[n=x.key]||(h[n]=[])).push(f);return h}_areDescendentsComplete(t,n,h){return t.length===1&&t[0].isOverscaled()?t[0].overscaledZ===n:Math.pow(4,n-h)===t.length}getLoadedTile(t){return this._inViewTiles.getLoadedTile(t)}updateCacheSize(t){const n=Math.ceil(t.width/this._source.tileSize)+1,h=Math.ceil(t.height/this._source.tileSize)+1,f=Math.floor(n*h*(this._maxTileCacheZoomLevels===null?p.c.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),x=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,f):f;this._outOfViewCache.setMaxSize(x)}handleWrapJump(t){const n=Math.round((t-(this._prevLng===void 0?t:this._prevLng))/360);this._prevLng=t,n&&(this._inViewTiles.handleWrapJump(n),this._resetTileReloadTimers())}update(t,n){if(!this._sourceLoaded||this._paused)return;let h;this.transform=t,this.terrain=n,this.updateCacheSize(t),this.handleWrapJump(this.transform.center.lng),this.used||this.usedForTerrain?this._source.tileID?h=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((D=>new p.a2(D.canonical.z,D.wrap,D.canonical.z,D.canonical.x,D.canonical.y))):(h=er(t,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.type==="vector"&&this.map._zoomLevelsToOverscale!==void 0?t.maxZoom-this.map._zoomLevelsToOverscale:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:n,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(h=h.filter((D=>this._source.hasTile(D))))):h=[],this.usedForTerrain&&(h=this._addTerrainIdealTiles(h));const f=h.length===0&&!this._updated&&this._didEmitContent;this._updated=!0,f&&this.fire(new p.l("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const x=Wi(t,this._source),T=this._updateRetainedTiles(h,x),C=at(this._source.type);C&&this._rasterFadeDuration>0&&!n&&(function(D,B,N,G,U,$,ie){const he=Gt(),Ae=p.av(B);for(const ce of B){const ye=D.getTileById(ce.key);ye.fadingDirection!==Qe.Departing&&ye.fadeOpacity!==0||ye.resetFadeLogic(),It(D,ye,N,he,G,U,ie)||At(D,ye,N,he,$,ie)||X(ye,Ae,he,ie)||ye.resetFadeLogic()}})(this._inViewTiles,h,T,this._maxFadingAncestorLevels,this._source.minzoom,this._source.maxzoom,this._rasterFadeDuration),C?this._cleanUpRasterTiles(T):this._cleanUpVectorTiles(T)}_cleanUpRasterTiles(t){for(const n of this._inViewTiles.getAllIds())t[n]||this._removeTile(n)}_cleanUpVectorTiles(t){for(const n of this._inViewTiles.getAllIds()){const h=this._inViewTiles.getTileById(n);t[n]?h.clearSymbolFadeHold():h.hasSymbolBuckets?h.holdingForSymbolFade()?h.symbolFadeFinished()&&this._removeTile(n):h.setSymbolHoldDuration(this.map._fadeDuration):this._removeTile(n)}}_addTerrainIdealTiles(t){const n=[];for(const h of t)if(h.canonical.z>this._source.minzoom){const f=h.scaledTo(h.canonical.z-1);n.push(f);const x=h.scaledTo(Math.max(this._source.minzoom,Math.min(h.canonical.z,5)));n.push(x)}return t.concat(n)}releaseSymbolFadeTiles(){for(const t of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(t).holdingForSymbolFade()&&this._removeTile(t)}_updateRetainedTiles(t,n){var h;const f=new Set;for(const B of t)this._addTile(B).hasData()||f.add(B);const x=t.reduce(((B,N)=>(B[N.key]=N,B)),{}),T=this._retainLoadedChildren(x,f),C={},D=Math.max(n-Qi.maxUnderzooming,this._source.minzoom);for(const B of T){let N=this._inViewTiles.getTileById(B.key),G=N==null?void 0:N.wasRequested();for(let U=B.overscaledZ-1;U>=D;--U){const $=B.scaledTo(U);if(C[$.key])break;if(C[$.key]=!0,N=this.getTile($),!N&&G&&(N=this._addTile($)),N){const ie=N.hasData();if((ie||!(!((h=this.map)===null||h===void 0)&&h.cancelPendingTileRequestsWhileZooming)||G)&&(x[$.key]=$),G=N.wasRequested(),ie)break}}}return x}_addTile(t){let n=this._inViewTiles.getTileById(t.key);if(n)return n;n=this._outOfViewCache.getAndRemove(t),n&&(n.resetFadeLogic(),this._setTileReloadTimer(t.key,n),n.tileID=t,this._state.initializeTileState(n,this.map?this.map.painter:null));const h=n;return n||(n=new ft(t,this._source.tileSize*t.overscaleFactor()),this._loadTile(n,t.key,n.state)),n.uses++,this._inViewTiles.setTile(t.key,n),h||this._source.fire(new p.l("dataloading",{tile:n,coord:n.tileID,dataType:"source"})),n}_setTileReloadTimer(t,n){this._clearTileReloadTimer(t);const h=n.getExpiryTimeout();h&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),h))}_clearTileReloadTimer(t){const n=this._timers[t];n&&(clearTimeout(n),delete this._timers[t])}_resetTileReloadTimers(){for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t of this._inViewTiles.getAllIds()){const n=this._inViewTiles.getTileById(t);this._setTileReloadTimer(t,n)}}refreshTiles(t){for(const n of this._inViewTiles.getAllIds()){const h=this._inViewTiles.getTileById(n);(this._inViewTiles.isIdRenderable(n)||h.state=="errored")&&t.some((f=>f.equals(h.tileID.canonical)))&&this._reloadTile(n,"expired")}}_removeTile(t){const n=this._inViewTiles.getTileById(t);n&&(n.uses--,this._inViewTiles.deleteTileById(t),this._clearTileReloadTimer(t),n.uses>0||(n.hasData()&&n.state!=="reloading"?this._outOfViewCache.add(n.tileID,n,n.getExpiryTimeout()):(n.aborted=!0,this._abortTile(n),this._unloadTile(n))))}_dataHandler(t){t.dataType==="source"&&(t.sourceDataType!=="metadata"?t.sourceDataType==="content"&&this._sourceLoaded&&!this._paused&&(this.reload(t.sourceDataChanged,t.shouldReloadTileOptions),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0):this._sourceLoaded=!0)}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t of this._inViewTiles.getAllIds())this._removeTile(t);this._outOfViewCache.reset()}tilesIn(t,n,h){const f=[],x=this.transform;if(!x)return f;const T=x.getCoveringTilesDetailsProvider().allowWorldCopies(),C=h?x.getCameraQueryGeometry(t):t,D=$=>x.screenPointToMercatorCoordinate($,this.terrain),B=this.transformBbox(t,D,!T),N=this.transformBbox(C,D,!T),G=this.getIds(),U=p.aa.fromPoints(N);for(let $=0;$<G.length;$++){const ie=this._inViewTiles.getTileById(G[$]);if(ie.holdingForSymbolFade())continue;const he=T?[ie.tileID]:[ie.tileID.unwrapTo(-1),ie.tileID.unwrapTo(0)],Ae=Math.pow(2,x.zoom-ie.tileID.overscaledZ),ce=n*ie.queryPadding*p.a5/ie.tileSize/Ae;for(const ye of he){const Pe=U.map((_e=>ye.getTilePoint(new p.a9(_e.x,_e.y))));if(Pe.expandBy(ce),Pe.intersects(Ve)){const _e=B.map((Ce=>ye.getTilePoint(Ce))),we=N.map((Ce=>ye.getTilePoint(Ce)));f.push({tile:ie,tileID:T?ye:ye.unwrapTo(0),queryGeometry:_e,cameraQueryGeometry:we,scale:Ae})}}}return f}transformBbox(t,n,h){let f=t.map(n);if(h){const x=p.aa.fromPoints(t);x.shrinkBy(.001*Math.min(x.width(),x.height()));const T=x.map(n);p.aa.fromPoints(f).covers(T)||(f=f.map((C=>C.x>.5?new p.a9(C.x-1,C.y,C.z):C)))}return f}getVisibleCoordinates(t){const n=this.getRenderableIds(t).map((h=>this._inViewTiles.getTileById(h).tileID));return this.transform&&this.transform.populateCache(n),n}hasTransition(){return!!this._source.hasTransition()||!(!at(this._source.type)||!(function(t,n){if(n<=0)return!1;const h=Gt();for(const f of t.getAllTiles())if(f.fadeEndTime>=h)return!0;return!1})(this._inViewTiles,this._rasterFadeDuration))}setRasterFadeDuration(t){this._rasterFadeDuration=t}setFeatureState(t,n,h){this._state.updateState(t=t||p.ai,n,h)}removeFeatureState(t,n,h){this._state.removeFeatureState(t=t||p.ai,n,h)}getFeatureState(t,n){return this._state.getState(t=t||p.ai,n)}setDependencies(t,n,h){const f=this._inViewTiles.getTileById(t);f&&f.setDependencies(n,h)}reloadTilesForDependencies(t,n){for(const h of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(h).hasDependency(t,n)&&this._reloadTile(h,"reloading");this._outOfViewCache.filter((h=>!h.hasDependency(t,n)))}areTilesLoaded(){for(const t of this._inViewTiles.getAllTiles())if(t.state!=="loaded"&&t.state!=="errored")return!1;return!0}}Qi.maxUnderzooming=10,Qi.maxOverzooming=3;class ut{constructor(t,n){this.reset(t,n)}reset(t,n){this.points=t||[],this._distances=[0];for(let h=1;h<this.points.length;h++)this._distances[h]=this._distances[h-1]+this.points[h].dist(this.points[h-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(n||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(t){if(this.points.length===1)return this.points[0];t=p.an(t,0,1);let n=1,h=this._distances[n];const f=t*this.paddedLength+this.padding;for(;h<f&&n<this._distances.length;)h=this._distances[++n];const x=n-1,T=this._distances[x],C=h-T,D=C>0?(f-T)/C:0;return this.points[x].mult(1-D).add(this.points[n].mult(D))}}function zt(y,t){let n=!0;return y==="always"||y!=="never"&&t!=="never"||(n=!1),n}class $t{constructor(t,n,h){const f=this.boxCells=[],x=this.circleCells=[];this.xCellCount=Math.ceil(t/h),this.yCellCount=Math.ceil(n/h);for(let T=0;T<this.xCellCount*this.yCellCount;T++)f.push([]),x.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=t,this.height=n,this.xScale=this.xCellCount/t,this.yScale=this.yCellCount/n,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(t,n,h,f,x){this._forEachCell(n,h,f,x,this._insertBoxCell,this.boxUid++),this.boxKeys.push(t),this.bboxes.push(n),this.bboxes.push(h),this.bboxes.push(f),this.bboxes.push(x)}insertCircle(t,n,h,f){this._forEachCell(n-f,h-f,n+f,h+f,this._insertCircleCell,this.circleUid++),this.circleKeys.push(t),this.circles.push(n),this.circles.push(h),this.circles.push(f)}_insertBoxCell(t,n,h,f,x,T){this.boxCells[x].push(T)}_insertCircleCell(t,n,h,f,x,T){this.circleCells[x].push(T)}_query(t,n,h,f,x,T,C){if(h<0||t>this.width||f<0||n>this.height)return[];const D=[];if(t<=0&&n<=0&&this.width<=h&&this.height<=f){if(x)return[{key:null,x1:t,y1:n,x2:h,y2:f}];for(let B=0;B<this.boxKeys.length;B++)D.push({key:this.boxKeys[B],x1:this.bboxes[4*B],y1:this.bboxes[4*B+1],x2:this.bboxes[4*B+2],y2:this.bboxes[4*B+3]});for(let B=0;B<this.circleKeys.length;B++){const N=this.circles[3*B],G=this.circles[3*B+1],U=this.circles[3*B+2];D.push({key:this.circleKeys[B],x1:N-U,y1:G-U,x2:N+U,y2:G+U})}}else this._forEachCell(t,n,h,f,this._queryCell,D,{hitTest:x,overlapMode:T,seenUids:{box:{},circle:{}}},C);return D}query(t,n,h,f){return this._query(t,n,h,f,!1,null)}hitTest(t,n,h,f,x,T){return this._query(t,n,h,f,!0,x,T).length>0}hitTestCircle(t,n,h,f,x){const T=t-h,C=t+h,D=n-h,B=n+h;if(C<0||T>this.width||B<0||D>this.height)return!1;const N=[];return this._forEachCell(T,D,C,B,this._queryCellCircle,N,{hitTest:!0,overlapMode:f,circle:{x:t,y:n,radius:h},seenUids:{box:{},circle:{}}},x),N.length>0}_queryCell(t,n,h,f,x,T,C,D){const{seenUids:B,hitTest:N,overlapMode:G}=C,U=this.boxCells[x];if(U!==null){const ie=this.bboxes;for(const he of U)if(!B.box[he]){B.box[he]=!0;const Ae=4*he,ce=this.boxKeys[he];if(t<=ie[Ae+2]&&n<=ie[Ae+3]&&h>=ie[Ae+0]&&f>=ie[Ae+1]&&(!D||D(ce))&&(!N||!zt(G,ce.overlapMode))&&(T.push({key:ce,x1:ie[Ae],y1:ie[Ae+1],x2:ie[Ae+2],y2:ie[Ae+3]}),N))return!0}}const $=this.circleCells[x];if($!==null){const ie=this.circles;for(const he of $)if(!B.circle[he]){B.circle[he]=!0;const Ae=3*he,ce=this.circleKeys[he];if(this._circleAndRectCollide(ie[Ae],ie[Ae+1],ie[Ae+2],t,n,h,f)&&(!D||D(ce))&&(!N||!zt(G,ce.overlapMode))){const ye=ie[Ae],Pe=ie[Ae+1],_e=ie[Ae+2];if(T.push({key:ce,x1:ye-_e,y1:Pe-_e,x2:ye+_e,y2:Pe+_e}),N)return!0}}}return!1}_queryCellCircle(t,n,h,f,x,T,C,D){const{circle:B,seenUids:N,overlapMode:G}=C,U=this.boxCells[x];if(U!==null){const ie=this.bboxes;for(const he of U)if(!N.box[he]){N.box[he]=!0;const Ae=4*he,ce=this.boxKeys[he];if(this._circleAndRectCollide(B.x,B.y,B.radius,ie[Ae+0],ie[Ae+1],ie[Ae+2],ie[Ae+3])&&(!D||D(ce))&&!zt(G,ce.overlapMode))return T.push(!0),!0}}const $=this.circleCells[x];if($!==null){const ie=this.circles;for(const he of $)if(!N.circle[he]){N.circle[he]=!0;const Ae=3*he,ce=this.circleKeys[he];if(this._circlesCollide(ie[Ae],ie[Ae+1],ie[Ae+2],B.x,B.y,B.radius)&&(!D||D(ce))&&!zt(G,ce.overlapMode))return T.push(!0),!0}}}_forEachCell(t,n,h,f,x,T,C,D){const B=this._convertToXCellCoord(t),N=this._convertToYCellCoord(n),G=this._convertToXCellCoord(h),U=this._convertToYCellCoord(f);for(let $=B;$<=G;$++)for(let ie=N;ie<=U;ie++)if(x.call(this,t,n,h,f,this.xCellCount*ie+$,T,C,D))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,n,h,f,x,T){const C=f-t,D=x-n,B=h+T;return B*B>C*C+D*D}_circleAndRectCollide(t,n,h,f,x,T,C){const D=(T-f)/2,B=Math.abs(t-(f+D));if(B>D+h)return!1;const N=(C-x)/2,G=Math.abs(n-(x+N));if(G>N+h)return!1;if(B<=D||G<=N)return!0;const U=B-D,$=G-N;return U*U+$*$<=h*h}}function fi(y,t,n){const h=p.N();if(!y){const{vecSouth:G,vecEast:U}=jr(t),$=ur();$[0]=U[0],$[1]=U[1],$[2]=G[0],$[3]=G[1],f=$,(N=(T=(x=$)[0])*(B=x[3])-(D=x[2])*(C=x[1]))&&(f[0]=B*(N=1/N),f[1]=-C*N,f[2]=-D*N,f[3]=T*N),h[0]=$[0],h[1]=$[1],h[4]=$[2],h[5]=$[3]}var f,x,T,C,D,B,N;return p.Q(h,h,[1/n,1/n,1]),h}function di(y,t,n,h){if(y){const f=p.N();if(!t){const{vecSouth:x,vecEast:T}=jr(n);f[0]=T[0],f[1]=T[1],f[4]=x[0],f[5]=x[1]}return p.Q(f,f,[h,h,1]),f}return n.pixelsToClipSpaceMatrix}function jr(y){const t=Math.cos(y.rollInRadians),n=Math.sin(y.rollInRadians),h=Math.cos(y.pitchInRadians),f=Math.cos(y.bearingInRadians),x=Math.sin(y.bearingInRadians),T=p.aC();T[0]=-f*h*n-x*t,T[1]=-x*h*n+f*t;const C=p.aD(T);C<1e-9?p.aE(T):p.aF(T,T,1/C);const D=p.aC();D[0]=f*h*t-x*n,D[1]=x*h*t+f*n;const B=p.aD(D);return B<1e-9?p.aE(D):p.aF(D,D,1/B),{vecEast:D,vecSouth:T}}function ni(y,t,n,h){let f;h?(f=[y,t,h(y,t),1],p.aH(f,f,n)):(f=[y,t,0,1],te(f,f,n));const x=f[3];return{point:new p.P(f[0]/x,f[1]/x),signedDistanceFromCamera:x,isOccluded:!1}}function Ea(y,t){return .5+y/t*.5}function xo(y,t){return y.x>=-t[0]&&y.x<=t[0]&&y.y>=-t[1]&&y.y<=t[1]}function kn(y,t,n,h,f,x,T,C,D,B,N,G,U){const $=n?y.textSizeData:y.iconSizeData,ie=p.ay($,t.transform.zoom),he=[256/t.width*2+1,256/t.height*2+1],Ae=n?y.text.dynamicLayoutVertexArray:y.icon.dynamicLayoutVertexArray;Ae.clear();const ce=y.lineVertexArray,ye=n?y.text.placedSymbolArray:y.icon.placedSymbolArray,Pe=t.transform.width/t.transform.height;let _e=!1;for(let we=0;we<ye.length;we++){const Ce=ye.get(we);if(Ce.hidden||Ce.writingMode===p.az.vertical&&!_e){Xi(Ce.numGlyphs,Ae);continue}_e=!1;const be=new p.P(Ce.anchorX,Ce.anchorY),Le={getElevation:U,pitchedLabelPlaneMatrix:h,lineVertexArray:ce,pitchWithMap:x,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:t.transform,tileAnchorPoint:be,unwrappedTileID:D,width:B,height:N,translation:G},Ke=qt(Ce.anchorX,Ce.anchorY,Le);if(!xo(Ke.point,he)){Xi(Ce.numGlyphs,Ae);continue}const He=Ea(t.transform.cameraToCenterDistance,Ke.signedDistanceFromCamera),$e=p.aA($,ie,Ce),Ye=x?$e*t.transform.getPitchedTextCorrection(Ce.anchorX,Ce.anchorY,D)/He:$e*He,xt=bo({projectionContext:Le,pitchedLabelPlaneMatrixInverse:f,symbol:Ce,fontSize:Ye,flip:!1,keepUpright:T,glyphOffsetArray:y.glyphOffsetArray,dynamicLayoutVertexArray:Ae,aspectRatio:Pe,rotateToLine:C});_e=xt.useVertical,(xt.notEnoughRoom||_e||xt.needsFlipping&&bo({projectionContext:Le,pitchedLabelPlaneMatrixInverse:f,symbol:Ce,fontSize:Ye,flip:!0,keepUpright:T,glyphOffsetArray:y.glyphOffsetArray,dynamicLayoutVertexArray:Ae,aspectRatio:Pe,rotateToLine:C}).notEnoughRoom)&&Xi(Ce.numGlyphs,Ae)}n?y.text.dynamicLayoutVertexBuffer.updateData(Ae):y.icon.dynamicLayoutVertexBuffer.updateData(Ae)}function qn(y,t,n,h,f,x,T,C){const D=x.glyphStartIndex+x.numGlyphs,B=x.lineStartIndex,N=x.lineStartIndex+x.lineLength,G=t.getoffsetX(x.glyphStartIndex),U=t.getoffsetX(D-1),$=zn(y*G,n,h,f,x.segment,B,N,C,T);if(!$)return null;const ie=zn(y*U,n,h,f,x.segment,B,N,C,T);return ie?C.projectionCache.anyProjectionOccluded?null:{first:$,last:ie}:null}function Hn(y,t,n,h){return y===p.az.horizontal&&Math.abs(n.y-t.y)>Math.abs(n.x-t.x)*h?{useVertical:!0}:(y===p.az.vertical?t.y<n.y:t.x>n.x)?{needsFlipping:!0}:null}function bo(y){const{projectionContext:t,pitchedLabelPlaneMatrixInverse:n,symbol:h,fontSize:f,flip:x,keepUpright:T,glyphOffsetArray:C,dynamicLayoutVertexArray:D,aspectRatio:B,rotateToLine:N}=y,G=f/24,U=h.lineOffsetX*G,$=h.lineOffsetY*G;let ie;if(h.numGlyphs>1){const he=h.glyphStartIndex+h.numGlyphs,Ae=h.lineStartIndex,ce=h.lineStartIndex+h.lineLength,ye=qn(G,C,U,$,x,h,N,t);if(!ye)return{notEnoughRoom:!0};const Pe=ae(ye.first.point.x,ye.first.point.y,t,n),_e=ae(ye.last.point.x,ye.last.point.y,t,n);if(T&&!x){const we=Hn(h.writingMode,Pe,_e,B);if(we)return we}ie=[ye.first];for(let we=h.glyphStartIndex+1;we<he-1;we++){const Ce=zn(G*C.getoffsetX(we),U,$,x,h.segment,Ae,ce,t,N);if(!Ce)return{notEnoughRoom:!0};ie.push(Ce)}ie.push(ye.last)}else{if(T&&!x){const Ae=Ft(t.tileAnchorPoint.x,t.tileAnchorPoint.y,t).point,ce=h.lineStartIndex+h.segment+1,ye=new p.P(t.lineVertexArray.getx(ce),t.lineVertexArray.gety(ce)),Pe=Ft(ye.x,ye.y,t),_e=Pe.signedDistanceFromCamera>0?Pe.point:Sa(t.tileAnchorPoint,ye,Ae,1,t),we=ae(Ae.x,Ae.y,t,n),Ce=ae(_e.x,_e.y,t,n),be=Hn(h.writingMode,we,Ce,B);if(be)return be}const he=zn(G*C.getoffsetX(h.glyphStartIndex),U,$,x,h.segment,h.lineStartIndex,h.lineStartIndex+h.lineLength,t,N);if(!he||t.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};ie=[he]}for(const he of ie)p.aG(D,he.point,he.angle);return{}}function Sa(y,t,n,h,f){const x=y.add(y.sub(t)._unit()),T=Ft(x.x,x.y,f).point,C=n.sub(T);return n.add(C._mult(h/C.mag()))}function vr(y,t,n){const h=t.projectionCache;if(h.projections[y])return h.projections[y];const f=new p.P(t.lineVertexArray.getx(y),t.lineVertexArray.gety(y)),x=Ft(f.x,f.y,t);if(x.signedDistanceFromCamera>0)return h.projections[y]=x.point,h.anyProjectionOccluded=h.anyProjectionOccluded||x.isOccluded,x.point;const T=y-n.direction;return Sa(n.distanceFromAnchor===0?t.tileAnchorPoint:new p.P(t.lineVertexArray.getx(T),t.lineVertexArray.gety(T)),f,n.previousVertex,n.absOffsetX-n.distanceFromAnchor+1,t)}function Ft(y,t,n){const h=y+n.translation[0],f=t+n.translation[1];let x;return n.pitchWithMap?(x=ni(h,f,n.pitchedLabelPlaneMatrix,n.getElevation),x.isOccluded=!1):(x=n.transform.projectTileCoordinates(h,f,n.unwrappedTileID,n.getElevation),x.point.x=(.5*x.point.x+.5)*n.width,x.point.y=(.5*-x.point.y+.5)*n.height),x}function ae(y,t,n,h){if(n.pitchWithMap){const f=[y,t,0,1];return p.aH(f,f,h),n.transform.projectTileCoordinates(f[0]/f[3],f[1]/f[3],n.unwrappedTileID,n.getElevation).point}return{x:y/n.width*2-1,y:1-t/n.height*2}}function qt(y,t,n){return n.transform.projectTileCoordinates(y,t,n.unwrappedTileID,n.getElevation)}function Uo(y,t,n){return y._unit()._perp()._mult(t*n)}function wo(y,t,n,h,f,x,T,C,D){if(C.projectionCache.offsets[y])return C.projectionCache.offsets[y];const B=n.add(t);if(y+D.direction<h||y+D.direction>=f)return C.projectionCache.offsets[y]=B,B;const N=vr(y+D.direction,C,D),G=Uo(N.sub(n),T,D.direction),U=n.add(G),$=N.add(G);return C.projectionCache.offsets[y]=p.aI(x,B,U,$)||B,C.projectionCache.offsets[y]}function zn(y,t,n,h,f,x,T,C,D){const B=h?y-t:y+t;let N=B>0?1:-1,G=0;h&&(N*=-1,G=Math.PI),N<0&&(G+=Math.PI);let U,$=N>0?x+f:x+f+1;C.projectionCache.cachedAnchorPoint?U=C.projectionCache.cachedAnchorPoint:(U=Ft(C.tileAnchorPoint.x,C.tileAnchorPoint.y,C).point,C.projectionCache.cachedAnchorPoint=U);let ie,he,Ae=U,ce=U,ye=0,Pe=0;const _e=Math.abs(B),we=[];let Ce;for(;ye+Pe<=_e;){if($+=N,$<x||$>=T)return null;ye+=Pe,ce=Ae,he=ie;const Ke={absOffsetX:_e,direction:N,distanceFromAnchor:ye,previousVertex:ce};if(Ae=vr($,C,Ke),n===0)we.push(ce),Ce=Ae.sub(ce);else{let He;const $e=Ae.sub(ce);He=$e.mag()===0?Uo(vr($+N,C,Ke).sub(Ae),n,N):Uo($e,n,N),he||(he=ce.add(He)),ie=wo($,He,Ae,x,T,he,n,C,Ke),we.push(he),Ce=ie.sub(he)}Pe=Ce.mag()}const be=Ce._mult((_e-ye)/Pe)._add(he||ce),Le=G+Math.atan2(Ae.y-ce.y,Ae.x-ce.x);return we.push(be),{point:be,angle:D?Le:0,path:we}}const Fi=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function Xi(y,t){for(let n=0;n<y;n++){const h=t.length;t.resize(h+4),t.float32.set(Fi,3*h)}}function te(y,t,n){const h=t[0],f=t[1];return y[0]=n[0]*h+n[4]*f+n[12],y[1]=n[1]*h+n[5]*f+n[13],y[3]=n[3]*h+n[7]*f+n[15],y}const tr=100;class Go{constructor(t,n=new $t(t.width+200,t.height+200,25),h=new $t(t.width+200,t.height+200,25)){this.transform=t,this.grid=n,this.ignoredGrid=h,this.pitchFactor=Math.cos(t.pitch*Math.PI/180)*t.cameraToCenterDistance,this.screenRightBoundary=t.width+tr,this.screenBottomBoundary=t.height+tr,this.gridRightBoundary=t.width+200,this.gridBottomBoundary=t.height+200,this.perspectiveRatioCutoff=.6}placeCollisionBox(t,n,h,f,x,T,C,D,B,N,G,U){const $=this.projectAndGetPerspectiveRatio(t.anchorPointX+D[0],t.anchorPointY+D[1],x,N,U),ie=h*$.perspectiveRatio;let he;if(T||C)he=this._projectCollisionBox(t,ie,f,x,T,C,D,$,N,G,U);else{const Ce=$.x+(G?G.x*ie:0),be=$.y+(G?G.y*ie:0);he={allPointsOccluded:!1,box:[Ce+t.x1*ie,be+t.y1*ie,Ce+t.x2*ie,be+t.y2*ie]}}const[Ae,ce,ye,Pe]=he.box,_e=T?he.allPointsOccluded:$.isOccluded;let we=_e;return we||(we=$.perspectiveRatio<this.perspectiveRatioCutoff),we||(we=!this.isInsideGrid(Ae,ce,ye,Pe)),we||n!=="always"&&this.grid.hitTest(Ae,ce,ye,Pe,n,B)?{box:[Ae,ce,ye,Pe],placeable:!1,offscreen:!1,occluded:_e}:{box:[Ae,ce,ye,Pe],placeable:!0,offscreen:this.isOffscreen(Ae,ce,ye,Pe),occluded:_e}}placeCollisionCircles(t,n,h,f,x,T,C,D,B,N,G,U,$,ie){const he=[],Ae=new p.P(n.anchorX,n.anchorY),ce=this.getPerspectiveRatio(Ae.x,Ae.y,T,ie),ye=(B?x*this.transform.getPitchedTextCorrection(n.anchorX,n.anchorY,T)/ce:x*ce)/p.aM,Pe={getElevation:ie,pitchedLabelPlaneMatrix:C,lineVertexArray:h,pitchWithMap:B,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:this.transform,tileAnchorPoint:Ae,unwrappedTileID:T,width:this.transform.width,height:this.transform.height,translation:$},_e=qn(ye,f,n.lineOffsetX*ye,n.lineOffsetY*ye,!1,n,!1,Pe);let we=!1,Ce=!1,be=!0;if(_e){const Le=.5*G*ce+U,Ke=new p.P(-100,-100),He=new p.P(this.screenRightBoundary,this.screenBottomBoundary),$e=new ut,Ye=_e.first,xt=_e.last;let wt=[];for(let mi=Ye.path.length-1;mi>=1;mi--)wt.push(Ye.path[mi]);for(let mi=1;mi<xt.path.length;mi++)wt.push(xt.path[mi]);const pt=2.5*Le;if(B){const mi=this.projectPathToScreenSpace(wt,Pe);wt=mi.some((sr=>sr.signedDistanceFromCamera<=0))?[]:mi.map((sr=>sr.point))}let Pt=[];if(wt.length>0){const mi=wt[0].clone(),sr=wt[0].clone();for(let Dr=1;Dr<wt.length;Dr++)mi.x=Math.min(mi.x,wt[Dr].x),mi.y=Math.min(mi.y,wt[Dr].y),sr.x=Math.max(sr.x,wt[Dr].x),sr.y=Math.max(sr.y,wt[Dr].y);Pt=mi.x>=Ke.x&&sr.x<=He.x&&mi.y>=Ke.y&&sr.y<=He.y?[wt]:sr.x<Ke.x||mi.x>He.x||sr.y<Ke.y||mi.y>He.y?[]:p.aJ([wt],Ke.x,Ke.y,He.x,He.y)}for(const mi of Pt){$e.reset(mi,.25*Le);let sr=0;sr=$e.length<=.5*Le?1:Math.ceil($e.paddedLength/pt)+1;for(let Dr=0;Dr<sr;Dr++){const mr=Dr/Math.max(sr-1,1),Rr=$e.lerp(mr),_r=Rr.x+tr,Yr=Rr.y+tr;he.push(_r,Yr,Le,0);const Fr=_r-Le,rs=Yr-Le,dn=_r+Le,an=Yr+Le;if(be=be&&this.isOffscreen(Fr,rs,dn,an),Ce=Ce||this.isInsideGrid(Fr,rs,dn,an),t!=="always"&&this.grid.hitTestCircle(_r,Yr,Le,t,N)&&(we=!0,!D))return{circles:[],offscreen:!1,collisionDetected:we}}}}return{circles:!D&&we||!Ce||ce<this.perspectiveRatioCutoff?[]:he,offscreen:be,collisionDetected:we}}projectPathToScreenSpace(t,n){const h=(function(f,x){const T=p.N();return p.aB(T,x.pitchedLabelPlaneMatrix),f.map((C=>{const D=ni(C.x,C.y,T,x.getElevation),B=x.transform.projectTileCoordinates(D.point.x,D.point.y,x.unwrappedTileID,x.getElevation);return B.point.x=(.5*B.point.x+.5)*x.width,B.point.y=(.5*-B.point.y+.5)*x.height,B}))})(t,n);return(function(f){let x=0,T=0,C=0,D=0;for(let B=0;B<f.length;B++)f[B].isOccluded?(C=B+1,D=0):(D++,D>T&&(T=D,x=C));return f.slice(x,x+T)})(h)}queryRenderedSymbols(t){if(t.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};const n=[],h=new p.aa;for(const G of t){const U=new p.P(G.x+tr,G.y+tr);h.extend(U),n.push(U)}const{minX:f,minY:x,maxX:T,maxY:C}=h,D=this.grid.query(f,x,T,C).concat(this.ignoredGrid.query(f,x,T,C)),B={},N={};for(const G of D){const U=G.key;if(B[U.bucketInstanceId]===void 0&&(B[U.bucketInstanceId]={}),B[U.bucketInstanceId][U.featureIndex])continue;const $=[new p.P(G.x1,G.y1),new p.P(G.x2,G.y1),new p.P(G.x2,G.y2),new p.P(G.x1,G.y2)];p.aK(n,$)&&(B[U.bucketInstanceId][U.featureIndex]=!0,N[U.bucketInstanceId]===void 0&&(N[U.bucketInstanceId]=[]),N[U.bucketInstanceId].push(U.featureIndex))}return N}insertCollisionBox(t,n,h,f,x,T){(h?this.ignoredGrid:this.grid).insert({bucketInstanceId:f,featureIndex:x,collisionGroupID:T,overlapMode:n},t[0],t[1],t[2],t[3])}insertCollisionCircles(t,n,h,f,x,T){const C=h?this.ignoredGrid:this.grid,D={bucketInstanceId:f,featureIndex:x,collisionGroupID:T,overlapMode:n};for(let B=0;B<t.length;B+=4)C.insertCircle(D,t[B],t[B+1],t[B+2])}projectAndGetPerspectiveRatio(t,n,h,f,x){if(x){let T;f?(T=[t,n,f(t,n),1],p.aH(T,T,x)):(T=[t,n,0,1],te(T,T,x));const C=T[3];return{x:(T[0]/C+1)/2*this.transform.width+tr,y:(-T[1]/C+1)/2*this.transform.height+tr,perspectiveRatio:.5+this.transform.cameraToCenterDistance/C*.5,isOccluded:!1,signedDistanceFromCamera:C}}{const T=this.transform.projectTileCoordinates(t,n,h,f);return{x:(T.point.x+1)/2*this.transform.width+tr,y:(1-T.point.y)/2*this.transform.height+tr,perspectiveRatio:.5+this.transform.cameraToCenterDistance/T.signedDistanceFromCamera*.5,isOccluded:T.isOccluded,signedDistanceFromCamera:T.signedDistanceFromCamera}}}getPerspectiveRatio(t,n,h,f){const x=this.transform.projectTileCoordinates(t,n,h,f);return .5+this.transform.cameraToCenterDistance/x.signedDistanceFromCamera*.5}isOffscreen(t,n,h,f){return h<tr||t>=this.screenRightBoundary||f<tr||n>this.screenBottomBoundary}isInsideGrid(t,n,h,f){return h>=0&&t<this.gridRightBoundary&&f>=0&&n<this.gridBottomBoundary}getViewportMatrix(){const t=p.ar([]);return p.O(t,t,[-100,-100,0]),t}_projectCollisionBox(t,n,h,f,x,T,C,D,B,N,G){let U=1,$=0,ie=0,he=1;const Ae=t.anchorPointX+C[0],ce=t.anchorPointY+C[1];if(T&&!x){const wt=this.projectAndGetPerspectiveRatio(Ae+1,ce,f,B,G),pt=wt.x-D.x,Pt=Math.atan((wt.y-D.y)/pt)+(pt<0?Math.PI:0),mi=Math.sin(Pt),sr=Math.cos(Pt);U=sr,$=mi,ie=-mi,he=sr}else if(!T&&x){const wt=jr(this.transform);U=wt.vecEast[0],$=wt.vecEast[1],ie=wt.vecSouth[0],he=wt.vecSouth[1]}let ye=D.x,Pe=D.y,_e=n;x&&(ye=Ae,Pe=ce,_e=Math.pow(2,-(this.transform.zoom-h.overscaledZ)),_e*=this.transform.getPitchedTextCorrection(Ae,ce,f),N||(_e*=p.an(.5+D.signedDistanceFromCamera/this.transform.cameraToCenterDistance*.5,0,4))),N&&(ye+=U*N.x*_e+ie*N.y*_e,Pe+=$*N.x*_e+he*N.y*_e);const we=t.x1*_e,Ce=t.x2*_e,be=(we+Ce)/2,Le=t.y1*_e,Ke=t.y2*_e,He=(Le+Ke)/2,$e=[{offsetX:we,offsetY:Le},{offsetX:be,offsetY:Le},{offsetX:Ce,offsetY:Le},{offsetX:Ce,offsetY:He},{offsetX:Ce,offsetY:Ke},{offsetX:be,offsetY:Ke},{offsetX:we,offsetY:Ke},{offsetX:we,offsetY:He}];let Ye=[];for(const{offsetX:wt,offsetY:pt}of $e)Ye.push(new p.P(ye+U*wt+ie*pt,Pe+$*wt+he*pt));let xt=!1;if(x){const wt=Ye.map((pt=>this.projectAndGetPerspectiveRatio(pt.x,pt.y,f,B,G)));xt=wt.some((pt=>!pt.isOccluded)),Ye=wt.map((pt=>new p.P(pt.x,pt.y)))}else xt=!0;return{box:p.aL(Ye),allPointsOccluded:!xt}}}class Ha{constructor(t,n,h,f){this.opacity=t?Math.max(0,Math.min(1,t.opacity+(t.placed?n:-n))):f&&h?1:0,this.placed=h}isHidden(){return this.opacity===0&&!this.placed}}class _i{constructor(t,n,h,f,x){this.text=new Ha(t?t.text:null,n,h,x),this.icon=new Ha(t?t.icon:null,n,f,x)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class Sr{constructor(t,n,h){this.text=t,this.icon=n,this.skipFade=h}}class Wa{constructor(t,n,h,f,x){this.bucketInstanceId=t,this.featureIndex=n,this.sourceLayerIndex=h,this.bucketIndex=f,this.tileID=x}}class ha{constructor(t){this.crossSourceCollisions=t,this.maxGroupID=0,this.collisionGroups={}}get(t){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[t]){const n=++this.maxGroupID;this.collisionGroups[t]={ID:n,predicate:h=>h.collisionGroupID===n}}return this.collisionGroups[t]}}function _n(y,t,n,h,f){const{horizontalAlign:x,verticalAlign:T}=p.aS(y);return new p.P(-(x-.5)*t+h[0]*f,-(T-.5)*n+h[1]*f)}class Qa{constructor(t,n,h,f,x){this.transform=t.clone(),this.terrain=n,this.collisionIndex=new Go(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=h,this.retainedQueryData={},this.collisionGroups=new ha(f),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=x,x&&(x.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(t){const n=this.terrain;return n?(h,f)=>n.getElevation(t,h,f):null}getBucketParts(t,n,h,f){const x=h.getBucket(n),T=h.latestFeatureIndex;if(!x||!T||n.id!==x.layerIds[0])return;const C=h.collisionBoxArray,D=x.layers[0].layout,B=x.layers[0].paint,N=Math.pow(2,this.transform.zoom-h.tileID.overscaledZ),G=h.tileSize/p.a5,U=h.tileID.toUnwrapped(),$=D.get("text-rotation-alignment")==="map",ie=p.aN(h,1,this.transform.zoom),he=p.aO(this.collisionIndex.transform,h,B.get("text-translate"),B.get("text-translate-anchor")),Ae=p.aO(this.collisionIndex.transform,h,B.get("icon-translate"),B.get("icon-translate-anchor")),ce=fi($,this.transform,ie);this.retainedQueryData[x.bucketInstanceId]=new Wa(x.bucketInstanceId,T,x.sourceLayerIndex,x.index,h.tileID);const ye={bucket:x,layout:D,translationText:he,translationIcon:Ae,unwrappedTileID:U,pitchedLabelPlaneMatrix:ce,scale:N,textPixelRatio:G,holdingForFade:h.holdingForSymbolFade(),collisionBoxArray:C,partiallyEvaluatedTextSize:p.ay(x.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(x.sourceID)};if(f)for(const Pe of x.sortKeyRanges){const{sortKey:_e,symbolInstanceStart:we,symbolInstanceEnd:Ce}=Pe;t.push({sortKey:_e,symbolInstanceStart:we,symbolInstanceEnd:Ce,parameters:ye})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:x.symbolInstances.length,parameters:ye})}attemptAnchorPlacement(t,n,h,f,x,T,C,D,B,N,G,U,$,ie,he,Ae,ce,ye,Pe,_e){const we=p.aP[t.textAnchor],Ce=[t.textOffset0,t.textOffset1],be=_n(we,h,f,Ce,x),Le=this.collisionIndex.placeCollisionBox(n,U,D,B,N,C,T,Ae,G.predicate,Pe,be,_e);if((!ye||this.collisionIndex.placeCollisionBox(ye,U,D,B,N,C,T,ce,G.predicate,Pe,be,_e).placeable)&&Le.placeable){let Ke;if(this.prevPlacement&&this.prevPlacement.variableOffsets[$.crossTileID]&&this.prevPlacement.placements[$.crossTileID]&&this.prevPlacement.placements[$.crossTileID].text&&(Ke=this.prevPlacement.variableOffsets[$.crossTileID].anchor),$.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[$.crossTileID]={textOffset:Ce,width:h,height:f,anchor:we,textBoxScale:x,prevAnchor:Ke},this.markUsedJustification(ie,we,$,he),ie.allowVerticalPlacement&&(this.markUsedOrientation(ie,he,$),this.placedOrientations[$.crossTileID]=he),{shift:be,placedGlyphBoxes:Le}}}placeLayerBucketPart(t,n,h){const{bucket:f,layout:x,translationText:T,translationIcon:C,unwrappedTileID:D,pitchedLabelPlaneMatrix:B,textPixelRatio:N,holdingForFade:G,collisionBoxArray:U,partiallyEvaluatedTextSize:$,collisionGroup:ie}=t.parameters,he=x.get("text-optional"),Ae=x.get("icon-optional"),ce=p.aQ(x,"text-overlap","text-allow-overlap"),ye=ce==="always",Pe=p.aQ(x,"icon-overlap","icon-allow-overlap"),_e=Pe==="always",we=x.get("text-rotation-alignment")==="map",Ce=x.get("text-pitch-alignment")==="map",be=x.get("icon-text-fit")!=="none",Le=x.get("symbol-z-order")==="viewport-y",Ke=ye&&(_e||!f.hasIconData()||Ae),He=_e&&(ye||!f.hasTextData()||he);!f.collisionArrays&&U&&f.deserializeCollisionBoxes(U);const $e=this.retainedQueryData[f.bucketInstanceId].tileID,Ye=this._getTerrainElevationFunc($e),xt=this.transform.getFastPathSimpleProjectionMatrix($e),wt=(pt,Pt,mi)=>{var sr,Dr;if(n[pt.crossTileID])return;if(G)return void(this.placements[pt.crossTileID]=new Sr(!1,!1,!1));let mr=!1,Rr=!1,_r=!0,Yr=null,Fr={box:null,placeable:!1,offscreen:null,occluded:!1},rs={placeable:!1},dn=null,an=null,ms=null,cl=0,Va=0,wa=0;Pt.textFeatureIndex?cl=Pt.textFeatureIndex:pt.useRuntimeCollisionCircles&&(cl=pt.featureIndex),Pt.verticalTextFeatureIndex&&(Va=Pt.verticalTextFeatureIndex);const eo=Pt.textBox;if(eo){const zo=Tr=>{let gr=p.az.horizontal;if(f.allowVerticalPlacement&&!Tr&&this.prevPlacement){const Vn=this.prevPlacement.placedOrientations[pt.crossTileID];Vn&&(this.placedOrientations[pt.crossTileID]=Vn,gr=Vn,this.markUsedOrientation(f,gr,pt))}return gr},Ta=(Tr,gr)=>{if(f.allowVerticalPlacement&&pt.numVerticalGlyphVertices>0&&Pt.verticalTextBox){for(const Vn of f.writingModes)if(Vn===p.az.vertical?(Fr=gr(),rs=Fr):Fr=Tr(),Fr&&Fr.placeable)break}else Fr=Tr()},na=pt.textAnchorOffsetStartIndex,sa=pt.textAnchorOffsetEndIndex;if(sa===na){const Tr=(gr,Vn)=>{const jn=this.collisionIndex.placeCollisionBox(gr,ce,N,$e,D,Ce,we,T,ie.predicate,Ye,void 0,xt);return jn&&jn.placeable&&(this.markUsedOrientation(f,Vn,pt),this.placedOrientations[pt.crossTileID]=Vn),jn};Ta((()=>Tr(eo,p.az.horizontal)),(()=>{const gr=Pt.verticalTextBox;return f.allowVerticalPlacement&&pt.numVerticalGlyphVertices>0&&gr?Tr(gr,p.az.vertical):{box:null,offscreen:null}})),zo(Fr&&Fr.placeable)}else{let Tr=p.aP[(Dr=(sr=this.prevPlacement)===null||sr===void 0?void 0:sr.variableOffsets[pt.crossTileID])===null||Dr===void 0?void 0:Dr.anchor];const gr=(jn,$h,Yh)=>{const Ll=jn.x2-jn.x1,kc=jn.y2-jn.y1,Xh=pt.textBoxScale,xh=be&&Pe==="never"?$h:null;let Al=null,fl=ce==="never"?1:2,dl="never";Tr&&fl++;for(let bh=0;bh<fl;bh++){for(let wh=na;wh<sa;wh++){const Hu=f.textAnchorOffsets.get(wh);if(Tr&&Hu.textAnchor!==Tr)continue;const Wu=this.attemptAnchorPlacement(Hu,jn,Ll,kc,Xh,we,Ce,N,$e,D,ie,dl,pt,f,Yh,T,C,xh,Ye);if(Wu&&(Al=Wu.placedGlyphBoxes,Al&&Al.placeable))return mr=!0,Yr=Wu.shift,Al}Tr?Tr=null:dl=ce}return h&&!Al&&(Al={box:this.collisionIndex.placeCollisionBox(eo,"always",N,$e,D,Ce,we,T,ie.predicate,Ye,void 0,xt).box,offscreen:!1,placeable:!1,occluded:!1}),Al};Ta((()=>gr(eo,Pt.iconBox,p.az.horizontal)),(()=>{const jn=Pt.verticalTextBox;return f.allowVerticalPlacement&&(!Fr||!Fr.placeable)&&pt.numVerticalGlyphVertices>0&&jn?gr(jn,Pt.verticalIconBox,p.az.vertical):{box:null,occluded:!0,offscreen:null}})),Fr&&(mr=Fr.placeable,_r=Fr.offscreen);const Vn=zo(Fr&&Fr.placeable);if(!mr&&this.prevPlacement){const jn=this.prevPlacement.variableOffsets[pt.crossTileID];jn&&(this.variableOffsets[pt.crossTileID]=jn,this.markUsedJustification(f,jn.anchor,pt,Vn))}}}if(dn=Fr,mr=dn&&dn.placeable,_r=dn&&dn.offscreen,pt.useRuntimeCollisionCircles&&pt.centerJustifiedTextSymbolIndex>=0){const zo=f.text.placedSymbolArray.get(pt.centerJustifiedTextSymbolIndex),Ta=p.aA(f.textSizeData,$,zo),na=x.get("text-padding");an=this.collisionIndex.placeCollisionCircles(ce,zo,f.lineVertexArray,f.glyphOffsetArray,Ta,D,B,h,Ce,ie.predicate,pt.collisionCircleDiameter,na,T,Ye),an.circles.length&&an.collisionDetected&&!h&&p.w("Collisions detected, but collision boxes are not shown"),mr=ye||an.circles.length>0&&!an.collisionDetected,_r=_r&&an.offscreen}if(Pt.iconFeatureIndex&&(wa=Pt.iconFeatureIndex),Pt.iconBox){const zo=Ta=>this.collisionIndex.placeCollisionBox(Ta,Pe,N,$e,D,Ce,we,C,ie.predicate,Ye,be&&Yr?Yr:void 0,xt);rs&&rs.placeable&&Pt.verticalIconBox?(ms=zo(Pt.verticalIconBox),Rr=ms.placeable):(ms=zo(Pt.iconBox),Rr=ms.placeable),_r=_r&&ms.offscreen}const kl=he||pt.numHorizontalGlyphVertices===0&&pt.numVerticalGlyphVertices===0,Mu=Ae||pt.numIconVertices===0;kl||Mu?Mu?kl||(Rr=Rr&&mr):mr=Rr&&mr:Rr=mr=Rr&&mr;const zl=Rr&&ms.placeable;if(mr&&dn.placeable&&this.collisionIndex.insertCollisionBox(dn.box,ce,x.get("text-ignore-placement"),f.bucketInstanceId,rs&&rs.placeable&&Va?Va:cl,ie.ID),zl&&this.collisionIndex.insertCollisionBox(ms.box,Pe,x.get("icon-ignore-placement"),f.bucketInstanceId,wa,ie.ID),an&&mr&&this.collisionIndex.insertCollisionCircles(an.circles,ce,x.get("text-ignore-placement"),f.bucketInstanceId,cl,ie.ID),h&&this.storeCollisionData(f.bucketInstanceId,mi,Pt,dn,ms,an),pt.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");if(f.bucketInstanceId===0)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[pt.crossTileID]=new Sr((mr||Ke)&&!(dn!=null&&dn.occluded),(Rr||He)&&!(ms!=null&&ms.occluded),_r||f.justReloaded),n[pt.crossTileID]=!0};if(Le){if(t.symbolInstanceStart!==0)throw new Error("bucket.bucketInstanceId should be 0");const pt=f.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let Pt=pt.length-1;Pt>=0;--Pt){const mi=pt[Pt];wt(f.symbolInstances.get(mi),f.collisionArrays[mi],mi)}}else for(let pt=t.symbolInstanceStart;pt<t.symbolInstanceEnd;pt++)wt(f.symbolInstances.get(pt),f.collisionArrays[pt],pt);f.justReloaded=!1}storeCollisionData(t,n,h,f,x,T){if(h.textBox||h.iconBox){let C,D;this.collisionBoxArrays.has(t)?C=this.collisionBoxArrays.get(t):(C=new Map,this.collisionBoxArrays.set(t,C)),C.has(n)?D=C.get(n):(D={text:null,icon:null},C.set(n,D)),h.textBox&&(D.text=f.box),h.iconBox&&(D.icon=x.box)}if(T){let C=this.collisionCircleArrays[t];C===void 0&&(C=this.collisionCircleArrays[t]=[]);for(let D=0;D<T.circles.length;D+=4)C.push(T.circles[D+0]-tr),C.push(T.circles[D+1]-tr),C.push(T.circles[D+2]),C.push(T.collisionDetected?1:0)}}markUsedJustification(t,n,h,f){let x;x=f===p.az.vertical?h.verticalPlacedTextSymbolIndex:{left:h.leftJustifiedTextSymbolIndex,center:h.centerJustifiedTextSymbolIndex,right:h.rightJustifiedTextSymbolIndex}[p.aR(n)];const T=[h.leftJustifiedTextSymbolIndex,h.centerJustifiedTextSymbolIndex,h.rightJustifiedTextSymbolIndex,h.verticalPlacedTextSymbolIndex];for(const C of T)C>=0&&(t.text.placedSymbolArray.get(C).crossTileID=x>=0&&C!==x?0:h.crossTileID)}markUsedOrientation(t,n,h){const f=n===p.az.horizontal||n===p.az.horizontalOnly?n:0,x=n===p.az.vertical?n:0,T=[h.leftJustifiedTextSymbolIndex,h.centerJustifiedTextSymbolIndex,h.rightJustifiedTextSymbolIndex];for(const C of T)t.text.placedSymbolArray.get(C).placedOrientation=f;h.verticalPlacedTextSymbolIndex&&(t.text.placedSymbolArray.get(h.verticalPlacedTextSymbolIndex).placedOrientation=x)}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;const n=this.prevPlacement;let h=!1;this.prevZoomAdjustment=n?n.zoomAdjustment(this.transform.zoom):0;const f=n?n.symbolFadeChange(t):1,x=n?n.opacities:{},T=n?n.variableOffsets:{},C=n?n.placedOrientations:{};for(const D in this.placements){const B=this.placements[D],N=x[D];N?(this.opacities[D]=new _i(N,f,B.text,B.icon),h=h||B.text!==N.text.placed||B.icon!==N.icon.placed):(this.opacities[D]=new _i(null,f,B.text,B.icon,B.skipFade),h=h||B.text||B.icon)}for(const D in x){const B=x[D];if(!this.opacities[D]){const N=new _i(B,f,!1,!1);N.isHidden()||(this.opacities[D]=N,h=h||B.text.placed||B.icon.placed)}}for(const D in T)this.variableOffsets[D]||!this.opacities[D]||this.opacities[D].isHidden()||(this.variableOffsets[D]=T[D]);for(const D in C)this.placedOrientations[D]||!this.opacities[D]||this.opacities[D].isHidden()||(this.placedOrientations[D]=C[D]);if(n&&n.lastPlacementChangeTime===void 0)throw new Error("Last placement time for previous placement is not defined");h?this.lastPlacementChangeTime=t:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=n?n.lastPlacementChangeTime:t)}updateLayerOpacities(t,n){const h={};for(const f of n){const x=f.getBucket(t);x&&f.latestFeatureIndex&&t.id===x.layerIds[0]&&this.updateBucketOpacities(x,f.tileID,h,f.collisionBoxArray)}}updateBucketOpacities(t,n,h,f){t.hasTextData()&&(t.text.opacityVertexArray.clear(),t.text.hasVisibleVertices=!1),t.hasIconData()&&(t.icon.opacityVertexArray.clear(),t.icon.hasVisibleVertices=!1),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const x=t.layers[0],T=x.layout,C=new _i(null,0,!1,!1,!0),D=T.get("text-allow-overlap"),B=T.get("icon-allow-overlap"),N=x._unevaluatedLayout.hasValue("text-variable-anchor")||x._unevaluatedLayout.hasValue("text-variable-anchor-offset"),G=T.get("text-rotation-alignment")==="map",U=T.get("text-pitch-alignment")==="map",$=T.get("icon-text-fit")!=="none",ie=new _i(null,0,D&&(B||!t.hasIconData()||T.get("icon-optional")),B&&(D||!t.hasTextData()||T.get("text-optional")),!0);!t.collisionArrays&&f&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(f);const he=(ce,ye,Pe)=>{for(let _e=0;_e<ye/4;_e++)ce.opacityVertexArray.emplaceBack(Pe);ce.hasVisibleVertices=ce.hasVisibleVertices||Pe!==qo},Ae=this.collisionBoxArrays.get(t.bucketInstanceId);for(let ce=0;ce<t.symbolInstances.length;ce++){const ye=t.symbolInstances.get(ce),{numHorizontalGlyphVertices:Pe,numVerticalGlyphVertices:_e,crossTileID:we}=ye;let Ce=this.opacities[we];h[we]?Ce=C:Ce||(Ce=ie,this.opacities[we]=Ce),h[we]=!0;const be=ye.numIconVertices>0,Le=this.placedOrientations[ye.crossTileID],Ke=Le===p.az.vertical,He=Le===p.az.horizontal||Le===p.az.horizontalOnly;if(Pe>0||_e>0){const Ye=Ca(Ce.text);he(t.text,Pe,Ke?qo:Ye),he(t.text,_e,He?qo:Ye);const xt=Ce.text.isHidden();[ye.rightJustifiedTextSymbolIndex,ye.centerJustifiedTextSymbolIndex,ye.leftJustifiedTextSymbolIndex].forEach((Pt=>{Pt>=0&&(t.text.placedSymbolArray.get(Pt).hidden=xt||Ke?1:0)})),ye.verticalPlacedTextSymbolIndex>=0&&(t.text.placedSymbolArray.get(ye.verticalPlacedTextSymbolIndex).hidden=xt||He?1:0);const wt=this.variableOffsets[ye.crossTileID];wt&&this.markUsedJustification(t,wt.anchor,ye,Le);const pt=this.placedOrientations[ye.crossTileID];pt&&(this.markUsedJustification(t,"left",ye,pt),this.markUsedOrientation(t,pt,ye))}if(be){const Ye=Ca(Ce.icon),xt=!($&&ye.verticalPlacedIconSymbolIndex&&Ke);ye.placedIconSymbolIndex>=0&&(he(t.icon,ye.numIconVertices,xt?Ye:qo),t.icon.placedSymbolArray.get(ye.placedIconSymbolIndex).hidden=Ce.icon.isHidden()),ye.verticalPlacedIconSymbolIndex>=0&&(he(t.icon,ye.numVerticalIconVertices,xt?qo:Ye),t.icon.placedSymbolArray.get(ye.verticalPlacedIconSymbolIndex).hidden=Ce.icon.isHidden())}const $e=Ae&&Ae.has(ce)?Ae.get(ce):{text:null,icon:null};if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const Ye=t.collisionArrays[ce];if(Ye){let xt=new p.P(0,0);if(Ye.textBox||Ye.verticalTextBox){let wt=!0;if(N){const pt=this.variableOffsets[we];pt?(xt=_n(pt.anchor,pt.width,pt.height,pt.textOffset,pt.textBoxScale),G&&xt._rotate(U?-this.transform.bearingInRadians:this.transform.bearingInRadians)):wt=!1}if(Ye.textBox||Ye.verticalTextBox){let pt;Ye.textBox&&(pt=Ke),Ye.verticalTextBox&&(pt=He),Ln(t.textCollisionBox.collisionVertexArray,Ce.text.placed,!wt||pt,$e.text,xt.x,xt.y)}}if(Ye.iconBox||Ye.verticalIconBox){const wt=!!(!He&&Ye.verticalIconBox);let pt;Ye.iconBox&&(pt=wt),Ye.verticalIconBox&&(pt=!wt),Ln(t.iconCollisionBox.collisionVertexArray,Ce.icon.placed,pt,$e.icon,$?xt.x:0,$?xt.y:0)}}}}if(t.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.text.opacityVertexArray.length!==t.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${t.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${t.text.layoutVertexArray.length}) / 4`);if(t.icon.opacityVertexArray.length!==t.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${t.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${t.icon.layoutVertexArray.length}) / 4`);t.bucketInstanceId in this.collisionCircleArrays&&(t.collisionCircleArray=this.collisionCircleArrays[t.bucketInstanceId],delete this.collisionCircleArrays[t.bucketInstanceId])}symbolFadeChange(t){return this.fadeDuration===0?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,n){const h=this.zoomAtLastRecencyCheck===n?1-this.zoomAdjustment(n):1;return this.zoomAtLastRecencyCheck=n,this.commitTime+this.fadeDuration*h>t}setStale(){this.stale=!0}}function Ln(y,t,n,h,f,x){h&&h.length!==0||(h=[0,0,0,0]);const T=h[0]-tr,C=h[1]-tr,D=h[2]-tr,B=h[3]-tr;y.emplaceBack(t?1:0,n?1:0,f||0,x||0,T,C),y.emplaceBack(t?1:0,n?1:0,f||0,x||0,D,C),y.emplaceBack(t?1:0,n?1:0,f||0,x||0,D,B),y.emplaceBack(t?1:0,n?1:0,f||0,x||0,T,B)}const ar=Math.pow(2,25),Cr=Math.pow(2,24),To=Math.pow(2,17),so=Math.pow(2,16),js=Math.pow(2,9),$a=Math.pow(2,8),ks=Math.pow(2,1);function Ca(y){if(y.opacity===0&&!y.placed)return 0;if(y.opacity===1&&y.placed)return 4294967295;const t=y.placed?1:0,n=Math.floor(127*y.opacity);return n*ar+t*Cr+n*To+t*so+n*js+t*$a+n*ks+t}const qo=0;class zs{constructor(t){this._sortAcrossTiles=t.layout.get("symbol-z-order")!=="viewport-y"&&!t.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(t,n,h,f,x){const T=this._bucketParts;for(;this._currentTileIndex<t.length;)if(n.getBucketParts(T,f,t[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,x())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,T.sort(((C,D)=>C.sortKey-D.sortKey)));this._currentPartIndex<T.length;)if(n.placeLayerBucketPart(T[this._currentPartIndex],this._seenCrossTileIDs,h),this._currentPartIndex++,x())return!0;return!1}}class Vi{constructor(t,n,h,f,x,T,C,D){this.placement=new Qa(t,n,T,C,D),this._currentPlacementIndex=h.length-1,this._forceFullPlacement=f,this._showCollisionBoxes=x,this._done=!1}isDone(){return this._done}continuePlacement(t,n,h){const f=Gt(),x=()=>!this._forceFullPlacement&&Gt()-f>2;for(;this._currentPlacementIndex>=0;){const T=n[t[this._currentPlacementIndex]],C=this.placement.collisionIndex.transform.zoom;if(T.type==="symbol"&&(!T.minzoom||T.minzoom<=C)&&(!T.maxzoom||T.maxzoom>C)){if(this._inProgressLayer||(this._inProgressLayer=new zs(T)),this._inProgressLayer.continuePlacement(h[T.source],this.placement,this._showCollisionBoxes,T,x))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(t){return this.placement.commit(t),this.placement}}const oi=512/p.a5/2;class Ho{constructor(t,n,h){this.tileID=t,this.bucketInstanceId=h,this._symbolsByKey={};const f=new Map;for(let x=0;x<n.length;x++){const T=n.get(x),C=T.key,D=f.get(C);D?D.push(T):f.set(C,[T])}for(const[x,T]of f){const C={positions:T.map((D=>({x:Math.floor(D.anchorX*oi),y:Math.floor(D.anchorY*oi)}))),crossTileIDs:T.map((D=>D.crossTileID))};if(C.positions.length>128){const D=new p.aT(C.positions.length,16,Uint16Array);for(const{x:B,y:N}of C.positions)D.add(B,N);D.finish(),delete C.positions,C.index=D}this._symbolsByKey[x]=C}}getScaledCoordinates(t,n){const{x:h,y:f,z:x}=this.tileID.canonical,{x:T,y:C,z:D}=n.canonical,B=oi/Math.pow(2,D-x),N=(C*p.a5+t.anchorY)*B,G=f*p.a5*oi;return{x:Math.floor((T*p.a5+t.anchorX)*B-h*p.a5*oi),y:Math.floor(N-G)}}findMatches(t,n,h){const f=this.tileID.canonical.z<n.canonical.z?1:Math.pow(2,this.tileID.canonical.z-n.canonical.z);for(let x=0;x<t.length;x++){const T=t.get(x);if(T.crossTileID)continue;const C=this._symbolsByKey[T.key];if(!C)continue;const D=this.getScaledCoordinates(T,n);if(C.index){const B=C.index.range(D.x-f,D.y-f,D.x+f,D.y+f).sort();for(const N of B){const G=C.crossTileIDs[N];if(!h[G]){h[G]=!0,T.crossTileID=G;break}}}else if(C.positions)for(let B=0;B<C.positions.length;B++){const N=C.positions[B],G=C.crossTileIDs[B];if(Math.abs(N.x-D.x)<=f&&Math.abs(N.y-D.y)<=f&&!h[G]){h[G]=!0,T.crossTileID=G;break}}}}getCrossTileIDsLists(){return Object.values(this._symbolsByKey).map((({crossTileIDs:t})=>t))}}class Nl{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Ia{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(t){const n=Math.round((t-this.lng)/360);if(n!==0)for(const h in this.indexes){const f=this.indexes[h],x={};for(const T in f){const C=f[T];C.tileID=C.tileID.unwrapTo(C.tileID.wrap+n),x[C.tileID.key]=C}this.indexes[h]=x}this.lng=t}addBucket(t,n,h){if(this.indexes[t.overscaledZ]&&this.indexes[t.overscaledZ][t.key]){if(this.indexes[t.overscaledZ][t.key].bucketInstanceId===n.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(t.overscaledZ,this.indexes[t.overscaledZ][t.key])}for(let x=0;x<n.symbolInstances.length;x++)n.symbolInstances.get(x).crossTileID=0;this.usedCrossTileIDs[t.overscaledZ]||(this.usedCrossTileIDs[t.overscaledZ]={});const f=this.usedCrossTileIDs[t.overscaledZ];for(const x in this.indexes){const T=this.indexes[x];if(Number(x)>t.overscaledZ)for(const C in T){const D=T[C];D.tileID.isChildOf(t)&&D.findMatches(n.symbolInstances,t,f)}else{const C=T[t.scaledTo(Number(x)).key];C&&C.findMatches(n.symbolInstances,t,f)}}for(let x=0;x<n.symbolInstances.length;x++){const T=n.symbolInstances.get(x);T.crossTileID||(T.crossTileID=h.generate(),f[T.crossTileID]=!0)}return this.indexes[t.overscaledZ]===void 0&&(this.indexes[t.overscaledZ]={}),this.indexes[t.overscaledZ][t.key]=new Ho(t,n.symbolInstances,n.bucketInstanceId),!0}removeBucketCrossTileIDs(t,n){for(const h of n.getCrossTileIDsLists())for(const f of h)delete this.usedCrossTileIDs[t][f]}removeStaleBuckets(t){let n=!1;for(const h in this.indexes){const f=this.indexes[h];for(const x in f)t[f[x].bucketInstanceId]||(this.removeBucketCrossTileIDs(h,f[x]),delete f[x],n=!0)}return n}}class Wn{constructor(){this.layerIndexes={},this.crossTileIDs=new Nl,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(t,n,h){let f=this.layerIndexes[t.id];f===void 0&&(f=this.layerIndexes[t.id]=new Ia);let x=!1;const T={};f.handleWrapJump(h);for(const C of n){const D=C.getBucket(t);D&&t.id===D.layerIds[0]&&(D.bucketInstanceId||(D.bucketInstanceId=++this.maxBucketInstanceId),f.addBucket(C.tileID,D,this.crossTileIDs)&&(x=!0),T[D.bucketInstanceId]=!0)}return f.removeStaleBuckets(T)&&(x=!0),x}pruneUnusedLayers(t){const n={};t.forEach((h=>{n[h]=!0}));for(const h in this.layerIndexes)n[h]||delete this.layerIndexes[h]}}var Ht="void main() {fragColor=vec4(1.0);}";const Li={prelude:Dt(`#ifdef GL_ES 9 - precision mediump float; 10 - #else 11 - #if !defined(lowp) 12 - #define lowp 13 - #endif 14 - #if !defined(mediump) 15 - #define mediump 16 - #endif 17 - #if !defined(highp) 18 - #define highp 19 - #endif 20 - #endif 21 - out highp vec4 fragColor;`,`#ifdef GL_ES 22 - precision highp float; 23 - #else 24 - #if !defined(lowp) 25 - #define lowp 26 - #endif 27 - #if !defined(mediump) 28 - #define mediump 29 - #endif 30 - #if !defined(highp) 31 - #define highp 32 - #endif 33 - #endif 34 - vec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0 35 - );}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 36 - );} 37 - #ifdef TERRAIN3D 38 - uniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth; 39 - #endif 40 - const 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) { 41 - #ifdef TERRAIN3D 42 - highp 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)); 43 - #else 44 - return 1.0; 45 - #endif 46 - }float calculate_visibility(vec4 pos) { 47 - #ifdef TERRAIN3D 48 - vec3 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; 49 - #else 50 - return 1.0; 51 - #endif 52 - }float ele(vec2 pos) { 53 - #ifdef TERRAIN3D 54 - vec4 rgb=(texture(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a; 55 - #else 56 - return 0.0; 57 - #endif 58 - }float get_elevation(vec2 pos) { 59 - #ifdef TERRAIN3D 60 - #ifdef GLOBE 61 - if ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;} 62 - #endif 63 - vec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration; 64 - #else 65 - return 0.0; 66 - #endif 67 - }const float PI=3.141592653589793;uniform mat4 u_projection_matrix;`),projectionMercator:Dt("","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:Dt("",`#define GLOBE_RADIUS 6371008.8 68 - uniform highp vec4 u_projection_tile_mercator_coords;uniform highp vec4 u_projection_clipping_plane;uniform highp float u_projection_transition;uniform mat4 u_projection_fallback_matrix;vec3 globeRotateVector(vec3 vec,vec2 angles) {vec3 axisRight=vec3(vec.z,0.0,-vec.x);vec3 axisUp=cross(axisRight,vec);axisRight=normalize(axisRight);axisUp=normalize(axisUp);vec2 t=tan(angles);return normalize(vec+axisRight*t.x+axisUp*t.y);}mat3 globeGetRotationMatrix(vec3 spherePos) {vec3 axisRight=vec3(spherePos.z,0.0,-spherePos.x);vec3 axisDown=cross(axisRight,spherePos);axisRight=normalize(axisRight);axisDown=normalize(axisDown);return mat3(axisRight,axisDown,spherePos 69 - );}float circumferenceRatioAtTileY(float tileY) {float mercator_pos_y=u_projection_tile_mercator_coords.y+u_projection_tile_mercator_coords.w*tileY;float spherical_y=2.0*atan(exp(PI-(mercator_pos_y*PI*2.0)))-PI*0.5;return cos(spherical_y);}float projectLineThickness(float tileY) {float thickness=1.0/circumferenceRatioAtTileY(tileY); 70 - 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;vec2 spherical;spherical.x=mercator_pos.x*PI*2.0+PI;spherical.y=2.0*atan(exp(PI-(mercator_pos.y*PI*2.0)))-PI*0.5;float len=cos(spherical.y);vec3 pos=vec3(sin(spherical.x)*len,sin(spherical.y),cos(spherical.x)*len 71 - );if (rawPos.y <-32767.5) {pos=vec3(0.0,1.0,0.0);}if (rawPos.y > 32766.5) {pos=vec3(0.0,-1.0,0.0);}return pos;}vec3 projectToSphere(vec2 posInTile) {return projectToSphere(posInTile,vec2(0.0,0.0));}float globeComputeClippingZ(vec3 spherePos) {return (1.0-(dot(spherePos,u_projection_clipping_plane.xyz)+u_projection_clipping_plane.w));}vec4 interpolateProjection(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);globePosition.z=globeComputeClippingZ(elevatedPos)*globePosition.w;if (u_projection_transition > 0.999) {return globePosition;}vec4 flatPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);const float z_globeness_threshold=0.2;vec4 result=globePosition;result.z=mix(0.0,globePosition.z,clamp((u_projection_transition-z_globeness_threshold)/(1.0-z_globeness_threshold),0.0,1.0));result.xyw=mix(flatPosition.xyw,globePosition.xyw,u_projection_transition);if ((posInTile.y <-32767.5) || (posInTile.y > 32766.5)) {result=globePosition;const float poles_hidden_anim_percentage=0.02;result.z=mix(globePosition.z,100.0,pow(max((1.0-u_projection_transition)/poles_hidden_anim_percentage,0.0),8.0));}return result;}vec4 interpolateProjectionFor3D(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);if (u_projection_transition > 0.999) {return globePosition;}vec4 fallbackPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);return mix(fallbackPosition,globePosition,u_projection_transition);}vec4 projectTile(vec2 posInTile) {return interpolateProjection(posInTile,projectToSphere(posInTile),0.0);}vec4 projectTile(vec2 posInTile,vec2 rawPos) {return interpolateProjection(posInTile,projectToSphere(posInTile,rawPos),0.0);}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return interpolateProjection(posInTile,projectToSphere(posInTile),elevation);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {vec3 spherePos=projectToSphere(posInTile,posInTile);return interpolateProjectionFor3D(posInTile,spherePos,elevation);}`),background:Dt(`uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity; 72 - #ifdef OVERDRAW_INSPECTOR 73 - fragColor=vec4(1.0); 74 - #endif 75 - }`,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),backgroundPattern:Dt(`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; 76 - #ifdef OVERDRAW_INSPECTOR 77 - fragColor=vec4(1.0); 78 - #endif 79 - }`,"uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;void main() {gl_Position=projectTile(a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}"),circle:Dt(`in vec3 v_data;in float v_visibility; 80 - #pragma mapbox: define highp vec4 color 81 - #pragma mapbox: define mediump float radius 82 - #pragma mapbox: define lowp float blur 83 - #pragma mapbox: define lowp float opacity 84 - #pragma mapbox: define highp vec4 stroke_color 85 - #pragma mapbox: define mediump float stroke_width 86 - #pragma mapbox: define lowp float stroke_opacity 87 - void main() { 88 - #pragma mapbox: initialize highp vec4 color 89 - #pragma mapbox: initialize mediump float radius 90 - #pragma mapbox: initialize lowp float blur 91 - #pragma mapbox: initialize lowp float opacity 92 - #pragma mapbox: initialize highp vec4 stroke_color 93 - #pragma mapbox: initialize mediump float stroke_width 94 - #pragma mapbox: initialize lowp float stroke_opacity 95 - vec2 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;} 96 - #ifdef OVERDRAW_INSPECTOR 97 - fragColor=vec4(1.0); 98 - #endif 99 - }`,`uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform highp float u_globe_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;uniform vec2 u_translate;in vec2 a_pos;out vec3 v_data;out float v_visibility; 100 - #pragma mapbox: define highp vec4 color 101 - #pragma mapbox: define mediump float radius 102 - #pragma mapbox: define lowp float blur 103 - #pragma mapbox: define lowp float opacity 104 - #pragma mapbox: define highp vec4 stroke_color 105 - #pragma mapbox: define mediump float stroke_width 106 - #pragma mapbox: define lowp float stroke_opacity 107 - void main(void) { 108 - #pragma mapbox: initialize highp vec4 color 109 - #pragma mapbox: initialize mediump float radius 110 - #pragma mapbox: initialize lowp float blur 111 - #pragma mapbox: initialize lowp float opacity 112 - #pragma mapbox: initialize highp vec4 stroke_color 113 - #pragma mapbox: initialize mediump float stroke_width 114 - #pragma mapbox: initialize lowp float stroke_opacity 115 - vec2 pos_raw=a_pos+32768.0;vec2 extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);vec2 circle_center=floor(pos_raw/8.0)+u_translate;float ele=get_elevation(circle_center);v_visibility=calculate_visibility(projectTileWithElevation(circle_center,ele));if (u_pitch_with_map) { 116 - #ifdef GLOBE 117 - vec3 center_vector=projectToSphere(circle_center); 118 - #endif 119 - float 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 { 120 - #ifdef GLOBE 121 - vec4 projected_center=interpolateProjection(circle_center,center_vector,ele); 122 - #else 123 - vec4 projected_center=projectTileWithElevation(circle_center,ele); 124 - #endif 125 - corner_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);} 126 - #ifdef GLOBE 127 - vec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele); 128 - #else 129 - gl_Position=projectTileWithElevation(corner_position,ele); 130 - #endif 131 - } 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:Dt(Ht,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:Dt(`uniform highp float u_intensity;in vec2 v_extrude; 132 - #pragma mapbox: define highp float weight 133 - #define GAUSS_COEF 0.3989422804014327 134 - void main() { 135 - #pragma mapbox: initialize highp float weight 136 - float 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); 137 - #ifdef OVERDRAW_INSPECTOR 138 - fragColor=vec4(1.0); 139 - #endif 140 - }`,`uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;uniform highp float u_globe_extrude_scale;in vec2 a_pos;out vec2 v_extrude; 141 - #pragma mapbox: define highp float weight 142 - #pragma mapbox: define mediump float radius 143 - const highp float ZERO=1.0/255.0/16.0; 144 - #define GAUSS_COEF 0.3989422804014327 145 - void main(void) { 146 - #pragma mapbox: initialize highp float weight 147 - #pragma mapbox: initialize mediump float radius 148 - vec2 pos_raw=a_pos+32768.0;vec2 unscaled_extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 circle_center=floor(pos_raw/8.0); 149 - #ifdef GLOBE 150 - vec2 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); 151 - #else 152 - gl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center)); 153 - #endif 154 - }`),heatmapTexture:Dt(`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; 155 - #ifdef OVERDRAW_INSPECTOR 156 - fragColor=vec4(0.0); 157 - #endif 158 - }`,"uniform mat4 u_matrix;uniform vec2 u_world;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:Dt("in float v_placed;in float v_notUsed;void main() {float alpha=0.5;fragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {fragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {fragColor*=.1;}}","in vec2 a_anchor_pos;in vec2 a_placed;in vec2 a_box_real;uniform vec2 u_pixel_extrude_scale;out float v_placed;out float v_notUsed;void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:Dt("in float v_radius;in vec2 v_extrude;in float v_collision;void main() {float alpha=0.5;float stroke_radius=0.9;float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);fragColor=color*alpha*opacity_t;}","in vec2 a_pos;in float a_radius;in vec2 a_flags;uniform vec2 u_viewport_size;out float v_radius;out vec2 v_extrude;out float v_collision;void main() {float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_collision=collision;gl_Position=vec4((a_pos/u_viewport_size*2.0-1.0)*vec2(1.0,-1.0),0.0,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),colorRelief:Dt(`#ifdef GL_ES 159 - precision highp float; 160 - #endif 161 - uniform sampler2D u_image;uniform vec4 u_unpack;uniform sampler2D u_elevation_stops;uniform sampler2D u_color_stops;uniform int u_color_ramp_size;uniform float u_opacity;in vec2 v_pos;float getElevation(vec2 coord) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}float getElevationStop(int stop) {float x=(float(stop)+0.5)/float(u_color_ramp_size);vec4 data=texture(u_elevation_stops,vec2(x,0))*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {float el=getElevation(v_pos);int r=(u_color_ramp_size-1);int l=0;float el_l=getElevationStop(l);float el_r=getElevationStop(r);while(r-l > 1){int m=(r+l)/2;float el_m=getElevationStop(m);if(el < el_m){r=m;el_r=el_m;}else 162 - {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)); 163 - #ifdef OVERDRAW_INSPECTOR 164 - fragColor=vec4(1.0); 165 - #endif 166 - }`,"uniform vec2 u_dimension;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_pos/8192.0)*scale+epsilon;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),debug:Dt("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);fragColor=mix(u_color,overlay_color,overlay_color.a);}","in vec2 a_pos;out vec2 v_uv;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=projectTileWithElevation(a_pos*u_overlay_scale,get_elevation(a_pos));}"),depth:Dt(Ht,`in vec2 a_pos;void main() { 167 - #ifdef GLOBE 168 - gl_Position=projectTileFor3D(a_pos,0.0); 169 - #else 170 - gl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0); 171 - #endif 172 - }`),fill:Dt(`#pragma mapbox: define highp vec4 color 173 - #pragma mapbox: define lowp float opacity 174 - void main() { 175 - #pragma mapbox: initialize highp vec4 color 176 - #pragma mapbox: initialize lowp float opacity 177 - fragColor=color*opacity; 178 - #ifdef OVERDRAW_INSPECTOR 179 - fragColor=vec4(1.0); 180 - #endif 181 - }`,`uniform vec2 u_fill_translate;in vec2 a_pos; 182 - #pragma mapbox: define highp vec4 color 183 - #pragma mapbox: define lowp float opacity 184 - void main() { 185 - #pragma mapbox: initialize highp vec4 color 186 - #pragma mapbox: initialize lowp float opacity 187 - gl_Position=projectTile(a_pos+u_fill_translate,a_pos);}`),fillOutline:Dt(`in vec2 v_pos; 188 - #ifdef GLOBE 189 - in float v_depth; 190 - #endif 191 - #pragma mapbox: define highp vec4 outline_color 192 - #pragma mapbox: define lowp float opacity 193 - void main() { 194 - #pragma mapbox: initialize highp vec4 outline_color 195 - #pragma mapbox: initialize lowp float opacity 196 - float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=outline_color*(alpha*opacity); 197 - #ifdef GLOBE 198 - if (v_depth > 1.0) {discard;} 199 - #endif 200 - #ifdef OVERDRAW_INSPECTOR 201 - fragColor=vec4(1.0); 202 - #endif 203 - }`,`uniform vec2 u_world;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos; 204 - #ifdef GLOBE 205 - out float v_depth; 206 - #endif 207 - #pragma mapbox: define highp vec4 outline_color 208 - #pragma mapbox: define lowp float opacity 209 - void main() { 210 - #pragma mapbox: initialize highp vec4 outline_color 211 - #pragma mapbox: initialize lowp float opacity 212 - gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world; 213 - #ifdef GLOBE 214 - v_depth=gl_Position.z/gl_Position.w; 215 - #endif 216 - }`),fillOutlinePattern:Dt(`uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;in vec2 v_pos_a;in vec2 v_pos_b;in vec2 v_pos; 217 - #ifdef GLOBE 218 - in float v_depth; 219 - #endif 220 - #pragma mapbox: define lowp float opacity 221 - #pragma mapbox: define lowp vec4 pattern_from 222 - #pragma mapbox: define lowp vec4 pattern_to 223 - void main() { 224 - #pragma mapbox: initialize lowp float opacity 225 - #pragma mapbox: initialize mediump vec4 pattern_from 226 - #pragma mapbox: initialize mediump vec4 pattern_to 227 - 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;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=mix(color1,color2,u_fade)*alpha*opacity; 228 - #ifdef GLOBE 229 - if (v_depth > 1.0) {discard;} 230 - #endif 231 - #ifdef OVERDRAW_INSPECTOR 232 - fragColor=vec4(1.0); 233 - #endif 234 - }`,`uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;out vec2 v_pos; 235 - #ifdef GLOBE 236 - out float v_depth; 237 - #endif 238 - #pragma mapbox: define lowp float opacity 239 - #pragma mapbox: define lowp vec4 pattern_from 240 - #pragma mapbox: define lowp vec4 pattern_to 241 - #pragma mapbox: define lowp float pixel_ratio_from 242 - #pragma mapbox: define lowp float pixel_ratio_to 243 - void main() { 244 - #pragma mapbox: initialize lowp float opacity 245 - #pragma mapbox: initialize mediump vec4 pattern_from 246 - #pragma mapbox: initialize mediump vec4 pattern_to 247 - #pragma mapbox: initialize lowp float pixel_ratio_from 248 - #pragma mapbox: initialize lowp float pixel_ratio_to 249 - 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; 250 - #ifdef GLOBE 251 - v_depth=gl_Position.z/gl_Position.w; 252 - #endif 253 - }`),fillPattern:Dt(`#ifdef GL_ES 254 - precision highp float; 255 - #endif 256 - uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b; 257 - #pragma mapbox: define lowp float opacity 258 - #pragma mapbox: define lowp vec4 pattern_from 259 - #pragma mapbox: define lowp vec4 pattern_to 260 - void main() { 261 - #pragma mapbox: initialize lowp float opacity 262 - #pragma mapbox: initialize mediump vec4 pattern_from 263 - #pragma mapbox: initialize mediump vec4 pattern_to 264 - 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;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_fade)*opacity; 265 - #ifdef OVERDRAW_INSPECTOR 266 - fragColor=vec4(1.0); 267 - #endif 268 - }`,`uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b; 269 - #pragma mapbox: define lowp float opacity 270 - #pragma mapbox: define lowp vec4 pattern_from 271 - #pragma mapbox: define lowp vec4 pattern_to 272 - #pragma mapbox: define lowp float pixel_ratio_from 273 - #pragma mapbox: define lowp float pixel_ratio_to 274 - void main() { 275 - #pragma mapbox: initialize lowp float opacity 276 - #pragma mapbox: initialize mediump vec4 pattern_from 277 - #pragma mapbox: initialize mediump vec4 pattern_to 278 - #pragma mapbox: initialize lowp float pixel_ratio_from 279 - #pragma mapbox: initialize lowp float pixel_ratio_to 280 - 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:Dt(`in vec4 v_color;void main() {fragColor=v_color; 281 - #ifdef OVERDRAW_INSPECTOR 282 - fragColor=vec4(1.0); 283 - #endif 284 - }`,`uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;in vec2 a_pos;in vec4 a_normal_ed; 285 - #ifdef TERRAIN3D 286 - in vec2 a_centroid; 287 - #endif 288 - out vec4 v_color; 289 - #pragma mapbox: define highp float base 290 - #pragma mapbox: define highp float height 291 - #pragma mapbox: define highp vec4 color 292 - void main() { 293 - #pragma mapbox: initialize highp float base 294 - #pragma mapbox: initialize highp float height 295 - #pragma mapbox: initialize highp vec4 color 296 - vec3 normal=a_normal_ed.xyz; 297 - #ifdef TERRAIN3D 298 - float height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0); 299 - #else 300 - float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0; 301 - #endif 302 - base=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate; 303 - #ifdef GLOBE 304 - vec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation); 305 - #else 306 - gl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0); 307 - #endif 308 - float 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); 309 - #ifdef GLOBE 310 - mat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition); 311 - #endif 312 - directional=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:Dt(`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; 313 - #pragma mapbox: define lowp float base 314 - #pragma mapbox: define lowp float height 315 - #pragma mapbox: define lowp vec4 pattern_from 316 - #pragma mapbox: define lowp vec4 pattern_to 317 - #pragma mapbox: define lowp float pixel_ratio_from 318 - #pragma mapbox: define lowp float pixel_ratio_to 319 - void main() { 320 - #pragma mapbox: initialize lowp float base 321 - #pragma mapbox: initialize lowp float height 322 - #pragma mapbox: initialize mediump vec4 pattern_from 323 - #pragma mapbox: initialize mediump vec4 pattern_to 324 - #pragma mapbox: initialize lowp float pixel_ratio_from 325 - #pragma mapbox: initialize lowp float pixel_ratio_to 326 - 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;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; 327 - #ifdef OVERDRAW_INSPECTOR 328 - fragColor=vec4(1.0); 329 - #endif 330 - }`,`uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;in vec2 a_pos;in vec4 a_normal_ed; 331 - #ifdef TERRAIN3D 332 - in vec2 a_centroid; 333 - #endif 334 - #ifdef GLOBE 335 - out vec3 v_sphere_pos; 336 - #endif 337 - out vec2 v_pos_a;out vec2 v_pos_b;out vec4 v_lighting; 338 - #pragma mapbox: define lowp float base 339 - #pragma mapbox: define lowp float height 340 - #pragma mapbox: define lowp vec4 pattern_from 341 - #pragma mapbox: define lowp vec4 pattern_to 342 - #pragma mapbox: define lowp float pixel_ratio_from 343 - #pragma mapbox: define lowp float pixel_ratio_to 344 - void main() { 345 - #pragma mapbox: initialize lowp float base 346 - #pragma mapbox: initialize lowp float height 347 - #pragma mapbox: initialize mediump vec4 pattern_from 348 - #pragma mapbox: initialize mediump vec4 pattern_to 349 - #pragma mapbox: initialize lowp float pixel_ratio_from 350 - #pragma mapbox: initialize lowp float pixel_ratio_to 351 - 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;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to; 352 - #ifdef TERRAIN3D 353 - float height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0); 354 - #else 355 - float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0; 356 - #endif 357 - base=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate; 358 - #ifdef GLOBE 359 - vec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation); 360 - #else 361 - gl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0); 362 - #endif 363 - vec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0 364 - ? a_pos 365 - : 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:Dt(`#ifdef GL_ES 366 - precision highp float; 367 - #endif 368 - uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {vec2 epsilon=1.0/u_dimension;float tileSize=u_dimension.x-2.0;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))*tileSize/pow(2.0,exaggeration+(28.2562-u_zoom));fragColor=clamp(vec4(deriv.x/8.0+0.5,deriv.y/8.0+0.5,1.0,1.0),0.0,1.0); 369 - #ifdef OVERDRAW_INSPECTOR 370 - fragColor=vec4(1.0); 371 - #endif 372 - }`,"uniform mat4 u_matrix;uniform vec2 u_dimension;in vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:Dt(`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]; 373 - #define PI 3.141592653589793 374 - #define STANDARD 0 375 - #define COMBINED 1 376 - #define IGOR 2 377 - #define MULTIDIRECTIONAL 3 378 - #define BASIC 4 379 - float 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 380 - {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 381 - {fragColor+=u_shadows[i]*(1.0-2.0*shade)/float(NUM_ILLUMINATION_SOURCES);}}}void combined_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=acos((sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv)));cang=clamp(cang,0.0,PI/2.0);float shade=cang*atan(length(deriv))*4.0/PI/PI;float highlight=(PI/2.0-cang)*atan(length(deriv))*4.0/PI/PI;fragColor=u_shadows[0]*shade+u_highlights[0]*highlight;}void main() {vec4 pixel=texture(u_image,v_pos);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));vec2 deriv=((pixel.rg*8.0)-4.0)/scaleFactor;if (u_method==BASIC) {basic_hillshade(deriv);} else if (u_method==COMBINED) {combined_hillshade(deriv);} else if (u_method==IGOR) {igor_hillshade(deriv);} else if (u_method==MULTIDIRECTIONAL) {multidirectional_hillshade(deriv);} else if (u_method==STANDARD) {standard_hillshade(deriv);} else {standard_hillshade(deriv);} 382 - #ifdef OVERDRAW_INSPECTOR 383 - fragColor=vec4(1.0); 384 - #endif 385 - }`,"uniform mat4 u_matrix;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);v_pos=a_pos/8192.0;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),line:Dt(`uniform lowp float u_device_pixel_ratio;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale; 386 - #ifdef GLOBE 387 - in float v_depth; 388 - #endif 389 - #pragma mapbox: define highp vec4 color 390 - #pragma mapbox: define lowp float blur 391 - #pragma mapbox: define lowp float opacity 392 - void main() { 393 - #pragma mapbox: initialize highp vec4 color 394 - #pragma mapbox: initialize lowp float blur 395 - #pragma mapbox: initialize lowp float opacity 396 - 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); 397 - #ifdef GLOBE 398 - if (v_depth > 1.0) {discard;} 399 - #endif 400 - #ifdef OVERDRAW_INSPECTOR 401 - fragColor=vec4(1.0); 402 - #endif 403 - }`,` 404 - #define scale 0.015873016 405 - in vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp float v_linesofar; 406 - #ifdef GLOBE 407 - out float v_depth; 408 - #endif 409 - #pragma mapbox: define highp vec4 color 410 - #pragma mapbox: define lowp float blur 411 - #pragma mapbox: define lowp float opacity 412 - #pragma mapbox: define mediump float gapwidth 413 - #pragma mapbox: define lowp float offset 414 - #pragma mapbox: define mediump float width 415 - void main() { 416 - #pragma mapbox: initialize highp vec4 color 417 - #pragma mapbox: initialize lowp float blur 418 - #pragma mapbox: initialize lowp float opacity 419 - #pragma mapbox: initialize mediump float gapwidth 420 - #pragma mapbox: initialize lowp float offset 421 - #pragma mapbox: initialize mediump float width 422 - float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude; 423 - #ifdef GLOBE 424 - v_depth=gl_Position.z/gl_Position.w; 425 - #endif 426 - #ifdef TERRAIN3D 427 - v_gamma_scale=1.0; 428 - #else 429 - float 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; 430 - #endif 431 - v_width2=vec2(outset,inset);}`),lineGradient:Dt(`uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec2 v_uv; 432 - #ifdef GLOBE 433 - in float v_depth; 434 - #endif 435 - #pragma mapbox: define lowp float blur 436 - #pragma mapbox: define lowp float opacity 437 - void main() { 438 - #pragma mapbox: initialize lowp float blur 439 - #pragma mapbox: initialize lowp float opacity 440 - 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); 441 - #ifdef GLOBE 442 - if (v_depth > 1.0) {discard;} 443 - #endif 444 - #ifdef OVERDRAW_INSPECTOR 445 - fragColor=vec4(1.0); 446 - #endif 447 - }`,` 448 - #define scale 0.015873016 449 - in vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv; 450 - #ifdef GLOBE 451 - out float v_depth; 452 - #endif 453 - #pragma mapbox: define lowp float blur 454 - #pragma mapbox: define lowp float opacity 455 - #pragma mapbox: define mediump float gapwidth 456 - #pragma mapbox: define lowp float offset 457 - #pragma mapbox: define mediump float width 458 - void main() { 459 - #pragma mapbox: initialize lowp float blur 460 - #pragma mapbox: initialize lowp float opacity 461 - #pragma mapbox: initialize mediump float gapwidth 462 - #pragma mapbox: initialize lowp float offset 463 - #pragma mapbox: initialize mediump float width 464 - float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude; 465 - #ifdef GLOBE 466 - v_depth=gl_Position.z/gl_Position.w; 467 - #endif 468 - #ifdef TERRAIN3D 469 - v_gamma_scale=1.0; 470 - #else 471 - float 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; 472 - #endif 473 - v_width2=vec2(outset,inset);}`),linePattern:Dt(`#ifdef GL_ES 474 - precision highp float; 475 - #endif 476 - uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;in vec2 v_normal;in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;in float v_width; 477 - #ifdef GLOBE 478 - in float v_depth; 479 - #endif 480 - #pragma mapbox: define lowp vec4 pattern_from 481 - #pragma mapbox: define lowp vec4 pattern_to 482 - #pragma mapbox: define lowp float pixel_ratio_from 483 - #pragma mapbox: define lowp float pixel_ratio_to 484 - #pragma mapbox: define lowp float blur 485 - #pragma mapbox: define lowp float opacity 486 - void main() { 487 - #pragma mapbox: initialize mediump vec4 pattern_from 488 - #pragma mapbox: initialize mediump vec4 pattern_to 489 - #pragma mapbox: initialize lowp float pixel_ratio_from 490 - #pragma mapbox: initialize lowp float pixel_ratio_to 491 - #pragma mapbox: initialize lowp float blur 492 - #pragma mapbox: initialize lowp float opacity 493 - 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; 494 - #ifdef GLOBE 495 - if (v_depth > 1.0) {discard;} 496 - #endif 497 - #ifdef OVERDRAW_INSPECTOR 498 - fragColor=vec4(1.0); 499 - #endif 500 - }`,` 501 - #define scale 0.015873016 502 - #define LINE_DISTANCE_SCALE 2.0 503 - in vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;out float v_width; 504 - #ifdef GLOBE 505 - out float v_depth; 506 - #endif 507 - #pragma mapbox: define lowp float blur 508 - #pragma mapbox: define lowp float opacity 509 - #pragma mapbox: define lowp float offset 510 - #pragma mapbox: define mediump float gapwidth 511 - #pragma mapbox: define mediump float width 512 - #pragma mapbox: define lowp float floorwidth 513 - #pragma mapbox: define lowp vec4 pattern_from 514 - #pragma mapbox: define lowp vec4 pattern_to 515 - #pragma mapbox: define lowp float pixel_ratio_from 516 - #pragma mapbox: define lowp float pixel_ratio_to 517 - void main() { 518 - #pragma mapbox: initialize lowp float blur 519 - #pragma mapbox: initialize lowp float opacity 520 - #pragma mapbox: initialize lowp float offset 521 - #pragma mapbox: initialize mediump float gapwidth 522 - #pragma mapbox: initialize mediump float width 523 - #pragma mapbox: initialize lowp float floorwidth 524 - #pragma mapbox: initialize mediump vec4 pattern_from 525 - #pragma mapbox: initialize mediump vec4 pattern_to 526 - #pragma mapbox: initialize lowp float pixel_ratio_from 527 - #pragma mapbox: initialize lowp float pixel_ratio_to 528 - float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude; 529 - #ifdef GLOBE 530 - v_depth=gl_Position.z/gl_Position.w; 531 - #endif 532 - #ifdef TERRAIN3D 533 - v_gamma_scale=1.0; 534 - #else 535 - float 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; 536 - #endif 537 - v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}`),lineSDF:Dt(`uniform lowp float u_device_pixel_ratio;uniform lowp float u_lineatlas_width;uniform sampler2D u_image;uniform float u_mix;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale; 538 - #ifdef GLOBE 539 - in float v_depth; 540 - #endif 541 - #pragma mapbox: define highp vec4 color 542 - #pragma mapbox: define lowp float blur 543 - #pragma mapbox: define lowp float opacity 544 - #pragma mapbox: define mediump float width 545 - #pragma mapbox: define lowp float floorwidth 546 - #pragma mapbox: define mediump vec4 dasharray_from 547 - #pragma mapbox: define mediump vec4 dasharray_to 548 - void main() { 549 - #pragma mapbox: initialize highp vec4 color 550 - #pragma mapbox: initialize lowp float blur 551 - #pragma mapbox: initialize lowp float opacity 552 - #pragma mapbox: initialize mediump float width 553 - #pragma mapbox: initialize lowp float floorwidth 554 - #pragma mapbox: initialize mediump vec4 dasharray_from 555 - #pragma mapbox: initialize mediump vec4 dasharray_to 556 - 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); 557 - #ifdef GLOBE 558 - if (v_depth > 1.0) {discard;} 559 - #endif 560 - #ifdef OVERDRAW_INSPECTOR 561 - fragColor=vec4(1.0); 562 - #endif 563 - }`,` 564 - #define scale 0.015873016 565 - #define LINE_DISTANCE_SCALE 2.0 566 - in vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale; 567 - #ifdef GLOBE 568 - out float v_depth; 569 - #endif 570 - #pragma mapbox: define highp vec4 color 571 - #pragma mapbox: define lowp float blur 572 - #pragma mapbox: define lowp float opacity 573 - #pragma mapbox: define mediump float gapwidth 574 - #pragma mapbox: define lowp float offset 575 - #pragma mapbox: define mediump float width 576 - #pragma mapbox: define lowp float floorwidth 577 - #pragma mapbox: define mediump vec4 dasharray_from 578 - #pragma mapbox: define mediump vec4 dasharray_to 579 - void main() { 580 - #pragma mapbox: initialize highp vec4 color 581 - #pragma mapbox: initialize lowp float blur 582 - #pragma mapbox: initialize lowp float opacity 583 - #pragma mapbox: initialize mediump float gapwidth 584 - #pragma mapbox: initialize lowp float offset 585 - #pragma mapbox: initialize mediump float width 586 - #pragma mapbox: initialize lowp float floorwidth 587 - #pragma mapbox: initialize mediump vec4 dasharray_from 588 - #pragma mapbox: initialize mediump vec4 dasharray_to 589 - float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude; 590 - #ifdef GLOBE 591 - v_depth=gl_Position.z/gl_Position.w; 592 - #endif 593 - #ifdef TERRAIN3D 594 - v_gamma_scale=1.0; 595 - #else 596 - float 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; 597 - #endif 598 - float 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:Dt(`uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform sampler2D u_image_dash;uniform float u_mix;uniform lowp float u_lineatlas_width;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;in highp vec2 v_uv; 599 - #ifdef GLOBE 600 - in float v_depth; 601 - #endif 602 - #pragma mapbox: define lowp float blur 603 - #pragma mapbox: define lowp float opacity 604 - #pragma mapbox: define mediump float width 605 - #pragma mapbox: define lowp float floorwidth 606 - #pragma mapbox: define mediump vec4 dasharray_from 607 - #pragma mapbox: define mediump vec4 dasharray_to 608 - void main() { 609 - #pragma mapbox: initialize lowp float blur 610 - #pragma mapbox: initialize lowp float opacity 611 - #pragma mapbox: initialize mediump float width 612 - #pragma mapbox: initialize lowp float floorwidth 613 - #pragma mapbox: initialize mediump vec4 dasharray_from 614 - #pragma mapbox: initialize mediump vec4 dasharray_to 615 - 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); 616 - #ifdef GLOBE 617 - if (v_depth > 1.0) {discard;} 618 - #endif 619 - #ifdef OVERDRAW_INSPECTOR 620 - fragColor=vec4(1.0); 621 - #endif 622 - }`,` 623 - #define scale 0.015873016 624 - #define LINE_DISTANCE_SCALE 2.0 625 - in vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;out vec2 v_tex_a;out vec2 v_tex_b; 626 - #ifdef GLOBE 627 - out float v_depth; 628 - #endif 629 - #pragma mapbox: define lowp float blur 630 - #pragma mapbox: define lowp float opacity 631 - #pragma mapbox: define mediump float gapwidth 632 - #pragma mapbox: define lowp float offset 633 - #pragma mapbox: define mediump float width 634 - #pragma mapbox: define lowp float floorwidth 635 - #pragma mapbox: define mediump vec4 dasharray_from 636 - #pragma mapbox: define mediump vec4 dasharray_to 637 - void main() { 638 - #pragma mapbox: initialize lowp float blur 639 - #pragma mapbox: initialize lowp float opacity 640 - #pragma mapbox: initialize mediump float gapwidth 641 - #pragma mapbox: initialize lowp float offset 642 - #pragma mapbox: initialize mediump float width 643 - #pragma mapbox: initialize lowp float floorwidth 644 - #pragma mapbox: initialize mediump vec4 dasharray_from 645 - #pragma mapbox: initialize mediump vec4 dasharray_to 646 - float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;float texel_height=1.0/u_image_height;float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude; 647 - #ifdef GLOBE 648 - v_depth=gl_Position.z/gl_Position.w; 649 - #endif 650 - #ifdef TERRAIN3D 651 - v_gamma_scale=1.0; 652 - #else 653 - float 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; 654 - #endif 655 - float u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}`),raster:Dt(`uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec2 v_pos0;in vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture(u_image0,v_pos0);vec4 color1=texture(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);fragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a); 656 - #ifdef OVERDRAW_INSPECTOR 657 - fragColor=vec4(1.0); 658 - #endif 659 - }`,`uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;uniform vec4 u_coords_top;uniform vec4 u_coords_bottom;in vec2 a_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {vec2 fractionalPos=a_pos/8192.0;vec2 position=mix(mix(u_coords_top.xy,u_coords_top.zw,fractionalPos.x),mix(u_coords_bottom.xy,u_coords_bottom.zw,fractionalPos.x),fractionalPos.y);gl_Position=projectTile(position,position);v_pos0=((fractionalPos-0.5)/u_buffer_scale)+0.5; 660 - #ifdef GLOBE 661 - if (a_pos.y <-32767.5) {v_pos0.y=0.0;}if (a_pos.y > 32766.5) {v_pos0.y=1.0;} 662 - #endif 663 - v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}`),symbolIcon:Dt(`uniform sampler2D u_texture;in vec2 v_tex;in float v_fade_opacity; 664 - #pragma mapbox: define lowp float opacity 665 - void main() { 666 - #pragma mapbox: initialize lowp float opacity 667 - lowp float alpha=opacity*v_fade_opacity;fragColor=texture(u_texture,v_tex)*alpha; 668 - #ifdef OVERDRAW_INSPECTOR 669 - fragColor=vec4(1.0); 670 - #endif 671 - }`,`in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_tex;out float v_fade_opacity; 672 - #pragma mapbox: define lowp float opacity 673 - void main() { 674 - #pragma mapbox: initialize lowp float opacity 675 - vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ? 676 - camera_to_anchor_distance/u_camera_to_center_distance : 677 - u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0; 678 - #ifdef GLOBE 679 - if(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);} 680 - #endif 681 - vec4 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;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}`),symbolSDF:Dt(`#define SDF_PX 8.0 682 - uniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;in vec2 v_data0;in vec3 v_data1; 683 - #pragma mapbox: define highp vec4 fill_color 684 - #pragma mapbox: define highp vec4 halo_color 685 - #pragma mapbox: define lowp float opacity 686 - #pragma mapbox: define lowp float halo_width 687 - #pragma mapbox: define lowp float halo_blur 688 - void main() { 689 - #pragma mapbox: initialize highp vec4 fill_color 690 - #pragma mapbox: initialize highp vec4 halo_color 691 - #pragma mapbox: initialize lowp float opacity 692 - #pragma mapbox: initialize lowp float halo_width 693 - #pragma mapbox: initialize lowp float halo_blur 694 - float 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 fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}fragColor=color*(alpha*opacity*fade_opacity); 695 - #ifdef OVERDRAW_INSPECTOR 696 - fragColor=vec4(1.0); 697 - #endif 698 - }`,`in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_data0;out vec3 v_data1; 699 - #pragma mapbox: define highp vec4 fill_color 700 - #pragma mapbox: define highp vec4 halo_color 701 - #pragma mapbox: define lowp float opacity 702 - #pragma mapbox: define lowp float halo_width 703 - #pragma mapbox: define lowp float halo_blur 704 - void main() { 705 - #pragma mapbox: initialize highp vec4 fill_color 706 - #pragma mapbox: initialize highp vec4 halo_color 707 - #pragma mapbox: initialize lowp float opacity 708 - #pragma mapbox: initialize lowp float halo_width 709 - #pragma mapbox: initialize lowp float halo_blur 710 - vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ? 711 - camera_to_anchor_distance/u_camera_to_center_distance : 712 - u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0; 713 - #ifdef GLOBE 714 - if(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);} 715 - #endif 716 - vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*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;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}`),symbolTextAndIcon:Dt(`#define SDF_PX 8.0 717 - #define SDF 1.0 718 - #define ICON 0.0 719 - uniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;in vec4 v_data0;in vec4 v_data1; 720 - #pragma mapbox: define highp vec4 fill_color 721 - #pragma mapbox: define highp vec4 halo_color 722 - #pragma mapbox: define lowp float opacity 723 - #pragma mapbox: define lowp float halo_width 724 - #pragma mapbox: define lowp float halo_blur 725 - void main() { 726 - #pragma mapbox: initialize highp vec4 fill_color 727 - #pragma mapbox: initialize highp vec4 halo_color 728 - #pragma mapbox: initialize lowp float opacity 729 - #pragma mapbox: initialize lowp float halo_width 730 - #pragma mapbox: initialize lowp float halo_blur 731 - float fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;fragColor=texture(u_texture_icon,tex_icon)*alpha; 732 - #ifdef OVERDRAW_INSPECTOR 733 - fragColor=vec4(1.0); 734 - #endif 735 - return;}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;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);fragColor=color*(alpha*opacity*fade_opacity); 736 - #ifdef OVERDRAW_INSPECTOR 737 - fragColor=vec4(1.0); 738 - #endif 739 - }`,`in vec4 a_pos_offset;in vec4 a_data;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec4 v_data0;out vec4 v_data1; 740 - #pragma mapbox: define highp vec4 fill_color 741 - #pragma mapbox: define highp vec4 halo_color 742 - #pragma mapbox: define lowp float opacity 743 - #pragma mapbox: define lowp float halo_width 744 - #pragma mapbox: define lowp float halo_blur 745 - void main() { 746 - #pragma mapbox: initialize highp vec4 fill_color 747 - #pragma mapbox: initialize highp vec4 halo_color 748 - #pragma mapbox: initialize lowp float opacity 749 - #pragma mapbox: initialize lowp float halo_width 750 - #pragma mapbox: initialize lowp float halo_blur 751 - vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ? 752 - camera_to_anchor_distance/u_camera_to_center_distance : 753 - u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0; 754 - #ifdef GLOBE 755 - if(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);} 756 - #endif 757 - vec4 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;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}`),terrain:Dt("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 && v_fog_depth > u_fog_ground_blend) {vec4 surface_color_linear=gammaToLinear(surface_color);float blend_color=smoothstep(0.0,1.0,max((v_fog_depth-u_horizon_fog_blend)/(1.0-u_horizon_fog_blend),0.0));vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);float factor_fog=max(v_fog_depth-u_fog_ground_blend,0.0)/(1.0-u_fog_ground_blend);fragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {fragColor=surface_color;}}","in vec3 a_pos3d;uniform mat4 u_fog_matrix;uniform float u_ele_delta;out vec2 v_texture_pos;out float v_fog_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,get_elevation(a_pos3d.xy)-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:Dt("in float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {fragColor=pack(v_depth);}","in vec3 a_pos3d;uniform float u_ele_delta;out float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);v_depth=gl_Position.z/gl_Position.w;}"),terrainCoords:Dt("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;in vec2 v_texture_pos;void main() {vec4 rgba=texture(u_texture,v_texture_pos);fragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}","in vec3 a_pos3d;uniform float u_ele_delta;out vec2 v_texture_pos;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);}"),projectionErrorMeasurement:Dt("in vec4 v_output_error_encoded;void main() {fragColor=v_output_error_encoded;}","in vec2 a_pos;uniform highp float u_input;uniform highp float u_output_expected;out vec4 v_output_error_encoded;void main() {float real_output=2.0*atan(exp(PI-(u_input*PI*2.0)))-PI*0.5;float error=real_output-u_output_expected;float abs_error=abs(error)*128.0;v_output_error_encoded.x=min(floor(abs_error*256.0),255.0)/255.0;abs_error-=v_output_error_encoded.x;v_output_error_encoded.y=min(floor(abs_error*65536.0),255.0)/255.0;abs_error-=v_output_error_encoded.x/255.0;v_output_error_encoded.z=min(floor(abs_error*16777216.0),255.0)/255.0;v_output_error_encoded.w=error >=0.0 ? 1.0 : 0.0;gl_Position=vec4(a_pos,0.0,1.0);}"),atmosphere:Dt(`#ifdef GL_ES 758 - precision highp float; 759 - #endif 760 - in 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 761 - );color.rgb=1.0-exp(-1.0*color.rgb);color=pow(color,vec4(1.0/2.2));fragColor=vec4(color.rgb,1.0-color.a)*u_atmosphere_blend;}`,"in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 view_direction;void main() {view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,0.0,1.0);}"),sky:Dt("uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform vec2 u_horizon;uniform vec2 u_horizon_normal;uniform float u_sky_horizon_blend;uniform float u_sky_blend;void main() {float x=gl_FragCoord.x;float y=gl_FragCoord.y;float blend=(y-u_horizon.y)*u_horizon_normal.y+(x-u_horizon.x)*u_horizon_normal.x;if (blend > 0.0) {if (blend < u_sky_horizon_blend) {fragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {fragColor=u_sky_color;}}fragColor=mix(fragColor,vec4(vec3(0.0),0.0),u_sky_blend);}","in vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}")};function Dt(y,t){const n=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,h=t.match(/in ([\w]+) ([\w]+)/g),f=y.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),x=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),T=x?x.concat(f):f,C={};return{fragmentSource:y=y.replace(n,((D,B,N,G,U)=>(C[U]=!0,B==="define"?` 762 - #ifndef HAS_UNIFORM_u_${U} 763 - in ${N} ${G} ${U}; 764 - #else 765 - uniform ${N} ${G} u_${U}; 766 - #endif 767 - `:` 768 - #ifdef HAS_UNIFORM_u_${U} 769 - ${N} ${G} ${U} = u_${U}; 770 - #endif 771 - `))),vertexSource:t=t.replace(n,((D,B,N,G,U)=>{const $=G==="float"?"vec2":"vec4",ie=U.match(/color/)?"color":$;return C[U]?B==="define"?` 772 - #ifndef HAS_UNIFORM_u_${U} 773 - uniform lowp float u_${U}_t; 774 - in ${N} ${$} a_${U}; 775 - out ${N} ${G} ${U}; 776 - #else 777 - uniform ${N} ${G} u_${U}; 778 - #endif 779 - `:ie==="vec4"?` 780 - #ifndef HAS_UNIFORM_u_${U} 781 - ${U} = a_${U}; 782 - #else 783 - ${N} ${G} ${U} = u_${U}; 784 - #endif 785 - `:` 786 - #ifndef HAS_UNIFORM_u_${U} 787 - ${U} = unpack_mix_${ie}(a_${U}, u_${U}_t); 788 - #else 789 - ${N} ${G} ${U} = u_${U}; 790 - #endif 791 - `:B==="define"?` 792 - #ifndef HAS_UNIFORM_u_${U} 793 - uniform lowp float u_${U}_t; 794 - in ${N} ${$} a_${U}; 795 - #else 796 - uniform ${N} ${G} u_${U}; 797 - #endif 798 - `:ie==="vec4"?` 799 - #ifndef HAS_UNIFORM_u_${U} 800 - ${N} ${G} ${U} = a_${U}; 801 - #else 802 - ${N} ${G} ${U} = u_${U}; 803 - #endif 804 - `:` 805 - #ifndef HAS_UNIFORM_u_${U} 806 - ${N} ${G} ${U} = unpack_mix_${ie}(a_${U}, u_${U}_t); 807 - #else 808 - ${N} ${G} ${U} = u_${U}; 809 - #endif 810 - `})),staticAttributes:h,staticUniforms:T}}class Ki{constructor(t,n,h){this.vertexBuffer=t,this.indexBuffer=n,this.segments=h}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}var Zs=p.aU([{name:"a_pos",type:"Int16",components:2}]);const cn="#define PROJECTION_MERCATOR",gn="mercator";class Lr{constructor(){this._cachedMesh=null}get name(){return"mercator"}get useSubdivision(){return!1}get shaderVariantName(){return gn}get shaderDefine(){return cn}get shaderPreludeCode(){return Li.projectionMercator}get vertexShaderPreludeCode(){return Li.projectionMercator.vertexSource}get subdivisionGranularity(){return p.aV.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(t){}getMeshFromTileID(t,n,h,f,x){if(this._cachedMesh)return this._cachedMesh;const T=new p.aW;T.emplaceBack(0,0),T.emplaceBack(p.a5,0),T.emplaceBack(0,p.a5),T.emplaceBack(p.a5,p.a5);const C=t.createVertexBuffer(T,Zs.members),D=p.aX.simpleSegment(0,0,4,2),B=new p.aY;B.emplaceBack(1,0,2),B.emplaceBack(1,2,3);const N=t.createIndexBuffer(B);return this._cachedMesh=new Ki(C,N,D),this._cachedMesh}recalculate(){}hasTransition(){return!1}setErrorQueryLatitudeDegrees(t){}}class Us{constructor(t=0,n=0,h=0,f=0){if(isNaN(t)||t<0||isNaN(n)||n<0||isNaN(h)||h<0||isNaN(f)||f<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=n,this.left=h,this.right=f}interpolate(t,n,h){return n.top!=null&&t.top!=null&&(this.top=p.G.number(t.top,n.top,h)),n.bottom!=null&&t.bottom!=null&&(this.bottom=p.G.number(t.bottom,n.bottom,h)),n.left!=null&&t.left!=null&&(this.left=p.G.number(t.left,n.left,h)),n.right!=null&&t.right!=null&&(this.right=p.G.number(t.right,n.right,h)),this}getCenter(t,n){const h=p.an((this.left+t-this.right)/2,0,t),f=p.an((this.top+n-this.bottom)/2,0,n);return new p.P(h,f)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new Us(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Qn(y,t){if(!y.renderWorldCopies||y.lngRange)return;const n=t.lng-y.center.lng;t.lng+=n>180?-360:n<-180?360:0}function Si(y){return Math.max(0,Math.floor(y))}class $n{constructor(t,n){var h;this.applyConstrain=(f,x)=>this._constrainOverride!==null?this._constrainOverride(f,x):this._callbacks.defaultConstrain(f,x),this._callbacks=t,this._tileSize=512,this._renderWorldCopies=(n==null?void 0:n.renderWorldCopies)===void 0||!!(n!=null&&n.renderWorldCopies),this._minZoom=(n==null?void 0:n.minZoom)||0,this._maxZoom=(n==null?void 0:n.maxZoom)||22,this._minPitch=(n==null?void 0:n.minPitch)==null?0:n==null?void 0:n.minPitch,this._maxPitch=(n==null?void 0:n.maxPitch)==null?60:n==null?void 0:n.maxPitch,this._constrainOverride=(h=n==null?void 0:n.constrainOverride)!==null&&h!==void 0?h:null,this.setMaxBounds(),this._width=0,this._height=0,this._center=new p.V(0,0),this._elevation=0,this._zoom=0,this._tileZoom=Si(this._zoom),this._scale=p.aq(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new Us,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0}apply(t,n,h){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=Si(this._zoom),this._scale=p.aq(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 Us(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=!h&&t.autoCalculateNearFarZ,n&&this.constrainInternal(),this._calcMatrices()}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(t){this._minElevationForCurrentTile=t}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(t){this._minZoom!==t&&(this._minZoom=t,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get maxZoom(){return this._maxZoom}setMaxZoom(t){this._maxZoom!==t&&(this._maxZoom=t,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get minPitch(){return this._minPitch}setMinPitch(t){this._minPitch!==t&&(this._minPitch=t,this.setPitch(Math.max(this.pitch,t)))}get maxPitch(){return this._maxPitch}setMaxPitch(t){this._maxPitch!==t&&(this._maxPitch=t,this.setPitch(Math.min(this.pitch,t)))}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(t){t===void 0?t=!0:t===null&&(t=!1),this._renderWorldCopies=t}get constrainOverride(){return this._constrainOverride}setConstrainOverride(t){t===void 0&&(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 p.P(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(t){const n=p.W(t,-180,180)*Math.PI/180;var h,f,x,T,C,D,B,N,G;this._bearingInRadians!==n&&(this._unmodified=!1,this._bearingInRadians=n,this._calcMatrices(),this._rotationMatrix=ur(),h=this._rotationMatrix,x=-this._bearingInRadians,T=(f=this._rotationMatrix)[0],C=f[1],D=f[2],B=f[3],N=Math.sin(x),G=Math.cos(x),h[0]=T*G+D*N,h[1]=C*G+B*N,h[2]=T*-N+D*G,h[3]=C*-N+B*G)}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(t){const n=p.an(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==n&&(this._unmodified=!1,this._pitchInRadians=n,this._calcMatrices())}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(t){const n=t/180*Math.PI;this._rollInRadians!==n&&(this._unmodified=!1,this._rollInRadians=n,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return p.aZ(this._fovInRadians)}setFov(t){t=p.an(t,.1,150),this.fov!==t&&(this._unmodified=!1,this._fovInRadians=p.ap(t),this._calcMatrices())}get zoom(){return this._zoom}setZoom(t){const n=this.applyConstrain(this._center,t).zoom;this._zoom!==n&&(this._unmodified=!1,this._zoom=n,this._tileZoom=Math.max(0,Math.floor(n)),this._scale=p.aq(n),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,n){this._autoCalculateNearFarZ=!1,this._nearZ=t,this._farZ=n,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(t){return this._edgeInsets.equals(t)}interpolatePadding(t,n,h){this._unmodified=!1,this._edgeInsets.interpolate(t,n,h),this.constrainInternal(),this._calcMatrices()}resize(t,n,h=!0){this._width=t,this._height=n,h&&this.constrainInternal(),this._calcMatrices()}getMaxBounds(){return this._latRange&&this._latRange.length===2&&this._lngRange&&this._lngRange.length===2?new Ui([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]]):null}setMaxBounds(t){t?(this._lngRange=[t.getWest(),t.getEast()],this._latRange=[t.getSouth(),t.getNorth()],this.constrainInternal()):(this._lngRange=null,this._latRange=[-p.ao,p.ao])}getCameraQueryGeometry(t,n){if(n.length===1)return[n[0],t];{const{minX:h,minY:f,maxX:x,maxY:T}=p.aa.fromPoints(n).extend(t);return[new p.P(h,f),new p.P(x,f),new p.P(x,T),new p.P(h,T),new p.P(h,f)]}}constrainInternal(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;const t=this._unmodified,{center:n,zoom:h}=this.applyConstrain(this.center,this.zoom);this.setCenter(n),this.setZoom(h),this._unmodified=t,this._constraining=!1}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let t=p.ar(new Float64Array(16));p.Q(t,t,[this._width/2,-this._height/2,1]),p.O(t,t,[1,-1,0]),this._clipSpaceToPixelsMatrix=t,t=p.ar(new Float64Array(16)),p.Q(t,t,[1,-1,1]),p.O(t,t,[-1,-1,0]),p.Q(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,n,h,f){const x=h!==void 0?h:this.bearing,T=f=f!==void 0?f:this.pitch,{distanceToCenter:C,clampedElevation:D}=this._distanceToCenterFromAltElevationPitch(n,this.elevation,T),{x:B,y:N}=Hi(T,x),G=p.a9.fromLngLat(t,n);let U,$,ie=p.a_(1,G.y),he=0;do{if(he+=1,he>10)break;$=C/ie,U=new p.a9(G.x+B*$,G.y+N*$),ie=1/U.meterInMercatorCoordinateUnits()}while(Math.abs(C-$*ie)>1e-12);return{center:U.toLngLat(),elevation:D,zoom:p.at(this.height/2/Math.tan(this.fovInRadians/2)/$/this.tileSize)}}recalculateZoomAndCenter(t){if(this.elevation-t==0)return;const n=1/this.worldSize,h=p.as(1,this.center.lat)*this.worldSize,f=p.a9.fromLngLat(this.center,this.elevation),x=f.x/n,T=f.y/n,C=f.z/n,D=this.pitch,B=this.bearing,{x:N,y:G,z:U}=Hi(D,B),$=this.cameraToCenterDistance,ie=x+$*-N,he=T+$*-G,Ae=C+$*U,{distanceToCenter:ce,clampedElevation:ye}=this._distanceToCenterFromAltElevationPitch(Ae/h,t,D),Pe=ce*h,_e=new p.a9((ie+N*Pe)*n,(he+G*Pe)*n,0).toLngLat(),we=p.as(1,_e.lat),Ce=p.at(this.height/2/Math.tan(this.fovInRadians/2)/ce/we/this.tileSize);this._elevation=ye,this._center=_e,this.setZoom(Ce)}_distanceToCenterFromAltElevationPitch(t,n,h){const f=-Math.cos(p.ap(h)),x=t-n;let T,C=n;return f*x>=0||Math.abs(f)<.1?(T=1e4,C=t+T*f):T=-x/f,{distanceToCenter:T,clampedElevation:C}}getCameraPoint(){const t=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new p.P(t*Math.sin(this.rollInRadians),t*Math.cos(this.rollInRadians)))}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this._cameraToCenterDistance/this._pixelPerMeter+this.elevation}getCameraLngLat(){const t=p.as(1,this.center.lat)*this.worldSize;return qe(this.center,this.elevation,this.pitch,this.bearing,this.cameraToCenterDistance/t).toLngLat()}getMercatorTileCoordinates(t){if(!t)return[0,0,1,1];const n=t.canonical.z>=0?1<<t.canonical.z:Math.pow(2,t.canonical.z);return[t.canonical.x/n,t.canonical.y/n,1/n/p.a5,1/n/p.a5]}}class gs{constructor(t,n){this.min=t,this.max=n,this.center=p.a$([],p.b0([],this.min,this.max),.5)}quadrant(t){const n=[t%2==0,t<2],h=p.b1(this.min),f=p.b1(this.max);for(let x=0;x<n.length;x++)h[x]=n[x]?this.min[x]:this.center[x],f[x]=n[x]?this.center[x]:this.max[x];return f[2]=this.max[2],new gs(h,f)}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 n=!0;for(let h=0;h<t.planes.length;h++){const f=this.intersectsPlane(t.planes[h]);if(f===0)return 0;f===1&&(n=!1)}return n?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 n=t[3],h=t[3];for(let f=0;f<3;f++)t[f]>0?(n+=t[f]*this.min[f],h+=t[f]*this.max[f]):(h+=t[f]*this.min[f],n+=t[f]*this.max[f]);return n>=0?2:h<0?0:1}}class ca{distanceToTile2d(t,n,h,f){const x=f.distanceX([t,n]),T=f.distanceY([t,n]);return Math.hypot(x,T)}getWrap(t,n,h){return h}getTileBoundingVolume(t,n,h,f){var x,T;let C=0,D=0;if(f!=null&&f.terrain){const N=new p.a2(t.z,n,t.z,t.x,t.y),G=f.terrain.getMinMaxElevation(N);C=(x=G.minElevation)!==null&&x!==void 0?x:Math.min(0,h),D=(T=G.maxElevation)!==null&&T!==void 0?T:Math.max(0,h)}const B=1<<t.z;return new gs([n+t.x/B,t.y/B,C],[n+(t.x+1)/B,(t.y+1)/B,D])}allowVariableZoom(t,n){const h=t.fov*(Math.abs(Math.cos(t.rollInRadians))*t.height+Math.abs(Math.sin(t.rollInRadians))*t.width)/t.height,f=p.an(78.5-h/2,0,60);return!!n.terrain||t.pitch>f}allowWorldCopies(){return!0}prepareNextFrame(){}}class Yn{constructor(t,n,h){this.points=t,this.planes=n,this.aabb=h}static fromInvProjectionMatrix(t,n=1,h=0,f,x){const T=x?[[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]],C=Math.pow(2,h),D=[[-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((U=>(function($,ie,he,Ae){const ce=p.aH([],$,ie),ye=1/ce[3]/he*Ae;return p.b6(ce,ce,[ye,ye,1/ce[3],ye])})(U,t,n,C)));f&&(function(U,$,ie,he){const Ae=he?4:0,ce=he?0:4;let ye=0;const Pe=[],_e=[];for(let be=0;be<4;be++){const Le=p.b2([],U[be+ce],U[be+Ae]),Ke=p.b7(Le);p.a$(Le,Le,1/Ke),Pe.push(Ke),_e.push(Le)}for(let be=0;be<4;be++){const Le=p.b8(U[be+Ae],_e[be],ie);ye=Le!==null&&Le>=0?Math.max(ye,Le):Math.max(ye,Pe[be])}const we=(function(be,Le){const Ke=p.b2([],be[Le[0]],be[Le[1]]),He=p.b2([],be[Le[2]],be[Le[1]]),$e=[0,0,0,0];return p.b3($e,p.b4([],Ke,He)),$e[3]=-p.b5($e,be[Le[0]]),$e})(U,$),Ce=(function(be,Le){const Ke=p.b9(be),He=p.ba([],be,1/Ke),$e=p.b2([],Le,p.a$([],He,p.b5(Le,He))),Ye=p.b9($e);if(Ye>0){const xt=Math.sqrt(1-He[3]*He[3]),wt=p.a$([],He,-He[3]),pt=p.b0([],wt,p.a$([],$e,xt/Ye));return p.bb(Le,pt)}return null})(ie,we);if(Ce!==null){const be=Ce/p.b5(_e[0],we);ye=Math.min(ye,be)}for(let be=0;be<4;be++){const Le=Math.min(ye,Pe[be]);U[be+ce]=[U[be+Ae][0]+_e[be][0]*Le,U[be+Ae][1]+_e[be][1]*Le,U[be+Ae][2]+_e[be][2]*Le,1]}})(D,T[0],f,x);const B=T.map((U=>{const $=p.b2([],D[U[0]],D[U[1]]),ie=p.b2([],D[U[2]],D[U[1]]),he=p.b3([],p.b4([],$,ie)),Ae=-p.b5(he,D[U[1]]);return he.concat(Ae)})),N=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],G=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const U of D)for(let $=0;$<3;$++)N[$]=Math.min(N[$],U[$]),G[$]=Math.max(G[$],U[$]);return new Yn(D,B,new gs(N,G))}}class Po{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,n,h){return this._helper.interpolatePadding(t,n,h)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,n,h=!0){this._helper.resize(t,n,h)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}setConstrainOverride(t){this._helper.setConstrainOverride(t)}overrideNearFarZ(t,n){this._helper.overrideNearFarZ(t,n)}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,n){}constructor(t){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this.defaultConstrain=(n,h)=>{h=p.an(+h,this.minZoom,this.maxZoom);const f={center:new p.V(n.lng,n.lat),zoom:h};let x=this._helper._lngRange;if(!this._helper._renderWorldCopies&&x===null){const _e=179.9999999999;x=[-_e,_e]}const T=this.tileSize*p.aq(f.zoom);let C=0,D=T,B=0,N=T,G=0,U=0;const{x:$,y:ie}=this.size;if(this._helper._latRange){const _e=this._helper._latRange;C=p.X(_e[1])*T,D=p.X(_e[0])*T,D-C<ie&&(G=ie/(D-C))}x&&(B=p.W(p.Y(x[0])*T,0,T),N=p.W(p.Y(x[1])*T,0,T),N<B&&(N+=T),N-B<$&&(U=$/(N-B)));const{x:he,y:Ae}=je(T,n);let ce,ye;const Pe=Math.max(U||0,G||0);if(Pe){const _e=new p.P(U?(N+B)/2:he,G?(D+C)/2:Ae);return f.center=Xt(T,_e).wrap(),f.zoom+=p.at(Pe),f}if(this._helper._latRange){const _e=ie/2;Ae-_e<C&&(ye=C+_e),Ae+_e>D&&(ye=D-_e)}if(x){const _e=(B+N)/2;let we=he;this._helper._renderWorldCopies&&(we=p.W(he,_e-T/2,_e+T/2));const Ce=$/2;we-Ce<B&&(ce=B+Ce),we+Ce>N&&(ce=N-Ce)}if(ce!==void 0||ye!==void 0){const _e=new p.P(ce??he,ye??Ae);f.center=Xt(T,_e).wrap()}return f},this.applyConstrain=(n,h)=>this._helper.applyConstrain(n,h),this._helper=new $n({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(n,h)=>this.defaultConstrain(n,h)},t),this._coveringTilesDetailsProvider=new ca}clone(){const t=new Po;return t.apply(this,!1),t}apply(t,n,h){this._helper.apply(t,n,h)}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(t){const n=[new p.bc(0,t)];if(this._helper._renderWorldCopies){const h=this.screenPointToMercatorCoordinate(new p.P(0,0)),f=this.screenPointToMercatorCoordinate(new p.P(this._helper._width,0)),x=this.screenPointToMercatorCoordinate(new p.P(this._helper._width,this._helper._height)),T=this.screenPointToMercatorCoordinate(new p.P(0,this._helper._height)),C=Math.floor(Math.min(h.x,f.x,x.x,T.x)),D=Math.floor(Math.max(h.x,f.x,x.x,T.x)),B=1;for(let N=C-B;N<=D+B;N++)N!==0&&n.push(new p.bc(N,t))}return n}getCameraFrustum(){return Yn.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(t){const n=this.screenPointToLocation(this.centerPoint,t),h=t?t.getElevationForLngLatZoom(n,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(h)}setLocationAtPoint(t,n){const h=p.as(this.elevation,this.center.lat),f=this.screenPointToMercatorCoordinateAtZ(n,h),x=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,h),T=p.a9.fromLngLat(t),C=new p.a9(T.x-(f.x-x.x),T.y-(f.y-x.y));this.setCenter(C==null?void 0:C.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(t,n){return n?this.coordinatePoint(p.a9.fromLngLat(t),n.getElevationForLngLat(t,this),this._pixelMatrix3D):this.coordinatePoint(p.a9.fromLngLat(t))}screenPointToLocation(t,n){var h;return(h=this.screenPointToMercatorCoordinate(t,n))===null||h===void 0?void 0:h.toLngLat()}screenPointToMercatorCoordinate(t,n){if(n){const h=n.pointCoordinate(t);if(h!=null)return h}return this.screenPointToMercatorCoordinateAtZ(t)}screenPointToMercatorCoordinateAtZ(t,n){const h=n||0,f=[t.x,t.y,0,1],x=[t.x,t.y,1,1];p.aH(f,f,this._pixelMatrixInverse),p.aH(x,x,this._pixelMatrixInverse);const T=f[3],C=x[3],D=f[1]/T,B=x[1]/C,N=f[2]/T,G=x[2]/C,U=N===G?0:(h-N)/(G-N);return new p.a9(p.G.number(f[0]/T,x[0]/C,U)/this.worldSize,p.G.number(D,B,U)/this.worldSize,h)}coordinatePoint(t,n=0,h=this._pixelMatrix){const f=[t.x*this.worldSize,t.y*this.worldSize,n,1];return p.aH(f,f,h),new p.P(f[0]/f[3],f[1]/f[3])}getBounds(){const t=Math.max(0,this._helper._height/2-Gi(this));return new Ui().extend(this.screenPointToLocation(new p.P(0,t))).extend(this.screenPointToLocation(new p.P(this._helper._width,t))).extend(this.screenPointToLocation(new p.P(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new p.P(0,this._helper._height)))}isPointOnMapSurface(t,n){return n?n.pointCoordinate(t)!=null:t.y>this.height/2-Gi(this)}calculatePosMatrix(t,n=!1,h){var f;const x=(f=t.key)!==null&&f!==void 0?f:p.bd(t.wrap,t.canonical.z,t.canonical.z,t.canonical.x,t.canonical.y),T=n?this._alignedPosMatrixCache:this._posMatrixCache;if(T.has(x)){const B=T.get(x);return h?B.f32:B.f64}const C=Bi(t,this.worldSize);p.S(C,n?this._alignedProjMatrix:this._viewProjMatrix,C);const D={f64:C,f32:new Float32Array(C)};return T.set(x,D),h?D.f32:D.f64}calculateFogMatrix(t){const n=t.key,h=this._fogMatrixCacheF32;if(h.has(n))return h.get(n);const f=Bi(t,this.worldSize);return p.S(f,this._fogMatrix,f),h.set(n,new Float32Array(f)),h.get(n)}calculateCenterFromCameraLngLatAlt(t,n,h,f){return this._helper.calculateCenterFromCameraLngLatAlt(t,n,h,f)}_calculateNearFarZIfNeeded(t,n,h){if(!this._helper.autoCalculateNearFarZ)return;const f=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),x=t-f*this._helper._pixelPerMeter/Math.cos(n),T=f<0?x:t,C=Math.PI/2+this.pitchInRadians,D=p.ap(this.fov)*(Math.abs(Math.cos(p.ap(this.roll)))*this.height+Math.abs(Math.sin(p.ap(this.roll)))*this.width)/this.height*(.5+h.y/this.height),B=Math.sin(D)*T/Math.sin(p.an(Math.PI-C-D,.01,Math.PI-.01)),N=Gi(this),G=Math.atan(N/this._helper.cameraToCenterDistance),U=p.ap(.75),$=G>U?2*G*(.5+h.y/(2*N)):U,ie=Math.sin($)*T/Math.sin(p.an(Math.PI-C-$,.01,Math.PI-.01)),he=Math.min(B,ie);this._helper._farZ=1.01*(Math.cos(Math.PI/2-n)*he+T),this._helper._nearZ=this._helper._height/50}_calcMatrices(){if(!this._helper._height)return;const t=this.centerOffset,n=je(this.worldSize,this.center),h=n.x,f=n.y;this._helper._pixelPerMeter=p.as(1,this.center.lat)*this.worldSize;const x=p.ap(Math.min(this.pitch,St)),T=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(x));let C;this._calculateNearFarZIfNeeded(T,x,t),C=new Float64Array(16),p.be(C,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),p.aB(this._invProjMatrix,C),C[8]=2*-t.x/this._helper._width,C[9]=2*t.y/this._helper._height,this._projectionMatrix=p.bf(C),p.Q(C,C,[1,-1,1]),p.O(C,C,[0,0,-this._helper.cameraToCenterDistance]),p.bg(C,C,-this.rollInRadians),p.bh(C,C,this.pitchInRadians),p.bg(C,C,-this.bearingInRadians),p.O(C,C,[-h,-f,0]),this._mercatorMatrix=p.Q([],C,[this.worldSize,this.worldSize,this.worldSize]),p.Q(C,C,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=p.S(new Float64Array(16),this.clipSpaceToPixelsMatrix,C),p.O(C,C,[0,0,-this.elevation]),this._viewProjMatrix=C,this._invViewProjMatrix=p.aB([],C);const D=[0,0,-1,1];p.aH(D,D,this._invViewProjMatrix),this._cameraPosition=[D[0]/D[3],D[1]/D[3],D[2]/D[3]],this._fogMatrix=new Float64Array(16),p.be(this._fogMatrix,this.fovInRadians,this.width/this.height,T,this._helper._farZ),this._fogMatrix[8]=2*-t.x/this.width,this._fogMatrix[9]=2*t.y/this.height,p.Q(this._fogMatrix,this._fogMatrix,[1,-1,1]),p.O(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),p.bg(this._fogMatrix,this._fogMatrix,-this.rollInRadians),p.bh(this._fogMatrix,this._fogMatrix,this.pitchInRadians),p.bg(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),p.O(this._fogMatrix,this._fogMatrix,[-h,-f,0]),p.Q(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),p.O(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=p.S(new Float64Array(16),this.clipSpaceToPixelsMatrix,C);const B=this._helper._width%2/2,N=this._helper._height%2/2,G=Math.cos(this.bearingInRadians),U=Math.sin(-this.bearingInRadians),$=h-Math.round(h)+G*B+U*N,ie=f-Math.round(f)+G*N+U*B,he=new Float64Array(C);if(p.O(he,he,[$>.5?$-1:$,ie>.5?ie-1:ie,0]),this._alignedProjMatrix=he,C=p.aB(new Float64Array(16),this._pixelMatrix),!C)throw new Error("failed to invert matrix");this._pixelMatrixInverse=C,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;const t=this.screenPointToMercatorCoordinate(new p.P(0,0)),n=[t.x*this.worldSize,t.y*this.worldSize,0,1];return p.aH(n,n,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){const t=p.as(1,this.center.lat)*this.worldSize;return qe(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/t).toLngLat()}lngLatToCameraDepth(t,n){const h=p.a9.fromLngLat(t),f=[h.x*this.worldSize,h.y*this.worldSize,n,1];return p.aH(f,f,this._viewProjMatrix),f[2]/f[3]}getProjectionData(t){const{overscaledTileID:n,aligned:h,applyTerrainMatrix:f}=t,x=this._helper.getMercatorTileCoordinates(n),T=n?this.calculatePosMatrix(n,h,!0):null;let C;return C=n&&n.terrainRttPosMatrix32f&&f?n.terrainRttPosMatrix32f:T||p.bi(),{mainMatrix:C,tileMercatorCoords:x,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:C}}isLocationOccluded(t){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(t,n,h){return 1}transformLightDirection(t){return p.b1(t)}getRayDirectionFromPixel(t){throw new Error("Not implemented.")}projectTileCoordinates(t,n,h,f){const x=this.calculatePosMatrix(h);let T;f?(T=[t,n,f(t,n),1],p.aH(T,T,x)):(T=[t,n,0,1],te(T,T,x));const C=T[3];return{point:new p.P(T[0]/C,T[1]/C),signedDistanceFromCamera:C,isOccluded:!1}}populateCache(t){for(const n of t)this.calculatePosMatrix(n)}getMatrixForModel(t,n){const h=p.a9.fromLngLat(t,n),f=h.meterInMercatorCoordinateUnits(),x=p.bj();return p.O(x,x,[h.x,h.y,h.z]),p.bg(x,x,Math.PI),p.bh(x,x,Math.PI/2),p.Q(x,x,[-f,f,f]),x}getProjectionDataForCustomLayer(t=!0){const n=new p.a2(0,0,0,0,0),h=this.getProjectionData({overscaledTileID:n,applyGlobeMatrix:t}),f=Bi(n,this.worldSize);p.S(f,this._viewProjMatrix,f),h.tileMercatorCoords=[0,0,1,1];const x=[p.a5,p.a5,this.worldSize/this._helper.pixelsPerMeter],T=p.bk();return p.Q(T,f,x),h.fallbackMatrix=T,h.mainMatrix=T,h}getFastPathSimpleProjectionMatrix(t){return this.calculatePosMatrix(t)}}function Ls(){p.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function Vl(y){if(y.useSlerp)if(y.k<1){const t=p.bl(y.startEulerAngles.roll,y.startEulerAngles.pitch,y.startEulerAngles.bearing),n=p.bl(y.endEulerAngles.roll,y.endEulerAngles.pitch,y.endEulerAngles.bearing),h=new Float64Array(4);p.bm(h,t,n,y.k);const f=p.bn(h);y.tr.setRoll(f.roll),y.tr.setPitch(f.pitch),y.tr.setBearing(f.bearing)}else y.tr.setRoll(y.endEulerAngles.roll),y.tr.setPitch(y.endEulerAngles.pitch),y.tr.setBearing(y.endEulerAngles.bearing);else y.tr.setRoll(p.G.number(y.startEulerAngles.roll,y.endEulerAngles.roll,y.k)),y.tr.setPitch(p.G.number(y.startEulerAngles.pitch,y.endEulerAngles.pitch,y.k)),y.tr.setBearing(p.G.number(y.startEulerAngles.bearing,y.endEulerAngles.bearing,y.k))}function Qr(y,t,n,h,f){const x=f.padding,T=je(f.worldSize,n.getNorthWest()),C=je(f.worldSize,n.getNorthEast()),D=je(f.worldSize,n.getSouthEast()),B=je(f.worldSize,n.getSouthWest()),N=p.ap(-h),G=T.rotate(N),U=C.rotate(N),$=D.rotate(N),ie=B.rotate(N),he=new p.P(Math.max(G.x,U.x,ie.x,$.x),Math.max(G.y,U.y,ie.y,$.y)),Ae=new p.P(Math.min(G.x,U.x,ie.x,$.x),Math.min(G.y,U.y,ie.y,$.y)),ce=he.sub(Ae),ye=(f.width-(x.left+x.right+t.left+t.right))/ce.x,Pe=(f.height-(x.top+x.bottom+t.top+t.bottom))/ce.y;if(Pe<0||ye<0)return void Ls();const _e=Math.min(p.at(f.scale*Math.min(ye,Pe)),y.maxZoom),we=p.P.convert(y.offset),Ce=new p.P((t.left-t.right)/2,(t.top-t.bottom)/2).rotate(p.ap(h)),be=we.add(Ce).mult(f.scale/p.aq(_e));return{center:Xt(f.worldSize,T.add(D).div(2).sub(be)),zoom:_e,bearing:h}}class hi{get useGlobeControls(){return!1}handlePanInertia(t,n){const h=t.mag(),f=Math.abs(Gi(n));return{easingOffset:t.mult(Math.min(.75*f/h,1)),easingCenter:n.center}}handleMapControlsRollPitchBearingZoom(t,n){t.bearingDelta&&n.setBearing(n.bearing+t.bearingDelta),t.pitchDelta&&n.setPitch(n.pitch+t.pitchDelta),t.rollDelta&&n.setRoll(n.roll+t.rollDelta),t.zoomDelta&&n.setZoom(n.zoom+t.zoomDelta)}handleMapControlsPan(t,n,h){t.around.distSqr(n.centerPoint)<.01||n.setLocationAtPoint(h,t.around)}cameraForBoxAndBearing(t,n,h,f,x){return Qr(t,n,h,f,x)}handleJumpToCenterZoom(t,n){t.zoom!==(n.zoom!==void 0?+n.zoom:t.zoom)&&t.setZoom(+n.zoom),n.center!==void 0&&t.setCenter(p.V.convert(n.center))}handleEaseTo(t,n){const h=t.zoom,f=t.padding,x={roll:t.roll,pitch:t.pitch,bearing:t.bearing},T={roll:n.roll===void 0?t.roll:n.roll,pitch:n.pitch===void 0?t.pitch:n.pitch,bearing:n.bearing===void 0?t.bearing:n.bearing},C=n.zoom!==void 0,D=!t.isPaddingEqual(n.padding);let B=!1;const N=C?+n.zoom:t.zoom;let G=t.centerPoint.add(n.offsetAsPoint);const U=t.screenPointToLocation(G),{center:$,zoom:ie}=t.applyConstrain(p.V.convert(n.center||U),N??h);Qn(t,$);const he=je(t.worldSize,U),Ae=je(t.worldSize,$).sub(he),ce=p.aq(ie-h);return B=ie!==h,{easeFunc:ye=>{if(B&&t.setZoom(p.G.number(h,ie,ye)),p.bo(x,T)||Vl({startEulerAngles:x,endEulerAngles:T,tr:t,k:ye,useSlerp:x.roll!=T.roll}),D&&(t.interpolatePadding(f,n.padding,ye),G=t.centerPoint.add(n.offsetAsPoint)),n.around)t.setLocationAtPoint(n.around,n.aroundPoint);else{const Pe=p.aq(t.zoom-h),_e=ie>h?Math.min(2,ce):Math.max(.5,ce),we=Math.pow(_e,1-ye),Ce=Xt(t.worldSize,he.add(Ae.mult(ye*we)).mult(Pe));t.setLocationAtPoint(t.renderWorldCopies?Ce.wrap():Ce,G)}},isZooming:B,elevationCenter:$}}handleFlyTo(t,n){const h=n.zoom!==void 0,f=t.zoom,x=t.applyConstrain(p.V.convert(n.center||n.locationAtOffset),h?+n.zoom:f),T=x.center,C=x.zoom;Qn(t,T);const D=je(t.worldSize,n.locationAtOffset),B=je(t.worldSize,T).sub(D),N=B.mag(),G=p.aq(C-f);let U;if(n.minZoom!==void 0){const $=Math.min(+n.minZoom,f,C),ie=t.applyConstrain(T,$).zoom;U=p.aq(ie-f)}return{easeFunc:($,ie,he,Ae)=>{t.setZoom($===1?C:f+p.at(ie));const ce=$===1?T:Xt(t.worldSize,D.add(B.mult(he)).mult(ie));t.setLocationAtPoint(t.renderWorldCopies?ce.wrap():ce,Ae)},scaleOfZoom:G,targetCenter:T,scaleOfMinZoom:U,pixelPathLength:N}}}class bi{constructor(t,n,h){this.blendFunction=t,this.blendColor=n,this.mask=h}}bi.Replace=[1,0],bi.disabled=new bi(bi.Replace,p.bp.transparent,[!1,!1,!1,!1]),bi.unblended=new bi(bi.Replace,p.bp.transparent,[!0,!0,!0,!0]),bi.alphaBlended=new bi([1,771],p.bp.transparent,[!0,!0,!0,!0]);const nn=2305;class wi{constructor(t,n,h){this.enable=t,this.mode=n,this.frontFace=h}}wi.disabled=new wi(!1,1029,nn),wi.backCCW=new wi(!0,1029,nn),wi.frontCCW=new wi(!0,1028,nn);class ri{constructor(t,n,h){this.func=t,this.mask=n,this.range=h}}ri.ReadOnly=!1,ri.ReadWrite=!0,ri.disabled=new ri(519,ri.ReadOnly,[0,1]);const Aa=7680;class Ci{constructor(t,n,h,f,x,T){this.test=t,this.ref=n,this.mask=h,this.fail=f,this.depthFail=x,this.pass=T}}Ci.disabled=new Ci({func:519,mask:0},0,0,Aa,Aa,Aa);const Da=new WeakMap;function Xn(y){var t;if(Da.has(y))return Da.get(y);{const n=(t=y.getParameter(y.VERSION))===null||t===void 0?void 0:t.startsWith("WebGL 2.0");return Da.set(y,n),n}}class oo{get awaitingQuery(){return!!this._readbackQueue}constructor(t){this._readbackWaitFrames=4,this._measureWaitFrames=6,this._texWidth=1,this._texHeight=1,this._measuredError=0,this._updateCount=0,this._lastReadbackFrame=-1e3,this._readbackQueue=null,this._cachedRenderContext=t;const n=t.context,h=n.gl;this._texFormat=h.RGBA,this._texType=h.UNSIGNED_BYTE;const f=new p.aW;f.emplaceBack(-1,-1),f.emplaceBack(2,-1),f.emplaceBack(-1,2);const x=new p.aY;x.emplaceBack(0,1,2),this._fullscreenTriangle=new Ki(n.createVertexBuffer(f,Zs.members),n.createIndexBuffer(x),p.aX.simpleSegment(0,0,f.length,x.length)),this._resultBuffer=new Uint8Array(4),n.activeTexture.set(h.TEXTURE1);const T=h.createTexture();h.bindTexture(h.TEXTURE_2D,T),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MIN_FILTER,h.NEAREST),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MAG_FILTER,h.NEAREST),h.texImage2D(h.TEXTURE_2D,0,this._texFormat,this._texWidth,this._texHeight,0,this._texFormat,this._texType,null),this._fbo=n.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(T),Xn(h)&&(this._pbo=h.createBuffer(),h.bindBuffer(h.PIXEL_PACK_BUFFER,this._pbo),h.bufferData(h.PIXEL_PACK_BUFFER,4,h.STREAM_READ),h.bindBuffer(h.PIXEL_PACK_BUFFER,null))}destroy(){const t=this._cachedRenderContext.context.gl;this._fullscreenTriangle.destroy(),this._fbo.destroy(),t.deleteBuffer(this._pbo),this._fullscreenTriangle=null,this._fbo=null,this._pbo=null,this._resultBuffer=null}updateErrorLoop(t,n){const h=this._updateCount;return this._readbackQueue?h>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():h>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(t,n),this._updateCount++,this._measuredError}_bindFramebuffer(){const t=this._cachedRenderContext.context,n=t.gl;t.activeTexture.set(n.TEXTURE1),n.bindTexture(n.TEXTURE_2D,this._fbo.colorAttachment.get()),t.bindFramebuffer.set(this._fbo.framebuffer)}_renderErrorTexture(t,n){const h=this._cachedRenderContext.context,f=h.gl;if(this._bindFramebuffer(),h.viewport.set([0,0,this._texWidth,this._texHeight]),h.clear({color:p.bp.transparent}),this._cachedRenderContext.useProgram("projectionErrorMeasurement").draw(h,f.TRIANGLES,ri.disabled,Ci.disabled,bi.unblended,wi.disabled,((x,T)=>({u_input:x,u_output_expected:T}))(t,n),null,null,"$clipping",this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),this._pbo&&Xn(f)){f.bindBuffer(f.PIXEL_PACK_BUFFER,this._pbo),f.readBuffer(f.COLOR_ATTACHMENT0),f.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),f.bindBuffer(f.PIXEL_PACK_BUFFER,null);const x=f.fenceSync(f.SYNC_GPU_COMMANDS_COMPLETE,0);f.flush(),this._readbackQueue={frameNumberIssued:this._updateCount,sync:x}}else this._readbackQueue={frameNumberIssued:this._updateCount,sync:null}}_tryReadback(){const t=this._cachedRenderContext.context.gl;if(this._pbo&&this._readbackQueue&&Xn(t)){const n=t.clientWaitSync(this._readbackQueue.sync,0,0);if(n===t.WAIT_FAILED)return p.w("WebGL2 clientWaitSync failed."),this._readbackQueue=null,void(this._lastReadbackFrame=this._updateCount);if(n===t.TIMEOUT_EXPIRED)return;t.bindBuffer(t.PIXEL_PACK_BUFFER,this._pbo),t.getBufferSubData(t.PIXEL_PACK_BUFFER,0,this._resultBuffer,0,4),t.bindBuffer(t.PIXEL_PACK_BUFFER,null)}else this._bindFramebuffer(),t.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,this._resultBuffer);this._readbackQueue=null,this._measuredError=oo._parseRGBA8float(this._resultBuffer),this._lastReadbackFrame=this._updateCount}static _parseRGBA8float(t){let n=0;return n+=t[0]/256,n+=t[1]/65536,n+=t[2]/16777216,t[3]<127&&(n=-n),n/128}}const Kn=p.a5/128;function ka(y,t){const n=y.granularity!==void 0?Math.max(y.granularity,1):1,h=n+(y.generateBorders?2:0),f=n+(y.extendToNorthPole||y.generateBorders?1:0)+(y.extendToSouthPole||y.generateBorders?1:0),x=h+1,T=f+1,C=y.generateBorders?-1:0,D=y.generateBorders||y.extendToNorthPole?-1:0,B=n+(y.generateBorders?1:0),N=n+(y.generateBorders||y.extendToSouthPole?1:0),G=x*T,U=h*f*6,$=x*T>65536;if($&&t==="16bit")throw new Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");const ie=$||t==="32bit",he=new Int16Array(2*G);let Ae=0;for(let Pe=D;Pe<=N;Pe++)for(let _e=C;_e<=B;_e++){let we=_e/n*p.a5;_e===-1&&(we=-Kn),_e===n+1&&(we=p.a5+Kn);let Ce=Pe/n*p.a5;Pe===-1&&(Ce=y.extendToNorthPole?p.br:-Kn),Pe===n+1&&(Ce=y.extendToSouthPole?p.bs:p.a5+Kn),he[Ae++]=we,he[Ae++]=Ce}const ce=ie?new Uint32Array(U):new Uint16Array(U);let ye=0;for(let Pe=0;Pe<f;Pe++)for(let _e=0;_e<h;_e++){const we=_e+1+Pe*x,Ce=_e+(Pe+1)*x,be=_e+1+(Pe+1)*x;ce[ye++]=_e+Pe*x,ce[ye++]=Ce,ce[ye++]=we,ce[ye++]=we,ce[ye++]=Ce,ce[ye++]=be}return{vertices:he.buffer.slice(0),indices:ce.buffer.slice(0),uses32bitIndices:ie}}const fa=new p.aV({fill:new p.bt(128,2),line:new p.bt(512,0),tile:new p.bt(128,32),stencil:new p.bt(128,1),circle:3});class Bn{constructor(){this._tileMeshCache={},this._errorCorrectionUsable=0,this._errorMeasurementLastValue=0,this._errorCorrectionPreviousValue=0,this._errorMeasurementLastChangeTime=-1e3}get name(){return"vertical-perspective"}get transitionState(){return 1}get useSubdivision(){return!0}get shaderVariantName(){return"globe"}get shaderDefine(){return"#define GLOBE"}get shaderPreludeCode(){return Li.projectionGlobe}get vertexShaderPreludeCode(){return Li.projectionMercator.vertexSource}get subdivisionGranularity(){return fa}get useGlobeControls(){return!0}get latitudeErrorCorrectionRadians(){return this._errorCorrectionUsable}destroy(){this._errorMeasurement&&this._errorMeasurement.destroy()}updateGPUdependent(t){this._errorMeasurement||(this._errorMeasurement=new oo(t));const n=p.X(this._errorQueryLatitudeDegrees),h=2*Math.atan(Math.exp(Math.PI-n*Math.PI*2))-.5*Math.PI,f=this._errorMeasurement.updateErrorLoop(n,h),x=Gt();f!==this._errorMeasurementLastValue&&(this._errorCorrectionPreviousValue=this._errorCorrectionUsable,this._errorMeasurementLastValue=f,this._errorMeasurementLastChangeTime=x);const T=Math.min(Math.max((x-this._errorMeasurementLastChangeTime)/1e3/.5,0),1);this._errorCorrectionUsable=p.bu(this._errorCorrectionPreviousValue,-this._errorMeasurementLastValue,p.bv(T))}_getMeshKey(t){return`${t.granularity.toString(36)}_${t.generateBorders?"b":""}${t.extendToNorthPole?"n":""}${t.extendToSouthPole?"s":""}`}getMeshFromTileID(t,n,h,f,x){const T=(x==="stencil"?fa.stencil:fa.tile).getGranularityForZoomLevel(n.z);return this._getMesh(t,{granularity:T,generateBorders:h,extendToNorthPole:n.y===0&&f,extendToSouthPole:n.y===(1<<n.z)-1&&f})}_getMesh(t,n){const h=this._getMeshKey(n);if(h in this._tileMeshCache)return this._tileMeshCache[h];const f=(function(x,T){const C=ka(T,"16bit"),D=p.aW.deserialize({arrayBuffer:C.vertices,length:C.vertices.byteLength/2/2}),B=p.aY.deserialize({arrayBuffer:C.indices,length:C.indices.byteLength/2/3});return new Ki(x.createVertexBuffer(D,Zs.members),x.createIndexBuffer(B),p.aX.simpleSegment(0,0,D.length,B.length))})(t,n);return this._tileMeshCache[h]=f,f}recalculate(t){}hasTransition(){const t=Gt();let n=!1;return n=n||(t-this._errorMeasurementLastChangeTime)/1e3<.7,n=n||this._errorMeasurement&&this._errorMeasurement.awaitingQuery,n}setErrorQueryLatitudeDegrees(t){this._errorQueryLatitudeDegrees=t}}const Wo=new p.t({type:new p.D(p.u.projection.type)});class Gs extends p.E{constructor(t){super(),this._transitionable=new p.x(Wo,void 0),this.setProjection(t),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new p.H(0)),this._mercatorProjection=new Lr,this._verticalPerspectiveProjection=new Bn}get transitionState(){const t=this.properties.get("type");if(typeof t=="string"&&t==="mercator")return 0;if(typeof t=="string"&&t==="vertical-perspective")return 1;if(t instanceof p.bw){if(t.from==="vertical-perspective"&&t.to==="mercator")return 1-t.transition;if(t.from==="mercator"&&t.to==="vertical-perspective")return t.transition}return 1}get useGlobeRendering(){return this.transitionState>0}get latitudeErrorCorrectionRadians(){return this._verticalPerspectiveProjection.latitudeErrorCorrectionRadians}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return"globe"}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy()}updateGPUdependent(t){this._mercatorProjection.updateGPUdependent(t),this._verticalPerspectiveProjection.updateGPUdependent(t)}getMeshFromTileID(t,n,h,f,x){return this.currentProjection.getMeshFromTileID(t,n,h,f,x)}setProjection(t){this._transitionable.setValue("type",(t==null?void 0:t.type)||"mercator")}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}setErrorQueryLatitudeDegrees(t){this._verticalPerspectiveProjection.setErrorQueryLatitudeDegrees(t),this._mercatorProjection.setErrorQueryLatitudeDegrees(t)}}function xr(y){const t=ao(y.worldSize,y.center.lat);return 2*Math.PI*t}function ys(y,t,n,h,f){const x=1/(1<<f),T=t/p.a5*x+h*x,C=p.by((y/p.a5*x+n*x)*Math.PI*2+Math.PI,2*Math.PI),D=2*Math.atan(Math.exp(Math.PI-T*Math.PI*2))-.5*Math.PI,B=Math.cos(D),N=new Float64Array(3);return N[0]=Math.sin(C)*B,N[1]=Math.sin(D),N[2]=Math.cos(C)*B,N}function ir(y){return(function(t,n){const h=Math.cos(n),f=new Float64Array(3);return f[0]=Math.sin(t)*h,f[1]=Math.sin(n),f[2]=Math.cos(t)*h,f})(y.lng*Math.PI/180,y.lat*Math.PI/180)}function ao(y,t){return y/(2*Math.PI)/Math.cos(t*Math.PI/180)}function yl(y){const t=Math.asin(y[1])/Math.PI*180,n=Math.sqrt(y[0]*y[0]+y[2]*y[2]);if(n>1e-6){const h=y[0]/n,f=Math.acos(y[2]/n),x=(h>0?f:-f)/Math.PI*180;return new p.V(p.W(x,-180,180),t)}return new p.V(0,t)}function Qo(y){return Math.cos(y*Math.PI/180)}function dr(y,t){const n=Qo(y),h=Qo(t);return p.at(h/n)}function jl(y,t){const n=y.rotate(t.bearingInRadians),h=t.zoom+dr(t.center.lat,0),f=p.bu(1/Qo(t.center.lat),1/Qo(Math.min(Math.abs(t.center.lat),60)),p.bx(h,7,3,0,1)),x=360/xr({worldSize:t.worldSize,center:{lat:t.center.lat}});return new p.V(t.center.lng-n.x*x*f,p.an(t.center.lat+n.y*x,-p.ao,p.ao))}function vl(y){const t=.5*y,n=Math.sin(t),h=Math.cos(t);return Math.log(n+h)-Math.log(h-n)}function Ya(y,t,n,h){const f=y.lat+n*h;if(Math.abs(n)>1){const x=(Math.sign(y.lat+n)!==Math.sign(y.lat)?-Math.abs(y.lat):Math.abs(y.lat))*Math.PI/180,T=Math.abs(y.lat+n)*Math.PI/180,C=vl(x+h*(T-x)),D=vl(x),B=vl(T);return new p.V(y.lng+t*((C-D)/(B-D)),f)}return new p.V(y.lng+t*h,f)}class uu{constructor(t){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._boundingVolumeFactory=t}swapBuffers(){if(!this._hadAnyChanges)return;const t=this._cachePrevious;this._cachePrevious=this._cache,this._cache=t,this._cache.clear(),this._hadAnyChanges=!1}getTileBoundingVolume(t,n,h,f){const x=`${t.z}_${t.x}_${t.y}_${f!=null&&f.terrain?"t":""}`,T=this._cache.get(x);if(T)return T;const C=this._cachePrevious.get(x);if(C)return this._cache.set(x,C),C;const D=this._boundingVolumeFactory(t,n,h,f);return this._cache.set(x,D),this._hadAnyChanges=!0,D}}class Mo{constructor(t,n,h,f){this.min=h,this.max=f,this.points=t,this.planes=n}static fromAabb(t,n){const h=[];for(let f=0;f<8;f++)h.push([1&~f?t[0]:n[0],(f>>1&1)==1?n[1]:t[1],(f>>2&1)==1?n[2]:t[2]]);return new Mo(h,[[-1,0,0,n[0]],[1,0,0,-t[0]],[0,-1,0,n[1]],[0,1,0,-t[1]],[0,0,-1,n[2]],[0,0,1,-t[2]]],t,n)}static fromCenterSizeAngles(t,n,h){const f=p.bB([],h[0],h[1],h[2]),x=p.bC([],[n[0],0,0],f),T=p.bC([],[0,n[1],0],f),C=p.bC([],[0,0,n[2]],f),D=[...t],B=[...t];for(let G=0;G<8;G++)for(let U=0;U<3;U++){const $=t[U]+x[U]*(1&~G?-1:1)+T[U]*((G>>1&1)==1?1:-1)+C[U]*((G>>2&1)==1?1:-1);D[U]=Math.min(D[U],$),B[U]=Math.max(B[U],$)}const N=[];for(let G=0;G<8;G++){const U=[...t];p.b0(U,U,p.a$([],x,1&~G?-1:1)),p.b0(U,U,p.a$([],T,(G>>1&1)==1?1:-1)),p.b0(U,U,p.a$([],C,(G>>2&1)==1?1:-1)),N.push(U)}return new Mo(N,[[...x,-p.b5(x,N[0])],[...T,-p.b5(T,N[0])],[...C,-p.b5(C,N[0])],[-x[0],-x[1],-x[2],-p.b5(x,N[7])],[-T[0],-T[1],-T[2],-p.b5(T,N[7])],[-C[0],-C[1],-C[2],-p.b5(C,N[7])]],D,B)}intersectsFrustum(t){let n=!0;const h=this.points.length,f=this.planes.length,x=t.planes.length,T=t.points.length;for(let C=0;C<x;C++){const D=t.planes[C];let B=0;for(let N=0;N<h;N++){const G=this.points[N];D[0]*G[0]+D[1]*G[1]+D[2]*G[2]+D[3]>=0&&B++}if(B===0)return 0;B<h&&(n=!1)}if(n)return 2;for(let C=0;C<f;C++){const D=this.planes[C];let B=0;for(let N=0;N<T;N++){const G=t.points[N];D[0]*G[0]+D[1]*G[1]+D[2]*G[2]+D[3]>=0&&B++}if(B===0)return 0}return 1}intersectsPlane(t){const n=this.points.length;let h=0;for(let f=0;f<n;f++){const x=this.points[f];t[0]*x[0]+t[1]*x[1]+t[2]*x[2]+t[3]>=0&&h++}return h===n?2:h===0?0:1}}function za(y,t,n){const h=y-t;return h<0?-h:Math.max(0,h-n)}function lo(y,t,n,h,f){const x=y-n;let T;return T=x<0?Math.min(-x,1+x-f):x>1?Math.min(Math.max(x-f,0),1-x):0,Math.max(T,za(t,h,f))}class vs{constructor(){this._boundingVolumeCache=new uu(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(t,n,h,f){const x=1<<h.z,T=1/x,C=h.x/x,D=h.y/x;let B=2;return B=Math.min(B,lo(t,n,C,D,T)),B=Math.min(B,lo(t,n,C+.5,-D-T,T)),B=Math.min(B,lo(t,n,C+.5,2-D-T,T)),B}getWrap(t,n,h){const f=1<<n.z,x=1/f,T=n.x/f,C=za(t.x,T,x),D=za(t.x,T-1,x),B=za(t.x,T+1,x),N=Math.min(C,D,B);return N===B?1:N===D?-1:0}allowVariableZoom(t,n){return Wi(t,n)>4}allowWorldCopies(){return!1}getTileBoundingVolume(t,n,h,f){return this._boundingVolumeCache.getTileBoundingVolume(t,n,h,f)}_computeTileBoundingVolume(t,n,h,f){var x,T;let C=0,D=0;if(f!=null&&f.terrain){const B=new p.a2(t.z,n,t.z,t.x,t.y),N=f.terrain.getMinMaxElevation(B);C=(x=N.minElevation)!==null&&x!==void 0?x:Math.min(0,h),D=(T=N.maxElevation)!==null&&T!==void 0?T:Math.max(0,h)}if(C/=p.bE,D/=p.bE,C+=1,D+=1,t.z<=0)return Mo.fromAabb([-D,-D,-D],[D,D,D]);if(t.z===1)return Mo.fromAabb([t.x===0?-D:0,t.y===0?0:-D,-D],[t.x===0?0:D,t.y===0?D:0,D]);{const B=[ys(0,0,t.x,t.y,t.z),ys(p.a5,0,t.x,t.y,t.z),ys(p.a5,p.a5,t.x,t.y,t.z),ys(0,p.a5,t.x,t.y,t.z)],N=[];for(const $e of B)N.push(p.a$([],$e,D));if(D!==C)for(const $e of B)N.push(p.a$([],$e,C));t.y===0&&N.push([0,1,0]),t.y===(1<<t.z)-1&&N.push([0,-1,0]);const G=[1,1,1],U=[-1,-1,-1];for(const $e of N)for(let Ye=0;Ye<3;Ye++)G[Ye]=Math.min(G[Ye],$e[Ye]),U[Ye]=Math.max(U[Ye],$e[Ye]);const $=ys(p.a5/2,p.a5/2,t.x,t.y,t.z),ie=p.b4([],[0,1,0],$);p.b3(ie,ie);const he=p.b4([],$,ie);p.b3(he,he);const Ae=p.b4([],B[2],B[1]);p.b3(Ae,Ae);const ce=p.b4([],B[0],B[3]);p.b3(ce,ce),N.push(p.a$([],$,D)),t.y>=(1<<t.z)/2&&N.push(p.a$([],ys(p.a5/2,0,t.x,t.y,t.z),D)),t.y<(1<<t.z)/2&&N.push(p.a$([],ys(p.a5/2,p.a5,t.x,t.y,t.z),D));const ye=La($,N),Pe=La(he,N),_e=[-$[0],-$[1],-$[2],ye.max],we=[$[0],$[1],$[2],-ye.min],Ce=[-he[0],-he[1],-he[2],Pe.max],be=[he[0],he[1],he[2],-Pe.min],Le=[...Ae,0],Ke=[...ce,0],He=[];return t.y===0?He.push(p.bD(Ke,Le,_e),p.bD(Ke,Le,we)):He.push(p.bD(Ce,Le,_e),p.bD(Ce,Le,we),p.bD(Ce,Ke,_e),p.bD(Ce,Ke,we)),t.y===(1<<t.z)-1?He.push(p.bD(Ke,Le,_e),p.bD(Ke,Le,we)):He.push(p.bD(be,Le,_e),p.bD(be,Le,we),p.bD(be,Ke,_e),p.bD(be,Ke,we)),new Mo(He,[_e,we,Ce,be,Le,Ke],G,U)}}}function La(y,t){let n=1/0,h=-1/0;for(const f of t){const x=p.b5(y,f);n=Math.min(n,x),h=Math.max(h,x)}return{min:n,max:h}}class qs{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,n,h){return this._helper.interpolatePadding(t,n,h)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,n){this._helper.resize(t,n)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}setConstrainOverride(t){this._helper.setConstrainOverride(t)}overrideNearFarZ(t,n){this._helper.overrideNearFarZ(t,n)}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=p.bF(),this._projectionMatrix=p.bj(),this._globeViewProjMatrix32f=p.bi(),this._globeViewProjMatrixNoCorrection=p.bj(),this._globeViewProjMatrixNoCorrectionInverted=p.bj(),this._globeProjMatrixInverted=p.bj(),this._cameraPosition=p.bz(),this._globeLatitudeErrorCorrectionRadians=0,this.defaultConstrain=(n,h)=>{const f=p.an(n.lat,-p.ao,p.ao),x=p.an(+h,this.minZoom+dr(0,f),this.maxZoom);return{center:new p.V(n.lng,f),zoom:x}},this.applyConstrain=(n,h)=>this._helper.applyConstrain(n,h),this._helper=new $n({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(n,h)=>this.defaultConstrain(n,h)},t),this._coveringTilesDetailsProvider=new vs}clone(){const t=new qs;return t.apply(this,!1),t}apply(t,n,h){this._globeLatitudeErrorCorrectionRadians=h||0,this._helper.apply(t,n)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){const t=p.bz();return t[0]=this._cameraPosition[0],t[1]=this._cameraPosition[1],t[2]=this._cameraPosition[2],t}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(t){const{overscaledTileID:n,applyGlobeMatrix:h}=t,f=this._helper.getMercatorTileCoordinates(n);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:f,clippingPlane:this._cachedClippingPlane,projectionTransition:h?1:0,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(t){const n=this.pitchInRadians,h=this.cameraToCenterDistance/t,f=Math.sin(n)*h,x=Math.cos(n)*h+1,T=1/Math.sqrt(f*f+x*x)*1;let C=-f,D=x;const B=Math.sqrt(C*C+D*D);C/=B,D/=B;const N=[0,C,D];p.bG(N,N,[0,0,0],-this.bearingInRadians),p.bH(N,N,[0,0,0],-1*this.center.lat*Math.PI/180),p.bI(N,N,[0,0,0],this.center.lng*Math.PI/180);const G=1/p.b7(N);return p.a$(N,N,G),[...N,-T*G]}isLocationOccluded(t){return!this.isSurfacePointVisible(ir(t))}transformLightDirection(t){const n=this._helper._center.lng*Math.PI/180,h=this._helper._center.lat*Math.PI/180,f=Math.cos(h),x=[Math.sin(n)*f,Math.sin(h),Math.cos(n)*f],T=[x[2],0,-x[0]],C=[0,0,0];p.b4(C,T,x),p.b3(T,T),p.b3(C,C);const D=[0,0,0];return p.b3(D,[T[0]*t[0]+C[0]*t[1]+x[0]*t[2],T[1]*t[0]+C[1]*t[1]+x[1]*t[2],T[2]*t[0]+C[2]*t[1]+x[2]*t[2]]),D}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,n,h){const f=(function(C,D,B){const N=1/(1<<B.z);return new p.a9(C/p.a5*N+B.x*N,D/p.a5*N+B.y*N)})(t,n,h.canonical),x=(T=f.y,[p.by(f.x*Math.PI*2+Math.PI,2*Math.PI),2*Math.atan(Math.exp(Math.PI-T*Math.PI*2))-.5*Math.PI]);var T;return this.getCircleRadiusCorrection()/Math.cos(x[1])}projectTileCoordinates(t,n,h,f){const x=h.canonical,T=ys(t,n,x.x,x.y,x.z),C=1+(f?f(t,n):0)/p.bE,D=[T[0]*C,T[1]*C,T[2]*C,1];p.aH(D,D,this._globeViewProjMatrixNoCorrection);const B=this._cachedClippingPlane,N=B[0]*T[0]+B[1]*T[1]+B[2]*T[2]+B[3]<0;return{point:new p.P(D[0]/D[3],D[1]/D[3]),signedDistanceFromCamera:D[3],isOccluded:N}}_calcMatrices(){if(!this._helper._width||!this._helper._height)return;const t=ao(this.worldSize,this.center.lat),n=p.bk(),h=p.bk();this._helper.autoCalculateNearFarZ&&(this._helper._nearZ=.5,this._helper._farZ=this.cameraToCenterDistance+2*t),p.be(n,this.fovInRadians,this.width/this.height,this._helper._nearZ,this._helper._farZ);const f=this.centerOffset;n[8]=2*-f.x/this._helper._width,n[9]=2*f.y/this._helper._height,this._projectionMatrix=p.bf(n),this._globeProjMatrixInverted=p.bk(),p.aB(this._globeProjMatrixInverted,n),p.O(n,n,[0,0,-this.cameraToCenterDistance]),p.bg(n,n,this.rollInRadians),p.bh(n,n,-this.pitchInRadians),p.bg(n,n,this.bearingInRadians),p.O(n,n,[0,0,-t]);const x=p.bz();x[0]=t,x[1]=t,x[2]=t,p.bh(h,n,this.center.lat*Math.PI/180),p.bJ(h,h,-this.center.lng*Math.PI/180),p.Q(h,h,x),this._globeViewProjMatrixNoCorrection=h,p.bh(n,n,this.center.lat*Math.PI/180-this._globeLatitudeErrorCorrectionRadians),p.bJ(n,n,-this.center.lng*Math.PI/180),p.Q(n,n,x),this._globeViewProjMatrix32f=new Float32Array(n),this._globeViewProjMatrixNoCorrectionInverted=p.bk(),p.aB(this._globeViewProjMatrixNoCorrectionInverted,h);const T=p.bz();this._cameraPosition=p.bz(),this._cameraPosition[2]=this.cameraToCenterDistance/t,p.bG(this._cameraPosition,this._cameraPosition,T,-this.rollInRadians),p.bH(this._cameraPosition,this._cameraPosition,T,this.pitchInRadians),p.bG(this._cameraPosition,this._cameraPosition,T,-this.bearingInRadians),p.b0(this._cameraPosition,this._cameraPosition,[0,0,1]),p.bH(this._cameraPosition,this._cameraPosition,T,-this.center.lat*Math.PI/180),p.bI(this._cameraPosition,this._cameraPosition,T,this.center.lng*Math.PI/180),this._cachedClippingPlane=this._computeClippingPlane(t);const C=p.bf(this._globeViewProjMatrixNoCorrectionInverted);p.Q(C,C,[1,1,-1]),this._cachedFrustum=Yn.fromInvProjectionMatrix(C,1,0,this._cachedClippingPlane,!0)}calculateFogMatrix(t){p.w("calculateFogMatrix is not supported on globe projection.");const n=p.bk();return p.ar(n),n}getVisibleUnwrappedCoordinates(t){return[new p.bc(0,t)]}getCameraFrustum(){return this._cachedFrustum}getClippingPlane(){return this._cachedClippingPlane}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(t){t&&p.w("terrain is not fully supported on vertical perspective projection."),this._helper.recalculateZoomAndCenter(0)}maxPitchScaleFactor(){return 1}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(t,n){if(!this._globeViewProjMatrixNoCorrection)return 1;const h=ir(t);p.a$(h,h,1+n/p.bE);const f=p.bF();return p.aH(f,[h[0],h[1],h[2],1],this._globeViewProjMatrixNoCorrection),f[2]/f[3]}populateCache(t){}getBounds(){const t=.5*this.width,n=.5*this.height,h=[new p.P(0,0),new p.P(t,0),new p.P(this.width,0),new p.P(this.width,n),new p.P(this.width,this.height),new p.P(t,this.height),new p.P(0,this.height),new p.P(0,n)],f=[];for(const G of h)f.push(this.unprojectScreenPoint(G));let x=0,T=0,C=0,D=0;const B=this.center;for(const G of f){const U=p.bK(B.lng,G.lng),$=p.bK(B.lat,G.lat);U<T&&(T=U),U>x&&(x=U),$<D&&(D=$),$>C&&(C=$)}const N=[B.lng+T,B.lat+D,B.lng+x,B.lat+C];return this.isSurfacePointOnScreen([0,1,0])&&(N[3]=90,N[0]=-180,N[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(N[1]=-90,N[0]=-180,N[2]=180),new Ui(N)}calculateCenterFromCameraLngLatAlt(t,n,h,f){return this._helper.calculateCenterFromCameraLngLatAlt(t,n,h,f)}setLocationAtPoint(t,n){const h=ir(this.unprojectScreenPoint(n)),f=ir(t),x=p.bz();p.bL(x);const T=p.bz();p.bI(T,h,x,-this.center.lng*Math.PI/180),p.bH(T,T,x,this.center.lat*Math.PI/180);const C=f[0]*f[0]+f[2]*f[2],D=T[0]*T[0];if(C<D)return;const B=Math.sqrt(C-D),N=-B,G=p.bM(f[0],f[2],T[0],B),U=p.bM(f[0],f[2],T[0],N),$=p.bz();p.bI($,f,x,-G);const ie=p.bM($[1],$[2],T[1],T[2]),he=p.bz();p.bI(he,f,x,-U);const Ae=p.bM(he[1],he[2],T[1],T[2]),ce=.5*Math.PI,ye=ie>=-ce&&ie<=ce,Pe=Ae>=-ce&&Ae<=ce;let _e,we;if(ye&&Pe){const Ke=this.center.lng*Math.PI/180,He=this.center.lat*Math.PI/180;p.bN(G,Ke)+p.bN(ie,He)<p.bN(U,Ke)+p.bN(Ae,He)?(_e=G,we=ie):(_e=U,we=Ae)}else if(ye)_e=G,we=ie;else{if(!Pe)return;_e=U,we=Ae}const Ce=_e/Math.PI*180,be=we/Math.PI*180,Le=this.center.lat;this.setCenter(new p.V(Ce,p.an(be,-90,90))),this.setZoom(this.zoom+dr(Le,this.center.lat))}locationToScreenPoint(t,n){const h=ir(t);if(n){const f=n.getElevationForLngLatZoom(t,this._helper._tileZoom);p.a$(h,h,1+f/p.bE)}return this._projectSurfacePointToScreen(h)}_projectSurfacePointToScreen(t){const n=p.bF();return p.aH(n,[...t,1],this._globeViewProjMatrixNoCorrection),n[0]/=n[3],n[1]/=n[3],new p.P((.5*n[0]+.5)*this.width,(.5*-n[1]+.5)*this.height)}screenPointToMercatorCoordinate(t,n){if(n){const h=n.pointCoordinate(t);if(h)return h}return p.a9.fromLngLat(this.unprojectScreenPoint(t))}screenPointToLocation(t,n){var h;return(h=this.screenPointToMercatorCoordinate(t,n))===null||h===void 0?void 0:h.toLngLat()}isPointOnMapSurface(t,n){const h=this._cameraPosition,f=this.getRayDirectionFromPixel(t);return!!this.rayPlanetIntersection(h,f)}getRayDirectionFromPixel(t){const n=p.bF();n[0]=t.x/this.width*2-1,n[1]=-1*(t.y/this.height*2-1),n[2]=1,n[3]=1,p.aH(n,n,this._globeViewProjMatrixNoCorrectionInverted),n[0]/=n[3],n[1]/=n[3],n[2]/=n[3];const h=p.bz();h[0]=n[0]-this._cameraPosition[0],h[1]=n[1]-this._cameraPosition[1],h[2]=n[2]-this._cameraPosition[2];const f=p.bz();return p.b3(f,h),f}isSurfacePointVisible(t){const n=this._cachedClippingPlane;return n[0]*t[0]+n[1]*t[1]+n[2]*t[2]+n[3]>=0}isSurfacePointOnScreen(t){if(!this.isSurfacePointVisible(t))return!1;const n=p.bF();return p.aH(n,[...t,1],this._globeViewProjMatrixNoCorrection),n[0]/=n[3],n[1]/=n[3],n[2]/=n[3],n[0]>-1&&n[0]<1&&n[1]>-1&&n[1]<1&&n[2]>-1&&n[2]<1}rayPlanetIntersection(t,n){const h=p.b5(t,n),f=p.bz(),x=p.bz();p.a$(x,n,h),p.b2(f,t,x);const T=1-p.b5(f,f);if(T<0)return null;const C=p.b5(t,t)-1,D=-h+(h<0?1:-1)*Math.sqrt(T),B=C/D,N=D;return{tMin:Math.min(B,N),tMax:Math.max(B,N)}}unprojectScreenPoint(t){const n=this._cameraPosition,h=this.getRayDirectionFromPixel(t),f=this.rayPlanetIntersection(n,h);if(f){const N=p.bz();p.b0(N,n,[h[0]*f.tMin,h[1]*f.tMin,h[2]*f.tMin]);const G=p.bz();return p.b3(G,N),yl(G)}const x=this._cachedClippingPlane,T=x[0]*h[0]+x[1]*h[1]+x[2]*h[2],C=-p.bb(x,n)/T,D=p.bz();if(C>0)p.b0(D,n,[h[0]*C,h[1]*C,h[2]*C]);else{const N=p.bz();p.b0(N,n,[2*h[0],2*h[1],2*h[2]]);const G=p.bb(this._cachedClippingPlane,N);p.b2(D,N,[this._cachedClippingPlane[0]*G,this._cachedClippingPlane[1]*G,this._cachedClippingPlane[2]*G])}const B=(function(N){const G=p.bz();return G[0]=N[0]*-N[3],G[1]=N[1]*-N[3],G[2]=N[2]*-N[3],{center:G,radius:Math.sqrt(1-N[3]*N[3])}})(x);return yl((function(N,G,U){const $=p.bz();p.b2($,U,N);const ie=p.bz();return p.bA(ie,N,$,G/p.b9($)),ie})(B.center,B.radius,D))}getMatrixForModel(t,n){const h=p.V.convert(t),f=1/p.bE,x=p.bj();return p.bJ(x,x,h.lng/180*Math.PI),p.bh(x,x,-h.lat/180*Math.PI),p.O(x,x,[0,0,1+n/p.bE]),p.bh(x,x,.5*Math.PI),p.Q(x,x,[f,f,f]),x}getProjectionDataForCustomLayer(t=!0){const n=this.getProjectionData({overscaledTileID:new p.a2(0,0,0,0,0),applyGlobeMatrix:t});return n.tileMercatorCoords=[0,0,1,1],n}getFastPathSimpleProjectionMatrix(t){}}class An{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,n,h){return this._helper.interpolatePadding(t,n,h)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,n,h=!0){this._helper.resize(t,n,h)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}setConstrainOverride(t){this._helper.setConstrainOverride(t)}overrideNearFarZ(t,n){this._helper.overrideNearFarZ(t,n)}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,n){this._globeness=t,this._globeLatitudeErrorCorrectionRadians=n,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().prepareNextFrame(),this._mercatorTransform.getCoveringTilesDetailsProvider().prepareNextFrame()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(t){this._globeLatitudeErrorCorrectionRadians=0,this._globeness=1,this.defaultConstrain=(n,h)=>this.currentTransform.defaultConstrain(n,h),this.applyConstrain=(n,h)=>this._helper.applyConstrain(n,h),this._helper=new $n({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(n,h)=>this.defaultConstrain(n,h)},t),this._globeness=1,this._mercatorTransform=new Po,this._verticalPerspectiveTransform=new qs}clone(){const t=new An;return t._globeness=this._globeness,t._globeLatitudeErrorCorrectionRadians=this._globeLatitudeErrorCorrectionRadians,t.apply(this,!1),t}apply(t,n){this._helper.apply(t,n),this._mercatorTransform.apply(this,!1),this._verticalPerspectiveTransform.apply(this,!1,this._globeLatitudeErrorCorrectionRadians)}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(t){const n=this._mercatorTransform.getProjectionData(t),h=this._verticalPerspectiveTransform.getProjectionData(t);return{mainMatrix:this.isGlobeRendering?h.mainMatrix:n.mainMatrix,clippingPlane:h.clippingPlane,tileMercatorCoords:h.tileMercatorCoords,projectionTransition:t.applyGlobeMatrix?this._globeness:0,fallbackMatrix:n.fallbackMatrix}}isLocationOccluded(t){return this.currentTransform.isLocationOccluded(t)}transformLightDirection(t){return this.currentTransform.transformLightDirection(t)}getPixelScale(){return p.bu(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return p.bu(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(t,n,h){const f=this._mercatorTransform.getPitchedTextCorrection(t,n,h),x=this._verticalPerspectiveTransform.getPitchedTextCorrection(t,n,h);return p.bu(f,x,this._globeness)}projectTileCoordinates(t,n,h,f){return this.currentTransform.projectTileCoordinates(t,n,h,f)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform.apply(this,!1,this._globeLatitudeErrorCorrectionRadians),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ)}calculateFogMatrix(t){return this.currentTransform.calculateFogMatrix(t)}getVisibleUnwrappedCoordinates(t){return this.currentTransform.getVisibleUnwrappedCoordinates(t)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(t){this._mercatorTransform.recalculateZoomAndCenter(t),this._verticalPerspectiveTransform.recalculateZoomAndCenter(t)}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(t,n){return this.currentTransform.lngLatToCameraDepth(t,n)}populateCache(t){this._mercatorTransform.populateCache(t),this._verticalPerspectiveTransform.populateCache(t)}getBounds(){return this.currentTransform.getBounds()}calculateCenterFromCameraLngLatAlt(t,n,h,f){return this._helper.calculateCenterFromCameraLngLatAlt(t,n,h,f)}setLocationAtPoint(t,n){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(t,n),void this.apply(this._mercatorTransform,!1);this._verticalPerspectiveTransform.setLocationAtPoint(t,n),this.apply(this._verticalPerspectiveTransform,!1)}locationToScreenPoint(t,n){return this.currentTransform.locationToScreenPoint(t,n)}screenPointToMercatorCoordinate(t,n){return this.currentTransform.screenPointToMercatorCoordinate(t,n)}screenPointToLocation(t,n){return this.currentTransform.screenPointToLocation(t,n)}isPointOnMapSurface(t,n){return this.currentTransform.isPointOnMapSurface(t,n)}getRayDirectionFromPixel(t){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(t)}getMatrixForModel(t,n){return this.currentTransform.getMatrixForModel(t,n)}getProjectionDataForCustomLayer(t=!0){const n=this._mercatorTransform.getProjectionDataForCustomLayer(t);if(!this.isGlobeRendering)return n;const h=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(t);return h.fallbackMatrix=n.mainMatrix,h}getFastPathSimpleProjectionMatrix(t){return this.currentTransform.getFastPathSimpleProjectionMatrix(t)}}class Ar{get useGlobeControls(){return!0}handlePanInertia(t,n){const h=jl(t,n);return Math.abs(h.lng-n.center.lng)>180&&(h.lng=n.center.lng+179.5*Math.sign(h.lng-n.center.lng)),{easingCenter:h,easingOffset:new p.P(0,0)}}handleMapControlsRollPitchBearingZoom(t,n){const h=t.around,f=n.screenPointToLocation(h);t.bearingDelta&&n.setBearing(n.bearing+t.bearingDelta),t.pitchDelta&&n.setPitch(n.pitch+t.pitchDelta),t.rollDelta&&n.setRoll(n.roll+t.rollDelta);const x=n.zoom;t.zoomDelta&&n.setZoom(n.zoom+t.zoomDelta);const T=n.zoom-x;if(T===0)return;const C=p.bK(n.center.lng,f.lng),D=C/(Math.abs(C/180)+1),B=p.bK(n.center.lat,f.lat),N=n.getRayDirectionFromPixel(h),G=n.cameraPosition,U=-1*p.b5(G,N),$=p.bz();p.b0($,G,[N[0]*U,N[1]*U,N[2]*U]);const ie=p.b7($)-1,he=Math.exp(.5*-Math.max(ie-.3,0)),Ae=ao(n.worldSize,n.center.lat)/Math.min(n.width,n.height),ce=p.bx(Ae,.9,.5,1,.25),ye=(1-p.aq(-T))*Math.min(he,ce),Pe=n.center.lat,_e=n.zoom,we=new p.V(n.center.lng+D*ye,p.an(n.center.lat+B*ye,-p.ao,p.ao));n.setLocationAtPoint(f,h);const Ce=n.center,be=p.bx(Math.abs(C),45,85,0,1),Le=p.bx(Ae,.75,.35,0,1),Ke=Math.pow(Math.max(be,Le),.25),He=p.bK(Ce.lng,we.lng),$e=p.bK(Ce.lat,we.lat);n.setCenter(new p.V(Ce.lng+He*Ke,Ce.lat+$e*Ke).wrap()),n.setZoom(_e+dr(Pe,n.center.lat))}handleMapControlsPan(t,n,h){if(!t.panDelta)return;const f=n.center.lat,x=n.zoom;n.setCenter(jl(t.panDelta,n).wrap()),n.setZoom(x+dr(f,n.center.lat))}cameraForBoxAndBearing(t,n,h,f,x){const T=Qr(t,n,h,f,x),C=n.left/x.width*2-1,D=(x.width-n.right)/x.width*2-1,B=n.top/x.height*-2+1,N=(x.height-n.bottom)/x.height*-2+1,G=p.bK(h.getWest(),h.getEast())<0,U=G?h.getEast():h.getWest(),$=G?h.getWest():h.getEast(),ie=Math.max(h.getNorth(),h.getSouth()),he=Math.min(h.getNorth(),h.getSouth()),Ae=U+.5*p.bK(U,$),ce=ie+.5*p.bK(ie,he),ye=x.clone();ye.setCenter(T.center),ye.setBearing(T.bearing),ye.setPitch(0),ye.setRoll(0),ye.setZoom(T.zoom);const Pe=ye.modelViewProjectionMatrix,_e=[ir(h.getNorthWest()),ir(h.getNorthEast()),ir(h.getSouthWest()),ir(h.getSouthEast()),ir(new p.V($,ce)),ir(new p.V(U,ce)),ir(new p.V(Ae,ie)),ir(new p.V(Ae,he))],we=ir(T.center);let Ce=Number.POSITIVE_INFINITY;for(const be of _e)C<0&&(Ce=Ar.getLesserNonNegativeNonNull(Ce,Ar.solveVectorScale(be,we,Pe,"x",C))),D>0&&(Ce=Ar.getLesserNonNegativeNonNull(Ce,Ar.solveVectorScale(be,we,Pe,"x",D))),B>0&&(Ce=Ar.getLesserNonNegativeNonNull(Ce,Ar.solveVectorScale(be,we,Pe,"y",B))),N<0&&(Ce=Ar.getLesserNonNegativeNonNull(Ce,Ar.solveVectorScale(be,we,Pe,"y",N)));if(Number.isFinite(Ce)&&Ce!==0)return T.zoom=ye.zoom+p.at(Ce),T;Ls()}handleJumpToCenterZoom(t,n){const h=t.center.lat,f=t.applyConstrain(n.center?p.V.convert(n.center):t.center,t.zoom).center;t.setCenter(f.wrap());const x=n.zoom!==void 0?+n.zoom:t.zoom+dr(h,f.lat);t.zoom!==x&&t.setZoom(x)}handleEaseTo(t,n){const h=t.zoom,f=t.center,x=t.padding,T={roll:t.roll,pitch:t.pitch,bearing:t.bearing},C={roll:n.roll===void 0?t.roll:n.roll,pitch:n.pitch===void 0?t.pitch:n.pitch,bearing:n.bearing===void 0?t.bearing:n.bearing},D=n.zoom!==void 0,B=!t.isPaddingEqual(n.padding);let N=!1;const G=n.center?p.V.convert(n.center):f,U=t.applyConstrain(G,h).center;Qn(t,U);const $=t.clone();$.setCenter(U),$.setZoom(D?+n.zoom:h+dr(f.lat,G.lat)),$.setBearing(n.bearing);const ie=new p.P(p.an(t.centerPoint.x+n.offsetAsPoint.x,0,t.width),p.an(t.centerPoint.y+n.offsetAsPoint.y,0,t.height));$.setLocationAtPoint(U,ie);const he=(n.offset&&n.offsetAsPoint.mag())>0?$.center:U,Ae=D?+n.zoom:h+dr(f.lat,he.lat),ce=h+dr(f.lat,0),ye=Ae+dr(he.lat,0),Pe=p.bK(f.lng,he.lng),_e=p.bK(f.lat,he.lat),we=p.aq(ye-ce);return N=Ae!==h,{easeFunc:Ce=>{if(p.bo(T,C)||Vl({startEulerAngles:T,endEulerAngles:C,tr:t,k:Ce,useSlerp:T.roll!=C.roll}),B&&t.interpolatePadding(x,n.padding,Ce),n.around)p.w("Easing around a point is not supported under globe projection."),t.setLocationAtPoint(n.around,n.aroundPoint);else{const be=ye>ce?Math.min(2,we):Math.max(.5,we),Le=Math.pow(be,1-Ce),Ke=Ya(f,Pe,_e,Ce*Le);t.setCenter(Ke.wrap())}if(N){const be=p.G.number(ce,ye,Ce)+dr(0,t.center.lat);t.setZoom(be)}},isZooming:N,elevationCenter:he}}handleFlyTo(t,n){const h=n.zoom!==void 0,f=t.center,x=t.zoom,T=t.padding,C=!t.isPaddingEqual(n.padding),D=t.applyConstrain(p.V.convert(n.center||n.locationAtOffset),x).center,B=h?+n.zoom:t.zoom+dr(t.center.lat,D.lat),N=t.clone();N.setCenter(D),N.setZoom(B),N.setBearing(n.bearing);const G=new p.P(p.an(t.centerPoint.x+n.offsetAsPoint.x,0,t.width),p.an(t.centerPoint.y+n.offsetAsPoint.y,0,t.height));N.setLocationAtPoint(D,G);const U=N.center;Qn(t,U);const $=(function(_e,we,Ce){const be=ir(we),Le=ir(Ce),Ke=p.b5(be,Le),He=Math.acos(Ke),$e=xr(_e);return He/(2*Math.PI)*$e})(t,f,U),ie=x+dr(f.lat,0),he=B+dr(U.lat,0),Ae=p.aq(he-ie);let ce;if(typeof n.minZoom=="number"){const _e=+n.minZoom+dr(U.lat,0),we=Math.min(_e,ie,he)+dr(0,U.lat),Ce=t.applyConstrain(U,we).zoom+dr(U.lat,0);ce=p.aq(Ce-ie)}const ye=p.bK(f.lng,U.lng),Pe=p.bK(f.lat,U.lat);return{easeFunc:(_e,we,Ce,be)=>{const Le=Ya(f,ye,Pe,Ce);C&&t.interpolatePadding(T,n.padding,_e);const Ke=_e===1?U:Le;t.setCenter(Ke.wrap());const He=ie+p.at(we);t.setZoom(_e===1?B:He+dr(0,Ke.lat))},scaleOfZoom:Ae,targetCenter:U,scaleOfMinZoom:ce,pixelPathLength:$}}static solveVectorScale(t,n,h,f,x){const T=f==="x"?[h[0],h[4],h[8],h[12]]:[h[1],h[5],h[9],h[13]],C=[h[3],h[7],h[11],h[15]],D=t[0]*T[0]+t[1]*T[1]+t[2]*T[2],B=t[0]*C[0]+t[1]*C[1]+t[2]*C[2],N=n[0]*T[0]+n[1]*T[1]+n[2]*T[2],G=n[0]*C[0]+n[1]*C[1]+n[2]*C[2];return N+x*B===D+x*G||C[3]*(D-N)+T[3]*(G-B)+D*G==N*B?null:(N+T[3]-x*G-x*C[3])/(N-D-x*G+x*B)}static getLesserNonNegativeNonNull(t,n){return n!==null&&n>=0&&n<t?n:t}}class xl{constructor(t){this._globe=t,this._mercatorCameraHelper=new hi,this._verticalPerspectiveCameraHelper=new Ar}get useGlobeControls(){return this._globe.useGlobeRendering}get currentHelper(){return this.useGlobeControls?this._verticalPerspectiveCameraHelper:this._mercatorCameraHelper}handlePanInertia(t,n){return this.currentHelper.handlePanInertia(t,n)}handleMapControlsRollPitchBearingZoom(t,n){return this.currentHelper.handleMapControlsRollPitchBearingZoom(t,n)}handleMapControlsPan(t,n,h){this.currentHelper.handleMapControlsPan(t,n,h)}cameraForBoxAndBearing(t,n,h,f,x){return this.currentHelper.cameraForBoxAndBearing(t,n,h,f,x)}handleJumpToCenterZoom(t,n){this.currentHelper.handleJumpToCenterZoom(t,n)}handleEaseTo(t,n){return this.currentHelper.handleEaseTo(t,n)}handleFlyTo(t,n){return this.currentHelper.handleFlyTo(t,n)}}const Eo=(y,t)=>p.B(y,t&&t.filter((n=>n.identifier!=="source.canvas"))),So=p.bO();class Jn extends p.E{constructor(t,n={}){var h,f;super(),this._rtlPluginLoaded=()=>{for(const T in this.tileManagers){const C=this.tileManagers[T].getSource().type;C!=="vector"&&C!=="geojson"||this.tileManagers[T].reload()}},this.map=t,this.dispatcher=new us(yo(),t._getMapId()),this.dispatcher.registerMessageHandler("GG",((T,C)=>this.getGlyphs(T,C))),this.dispatcher.registerMessageHandler("GI",((T,C)=>this.getImages(T,C))),this.dispatcher.registerMessageHandler("GDA",((T,C)=>this.getDashes(T,C))),this.imageManager=new Ji,this.imageManager.setEventedParent(this);const x=((h=t._container)===null||h===void 0?void 0:h.lang)||typeof document<"u"&&((f=document.documentElement)===null||f===void 0?void 0:f.lang)||void 0;this.glyphManager=new Hr(t._requestManager,n.localIdeographFontFamily,x),this.lineAtlas=new Wr(256,512),this.crossTileSymbolIndex=new Wn,this._setInitialValues(),this._resetUpdates(),this.dispatcher.broadcast("SR",p.bP()),Fe().on(Me,this._rtlPluginLoaded),this.on("data",(T=>{if(T.dataType!=="source"||T.sourceDataType!=="metadata")return;const C=this.tileManagers[T.sourceId];if(!C)return;const D=C.getSource();if(D&&D.vectorLayerIds)for(const B in this._layers){const N=this._layers[B];N.source===D.id&&this._validateLayer(N)}}))}_setInitialValues(){var t;this._spritesImagesIds={},this._layers={},this._order=[],this.tileManagers={},this.zoomHistory=new p.bQ,this._availableImages=[],this._globalState={},this._serializedLayers={},this.stylesheet=null,this.light=null,this.sky=null,this.projection&&(this.projection.destroy(),delete this.projection),this._loaded=!1,this._changed=!1,this._updatedLayers={},this._updatedSources={},this._changedImages={},this._glyphsDidChange=!1,this._updatedPaintProps={},this._layerOrderChanged=!1,this.crossTileSymbolIndex=new(((t=this.crossTileSymbolIndex)===null||t===void 0?void 0:t.constructor)||Object),this.pauseablePlacement=void 0,this.placement=void 0,this.z=0}setGlobalStateProperty(t,n){var h,f,x;this._checkLoaded();const T=n===null?(x=(f=(h=this.stylesheet.state)===null||h===void 0?void 0:h[t])===null||f===void 0?void 0:f.default)!==null&&x!==void 0?x:null:n;if(p.bR(T,this._globalState[t]))return this;this._globalState[t]=T,this._applyGlobalStateChanges([t])}getGlobalState(){return this._globalState}setGlobalState(t){this._checkLoaded();const n=[];for(const h in t)!p.bR(this._globalState[h],t[h].default)&&(n.push(h),this._globalState[h]=t[h].default);this._applyGlobalStateChanges(n)}_applyGlobalStateChanges(t){if(t.length===0)return;const n=new Set,h={};for(const f of t){h[f]=this._globalState[f];for(const x in this._layers){const T=this._layers[x],C=T.getLayoutAffectingGlobalStateRefs(),D=T.getPaintAffectingGlobalStateRefs(),B=T.getVisibilityAffectingGlobalStateRefs();if(C.has(f)&&n.add(T.source),D.has(f))for(const{name:N,value:G}of D.get(f))this._updatePaintProperty(T,N,G);B!=null&&B.has(f)&&(T.recalculateVisibility(),this._updateLayer(T))}}this.dispatcher.broadcast("UGS",h);for(const f in this.tileManagers)n.has(f)&&(this._reloadSource(f),this._changed=!0)}loadURL(t,n={},h){this.fire(new p.l("dataloading",{dataType:"style"})),n.validate=typeof n.validate!="boolean"||n.validate;const f=this.map._requestManager.transformRequest(t,"Style");this._loadStyleRequest=new AbortController;const x=this._loadStyleRequest;p.j(f,this._loadStyleRequest).then((T=>{this._loadStyleRequest=null,this._load(T.data,n,h)})).catch((T=>{this._loadStyleRequest=null,T&&!x.signal.aborted&&this.fire(new p.k(T))}))}loadJSON(t,n={},h){this.fire(new p.l("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,zr.frameAsync(this._frameRequest).then((()=>{this._frameRequest=null,n.validate=n.validate!==!1,this._load(t,n,h)})).catch((()=>{}))}loadEmpty(){this.fire(new p.l("dataloading",{dataType:"style"})),this._load(So,{validate:!1})}_load(t,n,h){var f,x;let T=n.transformStyle?n.transformStyle(h,t):t;if(!n.validate||!Eo(this,p.C(T))){T=Object.assign({},T),this._loaded=!0,this.stylesheet=T;for(const C in T.sources)this.addSource(C,T.sources[C],{validate:!1});T.sprite?this._loadSprite(T.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(T.glyphs),this._createLayers(),this.light=new Yt(this.stylesheet.light),this._setProjectionInternal(((f=this.stylesheet.projection)===null||f===void 0?void 0:f.type)||"mercator"),this.sky=new Mr(this.stylesheet.sky),this.map.setTerrain((x=this.stylesheet.terrain)!==null&&x!==void 0?x:null),this.fire(new p.l("data",{dataType:"style"})),this.fire(new p.l("style.load"))}}_createLayers(){var t,n,h;const f=p.bS(this.stylesheet.layers);this.setGlobalState((t=this.stylesheet.state)!==null&&t!==void 0?t:null),this.dispatcher.broadcast("SL",f),this._order=f.map((x=>x.id)),this._layers={},this._serializedLayers=null;for(const x of f){const T=p.bT(x,this._globalState);if(T.setEventedParent(this,{layer:{id:x.id}}),this._layers[x.id]=T,p.bU(T)&&this.tileManagers[T.source]){const C=(h=(n=x.paint)===null||n===void 0?void 0:n["raster-fade-duration"])!==null&&h!==void 0?h:T.paint.get("raster-fade-duration");this.tileManagers[T.source].setRasterFadeDuration(C)}}}_loadSprite(t,n=!1,h=void 0){this.imageManager.setLoaded(!1);const f=new AbortController;let x;this._spriteRequest=f,(function(T,C,D,B){return p._(this,void 0,void 0,(function*(){const N=Vs(T),G=D>1?"@2x":"",U={},$={};for(const{id:ie,url:he}of N){const Ae=C.transformRequest(Cs(he,G,".json"),"SpriteJSON");U[ie]=p.j(Ae,B);const ce=C.transformRequest(Cs(he,G,".png"),"SpriteImage");$[ie]=En.getImage(ce,B)}return yield Promise.all([...Object.values(U),...Object.values($)]),(function(ie,he){return p._(this,void 0,void 0,(function*(){const Ae={};for(const ce in ie){Ae[ce]={};const ye=zr.getImageCanvasContext((yield he[ce]).data),Pe=(yield ie[ce]).data;for(const _e in Pe){const{width:we,height:Ce,x:be,y:Le,sdf:Ke,pixelRatio:He,stretchX:$e,stretchY:Ye,content:xt,textFitWidth:wt,textFitHeight:pt}=Pe[_e];Ae[ce][_e]={data:null,pixelRatio:He,sdf:Ke,stretchX:$e,stretchY:Ye,content:xt,textFitWidth:wt,textFitHeight:pt,spriteData:{width:we,height:Ce,x:be,y:Le,context:ye}}}}return Ae}))})(U,$)}))})(t,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then((T=>{if(this._spriteRequest=null,T)for(const C in T){this._spritesImagesIds[C]=[];const D=this._spritesImagesIds[C]?this._spritesImagesIds[C].filter((B=>!(B in T))):[];for(const B of D)this.imageManager.removeImage(B),this._changedImages[B]=!0;for(const B in T[C]){const N=C==="default"?B:`${C}:${B}`;this._spritesImagesIds[C].push(N),N in this.imageManager.images?this.imageManager.updateImage(N,T[C][B],!1):this.imageManager.addImage(N,T[C][B]),n&&(this._changedImages[N]=!0)}}})).catch((T=>{this._spriteRequest=null,x=T,f.signal.aborted||this.fire(new p.k(x))})).finally((()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),n&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new p.l("data",{dataType:"style"})),h&&h(x)}))}_unloadSprite(){for(const t of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(t),this._changedImages[t]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new p.l("data",{dataType:"style"}))}_validateLayer(t){const n=this.tileManagers[t.source];if(!n)return;const h=t.sourceLayer;if(!h)return;const f=n.getSource();(f.type==="geojson"||f.vectorLayerIds&&f.vectorLayerIds.indexOf(h)===-1)&&this.fire(new p.k(new Error(`Source layer "${h}" does not exist on source "${f.id}" as specified by style layer "${t.id}".`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const t in this.tileManagers)if(!this.tileManagers[t].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeByIds(t,n=!1){const h=this._serializedAllLayers();if(!t||t.length===0)return Object.values(n?p.bV(h):h);const f=[];for(const x of t)if(h[x]){const T=n?p.bV(h[x]):h[x];f.push(T)}return f}_serializedAllLayers(){let t=this._serializedLayers;if(t)return t;t=this._serializedLayers={};const n=Object.keys(this._layers);for(const h of n){const f=this._layers[h];f.type!=="custom"&&(t[h]=f.serialize())}return t}hasTransitions(){var t,n,h;if(!((t=this.light)===null||t===void 0)&&t.hasTransition()||!((n=this.sky)===null||n===void 0)&&n.hasTransition()||!((h=this.projection)===null||h===void 0)&&h.hasTransition())return!0;for(const f in this.tileManagers)if(this.tileManagers[f].hasTransition())return!0;for(const f in this._layers)if(this._layers[f].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(t){if(!this._loaded)return;const n=this._changed;if(n){const f=Object.keys(this._updatedLayers),x=Object.keys(this._removedLayers);(f.length||x.length)&&this._updateWorkerLayers(f,x);for(const T in this._updatedSources){const C=this._updatedSources[T];if(C==="reload")this._reloadSource(T);else{if(C!=="clear")throw new Error(`Invalid action ${C}`);this._clearSource(T)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const T in this._updatedPaintProps)this._layers[T].updateTransitions(t);this.light.updateTransitions(t),this.sky.updateTransitions(t),this._resetUpdates()}const h={};for(const f in this.tileManagers){const x=this.tileManagers[f];h[f]=x.used,x.used=!1}for(const f of this._order){const x=this._layers[f];x.recalculate(t,this._availableImages),!x.isHidden(t.zoom)&&x.source&&(this.tileManagers[x.source].used=!0)}for(const f in h){const x=this.tileManagers[f];!!h[f]!=!!x.used&&x.fire(new p.l("data",{sourceDataType:"visibility",dataType:"source",sourceId:f}))}this.light.recalculate(t),this.sky.recalculate(t),this.projection.recalculate(t),this.z=t.zoom,n&&this.fire(new p.l("data",{dataType:"style"}))}_updateTilesForChangedImages(){const t=Object.keys(this._changedImages);if(t.length){for(const n in this.tileManagers)this.tileManagers[n].reloadTilesForDependencies(["icons","patterns"],t);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const t in this.tileManagers)this.tileManagers[t].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(t,n){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(t,!1),removedIds:n})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(t,n={}){var h;this._checkLoaded();const f=this.serialize();if(t=n.transformStyle?n.transformStyle(f,t):t,((h=n.validate)===null||h===void 0||h)&&Eo(this,p.C(t)))return!1;(t=p.bV(t)).layers=p.bS(t.layers);const x=p.bW(f,t),T=this._getOperationsToPerform(x);if(T.unimplemented.length>0)throw new Error(`Unimplemented: ${T.unimplemented.join(", ")}.`);if(T.operations.length===0)return!1;for(const C of T.operations)C();return this.stylesheet=t,this._serializedLayers=null,this.fire(new p.l("style.load",{style:this})),!0}_getOperationsToPerform(t){const n=[],h=[];for(const f of t)switch(f.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":case"setRoll":continue;case"addLayer":n.push((()=>this.addLayer.apply(this,f.args)));break;case"removeLayer":n.push((()=>this.removeLayer.apply(this,f.args)));break;case"setPaintProperty":n.push((()=>this.setPaintProperty.apply(this,f.args)));break;case"setLayoutProperty":n.push((()=>this.setLayoutProperty.apply(this,f.args)));break;case"setFilter":n.push((()=>this.setFilter.apply(this,f.args)));break;case"addSource":n.push((()=>this.addSource.apply(this,f.args)));break;case"removeSource":n.push((()=>this.removeSource.apply(this,f.args)));break;case"setLayerZoomRange":n.push((()=>this.setLayerZoomRange.apply(this,f.args)));break;case"setLight":n.push((()=>this.setLight.apply(this,f.args)));break;case"setGeoJSONSourceData":n.push((()=>this.setGeoJSONSourceData.apply(this,f.args)));break;case"setGlyphs":n.push((()=>this.setGlyphs.apply(this,f.args)));break;case"setSprite":n.push((()=>this.setSprite.apply(this,f.args)));break;case"setTerrain":n.push((()=>this.map.setTerrain.apply(this,f.args)));break;case"setSky":n.push((()=>this.setSky.apply(this,f.args)));break;case"setProjection":this.setProjection.apply(this,f.args);break;case"setGlobalState":n.push((()=>this.setGlobalState.apply(this,f.args)));break;case"setTransition":n.push((()=>{}));break;default:h.push(f.command)}return{operations:n,unimplemented:h}}addImage(t,n){if(this.getImage(t))return this.fire(new p.k(new Error(`An image named "${t}" already exists.`)));this.imageManager.addImage(t,n),this._afterImageUpdated(t)}updateImage(t,n){this.imageManager.updateImage(t,n)}getImage(t){return this.imageManager.getImage(t)}removeImage(t){if(!this.getImage(t))return this.fire(new p.k(new Error(`An image named "${t}" does not exist.`)));this.imageManager.removeImage(t),this._afterImageUpdated(t)}_afterImageUpdated(t){this._availableImages=this.imageManager.listImages(),this._changedImages[t]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new p.l("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(t,n,h={}){if(this._checkLoaded(),this.tileManagers[t]!==void 0)throw new Error(`Source "${t}" already exists.`);if(!n.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(n).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(n.type)>=0&&this._validate(p.C.source,`sources.${t}`,n,null,h))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);const f=this.tileManagers[t]=new Qi(t,n,this.dispatcher);f.style=this,f.setEventedParent(this,(()=>({isSourceLoaded:f.loaded(),source:f.serialize(),sourceId:t}))),f.onAdd(this.map),this._changed=!0}removeSource(t){if(this._checkLoaded(),this.tileManagers[t]===void 0)throw new Error("There is no source with this ID");for(const h in this._layers)if(this._layers[h].source===t)return this.fire(new p.k(new Error(`Source "${t}" cannot be removed while layer "${h}" is using it.`)));const n=this.tileManagers[t];delete this.tileManagers[t],delete this._updatedSources[t],n.fire(new p.l("data",{sourceDataType:"metadata",dataType:"source",sourceId:t})),n.setEventedParent(null),n.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(t,n){if(this._checkLoaded(),this.tileManagers[t]===void 0)throw new Error(`There is no source with this ID=${t}`);const h=this.tileManagers[t].getSource();if(h.type!=="geojson")throw new Error(`geojsonSource.type is ${h.type}, which is !== 'geojson`);h.setData(n),this._changed=!0}getSource(t){return this.tileManagers[t]&&this.tileManagers[t].getSource()}addLayer(t,n,h={}){this._checkLoaded();const f=t.id;if(this.getLayer(f))return void this.fire(new p.k(new Error(`Layer "${f}" already exists on this map.`)));let x;if(t.type==="custom"){if(Eo(this,p.bX(t)))return;x=p.bT(t,this._globalState)}else{if("source"in t&&typeof t.source=="object"&&(this.addSource(f,t.source),t=p.bV(t),t=p.e(t,{source:f})),this._validate(p.C.layer,`layers.${f}`,t,{arrayIndex:-1},h))return;x=p.bT(t,this._globalState),this._validateLayer(x),x.setEventedParent(this,{layer:{id:f}})}const T=n?this._order.indexOf(n):this._order.length;if(n&&T===-1)this.fire(new p.k(new Error(`Cannot add layer "${f}" before non-existing layer "${n}".`)));else{if(this._order.splice(T,0,f),this._layerOrderChanged=!0,this._layers[f]=x,this._removedLayers[f]&&x.source&&x.type!=="custom"){const C=this._removedLayers[f];delete this._removedLayers[f],C.type!==x.type?this._updatedSources[x.source]="clear":(this._updatedSources[x.source]="reload",this.tileManagers[x.source].pause())}this._updateLayer(x),x.onAdd&&x.onAdd(this.map)}}moveLayer(t,n){if(this._checkLoaded(),this._changed=!0,!this._layers[t])return void this.fire(new p.k(new Error(`The layer '${t}' does not exist in the map's style and cannot be moved.`)));if(t===n)return;const h=this._order.indexOf(t);this._order.splice(h,1);const f=n?this._order.indexOf(n):this._order.length;n&&f===-1?this.fire(new p.k(new Error(`Cannot move layer "${t}" before non-existing layer "${n}".`))):(this._order.splice(f,0,t),this._layerOrderChanged=!0)}removeLayer(t){this._checkLoaded();const n=this._layers[t];if(!n)return void this.fire(new p.k(new Error(`Cannot remove non-existing layer "${t}".`)));n.setEventedParent(null);const h=this._order.indexOf(t);this._order.splice(h,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[t]=n,delete this._layers[t],this._serializedLayers&&delete this._serializedLayers[t],delete this._updatedLayers[t],delete this._updatedPaintProps[t],n.onRemove&&n.onRemove(this.map)}getLayer(t){return this._layers[t]}getLayersOrder(){return[...this._order]}hasLayer(t){return t in this._layers}setLayerZoomRange(t,n,h){this._checkLoaded();const f=this.getLayer(t);f?f.minzoom===n&&f.maxzoom===h||(n!=null&&(f.minzoom=n),h!=null&&(f.maxzoom=h),this._updateLayer(f)):this.fire(new p.k(new Error(`Cannot set the zoom range of non-existing layer "${t}".`)))}setFilter(t,n,h={}){this._checkLoaded();const f=this.getLayer(t);if(f){if(!p.bR(f.filter,n))return n==null?(f.setFilter(void 0),void this._updateLayer(f)):void(this._validate(p.C.filter,`layers.${f.id}.filter`,n,null,h)||(f.setFilter(p.bV(n)),this._updateLayer(f)))}else this.fire(new p.k(new Error(`Cannot filter non-existing layer "${t}".`)))}getFilter(t){return p.bV(this.getLayer(t).filter)}setLayoutProperty(t,n,h,f={}){this._checkLoaded();const x=this.getLayer(t);x?p.bR(x.getLayoutProperty(n),h)||(x.setLayoutProperty(n,h,f),this._updateLayer(x)):this.fire(new p.k(new Error(`Cannot style non-existing layer "${t}".`)))}getLayoutProperty(t,n){const h=this.getLayer(t);if(h)return h.getLayoutProperty(n);this.fire(new p.k(new Error(`Cannot get style of non-existing layer "${t}".`)))}setPaintProperty(t,n,h,f={}){this._checkLoaded();const x=this.getLayer(t);x?p.bR(x.getPaintProperty(n),h)||this._updatePaintProperty(x,n,h,f):this.fire(new p.k(new Error(`Cannot style non-existing layer "${t}".`)))}_updatePaintProperty(t,n,h,f={}){t.setPaintProperty(n,h,f)&&this._updateLayer(t),p.bU(t)&&n==="raster-fade-duration"&&this.tileManagers[t.source].setRasterFadeDuration(h),this._changed=!0,this._updatedPaintProps[t.id]=!0,this._serializedLayers=null}getPaintProperty(t,n){return this.getLayer(t).getPaintProperty(n)}setFeatureState(t,n){this._checkLoaded();const h=t.source,f=t.sourceLayer,x=this.tileManagers[h];if(x===void 0)return void this.fire(new p.k(new Error(`The source '${h}' does not exist in the map's style.`)));const T=x.getSource().type;T==="geojson"&&f?this.fire(new p.k(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):T!=="vector"||f?(t.id===void 0&&this.fire(new p.k(new Error("The feature id parameter must be provided."))),x.setFeatureState(f,t.id,n)):this.fire(new p.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(t,n){this._checkLoaded();const h=t.source,f=this.tileManagers[h];if(f===void 0)return void this.fire(new p.k(new Error(`The source '${h}' does not exist in the map's style.`)));const x=f.getSource().type,T=x==="vector"?t.sourceLayer:void 0;x!=="vector"||T?n&&typeof t.id!="string"&&typeof t.id!="number"?this.fire(new p.k(new Error("A feature id is required to remove its specific state property."))):f.removeFeatureState(T,t.id,n):this.fire(new p.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(t){this._checkLoaded();const n=t.source,h=t.sourceLayer,f=this.tileManagers[n];if(f!==void 0)return f.getSource().type!=="vector"||h?(t.id===void 0&&this.fire(new p.k(new Error("The feature id parameter must be provided."))),f.getFeatureState(h,t.id)):void this.fire(new p.k(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new p.k(new Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return p.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const t=p.bY(this.tileManagers,(x=>x.serialize())),n=this._serializeByIds(this._order,!0),h=this.map.getTerrain()||void 0,f=this.stylesheet;return p.bZ({version:f.version,name:f.name,metadata:f.metadata,light:f.light,sky:f.sky,center:f.center,zoom:f.zoom,bearing:f.bearing,pitch:f.pitch,sprite:f.sprite,glyphs:f.glyphs,transition:f.transition,projection:f.projection,sources:t,layers:n,terrain:h},(x=>x!==void 0))}_updateLayer(t){this._updatedLayers[t.id]=!0,t.source&&!this._updatedSources[t.source]&&this.tileManagers[t.source].getSource().type!=="raster"&&(this._updatedSources[t.source]="reload",this.tileManagers[t.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(t){const n=T=>this._layers[T].type==="fill-extrusion",h={},f=[];for(let T=this._order.length-1;T>=0;T--){const C=this._order[T];if(n(C)){h[C]=T;for(const D of t){const B=D[C];if(B)for(const N of B)f.push(N)}}}f.sort(((T,C)=>C.intersectionZ-T.intersectionZ));const x=[];for(let T=this._order.length-1;T>=0;T--){const C=this._order[T];if(n(C))for(let D=f.length-1;D>=0;D--){const B=f[D].feature;if(h[B.layer.id]<T)break;x.push(B),f.pop()}else for(const D of t){const B=D[C];if(B)for(const N of B)x.push(N.feature)}}return x}queryRenderedFeatures(t,n,h){n&&n.filter&&this._validate(p.C.filter,"queryRenderedFeatures.filter",n.filter,null,n);const f={};if(n&&n.layers){if(!(Array.isArray(n.layers)||n.layers instanceof Set))return this.fire(new p.k(new Error("parameters.layers must be an Array or a Set of strings"))),[];for(const B of n.layers){const N=this._layers[B];if(!N)return this.fire(new p.k(new Error(`The layer '${B}' does not exist in the map's style and cannot be queried for features.`))),[];f[N.source]=!0}}const x=[];n.availableImages=this._availableImages;const T=this._serializedAllLayers(),C=n.layers instanceof Set?n.layers:Array.isArray(n.layers)?new Set(n.layers):null,D=Object.assign(Object.assign({},n),{layers:C,globalState:this._globalState});for(const B in this.tileManagers)n.layers&&!f[B]||x.push(Vo(this.tileManagers[B],this._layers,T,t,D,h,this.map.terrain?(N,G,U)=>this.map.terrain.getElevation(N,G,U):void 0));return this.placement&&x.push((function(B,N,G,U,$,ie,he){const Ae={},ce=ie.queryRenderedSymbols(U),ye=[];for(const Pe of Object.keys(ce).map(Number))ye.push(he[Pe]);ye.sort(en);for(const Pe of ye){const _e=Pe.featureIndex.lookupSymbolFeatures(ce[Pe.bucketInstanceId],N,Pe.bucketIndex,Pe.sourceLayerIndex,{filterSpec:$.filter,globalState:$.globalState},$.layers,$.availableImages,B);for(const we in _e){const Ce=Ae[we]=Ae[we]||[],be=_e[we];be.sort(((Le,Ke)=>{const He=Pe.featureSortOrder;if(He){const $e=He.indexOf(Le.featureIndex);return He.indexOf(Ke.featureIndex)-$e}return Ke.featureIndex-Le.featureIndex}));for(const Le of be)Ce.push(Le)}}return(function(Pe,_e,we){for(const Ce in Pe)for(const be of Pe[Ce])hs(be,we[_e[Ce].source]);return Pe})(Ae,B,G)})(this._layers,T,this.tileManagers,t,D,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(x)}querySourceFeatures(t,n){n!=null&&n.filter&&this._validate(p.C.filter,"querySourceFeatures.filter",n.filter,null,n);const h=this.tileManagers[t];return h?(function(f,x){const T=f.getRenderableIds().map((B=>f.getTileByID(B))),C=[],D={};for(let B=0;B<T.length;B++){const N=T[B],G=N.tileID.canonical.key;D[G]||(D[G]=!0,N.querySourceFeatures(C,x))}return C})(h,n?Object.assign(Object.assign({},n),{globalState:this._globalState}):{globalState:this._globalState}):[]}getLight(){return this.light.getLight()}setLight(t,n={}){this._checkLoaded();const h=this.light.getLight();let f=!1;for(const T in t)if(!p.bR(t[T],h[T])){f=!0;break}if(!f)return;const x={now:Gt(),transition:p.e({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(t,n),this.light.updateTransitions(x)}getProjection(){var t;return(t=this.stylesheet)===null||t===void 0?void 0:t.projection}setProjection(t){if(this._checkLoaded(),this.projection){if(this.projection.name===t.type)return;this.projection.destroy(),delete this.projection}this.stylesheet.projection=t,this._setProjectionInternal(t.type)}getSky(){var t;return(t=this.stylesheet)===null||t===void 0?void 0:t.sky}setSky(t,n={}){this._checkLoaded();const h=this.getSky();let f=!1;if(!t&&!h)return;if(t&&!h)f=!0;else if(!t&&h)f=!0;else for(const T in t)if(!p.bR(t[T],h[T])){f=!0;break}if(!f)return;const x={now:Gt(),transition:p.e({duration:300,delay:0},this.stylesheet.transition)};this.stylesheet.sky=t,this.sky.setSky(t,n),this.sky.updateTransitions(x)}_setProjectionInternal(t){const n=(function(h,f){const x={constrainOverride:f};if(Array.isArray(h)){const T=new Gs({type:h});return{projection:T,transform:new An(x),cameraHelper:new xl(T)}}switch(h){case"mercator":return{projection:new Lr,transform:new Po(x),cameraHelper:new hi};case"globe":{const T=new Gs({type:["interpolate",["linear"],["zoom"],11,"vertical-perspective",12,"mercator"]});return{projection:T,transform:new An(x),cameraHelper:new xl(T)}}case"vertical-perspective":return{projection:new Bn,transform:new qs(x),cameraHelper:new Ar};default:return p.w(`Unknown projection name: ${h}. Falling back to mercator projection.`),{projection:new Lr,transform:new Po(x),cameraHelper:new hi}}})(t,this.map.transformConstrain);this.projection=n.projection,this.map.migrateProjection(n.transform,n.cameraHelper);for(const h in this.tileManagers)this.tileManagers[h].reload()}_validate(t,n,h,f,x={}){return(!x||x.validate!==!1)&&Eo(this,t.call(p.C,p.e({key:n,style:this.serialize(),value:h,styleSpec:p.u},f)))}_remove(t=!0){this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._loadStyleRequest&&(this._loadStyleRequest.abort(),this._loadStyleRequest=null),this._spriteRequest&&(this._spriteRequest.abort(),this._spriteRequest=null),Fe().off(Me,this._rtlPluginLoaded);for(const n in this._layers)this._layers[n].setEventedParent(null);for(const n in this.tileManagers){const h=this.tileManagers[n];h.setEventedParent(null),h.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null),t&&this.dispatcher.broadcast("RM",void 0),this.dispatcher.remove(t)}_clearSource(t){this.tileManagers[t].clearTiles()}_reloadSource(t){this.tileManagers[t].resume(),this.tileManagers[t].reload()}_updateSources(t){for(const n in this.tileManagers)this.tileManagers[n].update(t,this.map.terrain)}_generateCollisionBoxes(){for(const t in this.tileManagers)this._reloadSource(t)}_updatePlacement(t,n,h,f,x=!1){let T=!1,C=!1;const D={};for(const B of this._order){const N=this._layers[B];if(N.type!=="symbol")continue;if(!D[N.source]){const U=this.tileManagers[N.source];D[N.source]=U.getRenderableIds(!0).map(($=>U.getTileByID($))).sort((($,ie)=>ie.tileID.overscaledZ-$.tileID.overscaledZ||($.tileID.isLessThan(ie.tileID)?-1:1)))}const G=this.crossTileSymbolIndex.addLayer(N,D[N.source],t.center.lng);T=T||G}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((x=x||this._layerOrderChanged||h===0)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(Gt(),t.zoom))&&(this.pauseablePlacement=new Vi(t,this.map.terrain,this._order,x,n,h,f,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,D),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(Gt()),C=!0),T&&this.pauseablePlacement.placement.setStale()),C||T)for(const B of this._order){const N=this._layers[B];N.type==="symbol"&&this.placement.updateLayerOpacities(N,D[N.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(Gt())}_releaseSymbolFadeTiles(){for(const t in this.tileManagers)this.tileManagers[t].releaseSymbolFadeTiles()}getImages(t,n){return p._(this,void 0,void 0,(function*(){const h=yield this.imageManager.getImages(n.icons);this._updateTilesForChangedImages();const f=this.tileManagers[n.source];return f&&f.setDependencies(n.tileID.key,n.type,n.icons),h}))}getGlyphs(t,n){return p._(this,void 0,void 0,(function*(){const h=yield this.glyphManager.getGlyphs(n.stacks),f=this.tileManagers[n.source];return f&&f.setDependencies(n.tileID.key,n.type,[""]),h}))}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(t,n={}){this._checkLoaded(),t&&this._validate(p.C.glyphs,"glyphs",t,null,n)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=t,this.glyphManager.entries={},this.glyphManager.setURL(t))}getDashes(t,n){return p._(this,void 0,void 0,(function*(){const h={};for(const[f,x]of Object.entries(n.dashes))h[f]=this.lineAtlas.getDash(x.dasharray,x.round);return h}))}addSprite(t,n,h={},f){this._checkLoaded();const x=[{id:t,url:n}],T=[...Vs(this.stylesheet.sprite),...x];this._validate(p.C.sprite,"sprite",T,null,h)||(this.stylesheet.sprite=T,this._loadSprite(x,!0,f))}removeSprite(t){this._checkLoaded();const n=Vs(this.stylesheet.sprite);if(n.find((h=>h.id===t))){if(this._spritesImagesIds[t])for(const h of this._spritesImagesIds[t])this.imageManager.removeImage(h),this._changedImages[h]=!0;n.splice(n.findIndex((h=>h.id===t)),1),this.stylesheet.sprite=n.length>0?n:void 0,delete this._spritesImagesIds[t],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new p.l("data",{dataType:"style"}))}else this.fire(new p.k(new Error(`Sprite "${t}" doesn't exists on this map.`)))}getSprite(){return Vs(this.stylesheet.sprite)}setSprite(t,n={},h){this._checkLoaded(),t&&this._validate(p.C.sprite,"sprite",t,null,n)||(this.stylesheet.sprite=t,t?this._loadSprite(t,!0,h):(this._unloadSprite(),h&&h(null)))}destroy(){this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._loadStyleRequest&&(this._loadStyleRequest.abort(),this._loadStyleRequest=null),this._spriteRequest&&(this._spriteRequest.abort(),this._spriteRequest=null);for(const t in this.tileManagers){const n=this.tileManagers[t];n.setEventedParent(null),n.onRemove(this.map)}this.tileManagers={},this.imageManager&&(this.imageManager.setEventedParent(null),this.imageManager.destroy(),this._availableImages=[],this._spritesImagesIds={}),this.glyphManager&&this.glyphManager.destroy();for(const t in this._layers){const n=this._layers[t];n.setEventedParent(null),n.onRemove&&n.onRemove(this.map)}this._setInitialValues(),this.setEventedParent(null),this.dispatcher.unregisterMessageHandler("GG"),this.dispatcher.unregisterMessageHandler("GI"),this.dispatcher.unregisterMessageHandler("GDA"),this.dispatcher.remove(!0),this._listeners={},this._oneTimeListeners={}}}var hu=p.aU([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class da{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(t,n,h,f,x,T,C,D,B){this.context=t;let N=this.boundPaintVertexBuffers.length!==f.length;for(let G=0;!N&&G<f.length;G++)this.boundPaintVertexBuffers[G]!==f[G]&&(N=!0);!this.vao||this.boundProgram!==n||this.boundLayoutVertexBuffer!==h||N||this.boundIndexBuffer!==x||this.boundVertexOffset!==T||this.boundDynamicVertexBuffer!==C||this.boundDynamicVertexBuffer2!==D||this.boundDynamicVertexBuffer3!==B?this.freshBind(n,h,f,x,T,C,D,B):(t.bindVertexArray.set(this.vao),C&&C.bind(),x&&x.dynamicDraw&&x.bind(),D&&D.bind(),B&&B.bind())}freshBind(t,n,h,f,x,T,C,D){const B=t.numAttributes,N=this.context,G=N.gl;this.vao&&this.destroy(),this.vao=N.createVertexArray(),N.bindVertexArray.set(this.vao),this.boundProgram=t,this.boundLayoutVertexBuffer=n,this.boundPaintVertexBuffers=h,this.boundIndexBuffer=f,this.boundVertexOffset=x,this.boundDynamicVertexBuffer=T,this.boundDynamicVertexBuffer2=C,this.boundDynamicVertexBuffer3=D,n.enableAttributes(G,t);for(const U of h)U.enableAttributes(G,t);T&&T.enableAttributes(G,t),C&&C.enableAttributes(G,t),D&&D.enableAttributes(G,t),n.bind(),n.setVertexAttribPointers(G,t,x);for(const U of h)U.bind(),U.setVertexAttribPointers(G,t,x);T&&(T.bind(),T.setVertexAttribPointers(G,t,x)),f&&f.bind(),C&&(C.bind(),C.setVertexAttribPointers(G,t,x)),D&&(D.bind(),D.setVertexAttribPointers(G,t,x)),N.currentNumAttributes=B}destroy(){this.vao&&(this.context.deleteVertexArray(this.vao),this.vao=null)}}const bl=(y,t,n,h,f)=>({u_texture:0,u_ele_delta:y,u_fog_matrix:t,u_fog_color:n?n.properties.get("fog-color"):p.bp.white,u_fog_ground_blend:n?n.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:f?0:n?n.calculateFogBlendOpacity(h):0,u_horizon_color:n?n.properties.get("horizon-color"):p.bp.white,u_horizon_fog_blend:n?n.properties.get("horizon-fog-blend"):1,u_is_globe_mode:f?1:0}),pa={mainMatrix:"u_projection_matrix",tileMercatorCoords:"u_projection_tile_mercator_coords",clippingPlane:"u_projection_clipping_plane",projectionTransition:"u_projection_transition",fallbackMatrix:"u_projection_fallback_matrix"};function Rn(y){const t=[];for(let n=0;n<y.length;n++){if(y[n]===null)continue;const h=y[n].split(" ");t.push(h.pop())}return t}class $o{constructor(t,n,h,f,x,T,C,D,B=[]){const N=t.gl;this.program=N.createProgram();const G=Rn(n.staticAttributes),U=h?h.getBinderAttributes():[],$=G.concat(U),ie=Li.prelude.staticUniforms?Rn(Li.prelude.staticUniforms):[],he=C.staticUniforms?Rn(C.staticUniforms):[],Ae=n.staticUniforms?Rn(n.staticUniforms):[],ce=h?h.getBinderUniforms():[],ye=ie.concat(he).concat(Ae).concat(ce),Pe=[];for(const He of ye)Pe.indexOf(He)<0&&Pe.push(He);const _e=h?h.defines():[];Xn(N)&&_e.unshift("#version 300 es"),x&&_e.push("#define OVERDRAW_INSPECTOR;"),T&&_e.push("#define TERRAIN3D;"),D&&_e.push(D),B&&_e.push(...B);let we=_e.concat(Li.prelude.fragmentSource,C.fragmentSource,n.fragmentSource).join(` 811 - `),Ce=_e.concat(Li.prelude.vertexSource,C.vertexSource,n.vertexSource).join(` 812 - `);Xn(N)||(we=(function(He){return He.replace(/\bin\s/g,"varying ").replace("out highp vec4 fragColor;","").replace(/fragColor/g,"gl_FragColor").replace(/texture\(/g,"texture2D(")})(we),Ce=(function(He){return He.replace(/\bin\s/g,"attribute ").replace(/\bout\s/g,"varying ").replace(/texture\(/g,"texture2D(")})(Ce));const be=N.createShader(N.FRAGMENT_SHADER);if(N.isContextLost())return void(this.failedToCreate=!0);if(N.shaderSource(be,we),N.compileShader(be),!N.getShaderParameter(be,N.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${N.getShaderInfoLog(be)}`);N.attachShader(this.program,be);const Le=N.createShader(N.VERTEX_SHADER);if(N.isContextLost())return void(this.failedToCreate=!0);if(N.shaderSource(Le,Ce),N.compileShader(Le),!N.getShaderParameter(Le,N.COMPILE_STATUS))throw new Error(`Could not compile vertex shader: ${N.getShaderInfoLog(Le)}`);N.attachShader(this.program,Le),this.attributes={};const Ke={};this.numAttributes=$.length;for(let He=0;He<this.numAttributes;He++)$[He]&&(N.bindAttribLocation(this.program,He,$[He]),this.attributes[$[He]]=He);if(N.linkProgram(this.program),!N.getProgramParameter(this.program,N.LINK_STATUS))throw new Error(`Program failed to link: ${N.getProgramInfoLog(this.program)}`);N.deleteShader(Le),N.deleteShader(be);for(let He=0;He<Pe.length;He++){const $e=Pe[He];if($e&&!Ke[$e]){const Ye=N.getUniformLocation(this.program,$e);Ye&&(Ke[$e]=Ye)}}this.fixedUniforms=f(t,Ke),this.terrainUniforms=((He,$e)=>({u_depth:new p.b_(He,$e.u_depth),u_terrain:new p.b_(He,$e.u_terrain),u_terrain_dim:new p.bq(He,$e.u_terrain_dim),u_terrain_matrix:new p.c0(He,$e.u_terrain_matrix),u_terrain_unpack:new p.c1(He,$e.u_terrain_unpack),u_terrain_exaggeration:new p.bq(He,$e.u_terrain_exaggeration)}))(t,Ke),this.projectionUniforms=((He,$e)=>({u_projection_matrix:new p.c0(He,$e.u_projection_matrix),u_projection_tile_mercator_coords:new p.c1(He,$e.u_projection_tile_mercator_coords),u_projection_clipping_plane:new p.c1(He,$e.u_projection_clipping_plane),u_projection_transition:new p.bq(He,$e.u_projection_transition),u_projection_fallback_matrix:new p.c0(He,$e.u_projection_fallback_matrix)}))(t,Ke),this.binderUniforms=h?h.getUniforms(t,Ke):[]}draw(t,n,h,f,x,T,C,D,B,N,G,U,$,ie,he,Ae,ce,ye,Pe){const _e=t.gl;if(this.failedToCreate)return;if(t.program.set(this.program),t.setDepthMode(h),t.setStencilMode(f),t.setColorMode(x),t.setCullFace(T),D){t.activeTexture.set(_e.TEXTURE2),_e.bindTexture(_e.TEXTURE_2D,D.depthTexture),t.activeTexture.set(_e.TEXTURE3),_e.bindTexture(_e.TEXTURE_2D,D.texture);for(const Ce in this.terrainUniforms)this.terrainUniforms[Ce].set(D[Ce])}if(B)for(const Ce in B)this.projectionUniforms[pa[Ce]].set(B[Ce]);if(C)for(const Ce in this.fixedUniforms)this.fixedUniforms[Ce].set(C[Ce]);Ae&&Ae.setUniforms(t,this.binderUniforms,ie,{zoom:he});let we=0;switch(n){case _e.LINES:we=2;break;case _e.TRIANGLES:we=3;break;case _e.LINE_STRIP:we=1}for(const Ce of $.get()){const be=Ce.vaos||(Ce.vaos={});(be[N]||(be[N]=new da)).bind(t,this,G,Ae?Ae.getPaintVertexBuffers():[],U,Ce.vertexOffset,ce,ye,Pe),_e.drawElements(n,Ce.primitiveLength*we,_e.UNSIGNED_SHORT,Ce.primitiveOffset*we*2)}}}function Zl(y,t,n){const h=1/p.aN(n,1,t.transform.tileZoom),f=Math.pow(2,n.tileID.overscaledZ),x=n.tileSize*Math.pow(2,t.transform.tileZoom)/f,T=x*(n.tileID.canonical.x+n.tileID.wrap*f),C=x*n.tileID.canonical.y;return{u_image:0,u_texsize:n.imageAtlasTexture.size,u_scale:[h,y.fromScale,y.toScale],u_fade:y.t,u_pixel_coord_upper:[T>>16,C>>16],u_pixel_coord_lower:[65535&T,65535&C]}}const cs=(y,t,n,h)=>{const f=y.style.light,x=f.properties.get("position"),T=[x.x,x.y,x.z],C=p.c4();f.properties.get("anchor")==="viewport"&&p.c5(C,y.transform.bearingInRadians),p.c6(T,T,C);const D=y.transform.transformLightDirection(T),B=f.properties.get("color");return{u_lightpos:T,u_lightpos_globe:D,u_lightintensity:f.properties.get("intensity"),u_lightcolor:[B.r,B.g,B.b],u_vertical_gradient:+t,u_opacity:n,u_fill_translate:h}},wl=(y,t,n,h,f,x,T)=>p.e(cs(y,t,n,h),Zl(x,y,T),{u_height_factor:-Math.pow(2,f.overscaledZ)/T.tileSize/8}),Hs=(y,t,n,h)=>p.e(Zl(t,y,n),{u_fill_translate:h}),Xa=(y,t)=>({u_world:y,u_fill_translate:t}),Ws=(y,t,n,h,f)=>p.e(Hs(y,t,n,f),{u_world:h}),$i=(y,t,n,h,f)=>{const x=y.transform;let T,C,D=0;if(n.paint.get("circle-pitch-alignment")==="map"){const B=p.aN(t,1,x.zoom);T=!0,C=[B,B],D=B/(p.a5*Math.pow(2,t.tileID.overscaledZ))*2*Math.PI*f}else T=!1,C=x.pixelsToGLUnits;return{u_camera_to_center_distance:x.cameraToCenterDistance,u_scale_with_map:+(n.paint.get("circle-pitch-scale")==="map"),u_pitch_with_map:+T,u_device_pixel_ratio:y.pixelRatio,u_extrude_scale:C,u_globe_extrude_scale:D,u_translate:h}},Qs=y=>({u_pixel_extrude_scale:[1/y.width,1/y.height]}),Tl=y=>({u_viewport_size:[y.width,y.height]}),Bs=(y,t=1)=>({u_color:y,u_overlay:0,u_overlay_scale:t}),uo=(y,t,n,h)=>{const f=p.aN(y,1,t)/(p.a5*Math.pow(2,y.tileID.overscaledZ))*2*Math.PI*h;return{u_extrude_scale:p.aN(y,1,t),u_intensity:n,u_globe_extrude_scale:f}},Ul=(y,t,n,h)=>{const f=p.N();p.c7(f,0,y.width,y.height,0,0,1);const x=y.context.gl;return{u_matrix:f,u_world:[x.drawingBufferWidth,x.drawingBufferHeight],u_image:n,u_color_ramp:h,u_opacity:t.paint.get("heatmap-opacity")}},ma=(y,t,n)=>{const h=n.paint.get("hillshade-accent-color");let f;switch(n.paint.get("hillshade-method")){case"basic":f=4;break;case"combined":f=1;break;case"igor":f=2;break;case"multidirectional":f=3;break;default:f=0}const x=n.getIlluminationProperties();for(let T=0;T<x.directionRadians.length;T++)n.paint.get("hillshade-illumination-anchor")==="viewport"&&(x.directionRadians[T]+=y.transform.bearingInRadians);return{u_image:0,u_latrange:Ir(0,t.tileID),u_exaggeration:n.paint.get("hillshade-exaggeration"),u_altitudes:x.altitudeRadians,u_azimuths:x.directionRadians,u_accent:h,u_method:f,u_highlights:x.highlightColor,u_shadows:x.shadowColor}},cu=(y,t)=>{const n=t.stride,h=p.N();return p.c7(h,0,p.a5,-p.a5,0,0,1),p.O(h,h,[0,-p.a5,0]),{u_matrix:h,u_image:1,u_dimension:[n,n],u_zoom:y.overscaledZ,u_unpack:t.getUnpackVector()}};function Ir(y,t){const n=Math.pow(2,t.canonical.z),h=t.canonical.y;return[new p.a9(0,h/n).toLngLat().lat,new p.a9(0,(h+1)/n).toLngLat().lat]}const Ka=(y,t,n=0)=>({u_image:0,u_unpack:t.getUnpackVector(),u_dimension:[t.stride,t.stride],u_elevation_stops:1,u_color_stops:4,u_color_ramp_size:n,u_opacity:y.paint.get("color-relief-opacity")}),yn=(y,t,n,h)=>{const f=y.transform;return{u_translation:ho(y,t,n),u_ratio:h/p.aN(t,1,f.zoom),u_device_pixel_ratio:y.pixelRatio,u_units_to_pixels:[1/f.pixelsToGLUnits[0],1/f.pixelsToGLUnits[1]]}},Gl=(y,t,n,h,f)=>p.e(yn(y,t,n,h),{u_image:0,u_image_height:f}),As=(y,t,n,h,f)=>{const x=y.transform,T=Fn(t,x);return{u_translation:ho(y,t,n),u_texsize:t.imageAtlasTexture.size,u_ratio:h/p.aN(t,1,x.zoom),u_device_pixel_ratio:y.pixelRatio,u_image:0,u_scale:[T,f.fromScale,f.toScale],u_fade:f.t,u_units_to_pixels:[1/x.pixelsToGLUnits[0],1/x.pixelsToGLUnits[1]]}},Ba=(y,t,n,h,f)=>{const x=Fn(t,y.transform);return p.e(yn(y,t,n,h),{u_tileratio:x,u_crossfade_from:f.fromScale,u_crossfade_to:f.toScale,u_image:0,u_mix:f.t,u_lineatlas_width:y.lineAtlas.width,u_lineatlas_height:y.lineAtlas.height})},vn=(y,t,n,h,f,x)=>{const T=Fn(t,y.transform);return p.e(yn(y,t,n,h),{u_image:0,u_image_height:x,u_tileratio:T,u_crossfade_from:f.fromScale,u_crossfade_to:f.toScale,u_image_dash:1,u_mix:f.t,u_lineatlas_width:y.lineAtlas.width,u_lineatlas_height:y.lineAtlas.height})};function Fn(y,t){return 1/p.aN(y,1,t.tileZoom)}function ho(y,t,n){return p.aO(y.transform,t,n.paint.get("line-translate"),n.paint.get("line-translate-anchor"))}const $s=(y,t,n,h,f)=>{return{u_tl_parent:y,u_scale_parent:t,u_buffer_scale:1,u_fade_t:n.mix,u_opacity:n.opacity*h.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:h.paint.get("raster-brightness-min"),u_brightness_high:h.paint.get("raster-brightness-max"),u_saturation_factor:(T=h.paint.get("raster-saturation"),T>0?1-1/(1.001-T):-T),u_contrast_factor:(x=h.paint.get("raster-contrast"),x>0?1/(1-x):1+x),u_spin_weights:xs(h.paint.get("raster-hue-rotate")),u_coords_top:[f[0].x,f[0].y,f[1].x,f[1].y],u_coords_bottom:[f[3].x,f[3].y,f[2].x,f[2].y]};var x,T};function xs(y){y*=Math.PI/180;const t=Math.sin(y),n=Math.cos(y);return[(2*n+1)/3,(-Math.sqrt(3)*t-n+1)/3,(Math.sqrt(3)*t-n+1)/3]}const fs=(y,t,n,h,f,x,T,C,D,B,N,G,U)=>{const $=T.transform;return{u_is_size_zoom_constant:+(y==="constant"||y==="source"),u_is_size_feature_constant:+(y==="constant"||y==="camera"),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:$.cameraToCenterDistance,u_pitch:$.pitch/360*2*Math.PI,u_rotate_symbol:+n,u_aspect_ratio:$.width/$.height,u_fade_change:T.options.fadeDuration?T.symbolFadeChange:1,u_label_plane_matrix:C,u_coord_matrix:D,u_is_text:+N,u_pitch_with_map:+h,u_is_along_line:f,u_is_variable_anchor:x,u_texsize:G,u_texture:0,u_translation:B,u_pitched_scale:U}},Yo=(y,t,n,h,f,x,T,C,D,B,N,G,U,$)=>{const ie=T.transform;return p.e(fs(y,t,n,h,f,x,T,C,D,B,N,G,$),{u_gamma_scale:h?Math.cos(ie.pitch*Math.PI/180)*ie.cameraToCenterDistance:1,u_device_pixel_ratio:T.pixelRatio,u_is_halo:1})},Ys=(y,t,n,h,f,x,T,C,D,B,N,G,U)=>p.e(Yo(y,t,n,h,f,x,T,C,D,B,!0,N,0,U),{u_texsize_icon:G,u_texture_icon:1}),Ja=(y,t)=>({u_opacity:y,u_color:t}),Pl=(y,t,n,h,f)=>p.e((function(x,T,C,D){const B=C.imageManager.getPattern(x.from.toString()),N=C.imageManager.getPattern(x.to.toString()),{width:G,height:U}=C.imageManager.getPixelSize(),$=Math.pow(2,D.tileID.overscaledZ),ie=D.tileSize*Math.pow(2,C.transform.tileZoom)/$,he=ie*(D.tileID.canonical.x+D.tileID.wrap*$),Ae=ie*D.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:B.tl,u_pattern_br_a:B.br,u_pattern_tl_b:N.tl,u_pattern_br_b:N.br,u_texsize:[G,U],u_mix:T.t,u_pattern_size_a:B.displaySize,u_pattern_size_b:N.displaySize,u_scale_a:T.fromScale,u_scale_b:T.toScale,u_tile_units_to_pixels:1/p.aN(D,1,C.transform.tileZoom),u_pixel_coord_upper:[he>>16,Ae>>16],u_pixel_coord_lower:[65535&he,65535&Ae]}})(n,f,t,h),{u_opacity:y}),Ra=(y,t)=>{},Au={fillExtrusion:(y,t)=>({u_lightpos:new p.c2(y,t.u_lightpos),u_lightpos_globe:new p.c2(y,t.u_lightpos_globe),u_lightintensity:new p.bq(y,t.u_lightintensity),u_lightcolor:new p.c2(y,t.u_lightcolor),u_vertical_gradient:new p.bq(y,t.u_vertical_gradient),u_opacity:new p.bq(y,t.u_opacity),u_fill_translate:new p.c3(y,t.u_fill_translate)}),fillExtrusionPattern:(y,t)=>({u_lightpos:new p.c2(y,t.u_lightpos),u_lightpos_globe:new p.c2(y,t.u_lightpos_globe),u_lightintensity:new p.bq(y,t.u_lightintensity),u_lightcolor:new p.c2(y,t.u_lightcolor),u_vertical_gradient:new p.bq(y,t.u_vertical_gradient),u_height_factor:new p.bq(y,t.u_height_factor),u_opacity:new p.bq(y,t.u_opacity),u_fill_translate:new p.c3(y,t.u_fill_translate),u_image:new p.b_(y,t.u_image),u_texsize:new p.c3(y,t.u_texsize),u_pixel_coord_upper:new p.c3(y,t.u_pixel_coord_upper),u_pixel_coord_lower:new p.c3(y,t.u_pixel_coord_lower),u_scale:new p.c2(y,t.u_scale),u_fade:new p.bq(y,t.u_fade)}),fill:(y,t)=>({u_fill_translate:new p.c3(y,t.u_fill_translate)}),fillPattern:(y,t)=>({u_image:new p.b_(y,t.u_image),u_texsize:new p.c3(y,t.u_texsize),u_pixel_coord_upper:new p.c3(y,t.u_pixel_coord_upper),u_pixel_coord_lower:new p.c3(y,t.u_pixel_coord_lower),u_scale:new p.c2(y,t.u_scale),u_fade:new p.bq(y,t.u_fade),u_fill_translate:new p.c3(y,t.u_fill_translate)}),fillOutline:(y,t)=>({u_world:new p.c3(y,t.u_world),u_fill_translate:new p.c3(y,t.u_fill_translate)}),fillOutlinePattern:(y,t)=>({u_world:new p.c3(y,t.u_world),u_image:new p.b_(y,t.u_image),u_texsize:new p.c3(y,t.u_texsize),u_pixel_coord_upper:new p.c3(y,t.u_pixel_coord_upper),u_pixel_coord_lower:new p.c3(y,t.u_pixel_coord_lower),u_scale:new p.c2(y,t.u_scale),u_fade:new p.bq(y,t.u_fade),u_fill_translate:new p.c3(y,t.u_fill_translate)}),circle:(y,t)=>({u_camera_to_center_distance:new p.bq(y,t.u_camera_to_center_distance),u_scale_with_map:new p.b_(y,t.u_scale_with_map),u_pitch_with_map:new p.b_(y,t.u_pitch_with_map),u_extrude_scale:new p.c3(y,t.u_extrude_scale),u_device_pixel_ratio:new p.bq(y,t.u_device_pixel_ratio),u_globe_extrude_scale:new p.bq(y,t.u_globe_extrude_scale),u_translate:new p.c3(y,t.u_translate)}),collisionBox:(y,t)=>({u_pixel_extrude_scale:new p.c3(y,t.u_pixel_extrude_scale)}),collisionCircle:(y,t)=>({u_viewport_size:new p.c3(y,t.u_viewport_size)}),debug:(y,t)=>({u_color:new p.b$(y,t.u_color),u_overlay:new p.b_(y,t.u_overlay),u_overlay_scale:new p.bq(y,t.u_overlay_scale)}),depth:Ra,clippingMask:Ra,heatmap:(y,t)=>({u_extrude_scale:new p.bq(y,t.u_extrude_scale),u_intensity:new p.bq(y,t.u_intensity),u_globe_extrude_scale:new p.bq(y,t.u_globe_extrude_scale)}),heatmapTexture:(y,t)=>({u_matrix:new p.c0(y,t.u_matrix),u_world:new p.c3(y,t.u_world),u_image:new p.b_(y,t.u_image),u_color_ramp:new p.b_(y,t.u_color_ramp),u_opacity:new p.bq(y,t.u_opacity)}),hillshade:(y,t)=>({u_image:new p.b_(y,t.u_image),u_latrange:new p.c3(y,t.u_latrange),u_exaggeration:new p.bq(y,t.u_exaggeration),u_altitudes:new p.c9(y,t.u_altitudes),u_azimuths:new p.c9(y,t.u_azimuths),u_accent:new p.b$(y,t.u_accent),u_method:new p.b_(y,t.u_method),u_shadows:new p.c8(y,t.u_shadows),u_highlights:new p.c8(y,t.u_highlights)}),hillshadePrepare:(y,t)=>({u_matrix:new p.c0(y,t.u_matrix),u_image:new p.b_(y,t.u_image),u_dimension:new p.c3(y,t.u_dimension),u_zoom:new p.bq(y,t.u_zoom),u_unpack:new p.c1(y,t.u_unpack)}),colorRelief:(y,t)=>({u_image:new p.b_(y,t.u_image),u_unpack:new p.c1(y,t.u_unpack),u_dimension:new p.c3(y,t.u_dimension),u_elevation_stops:new p.b_(y,t.u_elevation_stops),u_color_stops:new p.b_(y,t.u_color_stops),u_color_ramp_size:new p.b_(y,t.u_color_ramp_size),u_opacity:new p.bq(y,t.u_opacity)}),line:(y,t)=>({u_translation:new p.c3(y,t.u_translation),u_ratio:new p.bq(y,t.u_ratio),u_device_pixel_ratio:new p.bq(y,t.u_device_pixel_ratio),u_units_to_pixels:new p.c3(y,t.u_units_to_pixels)}),lineGradient:(y,t)=>({u_translation:new p.c3(y,t.u_translation),u_ratio:new p.bq(y,t.u_ratio),u_device_pixel_ratio:new p.bq(y,t.u_device_pixel_ratio),u_units_to_pixels:new p.c3(y,t.u_units_to_pixels),u_image:new p.b_(y,t.u_image),u_image_height:new p.bq(y,t.u_image_height)}),linePattern:(y,t)=>({u_translation:new p.c3(y,t.u_translation),u_texsize:new p.c3(y,t.u_texsize),u_ratio:new p.bq(y,t.u_ratio),u_device_pixel_ratio:new p.bq(y,t.u_device_pixel_ratio),u_image:new p.b_(y,t.u_image),u_units_to_pixels:new p.c3(y,t.u_units_to_pixels),u_scale:new p.c2(y,t.u_scale),u_fade:new p.bq(y,t.u_fade)}),lineSDF:(y,t)=>({u_translation:new p.c3(y,t.u_translation),u_ratio:new p.bq(y,t.u_ratio),u_device_pixel_ratio:new p.bq(y,t.u_device_pixel_ratio),u_units_to_pixels:new p.c3(y,t.u_units_to_pixels),u_image:new p.b_(y,t.u_image),u_mix:new p.bq(y,t.u_mix),u_tileratio:new p.bq(y,t.u_tileratio),u_crossfade_from:new p.bq(y,t.u_crossfade_from),u_crossfade_to:new p.bq(y,t.u_crossfade_to),u_lineatlas_width:new p.bq(y,t.u_lineatlas_width),u_lineatlas_height:new p.bq(y,t.u_lineatlas_height)}),lineGradientSDF:(y,t)=>({u_translation:new p.c3(y,t.u_translation),u_ratio:new p.bq(y,t.u_ratio),u_device_pixel_ratio:new p.bq(y,t.u_device_pixel_ratio),u_units_to_pixels:new p.c3(y,t.u_units_to_pixels),u_image:new p.b_(y,t.u_image),u_image_height:new p.bq(y,t.u_image_height),u_tileratio:new p.bq(y,t.u_tileratio),u_crossfade_from:new p.bq(y,t.u_crossfade_from),u_crossfade_to:new p.bq(y,t.u_crossfade_to),u_image_dash:new p.b_(y,t.u_image_dash),u_mix:new p.bq(y,t.u_mix),u_lineatlas_width:new p.bq(y,t.u_lineatlas_width),u_lineatlas_height:new p.bq(y,t.u_lineatlas_height)}),raster:(y,t)=>({u_tl_parent:new p.c3(y,t.u_tl_parent),u_scale_parent:new p.bq(y,t.u_scale_parent),u_buffer_scale:new p.bq(y,t.u_buffer_scale),u_fade_t:new p.bq(y,t.u_fade_t),u_opacity:new p.bq(y,t.u_opacity),u_image0:new p.b_(y,t.u_image0),u_image1:new p.b_(y,t.u_image1),u_brightness_low:new p.bq(y,t.u_brightness_low),u_brightness_high:new p.bq(y,t.u_brightness_high),u_saturation_factor:new p.bq(y,t.u_saturation_factor),u_contrast_factor:new p.bq(y,t.u_contrast_factor),u_spin_weights:new p.c2(y,t.u_spin_weights),u_coords_top:new p.c1(y,t.u_coords_top),u_coords_bottom:new p.c1(y,t.u_coords_bottom)}),symbolIcon:(y,t)=>({u_is_size_zoom_constant:new p.b_(y,t.u_is_size_zoom_constant),u_is_size_feature_constant:new p.b_(y,t.u_is_size_feature_constant),u_size_t:new p.bq(y,t.u_size_t),u_size:new p.bq(y,t.u_size),u_camera_to_center_distance:new p.bq(y,t.u_camera_to_center_distance),u_pitch:new p.bq(y,t.u_pitch),u_rotate_symbol:new p.b_(y,t.u_rotate_symbol),u_aspect_ratio:new p.bq(y,t.u_aspect_ratio),u_fade_change:new p.bq(y,t.u_fade_change),u_label_plane_matrix:new p.c0(y,t.u_label_plane_matrix),u_coord_matrix:new p.c0(y,t.u_coord_matrix),u_is_text:new p.b_(y,t.u_is_text),u_pitch_with_map:new p.b_(y,t.u_pitch_with_map),u_is_along_line:new p.b_(y,t.u_is_along_line),u_is_variable_anchor:new p.b_(y,t.u_is_variable_anchor),u_texsize:new p.c3(y,t.u_texsize),u_texture:new p.b_(y,t.u_texture),u_translation:new p.c3(y,t.u_translation),u_pitched_scale:new p.bq(y,t.u_pitched_scale)}),symbolSDF:(y,t)=>({u_is_size_zoom_constant:new p.b_(y,t.u_is_size_zoom_constant),u_is_size_feature_constant:new p.b_(y,t.u_is_size_feature_constant),u_size_t:new p.bq(y,t.u_size_t),u_size:new p.bq(y,t.u_size),u_camera_to_center_distance:new p.bq(y,t.u_camera_to_center_distance),u_pitch:new p.bq(y,t.u_pitch),u_rotate_symbol:new p.b_(y,t.u_rotate_symbol),u_aspect_ratio:new p.bq(y,t.u_aspect_ratio),u_fade_change:new p.bq(y,t.u_fade_change),u_label_plane_matrix:new p.c0(y,t.u_label_plane_matrix),u_coord_matrix:new p.c0(y,t.u_coord_matrix),u_is_text:new p.b_(y,t.u_is_text),u_pitch_with_map:new p.b_(y,t.u_pitch_with_map),u_is_along_line:new p.b_(y,t.u_is_along_line),u_is_variable_anchor:new p.b_(y,t.u_is_variable_anchor),u_texsize:new p.c3(y,t.u_texsize),u_texture:new p.b_(y,t.u_texture),u_gamma_scale:new p.bq(y,t.u_gamma_scale),u_device_pixel_ratio:new p.bq(y,t.u_device_pixel_ratio),u_is_halo:new p.b_(y,t.u_is_halo),u_translation:new p.c3(y,t.u_translation),u_pitched_scale:new p.bq(y,t.u_pitched_scale)}),symbolTextAndIcon:(y,t)=>({u_is_size_zoom_constant:new p.b_(y,t.u_is_size_zoom_constant),u_is_size_feature_constant:new p.b_(y,t.u_is_size_feature_constant),u_size_t:new p.bq(y,t.u_size_t),u_size:new p.bq(y,t.u_size),u_camera_to_center_distance:new p.bq(y,t.u_camera_to_center_distance),u_pitch:new p.bq(y,t.u_pitch),u_rotate_symbol:new p.b_(y,t.u_rotate_symbol),u_aspect_ratio:new p.bq(y,t.u_aspect_ratio),u_fade_change:new p.bq(y,t.u_fade_change),u_label_plane_matrix:new p.c0(y,t.u_label_plane_matrix),u_coord_matrix:new p.c0(y,t.u_coord_matrix),u_is_text:new p.b_(y,t.u_is_text),u_pitch_with_map:new p.b_(y,t.u_pitch_with_map),u_is_along_line:new p.b_(y,t.u_is_along_line),u_is_variable_anchor:new p.b_(y,t.u_is_variable_anchor),u_texsize:new p.c3(y,t.u_texsize),u_texsize_icon:new p.c3(y,t.u_texsize_icon),u_texture:new p.b_(y,t.u_texture),u_texture_icon:new p.b_(y,t.u_texture_icon),u_gamma_scale:new p.bq(y,t.u_gamma_scale),u_device_pixel_ratio:new p.bq(y,t.u_device_pixel_ratio),u_is_halo:new p.b_(y,t.u_is_halo),u_translation:new p.c3(y,t.u_translation),u_pitched_scale:new p.bq(y,t.u_pitched_scale)}),background:(y,t)=>({u_opacity:new p.bq(y,t.u_opacity),u_color:new p.b$(y,t.u_color)}),backgroundPattern:(y,t)=>({u_opacity:new p.bq(y,t.u_opacity),u_image:new p.b_(y,t.u_image),u_pattern_tl_a:new p.c3(y,t.u_pattern_tl_a),u_pattern_br_a:new p.c3(y,t.u_pattern_br_a),u_pattern_tl_b:new p.c3(y,t.u_pattern_tl_b),u_pattern_br_b:new p.c3(y,t.u_pattern_br_b),u_texsize:new p.c3(y,t.u_texsize),u_mix:new p.bq(y,t.u_mix),u_pattern_size_a:new p.c3(y,t.u_pattern_size_a),u_pattern_size_b:new p.c3(y,t.u_pattern_size_b),u_scale_a:new p.bq(y,t.u_scale_a),u_scale_b:new p.bq(y,t.u_scale_b),u_pixel_coord_upper:new p.c3(y,t.u_pixel_coord_upper),u_pixel_coord_lower:new p.c3(y,t.u_pixel_coord_lower),u_tile_units_to_pixels:new p.bq(y,t.u_tile_units_to_pixels)}),terrain:(y,t)=>({u_texture:new p.b_(y,t.u_texture),u_ele_delta:new p.bq(y,t.u_ele_delta),u_fog_matrix:new p.c0(y,t.u_fog_matrix),u_fog_color:new p.b$(y,t.u_fog_color),u_fog_ground_blend:new p.bq(y,t.u_fog_ground_blend),u_fog_ground_blend_opacity:new p.bq(y,t.u_fog_ground_blend_opacity),u_horizon_color:new p.b$(y,t.u_horizon_color),u_horizon_fog_blend:new p.bq(y,t.u_horizon_fog_blend),u_is_globe_mode:new p.bq(y,t.u_is_globe_mode)}),terrainDepth:(y,t)=>({u_ele_delta:new p.bq(y,t.u_ele_delta)}),terrainCoords:(y,t)=>({u_texture:new p.b_(y,t.u_texture),u_terrain_coords_id:new p.bq(y,t.u_terrain_coords_id),u_ele_delta:new p.bq(y,t.u_ele_delta)}),projectionErrorMeasurement:(y,t)=>({u_input:new p.bq(y,t.u_input),u_output_expected:new p.bq(y,t.u_output_expected)}),atmosphere:(y,t)=>({u_sun_pos:new p.c2(y,t.u_sun_pos),u_atmosphere_blend:new p.bq(y,t.u_atmosphere_blend),u_globe_position:new p.c2(y,t.u_globe_position),u_globe_radius:new p.bq(y,t.u_globe_radius),u_inv_proj_matrix:new p.c0(y,t.u_inv_proj_matrix)}),sky:(y,t)=>({u_sky_color:new p.b$(y,t.u_sky_color),u_horizon_color:new p.b$(y,t.u_horizon_color),u_horizon:new p.c3(y,t.u_horizon),u_horizon_normal:new p.c3(y,t.u_horizon_normal),u_sky_horizon_blend:new p.bq(y,t.u_sky_horizon_blend),u_sky_blend:new p.bq(y,t.u_sky_blend)})};class el{constructor(t,n,h){this.context=t;const f=t.gl;this.buffer=f.createBuffer(),this.dynamicDraw=!!h,this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),f.bufferData(f.ELEMENT_ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?f.DYNAMIC_DRAW:f.STATIC_DRAW),this.dynamicDraw||delete n.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){const n=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),n.bufferSubData(n.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const Ml={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class tl{constructor(t,n,h,f){this.length=n.length,this.attributes=h,this.itemSize=n.bytesPerElement,this.dynamicDraw=f,this.context=t;const x=t.gl;this.buffer=x.createBuffer(),t.bindVertexBuffer.set(this.buffer),x.bufferData(x.ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?x.DYNAMIC_DRAW:x.STATIC_DRAW),this.dynamicDraw||delete n.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(t){if(t.length!==this.length)throw new Error(`Length of new data is ${t.length}, which doesn't match current length of ${this.length}`);const n=this.context.gl;this.bind(),n.bufferSubData(n.ARRAY_BUFFER,0,t.arrayBuffer)}enableAttributes(t,n){for(let h=0;h<this.attributes.length;h++){const f=n.attributes[this.attributes[h].name];f!==void 0&&t.enableVertexAttribArray(f)}}setVertexAttribPointers(t,n,h){for(let f=0;f<this.attributes.length;f++){const x=this.attributes[f],T=n.attributes[x.name];T!==void 0&&t.vertexAttribPointer(T,x.components,t[Ml[x.type]],!1,this.itemSize,x.offset+this.itemSize*(h||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class Ii{constructor(t){this.gl=t.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(t){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class sn extends Ii{getDefault(){return p.bp.transparent}set(t){const n=this.current;(t.r!==n.r||t.g!==n.g||t.b!==n.b||t.a!==n.a||this.dirty)&&(this.gl.clearColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class $r extends Ii{getDefault(){return 1}set(t){(t!==this.current||this.dirty)&&(this.gl.clearDepth(t),this.current=t,this.dirty=!1)}}class il extends Ii{getDefault(){return 0}set(t){(t!==this.current||this.dirty)&&(this.gl.clearStencil(t),this.current=t,this.dirty=!1)}}class Xs extends Ii{getDefault(){return[!0,!0,!0,!0]}set(t){const n=this.current;(t[0]!==n[0]||t[1]!==n[1]||t[2]!==n[2]||t[3]!==n[3]||this.dirty)&&(this.gl.colorMask(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class Xo extends Ii{getDefault(){return!0}set(t){(t!==this.current||this.dirty)&&(this.gl.depthMask(t),this.current=t,this.dirty=!1)}}class _a extends Ii{getDefault(){return 255}set(t){(t!==this.current||this.dirty)&&(this.gl.stencilMask(t),this.current=t,this.dirty=!1)}}class ga extends Ii{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(t){const n=this.current;(t.func!==n.func||t.ref!==n.ref||t.mask!==n.mask||this.dirty)&&(this.gl.stencilFunc(t.func,t.ref,t.mask),this.current=t,this.dirty=!1)}}class fn extends Ii{getDefault(){const t=this.gl;return[t.KEEP,t.KEEP,t.KEEP]}set(t){const n=this.current;(t[0]!==n[0]||t[1]!==n[1]||t[2]!==n[2]||this.dirty)&&(this.gl.stencilOp(t[0],t[1],t[2]),this.current=t,this.dirty=!1)}}class ql extends Ii{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;t?n.enable(n.STENCIL_TEST):n.disable(n.STENCIL_TEST),this.current=t,this.dirty=!1}}class Ko extends Ii{getDefault(){return[0,1]}set(t){const n=this.current;(t[0]!==n[0]||t[1]!==n[1]||this.dirty)&&(this.gl.depthRange(t[0],t[1]),this.current=t,this.dirty=!1)}}class rl extends Ii{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;t?n.enable(n.DEPTH_TEST):n.disable(n.DEPTH_TEST),this.current=t,this.dirty=!1}}class Rs extends Ii{getDefault(){return this.gl.LESS}set(t){(t!==this.current||this.dirty)&&(this.gl.depthFunc(t),this.current=t,this.dirty=!1)}}class Fa extends Ii{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;t?n.enable(n.BLEND):n.disable(n.BLEND),this.current=t,this.dirty=!1}}class es extends Ii{getDefault(){const t=this.gl;return[t.ONE,t.ZERO]}set(t){const n=this.current;(t[0]!==n[0]||t[1]!==n[1]||this.dirty)&&(this.gl.blendFunc(t[0],t[1]),this.current=t,this.dirty=!1)}}class ya extends Ii{getDefault(){return p.bp.transparent}set(t){const n=this.current;(t.r!==n.r||t.g!==n.g||t.b!==n.b||t.a!==n.a||this.dirty)&&(this.gl.blendColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class Oa extends Ii{getDefault(){return this.gl.FUNC_ADD}set(t){(t!==this.current||this.dirty)&&(this.gl.blendEquation(t),this.current=t,this.dirty=!1)}}class va extends Ii{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;t?n.enable(n.CULL_FACE):n.disable(n.CULL_FACE),this.current=t,this.dirty=!1}}class xa extends Ii{getDefault(){return this.gl.BACK}set(t){(t!==this.current||this.dirty)&&(this.gl.cullFace(t),this.current=t,this.dirty=!1)}}class co extends Ii{getDefault(){return this.gl.CCW}set(t){(t!==this.current||this.dirty)&&(this.gl.frontFace(t),this.current=t,this.dirty=!1)}}class ba extends Ii{getDefault(){return null}set(t){(t!==this.current||this.dirty)&&(this.gl.useProgram(t),this.current=t,this.dirty=!1)}}class nl extends Ii{getDefault(){return this.gl.TEXTURE0}set(t){(t!==this.current||this.dirty)&&(this.gl.activeTexture(t),this.current=t,this.dirty=!1)}}class gi extends Ii{getDefault(){const t=this.gl;return[0,0,t.drawingBufferWidth,t.drawingBufferHeight]}set(t){const n=this.current;(t[0]!==n[0]||t[1]!==n[1]||t[2]!==n[2]||t[3]!==n[3]||this.dirty)&&(this.gl.viewport(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class sl extends Ii{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.bindFramebuffer(n.FRAMEBUFFER,t),this.current=t,this.dirty=!1}}class El extends Ii{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.bindRenderbuffer(n.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class Fs extends Ii{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.bindTexture(n.TEXTURE_2D,t),this.current=t,this.dirty=!1}}class Jo extends Ii{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.bindBuffer(n.ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class Hl extends Ii{getDefault(){return null}set(t){const n=this.gl;n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class Wl extends Ii{getDefault(){return null}set(t){var n;if(t===this.current&&!this.dirty)return;const h=this.gl;Xn(h)?h.bindVertexArray(t):(n=h.getExtension("OES_vertex_array_object"))===null||n===void 0||n.bindVertexArrayOES(t),this.current=t,this.dirty=!1}}class Ql extends Ii{getDefault(){return 4}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.pixelStorei(n.UNPACK_ALIGNMENT,t),this.current=t,this.dirty=!1}}class $l extends Ii{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t),this.current=t,this.dirty=!1}}class ol extends Ii{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,t),this.current=t,this.dirty=!1}}class ds extends Ii{constructor(t,n){super(t),this.context=t,this.parent=n}getDefault(){return null}}class u extends ds{setDirty(){this.dirty=!0}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const n=this.gl;n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,t,0),this.current=t,this.dirty=!1}}class v extends ds{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const n=this.gl;n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class E extends ds{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const n=this.gl;n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,t),this.current=t,this.dirty=!1}}const R="Framebuffer is not complete";class q{constructor(t,n,h,f,x){this.context=t,this.width=n,this.height=h;const T=t.gl,C=this.framebuffer=T.createFramebuffer();if(this.colorAttachment=new u(t,C),f)this.depthAttachment=x?new E(t,C):new v(t,C);else if(x)throw new Error("Stencil cannot be set without depth");if(T.checkFramebufferStatus(T.FRAMEBUFFER)!==T.FRAMEBUFFER_COMPLETE)throw new Error(R)}destroy(){const t=this.context.gl,n=this.colorAttachment.get();if(n&&t.deleteTexture(n),this.depthAttachment){const h=this.depthAttachment.get();h&&t.deleteRenderbuffer(h)}t.deleteFramebuffer(this.framebuffer)}}class ne{constructor(t){var n,h;if(this.gl=t,this.clearColor=new sn(this),this.clearDepth=new $r(this),this.clearStencil=new il(this),this.colorMask=new Xs(this),this.depthMask=new Xo(this),this.stencilMask=new _a(this),this.stencilFunc=new ga(this),this.stencilOp=new fn(this),this.stencilTest=new ql(this),this.depthRange=new Ko(this),this.depthTest=new rl(this),this.depthFunc=new Rs(this),this.blend=new Fa(this),this.blendFunc=new es(this),this.blendColor=new ya(this),this.blendEquation=new Oa(this),this.cullFace=new va(this),this.cullFaceSide=new xa(this),this.frontFace=new co(this),this.program=new ba(this),this.activeTexture=new nl(this),this.viewport=new gi(this),this.bindFramebuffer=new sl(this),this.bindRenderbuffer=new El(this),this.bindTexture=new Fs(this),this.bindVertexBuffer=new Jo(this),this.bindElementBuffer=new Hl(this),this.bindVertexArray=new Wl(this),this.pixelStoreUnpack=new Ql(this),this.pixelStoreUnpackPremultiplyAlpha=new $l(this),this.pixelStoreUnpackFlipY=new ol(this),this.extTextureFilterAnisotropic=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_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),Xn(t)){this.HALF_FLOAT=t.HALF_FLOAT;const f=t.getExtension("EXT_color_buffer_half_float");this.RGBA16F=(n=t.RGBA16F)!==null&&n!==void 0?n:f==null?void 0:f.RGBA16F_EXT,this.RGB16F=(h=t.RGB16F)!==null&&h!==void 0?h:f==null?void 0:f.RGB16F_EXT,t.getExtension("EXT_color_buffer_float")}else{t.getExtension("EXT_color_buffer_half_float"),t.getExtension("OES_texture_half_float_linear");const f=t.getExtension("OES_texture_half_float");this.HALF_FLOAT=f==null?void 0:f.HALF_FLOAT_OES}}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArray.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(t,n){return new el(this,t,n)}createVertexBuffer(t,n,h){return new tl(this,t,n,h)}createRenderbuffer(t,n,h){const f=this.gl,x=f.createRenderbuffer();return this.bindRenderbuffer.set(x),f.renderbufferStorage(f.RENDERBUFFER,t,n,h),this.bindRenderbuffer.set(null),x}createFramebuffer(t,n,h,f){return new q(this,t,n,h,f)}clear({color:t,depth:n,stencil:h}){const f=this.gl;let x=0;t&&(x|=f.COLOR_BUFFER_BIT,this.clearColor.set(t),this.colorMask.set([!0,!0,!0,!0])),n!==void 0&&(x|=f.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(n),this.depthMask.set(!0)),h!==void 0&&(x|=f.STENCIL_BUFFER_BIT,this.clearStencil.set(h),this.stencilMask.set(255)),f.clear(x)}setCullFace(t){t.enable===!1?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){p.bR(t.blendFunction,bi.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(t.blendFunction),this.blendColor.set(t.blendColor)),this.colorMask.set(t.mask)}createVertexArray(){var t;return Xn(this.gl)?this.gl.createVertexArray():(t=this.gl.getExtension("OES_vertex_array_object"))===null||t===void 0?void 0:t.createVertexArrayOES()}deleteVertexArray(t){var n;return Xn(this.gl)?this.gl.deleteVertexArray(t):(n=this.gl.getExtension("OES_vertex_array_object"))===null||n===void 0?void 0:n.deleteVertexArrayOES(t)}unbindVAO(){this.bindVertexArray.set(null)}}let Ee;function Ze(y,t,n,h,f){const x=y.context,T=y.transform,C=x.gl,D=y.useProgram("collisionBox"),B=[];let N=0,G=0;for(let ce=0;ce<h.length;ce++){const ye=h[ce],Pe=t.getTile(ye).getBucket(n);if(!Pe)continue;const _e=f?Pe.textCollisionBox:Pe.iconCollisionBox,we=Pe.collisionCircleArray;we.length>0&&(B.push({circleArray:we,circleOffset:G,coord:ye}),N+=we.length/4,G=N),_e&&D.draw(x,C.LINES,ri.disabled,Ci.disabled,y.colorModeForRenderPass(),wi.disabled,Qs(y.transform),y.style.map.terrain&&y.style.map.terrain.getTerrainData(ye),T.getProjectionData({overscaledTileID:ye,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),n.id,_e.layoutVertexBuffer,_e.indexBuffer,_e.segments,null,y.transform.zoom,null,null,_e.collisionVertexBuffer)}if(!f||!B.length)return;const U=y.useProgram("collisionCircle"),$=new p.ca;$.resize(4*N),$._trim();let ie=0;for(const ce of B)for(let ye=0;ye<ce.circleArray.length/4;ye++){const Pe=4*ye,_e=ce.circleArray[Pe+0],we=ce.circleArray[Pe+1],Ce=ce.circleArray[Pe+2],be=ce.circleArray[Pe+3];$.emplace(ie++,_e,we,Ce,be,0),$.emplace(ie++,_e,we,Ce,be,1),$.emplace(ie++,_e,we,Ce,be,2),$.emplace(ie++,_e,we,Ce,be,3)}(!Ee||Ee.length<2*N)&&(Ee=(function(ce){const ye=2*ce,Pe=new p.cc;Pe.resize(ye),Pe._trim();for(let _e=0;_e<ye;_e++){const we=6*_e;Pe.uint16[we+0]=4*_e+0,Pe.uint16[we+1]=4*_e+1,Pe.uint16[we+2]=4*_e+2,Pe.uint16[we+3]=4*_e+2,Pe.uint16[we+4]=4*_e+3,Pe.uint16[we+5]=4*_e+0}return Pe})(N));const he=x.createIndexBuffer(Ee,!0),Ae=x.createVertexBuffer($,p.cb.members,!0);for(const ce of B){const ye=Tl(y.transform);U.draw(x,C.TRIANGLES,ri.disabled,Ci.disabled,y.colorModeForRenderPass(),wi.disabled,ye,y.style.map.terrain&&y.style.map.terrain.getTerrainData(ce.coord),null,n.id,Ae,he,p.aX.simpleSegment(0,2*ce.circleOffset,ce.circleArray.length,ce.circleArray.length/2),null,y.transform.zoom,null,null,null)}Ae.destroy(),he.destroy()}const tt=p.ar(new Float32Array(16));function gt(y,t,n,h,f,x){const{horizontalAlign:T,verticalAlign:C}=p.aS(y);return new p.P((-(T-.5)*t/f+h[0])*x,(-(C-.5)*n/f+h[1])*x)}function Rt(y,t,n,h,f,x){const T=t.tileAnchorPoint.add(new p.P(t.translation[0],t.translation[1]));if(t.pitchWithMap){let C=h.mult(x);n||(C=C.rotate(-f));const D=T.add(C);return ni(D.x,D.y,t.pitchedLabelPlaneMatrix,t.getElevation).point}if(n){const C=Ft(t.tileAnchorPoint.x+1,t.tileAnchorPoint.y,t).point.sub(y),D=Math.atan(C.y/C.x)+(C.x<0?Math.PI:0);return y.add(h.rotate(D))}return y.add(h)}function Jt(y,t,n,h,f,x,T,C,D,B,N,G){const U=y.text.placedSymbolArray,$=y.text.dynamicLayoutVertexArray,ie=y.icon.dynamicLayoutVertexArray,he={};$.clear();for(let Ae=0;Ae<U.length;Ae++){const ce=U.get(Ae),ye=ce.hidden||!ce.crossTileID||y.allowVerticalPlacement&&!ce.placedOrientation?null:h[ce.crossTileID];if(ye){const Pe=new p.P(ce.anchorX,ce.anchorY),_e={getElevation:G,width:f.width,height:f.height,pitchedLabelPlaneMatrix:x,pitchWithMap:n,transform:f,tileAnchorPoint:Pe,translation:B,unwrappedTileID:N},we=n?qt(Pe.x,Pe.y,_e):Ft(Pe.x,Pe.y,_e),Ce=Ea(f.cameraToCenterDistance,we.signedDistanceFromCamera);let be=p.aA(y.textSizeData,C,ce)*Ce/p.aM;n&&(be*=y.tilePixelRatio/T);const{width:Le,height:Ke,anchor:He,textOffset:$e,textBoxScale:Ye}=ye,xt=gt(He,Le,Ke,$e,Ye,be),wt=f.getPitchedTextCorrection(Pe.x+B[0],Pe.y+B[1],N),pt=Rt(we.point,_e,t,xt,-f.bearingInRadians,wt),Pt=y.allowVerticalPlacement&&ce.placedOrientation===p.az.vertical?Math.PI/2:0;for(let mi=0;mi<ce.numGlyphs;mi++)p.aG($,pt,Pt);D&&ce.associatedIconIndex>=0&&(he[ce.associatedIconIndex]={shiftedAnchor:pt,angle:Pt})}else Xi(ce.numGlyphs,$)}if(D){ie.clear();const Ae=y.icon.placedSymbolArray;for(let ce=0;ce<Ae.length;ce++){const ye=Ae.get(ce);if(ye.hidden)Xi(ye.numGlyphs,ie);else{const Pe=he[ce];if(Pe)for(let _e=0;_e<ye.numGlyphs;_e++)p.aG(ie,Pe.shiftedAnchor,Pe.angle);else Xi(ye.numGlyphs,ie)}}y.icon.dynamicLayoutVertexBuffer.updateData(ie)}y.text.dynamicLayoutVertexBuffer.updateData($)}function Ti(y,t,n){return n.iconsInText&&t?"symbolTextAndIcon":y?"symbolSDF":"symbolIcon"}function Zr(y,t,n,h,f,x,T,C,D,B,N,G,U){const $=y.context,ie=$.gl,he=y.transform,Ae=C==="map",ce=D==="map",ye=C!=="viewport"&&n.layout.get("symbol-placement")!=="point",Pe=Ae&&!ce&&!ye,_e=!n.layout.get("symbol-sort-key").isConstant();let we=!1;const Ce=y.getDepthModeForSublayer(0,ri.ReadOnly),be=n._unevaluatedLayout.hasValue("text-variable-anchor")||n._unevaluatedLayout.hasValue("text-variable-anchor-offset"),Le=[],Ke=he.getCircleRadiusCorrection();for(const He of h){const $e=t.getTile(He),Ye=$e.getBucket(n);if(!Ye)continue;const xt=f?Ye.text:Ye.icon;if(!xt||!xt.segments.get().length||!xt.hasVisibleVertices)continue;const wt=xt.programConfigurations.get(n.id),pt=f||Ye.sdfIcons,Pt=f?Ye.textSizeData:Ye.iconSizeData,mi=ce||he.pitch!==0,sr=y.useProgram(Ti(pt,f,Ye),wt),Dr=p.ay(Pt,he.zoom),mr=y.style.map.terrain&&y.style.map.terrain.getTerrainData(He);let Rr,_r,Yr,Fr,rs=[0,0],dn=null;if(f)_r=$e.glyphAtlasTexture,Yr=ie.LINEAR,Rr=$e.glyphAtlasTexture.size,Ye.iconsInText&&(rs=$e.imageAtlasTexture.size,dn=$e.imageAtlasTexture,Fr=mi||y.options.rotating||y.options.zooming||Pt.kind==="composite"||Pt.kind==="camera"?ie.LINEAR:ie.NEAREST);else{const Tr=n.layout.get("icon-size").constantOr(0)!==1||Ye.iconsNeedLinear;_r=$e.imageAtlasTexture,Yr=pt||y.options.rotating||y.options.zooming||Tr||mi?ie.LINEAR:ie.NEAREST,Rr=$e.imageAtlasTexture.size}const an=p.aN($e,1,y.transform.zoom),ms=fi(Ae,y.transform,an),cl=p.N();p.aB(cl,ms);const Va=di(ce,Ae,y.transform,an),wa=p.aO(he,$e,x,T),eo=he.getProjectionData({overscaledTileID:He,applyGlobeMatrix:!U,applyTerrainMatrix:!0}),kl=be&&Ye.hasTextData(),Mu=n.layout.get("icon-text-fit")!=="none"&&kl&&Ye.hasIconData();if(ye){const Tr=y.style.map.terrain?(Vn,jn)=>y.style.map.terrain.getElevation(He,Vn,jn):null,gr=n.layout.get("text-rotation-alignment")==="map";kn(Ye,y,f,ms,cl,ce,B,gr,He.toUnwrapped(),he.width,he.height,wa,Tr)}const zl=f&&be||Mu,zo=ye||zl?tt:ce?ms:y.transform.clipSpaceToPixelsMatrix,Ta=pt&&n.paint.get(f?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let na;na=pt?Ye.iconsInText?Ys(Pt.kind,Dr,Pe,ce,ye,zl,y,zo,Va,wa,Rr,rs,Ke):Yo(Pt.kind,Dr,Pe,ce,ye,zl,y,zo,Va,wa,f,Rr,0,Ke):fs(Pt.kind,Dr,Pe,ce,ye,zl,y,zo,Va,wa,f,Rr,Ke);const sa={program:sr,buffers:xt,uniformValues:na,projectionData:eo,atlasTexture:_r,atlasTextureIcon:dn,atlasInterpolation:Yr,atlasInterpolationIcon:Fr,isSDF:pt,hasHalo:Ta};if(_e&&Ye.canOverlap){we=!0;const Tr=xt.segments.get();for(const gr of Tr)Le.push({segments:new p.aX([gr]),sortKey:gr.sortKey,state:sa,terrainData:mr})}else Le.push({segments:xt.segments,sortKey:0,state:sa,terrainData:mr})}we&&Le.sort(((He,$e)=>He.sortKey-$e.sortKey));for(const He of Le){const $e=He.state;if($.activeTexture.set(ie.TEXTURE0),$e.atlasTexture.bind($e.atlasInterpolation,ie.CLAMP_TO_EDGE),$e.atlasTextureIcon&&($.activeTexture.set(ie.TEXTURE1),$e.atlasTextureIcon&&$e.atlasTextureIcon.bind($e.atlasInterpolationIcon,ie.CLAMP_TO_EDGE)),$e.isSDF){const Ye=$e.uniformValues;$e.hasHalo&&(Ye.u_is_halo=1,Br($e.buffers,He.segments,n,y,$e.program,Ce,N,G,Ye,$e.projectionData,He.terrainData)),Ye.u_is_halo=0}Br($e.buffers,He.segments,n,y,$e.program,Ce,N,G,$e.uniformValues,$e.projectionData,He.terrainData)}}function Br(y,t,n,h,f,x,T,C,D,B,N){const G=h.context;f.draw(G,G.gl.TRIANGLES,x,T,C,wi.backCCW,D,N,B,n.id,y.layoutVertexBuffer,y.indexBuffer,t,n.paint,h.transform.zoom,y.programConfigurations.get(n.id),y.dynamicLayoutVertexBuffer,y.opacityVertexBuffer)}function ps(y,t,n,h,f){const x=y.context,T=x.gl,C=Ci.disabled,D=new bi([T.ONE,T.ONE],p.bp.transparent,[!0,!0,!0,!0]),B=t.getBucket(n);if(!B)return;const N=h.key;let G=n.heatmapFbos.get(N);G||(G=Ks(x,t.tileSize,t.tileSize),n.heatmapFbos.set(N,G)),x.bindFramebuffer.set(G.framebuffer),x.viewport.set([0,0,t.tileSize,t.tileSize]),x.clear({color:p.bp.transparent});const U=B.programConfigurations.get(n.id),$=y.useProgram("heatmap",U,!f),ie=y.transform.getProjectionData({overscaledTileID:t.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),he=y.style.map.terrain.getTerrainData(h);$.draw(x,T.TRIANGLES,ri.disabled,C,D,wi.disabled,uo(t,y.transform.zoom,n.paint.get("heatmap-intensity"),1),he,ie,n.id,B.layoutVertexBuffer,B.indexBuffer,B.segments,n.paint,y.transform.zoom,U)}function On(y,t,n,h,f){const x=y.context,T=x.gl,C=y.transform;x.setColorMode(y.colorModeForRenderPass());const D=al(x,t),B=n.key,N=t.heatmapFbos.get(B);if(!N)return;x.activeTexture.set(T.TEXTURE0),T.bindTexture(T.TEXTURE_2D,N.colorAttachment.get()),x.activeTexture.set(T.TEXTURE1),D.bind(T.LINEAR,T.CLAMP_TO_EDGE);const G=C.getProjectionData({overscaledTileID:n,applyTerrainMatrix:f,applyGlobeMatrix:!h});y.useProgram("heatmapTexture").draw(x,T.TRIANGLES,ri.disabled,Ci.disabled,y.colorModeForRenderPass(),wi.disabled,Ul(y,t,0,1),null,G,t.id,y.rasterBoundsBuffer,y.quadTriangleIndexBuffer,y.rasterBoundsSegments,t.paint,C.zoom),N.destroy(),t.heatmapFbos.delete(B)}function Ks(y,t,n){var h,f;const x=y.gl,T=x.createTexture();x.bindTexture(x.TEXTURE_2D,T),x.texParameteri(x.TEXTURE_2D,x.TEXTURE_WRAP_S,x.CLAMP_TO_EDGE),x.texParameteri(x.TEXTURE_2D,x.TEXTURE_WRAP_T,x.CLAMP_TO_EDGE),x.texParameteri(x.TEXTURE_2D,x.TEXTURE_MIN_FILTER,x.LINEAR),x.texParameteri(x.TEXTURE_2D,x.TEXTURE_MAG_FILTER,x.LINEAR);const C=(h=y.HALF_FLOAT)!==null&&h!==void 0?h:x.UNSIGNED_BYTE,D=(f=y.RGBA16F)!==null&&f!==void 0?f:x.RGBA;x.texImage2D(x.TEXTURE_2D,0,D,t,n,0,x.RGBA,C,null);const B=y.createFramebuffer(t,n,!1,!1);return B.colorAttachment.set(T),B}function al(y,t){return t.colorRampTexture||(t.colorRampTexture=new p.T(y,t.colorRamp,y.gl.RGBA)),t.colorRampTexture}function Yl(y,t,n,h,f,x,T,C){let D=256;if(f.stepInterpolant){const B=t.getSource().maxzoom,N=T.canonical.z===B?Math.ceil(1<<y.transform.maxZoom-T.canonical.z):1;D=p.an(p.ce(x.maxLineLength/p.a5*1024*N),256,n.maxTextureSize)}return C.gradient=p.cf({expression:f.gradientExpression(),evaluationKey:"lineProgress",resolution:D,image:C.gradient||void 0,clips:x.lineClipsArray}),C.texture?C.texture.update(C.gradient):C.texture=new p.T(n,C.gradient,h.RGBA),C.version=f.gradientVersion,C.texture}function Xl(y,t,n,h,f){y.activeTexture.set(t.TEXTURE0),n.imageAtlasTexture.bind(t.LINEAR,t.CLAMP_TO_EDGE),h.updatePaintBuffers(f)}function br(y,t,n,h,f,x){(f||y.lineAtlas.dirty)&&(t.activeTexture.set(n.TEXTURE0),y.lineAtlas.bind(t)),h.updatePaintBuffers(x)}function ea(y,t,n,h,f,x,T){const C=x.gradients[f.id];let D=C.texture;f.gradientVersion!==C.version&&(D=Yl(y,t,n,h,f,x,T,C)),n.activeTexture.set(h.TEXTURE0),D.bind(f.stepInterpolant?h.NEAREST:h.LINEAR,h.CLAMP_TO_EDGE)}function Nn(y,t,n,h,f,x,T,C,D){const B=x.gradients[f.id];let N=B.texture;f.gradientVersion!==B.version&&(N=Yl(y,t,n,h,f,x,T,B)),n.activeTexture.set(h.TEXTURE0),N.bind(f.stepInterpolant?h.NEAREST:h.LINEAR,h.CLAMP_TO_EDGE),n.activeTexture.set(h.TEXTURE1),y.lineAtlas.bind(n),C.updatePaintBuffers(D)}function pr(y,t,n,h,f){if(!n||!h||!h.imageAtlas)return;const x=h.imageAtlas.patternPositions;let T=x[n.to.toString()],C=x[n.from.toString()];if(!T&&C&&(T=C),!C&&T&&(C=T),!T||!C){const D=f.getPaintProperty(t);T=x[D],C=x[D]}T&&C&&y.setConstantPatternPositions(T,C)}function nr(y,t,n,h,f,x,T,C){const D=y.context.gl,B="fill-pattern",N=n.paint.get(B),G=N&&N.constantOr(1),U=n.getCrossfadeParameters();let $,ie,he,Ae,ce;const ye=y.transform,Pe=n.paint.get("fill-translate"),_e=n.paint.get("fill-translate-anchor");T?(ie=G&&!n.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",$=D.LINES):(ie=G?"fillPattern":"fill",$=D.TRIANGLES);const we=N.constantOr(null);for(const Ce of h){const be=t.getTile(Ce);if(G&&!be.patternsLoaded())continue;const Le=be.getBucket(n);if(!Le)continue;const Ke=Le.programConfigurations.get(n.id),He=y.useProgram(ie,Ke),$e=y.style.map.terrain&&y.style.map.terrain.getTerrainData(Ce);G&&(y.context.activeTexture.set(D.TEXTURE0),be.imageAtlasTexture.bind(D.LINEAR,D.CLAMP_TO_EDGE),Ke.updatePaintBuffers(U)),pr(Ke,B,we,be,n);const Ye=ye.getProjectionData({overscaledTileID:Ce,applyGlobeMatrix:!C,applyTerrainMatrix:!0}),xt=p.aO(ye,be,Pe,_e);if(T){Ae=Le.indexBuffer2,ce=Le.segments2;const pt=[D.drawingBufferWidth,D.drawingBufferHeight];he=ie==="fillOutlinePattern"&&G?Ws(y,U,be,pt,xt):Xa(pt,xt)}else Ae=Le.indexBuffer,ce=Le.segments,he=G?Hs(y,U,be,xt):{u_fill_translate:xt};const wt=y.stencilModeForClipping(Ce);He.draw(y.context,$,f,wt,x,wi.backCCW,he,$e,Ye,n.id,Le.layoutVertexBuffer,Ae,ce,n.paint,y.transform.zoom,Ke)}}function ll(y,t,n,h,f,x,T,C){const D=y.context,B=D.gl,N="fill-extrusion-pattern",G=n.paint.get(N),U=G.constantOr(1),$=n.getCrossfadeParameters(),ie=n.paint.get("fill-extrusion-opacity"),he=G.constantOr(null),Ae=y.transform;for(const ce of h){const ye=t.getTile(ce),Pe=ye.getBucket(n);if(!Pe)continue;const _e=y.style.map.terrain&&y.style.map.terrain.getTerrainData(ce),we=Pe.programConfigurations.get(n.id),Ce=y.useProgram(U?"fillExtrusionPattern":"fillExtrusion",we);U&&(y.context.activeTexture.set(B.TEXTURE0),ye.imageAtlasTexture.bind(B.LINEAR,B.CLAMP_TO_EDGE),we.updatePaintBuffers($));const be=Ae.getProjectionData({overscaledTileID:ce,applyGlobeMatrix:!C,applyTerrainMatrix:!0});pr(we,N,he,ye,n);const Le=p.aO(Ae,ye,n.paint.get("fill-extrusion-translate"),n.paint.get("fill-extrusion-translate-anchor")),Ke=n.paint.get("fill-extrusion-vertical-gradient"),He=U?wl(y,Ke,ie,Le,ce,$,ye):cs(y,Ke,ie,Le);Ce.draw(D,D.gl.TRIANGLES,f,x,T,wi.backCCW,He,_e,be,n.id,Pe.layoutVertexBuffer,Pe.indexBuffer,Pe.segments,n.paint,y.transform.zoom,we,y.style.map.terrain&&Pe.centroidVertexBuffer)}}function Co(y,t,n,h,f,x,T,C,D){var B;const N=y.style.projection,G=y.context,U=y.transform,$=G.gl,ie=[`#define NUM_ILLUMINATION_SOURCES ${n.paint.get("hillshade-highlight-color").values.length}`],he=y.useProgram("hillshade",null,!1,ie),Ae=!y.options.moving;for(const ce of h){const ye=t.getTile(ce),Pe=ye.fbo;if(!Pe)continue;const _e=N.getMeshFromTileID(G,ce.canonical,C,!0,"raster"),we=(B=y.style.map.terrain)===null||B===void 0?void 0:B.getTerrainData(ce);G.activeTexture.set($.TEXTURE0),$.bindTexture($.TEXTURE_2D,Pe.colorAttachment.get());const Ce=U.getProjectionData({overscaledTileID:ce,aligned:Ae,applyGlobeMatrix:!D,applyTerrainMatrix:!0});he.draw(G,$.TRIANGLES,x,f[ce.overscaledZ],T,wi.backCCW,ma(y,ye,n),we,Ce,n.id,_e.vertexBuffer,_e.indexBuffer,_e.segments)}}function Ao(y,t,n,h,f,x,T,C,D){var B;const N=y.style.projection,G=y.context,U=y.transform,$=G.gl,ie=y.useProgram("colorRelief"),he=!y.options.moving;let Ae=!0,ce=0;for(const ye of h){const Pe=t.getTile(ye),_e=Pe.dem;if(Ae){const He=$.getParameter($.MAX_TEXTURE_SIZE),{elevationTexture:$e,colorTexture:Ye}=n.getColorRampTextures(G,He,_e.getUnpackVector());G.activeTexture.set($.TEXTURE1),$e.bind($.NEAREST,$.CLAMP_TO_EDGE),G.activeTexture.set($.TEXTURE4),Ye.bind($.LINEAR,$.CLAMP_TO_EDGE),Ae=!1,ce=$e.size[0]}if(!_e||!_e.data)continue;const we=_e.stride,Ce=_e.getPixels();if(G.activeTexture.set($.TEXTURE0),G.pixelStoreUnpackPremultiplyAlpha.set(!1),Pe.demTexture=Pe.demTexture||y.getTileTexture(we),Pe.demTexture){const He=Pe.demTexture;He.update(Ce,{premultiply:!1}),He.bind($.LINEAR,$.CLAMP_TO_EDGE)}else Pe.demTexture=new p.T(G,Ce,$.RGBA,{premultiply:!1}),Pe.demTexture.bind($.LINEAR,$.CLAMP_TO_EDGE);const be=N.getMeshFromTileID(G,ye.canonical,C,!0,"raster"),Le=(B=y.style.map.terrain)===null||B===void 0?void 0:B.getTerrainData(ye),Ke=U.getProjectionData({overscaledTileID:ye,aligned:he,applyGlobeMatrix:!D,applyTerrainMatrix:!0});ie.draw(G,$.TRIANGLES,x,f[ye.overscaledZ],T,wi.backCCW,Ka(n,Pe.dem,ce),Le,Ke,n.id,be.vertexBuffer,be.indexBuffer,be.segments)}}const Ur=[new p.P(0,0),new p.P(p.a5,0),new p.P(p.a5,p.a5),new p.P(0,p.a5)];function ta(y,t,n,h,f,x,T,C,D=!1,B=!1){const N=h[h.length-1].overscaledZ,G=y.context,U=G.gl,$=y.useProgram("raster"),ie=y.transform,he=y.style.projection,Ae=y.colorModeForRenderPass(),ce=!y.options.moving,ye=n.paint.get("raster-opacity"),Pe=n.paint.get("raster-resampling"),_e=n.paint.get("raster-fade-duration"),we=!!y.style.map.terrain;for(const Ce of h){const be=y.getDepthModeForSublayer(Ce.overscaledZ-N,ye===1?ri.ReadWrite:ri.ReadOnly,U.LESS),Le=t.getTile(Ce),Ke=Pe==="nearest"?U.NEAREST:U.LINEAR;G.activeTexture.set(U.TEXTURE0),Le.texture.bind(Ke,U.CLAMP_TO_EDGE,U.LINEAR_MIPMAP_NEAREST),G.activeTexture.set(U.TEXTURE1);const{parentTile:He,parentScaleBy:$e,parentTopLeft:Ye,fadeValues:xt}=Kl(Le,t,_e,we);Le.fadeOpacity=xt.tileOpacity,He?(He.fadeOpacity=xt.parentTileOpacity,He.texture.bind(Ke,U.CLAMP_TO_EDGE,U.LINEAR_MIPMAP_NEAREST)):Le.texture.bind(Ke,U.CLAMP_TO_EDGE,U.LINEAR_MIPMAP_NEAREST),Le.texture.useMipmap&&G.extTextureFilterAnisotropic&&y.transform.pitch>20&&U.texParameterf(U.TEXTURE_2D,G.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,G.extTextureFilterAnisotropicMax);const wt=y.style.map.terrain&&y.style.map.terrain.getTerrainData(Ce),pt=ie.getProjectionData({overscaledTileID:Ce,aligned:ce,applyGlobeMatrix:!B,applyTerrainMatrix:!0}),Pt=$s(Ye,$e,xt.fadeMix,n,C),mi=he.getMeshFromTileID(G,Ce.canonical,x,T,"raster");$.draw(G,U.TRIANGLES,be,f?f[Ce.overscaledZ]:Ci.disabled,Ae,D?wi.frontCCW:wi.backCCW,Pt,wt,pt,n.id,mi.vertexBuffer,mi.indexBuffer,mi.segments)}}function Kl(y,t,n,h){const f={parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:{tileOpacity:1,parentTileOpacity:1,fadeMix:{opacity:1,mix:0}}};if(n===0||h)return f;if(y.fadingParentID){const x=t.getLoadedTile(y.fadingParentID);if(!x)return f;const T=Math.pow(2,x.tileID.overscaledZ-y.tileID.overscaledZ),C=[y.tileID.canonical.x*T%1,y.tileID.canonical.y*T%1],D=(function(B,N,G){const U=Gt(),$=(U-N.timeAdded)/G,ie=B.fadingDirection===Qe.Incoming,he=p.an((U-B.timeAdded)/G,0,1),Ae=p.an(1-$,0,1),ce=ie?he:Ae;return{tileOpacity:ce,parentTileOpacity:ie?Ae:he,fadeMix:{opacity:1,mix:1-ce}}})(y,x,n);return{parentTile:x,parentScaleBy:T,parentTopLeft:C,fadeValues:D}}if(y.selfFading){const x=(function(T,C){const D=(Gt()-T.timeAdded)/C,B=p.an(D,0,1);return{tileOpacity:B,fadeMix:{opacity:B,mix:0}}})(y,n);return{parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:x}}return f}const fu=new p.bp(1,0,0,1),du=new p.bp(0,1,0,1),pu=new p.bp(0,0,1,1),mu=new p.bp(1,0,1,1),ia=new p.bp(0,1,1,1);function _u(y,t,n,h){Sl(y,0,t+n/2,y.transform.width,n,h)}function gu(y,t,n,h){Sl(y,t-n/2,0,n,y.transform.height,h)}function Sl(y,t,n,h,f,x){const T=y.context,C=T.gl;C.enable(C.SCISSOR_TEST),C.scissor(t*y.pixelRatio,n*y.pixelRatio,h*y.pixelRatio,f*y.pixelRatio),T.clear({color:x}),C.disable(C.SCISSOR_TEST)}function Fu(y,t,n){const h=y.context,f=h.gl,x=y.useProgram("debug"),T=ri.disabled,C=Ci.disabled,D=y.colorModeForRenderPass(),B="$debug",N=y.style.map.terrain&&y.style.map.terrain.getTerrainData(n);h.activeTexture.set(f.TEXTURE0);const G=t.getTileByID(n.key).latestRawTileData,U=Math.floor((G&&G.byteLength||0)/1024),$=t.getTile(n).tileSize,ie=512/Math.min($,512)*(n.overscaledZ/y.transform.zoom)*.5;let he=n.canonical.toString();n.overscaledZ!==n.canonical.z&&(he+=` => ${n.overscaledZ}`),(function(ce,ye){ce.initDebugOverlayCanvas();const Pe=ce.debugOverlayCanvas,_e=ce.context.gl,we=ce.debugOverlayCanvas.getContext("2d");we.clearRect(0,0,Pe.width,Pe.height),we.shadowColor="white",we.shadowBlur=2,we.lineWidth=1.5,we.strokeStyle="white",we.textBaseline="top",we.font="bold 36px Open Sans, sans-serif",we.fillText(ye,5,5),we.strokeText(ye,5,5),ce.debugOverlayTexture.update(Pe),ce.debugOverlayTexture.bind(_e.LINEAR,_e.CLAMP_TO_EDGE)})(y,`${he} ${U}kB`);const Ae=y.transform.getProjectionData({overscaledTileID:n,applyGlobeMatrix:!0,applyTerrainMatrix:!0});x.draw(h,f.TRIANGLES,T,C,bi.alphaBlended,wi.disabled,Bs(p.bp.transparent,ie),null,Ae,B,y.debugBuffer,y.quadTriangleIndexBuffer,y.debugSegments),x.draw(h,f.LINE_STRIP,T,C,D,wi.disabled,Bs(p.bp.red),N,Ae,B,y.debugBuffer,y.tileBorderIndexBuffer,y.debugSegments)}function Io(y,t,n,h){const{isRenderingGlobe:f}=h,x=y.context,T=x.gl,C=y.transform,D=y.colorModeForRenderPass(),B=y.getDepthModeFor3D(),N=y.useProgram("terrain");x.bindFramebuffer.set(null),x.viewport.set([0,0,y.width,y.height]);for(const G of n){const U=t.getTerrainMesh(G.tileID),$=y.renderToTexture.getTexture(G),ie=t.getTerrainData(G.tileID);x.activeTexture.set(T.TEXTURE0),T.bindTexture(T.TEXTURE_2D,$.texture);const he=t.getMeshFrameDelta(C.zoom),Ae=C.calculateFogMatrix(G.tileID.toUnwrapped()),ce=bl(he,Ae,y.style.sky,C.pitch,f),ye=C.getProjectionData({overscaledTileID:G.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});N.draw(x,T.TRIANGLES,B,Ci.disabled,D,wi.backCCW,ce,ie,ye,"terrain",U.vertexBuffer,U.indexBuffer,U.segments)}}function Js(y,t){if(!t.mesh){const n=new p.aW;n.emplaceBack(-1,-1),n.emplaceBack(1,-1),n.emplaceBack(1,1),n.emplaceBack(-1,1);const h=new p.aY;h.emplaceBack(0,1,2),h.emplaceBack(0,2,3),t.mesh=new Ki(y.createVertexBuffer(n,Zs.members),y.createIndexBuffer(h),p.aX.simpleSegment(0,0,n.length,h.length))}return t.mesh}class Qt{constructor(t,n){this.context=new ne(t),this.transform=n,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:p.ar(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=Qi.maxOverzooming+Qi.maxUnderzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Wn}resize(t,n,h){if(this.width=Math.floor(t*h),this.height=Math.floor(n*h),this.pixelRatio=h,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const f of this.style._order)this.style._layers[f].resize()}setup(){const t=this.context,n=new p.aW;n.emplaceBack(0,0),n.emplaceBack(p.a5,0),n.emplaceBack(0,p.a5),n.emplaceBack(p.a5,p.a5),this.tileExtentBuffer=t.createVertexBuffer(n,Zs.members),this.tileExtentSegments=p.aX.simpleSegment(0,0,4,2);const h=new p.aW;h.emplaceBack(0,0),h.emplaceBack(p.a5,0),h.emplaceBack(0,p.a5),h.emplaceBack(p.a5,p.a5),this.debugBuffer=t.createVertexBuffer(h,Zs.members),this.debugSegments=p.aX.simpleSegment(0,0,4,5);const f=new p.ch;f.emplaceBack(0,0,0,0),f.emplaceBack(p.a5,0,p.a5,0),f.emplaceBack(0,p.a5,0,p.a5),f.emplaceBack(p.a5,p.a5,p.a5,p.a5),this.rasterBoundsBuffer=t.createVertexBuffer(f,hu.members),this.rasterBoundsSegments=p.aX.simpleSegment(0,0,4,2);const x=new p.aW;x.emplaceBack(0,0),x.emplaceBack(p.a5,0),x.emplaceBack(0,p.a5),x.emplaceBack(p.a5,p.a5),this.rasterBoundsBufferPosOnly=t.createVertexBuffer(x,Zs.members),this.rasterBoundsSegmentsPosOnly=p.aX.simpleSegment(0,0,4,5);const T=new p.aW;T.emplaceBack(0,0),T.emplaceBack(1,0),T.emplaceBack(0,1),T.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(T,Zs.members),this.viewportSegments=p.aX.simpleSegment(0,0,4,2);const C=new p.ci;C.emplaceBack(0),C.emplaceBack(1),C.emplaceBack(3),C.emplaceBack(2),C.emplaceBack(0),this.tileBorderIndexBuffer=t.createIndexBuffer(C);const D=new p.aY;D.emplaceBack(1,0,2),D.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(D);const B=this.context.gl;this.stencilClearMode=new Ci({func:B.ALWAYS,mask:0},0,255,B.ZERO,B.ZERO,B.ZERO),this.tileExtentMesh=new Ki(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){const t=this.context,n=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const h=p.N();p.c7(h,0,this.width,this.height,0,0,1),p.Q(h,h,[n.drawingBufferWidth,n.drawingBufferHeight,0]);const f={mainMatrix:h,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:h};this.useProgram("clippingMask",null,!0).draw(t,n.TRIANGLES,ri.disabled,this.stencilClearMode,bi.disabled,wi.disabled,null,null,f,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(t,n,h){if(this.currentStencilSource===t.source||!t.isTileClipped()||!n||!n.length)return;this.currentStencilSource=t.source,this.nextStencilID+n.length>256&&this.clearStencil();const f=this.context;f.setColorMode(bi.disabled),f.setDepthMode(ri.disabled);const x={};for(const T of n)x[T.key]=this.nextStencilID++;this._renderTileMasks(x,n,h,!0),this._renderTileMasks(x,n,h,!1),this._tileClippingMaskIDs=x}_renderTileMasks(t,n,h,f){const x=this.context,T=x.gl,C=this.style.projection,D=this.transform,B=this.useProgram("clippingMask");for(const N of n){const G=t[N.key],U=this.style.map.terrain&&this.style.map.terrain.getTerrainData(N),$=C.getMeshFromTileID(this.context,N.canonical,f,!0,"stencil"),ie=D.getProjectionData({overscaledTileID:N,applyGlobeMatrix:!h,applyTerrainMatrix:!0});B.draw(x,T.TRIANGLES,ri.disabled,new Ci({func:T.ALWAYS,mask:0},G,255,T.KEEP,T.KEEP,T.REPLACE),bi.disabled,h?wi.disabled:wi.backCCW,null,U,ie,"$clipping",$.vertexBuffer,$.indexBuffer,$.segments)}}_renderTilesDepthBuffer(){const t=this.context,n=t.gl,h=this.style.projection,f=this.transform,x=this.useProgram("depth"),T=this.getDepthModeFor3D(),C=er(f,{tileSize:f.tileSize});for(const D of C){const B=this.style.map.terrain&&this.style.map.terrain.getTerrainData(D),N=h.getMeshFromTileID(this.context,D.canonical,!0,!0,"raster"),G=f.getProjectionData({overscaledTileID:D,applyGlobeMatrix:!0,applyTerrainMatrix:!0});x.draw(t,n.TRIANGLES,T,Ci.disabled,bi.disabled,wi.backCCW,null,B,G,"$clipping",N.vertexBuffer,N.indexBuffer,N.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const t=this.nextStencilID++,n=this.context.gl;return new Ci({func:n.NOTEQUAL,mask:255},t,255,n.KEEP,n.KEEP,n.REPLACE)}stencilModeForClipping(t){const n=this.context.gl;return new Ci({func:n.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,n.KEEP,n.KEEP,n.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(t){const n=this.context.gl,h=t.sort(((T,C)=>C.overscaledZ-T.overscaledZ)),f=h[h.length-1].overscaledZ,x=h[0].overscaledZ-f+1;if(x>1){this.currentStencilSource=void 0,this.nextStencilID+x>256&&this.clearStencil();const T={};for(let C=0;C<x;C++)T[C+f]=new Ci({func:n.GEQUAL,mask:255},C+this.nextStencilID,255,n.KEEP,n.KEEP,n.REPLACE);return this.nextStencilID+=x,[T,h]}return[{[f]:Ci.disabled},h]}stencilConfigForOverlapTwoPass(t){const n=this.context.gl,h=t.sort(((T,C)=>C.overscaledZ-T.overscaledZ)),f=h[h.length-1].overscaledZ,x=h[0].overscaledZ-f+1;if(this.clearStencil(),x>1){const T={},C={};for(let D=0;D<x;D++)T[D+f]=new Ci({func:n.GREATER,mask:255},x+1+D,255,n.KEEP,n.KEEP,n.REPLACE),C[D+f]=new Ci({func:n.GREATER,mask:255},1+D,255,n.KEEP,n.KEEP,n.REPLACE);return this.nextStencilID=2*x+1,[T,C,h]}return this.nextStencilID=3,[{[f]:new Ci({func:n.GREATER,mask:255},2,255,n.KEEP,n.KEEP,n.REPLACE)},{[f]:new Ci({func:n.GREATER,mask:255},1,255,n.KEEP,n.KEEP,n.REPLACE)},h]}colorModeForRenderPass(){const t=this.context.gl;return this._showOverdrawInspector?new bi([t.CONSTANT_COLOR,t.ONE],new p.bp(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?bi.unblended:bi.alphaBlended}getDepthModeForSublayer(t,n,h){if(!this.opaquePassEnabledForLayer())return ri.disabled;const f=1-((1+this.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new ri(h||this.context.gl.LEQUAL,n,[f,f])}getDepthModeFor3D(){return new ri(this.context.gl.LEQUAL,ri.ReadWrite,this.depthRangeFor3D)}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(t,n){var h,f;this.style=t,this.options=n,this.lineAtlas=t.lineAtlas,this.imageManager=t.imageManager,this.glyphManager=t.glyphManager,this.symbolFadeChange=t.placement.symbolFadeChange(Gt()),this.imageManager.beginFrame();const x=this.style._order,T=this.style.tileManagers,C={},D={},B={},N={isRenderingToTexture:!1,isRenderingGlobe:((h=t.projection)===null||h===void 0?void 0:h.transitionState)>0};for(const U in T){const $=T[U];$.used&&$.prepare(this.context),C[U]=$.getVisibleCoordinates(!1),D[U]=C[U].slice().reverse(),B[U]=$.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let U=0;U<x.length;U++)if(this.style._layers[x[U]].is3D()){this.opaquePassCutoff=U;break}this.maybeDrawDepthAndCoords(!1),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0),this.renderPass="offscreen";for(const U of x){const $=this.style._layers[U];if(!$.hasOffscreenPass()||$.isHidden(this.transform.zoom))continue;const ie=D[$.source];($.type==="custom"||ie.length)&&this.renderLayer(this,T[$.source],$,ie,N)}if((f=this.style.projection)===null||f===void 0||f.updateGPUdependent({context:this.context,useProgram:U=>this.useProgram(U)}),this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:n.showOverdrawInspector?p.bp.black:p.bp.transparent,depth:1}),this.clearStencil(),this.style.sky&&(function(U,$){const ie=U.context,he=ie.gl,Ae=((Ce,be,Le)=>{const Ke=Math.cos(be.rollInRadians),He=Math.sin(be.rollInRadians),$e=Gi(be),Ye=be.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return{u_sky_color:Ce.properties.get("sky-color"),u_horizon_color:Ce.properties.get("horizon-color"),u_horizon:[(be.width/2-$e*He)*Le,(be.height/2+$e*Ke)*Le],u_horizon_normal:[-He,Ke],u_sky_horizon_blend:Ce.properties.get("sky-horizon-blend")*be.height/2*Le,u_sky_blend:Ye}})($,U.style.map.transform,U.pixelRatio),ce=new ri(he.LEQUAL,ri.ReadWrite,[0,1]),ye=Ci.disabled,Pe=U.colorModeForRenderPass(),_e=U.useProgram("sky"),we=Js(ie,$);_e.draw(ie,he.TRIANGLES,ce,ye,Pe,wi.disabled,Ae,null,void 0,"sky",we.vertexBuffer,we.indexBuffer,we.segments)})(this,this.style.sky),this._showOverdrawInspector=n.showOverdrawInspector,this.depthRangeFor3D=[0,1-(t._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=x.length-1;this.currentLayer>=0;this.currentLayer--){const U=this.style._layers[x[this.currentLayer]],$=T[U.source],ie=C[U.source];this._renderTileClippingMasks(U,ie,!1),this.renderLayer(this,$,U,ie,N)}this.renderPass="translucent";let G=!1;for(this.currentLayer=0;this.currentLayer<x.length;this.currentLayer++){const U=this.style._layers[x[this.currentLayer]],$=T[U.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(U,N))continue;this.opaquePassEnabledForLayer()||G||(G=!0,N.isRenderingGlobe&&!this.style.map.terrain&&this._renderTilesDepthBuffer());const ie=(U.type==="symbol"?B:D)[U.source];this._renderTileClippingMasks(U,C[U.source],!!this.renderToTexture),this.renderLayer(this,$,U,ie,N)}if(N.isRenderingGlobe&&(function(U,$,ie){const he=U.context,Ae=he.gl,ce=U.useProgram("atmosphere"),ye=new ri(Ae.LEQUAL,ri.ReadOnly,[0,1]),Pe=U.transform,_e=(function(Ye,xt){const wt=Ye.properties.get("position"),pt=[-wt.x,-wt.y,-wt.z],Pt=p.ar(new Float64Array(16));return Ye.properties.get("anchor")==="map"&&(p.bg(Pt,Pt,xt.rollInRadians),p.bh(Pt,Pt,-xt.pitchInRadians),p.bg(Pt,Pt,xt.bearingInRadians),p.bh(Pt,Pt,xt.center.lat*Math.PI/180),p.bJ(Pt,Pt,-xt.center.lng*Math.PI/180)),p.cg(pt,pt,Pt),pt})(ie,U.transform),we=Pe.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),Ce=$.properties.get("atmosphere-blend")*we.projectionTransition;if(Ce===0)return;const be=ao(Pe.worldSize,Pe.center.lat),Le=Pe.inverseProjectionMatrix,Ke=new Float64Array(4);Ke[3]=1,p.aH(Ke,Ke,Pe.modelViewProjectionMatrix),Ke[0]/=Ke[3],Ke[1]/=Ke[3],Ke[2]/=Ke[3],Ke[3]=1,p.aH(Ke,Ke,Le),Ke[0]/=Ke[3],Ke[1]/=Ke[3],Ke[2]/=Ke[3],Ke[3]=1;const He=((Ye,xt,wt,pt,Pt)=>({u_sun_pos:Ye,u_atmosphere_blend:xt,u_globe_position:wt,u_globe_radius:pt,u_inv_proj_matrix:Pt}))(_e,Ce,[Ke[0],Ke[1],Ke[2]],be,Le),$e=Js(he,$);ce.draw(he,Ae.TRIANGLES,ye,Ci.disabled,bi.alphaBlended,wi.disabled,He,null,null,"atmosphere",$e.vertexBuffer,$e.indexBuffer,$e.segments)})(this,this.style.sky,this.style.light),this.options.showTileBoundaries){const U=(function($,ie){let he=null;const Ae=Object.values($._layers).flatMap((_e=>_e.source&&!_e.isHidden(ie)?[$.tileManagers[_e.source]]:[])),ce=Ae.filter((_e=>_e.getSource().type==="vector")),ye=Ae.filter((_e=>_e.getSource().type!=="vector")),Pe=_e=>{(!he||he.getSource().maxzoom<_e.getSource().maxzoom)&&(he=_e)};return ce.forEach((_e=>Pe(_e))),he||ye.forEach((_e=>Pe(_e))),he})(this.style,this.transform.zoom);U&&(function($,ie,he){for(let Ae=0;Ae<he.length;Ae++)Fu($,ie,he[Ae])})(this,U,U.getVisibleCoordinates())}this.options.showPadding&&(function(U){const $=U.transform.padding;_u(U,U.transform.height-($.top||0),3,fu),_u(U,$.bottom||0,3,du),gu(U,$.left||0,3,pu),gu(U,U.transform.width-($.right||0),3,mu);const ie=U.transform.centerPoint;(function(he,Ae,ce,ye){Sl(he,Ae-1,ce-10,2,20,ye),Sl(he,Ae-10,ce-1,20,2,ye)})(U,ie.x,U.transform.height-ie.y,ia)})(this),this.context.setDefault()}maybeDrawDepthAndCoords(t){if(!this.style||!this.style.map||!this.style.map.terrain)return;const n=this.terrainFacilitator.matrix,h=this.transform.modelViewProjectionMatrix;let f=this.terrainFacilitator.dirty;f||(f=t?!p.cj(n,h):!p.ck(n,h)),f||(f=this.style.map.terrain.tileManager.anyTilesAfterTime(this.terrainFacilitator.renderTime)),f&&(p.cl(n,h),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,(function(x,T){const C=x.context,D=C.gl,B=x.transform,N=bi.unblended,G=new ri(D.LEQUAL,ri.ReadWrite,[0,1]),U=T.tileManager.getRenderableTiles(),$=x.useProgram("terrainDepth");C.bindFramebuffer.set(T.getFramebuffer("depth").framebuffer),C.viewport.set([0,0,x.width/devicePixelRatio,x.height/devicePixelRatio]),C.clear({color:p.bp.transparent,depth:1});for(const ie of U){const he=T.getTerrainMesh(ie.tileID),Ae=T.getTerrainData(ie.tileID),ce=B.getProjectionData({overscaledTileID:ie.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0}),ye={u_ele_delta:T.getMeshFrameDelta(B.zoom)};$.draw(C,D.TRIANGLES,G,Ci.disabled,N,wi.backCCW,ye,Ae,ce,"terrain",he.vertexBuffer,he.indexBuffer,he.segments)}C.bindFramebuffer.set(null),C.viewport.set([0,0,x.width,x.height])})(this,this.style.map.terrain),(function(x,T){const C=x.context,D=C.gl,B=x.transform,N=bi.unblended,G=new ri(D.LEQUAL,ri.ReadWrite,[0,1]),U=T.getCoordsTexture(),$=T.tileManager.getRenderableTiles(),ie=x.useProgram("terrainCoords");C.bindFramebuffer.set(T.getFramebuffer("coords").framebuffer),C.viewport.set([0,0,x.width/devicePixelRatio,x.height/devicePixelRatio]),C.clear({color:p.bp.transparent,depth:1}),T.coordsIndex=[];for(const he of $){const Ae=T.getTerrainMesh(he.tileID),ce=T.getTerrainData(he.tileID);C.activeTexture.set(D.TEXTURE0),D.bindTexture(D.TEXTURE_2D,U.texture);const ye={u_terrain_coords_id:(255-T.coordsIndex.length)/255,u_texture:0,u_ele_delta:T.getMeshFrameDelta(B.zoom)},Pe=B.getProjectionData({overscaledTileID:he.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});ie.draw(C,D.TRIANGLES,G,Ci.disabled,N,wi.backCCW,ye,ce,Pe,"terrain",Ae.vertexBuffer,Ae.indexBuffer,Ae.segments),T.coordsIndex.push(he.tileID.key)}C.bindFramebuffer.set(null),C.viewport.set([0,0,x.width,x.height])})(this,this.style.map.terrain))}renderLayer(t,n,h,f,x){h.isHidden(this.transform.zoom)||(h.type==="background"||h.type==="custom"||(f||[]).length)&&(this.id=h.id,p.cm(h)?(function(T,C,D,B,N,G){if(T.renderPass!=="translucent")return;const{isRenderingToTexture:U}=G,$=Ci.disabled,ie=T.colorModeForRenderPass();(D._unevaluatedLayout.hasValue("text-variable-anchor")||D._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&(function(he,Ae,ce,ye,Pe,_e,we,Ce,be){const Le=Ae.transform,Ke=Ae.style.map.terrain,He=Pe==="map",$e=_e==="map";for(const Ye of he){const xt=ye.getTile(Ye),wt=xt.getBucket(ce);if(!wt||!wt.text||!wt.text.segments.get().length)continue;const pt=p.ay(wt.textSizeData,Le.zoom),Pt=p.aN(xt,1,Ae.transform.zoom),mi=fi(He,Ae.transform,Pt),sr=ce.layout.get("icon-text-fit")!=="none"&&wt.hasIconData();if(pt){const Dr=Math.pow(2,Le.zoom-xt.tileID.overscaledZ),mr=Ke?(Rr,_r)=>Ke.getElevation(Ye,Rr,_r):null;Jt(wt,He,$e,be,Le,mi,Dr,pt,sr,p.aO(Le,xt,we,Ce),Ye.toUnwrapped(),mr)}}})(B,T,D,C,D.layout.get("text-rotation-alignment"),D.layout.get("text-pitch-alignment"),D.paint.get("text-translate"),D.paint.get("text-translate-anchor"),N),D.paint.get("icon-opacity").constantOr(1)!==0&&Zr(T,C,D,B,!1,D.paint.get("icon-translate"),D.paint.get("icon-translate-anchor"),D.layout.get("icon-rotation-alignment"),D.layout.get("icon-pitch-alignment"),D.layout.get("icon-keep-upright"),$,ie,U),D.paint.get("text-opacity").constantOr(1)!==0&&Zr(T,C,D,B,!0,D.paint.get("text-translate"),D.paint.get("text-translate-anchor"),D.layout.get("text-rotation-alignment"),D.layout.get("text-pitch-alignment"),D.layout.get("text-keep-upright"),$,ie,U),C.map.showCollisionBoxes&&(Ze(T,C,D,B,!0),Ze(T,C,D,B,!1))})(t,n,h,f,this.style.placement.variableOffsets,x):p.cn(h)?(function(T,C,D,B,N){if(T.renderPass!=="translucent")return;const{isRenderingToTexture:G}=N,U=D.paint.get("circle-opacity"),$=D.paint.get("circle-stroke-width"),ie=D.paint.get("circle-stroke-opacity"),he=!D.layout.get("circle-sort-key").isConstant();if(U.constantOr(1)===0&&($.constantOr(1)===0||ie.constantOr(1)===0))return;const Ae=T.context,ce=Ae.gl,ye=T.transform,Pe=T.getDepthModeForSublayer(0,ri.ReadOnly),_e=Ci.disabled,we=T.colorModeForRenderPass(),Ce=[],be=ye.getCircleRadiusCorrection();for(let Le=0;Le<B.length;Le++){const Ke=B[Le],He=C.getTile(Ke),$e=He.getBucket(D);if(!$e)continue;const Ye=D.paint.get("circle-translate"),xt=D.paint.get("circle-translate-anchor"),wt=p.aO(ye,He,Ye,xt),pt=$e.programConfigurations.get(D.id),Pt=T.useProgram("circle",pt),mi=$e.layoutVertexBuffer,sr=$e.indexBuffer,Dr=T.style.map.terrain&&T.style.map.terrain.getTerrainData(Ke),mr={programConfiguration:pt,program:Pt,layoutVertexBuffer:mi,indexBuffer:sr,uniformValues:$i(T,He,D,wt,be),terrainData:Dr,projectionData:ye.getProjectionData({overscaledTileID:Ke,applyGlobeMatrix:!G,applyTerrainMatrix:!0})};if(he){const Rr=$e.segments.get();for(const _r of Rr)Ce.push({segments:new p.aX([_r]),sortKey:_r.sortKey,state:mr})}else Ce.push({segments:$e.segments,sortKey:0,state:mr})}he&&Ce.sort(((Le,Ke)=>Le.sortKey-Ke.sortKey));for(const Le of Ce){const{programConfiguration:Ke,program:He,layoutVertexBuffer:$e,indexBuffer:Ye,uniformValues:xt,terrainData:wt,projectionData:pt}=Le.state;He.draw(Ae,ce.TRIANGLES,Pe,_e,we,wi.backCCW,xt,wt,pt,D.id,$e,Ye,Le.segments,D.paint,T.transform.zoom,Ke)}})(t,n,h,f,x):p.co(h)?(function(T,C,D,B,N){if(D.paint.get("heatmap-opacity")===0)return;const G=T.context,{isRenderingToTexture:U,isRenderingGlobe:$}=N;if(T.style.map.terrain){for(const ie of B){const he=C.getTile(ie);C.hasRenderableParent(ie)||(T.renderPass==="offscreen"?ps(T,he,D,ie,$):T.renderPass==="translucent"&&On(T,D,ie,U,$))}G.viewport.set([0,0,T.width,T.height])}else T.renderPass==="offscreen"?(function(ie,he,Ae,ce){const ye=ie.context,Pe=ye.gl,_e=ie.transform,we=Ci.disabled,Ce=new bi([Pe.ONE,Pe.ONE],p.bp.transparent,[!0,!0,!0,!0]);(function(be,Le,Ke){const He=be.gl;be.activeTexture.set(He.TEXTURE1),be.viewport.set([0,0,Le.width/4,Le.height/4]);let $e=Ke.heatmapFbos.get(p.cd);$e?(He.bindTexture(He.TEXTURE_2D,$e.colorAttachment.get()),be.bindFramebuffer.set($e.framebuffer)):($e=Ks(be,Le.width/4,Le.height/4),Ke.heatmapFbos.set(p.cd,$e))})(ye,ie,Ae),ye.clear({color:p.bp.transparent});for(let be=0;be<ce.length;be++){const Le=ce[be];if(he.hasRenderableParent(Le))continue;const Ke=he.getTile(Le),He=Ke.getBucket(Ae);if(!He)continue;const $e=He.programConfigurations.get(Ae.id),Ye=ie.useProgram("heatmap",$e),xt=_e.getProjectionData({overscaledTileID:Le,applyGlobeMatrix:!0,applyTerrainMatrix:!1}),wt=_e.getCircleRadiusCorrection();Ye.draw(ye,Pe.TRIANGLES,ri.disabled,we,Ce,wi.backCCW,uo(Ke,_e.zoom,Ae.paint.get("heatmap-intensity"),wt),null,xt,Ae.id,He.layoutVertexBuffer,He.indexBuffer,He.segments,Ae.paint,_e.zoom,$e)}ye.viewport.set([0,0,ie.width,ie.height])})(T,C,D,B):T.renderPass==="translucent"&&(function(ie,he){const Ae=ie.context,ce=Ae.gl;Ae.setColorMode(ie.colorModeForRenderPass());const ye=he.heatmapFbos.get(p.cd);ye&&(Ae.activeTexture.set(ce.TEXTURE0),ce.bindTexture(ce.TEXTURE_2D,ye.colorAttachment.get()),Ae.activeTexture.set(ce.TEXTURE1),al(Ae,he).bind(ce.LINEAR,ce.CLAMP_TO_EDGE),ie.useProgram("heatmapTexture").draw(Ae,ce.TRIANGLES,ri.disabled,Ci.disabled,ie.colorModeForRenderPass(),wi.disabled,Ul(ie,he,0,1),null,null,he.id,ie.viewportBuffer,ie.quadTriangleIndexBuffer,ie.viewportSegments,he.paint,ie.transform.zoom))})(T,D)})(t,n,h,f,x):p.cp(h)?(function(T,C,D,B,N){if(T.renderPass!=="translucent")return;const{isRenderingToTexture:G}=N,U=D.paint.get("line-opacity"),$=D.paint.get("line-width");if(U.constantOr(1)===0||$.constantOr(1)===0)return;const ie=T.getDepthModeForSublayer(0,ri.ReadOnly),he=T.colorModeForRenderPass(),Ae=D.paint.get("line-dasharray"),ce=Ae.constantOr(1),ye=D.paint.get("line-pattern"),Pe=ye.constantOr(1),_e=D.paint.get("line-gradient"),we=D.getCrossfadeParameters();let Ce;Ce=Pe?"linePattern":ce&&_e?"lineGradientSDF":ce?"lineSDF":_e?"lineGradient":"line";const be=T.context,Le=be.gl,Ke=T.transform;let He=!0;for(const $e of B){const Ye=C.getTile($e);if(Pe&&!Ye.patternsLoaded())continue;const xt=Ye.getBucket(D);if(!xt)continue;const wt=xt.programConfigurations.get(D.id),pt=T.context.program.get(),Pt=T.useProgram(Ce,wt),mi=He||Pt.program!==pt,sr=T.style.map.terrain&&T.style.map.terrain.getTerrainData($e),Dr=ye.constantOr(null),mr=Ae&&Ae.constantOr(null);if(Dr&&Ye.imageAtlas){const rs=Ye.imageAtlas,dn=rs.patternPositions[Dr.to.toString()],an=rs.patternPositions[Dr.from.toString()];dn&&an&&wt.setConstantPatternPositions(dn,an)}else if(mr){const rs=D.layout.get("line-cap")==="round",dn=T.lineAtlas.getDash(mr.to,rs),an=T.lineAtlas.getDash(mr.from,rs);wt.setConstantDashPositions(dn,an)}const Rr=Ke.getProjectionData({overscaledTileID:$e,applyGlobeMatrix:!G,applyTerrainMatrix:!0}),_r=Ke.getPixelScale();let Yr;Pe?(Yr=As(T,Ye,D,_r,we),Xl(be,Le,Ye,wt,we)):ce&&_e?(Yr=vn(T,Ye,D,_r,we,xt.lineClipsArray.length),Nn(T,C,be,Le,D,xt,$e,wt,we)):ce?(Yr=Ba(T,Ye,D,_r,we),br(T,be,Le,wt,mi,we)):_e?(Yr=Gl(T,Ye,D,_r,xt.lineClipsArray.length),ea(T,C,be,Le,D,xt,$e)):Yr=yn(T,Ye,D,_r);const Fr=T.stencilModeForClipping($e);Pt.draw(be,Le.TRIANGLES,ie,Fr,he,wi.disabled,Yr,sr,Rr,D.id,xt.layoutVertexBuffer,xt.indexBuffer,xt.segments,D.paint,T.transform.zoom,wt,xt.layoutVertexBuffer2),He=!1}})(t,n,h,f,x):p.cq(h)?(function(T,C,D,B,N){const G=D.paint.get("fill-color"),U=D.paint.get("fill-opacity");if(U.constantOr(1)===0)return;const{isRenderingToTexture:$}=N,ie=T.colorModeForRenderPass(),he=D.paint.get("fill-pattern"),Ae=T.opaquePassEnabledForLayer()&&!he.constantOr(1)&&G.constantOr(p.bp.transparent).a===1&&U.constantOr(0)===1?"opaque":"translucent";if(T.renderPass===Ae){const ce=T.getDepthModeForSublayer(1,T.renderPass==="opaque"?ri.ReadWrite:ri.ReadOnly);nr(T,C,D,B,ce,ie,!1,$)}if(T.renderPass==="translucent"&&D.paint.get("fill-antialias")){const ce=T.getDepthModeForSublayer(D.getPaintProperty("fill-outline-color")?2:0,ri.ReadOnly);nr(T,C,D,B,ce,ie,!0,$)}})(t,n,h,f,x):p.cr(h)?(function(T,C,D,B,N){const G=D.paint.get("fill-extrusion-opacity");if(G===0)return;const{isRenderingToTexture:U}=N;if(T.renderPass==="translucent"){const $=new ri(T.context.gl.LEQUAL,ri.ReadWrite,T.depthRangeFor3D);if(G!==1||D.paint.get("fill-extrusion-pattern").constantOr(1))ll(T,C,D,B,$,Ci.disabled,bi.disabled,U),ll(T,C,D,B,$,T.stencilModeFor3D(),T.colorModeForRenderPass(),U);else{const ie=T.colorModeForRenderPass();ll(T,C,D,B,$,Ci.disabled,ie,U)}}})(t,n,h,f,x):p.cs(h)?(function(T,C,D,B,N){if(T.renderPass!=="offscreen"&&T.renderPass!=="translucent")return;const{isRenderingToTexture:G}=N,U=T.context,$=T.style.projection.useSubdivision,ie=T.getDepthModeForSublayer(0,ri.ReadOnly),he=T.colorModeForRenderPass();if(T.renderPass==="offscreen")(function(Ae,ce,ye,Pe,_e,we,Ce){const be=Ae.context,Le=be.gl;for(const Ke of ye){const He=ce.getTile(Ke),$e=He.dem;if(!$e||!$e.data||!He.needsHillshadePrepare)continue;const Ye=$e.dim,xt=$e.stride,wt=$e.getPixels();if(be.activeTexture.set(Le.TEXTURE1),be.pixelStoreUnpackPremultiplyAlpha.set(!1),He.demTexture=He.demTexture||Ae.getTileTexture(xt),He.demTexture){const Pt=He.demTexture;Pt.update(wt,{premultiply:!1}),Pt.bind(Le.NEAREST,Le.CLAMP_TO_EDGE)}else He.demTexture=new p.T(be,wt,Le.RGBA,{premultiply:!1}),He.demTexture.bind(Le.NEAREST,Le.CLAMP_TO_EDGE);be.activeTexture.set(Le.TEXTURE0);let pt=He.fbo;if(!pt){const Pt=new p.T(be,{width:Ye,height:Ye,data:null},Le.RGBA);Pt.bind(Le.LINEAR,Le.CLAMP_TO_EDGE),pt=He.fbo=be.createFramebuffer(Ye,Ye,!0,!1),pt.colorAttachment.set(Pt.texture)}be.bindFramebuffer.set(pt.framebuffer),be.viewport.set([0,0,Ye,Ye]),Ae.useProgram("hillshadePrepare").draw(be,Le.TRIANGLES,_e,we,Ce,wi.disabled,cu(He.tileID,$e),null,null,Pe.id,Ae.rasterBoundsBuffer,Ae.quadTriangleIndexBuffer,Ae.rasterBoundsSegments),He.needsHillshadePrepare=!1}})(T,C,B,D,ie,Ci.disabled,he),U.viewport.set([0,0,T.width,T.height]);else if(T.renderPass==="translucent")if($){const[Ae,ce,ye]=T.stencilConfigForOverlapTwoPass(B);Co(T,C,D,ye,Ae,ie,he,!1,G),Co(T,C,D,ye,ce,ie,he,!0,G)}else{const[Ae,ce]=T.getStencilConfigForOverlapAndUpdateStencilID(B);Co(T,C,D,ce,Ae,ie,he,!1,G)}})(t,n,h,f,x):p.ct(h)?(function(T,C,D,B,N){if(T.renderPass!=="translucent"||!B.length)return;const{isRenderingToTexture:G}=N,U=T.style.projection.useSubdivision,$=T.getDepthModeForSublayer(0,ri.ReadOnly),ie=T.colorModeForRenderPass();if(U){const[he,Ae,ce]=T.stencilConfigForOverlapTwoPass(B);Ao(T,C,D,ce,he,$,ie,!1,G),Ao(T,C,D,ce,Ae,$,ie,!0,G)}else{const[he,Ae]=T.getStencilConfigForOverlapAndUpdateStencilID(B);Ao(T,C,D,Ae,he,$,ie,!1,G)}})(t,n,h,f,x):p.bU(h)?(function(T,C,D,B,N){if(T.renderPass!=="translucent"||D.paint.get("raster-opacity")===0||!B.length)return;const{isRenderingToTexture:G}=N,U=C.getSource(),$=T.style.projection.useSubdivision;if(U instanceof mn)ta(T,C,D,B,null,!1,!1,U.tileCoords,U.flippedWindingOrder,G);else if($){const[ie,he,Ae]=T.stencilConfigForOverlapTwoPass(B);ta(T,C,D,Ae,ie,!1,!0,Ur,!1,G),ta(T,C,D,Ae,he,!0,!0,Ur,!1,G)}else{const[ie,he]=T.getStencilConfigForOverlapAndUpdateStencilID(B);ta(T,C,D,he,ie,!1,!0,Ur,!1,G)}})(t,n,h,f,x):p.cu(h)?(function(T,C,D,B,N){const G=D.paint.get("background-color"),U=D.paint.get("background-opacity");if(U===0)return;const{isRenderingToTexture:$}=N,ie=T.context,he=ie.gl,Ae=T.style.projection,ce=T.transform,ye=ce.tileSize,Pe=D.paint.get("background-pattern");if(T.isPatternMissing(Pe))return;const _e=!Pe&&G.a===1&&U===1&&T.opaquePassEnabledForLayer()?"opaque":"translucent";if(T.renderPass!==_e)return;const we=Ci.disabled,Ce=T.getDepthModeForSublayer(0,_e==="opaque"?ri.ReadWrite:ri.ReadOnly),be=T.colorModeForRenderPass(),Le=T.useProgram(Pe?"backgroundPattern":"background"),Ke=B||er(ce,{tileSize:ye,terrain:T.style.map.terrain});Pe&&(ie.activeTexture.set(he.TEXTURE0),T.imageManager.bind(T.context));const He=D.getCrossfadeParameters();for(const $e of Ke){const Ye=ce.getProjectionData({overscaledTileID:$e,applyGlobeMatrix:!$,applyTerrainMatrix:!0}),xt=Pe?Pl(U,T,Pe,{tileID:$e,tileSize:ye},He):Ja(U,G),wt=T.style.map.terrain&&T.style.map.terrain.getTerrainData($e),pt=Ae.getMeshFromTileID(ie,$e.canonical,!1,!0,"raster");Le.draw(ie,he.TRIANGLES,Ce,we,be,wi.backCCW,xt,wt,Ye,D.id,pt.vertexBuffer,pt.indexBuffer,pt.segments)}})(t,0,h,f,x):p.cv(h)&&(function(T,C,D,B){const{isRenderingGlobe:N}=B,G=T.context,U=D.implementation,$=T.style.projection,ie=T.transform,he=ie.getProjectionDataForCustomLayer(N),Ae={farZ:ie.farZ,nearZ:ie.nearZ,fov:ie.fov*Math.PI/180,modelViewProjectionMatrix:ie.modelViewProjectionMatrix,projectionMatrix:ie.projectionMatrix,shaderData:{variantName:$.shaderVariantName,vertexShaderPrelude:`const float PI = 3.141592653589793; 813 - uniform mat4 u_projection_matrix; 814 - ${$.shaderPreludeCode.vertexSource}`,define:$.shaderDefine},defaultProjectionData:he},ce=U.renderingMode?U.renderingMode:"2d";if(T.renderPass==="offscreen"){const ye=U.prerender;ye&&(T.setCustomLayerDefaults(),G.setColorMode(T.colorModeForRenderPass()),ye.call(U,G.gl,Ae),G.setDirty(),T.setBaseState())}else if(T.renderPass==="translucent"){T.setCustomLayerDefaults(),G.setColorMode(T.colorModeForRenderPass()),G.setStencilMode(Ci.disabled);const ye=ce==="3d"?T.getDepthModeFor3D():T.getDepthModeForSublayer(0,ri.ReadOnly);G.setDepthMode(ye),U.render(G.gl,Ae),G.setDirty(),T.setBaseState(),G.bindFramebuffer.set(null)}})(t,0,h,x))}saveTileTexture(t){const n=this._tileTextures[t.size[0]];n?n.push(t):this._tileTextures[t.size[0]]=[t]}getTileTexture(t){const n=this._tileTextures[t];return n&&n.length>0?n.pop():null}isPatternMissing(t){if(!t)return!1;if(!t.from||!t.to)return!0;const n=this.imageManager.getPattern(t.from.toString()),h=this.imageManager.getPattern(t.to.toString());return!n||!h}useProgram(t,n,h=!1,f=[]){this.cache=this.cache||{};const x=!!this.style.map.terrain,T=this.style.projection,C=h?Li.projectionMercator:T.shaderPreludeCode,D=h?cn:T.shaderDefine,B=t+(n?n.cacheKey:"")+`/${h?gn:T.shaderVariantName}`+(this._showOverdrawInspector?"/overdraw":"")+(x?"/terrain":"")+(f?`/${f.join("/")}`:"");return this.cache[B]||(this.cache[B]=new $o(this.context,Li[t],n,Au[t],this._showOverdrawInspector,x,C,D,f)),this.cache[B]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const t=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(t.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new p.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){var t,n;if(this._tileTextures){for(const h in this._tileTextures){const f=this._tileTextures[h];if(f)for(const x of f)x.destroy()}this._tileTextures={}}if(this.tileExtentBuffer&&this.tileExtentBuffer.destroy(),this.debugBuffer&&this.debugBuffer.destroy(),this.rasterBoundsBuffer&&this.rasterBoundsBuffer.destroy(),this.rasterBoundsBufferPosOnly&&this.rasterBoundsBufferPosOnly.destroy(),this.viewportBuffer&&this.viewportBuffer.destroy(),this.tileBorderIndexBuffer&&this.tileBorderIndexBuffer.destroy(),this.quadTriangleIndexBuffer&&this.quadTriangleIndexBuffer.destroy(),this.tileExtentMesh&&((t=this.tileExtentMesh.vertexBuffer)===null||t===void 0||t.destroy()),this.tileExtentMesh&&((n=this.tileExtentMesh.indexBuffer)===null||n===void 0||n.destroy()),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.cache){for(const h in this.cache){const f=this.cache[h];f&&f.program&&this.context.gl.deleteProgram(f.program)}this.cache={}}this.context&&this.context.setDefault()}overLimit(){const{drawingBufferWidth:t,drawingBufferHeight:n}=this.context.gl;return this.width!==t||this.height!==n}}function ts(y,t){let n,h=!1,f=null,x=null;const T=()=>{f=null,h&&(y.apply(x,n),f=setTimeout(T,t),h=!1)};return(...C)=>(h=!0,x=this,n=C,f||T(),f)}class Wt{constructor(t){this._getCurrentHash=()=>{const n=window.location.hash.replace("#","");if(this._hashName){let h;return n.split("&").map((f=>f.split("="))).forEach((f=>{f[0]===this._hashName&&(h=f)})),(h&&h[1]||"").split("/")}return n.split("/")},this._onHashChange=()=>{const n=this._getCurrentHash();if(!this._isValidHash(n))return!1;const h=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(n[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+n[2],+n[1]],zoom:+n[0],bearing:h,pitch:+(n[4]||0)}),!0},this._updateHashUnthrottled=()=>{const n=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,n)},this._removeHash=()=>{const n=this._getCurrentHash();if(n.length===0)return;const h=n.join("/");let f=h;f.split("&").length>0&&(f=f.split("&")[0]),this._hashName&&(f=`${this._hashName}=${h}`);let x=window.location.hash.replace(f,"");x.startsWith("#&")?x=x.slice(0,1)+x.slice(2):x==="#"&&(x="");let T=window.location.href.replace(/(#.+)?$/,x);T=T.replace("&&","&"),window.history.replaceState(window.history.state,null,T)},this._updateHash=ts(this._updateHashUnthrottled,300),this._hashName=t&&encodeURIComponent(t)}addTo(t){return this._map=t,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(t){const n=this._map.getCenter(),h=Math.round(100*this._map.getZoom())/100,f=Math.ceil((h*Math.LN2+Math.log(512/360/.5))/Math.LN10),x=Math.pow(10,f),T=Math.round(n.lng*x)/x,C=Math.round(n.lat*x)/x,D=this._map.getBearing(),B=this._map.getPitch();let N="";if(N+=t?`/${T}/${C}/${h}`:`${h}/${C}/${T}`,(D||B)&&(N+="/"+Math.round(10*D)/10),B&&(N+=`/${Math.round(B)}`),this._hashName){const G=this._hashName;let U=!1;const $=window.location.hash.slice(1).split("&").map((ie=>{const he=ie.split("=")[0];return he===G?(U=!0,`${he}=${N}`):ie})).filter((ie=>ie));return U||$.push(`${G}=${N}`),`#${$.join("&")}`}return`#${N}`}_isValidHash(t){if(t.length<3||t.some(isNaN))return!1;try{new p.V(+t[2],+t[1])}catch{return!1}const n=+t[0],h=+(t[3]||0),f=+(t[4]||0);return n>=this._map.getMinZoom()&&n<=this._map.getMaxZoom()&&h>=-180&&h<=180&&f>=this._map.getMinPitch()&&f<=this._map.getMaxPitch()}}const wr={linearity:.3,easing:p.cw(0,0,.3,1)},yu=p.e({deceleration:2500,maxSpeed:1400},wr),bs=p.e({deceleration:20,maxSpeed:1400},wr),xn=p.e({deceleration:1e3,maxSpeed:360},wr),Ou=p.e({deceleration:1e3,maxSpeed:90},wr),lr=p.e({deceleration:1e3,maxSpeed:360},wr);class ul{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:Gt(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,n=Gt();for(;t.length>0&&n-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const n={zoom:0,bearing:0,pitch:0,roll:0,pan:new p.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:x}of this._inertiaBuffer)n.zoom+=x.zoomDelta||0,n.bearing+=x.bearingDelta||0,n.pitch+=x.pitchDelta||0,n.roll+=x.rollDelta||0,x.panDelta&&n.pan._add(x.panDelta),x.around&&(n.around=x.around),x.pinchAround&&(n.pinchAround=x.pinchAround);const h=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,f={};if(n.pan.mag()){const x=hl(n.pan.mag(),h,p.e({},yu,t||{})),T=n.pan.mult(x.amount/n.pan.mag()),C=this._map.cameraHelper.handlePanInertia(T,this._map.transform);f.center=C.easingCenter,f.offset=C.easingOffset,Do(f,x)}if(n.zoom){const x=hl(n.zoom,h,bs);f.zoom=this._map.transform.zoom+x.amount,Do(f,x)}if(n.bearing){const x=hl(n.bearing,h,xn);f.bearing=this._map.transform.bearing+p.an(x.amount,-179,179),Do(f,x)}if(n.pitch){const x=hl(n.pitch,h,Ou);f.pitch=this._map.transform.pitch+x.amount,Do(f,x)}if(n.roll){const x=hl(n.roll,h,lr);f.roll=this._map.transform.roll+p.an(x.amount,-179,179),Do(f,x)}if(f.zoom||f.bearing){const x=n.pinchAround===void 0?n.around:n.pinchAround;f.around=x?this._map.unproject(x):this._map.getCenter()}return this.clear(),p.e(f,{noMoveStart:!0})}}function Do(y,t){(!y.duration||y.duration<t.duration)&&(y.duration=t.duration,y.easing=t.easing)}function hl(y,t,n){const{maxSpeed:h,linearity:f,deceleration:x}=n,T=p.an(y*f/(t/1e3),-h,h),C=Math.abs(T)/(x*f);return{easing:n.easing,duration:1e3*C,amount:T*(C/2)}}class ht extends p.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n,h,f={}){h=h instanceof MouseEvent?h:new MouseEvent(t,h);const x=rt.mousePos(n.getCanvas(),h),T=n.unproject(x);super(t,p.e({point:x,lngLat:T,originalEvent:h},f)),this._defaultPrevented=!1,this.target=n}}class yt extends p.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n,h){const f=t==="touchend"?h.changedTouches:h.touches,x=rt.touchPos(n.getCanvasContainer(),f),T=x.map((D=>n.unproject(D))),C=x.reduce(((D,B,N,G)=>D.add(B.div(G.length))),new p.P(0,0));super(t,{points:x,point:C,lngLats:T,lngLat:n.unproject(C),originalEvent:h}),this._defaultPrevented=!1}}class Jl extends p.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n,h){super(t,{originalEvent:h}),this._defaultPrevented=!1}}class Nu{constructor(t,n){this._map=t,this._clickTolerance=n.clickTolerance}reset(){delete this._mousedownPos}wheel(t){return this._firePreventable(new Jl(t.type,this._map,t))}mousedown(t,n){return this._mousedownPos=n,this._firePreventable(new ht(t.type,this._map,t))}mouseup(t){this._map.fire(new ht(t.type,this._map,t))}click(t,n){this._mousedownPos&&this._mousedownPos.dist(n)>=this._clickTolerance||this._map.fire(new ht(t.type,this._map,t))}dblclick(t){return this._firePreventable(new ht(t.type,this._map,t))}mouseover(t){this._map.fire(new ht(t.type,this._map,t))}mouseout(t){this._map.fire(new ht(t.type,this._map,t))}touchstart(t){return this._firePreventable(new yt(t.type,this._map,t))}touchmove(t){this._map.fire(new yt(t.type,this._map,t))}touchend(t){this._map.fire(new yt(t.type,this._map,t))}touchcancel(t){this._map.fire(new yt(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class eu{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(t){this._map.fire(new ht(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new ht("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._ignoreContextMenu||this._map.fire(new ht(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class ra{constructor(t){this._map=t}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(t){return this.transform.screenPointToLocation(p.P.convert(t),this._map.terrain)}}class fo{constructor(t,n){this._map=t,this._tr=new ra(t),this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=n.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(t,n){this.isEnabled()&&t.shiftKey&&t.button===0&&(rt.disableDrag(),this._startPos=this._lastPos=n,this._active=!0)}mousemoveWindow(t,n){if(!this._active)return;const h=n;if(this._lastPos.equals(h)||!this._box&&h.dist(this._startPos)<this._clickTolerance)return;const f=this._startPos;this._lastPos=h,this._box||(this._box=rt.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",t));const x=Math.min(f.x,h.x),T=Math.max(f.x,h.x),C=Math.min(f.y,h.y),D=Math.max(f.y,h.y);rt.setTransform(this._box,`translate(${x}px,${C}px)`),this._box.style.width=T-x+"px",this._box.style.height=D-C+"px"}mouseupWindow(t,n){if(!this._active||t.button!==0)return;const h=this._startPos,f=n;if(this.reset(),rt.suppressClick(),h.x!==f.x||h.y!==f.y)return this._map.fire(new p.l("boxzoomend",{originalEvent:t})),{cameraAnimation:x=>x.fitScreenCoordinates(h,f,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",t)}keydown(t){this._active&&t.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",t))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(rt.remove(this._box),this._box=null),rt.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(t,n){return this._map.fire(new p.l(t,{originalEvent:n}))}}function bn(y,t){if(y.length!==t.length)throw new Error(`The number of touches and points are not equal - touches ${y.length}, points ${t.length}`);const n={};for(let h=0;h<y.length;h++)n[y[h].identifier]=t[h];return n}class kt{constructor(t){this.reset(),this.numTouches=t.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(t,n,h){(this.centroid||h.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=t.timeStamp),h.length===this.numTouches&&(this.centroid=(function(f){const x=new p.P(0,0);for(const T of f)x._add(T);return x.div(f.length)})(n),this.touches=bn(h,n)))}touchmove(t,n,h){if(this.aborted||!this.centroid)return;const f=bn(h,n);for(const x in this.touches){const T=f[x];(!T||T.dist(this.touches[x])>30)&&(this.aborted=!0)}}touchend(t,n,h){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),h.length===0){const f=!this.aborted&&this.centroid;if(this.reset(),f)return f}}}class po{constructor(t){this.singleTap=new kt(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(t,n,h){this.singleTap.touchstart(t,n,h)}touchmove(t,n,h){this.singleTap.touchmove(t,n,h)}touchend(t,n,h){const f=this.singleTap.touchend(t,n,h);if(f){const x=t.timeStamp-this.lastTime<500,T=!this.lastTap||this.lastTap.dist(f)<30;if(x&&T||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=f,this.count===this.numTaps)return this.reset(),f}}}class l{constructor(t){this._tr=new ra(t),this._zoomIn=new po({numTouches:1,numTaps:2}),this._zoomOut=new po({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,n,h){this._zoomIn.touchstart(t,n,h),this._zoomOut.touchstart(t,n,h)}touchmove(t,n,h){this._zoomIn.touchmove(t,n,h),this._zoomOut.touchmove(t,n,h)}touchend(t,n,h){const f=this._zoomIn.touchend(t,n,h),x=this._zoomOut.touchend(t,n,h),T=this._tr;return f?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:C=>C.easeTo({duration:300,zoom:T.zoom+1,around:T.unproject(f)},{originalEvent:t})}):x?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:C=>C.easeTo({duration:300,zoom:T.zoom-1,around:T.unproject(x)},{originalEvent:t})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class a{constructor(t){this._enabled=!!t.enable,this._moveStateManager=t.moveStateManager,this._clickTolerance=t.clickTolerance||1,this._moveFunction=t.move,this._activateOnStart=!!t.activateOnStart,t.assignEvents(this),this.reset()}reset(t){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(t)}_move(...t){const n=this._moveFunction(...t);if(n.bearingDelta||n.pitchDelta||n.rollDelta||n.around||n.panDelta)return this._active=!0,n}dragStart(t,n){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(t)&&(this._moveStateManager.startMove(t),this._lastPoint=Array.isArray(n)?n[0]:n,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(t,n){if(!this.isEnabled())return;const h=this._lastPoint;if(!h)return;if(t.preventDefault(),!this._moveStateManager.isValidMoveEvent(t))return void this.reset(t);const f=Array.isArray(n)?n[0]:n;return!this._moved&&f.dist(h)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=f,this._move(h,f))}dragEnd(t){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(t)&&(this._moved&&rt.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 c=0,m=2,g={[c]:1,[m]:2};class w{constructor(t){this._correctEvent=t.checkCorrectEvent}startMove(t){const n=rt.mouseButton(t);this._eventButton=n}endMove(t){delete this._eventButton}isValidStartEvent(t){return this._correctEvent(t)}isValidMoveEvent(t){return!(function(n,h){const f=g[h];return n.buttons===void 0||(n.buttons&f)!==f})(t,this._eventButton)}isValidEndEvent(t){return rt.mouseButton(t)===this._eventButton}}class P{constructor(){this._firstTouch=void 0}_isOneFingerTouch(t){return t.targetTouches.length===1}_isSameTouchEvent(t){return t.targetTouches[0].identifier===this._firstTouch}startMove(t){this._firstTouch=t.targetTouches[0].identifier}endMove(t){delete this._firstTouch}isValidStartEvent(t){return this._isOneFingerTouch(t)}isValidMoveEvent(t){return this._isOneFingerTouch(t)&&this._isSameTouchEvent(t)}isValidEndEvent(t){return this._isOneFingerTouch(t)&&this._isSameTouchEvent(t)}}class S{constructor(t=new w({checkCorrectEvent:()=>!0}),n=new P){this.mouseMoveStateManager=t,this.oneFingerTouchMoveStateManager=n}_executeRelevantHandler(t,n,h){return t instanceof MouseEvent?n(t):typeof TouchEvent<"u"&&t instanceof TouchEvent?h(t):void 0}startMove(t){this._executeRelevantHandler(t,(n=>this.mouseMoveStateManager.startMove(n)),(n=>this.oneFingerTouchMoveStateManager.startMove(n)))}endMove(t){this._executeRelevantHandler(t,(n=>this.mouseMoveStateManager.endMove(n)),(n=>this.oneFingerTouchMoveStateManager.endMove(n)))}isValidStartEvent(t){return this._executeRelevantHandler(t,(n=>this.mouseMoveStateManager.isValidStartEvent(n)),(n=>this.oneFingerTouchMoveStateManager.isValidStartEvent(n)))}isValidMoveEvent(t){return this._executeRelevantHandler(t,(n=>this.mouseMoveStateManager.isValidMoveEvent(n)),(n=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(n)))}isValidEndEvent(t){return this._executeRelevantHandler(t,(n=>this.mouseMoveStateManager.isValidEndEvent(n)),(n=>this.oneFingerTouchMoveStateManager.isValidEndEvent(n)))}}const z=y=>{y.mousedown=y.dragStart,y.mousemoveWindow=y.dragMove,y.mouseup=y.dragEnd,y.contextmenu=t=>{t.preventDefault()}};class O{constructor(t,n){this._clickTolerance=t.clickTolerance||1,this._map=n,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new p.P(0,0)}_shouldBePrevented(t){return t<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(t,n,h){return this._calculateTransform(t,n,h)}touchmove(t,n,h){if(this._active){if(!this._shouldBePrevented(h.length))return t.preventDefault(),this._calculateTransform(t,n,h);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",t)}}touchend(t,n,h){this._calculateTransform(t,n,h),this._active&&this._shouldBePrevented(h.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(t,n,h){h.length>0&&(this._active=!0);const f=bn(h,n),x=new p.P(0,0),T=new p.P(0,0);let C=0;for(const B in f){const N=f[B],G=this._touches[B];G&&(x._add(N),T._add(N.sub(G)),C++,f[B]=N)}if(this._touches=f,this._shouldBePrevented(C)||!T.mag())return;const D=T.div(C);return this._sum._add(D),this._sum.mag()<this._clickTolerance?void 0:{around:x.div(C),panDelta:D}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Z{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(t,n,h){this._firstTwoTouches||h.length<2||(this._firstTwoTouches=[h[0].identifier,h[1].identifier],this._start([n[0],n[1]]))}touchmove(t,n,h){if(!this._firstTwoTouches)return;t.preventDefault();const[f,x]=this._firstTwoTouches,T=se(h,n,f),C=se(h,n,x);if(!T||!C)return;const D=this._aroundCenter?null:T.add(C).div(2);return this._move([T,C],D,t)}touchend(t,n,h){if(!this._firstTwoTouches)return;const[f,x]=this._firstTwoTouches,T=se(h,n,f),C=se(h,n,x);T&&C||(this._active&&rt.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(t){this._enabled=!0,this._aroundCenter=!!t&&t.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}}function se(y,t,n){for(let h=0;h<y.length;h++)if(y[h].identifier===n)return t[h]}function pe(y,t){return Math.log(y/t)/Math.LN2}class de extends Z{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(t){this._startDistance=this._distance=t[0].dist(t[1])}_move(t,n){const h=this._distance;if(this._distance=t[0].dist(t[1]),this._active||!(Math.abs(pe(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:pe(this._distance,h),pinchAround:n}}}function me(y,t){return 180*y.angleWith(t)/Math.PI}class Ie extends Z{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,n,h){const f=this._vector;if(this._vector=t[0].sub(t[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:me(this._vector,f),pinchAround:n}}_isBelowThreshold(t){this._minDiameter=Math.min(this._minDiameter,t.mag());const n=25/(Math.PI*this._minDiameter)*360,h=me(t,this._startVector);return Math.abs(h)<n}}function Be(y){return Math.abs(y.y)>Math.abs(y.x)}class Je extends Z{constructor(t){super(),this._currentTouchCount=0,this._map=t}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(t,n,h){super.touchstart(t,n,h),this._currentTouchCount=h.length}_start(t){this._lastPoints=t,Be(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,n,h){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const f=t[0].sub(this._lastPoints[0]),x=t[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(f,x,h.timeStamp),this._valid?(this._lastPoints=t,this._active=!0,{pitchDelta:(f.y+x.y)/2*-.5}):void 0}gestureBeginsVertically(t,n,h){if(this._valid!==void 0)return this._valid;const f=t.mag()>=2,x=n.mag()>=2;if(!f&&!x)return;if(!f||!x)return this._firstMove===void 0&&(this._firstMove=h),h-this._firstMove<100&&void 0;const T=t.y>0==n.y>0;return Be(t)&&Be(n)&&T}}const Oe={panStep:100,bearingStep:15,pitchStep:10};class ze{constructor(t){this._tr=new ra(t);const n=Oe;this._panStep=n.panStep,this._bearingStep=n.bearingStep,this._pitchStep=n.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let n=0,h=0,f=0,x=0,T=0;switch(t.keyCode){case 61:case 107:case 171:case 187:n=1;break;case 189:case 109:case 173:n=-1;break;case 37:t.shiftKey?h=-1:(t.preventDefault(),x=-1);break;case 39:t.shiftKey?h=1:(t.preventDefault(),x=1);break;case 38:t.shiftKey?f=1:(t.preventDefault(),T=-1);break;case 40:t.shiftKey?f=-1:(t.preventDefault(),T=1);break;default:return}return this._rotationDisabled&&(h=0,f=0),{cameraAnimation:C=>{const D=this._tr;C.easeTo({duration:300,easeId:"keyboardHandler",easing:De,zoom:n?Math.round(D.zoom)+n*(t.shiftKey?2:1):D.zoom,bearing:D.bearing+h*this._bearingStep,pitch:D.pitch+f*this._pitchStep,offset:[-x*this._panStep,-T*this._panStep],center:D.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 De(y){return y*(2-y)}const bt=4.000244140625,Zt=1/450;class Nt{constructor(t,n){this._onTimeout=h=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(h)},this._map=t,this._tr=new ra(t),this._triggerRenderFrame=n,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=Zt}setZoomRate(t){this._defaultZoomRate=t}setWheelZoomRate(t){this._wheelZoomRate=t}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!t&&t.around==="center")}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 n=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const h=Gt(),f=h-(this._lastWheelEventTime||0);this._lastWheelEventTime=h,n!==0&&n%bt==0?this._type="wheel":n!==0&&Math.abs(n)<4?this._type="trackpad":f>400?(this._type=null,this._lastValue=n,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(f*n)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,n+=this._lastValue)),t.shiftKey&&n&&(n/=4),this._type&&(this._lastWheelEvent=t,this._delta-=n,this._active||this._start(t)),t.preventDefault()}_start(t){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const n=rt.mousePos(this._map.getCanvas(),t),h=this._tr;this._aroundPoint=this._aroundCenter?h.transform.locationToScreenPoint(p.V.convert(h.center)):n,this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const t=this._tr.transform;if(typeof this._lastExpectedZoom=="number"){const C=t.zoom-this._lastExpectedZoom;typeof this._startZoom=="number"&&(this._startZoom+=C),typeof this._targetZoom=="number"&&(this._targetZoom+=C)}if(this._delta!==0){const C=this._type==="wheel"&&Math.abs(this._delta)>bt?this._wheelZoomRate:this._defaultZoomRate;let D=2/(1+Math.exp(-Math.abs(this._delta*C)));this._delta<0&&D!==0&&(D=1/D);const B=typeof this._targetZoom!="number"?t.scale:p.aq(this._targetZoom);this._targetZoom=t.applyConstrain(t.getCameraLngLat(),p.at(B*D)).zoom,this._type==="wheel"&&(this._startZoom=t.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const n=typeof this._targetZoom!="number"?t.zoom:this._targetZoom,h=this._startZoom,f=this._easing;let x,T=!1;if(this._type==="wheel"&&h&&f){const C=Gt()-this._lastWheelEventTime,D=Math.min((C+5)/200,1),B=f(D);x=p.G.number(h,n,B),D<1?this._frameId||(this._frameId=!0):T=!0}else x=n,T=!0;return this._active=!0,T&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout}),200)),this._lastExpectedZoom=x,{noInertia:!0,needsRenderFrame:!T,zoomDelta:x-t.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let n=p.cy;if(this._prevEase){const h=this._prevEase,f=(Gt()-h.start)/h.duration,x=h.easing(f+.01)-h.easing(f),T=.27/Math.sqrt(x*x+1e-4)*.01,C=Math.sqrt(.0729-T*T);n=p.cw(T,C,.25,1)}return this._prevEase={start:Gt(),duration:t,easing:n},n}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class ai{constructor(t,n){this._clickZoom=t,this._tapZoom=n}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class pi{constructor(t){this._tr=new ra(t),this.reset()}reset(){this._active=!1}dblclick(t,n){return t.preventDefault(),{cameraAnimation:h=>{h.easeTo({duration:300,zoom:this._tr.zoom+(t.shiftKey?-1:1),around:this._tr.unproject(n)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Mi{constructor(){this._tap=new po({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(t,n,h){if(!this._swipePoint)if(this._tapTime){const f=n[0],x=t.timeStamp-this._tapTime<500,T=this._tapPoint.dist(f)<30;x&&T?h.length>0&&(this._swipePoint=f,this._swipeTouch=h[0].identifier):this.reset()}else this._tap.touchstart(t,n,h)}touchmove(t,n,h){if(this._tapTime){if(this._swipePoint){if(h[0].identifier!==this._swipeTouch)return;const f=n[0],x=f.y-this._swipePoint.y;return this._swipePoint=f,t.preventDefault(),this._active=!0,{zoomDelta:x/128}}}else this._tap.touchmove(t,n,h)}touchend(t,n,h){if(this._tapTime)this._swipePoint&&h.length===0&&this.reset();else{const f=this._tap.touchend(t,n,h);f&&(this._tapTime=t.timeStamp,this._tapPoint=f)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class ei{constructor(t,n,h){this._el=t,this._mousePan=n,this._touchPan=h}enable(t){this._inertiaOptions=t||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Vt{constructor(t,n,h,f){this._pitchWithRotate=t.pitchWithRotate,this._rollEnabled=t.rollEnabled,this._mouseRotate=n,this._mousePitch=h,this._mouseRoll=f}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}}class vt{constructor(t,n,h,f){this._el=t,this._touchZoom=n,this._touchRotate=h,this._tapDragZoom=f,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()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}class _t{constructor(t,n){this._bypassKey=navigator.userAgent.indexOf("Mac")!==-1?"metaKey":"ctrlKey",this._map=t,this._options=n,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;const t=this._map.getCanvasContainer();t.classList.add("maplibregl-cooperative-gestures"),this._container=rt.create("div","maplibregl-cooperative-gesture-screen",t);let n=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(n=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const h=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),f=document.createElement("div");f.className="maplibregl-desktop-message",f.textContent=n,this._container.appendChild(f);const x=document.createElement("div");x.className="maplibregl-mobile-message",x.textContent=h,this._container.appendChild(x),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(rt.remove(this._container),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,n){this._enabled&&(this._map.fire(new p.l("cooperativegestureprevented",{gestureType:t,originalEvent:n})),this._container.classList.add("maplibregl-show"),setTimeout((()=>{this._container.classList.remove("maplibregl-show")}),100))}}const Mt=y=>y.zoom||y.drag||y.roll||y.pitch||y.rotate;class li extends p.l{}function Yi(y){return y.panDelta&&y.panDelta.mag()||y.zoomDelta||y.bearingDelta||y.pitchDelta||y.rollDelta}class wn{constructor(t,n){this.handleWindowEvent=f=>{this.handleEvent(f,`${f.type}Window`)},this.handleEvent=(f,x)=>{if(f.type==="blur")return void this.stop(!0);this._updatingCamera=!0;const T=f.type==="renderFrame"?void 0:f,C={needsRenderFrame:!1},D={},B={};for(const{handlerName:U,handler:$,allowed:ie}of this._handlers){if(!$.isEnabled())continue;let he;if(this._blockedByActive(B,ie,U))$.reset();else if($[x||f.type]){if(p.cz(f,x||f.type)){const Ae=rt.mousePos(this._map.getCanvas(),f);he=$[x||f.type](f,Ae)}else if(p.cA(f,x||f.type)){const Ae=this._getMapTouches(f.touches),ce=rt.touchPos(this._map.getCanvas(),Ae);he=$[x||f.type](f,ce,Ae)}else p.cB(x||f.type)||(he=$[x||f.type](f));this.mergeHandlerResult(C,D,he,U,T),he&&he.needsRenderFrame&&this._triggerRenderFrame()}(he||$.isActive())&&(B[U]=$)}const N={};for(const U in this._previousActiveHandlers)B[U]||(N[U]=T);this._previousActiveHandlers=B,(Object.keys(N).length||Yi(C))&&(this._changes.push([C,D,N]),this._triggerRenderFrame()),(Object.keys(B).length||Yi(C))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:G}=C;G&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],G(this._map))},this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new ul(t),this._bearingSnap=n.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(n);const h=this._el;this._listeners=[[h,"touchstart",{passive:!0}],[h,"touchmove",{passive:!1}],[h,"touchend",void 0],[h,"touchcancel",void 0],[h,"mousedown",void 0],[h,"mousemove",void 0],[h,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[h,"mouseover",void 0],[h,"mouseout",void 0],[h,"dblclick",void 0],[h,"click",void 0],[h,"keydown",{capture:!1}],[h,"keyup",void 0],[h,"wheel",{passive:!1}],[h,"contextmenu",void 0],[window,"blur",void 0]];for(const[f,x,T]of this._listeners)rt.addEventListener(f,x,f===document?this.handleWindowEvent:this.handleEvent,T)}destroy(){for(const[t,n,h]of this._listeners)rt.removeEventListener(t,n,t===document?this.handleWindowEvent:this.handleEvent,h)}_addDefaultHandlers(t){const n=this._map,h=n.getCanvasContainer();this._add("mapEvent",new Nu(n,t));const f=n.boxZoom=new fo(n,t);this._add("boxZoom",f),t.interactive&&t.boxZoom&&f.enable();const x=n.cooperativeGestures=new _t(n,t.cooperativeGestures);this._add("cooperativeGestures",x),t.cooperativeGestures&&x.enable();const T=new l(n),C=new pi(n);n.doubleClickZoom=new ai(C,T),this._add("tapZoom",T),this._add("clickZoom",C),t.interactive&&t.doubleClickZoom&&n.doubleClickZoom.enable();const D=new Mi;this._add("tapDragZoom",D);const B=n.touchPitch=new Je(n);this._add("touchPitch",B),t.interactive&&t.touchPitch&&n.touchPitch.enable(t.touchPitch);const N=()=>n.project(n.getCenter()),G=(function({enable:_e,clickTolerance:we,aroundCenter:Ce=!0,minPixelCenterThreshold:be=100,rotateDegreesPerPixelMoved:Le=.8},Ke){const He=new w({checkCorrectEvent:$e=>rt.mouseButton($e)===0&&$e.ctrlKey||rt.mouseButton($e)===2&&!$e.ctrlKey});return new a({clickTolerance:we,move:($e,Ye)=>{const xt=Ke();if(Ce&&Math.abs(xt.y-$e.y)>be)return{bearingDelta:p.cx(new p.P($e.x,Ye.y),Ye,xt)};let wt=(Ye.x-$e.x)*Le;return Ce&&Ye.y<xt.y&&(wt=-wt),{bearingDelta:wt}},moveStateManager:He,enable:_e,assignEvents:z})})(t,N),U=(function({enable:_e,clickTolerance:we,pitchDegreesPerPixelMoved:Ce=-.5}){const be=new w({checkCorrectEvent:Le=>rt.mouseButton(Le)===0&&Le.ctrlKey||rt.mouseButton(Le)===2});return new a({clickTolerance:we,move:(Le,Ke)=>({pitchDelta:(Ke.y-Le.y)*Ce}),moveStateManager:be,enable:_e,assignEvents:z})})(t),$=(function({enable:_e,clickTolerance:we,rollDegreesPerPixelMoved:Ce=.3},be){const Le=new w({checkCorrectEvent:Ke=>rt.mouseButton(Ke)===2&&Ke.ctrlKey});return new a({clickTolerance:we,move:(Ke,He)=>{const $e=be();let Ye=(He.x-Ke.x)*Ce;return He.y<$e.y&&(Ye=-Ye),{rollDelta:Ye}},moveStateManager:Le,enable:_e,assignEvents:z})})(t,N);n.dragRotate=new Vt(t,G,U,$),this._add("mouseRotate",G,["mousePitch"]),this._add("mousePitch",U,["mouseRotate","mouseRoll"]),this._add("mouseRoll",$,["mousePitch"]),t.interactive&&t.dragRotate&&n.dragRotate.enable();const ie=(function({enable:_e,clickTolerance:we}){const Ce=new w({checkCorrectEvent:be=>rt.mouseButton(be)===0&&!be.ctrlKey});return new a({clickTolerance:we,move:(be,Le)=>({around:Le,panDelta:Le.sub(be)}),activateOnStart:!0,moveStateManager:Ce,enable:_e,assignEvents:z})})(t),he=new O(t,n);n.dragPan=new ei(h,ie,he),this._add("mousePan",ie),this._add("touchPan",he,["touchZoom","touchRotate"]),t.interactive&&t.dragPan&&n.dragPan.enable(t.dragPan);const Ae=new Ie,ce=new de;n.touchZoomRotate=new vt(h,ce,Ae,D),this._add("touchRotate",Ae,["touchPan","touchZoom"]),this._add("touchZoom",ce,["touchPan","touchRotate"]),t.interactive&&t.touchZoomRotate&&n.touchZoomRotate.enable(t.touchZoomRotate),this._add("blockableMapEvent",new eu(n));const ye=n.scrollZoom=new Nt(n,(()=>this._triggerRenderFrame()));this._add("scrollZoom",ye,["mousePan"]),t.interactive&&t.scrollZoom&&n.scrollZoom.enable(t.scrollZoom);const Pe=n.keyboard=new ze(n);this._add("keyboard",Pe),t.interactive&&t.keyboard&&n.keyboard.enable()}_add(t,n,h){this._handlers.push({handlerName:t,handler:n,allowed:h}),this._handlersById[t]=n}stop(t){if(!this._updatingCamera){for(const{handler:n}of this._handlers)n.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[]}}isActive(){for(const{handler:t}of this._handlers)if(t.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!Mt(this._eventsInProgress)||this.isZooming()}_blockedByActive(t,n,h){for(const f in t)if(f!==h&&(!n||n.indexOf(f)<0))return!0;return!1}_getMapTouches(t){const n=[];for(const h of t)this._el.contains(h.target)&&n.push(h);return n}mergeHandlerResult(t,n,h,f,x){if(!h)return;p.e(t,h);const T={handlerName:f,originalEvent:h.originalEvent||x};h.zoomDelta!==void 0&&(n.zoom=T),h.panDelta!==void 0&&(n.drag=T),h.rollDelta!==void 0&&(n.roll=T),h.pitchDelta!==void 0&&(n.pitch=T),h.bearingDelta!==void 0&&(n.rotate=T)}_applyChanges(){const t={},n={},h={};for(const[f,x,T]of this._changes)f.panDelta&&(t.panDelta=(t.panDelta||new p.P(0,0))._add(f.panDelta)),f.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+f.zoomDelta),f.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+f.bearingDelta),f.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+f.pitchDelta),f.rollDelta&&(t.rollDelta=(t.rollDelta||0)+f.rollDelta),f.around!==void 0&&(t.around=f.around),f.pinchAround!==void 0&&(t.pinchAround=f.pinchAround),f.noInertia&&(t.noInertia=f.noInertia),p.e(n,x),p.e(h,T);this._updateMapTransform(t,n,h),this._changes=[]}_updateMapTransform(t,n,h){const f=this._map,x=f._getTransformForUpdate(),T=f.terrain;if(!(Yi(t)||T&&this._terrainMovement))return this._fireEvents(n,h,!0);f._stop(!0);let{panDelta:C,zoomDelta:D,bearingDelta:B,pitchDelta:N,rollDelta:G,around:U,pinchAround:$}=t;$!==void 0&&(U=$),U=U||f.transform.centerPoint,T&&!x.isPointOnMapSurface(U)&&(U=x.centerPoint);const ie={panDelta:C,zoomDelta:D,rollDelta:G,pitchDelta:N,bearingDelta:B,around:U};this._map.cameraHelper.useGlobeControls&&!x.isPointOnMapSurface(U)&&(U=x.centerPoint);const he=U.distSqr(x.centerPoint)<.01?x.center:x.screenPointToLocation(C?U.sub(C):U);this._handleMapControls({terrain:T,tr:x,deltasForHelper:ie,preZoomAroundLoc:he,combinedEventsInProgress:n,panDelta:C}),f._applyUpdatedTransform(x),this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(n,h,!0)}_handleMapControls({terrain:t,tr:n,deltasForHelper:h,preZoomAroundLoc:f,combinedEventsInProgress:x,panDelta:T}){const C=this._map.cameraHelper;if(C.handleMapControlsRollPitchBearingZoom(h,n),t)return C.useGlobeControls?(this._terrainMovement||!x.drag&&!x.zoom||(this._terrainMovement=!0,this._map._elevationFreeze=!0),void C.handleMapControlsPan(h,n,f)):this._terrainMovement||!x.drag&&!x.zoom?void(x.drag&&this._terrainMovement&&T?n.setCenter(n.screenPointToLocation(n.centerPoint.sub(T))):C.handleMapControlsPan(h,n,f)):(this._terrainMovement=!0,this._map._elevationFreeze=!0,void C.handleMapControlsPan(h,n,f));C.handleMapControlsPan(h,n,f)}_fireEvents(t,n,h){const f=Mt(this._eventsInProgress),x=Mt(t),T={};for(const G in t){const{originalEvent:U}=t[G];this._eventsInProgress[G]||(T[`${G}start`]=U),this._eventsInProgress[G]=t[G]}!f&&x&&this._fireEvent("movestart",x.originalEvent);for(const G in T)this._fireEvent(G,T[G]);x&&this._fireEvent("move",x.originalEvent);for(const G in t){const{originalEvent:U}=t[G];this._fireEvent(G,U)}const C={};let D;for(const G in this._eventsInProgress){const{handlerName:U,originalEvent:$}=this._eventsInProgress[G];this._handlersById[U].isActive()||(delete this._eventsInProgress[G],D=n[U]||$,C[`${G}end`]=D)}for(const G in C)this._fireEvent(G,C[G]);const B=Mt(this._eventsInProgress),N=(f||x)&&!B;if(N&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const G=this._map._getTransformForUpdate();this._map.getCenterClampedToGround()&&G.recalculateZoomAndCenter(this._map.terrain),this._map._applyUpdatedTransform(G)}if(h&&N){this._updatingCamera=!0;const G=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),U=$=>$!==0&&-this._bearingSnap<$&&$<this._bearingSnap;!G||!G.essential&&zr.prefersReducedMotion?(this._map.fire(new p.l("moveend",{originalEvent:D})),U(this._map.getBearing())&&this._map.resetNorth()):(U(G.bearing||this._map.getBearing())&&(G.bearing=0),G.freezeElevation=!0,this._map.easeTo(G,{originalEvent:D})),this._updatingCamera=!1}}_fireEvent(t,n){this._map.fire(new p.l(t,n?{originalEvent:n}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add((t=>{delete this._frameId,this.handleEvent(new li("renderFrame",{timeStamp:t})),this._applyChanges()}))}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class is extends p.E{constructor(t,n,h){super(),this._renderFrameCallback=()=>{const f=Math.min((Gt()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(f)),f<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=h.bearingSnap,this.cameraHelper=n,this.on("moveend",(()=>{delete this._requestedCameraState}))}migrateProjection(t,n){t.apply(this.transform,!0),this.transform=t,this.cameraHelper=n}getCenter(){return new p.V(this.transform.center.lng,this.transform.center.lat)}setCenter(t,n){return this.jumpTo({center:t},n)}getCenterElevation(){return this.transform.elevation}setCenterElevation(t,n){return this.jumpTo({elevation:t},n),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(t){this._centerClampedToGround=t}panBy(t,n,h){return t=p.P.convert(t).mult(-1),this.panTo(this.transform.center,p.e({offset:t},n),h)}panTo(t,n,h){return this.easeTo(p.e({center:t},n),h)}getZoom(){return this.transform.zoom}setZoom(t,n){return this.jumpTo({zoom:t},n),this}zoomTo(t,n,h){return this.easeTo(p.e({zoom:t},n),h)}zoomIn(t,n){return this.zoomTo(this.getZoom()+1,t,n),this}zoomOut(t,n){return this.zoomTo(this.getZoom()-1,t,n),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(t,n){return t!=this.transform.fov&&(this.transform.setFov(t),this.fire(new p.l("movestart",n)).fire(new p.l("move",n)).fire(new p.l("moveend",n))),this}getBearing(){return this.transform.bearing}setBearing(t,n){return this.jumpTo({bearing:t},n),this}getPadding(){return this.transform.padding}setPadding(t,n){return this.jumpTo({padding:t},n),this}rotateTo(t,n,h){return this.easeTo(p.e({bearing:t},n),h)}resetNorth(t,n){return this.rotateTo(0,p.e({duration:1e3},t),n),this}resetNorthPitch(t,n){return this.easeTo(p.e({bearing:0,pitch:0,roll:0,duration:1e3},t),n),this}snapToNorth(t,n){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(t,n):this}getPitch(){return this.transform.pitch}setPitch(t,n){return this.jumpTo({pitch:t},n),this}getRoll(){return this.transform.roll}setRoll(t,n){return this.jumpTo({roll:t},n),this}cameraForBounds(t,n){t=Ui.convert(t).adjustAntiMeridian();const h=n&&n.bearing||0;return this._cameraForBoxAndBearing(t.getNorthWest(),t.getSouthEast(),h,n)}_cameraForBoxAndBearing(t,n,h,f){const x={top:0,bottom:0,right:0,left:0};if(typeof(f=p.e({padding:x,offset:[0,0],maxZoom:this.transform.maxZoom},f)).padding=="number"){const B=f.padding;f.padding={top:B,bottom:B,right:B,left:B}}const T=p.e(x,f.padding);f.padding=T;const C=this.transform,D=new Ui(t,n);return this.cameraHelper.cameraForBoxAndBearing(f,T,D,h,C)}fitBounds(t,n,h){return this._fitInternal(this.cameraForBounds(t,n),n,h)}fitScreenCoordinates(t,n,h,f,x){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.screenPointToLocation(p.P.convert(t)),this.transform.screenPointToLocation(p.P.convert(n)),h,f),f,x)}_fitInternal(t,n,h){return t?(delete(n=p.e(t,n)).padding,n.linear?this.easeTo(n,h):this.flyTo(n,h)):this}jumpTo(t,n){this.stop();const h=this._getTransformForUpdate();let f=!1,x=!1,T=!1;const C=h.zoom;this.cameraHelper.handleJumpToCenterZoom(h,t);const D=h.zoom!==C;return"elevation"in t&&h.elevation!==+t.elevation&&h.setElevation(+t.elevation),"bearing"in t&&h.bearing!==+t.bearing&&(f=!0,h.setBearing(+t.bearing)),"pitch"in t&&h.pitch!==+t.pitch&&(x=!0,h.setPitch(+t.pitch)),"roll"in t&&h.roll!==+t.roll&&(T=!0,h.setRoll(+t.roll)),t.padding==null||h.isPaddingEqual(t.padding)||h.setPadding(t.padding),this._applyUpdatedTransform(h),this.fire(new p.l("movestart",n)).fire(new p.l("move",n)),D&&this.fire(new p.l("zoomstart",n)).fire(new p.l("zoom",n)).fire(new p.l("zoomend",n)),f&&this.fire(new p.l("rotatestart",n)).fire(new p.l("rotate",n)).fire(new p.l("rotateend",n)),x&&this.fire(new p.l("pitchstart",n)).fire(new p.l("pitch",n)).fire(new p.l("pitchend",n)),T&&this.fire(new p.l("rollstart",n)).fire(new p.l("roll",n)).fire(new p.l("rollend",n)),this.fire(new p.l("moveend",n))}calculateCameraOptionsFromTo(t,n,h,f=0){const x=p.a9.fromLngLat(t,n),T=p.a9.fromLngLat(h,f),C=T.x-x.x,D=T.y-x.y,B=T.z-x.z,N=Math.hypot(C,D,B);if(N===0)throw new Error("Can't calculate camera options with same From and To");const G=Math.hypot(C,D),U=p.at(this.transform.cameraToCenterDistance/N/this.transform.tileSize),$=180*Math.atan2(C,-D)/Math.PI;let ie=180*Math.acos(G/N)/Math.PI;return ie=B<0?90-ie:90+ie,{center:T.toLngLat(),elevation:f,zoom:U,pitch:ie,bearing:$}}calculateCameraOptionsFromCameraLngLatAltRotation(t,n,h,f,x){const T=this.transform.calculateCenterFromCameraLngLatAlt(t,n,h,f);return{center:T.center,elevation:T.elevation,zoom:T.zoom,bearing:h,pitch:f,roll:x}}easeTo(t,n){this._stop(!1,t.easeId),((t=p.e({offset:[0,0],duration:500,easing:p.cy},t)).animate===!1||!t.essential&&zr.prefersReducedMotion)&&(t.duration=0);const h=this._getTransformForUpdate(),f=this.getBearing(),x=h.pitch,T=h.roll,C="bearing"in t?this._normalizeBearing(t.bearing,f):f,D="pitch"in t?+t.pitch:x,B="roll"in t?this._normalizeBearing(t.roll,T):T,N="padding"in t?t.padding:h.padding,G=p.P.convert(t.offset);let U,$;t.around&&(U=p.V.convert(t.around),$=h.locationToScreenPoint(U));const ie={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching,rolling:this._rolling},he=this.cameraHelper.handleEaseTo(h,{bearing:C,pitch:D,roll:B,padding:N,around:U,aroundPoint:$,offsetAsPoint:G,offset:t.offset,zoom:t.zoom,center:t.center});return this._rotating=this._rotating||f!==C,this._pitching=this._pitching||D!==x,this._rolling=this._rolling||B!==T,this._padding=!h.isPaddingEqual(N),this._zooming=this._zooming||he.isZooming,this._easeId=t.easeId,this._prepareEase(n,t.noMoveStart,ie),this.terrain&&this._prepareElevation(he.elevationCenter),this._ease((Ae=>{he.easeFunc(Ae),this.terrain&&!t.freezeElevation&&this._updateElevation(Ae),this._applyUpdatedTransform(h),this._fireMoveEvents(n)}),(Ae=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(n,Ae)}),t),this}_prepareEase(t,n,h={}){this._moving=!0,n||h.moving||this.fire(new p.l("movestart",t)),this._zooming&&!h.zooming&&this.fire(new p.l("zoomstart",t)),this._rotating&&!h.rotating&&this.fire(new p.l("rotatestart",t)),this._pitching&&!h.pitching&&this.fire(new p.l("pitchstart",t)),this._rolling&&!h.rolling&&this.fire(new p.l("rollstart",t))}_prepareElevation(t){this._elevationCenter=t,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(t,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(t){this._elevationStart!==void 0&&this._elevationCenter!==void 0||this._prepareElevation(this.transform.center),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));const n=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(t<1&&n!==this._elevationTarget){const h=this._elevationTarget-this._elevationStart;this._elevationStart+=t*(h-(n-(h*t+this._elevationStart))/(1-t)),this._elevationTarget=n}this.transform.setElevation(p.G.number(this._elevationStart,this._elevationTarget,t))}_finalizeElevation(){this._elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(t){if(!this.terrain&&t.elevation>=0&&t.pitch<=90)return{};const n=t.getCameraLngLat(),h=t.getCameraAltitude(),f=this.terrain?this.terrain.getElevationForLngLatZoom(n,t.zoom):0;if(h<f){const x=this.calculateCameraOptionsFromTo(n,f,t.center,t.elevation);return{pitch:x.pitch,zoom:x.zoom}}return{}}_applyUpdatedTransform(t){const n=[];if(n.push((f=>this._elevateCameraIfInsideTerrain(f))),this.transformCameraUpdate&&n.push((f=>this.transformCameraUpdate(f))),!n.length)return;const h=t.clone();for(const f of n){const x=h.clone(),{center:T,zoom:C,roll:D,pitch:B,bearing:N,elevation:G}=f(x);T&&x.setCenter(T),G!==void 0&&x.setElevation(G),C!==void 0&&x.setZoom(C),D!==void 0&&x.setRoll(D),B!==void 0&&x.setPitch(B),N!==void 0&&x.setBearing(N),h.apply(x,!1)}this.transform.apply(h,!1)}_fireMoveEvents(t){this.fire(new p.l("move",t)),this._zooming&&this.fire(new p.l("zoom",t)),this._rotating&&this.fire(new p.l("rotate",t)),this._pitching&&this.fire(new p.l("pitch",t)),this._rolling&&this.fire(new p.l("roll",t))}_afterEase(t,n){if(this._easeId&&n&&this._easeId===n)return;delete this._easeId;const h=this._zooming,f=this._rotating,x=this._pitching,T=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,h&&this.fire(new p.l("zoomend",t)),f&&this.fire(new p.l("rotateend",t)),x&&this.fire(new p.l("pitchend",t)),T&&this.fire(new p.l("rollend",t)),this.fire(new p.l("moveend",t))}flyTo(t,n){if(!t.essential&&zr.prefersReducedMotion){const Ye=p.U(t,["center","zoom","bearing","pitch","roll","elevation","padding"]);return this.jumpTo(Ye,n)}this.stop(),t=p.e({offset:[0,0],speed:1.2,curve:1.42,easing:p.cy},t);const h=this._getTransformForUpdate(),f=h.bearing,x=h.pitch,T=h.roll,C=h.padding,D="bearing"in t?this._normalizeBearing(t.bearing,f):f,B="pitch"in t?+t.pitch:x,N="roll"in t?this._normalizeBearing(t.roll,T):T,G="padding"in t?t.padding:h.padding,U=p.P.convert(t.offset);let $=h.centerPoint.add(U);const ie=h.screenPointToLocation($),he=this.cameraHelper.handleFlyTo(h,{bearing:D,pitch:B,roll:N,padding:G,locationAtOffset:ie,offsetAsPoint:U,center:t.center,minZoom:t.minZoom,zoom:t.zoom});let Ae=t.curve;const ce=Math.max(h.width,h.height),ye=ce/he.scaleOfZoom,Pe=he.pixelPathLength;typeof he.scaleOfMinZoom=="number"&&(Ae=Math.sqrt(ce/he.scaleOfMinZoom/Pe*2));const _e=Ae*Ae;function we(Ye){const xt=(ye*ye-ce*ce+(Ye?-1:1)*_e*_e*Pe*Pe)/(2*(Ye?ye:ce)*_e*Pe);return Math.log(Math.sqrt(xt*xt+1)-xt)}function Ce(Ye){return(Math.exp(Ye)-Math.exp(-Ye))/2}function be(Ye){return(Math.exp(Ye)+Math.exp(-Ye))/2}const Le=we(!1);let Ke=function(Ye){return be(Le)/be(Le+Ae*Ye)},He=function(Ye){return ce*((be(Le)*(Ce(xt=Le+Ae*Ye)/be(xt))-Ce(Le))/_e)/Pe;var xt},$e=(we(!0)-Le)/Ae;if(Math.abs(Pe)<2e-6||!isFinite($e)){if(Math.abs(ce-ye)<1e-6)return this.easeTo(t,n);const Ye=ye<ce?-1:1;$e=Math.abs(Math.log(ye/ce))/Ae,He=()=>0,Ke=xt=>Math.exp(Ye*Ae*xt)}return t.duration="duration"in t?+t.duration:1e3*$e/("screenSpeed"in t?+t.screenSpeed/Ae:+t.speed),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0),this._zooming=!0,this._rotating=f!==D,this._pitching=B!==x,this._rolling=N!==T,this._padding=!h.isPaddingEqual(G),this._prepareEase(n,!1),this.terrain&&this._prepareElevation(he.targetCenter),this._ease((Ye=>{const xt=Ye*$e,wt=1/Ke(xt),pt=He(xt);this._rotating&&h.setBearing(p.G.number(f,D,Ye)),this._pitching&&h.setPitch(p.G.number(x,B,Ye)),this._rolling&&h.setRoll(p.G.number(T,N,Ye)),this._padding&&(h.interpolatePadding(C,G,Ye),$=h.centerPoint.add(U)),he.easeFunc(Ye,wt,pt,$),this.terrain&&!t.freezeElevation&&this._updateElevation(Ye),this._applyUpdatedTransform(h),this._fireMoveEvents(n)}),(()=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(n)}),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(t,n){var h;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const f=this._onEaseEnd;delete this._onEaseEnd,f.call(this,n)}return t||(h=this.handlers)===null||h===void 0||h.stop(!1),this}_ease(t,n,h){h.animate===!1||h.duration===0?(t(1),n()):(this._easeStart=Gt(),this._easeOptions=h,this._onEaseFrame=t,this._onEaseEnd=n,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(t,n){t=p.W(t,-180,180);const h=Math.abs(t-n);return Math.abs(t-360-n)<h&&(t-=360),Math.abs(t+360-n)<h&&(t+=360),t}queryTerrainElevation(t){return this.terrain?this.terrain.getElevationForLngLat(p.V.convert(t),this.transform):null}}const ko={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};class dh{constructor(t=ko){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=n=>{!n||n.sourceDataType!=="metadata"&&n.sourceDataType!=="visibility"&&n.dataType!=="style"&&n.type!=="terrain"||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact===!1?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=rt.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=rt.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=rt.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(){rt.remove(this._container),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,n){const h=this._map._getUIString(`AttributionControl.${n}`);t.title=h,t.setAttribute("aria-label",h)}_updateAttributions(){if(!this._map.style)return;let t=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=t.concat(this.options.customAttribution.map((f=>typeof f!="string"?"":f))):typeof this.options.customAttribution=="string"&&t.push(this.options.customAttribution)),this._map.style.stylesheet){const f=this._map.style.stylesheet;this.styleOwner=f.owner,this.styleId=f.id}const n=this._map.style.tileManagers;for(const f in n){const x=n[f];if(x.used||x.usedForTerrain){const T=x.getSource();T.attribution&&t.indexOf(T.attribution)<0&&t.push(T.attribution)}}t=t.filter((f=>String(f).trim())),t.sort(((f,x)=>f.length-x.length)),t=t.filter(((f,x)=>{for(let T=x+1;T<t.length;T++)if(t[T].indexOf(f)>=0)return!1;return!0}));const h=t.join(" | ");h!==this._attribHTML&&(this._attribHTML=h,t.length?(this._innerContainer.innerHTML=rt.sanitize(h),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class Qh{constructor(t={}){this._updateCompact=()=>{const n=this._container.children;if(n.length){const h=n[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&h.classList.add("maplibregl-compact"):h.classList.remove("maplibregl-compact")}},this.options=t}getDefaultPosition(){return"bottom-left"}onAdd(t){this._map=t,this._compact=this.options&&this.options.compact,this._container=rt.create("div","maplibregl-ctrl");const n=rt.create("a","maplibregl-ctrl-logo");return n.target="_blank",n.rel="noopener nofollow",n.href="https://maplibre.org/",n.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),n.setAttribute("rel","noopener nofollow"),this._container.appendChild(n),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){rt.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class Ic{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){const n=++this._id;return this._queue.push({callback:t,id:n,cancelled:!1}),n}remove(t){const n=this._currentlyRunning,h=n?this._queue.concat(n):this._queue;for(const f of h)if(f.id===t)return void(f.cancelled=!0)}run(t=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const n=this._currentlyRunning=this._queue;this._queue=[];for(const h of n)if(!h.cancelled&&(h.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var Dc=p.aU([{name:"a_pos3d",type:"Int16",components:3}]);class vu extends p.E{constructor(t){super(),this._lastTilesetChange=Gt(),this.tileManager=t,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=t._source.tileSize*2**this.deltaZoom,t.usedForTerrain=!0,t.tileSize=this.tileSize}destruct(){this.tileManager.usedForTerrain=!1,this.tileManager.tileSize=null}getSource(){return this.tileManager._source}update(t,n){this.tileManager.update(t,n),this._renderableTilesKeys=[];const h={};for(const f of er(t,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:n,calculateTileZoom:this.tileManager._source.calculateTileZoom}))h[f.key]=!0,this._renderableTilesKeys.push(f.key),this._tiles[f.key]||(f.terrainRttPosMatrix32f=new Float64Array(16),p.c7(f.terrainRttPosMatrix32f,0,p.a5,p.a5,0,0,1),this._tiles[f.key]=new ft(f,this.tileSize),this._lastTilesetChange=Gt());for(const f in this._tiles)h[f]||delete this._tiles[f]}freeRtt(t){for(const n in this._tiles){const h=this._tiles[n];(!t||h.tileID.equals(t)||h.tileID.isChildOf(t)||t.isChildOf(h.tileID))&&(h.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map((t=>this.getTileByID(t)))}getTileByID(t){return this._tiles[t]}getTerrainCoords(t,n){return n?this._getTerrainCoordsForTileRanges(t,n):this._getTerrainCoordsForRegularTile(t)}_getTerrainCoordsForRegularTile(t){const n={};for(const h of this._renderableTilesKeys){const f=this._tiles[h].tileID,x=t.clone(),T=p.bk();if(f.canonical.equals(t.canonical))p.c7(T,0,p.a5,p.a5,0,0,1);else if(f.canonical.isChildOf(t.canonical)){const C=f.canonical.z-t.canonical.z,D=f.canonical.x-(f.canonical.x>>C<<C),B=f.canonical.y-(f.canonical.y>>C<<C),N=p.a5>>C;p.c7(T,0,N,N,0,0,1),p.O(T,T,[-D*N,-B*N,0])}else{if(!t.canonical.isChildOf(f.canonical))continue;{const C=t.canonical.z-f.canonical.z,D=t.canonical.x-(t.canonical.x>>C<<C),B=t.canonical.y-(t.canonical.y>>C<<C),N=p.a5>>C;p.c7(T,0,p.a5,p.a5,0,0,1),p.O(T,T,[D*N,B*N,0]),p.Q(T,T,[1/2**C,1/2**C,0])}}x.terrainRttPosMatrix32f=new Float32Array(T),n[h]=x}return n}_getTerrainCoordsForTileRanges(t,n){const h={};for(const f of this._renderableTilesKeys){const x=this._tiles[f].tileID;if(!this._isWithinTileRanges(x,n))continue;const T=t.clone(),C=p.bk();if(x.canonical.z===t.canonical.z){const D=t.canonical.x-x.canonical.x+t.wrap*(1<<t.canonical.z),B=t.canonical.y-x.canonical.y;p.c7(C,0,p.a5,p.a5,0,0,1),p.O(C,C,[D*p.a5,B*p.a5,0])}else if(x.canonical.z>t.canonical.z){const D=x.canonical.z-t.canonical.z,B=x.canonical.x-(x.canonical.x>>D<<D)+t.wrap*(1<<x.canonical.z),N=x.canonical.y-(x.canonical.y>>D<<D),G=t.canonical.x-(x.canonical.x>>D),U=t.canonical.y-(x.canonical.y>>D),$=p.a5>>D;p.c7(C,0,$,$,0,0,1),p.O(C,C,[-B*$+G*p.a5,-N*$+U*p.a5,0])}else{const D=t.canonical.z-x.canonical.z,B=t.canonical.x-(t.canonical.x>>D<<D)+t.wrap*(1<<t.canonical.z),N=t.canonical.y-(t.canonical.y>>D<<D),G=(t.canonical.x>>D)-x.canonical.x,U=(t.canonical.y>>D)-x.canonical.y,$=p.a5<<D;p.c7(C,0,$,$,0,0,1),p.O(C,C,[B*p.a5+G*$,N*p.a5+U*$,0])}T.terrainRttPosMatrix32f=new Float32Array(C),h[f]=T}return h}getSourceTile(t,n){const h=this.tileManager._source;let f=t.overscaledZ-this.deltaZoom;if(f>h.maxzoom&&(f=h.maxzoom),f<h.minzoom)return;this._sourceTileCache[t.key]||(this._sourceTileCache[t.key]=t.scaledTo(f).key);let x=this.findTileInCaches(this._sourceTileCache[t.key]);if(!(x!=null&&x.dem)&&n)for(;f>=h.minzoom&&!(x!=null&&x.dem);)x=this.findTileInCaches(t.scaledTo(f--).key);return x}findTileInCaches(t){let n=this.tileManager.getTileByID(t);return n||(n=this.tileManager._outOfViewCache.getByKey(t),n)}anyTilesAfterTime(t=Date.now()){return this._lastTilesetChange>=t}_isWithinTileRanges(t,n){const h=n[t.canonical.z];return!!h&&(t.wrap>h.minWrap||t.wrap<h.maxWrap||t.canonical.x>=h.minTileXWrapped&&t.canonical.x<=h.maxTileXWrapped&&t.canonical.y>=h.minTileY&&t.canonical.y<=h.maxTileY)}}class Gr{constructor(t,n,h){this._meshCache={},this.painter=t,this.tileManager=new vu(n),this.options=h,this.exaggeration=typeof h.exaggeration=="number"?h.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(t,n,h,f=p.a5){var x;if(!(n>=0&&n<f&&h>=0&&h<f))return 0;const T=this.getTerrainData(t),C=(x=T.tile)===null||x===void 0?void 0:x.dem;if(!C)return 0;const D=p.cC([],[n/f*p.a5,h/f*p.a5],T.u_terrain_matrix),B=[D[0]*C.dim,D[1]*C.dim],N=Math.floor(B[0]),G=Math.floor(B[1]),U=B[0]-N,$=B[1]-G;return C.get(N,G)*(1-U)*(1-$)+C.get(N+1,G)*U*(1-$)+C.get(N,G+1)*(1-U)*$+C.get(N+1,G+1)*U*$}getElevationForLngLatZoom(t,n){if(!p.cD(n,t.wrap()))return 0;const{tileID:h,mercatorX:f,mercatorY:x}=this._getOverscaledTileIDFromLngLatZoom(t,n);return this.getElevation(h,f%p.a5,x%p.a5,p.a5)}getElevationForLngLat(t,n){const h=er(n,{maxzoom:this.tileManager.maxzoom,minzoom:this.tileManager.minzoom,tileSize:512,terrain:this});let f=0;for(const x of h)x.canonical.z>f&&(f=Math.min(x.canonical.z,this.tileManager.maxzoom));return this.getElevationForLngLatZoom(t,f)}getElevation(t,n,h,f=p.a5){return this.getDEMElevation(t,n,h,f)*this.exaggeration}getTerrainData(t){if(!this._emptyDemTexture){const f=this.painter.context,x=new p.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new p.T(f,x,f.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new p.T(f,new p.R({width:1,height:1}),f.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(f.gl.NEAREST,f.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=p.ar([])}const n=this.tileManager.getSourceTile(t,!0);if(n&&n.dem&&(!n.demTexture||n.needsTerrainPrepare)){const f=this.painter.context;n.demTexture=this.painter.getTileTexture(n.dem.stride),n.demTexture?n.demTexture.update(n.dem.getPixels(),{premultiply:!1}):n.demTexture=new p.T(f,n.dem.getPixels(),f.gl.RGBA,{premultiply:!1}),n.demTexture.bind(f.gl.NEAREST,f.gl.CLAMP_TO_EDGE),n.needsTerrainPrepare=!1}const h=n&&n.toString()+n.tileID.key+t.key;if(h&&!this._demMatrixCache[h]){const f=this.tileManager.getSource().maxzoom;let x=t.canonical.z-n.tileID.canonical.z;t.overscaledZ>t.canonical.z&&(t.canonical.z>=f?x=t.canonical.z-f:p.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const T=t.canonical.x-(t.canonical.x>>x<<x),C=t.canonical.y-(t.canonical.y>>x<<x),D=p.cE(new Float64Array(16),[1/(p.a5<<x),1/(p.a5<<x),0]);p.O(D,D,[T*p.a5,C*p.a5,0]),this._demMatrixCache[t.key]={matrix:D,coord:t}}return{u_depth:2,u_terrain:3,u_terrain_dim:n&&n.dem&&n.dem.dim||1,u_terrain_matrix:h?this._demMatrixCache[t.key].matrix:this._emptyDemMatrix,u_terrain_unpack:n&&n.dem&&n.dem.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(n&&n.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:n}}getFramebuffer(t){const n=this.painter,h=n.width/devicePixelRatio,f=n.height/devicePixelRatio;return!this._fbo||this._fbo.width===h&&this._fbo.height===f||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new p.T(n.context,{width:h,height:f,data:null},n.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(n.context.gl.NEAREST,n.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new p.T(n.context,{width:h,height:f,data:null},n.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(n.context.gl.NEAREST,n.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=n.context.createFramebuffer(h,f,!0,!1),this._fbo.depthAttachment.set(n.context.createRenderbuffer(n.context.gl.DEPTH_COMPONENT16,h,f))),this._fbo.colorAttachment.set(t==="coords"?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){const t=this.painter.context;if(this._coordsTexture)return this._coordsTexture;const n=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let x=0,T=0;x<this._coordsTextureSize;x++)for(let C=0;C<this._coordsTextureSize;C++,T+=4)n[T+0]=255&C,n[T+1]=255&x,n[T+2]=C>>8<<4|x>>8,n[T+3]=0;const h=new p.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(n.buffer)),f=new p.T(t,h,t.gl.RGBA,{premultiply:!1});return f.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._coordsTexture=f,f}pointCoordinate(t){this.painter.maybeDrawDepthAndCoords(!0);const n=new Uint8Array(4),h=this.painter.context,f=h.gl,x=Math.round(t.x*this.painter.pixelRatio/devicePixelRatio),T=Math.round(t.y*this.painter.pixelRatio/devicePixelRatio),C=Math.round(this.painter.height/devicePixelRatio);h.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),f.readPixels(x,C-T-1,1,1,f.RGBA,f.UNSIGNED_BYTE,n),h.bindFramebuffer.set(null);const D=n[0]+(n[2]>>4<<8),B=n[1]+((15&n[2])<<8),N=this.coordsIndex[255-n[3]],G=N&&this.tileManager.getTileByID(N);if(!G)return null;const U=this._coordsTextureSize,$=(1<<G.tileID.canonical.z)*U;return new p.a9((G.tileID.canonical.x*U+D)/$+G.tileID.wrap,(G.tileID.canonical.y*U+B)/$,this.getElevation(G.tileID,D,B,U))}depthAtPoint(t){const n=new Uint8Array(4),h=this.painter.context,f=h.gl;return h.bindFramebuffer.set(this.getFramebuffer("depth").framebuffer),f.readPixels(t.x,this.painter.height/devicePixelRatio-t.y-1,1,1,f.RGBA,f.UNSIGNED_BYTE,n),h.bindFramebuffer.set(null),(n[0]/16777216+n[1]/65536+n[2]/256+n[3])/256}getTerrainMesh(t){var n;const h=((n=this.painter.style.projection)===null||n===void 0?void 0:n.transitionState)>0,f=h&&t.canonical.y===0,x=h&&t.canonical.y===(1<<t.canonical.z)-1,T=`m_${f?"n":""}_${x?"s":""}`;if(this._meshCache[T])return this._meshCache[T];const C=this.painter.context,D=new p.cF,B=new p.aY,N=this.meshSize,G=p.a5/N,U=N*N;for(let be=0;be<=N;be++)for(let Le=0;Le<=N;Le++)D.emplaceBack(Le*G,be*G,0);for(let be=0;be<U;be+=N+1)for(let Le=0;Le<N;Le++)B.emplaceBack(Le+be,N+Le+be+1,N+Le+be+2),B.emplaceBack(Le+be,N+Le+be+2,Le+be+1);const $=D.length,ie=$+(N+1),he=(N+1)*N,Ae=f?p.br:0,ce=f?0:1,ye=x?p.bs:p.a5,Pe=x?0:1;for(let be=0;be<=N;be++)D.emplaceBack(be*G,Ae,ce);for(let be=0;be<=N;be++)D.emplaceBack(be*G,ye,Pe);for(let be=0;be<N;be++)B.emplaceBack(he+be,ie+be,ie+be+1),B.emplaceBack(he+be,ie+be+1,he+be+1),B.emplaceBack(0+be,$+be+1,$+be),B.emplaceBack(0+be,0+be+1,$+be+1);const _e=D.length,we=_e+2*(N+1);for(const be of[0,1])for(let Le=0;Le<=N;Le++)for(const Ke of[0,1])D.emplaceBack(be*p.a5,Le*G,Ke);for(let be=0;be<2*N;be+=2)B.emplaceBack(_e+be,_e+be+1,_e+be+3),B.emplaceBack(_e+be,_e+be+3,_e+be+2),B.emplaceBack(we+be,we+be+3,we+be+1),B.emplaceBack(we+be,we+be+2,we+be+3);const Ce=new Ki(C.createVertexBuffer(D,Dc.members),C.createIndexBuffer(B),p.aX.simpleSegment(0,0,D.length,B.length));return this._meshCache[T]=Ce,Ce}getMeshFrameDelta(t){return 2*Math.PI*p.bE/Math.pow(2,Math.max(t,0))/5}getMinTileElevationForLngLatZoom(t,n){var h;if(!p.cD(n,t.wrap()))return 0;const{tileID:f}=this._getOverscaledTileIDFromLngLatZoom(t,n);return(h=this.getMinMaxElevation(f).minElevation)!==null&&h!==void 0?h:0}getMinMaxElevation(t){const n=this.getTerrainData(t).tile,h={minElevation:null,maxElevation:null};return n&&n.dem&&(h.minElevation=n.dem.min*this.exaggeration,h.maxElevation=n.dem.max*this.exaggeration),h}_getOverscaledTileIDFromLngLatZoom(t,n){const h=p.a9.fromLngLat(t.wrap()),f=(1<<n)*p.a5,x=h.x*f,T=h.y*f,C=Math.floor(x/p.a5),D=Math.floor(T/p.a5);return{tileID:new p.a2(n,0,n,C,D),mercatorX:x,mercatorY:T}}}class on{constructor(t,n,h){this._context=t,this._size=n,this._tileSize=h,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(const t of this._objects)t.texture.destroy(),t.fbo.destroy()}_createObject(t){const n=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),h=new p.T(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return h.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),this._context.extTextureFilterAnisotropic&&this._context.gl.texParameterf(this._context.gl.TEXTURE_2D,this._context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this._context.extTextureFilterAnisotropicMax),n.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),n.colorAttachment.set(h.texture),{id:t,fbo:n,texture:h,stamp:-1,inUse:!1}}getObjectForId(t){return this._objects[t]}useObject(t){t.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter((n=>t.id!==n)),this._recentlyUsed.push(t.id)}stampObject(t){t.stamp=++this._stamp}getOrCreateFreeObject(){for(const n of this._recentlyUsed)if(!this._objects[n].inUse)return this._objects[n];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const t=this._createObject(this._objects.length);return this._objects.push(t),t}freeObject(t){t.inUse=!1}freeAllObjects(){for(const t of this._objects)this.freeObject(t)}isFull(){return!(this._objects.length<this._size)&&this._objects.some((t=>!t.inUse))===!1}}const Cl={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};class xu{constructor(t,n){this.painter=t,this.terrain=n,this.pool=new on(t.context,30,n.tileManager.tileSize*n.qualityFactor)}destruct(){this.pool.destruct()}getTexture(t){return this.pool.getObjectForId(t.rtt[this._stacks.length-1].id).texture}prepareForRender(t,n){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.tileManager.getRenderableTiles(),this._renderableLayerIds=t._order.filter((h=>!t._layers[h].isHidden(n))),this._coordsAscending={};for(const h in t.tileManagers){this._coordsAscending[h]={};const f=t.tileManagers[h].getVisibleCoordinates(),x=t.tileManagers[h].getSource(),T=x instanceof mn?x.terrainTileRanges:null;for(const C of f){const D=this.terrain.tileManager.getTerrainCoords(C,T);for(const B in D)this._coordsAscending[h][B]||(this._coordsAscending[h][B]=[]),this._coordsAscending[h][B].push(D[B])}}this._coordsAscendingStr={};for(const h of t._order){const f=t._layers[h],x=f.source;if(Cl[f.type]&&!this._coordsAscendingStr[x]){this._coordsAscendingStr[x]={};for(const T in this._coordsAscending[x])this._coordsAscendingStr[x][T]=this._coordsAscending[x][T].map((C=>C.key)).sort().join()}}for(const h of this._renderableTiles)for(const f in this._coordsAscendingStr){const x=this._coordsAscendingStr[f][h.tileID.key];x&&x!==h.rttCoords[f]&&(h.rtt=[])}}renderLayer(t,n){if(t.isHidden(this.painter.transform.zoom))return!1;const h=Object.assign(Object.assign({},n),{isRenderingToTexture:!0}),f=t.type,x=this.painter,T=this._renderableLayerIds[this._renderableLayerIds.length-1]===t.id;if(Cl[f]&&(this._prevType&&Cl[this._prevType]||this._stacks.push([]),this._prevType=f,this._stacks[this._stacks.length-1].push(t.id),!T))return!0;if(Cl[this._prevType]||Cl[f]&&T){this._prevType=f;const C=this._stacks.length-1,D=this._stacks[C]||[];for(const B of this._renderableTiles){if(this.pool.isFull()&&(Io(this.painter,this.terrain,this._rttTiles,h),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(B),B.rtt[C]){const G=this.pool.getObjectForId(B.rtt[C].id);if(G.stamp===B.rtt[C].stamp){this.pool.useObject(G);continue}}const N=this.pool.getOrCreateFreeObject();this.pool.useObject(N),this.pool.stampObject(N),B.rtt[C]={id:N.id,stamp:N.stamp},x.context.bindFramebuffer.set(N.fbo.framebuffer),x.context.clear({color:p.bp.transparent,stencil:0}),x.currentStencilSource=void 0;for(let G=0;G<D.length;G++){const U=x.style._layers[D[G]],$=U.source?this._coordsAscending[U.source][B.tileID.key]:[B.tileID];x.context.viewport.set([0,0,N.fbo.width,N.fbo.height]),x._renderTileClippingMasks(U,$,!0),x.renderLayer(x,x.style.tileManagers[U.source],U,$,h),U.source&&(B.rttCoords[U.source]=this._coordsAscendingStr[U.source][B.tileID.key])}}return Io(this.painter,this.terrain,this._rttTiles,h),this._rttTiles=[],this.pool.freeAllObjects(),Cl[f]}return!1}}const Vu={"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":"Reset bearing to 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"},ph=it,ju={hash:!1,interactive:!0,bearingSnap:7,attributionControl:ko,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:p.c.MAX_TILE_CACHE_ZOOM_LEVELS,transformRequest:null,transformCameraUpdate:null,transformConstrain:null,fadeDuration:300,crossSourceCollisions:!0,clickTolerance:3,localIdeographFontFamily:"sans-serif",pitchWithRotate:!0,rollEnabled:!1,reduceMotion:void 0,validateStyle:!0,maxCanvasSize:[4096,4096],cancelPendingTileRequestsWhileZooming:!0,centerClampedToGround:!0,experimentalZoomLevelsToOverscale:void 0},mh={showCompass:!0,showZoom:!0,visualizePitch:!1,visualizeRoll:!0};class bu{constructor(t,n,h=!1){this.mousedown=x=>{this.startMove(x,rt.mousePos(this.element,x)),rt.addEventListener(window,"mousemove",this.mousemove),rt.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=x=>{this.move(x,rt.mousePos(this.element,x))},this.mouseup=x=>{this._rotatePitchHandler.dragEnd(x),this.offTemp()},this.touchstart=x=>{x.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=rt.touchPos(this.element,x.targetTouches)[0],this.startMove(x,this._startPos),rt.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),rt.addEventListener(window,"touchend",this.touchend))},this.touchmove=x=>{x.targetTouches.length!==1?this.reset():(this._lastPos=rt.touchPos(this.element,x.targetTouches)[0],this.move(x,this._lastPos))},this.touchend=x=>{x.targetTouches.length===0&&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=n;const f=new S;this._rotatePitchHandler=new a({clickTolerance:3,move:(x,T)=>{const C=n.getBoundingClientRect(),D=new p.P((C.bottom-C.top)/2,(C.right-C.left)/2);return{bearingDelta:p.cx(new p.P(x.x,T.y),T,D),pitchDelta:h?-.5*(T.y-x.y):void 0}},moveStateManager:f,enable:!0,assignEvents:()=>{}}),this.map=t,rt.addEventListener(n,"mousedown",this.mousedown),rt.addEventListener(n,"touchstart",this.touchstart,{passive:!1}),rt.addEventListener(n,"touchcancel",this.reset)}startMove(t,n){this._rotatePitchHandler.dragStart(t,n),rt.disableDrag()}move(t,n){const h=this.map,{bearingDelta:f,pitchDelta:x}=this._rotatePitchHandler.dragMove(t,n)||{};f&&h.setBearing(h.getBearing()+f),x&&h.setPitch(h.getPitch()+x)}off(){const t=this.element;rt.removeEventListener(t,"mousedown",this.mousedown),rt.removeEventListener(t,"touchstart",this.touchstart,{passive:!1}),rt.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),rt.removeEventListener(window,"touchend",this.touchend),rt.removeEventListener(t,"touchcancel",this.reset),this.offTemp()}offTemp(){rt.enableDrag(),rt.removeEventListener(window,"mousemove",this.mousemove),rt.removeEventListener(window,"mouseup",this.mouseup),rt.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),rt.removeEventListener(window,"touchend",this.touchend)}}let Na;function Zu(y,t,n,h=!1){if(h||!n.getCoveringTilesDetailsProvider().allowWorldCopies())return y==null?void 0:y.wrap();const f=new p.V(y.lng,y.lat);if(y=new p.V(y.lng,y.lat),t){const x=new p.V(y.lng-360,y.lat),T=new p.V(y.lng+360,y.lat),C=n.locationToScreenPoint(y).distSqr(t);n.locationToScreenPoint(x).distSqr(t)<C?y=x:n.locationToScreenPoint(T).distSqr(t)<C&&(y=T)}for(;Math.abs(y.lng-n.center.lng)>180;){const x=n.locationToScreenPoint(y);if(x.x>=0&&x.y>=0&&x.x<=n.width&&x.y<=n.height)break;y.lng>n.center.lng?y.lng-=360:y.lng+=360}return y.lng!==f.lng&&n.isPointOnMapSurface(n.locationToScreenPoint(y))?y:f}const wu={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function Uu(y,t,n){const h=y.classList;for(const f in wu)h.remove(`maplibregl-${n}-anchor-${f}`);h.add(`maplibregl-${n}-anchor-${t}`)}class Tu extends p.E{constructor(t){if(super(),this._onKeyPress=n=>{const h=n.code,f=n.charCode||n.keyCode;h!=="Space"&&h!=="Enter"&&f!==32&&f!==13||this.togglePopup()},this._onMapClick=n=>{const h=n.originalEvent.target,f=this._element;this._popup&&(h===f||f.contains(h))&&this.togglePopup()},this._update=n=>{if(!this._map)return;const h=this._map.loaded()&&!this._map.isMoving();((n==null?void 0:n.type)==="terrain"||(n==null?void 0:n.type)==="render"&&!h)&&this._map.once("render",this._update),this._lngLat=Zu(this._lngLat,this._flatPos,this._map.transform),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let f="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?f=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(f=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let x="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?x="rotateX(0deg)":this._pitchAlignment==="map"&&(x=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||n&&n.type!=="moveend"||(this._pos=this._pos.round()),rt.setTransform(this._element,`${wu[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${x} ${f}`),zr.frameAsync(new AbortController).then((()=>{this._updateOpacity(n&&n.type==="moveend")})).catch((()=>{}))},this._onMove=n=>{if(!this._isDragging){const h=this._clickTolerance||this._map._clickTolerance;this._isDragging=n.point.dist(this._pointerdownPos)>=h}this._isDragging&&(this._pos=n.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new p.l("dragstart"))),this.fire(new p.l("drag")))},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),this._state==="active"&&this.fire(new p.l("dragend")),this._state="inactive"},this._addDragHandler=n=>{this._element.contains(n.originalEvent.target)&&(n.preventDefault(),this._positionDelta=n.point.sub(this._pos).add(this._offset),this._pointerdownPos=n.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))},this._anchor=t&&t.anchor||"center",this._color=t&&t.color||"#3FB1CE",this._scale=t&&t.scale||1,this._draggable=t&&t.draggable||!1,this._clickTolerance=t&&t.clickTolerance||0,this._subpixelPositioning=t&&t.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=t&&t.rotation||0,this._rotationAlignment=t&&t.rotationAlignment||"auto",this._pitchAlignment=t&&t.pitchAlignment&&t.pitchAlignment!=="auto"?t.pitchAlignment:this._rotationAlignment,this.setOpacity(t==null?void 0:t.opacity,t==null?void 0:t.opacityWhenCovered),t&&t.element)this._element=t.element,this._offset=p.P.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=rt.create("div");const n=rt.createNS("http://www.w3.org/2000/svg","svg"),h=41,f=27;n.setAttributeNS(null,"display","block"),n.setAttributeNS(null,"height",`${h}px`),n.setAttributeNS(null,"width",`${f}px`),n.setAttributeNS(null,"viewBox",`0 0 ${f} ${h}`);const x=rt.createNS("http://www.w3.org/2000/svg","g");x.setAttributeNS(null,"stroke","none"),x.setAttributeNS(null,"stroke-width","1"),x.setAttributeNS(null,"fill","none"),x.setAttributeNS(null,"fill-rule","evenodd");const T=rt.createNS("http://www.w3.org/2000/svg","g");T.setAttributeNS(null,"fill-rule","nonzero");const C=rt.createNS("http://www.w3.org/2000/svg","g");C.setAttributeNS(null,"transform","translate(3.0, 29.0)"),C.setAttributeNS(null,"fill","#000000");const D=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const ce of D){const ye=rt.createNS("http://www.w3.org/2000/svg","ellipse");ye.setAttributeNS(null,"opacity","0.04"),ye.setAttributeNS(null,"cx","10.5"),ye.setAttributeNS(null,"cy","5.80029008"),ye.setAttributeNS(null,"rx",ce.rx),ye.setAttributeNS(null,"ry",ce.ry),C.appendChild(ye)}const B=rt.createNS("http://www.w3.org/2000/svg","g");B.setAttributeNS(null,"fill",this._color);const N=rt.createNS("http://www.w3.org/2000/svg","path");N.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),B.appendChild(N);const G=rt.createNS("http://www.w3.org/2000/svg","g");G.setAttributeNS(null,"opacity","0.25"),G.setAttributeNS(null,"fill","#000000");const U=rt.createNS("http://www.w3.org/2000/svg","path");U.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),G.appendChild(U);const $=rt.createNS("http://www.w3.org/2000/svg","g");$.setAttributeNS(null,"transform","translate(6.0, 7.0)"),$.setAttributeNS(null,"fill","#FFFFFF");const ie=rt.createNS("http://www.w3.org/2000/svg","g");ie.setAttributeNS(null,"transform","translate(8.0, 8.0)");const he=rt.createNS("http://www.w3.org/2000/svg","circle");he.setAttributeNS(null,"fill","#000000"),he.setAttributeNS(null,"opacity","0.25"),he.setAttributeNS(null,"cx","5.5"),he.setAttributeNS(null,"cy","5.5"),he.setAttributeNS(null,"r","5.4999962");const Ae=rt.createNS("http://www.w3.org/2000/svg","circle");Ae.setAttributeNS(null,"fill","#FFFFFF"),Ae.setAttributeNS(null,"cx","5.5"),Ae.setAttributeNS(null,"cy","5.5"),Ae.setAttributeNS(null,"r","5.4999962"),ie.appendChild(he),ie.appendChild(Ae),T.appendChild(C),T.appendChild(B),T.appendChild(G),T.appendChild($),T.appendChild(ie),n.appendChild(T),n.setAttributeNS(null,"height",h*this._scale+"px"),n.setAttributeNS(null,"width",f*this._scale+"px"),this._element.appendChild(n),this._offset=p.P.convert(t&&t.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",(n=>{n.preventDefault()})),this._element.addEventListener("mousedown",(n=>{n.preventDefault()})),Uu(this._element,this._anchor,"marker"),t&&t.className)for(const n of t.className.split(" "))this._element.classList.add(n);this._popup=null}addTo(t){return this.remove(),this._map=t,this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label",t._getUIString("Marker.Title")),this._element.hasAttribute("role")||this._element.setAttribute("role","button"),t.getCanvasContainer().appendChild(this._element),t.on("move",this._update),t.on("moveend",this._update),t.on("terrain",this._update),t.on("projectiontransition",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),rt.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=p.V.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(t){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),t){if(!("offset"in t.options)){const f=Math.abs(13.5)/Math.SQRT2;t.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[f,-1*(38.1-13.5+f)],"bottom-right":[-f,-1*(38.1-13.5+f)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=t,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}setSubpixelPositioning(t){return this._subpixelPositioning=t,this}getPopup(){return this._popup}togglePopup(){const t=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:t?(t.isOpen()?t.remove():(t.setLngLat(this._lngLat),t.addTo(this._map)),this):this}_updateOpacity(t=!1){var n,h;const f=(n=this._map)===null||n===void 0?void 0:n.terrain,x=this._map.transform.isLocationOccluded(this._lngLat);if(!f||x){const $=x?this._opacityWhenCovered:this._opacity;return void(this._element.style.opacity!==$&&(this._element.style.opacity=$))}if(t)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout((()=>{this._opacityTimeout=null}),100)}const T=this._map,C=T.terrain.depthAtPoint(this._pos),D=T.terrain.getElevationForLngLat(this._lngLat,T.transform);if(T.transform.lngLatToCameraDepth(this._lngLat,D)-C<.006)return void(this._element.style.opacity=this._opacity);const B=-this._offset.y/T.transform.pixelsPerMeter,N=Math.sin(T.getPitch()*Math.PI/180)*B,G=T.terrain.depthAtPoint(new p.P(this._pos.x,this._pos.y-this._offset.y)),U=T.transform.lngLatToCameraDepth(this._lngLat,D+N)-G>.006;!((h=this._popup)===null||h===void 0)&&h.isOpen()&&U&&this._popup.remove(),this._element.style.opacity=U?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(t){return this._offset=p.P.convert(t),this._update(),this}addClassName(t){this._element.classList.add(t)}removeClassName(t){this._element.classList.remove(t)}toggleClassName(t){return this._element.classList.toggle(t)}setDraggable(t){return this._draggable=!!t,this._map&&(t?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(t){return this._rotation=t||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(t){return this._rotationAlignment=t||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(t){return this._pitchAlignment=t&&t!=="auto"?t:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(t,n){return(this._opacity===void 0||t===void 0&&n===void 0)&&(this._opacity="1",this._opacityWhenCovered="0.2"),t!==void 0&&(this._opacity=t),n!==void 0&&(this._opacityWhenCovered=n),this._map&&this._updateOpacity(!0),this}}const _h={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let tu=0,Il=!1;const gh={maxWidth:100,unit:"metric"};function Pu(y,t,n){const h=n&&n.maxWidth||100,f=y._container.clientHeight/2,x=y._container.clientWidth/2,T=y.unproject([x-h/2,f]),C=y.unproject([x+h/2,f]),D=Math.round(y.project(C).x-y.project(T).x),B=Math.min(h,D,y._container.clientWidth),N=T.distanceTo(C);if(n&&n.unit==="imperial"){const G=3.2808*N;G>5280?Dl(t,B,G/5280,y._getUIString("ScaleControl.Miles")):Dl(t,B,G,y._getUIString("ScaleControl.Feet"))}else n&&n.unit==="nautical"?Dl(t,B,N/1852,y._getUIString("ScaleControl.NauticalMiles")):N>=1e3?Dl(t,B,N/1e3,y._getUIString("ScaleControl.Kilometers")):Dl(t,B,N,y._getUIString("ScaleControl.Meters"))}function Dl(y,t,n,h){const f=(function(x){const T=Math.pow(10,`${Math.floor(x)}`.length-1);let C=x/T;return C=C>=10?10:C>=5?5:C>=3?3:C>=2?2:C>=1?1:(function(D){const B=Math.pow(10,Math.ceil(-Math.log(D)/Math.LN10));return Math.round(D*B)/B})(C),T*C})(n);y.style.width=t*(f/n)+"px",y.innerHTML=`${f}&nbsp;${h}`}const yh={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0,padding:void 0},Gu=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function qu(y){if(y){if(typeof y=="number"){const t=Math.round(Math.abs(y)/Math.SQRT2);return{center:new p.P(0,0),top:new p.P(0,y),"top-left":new p.P(t,t),"top-right":new p.P(-t,t),bottom:new p.P(0,-y),"bottom-left":new p.P(t,-t),"bottom-right":new p.P(-t,-t),left:new p.P(y,0),right:new p.P(-y,0)}}if(y instanceof p.P||Array.isArray(y)){const t=p.P.convert(y);return{center:t,top:t,"top-left":t,"top-right":t,bottom:t,"bottom-left":t,"bottom-right":t,left:t,right:t}}return{center:p.P.convert(y.center||[0,0]),top:p.P.convert(y.top||[0,0]),"top-left":p.P.convert(y["top-left"]||[0,0]),"top-right":p.P.convert(y["top-right"]||[0,0]),bottom:p.P.convert(y.bottom||[0,0]),"bottom-left":p.P.convert(y["bottom-left"]||[0,0]),"bottom-right":p.P.convert(y["bottom-right"]||[0,0]),left:p.P.convert(y.left||[0,0]),right:p.P.convert(y.right||[0,0])}}return qu(new p.P(0,0))}const vh=it;W.AJAXError=p.cI,W.Event=p.l,W.Evented=p.E,W.LngLat=p.V,W.MercatorCoordinate=p.a9,W.Point=p.P,W.addProtocol=p.cJ,W.config=p.c,W.removeProtocol=p.cK,W.AttributionControl=dh,W.BoxZoomHandler=fo,W.CanvasSource=ee,W.CooperativeGesturesHandler=_t,W.DoubleClickZoomHandler=ai,W.DragPanHandler=ei,W.DragRotateHandler=Vt,W.EdgeInsets=Us,W.FullscreenControl=class extends p.E{constructor(y={}){super(),this._onFullscreenChange=()=>{var t;let n=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;!((t=n==null?void 0:n.shadowRoot)===null||t===void 0)&&t.fullscreenElement;)n=n.shadowRoot.fullscreenElement;n===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,y&&y.container&&(y.container instanceof HTMLElement?this._container=y.container:p.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(y){return this._map=y,this._container||(this._container=this._map.getContainer()),this._controlContainer=rt.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){rt.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const y=this._fullscreenButton=rt.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);rt.create("span","maplibregl-ctrl-icon",y).setAttribute("aria-hidden","true"),y.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const y=this._getTitle();this._fullscreenButton.setAttribute("aria-label",y),this._fullscreenButton.title=y}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new p.l("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new p.l("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},W.GeoJSONSource=Ds,W.GeolocateControl=class extends p.E{constructor(y){super(),this._onSuccess=t=>{if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new p.l("outofmaxbounds",t)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=t,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&this._watchState!=="OFF"&&this._updateMarker(t),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(t),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new p.l("geolocate",t)),this._finish()}},this._updateCamera=t=>{const n=new p.V(t.coords.longitude,t.coords.latitude),h=t.coords.accuracy,f=this._map.getBearing(),x=p.e({bearing:f},this.options.fitBoundsOptions),T=Ui.fromLngLat(n,h);this._map.fitBounds(T,x,{geolocateSource:!0})},this._updateMarker=t=>{if(t){const n=new p.V(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(n).addTo(this._map),this._userLocationDotMarker.setLngLat(n).addTo(this._map),this._accuracy=t.coords.accuracy,this._updateCircleRadiusIfNeeded()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onUpdate=()=>{this._updateCircleRadiusIfNeeded()},this._onError=t=>{if(this._map){if(t.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(t.code===3&&Il)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new p.l("error",t)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this._geolocateButton=rt.create("button","maplibregl-ctrl-geolocate",this._container),rt.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=t=>{if(this._map){if(t===!1){p.w("Geolocation support is not available so the GeolocateControl will be disabled.");const n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n)}else{const n=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=rt.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Tu({element:this._dotElement}),this._circleElement=rt.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Tu({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onUpdate),this._map.on("move",this._onUpdate),this._map.on("rotate",this._onUpdate),this._map.on("pitch",this._onUpdate)),this._geolocateButton.addEventListener("click",(()=>this.trigger())),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(n=>{const h=(n==null?void 0:n[0])instanceof ResizeObserverEntry;n.geolocateSource||this._watchState!=="ACTIVE_LOCK"||h||this._map.isZooming()||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new p.l("trackuserlocationend")),this.fire(new p.l("userlocationlostfocus")))}))}},this.options=p.e({},_h,y)}onAdd(y){return this._map=y,this._container=rt.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),(function(){return p._(this,arguments,void 0,(function*(t=!1){if(Na!==void 0&&!t)return Na;if(window.navigator.permissions===void 0)return Na=!!window.navigator.geolocation,Na;try{Na=(yield window.navigator.permissions.query({name:"geolocation"})).state!=="denied"}catch{Na=!!window.navigator.geolocation}return Na}))})().then((t=>this._finishSetupUI(t))),this._container}onRemove(){this._geolocationWatchID!==void 0&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),rt.remove(this._container),this._map.off("zoom",this._onUpdate),this._map.off("move",this._onUpdate),this._map.off("rotate",this._onUpdate),this._map.off("pitch",this._onUpdate),this._map=void 0,tu=0,Il=!1}_isOutOfMapMaxBounds(y){const t=this._map.getMaxBounds(),n=y.coords;return t&&(n.longitude<t.getWest()||n.longitude>t.getEast()||n.latitude<t.getSouth()||n.latitude>t.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":case"BACKGROUND_ERROR":case"OFF":case void 0:break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadiusIfNeeded(){const y=this._userLocationDotMarker.getLngLat();if(!(this.options.showUserLocation&&this.options.showAccuracyCircle&&this._accuracy&&y))return;const t=this._map.project(y),n=this._map.unproject([t.x+100,t.y]),h=y.distanceTo(n)/100,f=2*this._accuracy/h;this._circleElement.style.width=`${f.toFixed(2)}px`,this._circleElement.style.height=`${f.toFixed(2)}px`}trigger(){if(!this._setup)return p.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new p.l("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":tu--,Il=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new p.l("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new p.l("trackuserlocationstart")),this.fire(new p.l("userlocationfocus"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let y;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),tu++,tu>1?(y={maximumAge:6e5,timeout:0},Il=!0):(y=this.options.positionOptions,Il=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,y)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},W.GlobeControl=class{constructor(){this._toggleProjection=()=>{var y;const t=(y=this._map.getProjection())===null||y===void 0?void 0:y.type;this._map.setProjection(t!=="mercator"&&t?{type:"mercator"}:{type:"globe"}),this._updateGlobeIcon()},this._updateGlobeIcon=()=>{var y;this._globeButton.classList.remove("maplibregl-ctrl-globe"),this._globeButton.classList.remove("maplibregl-ctrl-globe-enabled"),((y=this._map.getProjection())===null||y===void 0?void 0:y.type)==="globe"?(this._globeButton.classList.add("maplibregl-ctrl-globe-enabled"),this._globeButton.title=this._map._getUIString("GlobeControl.Disable")):(this._globeButton.classList.add("maplibregl-ctrl-globe"),this._globeButton.title=this._map._getUIString("GlobeControl.Enable"))}}onAdd(y){return this._map=y,this._container=rt.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._globeButton=rt.create("button","maplibregl-ctrl-globe",this._container),rt.create("span","maplibregl-ctrl-icon",this._globeButton).setAttribute("aria-hidden","true"),this._globeButton.type="button",this._globeButton.addEventListener("click",this._toggleProjection),this._updateGlobeIcon(),this._map.on("styledata",this._updateGlobeIcon),this._container}onRemove(){rt.remove(this._container),this._map.off("styledata",this._updateGlobeIcon),this._globeButton.removeEventListener("click",this._toggleProjection),this._map=void 0}},W.Hash=Wt,W.ImageSource=mn,W.KeyboardHandler=ze,W.LngLatBounds=Ui,W.LogoControl=Qh,W.Map=class extends is{constructor(y){var t,n;p.cG.mark(p.cH.create);const h=Object.assign(Object.assign(Object.assign({},ju),y),{canvasContextAttributes:Object.assign(Object.assign({},ju.canvasContextAttributes),y.canvasContextAttributes)});if(h.minZoom!=null&&h.maxZoom!=null&&h.minZoom>h.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(h.minPitch!=null&&h.maxPitch!=null&&h.minPitch>h.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(h.minPitch!=null&&h.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(h.maxPitch!=null&&h.maxPitch>180)throw new Error("maxPitch must be less than or equal to 180");const f=new Po,x=new hi;if(h.minZoom!==void 0&&f.setMinZoom(h.minZoom),h.maxZoom!==void 0&&f.setMaxZoom(h.maxZoom),h.minPitch!==void 0&&f.setMinPitch(h.minPitch),h.maxPitch!==void 0&&f.setMaxPitch(h.maxPitch),h.renderWorldCopies!==void 0&&f.setRenderWorldCopies(h.renderWorldCopies),h.transformConstrain!==null&&f.setConstrainOverride(h.transformConstrain),super(f,x,{bearingSnap:h.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new Ic,this._controls=[],this._mapId=p.af(),this._lostContextStyle={style:null,images:null},this._contextLost=C=>{C.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.painter.destroy();for(const D of Object.values(this.style._layers))if(D.type==="custom"&&console.warn(`Custom layer with id '${D.id}' cannot be restored after WebGL context loss. You will need to re-add it manually after context restoration.`),D._listeners)for(const[B]of Object.entries(D._listeners))console.warn(`Custom layer with id '${D.id}' had event listeners for event '${B}' which cannot be restored after WebGL context loss. You will need to re-add them manually after context restoration.`);this._lostContextStyle=this._getStyleAndImages(),this.style.destroy(),this.style=null,this.fire(new p.l("webglcontextlost",{originalEvent:C}))},this._contextRestored=C=>{this._lostContextStyle.style&&this.setStyle(this._lostContextStyle.style,{diff:!1}),this._lostContextStyle.images&&(this.style.imageManager.images=this._lostContextStyle.images),this._lostContextStyle={style:null,images:null},this._setupPainter(),this.resize(),this._update(),this._resizeInternal(),this.fire(new p.l("webglcontextrestored",{originalEvent:C}))},this._onMapScroll=C=>{if(C.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=h.interactive,this._maxTileCacheSize=h.maxTileCacheSize,this._maxTileCacheZoomLevels=h.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},h.canvasContextAttributes),this._trackResize=h.trackResize===!0,this._bearingSnap=h.bearingSnap,this._centerClampedToGround=h.centerClampedToGround,this._refreshExpiredTiles=h.refreshExpiredTiles===!0,this._fadeDuration=h.fadeDuration,this._crossSourceCollisions=h.crossSourceCollisions===!0,this._collectResourceTiming=h.collectResourceTiming===!0,this._locale=Object.assign(Object.assign({},Vu),h.locale),this._clickTolerance=h.clickTolerance,this._overridePixelRatio=h.pixelRatio,this._maxCanvasSize=h.maxCanvasSize,this._zoomLevelsToOverscale=h.experimentalZoomLevelsToOverscale,this.transformCameraUpdate=h.transformCameraUpdate,this.transformConstrain=h.transformConstrain,this.cancelPendingTileRequestsWhileZooming=h.cancelPendingTileRequestsWhileZooming===!0,h.reduceMotion!==void 0&&(zr.prefersReducedMotion=h.reduceMotion),this._imageQueueHandle=En.addThrottleControl((()=>this.isMoving())),this._requestManager=new Oo(h.transformRequest),typeof h.container=="string"){if(this._container=document.getElementById(h.container),!this._container)throw new Error(`Container '${h.container}' not found.`)}else{if(!(h.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=h.container}if(h.maxBounds&&this.setMaxBounds(h.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",(()=>this._update(!1))),this.on("moveend",(()=>this._update(!1))),this.on("zoom",(()=>this._update(!0))),this.on("terrain",(()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)})),this.once("idle",(()=>{this._idleTriggered=!0})),typeof window<"u"){addEventListener("online",this._onWindowOnline,!1);let C=!1;const D=ts((B=>{this._trackResize&&!this._removed&&(this.resize(B),this.redraw())}),50);this._resizeObserver=new ResizeObserver((B=>{C?D(B):C=!0})),this._resizeObserver.observe(this._container)}this.handlers=new wn(this,h),this._hash=h.hash&&new Wt(typeof h.hash=="string"&&h.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:h.center,elevation:h.elevation,zoom:h.zoom,bearing:h.bearing,pitch:h.pitch,roll:h.roll}),h.bounds&&(this.resize(),this.fitBounds(h.bounds,p.e({},h.fitBoundsOptions,{duration:0}))));const T=typeof h.style=="string"||((n=(t=h.style)===null||t===void 0?void 0:t.projection)===null||n===void 0?void 0:n.type)!=="globe";this.resize(null,T),this._localIdeographFontFamily=h.localIdeographFontFamily,this._validateStyle=h.validateStyle,h.style&&this.setStyle(h.style,{localIdeographFontFamily:h.localIdeographFontFamily}),h.attributionControl&&this.addControl(new dh(typeof h.attributionControl=="boolean"?void 0:h.attributionControl)),h.maplibreLogo&&this.addControl(new Qh,h.logoPosition),this.on("style.load",(()=>{if(T||this._resizeTransform(),this.transform.unmodified){const C=p.U(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(C)}})),this.on("data",(C=>{this._update(C.dataType==="style"),this.fire(new p.l(`${C.dataType}data`,C))})),this.on("dataloading",(C=>{this.fire(new p.l(`${C.dataType}dataloading`,C))})),this.on("dataabort",(C=>{this.fire(new p.l("sourcedataabort",C))}))}_getMapId(){return this._mapId}setGlobalStateProperty(y,t){return this.style.setGlobalStateProperty(y,t),this._update(!0)}getGlobalState(){return this.style.getGlobalState()}addControl(y,t){if(t===void 0&&(t=y.getDefaultPosition?y.getDefaultPosition():"top-right"),!y||!y.onAdd)return this.fire(new p.k(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const n=y.onAdd(this);this._controls.push(y);const h=this._controlPositions[t];return t.indexOf("bottom")!==-1?h.insertBefore(n,h.firstChild):h.appendChild(n),this}removeControl(y){if(!y||!y.onRemove)return this.fire(new p.k(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const t=this._controls.indexOf(y);return t>-1&&this._controls.splice(t,1),y.onRemove(this),this}hasControl(y){return this._controls.indexOf(y)>-1}coveringTiles(y){return er(this.transform,y)}calculateCameraOptionsFromTo(y,t,n,h){return h==null&&this.terrain&&(h=this.terrain.getElevationForLngLat(n,this.transform)),super.calculateCameraOptionsFromTo(y,t,n,h)}resize(y,t=!0){if(this._lostContextStyle.style!==null)return this;this._resizeInternal(t);const n=!this._moving;return n&&(this.stop(),this.fire(new p.l("movestart",y)).fire(new p.l("move",y))),this.fire(new p.l("resize",y)),n&&this.fire(new p.l("moveend",y)),this}_resizeInternal(y=!0){const[t,n]=this._containerDimensions(),h=this._getClampedPixelRatio(t,n);if(this._resizeCanvas(t,n,h),this.painter.resize(t,n,h),this.painter.overLimit()){const f=this.painter.context.gl;this._maxCanvasSize=[f.drawingBufferWidth,f.drawingBufferHeight];const x=this._getClampedPixelRatio(t,n);this._resizeCanvas(t,n,x),this.painter.resize(t,n,x)}this._resizeTransform(y)}_resizeTransform(y=!0){var t;const[n,h]=this._containerDimensions();this.transform.resize(n,h,y),(t=this._requestedCameraState)===null||t===void 0||t.resize(n,h,y)}_getClampedPixelRatio(y,t){const{0:n,1:h}=this._maxCanvasSize,f=this.getPixelRatio(),x=y*f,T=t*f;return Math.min(x>n?n/x:1,T>h?h/T:1)*f}getPixelRatio(){var y;return(y=this._overridePixelRatio)!==null&&y!==void 0?y:devicePixelRatio}setPixelRatio(y){this._overridePixelRatio=y,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(y){return this.transform.setMaxBounds(Ui.convert(y)),this._update()}setMinZoom(y){if((y=y??-2)>=-2&&y<=this.transform.maxZoom){const t=this._getTransformForUpdate();return t.setMinZoom(y),this._applyUpdatedTransform(t),this._update(),this}throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(y){if((y=y??22)>=this.transform.minZoom){const t=this._getTransformForUpdate();return t.setMaxZoom(y),this._applyUpdatedTransform(t),this._update(),this}throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(y){if((y=y??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(y>=0&&y<=this.transform.maxPitch)return this.transform.setMinPitch(y),this._update(),this.getPitch()<y&&this.setPitch(y),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(y){if((y=y??60)>180)throw new Error("maxPitch must be less than or equal to 180");if(y>=this.transform.minPitch)return this.transform.setMaxPitch(y),this._update(),this.getPitch()>y&&this.setPitch(y),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(y){return this.transform.setRenderWorldCopies(y),this._update()}setTransformConstrain(y){return this.transform.setConstrainOverride(y),this._update()}project(y){return this.transform.locationToScreenPoint(p.V.convert(y),this.style&&this.terrain)}unproject(y){return this.transform.screenPointToLocation(p.P.convert(y),this.terrain)}isMoving(){var y;return this._moving||((y=this.handlers)===null||y===void 0?void 0:y.isMoving())}isZooming(){var y;return this._zooming||((y=this.handlers)===null||y===void 0?void 0:y.isZooming())}isRotating(){var y;return this._rotating||((y=this.handlers)===null||y===void 0?void 0:y.isRotating())}_createDelegatedListener(y,t,n){if(y==="mouseenter"||y==="mouseover"){let h=!1;return{layers:t,listener:n,delegates:{mousemove:x=>{const T=t.filter((D=>this.getLayer(D))),C=T.length!==0?this.queryRenderedFeatures(x.point,{layers:T}):[];C.length?h||(h=!0,n.call(this,new ht(y,this,x.originalEvent,{features:C}))):h=!1},mouseout:()=>{h=!1}}}}if(y==="mouseleave"||y==="mouseout"){let h=!1;return{layers:t,listener:n,delegates:{mousemove:T=>{const C=t.filter((D=>this.getLayer(D)));(C.length!==0?this.queryRenderedFeatures(T.point,{layers:C}):[]).length?h=!0:h&&(h=!1,n.call(this,new ht(y,this,T.originalEvent)))},mouseout:T=>{h&&(h=!1,n.call(this,new ht(y,this,T.originalEvent)))}}}}{const h=f=>{const x=t.filter((C=>this.getLayer(C))),T=x.length!==0?this.queryRenderedFeatures(f.point,{layers:x}):[];T.length&&(f.features=T,n.call(this,f),delete f.features)};return{layers:t,listener:n,delegates:{[y]:h}}}}_saveDelegatedListener(y,t){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[y]=this._delegatedListeners[y]||[],this._delegatedListeners[y].push(t)}_removeDelegatedListener(y,t,n){if(!this._delegatedListeners||!this._delegatedListeners[y])return;const h=this._delegatedListeners[y];for(let f=0;f<h.length;f++){const x=h[f];if(x.listener===n&&x.layers.length===t.length&&x.layers.every((T=>t.includes(T)))){for(const T in x.delegates)this.off(T,x.delegates[T]);return void h.splice(f,1)}}}on(y,t,n){if(n===void 0)return super.on(y,t);const h=typeof t=="string"?[t]:t,f=this._createDelegatedListener(y,h,n);this._saveDelegatedListener(y,f);for(const x in f.delegates)this.on(x,f.delegates[x]);return{unsubscribe:()=>{this._removeDelegatedListener(y,h,n)}}}once(y,t,n){if(n===void 0)return super.once(y,t);const h=typeof t=="string"?[t]:t,f=this._createDelegatedListener(y,h,n);for(const x in f.delegates){const T=f.delegates[x];f.delegates[x]=(...C)=>{this._removeDelegatedListener(y,h,n),T(...C)}}this._saveDelegatedListener(y,f);for(const x in f.delegates)this.once(x,f.delegates[x]);return this}off(y,t,n){return n===void 0?super.off(y,t):(this._removeDelegatedListener(y,typeof t=="string"?[t]:t,n),this)}queryRenderedFeatures(y,t){if(!this.style)return[];let n;const h=y instanceof p.P||Array.isArray(y),f=h?y:[[0,0],[this.transform.width,this.transform.height]];if(t=t||(h?{}:y)||{},f instanceof p.P||typeof f[0]=="number")n=[p.P.convert(f)];else{const x=p.P.convert(f[0]),T=p.P.convert(f[1]);n=[x,new p.P(T.x,x.y),T,new p.P(x.x,T.y),x]}return this.style.queryRenderedFeatures(n,t,this.transform)}querySourceFeatures(y,t){return this.style.querySourceFeatures(y,t)}setStyle(y,t){return(t=p.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},t)).diff!==!1&&t.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&y?(this._diffStyle(y,t),this):(this._localIdeographFontFamily=t.localIdeographFontFamily,this._updateStyle(y,t))}setTransformRequest(y){return this._requestManager.setTransformRequest(y),this}_getUIString(y){const t=this._locale[y];if(t==null)throw new Error(`Missing UI string '${y}'`);return t}_updateStyle(y,t){var n,h;if(t.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",(()=>this._updateStyle(y,t)));const f=this.style&&t.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!y)),y?(this.style=new Jn(this,t||{}),this.style.setEventedParent(this,{style:this.style}),typeof y=="string"?this.style.loadURL(y,t,f):this.style.loadJSON(y,t,f),this):((h=(n=this.style)===null||n===void 0?void 0:n.projection)===null||h===void 0||h.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new Jn(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(y,t){if(typeof y=="string"){const n=this._requestManager.transformRequest(y,"Style");p.j(n,new AbortController).then((h=>{this._updateDiff(h.data,t)})).catch((h=>{h&&this.fire(new p.k(h))}))}else typeof y=="object"&&this._updateDiff(y,t)}_updateDiff(y,t){try{this.style.setState(y,t)&&this._update(!0)}catch(n){p.w(`Unable to perform style diff: ${n.message||n.error||n}. Rebuilding the style from scratch.`),this._updateStyle(y,t)}}getStyle(){if(this.style)return this.style.serialize()}_getStyleAndImages(){return this.style?{style:this.style.serialize(),images:this.style.imageManager.cloneImages()}:{style:null,images:{}}}isStyleLoaded(){return this.style?this.style.loaded():p.w("There is no style added to the map.")}addSource(y,t){return this._lazyInitEmptyStyle(),this.style.addSource(y,t),this._update(!0)}isSourceLoaded(y){const t=this.style&&this.style.tileManagers[y];if(t!==void 0)return t.loaded();this.fire(new p.k(new Error(`There is no tile manager with ID '${y}'`)))}setTerrain(y){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),y){const t=this.style.tileManagers[y.source];if(!t)throw new Error(`cannot load terrain, because there exists no source with ID: ${y.source}`);this.terrain===null&&t.reload();for(const n in this.style._layers){const h=this.style._layers[n];h.type==="hillshade"&&h.source===y.source&&p.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality."),h.type==="color-relief"&&h.source===y.source&&p.w("You are using the same source for a color-relief layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.")}this.terrain=new Gr(this.painter,t,y),this.painter.renderToTexture=new xu(this.painter,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._terrainDataCallback=n=>{var h;n.dataType==="style"?this.terrain.tileManager.freeRtt():n.dataType==="source"&&n.tile&&(n.sourceId!==y.source||this._elevationFreeze||(this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))),((h=n.source)===null||h===void 0?void 0:h.type)==="image"?this.terrain.tileManager.freeRtt():this.terrain.tileManager.freeRtt(n.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.tileManager.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0);return this.fire(new p.l("terrain",{terrain:y})),this}getTerrain(){var y,t;return(t=(y=this.terrain)===null||y===void 0?void 0:y.options)!==null&&t!==void 0?t:null}areTilesLoaded(){const y=this.style&&this.style.tileManagers;for(const t of Object.values(y))if(!t.areTilesLoaded())return!1;return!0}removeSource(y){return this.style.removeSource(y),this._update(!0)}getSource(y){return this.style.getSource(y)}setSourceTileLodParams(y,t,n){if(n){const h=this.getSource(n);if(!h)throw new Error(`There is no source with ID "${n}", cannot set LOD parameters`);h.calculateTileZoom=qi(Math.max(1,y),Math.max(1,t))}else for(const h in this.style.tileManagers)this.style.tileManagers[h].getSource().calculateTileZoom=qi(Math.max(1,y),Math.max(1,t));return this._update(!0),this}refreshTiles(y,t){const n=this.style.tileManagers[y];if(!n)throw new Error(`There is no tile manager with ID "${y}", cannot refresh tile`);t===void 0?n.reload(!0):n.refreshTiles(t.map((h=>new p.ac(h.z,h.x,h.y))))}addImage(y,t,n={}){const{pixelRatio:h=1,sdf:f=!1,stretchX:x,stretchY:T,content:C,textFitWidth:D,textFitHeight:B}=n;if(this._lazyInitEmptyStyle(),!(t instanceof HTMLImageElement||p.b(t))){if(t.width===void 0||t.height===void 0)return this.fire(new p.k(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:N,height:G,data:U}=t,$=t;return this.style.addImage(y,{data:new p.R({width:N,height:G},new Uint8Array(U)),pixelRatio:h,stretchX:x,stretchY:T,content:C,textFitWidth:D,textFitHeight:B,sdf:f,version:0,userImage:$}),$.onAdd&&$.onAdd(this,y),this}}{const{width:N,height:G,data:U}=zr.getImageData(t);this.style.addImage(y,{data:new p.R({width:N,height:G},U),pixelRatio:h,stretchX:x,stretchY:T,content:C,textFitWidth:D,textFitHeight:B,sdf:f,version:0})}}updateImage(y,t){const n=this.style.getImage(y);if(!n)return this.fire(new p.k(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const h=t instanceof HTMLImageElement||p.b(t)?zr.getImageData(t):t,{width:f,height:x,data:T}=h;if(f===void 0||x===void 0)return this.fire(new p.k(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(f!==n.data.width||x!==n.data.height)return this.fire(new p.k(new Error("The width and height of the updated image must be that same as the previous version of the image")));const C=!(t instanceof HTMLImageElement||p.b(t));return n.data.replace(T,C),this.style.updateImage(y,n),this}getImage(y){return this.style.getImage(y)}hasImage(y){return y?!!this.style.getImage(y):(this.fire(new p.k(new Error("Missing required image id"))),!1)}removeImage(y){this.style.removeImage(y)}loadImage(y){return En.getImage(this._requestManager.transformRequest(y,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(y,t){return this._lazyInitEmptyStyle(),this.style.addLayer(y,t),this._update(!0)}moveLayer(y,t){return this.style.moveLayer(y,t),this._update(!0)}removeLayer(y){return this.style.removeLayer(y),this._update(!0)}getLayer(y){return this.style.getLayer(y)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(y,t,n){return this.style.setLayerZoomRange(y,t,n),this._update(!0)}setFilter(y,t,n={}){return this.style.setFilter(y,t,n),this._update(!0)}getFilter(y){return this.style.getFilter(y)}setPaintProperty(y,t,n,h={}){return this.style.setPaintProperty(y,t,n,h),this._update(!0)}getPaintProperty(y,t){return this.style.getPaintProperty(y,t)}setLayoutProperty(y,t,n,h={}){return this.style.setLayoutProperty(y,t,n,h),this._update(!0)}getLayoutProperty(y,t){return this.style.getLayoutProperty(y,t)}setGlyphs(y,t={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(y,t),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(y,t,n={}){return this._lazyInitEmptyStyle(),this.style.addSprite(y,t,n,(h=>{h||this._update(!0)})),this}removeSprite(y){return this._lazyInitEmptyStyle(),this.style.removeSprite(y),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(y,t={}){return this._lazyInitEmptyStyle(),this.style.setSprite(y,t,(n=>{n||this._update(!0)})),this}setLight(y,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(y,t),this._update(!0)}getLight(){return this.style.getLight()}setSky(y,t={}){return this._lazyInitEmptyStyle(),this.style.setSky(y,t),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(y,t){return this.style.setFeatureState(y,t),this._update()}removeFeatureState(y,t){return this.style.removeFeatureState(y,t),this._update()}getFeatureState(y){return this.style.getFeatureState(y)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let y=0,t=0;return this._container&&(y=this._container.clientWidth||400,t=this._container.clientHeight||300),[y,t]}_setupContainer(){const y=this._container;y.classList.add("maplibregl-map");const t=this._canvasContainer=rt.create("div","maplibregl-canvas-container",y);this._interactive&&t.classList.add("maplibregl-interactive"),this._canvas=rt.create("canvas","maplibregl-canvas",t),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");const n=this._containerDimensions(),h=this._getClampedPixelRatio(n[0],n[1]);this._resizeCanvas(n[0],n[1],h);const f=this._controlContainer=rt.create("div","maplibregl-control-container",y),x=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((T=>{x[T]=rt.create("div",`maplibregl-ctrl-${T} `,f)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(y,t,n){this._canvas.width=Math.floor(n*y),this._canvas.height=Math.floor(n*t),this._canvas.style.width=`${y}px`,this._canvas.style.height=`${t}px`}_setupPainter(){const y=Object.assign(Object.assign({},this._canvasContextAttributes),{alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0});let t=null;this._canvas.addEventListener("webglcontextcreationerror",(h=>{t={requestedAttributes:y},h&&(t.statusMessage=h.statusMessage,t.type=h.type)}),{once:!0});let n=null;if(n=this._canvasContextAttributes.contextType?this._canvas.getContext(this._canvasContextAttributes.contextType,y):this._canvas.getContext("webgl2",y)||this._canvas.getContext("webgl",y),!n){const h="Failed to initialize WebGL";throw t?(t.message=h,new Error(JSON.stringify(t))):new Error(h)}this.painter=new Qt(n,this.transform),Fo.testSupport(n)}migrateProjection(y,t){super.migrateProjection(y,t),this.painter.transform=y,this.fire(new p.l("projectiontransition",{newProjection:this.style.projection.name}))}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(y){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||y,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(y){return this._update(),this._renderTaskQueue.add(y)}_cancelRenderFrame(y){this._renderTaskQueue.remove(y)}_render(y){var t,n,h,f,x;const T=this._idleTriggered?this._fadeDuration:0,C=((t=this.style.projection)===null||t===void 0?void 0:t.transitionState)>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(y),this._removed)return;let D=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const G=this.transform.zoom,U=Gt();this.style.zoomHistory.update(G,U);const $=new p.H(G,{now:U,fadeDuration:T,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),ie=$.crossFadingFactor();ie===1&&ie===this._crossFadingFactor||(D=!0,this._crossFadingFactor=ie),this.style.update($)}const B=((n=this.style.projection)===null||n===void 0?void 0:n.transitionState)>0!==C;(h=this.style.projection)===null||h===void 0||h.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState((f=this.style.projection)===null||f===void 0?void 0:f.transitionState,(x=this.style.projection)===null||x===void 0?void 0:x.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||B)&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.tileManager.update(this.transform,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),!this._elevationFreeze&&this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0)),this._placementDirty=this.style&&this.style._updatePlacement(this.transform,this.showCollisionBoxes,T,this._crossSourceCollisions,B),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:T,showPadding:this.showPadding}),this.fire(new p.l("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,p.cG.mark(p.cH.load),this.fire(new p.l("load"))),this.style&&(this.style.hasTransitions()||D)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const N=this._sourcesDirty||this._styleDirty||this._placementDirty;return N||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new p.l("idle")),!this._loaded||this._fullyLoaded||N||(this._fullyLoaded=!0,p.cG.mark(p.cH.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var y;this._hash&&this._hash.remove();for(const n of this._controls)n.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),typeof window<"u"&&removeEventListener("online",this._onWindowOnline,!1),En.removeThrottleControl(this._imageQueueHandle),(y=this._resizeObserver)===null||y===void 0||y.disconnect();const t=this.painter.context.gl.getExtension("WEBGL_lose_context");t!=null&&t.loseContext&&t.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),rt.remove(this._canvasContainer),rt.remove(this._controlContainer),this._container.removeEventListener("scroll",this._onMapScroll,!1),this._container.classList.remove("maplibregl-map"),p.cG.clearMetrics(),this._removed=!0,this.fire(new p.l("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,zr.frame(this._frameRequest,(y=>{p.cG.frame(y),this._frameRequest=null;try{this._render(y)}catch(t){if(!p.Z(t)&&!(function(n){return n.message===R})(t))throw t}}),(()=>{})))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(y){this._showTileBoundaries!==y&&(this._showTileBoundaries=y,this._update())}get showPadding(){return!!this._showPadding}set showPadding(y){this._showPadding!==y&&(this._showPadding=y,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(y){this._showCollisionBoxes!==y&&(this._showCollisionBoxes=y,y?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(y){this._showOverdrawInspector!==y&&(this._showOverdrawInspector=y,this._update())}get repaint(){return!!this._repaint}set repaint(y){this._repaint!==y&&(this._repaint=y,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(y){this._vertices=y,this._update()}get version(){return ph}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(y){return this._lazyInitEmptyStyle(),this.style.setProjection(y),this._update(!0)}},W.MapMouseEvent=ht,W.MapTouchEvent=yt,W.MapWheelEvent=Jl,W.Marker=Tu,W.NavigationControl=class{constructor(y){this._updateZoomButtons=()=>{const t=this._map.getZoom(),n=t===this._map.getMaxZoom(),h=t===this._map.getMinZoom();this._zoomInButton.disabled=n,this._zoomOutButton.disabled=h,this._zoomInButton.setAttribute("aria-disabled",n.toString()),this._zoomOutButton.setAttribute("aria-disabled",h.toString())},this._rotateCompassArrow=()=>{this._compassIcon.style.transform=this.options.visualizePitch&&this.options.visualizeRoll?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateZ(${-this._map.transform.roll}deg) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizeRoll?`rotate(${-this._map.transform.bearing-this._map.transform.roll}deg)`:`rotate(${-this._map.transform.bearing}deg)`},this._setButtonTitle=(t,n)=>{const h=this._map._getUIString(`NavigationControl.${n}`);t.title=h,t.setAttribute("aria-label",h)},this.options=p.e({},mh,y),this._container=rt.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}))),rt.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}))),rt.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=rt.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(y){return this._map=y,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.on("roll",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new bu(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){rt.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.off("roll",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(y,t){const n=rt.create("button",y,this._container);return n.type="button",n.addEventListener("click",t),n}},W.Popup=class extends p.E{constructor(y){super(),this._updateOpacity=()=>{this.options.locationOccludedOpacity!==void 0&&(this._container.style.opacity=this._map.transform.isLocationOccluded(this.getLngLat())?`${this.options.locationOccludedOpacity}`:"")},this.remove=()=>(this._content&&rt.remove(this._content),this._container&&(rt.remove(this._container),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("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new p.l("close"))),this),this._onMouseUp=t=>{this._update(t.point)},this._onMouseMove=t=>{this._update(t.point)},this._onDrag=t=>{this._update(t.point)},this._update=t=>{if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=rt.create("div","maplibregl-popup",this._map.getContainer()),this._tip=rt.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const T of this.options.className.split(" "))this._container.classList.add(T);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=Zu(this._lngLat,this._flatPos,this._map.transform,this._trackPointer),this._trackPointer&&!t)return;const n=this._flatPos=this._pos=this._trackPointer&&t?t:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&t?t:this._map.transform.locationToScreenPoint(this._lngLat));let h=this.options.anchor;const f=qu(this.options.offset);if(!h){const T=this._container.offsetWidth,C=this._container.offsetHeight,D=(function(N){var G,U,$,ie;return N?{top:(G=N.top)!==null&&G!==void 0?G:0,right:(U=N.right)!==null&&U!==void 0?U:0,bottom:($=N.bottom)!==null&&$!==void 0?$:0,left:(ie=N.left)!==null&&ie!==void 0?ie:0}:{top:0,right:0,bottom:0,left:0}})(this.options.padding);let B;B=n.y+f.bottom.y<C+D.top?["top"]:n.y>this._map.transform.height-C-D.bottom?["bottom"]:[],n.x<T/2+D.left?B.push("left"):n.x>this._map.transform.width-T/2-D.right&&B.push("right"),h=B.length===0?"bottom":B.join("-")}let x=n.add(f[h]);this.options.subpixelPositioning||(x=x.round()),rt.setTransform(this._container,`${wu[h]} translate(${x.x}px,${x.y}px)`),Uu(this._container,h,"popup"),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=p.e(Object.create(yh),y)}addTo(y){return this._map&&this.remove(),this._map=y,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._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),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 p.l("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(y){return this._lngLat=p.V.convert(y),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),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._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(y){return this.setDOMContent(document.createTextNode(y))}setHTML(y){const t=document.createDocumentFragment(),n=document.createElement("body");let h;for(n.innerHTML=y;h=n.firstChild,h;)t.appendChild(h);return this.setDOMContent(t)}getMaxWidth(){var y;return(y=this._container)===null||y===void 0?void 0:y.style.maxWidth}setMaxWidth(y){return this.options.maxWidth=y,this._update(),this}setDOMContent(y){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=rt.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(y),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(y){return this._container&&this._container.classList.add(y),this}removeClassName(y){return this._container&&this._container.classList.remove(y),this}setOffset(y){return this.options.offset=y,this._update(),this}toggleClassName(y){if(this._container)return this._container.classList.toggle(y)}setSubpixelPositioning(y){this.options.subpixelPositioning=y}setPadding(y){this.options.padding=y,this._update()}_createCloseButton(){this.options.closeButton&&(this._closeButton=rt.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="&#215;",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const y=this._container.querySelector(Gu);y&&y.focus()}},W.RasterDEMTileSource=tn,W.RasterTileSource=Zo,W.ScaleControl=class{constructor(y){this._onMove=()=>{Pu(this._map,this._container,this.options)},this.setUnit=t=>{this.options.unit=t,Pu(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},gh),y)}getDefaultPosition(){return"bottom-left"}onAdd(y){return this._map=y,this._container=rt.create("div","maplibregl-ctrl maplibregl-ctrl-scale",y.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){rt.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},W.ScrollZoomHandler=Nt,W.Style=Jn,W.TerrainControl=class{constructor(y){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))},this.options=y}onAdd(y){return this._map=y,this._container=rt.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=rt.create("button","maplibregl-ctrl-terrain",this._container),rt.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){rt.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},W.TwoFingersTouchPitchHandler=Je,W.TwoFingersTouchRotateHandler=Ie,W.TwoFingersTouchZoomHandler=de,W.TwoFingersTouchZoomRotateHandler=vt,W.VectorTileSource=jo,W.VideoSource=Ne,W.addSourceType=(y,t)=>p._(void 0,void 0,void 0,(function*(){if(le(y))throw new Error(`A source type called "${y}" already exists.`);((n,h)=>{K[n]=h})(y,t)})),W.clearPrewarmedResources=function(){const y=hn;y&&(y.isPreloaded()&&y.numActive()===1?(y.release(or),hn=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},W.createTileMesh=ka,W.getMaxParallelImageRequests=function(){return p.c.MAX_PARALLEL_IMAGE_REQUESTS},W.getRTLTextPluginStatus=function(){return Fe().getRTLTextPluginStatus()},W.getVersion=function(){return vh},W.getWorkerCount=function(){return xi.workerCount},W.getWorkerUrl=function(){return p.c.WORKER_URL},W.importScriptInWorkers=function(y){return No().broadcast("IS",y)},W.isTimeFrozen=function(){return Mn.isFrozen()},W.now=Gt,W.prewarm=function(){yo().acquire(or)},W.restoreNow=function(){Mn.restoreNow()},W.setMaxParallelImageRequests=function(y){p.c.MAX_PARALLEL_IMAGE_REQUESTS=y},W.setNow=function(y){Mn.setNow(y)},W.setRTLTextPlugin=function(y,t){return Fe().setRTLTextPlugin(y,t)},W.setWorkerCount=function(y){xi.workerCount=y},W.setWorkerUrl=function(y){p.c.WORKER_URL=y}}));var ct=fe;return ct}))})(Tc)),Tc.exports}var yp=bg();const wg=Jd(yp),Sg=Kd({__proto__:null,default:wg},[yp]),Cg=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{Eg as a,Cg as b,Mg as h,Pg as l,Sg as m};
+1
static/js/profile-cropper-Cp_DD48I.js
··· 1 + import{a as y,S as h}from"./main-B2-Bk5P8.js";import{loadCropper as w}from"./index-8MdtY9qF.js";let r=null,o=null,m=!1;async function E(){const i=document.getElementById("avatar-input"),s=document.getElementById("banner-input");if(!i&&!s||m)return;m=!0;const e=await w();i&&v(i,e),s&&C(s,e)}function v(i,s){const e=document.getElementById("avatar-canvas"),d=document.getElementById("avatar-crop");!e||!d||(i.addEventListener("change",n=>{var p;const t=(p=n.target.files)==null?void 0:p[0];if(!t)return;const c=new FileReader;c.onload=u=>{var g;const a=new Image;a.onload=()=>{e.width=a.width,e.height=a.height,e.style.display="block",d.style.display="inline-block";const f=e.getContext("2d");f&&f.drawImage(a,0,0),r&&r.destroy(),r=new s(e,{aspectRatio:1,viewMode:1})},a.src=(g=u.target)==null?void 0:g.result},c.readAsDataURL(t)}),d.addEventListener("click",()=>{r&&r.getCroppedCanvas({width:400,height:400}).toBlob(async n=>{if(!n)return;const l=new FormData;l.append("avatar",n,"avatar.png");try{(await y("/settings/avatar",{method:"POST",body:l})).ok&&window.location.reload()}catch(t){t instanceof h?alert(t.message):(console.error("Avatar upload error:",t),alert("Failed to upload avatar. Please try again."))}},"image/png")}))}function C(i,s){const e=document.getElementById("banner-canvas"),d=document.getElementById("banner-crop");!e||!d||(i.addEventListener("change",n=>{var p;const t=(p=n.target.files)==null?void 0:p[0];if(!t)return;const c=new FileReader;c.onload=u=>{var g;const a=new Image;a.onload=()=>{e.width=a.width,e.height=a.height,e.style.display="block",d.style.display="inline-block";const f=e.getContext("2d");f&&f.drawImage(a,0,0),o&&o.destroy(),o=new s(e,{aspectRatio:16/9,viewMode:1})},a.src=(g=u.target)==null?void 0:g.result},c.readAsDataURL(t)}),d.addEventListener("click",()=>{o&&o.getCroppedCanvas({width:1600,height:900}).toBlob(async n=>{if(!n)return;const l=new FormData;l.append("banner",n,"banner.png");try{(await y("/settings/banner",{method:"POST",body:l})).ok&&window.location.reload()}catch(t){t instanceof h?alert(t.message):(console.error("Banner upload error:",t),alert("Failed to upload banner. Please try again."))}},"image/png")}))}function I(){r&&(r.destroy(),r=null),o&&(o.destroy(),o=null),m=!1}export{I as destroyProfileCropper,E as initProfileCropper};
-1
static/js/profile-cropper-DwPaCPSP.js
··· 1 - import{loadCropper as h}from"./index-Bcnf8oUZ.js";import"./main-CuQd5Sql.js";let r=null,o=null,m=!1;async function b(){const i=document.getElementById("avatar-input"),d=document.getElementById("banner-input");if(!i&&!d||m)return;m=!0;const t=await h();i&&w(i,t),d&&y(d,t)}function w(i,d){const t=document.getElementById("avatar-canvas"),s=document.getElementById("avatar-crop");!t||!s||(i.addEventListener("change",n=>{var p;const a=(p=n.target.files)==null?void 0:p[0];if(!a)return;const l=new FileReader;l.onload=u=>{var g;const e=new Image;e.onload=()=>{t.width=e.width,t.height=e.height,t.style.display="block",s.style.display="inline-block";const f=t.getContext("2d");f&&f.drawImage(e,0,0),r&&r.destroy(),r=new d(t,{aspectRatio:1,viewMode:1})},e.src=(g=u.target)==null?void 0:g.result},l.readAsDataURL(a)}),s.addEventListener("click",()=>{r&&r.getCroppedCanvas({width:400,height:400}).toBlob(n=>{if(!n)return;const c=new FormData;c.append("avatar",n,"avatar.png"),fetch("/settings/avatar",{method:"POST",body:c}).then(a=>{a.ok&&window.location.reload()})},"image/png")}))}function y(i,d){const t=document.getElementById("banner-canvas"),s=document.getElementById("banner-crop");!t||!s||(i.addEventListener("change",n=>{var p;const a=(p=n.target.files)==null?void 0:p[0];if(!a)return;const l=new FileReader;l.onload=u=>{var g;const e=new Image;e.onload=()=>{t.width=e.width,t.height=e.height,t.style.display="block",s.style.display="inline-block";const f=t.getContext("2d");f&&f.drawImage(e,0,0),o&&o.destroy(),o=new d(t,{aspectRatio:16/9,viewMode:1})},e.src=(g=u.target)==null?void 0:g.result},l.readAsDataURL(a)}),s.addEventListener("click",()=>{o&&o.getCroppedCanvas({width:1600,height:900}).toBlob(n=>{if(!n)return;const c=new FormData;c.append("banner",n,"banner.png"),fetch("/settings/banner",{method:"POST",body:c}).then(a=>{a.ok&&window.location.reload()})},"image/png")}))}function I(){r&&(r.destroy(),r=null),o&&(o.destroy(),o=null),m=!1}export{I as destroyProfileCropper,b as initProfileCropper};
+1 -1
templates/en-us/bare.html
··· 14 14 {% endblock %} 15 15 <meta name="theme-color" content="#00d1b2"> 16 16 </head> 17 - <body hx-ext="loading-states"> 17 + <body hx-ext="auth-refresh,loading-states"> 18 18 {% include 'en-us/nav.html' %} 19 19 {% block content %}{% endblock %} 20 20 {% include 'en-us/footer.html' %}
+1 -1
templates/en-us/base.html
··· 20 20 {% endblock %} 21 21 <meta name="theme-color" content="#00d1b2"> 22 22 </head> 23 - <body hx-ext="loading-states"> 23 + <body hx-ext="auth-refresh,loading-states"> 24 24 {% include 'en-us/nav.html' %} 25 25 {% block content %}{% endblock %} 26 26 {% include 'en-us/footer.html' %}
+14
templates/en-us/settings.common.html
··· 60 60 </div> 61 61 </div> 62 62 </div> 63 + 64 + <hr> 65 + 66 + <div class="columns"> 67 + <div class="column"> 68 + <h2 class="subtitle">MCP Configuration</h2> 69 + <p class="has-text-grey mb-4"> 70 + Control how AI agents can interact with your account via Model Context Protocol. 71 + </p> 72 + <div id="mcp-config-form"> 73 + {% include "en-us/settings.mcp.html" %} 74 + </div> 75 + </div> 76 + </div> 63 77 </div> 64 78 </div> 65 79 </div>
+19
templates/en-us/settings.mcp.html
··· 1 + <form id="mcp-config-form" method="post" hx-post="/api/mcp/configuration" hx-swap="none"> 2 + <div class="field"> 3 + <label class="checkbox"> 4 + <input type="checkbox" name="allow_dangerous" {% if mcp_allow_dangerous %}checked{% endif %}> 5 + Allow dangerous operations 6 + </label> 7 + <p class="help"> 8 + When enabled, MCP clients can invoke destructive XRPC methods including: 9 + com.atproto.repo.deleteRecord, com.atproto.repo.applyWrites. 10 + Only enable if you trust your MCP client applications. 11 + </p> 12 + </div> 13 + 14 + <div class="field"> 15 + <div class="control"> 16 + <button type="submit" class="button is-primary">Save MCP Settings</button> 17 + </div> 18 + </div> 19 + </form>