From 869366b567f20b8f1d6d4344fde7ecee674a96b5 Mon Sep 17 00:00:00 2001 From: korywka Date: Fri, 19 Apr 2024 23:26:05 +0200 Subject: [PATCH] fix: style control --- packages/compass/package.json | 57 ++++--- packages/helpers/package.json | 53 +++---- packages/image/package.json | 75 +++++---- packages/inspect/package.json | 57 ++++--- packages/language/package.json | 51 +++---- packages/ruler/package.json | 66 ++++---- packages/styles/package.json | 57 ++++--- packages/styles/src/index.js | 39 +++-- packages/tooltip/package.json | 51 +++---- packages/zoom/package.json | 57 ++++--- pnpm-lock.yaml | 269 +++++++++++++++++++-------------- preview/package.json | 58 +++---- preview/preview.bundle.css | 2 +- preview/preview.bundle.js | 132 ++++++---------- preview/preview.js | 2 +- 15 files changed, 515 insertions(+), 511 deletions(-) diff --git a/packages/compass/package.json b/packages/compass/package.json index 12e4f67..0da7f44 100644 --- a/packages/compass/package.json +++ b/packages/compass/package.json @@ -1,31 +1,28 @@ { - "name": "@mapbox-controls/compass", - "version": "1.1.0", - "description": "Indicate map direction", - "type": "module", - "main": "./src/index.js", - "scripts": { - "build": "tsc" - }, - "dependencies": { - "@mapbox-controls/helpers": "1.1.0" - }, - "devDependencies": { - "@types/mapbox-gl": "2.7.19", - "mapbox-gl": "3.0.1" - }, - "peerDependencies": { - "mapbox-gl": ">=1.0.0 <4.0.0" - }, - "types": "./types/index.d.ts", - "files": [ - "src", - "types" - ], - "publishConfig": { - "access": "public", - "registry": "https://registry.npmjs.org/" - }, - "repository": "korywka/mapbox-controls", - "license": "MIT" -} \ No newline at end of file + "name": "@mapbox-controls/compass", + "version": "1.1.0", + "description": "Indicate map direction", + "type": "module", + "main": "./src/index.js", + "scripts": { + "build": "tsc" + }, + "dependencies": { + "@mapbox-controls/helpers": "1.1.0" + }, + "devDependencies": { + "@types/mapbox-gl": "3.1.0", + "mapbox-gl": "3.3.0" + }, + "peerDependencies": { + "mapbox-gl": ">=1.0.0 <4.0.0" + }, + "types": "./types/index.d.ts", + "files": ["src", "types"], + "publishConfig": { + "access": "public", + "registry": "https://registry.npmjs.org/" + }, + "repository": "korywka/mapbox-controls", + "license": "MIT" +} diff --git a/packages/helpers/package.json b/packages/helpers/package.json index 3034800..33683f9 100644 --- a/packages/helpers/package.json +++ b/packages/helpers/package.json @@ -1,29 +1,26 @@ { - "name": "@mapbox-controls/helpers", - "version": "1.1.0", - "description": "Helpers for mapbox controls", - "type": "module", - "main": "./src/index.js", - "scripts": { - "build": "tsc" - }, - "devDependencies": { - "@types/geojson": "7946.0.13", - "@types/mapbox-gl": "2.7.19", - "mapbox-gl": "3.0.1" - }, - "peerDependencies": { - "mapbox-gl": ">=1.0.0 <4.0.0" - }, - "types": "./types/index.d.ts", - "files": [ - "src", - "types" - ], - "publishConfig": { - "access": "public", - "registry": "https://registry.npmjs.org/" - }, - "repository": "korywka/mapbox-gl-controls", - "license": "MIT" -} \ No newline at end of file + "name": "@mapbox-controls/helpers", + "version": "1.1.0", + "description": "Helpers for mapbox controls", + "type": "module", + "main": "./src/index.js", + "scripts": { + "build": "tsc" + }, + "devDependencies": { + "@types/geojson": "7946.0.13", + "@types/mapbox-gl": "3.1.0", + "mapbox-gl": "3.3.0" + }, + "peerDependencies": { + "mapbox-gl": ">=1.0.0 <4.0.0" + }, + "types": "./types/index.d.ts", + "files": ["src", "types"], + "publishConfig": { + "access": "public", + "registry": "https://registry.npmjs.org/" + }, + "repository": "korywka/mapbox-gl-controls", + "license": "MIT" +} diff --git a/packages/image/package.json b/packages/image/package.json index a974e3d..61d7e87 100644 --- a/packages/image/package.json +++ b/packages/image/package.json @@ -1,40 +1,37 @@ { - "name": "@mapbox-controls/image", - "version": "1.1.0", - "description": "Move, scale and rotate image on a map", - "type": "module", - "main": "./src/index.js", - "scripts": { - "build": "tsc" - }, - "dependencies": { - "@mapbox-controls/helpers": "1.1.0", - "@turf/bearing": "7.0.0-alpha.2", - "@turf/centroid": "7.0.0-alpha.2", - "@turf/helpers": "7.0.0-alpha.2", - "@turf/rhumb-bearing": "7.0.0-alpha.2", - "@turf/rhumb-distance": "7.0.0-alpha.2", - "@turf/transform-rotate": "7.0.0-alpha.2", - "@turf/transform-scale": "7.0.0-alpha.2", - "@turf/transform-translate": "7.0.0-alpha.2" - }, - "devDependencies": { - "@types/geojson": "7946.0.13", - "@types/mapbox-gl": "2.7.19", - "mapbox-gl": "3.0.1" - }, - "peerDependencies": { - "mapbox-gl": ">=1.0.0 <4.0.0" - }, - "types": "./types/index.d.ts", - "files": [ - "src", - "types" - ], - "publishConfig": { - "access": "public", - "registry": "https://registry.npmjs.org/" - }, - "repository": "korywka/mapbox-controls", - "license": "MIT" -} \ No newline at end of file + "name": "@mapbox-controls/image", + "version": "1.1.0", + "description": "Move, scale and rotate image on a map", + "type": "module", + "main": "./src/index.js", + "scripts": { + "build": "tsc" + }, + "dependencies": { + "@mapbox-controls/helpers": "1.1.0", + "@turf/bearing": "7.0.0-alpha.2", + "@turf/centroid": "7.0.0-alpha.2", + "@turf/helpers": "7.0.0-alpha.2", + "@turf/rhumb-bearing": "7.0.0-alpha.2", + "@turf/rhumb-distance": "7.0.0-alpha.2", + "@turf/transform-rotate": "7.0.0-alpha.2", + "@turf/transform-scale": "7.0.0-alpha.2", + "@turf/transform-translate": "7.0.0-alpha.2" + }, + "devDependencies": { + "@types/geojson": "7946.0.13", + "@types/mapbox-gl": "3.1.0", + "mapbox-gl": "3.3.0" + }, + "peerDependencies": { + "mapbox-gl": ">=1.0.0 <4.0.0" + }, + "types": "./types/index.d.ts", + "files": ["src", "types"], + "publishConfig": { + "access": "public", + "registry": "https://registry.npmjs.org/" + }, + "repository": "korywka/mapbox-controls", + "license": "MIT" +} diff --git a/packages/inspect/package.json b/packages/inspect/package.json index e751078..3a760e8 100644 --- a/packages/inspect/package.json +++ b/packages/inspect/package.json @@ -1,31 +1,28 @@ { - "name": "@mapbox-controls/inspect", - "version": "1.1.0", - "description": "Debug map style layers and sources", - "type": "module", - "main": "./src/index.js", - "scripts": { - "build": "tsc" - }, - "dependencies": { - "@mapbox-controls/helpers": "1.1.0" - }, - "devDependencies": { - "@types/mapbox-gl": "2.7.19", - "mapbox-gl": "3.0.1" - }, - "peerDependencies": { - "mapbox-gl": ">=1.0.0 <4.0.0" - }, - "types": "./types/index.d.ts", - "files": [ - "src", - "types" - ], - "publishConfig": { - "access": "public", - "registry": "https://registry.npmjs.org/" - }, - "repository": "korywka/mapbox-gl-controls", - "license": "MIT" -} \ No newline at end of file + "name": "@mapbox-controls/inspect", + "version": "1.1.0", + "description": "Debug map style layers and sources", + "type": "module", + "main": "./src/index.js", + "scripts": { + "build": "tsc" + }, + "dependencies": { + "@mapbox-controls/helpers": "1.1.0" + }, + "devDependencies": { + "@types/mapbox-gl": "3.1.0", + "mapbox-gl": "3.3.0" + }, + "peerDependencies": { + "mapbox-gl": ">=1.0.0 <4.0.0" + }, + "types": "./types/index.d.ts", + "files": ["src", "types"], + "publishConfig": { + "access": "public", + "registry": "https://registry.npmjs.org/" + }, + "repository": "korywka/mapbox-gl-controls", + "license": "MIT" +} diff --git a/packages/language/package.json b/packages/language/package.json index 8a62a7e..b7e6522 100644 --- a/packages/language/package.json +++ b/packages/language/package.json @@ -1,28 +1,25 @@ { - "name": "@mapbox-controls/language", - "version": "1.1.0", - "description": "Change map language", - "type": "module", - "main": "./src/index.js", - "scripts": { - "build": "tsc" - }, - "devDependencies": { - "@types/mapbox-gl": "2.7.19", - "mapbox-gl": "3.0.1" - }, - "peerDependencies": { - "mapbox-gl": ">=1.0.0 <4.0.0" - }, - "types": "./types/index.d.ts", - "files": [ - "src", - "types" - ], - "publishConfig": { - "access": "public", - "registry": "https://registry.npmjs.org/" - }, - "repository": "korywka/mapbox-controls", - "license": "MIT" -} \ No newline at end of file + "name": "@mapbox-controls/language", + "version": "1.1.0", + "description": "Change map language", + "type": "module", + "main": "./src/index.js", + "scripts": { + "build": "tsc" + }, + "devDependencies": { + "@types/mapbox-gl": "3.1.0", + "mapbox-gl": "3.3.0" + }, + "peerDependencies": { + "mapbox-gl": ">=1.0.0 <4.0.0" + }, + "types": "./types/index.d.ts", + "files": ["src", "types"], + "publishConfig": { + "access": "public", + "registry": "https://registry.npmjs.org/" + }, + "repository": "korywka/mapbox-controls", + "license": "MIT" +} diff --git a/packages/ruler/package.json b/packages/ruler/package.json index c1a1e91..bae75cc 100644 --- a/packages/ruler/package.json +++ b/packages/ruler/package.json @@ -1,34 +1,34 @@ { - "name": "@mapbox-controls/ruler", - "version": "1.1.0", - "description": "Measure distance between points on a map", - "type": "module", - "main": "./src/index.js", - "scripts": { - "build": "tsc" - }, - "dependencies": { - "@mapbox-controls/helpers": "1.1.0", - "@turf/distance": "7.0.0-alpha.2", - "@turf/helpers": "7.0.0-alpha.2" - }, - "devDependencies": { - "@types/geojson": "7946.0.13", - "@types/mapbox-gl": "2.7.19", - "mapbox-gl": "3.0.1" - }, - "peerDependencies": { - "mapbox-gl": ">=1.0.0 <4.0.0" - }, - "types": "./types/index.d.ts", - "files": [ - "src", - "types" - ], - "publishConfig": { - "access": "public", - "registry": "https://registry.npmjs.org/" - }, - "repository": "korywka/mapbox-gl-controls", - "license": "MIT" -} \ No newline at end of file + "name": "@mapbox-controls/ruler", + "version": "1.1.0", + "description": "Measure distance between points on a map", + "type": "module", + "main": "./src/index.js", + "scripts": { + "build": "tsc" + }, + "dependencies": { + "@mapbox-controls/helpers": "1.1.0", + "@turf/distance": "7.0.0-alpha.2", + "@turf/helpers": "7.0.0-alpha.2" + }, + "devDependencies": { + "@types/geojson": "7946.0.13", + "@types/mapbox-gl": "3.1.0", + "mapbox-gl": "3.3.0" + }, + "peerDependencies": { + "mapbox-gl": ">=1.0.0 <4.0.0" + }, + "types": "./types/index.d.ts", + "files": [ + "src", + "types" + ], + "publishConfig": { + "access": "public", + "registry": "https://registry.npmjs.org/" + }, + "repository": "korywka/mapbox-gl-controls", + "license": "MIT" +} diff --git a/packages/styles/package.json b/packages/styles/package.json index 2999d1a..52b9dd6 100644 --- a/packages/styles/package.json +++ b/packages/styles/package.json @@ -1,31 +1,28 @@ { - "name": "@mapbox-controls/styles", - "version": "1.1.0", - "description": "Change map style", - "type": "module", - "main": "./src/index.js", - "scripts": { - "build": "tsc" - }, - "dependencies": { - "@mapbox-controls/helpers": "1.1.0" - }, - "devDependencies": { - "@types/mapbox-gl": "2.7.19", - "mapbox-gl": "3.0.1" - }, - "peerDependencies": { - "mapbox-gl": ">=1.0.0 <4.0.0" - }, - "types": "./types/index.d.ts", - "files": [ - "src", - "types" - ], - "publishConfig": { - "access": "public", - "registry": "https://registry.npmjs.org/" - }, - "repository": "korywka/mapbox-controls", - "license": "MIT" -} \ No newline at end of file + "name": "@mapbox-controls/styles", + "version": "1.1.0", + "description": "Change map style", + "type": "module", + "main": "./src/index.js", + "scripts": { + "build": "tsc" + }, + "dependencies": { + "@mapbox-controls/helpers": "1.1.0" + }, + "devDependencies": { + "@types/mapbox-gl": "3.1.0", + "mapbox-gl": "3.3.0" + }, + "peerDependencies": { + "mapbox-gl": ">=1.0.0 <4.0.0" + }, + "types": "./types/index.d.ts", + "files": ["src", "types"], + "publishConfig": { + "access": "public", + "registry": "https://registry.npmjs.org/" + }, + "repository": "korywka/mapbox-controls", + "license": "MIT" +} diff --git a/packages/styles/src/index.js b/packages/styles/src/index.js index c6b4310..8ff4992 100644 --- a/packages/styles/src/index.js +++ b/packages/styles/src/index.js @@ -17,13 +17,13 @@ import { icons } from './icons.js'; const defaults = [ { - label: 'Streets', - styleName: 'Mapbox Streets', - styleUrl: 'mapbox://styles/mapbox/streets-v12', + label: 'Standard', + styleName: 'Mapbox Standard', + styleUrl: 'mapbox://styles/mapbox/standard', }, { label: 'Satellite', styleName: 'Mapbox Satellite Streets', - styleUrl: 'mapbox://sprites/mapbox/satellite-streets-v12', + styleUrl: 'mapbox://styles/mapbox/satellite-streets-v12', }, ]; @@ -36,12 +36,29 @@ export default class StylesControl { } /** @param {string} name */ - findStyleByName(name) { + findStyle(name) { const style = this.options.styles.find((s) => s.styleName === name); if (!style) throw Error(`can't find style with name ${name}`); return style; } + getCurrentStyleName() { + if (!this.map) throw Error('map is undefined'); + /** @type {string} */ + let name; + /** @type {any} mapbox standard style doesn't return JSON Style object */ + const style = this.map.getStyle(); + if (Array.isArray(style.imports) && style.imports.length) { + // mapbox standard style + name = style.imports[0].data.name; + } else { + // classic style + name = style.name; + } + if (!name) throw Error('style must have name'); + return name; + } + expanded() { if (!this.map) throw Error('map is undefined'); /** @type HTMLButtonElement[] */ @@ -67,9 +84,8 @@ export default class StylesControl { button.classList.remove('-active'); }); const styleNames = this.options.styles.map((style) => style.styleName); - const styleName = this.map.getStyle().name; - if (!styleName) throw Error('style must have name'); - const currentStyleIndex = styleNames.indexOf(styleName); + const currentStyleName = this.getCurrentStyleName(); + const currentStyleIndex = styleNames.indexOf(currentStyleName); if (currentStyleIndex !== -1) { const currentButton = buttons[currentStyleIndex]; currentButton.classList.add('-active'); @@ -93,16 +109,13 @@ export default class StylesControl { select.addEventListener('change', () => { if (!this.map) throw Error('map is undefined'); - const style = this.findStyleByName(select.value); + const style = this.findStyle(select.value); this.map.setStyle(style.styleUrl); if (this.options.onChange) this.options.onChange(style); }); this.map.on('styledata', () => { - if (!this.map) throw Error('map is undefined'); - const styleName = this.map.getStyle().name; - if (!styleName) throw Error('style must have name'); - select.value = styleName; + select.value = this.getCurrentStyleName(); }); } diff --git a/packages/tooltip/package.json b/packages/tooltip/package.json index e274166..9cd9d43 100644 --- a/packages/tooltip/package.json +++ b/packages/tooltip/package.json @@ -1,28 +1,25 @@ { - "name": "@mapbox-controls/tooltip", - "version": "1.1.0", - "description": "Display tooltip on hover", - "type": "module", - "main": "./src/index.js", - "scripts": { - "build": "tsc" - }, - "devDependencies": { - "@types/mapbox-gl": "2.7.19", - "mapbox-gl": "3.0.1" - }, - "peerDependencies": { - "mapbox-gl": ">=1.0.0 <4.0.0" - }, - "types": "./types/index.d.ts", - "files": [ - "src", - "types" - ], - "publishConfig": { - "access": "public", - "registry": "https://registry.npmjs.org/" - }, - "repository": "korywka/mapbox-gl-controls", - "license": "MIT" -} \ No newline at end of file + "name": "@mapbox-controls/tooltip", + "version": "1.1.0", + "description": "Display tooltip on hover", + "type": "module", + "main": "./src/index.js", + "scripts": { + "build": "tsc" + }, + "devDependencies": { + "@types/mapbox-gl": "3.1.0", + "mapbox-gl": "3.3.0" + }, + "peerDependencies": { + "mapbox-gl": ">=1.0.0 <4.0.0" + }, + "types": "./types/index.d.ts", + "files": ["src", "types"], + "publishConfig": { + "access": "public", + "registry": "https://registry.npmjs.org/" + }, + "repository": "korywka/mapbox-gl-controls", + "license": "MIT" +} diff --git a/packages/zoom/package.json b/packages/zoom/package.json index 13dc001..0d26303 100644 --- a/packages/zoom/package.json +++ b/packages/zoom/package.json @@ -1,31 +1,28 @@ { - "name": "@mapbox-controls/zoom", - "version": "1.1.0", - "description": "Zoom in and zoom out map", - "type": "module", - "main": "./src/index.js", - "scripts": { - "build": "tsc" - }, - "dependencies": { - "@mapbox-controls/helpers": "1.1.0" - }, - "devDependencies": { - "@types/mapbox-gl": "2.7.10", - "mapbox-gl": "3.0.1" - }, - "peerDependencies": { - "mapbox-gl": ">=1.0.0 <4.0.0" - }, - "types": "./types/index.d.ts", - "files": [ - "src", - "types" - ], - "publishConfig": { - "access": "public", - "registry": "https://registry.npmjs.org/" - }, - "repository": "korywka/mapbox-controls", - "license": "MIT" -} \ No newline at end of file + "name": "@mapbox-controls/zoom", + "version": "1.1.0", + "description": "Zoom in and zoom out map", + "type": "module", + "main": "./src/index.js", + "scripts": { + "build": "tsc" + }, + "dependencies": { + "@mapbox-controls/helpers": "1.1.0" + }, + "devDependencies": { + "@types/mapbox-gl": "3.1.0", + "mapbox-gl": "3.3.0" + }, + "peerDependencies": { + "mapbox-gl": ">=1.0.0 <4.0.0" + }, + "types": "./types/index.d.ts", + "files": ["src", "types"], + "publishConfig": { + "access": "public", + "registry": "https://registry.npmjs.org/" + }, + "repository": "korywka/mapbox-controls", + "license": "MIT" +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 96baa83..25a45cf 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -28,11 +28,11 @@ importers: version: link:../helpers devDependencies: '@types/mapbox-gl': - specifier: 2.7.19 - version: 2.7.19 + specifier: 3.1.0 + version: 3.1.0 mapbox-gl: - specifier: 3.0.1 - version: 3.0.1 + specifier: 3.3.0 + version: 3.3.0 packages/helpers: devDependencies: @@ -40,11 +40,11 @@ importers: specifier: 7946.0.13 version: 7946.0.13 '@types/mapbox-gl': - specifier: 2.7.19 - version: 2.7.19 + specifier: 3.1.0 + version: 3.1.0 mapbox-gl: - specifier: 3.0.1 - version: 3.0.1 + specifier: 3.3.0 + version: 3.3.0 packages/image: dependencies: @@ -80,11 +80,11 @@ importers: specifier: 7946.0.13 version: 7946.0.13 '@types/mapbox-gl': - specifier: 2.7.19 - version: 2.7.19 + specifier: 3.1.0 + version: 3.1.0 mapbox-gl: - specifier: 3.0.1 - version: 3.0.1 + specifier: 3.3.0 + version: 3.3.0 packages/inspect: dependencies: @@ -93,20 +93,20 @@ importers: version: link:../helpers devDependencies: '@types/mapbox-gl': - specifier: 2.7.19 - version: 2.7.19 + specifier: 3.1.0 + version: 3.1.0 mapbox-gl: - specifier: 3.0.1 - version: 3.0.1 + specifier: 3.3.0 + version: 3.3.0 packages/language: devDependencies: '@types/mapbox-gl': - specifier: 2.7.19 - version: 2.7.19 + specifier: 3.1.0 + version: 3.1.0 mapbox-gl: - specifier: 3.0.1 - version: 3.0.1 + specifier: 3.3.0 + version: 3.3.0 packages/ruler: dependencies: @@ -124,11 +124,11 @@ importers: specifier: 7946.0.13 version: 7946.0.13 '@types/mapbox-gl': - specifier: 2.7.19 - version: 2.7.19 + specifier: 3.1.0 + version: 3.1.0 mapbox-gl: - specifier: 3.0.1 - version: 3.0.1 + specifier: 3.3.0 + version: 3.3.0 packages/styles: dependencies: @@ -137,20 +137,20 @@ importers: version: link:../helpers devDependencies: '@types/mapbox-gl': - specifier: 2.7.19 - version: 2.7.19 + specifier: 3.1.0 + version: 3.1.0 mapbox-gl: - specifier: 3.0.1 - version: 3.0.1 + specifier: 3.3.0 + version: 3.3.0 packages/tooltip: devDependencies: '@types/mapbox-gl': - specifier: 2.7.19 - version: 2.7.19 + specifier: 3.1.0 + version: 3.1.0 mapbox-gl: - specifier: 3.0.1 - version: 3.0.1 + specifier: 3.3.0 + version: 3.3.0 packages/zoom: dependencies: @@ -159,11 +159,11 @@ importers: version: link:../helpers devDependencies: '@types/mapbox-gl': - specifier: 2.7.10 - version: 2.7.10 + specifier: 3.1.0 + version: 3.1.0 mapbox-gl: - specifier: 3.0.1 - version: 3.0.1 + specifier: 3.3.0 + version: 3.3.0 preview: dependencies: @@ -192,24 +192,24 @@ importers: specifier: workspace:* version: link:../packages/zoom mapbox-gl: - specifier: 3.0.1 - version: 3.0.1 + specifier: 3.3.0 + version: 3.3.0 devDependencies: '@rollup/plugin-commonjs': specifier: 25.0.7 - version: 25.0.7(rollup@4.9.1) + version: 25.0.7(rollup@4.14.3) '@rollup/plugin-node-resolve': specifier: 15.2.3 - version: 15.2.3(rollup@4.9.1) + version: 15.2.3(rollup@4.14.3) concurrently: specifier: 8.2.2 version: 8.2.2 rollup: - specifier: 4.9.1 - version: 4.9.1 + specifier: 4.14.3 + version: 4.14.3 rollup-plugin-import-css: - specifier: 3.3.5 - version: 3.3.5(rollup@4.9.1) + specifier: 3.5.0 + version: 3.5.0(rollup@4.14.3) serve: specifier: 14.2.1 version: 14.2.1 @@ -300,8 +300,8 @@ packages: resolution: {integrity: sha512-rY0o9A5ECsTQRVhv7tL/OyDpGAoUB4tTvLiW1DSzQGq4bvTPhNw1VpSNjDJc5GFZ2XuyOtSWSVN05qOtcD71qQ==} engines: {node: '>= 0.6'} - /@mapbox/mapbox-gl-supported@2.0.1: - resolution: {integrity: sha512-HP6XvfNIzfoMVfyGjBckjiAOQK9WfX0ywdLubuPMPv+Vqf5fj0uCbgBQYpiqcWZT6cbyyRnTSXDheT1ugvF6UQ==} + /@mapbox/mapbox-gl-supported@3.0.0: + resolution: {integrity: sha512-2XghOwu16ZwPJLOFVuIOaLbN0iKMn867evzXFyf0P22dqugezfJwLmdanAgU25ITvz1TvOfVP4jsDImlDJzcWg==} /@mapbox/point-geometry@0.1.0: resolution: {integrity: sha512-6j56HdLTwWGO0fJPlrZtdU/B13q8Uwmo18Ck2GnGgN9PCFyKTZ3UbXeEdRFh18i9XQ92eH2VdtpJHpBD3aripQ==} @@ -342,7 +342,7 @@ packages: fastq: 1.15.0 dev: true - /@rollup/plugin-commonjs@25.0.7(rollup@4.9.1): + /@rollup/plugin-commonjs@25.0.7(rollup@4.14.3): resolution: {integrity: sha512-nEvcR+LRjEjsaSsc4x3XZfCCvZIaSMenZu/OiwOKGN2UhQpAYI7ru7czFvyWbErlpoGjnSX3D5Ch5FcMA3kRWQ==} engines: {node: '>=14.0.0'} peerDependencies: @@ -351,16 +351,16 @@ packages: rollup: optional: true dependencies: - '@rollup/pluginutils': 5.0.4(rollup@4.9.1) + '@rollup/pluginutils': 5.0.4(rollup@4.14.3) commondir: 1.0.1 estree-walker: 2.0.2 glob: 8.1.0 is-reference: 1.2.1 magic-string: 0.30.5 - rollup: 4.9.1 + rollup: 4.14.3 dev: true - /@rollup/plugin-node-resolve@15.2.3(rollup@4.9.1): + /@rollup/plugin-node-resolve@15.2.3(rollup@4.14.3): resolution: {integrity: sha512-j/lym8nf5E21LwBT4Df1VD6hRO2L2iwUeUmP7litikRsVp1H6NWx20NEp0Y7su+7XGc476GnXXc4kFeZNGmaSQ==} engines: {node: '>=14.0.0'} peerDependencies: @@ -369,16 +369,16 @@ packages: rollup: optional: true dependencies: - '@rollup/pluginutils': 5.0.4(rollup@4.9.1) + '@rollup/pluginutils': 5.0.4(rollup@4.14.3) '@types/resolve': 1.20.2 deepmerge: 4.3.1 is-builtin-module: 3.2.1 is-module: 1.0.0 resolve: 1.22.4 - rollup: 4.9.1 + rollup: 4.14.3 dev: true - /@rollup/pluginutils@5.0.4(rollup@4.9.1): + /@rollup/pluginutils@5.0.4(rollup@4.14.3): resolution: {integrity: sha512-0KJnIoRI8A+a1dqOYLxH8vBf8bphDmty5QvIm2hqm7oFCFYKCAZWWd2hXgMibaPsNDhI0AtpYfQZJG47pt/k4g==} engines: {node: '>=14.0.0'} peerDependencies: @@ -390,107 +390,131 @@ packages: '@types/estree': 1.0.1 estree-walker: 2.0.2 picomatch: 2.3.1 - rollup: 4.9.1 + rollup: 4.14.3 dev: true - /@rollup/rollup-android-arm-eabi@4.9.1: - resolution: {integrity: sha512-6vMdBZqtq1dVQ4CWdhFwhKZL6E4L1dV6jUjuBvsavvNJSppzi6dLBbuV+3+IyUREaj9ZFvQefnQm28v4OCXlig==} + /@rollup/rollup-android-arm-eabi@4.14.3: + resolution: {integrity: sha512-X9alQ3XM6I9IlSlmC8ddAvMSyG1WuHk5oUnXGw+yUBs3BFoTizmG1La/Gr8fVJvDWAq+zlYTZ9DBgrlKRVY06g==} cpu: [arm] os: [android] requiresBuild: true dev: true optional: true - /@rollup/rollup-android-arm64@4.9.1: - resolution: {integrity: sha512-Jto9Fl3YQ9OLsTDWtLFPtaIMSL2kwGyGoVCmPC8Gxvym9TCZm4Sie+cVeblPO66YZsYH8MhBKDMGZ2NDxuk/XQ==} + /@rollup/rollup-android-arm64@4.14.3: + resolution: {integrity: sha512-eQK5JIi+POhFpzk+LnjKIy4Ks+pwJ+NXmPxOCSvOKSNRPONzKuUvWE+P9JxGZVxrtzm6BAYMaL50FFuPe0oWMQ==} cpu: [arm64] os: [android] requiresBuild: true dev: true optional: true - /@rollup/rollup-darwin-arm64@4.9.1: - resolution: {integrity: sha512-LtYcLNM+bhsaKAIGwVkh5IOWhaZhjTfNOkGzGqdHvhiCUVuJDalvDxEdSnhFzAn+g23wgsycmZk1vbnaibZwwA==} + /@rollup/rollup-darwin-arm64@4.14.3: + resolution: {integrity: sha512-Od4vE6f6CTT53yM1jgcLqNfItTsLt5zE46fdPaEmeFHvPs5SjZYlLpHrSiHEKR1+HdRfxuzXHjDOIxQyC3ptBA==} cpu: [arm64] os: [darwin] requiresBuild: true dev: true optional: true - /@rollup/rollup-darwin-x64@4.9.1: - resolution: {integrity: sha512-KyP/byeXu9V+etKO6Lw3E4tW4QdcnzDG/ake031mg42lob5tN+5qfr+lkcT/SGZaH2PdW4Z1NX9GHEkZ8xV7og==} + /@rollup/rollup-darwin-x64@4.14.3: + resolution: {integrity: sha512-0IMAO21axJeNIrvS9lSe/PGthc8ZUS+zC53O0VhF5gMxfmcKAP4ESkKOCwEi6u2asUrt4mQv2rjY8QseIEb1aw==} cpu: [x64] os: [darwin] requiresBuild: true dev: true optional: true - /@rollup/rollup-linux-arm-gnueabihf@4.9.1: - resolution: {integrity: sha512-Yqz/Doumf3QTKplwGNrCHe/B2p9xqDghBZSlAY0/hU6ikuDVQuOUIpDP/YcmoT+447tsZTmirmjgG3znvSCR0Q==} + /@rollup/rollup-linux-arm-gnueabihf@4.14.3: + resolution: {integrity: sha512-ge2DC7tHRHa3caVEoSbPRJpq7azhG+xYsd6u2MEnJ6XzPSzQsTKyXvh6iWjXRf7Rt9ykIUWHtl0Uz3T6yXPpKw==} cpu: [arm] os: [linux] requiresBuild: true dev: true optional: true - /@rollup/rollup-linux-arm64-gnu@4.9.1: - resolution: {integrity: sha512-u3XkZVvxcvlAOlQJ3UsD1rFvLWqu4Ef/Ggl40WAVCuogf4S1nJPHh5RTgqYFpCOvuGJ7H5yGHabjFKEZGExk5Q==} + /@rollup/rollup-linux-arm-musleabihf@4.14.3: + resolution: {integrity: sha512-ljcuiDI4V3ySuc7eSk4lQ9wU8J8r8KrOUvB2U+TtK0TiW6OFDmJ+DdIjjwZHIw9CNxzbmXY39wwpzYuFDwNXuw==} + cpu: [arm] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-linux-arm64-gnu@4.14.3: + resolution: {integrity: sha512-Eci2us9VTHm1eSyn5/eEpaC7eP/mp5n46gTRB3Aar3BgSvDQGJZuicyq6TsH4HngNBgVqC5sDYxOzTExSU+NjA==} cpu: [arm64] os: [linux] requiresBuild: true dev: true optional: true - /@rollup/rollup-linux-arm64-musl@4.9.1: - resolution: {integrity: sha512-0XSYN/rfWShW+i+qjZ0phc6vZ7UWI8XWNz4E/l+6edFt+FxoEghrJHjX1EY/kcUGCnZzYYRCl31SNdfOi450Aw==} + /@rollup/rollup-linux-arm64-musl@4.14.3: + resolution: {integrity: sha512-UrBoMLCq4E92/LCqlh+blpqMz5h1tJttPIniwUgOFJyjWI1qrtrDhhpHPuFxULlUmjFHfloWdixtDhSxJt5iKw==} cpu: [arm64] os: [linux] requiresBuild: true dev: true optional: true - /@rollup/rollup-linux-riscv64-gnu@4.9.1: - resolution: {integrity: sha512-LmYIO65oZVfFt9t6cpYkbC4d5lKHLYv5B4CSHRpnANq0VZUQXGcCPXHzbCXCz4RQnx7jvlYB1ISVNCE/omz5cw==} + /@rollup/rollup-linux-powerpc64le-gnu@4.14.3: + resolution: {integrity: sha512-5aRjvsS8q1nWN8AoRfrq5+9IflC3P1leMoy4r2WjXyFqf3qcqsxRCfxtZIV58tCxd+Yv7WELPcO9mY9aeQyAmw==} + cpu: [ppc64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-linux-riscv64-gnu@4.14.3: + resolution: {integrity: sha512-sk/Qh1j2/RJSX7FhEpJn8n0ndxy/uf0kI/9Zc4b1ELhqULVdTfN6HL31CDaTChiBAOgLcsJ1sgVZjWv8XNEsAQ==} cpu: [riscv64] os: [linux] requiresBuild: true dev: true optional: true - /@rollup/rollup-linux-x64-gnu@4.9.1: - resolution: {integrity: sha512-kr8rEPQ6ns/Lmr/hiw8sEVj9aa07gh1/tQF2Y5HrNCCEPiCBGnBUt9tVusrcBBiJfIt1yNaXN6r1CCmpbFEDpg==} + /@rollup/rollup-linux-s390x-gnu@4.14.3: + resolution: {integrity: sha512-jOO/PEaDitOmY9TgkxF/TQIjXySQe5KVYB57H/8LRP/ux0ZoO8cSHCX17asMSv3ruwslXW/TLBcxyaUzGRHcqg==} + cpu: [s390x] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-linux-x64-gnu@4.14.3: + resolution: {integrity: sha512-8ybV4Xjy59xLMyWo3GCfEGqtKV5M5gCSrZlxkPGvEPCGDLNla7v48S662HSGwRd6/2cSneMQWiv+QzcttLrrOA==} cpu: [x64] os: [linux] requiresBuild: true dev: true optional: true - /@rollup/rollup-linux-x64-musl@4.9.1: - resolution: {integrity: sha512-t4QSR7gN+OEZLG0MiCgPqMWZGwmeHhsM4AkegJ0Kiy6TnJ9vZ8dEIwHw1LcZKhbHxTY32hp9eVCMdR3/I8MGRw==} + /@rollup/rollup-linux-x64-musl@4.14.3: + resolution: {integrity: sha512-s+xf1I46trOY10OqAtZ5Rm6lzHre/UiLA1J2uOhCFXWkbZrJRkYBPO6FhvGfHmdtQ3Bx793MNa7LvoWFAm93bg==} cpu: [x64] os: [linux] requiresBuild: true dev: true optional: true - /@rollup/rollup-win32-arm64-msvc@4.9.1: - resolution: {integrity: sha512-7XI4ZCBN34cb+BH557FJPmh0kmNz2c25SCQeT9OiFWEgf8+dL6ZwJ8f9RnUIit+j01u07Yvrsuu1rZGxJCc51g==} + /@rollup/rollup-win32-arm64-msvc@4.14.3: + resolution: {integrity: sha512-+4h2WrGOYsOumDQ5S2sYNyhVfrue+9tc9XcLWLh+Kw3UOxAvrfOrSMFon60KspcDdytkNDh7K2Vs6eMaYImAZg==} cpu: [arm64] os: [win32] requiresBuild: true dev: true optional: true - /@rollup/rollup-win32-ia32-msvc@4.9.1: - resolution: {integrity: sha512-yE5c2j1lSWOH5jp+Q0qNL3Mdhr8WuqCNVjc6BxbVfS5cAS6zRmdiw7ktb8GNpDCEUJphILY6KACoFoRtKoqNQg==} + /@rollup/rollup-win32-ia32-msvc@4.14.3: + resolution: {integrity: sha512-T1l7y/bCeL/kUwh9OD4PQT4aM7Bq43vX05htPJJ46RTI4r5KNt6qJRzAfNfM+OYMNEVBWQzR2Gyk+FXLZfogGw==} cpu: [ia32] os: [win32] requiresBuild: true dev: true optional: true - /@rollup/rollup-win32-x64-msvc@4.9.1: - resolution: {integrity: sha512-PyJsSsafjmIhVgaI1Zdj7m8BB8mMckFah/xbpplObyHfiXzKcI5UOUXRyOdHW7nz4DpMCuzLnF7v5IWHenCwYA==} + /@rollup/rollup-win32-x64-msvc@4.14.3: + resolution: {integrity: sha512-/BypzV0H1y1HzgYpxqRaXGBRqfodgoBBCcsrujT6QRcakDQdfU+Lq9PENPh5jB4I44YWq+0C2eHsHya+nZY1sA==} cpu: [x64] os: [win32] requiresBuild: true @@ -629,18 +653,16 @@ packages: resolution: {integrity: sha512-LG4opVs2ANWZ1TJoKc937iMmNstM/d0ae1vNbnBvBhqCSezgVUOzcLCqbI5elV8Vy6WKwKjaqR+zO9VKirBBCA==} dev: true - /@types/geojson@7946.0.13: - resolution: {integrity: sha512-bmrNrgKMOhM3WsafmbGmC+6dsF2Z308vLFsQ3a/bT8X8Sv5clVYpPars/UPq+sAaJP+5OoLAYgwbkS5QEJdLUQ==} + /@types/estree@1.0.5: + resolution: {integrity: sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==} dev: true - /@types/mapbox-gl@2.7.10: - resolution: {integrity: sha512-nMVEcu9bAcenvx6oPWubQSPevsekByjOfKjlkr+8P91vawtkxTnopDoXXq1Qn/f4cg3zt0Z2W9DVsVsKRNXJTw==} - dependencies: - '@types/geojson': 7946.0.13 + /@types/geojson@7946.0.13: + resolution: {integrity: sha512-bmrNrgKMOhM3WsafmbGmC+6dsF2Z308vLFsQ3a/bT8X8Sv5clVYpPars/UPq+sAaJP+5OoLAYgwbkS5QEJdLUQ==} dev: true - /@types/mapbox-gl@2.7.19: - resolution: {integrity: sha512-pkRdlhQJNbtwcKJSVC4uuOA6M3OlOObIMhNecqHB991oeaDF5XkjSIRaTE0lh5p4KClptSCxW6MBiREVRHrl2A==} + /@types/mapbox-gl@3.1.0: + resolution: {integrity: sha512-hI6cQDjw1bkJw7MC/eHMqq5TWUamLwsujnUUeiIX2KDRjxRNSYMjnHz07+LATz9I9XIsKumOtUz4gRYnZOJ/FA==} dependencies: '@types/geojson': 7946.0.13 dev: true @@ -1128,6 +1150,9 @@ packages: reusify: 1.0.4 dev: true + /fflate@0.8.2: + resolution: {integrity: sha512-cPJU47OaAoCbg0pBvzsgpTPhmhqI5eJjh/JIu8tPj5q+T7iLvW/JAYUqmE7KOB4R1ZyEhzBaIQpQpardBF5z8A==} + /file-entry-cache@6.0.1: resolution: {integrity: sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==} engines: {node: ^10.12.0 || >=12.0.0} @@ -1402,6 +1427,9 @@ packages: p-locate: 5.0.0 dev: true + /lodash.clonedeep@4.5.0: + resolution: {integrity: sha512-H5ZhCF25riFd9uB5UCkVKo61m3S/xZk1x4wA6yp/L3RFP6Z/eHH1ymQcGLo7J3GMPfm0V/7m1tryHuGVxpqEBQ==} + /lodash.merge@4.6.2: resolution: {integrity: sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==} dev: true @@ -1417,12 +1445,12 @@ packages: '@jridgewell/sourcemap-codec': 1.4.15 dev: true - /mapbox-gl@3.0.1: - resolution: {integrity: sha512-o7C6sAlj6Hkdd4xQVEgQflgJYNYyZOAtYahhIOb9m8chI8umtWcCp8Ie0iGLYJvce1WHRMa3WGzs69ggwuWlDA==} + /mapbox-gl@3.3.0: + resolution: {integrity: sha512-cVeAu9PxPTx113AnJAzcSKbBtL5F5EpJ6/NuYgNib9zNduNSoDG2oVX6xK0bAP/VwwVwRh9SEhcyM7nh4GThvQ==} dependencies: '@mapbox/geojson-rewind': 0.5.2 '@mapbox/jsonlint-lines-primitives': 2.0.2 - '@mapbox/mapbox-gl-supported': 2.0.1 + '@mapbox/mapbox-gl-supported': 3.0.0 '@mapbox/point-geometry': 0.1.0 '@mapbox/tiny-sdf': 2.0.6 '@mapbox/unitbezier': 0.0.1 @@ -1431,17 +1459,22 @@ packages: cheap-ruler: 3.0.2 csscolorparser: 1.0.3 earcut: 2.2.4 + fflate: 0.8.2 geojson-vt: 3.2.1 gl-matrix: 3.4.3 grid-index: 1.1.0 kdbush: 4.0.2 + lodash.clonedeep: 4.5.0 murmurhash-js: 1.0.0 pbf: 3.2.1 potpack: 2.0.0 quickselect: 2.0.0 rw: 1.3.3 + serialize-to-js: 3.1.2 supercluster: 8.0.1 + tiny-lru: 11.2.6 tinyqueue: 2.0.3 + tweakpane: 4.0.3 vt-pbf: 3.1.3 /merge-stream@2.0.0: @@ -1717,34 +1750,39 @@ packages: glob: 7.2.3 dev: true - /rollup-plugin-import-css@3.3.5(rollup@4.9.1): - resolution: {integrity: sha512-wSfzveEzvUDlVevo70kmVD5Mk785UN55NG4C7VVnrmdE0qZ8apcVVFajyCPfFYSNxq5YkccOcrGUT2T/2HnEcQ==} + /rollup-plugin-import-css@3.5.0(rollup@4.14.3): + resolution: {integrity: sha512-JOVow6n00qt2C/NnsqPmIjFOfxIAudwWqC5SaC84CodMGiMFaP1gPAdgnJ8g8hcG+P85TCYp2kI98grYCEt5pg==} engines: {node: '>=16'} peerDependencies: rollup: ^2.x.x || ^3.x.x || ^4.x.x dependencies: - '@rollup/pluginutils': 5.0.4(rollup@4.9.1) - rollup: 4.9.1 + '@rollup/pluginutils': 5.0.4(rollup@4.14.3) + rollup: 4.14.3 dev: true - /rollup@4.9.1: - resolution: {integrity: sha512-pgPO9DWzLoW/vIhlSoDByCzcpX92bKEorbgXuZrqxByte3JFk2xSW2JEeAcyLc9Ru9pqcNNW+Ob7ntsk2oT/Xw==} + /rollup@4.14.3: + resolution: {integrity: sha512-ag5tTQKYsj1bhrFC9+OEWqb5O6VYgtQDO9hPDBMmIbePwhfSr+ExlcU741t8Dhw5DkPCQf6noz0jb36D6W9/hw==} engines: {node: '>=18.0.0', npm: '>=8.0.0'} hasBin: true + dependencies: + '@types/estree': 1.0.5 optionalDependencies: - '@rollup/rollup-android-arm-eabi': 4.9.1 - '@rollup/rollup-android-arm64': 4.9.1 - '@rollup/rollup-darwin-arm64': 4.9.1 - '@rollup/rollup-darwin-x64': 4.9.1 - '@rollup/rollup-linux-arm-gnueabihf': 4.9.1 - '@rollup/rollup-linux-arm64-gnu': 4.9.1 - '@rollup/rollup-linux-arm64-musl': 4.9.1 - '@rollup/rollup-linux-riscv64-gnu': 4.9.1 - '@rollup/rollup-linux-x64-gnu': 4.9.1 - '@rollup/rollup-linux-x64-musl': 4.9.1 - '@rollup/rollup-win32-arm64-msvc': 4.9.1 - '@rollup/rollup-win32-ia32-msvc': 4.9.1 - '@rollup/rollup-win32-x64-msvc': 4.9.1 + '@rollup/rollup-android-arm-eabi': 4.14.3 + '@rollup/rollup-android-arm64': 4.14.3 + '@rollup/rollup-darwin-arm64': 4.14.3 + '@rollup/rollup-darwin-x64': 4.14.3 + '@rollup/rollup-linux-arm-gnueabihf': 4.14.3 + '@rollup/rollup-linux-arm-musleabihf': 4.14.3 + '@rollup/rollup-linux-arm64-gnu': 4.14.3 + '@rollup/rollup-linux-arm64-musl': 4.14.3 + '@rollup/rollup-linux-powerpc64le-gnu': 4.14.3 + '@rollup/rollup-linux-riscv64-gnu': 4.14.3 + '@rollup/rollup-linux-s390x-gnu': 4.14.3 + '@rollup/rollup-linux-x64-gnu': 4.14.3 + '@rollup/rollup-linux-x64-musl': 4.14.3 + '@rollup/rollup-win32-arm64-msvc': 4.14.3 + '@rollup/rollup-win32-ia32-msvc': 4.14.3 + '@rollup/rollup-win32-x64-msvc': 4.14.3 fsevents: 2.3.3 dev: true @@ -1771,6 +1809,10 @@ packages: resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==} dev: true + /serialize-to-js@3.1.2: + resolution: {integrity: sha512-owllqNuDDEimQat7EPG0tH7JjO090xKNzUtYz6X+Sk2BXDnOCilDdNLwjWeFywG9xkJul1ULvtUQa9O4pUaY0w==} + engines: {node: '>=4.0.0'} + /serve-handler@6.1.5: resolution: {integrity: sha512-ijPFle6Hwe8zfmBxJdE+5fta53fdIY0lHISJvuikXB3VYFafRjMRpOffSPvCYsbKyBA7pvy9oYr/BT1O3EArlg==} dependencies: @@ -1903,6 +1945,10 @@ packages: resolution: {integrity: sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==} dev: true + /tiny-lru@11.2.6: + resolution: {integrity: sha512-0PU3c9PjMnltZaFo2sGYv/nnJsMjG0Cxx8X6FXHPPGjFyoo1SJDxvUXW1207rdiSxYizf31roo+GrkIByQeZoA==} + engines: {node: '>=12'} + /tinyqueue@2.0.3: resolution: {integrity: sha512-ppJZNDuKGgxzkHihX8v9v9G5f+18gzaTfrukGrq6ueg0lmH4nqVnA2IPG0AEH3jKEk2GRJCUhDoqpoiw3PHLBA==} @@ -1914,6 +1960,9 @@ packages: /tslib@2.6.2: resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==} + /tweakpane@4.0.3: + resolution: {integrity: sha512-BlcWOAe8oe4c+k9pmLBARGdWB6MVZMszayekkixQXTgkxTaYoTUpHpwVEp+3HkoamZkomodpbBf0CkguIHTgLg==} + /type-check@0.4.0: resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==} engines: {node: '>= 0.8.0'} diff --git a/preview/package.json b/preview/package.json index fb6ceee..02f5632 100644 --- a/preview/package.json +++ b/preview/package.json @@ -1,30 +1,30 @@ { - "name": "preview", - "private": "true", - "type": "module", - "scripts": { - "start": "concurrently \"npm:serve\" \"npm:watch\"", - "serve": "serve .", - "build": "rollup -c", - "watch": "rollup -c -w" - }, - "dependencies": { - "@mapbox-controls/compass": "workspace:*", - "@mapbox-controls/image": "workspace:*", - "@mapbox-controls/inspect": "workspace:*", - "@mapbox-controls/language": "workspace:*", - "@mapbox-controls/ruler": "workspace:*", - "@mapbox-controls/styles": "workspace:*", - "@mapbox-controls/tooltip": "workspace:*", - "@mapbox-controls/zoom": "workspace:*", - "mapbox-gl": "3.0.1" - }, - "devDependencies": { - "@rollup/plugin-commonjs": "25.0.7", - "@rollup/plugin-node-resolve": "15.2.3", - "concurrently": "8.2.2", - "rollup": "4.9.1", - "rollup-plugin-import-css": "3.3.5", - "serve": "14.2.1" - } -} \ No newline at end of file + "name": "preview", + "private": "true", + "type": "module", + "scripts": { + "start": "concurrently \"npm:serve\" \"npm:watch\"", + "serve": "serve .", + "build": "rollup -c", + "watch": "rollup -c -w" + }, + "dependencies": { + "@mapbox-controls/compass": "workspace:*", + "@mapbox-controls/image": "workspace:*", + "@mapbox-controls/inspect": "workspace:*", + "@mapbox-controls/language": "workspace:*", + "@mapbox-controls/ruler": "workspace:*", + "@mapbox-controls/styles": "workspace:*", + "@mapbox-controls/tooltip": "workspace:*", + "@mapbox-controls/zoom": "workspace:*", + "mapbox-gl": "3.3.0" + }, + "devDependencies": { + "@rollup/plugin-commonjs": "25.0.7", + "@rollup/plugin-node-resolve": "15.2.3", + "concurrently": "8.2.2", + "rollup": "4.14.3", + "rollup-plugin-import-css": "3.5.0", + "serve": "14.2.1" + } +} diff --git a/preview/preview.bundle.css b/preview/preview.bundle.css index 1295012..4e0c893 100644 --- a/preview/preview.bundle.css +++ b/preview/preview.bundle.css @@ -1,4 +1,4 @@ -.mapboxgl-map{-webkit-tap-highlight-color:rgb(0 0 0/0);font:12px/20px Helvetica Neue,Arial,Helvetica,sans-serif;overflow:hidden;position:relative}.mapboxgl-canvas{left:0;position:absolute;top:0}.mapboxgl-map:-webkit-full-screen{height:100%;width:100%}.mapboxgl-canary{background-color:salmon}.mapboxgl-canvas-container.mapboxgl-interactive,.mapboxgl-ctrl-group button.mapboxgl-ctrl-compass{cursor:grab;-webkit-user-select:none;user-select:none}.mapboxgl-canvas-container.mapboxgl-interactive.mapboxgl-track-pointer{cursor:pointer}.mapboxgl-canvas-container.mapboxgl-interactive:active,.mapboxgl-ctrl-group button.mapboxgl-ctrl-compass:active{cursor:grabbing}.mapboxgl-canvas-container.mapboxgl-touch-zoom-rotate,.mapboxgl-canvas-container.mapboxgl-touch-zoom-rotate .mapboxgl-canvas{touch-action:pan-x pan-y}.mapboxgl-canvas-container.mapboxgl-touch-drag-pan,.mapboxgl-canvas-container.mapboxgl-touch-drag-pan .mapboxgl-canvas{touch-action:pinch-zoom}.mapboxgl-canvas-container.mapboxgl-touch-zoom-rotate.mapboxgl-touch-drag-pan,.mapboxgl-canvas-container.mapboxgl-touch-zoom-rotate.mapboxgl-touch-drag-pan .mapboxgl-canvas{touch-action:none}.mapboxgl-ctrl-bottom-left,.mapboxgl-ctrl-bottom-right,.mapboxgl-ctrl-top-left,.mapboxgl-ctrl-top-right{pointer-events:none;position:absolute;z-index:2}.mapboxgl-ctrl-top-left{left:0;top:0}.mapboxgl-ctrl-top-right{right:0;top:0}.mapboxgl-ctrl-bottom-left{bottom:0;left:0}.mapboxgl-ctrl-bottom-right{bottom:0;right:0}.mapboxgl-ctrl{clear:both;pointer-events:auto;transform:translate(0)}.mapboxgl-ctrl-top-left .mapboxgl-ctrl{float:left;margin:10px 0 0 10px}.mapboxgl-ctrl-top-right .mapboxgl-ctrl{float:right;margin:10px 10px 0 0}.mapboxgl-ctrl-bottom-left .mapboxgl-ctrl{float:left;margin:0 0 10px 10px}.mapboxgl-ctrl-bottom-right .mapboxgl-ctrl{float:right;margin:0 10px 10px 0}.mapboxgl-ctrl-group{background:#fff;border-radius:4px}.mapboxgl-ctrl-group:not(:empty){box-shadow:0 0 0 2px rgba(0,0,0,.1)}@media (-ms-high-contrast:active){.mapboxgl-ctrl-group:not(:empty){box-shadow:0 0 0 2px ButtonText}}.mapboxgl-ctrl-group button{background-color:transparent;border:0;box-sizing:border-box;cursor:pointer;display:block;height:29px;outline:none;overflow:hidden;padding:0;width:29px}.mapboxgl-ctrl-group button+button{border-top:1px solid #ddd}.mapboxgl-ctrl button .mapboxgl-ctrl-icon{background-position:50%;background-repeat:no-repeat;display:block;height:100%;width:100%}@media (-ms-high-contrast:active){.mapboxgl-ctrl-icon{background-color:transparent}.mapboxgl-ctrl-group button+button{border-top:1px solid ButtonText}}.mapboxgl-ctrl-attrib-button:focus,.mapboxgl-ctrl-group button:focus{box-shadow:0 0 2px 2px #0096ff}.mapboxgl-ctrl button:disabled{cursor:not-allowed}.mapboxgl-ctrl button:disabled .mapboxgl-ctrl-icon{opacity:.25}.mapboxgl-ctrl-group button:first-child{border-radius:4px 4px 0 0}.mapboxgl-ctrl-group button:last-child{border-radius:0 0 4px 4px}.mapboxgl-ctrl-group button:only-child{border-radius:inherit}.mapboxgl-ctrl button:not(:disabled):hover{background-color:rgb(0 0 0/5%)}.mapboxgl-ctrl-group button:focus:focus-visible{box-shadow:0 0 2px 2px #0096ff}.mapboxgl-ctrl-group button:focus:not(:focus-visible){box-shadow:none}.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-out .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' 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 13h-9z'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-in .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' 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.5z'/%3E%3C/svg%3E")}@media (-ms-high-contrast:active){.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-out .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' 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 13h-9z'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-in .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' 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.5z'/%3E%3C/svg%3E")}}@media (-ms-high-contrast:black-on-white){.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-out .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23000' 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 13h-9z'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-in .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23000' 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.5z'/%3E%3C/svg%3E")}}.mapboxgl-ctrl button.mapboxgl-ctrl-fullscreen .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' 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-3h1zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16h1zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5H13zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1V7.5z'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-shrink .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' 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-1h-5.5zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1v-5.5zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1v5.5zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1h5.5z'/%3E%3C/svg%3E")}@media (-ms-high-contrast:active){.mapboxgl-ctrl button.mapboxgl-ctrl-fullscreen .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' 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-3h1zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16h1zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5H13zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1V7.5z'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-shrink .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' 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-1h-5.5zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1v-5.5zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1v5.5zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1h5.5z'/%3E%3C/svg%3E")}}@media (-ms-high-contrast:black-on-white){.mapboxgl-ctrl button.mapboxgl-ctrl-fullscreen .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23000' 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-3h1zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16h1zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5H13zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1V7.5z'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-shrink .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23000' 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-1h-5.5zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1v-5.5zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1v5.5zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1h5.5z'/%3E%3C/svg%3E")}}.mapboxgl-ctrl button.mapboxgl-ctrl-compass .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M10.5 14l4-8 4 8h-8z'/%3E%3Cpath id='south' d='M10.5 16l4 8 4-8h-8z' fill='%23ccc'/%3E%3C/svg%3E")}@media (-ms-high-contrast:active){.mapboxgl-ctrl button.mapboxgl-ctrl-compass .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M10.5 14l4-8 4 8h-8z'/%3E%3Cpath id='south' d='M10.5 16l4 8 4-8h-8z' fill='%23999'/%3E%3C/svg%3E")}}@media (-ms-high-contrast:black-on-white){.mapboxgl-ctrl button.mapboxgl-ctrl-compass .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23000' viewBox='0 0 29 29'%3E%3Cpath d='M10.5 14l4-8 4 8h-8z'/%3E%3Cpath id='south' d='M10.5 16l4 8 4-8h-8z' fill='%23ccc'/%3E%3C/svg%3E")}}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23333'%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-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate:disabled .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23aaa'%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-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' fill='%23f00'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-active .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%2333b5e5'%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-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-active-error .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23e58978'%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-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-background .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%2333b5e5'%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-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2' display='none'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-background-error .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23e54e33'%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-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2' display='none'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-waiting .mapboxgl-ctrl-icon{animation:mapboxgl-spin 2s linear infinite}@media (-ms-high-contrast:active){.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23fff'%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-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate:disabled .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23999'%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-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' fill='%23f00'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-active .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%2333b5e5'%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-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-active-error .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23e58978'%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-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-background .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%2333b5e5'%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-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2' display='none'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-background-error .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23e54e33'%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-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2' display='none'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E")}}@media (-ms-high-contrast:black-on-white){.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23000'%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-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate:disabled .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23666'%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-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' fill='%23f00'/%3E%3C/svg%3E")}}@keyframes mapboxgl-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}a.mapboxgl-ctrl-logo{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' fill-rule='evenodd' viewBox='0 0 88 23'%3E%3Cdefs%3E%3Cpath id='logo' d='M11.5 2.25c5.105 0 9.25 4.145 9.25 9.25s-4.145 9.25-9.25 9.25-9.25-4.145-9.25-9.25 4.145-9.25 9.25-9.25zM6.997 15.983c-.051-.338-.828-5.802 2.233-8.873a4.395 4.395 0 013.13-1.28c1.27 0 2.49.51 3.39 1.42.91.9 1.42 2.12 1.42 3.39 0 1.18-.449 2.301-1.28 3.13C12.72 16.93 7 16 7 16l-.003-.017zM15.3 10.5l-2 .8-.8 2-.8-2-2-.8 2-.8.8-2 .8 2 2 .8z'/%3E%3Cpath id='text' d='M50.63 8c.13 0 .23.1.23.23V9c.7-.76 1.7-1.18 2.73-1.18 2.17 0 3.95 1.85 3.95 4.17s-1.77 4.19-3.94 4.19c-1.04 0-2.03-.43-2.74-1.18v3.77c0 .13-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V8.23c0-.12.1-.23.23-.23h1.4zm-3.86.01c.01 0 .01 0 .01-.01.13 0 .22.1.22.22v7.55c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V15c-.7.76-1.69 1.19-2.73 1.19-2.17 0-3.94-1.87-3.94-4.19 0-2.32 1.77-4.19 3.94-4.19 1.03 0 2.02.43 2.73 1.18v-.75c0-.12.1-.23.23-.23h1.4zm26.375-.19a4.24 4.24 0 00-4.16 3.29c-.13.59-.13 1.19 0 1.77a4.233 4.233 0 004.17 3.3c2.35 0 4.26-1.87 4.26-4.19 0-2.32-1.9-4.17-4.27-4.17zM60.63 5c.13 0 .23.1.23.23v3.76c.7-.76 1.7-1.18 2.73-1.18 1.88 0 3.45 1.4 3.84 3.28.13.59.13 1.2 0 1.8-.39 1.88-1.96 3.29-3.84 3.29-1.03 0-2.02-.43-2.73-1.18v.77c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V5.23c0-.12.1-.23.23-.23h1.4zm-34 11h-1.4c-.13 0-.23-.11-.23-.23V8.22c.01-.13.1-.22.23-.22h1.4c.13 0 .22.11.23.22v.68c.5-.68 1.3-1.09 2.16-1.1h.03c1.09 0 2.09.6 2.6 1.55.45-.95 1.4-1.55 2.44-1.56 1.62 0 2.93 1.25 2.9 2.78l.03 5.2c0 .13-.1.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.8 0-1.46.7-1.59 1.62l.01 4.68c0 .13-.11.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.85 0-1.54.79-1.6 1.8v4.5c0 .13-.1.23-.23.23zm53.615 0h-1.61c-.04 0-.08-.01-.12-.03-.09-.06-.13-.19-.06-.28l2.43-3.71-2.39-3.65a.213.213 0 01-.03-.12c0-.12.09-.21.21-.21h1.61c.13 0 .24.06.3.17l1.41 2.37 1.4-2.37a.34.34 0 01.3-.17h1.6c.04 0 .08.01.12.03.09.06.13.19.06.28l-2.37 3.65 2.43 3.7c0 .05.01.09.01.13 0 .12-.09.21-.21.21h-1.61c-.13 0-.24-.06-.3-.17l-1.44-2.42-1.44 2.42a.34.34 0 01-.3.17zm-7.12-1.49c-1.33 0-2.42-1.12-2.42-2.51 0-1.39 1.08-2.52 2.42-2.52 1.33 0 2.42 1.12 2.42 2.51 0 1.39-1.08 2.51-2.42 2.52zm-19.865 0c-1.32 0-2.39-1.11-2.42-2.48v-.07c.02-1.38 1.09-2.49 2.4-2.49 1.32 0 2.41 1.12 2.41 2.51 0 1.39-1.07 2.52-2.39 2.53zm-8.11-2.48c-.01 1.37-1.09 2.47-2.41 2.47s-2.42-1.12-2.42-2.51c0-1.39 1.08-2.52 2.4-2.52 1.33 0 2.39 1.11 2.41 2.48l.02.08zm18.12 2.47c-1.32 0-2.39-1.11-2.41-2.48v-.06c.02-1.38 1.09-2.48 2.41-2.48s2.42 1.12 2.42 2.51c0 1.39-1.09 2.51-2.42 2.51z'/%3E%3C/defs%3E%3Cmask id='clip'%3E%3Crect x='0' y='0' width='100%25' height='100%25' fill='white'/%3E%3Cuse xlink:href='%23logo'/%3E%3Cuse xlink:href='%23text'/%3E%3C/mask%3E%3Cg id='outline' opacity='0.3' stroke='%23000' stroke-width='3'%3E%3Ccircle mask='url(%23clip)' cx='11.5' cy='11.5' r='9.25'/%3E%3Cuse xlink:href='%23text' mask='url(%23clip)'/%3E%3C/g%3E%3Cg id='fill' opacity='0.9' fill='%23fff'%3E%3Cuse xlink:href='%23logo'/%3E%3Cuse xlink:href='%23text'/%3E%3C/g%3E%3C/svg%3E");background-repeat:no-repeat;cursor:pointer;display:block;height:23px;margin:0 0 -4px -4px;overflow:hidden;width:88px}a.mapboxgl-ctrl-logo.mapboxgl-compact{width:23px}@media (-ms-high-contrast:active){a.mapboxgl-ctrl-logo{background-color:transparent;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' fill-rule='evenodd' viewBox='0 0 88 23'%3E%3Cdefs%3E%3Cpath id='logo' d='M11.5 2.25c5.105 0 9.25 4.145 9.25 9.25s-4.145 9.25-9.25 9.25-9.25-4.145-9.25-9.25 4.145-9.25 9.25-9.25zM6.997 15.983c-.051-.338-.828-5.802 2.233-8.873a4.395 4.395 0 013.13-1.28c1.27 0 2.49.51 3.39 1.42.91.9 1.42 2.12 1.42 3.39 0 1.18-.449 2.301-1.28 3.13C12.72 16.93 7 16 7 16l-.003-.017zM15.3 10.5l-2 .8-.8 2-.8-2-2-.8 2-.8.8-2 .8 2 2 .8z'/%3E%3Cpath id='text' d='M50.63 8c.13 0 .23.1.23.23V9c.7-.76 1.7-1.18 2.73-1.18 2.17 0 3.95 1.85 3.95 4.17s-1.77 4.19-3.94 4.19c-1.04 0-2.03-.43-2.74-1.18v3.77c0 .13-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V8.23c0-.12.1-.23.23-.23h1.4zm-3.86.01c.01 0 .01 0 .01-.01.13 0 .22.1.22.22v7.55c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V15c-.7.76-1.69 1.19-2.73 1.19-2.17 0-3.94-1.87-3.94-4.19 0-2.32 1.77-4.19 3.94-4.19 1.03 0 2.02.43 2.73 1.18v-.75c0-.12.1-.23.23-.23h1.4zm26.375-.19a4.24 4.24 0 00-4.16 3.29c-.13.59-.13 1.19 0 1.77a4.233 4.233 0 004.17 3.3c2.35 0 4.26-1.87 4.26-4.19 0-2.32-1.9-4.17-4.27-4.17zM60.63 5c.13 0 .23.1.23.23v3.76c.7-.76 1.7-1.18 2.73-1.18 1.88 0 3.45 1.4 3.84 3.28.13.59.13 1.2 0 1.8-.39 1.88-1.96 3.29-3.84 3.29-1.03 0-2.02-.43-2.73-1.18v.77c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V5.23c0-.12.1-.23.23-.23h1.4zm-34 11h-1.4c-.13 0-.23-.11-.23-.23V8.22c.01-.13.1-.22.23-.22h1.4c.13 0 .22.11.23.22v.68c.5-.68 1.3-1.09 2.16-1.1h.03c1.09 0 2.09.6 2.6 1.55.45-.95 1.4-1.55 2.44-1.56 1.62 0 2.93 1.25 2.9 2.78l.03 5.2c0 .13-.1.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.8 0-1.46.7-1.59 1.62l.01 4.68c0 .13-.11.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.85 0-1.54.79-1.6 1.8v4.5c0 .13-.1.23-.23.23zm53.615 0h-1.61c-.04 0-.08-.01-.12-.03-.09-.06-.13-.19-.06-.28l2.43-3.71-2.39-3.65a.213.213 0 01-.03-.12c0-.12.09-.21.21-.21h1.61c.13 0 .24.06.3.17l1.41 2.37 1.4-2.37a.34.34 0 01.3-.17h1.6c.04 0 .08.01.12.03.09.06.13.19.06.28l-2.37 3.65 2.43 3.7c0 .05.01.09.01.13 0 .12-.09.21-.21.21h-1.61c-.13 0-.24-.06-.3-.17l-1.44-2.42-1.44 2.42a.34.34 0 01-.3.17zm-7.12-1.49c-1.33 0-2.42-1.12-2.42-2.51 0-1.39 1.08-2.52 2.42-2.52 1.33 0 2.42 1.12 2.42 2.51 0 1.39-1.08 2.51-2.42 2.52zm-19.865 0c-1.32 0-2.39-1.11-2.42-2.48v-.07c.02-1.38 1.09-2.49 2.4-2.49 1.32 0 2.41 1.12 2.41 2.51 0 1.39-1.07 2.52-2.39 2.53zm-8.11-2.48c-.01 1.37-1.09 2.47-2.41 2.47s-2.42-1.12-2.42-2.51c0-1.39 1.08-2.52 2.4-2.52 1.33 0 2.39 1.11 2.41 2.48l.02.08zm18.12 2.47c-1.32 0-2.39-1.11-2.41-2.48v-.06c.02-1.38 1.09-2.48 2.41-2.48s2.42 1.12 2.42 2.51c0 1.39-1.09 2.51-2.42 2.51z'/%3E%3C/defs%3E%3Cmask id='clip'%3E%3Crect x='0' y='0' width='100%25' height='100%25' fill='white'/%3E%3Cuse xlink:href='%23logo'/%3E%3Cuse xlink:href='%23text'/%3E%3C/mask%3E%3Cg id='outline' opacity='1' stroke='%23000' stroke-width='3'%3E%3Ccircle mask='url(%23clip)' cx='11.5' cy='11.5' r='9.25'/%3E%3Cuse xlink:href='%23text' mask='url(%23clip)'/%3E%3C/g%3E%3Cg id='fill' opacity='1' fill='%23fff'%3E%3Cuse xlink:href='%23logo'/%3E%3Cuse xlink:href='%23text'/%3E%3C/g%3E%3C/svg%3E")}}@media (-ms-high-contrast:black-on-white){a.mapboxgl-ctrl-logo{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' fill-rule='evenodd' viewBox='0 0 88 23'%3E%3Cdefs%3E%3Cpath id='logo' d='M11.5 2.25c5.105 0 9.25 4.145 9.25 9.25s-4.145 9.25-9.25 9.25-9.25-4.145-9.25-9.25 4.145-9.25 9.25-9.25zM6.997 15.983c-.051-.338-.828-5.802 2.233-8.873a4.395 4.395 0 013.13-1.28c1.27 0 2.49.51 3.39 1.42.91.9 1.42 2.12 1.42 3.39 0 1.18-.449 2.301-1.28 3.13C12.72 16.93 7 16 7 16l-.003-.017zM15.3 10.5l-2 .8-.8 2-.8-2-2-.8 2-.8.8-2 .8 2 2 .8z'/%3E%3Cpath id='text' d='M50.63 8c.13 0 .23.1.23.23V9c.7-.76 1.7-1.18 2.73-1.18 2.17 0 3.95 1.85 3.95 4.17s-1.77 4.19-3.94 4.19c-1.04 0-2.03-.43-2.74-1.18v3.77c0 .13-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V8.23c0-.12.1-.23.23-.23h1.4zm-3.86.01c.01 0 .01 0 .01-.01.13 0 .22.1.22.22v7.55c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V15c-.7.76-1.69 1.19-2.73 1.19-2.17 0-3.94-1.87-3.94-4.19 0-2.32 1.77-4.19 3.94-4.19 1.03 0 2.02.43 2.73 1.18v-.75c0-.12.1-.23.23-.23h1.4zm26.375-.19a4.24 4.24 0 00-4.16 3.29c-.13.59-.13 1.19 0 1.77a4.233 4.233 0 004.17 3.3c2.35 0 4.26-1.87 4.26-4.19 0-2.32-1.9-4.17-4.27-4.17zM60.63 5c.13 0 .23.1.23.23v3.76c.7-.76 1.7-1.18 2.73-1.18 1.88 0 3.45 1.4 3.84 3.28.13.59.13 1.2 0 1.8-.39 1.88-1.96 3.29-3.84 3.29-1.03 0-2.02-.43-2.73-1.18v.77c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V5.23c0-.12.1-.23.23-.23h1.4zm-34 11h-1.4c-.13 0-.23-.11-.23-.23V8.22c.01-.13.1-.22.23-.22h1.4c.13 0 .22.11.23.22v.68c.5-.68 1.3-1.09 2.16-1.1h.03c1.09 0 2.09.6 2.6 1.55.45-.95 1.4-1.55 2.44-1.56 1.62 0 2.93 1.25 2.9 2.78l.03 5.2c0 .13-.1.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.8 0-1.46.7-1.59 1.62l.01 4.68c0 .13-.11.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.85 0-1.54.79-1.6 1.8v4.5c0 .13-.1.23-.23.23zm53.615 0h-1.61c-.04 0-.08-.01-.12-.03-.09-.06-.13-.19-.06-.28l2.43-3.71-2.39-3.65a.213.213 0 01-.03-.12c0-.12.09-.21.21-.21h1.61c.13 0 .24.06.3.17l1.41 2.37 1.4-2.37a.34.34 0 01.3-.17h1.6c.04 0 .08.01.12.03.09.06.13.19.06.28l-2.37 3.65 2.43 3.7c0 .05.01.09.01.13 0 .12-.09.21-.21.21h-1.61c-.13 0-.24-.06-.3-.17l-1.44-2.42-1.44 2.42a.34.34 0 01-.3.17zm-7.12-1.49c-1.33 0-2.42-1.12-2.42-2.51 0-1.39 1.08-2.52 2.42-2.52 1.33 0 2.42 1.12 2.42 2.51 0 1.39-1.08 2.51-2.42 2.52zm-19.865 0c-1.32 0-2.39-1.11-2.42-2.48v-.07c.02-1.38 1.09-2.49 2.4-2.49 1.32 0 2.41 1.12 2.41 2.51 0 1.39-1.07 2.52-2.39 2.53zm-8.11-2.48c-.01 1.37-1.09 2.47-2.41 2.47s-2.42-1.12-2.42-2.51c0-1.39 1.08-2.52 2.4-2.52 1.33 0 2.39 1.11 2.41 2.48l.02.08zm18.12 2.47c-1.32 0-2.39-1.11-2.41-2.48v-.06c.02-1.38 1.09-2.48 2.41-2.48s2.42 1.12 2.42 2.51c0 1.39-1.09 2.51-2.42 2.51z'/%3E%3C/defs%3E%3Cmask id='clip'%3E%3Crect x='0' y='0' width='100%25' height='100%25' fill='white'/%3E%3Cuse xlink:href='%23logo'/%3E%3Cuse xlink:href='%23text'/%3E%3C/mask%3E%3Cg id='outline' opacity='1' stroke='%23fff' stroke-width='3' fill='%23fff'%3E%3Ccircle mask='url(%23clip)' cx='11.5' cy='11.5' r='9.25'/%3E%3Cuse xlink:href='%23text' mask='url(%23clip)'/%3E%3C/g%3E%3Cg id='fill' opacity='1' fill='%23000'%3E%3Cuse xlink:href='%23logo'/%3E%3Cuse xlink:href='%23text'/%3E%3C/g%3E%3C/svg%3E")}}.mapboxgl-ctrl.mapboxgl-ctrl-attrib{background-color:hsla(0,0%,100%,.5);margin:0;padding:0 5px}@media screen{.mapboxgl-ctrl-attrib.mapboxgl-compact{background-color:#fff;border-radius:12px;margin:10px;min-height:20px;padding:2px 24px 2px 0;position:relative}.mapboxgl-ctrl-attrib.mapboxgl-compact-show{padding:2px 28px 2px 8px;visibility:visible}.mapboxgl-ctrl-bottom-left>.mapboxgl-ctrl-attrib.mapboxgl-compact-show,.mapboxgl-ctrl-top-left>.mapboxgl-ctrl-attrib.mapboxgl-compact-show{border-radius:12px;padding:2px 8px 2px 28px}.mapboxgl-ctrl-attrib.mapboxgl-compact .mapboxgl-ctrl-attrib-inner{display:none}.mapboxgl-ctrl-attrib-button{background-color:hsla(0,0%,100%,.5);background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill-rule='evenodd'%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;box-sizing:border-box;cursor:pointer;display:none;height:24px;outline:none;position:absolute;right:0;top:0;width:24px}.mapboxgl-ctrl-bottom-left .mapboxgl-ctrl-attrib-button,.mapboxgl-ctrl-top-left .mapboxgl-ctrl-attrib-button{left:0}.mapboxgl-ctrl-attrib.mapboxgl-compact .mapboxgl-ctrl-attrib-button,.mapboxgl-ctrl-attrib.mapboxgl-compact-show .mapboxgl-ctrl-attrib-inner{display:block}.mapboxgl-ctrl-attrib.mapboxgl-compact-show .mapboxgl-ctrl-attrib-button{background-color:rgb(0 0 0/5%)}.mapboxgl-ctrl-bottom-right>.mapboxgl-ctrl-attrib.mapboxgl-compact:after{bottom:0;right:0}.mapboxgl-ctrl-top-right>.mapboxgl-ctrl-attrib.mapboxgl-compact:after{right:0;top:0}.mapboxgl-ctrl-top-left>.mapboxgl-ctrl-attrib.mapboxgl-compact:after{left:0;top:0}.mapboxgl-ctrl-bottom-left>.mapboxgl-ctrl-attrib.mapboxgl-compact:after{bottom:0;left:0}}@media screen and (-ms-high-contrast:active){.mapboxgl-ctrl-attrib.mapboxgl-compact:after{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill-rule='evenodd' fill='%23fff'%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 (-ms-high-contrast:black-on-white){.mapboxgl-ctrl-attrib.mapboxgl-compact:after{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill-rule='evenodd'%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")}}.mapboxgl-ctrl-attrib a{color:rgba(0,0,0,.75);text-decoration:none}.mapboxgl-ctrl-attrib a:hover{color:inherit;text-decoration:underline}.mapboxgl-ctrl-attrib .mapbox-improve-map{font-weight:700;margin-left:2px}.mapboxgl-attrib-empty{display:none}.mapboxgl-ctrl-scale{background-color:hsla(0,0%,100%,.75);border:2px solid #333;border-top:#333;box-sizing:border-box;color:#333;font-size:10px;padding:0 5px;white-space:nowrap}.mapboxgl-popup{display:flex;left:0;pointer-events:none;position:absolute;top:0;will-change:transform}.mapboxgl-popup-anchor-top,.mapboxgl-popup-anchor-top-left,.mapboxgl-popup-anchor-top-right{flex-direction:column}.mapboxgl-popup-anchor-bottom,.mapboxgl-popup-anchor-bottom-left,.mapboxgl-popup-anchor-bottom-right{flex-direction:column-reverse}.mapboxgl-popup-anchor-left{flex-direction:row}.mapboxgl-popup-anchor-right{flex-direction:row-reverse}.mapboxgl-popup-tip{border:10px solid transparent;height:0;width:0;z-index:1}.mapboxgl-popup-anchor-top .mapboxgl-popup-tip{align-self:center;border-bottom-color:#fff;border-top:none}.mapboxgl-popup-anchor-top-left .mapboxgl-popup-tip{align-self:flex-start;border-bottom-color:#fff;border-left:none;border-top:none}.mapboxgl-popup-anchor-top-right .mapboxgl-popup-tip{align-self:flex-end;border-bottom-color:#fff;border-right:none;border-top:none}.mapboxgl-popup-anchor-bottom .mapboxgl-popup-tip{align-self:center;border-bottom:none;border-top-color:#fff}.mapboxgl-popup-anchor-bottom-left .mapboxgl-popup-tip{align-self:flex-start;border-bottom:none;border-left:none;border-top-color:#fff}.mapboxgl-popup-anchor-bottom-right .mapboxgl-popup-tip{align-self:flex-end;border-bottom:none;border-right:none;border-top-color:#fff}.mapboxgl-popup-anchor-left .mapboxgl-popup-tip{align-self:center;border-left:none;border-right-color:#fff}.mapboxgl-popup-anchor-right .mapboxgl-popup-tip{align-self:center;border-left-color:#fff;border-right:none}.mapboxgl-popup-close-button{background-color:transparent;border:0;border-radius:0 3px 0 0;cursor:pointer;position:absolute;right:0;top:0}.mapboxgl-popup-close-button:hover{background-color:rgb(0 0 0/5%)}.mapboxgl-popup-content{background:#fff;border-radius:3px;box-shadow:0 1px 2px rgba(0,0,0,.1);padding:10px 10px 15px;pointer-events:auto;position:relative}.mapboxgl-popup-anchor-top-left .mapboxgl-popup-content{border-top-left-radius:0}.mapboxgl-popup-anchor-top-right .mapboxgl-popup-content{border-top-right-radius:0}.mapboxgl-popup-anchor-bottom-left .mapboxgl-popup-content{border-bottom-left-radius:0}.mapboxgl-popup-anchor-bottom-right .mapboxgl-popup-content{border-bottom-right-radius:0}.mapboxgl-popup-track-pointer{display:none}.mapboxgl-popup-track-pointer *{pointer-events:none;user-select:none}.mapboxgl-map:hover .mapboxgl-popup-track-pointer{display:flex}.mapboxgl-map:active .mapboxgl-popup-track-pointer{display:none}.mapboxgl-marker{left:0;opacity:1;position:absolute;top:0;transition:opacity .2s;will-change:transform}.mapboxgl-user-location-dot,.mapboxgl-user-location-dot:before{background-color:#1da1f2;border-radius:50%;height:15px;width:15px}.mapboxgl-user-location-dot:before{animation:mapboxgl-user-location-dot-pulse 2s infinite;content:"";position:absolute}.mapboxgl-user-location-dot:after{border:2px solid #fff;border-radius:50%;box-shadow:0 0 3px rgba(0,0,0,.35);box-sizing:border-box;content:"";height:19px;left:-2px;position:absolute;top:-2px;width:19px}.mapboxgl-user-location-show-heading .mapboxgl-user-location-heading{height:0;width:0}.mapboxgl-user-location-show-heading .mapboxgl-user-location-heading:after,.mapboxgl-user-location-show-heading .mapboxgl-user-location-heading:before{border-bottom:7.5px solid #4aa1eb;content:"";position:absolute}.mapboxgl-user-location-show-heading .mapboxgl-user-location-heading:before{border-left:7.5px solid transparent;transform:translateY(-28px) skewY(-20deg)}.mapboxgl-user-location-show-heading .mapboxgl-user-location-heading:after{border-right:7.5px solid transparent;transform:translate(7.5px,-28px) skewY(20deg)}@keyframes mapboxgl-user-location-dot-pulse{0%{opacity:1;transform:scale(1)}70%{opacity:0;transform:scale(3)}to{opacity:0;transform:scale(1)}}.mapboxgl-user-location-dot-stale{background-color:#aaa}.mapboxgl-user-location-dot-stale:after{display:none}.mapboxgl-user-location-accuracy-circle{background-color:#1da1f233;border-radius:100%;height:1px;width:1px}.mapboxgl-crosshair,.mapboxgl-crosshair .mapboxgl-interactive,.mapboxgl-crosshair .mapboxgl-interactive:active{cursor:crosshair}.mapboxgl-boxzoom{background:#fff;border:2px dotted #202020;height:0;left:0;opacity:.5;position:absolute;top:0;width:0}@media print{.mapbox-improve-map{display:none}}.mapboxgl-scroll-zoom-blocker,.mapboxgl-touch-pan-blocker{align-items:center;background:rgba(0,0,0,.7);color:#fff;display:flex;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif;height:100%;justify-content:center;left:0;opacity:0;pointer-events:none;position:absolute;text-align:center;top:0;transition:opacity .75s ease-in-out;transition-delay:1s;width:100%}.mapboxgl-scroll-zoom-blocker-show,.mapboxgl-touch-pan-blocker-show{opacity:1;transition:opacity .1s ease-in-out}.mapboxgl-canvas-container.mapboxgl-touch-pan-blocker-override.mapboxgl-scrollable-page,.mapboxgl-canvas-container.mapboxgl-touch-pan-blocker-override.mapboxgl-scrollable-page .mapboxgl-canvas{touch-action:pan-x pan-y} +.mapboxgl-map{font:12px/20px Helvetica Neue,Arial,Helvetica,sans-serif;overflow:hidden;position:relative;-webkit-tap-highlight-color:rgb(0 0 0/0)}.mapboxgl-canvas{left:0;position:absolute;top:0}.mapboxgl-map:-webkit-full-screen{height:100%;width:100%}.mapboxgl-canary{background-color:salmon}.mapboxgl-canvas-container.mapboxgl-interactive,.mapboxgl-ctrl-group button.mapboxgl-ctrl-compass{cursor:grab;-webkit-user-select:none;user-select:none}.mapboxgl-canvas-container.mapboxgl-interactive.mapboxgl-track-pointer{cursor:pointer}.mapboxgl-canvas-container.mapboxgl-interactive:active,.mapboxgl-ctrl-group button.mapboxgl-ctrl-compass:active{cursor:grabbing}.mapboxgl-canvas-container.mapboxgl-touch-zoom-rotate,.mapboxgl-canvas-container.mapboxgl-touch-zoom-rotate .mapboxgl-canvas{touch-action:pan-x pan-y}.mapboxgl-canvas-container.mapboxgl-touch-drag-pan,.mapboxgl-canvas-container.mapboxgl-touch-drag-pan .mapboxgl-canvas{touch-action:pinch-zoom}.mapboxgl-canvas-container.mapboxgl-touch-zoom-rotate.mapboxgl-touch-drag-pan,.mapboxgl-canvas-container.mapboxgl-touch-zoom-rotate.mapboxgl-touch-drag-pan .mapboxgl-canvas{touch-action:none}.mapboxgl-ctrl-bottom-left,.mapboxgl-ctrl-bottom-right,.mapboxgl-ctrl-top-left,.mapboxgl-ctrl-top-right{pointer-events:none;position:absolute;z-index:2}.mapboxgl-ctrl-top-left{left:0;top:0}.mapboxgl-ctrl-top-right{right:0;top:0}.mapboxgl-ctrl-bottom-left{bottom:0;left:0}.mapboxgl-ctrl-bottom-right{bottom:0;right:0}.mapboxgl-ctrl{clear:both;pointer-events:auto;transform:translate(0)}.mapboxgl-ctrl-top-left .mapboxgl-ctrl{float:left;margin:10px 0 0 10px}.mapboxgl-ctrl-top-right .mapboxgl-ctrl{float:right;margin:10px 10px 0 0}.mapboxgl-ctrl-bottom-left .mapboxgl-ctrl{float:left;margin:0 0 10px 10px}.mapboxgl-ctrl-bottom-right .mapboxgl-ctrl{float:right;margin:0 10px 10px 0}.mapboxgl-ctrl-group{background:#fff;border-radius:4px}.mapboxgl-ctrl-group:not(:empty){box-shadow:0 0 0 2px rgba(0,0,0,.1)}@media (-ms-high-contrast:active){.mapboxgl-ctrl-group:not(:empty){box-shadow:0 0 0 2px ButtonText}}.mapboxgl-ctrl-group button{background-color:transparent;border:0;box-sizing:border-box;cursor:pointer;display:block;height:29px;outline:none;overflow:hidden;padding:0;width:29px}.mapboxgl-ctrl-group button+button{border-top:1px solid #ddd}.mapboxgl-ctrl button .mapboxgl-ctrl-icon{background-position:50%;background-repeat:no-repeat;display:block;height:100%;width:100%}@media (-ms-high-contrast:active){.mapboxgl-ctrl-icon{background-color:transparent}.mapboxgl-ctrl-group button+button{border-top:1px solid ButtonText}}.mapboxgl-ctrl-attrib-button:focus,.mapboxgl-ctrl-group button:focus{box-shadow:0 0 2px 2px #0096ff}.mapboxgl-ctrl button:disabled{cursor:not-allowed}.mapboxgl-ctrl button:disabled .mapboxgl-ctrl-icon{opacity:.25}.mapboxgl-ctrl-group button:first-child{border-radius:4px 4px 0 0}.mapboxgl-ctrl-group button:last-child{border-radius:0 0 4px 4px}.mapboxgl-ctrl-group button:only-child{border-radius:inherit}.mapboxgl-ctrl button:not(:disabled):hover{background-color:rgb(0 0 0/5%)}.mapboxgl-ctrl-group button:focus:focus-visible{box-shadow:0 0 2px 2px #0096ff}.mapboxgl-ctrl-group button:focus:not(:focus-visible){box-shadow:none}.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-out .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' 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 13h-9z'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-in .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' 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.5z'/%3E%3C/svg%3E")}@media (-ms-high-contrast:active){.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-out .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' 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 13h-9z'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-in .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' 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.5z'/%3E%3C/svg%3E")}}@media (-ms-high-contrast:black-on-white){.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-out .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23000' 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 13h-9z'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-in .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23000' 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.5z'/%3E%3C/svg%3E")}}.mapboxgl-ctrl button.mapboxgl-ctrl-fullscreen .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' 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-3h1zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16h1zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5H13zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1V7.5z'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-shrink .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' 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-1h-5.5zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1v-5.5zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1v5.5zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1h5.5z'/%3E%3C/svg%3E")}@media (-ms-high-contrast:active){.mapboxgl-ctrl button.mapboxgl-ctrl-fullscreen .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' 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-3h1zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16h1zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5H13zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1V7.5z'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-shrink .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' 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-1h-5.5zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1v-5.5zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1v5.5zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1h5.5z'/%3E%3C/svg%3E")}}@media (-ms-high-contrast:black-on-white){.mapboxgl-ctrl button.mapboxgl-ctrl-fullscreen .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23000' 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-3h1zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16h1zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5H13zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1V7.5z'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-shrink .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23000' 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-1h-5.5zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1v-5.5zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1v5.5zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1h5.5z'/%3E%3C/svg%3E")}}.mapboxgl-ctrl button.mapboxgl-ctrl-compass .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M10.5 14l4-8 4 8h-8z'/%3E%3Cpath id='south' d='M10.5 16l4 8 4-8h-8z' fill='%23ccc'/%3E%3C/svg%3E")}@media (-ms-high-contrast:active){.mapboxgl-ctrl button.mapboxgl-ctrl-compass .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M10.5 14l4-8 4 8h-8z'/%3E%3Cpath id='south' d='M10.5 16l4 8 4-8h-8z' fill='%23999'/%3E%3C/svg%3E")}}@media (-ms-high-contrast:black-on-white){.mapboxgl-ctrl button.mapboxgl-ctrl-compass .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23000' viewBox='0 0 29 29'%3E%3Cpath d='M10.5 14l4-8 4 8h-8z'/%3E%3Cpath id='south' d='M10.5 16l4 8 4-8h-8z' fill='%23ccc'/%3E%3C/svg%3E")}}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23333'%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-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate:disabled .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23aaa'%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-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' fill='%23f00'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-active .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%2333b5e5'%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-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-active-error .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23e58978'%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-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-background .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%2333b5e5'%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-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2' display='none'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-background-error .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23e54e33'%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-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2' display='none'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-waiting .mapboxgl-ctrl-icon{animation:mapboxgl-spin 2s linear infinite}@media (-ms-high-contrast:active){.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23fff'%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-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate:disabled .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23999'%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-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' fill='%23f00'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-active .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%2333b5e5'%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-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-active-error .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23e58978'%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-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-background .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%2333b5e5'%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-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2' display='none'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-background-error .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23e54e33'%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-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2' display='none'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E")}}@media (-ms-high-contrast:black-on-white){.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23000'%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-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate:disabled .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23666'%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-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' fill='%23f00'/%3E%3C/svg%3E")}}@keyframes mapboxgl-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}a.mapboxgl-ctrl-logo{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' fill-rule='evenodd' viewBox='0 0 88 23'%3E%3Cdefs%3E%3Cpath id='logo' d='M11.5 2.25c5.105 0 9.25 4.145 9.25 9.25s-4.145 9.25-9.25 9.25-9.25-4.145-9.25-9.25 4.145-9.25 9.25-9.25zM6.997 15.983c-.051-.338-.828-5.802 2.233-8.873a4.395 4.395 0 013.13-1.28c1.27 0 2.49.51 3.39 1.42.91.9 1.42 2.12 1.42 3.39 0 1.18-.449 2.301-1.28 3.13C12.72 16.93 7 16 7 16l-.003-.017zM15.3 10.5l-2 .8-.8 2-.8-2-2-.8 2-.8.8-2 .8 2 2 .8z'/%3E%3Cpath id='text' d='M50.63 8c.13 0 .23.1.23.23V9c.7-.76 1.7-1.18 2.73-1.18 2.17 0 3.95 1.85 3.95 4.17s-1.77 4.19-3.94 4.19c-1.04 0-2.03-.43-2.74-1.18v3.77c0 .13-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V8.23c0-.12.1-.23.23-.23h1.4zm-3.86.01c.01 0 .01 0 .01-.01.13 0 .22.1.22.22v7.55c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V15c-.7.76-1.69 1.19-2.73 1.19-2.17 0-3.94-1.87-3.94-4.19 0-2.32 1.77-4.19 3.94-4.19 1.03 0 2.02.43 2.73 1.18v-.75c0-.12.1-.23.23-.23h1.4zm26.375-.19a4.24 4.24 0 00-4.16 3.29c-.13.59-.13 1.19 0 1.77a4.233 4.233 0 004.17 3.3c2.35 0 4.26-1.87 4.26-4.19 0-2.32-1.9-4.17-4.27-4.17zM60.63 5c.13 0 .23.1.23.23v3.76c.7-.76 1.7-1.18 2.73-1.18 1.88 0 3.45 1.4 3.84 3.28.13.59.13 1.2 0 1.8-.39 1.88-1.96 3.29-3.84 3.29-1.03 0-2.02-.43-2.73-1.18v.77c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V5.23c0-.12.1-.23.23-.23h1.4zm-34 11h-1.4c-.13 0-.23-.11-.23-.23V8.22c.01-.13.1-.22.23-.22h1.4c.13 0 .22.11.23.22v.68c.5-.68 1.3-1.09 2.16-1.1h.03c1.09 0 2.09.6 2.6 1.55.45-.95 1.4-1.55 2.44-1.56 1.62 0 2.93 1.25 2.9 2.78l.03 5.2c0 .13-.1.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.8 0-1.46.7-1.59 1.62l.01 4.68c0 .13-.11.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.85 0-1.54.79-1.6 1.8v4.5c0 .13-.1.23-.23.23zm53.615 0h-1.61c-.04 0-.08-.01-.12-.03-.09-.06-.13-.19-.06-.28l2.43-3.71-2.39-3.65a.213.213 0 01-.03-.12c0-.12.09-.21.21-.21h1.61c.13 0 .24.06.3.17l1.41 2.37 1.4-2.37a.34.34 0 01.3-.17h1.6c.04 0 .08.01.12.03.09.06.13.19.06.28l-2.37 3.65 2.43 3.7c0 .05.01.09.01.13 0 .12-.09.21-.21.21h-1.61c-.13 0-.24-.06-.3-.17l-1.44-2.42-1.44 2.42a.34.34 0 01-.3.17zm-7.12-1.49c-1.33 0-2.42-1.12-2.42-2.51 0-1.39 1.08-2.52 2.42-2.52 1.33 0 2.42 1.12 2.42 2.51 0 1.39-1.08 2.51-2.42 2.52zm-19.865 0c-1.32 0-2.39-1.11-2.42-2.48v-.07c.02-1.38 1.09-2.49 2.4-2.49 1.32 0 2.41 1.12 2.41 2.51 0 1.39-1.07 2.52-2.39 2.53zm-8.11-2.48c-.01 1.37-1.09 2.47-2.41 2.47s-2.42-1.12-2.42-2.51c0-1.39 1.08-2.52 2.4-2.52 1.33 0 2.39 1.11 2.41 2.48l.02.08zm18.12 2.47c-1.32 0-2.39-1.11-2.41-2.48v-.06c.02-1.38 1.09-2.48 2.41-2.48s2.42 1.12 2.42 2.51c0 1.39-1.09 2.51-2.42 2.51z'/%3E%3C/defs%3E%3Cmask id='clip'%3E%3Crect x='0' y='0' width='100%25' height='100%25' fill='white'/%3E%3Cuse xlink:href='%23logo'/%3E%3Cuse xlink:href='%23text'/%3E%3C/mask%3E%3Cg id='outline' opacity='0.3' stroke='%23000' stroke-width='3'%3E%3Ccircle mask='url(%23clip)' cx='11.5' cy='11.5' r='9.25'/%3E%3Cuse xlink:href='%23text' mask='url(%23clip)'/%3E%3C/g%3E%3Cg id='fill' opacity='0.9' fill='%23fff'%3E%3Cuse xlink:href='%23logo'/%3E%3Cuse xlink:href='%23text'/%3E%3C/g%3E%3C/svg%3E");background-repeat:no-repeat;cursor:pointer;display:block;height:23px;margin:0 0 -4px -4px;overflow:hidden;width:88px}a.mapboxgl-ctrl-logo.mapboxgl-compact{width:23px}@media (-ms-high-contrast:active){a.mapboxgl-ctrl-logo{background-color:transparent;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' fill-rule='evenodd' viewBox='0 0 88 23'%3E%3Cdefs%3E%3Cpath id='logo' d='M11.5 2.25c5.105 0 9.25 4.145 9.25 9.25s-4.145 9.25-9.25 9.25-9.25-4.145-9.25-9.25 4.145-9.25 9.25-9.25zM6.997 15.983c-.051-.338-.828-5.802 2.233-8.873a4.395 4.395 0 013.13-1.28c1.27 0 2.49.51 3.39 1.42.91.9 1.42 2.12 1.42 3.39 0 1.18-.449 2.301-1.28 3.13C12.72 16.93 7 16 7 16l-.003-.017zM15.3 10.5l-2 .8-.8 2-.8-2-2-.8 2-.8.8-2 .8 2 2 .8z'/%3E%3Cpath id='text' d='M50.63 8c.13 0 .23.1.23.23V9c.7-.76 1.7-1.18 2.73-1.18 2.17 0 3.95 1.85 3.95 4.17s-1.77 4.19-3.94 4.19c-1.04 0-2.03-.43-2.74-1.18v3.77c0 .13-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V8.23c0-.12.1-.23.23-.23h1.4zm-3.86.01c.01 0 .01 0 .01-.01.13 0 .22.1.22.22v7.55c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V15c-.7.76-1.69 1.19-2.73 1.19-2.17 0-3.94-1.87-3.94-4.19 0-2.32 1.77-4.19 3.94-4.19 1.03 0 2.02.43 2.73 1.18v-.75c0-.12.1-.23.23-.23h1.4zm26.375-.19a4.24 4.24 0 00-4.16 3.29c-.13.59-.13 1.19 0 1.77a4.233 4.233 0 004.17 3.3c2.35 0 4.26-1.87 4.26-4.19 0-2.32-1.9-4.17-4.27-4.17zM60.63 5c.13 0 .23.1.23.23v3.76c.7-.76 1.7-1.18 2.73-1.18 1.88 0 3.45 1.4 3.84 3.28.13.59.13 1.2 0 1.8-.39 1.88-1.96 3.29-3.84 3.29-1.03 0-2.02-.43-2.73-1.18v.77c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V5.23c0-.12.1-.23.23-.23h1.4zm-34 11h-1.4c-.13 0-.23-.11-.23-.23V8.22c.01-.13.1-.22.23-.22h1.4c.13 0 .22.11.23.22v.68c.5-.68 1.3-1.09 2.16-1.1h.03c1.09 0 2.09.6 2.6 1.55.45-.95 1.4-1.55 2.44-1.56 1.62 0 2.93 1.25 2.9 2.78l.03 5.2c0 .13-.1.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.8 0-1.46.7-1.59 1.62l.01 4.68c0 .13-.11.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.85 0-1.54.79-1.6 1.8v4.5c0 .13-.1.23-.23.23zm53.615 0h-1.61c-.04 0-.08-.01-.12-.03-.09-.06-.13-.19-.06-.28l2.43-3.71-2.39-3.65a.213.213 0 01-.03-.12c0-.12.09-.21.21-.21h1.61c.13 0 .24.06.3.17l1.41 2.37 1.4-2.37a.34.34 0 01.3-.17h1.6c.04 0 .08.01.12.03.09.06.13.19.06.28l-2.37 3.65 2.43 3.7c0 .05.01.09.01.13 0 .12-.09.21-.21.21h-1.61c-.13 0-.24-.06-.3-.17l-1.44-2.42-1.44 2.42a.34.34 0 01-.3.17zm-7.12-1.49c-1.33 0-2.42-1.12-2.42-2.51 0-1.39 1.08-2.52 2.42-2.52 1.33 0 2.42 1.12 2.42 2.51 0 1.39-1.08 2.51-2.42 2.52zm-19.865 0c-1.32 0-2.39-1.11-2.42-2.48v-.07c.02-1.38 1.09-2.49 2.4-2.49 1.32 0 2.41 1.12 2.41 2.51 0 1.39-1.07 2.52-2.39 2.53zm-8.11-2.48c-.01 1.37-1.09 2.47-2.41 2.47s-2.42-1.12-2.42-2.51c0-1.39 1.08-2.52 2.4-2.52 1.33 0 2.39 1.11 2.41 2.48l.02.08zm18.12 2.47c-1.32 0-2.39-1.11-2.41-2.48v-.06c.02-1.38 1.09-2.48 2.41-2.48s2.42 1.12 2.42 2.51c0 1.39-1.09 2.51-2.42 2.51z'/%3E%3C/defs%3E%3Cmask id='clip'%3E%3Crect x='0' y='0' width='100%25' height='100%25' fill='white'/%3E%3Cuse xlink:href='%23logo'/%3E%3Cuse xlink:href='%23text'/%3E%3C/mask%3E%3Cg id='outline' opacity='1' stroke='%23000' stroke-width='3'%3E%3Ccircle mask='url(%23clip)' cx='11.5' cy='11.5' r='9.25'/%3E%3Cuse xlink:href='%23text' mask='url(%23clip)'/%3E%3C/g%3E%3Cg id='fill' opacity='1' fill='%23fff'%3E%3Cuse xlink:href='%23logo'/%3E%3Cuse xlink:href='%23text'/%3E%3C/g%3E%3C/svg%3E")}}@media (-ms-high-contrast:black-on-white){a.mapboxgl-ctrl-logo{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' fill-rule='evenodd' viewBox='0 0 88 23'%3E%3Cdefs%3E%3Cpath id='logo' d='M11.5 2.25c5.105 0 9.25 4.145 9.25 9.25s-4.145 9.25-9.25 9.25-9.25-4.145-9.25-9.25 4.145-9.25 9.25-9.25zM6.997 15.983c-.051-.338-.828-5.802 2.233-8.873a4.395 4.395 0 013.13-1.28c1.27 0 2.49.51 3.39 1.42.91.9 1.42 2.12 1.42 3.39 0 1.18-.449 2.301-1.28 3.13C12.72 16.93 7 16 7 16l-.003-.017zM15.3 10.5l-2 .8-.8 2-.8-2-2-.8 2-.8.8-2 .8 2 2 .8z'/%3E%3Cpath id='text' d='M50.63 8c.13 0 .23.1.23.23V9c.7-.76 1.7-1.18 2.73-1.18 2.17 0 3.95 1.85 3.95 4.17s-1.77 4.19-3.94 4.19c-1.04 0-2.03-.43-2.74-1.18v3.77c0 .13-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V8.23c0-.12.1-.23.23-.23h1.4zm-3.86.01c.01 0 .01 0 .01-.01.13 0 .22.1.22.22v7.55c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V15c-.7.76-1.69 1.19-2.73 1.19-2.17 0-3.94-1.87-3.94-4.19 0-2.32 1.77-4.19 3.94-4.19 1.03 0 2.02.43 2.73 1.18v-.75c0-.12.1-.23.23-.23h1.4zm26.375-.19a4.24 4.24 0 00-4.16 3.29c-.13.59-.13 1.19 0 1.77a4.233 4.233 0 004.17 3.3c2.35 0 4.26-1.87 4.26-4.19 0-2.32-1.9-4.17-4.27-4.17zM60.63 5c.13 0 .23.1.23.23v3.76c.7-.76 1.7-1.18 2.73-1.18 1.88 0 3.45 1.4 3.84 3.28.13.59.13 1.2 0 1.8-.39 1.88-1.96 3.29-3.84 3.29-1.03 0-2.02-.43-2.73-1.18v.77c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V5.23c0-.12.1-.23.23-.23h1.4zm-34 11h-1.4c-.13 0-.23-.11-.23-.23V8.22c.01-.13.1-.22.23-.22h1.4c.13 0 .22.11.23.22v.68c.5-.68 1.3-1.09 2.16-1.1h.03c1.09 0 2.09.6 2.6 1.55.45-.95 1.4-1.55 2.44-1.56 1.62 0 2.93 1.25 2.9 2.78l.03 5.2c0 .13-.1.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.8 0-1.46.7-1.59 1.62l.01 4.68c0 .13-.11.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.85 0-1.54.79-1.6 1.8v4.5c0 .13-.1.23-.23.23zm53.615 0h-1.61c-.04 0-.08-.01-.12-.03-.09-.06-.13-.19-.06-.28l2.43-3.71-2.39-3.65a.213.213 0 01-.03-.12c0-.12.09-.21.21-.21h1.61c.13 0 .24.06.3.17l1.41 2.37 1.4-2.37a.34.34 0 01.3-.17h1.6c.04 0 .08.01.12.03.09.06.13.19.06.28l-2.37 3.65 2.43 3.7c0 .05.01.09.01.13 0 .12-.09.21-.21.21h-1.61c-.13 0-.24-.06-.3-.17l-1.44-2.42-1.44 2.42a.34.34 0 01-.3.17zm-7.12-1.49c-1.33 0-2.42-1.12-2.42-2.51 0-1.39 1.08-2.52 2.42-2.52 1.33 0 2.42 1.12 2.42 2.51 0 1.39-1.08 2.51-2.42 2.52zm-19.865 0c-1.32 0-2.39-1.11-2.42-2.48v-.07c.02-1.38 1.09-2.49 2.4-2.49 1.32 0 2.41 1.12 2.41 2.51 0 1.39-1.07 2.52-2.39 2.53zm-8.11-2.48c-.01 1.37-1.09 2.47-2.41 2.47s-2.42-1.12-2.42-2.51c0-1.39 1.08-2.52 2.4-2.52 1.33 0 2.39 1.11 2.41 2.48l.02.08zm18.12 2.47c-1.32 0-2.39-1.11-2.41-2.48v-.06c.02-1.38 1.09-2.48 2.41-2.48s2.42 1.12 2.42 2.51c0 1.39-1.09 2.51-2.42 2.51z'/%3E%3C/defs%3E%3Cmask id='clip'%3E%3Crect x='0' y='0' width='100%25' height='100%25' fill='white'/%3E%3Cuse xlink:href='%23logo'/%3E%3Cuse xlink:href='%23text'/%3E%3C/mask%3E%3Cg id='outline' opacity='1' stroke='%23fff' stroke-width='3' fill='%23fff'%3E%3Ccircle mask='url(%23clip)' cx='11.5' cy='11.5' r='9.25'/%3E%3Cuse xlink:href='%23text' mask='url(%23clip)'/%3E%3C/g%3E%3Cg id='fill' opacity='1' fill='%23000'%3E%3Cuse xlink:href='%23logo'/%3E%3Cuse xlink:href='%23text'/%3E%3C/g%3E%3C/svg%3E")}}.mapboxgl-ctrl.mapboxgl-ctrl-attrib{background-color:hsla(0,0%,100%,.5);margin:0;padding:0 5px}@media screen{.mapboxgl-ctrl-attrib.mapboxgl-compact{background-color:#fff;border-radius:12px;box-sizing:content-box;margin:10px;min-height:20px;padding:2px 24px 2px 0;position:relative}.mapboxgl-ctrl-attrib.mapboxgl-compact-show{padding:2px 28px 2px 8px;visibility:visible}.mapboxgl-ctrl-bottom-left>.mapboxgl-ctrl-attrib.mapboxgl-compact-show,.mapboxgl-ctrl-top-left>.mapboxgl-ctrl-attrib.mapboxgl-compact-show{border-radius:12px;padding:2px 8px 2px 28px}.mapboxgl-ctrl-attrib.mapboxgl-compact .mapboxgl-ctrl-attrib-inner{display:none}.mapboxgl-ctrl-attrib-button{background-color:hsla(0,0%,100%,.5);background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill-rule='evenodd'%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;box-sizing:border-box;cursor:pointer;display:none;height:24px;outline:none;position:absolute;right:0;top:0;width:24px}.mapboxgl-ctrl-bottom-left .mapboxgl-ctrl-attrib-button,.mapboxgl-ctrl-top-left .mapboxgl-ctrl-attrib-button{left:0}.mapboxgl-ctrl-attrib.mapboxgl-compact .mapboxgl-ctrl-attrib-button,.mapboxgl-ctrl-attrib.mapboxgl-compact-show .mapboxgl-ctrl-attrib-inner{display:block}.mapboxgl-ctrl-attrib.mapboxgl-compact-show .mapboxgl-ctrl-attrib-button{background-color:rgb(0 0 0/5%)}.mapboxgl-ctrl-bottom-right>.mapboxgl-ctrl-attrib.mapboxgl-compact:after{bottom:0;right:0}.mapboxgl-ctrl-top-right>.mapboxgl-ctrl-attrib.mapboxgl-compact:after{right:0;top:0}.mapboxgl-ctrl-top-left>.mapboxgl-ctrl-attrib.mapboxgl-compact:after{left:0;top:0}.mapboxgl-ctrl-bottom-left>.mapboxgl-ctrl-attrib.mapboxgl-compact:after{bottom:0;left:0}}@media screen and (-ms-high-contrast:active){.mapboxgl-ctrl-attrib.mapboxgl-compact:after{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill-rule='evenodd' fill='%23fff'%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 (-ms-high-contrast:black-on-white){.mapboxgl-ctrl-attrib.mapboxgl-compact:after{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill-rule='evenodd'%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")}}.mapboxgl-ctrl-attrib a{color:rgba(0,0,0,.75);text-decoration:none}.mapboxgl-ctrl-attrib a:hover{color:inherit;text-decoration:underline}.mapboxgl-ctrl-attrib .mapbox-improve-map{font-weight:700;margin-left:2px}.mapboxgl-attrib-empty{display:none}.mapboxgl-ctrl-scale{background-color:hsla(0,0%,100%,.75);border:2px solid #333;border-top:#333;box-sizing:border-box;color:#333;font-size:10px;padding:0 5px;white-space:nowrap}.mapboxgl-popup{display:flex;left:0;pointer-events:none;position:absolute;top:0;will-change:transform}.mapboxgl-popup-anchor-top,.mapboxgl-popup-anchor-top-left,.mapboxgl-popup-anchor-top-right{flex-direction:column}.mapboxgl-popup-anchor-bottom,.mapboxgl-popup-anchor-bottom-left,.mapboxgl-popup-anchor-bottom-right{flex-direction:column-reverse}.mapboxgl-popup-anchor-left{flex-direction:row}.mapboxgl-popup-anchor-right{flex-direction:row-reverse}.mapboxgl-popup-tip{border:10px solid transparent;height:0;width:0;z-index:1}.mapboxgl-popup-anchor-top .mapboxgl-popup-tip{align-self:center;border-bottom-color:#fff;border-top:none}.mapboxgl-popup-anchor-top-left .mapboxgl-popup-tip{align-self:flex-start;border-bottom-color:#fff;border-left:none;border-top:none}.mapboxgl-popup-anchor-top-right .mapboxgl-popup-tip{align-self:flex-end;border-bottom-color:#fff;border-right:none;border-top:none}.mapboxgl-popup-anchor-bottom .mapboxgl-popup-tip{align-self:center;border-bottom:none;border-top-color:#fff}.mapboxgl-popup-anchor-bottom-left .mapboxgl-popup-tip{align-self:flex-start;border-bottom:none;border-left:none;border-top-color:#fff}.mapboxgl-popup-anchor-bottom-right .mapboxgl-popup-tip{align-self:flex-end;border-bottom:none;border-right:none;border-top-color:#fff}.mapboxgl-popup-anchor-left .mapboxgl-popup-tip{align-self:center;border-left:none;border-right-color:#fff}.mapboxgl-popup-anchor-right .mapboxgl-popup-tip{align-self:center;border-left-color:#fff;border-right:none}.mapboxgl-popup-close-button{background-color:transparent;border:0;border-radius:0 3px 0 0;cursor:pointer;position:absolute;right:0;top:0}.mapboxgl-popup-close-button:hover{background-color:rgb(0 0 0/5%)}.mapboxgl-popup-content{background:#fff;border-radius:3px;box-shadow:0 1px 2px rgba(0,0,0,.1);padding:10px 10px 15px;pointer-events:auto;position:relative}.mapboxgl-popup-anchor-top-left .mapboxgl-popup-content{border-top-left-radius:0}.mapboxgl-popup-anchor-top-right .mapboxgl-popup-content{border-top-right-radius:0}.mapboxgl-popup-anchor-bottom-left .mapboxgl-popup-content{border-bottom-left-radius:0}.mapboxgl-popup-anchor-bottom-right .mapboxgl-popup-content{border-bottom-right-radius:0}.mapboxgl-popup-track-pointer{display:none}.mapboxgl-popup-track-pointer *{pointer-events:none;user-select:none}.mapboxgl-map:hover .mapboxgl-popup-track-pointer{display:flex}.mapboxgl-map:active .mapboxgl-popup-track-pointer{display:none}.mapboxgl-marker{left:0;opacity:1;position:absolute;top:0;transition:opacity .2s;will-change:transform}.mapboxgl-user-location-dot,.mapboxgl-user-location-dot:before{background-color:#1da1f2;border-radius:50%;height:15px;width:15px}.mapboxgl-user-location-dot:before{animation:mapboxgl-user-location-dot-pulse 2s infinite;content:"";position:absolute}.mapboxgl-user-location-dot:after{border:2px solid #fff;border-radius:50%;box-shadow:0 0 3px rgba(0,0,0,.35);box-sizing:border-box;content:"";height:19px;left:-2px;position:absolute;top:-2px;width:19px}.mapboxgl-user-location-show-heading .mapboxgl-user-location-heading{height:0;width:0}.mapboxgl-user-location-show-heading .mapboxgl-user-location-heading:after,.mapboxgl-user-location-show-heading .mapboxgl-user-location-heading:before{border-bottom:7.5px solid #4aa1eb;content:"";position:absolute}.mapboxgl-user-location-show-heading .mapboxgl-user-location-heading:before{border-left:7.5px solid transparent;transform:translateY(-28px) skewY(-20deg)}.mapboxgl-user-location-show-heading .mapboxgl-user-location-heading:after{border-right:7.5px solid transparent;transform:translate(7.5px,-28px) skewY(20deg)}@keyframes mapboxgl-user-location-dot-pulse{0%{opacity:1;transform:scale(1)}70%{opacity:0;transform:scale(3)}to{opacity:0;transform:scale(1)}}.mapboxgl-user-location-dot-stale{background-color:#aaa}.mapboxgl-user-location-dot-stale:after{display:none}.mapboxgl-user-location-accuracy-circle{background-color:#1da1f233;border-radius:100%;height:1px;width:1px}.mapboxgl-crosshair,.mapboxgl-crosshair .mapboxgl-interactive,.mapboxgl-crosshair .mapboxgl-interactive:active{cursor:crosshair}.mapboxgl-boxzoom{background:#fff;border:2px dotted #202020;height:0;left:0;opacity:.5;position:absolute;top:0;width:0}@media print{.mapbox-improve-map{display:none}}.mapboxgl-scroll-zoom-blocker,.mapboxgl-touch-pan-blocker{align-items:center;background:rgba(0,0,0,.7);color:#fff;display:flex;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif;height:100%;justify-content:center;left:0;opacity:0;pointer-events:none;position:absolute;text-align:center;top:0;transition:opacity .75s ease-in-out;transition-delay:1s;width:100%}.mapboxgl-scroll-zoom-blocker-show,.mapboxgl-touch-pan-blocker-show{opacity:1;transition:opacity .1s ease-in-out}.mapboxgl-canvas-container.mapboxgl-touch-pan-blocker-override.mapboxgl-scrollable-page,.mapboxgl-canvas-container.mapboxgl-touch-pan-blocker-override.mapboxgl-scrollable-page .mapboxgl-canvas{touch-action:pan-x pan-y} .mapbox-ctrl-compass button { display: flex; align-items: center; diff --git a/preview/preview.bundle.js b/preview/preview.bundle.js index a86f58c..e381f6c 100644 --- a/preview/preview.bundle.js +++ b/preview/preview.bundle.js @@ -38,13 +38,21 @@ } - define(["exports"],(function(e){var t="undefined"!=typeof self?self:{},i="3.0.1";let r;const n={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(null==r){const e=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{r=null!=process.env.API_URL_REGEX?new RegExp(process.env.API_URL_REGEX):e;}catch(t){r=e;}}return r},get API_TILEJSON_REGEX(){return /^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/v[0-9]*\/.*\.json.*$)/i},get API_SPRITE_REGEX(){return /^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*\/sprite.*\..*$)/i},get API_FONTS_REGEX(){return /^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/fonts\/v[0-9]*\/)(.*\.pbf.*$)/i},get API_STYLE_REGEX(){return /^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*$)/i},get API_CDN_URL_REGEX(){return /^((https?:)?\/\/)?api\.mapbox\.c(n|om)(\/mapbox-gl-js\/)(.*$)/i},get EVENTS_URL(){if(!n.API_URL)return null;try{const e=new URL(n.API_URL);return "api.mapbox.cn"===e.hostname?"https://events.mapbox.cn/events/v2":"api.mapbox.com"===e.hostname?"https://events.mapbox.com/events/v2":null}catch(e){return null}},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,DEFAULT_STYLE:"mapbox://styles/mapbox/standard",MAX_PARALLEL_IMAGE_REQUESTS:16,DRACO_URL:"https://api.mapbox.com/mapbox-gl-js/draco_decoder_gltf_v1.5.6.wasm",GLYPHS_URL:"mapbox://fonts/mapbox/{fontstack}/{range}.pbf"},o={supported:!1,testSupport:function(e){!l&&a&&(c?h(e):s=e);}};let s,a,l=!1,c=!1;function h(e){const t=e.createTexture();e.bindTexture(e.TEXTURE_2D,t);try{if(e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,a),e.isContextLost())return;o.supported=!0;}catch(e){}e.deleteTexture(t),l=!0;}t.document&&(a=t.document.createElement("img"),a.onload=function(){s&&h(s),s=null,c=!0;},a.onerror=function(){l=!0,s=null;},a.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const u="01";function d(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var p=f;function f(e,t,i,r){this.cx=3*e,this.bx=3*(i-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(r-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=t,this.p2x=i,this.p2y=r;}f.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,t){if(void 0===t&&(t=1e-6),e<0)return 0;if(e>1)return 1;for(var i=e,r=0;r<8;r++){var n=this.sampleCurveX(i)-e;if(Math.abs(n)n?s=i:a=i,i=.5*(a-s)+s;return i},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}};var m=d(p),_=g;function g(e,t){this.x=e,this.y=t;}g.prototype={clone:function(){return new g(this.x,this.y)},add:function(e){return this.clone()._add(e)},sub:function(e){return this.clone()._sub(e)},multByPoint:function(e){return this.clone()._multByPoint(e)},divByPoint:function(e){return this.clone()._divByPoint(e)},mult:function(e){return this.clone()._mult(e)},div:function(e){return this.clone()._div(e)},rotate:function(e){return this.clone()._rotate(e)},rotateAround:function(e,t){return this.clone()._rotateAround(e,t)},matMult:function(e){return this.clone()._matMult(e)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(e){return this.x===e.x&&this.y===e.y},dist:function(e){return Math.sqrt(this.distSqr(e))},distSqr:function(e){var t=e.x-this.x,i=e.y-this.y;return t*t+i*i},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith:function(e){return this.angleWithSep(e.x,e.y)},angleWithSep:function(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult:function(e){var t=e[2]*this.x+e[3]*this.y;return this.x=e[0]*this.x+e[1]*this.y,this.y=t,this},_add:function(e){return this.x+=e.x,this.y+=e.y,this},_sub:function(e){return this.x-=e.x,this.y-=e.y,this},_mult:function(e){return this.x*=e,this.y*=e,this},_div:function(e){return this.x/=e,this.y/=e,this},_multByPoint:function(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint:function(e){return this.x/=e.x,this.y/=e.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var e=this.y;return this.y=this.x,this.x=-e,this},_rotate:function(e){var t=Math.cos(e),i=Math.sin(e),r=i*this.x+t*this.y;return this.x=t*this.x-i*this.y,this.y=r,this},_rotateAround:function(e,t){var i=Math.cos(e),r=Math.sin(e),n=t.y+r*(this.x-t.x)+i*(this.y-t.y);return this.x=t.x+i*(this.x-t.x)-r*(this.y-t.y),this.y=n,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},g.convert=function(e){return e instanceof g?e:Array.isArray(e)?new g(e[0],e[1]):e};var y=d(_);function x(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return !1;for(let i=0;i=1)return 1;const t=e*e,i=t*e;return 4*(e<.5?i:3*(e-t)+i-.75)}function A(e){let t=1/0,i=1/0,r=-1/0,n=-1/0;for(const o of e)t=Math.min(t,o.x),i=Math.min(i,o.y),r=Math.max(r,o.x),n=Math.max(n,o.y);return {min:new y(t,i),max:new y(r,n)}}function S(e,t,i=0,r=!0){const n=new y(i,i),o=e.sub(n),s=t.add(n),a=[o,new y(s.x,o.y),s,new y(o.x,s.y)];return r&&a.push(o.clone()),a}function I(e,t,i,r){const n=new m(e,t,i,r);return function(e){return n.solve(e)}}const C=I(.25,.1,.25,1);function z(e,t,i){return Math.min(i,Math.max(t,e))}function D(e,t,i){return (i=z((i-e)/(t-e),0,1))*i*(3-2*i)}function P(e,t,i){const r=i-t,n=((e-t)%r+r)%r+t;return n===t?i:n}function R(e,t,i){if(!e.length)return i(null,[]);let r=e.length;const n=new Array(e.length);let o=null;e.forEach(((e,s)=>{t(e,((e,t)=>{e&&(o=e),n[s]=t,0==--r&&i(o,n);}));}));}function L(e){const t=[];for(const i in e)t.push(e[i]);return t}function k(e,...t){for(const i of t)for(const t in i)e[t]=i[t];return e}function O(e,t){const i={};for(let r=0;r>t/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,e)}()}function U(e){return e<=1?1:Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function V(e){return !!e&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)}function j(e,t){e.forEach((e=>{t[e]&&(t[e]=t[e].bind(t));}));}function G(e,t){return -1!==e.indexOf(t,e.length-t.length)}function q(e,t,i){const r={};for(const n in e)r[n]=t.call(i||this,e[n],n,e);return r}function Z(e,t,i){const r={};for(const n in e)t.call(i||this,e[n],n,e)&&(r[n]=e[n]);return r}function $(e){return Array.isArray(e)?e.map($):"object"==typeof e&&e?q(e,$):e}const H={};function W(e){H[e]||("undefined"!=typeof console&&console.warn(e),H[e]=!0);}function X(e,t,i){return (i.y-e.y)*(t.x-e.x)>(t.y-e.y)*(i.x-e.x)}function Y(e){let t=0;for(let i,r,n=0,o=e.length,s=o-1;n0?Math.acos(i/r)*b:0;let o=0!==e||0!==t?Math.atan2(-t,-e)*b+90:0;return o<0&&(o+=360),[r,o,n]}function Q(){return "undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope}function ee(e){const t={};if(e.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((e,i,r,n)=>{const o=r||n;return t[i]=!o||o.toLowerCase(),""})),t["max-age"]){const e=parseInt(t["max-age"],10);isNaN(e)?delete t["max-age"]:t["max-age"]=e;}return t}let te=null;function ie(){return !!t.document.fullscreenElement||!!t.document.webkitFullscreenElement}function re(e){try{const i=t[e];return i.setItem("_mapbox_test_",1),i.removeItem("_mapbox_test_"),!0}catch(e){return !1}}function ne(e,t){return [e[4*t],e[4*t+1],e[4*t+2],e[4*t+3]]}function oe(e,t,i){e[4*t+0]=i[0],e[4*t+1]=i[1],e[4*t+2]=i[2],e[4*t+3]=i[3];}function se(e,t){return [Math.pow(e[0],2.2)*t,Math.pow(e[1],2.2)*t,Math.pow(e[2],2.2)*t]}function ae(e){return [Math.pow(e[0],1/2.2),Math.pow(e[1],1/2.2),Math.pow(e[2],1/2.2)]}const le="mapbox-tiles";let ce=500,he=50;let ue,de;function pe(){try{return t.caches}catch(e){}}function fe(){pe()&&!ue&&(ue=t.caches.open(le));}function me(e){const t=e.indexOf("?");if(t<0)return e;const i=function(e){const t=e.indexOf("?");return t>0?e.slice(t+1).split("&"):[]}(e),r=i.filter((e=>{const t=e.split("=");return "language"===t[0]||"worldview"===t[0]}));return r.length?`${e.slice(0,t)}?${r.join("&")}`:e.slice(0,t)}let _e=1/0;function ge(e){_e++,_e>he&&(e.getActor().send("enforceCacheSizeLimit",ce),_e=0);}const ye={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image",Model:"Model"};"function"==typeof Object.freeze&&Object.freeze(ye);class xe extends Error{constructor(e,t,i){401===t&&Pe(i)&&(e+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(e),this.status=t,this.url=i;}toString(){return `${this.name}: ${this.message} (${this.status}): ${this.url}`}}const ve=Q()?()=>self.worker&&self.worker.referrer:()=>("blob:"===t.location.protocol?t.parent:t).location.href;const be=function(e,i){if(!(/^file:/.test(r=e.url)||/^file:/.test(ve())&&!/^\w+:/.test(r))){if(t.fetch&&t.Request&&t.AbortController&&t.Request.prototype.hasOwnProperty("signal"))return function(e,i){const r=new t.AbortController,n=new t.Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,referrer:ve(),referrerPolicy:e.referrerPolicy,signal:r.signal});let o=!1,s=!1;const a=(l=n.url).indexOf("sku=")>0&&Pe(l);var l;"json"===e.type&&n.headers.set("Accept","application/json");const c=(r,o,l)=>{if(s)return;if(r&&"SecurityError"!==r.message&&W(r.toString()),o&&l)return h(o);const c=Date.now();t.fetch(n).then((t=>{if(t.ok){const e=a?t.clone():null;return h(t,e,c)}return i(new xe(t.statusText,t.status,e.url))})).catch((t=>{"AbortError"!==t.name&&i(new Error(`${t.message} ${e.url}`));}));},h=(r,a,l)=>{("arrayBuffer"===e.type?r.arrayBuffer():"json"===e.type?r.json():r.text()).then((e=>{s||(a&&l&&function(e,i,r){if(fe(),!ue)return;const n={status:i.status,statusText:i.statusText,headers:new t.Headers};i.headers.forEach(((e,t)=>n.headers.set(t,e)));const o=ee(i.headers.get("Cache-Control")||"");if(o["no-store"])return;o["max-age"]&&n.headers.set("Expires",new Date(r+1e3*o["max-age"]).toUTCString());const s=n.headers.get("Expires");s&&(new Date(s).getTime()-r<42e4||function(e,t){if(void 0===de)try{new Response(new ReadableStream),de=!0;}catch(e){de=!1;}de?t(e.body):e.blob().then(t);}(i,(i=>{const r=new t.Response(i,n);fe(),ue&&ue.then((t=>t.put(me(e.url),r))).catch((e=>W(e.message)));})));}(n,a,l),o=!0,i(null,e,r.headers.get("Cache-Control"),r.headers.get("Expires")));})).catch((e=>{s||i(new Error(e.message));}));};return a?function(e,t){if(fe(),!ue)return t(null);const i=me(e.url);ue.then((e=>{e.match(i).then((r=>{const n=function(e){if(!e)return !1;const t=new Date(e.headers.get("Expires")||0),i=ee(e.headers.get("Cache-Control")||"");return t>Date.now()&&!i["no-cache"]}(r);e.delete(i),n&&e.put(i,r.clone()),t(null,r,n);})).catch(t);})).catch(t);}(n,c):c(null,null),{cancel:()=>{s=!0,o||r.abort();}}}(e,i);if(Q()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",e,i,void 0,!0)}var r;return function(e,i){const r=new t.XMLHttpRequest;r.open(e.method||"GET",e.url,!0),"arrayBuffer"===e.type&&(r.responseType="arraybuffer");for(const t in e.headers)r.setRequestHeader(t,e.headers[t]);return "json"===e.type&&(r.responseType="text",r.setRequestHeader("Accept","application/json")),r.withCredentials="include"===e.credentials,r.onerror=()=>{i(new Error(r.statusText));},r.onload=()=>{if((r.status>=200&&r.status<300||0===r.status)&&null!==r.response){let t=r.response;if("json"===e.type)try{t=JSON.parse(r.response);}catch(e){return i(e)}i(null,t,r.getResponseHeader("Cache-Control"),r.getResponseHeader("Expires"));}else i(new xe(r.statusText,r.status,e.url));},r.send(e.body),{cancel:()=>r.abort()}}(e,i)},we=function(e,t){return be(k(e,{type:"json"}),t)},Te=function(e,t){return be(k(e,{type:"arrayBuffer"}),t)};function Ee(e){const i=t.document.createElement("a");return i.href=e,i.protocol===t.document.location.protocol&&i.host===t.document.location.host}const Me="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let Ae,Se;Ae=[],Se=0;const Ie=function(e,i){if(o.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),Se>=n.MAX_PARALLEL_IMAGE_REQUESTS){const t={requestParameters:e,callback:i,cancelled:!1,cancel(){this.cancelled=!0;}};return Ae.push(t),t}Se++;let r=!1;const s=()=>{if(!r)for(r=!0,Se--;Ae.length&&Se{s(),e?i(e):r&&(t.createImageBitmap?function(e,i){const r=new t.Blob([new Uint8Array(e)],{type:"image/png"});t.createImageBitmap(r).then((e=>{i(null,e);})).catch((e=>{i(new Error(`Could not load image because of ${e.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`));}));}(r,((e,t)=>i(e,t,n,o))):function(e,i){const r=new t.Image,n=t.URL;r.onload=()=>{i(null,r),n.revokeObjectURL(r.src),r.onload=null,t.requestAnimationFrame((()=>{r.src=Me;}));},r.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 o=new t.Blob([new Uint8Array(e)],{type:"image/png"});r.src=e.byteLength?n.createObjectURL(o):Me;}(r,((e,t)=>i(e,t,n,o))));}));return {cancel:()=>{a.cancel(),s();}}},Ce="NO_ACCESS_TOKEN";class ze{constructor(e,t,i){this._transformRequestFn=e,this._customAccessToken=t,this._silenceAuthErrors=!!i,this._createSkuToken();}_createSkuToken(){const e=function(){let e="";for(let t=0;t<10;t++)e+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return {token:["1",u,e].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=e.token,this._skuTokenExpiresAt=e.tokenExpiresAt;}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}normalizeStyleURL(e,t){if(!De(e))return e;const r=Be(e);return r.params.push(`sdk=js-${i}`),r.path=`/styles/v1${r.path}`,this._makeAPIURL(r,this._customAccessToken||t)}normalizeGlyphsURL(e,t){if(!De(e))return e;const i=Be(e);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||t)}normalizeModelURL(e,t){if(!De(e))return e;const i=Be(e);return i.path=`/models/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||t)}normalizeSourceURL(e,t,i,r){if(!De(e))return e;const n=Be(e);return n.path=`/v4/${n.authority}.json`,n.params.push("secure"),i&&n.params.push(`language=${i}`),r&&n.params.push(`worldview=${r}`),this._makeAPIURL(n,this._customAccessToken||t)}normalizeSpriteURL(e,t,i,r){const n=Be(e);return De(e)?(n.path=`/styles/v1${n.path}/sprite${t}${i}`,this._makeAPIURL(n,this._customAccessToken||r)):(n.path+=`${t}${i}`,Fe(n))}normalizeTileURL(e,t,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),e&&!De(e))return e;const r=Be(e);r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${t||i&&"raster"!==r.authority&&512===i?"@2x":""}${o.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${n.RASTER_URL_PREFIX}${r.path}`:(r.path=r.path.replace(/^.+\/v4\//,"/"),r.path=`/${n.TILE_URL_VERSION}${r.path}`);const s=this._customAccessToken||function(e){for(const t of e){const e=t.match(/^access_token=(.*)$/);if(e)return e[1]}return null}(r.params)||n.ACCESS_TOKEN;return n.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&r.params.push(`sku=${this._skuToken}`),this._makeAPIURL(r,s)}canonicalizeTileURL(e,t){const i=Be(e);if(!i.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!i.path.match(/\.[\w]+$/))return e;let r="mapbox://";i.path.match(/^\/raster\/v1\//)?r+=`raster/${i.path.replace(`/${n.RASTER_URL_PREFIX}/`,"")}`:r+=`tiles/${i.path.replace(`/${n.TILE_URL_VERSION}/`,"")}`;let o=i.params;return t&&(o=o.filter((e=>!e.match(/^access_token=/)))),o.length&&(r+=`?${o.join("&")}`),r}canonicalizeTileset(e,t){const i=!!t&&De(t),r=[];for(const t of e.tiles||[])Pe(t)?r.push(this.canonicalizeTileURL(t,i)):r.push(t);return r}_makeAPIURL(e,t){const i="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",r=Be(n.API_URL);if(e.protocol=r.protocol,e.authority=r.authority,"http"===e.protocol){const t=e.params.indexOf("secure");t>=0&&e.params.splice(t,1);}if("/"!==r.path&&(e.path=`${r.path}${e.path}`),!n.REQUIRE_ACCESS_TOKEN)return Fe(e);if(t=t||n.ACCESS_TOKEN,!this._silenceAuthErrors){if(!t)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if("s"===t[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return e.params=e.params.filter((e=>-1===e.indexOf("access_token"))),e.params.push(`access_token=${t||""}`),Fe(e)}}function De(e){return 0===e.indexOf("mapbox:")}function Pe(e){return n.API_URL_REGEX.test(e)}function Re(e){return n.API_CDN_URL_REGEX.test(e)}function Le(e){return n.API_STYLE_REGEX.test(e)&&!ke(e)}function ke(e){return n.API_SPRITE_REGEX.test(e)}const Oe=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function Be(e){const t=e.match(Oe);if(!t)throw new Error("Unable to parse URL object");return {protocol:t[1],authority:t[2],path:t[3]||"/",params:t[4]?t[4].split("&"):[]}}function Fe(e){const t=e.params.length?`?${e.params.join("&")}`:"";return `${e.protocol}://${e.authority}${e.path}${t}`}const Ne="mapbox.eventData";function Ue(e){if(!e)return null;const i=e.split(".");if(!i||3!==i.length)return null;try{return JSON.parse(decodeURIComponent(t.atob(i[1]).split("").map((e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2))).join("")))}catch(e){return null}}class Ve{constructor(e){this.type=e,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null;}getStorageKey(e){const i=Ue(n.ACCESS_TOKEN);let r="";return r=i&&i.u?t.btoa(encodeURIComponent(i.u).replace(/%([0-9A-F]{2})/g,((e,t)=>String.fromCharCode(Number("0x"+t))))):n.ACCESS_TOKEN||"",e?`${Ne}.${e}:${r}`:`${Ne}:${r}`}fetchEventData(){const e=re("localStorage"),i=this.getStorageKey(),r=this.getStorageKey("uuid");if(e)try{const e=t.localStorage.getItem(i);e&&(this.eventData=JSON.parse(e));const n=t.localStorage.getItem(r);n&&(this.anonId=n);}catch(e){W("Unable to read from LocalStorage");}}saveEventData(){const e=re("localStorage"),i=this.getStorageKey(),r=this.getStorageKey("uuid");if(e)try{t.localStorage.setItem(r,this.anonId),Object.keys(this.eventData).length>=1&&t.localStorage.setItem(i,JSON.stringify(this.eventData));}catch(e){W("Unable to write to LocalStorage");}}processRequests(e){}postEvent(e,t,i,r){if(!n.EVENTS_URL)return;const o=Be(n.EVENTS_URL);o.params.push(`access_token=${r||n.ACCESS_TOKEN||""}`);const s={event:this.type,created:new Date(e).toISOString()},a=t?k(s,t):s,l={url:Fe(o),headers:{"Content-Type":"text/plain"},body:JSON.stringify([a])};this.pendingRequest=function(e,t){return be(k(e,{method:"POST"}),t)}(l,(e=>{this.pendingRequest=null,i(e),this.saveEventData(),this.processRequests(r);}));}queueRequest(e,t){this.queue.push(e),this.processRequests(t);}}const je=new class extends Ve{constructor(e){super("appUserTurnstile"),this._customAccessToken=e;}postTurnstileEvent(e,t){n.EVENTS_URL&&n.ACCESS_TOKEN&&Array.isArray(e)&&e.some((e=>De(e)||Pe(e)))&&this.queueRequest(Date.now(),t);}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const t=Ue(n.ACCESS_TOKEN),r=t?t.u:n.ACCESS_TOKEN;let o=r!==this.eventData.tokenU;V(this.anonId)||(this.anonId=N(),o=!0);const s=this.queue.shift();if(this.eventData.lastSuccess){const e=new Date(this.eventData.lastSuccess),t=new Date(s),i=(s-this.eventData.lastSuccess)/864e5;o=o||i>=1||i<-1||e.getDate()!==t.getDate();}else o=!0;o?this.postEvent(s,{sdkIdentifier:"mapbox-gl-js",sdkVersion:i,skuId:u,"enabled.telemetry":!1,userId:this.anonId},(e=>{e||(this.eventData.lastSuccess=s,this.eventData.tokenU=r);}),e):this.processRequests();}},Ge=je.postTurnstileEvent.bind(je),qe=new class extends Ve{constructor(){super("map.load"),this.success={},this.skuToken="";}postMapLoadEvent(e,t,i,r){this.skuToken=t,this.errorCb=r,n.EVENTS_URL&&(i||n.ACCESS_TOKEN?this.queueRequest({id:e,timestamp:Date.now()},i):this.errorCb(new Error(Ce)));}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{id:t,timestamp:r}=this.queue.shift();t&&this.success[t]||(this.anonId||this.fetchEventData(),V(this.anonId)||(this.anonId=N()),this.postEvent(r,{sdkIdentifier:"mapbox-gl-js",sdkVersion:i,skuId:u,skuToken:this.skuToken,userId:this.anonId},(e=>{e?this.errorCb(e):t&&(this.success[t]=!0);}),e));}},Ze=qe.postMapLoadEvent.bind(qe),$e=new class extends Ve{constructor(){super("gljs.performance");}postPerformanceEvent(e,t){n.EVENTS_URL&&(e||n.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:t},e);}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:r,performanceData:n}=this.queue.shift(),o=function(e){const r=t.performance.getEntriesByType("resource"),n=t.performance.getEntriesByType("mark"),o=function(e){const t={};if(e)for(const i in e)if("other"!==i)for(const r of e[i]){const e=`${i}ResolveRangeMin`,n=`${i}ResolveRangeMax`,o=`${i}RequestCount`,s=`${i}RequestCachedCount`;t[e]=Math.min(t[e]||1/0,r.startTime),t[n]=Math.max(t[n]||-1/0,r.responseEnd);const a=e=>{void 0===t[e]&&(t[e]=0),++t[e];};void 0!==r.transferSize&&0===r.transferSize&&a(s),a(o);}return t}(function(e,t){const i={};if(e)for(const r of e){const e=t(r);void 0===i[e]&&(i[e]=[]),i[e].push(r);}return i}(r,et)),s=t.devicePixelRatio,a=t.navigator.connection||t.navigator.mozConnection||t.navigator.webkitConnection,l={counters:[],metadata:[],attributes:[]},c=(e,t,i)=>{null!=i&&e.push({name:t,value:i.toString()});};for(const e in o)c(l.counters,e,o[e]);if(e.interactionRange[0]!==1/0&&e.interactionRange[1]!==-1/0&&(c(l.counters,"interactionRangeMin",e.interactionRange[0]),c(l.counters,"interactionRangeMax",e.interactionRange[1])),n)for(const e of Object.keys(Je)){const t=Je[e],i=n.find((e=>e.name===t));i&&c(l.counters,t,i.startTime);}return c(l.counters,"visibilityHidden",e.visibilityHidden),c(l.attributes,"style",function(e){if(e)for(const t of e){const e=t.name.split("?")[0];if(Le(e)){const t=e.split("/").slice(-2);if(2===t.length)return `mapbox://styles/${t[0]}/${t[1]}`}}}(r)),c(l.attributes,"terrainEnabled",e.terrainEnabled?"true":"false"),c(l.attributes,"fogEnabled",e.fogEnabled?"true":"false"),c(l.attributes,"projection",e.projection),c(l.attributes,"zoom",e.zoom),c(l.metadata,"devicePixelRatio",s),c(l.metadata,"connectionEffectiveType",a?a.effectiveType:void 0),c(l.metadata,"navigatorUserAgent",t.navigator.userAgent),c(l.metadata,"screenWidth",t.screen.width),c(l.metadata,"screenHeight",t.screen.height),c(l.metadata,"windowWidth",t.innerWidth),c(l.metadata,"windowHeight",t.innerHeight),c(l.metadata,"mapWidth",e.width/s),c(l.metadata,"mapHeight",e.height/s),c(l.metadata,"webglRenderer",e.renderer),c(l.metadata,"webglVendor",e.vendor),c(l.metadata,"sdkVersion",i),c(l.metadata,"sdkIdentifier","mapbox-gl-js"),l}(n);for(const e of o.metadata);for(const e of o.counters);for(const e of o.attributes);this.postEvent(r,o,(()=>{}),e);}},He=$e.postPerformanceEvent.bind($e),We=new class extends Ve{constructor(){super("map.auth"),this.success={},this.skuToken="";}getSession(e,t,i,r){if(!n.API_URL||!n.SESSION_PATH)return;const o=Be(n.API_URL+n.SESSION_PATH);o.params.push(`sku=${t||""}`),o.params.push(`access_token=${r||n.ACCESS_TOKEN||""}`);const s={url:Fe(o),headers:{"Content-Type":"text/plain"}};this.pendingRequest=function(e,t){return be(k(e,{method:"GET"}),t)}(s,(e=>{this.pendingRequest=null,i(e),this.saveEventData(),this.processRequests(r);}));}getSessionAPI(e,t,i,r){this.skuToken=t,this.errorCb=r,n.SESSION_PATH&&n.API_URL&&(i||n.ACCESS_TOKEN?this.queueRequest({id:e,timestamp:Date.now()},i):this.errorCb(new Error(Ce)));}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{id:t,timestamp:i}=this.queue.shift();t&&this.success[t]||this.getSession(i,this.skuToken,(e=>{e?this.errorCb(e):t&&(this.success[t]=!0);}),e);}},Xe=We.getSessionAPI.bind(We),Ye=new Set;function Ke(e,t){t?Ye.add(e):Ye.delete(e);}const Je={create:"create",load:"load",fullLoad:"fullLoad"},Qe={mark(e){t.performance.mark(e);},measure(e,i,r){t.performance.measure(e,i,r);}};function et(e){const t=e.name.split("?")[0];return Re(t)&&t.includes("mapbox-gl.js")?"javascript":Re(t)&&t.includes("mapbox-gl.css")?"css":function(e){return n.API_FONTS_REGEX.test(e)}(t)?"fontRange":ke(t)?"sprite":Le(t)?"style":function(e){return n.API_TILEJSON_REGEX.test(e)}(t)?"tilejson":"other"}const tt=t.performance;function it(e){const t=e?e.url.toString():void 0;return tt.getEntriesByName(t)}var rt=nt;function nt(e){return !function(e){return "undefined"==typeof window||"undefined"==typeof document?"not a browser":Array.prototype&&Array.prototype.every&&Array.prototype.filter&&Array.prototype.forEach&&Array.prototype.indexOf&&Array.prototype.lastIndexOf&&Array.prototype.map&&Array.prototype.some&&Array.prototype.reduce&&Array.prototype.reduceRight&&Array.isArray?Function.prototype&&Function.prototype.bind?Object.keys&&Object.create&&Object.getPrototypeOf&&Object.getOwnPropertyNames&&Object.isSealed&&Object.isFrozen&&Object.isExtensible&&Object.getOwnPropertyDescriptor&&Object.defineProperty&&Object.defineProperties&&Object.seal&&Object.freeze&&Object.preventExtensions?"JSON"in window&&"parse"in JSON&&"stringify"in JSON?function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return !1;var e,t,i=new Blob([""],{type:"text/javascript"}),r=URL.createObjectURL(i);try{t=new Worker(r),e=!0;}catch(t){e=!1;}return t&&t.terminate(),URL.revokeObjectURL(r),e}()?"Uint8ClampedArray"in window?ArrayBuffer.isView?function(){var e=document.createElement("canvas");e.width=e.height=1;var t=e.getContext("2d");if(!t)return !1;var i=t.getImageData(0,0,1,1);return i&&i.width===e.width}()?(void 0===ot[t=e&&e.failIfMajorPerformanceCaveat]&&(ot[t]=function(e){var t,i=function(e){var t=document.createElement("canvas"),i=Object.create(nt.webGLContextAttributes);return i.failIfMajorPerformanceCaveat=e,t.getContext("webgl",i)||t.getContext("experimental-webgl",i)}(e);if(!i)return !1;try{t=i.createShader(i.VERTEX_SHADER);}catch(e){return !1}return !(!t||i.isContextLost())&&(i.shaderSource(t,"void main() {}"),i.compileShader(t),!0===i.getShaderParameter(t,i.COMPILE_STATUS))}(t)),ot[t]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL support"):"insufficient Canvas/getImageData support":"insufficient ArrayBuffer support":"insufficient Uint8ClampedArray support":"insufficient worker support":"insufficient JSON support":"insufficient Object support":"insufficient Function support":"insufficent Array support";var t;}(e)}var ot={};let st,at,lt,ct;nt.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0};const ht={now:()=>void 0!==lt?lt:t.performance.now(),setNow(e){lt=e;},restoreNow(){lt=void 0;},frame(e){const i=t.requestAnimationFrame(e);return {cancel:()=>t.cancelAnimationFrame(i)}},getImageData(e,i=0){const{width:r,height:n}=e;ct||(ct=t.document.createElement("canvas"));const o=ct.getContext("2d",{willReadFrequently:!0});if(!o)throw new Error("failed to create canvas 2d context");return (r>ct.width||n>ct.height)&&(ct.width=r,ct.height=n),o.clearRect(-i,-i,r+2*i,n+2*i),o.drawImage(e,0,0,r,n),o.getImageData(-i,-i,r+2*i,n+2*i)},resolveURL:e=>(st||(st=t.document.createElement("a")),st.href=e,st.href),get devicePixelRatio(){return t.devicePixelRatio},get prefersReducedMotion(){return !!t.matchMedia&&(null==at&&(at=t.matchMedia("(prefers-reduced-motion: reduce)")),at.matches)}};function ut(e,i,r){const n=t.document.createElement(e);return void 0!==i&&(n.className=i),r&&r.appendChild(n),n}function dt(e,i,r){const n=t.document.createElementNS("http://www.w3.org/2000/svg",e);for(const e of Object.keys(i))n.setAttributeNS(null,e,i[e]);return r&&r.appendChild(n),n}const pt=t.document&&t.document.documentElement.style,ft=pt&&void 0!==pt.userSelect?"userSelect":"WebkitUserSelect";let mt;function _t(){pt&&ft&&(mt=pt[ft],pt[ft]="none");}function gt(){pt&&ft&&(pt[ft]=mt);}function yt(e){e.preventDefault(),e.stopPropagation(),t.removeEventListener("click",yt,!0);}function xt(){t.addEventListener("click",yt,!0),t.setTimeout((()=>{t.removeEventListener("click",yt,!0);}),0);}function vt(e,t){const i=e.getBoundingClientRect();return Tt(e,i,t)}function bt(e,t){const i=e.getBoundingClientRect(),r=[];for(let n=0;n=0?0:e.button}function Tt(e,t,i){const r=e.offsetWidth===t.width?1:e.offsetWidth/t.width;return new y((i.clientX-t.left)*r,(i.clientY-t.top)*r)}function Et(e,t,i){i[e]&&-1!==i[e].indexOf(t)||(i[e]=i[e]||[],i[e].push(t));}function Mt(e,t,i){if(i&&i[e]){const r=i[e].indexOf(t);-1!==r&&i[e].splice(r,1);}}class At{constructor(e,t={}){k(this,t),this.type=e;}}class St extends At{constructor(e,t={}){super("error",k({error:e},t));}}class It{on(e,t){return this._listeners=this._listeners||{},Et(e,t,this._listeners),this}off(e,t){return Mt(e,t,this._listeners),Mt(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners=this._oneTimeListeners||{},Et(e,t,this._oneTimeListeners),this):new Promise((t=>this.once(e,t)))}fire(e,t){"string"==typeof e&&(e=new At(e,t||{}));const i=e.type;if(this.listens(i)){e.target=this;const t=this._listeners&&this._listeners[i]?this._listeners[i].slice():[];for(const i of t)i.call(this,e);const r=this._oneTimeListeners&&this._oneTimeListeners[i]?this._oneTimeListeners[i].slice():[];for(const t of r)Mt(i,t,this._oneTimeListeners),t.call(this,e);const n=this._eventedParent;n&&(k(e,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),n.fire(e));}else e instanceof St&&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,t){return this._eventedParent=e,this._eventedParentData=t,this}}var Ct=JSON.parse('{"$version":8,"$root":{"version":{"required":true,"type":"enum","values":[8]},"fragment":{"type":"boolean"},"name":{"type":"string"},"metadata":{"type":"*"},"center":{"type":"array","value":"number"},"zoom":{"type":"number"},"bearing":{"type":"number","default":0,"period":360},"pitch":{"type":"number","default":0},"light":{"type":"light"},"lights":{"required":false,"type":"array","value":"light-3d"},"terrain":{"type":"terrain"},"fog":{"type":"fog"},"camera":{"type":"camera"},"imports":{"type":"array","value":"import"},"schema":{"type":"schema"},"sources":{"required":true,"type":"sources"},"sprite":{"type":"string"},"glyphs":{"type":"string","default":"mapbox://fonts/mapbox/{fontstack}/{range}.pbf"},"transition":{"type":"transition"},"projection":{"type":"projection"},"layers":{"required":true,"type":"array","value":"layer"},"models":{"type":"models"}},"model":{"type":"string","required":true},"import":{"id":{"type":"string","required":true},"url":{"type":"string","required":true},"config":{"type":"config"},"data":{"type":"$root"}},"config":{"*":{"type":"*"}},"schema":{"*":{"type":"option"}},"option":{"default":{"type":"*","required":true},"type":{"type":"enum","values":{"string":1,"number":1,"boolean":1,"color":1}},"array":{"type":"boolean"},"minValue":{"type":"number"},"maxValue":{"type":"number"},"stepValue":{"type":"number"},"values":{"type":"array","value":"*"},"metadata":{"type":"*"}},"models":{"*":{"type":"model"}},"light-3d":{"id":{"type":"string","required":true},"properties":{"type":"properties"},"type":{"type":"enum","values":{"ambient":{},"directional":{},"flat":{}}}},"properties":["properties_light_directional","properties_light_ambient","properties_light_flat"],"properties_light_directional":{"direction":{"type":"array","default":[210,30],"minimum":[0,0],"maximum":[360,90],"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"cast-shadows":{"type":"boolean","default":false,"expression":{},"property-type":"data-constant"},"shadow-intensity":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"properties_light_ambient":{"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"properties_light_flat":{"anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"property-type":"data-constant","expression":{"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"sources":{"*":{"type":"source"}},"source":["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image","source_model"],"source_vector":{"type":{"required":true,"type":"enum","values":{"vector":1}},"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":1,"tms":1},"default":"xyz"},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"attribution":{"type":"string"},"promoteId":{"type":"promoteId"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster":{"type":{"required":true,"type":"enum","values":{"raster":1}},"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},"scheme":{"type":"enum","values":{"xyz":1,"tms":1},"default":"xyz"},"attribution":{"type":"string"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_dem":{"type":{"required":true,"type":"enum","values":{"raster-dem":1}},"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},"attribution":{"type":"string"},"encoding":{"type":"enum","values":{"terrarium":1,"mapbox":1},"default":"mapbox"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_geojson":{"type":{"required":true,"type":"enum","values":{"geojson":1}},"data":{"type":"*"},"maxzoom":{"type":"number","default":18},"attribution":{"type":"string"},"buffer":{"type":"number","default":128,"maximum":512,"minimum":0},"filter":{"type":"*"},"tolerance":{"type":"number","default":0.375},"cluster":{"type":"boolean","default":false},"clusterRadius":{"type":"number","default":50,"minimum":0},"clusterMaxZoom":{"type":"number"},"clusterMinPoints":{"type":"number"},"clusterProperties":{"type":"*"},"lineMetrics":{"type":"boolean","default":false},"generateId":{"type":"boolean","default":false},"promoteId":{"type":"promoteId"}},"source_video":{"type":{"required":true,"type":"enum","values":{"video":1}},"urls":{"required":true,"type":"array","value":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_image":{"type":{"required":true,"type":"enum","values":{"image":1}},"url":{"required":false,"type":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_model":{"type":{"required":true,"type":"enum","values":{"model":1,"batched-model":1}},"maxzoom":{"type":"number","default":18},"minzoom":{"type":"number","default":0},"tiles":{"type":"array","value":"string"}},"layer":{"id":{"type":"string","required":true},"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"raster":{},"hillshade":{},"model":{},"background":{},"sky":{},"slot":{}},"required":true},"metadata":{"type":"*"},"source":{"type":"string"},"source-layer":{"type":"string"},"slot":{"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_background","layout_sky","layout_model"],"layout_background":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_sky":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_model":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"},"model-id":{"type":"string","default":"","property-type":"data-driven","expression":{"parameters":["zoom","feature"]}}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_circle":{"circle-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_heatmap":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_fill-extrusion":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"},"fill-extrusion-edge-radius":{"type":"number","private":true,"default":0,"minimum":0,"maximum":1,"expression":{},"property-type":"constant"}},"layout_line":{"line-cap":{"type":"enum","values":{"butt":1,"round":1,"square":1},"default":"butt","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-join":{"type":"enum","values":{"bevel":1,"round":1,"miter":1},"default":"miter","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-round-limit":{"type":"number","default":1.05,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_symbol":{"symbol-placement":{"type":"enum","values":{"point":1,"line":1,"line-center":1},"default":"point","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"symbol-spacing":{"type":"number","default":250,"minimum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","values":{"auto":1,"viewport-y":1,"source":1},"default":"auto","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"symbol-z-elevate":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-optional":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-size":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{"type":"enum","values":{"none":1,"width":1,"height":1,"both":1},"default":"none","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit-padding":{"type":"array","value":"number","length":4,"default":[0,0,0,0],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-image":{"type":"resolvedImage","tokens":true,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{"type":"number","default":0,"period":360,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{"type":"number","default":2,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-keep-upright":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-offset":{"type":"array","value":"number","length":2,"default":[0,0],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{"type":"enum","values":{"center":1,"left":1,"right":1,"top":1,"bottom":1,"top-left":1,"top-right":1,"bottom-left":1,"bottom-right":1},"default":"center","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-field":{"type":"formatted","default":"","tokens":true,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-font":{"type":"array","value":"string","default":["Open Sans Regular","Arial Unicode MS Regular"],"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size":{"type":"number","default":16,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{"type":"number","default":10,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-justify":{"type":"enum","values":{"auto":1,"left":1,"center":1,"right":1},"default":"center","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{"type":"number","default":0,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["zoom","feature"]}},"text-variable-anchor":{"type":"array","value":"enum","values":{"center":1,"left":1,"right":1,"top":1,"bottom":1,"top-left":1,"top-right":1,"bottom-left":1,"bottom-right":1},"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-anchor":{"type":"enum","values":{"center":1,"left":1,"right":1,"top":1,"bottom":1,"top-left":1,"top-right":1,"bottom-left":1,"bottom-right":1},"default":"center","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{"type":"number","default":45,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":1,"vertical":1},"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-rotate":{"type":"number","default":0,"period":360,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-padding":{"type":"number","default":2,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-keep-upright":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-transform":{"type":"enum","values":{"none":1,"uppercase":1,"lowercase":1},"default":"none","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-offset":{"type":"array","value":"number","length":2,"default":[0,0],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-optional":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_raster":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_hillshade":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"filter":{"type":"array","value":"*"},"filter_symbol":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature","pitch","distance-from-center"]}},"filter_fill":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_line":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_circle":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_fill-extrusion":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_heatmap":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_operator":{"type":"enum","values":{"==":1,"!=":1,">":1,">=":1,"<":1,"<=":1,"in":1,"!in":1,"all":1,"any":1,"none":1,"has":1,"!has":1}},"geometry_type":{"type":"enum","values":{"Point":1,"LineString":1,"Polygon":1}},"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":1,"exponential":1,"interval":1,"categorical":1},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":1,"lab":1,"hcl":1},"default":"rgb"},"default":{"type":"*","required":false}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"high-color":{"type":"color","property-type":"data-constant","default":"#245cdf","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"space-color":{"type":"color","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"horizon-blend":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,0.2,7,0.1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"star-intensity":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],5,0.35,6,0],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vertical-range":{"type":"array","default":[0,0],"minimum":0,"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}}},"camera":{"camera-projection":{"type":"enum","values":{"perspective":1,"orthographic":1},"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"default":"perspective","property-type":"data-constant"}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"property-type":"data-constant","expression":{"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":1,"equalEarth":1,"equirectangular":1,"lambertConformalConic":1,"mercator":1,"naturalEarth":1,"winkelTripel":1,"globe":1},"default":"mercator","required":true},"center":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-180,-90],"maximum":[180,90]},"parallels":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-90,-90],"maximum":[90,90]}},"terrain":{"source":{"type":"string","required":true},"exaggeration":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background","paint_sky","paint_model"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"fill-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-ambient-occlusion-intensity":{"property-type":"data-constant","type":"number","private":true,"default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-radius":{"property-type":"data-constant","type":"number","private":true,"default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-wall-radius":{"property-type":"data-constant","type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-radius":{"property-type":"data-constant","type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-attenuation":{"property-type":"data-constant","type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-flood-light-color":{"property-type":"data-constant","type":"color","default":"#ffffff","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-intensity":{"property-type":"data-constant","type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-wall-radius":{"property-type":"data-driven","type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-radius":{"property-type":"data-driven","type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-attenuation":{"property-type":"data-constant","type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-vertical-scale":{"property-type":"data-constant","type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-rounded-roof":{"property-type":"data-constant","type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-extrusion-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{},"property-type":"data-constant"}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-gradient":{"type":"color","expression":{"interpolated":true,"parameters":["line-progress"]},"property-type":"color-ramp"},"line-trim-offset":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1],"property-type":"constant"},"line-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"line-border-width":{"type":"number","private":true,"default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-border-color":{"type":"color","private":true,"default":"rgba(0, 0, 0, 0)","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"expression":{"interpolated":true,"parameters":["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-driven"},"text-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-image-cross-fade":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"transition":true},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","transition":true,"overridable":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-color":{"type":"color","expression":{"interpolated":true,"parameters":["raster-value"]},"property-type":"color-ramp"},"raster-color-mix":{"type":"array","default":[0.2126,0.7152,0.0722,0],"length":4,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-color-range":{"type":"array","default":[0,1],"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-resampling":{"type":"enum","values":{"linear":1,"nearest":1},"default":"linear","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"hillshade-accent-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"hillshade-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"}},"paint_background":{"background-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":1,"atmosphere":1},"default":"atmosphere","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun-intensity":{"type":"number","default":10,"minimum":0,"maximum":100,"property-type":"data-constant"},"sky-gradient-center":{"type":"array","value":"number","default":[0,0],"length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient-radius":{"type":"number","default":90,"minimum":0,"maximum":180,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"expression":{"interpolated":true,"parameters":["sky-radial-progress"]},"property-type":"color-ramp"},"sky-atmosphere-halo-color":{"type":"color","default":"white","property-type":"data-constant"},"sky-atmosphere-color":{"type":"color","default":"white","property-type":"data-constant"},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_model":{"model-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"model-rotation":{"type":"array","value":"number","length":3,"default":[0,0,0],"period":360,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-scale":{"type":"array","value":"number","length":3,"default":[1,1,1],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-translation":{"type":"array","value":"number","length":3,"default":[0,0,0],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-color":{"type":"color","default":"#ffffff","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":true},"model-color-mix-intensity":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-type":{"type":"enum","values":{"common-3d":1,"location-indicator":1},"default":"common-3d","property-type":"data-constant"},"model-cast-shadows":{"type":"boolean","default":true,"expression":{},"property-type":"data-constant"},"model-receive-shadows":{"type":"boolean","default":true,"expression":{},"property-type":"data-constant"},"model-ambient-occlusion-intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant","transition":true},"model-emissive-strength":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-roughness":{"type":"number","default":1,"minimum":0,"maximum":1,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state"]},"transition":true},"model-height-based-emissive-strength-multiplier":{"type":"array","default":[1,1,1,1,0],"length":5,"value":"number","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{},"property-type":"data-constant"}},"transition":{"duration":{"type":"number","default":300,"minimum":0},"delay":{"type":"number","default":0,"minimum":0}},"property-type":{"data-driven":{"type":"property-type"},"color-ramp":{"type":"property-type"},"data-constant":{"type":"property-type"},"constant":{"type":"property-type"}},"promoteId":{"*":{"type":"string"}}}');class zt{constructor(e,t,i,r){this.message=(e?`${e}: `:"")+i,r&&(this.identifier=r),null!=t&&t.__line__&&(this.line=t.__line__);}}class Dt extends zt{}function Pt(e,...t){for(const i of t)for(const t in i)e[t]=i[t];return e}function Rt(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function Lt(e){if(Array.isArray(e))return e.map(Lt);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){const t={};for(const i in e)t[i]=Lt(e[i]);return t}return Rt(e)}class kt extends Error{constructor(e,t){super(t),this.message=t,this.key=e;}}var Ot=kt;class Bt{constructor(e,t=[]){this.parent=e,this.bindings={};for(const[e,i]of t)this.bindings[e]=i;}concat(e){return new Bt(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)}}var Ft=Bt;const Nt={kind:"null"},Ut={kind:"number"},Vt={kind:"string"},jt={kind:"boolean"},Gt={kind:"color"},qt={kind:"object"},Zt={kind:"value"},$t={kind:"collator"},Ht={kind:"formatted"},Wt={kind:"resolvedImage"};function Xt(e,t){return {kind:"array",itemType:e,N:t}}function Yt(e){if("array"===e.kind){const t=Yt(e.itemType);return "number"==typeof e.N?`array<${t}, ${e.N}>`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}const Kt=[Nt,Ut,Vt,jt,Gt,Ht,qt,Xt(Zt),Wt];function Jt(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!Jt(e.itemType,t.itemType))&&("number"!=typeof e.N||e.N===t.N))return null}else {if(e.kind===t.kind)return null;if("value"===e.kind)for(const e of Kt)if(!Jt(e,t))return null}return `Expected ${Yt(e)} but found ${Yt(t)} instead.`}function Qt(e,t){return t.some((t=>t.kind===e.kind))}function ei(e,t){return t.some((t=>"null"===t?null===e:"array"===t?Array.isArray(e):"object"===t?e&&!Array.isArray(e)&&"object"==typeof e:t===typeof e))}var ti,ii={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function ri(e){return (e=Math.round(e))<0?0:e>255?255:e}function ni(e){return ri("%"===e[e.length-1]?parseFloat(e)/100*255:parseInt(e))}function oi(e){return (t="%"===e[e.length-1]?parseFloat(e)/100:parseFloat(e))<0?0:t>1?1:t;var t;}function si(e,t,i){return i<0?i+=1:i>1&&(i-=1),6*i<1?e+(t-e)*i*6:2*i<1?t:3*i<2?e+(t-e)*(2/3-i)*6:e}try{ti={}.parseCSSColor=function(e){var t,i=e.replace(/ /g,"").toLowerCase();if(i in ii)return ii[i].slice();if("#"===i[0])return 4===i.length?(t=parseInt(i.substr(1),16))>=0&&t<=4095?[(3840&t)>>4|(3840&t)>>8,240&t|(240&t)>>4,15&t|(15&t)<<4,1]:null:7===i.length&&(t=parseInt(i.substr(1),16))>=0&&t<=16777215?[(16711680&t)>>16,(65280&t)>>8,255&t,1]:null;var r=i.indexOf("("),n=i.indexOf(")");if(-1!==r&&n+1===i.length){var o=i.substr(0,r),s=i.substr(r+1,n-(r+1)).split(","),a=1;switch(o){case"rgba":if(4!==s.length)return null;a=oi(s.pop());case"rgb":return 3!==s.length?null:[ni(s[0]),ni(s[1]),ni(s[2]),a];case"hsla":if(4!==s.length)return null;a=oi(s.pop());case"hsl":if(3!==s.length)return null;var l=(parseFloat(s[0])%360+360)%360/360,c=oi(s[1]),h=oi(s[2]),u=h<=.5?h*(c+1):h+c-h*c,d=2*h-u;return [ri(255*si(d,u,l+1/3)),ri(255*si(d,u,l)),ri(255*si(d,u,l-1/3)),a];default:return null}}return null};}catch(e){}class ai{constructor(e,t,i,r=1){this.r=e,this.g=t,this.b=i,this.a=r;}static parse(e){if(!e)return;if(e instanceof ai)return e;if("string"!=typeof e)return;const t=ti(e);return t?new ai(t[0]/255*t[3],t[1]/255*t[3],t[2]/255*t[3],t[3]):void 0}toString(){const[e,t,i,r]=this.toArray();return `rgba(${Math.round(e)},${Math.round(t)},${Math.round(i)},${r})`}toArray(){const{r:e,g:t,b:i,a:r}=this;return 0===r?[0,0,0,0]:[255*e/r,255*t/r,255*i/r,r]}toArray01(){const{r:e,g:t,b:i,a:r}=this;return 0===r?[0,0,0,0]:[e/r,t/r,i/r,r]}toArray01Scaled(e){const{r:t,g:i,b:r,a:n}=this;return 0===n?[0,0,0]:[t/n*e,i/n*e,r/n*e]}toArray01PremultipliedAlpha(){const{r:e,g:t,b:i,a:r}=this;return [e,t,i,r]}toArray01Linear(){const{r:e,g:t,b:i,a:r}=this;return 0===r?[0,0,0,0]:[Math.pow(e/r,2.2),Math.pow(t/r,2.2),Math.pow(i/r,2.2),r]}}ai.black=new ai(0,0,0,1),ai.white=new ai(1,1,1,1),ai.transparent=new ai(0,0,0,0),ai.red=new ai(1,0,0,1),ai.blue=new ai(0,0,1,1);var li=ai;class ci{constructor(e,t,i){this.sensitivity=e?t?"variant":"case":t?"accent":"base",this.locale=i,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"});}compare(e,t){return this.collator.compare(e,t)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class hi{constructor(e,t,i,r,n){this.text=e.normalize?e.normalize():e,this.image=t,this.scale=i,this.fontStack=r,this.textColor=n;}}class ui{constructor(e){this.sections=e;}static fromString(e){return new ui([new hi(e,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((e=>0!==e.text.length||e.image&&0!==e.image.namePrimary.length))}static factory(e){return e instanceof ui?e:ui.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map((e=>e.text)).join("")}serialize(){const e=["format"];for(const t of this.sections){if(t.image){e.push(["image",t.image.namePrimary]);continue}e.push(t.text);const i={};t.fontStack&&(i["text-font"]=["literal",t.fontStack.split(",")]),t.scale&&(i["font-scale"]=t.scale),t.textColor&&(i["text-color"]=["rgba"].concat(t.textColor.toArray())),e.push(i);}return e}}class di{constructor(e){this.namePrimary=e.namePrimary,e.nameSecondary&&(this.nameSecondary=e.nameSecondary),this.available=e.available;}toString(){return this.nameSecondary?`[${this.namePrimary},${this.nameSecondary}]`:this.namePrimary}static fromString(e,t){return e?new di({namePrimary:e,nameSecondary:t,available:!1}):null}serialize(){return this.nameSecondary?["image",this.namePrimary,this.nameSecondary]:["image",this.namePrimary]}}function pi(e,t,i,r){return "number"==typeof e&&e>=0&&e<=255&&"number"==typeof t&&t>=0&&t<=255&&"number"==typeof i&&i>=0&&i<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid rgba value [${[e,t,i,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof r?[e,t,i,r]:[e,t,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function fi(e){if(null===e)return !0;if("string"==typeof e)return !0;if("boolean"==typeof e)return !0;if("number"==typeof e)return !0;if(e instanceof li)return !0;if(e instanceof ci)return !0;if(e instanceof ui)return !0;if(e instanceof di)return !0;if(Array.isArray(e)){for(const t of e)if(!fi(t))return !1;return !0}if("object"==typeof e){for(const t in e)if(!fi(e[t]))return !1;return !0}return !1}function mi(e){if(null===e)return Nt;if("string"==typeof e)return Vt;if("boolean"==typeof e)return jt;if("number"==typeof e)return Ut;if(e instanceof li)return Gt;if(e instanceof ci)return $t;if(e instanceof ui)return Ht;if(e instanceof di)return Wt;if(Array.isArray(e)){const t=e.length;let i;for(const t of e){const e=mi(t);if(i){if(i===e)continue;i=Zt;break}i=e;}return Xt(i||Zt,t)}return qt}function _i(e){const t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof li||e instanceof ui||e instanceof di?e.toString():JSON.stringify(e)}class gi{constructor(e,t){this.type=e,this.value=t;}static parse(e,t){if(2!==e.length)return t.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!fi(e[1]))return t.error("invalid value");const i=e[1];let r=mi(i);const n=t.expectedType;return "array"!==r.kind||0!==r.N||!n||"array"!==n.kind||"number"==typeof n.N&&0!==n.N||(r=n),new gi(r,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return !0}serialize(){return "array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof li?["rgba"].concat(this.value.toArray()):this.value instanceof ui?this.value.serialize():this.value}}var yi=gi,xi=class{constructor(e){this.name="ExpressionEvaluationError",this.message=e;}toJSON(){return this.message}};const vi={string:Vt,number:Ut,boolean:jt,object:qt};class bi{constructor(e,t){this.type=e,this.args=t;}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");let i,r=1;const n=e[0];if("array"===n){let n,o;if(e.length>2){const i=e[1];if("string"!=typeof i||!(i in vi)||"object"===i)return t.error('The item type argument of "array" must be one of string, number, boolean',1);n=vi[i],r++;}else n=Zt;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return t.error('The length argument to "array" must be a positive integer literal',2);o=e[2],r++;}i=Xt(n,o);}else i=vi[n];const o=[];for(;re.outputDefined()))}serialize(){const e=this.type,t=[e.kind];if("array"===e.kind){const i=e.itemType;if("string"===i.kind||"number"===i.kind||"boolean"===i.kind){t.push(i.kind);const r=e.N;("number"==typeof r||this.args.length>1)&&t.push(r);}}return t.concat(this.args.map((e=>e.serialize())))}}var wi=bi;class Ti{constructor(e){this.type=Ht,this.sections=e;}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const i=e[1];if(!Array.isArray(i)&&"object"==typeof i)return t.error("First argument must be an image or text section.");const r=[];let n=!1;for(let i=1;i<=e.length-1;++i){const o=e[i];if(n&&"object"==typeof o&&!Array.isArray(o)){n=!1;let e=null;if(o["font-scale"]&&(e=t.parse(o["font-scale"],1,Ut),!e))return null;let i=null;if(o["text-font"]&&(i=t.parse(o["text-font"],1,Xt(Vt)),!i))return null;let s=null;if(o["text-color"]&&(s=t.parse(o["text-color"],1,Gt),!s))return null;const a=r[r.length-1];a.scale=e,a.font=i,a.textColor=s;}else {const o=t.parse(e[i],1,Zt);if(!o)return null;const s=o.type.kind;if("string"!==s&&"value"!==s&&"null"!==s&&"resolvedImage"!==s)return t.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");n=!0,r.push({content:o,scale:null,font:null,textColor:null});}}return new Ti(r)}evaluate(e){return new ui(this.sections.map((t=>{const i=t.content.evaluate(e);return mi(i)===Wt?new hi("",i,null,null,null):new hi(_i(i),null,t.scale?t.scale.evaluate(e):null,t.font?t.font.evaluate(e).join(","):null,t.textColor?t.textColor.evaluate(e):null)})))}eachChild(e){for(const t of this.sections)e(t.content),t.scale&&e(t.scale),t.font&&e(t.font),t.textColor&&e(t.textColor);}outputDefined(){return !1}serialize(){const e=["format"];for(const t of this.sections){e.push(t.content.serialize());const i={};t.scale&&(i["font-scale"]=t.scale.serialize()),t.font&&(i["text-font"]=t.font.serialize()),t.textColor&&(i["text-color"]=t.textColor.serialize()),e.push(i);}return e}}class Ei{constructor(e,t){this.type=Wt,this.inputPrimary=e,this.inputSecondary=t;}static parse(e,t){if(e.length<2)return t.error("Expected two or more arguments.");const i=t.parse(e[1],1,Vt);if(!i)return t.error("No image name provided.");if(2===e.length)return new Ei(i);const r=t.parse(e[2],1,Vt);return r?new Ei(i,r):t.error("Secondary image variant is not a string.")}evaluate(e){const t=di.fromString(this.inputPrimary.evaluate(e),this.inputSecondary?this.inputSecondary.evaluate(e):void 0);return t&&e.availableImages&&(t.available=e.availableImages.indexOf(t.namePrimary)>-1,t.nameSecondary&&t.available&&e.availableImages&&(t.available=e.availableImages.indexOf(t.nameSecondary)>-1)),t}eachChild(e){e(this.inputPrimary),this.inputSecondary&&e(this.inputSecondary);}outputDefined(){return !1}serialize(){return this.inputSecondary?["image",this.inputPrimary.serialize(),this.inputSecondary.serialize()]:["image",this.inputPrimary.serialize()]}}function Mi(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}const Ai={"to-boolean":jt,"to-color":Gt,"to-number":Ut,"to-string":Vt};class Si{constructor(e,t){this.type=e,this.args=t;}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const i=e[0],r=[];let n=Nt;if("to-array"===i){if(!Array.isArray(e[1]))return null;const i=e[1].length;if(t.expectedType){if("array"!==t.expectedType.kind)return t.error(`Expected ${t.expectedType.kind} but found array.`);n=Xt(t.expectedType.itemType,i);}else {if(!(i>0&&fi(e[1][0])))return null;n=Xt(mi(e[1][0]),i);}for(let o=0;o4?`Invalid rbga value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:pi(t[0],t[1],t[2],t[3]),!i))return new li(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new xi(i||`Could not parse color from value '${"string"==typeof t?t:String(JSON.stringify(t))}'`)}if("number"===this.type.kind){let t=null;for(const i of this.args){if(t=i.evaluate(e),null===t)return 0;const r=Number(t);if(!isNaN(r))return r}throw new xi(`Could not convert ${JSON.stringify(t)} to number.`)}return "formatted"===this.type.kind?ui.fromString(_i(this.args[0].evaluate(e))):"resolvedImage"===this.type.kind?di.fromString(_i(this.args[0].evaluate(e))):"array"===this.type.kind?this.args.map((t=>t.evaluate(e))):_i(this.args[0].evaluate(e))}eachChild(e){this.args.forEach(e);}outputDefined(){return this.args.every((e=>e.outputDefined()))}serialize(){if("formatted"===this.type.kind)return new Ti([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new Ei(this.args[0]).serialize();const e="array"===this.type.kind?[]:[`to-${this.type.kind}`];return this.eachChild((t=>{e.push(t.serialize());})),e}}var Ii=Si;const Ci=["Unknown","Point","LineString","Polygon"];var zi=class{constructor(e){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null,this.options=e;}id(){return this.feature&&void 0!==this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Ci[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||{}}measureLight(e){return this.globals.brightness||0}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const e=this.featureDistanceData.center,t=this.featureDistanceData.scale,{x:i,y:r}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(i*t-e[0])+this.featureDistanceData.bearing[1]*(r*t-e[1])}return 0}parseColor(e){let t=this._parseColorCache[e];return t||(t=this._parseColorCache[e]=li.parse(e)),t}getConfig(e){return this.options?this.options.get(e):null}};class Di{constructor(e,t,i,r){this.name=e,this.type=t,this._evaluate=i,this.args=r;}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e);}outputDefined(){return !1}serialize(){return [this.name].concat(this.args.map((e=>e.serialize())))}static parse(e,t){const i=e[0],r=Di.definitions[i];if(!r)return t.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const n=Array.isArray(r)?r[0]:r.type,o=Array.isArray(r)?[[r[1],r[2]]]:r.overloads,s=o.filter((([t])=>!Array.isArray(t)||t.length===e.length-1));let a=null;for(const[r,o]of s){a=new Gr(t.registry,t.path,null,t.scope,void 0,t.options);const s=[];let l=!1;for(let t=1;t{return t=e,Array.isArray(t)?`(${t.map(Yt).join(", ")})`:`(${Yt(t.type)}...)`;var t;})).join(" | "),r=[];for(let i=1;in;){if(o-n>600){var a=o-n+1,l=r-n+1,c=Math.log(a),h=.5*Math.exp(2*c/3),u=.5*Math.sqrt(c*h*(a-h)/a)*(l-a/2<0?-1:1);e(i,r,Math.max(n,Math.floor(r-l*h/a+u)),Math.min(o,Math.floor(r+(a-l)*h/a+u)),s);}var d=i[r],p=n,f=o;for(t(i,n,r),s(i[o],d)>0&&t(i,n,o);p0;)f--;}0===s(i[n],d)?t(i,n,f):t(i,++f,o),f<=r&&(n=f+1),r<=f&&(o=f-1);}}function t(e,t,i){var r=e[t];e[t]=e[i],e[i]=r;}function i(e,t){return et?1:0}return function(t,r,n,o,s){e(t,r,n||0,o||t.length-1,s||i);}}();var ki=d(Li.exports);function Oi(e){let t=0;for(let i,r,n=0,o=e.length,s=o-1;n=t[2]||e[1]<=t[1]||e[3]>=t[3])}function Ni(e,t,i){const r=e[0]-t[0],n=e[1]-t[1],o=e[0]-i[0],s=e[1]-i[1];return r*s-o*n==0&&r*o<=0&&n*s<=0}function Ui(e,t,i=!1){let r=!1;for(let a=0,l=t.length;a(n=e)[1]!=(s=h)[1]>n[1]&&n[0]<(s[0]-o[0])*(n[1]-o[1])/(s[1]-o[1])+o[0]&&(r=!r);}}var n,o,s;return r}function Vi(e,t,i,r){const n=r[0]-i[0],o=r[1]-i[1],s=(e[0]-i[0])*o-n*(e[1]-i[1]),a=(t[0]-i[0])*o-n*(t[1]-i[1]);return s>0&&a<0||s<0&&a>0}function ji(e,t,i,r){return 0!=(n=[r[0]-i[0],r[1]-i[1]])[0]*(o=[t[0]-e[0],t[1]-e[1]])[1]-n[1]*o[0]&&!(!Vi(e,t,i,r)||!Vi(i,r,e,t));var n,o;}const Gi=8192;function qi(e,t){const i=(180+e[0])/360,r=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,n=Math.pow(2,t.z);return [Math.round(i*n*Gi),Math.round(r*n*Gi)]}function Zi(e,t){for(let i=0;ii[2]){const t=.5*r;let n=e[0]-i[0]>t?-r:i[0]-e[0]>t?r:0;0===n&&(n=e[0]-i[2]>t?-r:i[2]-e[0]>t?r:0),e[0]+=n;}Bi(t,e);}function Ji(e,t,i,r){const n=Math.pow(2,r.z)*Gi,o=[r.x*Gi,r.y*Gi],s=[];if(!e)return s;for(const r of e)for(const e of r){const r=[e.x+o[0],e.y+o[1]];Ki(r,t,i,n),s.push(r);}return s}function Qi(e,t,i,r){const n=Math.pow(2,r.z)*Gi,o=[r.x*Gi,r.y*Gi],s=[];if(!e)return s;for(const i of e){const e=[];for(const r of i){const i=[r.x+o[0],r.y+o[1]];Bi(t,i),e.push(i);}s.push(e);}if(t[2]-t[0]<=n/2){(a=t)[0]=a[1]=1/0,a[2]=a[3]=-1/0;for(const e of s)for(const r of e)Ki(r,t,i,n);}var a;return s}class er{constructor(e,t){this.type=jt,this.geojson=e,this.geometries=t;}static parse(e,t){if(2!==e.length)return t.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(fi(e[1])){const t=e[1];if("FeatureCollection"===t.type)for(let e=0;e180;)e-=360;return e}return n.fromTile=function(e,t,i){var o=Math.PI*(1-2*(e+.5)/Math.pow(2,t)),s=Math.atan(.5*(Math.exp(o)-Math.exp(-o)))/r;return new n(s,i)},o.units.get=function(){return e},n.prototype.distance=function(e,t){var i=l(e[0]-t[0])*this.kx,r=(e[1]-t[1])*this.ky;return Math.sqrt(i*i+r*r)},n.prototype.bearing=function(e,t){var i=l(t[0]-e[0])*this.kx;return Math.atan2(i,(t[1]-e[1])*this.ky)/r},n.prototype.destination=function(e,t,i){var n=i*r;return this.offset(e,Math.sin(n)*t,Math.cos(n)*t)},n.prototype.offset=function(e,t,i){return [e[0]+t/this.kx,e[1]+i/this.ky]},n.prototype.lineDistance=function(e){for(var t=0,i=0;it)return a(n,o,(t-(i-s))/s)}return e[e.length-1]},n.prototype.pointToSegmentDistance=function(e,t,i){var r=t[0],n=t[1],o=l(i[0]-r)*this.kx,s=(i[1]-n)*this.ky,a=0;return 0===o&&0===s||((a=(l(e[0]-r)*this.kx*o+(e[1]-n)*this.ky*s)/(o*o+s*s))>1?(r=i[0],n=i[1]):a>0&&(r+=o/this.kx*a,n+=s/this.ky*a)),o=l(e[0]-r)*this.kx,s=(e[1]-n)*this.ky,Math.sqrt(o*o+s*s)},n.prototype.pointOnLine=function(e,t){for(var i,r,n,o,s=1/0,a=0;a1?(c=e[a+1][0],h=e[a+1][1]):p>0&&(c+=u/this.kx*p,h+=d/this.ky*p));var f=(u=l(t[0]-c)*this.kx)*u+(d=(t[1]-h)*this.ky)*d;fn.index||r.index===n.index&&r.t>n.t){var o=r;r=n,n=o;}var a=[r.point],l=r.index+1,c=n.index;!s(i[l],a[0])&&l<=c&&a.push(i[l]);for(var h=l+1;h<=c;h++)a.push(i[h]);return s(i[c],n.point)||a.push(n.point),a},n.prototype.lineSliceAlong=function(e,t,i){for(var r=0,n=[],o=0;oe&&0===n.length&&n.push(a(s,l,(e-(r-c))/c)),r>=t)return n.push(a(s,l,(t-(r-c))/c)),n;r>e&&n.push(l);}return n},n.prototype.bufferPoint=function(e,t){var i=t/this.ky,r=t/this.kx;return [e[0]-r,e[1]-i,e[0]+r,e[1]+i]},n.prototype.bufferBBox=function(e,t){var i=t/this.ky,r=t/this.kx;return [e[0]-r,e[1]-i,e[2]+r,e[3]+i]},n.prototype.insideBBox=function(e,t){return l(e[0]-t[0])>=0&&l(e[0]-t[2])<=0&&e[1]>=t[1]&&e[1]<=t[3]},Object.defineProperties(n,o),n}();var rr=d(ir.exports),nr={exports:{}};nr.exports=function(){var e=function(e,i){if(void 0===e&&(e=[]),void 0===i&&(i=t),this.data=e,this.length=this.data.length,this.compare=i,this.length>0)for(var r=(this.length>>1)-1;r>=0;r--)this._down(r);};function t(e,t){return et?1:0}return e.prototype.push=function(e){this.data.push(e),this.length++,this._up(this.length-1);},e.prototype.pop=function(){if(0!==this.length){var e=this.data[0],t=this.data.pop();return this.length--,this.length>0&&(this.data[0]=t,this._down(0)),e}},e.prototype.peek=function(){return this.data[0]},e.prototype._up=function(e){for(var t=this.data,i=this.compare,r=t[e];e>0;){var n=e-1>>1,o=t[n];if(i(r,o)>=0)break;t[e]=o,e=n;}t[e]=r;},e.prototype._down=function(e){for(var t=this.data,i=this.compare,r=this.length>>1,n=t[e];e=0)break;t[e]=s,e=o;}t[e]=n;},e}();var or=d(nr.exports),sr=8192;function ar(e,t){return t.dist-e.dist}const lr=100,cr=50;function hr(e){const t=[1/0,1/0,-1/0,-1/0];if(t.length!==e.length)return !1;for(let i=0;i=e[0]&&e[1]e[1])return [null,null];const i=ur(e);if(t){if(2===i)return [e,null];const t=Math.floor(i/2);return [[e[0],e[0]+t],[e[0]+t,e[1]]]}{if(1===i)return [e,null];const t=Math.floor(i/2)-1;return [[e[0],e[0]+t],[e[0]+t+1,e[1]]]}}function fr(e,t){const i=[1/0,1/0,-1/0,-1/0];if(!dr(t,e.length))return i;for(let r=t[0];r<=t[1];++r)Bi(i,e[r]);return i}function mr(e){const t=[1/0,1/0,-1/0,-1/0];for(let i=0;it[2]&&(r=e[0]-t[2]),e[1]>t[3]&&(n=e[1]-t[3]),e[3]=r)return r;if(Fi(n,o)){if(Ar(e,t))return 0}else if(Ar(t,e))return 0;let s=r;for(const r of e)for(let e=0,n=r.length,o=n-1;e=o)continue;const c=n.range1;if(ur(c)<=a){if(!dr(c,e.length))return NaN;if(t){const t=Mr(e,c,i,r);if(0===(o=Math.min(o,t)))return o}else for(let t=c[0];t<=c[1];++t){const n=Er(e[t],i,r);if(0===(o=Math.min(o,n)))return o}}else {const i=pr(c,t);if(null!==i[0]){const t=_r(fr(e,i[0]),l,r);t=s)continue;const h=o.range1,u=o.range2;if(ur(h)<=l&&ur(u)<=c){if(!dr(h,e.length)||!dr(u,i.length))return NaN;if(t&&r?s=Math.min(s,wr(e,h,i,u,n)):t||r?t&&!r?s=Math.min(s,vr(i,u,e,h,n)):!t&&r&&(s=Math.min(s,vr(e,h,i,u,n))):s=Math.min(s,Tr(e,h,i,u,n)),0===s)return s}else {const o=pr(h,t),l=pr(u,r);Ir(a,s,n,e,i,o[0],l[0]),Ir(a,s,n,e,i,o[0],l[1]),Ir(a,s,n,e,i,o[1],l[0]),Ir(a,s,n,e,i,o[1],l[1]);}}return s}function Dr(e,t,i,r,n=1/0){let o=n;const s=fr(e,[0,e.length-1]);for(const n of i)if(!(o!==1/0&&_r(s,fr(n,[0,n.length-1]),r)>=o)&&(o=Math.min(o,zr(e,t,n,!0,r,o)),0===o))return o;return o}function Pr(e,t,i,r,n=1/0){let o=n;const s=fr(e,[0,e.length-1]);for(const n of i){if(o!==1/0&&_r(s,mr(n),r)>=o)continue;const i=Cr(e,t,n,r,o);if(isNaN(i))return i;if(0===(o=Math.min(o,i)))return o}return o}function Rr(e){return "Point"===e||"MultiPoint"===e||"LineString"===e||"MultiLineString"===e||"Polygon"===e||"MultiPolygon"===e}class Lr{constructor(e,t){this.type=Ut,this.geojson=e,this.geometries=t;}static parse(e,t){if(2!==e.length)return t.error(`'distance' expression requires either one argument, but found ' ${e.length-1} instead.`);if(fi(e[1])){const t=e[1];if("FeatureCollection"===t.type){for(let e=0;e{t&&!Or(e)&&(t=!1);})),t}function Br(e){if(e instanceof Pi&&"feature-state"===e.name)return !1;let t=!0;return e.eachChild((e=>{t&&!Br(e)&&(t=!1);})),t}function Fr(e){if(e instanceof Pi&&"config"===e.name)return !1;let t=!0;return e.eachChild((e=>{t&&!Fr(e)&&(t=!1);})),t}function Nr(e,t){if(e instanceof Pi&&t.indexOf(e.name)>=0)return !1;let i=!0;return e.eachChild((e=>{i&&!Nr(e,t)&&(i=!1);})),i}class Ur{constructor(e,t){this.type=t.type,this.name=e,this.boundExpression=t;}static parse(e,t){if(2!==e.length||"string"!=typeof e[1])return t.error("'var' expression requires exactly one string literal argument.");const i=e[1];return t.scope.has(i)?new Ur(i,t.scope.get(i)):t.error(`Unknown variable "${i}". Make sure "${i}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return !1}serialize(){return ["var",this.name]}}var Vr=Ur;class jr{constructor(e,t=[],i,r=new Ft,n=[],o){this.registry=e,this.path=t,this.key=t.map((e=>`[${e}]`)).join(""),this.scope=r,this.errors=n,this.expectedType=i,this.options=o;}parse(e,t,i,r,n={}){return t||i?this.concat(t,i,r)._parse(e,n):this._parse(e,n)}_parse(e,t){function i(e,t,i){return "assert"===i?new wi(t,[e]):"coerce"===i?new Ii(t,[e]):e}if(null!==e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e||(e=["literal",e]),Array.isArray(e)){if(0===e.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const r="string"==typeof e[0]?this.registry[e[0]]:void 0;if(r){let n=r.parse(e,this);if(!n)return null;if(this.expectedType){const e=this.expectedType,r=n.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==r.kind)if("color"!==e.kind&&"formatted"!==e.kind&&"resolvedImage"!==e.kind||"value"!==r.kind&&"string"!==r.kind){if(this.checkSubtype(e,r))return null}else n=i(n,e,t.typeAnnotation||"coerce");else n=i(n,e,t.typeAnnotation||"assert");}if(!(n instanceof yi)&&"resolvedImage"!==n.type.kind&&qr(n)){const e=new zi(this.options);try{n=new yi(n.type,n.evaluate(e));}catch(e){return this.error(e.message),null}}return n}return Ii.parse(["to-array",e],this)}return this.error(void 0===e?"'undefined' value invalid. Use null instead.":"object"==typeof e?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,t,i){const r="number"==typeof e?this.path.concat(e):this.path,n=i?this.scope.concat(i):this.scope;return new jr(this.registry,r,t||null,n,this.errors,this.options)}error(e,...t){const i=`${this.key}${t.map((e=>`[${e}]`)).join("")}`;this.errors.push(new Ot(i,e));}checkSubtype(e,t){const i=Jt(e,t);return i&&this.error(i),i}}var Gr=jr;function qr(e){if(e instanceof Vr)return qr(e.boundExpression);if(e instanceof Pi&&"error"===e.name)return !1;if(e instanceof Pi&&"config"===e.name)return !1;if(e instanceof Ri)return !1;if(e instanceof tr)return !1;if(e instanceof kr)return !1;const t=e instanceof Ii||e instanceof wi;let i=!0;return e.eachChild((e=>{i=t?i&&qr(e):i&&e instanceof yi;})),!!i&&Or(e)&&Nr(e,["zoom","heatmap-density","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light"])}function Zr(e,t){const i=e.length-1;let r,n,o=0,s=i,a=0;for(;o<=s;)if(a=Math.floor((o+s)/2),r=e[a],n=e[a+1],r<=t){if(a===i||tt))throw new xi("Input is not a number.");s=a-1;}return 0}class $r{constructor(e,t,i){this.type=e,this.input=t,this.labels=[],this.outputs=[];for(const[e,t]of i)this.labels.push(e),this.outputs.push(t);}static parse(e,t){if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");const i=t.parse(e[1],1,Ut);if(!i)return null;const r=[];let n=null;t.expectedType&&"value"!==t.expectedType.kind&&(n=t.expectedType);for(let i=1;i=o)return t.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const c=t.parse(s,l,n);if(!c)return null;n=n||c.type,r.push([o,c]);}return new $r(n,i,r)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const r=this.input.evaluate(e);if(r<=t[0])return i[0].evaluate(e);const n=t.length;return r>=t[n-1]?i[n-1].evaluate(e):i[Zr(t,r)].evaluate(e)}eachChild(e){e(this.input);for(const t of this.outputs)e(t);}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}serialize(){const e=["step",this.input.serialize()];for(let t=0;t0&&e.push(this.labels[t]),e.push(this.outputs[t].serialize());return e}}var Hr=$r;function Wr(e,t,i){return e*(1-i)+t*i}function Xr(e,t,i){return e.map(((e,r)=>Wr(e,t[r],i)))}var Yr=Object.freeze({__proto__:null,array:Xr,color:function(e,t,i){return new li(Wr(e.r,t.r,i),Wr(e.g,t.g,i),Wr(e.b,t.b,i),Wr(e.a,t.a,i))},number:Wr});const Kr=.95047,Jr=1.08883,Qr=4/29,en=6/29,tn=3*en*en,rn=en*en*en,nn=Math.PI/180,on=180/Math.PI;function sn(e){return e>rn?Math.pow(e,1/3):e/tn+Qr}function an(e){return e>en?e*e*e:tn*(e-Qr)}function ln(e){return 255*(e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055)}function cn(e){return (e/=255)<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function hn(e){const t=cn(e.r),i=cn(e.g),r=cn(e.b),n=sn((.4124564*t+.3575761*i+.1804375*r)/Kr),o=sn((.2126729*t+.7151522*i+.072175*r)/1);return {l:116*o-16,a:500*(n-o),b:200*(o-sn((.0193339*t+.119192*i+.9503041*r)/Jr)),alpha:e.a}}function un(e){let t=(e.l+16)/116,i=isNaN(e.a)?t:t+e.a/500,r=isNaN(e.b)?t:t-e.b/200;return t=1*an(t),i=Kr*an(i),r=Jr*an(r),new li(ln(3.2404542*i-1.5371385*t-.4985314*r),ln(-.969266*i+1.8760108*t+.041556*r),ln(.0556434*i-.2040259*t+1.0572252*r),e.alpha)}function dn(e,t,i){const r=t-e;return e+i*(r>180||r<-180?r-360*Math.round(r/360):r)}const pn={forward:hn,reverse:un,interpolate:function(e,t,i){return {l:Wr(e.l,t.l,i),a:Wr(e.a,t.a,i),b:Wr(e.b,t.b,i),alpha:Wr(e.alpha,t.alpha,i)}}},fn={forward:function(e){const{l:t,a:i,b:r}=hn(e),n=Math.atan2(r,i)*on;return {h:n<0?n+360:n,c:Math.sqrt(i*i+r*r),l:t,alpha:e.a}},reverse:function(e){const t=e.h*nn,i=e.c;return un({l:e.l,a:Math.cos(t)*i,b:Math.sin(t)*i,alpha:e.alpha})},interpolate:function(e,t,i){return {h:dn(e.h,t.h,i),c:Wr(e.c,t.c,i),l:Wr(e.l,t.l,i),alpha:Wr(e.alpha,t.alpha,i)}}};var mn=Object.freeze({__proto__:null,hcl:fn,lab:pn});class _n{constructor(e,t,i,r,n){this.type=e,this.operator=t,this.interpolation=i,this.input=r,this.labels=[],this.outputs=[];for(const[e,t]of n)this.labels.push(e),this.outputs.push(t);}static interpolationFactor(e,t,i,r){let n=0;if("exponential"===e.name)n=gn(t,e.base,i,r);else if("linear"===e.name)n=gn(t,1,i,r);else if("cubic-bezier"===e.name){const o=e.controlPoints;n=new m(o[0],o[1],o[2],o[3]).solve(gn(t,1,i,r));}return n}static parse(e,t){let[i,r,n,...o]=e;if(!Array.isArray(r)||0===r.length)return t.error("Expected an interpolation type expression.",1);if("linear"===r[0])r={name:"linear"};else if("exponential"===r[0]){const e=r[1];if("number"!=typeof e)return t.error("Exponential interpolation requires a numeric base.",1,1);r={name:"exponential",base:e};}else {if("cubic-bezier"!==r[0])return t.error(`Unknown interpolation type ${String(r[0])}`,1,0);{const e=r.slice(1);if(4!==e.length||e.some((e=>"number"!=typeof e||e<0||e>1)))return t.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);r={name:"cubic-bezier",controlPoints:e};}}if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");if(n=t.parse(n,2,Ut),!n)return null;const s=[];let a=null;"interpolate-hcl"===i||"interpolate-lab"===i?a=Gt:t.expectedType&&"value"!==t.expectedType.kind&&(a=t.expectedType);for(let e=0;e=i)return t.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',n);const c=t.parse(r,l,a);if(!c)return null;a=a||c.type,s.push([i,c]);}return "number"===a.kind||"color"===a.kind||"array"===a.kind&&"number"===a.itemType.kind&&"number"==typeof a.N?new _n(a,i,r,n,s):t.error(`Type ${Yt(a)} is not interpolatable.`)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const r=this.input.evaluate(e);if(r<=t[0])return i[0].evaluate(e);const n=t.length;if(r>=t[n-1])return i[n-1].evaluate(e);const o=Zr(t,r),s=_n.interpolationFactor(this.interpolation,r,t[o],t[o+1]),a=i[o].evaluate(e),l=i[o+1].evaluate(e);return "interpolate"===this.operator?Yr[this.type.kind.toLowerCase()](a,l,s):"interpolate-hcl"===this.operator?fn.reverse(fn.interpolate(fn.forward(a),fn.forward(l),s)):pn.reverse(pn.interpolate(pn.forward(a),pn.forward(l),s))}eachChild(e){e(this.input);for(const t of this.outputs)e(t);}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}serialize(){let e;e="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const t=[this.operator,e,this.input.serialize()];for(let e=0;eJt(r,e.type)));return new xn(o?Zt:i,n)}evaluate(e){let t,i=null,r=0;for(const n of this.args){if(r++,i=n.evaluate(e),i&&i instanceof di&&!i.available&&(t||(t=i),i=null,r===this.args.length))return t;if(null!==i)break}return i}eachChild(e){this.args.forEach(e);}outputDefined(){return this.args.every((e=>e.outputDefined()))}serialize(){const e=["coalesce"];return this.eachChild((t=>{e.push(t.serialize());})),e}}var vn=xn;class bn{constructor(e,t){this.type=t.type,this.bindings=[].concat(e),this.result=t;}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const t of this.bindings)e(t[1]);e(this.result);}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const i=[];for(let r=1;r=i.length)throw new xi(`Array index out of bounds: ${t} > ${i.length-1}.`);if(t!==Math.floor(t))throw new xi(`Array index must be an integer, but found ${t} instead.`);return i[t]}eachChild(e){e(this.index),e(this.input);}outputDefined(){return !1}serialize(){return ["at",this.index.serialize(),this.input.serialize()]}}var En=Tn;class Mn{constructor(e,t){this.type=jt,this.needle=e,this.haystack=t;}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Zt),r=t.parse(e[2],2,Zt);return i&&r?Qt(i.type,[jt,Vt,Ut,Nt,Zt])?new Mn(i,r):t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Yt(i.type)} instead`):null}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(null==i)return !1;if(!ei(t,["boolean","string","number","null"]))throw new xi(`Expected first argument to be of type boolean, string, number or null, but found ${Yt(mi(t))} instead.`);if(!ei(i,["string","array"]))throw new xi(`Expected second argument to be of type array or string, but found ${Yt(mi(i))} instead.`);return i.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack);}outputDefined(){return !0}serialize(){return ["in",this.needle.serialize(),this.haystack.serialize()]}}var An=Mn;class Sn{constructor(e,t,i){this.type=Ut,this.needle=e,this.haystack=t,this.fromIndex=i;}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Zt),r=t.parse(e[2],2,Zt);if(!i||!r)return null;if(!Qt(i.type,[jt,Vt,Ut,Nt,Zt]))return t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Yt(i.type)} instead`);if(4===e.length){const n=t.parse(e[3],3,Ut);return n?new Sn(i,r,n):null}return new Sn(i,r)}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!ei(t,["boolean","string","number","null"]))throw new xi(`Expected first argument to be of type boolean, string, number or null, but found ${Yt(mi(t))} instead.`);if(!ei(i,["string","array"]))throw new xi(`Expected second argument to be of type array or string, but found ${Yt(mi(i))} instead.`);if(this.fromIndex){const r=this.fromIndex.evaluate(e);return i.indexOf(t,r)}return i.indexOf(t)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex);}outputDefined(){return !1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const e=this.fromIndex.serialize();return ["index-of",this.needle.serialize(),this.haystack.serialize(),e]}return ["index-of",this.needle.serialize(),this.haystack.serialize()]}}var In=Sn;class Cn{constructor(e,t,i,r,n,o){this.inputType=e,this.type=t,this.input=i,this.cases=r,this.outputs=n,this.otherwise=o;}static parse(e,t){if(e.length<5)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return t.error("Expected an even number of arguments.");let i,r;t.expectedType&&"value"!==t.expectedType.kind&&(r=t.expectedType);const n={},o=[];for(let s=2;sNumber.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof e&&Math.floor(e)!==e)return c.error("Numeric branch labels must be integer values.");if(i){if(c.checkSubtype(i,mi(e)))return null}else i=mi(e);if(void 0!==n[String(e)])return c.error("Branch labels must be unique.");n[String(e)]=o.length;}const h=t.parse(l,s,r);if(!h)return null;r=r||h.type,o.push(h);}const s=t.parse(e[1],1,Zt);if(!s)return null;const a=t.parse(e[e.length-1],e.length-1,r);return a?"value"!==s.type.kind&&t.concat(1).checkSubtype(i,s.type)?null:new Cn(i,r,s,n,o,a):null}evaluate(e){const t=this.input.evaluate(e);return (mi(t)===this.inputType&&this.outputs[this.cases[t]]||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()}serialize(){const e=["match",this.input.serialize()],t=Object.keys(this.cases).sort(),i=[],r={};for(const e of t){const t=r[this.cases[e]];void 0===t?(r[this.cases[e]]=i.length,i.push([this.cases[e],[e]])):i[t][1].push(e);}const n=e=>"number"===this.inputType.kind?Number(e):e;for(const[t,r]of i)e.push(1===r.length?n(r[0]):r.map(n)),e.push(this.outputs[t].serialize());return e.push(this.otherwise.serialize()),e}}var zn=Cn;class Dn{constructor(e,t,i){this.type=e,this.branches=t,this.otherwise=i;}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return t.error("Expected an odd number of arguments.");let i;t.expectedType&&"value"!==t.expectedType.kind&&(i=t.expectedType);const r=[];for(let n=1;nt.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const e=["case"];return this.eachChild((t=>{e.push(t.serialize());})),e}}var Pn=Dn;class Rn{constructor(e,t,i,r){this.type=e,this.input=t,this.beginIndex=i,this.endIndex=r;}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Zt),r=t.parse(e[2],2,Ut);if(!i||!r)return null;if(!Qt(i.type,[Xt(Zt),Vt,Zt]))return t.error(`Expected first argument to be of type array or string, but found ${Yt(i.type)} instead`);if(4===e.length){const n=t.parse(e[3],3,Ut);return n?new Rn(i.type,i,r,n):null}return new Rn(i.type,i,r)}evaluate(e){const t=this.input.evaluate(e),i=this.beginIndex.evaluate(e);if(!ei(t,["string","array"]))throw new xi(`Expected first argument to be of type array or string, but found ${Yt(mi(t))} instead.`);if(this.endIndex){const r=this.endIndex.evaluate(e);return t.slice(i,r)}return t.slice(i)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex);}outputDefined(){return !1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const e=this.endIndex.serialize();return ["slice",this.input.serialize(),this.beginIndex.serialize(),e]}return ["slice",this.input.serialize(),this.beginIndex.serialize()]}}var Ln=Rn;function kn(e,t){return "=="===e||"!="===e?"boolean"===t.kind||"string"===t.kind||"number"===t.kind||"null"===t.kind||"value"===t.kind:"string"===t.kind||"number"===t.kind||"value"===t.kind}function On(e,t,i,r){return 0===r.compare(t,i)}function Bn(e,t,i){const r="=="!==e&&"!="!==e;return class n{constructor(e,t,i){this.type=jt,this.lhs=e,this.rhs=t,this.collator=i,this.hasUntypedArgument="value"===e.type.kind||"value"===t.type.kind;}static parse(e,t){if(3!==e.length&&4!==e.length)return t.error("Expected two or three arguments.");const i=e[0];let o=t.parse(e[1],1,Zt);if(!o)return null;if(!kn(i,o.type))return t.concat(1).error(`"${i}" comparisons are not supported for type '${Yt(o.type)}'.`);let s=t.parse(e[2],2,Zt);if(!s)return null;if(!kn(i,s.type))return t.concat(2).error(`"${i}" comparisons are not supported for type '${Yt(s.type)}'.`);if(o.type.kind!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return t.error(`Cannot compare types '${Yt(o.type)}' and '${Yt(s.type)}'.`);r&&("value"===o.type.kind&&"value"!==s.type.kind?o=new wi(s.type,[o]):"value"!==o.type.kind&&"value"===s.type.kind&&(s=new wi(o.type,[s])));let a=null;if(4===e.length){if("string"!==o.type.kind&&"string"!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return t.error("Cannot use collator to compare non-string types.");if(a=t.parse(e[3],3,$t),!a)return null}return new n(o,s,a)}evaluate(n){const o=this.lhs.evaluate(n),s=this.rhs.evaluate(n);if(r&&this.hasUntypedArgument){const t=mi(o),i=mi(s);if(t.kind!==i.kind||"string"!==t.kind&&"number"!==t.kind)throw new xi(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${t.kind}, ${i.kind}) instead.`)}if(this.collator&&!r&&this.hasUntypedArgument){const e=mi(o),i=mi(s);if("string"!==e.kind||"string"!==i.kind)return t(n,o,s)}return this.collator?i(n,o,s,this.collator.evaluate(n)):t(n,o,s)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator);}outputDefined(){return !0}serialize(){const t=[e];return this.eachChild((e=>{t.push(e.serialize());})),t}}}const Fn=Bn("==",(function(e,t,i){return t===i}),On),Nn=Bn("!=",(function(e,t,i){return t!==i}),(function(e,t,i,r){return !On(0,t,i,r)})),Un=Bn("<",(function(e,t,i){return t",(function(e,t,i){return t>i}),(function(e,t,i,r){return r.compare(t,i)>0})),jn=Bn("<=",(function(e,t,i){return t<=i}),(function(e,t,i,r){return r.compare(t,i)<=0})),Gn=Bn(">=",(function(e,t,i){return t>=i}),(function(e,t,i,r){return r.compare(t,i)>=0}));class qn{constructor(e,t,i,r,n,o){this.type=Vt,this.number=e,this.locale=t,this.currency=i,this.unit=r,this.minFractionDigits=n,this.maxFractionDigits=o;}static parse(e,t){if(3!==e.length)return t.error("Expected two arguments.");const i=t.parse(e[1],1,Ut);if(!i)return null;const r=e[2];if("object"!=typeof r||Array.isArray(r))return t.error("NumberFormat options argument must be an object.");let n=null;if(r.locale&&(n=t.parse(r.locale,1,Vt),!n))return null;let o=null;if(r.currency&&(o=t.parse(r.currency,1,Vt),!o))return null;let s=null;if(r.unit&&(s=t.parse(r.unit,1,Vt),!s))return null;let a=null;if(r["min-fraction-digits"]&&(a=t.parse(r["min-fraction-digits"],1,Ut),!a))return null;let l=null;return r["max-fraction-digits"]&&(l=t.parse(r["max-fraction-digits"],1,Ut),!l)?null:new qn(i,n,o,s,a,l)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(e):void 0,unit:this.unit?this.unit.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.unit&&e(this.unit),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits);}outputDefined(){return !1}serialize(){const e={};return this.locale&&(e.locale=this.locale.serialize()),this.currency&&(e.currency=this.currency.serialize()),this.unit&&(e.unit=this.unit.serialize()),this.minFractionDigits&&(e["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(e["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),e]}}class Zn{constructor(e){this.type=Ut,this.input=e;}static parse(e,t){if(2!==e.length)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);const i=t.parse(e[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?t.error(`Expected argument of type string or array, but found ${Yt(i.type)} instead.`):new Zn(i):null}evaluate(e){const t=this.input.evaluate(e);if("string"==typeof t)return t.length;if(Array.isArray(t))return t.length;throw new xi(`Expected value to be of type string or array, but found ${Yt(mi(t))} instead.`)}eachChild(e){e(this.input);}outputDefined(){return !1}serialize(){const e=["length"];return this.eachChild((t=>{e.push(t.serialize());})),e}}function $n(e){return function(){e=1831565813+(e|=0)|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}const Hn={"==":Fn,"!=":Nn,">":Vn,"<":Un,">=":Gn,"<=":jn,array:wi,at:En,boolean:wi,case:Pn,coalesce:vn,collator:Ri,format:Ti,image:Ei,in:An,"index-of":In,interpolate:yn,"interpolate-hcl":yn,"interpolate-lab":yn,length:Zn,let:wn,literal:yi,match:zn,number:wi,"number-format":qn,object:wi,slice:Ln,step:Hr,string:wi,"to-boolean":Ii,"to-color":Ii,"to-number":Ii,"to-string":Ii,var:Vr,within:tr,distance:kr};function Wn(e,[t,i,r,n]){t=t.evaluate(e),i=i.evaluate(e),r=r.evaluate(e);const o=n?n.evaluate(e):1,s=pi(t,i,r,o);if(s)throw new xi(s);return new li(t/255*o,i/255*o,r/255*o,o)}function Xn(e,[t,i,r,n]){t=t.evaluate(e),i=i.evaluate(e),r=r.evaluate(e);const o=n?n.evaluate(e):1,s=function(e,t,i,r){return "number"==typeof e&&e>=0&&e<=360?"number"==typeof t&&t>=0&&t<=100&&"number"==typeof i&&i>=0&&i<=100?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid hsla value [${[e,t,i,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${("number"==typeof r?[e,t,i,r]:[e,t,i]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${("number"==typeof r?[e,t,i,r]:[e,t,i]).join(", ")}]: 'h' must be between 0 and 360.`}(t,i,r,o);if(s)throw new xi(s);const a=`hsla(${t}, ${i}%, ${r}%, ${o})`,l=li.parse(a);if(!l)throw new xi(`Failed to parse HSLA color: ${a}`);return l}function Yn(e,t){return e in t}function Kn(e,t){const i=t[e];return void 0===i?null:i}function Jn(e,t,i){i.length&&(t+=`${i}`);const r=e.getConfig(t);return r?r.evaluate(e):null}function Qn(e){return {type:e}}Pi.register(Hn,{error:[{kind:"error"},[Vt],(e,[t])=>{throw new xi(t.evaluate(e))}],typeof:[Vt,[Zt],(e,[t])=>Yt(mi(t.evaluate(e)))],"to-rgba":[Xt(Ut,4),[Gt],(e,[t])=>t.evaluate(e).toArray()],rgb:[Gt,[Ut,Ut,Ut],Wn],rgba:[Gt,[Ut,Ut,Ut,Ut],Wn],hsl:[Gt,[Ut,Ut,Ut],Xn],hsla:[Gt,[Ut,Ut,Ut,Ut],Xn],has:{type:jt,overloads:[[[Vt],(e,[t])=>Yn(t.evaluate(e),e.properties())],[[Vt,qt],(e,[t,i])=>Yn(t.evaluate(e),i.evaluate(e))]]},get:{type:Zt,overloads:[[[Vt],(e,[t])=>Kn(t.evaluate(e),e.properties())],[[Vt,qt],(e,[t,i])=>Kn(t.evaluate(e),i.evaluate(e))]]},config:{type:Zt,overloads:[[[Vt],(e,[t])=>Jn(e,t.evaluate(e),"")],[[Vt,Vt],(e,[t,i])=>Jn(e,t.evaluate(e),i.evaluate(e))]]},"feature-state":[Zt,[Vt],(e,[t])=>Kn(t.evaluate(e),e.featureState||{})],properties:[qt,[],e=>e.properties()],"geometry-type":[Vt,[],e=>e.geometryType()],id:[Zt,[],e=>e.id()],zoom:[Ut,[],e=>e.globals.zoom],pitch:[Ut,[],e=>e.globals.pitch||0],"distance-from-center":[Ut,[],e=>e.distanceFromCenter()],"measure-light":[Ut,[Vt],(e,[t])=>e.measureLight(t.evaluate(e))],"heatmap-density":[Ut,[],e=>e.globals.heatmapDensity||0],"line-progress":[Ut,[],e=>e.globals.lineProgress||0],"raster-value":[Ut,[],e=>e.globals.rasterValue||0],"sky-radial-progress":[Ut,[],e=>e.globals.skyRadialProgress||0],accumulated:[Zt,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[Ut,Qn(Ut),(e,t)=>{let i=0;for(const r of t)i+=r.evaluate(e);return i}],"*":[Ut,Qn(Ut),(e,t)=>{let i=1;for(const r of t)i*=r.evaluate(e);return i}],"-":{type:Ut,overloads:[[[Ut,Ut],(e,[t,i])=>t.evaluate(e)-i.evaluate(e)],[[Ut],(e,[t])=>-t.evaluate(e)]]},"/":[Ut,[Ut,Ut],(e,[t,i])=>t.evaluate(e)/i.evaluate(e)],"%":[Ut,[Ut,Ut],(e,[t,i])=>t.evaluate(e)%i.evaluate(e)],ln2:[Ut,[],()=>Math.LN2],pi:[Ut,[],()=>Math.PI],e:[Ut,[],()=>Math.E],"^":[Ut,[Ut,Ut],(e,[t,i])=>Math.pow(t.evaluate(e),i.evaluate(e))],sqrt:[Ut,[Ut],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[Ut,[Ut],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[Ut,[Ut],(e,[t])=>Math.log(t.evaluate(e))],log2:[Ut,[Ut],(e,[t])=>Math.log(t.evaluate(e))/Math.LN2],sin:[Ut,[Ut],(e,[t])=>Math.sin(t.evaluate(e))],cos:[Ut,[Ut],(e,[t])=>Math.cos(t.evaluate(e))],tan:[Ut,[Ut],(e,[t])=>Math.tan(t.evaluate(e))],asin:[Ut,[Ut],(e,[t])=>Math.asin(t.evaluate(e))],acos:[Ut,[Ut],(e,[t])=>Math.acos(t.evaluate(e))],atan:[Ut,[Ut],(e,[t])=>Math.atan(t.evaluate(e))],min:[Ut,Qn(Ut),(e,t)=>Math.min(...t.map((t=>t.evaluate(e))))],max:[Ut,Qn(Ut),(e,t)=>Math.max(...t.map((t=>t.evaluate(e))))],abs:[Ut,[Ut],(e,[t])=>Math.abs(t.evaluate(e))],round:[Ut,[Ut],(e,[t])=>{const i=t.evaluate(e);return i<0?-Math.round(-i):Math.round(i)}],floor:[Ut,[Ut],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[Ut,[Ut],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[jt,[Vt,Zt],(e,[t,i])=>e.properties()[t.value]===i.value],"filter-id-==":[jt,[Zt],(e,[t])=>e.id()===t.value],"filter-type-==":[jt,[Vt],(e,[t])=>e.geometryType()===t.value],"filter-<":[jt,[Vt,Zt],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r{const i=e.id(),r=t.value;return typeof i==typeof r&&i":[jt,[Vt,Zt],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r>n}],"filter-id->":[jt,[Zt],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i>r}],"filter-<=":[jt,[Vt,Zt],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r<=n}],"filter-id-<=":[jt,[Zt],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i<=r}],"filter->=":[jt,[Vt,Zt],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r>=n}],"filter-id->=":[jt,[Zt],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i>=r}],"filter-has":[jt,[Zt],(e,[t])=>t.value in e.properties()],"filter-has-id":[jt,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[jt,[Xt(Vt)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[jt,[Xt(Zt)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[jt,[Vt,Xt(Zt)],(e,[t,i])=>i.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[jt,[Vt,Xt(Zt)],(e,[t,i])=>function(e,t,i,r){for(;i<=r;){const n=i+r>>1;if(t[n]===e)return !0;t[n]>e?r=n-1:i=n+1;}return !1}(e.properties()[t.value],i.value,0,i.value.length-1)],all:{type:jt,overloads:[[[jt,jt],(e,[t,i])=>t.evaluate(e)&&i.evaluate(e)],[Qn(jt),(e,t)=>{for(const i of t)if(!i.evaluate(e))return !1;return !0}]]},any:{type:jt,overloads:[[[jt,jt],(e,[t,i])=>t.evaluate(e)||i.evaluate(e)],[Qn(jt),(e,t)=>{for(const i of t)if(i.evaluate(e))return !0;return !1}]]},"!":[jt,[jt],(e,[t])=>!t.evaluate(e)],"is-supported-script":[jt,[Vt],(e,[t])=>{const i=e.globals&&e.globals.isSupportedScript;return !i||i(t.evaluate(e))}],upcase:[Vt,[Vt],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[Vt,[Vt],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[Vt,Qn(Zt),(e,t)=>t.map((t=>_i(t.evaluate(e)))).join("")],"resolved-locale":[Vt,[$t],(e,[t])=>t.evaluate(e).resolvedLocale()],random:[Ut,[Ut,Ut,Zt],(e,t)=>{const[i,r,n]=t.map((t=>t.evaluate(e)));if(i>r)return i;if(i===r)return i;let o;if("string"==typeof n)o=function(e){let t=0;if(0===e.length)return t;for(let i=0;i-1}function no(e){return "data-driven"===e["property-type"]}function oo(e){return ro(e.expression,"measure-light")}function so(e){return ro(e.expression,"zoom")}function ao(e){return !!e.expression&&e.expression.interpolated}function lo(e){return "object"==typeof e&&null!==e&&!Array.isArray(e)}function co(e){return e}function ho(e,t){const i="color"===t.type,r=e.stops&&"object"==typeof e.stops[0][0],n=r||!(r||void 0!==e.property),o=e.type||(ao(t)?"exponential":"interval");if(i&&((e=Pt({},e)).stops&&(e.stops=e.stops.map((e=>[e[0],li.parse(e[1])]))),e.default=li.parse(e.default?e.default:t.default)),e.colorSpace&&"rgb"!==e.colorSpace&&!mn[e.colorSpace])throw new Error(`Unknown color space: ${e.colorSpace}`);let s,a,l;if("exponential"===o)s=mo;else if("interval"===o)s=fo;else if("categorical"===o){s=po,a=Object.create(null);for(const t of e.stops)a[t[0]]=t[1];l=typeof e.stops[0][0];}else {if("identity"!==o)throw new Error(`Unknown function type "${o}"`);s=_o;}if(r){const i={},r=[];for(let t=0;te[0])),evaluate:({zoom:i},r)=>mo({stops:n,base:e.base},t,i).evaluate(i,r)}}if(n){const i="exponential"===o?{name:"exponential",base:void 0!==e.base?e.base:1}:null;return {kind:"camera",interpolationType:i,interpolationFactor:yn.interpolationFactor.bind(void 0,i),zoomStops:e.stops.map((e=>e[0])),evaluate:({zoom:i})=>s(e,t,i,a,l)}}return {kind:"source",evaluate(i,r){const n=r&&r.properties?r.properties[e.property]:void 0;return void 0===n?uo(e.default,t.default):s(e,t,n,a,l)}}}function uo(e,t,i){return void 0!==e?e:void 0!==t?t:void 0!==i?i:void 0}function po(e,t,i,r,n){return uo(typeof i===n?r[i]:void 0,e.default,t.default)}function fo(e,t,i){if("number"!==Mi(i))return uo(e.default,t.default);const r=e.stops.length;if(1===r)return e.stops[0][1];if(i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[r-1][0])return e.stops[r-1][1];const n=Zr(e.stops.map((e=>e[0])),i);return e.stops[n][1]}function mo(e,t,i){const r=void 0!==e.base?e.base:1;if("number"!==Mi(i))return uo(e.default,t.default);const n=e.stops.length;if(1===n)return e.stops[0][1];if(i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[n-1][0])return e.stops[n-1][1];const o=Zr(e.stops.map((e=>e[0])),i),s=function(e,t,i,r){const n=r-i,o=e-i;return 0===n?0:1===t?o/n:(Math.pow(t,o)-1)/(Math.pow(t,n)-1)}(i,r,e.stops[o][0],e.stops[o+1][0]),a=e.stops[o][1],l=e.stops[o+1][1];let c=Yr[t.type]||co;if(e.colorSpace&&"rgb"!==e.colorSpace){const t=mn[e.colorSpace];c=(e,i)=>t.reverse(t.interpolate(t.forward(e),t.forward(i),s));}return "function"==typeof a.evaluate?{evaluate(...e){const t=a.evaluate.apply(void 0,e),i=l.evaluate.apply(void 0,e);if(void 0!==t&&void 0!==i)return c(t,i,s)}}:c(a,l,s)}function _o(e,t,i){return "color"===t.type?i=li.parse(i):"formatted"===t.type?i=ui.fromString(i.toString()):"resolvedImage"===t.type?i=di.fromString(i.toString()):Mi(i)===t.type||"enum"===t.type&&t.values[i]||(i=void 0),uo(i,e.default,t.default)}class go{constructor(e,t,i){this.expression=e,this._warningHistory={},this._evaluator=new zi(i),this._defaultValue=t?function(e){return "color"===e.type&&(lo(e.default)||Array.isArray(e.default))?new li(0,0,0,0):"color"===e.type?li.parse(e.default)||null:void 0===e.default?null:e.default}(t):null,this._enumValues=t&&"enum"===t.type?t.values:null;}evaluateWithoutErrorHandling(e,t,i,r,n,o,s,a){return this._evaluator.globals=e,this._evaluator.feature=t,this._evaluator.featureState=i,this._evaluator.canonical=r||null,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=o,this._evaluator.featureTileCoord=s||null,this._evaluator.featureDistanceData=a||null,this.expression.evaluate(this._evaluator)}evaluate(e,t,i,r,n,o,s,a){this._evaluator.globals=e,this._evaluator.feature=t||null,this._evaluator.featureState=i||null,this._evaluator.canonical=r||null,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=o||null,this._evaluator.featureTileCoord=s||null,this._evaluator.featureDistanceData=a||null;try{const e=this.expression.evaluate(this._evaluator);if(null==e||"number"==typeof e&&e!=e)return this._defaultValue;if(this._enumValues&&!(e in this._enumValues))throw new xi(`Expected value to be one of ${Object.keys(this._enumValues).map((e=>JSON.stringify(e))).join(", ")}, but found ${JSON.stringify(e)} instead.`);return e}catch(e){return this._warningHistory[e.message]||(this._warningHistory[e.message]=!0,"undefined"!=typeof console&&console.warn(e.message)),this._defaultValue}}}function yo(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in eo}function xo(e,t,i){const r=new Gr(eo,[],t?function(e){const t={color:Gt,string:Vt,number:Ut,enum:Vt,boolean:jt,formatted:Ht,resolvedImage:Wt};return "array"===e.type?Xt(t[e.value]||Zt,e.length):t[e.type]}(t):void 0,void 0,void 0,i),n=r.parse(e,void 0,void 0,void 0,t&&"string"===t.type?{typeAnnotation:"coerce"}:void 0);return n?to(new go(n,t,i)):io(r.errors)}class vo{constructor(e,t,i){this.kind=e,this._styleExpression=t,this.isLightConstant=i,this.isStateDependent="constant"!==e&&!Br(t.expression),this.isConfigDependent=!Fr(t.expression);}evaluateWithoutErrorHandling(e,t,i,r,n,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,i,r,n,o)}evaluate(e,t,i,r,n,o){return this._styleExpression.evaluate(e,t,i,r,n,o)}}class bo{constructor(e,t,i,r,n){this.kind=e,this.zoomStops=i,this._styleExpression=t,this.isStateDependent="camera"!==e&&!Br(t.expression),this.isLightConstant=n,this.isConfigDependent=!Fr(t.expression),this.interpolationType=r;}evaluateWithoutErrorHandling(e,t,i,r,n,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,i,r,n,o)}evaluate(e,t,i,r,n,o){return this._styleExpression.evaluate(e,t,i,r,n,o)}interpolationFactor(e,t,i){return this.interpolationType?yn.interpolationFactor(this.interpolationType,e,t,i):0}}function wo(e,t,i){if("error"===(e=xo(e,t,i)).result)return e;const r=e.value.expression,n=Or(r);if(!n&&!no(t))return io([new Ot("","data expressions not supported")]);const o=Nr(r,["zoom","pitch","distance-from-center"]);if(!o&&!so(t))return io([new Ot("","zoom expressions not supported")]);const s=Nr(r,["measure-light"]);if(!s&&!oo(t))return io([new Ot("","measure-light expression not supported")]);const a=t.expression&&t.expression.relaxZoomRestriction,l=Eo(r);return l||o||a?l instanceof Ot?io([l]):l instanceof yn&&!ao(t)?io([new Ot("",'"interpolate" expressions cannot be used with this property')]):to(l?new bo(n?"camera":"composite",e.value,l.labels,l instanceof yn?l.interpolation:void 0,s):new vo(n?"constant":"source",e.value,s)):io([new Ot("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class To{constructor(e,t){this._parameters=e,this._specification=t,Pt(this,ho(this._parameters,this._specification));}static deserialize(e){return new To(e._parameters,e._specification)}static serialize(e){return {_parameters:e._parameters,_specification:e._specification}}}function Eo(e){let t=null;if(e instanceof wn)t=Eo(e.result);else if(e instanceof vn){for(const i of e.args)if(t=Eo(i),t)break}else (e instanceof Hr||e instanceof yn)&&e.input instanceof Pi&&"zoom"===e.input.name&&(t=e);return t instanceof Ot||e.eachChild((e=>{const i=Eo(e);i instanceof Ot?t=i:t&&i&&t!==i&&(t=new Ot("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'));})),t}function Mo(e){const t=e.key,i=e.value,r=e.valueSpec||{},n=e.objectElementValidators||{},o=e.style,s=e.styleSpec;let a=[];const l=Mi(i);if("object"!==l)return [new zt(t,i,`object expected, ${l} found`)];for(const e in i){const l=e.split(".")[0];let c;n[l]?c=n[l]:r[l]?c=as:n["*"]?c=n["*"]:r["*"]&&(c=as),c?a=a.concat(c({key:(t?`${t}.`:t)+e,value:i[e],valueSpec:r[l]||r["*"],style:o,styleSpec:s,object:i,objectKey:e},i)):a.push(new Dt(t,i[e],`unknown property "${e}"`));}for(const e in r)n[e]||r[e].required&&void 0===r[e].default&&void 0===i[e]&&a.push(new zt(t,i,`missing required property "${e}"`));return a}function Ao(e){const t=e.value,i=e.valueSpec,r=e.style,n=e.styleSpec,o=e.key,s=e.arrayElementValidator||as;if("array"!==Mi(t))return [new zt(o,t,`array expected, ${Mi(t)} found`)];if(i.length&&t.length!==i.length)return [new zt(o,t,`array length ${i.length} expected, length ${t.length} found`)];if(i["min-length"]&&t.lengthn)return [new zt(t,i,`${i} is greater than the maximum value ${n}`)]}return []}function Io(e){const t=e.valueSpec,i=Rt(e.value.type);let r,n,o,s={};const a="categorical"!==i&&void 0===e.value.property,l=!a,c="array"===Mi(e.value.stops)&&"array"===Mi(e.value.stops[0])&&"object"===Mi(e.value.stops[0][0]),h=Mo({key:e.key,value:e.value,valueSpec:e.styleSpec.function,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{stops:function(e){if("identity"===i)return [new zt(e.key,e.value,'identity function may not have a "stops" property')];let t=[];const r=e.value;return t=t.concat(Ao({key:e.key,value:r,valueSpec:e.valueSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:u})),"array"===Mi(r)&&0===r.length&&t.push(new zt(e.key,r,"array must have at least one stop")),t},default:function(e){return as({key:e.key,value:e.value,valueSpec:t,style:e.style,styleSpec:e.styleSpec})}}});return "identity"===i&&a&&h.push(new zt(e.key,e.value,'missing required property "property"')),"identity"===i||e.value.stops||h.push(new zt(e.key,e.value,'missing required property "stops"')),"exponential"===i&&e.valueSpec.expression&&!ao(e.valueSpec)&&h.push(new zt(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(l&&!no(e.valueSpec)?h.push(new zt(e.key,e.value,"property functions not supported")):a&&!so(e.valueSpec)&&h.push(new zt(e.key,e.value,"zoom functions not supported"))),"categorical"!==i&&!c||void 0!==e.value.property||h.push(new zt(e.key,e.value,'"property" property is required')),h;function u(e){let i=[];const r=e.value,a=e.key;if("array"!==Mi(r))return [new zt(a,r,`array expected, ${Mi(r)} found`)];if(2!==r.length)return [new zt(a,r,`array length 2 expected, length ${r.length} found`)];if(c){if("object"!==Mi(r[0]))return [new zt(a,r,`object expected, ${Mi(r[0])} found`)];if(void 0===r[0].zoom)return [new zt(a,r,"object stop key must have zoom")];if(void 0===r[0].value)return [new zt(a,r,"object stop key must have value")];const t=Rt(r[0].zoom);if("number"!=typeof t)return [new zt(a,r[0].zoom,"stop zoom values must be numbers")];if(o&&o>t)return [new zt(a,r[0].zoom,"stop zoom values must appear in ascending order")];t!==o&&(o=t,n=void 0,s={}),i=i.concat(Mo({key:`${a}[0]`,value:r[0],valueSpec:{zoom:{}},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:So,value:d}}));}else i=i.concat(d({key:`${a}[0]`,value:r[0],valueSpec:{},style:e.style,styleSpec:e.styleSpec},r));return yo(Lt(r[1]))?i.concat([new zt(`${a}[1]`,r[1],"expressions are not allowed in function stops.")]):i.concat(as({key:`${a}[1]`,value:r[1],valueSpec:t,style:e.style,styleSpec:e.styleSpec}))}function d(e,o){const a=Mi(e.value),l=Rt(e.value),c=null!==e.value?e.value:o;if(r){if(a!==r)return [new zt(e.key,c,`${a} stop domain type must match previous stop domain type ${r}`)]}else r=a;if("number"!==a&&"string"!==a&&"boolean"!==a&&"number"!=typeof l&&"string"!=typeof l&&"boolean"!=typeof l)return [new zt(e.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==a&&"categorical"!==i){let r=`number expected, ${a} found`;return no(t)&&void 0===i&&(r+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new zt(e.key,c,r)]}return "categorical"!==i||"number"!==a||"number"==typeof l&&isFinite(l)&&Math.floor(l)===l?"categorical"!==i&&"number"===a&&"number"==typeof l&&"number"==typeof n&&void 0!==n&&lnew zt(`${e.key}${t.key}`,e.value,t.message)));const i=t.value.expression||t.value._styleExpression.expression;if("property"===e.expressionContext&&"text-font"===e.propertyKey&&!i.outputDefined())return [new zt(e.key,e.value,`Invalid data expression for "${e.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===e.expressionContext&&"layout"===e.propertyType&&!Br(i))return [new zt(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===e.expressionContext)return zo(i,e);if(e.expressionContext&&0===e.expressionContext.indexOf("cluster")){if(!Nr(i,["zoom","feature-state"]))return [new zt(e.key,e.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===e.expressionContext&&!Or(i))return [new zt(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return []}function zo(e,t){const i=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(t.valueSpec&&t.valueSpec.expression)for(const e of t.valueSpec.expression.parameters)i.delete(e);if(0===i.size)return [];const r=[];return e instanceof Pi&&i.has(e.name)?[new zt(t.key,t.value,`["${e.name}"] expression is not supported in a filter for a ${t.object.type} layer with id: ${t.object.id}`)]:(e.eachChild((e=>{r.push(...zo(e,t));})),r)}function Do(e){const t=e.key,i=e.value,r=e.valueSpec,n=[];return Array.isArray(r.values)?-1===r.values.indexOf(Rt(i))&&n.push(new zt(t,i,`expected one of [${r.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(r.values).indexOf(Rt(i))&&n.push(new zt(t,i,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(i)} found`)),n}function Po(e){if(!0===e||!1===e)return !0;if(!Array.isArray(e)||0===e.length)return !1;switch(e[0]){case"has":return e.length>=2&&"$id"!==e[1]&&"$type"!==e[1];case"in":return e.length>=3&&("string"!=typeof e[1]||Array.isArray(e[2]));case"!in":case"!has":case"none":return !1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==e.length||Array.isArray(e[1])||Array.isArray(e[2]);case"any":case"all":for(const t of e.slice(1))if(!Po(t)&&"boolean"!=typeof t)return !1;return !0;default:return !0}}function Ro(e,t="fill"){if(null==e)return {filter:()=>!0,needGeometry:!1,needFeature:!1};Po(e)||(e=Uo(e));const i=e;let r=!0;try{r=function(e){if(!Oo(e))return e;let t=Lt(e);return ko(t),t=Lo(t),t}(i);}catch(e){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.\nThis is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md\nand paste the contents of this message in the report.\nThank you!\nFilter Expression:\n${JSON.stringify(i,null,2)}\n `);}const n=Ct[`filter_${t}`],o=xo(r,n);let s=null;if("error"===o.result)throw new Error(o.value.map((e=>`${e.key}: ${e.message}`)).join(", "));s=(e,t,i)=>o.value.evaluate(e,t,{},i);let a=null,l=null;if(r!==i){const e=xo(i,n);if("error"===e.result)throw new Error(e.value.map((e=>`${e.key}: ${e.message}`)).join(", "));a=(t,i,r,n,o)=>e.value.evaluate(t,i,{},r,void 0,void 0,n,o),l=!Or(e.value.expression);}return {filter:s,dynamicFilter:a||void 0,needGeometry:No(r),needFeature:!!l}}function Lo(e){if(!Array.isArray(e))return e;const t=function(e){if(Bo.has(e[0]))for(let t=1;tLo(e)))}function ko(e){let t=!1;const i=[];if("case"===e[0]){for(let r=1;r",">=","<","<=","to-boolean"]);function Fo(e,t){return et?1:0}function No(e){if(!Array.isArray(e))return !1;if("within"===e[0]||"distance"===e[0])return !0;for(let t=1;t"===t||"<="===t||">="===t?Vo(e[1],e[2],t):"any"===t?(i=e.slice(1),["any"].concat(i.map(Uo))):"all"===t?["all"].concat(e.slice(1).map(Uo)):"none"===t?["all"].concat(e.slice(1).map(Uo).map(qo)):"in"===t?jo(e[1],e.slice(2)):"!in"===t?qo(jo(e[1],e.slice(2))):"has"===t?Go(e[1]):"!has"!==t||qo(Go(e[1]));var i;}function Vo(e,t,i){switch(e){case"$type":return [`filter-type-${i}`,t];case"$id":return [`filter-id-${i}`,t];default:return [`filter-${i}`,e,t]}}function jo(e,t){if(0===t.length)return !1;switch(e){case"$type":return ["filter-type-in",["literal",t]];case"$id":return ["filter-id-in",["literal",t]];default:return t.length>200&&!t.some((e=>typeof e!=typeof t[0]))?["filter-in-large",e,["literal",t.sort(Fo)]]:["filter-in-small",e,["literal",t]]}}function Go(e){switch(e){case"$type":return !0;case"$id":return ["filter-has-id"];default:return ["filter-has",e]}}function qo(e){return ["!",e]}function Zo(e){return Po(Lt(e.value))?Co(Pt({},e,{expressionContext:"filter",valueSpec:e.styleSpec[`filter_${e.layerType||"fill"}`]})):$o(e)}function $o(e){const t=e.value,i=e.key;if("array"!==Mi(t))return [new zt(i,t,`array expected, ${Mi(t)} found`)];const r=e.styleSpec;let n,o=[];if(t.length<1)return [new zt(i,t,"filter array must have at least 1 element")];switch(o=o.concat(Do({key:`${i}[0]`,value:t[0],valueSpec:r.filter_operator,style:e.style,styleSpec:e.styleSpec})),Rt(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&"$type"===Rt(t[1])&&o.push(new zt(i,t,`"$type" cannot be use with operator "${t[0]}"`));case"==":case"!=":3!==t.length&&o.push(new zt(i,t,`filter array for operator "${t[0]}" must have 3 elements`));case"in":case"!in":t.length>=2&&(n=Mi(t[1]),"string"!==n&&o.push(new zt(`${i}[1]`,t[1],`string expected, ${n} found`)));for(let s=2;s{e in i&&t.push(new zt(r,i[e],`"${e}" is prohibited for ref layers`));})),n.layers.forEach((t=>{Rt(t.id)===a&&(e=t);})),e?e.ref?t.push(new zt(r,i.ref,"ref cannot reference another ref layer")):s=Rt(e.type):"string"==typeof a&&t.push(new zt(r,i.ref,`ref layer "${a}" not found`));}else if("background"!==s&&"sky"!==s&&"slot"!==s)if(i.source){const e=n.sources&&n.sources[i.source],o=e&&Rt(e.type);e?"vector"===o&&"raster"===s?t.push(new zt(r,i.source,`layer "${i.id}" requires a raster source`)):"raster"===o&&"raster"!==s?t.push(new zt(r,i.source,`layer "${i.id}" requires a vector source`)):"vector"!==o||i["source-layer"]?"raster-dem"===o&&"hillshade"!==s?t.push(new zt(r,i.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"!==s||!i.paint||!i.paint["line-gradient"]&&!i.paint["line-trim-offset"]||"geojson"===o&&e.lineMetrics||t.push(new zt(r,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new zt(r,i,`layer "${i.id}" must specify a "source-layer"`)):t.push(new zt(r,i.source,`source "${i.source}" not found`));}else t.push(new zt(r,i,'missing required property "source"'));return t=t.concat(Mo({key:r,value:i,valueSpec:o.layer,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":()=>[],type:()=>as({key:`${r}.type`,value:i.type,valueSpec:o.layer.type,style:e.style,styleSpec:e.styleSpec,object:i,objectKey:"type"}),filter:e=>Zo(Pt({layerType:s},e)),layout:e=>Mo({layer:i,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>Xo(Pt({layerType:s},e))}}),paint:e=>Mo({layer:i,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>Wo(Pt({layerType:s,layer:i},e))}})}})),t}function Ko(e){const t=e.value,i=e.key,r=Mi(t);return "string"!==r?[new zt(i,t,`string expected, ${r} found`)]:[]}const Jo={promoteId:function({key:e,value:t}){if("string"===Mi(t))return Ko({key:e,value:t});{const i=[];for(const r in t)i.push(...Ko({key:`${e}.${r}`,value:t[r]}));return i}}};function Qo(e){const t=e.value,i=e.key,r=e.styleSpec,n=e.style;if(!t.type)return [new zt(i,t,'"type" is required')];const o=Rt(t.type);let s;switch(o){case"vector":case"raster":case"raster-dem":return s=Mo({key:i,value:t,valueSpec:r[`source_${o.replace("-","_")}`],style:e.style,styleSpec:r,objectElementValidators:Jo}),s;case"geojson":if(s=Mo({key:i,value:t,valueSpec:r.source_geojson,style:n,styleSpec:r,objectElementValidators:Jo}),t.cluster)for(const e in t.clusterProperties){const[r,n]=t.clusterProperties[e],o="string"==typeof r?[r,["accumulated"],["get",e]]:r;s.push(...Co({key:`${i}.${e}.map`,value:n,expressionContext:"cluster-map"})),s.push(...Co({key:`${i}.${e}.reduce`,value:o,expressionContext:"cluster-reduce"}));}return s;case"video":return Mo({key:i,value:t,valueSpec:r.source_video,style:n,styleSpec:r});case"image":return Mo({key:i,value:t,valueSpec:r.source_image,style:n,styleSpec:r});case"canvas":return [new zt(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Do({key:`${i}.type`,value:t.type,valueSpec:{values:es(r)},style:n,styleSpec:r})}}function es(e){return e.source.reduce(((t,i)=>{const r=e[i];return "enum"===r.type.type&&(t=t.concat(Object.keys(r.type.values))),t}),[])}function ts(e){const t=e.value;let i=[];if(!t)return i;const r=Mi(t);return "string"!==r?(i=i.concat([new zt(e.key,t,`string expected, "${r}" found`)]),i):(function(e){const t=-1===e.indexOf("://");try{return new URL(e,t?"http://example.com":void 0),!0}catch(e){return !1}}(t)||(i=i.concat([new zt(e.key,t,`invalid url "${t}"`)])),i)}function is(e){const t=e.value,i=e.styleSpec,r=i.light,n=e.style;let o=[];const s=Mi(t);if(void 0===t)return o;if("object"!==s)return o=o.concat([new zt("light",t,`object expected, ${s} found`)]),o;for(const e in t){const s=e.match(/^(.*)-transition$/);o=o.concat(s&&r[s[1]]&&r[s[1]].transition?as({key:e,value:t[e],valueSpec:i.transition,style:n,styleSpec:i}):r[e]?as({key:e,value:t[e],valueSpec:r[e],style:n,styleSpec:i}):[new zt(e,t[e],`unknown property "${e}"`)]);}return o}function rs(e){const t=e.value;let i=[];if(!t)return i;const r=Mi(t);if("object"!==r)return i=i.concat([new zt("light-3d",t,`object expected, ${r} found`)]),i;const n=e.styleSpec,o=n["light-3d"],s=e.key,a=e.style,l=e.style.lights;for(const e of ["type","id"])if(!(e in t))return i=i.concat([new zt("light-3d",t,`missing property ${e} on light`)]),i;if(t.type&&l)for(let r=0;r[],array:Ao,boolean:function(e){const t=e.value,i=e.key,r=Mi(t);return "boolean"!==r?[new zt(i,t,`boolean expected, ${r} found`)]:[]},number:So,color:function(e){const t=e.key,i=e.value,r=Mi(i);return "string"!==r?[new zt(t,i,`color expected, ${r} found`)]:null===ti(i)?[new zt(t,i,`color expected, "${i}" found`)]:[]},enum:Do,filter:Zo,function:Io,layer:Yo,object:Mo,source:Qo,model:ts,light:is,"light-3d":rs,terrain:ns,fog:os,string:Ko,formatted:function(e){return 0===Ko(e).length?[]:Co(e)},resolvedImage:function(e){return 0===Ko(e).length?[]:Co(e)},projection:function(e){const t=e.value,i=e.styleSpec,r=i.projection,n=e.style;let o=[];const s=Mi(t);if("object"===s)for(const e in t)o=o.concat(as({key:e,value:t[e],valueSpec:r[e],style:n,styleSpec:i}));else "string"!==s&&(o=o.concat([new zt("projection",t,`object or string expected, ${s} found`)]));return o},import:function(e){const{value:t,styleSpec:i}=e,{data:r,...n}=t;Object.defineProperty(n,"__line__",{value:t.__line__,enumerable:!1});let o=Mo(Pt({},e,{value:n,valueSpec:i.import}));return ""===Rt(n.id)&&o.push(new zt(`${e.key}.id`,n,"import id can't be an empty string")),r&&(o=o.concat(cs(r,i,{key:`${e.key}.data`}))),o}};function as(e,t=!1){const i=e.value,r=e.valueSpec,n=e.styleSpec;if(r.expression&&lo(Rt(i)))return Io(e);if(r.expression&&yo(Lt(i)))return Co(e);if(r.type&&ss[r.type]){const i=ss[r.type](e);return !0===t&&i.length>0&&"array"===Mi(e.value)?Co(e):i}return Mo(Pt({},e,{valueSpec:r.type?n[r.type]:r}))}function ls(e){const t=e.value,i=e.key,r=Ko(e);return r.length||(-1===t.indexOf("{fontstack}")&&r.push(new zt(i,t,'"glyphs" url must include a "{fontstack}" token')),-1===t.indexOf("{range}")&&r.push(new zt(i,t,'"glyphs" url must include a "{range}" token'))),r}function cs(e,t=Ct,i={}){return as({key:i.key||"",value:e,valueSpec:t.$root,styleSpec:t,style:e,objectElementValidators:{glyphs:ls,"*":()=>[]}})}function hs(e,t=Ct){return bs(cs(e,t))}const us=e=>bs(Qo(e)),ds=e=>bs(is(e)),ps=e=>bs(rs(e)),fs=e=>bs(ns(e)),ms=e=>bs(os(e)),_s=e=>bs(Yo(e)),gs=e=>bs(Zo(e)),ys=e=>bs(Wo(e)),xs=e=>bs(Xo(e)),vs=e=>bs(ts(e));function bs(e){return e.slice().sort(((e,t)=>e.line&&t.line?e.line-t.line:0))}function ws(e,t){let i=!1;if(t&&t.length)for(const r of t)r instanceof Dt?W(r.message):(e.fire(new St(new Error(r.message))),i=!0);return i}var Ts=Ms,Es=3;function Ms(e,t,i){var r=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;var n=new Int32Array(this.arrayBuffer);e=n[0],this.d=(t=n[1])+2*(i=n[2]);for(var o=0;o=h[p+0]&&r>=h[p+1])?(s[d]=!0,o.push(c[d])):s[d]=!1;}}},Ms.prototype._forEachCell=function(e,t,i,r,n,o,s,a){for(var l=this._convertToCellCoord(e),c=this._convertToCellCoord(t),h=this._convertToCellCoord(i),u=this._convertToCellCoord(r),d=l;d<=h;d++)for(var p=c;p<=u;p++){var f=this.d*p+d;if((!a||a(this._convertFromCellCoord(d),this._convertFromCellCoord(p),this._convertFromCellCoord(d+1),this._convertFromCellCoord(p+1)))&&n.call(this,e,t,i,r,f,o,s,a))return}},Ms.prototype._convertFromCellCoord=function(e){return (e-this.padding)/this.scale},Ms.prototype._convertToCellCoord=function(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))},Ms.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var e=this.cells,t=Es+this.cells.length+1+1,i=0,r=0;r=0||(n[t]=Ds(e[t],i)));e instanceof Error&&(n.message=e.message);}if(n.$name)throw new Error("$name property is reserved for worker serialization logic.");return "Object"!==r&&(n.$name=r),n}throw new Error("can't serialize object of type "+typeof e)}function Ps(e){if(null==e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||e instanceof Boolean||e instanceof Number||e instanceof String||e instanceof Date||e instanceof RegExp||Cs(e)||zs(e)||ArrayBuffer.isView(e)||e instanceof t.ImageData)return e;if(Array.isArray(e))return e.map(Ps);if("object"==typeof e){const t=e.$name||"Object";if("Map"===t){const t=new Map;for(const i of Object.keys(e))"$name"!==i&&t.set(i,Ps(e[i]));return t}const{klass:i}=Ss[t];if(!i)throw new Error(`can't deserialize unregistered class ${t}`);if(i.deserialize)return i.deserialize(e);const r=Object.create(i.prototype);for(const t of Object.keys(e))"$name"!==t&&(r[t]=Ps(e[t]));return r}throw new Error("can't deserialize object of type "+typeof e)}const Rs={"Latin-1 Supplement":e=>e>=128&&e<=255,Arabic:e=>e>=1536&&e<=1791,"Arabic Supplement":e=>e>=1872&&e<=1919,"Arabic Extended-A":e=>e>=2208&&e<=2303,"Hangul Jamo":e=>e>=4352&&e<=4607,"Unified Canadian Aboriginal Syllabics":e=>e>=5120&&e<=5759,Khmer:e=>e>=6016&&e<=6143,"Unified Canadian Aboriginal Syllabics Extended":e=>e>=6320&&e<=6399,"General Punctuation":e=>e>=8192&&e<=8303,"Letterlike Symbols":e=>e>=8448&&e<=8527,"Number Forms":e=>e>=8528&&e<=8591,"Miscellaneous Technical":e=>e>=8960&&e<=9215,"Control Pictures":e=>e>=9216&&e<=9279,"Optical Character Recognition":e=>e>=9280&&e<=9311,"Enclosed Alphanumerics":e=>e>=9312&&e<=9471,"Geometric Shapes":e=>e>=9632&&e<=9727,"Miscellaneous Symbols":e=>e>=9728&&e<=9983,"Miscellaneous Symbols and Arrows":e=>e>=11008&&e<=11263,"CJK Radicals Supplement":e=>e>=11904&&e<=12031,"Kangxi Radicals":e=>e>=12032&&e<=12255,"Ideographic Description Characters":e=>e>=12272&&e<=12287,"CJK Symbols and Punctuation":e=>e>=12288&&e<=12351,Hiragana:e=>e>=12352&&e<=12447,Katakana:e=>e>=12448&&e<=12543,Bopomofo:e=>e>=12544&&e<=12591,"Hangul Compatibility Jamo":e=>e>=12592&&e<=12687,Kanbun:e=>e>=12688&&e<=12703,"Bopomofo Extended":e=>e>=12704&&e<=12735,"CJK Strokes":e=>e>=12736&&e<=12783,"Katakana Phonetic Extensions":e=>e>=12784&&e<=12799,"Enclosed CJK Letters and Months":e=>e>=12800&&e<=13055,"CJK Compatibility":e=>e>=13056&&e<=13311,"CJK Unified Ideographs Extension A":e=>e>=13312&&e<=19903,"Yijing Hexagram Symbols":e=>e>=19904&&e<=19967,"CJK Unified Ideographs":e=>e>=19968&&e<=40959,"Yi Syllables":e=>e>=40960&&e<=42127,"Yi Radicals":e=>e>=42128&&e<=42191,"Hangul Jamo Extended-A":e=>e>=43360&&e<=43391,"Hangul Syllables":e=>e>=44032&&e<=55215,"Hangul Jamo Extended-B":e=>e>=55216&&e<=55295,"Private Use Area":e=>e>=57344&&e<=63743,"CJK Compatibility Ideographs":e=>e>=63744&&e<=64255,"Arabic Presentation Forms-A":e=>e>=64336&&e<=65023,"Vertical Forms":e=>e>=65040&&e<=65055,"CJK Compatibility Forms":e=>e>=65072&&e<=65103,"Small Form Variants":e=>e>=65104&&e<=65135,"Arabic Presentation Forms-B":e=>e>=65136&&e<=65279,"Halfwidth and Fullwidth Forms":e=>e>=65280&&e<=65519,"CJK Unified Ideographs Extension B":e=>e>=131072&&e<=173791};function Ls(e){for(const t of e)if(Bs(t.charCodeAt(0)))return !0;return !1}function ks(e){for(const t of e)if(!Os(t.charCodeAt(0)))return !1;return !0}function Os(e){return !(Rs.Arabic(e)||Rs["Arabic Supplement"](e)||Rs["Arabic Extended-A"](e)||Rs["Arabic Presentation Forms-A"](e)||Rs["Arabic Presentation Forms-B"](e))}function Bs(e){return !(746!==e&&747!==e&&(e<4352||!(Rs["Bopomofo Extended"](e)||Rs.Bopomofo(e)||Rs["CJK Compatibility Forms"](e)&&!(e>=65097&&e<=65103)||Rs["CJK Compatibility Ideographs"](e)||Rs["CJK Compatibility"](e)||Rs["CJK Radicals Supplement"](e)||Rs["CJK Strokes"](e)||!(!Rs["CJK Symbols and Punctuation"](e)||e>=12296&&e<=12305||e>=12308&&e<=12319||12336===e)||Rs["CJK Unified Ideographs Extension A"](e)||Rs["CJK Unified Ideographs"](e)||Rs["Enclosed CJK Letters and Months"](e)||Rs["Hangul Compatibility Jamo"](e)||Rs["Hangul Jamo Extended-A"](e)||Rs["Hangul Jamo Extended-B"](e)||Rs["Hangul Jamo"](e)||Rs["Hangul Syllables"](e)||Rs.Hiragana(e)||Rs["Ideographic Description Characters"](e)||Rs.Kanbun(e)||Rs["Kangxi Radicals"](e)||Rs["Katakana Phonetic Extensions"](e)||Rs.Katakana(e)&&12540!==e||!(!Rs["Halfwidth and Fullwidth Forms"](e)||65288===e||65289===e||65293===e||e>=65306&&e<=65310||65339===e||65341===e||65343===e||e>=65371&&e<=65503||65507===e||e>=65512&&e<=65519)||!(!Rs["Small Form Variants"](e)||e>=65112&&e<=65118||e>=65123&&e<=65126)||Rs["Unified Canadian Aboriginal Syllabics"](e)||Rs["Unified Canadian Aboriginal Syllabics Extended"](e)||Rs["Vertical Forms"](e)||Rs["Yijing Hexagram Symbols"](e)||Rs["Yi Syllables"](e)||Rs["Yi Radicals"](e))))}function Fs(e){return !(Bs(e)||function(e){return !!(Rs["Latin-1 Supplement"](e)&&(167===e||169===e||174===e||177===e||188===e||189===e||190===e||215===e||247===e)||Rs["General Punctuation"](e)&&(8214===e||8224===e||8225===e||8240===e||8241===e||8251===e||8252===e||8258===e||8263===e||8264===e||8265===e||8273===e)||Rs["Letterlike Symbols"](e)||Rs["Number Forms"](e)||Rs["Miscellaneous Technical"](e)&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||9003===e||e>=9085&&e<=9114||e>=9150&&e<=9165||9167===e||e>=9169&&e<=9179||e>=9186&&e<=9215)||Rs["Control Pictures"](e)&&9251!==e||Rs["Optical Character Recognition"](e)||Rs["Enclosed Alphanumerics"](e)||Rs["Geometric Shapes"](e)||Rs["Miscellaneous Symbols"](e)&&!(e>=9754&&e<=9759)||Rs["Miscellaneous Symbols and Arrows"](e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||Rs["CJK Symbols and Punctuation"](e)||Rs.Katakana(e)||Rs["Private Use Area"](e)||Rs["CJK Compatibility Forms"](e)||Rs["Small Form Variants"](e)||Rs["Halfwidth and Fullwidth Forms"](e)||8734===e||8756===e||8757===e||e>=9984&&e<=10087||e>=10102&&e<=10131||65532===e||65533===e)}(e))}function Ns(e){return e>=1424&&e<=2303||Rs["Arabic Presentation Forms-A"](e)||Rs["Arabic Presentation Forms-B"](e)}function Us(e,t){return !(!t&&Ns(e)||e>=2304&&e<=3583||e>=3840&&e<=4255||Rs.Khmer(e))}function Vs(e){for(const t of e)if(Ns(t.charCodeAt(0)))return !0;return !1}const js="deferred",Gs="loading",qs="loaded";let Zs=null,$s="unavailable",Hs=null;const Ws=function(e){e&&"string"==typeof e&&e.indexOf("NetworkError")>-1&&($s="error"),Zs&&Zs(e);};function Xs(){Ys.fire(new At("pluginStateChange",{pluginStatus:$s,pluginURL:Hs}));}const Ys=new It,Ks=function(){return $s},Js=function(){if($s!==js||!Hs)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");$s=Gs,Xs(),Hs&&Te({url:Hs},(e=>{e?Ws(e):($s=qs,Xs());}));},Qs={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>$s===qs||null!=Qs.applyArabicShaping,isLoading:()=>$s===Gs,setState(e){$s=e.pluginStatus,Hs=e.pluginURL;},isParsed:()=>null!=Qs.applyArabicShaping&&null!=Qs.processBidirectionalText&&null!=Qs.processStyledBidirectionalText,getPluginURL:()=>Hs};class ea{constructor(e,t){this.zoom=e,t?(this.now=t.now,this.fadeDuration=t.fadeDuration,this.transition=t.transition,this.pitch=t.pitch,this.brightness=t.brightness):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0);}isSupportedScript(e){return function(e,t){for(const i of e)if(!Us(i.charCodeAt(0),t))return !1;return !0}(e,Qs.isLoaded())}}class ta{constructor(e,t,i){this.property=e,this.value=t,this.expression=function(e,t,i){if(lo(e))return new To(e,t);if(yo(e)||Array.isArray(e)&&e.length>0){const r=wo(e,t,i);if("error"===r.result)throw new Error(r.value.map((e=>`${e.key}: ${e.message}`)).join(", "));return r.value}{let i=e;return "string"==typeof e&&"color"===t.type&&(i=li.parse(e)),{kind:"constant",isConfigDependent:!1,evaluate:()=>i}}}(void 0===t?e.specification.default:t,e.specification,i);}isDataDriven(){return "source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(e,t,i){return this.property.possiblyEvaluate(this,e,t,i)}}class ia{constructor(e,t){this.property=e,this.value=new ta(e,void 0,t);}transitioned(e,t){return new na(this.property,this.value,t,k({},e.transition,this.transition),e.now)}untransitioned(){return new na(this.property,this.value,null,{},0)}}class ra{constructor(e,t){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._options=t,this.isConfigDependent=!1;}getValue(e){return $(this._values[e].value.value)}setValue(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new ia(this._values[e].property,this._options)),this._values[e].value=new ta(this._values[e].property,null===t?void 0:$(t),this._options),this.isConfigDependent=this.isConfigDependent||this._values[e].value.expression.isConfigDependent;}setTransitionOrValue(e,t){t&&(this._options=t);const i=this._properties.properties;if(e)for(const t in e){const r=e[t];if(G(t,"-transition")){const e=t.slice(0,-11);i[e]&&this.setTransition(e,r);}else i[t]&&this.setValue(t,r);}}getTransition(e){return $(this._values[e].transition)}setTransition(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new ia(this._values[e].property)),this._values[e].transition=$(t)||void 0;}serialize(){const e={};for(const t of Object.keys(this._values)){const i=this.getValue(t);void 0!==i&&(e[t]=i);const r=this.getTransition(t);void 0!==r&&(e[`${t}-transition`]=r);}return e}transitioned(e,t){const i=new oa(this._properties);for(const r of Object.keys(this._values))i._values[r]=this._values[r].transitioned(e,t._values[r]);return i}untransitioned(){const e=new oa(this._properties);for(const t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}}class na{constructor(e,t,i,r,n){const o=r.delay||0,s=r.duration||0;n=n||0,this.property=e,this.value=t,this.begin=n+o,this.end=this.begin+s,e.specification.transition&&(r.delay||r.duration)&&(this.prior=i);}possiblyEvaluate(e,t,i){const r=e.now||0,n=this.value.possiblyEvaluate(e,t,i),o=this.prior;if(o){if(r>this.end)return this.prior=null,n;if(this.value.isDataDriven())return this.prior=null,n;if(r=0?e.slice(0,t):e}Is(ha,"DataDrivenProperty"),Is(ca,"DataConstantProperty"),Is(ua,"ColorRampProperty");const ma="-transition";class _a extends It{constructor(e,t,i){if(super(),this.id=e.id,this.type=e.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,this.isConfigDependent=!1,"custom"!==e.type&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,"background"!==e.type&&"sky"!==e.type&&"slot"!==e.type&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),this.options=i,e.slot&&(this.slot=e.slot),t.layout&&(this._unevaluatedLayout=new sa(t.layout,i),this.isConfigDependent=this.isConfigDependent||this._unevaluatedLayout.isConfigDependent),t.paint)){this._transitionablePaint=new ra(t.paint,i);for(const t in e.paint)this.setPaintProperty(t,e.paint[t],{validate:!1});for(const t in e.layout)this.setLayoutProperty(t,e.layout[t],{validate:!1});this.isConfigDependent=this.isConfigDependent||this._transitionablePaint.isConfigDependent,this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new la(t.paint);}}setScope(e){this.scope=e,this.fqid=pa(this.id,e);}getLayoutProperty(e){return "visibility"===e?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,t,i={}){if(null!=t&&this._validate(xs,`layers.${this.id}.layout.${e}`,e,t,i))return;if("custom"===this.type&&"visibility"===e)return void(this.visibility=t);const r=this._unevaluatedLayout;r._properties.properties[e]&&(r.setValue(e,t),this.isConfigDependent=this.isConfigDependent||r.isConfigDependent,"visibility"===e&&this.possiblyEvaluateVisibility());}possiblyEvaluateVisibility(){this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0});}getPaintProperty(e){return G(e,ma)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,t,i={}){if(null!=t&&this._validate(ys,`layers.${this.id}.paint.${e}`,e,t,i))return !1;const r=this._transitionablePaint,n=r._properties.properties;if(G(e,ma)){const i=e.slice(0,-11);return n[i]&&r.setTransition(i,t||void 0),!1}if(!n[e])return !1;const o=r._values[e],s=o.value.isDataDriven(),a=o.value;r.setValue(e,t),this.isConfigDependent=this.isConfigDependent||r.isConfigDependent,this._handleSpecialPaintPropertyUpdate(e);const l=r._values[e].value,c=l.isDataDriven(),h=G(e,"pattern")||"line-dasharray"===e;return c||s||h||this._handleOverridablePaintPropertyUpdate(e,a,l)}_handleSpecialPaintPropertyUpdate(e){}getProgramIds(){return null}getDefaultProgramParams(e,t){return null}_handleOverridablePaintPropertyUpdate(e,t,i){return !1}isHidden(e){return !!(this.minzoom&&e=this.maxzoom)||"none"===this.visibility}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint);}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,t){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,t)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,t);}serialize(){return Z({id:this.id,type:this.type,slot:this.slot,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()},((e,t)=>!(void 0===e||"layout"===t&&!Object.keys(e).length||"paint"===t&&!Object.keys(e).length)))}_validate(e,t,i,r,n={}){return (!n||!1!==n.validate)&&ws(this,e.call(hs,{key:t,layerType:this.type,objectKey:i,value:r,styleSpec:Ct,style:{glyphs:!0,sprite:!0}}))}is3D(){return !1}isSky(){return !1}isTileClipped(){return !1}hasOffscreenPass(){return !1}hasShadowPass(){return !1}canCastShadows(){return !1}hasLightBeamPass(){return !1}cutoffRange(){return 0}resize(){}isStateDependent(){for(const e in this.paint._values){const t=this.paint.get(e);if(t instanceof aa&&no(t.property.specification)&&("source"===t.value.kind||"composite"===t.value.kind)&&t.value.isStateDependent)return !0}return !1}compileFilter(){this._filterCompiled||(this._featureFilter=Ro(this.filter),this._filterCompiled=!0);}invalidateCompiledFilter(){this._filterCompiled=!1;}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}class ga{constructor(){this.changed=!1,this._updatedLayers={},this._removedLayers={},this.updatedSourceCaches={},this.updatedPaintProps=new Set,this.changedImages=new Set;}updateLayer(e){const t=e.scope;this._updatedLayers[t]=this._updatedLayers[t]||new Set,this._updatedLayers[t].add(e.id);}removeLayer(e){const t=e.scope;this._removedLayers[t]=this._removedLayers[t]||{},this._updatedLayers[t]=this._updatedLayers[t]||new Set,this._removedLayers[t][e.id]=e,this._updatedLayers[t].delete(e.id),this.updatedPaintProps.delete(e.fqid);}getRemovedLayer(e){return this._removedLayers[e.scope]?this._removedLayers[e.scope][e.id]:null}discardLayerRemoval(e){this._removedLayers[e.scope]&&delete this._removedLayers[e.scope][e.id];}getLayerUpdatesByScope(){const e={};for(const t in this._updatedLayers)e[t]=e[t]||{},e[t].updatedIds=Array.from(this._updatedLayers[t].values());for(const t in this._removedLayers)e[t]=e[t]||{},e[t].removedIds=Object.keys(this._removedLayers[t]);return e}reset(){this.changed=!1,this._updatedLayers={},this._removedLayers={},this.updatedSourceCaches={},this.updatedPaintProps.clear(),this.changedImages.clear();}}const ya={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class xa{constructor(e,t){this._structArray=e,this._pos1=t*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8;}}class va{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0);}static serialize(e,t){return e._trim(),t&&(e.isTransferred=!0,t.add(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const t=Object.create(this.prototype);return t.arrayBuffer=e.arrayBuffer,t.length=e.length,t.capacity=e.arrayBuffer.byteLength/t.bytesPerElement,t._refreshViews(),t}_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 t=this.uint8;this._refreshViews(),t&&this.uint8.set(t);}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null;}}function ba(e,t=1){let i=0,r=0;return {members:e.map((e=>{const n=ya[e.type].BYTES_PER_ELEMENT,o=i=wa(i,Math.max(t,n)),s=e.components||1;return r=Math.max(r,n),i+=n*s,{name:e.name,type:e.type,components:s,offset:o}})),size:wa(i,Math.max(r,t)),alignment:t}}function wa(e,t){return Math.ceil(e/t)*t}class Ta extends va{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const r=2*e;return this.int16[r+0]=t,this.int16[r+1]=i,e}}Ta.prototype.bytesPerElement=4,Is(Ta,"StructArrayLayout2i4");class Ea extends va{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.int16[n+0]=t,this.int16[n+1]=i,this.int16[n+2]=r,e}}Ea.prototype.bytesPerElement=6,Is(Ea,"StructArrayLayout3i6");class Ma extends va{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=4*e;return this.int16[o+0]=t,this.int16[o+1]=i,this.int16[o+2]=r,this.int16[o+3]=n,e}}Ma.prototype.bytesPerElement=8,Is(Ma,"StructArrayLayout4i8");class Aa extends va{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,n)}emplace(e,t,i,r,n,o){const s=5*e;return this.int16[s+0]=t,this.int16[s+1]=i,this.int16[s+2]=r,this.int16[s+3]=n,this.int16[s+4]=o,e}}Aa.prototype.bytesPerElement=10,Is(Aa,"StructArrayLayout5i10");class Sa extends va{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r,n,o,s)}emplace(e,t,i,r,n,o,s,a){const l=6*e,c=12*e,h=3*e;return this.int16[l+0]=t,this.int16[l+1]=i,this.uint8[c+4]=r,this.uint8[c+5]=n,this.uint8[c+6]=o,this.uint8[c+7]=s,this.float32[h+2]=a,e}}Sa.prototype.bytesPerElement=12,Is(Sa,"StructArrayLayout2i4ub1f12");class Ia extends va{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=4*e;return this.float32[o+0]=t,this.float32[o+1]=i,this.float32[o+2]=r,this.float32[o+3]=n,e}}Ia.prototype.bytesPerElement=16,Is(Ia,"StructArrayLayout4f16");class Ca extends va{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,n)}emplace(e,t,i,r,n,o){const s=6*e,a=3*e;return this.uint16[s+0]=t,this.uint16[s+1]=i,this.uint16[s+2]=r,this.uint16[s+3]=n,this.float32[a+2]=o,e}}Ca.prototype.bytesPerElement=12,Is(Ca,"StructArrayLayout4ui1f12");class za extends va{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=4*e;return this.uint16[o+0]=t,this.uint16[o+1]=i,this.uint16[o+2]=r,this.uint16[o+3]=n,e}}za.prototype.bytesPerElement=8,Is(za,"StructArrayLayout4ui8");class Da extends va{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,r,n,o)}emplace(e,t,i,r,n,o,s){const a=6*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=r,this.int16[a+3]=n,this.int16[a+4]=o,this.int16[a+5]=s,e}}Da.prototype.bytesPerElement=12,Is(Da,"StructArrayLayout6i12");class Pa extends va{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e,t,i,r,n,o,s,a,l,c,h,u){const d=this.length;return this.resize(d+1),this.emplace(d,e,t,i,r,n,o,s,a,l,c,h,u)}emplace(e,t,i,r,n,o,s,a,l,c,h,u,d){const p=12*e;return this.int16[p+0]=t,this.int16[p+1]=i,this.int16[p+2]=r,this.int16[p+3]=n,this.uint16[p+4]=o,this.uint16[p+5]=s,this.uint16[p+6]=a,this.uint16[p+7]=l,this.int16[p+8]=c,this.int16[p+9]=h,this.int16[p+10]=u,this.int16[p+11]=d,e}}Pa.prototype.bytesPerElement=24,Is(Pa,"StructArrayLayout4i4ui4i24");class Ra extends va{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,r,n,o)}emplace(e,t,i,r,n,o,s){const a=10*e,l=5*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=r,this.float32[l+2]=n,this.float32[l+3]=o,this.float32[l+4]=s,e}}Ra.prototype.bytesPerElement=20,Is(Ra,"StructArrayLayout3i3f20");class La extends va{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer);}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint32[1*e+0]=t,e}}La.prototype.bytesPerElement=4,Is(La,"StructArrayLayout1ul4");class ka extends va{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const r=2*e;return this.uint16[r+0]=t,this.uint16[r+1]=i,e}}ka.prototype.bytesPerElement=4,Is(ka,"StructArrayLayout2ui4");class Oa extends va{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e,t,i,r,n,o,s,a,l,c,h,u,d){const p=this.length;return this.resize(p+1),this.emplace(p,e,t,i,r,n,o,s,a,l,c,h,u,d)}emplace(e,t,i,r,n,o,s,a,l,c,h,u,d,p){const f=20*e,m=10*e;return this.int16[f+0]=t,this.int16[f+1]=i,this.int16[f+2]=r,this.int16[f+3]=n,this.int16[f+4]=o,this.float32[m+3]=s,this.float32[m+4]=a,this.float32[m+5]=l,this.float32[m+6]=c,this.int16[f+14]=h,this.uint32[m+8]=u,this.uint16[f+18]=d,this.uint16[f+19]=p,e}}Oa.prototype.bytesPerElement=40,Is(Oa,"StructArrayLayout5i4f1i1ul2ui40");class Ba extends va{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r,n,o,s)}emplace(e,t,i,r,n,o,s,a){const l=8*e;return this.int16[l+0]=t,this.int16[l+1]=i,this.int16[l+2]=r,this.int16[l+4]=n,this.int16[l+5]=o,this.int16[l+6]=s,this.int16[l+7]=a,e}}Ba.prototype.bytesPerElement=16,Is(Ba,"StructArrayLayout3i2i2i16");class Fa extends va{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,n)}emplace(e,t,i,r,n,o){const s=4*e,a=8*e;return this.float32[s+0]=t,this.float32[s+1]=i,this.float32[s+2]=r,this.int16[a+6]=n,this.int16[a+7]=o,e}}Fa.prototype.bytesPerElement=16,Is(Fa,"StructArrayLayout2f1f2i16");class Na extends va{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=12*e,s=3*e;return this.uint8[o+0]=t,this.uint8[o+1]=i,this.float32[s+1]=r,this.float32[s+2]=n,e}}Na.prototype.bytesPerElement=12,Is(Na,"StructArrayLayout2ub2f12");class Ua extends va{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.float32[n+0]=t,this.float32[n+1]=i,this.float32[n+2]=r,e}}Ua.prototype.bytesPerElement=12,Is(Ua,"StructArrayLayout3f12");class Va extends va{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.uint16[n+0]=t,this.uint16[n+1]=i,this.uint16[n+2]=r,e}}Va.prototype.bytesPerElement=6,Is(Va,"StructArrayLayout3ui6");class ja extends va{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer);}emplaceBack(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v){const b=this.length;return this.resize(b+1),this.emplace(b,e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v)}emplace(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b){const w=30*e,T=15*e,E=60*e;return this.int16[w+0]=t,this.int16[w+1]=i,this.int16[w+2]=r,this.float32[T+2]=n,this.float32[T+3]=o,this.uint16[w+8]=s,this.uint16[w+9]=a,this.uint32[T+5]=l,this.uint32[T+6]=c,this.uint32[T+7]=h,this.uint16[w+16]=u,this.uint16[w+17]=d,this.uint16[w+18]=p,this.float32[T+10]=f,this.float32[T+11]=m,this.uint8[E+48]=_,this.uint8[E+49]=g,this.uint8[E+50]=y,this.uint32[T+13]=x,this.int16[w+28]=v,this.uint8[E+58]=b,e}}ja.prototype.bytesPerElement=60,Is(ja,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class Ga extends va{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer);}emplaceBack(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,M,A,S,I,C,z,D){const P=this.length;return this.resize(P+1),this.emplace(P,e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,M,A,S,I,C,z,D)}emplace(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,M,A,S,I,C,z,D,P){const R=20*e,L=40*e,k=80*e;return this.float32[R+0]=t,this.float32[R+1]=i,this.int16[L+4]=r,this.int16[L+5]=n,this.int16[L+6]=o,this.int16[L+7]=s,this.int16[L+8]=a,this.int16[L+9]=l,this.int16[L+10]=c,this.int16[L+11]=h,this.int16[L+12]=u,this.uint16[L+13]=d,this.uint16[L+14]=p,this.uint16[L+15]=f,this.uint16[L+16]=m,this.uint16[L+17]=_,this.uint16[L+18]=g,this.uint16[L+19]=y,this.uint16[L+20]=x,this.uint16[L+21]=v,this.uint16[L+22]=b,this.uint16[L+23]=w,this.uint16[L+24]=T,this.uint16[L+25]=E,this.uint16[L+26]=M,this.uint16[L+27]=A,this.uint32[R+14]=S,this.float32[R+15]=I,this.float32[R+16]=C,this.float32[R+17]=z,this.float32[R+18]=D,this.uint8[k+76]=P,e}}Ga.prototype.bytesPerElement=80,Is(Ga,"StructArrayLayout2f9i15ui1ul4f1ub80");class qa extends va{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.float32[1*e+0]=t,e}}qa.prototype.bytesPerElement=4,Is(qa,"StructArrayLayout1f4");class Za extends va{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,n)}emplace(e,t,i,r,n,o){const s=5*e;return this.float32[s+0]=t,this.float32[s+1]=i,this.float32[s+2]=r,this.float32[s+3]=n,this.float32[s+4]=o,e}}Za.prototype.bytesPerElement=20,Is(Za,"StructArrayLayout5f20");class $a extends va{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r,n,o,s)}emplace(e,t,i,r,n,o,s,a){const l=7*e;return this.float32[l+0]=t,this.float32[l+1]=i,this.float32[l+2]=r,this.float32[l+3]=n,this.float32[l+4]=o,this.float32[l+5]=s,this.float32[l+6]=a,e}}$a.prototype.bytesPerElement=28,Is($a,"StructArrayLayout7f28");class Ha extends va{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=6*e;return this.uint32[3*e+0]=t,this.uint16[o+2]=i,this.uint16[o+3]=r,this.uint16[o+4]=n,e}}Ha.prototype.bytesPerElement=12,Is(Ha,"StructArrayLayout1ul3ui12");class Wa extends va{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint16[1*e+0]=t,e}}Wa.prototype.bytesPerElement=2,Is(Wa,"StructArrayLayout1ui2");class Xa extends va{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const r=2*e;return this.float32[r+0]=t,this.float32[r+1]=i,e}}Xa.prototype.bytesPerElement=8,Is(Xa,"StructArrayLayout2f8");class Ya extends va{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m){const _=this.length;return this.resize(_+1),this.emplace(_,e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m)}emplace(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_){const g=16*e;return this.float32[g+0]=t,this.float32[g+1]=i,this.float32[g+2]=r,this.float32[g+3]=n,this.float32[g+4]=o,this.float32[g+5]=s,this.float32[g+6]=a,this.float32[g+7]=l,this.float32[g+8]=c,this.float32[g+9]=h,this.float32[g+10]=u,this.float32[g+11]=d,this.float32[g+12]=p,this.float32[g+13]=f,this.float32[g+14]=m,this.float32[g+15]=_,e}}Ya.prototype.bytesPerElement=64,Is(Ya,"StructArrayLayout16f64");class Ka extends va{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r,n,o,s)}emplace(e,t,i,r,n,o,s,a){const l=10*e,c=5*e;return this.uint16[l+0]=t,this.uint16[l+1]=i,this.uint16[l+2]=r,this.uint16[l+3]=n,this.float32[c+2]=o,this.float32[c+3]=s,this.float32[c+4]=a,e}}Ka.prototype.bytesPerElement=20,Is(Ka,"StructArrayLayout4ui3f20");class Ja extends va{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer);}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint8[1*e+0]=t,e}}Ja.prototype.bytesPerElement=1,Is(Ja,"StructArrayLayout1ub1");class Qa extends xa{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.int16[this._pos2+3]}get tileAnchorY(){return this._structArray.int16[this._pos2+4]}get x1(){return this._structArray.float32[this._pos4+3]}get y1(){return this._structArray.float32[this._pos4+4]}get x2(){return this._structArray.float32[this._pos4+5]}get y2(){return this._structArray.float32[this._pos4+6]}get padding(){return this._structArray.int16[this._pos2+14]}get featureIndex(){return this._structArray.uint32[this._pos4+8]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+18]}get bucketIndex(){return this._structArray.uint16[this._pos2+19]}}Qa.prototype.size=40;class el extends Oa{get(e){return new Qa(this,e)}}Is(el,"CollisionBoxArray");class tl extends xa{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(e){this._structArray.uint8[this._pos1+49]=e;}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(e){this._structArray.uint8[this._pos1+50]=e;}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(e){this._structArray.uint32[this._pos4+13]=e;}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(e){this._structArray.uint8[this._pos1+58]=e;}}tl.prototype.size=60;class il extends ja{get(e){return new tl(this,e)}}Is(il,"PlacedSymbolArray");class rl extends xa{get tileAnchorX(){return this._structArray.float32[this._pos4+0]}get tileAnchorY(){return this._structArray.float32[this._pos4+1]}get projectedAnchorX(){return this._structArray.int16[this._pos2+4]}get projectedAnchorY(){return this._structArray.int16[this._pos2+5]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+6]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+7]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+11]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get key(){return this._structArray.uint16[this._pos2+13]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+14]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+15]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+17]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+19]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+21]}get featureIndex(){return this._structArray.uint16[this._pos2+22]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+23]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numIconVertices(){return this._structArray.uint16[this._pos2+25]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+26]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+27]}get crossTileID(){return this._structArray.uint32[this._pos4+14]}set crossTileID(e){this._structArray.uint32[this._pos4+14]=e;}get textOffset0(){return this._structArray.float32[this._pos4+15]}get textOffset1(){return this._structArray.float32[this._pos4+16]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+17]}get zOffset(){return this._structArray.float32[this._pos4+18]}set zOffset(e){this._structArray.float32[this._pos4+18]=e;}get hasIconTextFit(){return this._structArray.uint8[this._pos1+76]}}rl.prototype.size=80;class nl extends Ga{get(e){return new rl(this,e)}}Is(nl,"SymbolInstanceArray");class ol extends qa{getoffsetX(e){return this.float32[1*e+0]}}Is(ol,"GlyphOffsetArray");class sl extends Ta{getx(e){return this.int16[2*e+0]}gety(e){return this.int16[2*e+1]}}Is(sl,"SymbolLineVertexArray");class al extends xa{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]}get layoutVertexArrayOffset(){return this._structArray.uint16[this._pos2+4]}}al.prototype.size=12;class ll extends Ha{get(e){return new al(this,e)}}Is(ll,"FeatureIndexArray");class cl extends ka{geta_centroid_pos0(e){return this.uint16[2*e+0]}geta_centroid_pos1(e){return this.uint16[2*e+1]}}Is(cl,"FillExtrusionCentroidArray");const hl=ba([{name:"a_pos",components:2,type:"Int16"}],4),ul=ba([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class dl{constructor(e=[]){this.segments=e;}_prepareSegment(e,t,i,r){let n=this.segments[this.segments.length-1];return e>dl.MAX_VERTEX_ARRAY_LENGTH&&W(`Max vertices per segment is ${dl.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!n||n.vertexLength+e>dl.MAX_VERTEX_ARRAY_LENGTH||n.sortKey!==r)&&(n={vertexOffset:t,primitiveOffset:i,vertexLength:0,primitiveLength:0},void 0!==r&&(n.sortKey=r),this.segments.push(n)),n}prepareSegment(e,t,i,r){return this._prepareSegment(e,t.length,i.length,r)}get(){return this.segments}destroy(){for(const e of this.segments)for(const t in e.vaos)e.vaos[t].destroy();}static simpleSegment(e,t,i,r){return new dl([{vertexOffset:e,primitiveOffset:t,vertexLength:i,primitiveLength:r,vaos:{},sortKey:0}])}}function pl(e,t){return 256*(e=z(Math.floor(e),0,255))+z(Math.floor(t),0,255)}dl.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Is(dl,"SegmentVector");const fl=ba([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),ml=ba([{name:"a_dash",components:4,type:"Uint16"}]);var _l={exports:{}},gl={exports:{}};!function(e){e.exports=function(e,t){var i,r,n,o,s,a,l,c;for(r=e.length-(i=3&e.length),n=t,s=3432918353,a=461845907,c=0;c>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<13|n>>>19))+((5*(n>>>16)&65535)<<16)&4294967295))+((58964+(o>>>16)&65535)<<16);switch(l=0,i){case 3:l^=(255&e.charCodeAt(c+2))<<16;case 2:l^=(255&e.charCodeAt(c+1))<<8;case 1:n^=l=(65535&(l=(l=(65535&(l^=255&e.charCodeAt(c)))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295;}return n^=e.length,n=2246822507*(65535&(n^=n>>>16))+((2246822507*(n>>>16)&65535)<<16)&4294967295,n=3266489909*(65535&(n^=n>>>13))+((3266489909*(n>>>16)&65535)<<16)&4294967295,(n^=n>>>16)>>>0};}(gl);var yl=gl.exports,xl={exports:{}};!function(e){e.exports=function(e,t){for(var i,r=e.length,n=t^r,o=0;r>=4;)i=1540483477*(65535&(i=255&e.charCodeAt(o)|(255&e.charCodeAt(++o))<<8|(255&e.charCodeAt(++o))<<16|(255&e.charCodeAt(++o))<<24))+((1540483477*(i>>>16)&65535)<<16),n=1540483477*(65535&n)+((1540483477*(n>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),r-=4,++o;switch(r){case 3:n^=(255&e.charCodeAt(o+2))<<16;case 2:n^=(255&e.charCodeAt(o+1))<<8;case 1:n=1540483477*(65535&(n^=255&e.charCodeAt(o)))+((1540483477*(n>>>16)&65535)<<16);}return n=1540483477*(65535&(n^=n>>>13))+((1540483477*(n>>>16)&65535)<<16),(n^=n>>>15)>>>0};}(xl);var vl=yl,bl=xl.exports;_l.exports=vl,_l.exports.murmur3=vl,_l.exports.murmur2=bl;var wl=d(_l.exports);class Tl{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1;}add(e,t,i,r){this.ids.push(El(e)),this.positions.push(t,i,r);}eachPosition(e,t){const i=El(e);let r=0,n=this.ids.length-1;for(;r>1;this.ids[e]>=i?n=e:r=e+1;}for(;this.ids[r]===i;)t(this.positions[3*r],this.positions[3*r+1],this.positions[3*r+2]),r++;}static serialize(e,t){const i=new Float64Array(e.ids),r=new Uint32Array(e.positions);return Ml(i,r,0,i.length-1),t&&(t.add(i.buffer),t.add(r.buffer)),{ids:i,positions:r}}static deserialize(e){const t=new Tl;let i;t.ids=e.ids,t.positions=e.positions;for(const e of t.ids)e!==i&&t.uniqueIds.push(e),i=e;return t.indexed=!0,t}}function El(e){const t=+e;return !isNaN(t)&&Number.MIN_SAFE_INTEGER<=t&&t<=Number.MAX_SAFE_INTEGER?t:wl(String(e))}function Ml(e,t,i,r){for(;i>1];let o=i-1,s=r+1;for(;;){do{o++;}while(e[o]n);if(o>=s)break;Al(e,o,s),Al(t,3*o,3*s),Al(t,3*o+1,3*s+1),Al(t,3*o+2,3*s+2);}s-i`u_${e}`)),this.type=i;}setUniform(e,t,i,r,n){t.set(e,n,r.constantOr(this.value));}getBinding(e,t){return "color"===this.type?new Rl(e):new Cl(e)}}class jl{constructor(e,t){this.uniformNames=t.map((e=>`u_${e}`)),this.pattern=null,this.pixelRatio=1;}setConstantPatternPositions(e){this.pixelRatio=e.pixelRatio||1,this.pattern=e.tl.concat(e.br);}setUniform(e,t,i,r,n){const o="u_pattern"===n||"u_dash"===n?this.pattern:"u_pixel_ratio"===n?this.pixelRatio:null;o&&t.set(e,n,o);}getBinding(e,t){return "u_pattern"===t||"u_dash"===t?new Pl(e):new Cl(e)}}class Gl{constructor(e,t,i,r){this.expression=e,this.type=i,this.maxValue=0,this.paintVertexAttributes=t.map((e=>({name:`a_${e}`,type:"Float32",components:"color"===i?2:1,offset:0}))),this.paintVertexArray=new r;}populatePaintArray(e,t,i,r,n,o,s){const a=this.paintVertexArray.length,l=this.expression.evaluate(new ea(0,{brightness:o}),t,{},n,r,s);this.paintVertexArray.resize(e),this._setPaintValue(a,e,l);}updatePaintArray(e,t,i,r,n,o,s){const a=this.expression.evaluate({zoom:0,brightness:s},i,r,void 0,n);this._setPaintValue(e,t,a);}_setPaintValue(e,t,i){if("color"===this.type){const r=Ul(i);for(let i=e;i`u_${e}_t`)),this.type=i,this.useIntegerZoom=r,this.zoom=n,this.maxValue=0,this.paintVertexAttributes=t.map((e=>({name:`a_${e}`,type:"Float32",components:"color"===i?4:2,offset:0}))),this.paintVertexArray=new o;}populatePaintArray(e,t,i,r,n,o,s){const a=this.expression.evaluate(new ea(this.zoom,{brightness:o}),t,{},n,r,s),l=this.expression.evaluate(new ea(this.zoom+1,{brightness:o}),t,{},n,r,s),c=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(c,e,a,l);}updatePaintArray(e,t,i,r,n,o,s){const a=this.expression.evaluate({zoom:this.zoom,brightness:s},i,r,void 0,n),l=this.expression.evaluate({zoom:this.zoom+1,brightness:s},i,r,void 0,n);this._setPaintValue(e,t,a,l);}_setPaintValue(e,t,i,r){if("color"===this.type){const n=Ul(i),o=Ul(r);for(let i=e;i!0)){this.binders={},this._buffers=[];const r=[];for(const n in e.paint._values){const o=e.paint.get(n);if(!i(n))continue;if(!(o instanceof aa&&no(o.property.specification)))continue;const s=Xl(n,e.type),a=o.value,l=o.property.specification.type,c=!!o.property.useIntegerZoom,h="line-dasharray"===n||n.endsWith("pattern"),u="line-dasharray"===n&&"constant"!==e.layout.get("line-cap").value.kind;if("constant"!==a.kind||u)if("source"===a.kind||u||h){const t=Jl(n,l,"source");this.binders[n]=h?new Zl(a,s,l,t,e.id):new Gl(a,s,l,t),r.push(`/a_${n}`);}else {const e=Jl(n,l,"composite");this.binders[n]=new ql(a,s,l,c,t,e),r.push(`/z_${n}`);}else this.binders[n]=h?new jl(a.value,s):new Vl(a.value,s,l),r.push(`/u_${n}`);}this.cacheKey=r.sort().join("");}getMaxValue(e){const t=this.binders[e];return t instanceof Gl||t instanceof ql?t.maxValue:0}populatePaintArrays(e,t,i,r,n,o,s){for(const a in this.binders){const l=this.binders[a];(l instanceof Gl||l instanceof ql||l instanceof Zl)&&l.populatePaintArray(e,t,i,r,n,o,s);}}setConstantPatternPositions(e){for(const t in this.binders){const i=this.binders[t];i instanceof jl&&i.setConstantPatternPositions(e);}}updatePaintArrays(e,t,i,r,n,o,s,a){let l=!1;const c=Object.keys(e),h=0!==c.length,u=h?c:t.uniqueIds;for(const c in this.binders){const d=this.binders[c];if((d instanceof Gl||d instanceof ql||d instanceof Zl)&&(!0===d.expression.isStateDependent||!1===d.expression.isLightConstant)){const p=n.paint.get(c);d.expression=p.value;for(const i of u){const n=e[i.toString()];t.eachPosition(i,((e,t,i)=>{const l=r.feature(e);d.updatePaintArray(t,i,l,n,o,s,a);}));}if(!h)for(const t of i.uniqueIds){const n=e[t.toString()];i.eachPosition(t,((e,t,i)=>{const l=r.feature(e);d.updatePaintArray(t,i,l,n,o,s,a);}));}l=!0;}}return l}defines(){const e=[];for(const t in this.binders){const i=this.binders[t];(i instanceof Vl||i instanceof jl)&&e.push(...i.uniformNames.map((e=>`#define HAS_UNIFORM_${e}`)));}return e}getBinderAttributes(){const e=[];for(const t in this.binders){const i=this.binders[t];if(i instanceof Gl||i instanceof ql||i instanceof Zl)for(let t=0;t!0)){this.programConfigurations={};for(const r of e)this.programConfigurations[r.id]=new $l(r,t,i);this.needsUpload=!1,this._featureMap=new Tl,this._featureMapWithoutIds=new Tl,this._bufferOffset=0,this._idlessCounter=0;}populatePaintArrays(e,t,i,r,n,o,s,a){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(e,t,r,n,o,s,a);void 0!==t.id?this._featureMap.add(t.id,i,this._bufferOffset,e):(this._featureMapWithoutIds.add(this._idlessCounter,i,this._bufferOffset,e),this._idlessCounter+=1),this._bufferOffset=e,this.needsUpload=!0;}updatePaintArrays(e,t,i,r,n,o){for(const s of i)this.needsUpload=this.programConfigurations[s.id].updatePaintArrays(e,this._featureMap,this._featureMapWithoutIds,t,s,r,n,o||0)||this.needsUpload;}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const t in this.programConfigurations)this.programConfigurations[t].upload(e);this.needsUpload=!1;}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy();}}const Wl={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-emissive-strength":["emissive_strength"],"icon-emissive-strength":["emissive_strength"],"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-pattern":["pattern","pixel_ratio"],"fill-pattern":["pattern","pixel_ratio"],"fill-extrusion-pattern":["pattern","pixel_ratio"],"line-dasharray":["dash"]};function Xl(e,t){return Wl[e]||[e.replace(`${t}-`,"").replace(/-/g,"_")]}const Yl={"line-pattern":{source:Ca,composite:Ca},"fill-pattern":{source:Ca,composite:Ca},"fill-extrusion-pattern":{source:Ca,composite:Ca},"line-dasharray":{source:za,composite:za}},Kl={color:{source:Xa,composite:Ia},number:{source:qa,composite:Xa}};function Jl(e,t,i){const r=Yl[e];return r&&r[i]||Kl[t][i]}Is(Vl,"ConstantBinder"),Is(jl,"PatternConstantBinder"),Is(Gl,"SourceExpressionBinder"),Is(Zl,"PatternCompositeBinder"),Is(ql,"CompositeExpressionBinder"),Is($l,"ProgramConfiguration",{omit:["_buffers"]}),Is(Hl,"ProgramConfigurationSet");class Ql{constructor(e,t){e&&(t?this.setSouthWest(e).setNorthEast(t):4===e.length?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1]));}setNorthEast(e){return this._ne=e instanceof Nd?new Nd(e.lng,e.lat):Nd.convert(e),this}setSouthWest(e){return this._sw=e instanceof Nd?new Nd(e.lng,e.lat):Nd.convert(e),this}extend(e){const t=this._sw,i=this._ne;let r,n;if(e instanceof Nd)r=e,n=e;else {if(!(e instanceof Ql))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(Ql.convert(e)):this.extend(Nd.convert(e)):"object"==typeof e&&null!==e&&e.hasOwnProperty("lat")&&(e.hasOwnProperty("lon")||e.hasOwnProperty("lng"))?this.extend(Nd.convert(e)):this;if(r=e._sw,n=e._ne,!r||!n)return this}return t||i?(t.lng=Math.min(r.lng,t.lng),t.lat=Math.min(r.lat,t.lat),i.lng=Math.max(n.lng,i.lng),i.lat=Math.max(n.lat,i.lat)):(this._sw=new Nd(r.lng,r.lat),this._ne=new Nd(n.lng,n.lat)),this}getCenter(){return new Nd((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 Nd(this.getWest(),this.getNorth())}getSouthEast(){return new Nd(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(e){const{lng:t,lat:i}=Nd.convert(e);let r=this._sw.lng<=t&&t<=this._ne.lng;return this._sw.lng>this._ne.lng&&(r=this._sw.lng>=t&&t>=this._ne.lng),this._sw.lat<=i&&i<=this._ne.lat&&r}static convert(e){return !e||e instanceof Ql?e:new Ql(e)}}var ec={},tc={};Object.defineProperty(tc,"__esModule",{value:!0}),tc.setMatrixArrayType=function(e){tc.ARRAY_TYPE=rc=e;},tc.toRadian=function(e){return e*oc},tc.equals=function(e,t){return Math.abs(e-t)<=ic*Math.max(1,Math.abs(e),Math.abs(t))},tc.RANDOM=tc.ARRAY_TYPE=tc.EPSILON=void 0;var ic=1e-6;tc.EPSILON=ic;var rc="undefined"!=typeof Float32Array?Float32Array:Array;tc.ARRAY_TYPE=rc;var nc=Math.random;tc.RANDOM=nc;var oc=Math.PI/180;Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});var sc={};function ac(e){return ac="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ac(e)}Object.defineProperty(sc,"__esModule",{value:!0}),sc.create=function(){var e=new lc.ARRAY_TYPE(4);return lc.ARRAY_TYPE!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e},sc.clone=function(e){var t=new lc.ARRAY_TYPE(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},sc.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},sc.identity=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e},sc.fromValues=function(e,t,i,r){var n=new lc.ARRAY_TYPE(4);return n[0]=e,n[1]=t,n[2]=i,n[3]=r,n},sc.set=function(e,t,i,r,n){return e[0]=t,e[1]=i,e[2]=r,e[3]=n,e},sc.transpose=function(e,t){if(e===t){var i=t[1];e[1]=t[2],e[2]=i;}else e[0]=t[0],e[1]=t[2],e[2]=t[1],e[3]=t[3];return e},sc.invert=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=i*o-n*r;return s?(e[0]=o*(s=1/s),e[1]=-r*s,e[2]=-n*s,e[3]=i*s,e):null},sc.adjoint=function(e,t){var i=t[0];return e[0]=t[3],e[1]=-t[1],e[2]=-t[2],e[3]=i,e},sc.determinant=function(e){return e[0]*e[3]-e[2]*e[1]},sc.multiply=hc,sc.rotate=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);return e[0]=r*l+o*a,e[1]=n*l+s*a,e[2]=r*-a+o*l,e[3]=n*-a+s*l,e},sc.scale=function(e,t,i){var r=t[1],n=t[2],o=t[3],s=i[0],a=i[1];return e[0]=t[0]*s,e[1]=r*s,e[2]=n*a,e[3]=o*a,e},sc.fromRotation=function(e,t){var i=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=i,e[2]=-i,e[3]=r,e},sc.fromScaling=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=t[1],e},sc.str=function(e){return "mat2("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},sc.frob=function(e){return Math.hypot(e[0],e[1],e[2],e[3])},sc.LDU=function(e,t,i,r){return e[2]=r[2]/r[0],i[0]=r[0],i[1]=r[1],i[3]=r[3]-e[2]*i[1],[e,t,i]},sc.add=function(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e[3]=t[3]+i[3],e},sc.subtract=uc,sc.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]},sc.equals=function(e,t){var i=e[0],r=e[1],n=e[2],o=e[3],s=t[0],a=t[1],l=t[2],c=t[3];return Math.abs(i-s)<=lc.EPSILON*Math.max(1,Math.abs(i),Math.abs(s))&&Math.abs(r-a)<=lc.EPSILON*Math.max(1,Math.abs(r),Math.abs(a))&&Math.abs(n-l)<=lc.EPSILON*Math.max(1,Math.abs(n),Math.abs(l))&&Math.abs(o-c)<=lc.EPSILON*Math.max(1,Math.abs(o),Math.abs(c))},sc.multiplyScalar=function(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e},sc.multiplyScalarAndAdd=function(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e[2]=t[2]+i[2]*r,e[3]=t[3]+i[3]*r,e},sc.sub=sc.mul=void 0;var lc=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==ac(e)&&"function"!=typeof e)return {default:e};var i=cc(void 0);if(i&&i.has(e))return i.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=n?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(r,o,s):r[o]=e[o];}return r.default=e,i&&i.set(e,r),r}(tc);function cc(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return (cc=function(e){return e?i:t})(e)}function hc(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=i[0],l=i[1],c=i[2],h=i[3];return e[0]=r*a+o*l,e[1]=n*a+s*l,e[2]=r*c+o*h,e[3]=n*c+s*h,e}function uc(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e[3]=t[3]-i[3],e}sc.mul=hc,sc.sub=uc;var dc={};function pc(e){return pc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},pc(e)}Object.defineProperty(dc,"__esModule",{value:!0}),dc.create=function(){var e=new fc.ARRAY_TYPE(6);return fc.ARRAY_TYPE!=Float32Array&&(e[1]=0,e[2]=0,e[4]=0,e[5]=0),e[0]=1,e[3]=1,e},dc.clone=function(e){var t=new fc.ARRAY_TYPE(6);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t},dc.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e},dc.identity=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e},dc.fromValues=function(e,t,i,r,n,o){var s=new fc.ARRAY_TYPE(6);return s[0]=e,s[1]=t,s[2]=i,s[3]=r,s[4]=n,s[5]=o,s},dc.set=function(e,t,i,r,n,o,s){return e[0]=t,e[1]=i,e[2]=r,e[3]=n,e[4]=o,e[5]=s,e},dc.invert=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=t[4],a=t[5],l=i*o-r*n;return l?(e[0]=o*(l=1/l),e[1]=-r*l,e[2]=-n*l,e[3]=i*l,e[4]=(n*a-o*s)*l,e[5]=(r*s-i*a)*l,e):null},dc.determinant=function(e){return e[0]*e[3]-e[1]*e[2]},dc.multiply=_c,dc.rotate=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=Math.sin(i),h=Math.cos(i);return e[0]=r*h+o*c,e[1]=n*h+s*c,e[2]=r*-c+o*h,e[3]=n*-c+s*h,e[4]=a,e[5]=l,e},dc.scale=function(e,t,i){var r=t[1],n=t[2],o=t[3],s=t[4],a=t[5],l=i[0],c=i[1];return e[0]=t[0]*l,e[1]=r*l,e[2]=n*c,e[3]=o*c,e[4]=s,e[5]=a,e},dc.translate=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=i[0],h=i[1];return e[0]=r,e[1]=n,e[2]=o,e[3]=s,e[4]=r*c+o*h+a,e[5]=n*c+s*h+l,e},dc.fromRotation=function(e,t){var i=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=i,e[2]=-i,e[3]=r,e[4]=0,e[5]=0,e},dc.fromScaling=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=t[1],e[4]=0,e[5]=0,e},dc.fromTranslation=function(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=t[0],e[5]=t[1],e},dc.str=function(e){return "mat2d("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+")"},dc.frob=function(e){return Math.hypot(e[0],e[1],e[2],e[3],e[4],e[5],1)},dc.add=function(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e[3]=t[3]+i[3],e[4]=t[4]+i[4],e[5]=t[5]+i[5],e},dc.subtract=gc,dc.multiplyScalar=function(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e[4]=t[4]*i,e[5]=t[5]*i,e},dc.multiplyScalarAndAdd=function(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e[2]=t[2]+i[2]*r,e[3]=t[3]+i[3]*r,e[4]=t[4]+i[4]*r,e[5]=t[5]+i[5]*r,e},dc.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]},dc.equals=function(e,t){var i=e[0],r=e[1],n=e[2],o=e[3],s=e[4],a=e[5],l=t[0],c=t[1],h=t[2],u=t[3],d=t[4],p=t[5];return Math.abs(i-l)<=fc.EPSILON*Math.max(1,Math.abs(i),Math.abs(l))&&Math.abs(r-c)<=fc.EPSILON*Math.max(1,Math.abs(r),Math.abs(c))&&Math.abs(n-h)<=fc.EPSILON*Math.max(1,Math.abs(n),Math.abs(h))&&Math.abs(o-u)<=fc.EPSILON*Math.max(1,Math.abs(o),Math.abs(u))&&Math.abs(s-d)<=fc.EPSILON*Math.max(1,Math.abs(s),Math.abs(d))&&Math.abs(a-p)<=fc.EPSILON*Math.max(1,Math.abs(a),Math.abs(p))},dc.sub=dc.mul=void 0;var fc=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==pc(e)&&"function"!=typeof e)return {default:e};var i=mc(void 0);if(i&&i.has(e))return i.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=n?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(r,o,s):r[o]=e[o];}return r.default=e,i&&i.set(e,r),r}(tc);function mc(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return (mc=function(e){return e?i:t})(e)}function _c(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=i[0],h=i[1],u=i[2],d=i[3],p=i[4],f=i[5];return e[0]=r*c+o*h,e[1]=n*c+s*h,e[2]=r*u+o*d,e[3]=n*u+s*d,e[4]=r*p+o*f+a,e[5]=n*p+s*f+l,e}function gc(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e[3]=t[3]-i[3],e[4]=t[4]-i[4],e[5]=t[5]-i[5],e}dc.mul=_c,dc.sub=gc;var yc={};function xc(e){return xc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},xc(e)}Object.defineProperty(yc,"__esModule",{value:!0}),yc.create=function(){var e=new vc.ARRAY_TYPE(9);return vc.ARRAY_TYPE!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e},yc.fromMat4=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[4],e[4]=t[5],e[5]=t[6],e[6]=t[8],e[7]=t[9],e[8]=t[10],e},yc.clone=function(e){var t=new vc.ARRAY_TYPE(9);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t},yc.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e},yc.fromValues=function(e,t,i,r,n,o,s,a,l){var c=new vc.ARRAY_TYPE(9);return c[0]=e,c[1]=t,c[2]=i,c[3]=r,c[4]=n,c[5]=o,c[6]=s,c[7]=a,c[8]=l,c},yc.set=function(e,t,i,r,n,o,s,a,l,c){return e[0]=t,e[1]=i,e[2]=r,e[3]=n,e[4]=o,e[5]=s,e[6]=a,e[7]=l,e[8]=c,e},yc.identity=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},yc.transpose=function(e,t){if(e===t){var i=t[1],r=t[2],n=t[5];e[1]=t[3],e[2]=t[6],e[3]=i,e[5]=t[7],e[6]=r,e[7]=n;}else e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8];return e},yc.invert=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],h=t[8],u=h*s-a*c,d=-h*o+a*l,p=c*o-s*l,f=i*u+r*d+n*p;return f?(e[0]=u*(f=1/f),e[1]=(-h*r+n*c)*f,e[2]=(a*r-n*s)*f,e[3]=d*f,e[4]=(h*i-n*l)*f,e[5]=(-a*i+n*o)*f,e[6]=p*f,e[7]=(-c*i+r*l)*f,e[8]=(s*i-r*o)*f,e):null},yc.adjoint=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],h=t[8];return e[0]=s*h-a*c,e[1]=n*c-r*h,e[2]=r*a-n*s,e[3]=a*l-o*h,e[4]=i*h-n*l,e[5]=n*o-i*a,e[6]=o*c-s*l,e[7]=r*l-i*c,e[8]=i*s-r*o,e},yc.determinant=function(e){var t=e[3],i=e[4],r=e[5],n=e[6],o=e[7],s=e[8];return e[0]*(s*i-r*o)+e[1]*(-s*t+r*n)+e[2]*(o*t-i*n)},yc.multiply=wc,yc.translate=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],h=t[7],u=t[8],d=i[0],p=i[1];return e[0]=r,e[1]=n,e[2]=o,e[3]=s,e[4]=a,e[5]=l,e[6]=d*r+p*s+c,e[7]=d*n+p*a+h,e[8]=d*o+p*l+u,e},yc.rotate=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],h=t[7],u=t[8],d=Math.sin(i),p=Math.cos(i);return e[0]=p*r+d*s,e[1]=p*n+d*a,e[2]=p*o+d*l,e[3]=p*s-d*r,e[4]=p*a-d*n,e[5]=p*l-d*o,e[6]=c,e[7]=h,e[8]=u,e},yc.scale=function(e,t,i){var r=i[0],n=i[1];return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=n*t[3],e[4]=n*t[4],e[5]=n*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e},yc.fromTranslation=function(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=t[0],e[7]=t[1],e[8]=1,e},yc.fromRotation=function(e,t){var i=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=i,e[2]=0,e[3]=-i,e[4]=r,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},yc.fromScaling=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=t[1],e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},yc.fromMat2d=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=0,e[3]=t[2],e[4]=t[3],e[5]=0,e[6]=t[4],e[7]=t[5],e[8]=1,e},yc.fromQuat=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=i+i,a=r+r,l=n+n,c=i*s,h=r*s,u=r*a,d=n*s,p=n*a,f=n*l,m=o*s,_=o*a,g=o*l;return e[0]=1-u-f,e[3]=h-g,e[6]=d+_,e[1]=h+g,e[4]=1-c-f,e[7]=p-m,e[2]=d-_,e[5]=p+m,e[8]=1-c-u,e},yc.normalFromMat4=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],h=t[8],u=t[9],d=t[10],p=t[11],f=t[12],m=t[13],_=t[14],g=t[15],y=i*a-r*s,x=i*l-n*s,v=i*c-o*s,b=r*l-n*a,w=r*c-o*a,T=n*c-o*l,E=h*m-u*f,M=h*_-d*f,A=h*g-p*f,S=u*_-d*m,I=u*g-p*m,C=d*g-p*_,z=y*C-x*I+v*S+b*A-w*M+T*E;return z?(e[0]=(a*C-l*I+c*S)*(z=1/z),e[1]=(l*A-s*C-c*M)*z,e[2]=(s*I-a*A+c*E)*z,e[3]=(n*I-r*C-o*S)*z,e[4]=(i*C-n*A+o*M)*z,e[5]=(r*A-i*I-o*E)*z,e[6]=(m*T-_*w+g*b)*z,e[7]=(_*v-f*T-g*x)*z,e[8]=(f*w-m*v+g*y)*z,e):null},yc.projection=function(e,t,i){return e[0]=2/t,e[1]=0,e[2]=0,e[3]=0,e[4]=-2/i,e[5]=0,e[6]=-1,e[7]=1,e[8]=1,e},yc.str=function(e){return "mat3("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+")"},yc.frob=function(e){return Math.hypot(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8])},yc.add=function(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e[3]=t[3]+i[3],e[4]=t[4]+i[4],e[5]=t[5]+i[5],e[6]=t[6]+i[6],e[7]=t[7]+i[7],e[8]=t[8]+i[8],e},yc.subtract=Tc,yc.multiplyScalar=function(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*i,e},yc.multiplyScalarAndAdd=function(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e[2]=t[2]+i[2]*r,e[3]=t[3]+i[3]*r,e[4]=t[4]+i[4]*r,e[5]=t[5]+i[5]*r,e[6]=t[6]+i[6]*r,e[7]=t[7]+i[7]*r,e[8]=t[8]+i[8]*r,e},yc.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]},yc.equals=function(e,t){var i=e[0],r=e[1],n=e[2],o=e[3],s=e[4],a=e[5],l=e[6],c=e[7],h=e[8],u=t[0],d=t[1],p=t[2],f=t[3],m=t[4],_=t[5],g=t[6],y=t[7],x=t[8];return Math.abs(i-u)<=vc.EPSILON*Math.max(1,Math.abs(i),Math.abs(u))&&Math.abs(r-d)<=vc.EPSILON*Math.max(1,Math.abs(r),Math.abs(d))&&Math.abs(n-p)<=vc.EPSILON*Math.max(1,Math.abs(n),Math.abs(p))&&Math.abs(o-f)<=vc.EPSILON*Math.max(1,Math.abs(o),Math.abs(f))&&Math.abs(s-m)<=vc.EPSILON*Math.max(1,Math.abs(s),Math.abs(m))&&Math.abs(a-_)<=vc.EPSILON*Math.max(1,Math.abs(a),Math.abs(_))&&Math.abs(l-g)<=vc.EPSILON*Math.max(1,Math.abs(l),Math.abs(g))&&Math.abs(c-y)<=vc.EPSILON*Math.max(1,Math.abs(c),Math.abs(y))&&Math.abs(h-x)<=vc.EPSILON*Math.max(1,Math.abs(h),Math.abs(x))},yc.sub=yc.mul=void 0;var vc=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==xc(e)&&"function"!=typeof e)return {default:e};var i=bc(void 0);if(i&&i.has(e))return i.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=n?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(r,o,s):r[o]=e[o];}return r.default=e,i&&i.set(e,r),r}(tc);function bc(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return (bc=function(e){return e?i:t})(e)}function wc(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],h=t[7],u=t[8],d=i[0],p=i[1],f=i[2],m=i[3],_=i[4],g=i[5],y=i[6],x=i[7],v=i[8];return e[0]=d*r+p*s+f*c,e[1]=d*n+p*a+f*h,e[2]=d*o+p*l+f*u,e[3]=m*r+_*s+g*c,e[4]=m*n+_*a+g*h,e[5]=m*o+_*l+g*u,e[6]=y*r+x*s+v*c,e[7]=y*n+x*a+v*h,e[8]=y*o+x*l+v*u,e}function Tc(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e[3]=t[3]-i[3],e[4]=t[4]-i[4],e[5]=t[5]-i[5],e[6]=t[6]-i[6],e[7]=t[7]-i[7],e[8]=t[8]-i[8],e}yc.mul=wc,yc.sub=Tc;var Ec={};function Mc(e){return Mc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Mc(e)}Object.defineProperty(Ec,"__esModule",{value:!0}),Ec.create=function(){var e=new Ac.ARRAY_TYPE(16);return Ac.ARRAY_TYPE!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e},Ec.clone=function(e){var t=new Ac.ARRAY_TYPE(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},Ec.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},Ec.fromValues=function(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m){var _=new Ac.ARRAY_TYPE(16);return _[0]=e,_[1]=t,_[2]=i,_[3]=r,_[4]=n,_[5]=o,_[6]=s,_[7]=a,_[8]=l,_[9]=c,_[10]=h,_[11]=u,_[12]=d,_[13]=p,_[14]=f,_[15]=m,_},Ec.set=function(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_){return e[0]=t,e[1]=i,e[2]=r,e[3]=n,e[4]=o,e[5]=s,e[6]=a,e[7]=l,e[8]=c,e[9]=h,e[10]=u,e[11]=d,e[12]=p,e[13]=f,e[14]=m,e[15]=_,e},Ec.identity=Ic,Ec.transpose=function(e,t){if(e===t){var i=t[1],r=t[2],n=t[3],o=t[6],s=t[7],a=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=i,e[6]=t[9],e[7]=t[13],e[8]=r,e[9]=o,e[11]=t[14],e[12]=n,e[13]=s,e[14]=a;}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e},Ec.invert=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],h=t[8],u=t[9],d=t[10],p=t[11],f=t[12],m=t[13],_=t[14],g=t[15],y=i*a-r*s,x=i*l-n*s,v=i*c-o*s,b=r*l-n*a,w=r*c-o*a,T=n*c-o*l,E=h*m-u*f,M=h*_-d*f,A=h*g-p*f,S=u*_-d*m,I=u*g-p*m,C=d*g-p*_,z=y*C-x*I+v*S+b*A-w*M+T*E;return z?(e[0]=(a*C-l*I+c*S)*(z=1/z),e[1]=(n*I-r*C-o*S)*z,e[2]=(m*T-_*w+g*b)*z,e[3]=(d*w-u*T-p*b)*z,e[4]=(l*A-s*C-c*M)*z,e[5]=(i*C-n*A+o*M)*z,e[6]=(_*v-f*T-g*x)*z,e[7]=(h*T-d*v+p*x)*z,e[8]=(s*I-a*A+c*E)*z,e[9]=(r*A-i*I-o*E)*z,e[10]=(f*w-m*v+g*y)*z,e[11]=(u*v-h*w-p*y)*z,e[12]=(a*M-s*S-l*E)*z,e[13]=(i*S-r*M+n*E)*z,e[14]=(m*x-f*b-_*y)*z,e[15]=(h*b-u*x+d*y)*z,e):null},Ec.adjoint=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],h=t[8],u=t[9],d=t[10],p=t[11],f=t[12],m=t[13],_=t[14],g=t[15];return e[0]=a*(d*g-p*_)-u*(l*g-c*_)+m*(l*p-c*d),e[1]=-(r*(d*g-p*_)-u*(n*g-o*_)+m*(n*p-o*d)),e[2]=r*(l*g-c*_)-a*(n*g-o*_)+m*(n*c-o*l),e[3]=-(r*(l*p-c*d)-a*(n*p-o*d)+u*(n*c-o*l)),e[4]=-(s*(d*g-p*_)-h*(l*g-c*_)+f*(l*p-c*d)),e[5]=i*(d*g-p*_)-h*(n*g-o*_)+f*(n*p-o*d),e[6]=-(i*(l*g-c*_)-s*(n*g-o*_)+f*(n*c-o*l)),e[7]=i*(l*p-c*d)-s*(n*p-o*d)+h*(n*c-o*l),e[8]=s*(u*g-p*m)-h*(a*g-c*m)+f*(a*p-c*u),e[9]=-(i*(u*g-p*m)-h*(r*g-o*m)+f*(r*p-o*u)),e[10]=i*(a*g-c*m)-s*(r*g-o*m)+f*(r*c-o*a),e[11]=-(i*(a*p-c*u)-s*(r*p-o*u)+h*(r*c-o*a)),e[12]=-(s*(u*_-d*m)-h*(a*_-l*m)+f*(a*d-l*u)),e[13]=i*(u*_-d*m)-h*(r*_-n*m)+f*(r*d-n*u),e[14]=-(i*(a*_-l*m)-s*(r*_-n*m)+f*(r*l-n*a)),e[15]=i*(a*d-l*u)-s*(r*d-n*u)+h*(r*l-n*a),e},Ec.determinant=function(e){var t=e[0],i=e[1],r=e[2],n=e[3],o=e[4],s=e[5],a=e[6],l=e[7],c=e[8],h=e[9],u=e[10],d=e[11],p=e[12],f=e[13],m=e[14],_=e[15];return (t*s-i*o)*(u*_-d*m)-(t*a-r*o)*(h*_-d*f)+(t*l-n*o)*(h*m-u*f)+(i*a-r*s)*(c*_-d*p)-(i*l-n*s)*(c*m-u*p)+(r*l-n*a)*(c*f-h*p)},Ec.multiply=Cc,Ec.translate=function(e,t,i){var r,n,o,s,a,l,c,h,u,d,p,f,m=i[0],_=i[1],g=i[2];return t===e?(e[12]=t[0]*m+t[4]*_+t[8]*g+t[12],e[13]=t[1]*m+t[5]*_+t[9]*g+t[13],e[14]=t[2]*m+t[6]*_+t[10]*g+t[14],e[15]=t[3]*m+t[7]*_+t[11]*g+t[15]):(n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],h=t[7],u=t[8],d=t[9],p=t[10],f=t[11],e[0]=r=t[0],e[1]=n,e[2]=o,e[3]=s,e[4]=a,e[5]=l,e[6]=c,e[7]=h,e[8]=u,e[9]=d,e[10]=p,e[11]=f,e[12]=r*m+a*_+u*g+t[12],e[13]=n*m+l*_+d*g+t[13],e[14]=o*m+c*_+p*g+t[14],e[15]=s*m+h*_+f*g+t[15]),e},Ec.scale=function(e,t,i){var r=i[0],n=i[1],o=i[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*n,e[5]=t[5]*n,e[6]=t[6]*n,e[7]=t[7]*n,e[8]=t[8]*o,e[9]=t[9]*o,e[10]=t[10]*o,e[11]=t[11]*o,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},Ec.rotate=function(e,t,i,r){var n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,M,A,S,I=r[0],C=r[1],z=r[2],D=Math.hypot(I,C,z);return D0?(i[0]=2*(a*s+h*r+l*o-c*n)/u,i[1]=2*(l*s+h*n+c*r-a*o)/u,i[2]=2*(c*s+h*o+a*n-l*r)/u):(i[0]=2*(a*s+h*r+l*o-c*n),i[1]=2*(l*s+h*n+c*r-a*o),i[2]=2*(c*s+h*o+a*n-l*r)),zc(e,t,i),e},Ec.getTranslation=function(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e},Ec.getScaling=Dc,Ec.getRotation=function(e,t){var i=new Ac.ARRAY_TYPE(3);Dc(i,t);var r=1/i[0],n=1/i[1],o=1/i[2],s=t[0]*r,a=t[1]*n,l=t[2]*o,c=t[4]*r,h=t[5]*n,u=t[6]*o,d=t[8]*r,p=t[9]*n,f=t[10]*o,m=s+h+f,_=0;return m>0?(_=2*Math.sqrt(m+1),e[3]=.25*_,e[0]=(u-p)/_,e[1]=(d-l)/_,e[2]=(a-c)/_):s>h&&s>f?(_=2*Math.sqrt(1+s-h-f),e[3]=(u-p)/_,e[0]=.25*_,e[1]=(a+c)/_,e[2]=(d+l)/_):h>f?(_=2*Math.sqrt(1+h-s-f),e[3]=(d-l)/_,e[0]=(a+c)/_,e[1]=.25*_,e[2]=(u+p)/_):(_=2*Math.sqrt(1+f-s-h),e[3]=(a-c)/_,e[0]=(d+l)/_,e[1]=(u+p)/_,e[2]=.25*_),e},Ec.fromRotationTranslationScale=function(e,t,i,r){var n=t[0],o=t[1],s=t[2],a=t[3],l=n+n,c=o+o,h=s+s,u=n*l,d=n*c,p=n*h,f=o*c,m=o*h,_=s*h,g=a*l,y=a*c,x=a*h,v=r[0],b=r[1],w=r[2];return e[0]=(1-(f+_))*v,e[1]=(d+x)*v,e[2]=(p-y)*v,e[3]=0,e[4]=(d-x)*b,e[5]=(1-(u+_))*b,e[6]=(m+g)*b,e[7]=0,e[8]=(p+y)*w,e[9]=(m-g)*w,e[10]=(1-(u+f))*w,e[11]=0,e[12]=i[0],e[13]=i[1],e[14]=i[2],e[15]=1,e},Ec.fromRotationTranslationScaleOrigin=function(e,t,i,r,n){var o=t[0],s=t[1],a=t[2],l=t[3],c=o+o,h=s+s,u=a+a,d=o*c,p=o*h,f=o*u,m=s*h,_=s*u,g=a*u,y=l*c,x=l*h,v=l*u,b=r[0],w=r[1],T=r[2],E=n[0],M=n[1],A=n[2],S=(1-(m+g))*b,I=(p+v)*b,C=(f-x)*b,z=(p-v)*w,D=(1-(d+g))*w,P=(_+y)*w,R=(f+x)*T,L=(_-y)*T,k=(1-(d+m))*T;return e[0]=S,e[1]=I,e[2]=C,e[3]=0,e[4]=z,e[5]=D,e[6]=P,e[7]=0,e[8]=R,e[9]=L,e[10]=k,e[11]=0,e[12]=i[0]+E-(S*E+z*M+R*A),e[13]=i[1]+M-(I*E+D*M+L*A),e[14]=i[2]+A-(C*E+P*M+k*A),e[15]=1,e},Ec.fromQuat=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=i+i,a=r+r,l=n+n,c=i*s,h=r*s,u=r*a,d=n*s,p=n*a,f=n*l,m=o*s,_=o*a,g=o*l;return e[0]=1-u-f,e[1]=h+g,e[2]=d-_,e[3]=0,e[4]=h-g,e[5]=1-c-f,e[6]=p+m,e[7]=0,e[8]=d+_,e[9]=p-m,e[10]=1-c-u,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},Ec.frustum=function(e,t,i,r,n,o,s){var a=1/(i-t),l=1/(n-r),c=1/(o-s);return e[0]=2*o*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*o*l,e[6]=0,e[7]=0,e[8]=(i+t)*a,e[9]=(n+r)*l,e[10]=(s+o)*c,e[11]=-1,e[12]=0,e[13]=0,e[14]=s*o*2*c,e[15]=0,e},Ec.perspectiveNO=Pc,Ec.perspectiveZO=function(e,t,i,r,n){var o,s=1/Math.tan(t/2);return e[0]=s/i,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=n&&n!==1/0?(e[10]=n*(o=1/(r-n)),e[14]=n*r*o):(e[10]=-1,e[14]=-r),e},Ec.perspectiveFromFieldOfView=function(e,t,i,r){var n=Math.tan(t.upDegrees*Math.PI/180),o=Math.tan(t.downDegrees*Math.PI/180),s=Math.tan(t.leftDegrees*Math.PI/180),a=Math.tan(t.rightDegrees*Math.PI/180),l=2/(s+a),c=2/(n+o);return e[0]=l,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=c,e[6]=0,e[7]=0,e[8]=-(s-a)*l*.5,e[9]=(n-o)*c*.5,e[10]=r/(i-r),e[11]=-1,e[12]=0,e[13]=0,e[14]=r*i/(i-r),e[15]=0,e},Ec.orthoNO=Rc,Ec.orthoZO=function(e,t,i,r,n,o,s){var a=1/(t-i),l=1/(r-n),c=1/(o-s);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=c,e[11]=0,e[12]=(t+i)*a,e[13]=(n+r)*l,e[14]=o*c,e[15]=1,e},Ec.lookAt=function(e,t,i,r){var n,o,s,a,l,c,h,u,d,p,f=t[0],m=t[1],_=t[2],g=r[0],y=r[1],x=r[2],v=i[0],b=i[1],w=i[2];return Math.abs(f-v)0&&(h*=p=1/Math.sqrt(p),u*=p,d*=p);var f=l*d-c*u,m=c*h-a*d,_=a*u-l*h;return (p=f*f+m*m+_*_)>0&&(f*=p=1/Math.sqrt(p),m*=p,_*=p),e[0]=f,e[1]=m,e[2]=_,e[3]=0,e[4]=u*_-d*m,e[5]=d*f-h*_,e[6]=h*m-u*f,e[7]=0,e[8]=h,e[9]=u,e[10]=d,e[11]=0,e[12]=n,e[13]=o,e[14]=s,e[15]=1,e},Ec.str=function(e){return "mat4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+", "+e[9]+", "+e[10]+", "+e[11]+", "+e[12]+", "+e[13]+", "+e[14]+", "+e[15]+")"},Ec.frob=function(e){return Math.hypot(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])},Ec.add=function(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e[3]=t[3]+i[3],e[4]=t[4]+i[4],e[5]=t[5]+i[5],e[6]=t[6]+i[6],e[7]=t[7]+i[7],e[8]=t[8]+i[8],e[9]=t[9]+i[9],e[10]=t[10]+i[10],e[11]=t[11]+i[11],e[12]=t[12]+i[12],e[13]=t[13]+i[13],e[14]=t[14]+i[14],e[15]=t[15]+i[15],e},Ec.subtract=Lc,Ec.multiplyScalar=function(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*i,e[9]=t[9]*i,e[10]=t[10]*i,e[11]=t[11]*i,e[12]=t[12]*i,e[13]=t[13]*i,e[14]=t[14]*i,e[15]=t[15]*i,e},Ec.multiplyScalarAndAdd=function(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e[2]=t[2]+i[2]*r,e[3]=t[3]+i[3]*r,e[4]=t[4]+i[4]*r,e[5]=t[5]+i[5]*r,e[6]=t[6]+i[6]*r,e[7]=t[7]+i[7]*r,e[8]=t[8]+i[8]*r,e[9]=t[9]+i[9]*r,e[10]=t[10]+i[10]*r,e[11]=t[11]+i[11]*r,e[12]=t[12]+i[12]*r,e[13]=t[13]+i[13]*r,e[14]=t[14]+i[14]*r,e[15]=t[15]+i[15]*r,e},Ec.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]},Ec.equals=function(e,t){var i=e[0],r=e[1],n=e[2],o=e[3],s=e[4],a=e[5],l=e[6],c=e[7],h=e[8],u=e[9],d=e[10],p=e[11],f=e[12],m=e[13],_=e[14],g=e[15],y=t[0],x=t[1],v=t[2],b=t[3],w=t[4],T=t[5],E=t[6],M=t[7],A=t[8],S=t[9],I=t[10],C=t[11],z=t[12],D=t[13],P=t[14],R=t[15];return Math.abs(i-y)<=Ac.EPSILON*Math.max(1,Math.abs(i),Math.abs(y))&&Math.abs(r-x)<=Ac.EPSILON*Math.max(1,Math.abs(r),Math.abs(x))&&Math.abs(n-v)<=Ac.EPSILON*Math.max(1,Math.abs(n),Math.abs(v))&&Math.abs(o-b)<=Ac.EPSILON*Math.max(1,Math.abs(o),Math.abs(b))&&Math.abs(s-w)<=Ac.EPSILON*Math.max(1,Math.abs(s),Math.abs(w))&&Math.abs(a-T)<=Ac.EPSILON*Math.max(1,Math.abs(a),Math.abs(T))&&Math.abs(l-E)<=Ac.EPSILON*Math.max(1,Math.abs(l),Math.abs(E))&&Math.abs(c-M)<=Ac.EPSILON*Math.max(1,Math.abs(c),Math.abs(M))&&Math.abs(h-A)<=Ac.EPSILON*Math.max(1,Math.abs(h),Math.abs(A))&&Math.abs(u-S)<=Ac.EPSILON*Math.max(1,Math.abs(u),Math.abs(S))&&Math.abs(d-I)<=Ac.EPSILON*Math.max(1,Math.abs(d),Math.abs(I))&&Math.abs(p-C)<=Ac.EPSILON*Math.max(1,Math.abs(p),Math.abs(C))&&Math.abs(f-z)<=Ac.EPSILON*Math.max(1,Math.abs(f),Math.abs(z))&&Math.abs(m-D)<=Ac.EPSILON*Math.max(1,Math.abs(m),Math.abs(D))&&Math.abs(_-P)<=Ac.EPSILON*Math.max(1,Math.abs(_),Math.abs(P))&&Math.abs(g-R)<=Ac.EPSILON*Math.max(1,Math.abs(g),Math.abs(R))},Ec.sub=Ec.mul=Ec.ortho=Ec.perspective=void 0;var Ac=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==Mc(e)&&"function"!=typeof e)return {default:e};var i=Sc(void 0);if(i&&i.has(e))return i.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=n?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(r,o,s):r[o]=e[o];}return r.default=e,i&&i.set(e,r),r}(tc);function Sc(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return (Sc=function(e){return e?i:t})(e)}function Ic(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Cc(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],h=t[7],u=t[8],d=t[9],p=t[10],f=t[11],m=t[12],_=t[13],g=t[14],y=t[15],x=i[0],v=i[1],b=i[2],w=i[3];return e[0]=x*r+v*a+b*u+w*m,e[1]=x*n+v*l+b*d+w*_,e[2]=x*o+v*c+b*p+w*g,e[3]=x*s+v*h+b*f+w*y,e[4]=(x=i[4])*r+(v=i[5])*a+(b=i[6])*u+(w=i[7])*m,e[5]=x*n+v*l+b*d+w*_,e[6]=x*o+v*c+b*p+w*g,e[7]=x*s+v*h+b*f+w*y,e[8]=(x=i[8])*r+(v=i[9])*a+(b=i[10])*u+(w=i[11])*m,e[9]=x*n+v*l+b*d+w*_,e[10]=x*o+v*c+b*p+w*g,e[11]=x*s+v*h+b*f+w*y,e[12]=(x=i[12])*r+(v=i[13])*a+(b=i[14])*u+(w=i[15])*m,e[13]=x*n+v*l+b*d+w*_,e[14]=x*o+v*c+b*p+w*g,e[15]=x*s+v*h+b*f+w*y,e}function zc(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=r+r,l=n+n,c=o+o,h=r*a,u=r*l,d=r*c,p=n*l,f=n*c,m=o*c,_=s*a,g=s*l,y=s*c;return e[0]=1-(p+m),e[1]=u+y,e[2]=d-g,e[3]=0,e[4]=u-y,e[5]=1-(h+m),e[6]=f+_,e[7]=0,e[8]=d+g,e[9]=f-_,e[10]=1-(h+p),e[11]=0,e[12]=i[0],e[13]=i[1],e[14]=i[2],e[15]=1,e}function Dc(e,t){var i=t[4],r=t[5],n=t[6],o=t[8],s=t[9],a=t[10];return e[0]=Math.hypot(t[0],t[1],t[2]),e[1]=Math.hypot(i,r,n),e[2]=Math.hypot(o,s,a),e}function Pc(e,t,i,r,n){var o,s=1/Math.tan(t/2);return e[0]=s/i,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=n&&n!==1/0?(e[10]=(n+r)*(o=1/(r-n)),e[14]=2*n*r*o):(e[10]=-1,e[14]=-2*r),e}function Rc(e,t,i,r,n,o,s){var a=1/(t-i),l=1/(r-n),c=1/(o-s);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*c,e[11]=0,e[12]=(t+i)*a,e[13]=(n+r)*l,e[14]=(s+o)*c,e[15]=1,e}function Lc(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e[3]=t[3]-i[3],e[4]=t[4]-i[4],e[5]=t[5]-i[5],e[6]=t[6]-i[6],e[7]=t[7]-i[7],e[8]=t[8]-i[8],e[9]=t[9]-i[9],e[10]=t[10]-i[10],e[11]=t[11]-i[11],e[12]=t[12]-i[12],e[13]=t[13]-i[13],e[14]=t[14]-i[14],e[15]=t[15]-i[15],e}Ec.perspective=Pc,Ec.ortho=Rc,Ec.mul=Cc,Ec.sub=Lc;var kc={},Oc={};function Bc(e){return Bc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Bc(e)}Object.defineProperty(Oc,"__esModule",{value:!0}),Oc.create=Uc,Oc.clone=function(e){var t=new Fc.ARRAY_TYPE(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},Oc.length=Vc,Oc.fromValues=function(e,t,i){var r=new Fc.ARRAY_TYPE(3);return r[0]=e,r[1]=t,r[2]=i,r},Oc.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},Oc.set=function(e,t,i,r){return e[0]=t,e[1]=i,e[2]=r,e},Oc.add=function(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e},Oc.subtract=jc,Oc.multiply=Gc,Oc.divide=qc,Oc.ceil=function(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e},Oc.floor=function(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e},Oc.min=function(e,t,i){return e[0]=Math.min(t[0],i[0]),e[1]=Math.min(t[1],i[1]),e[2]=Math.min(t[2],i[2]),e},Oc.max=function(e,t,i){return e[0]=Math.max(t[0],i[0]),e[1]=Math.max(t[1],i[1]),e[2]=Math.max(t[2],i[2]),e},Oc.round=function(e,t){return e[0]=Math.round(t[0]),e[1]=Math.round(t[1]),e[2]=Math.round(t[2]),e},Oc.scale=function(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e},Oc.scaleAndAdd=function(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e[2]=t[2]+i[2]*r,e},Oc.distance=Zc,Oc.squaredDistance=$c,Oc.squaredLength=Hc,Oc.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e},Oc.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e},Oc.normalize=function(e,t){var i=t[0],r=t[1],n=t[2],o=i*i+r*r+n*n;return o>0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e},Oc.dot=Wc,Oc.cross=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=i[0],a=i[1],l=i[2];return e[0]=n*l-o*a,e[1]=o*s-r*l,e[2]=r*a-n*s,e},Oc.lerp=function(e,t,i,r){var n=t[0],o=t[1],s=t[2];return e[0]=n+r*(i[0]-n),e[1]=o+r*(i[1]-o),e[2]=s+r*(i[2]-s),e},Oc.hermite=function(e,t,i,r,n,o){var s=o*o,a=s*(2*o-3)+1,l=s*(o-2)+o,c=s*(o-1),h=s*(3-2*o);return e[0]=t[0]*a+i[0]*l+r[0]*c+n[0]*h,e[1]=t[1]*a+i[1]*l+r[1]*c+n[1]*h,e[2]=t[2]*a+i[2]*l+r[2]*c+n[2]*h,e},Oc.bezier=function(e,t,i,r,n,o){var s=1-o,a=s*s,l=o*o,c=a*s,h=3*o*a,u=3*l*s,d=l*o;return e[0]=t[0]*c+i[0]*h+r[0]*u+n[0]*d,e[1]=t[1]*c+i[1]*h+r[1]*u+n[1]*d,e[2]=t[2]*c+i[2]*h+r[2]*u+n[2]*d,e},Oc.random=function(e,t){t=t||1;var i=2*Fc.RANDOM()*Math.PI,r=2*Fc.RANDOM()-1,n=Math.sqrt(1-r*r)*t;return e[0]=Math.cos(i)*n,e[1]=Math.sin(i)*n,e[2]=r*t,e},Oc.transformMat4=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=i[3]*r+i[7]*n+i[11]*o+i[15];return e[0]=(i[0]*r+i[4]*n+i[8]*o+i[12])/(s=s||1),e[1]=(i[1]*r+i[5]*n+i[9]*o+i[13])/s,e[2]=(i[2]*r+i[6]*n+i[10]*o+i[14])/s,e},Oc.transformMat3=function(e,t,i){var r=t[0],n=t[1],o=t[2];return e[0]=r*i[0]+n*i[3]+o*i[6],e[1]=r*i[1]+n*i[4]+o*i[7],e[2]=r*i[2]+n*i[5]+o*i[8],e},Oc.transformQuat=function(e,t,i){var r=i[0],n=i[1],o=i[2],s=t[0],a=t[1],l=t[2],c=n*l-o*a,h=o*s-r*l,u=r*a-n*s,d=n*u-o*h,p=o*c-r*u,f=r*h-n*c,m=2*i[3];return h*=m,u*=m,p*=2,f*=2,e[0]=s+(c*=m)+(d*=2),e[1]=a+h+p,e[2]=l+u+f,e},Oc.rotateX=function(e,t,i,r){var n=[],o=[];return n[0]=t[0]-i[0],n[1]=t[1]-i[1],n[2]=t[2]-i[2],o[0]=n[0],o[1]=n[1]*Math.cos(r)-n[2]*Math.sin(r),o[2]=n[1]*Math.sin(r)+n[2]*Math.cos(r),e[0]=o[0]+i[0],e[1]=o[1]+i[1],e[2]=o[2]+i[2],e},Oc.rotateY=function(e,t,i,r){var n=[],o=[];return n[0]=t[0]-i[0],n[1]=t[1]-i[1],n[2]=t[2]-i[2],o[0]=n[2]*Math.sin(r)+n[0]*Math.cos(r),o[1]=n[1],o[2]=n[2]*Math.cos(r)-n[0]*Math.sin(r),e[0]=o[0]+i[0],e[1]=o[1]+i[1],e[2]=o[2]+i[2],e},Oc.rotateZ=function(e,t,i,r){var n=[],o=[];return n[0]=t[0]-i[0],n[1]=t[1]-i[1],n[2]=t[2]-i[2],o[0]=n[0]*Math.cos(r)-n[1]*Math.sin(r),o[1]=n[0]*Math.sin(r)+n[1]*Math.cos(r),o[2]=n[2],e[0]=o[0]+i[0],e[1]=o[1]+i[1],e[2]=o[2]+i[2],e},Oc.angle=function(e,t){var i=e[0],r=e[1],n=e[2],o=t[0],s=t[1],a=t[2],l=Math.sqrt(i*i+r*r+n*n)*Math.sqrt(o*o+s*s+a*a),c=l&&Wc(e,t)/l;return Math.acos(Math.min(Math.max(c,-1),1))},Oc.zero=function(e){return e[0]=0,e[1]=0,e[2]=0,e},Oc.str=function(e){return "vec3("+e[0]+", "+e[1]+", "+e[2]+")"},Oc.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]},Oc.equals=function(e,t){var i=e[0],r=e[1],n=e[2],o=t[0],s=t[1],a=t[2];return Math.abs(i-o)<=Fc.EPSILON*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(r-s)<=Fc.EPSILON*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(n-a)<=Fc.EPSILON*Math.max(1,Math.abs(n),Math.abs(a))},Oc.forEach=Oc.sqrLen=Oc.len=Oc.sqrDist=Oc.dist=Oc.div=Oc.mul=Oc.sub=void 0;var Fc=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==Bc(e)&&"function"!=typeof e)return {default:e};var i=Nc(void 0);if(i&&i.has(e))return i.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=n?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(r,o,s):r[o]=e[o];}return r.default=e,i&&i.set(e,r),r}(tc);function Nc(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return (Nc=function(e){return e?i:t})(e)}function Uc(){var e=new Fc.ARRAY_TYPE(3);return Fc.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function Vc(e){return Math.hypot(e[0],e[1],e[2])}function jc(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e}function Gc(e,t,i){return e[0]=t[0]*i[0],e[1]=t[1]*i[1],e[2]=t[2]*i[2],e}function qc(e,t,i){return e[0]=t[0]/i[0],e[1]=t[1]/i[1],e[2]=t[2]/i[2],e}function Zc(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2])}function $c(e,t){var i=t[0]-e[0],r=t[1]-e[1],n=t[2]-e[2];return i*i+r*r+n*n}function Hc(e){var t=e[0],i=e[1],r=e[2];return t*t+i*i+r*r}function Wc(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}Oc.sub=jc,Oc.mul=Gc,Oc.div=qc,Oc.dist=Zc,Oc.sqrDist=$c,Oc.len=Vc,Oc.sqrLen=Hc;var Xc,Yc=(Xc=Uc(),function(e,t,i,r,n,o){var s,a;for(t||(t=3),i||(i=0),a=r?Math.min(r*t+i,e.length):e.length,s=i;s0&&(s=1/Math.sqrt(s)),e[0]=i*s,e[1]=r*s,e[2]=n*s,e[3]=o*s,e},Kc.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},Kc.cross=function(e,t,i,r){var n=i[0]*r[1]-i[1]*r[0],o=i[0]*r[2]-i[2]*r[0],s=i[0]*r[3]-i[3]*r[0],a=i[1]*r[2]-i[2]*r[1],l=i[1]*r[3]-i[3]*r[1],c=i[2]*r[3]-i[3]*r[2],h=t[0],u=t[1],d=t[2],p=t[3];return e[0]=u*c-d*l+p*a,e[1]=-h*c+d*s-p*o,e[2]=h*l-u*s+p*n,e[3]=-h*a+u*o-d*n,e},Kc.lerp=function(e,t,i,r){var n=t[0],o=t[1],s=t[2],a=t[3];return e[0]=n+r*(i[0]-n),e[1]=o+r*(i[1]-o),e[2]=s+r*(i[2]-s),e[3]=a+r*(i[3]-a),e},Kc.random=function(e,t){var i,r,n,o,s,a;t=t||1;do{s=(i=2*Qc.RANDOM()-1)*i+(r=2*Qc.RANDOM()-1)*r;}while(s>=1);do{a=(n=2*Qc.RANDOM()-1)*n+(o=2*Qc.RANDOM()-1)*o;}while(a>=1);var l=Math.sqrt((1-s)/a);return e[0]=t*i,e[1]=t*r,e[2]=t*n*l,e[3]=t*o*l,e},Kc.transformMat4=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3];return e[0]=i[0]*r+i[4]*n+i[8]*o+i[12]*s,e[1]=i[1]*r+i[5]*n+i[9]*o+i[13]*s,e[2]=i[2]*r+i[6]*n+i[10]*o+i[14]*s,e[3]=i[3]*r+i[7]*n+i[11]*o+i[15]*s,e},Kc.transformQuat=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=i[0],a=i[1],l=i[2],c=i[3],h=c*r+a*o-l*n,u=c*n+l*r-s*o,d=c*o+s*n-a*r,p=-s*r-a*n-l*o;return e[0]=h*c+p*-s+u*-l-d*-a,e[1]=u*c+p*-a+d*-s-h*-l,e[2]=d*c+p*-l+h*-a-u*-s,e[3]=t[3],e},Kc.zero=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e},Kc.str=function(e){return "vec4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},Kc.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]},Kc.equals=function(e,t){var i=e[0],r=e[1],n=e[2],o=e[3],s=t[0],a=t[1],l=t[2],c=t[3];return Math.abs(i-s)<=Qc.EPSILON*Math.max(1,Math.abs(i),Math.abs(s))&&Math.abs(r-a)<=Qc.EPSILON*Math.max(1,Math.abs(r),Math.abs(a))&&Math.abs(n-l)<=Qc.EPSILON*Math.max(1,Math.abs(n),Math.abs(l))&&Math.abs(o-c)<=Qc.EPSILON*Math.max(1,Math.abs(o),Math.abs(c))},Kc.forEach=Kc.sqrLen=Kc.len=Kc.sqrDist=Kc.dist=Kc.div=Kc.mul=Kc.sub=void 0;var Qc=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==Jc(e)&&"function"!=typeof e)return {default:e};var i=eh(void 0);if(i&&i.has(e))return i.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=n?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(r,o,s):r[o]=e[o];}return r.default=e,i&&i.set(e,r),r}(tc);function eh(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return (eh=function(e){return e?i:t})(e)}function th(){var e=new Qc.ARRAY_TYPE(4);return Qc.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function ih(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e[3]=t[3]-i[3],e}function rh(e,t,i){return e[0]=t[0]*i[0],e[1]=t[1]*i[1],e[2]=t[2]*i[2],e[3]=t[3]*i[3],e}function nh(e,t,i){return e[0]=t[0]/i[0],e[1]=t[1]/i[1],e[2]=t[2]/i[2],e[3]=t[3]/i[3],e}function oh(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2],t[3]-e[3])}function sh(e,t){var i=t[0]-e[0],r=t[1]-e[1],n=t[2]-e[2],o=t[3]-e[3];return i*i+r*r+n*n+o*o}function ah(e){return Math.hypot(e[0],e[1],e[2],e[3])}function lh(e){var t=e[0],i=e[1],r=e[2],n=e[3];return t*t+i*i+r*r+n*n}Kc.sub=ih,Kc.mul=rh,Kc.div=nh,Kc.dist=oh,Kc.sqrDist=sh,Kc.len=ah,Kc.sqrLen=lh;var ch=function(){var e=th();return function(t,i,r,n,o,s){var a,l;for(i||(i=4),r||(r=0),l=n?Math.min(n*i+r,t.length):t.length,a=r;auh.EPSILON?(e[0]=t[0]/r,e[1]=t[1]/r,e[2]=t[2]/r):(e[0]=1,e[1]=0,e[2]=0),i},kc.getAngle=function(e,t){var i=Mh(e,t);return Math.acos(2*i*i-1)},kc.multiply=xh,kc.rotateX=function(e,t,i){i*=.5;var r=t[0],n=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);return e[0]=r*l+s*a,e[1]=n*l+o*a,e[2]=o*l-n*a,e[3]=s*l-r*a,e},kc.rotateY=function(e,t,i){i*=.5;var r=t[0],n=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);return e[0]=r*l-o*a,e[1]=n*l+s*a,e[2]=o*l+r*a,e[3]=s*l-n*a,e},kc.rotateZ=function(e,t,i){i*=.5;var r=t[0],n=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);return e[0]=r*l+n*a,e[1]=n*l-r*a,e[2]=o*l+s*a,e[3]=s*l-o*a,e},kc.calculateW=function(e,t){var i=t[0],r=t[1],n=t[2];return e[0]=i,e[1]=r,e[2]=n,e[3]=Math.sqrt(Math.abs(1-i*i-r*r-n*n)),e},kc.exp=vh,kc.ln=bh,kc.pow=function(e,t,i){return bh(e,t),Eh(e,e,i),vh(e,e),e},kc.slerp=wh,kc.random=function(e){var t=uh.RANDOM(),i=uh.RANDOM(),r=uh.RANDOM(),n=Math.sqrt(1-t),o=Math.sqrt(t);return e[0]=n*Math.sin(2*Math.PI*i),e[1]=n*Math.cos(2*Math.PI*i),e[2]=o*Math.sin(2*Math.PI*r),e[3]=o*Math.cos(2*Math.PI*r),e},kc.invert=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=i*i+r*r+n*n+o*o,a=s?1/s:0;return e[0]=-i*a,e[1]=-r*a,e[2]=-n*a,e[3]=o*a,e},kc.conjugate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},kc.fromMat3=Th,kc.fromEuler=function(e,t,i,r){var n=.5*Math.PI/180;t*=n,i*=n,r*=n;var o=Math.sin(t),s=Math.cos(t),a=Math.sin(i),l=Math.cos(i),c=Math.sin(r),h=Math.cos(r);return e[0]=o*l*h-s*a*c,e[1]=s*a*h+o*l*c,e[2]=s*l*c-o*a*h,e[3]=s*l*h+o*a*c,e},kc.str=function(e){return "quat("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},kc.setAxes=kc.sqlerp=kc.rotationTo=kc.equals=kc.exactEquals=kc.normalize=kc.sqrLen=kc.squaredLength=kc.len=kc.length=kc.lerp=kc.dot=kc.scale=kc.mul=kc.add=kc.set=kc.copy=kc.fromValues=kc.clone=void 0;var uh=_h(tc),dh=_h(yc),ph=_h(Oc),fh=_h(Kc);function mh(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return (mh=function(e){return e?i:t})(e)}function _h(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!==hh(e)&&"function"!=typeof e)return {default:e};var i=mh(t);if(i&&i.has(e))return i.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=n?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(r,o,s):r[o]=e[o];}return r.default=e,i&&i.set(e,r),r}function gh(){var e=new uh.ARRAY_TYPE(4);return uh.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function yh(e,t,i){i*=.5;var r=Math.sin(i);return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=Math.cos(i),e}function xh(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=i[0],l=i[1],c=i[2],h=i[3];return e[0]=r*h+s*a+n*c-o*l,e[1]=n*h+s*l+o*a-r*c,e[2]=o*h+s*c+r*l-n*a,e[3]=s*h-r*a-n*l-o*c,e}function vh(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=Math.sqrt(i*i+r*r+n*n),a=Math.exp(o),l=s>0?a*Math.sin(s)/s:0;return e[0]=i*l,e[1]=r*l,e[2]=n*l,e[3]=a*Math.cos(s),e}function bh(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=Math.sqrt(i*i+r*r+n*n),a=s>0?Math.atan2(s,o)/s:0;return e[0]=i*a,e[1]=r*a,e[2]=n*a,e[3]=.5*Math.log(i*i+r*r+n*n+o*o),e}function wh(e,t,i,r){var n,o,s,a,l,c=t[0],h=t[1],u=t[2],d=t[3],p=i[0],f=i[1],m=i[2],_=i[3];return (o=c*p+h*f+u*m+d*_)<0&&(o=-o,p=-p,f=-f,m=-m,_=-_),1-o>uh.EPSILON?(n=Math.acos(o),s=Math.sin(n),a=Math.sin((1-r)*n)/s,l=Math.sin(r*n)/s):(a=1-r,l=r),e[0]=a*c+l*p,e[1]=a*h+l*f,e[2]=a*u+l*m,e[3]=a*d+l*_,e}function Th(e,t){var i,r=t[0]+t[4]+t[8];if(r>0)i=Math.sqrt(r+1),e[3]=.5*i,e[0]=(t[5]-t[7])*(i=.5/i),e[1]=(t[6]-t[2])*i,e[2]=(t[1]-t[3])*i;else {var n=0;t[4]>t[0]&&(n=1),t[8]>t[3*n+n]&&(n=2);var o=(n+1)%3,s=(n+2)%3;i=Math.sqrt(t[3*n+n]-t[3*o+o]-t[3*s+s]+1),e[n]=.5*i,e[3]=(t[3*o+s]-t[3*s+o])*(i=.5/i),e[o]=(t[3*o+n]+t[3*n+o])*i,e[s]=(t[3*s+n]+t[3*n+s])*i;}return e}kc.clone=fh.clone,kc.fromValues=fh.fromValues,kc.copy=fh.copy,kc.set=fh.set,kc.add=fh.add,kc.mul=xh;var Eh=fh.scale;kc.scale=Eh;var Mh=fh.dot;kc.dot=Mh,kc.lerp=fh.lerp;var Ah=fh.length;kc.length=Ah,kc.len=Ah;var Sh=fh.squaredLength;kc.squaredLength=Sh,kc.sqrLen=Sh;var Ih=fh.normalize;kc.normalize=Ih,kc.exactEquals=fh.exactEquals,kc.equals=fh.equals;var Ch,zh,Dh,Ph=(Ch=ph.create(),zh=ph.fromValues(1,0,0),Dh=ph.fromValues(0,1,0),function(e,t,i){var r=ph.dot(t,i);return r<-.999999?(ph.cross(Ch,zh,t),ph.len(Ch)<1e-6&&ph.cross(Ch,Dh,t),ph.normalize(Ch,Ch),yh(e,Ch,Math.PI),e):r>.999999?(e[0]=0,e[1]=0,e[2]=0,e[3]=1,e):(ph.cross(Ch,t,i),e[0]=Ch[0],e[1]=Ch[1],e[2]=Ch[2],e[3]=1+r,Ih(e,e))});kc.rotationTo=Ph;var Rh,Lh,kh=(Rh=gh(),Lh=gh(),function(e,t,i,r,n,o){return wh(Rh,t,n,o),wh(Lh,i,r,o),wh(e,Rh,Lh,2*o*(1-o)),e});kc.sqlerp=kh;var Oh,Bh=(Oh=dh.create(),function(e,t,i,r){return Oh[0]=i[0],Oh[3]=i[1],Oh[6]=i[2],Oh[1]=r[0],Oh[4]=r[1],Oh[7]=r[2],Oh[2]=-t[0],Oh[5]=-t[1],Oh[8]=-t[2],Ih(e,Th(e,Oh))});kc.setAxes=Bh;var Fh={};function Nh(e){return Nh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Nh(e)}Object.defineProperty(Fh,"__esModule",{value:!0}),Fh.create=function(){var e=new Uh.ARRAY_TYPE(8);return Uh.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[4]=0,e[5]=0,e[6]=0,e[7]=0),e[3]=1,e},Fh.clone=function(e){var t=new Uh.ARRAY_TYPE(8);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t},Fh.fromValues=function(e,t,i,r,n,o,s,a){var l=new Uh.ARRAY_TYPE(8);return l[0]=e,l[1]=t,l[2]=i,l[3]=r,l[4]=n,l[5]=o,l[6]=s,l[7]=a,l},Fh.fromRotationTranslationValues=function(e,t,i,r,n,o,s){var a=new Uh.ARRAY_TYPE(8);a[0]=e,a[1]=t,a[2]=i,a[3]=r;var l=.5*n,c=.5*o,h=.5*s;return a[4]=l*r+c*i-h*t,a[5]=c*r+h*e-l*i,a[6]=h*r+l*t-c*e,a[7]=-l*e-c*t-h*i,a},Fh.fromRotationTranslation=Zh,Fh.fromTranslation=function(e,t){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e[4]=.5*t[0],e[5]=.5*t[1],e[6]=.5*t[2],e[7]=0,e},Fh.fromRotation=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=0,e[5]=0,e[6]=0,e[7]=0,e},Fh.fromMat4=function(e,t){var i=Vh.create();jh.getRotation(i,t);var r=new Uh.ARRAY_TYPE(3);return jh.getTranslation(r,t),Zh(e,i,r),e},Fh.copy=$h,Fh.identity=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e[6]=0,e[7]=0,e},Fh.set=function(e,t,i,r,n,o,s,a,l){return e[0]=t,e[1]=i,e[2]=r,e[3]=n,e[4]=o,e[5]=s,e[6]=a,e[7]=l,e},Fh.getDual=function(e,t){return e[0]=t[4],e[1]=t[5],e[2]=t[6],e[3]=t[7],e},Fh.setDual=function(e,t){return e[4]=t[0],e[5]=t[1],e[6]=t[2],e[7]=t[3],e},Fh.getTranslation=function(e,t){var i=t[4],r=t[5],n=t[6],o=t[7],s=-t[0],a=-t[1],l=-t[2],c=t[3];return e[0]=2*(i*c+o*s+r*l-n*a),e[1]=2*(r*c+o*a+n*s-i*l),e[2]=2*(n*c+o*l+i*a-r*s),e},Fh.translate=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=.5*i[0],l=.5*i[1],c=.5*i[2],h=t[4],u=t[5],d=t[6],p=t[7];return e[0]=r,e[1]=n,e[2]=o,e[3]=s,e[4]=s*a+n*c-o*l+h,e[5]=s*l+o*a-r*c+u,e[6]=s*c+r*l-n*a+d,e[7]=-r*a-n*l-o*c+p,e},Fh.rotateX=function(e,t,i){var r=-t[0],n=-t[1],o=-t[2],s=t[3],a=t[4],l=t[5],c=t[6],h=t[7],u=a*s+h*r+l*o-c*n,d=l*s+h*n+c*r-a*o,p=c*s+h*o+a*n-l*r,f=h*s-a*r-l*n-c*o;return Vh.rotateX(e,t,i),e[4]=u*(s=e[3])+f*(r=e[0])+d*(o=e[2])-p*(n=e[1]),e[5]=d*s+f*n+p*r-u*o,e[6]=p*s+f*o+u*n-d*r,e[7]=f*s-u*r-d*n-p*o,e},Fh.rotateY=function(e,t,i){var r=-t[0],n=-t[1],o=-t[2],s=t[3],a=t[4],l=t[5],c=t[6],h=t[7],u=a*s+h*r+l*o-c*n,d=l*s+h*n+c*r-a*o,p=c*s+h*o+a*n-l*r,f=h*s-a*r-l*n-c*o;return Vh.rotateY(e,t,i),e[4]=u*(s=e[3])+f*(r=e[0])+d*(o=e[2])-p*(n=e[1]),e[5]=d*s+f*n+p*r-u*o,e[6]=p*s+f*o+u*n-d*r,e[7]=f*s-u*r-d*n-p*o,e},Fh.rotateZ=function(e,t,i){var r=-t[0],n=-t[1],o=-t[2],s=t[3],a=t[4],l=t[5],c=t[6],h=t[7],u=a*s+h*r+l*o-c*n,d=l*s+h*n+c*r-a*o,p=c*s+h*o+a*n-l*r,f=h*s-a*r-l*n-c*o;return Vh.rotateZ(e,t,i),e[4]=u*(s=e[3])+f*(r=e[0])+d*(o=e[2])-p*(n=e[1]),e[5]=d*s+f*n+p*r-u*o,e[6]=p*s+f*o+u*n-d*r,e[7]=f*s-u*r-d*n-p*o,e},Fh.rotateByQuatAppend=function(e,t,i){var r=i[0],n=i[1],o=i[2],s=i[3],a=t[0],l=t[1],c=t[2],h=t[3];return e[0]=a*s+h*r+l*o-c*n,e[1]=l*s+h*n+c*r-a*o,e[2]=c*s+h*o+a*n-l*r,e[3]=h*s-a*r-l*n-c*o,e[4]=(a=t[4])*s+(h=t[7])*r+(l=t[5])*o-(c=t[6])*n,e[5]=l*s+h*n+c*r-a*o,e[6]=c*s+h*o+a*n-l*r,e[7]=h*s-a*r-l*n-c*o,e},Fh.rotateByQuatPrepend=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=i[0],l=i[1],c=i[2],h=i[3];return e[0]=r*h+s*a+n*c-o*l,e[1]=n*h+s*l+o*a-r*c,e[2]=o*h+s*c+r*l-n*a,e[3]=s*h-r*a-n*l-o*c,e[4]=r*(h=i[7])+s*(a=i[4])+n*(c=i[6])-o*(l=i[5]),e[5]=n*h+s*l+o*a-r*c,e[6]=o*h+s*c+r*l-n*a,e[7]=s*h-r*a-n*l-o*c,e},Fh.rotateAroundAxis=function(e,t,i,r){if(Math.abs(r)0){i=Math.sqrt(i);var r=t[0]/i,n=t[1]/i,o=t[2]/i,s=t[3]/i,a=t[4],l=t[5],c=t[6],h=t[7],u=r*a+n*l+o*c+s*h;e[0]=r,e[1]=n,e[2]=o,e[3]=s,e[4]=(a-r*u)/i,e[5]=(l-n*u)/i,e[6]=(c-o*u)/i,e[7]=(h-s*u)/i;}return e},Fh.str=function(e){return "quat2("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+")"},Fh.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]},Fh.equals=function(e,t){var i=e[0],r=e[1],n=e[2],o=e[3],s=e[4],a=e[5],l=e[6],c=e[7],h=t[0],u=t[1],d=t[2],p=t[3],f=t[4],m=t[5],_=t[6],g=t[7];return Math.abs(i-h)<=Uh.EPSILON*Math.max(1,Math.abs(i),Math.abs(h))&&Math.abs(r-u)<=Uh.EPSILON*Math.max(1,Math.abs(r),Math.abs(u))&&Math.abs(n-d)<=Uh.EPSILON*Math.max(1,Math.abs(n),Math.abs(d))&&Math.abs(o-p)<=Uh.EPSILON*Math.max(1,Math.abs(o),Math.abs(p))&&Math.abs(s-f)<=Uh.EPSILON*Math.max(1,Math.abs(s),Math.abs(f))&&Math.abs(a-m)<=Uh.EPSILON*Math.max(1,Math.abs(a),Math.abs(m))&&Math.abs(l-_)<=Uh.EPSILON*Math.max(1,Math.abs(l),Math.abs(_))&&Math.abs(c-g)<=Uh.EPSILON*Math.max(1,Math.abs(c),Math.abs(g))},Fh.sqrLen=Fh.squaredLength=Fh.len=Fh.length=Fh.dot=Fh.mul=Fh.setReal=Fh.getReal=void 0;var Uh=qh(tc),Vh=qh(kc),jh=qh(Ec);function Gh(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return (Gh=function(e){return e?i:t})(e)}function qh(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!==Nh(e)&&"function"!=typeof e)return {default:e};var i=Gh(t);if(i&&i.has(e))return i.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=n?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(r,o,s):r[o]=e[o];}return r.default=e,i&&i.set(e,r),r}function Zh(e,t,i){var r=.5*i[0],n=.5*i[1],o=.5*i[2],s=t[0],a=t[1],l=t[2],c=t[3];return e[0]=s,e[1]=a,e[2]=l,e[3]=c,e[4]=r*c+n*l-o*a,e[5]=n*c+o*s-r*l,e[6]=o*c+r*a-n*s,e[7]=-r*s-n*a-o*l,e}function $h(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e}function Hh(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=i[4],l=i[5],c=i[6],h=i[7],u=t[4],d=t[5],p=t[6],f=t[7],m=i[0],_=i[1],g=i[2],y=i[3];return e[0]=r*y+s*m+n*g-o*_,e[1]=n*y+s*_+o*m-r*g,e[2]=o*y+s*g+r*_-n*m,e[3]=s*y-r*m-n*_-o*g,e[4]=r*h+s*a+n*c-o*l+u*y+f*m+d*g-p*_,e[5]=n*h+s*l+o*a-r*c+d*y+f*_+p*m-u*g,e[6]=o*h+s*c+r*l-n*a+p*y+f*g+u*_-d*m,e[7]=s*h-r*a-n*l-o*c+f*y-u*m-d*_-p*g,e}Fh.getReal=Vh.copy,Fh.setReal=Vh.copy,Fh.mul=Hh;var Wh=Vh.dot;Fh.dot=Wh;var Xh=Vh.length;Fh.length=Xh,Fh.len=Xh;var Yh=Vh.squaredLength;Fh.squaredLength=Yh,Fh.sqrLen=Yh;var Kh={};function Jh(e){return Jh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Jh(e)}Object.defineProperty(Kh,"__esModule",{value:!0}),Kh.create=tu,Kh.clone=function(e){var t=new Qh.ARRAY_TYPE(2);return t[0]=e[0],t[1]=e[1],t},Kh.fromValues=function(e,t){var i=new Qh.ARRAY_TYPE(2);return i[0]=e,i[1]=t,i},Kh.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e},Kh.set=function(e,t,i){return e[0]=t,e[1]=i,e},Kh.add=function(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e},Kh.subtract=iu,Kh.multiply=ru,Kh.divide=nu,Kh.ceil=function(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e},Kh.floor=function(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e},Kh.min=function(e,t,i){return e[0]=Math.min(t[0],i[0]),e[1]=Math.min(t[1],i[1]),e},Kh.max=function(e,t,i){return e[0]=Math.max(t[0],i[0]),e[1]=Math.max(t[1],i[1]),e},Kh.round=function(e,t){return e[0]=Math.round(t[0]),e[1]=Math.round(t[1]),e},Kh.scale=function(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e},Kh.scaleAndAdd=function(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e},Kh.distance=ou,Kh.squaredDistance=su,Kh.length=au,Kh.squaredLength=lu,Kh.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e},Kh.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e},Kh.normalize=function(e,t){var i=t[0],r=t[1],n=i*i+r*r;return n>0&&(n=1/Math.sqrt(n)),e[0]=t[0]*n,e[1]=t[1]*n,e},Kh.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]},Kh.cross=function(e,t,i){var r=t[0]*i[1]-t[1]*i[0];return e[0]=e[1]=0,e[2]=r,e},Kh.lerp=function(e,t,i,r){var n=t[0],o=t[1];return e[0]=n+r*(i[0]-n),e[1]=o+r*(i[1]-o),e},Kh.random=function(e,t){t=t||1;var i=2*Qh.RANDOM()*Math.PI;return e[0]=Math.cos(i)*t,e[1]=Math.sin(i)*t,e},Kh.transformMat2=function(e,t,i){var r=t[0],n=t[1];return e[0]=i[0]*r+i[2]*n,e[1]=i[1]*r+i[3]*n,e},Kh.transformMat2d=function(e,t,i){var r=t[0],n=t[1];return e[0]=i[0]*r+i[2]*n+i[4],e[1]=i[1]*r+i[3]*n+i[5],e},Kh.transformMat3=function(e,t,i){var r=t[0],n=t[1];return e[0]=i[0]*r+i[3]*n+i[6],e[1]=i[1]*r+i[4]*n+i[7],e},Kh.transformMat4=function(e,t,i){var r=t[0],n=t[1];return e[0]=i[0]*r+i[4]*n+i[12],e[1]=i[1]*r+i[5]*n+i[13],e},Kh.rotate=function(e,t,i,r){var n=t[0]-i[0],o=t[1]-i[1],s=Math.sin(r),a=Math.cos(r);return e[0]=n*a-o*s+i[0],e[1]=n*s+o*a+i[1],e},Kh.angle=function(e,t){var i=e[0],r=e[1],n=t[0],o=t[1],s=Math.sqrt(i*i+r*r)*Math.sqrt(n*n+o*o);return Math.acos(Math.min(Math.max(s&&(i*n+r*o)/s,-1),1))},Kh.zero=function(e){return e[0]=0,e[1]=0,e},Kh.str=function(e){return "vec2("+e[0]+", "+e[1]+")"},Kh.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Kh.equals=function(e,t){var i=e[0],r=e[1],n=t[0],o=t[1];return Math.abs(i-n)<=Qh.EPSILON*Math.max(1,Math.abs(i),Math.abs(n))&&Math.abs(r-o)<=Qh.EPSILON*Math.max(1,Math.abs(r),Math.abs(o))},Kh.forEach=Kh.sqrLen=Kh.sqrDist=Kh.dist=Kh.div=Kh.mul=Kh.sub=Kh.len=void 0;var Qh=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==Jh(e)&&"function"!=typeof e)return {default:e};var i=eu(void 0);if(i&&i.has(e))return i.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=n?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(r,o,s):r[o]=e[o];}return r.default=e,i&&i.set(e,r),r}(tc);function eu(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return (eu=function(e){return e?i:t})(e)}function tu(){var e=new Qh.ARRAY_TYPE(2);return Qh.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0),e}function iu(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e}function ru(e,t,i){return e[0]=t[0]*i[0],e[1]=t[1]*i[1],e}function nu(e,t,i){return e[0]=t[0]/i[0],e[1]=t[1]/i[1],e}function ou(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1])}function su(e,t){var i=t[0]-e[0],r=t[1]-e[1];return i*i+r*r}function au(e){return Math.hypot(e[0],e[1])}function lu(e){var t=e[0],i=e[1];return t*t+i*i}Kh.len=au,Kh.sub=iu,Kh.mul=ru,Kh.div=nu,Kh.dist=ou,Kh.sqrDist=su,Kh.sqrLen=lu;var cu=function(){var e=tu();return function(t,i,r,n,o,s){var a,l;for(i||(i=2),r||(r=0),l=n?Math.min(n*i+r,t.length):t.length,a=r;a0;o--)r=1<this.canonical.z?new Bu(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Bu(e,this.wrap,e,this.canonical.x>>t,this.canonical.y>>t)}calculateScaledKey(e,t=!0){if(this.overscaledZ===e&&t)return this.key;if(e>this.canonical.z)return Fu(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y);{const i=this.canonical.z-e;return Fu(this.wrap*+t,e,e,this.canonical.x>>i,this.canonical.y>>i)}}isChildOf(e){if(e.wrap!==this.wrap)return !1;const t=this.canonical.z-e.canonical.z;return 0===e.overscaledZ||e.overscaledZ>t&&e.canonical.y===this.canonical.y>>t}children(e){if(this.overscaledZ>=e)return [new Bu(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const t=this.canonical.z+1,i=2*this.canonical.x,r=2*this.canonical.y;return [new Bu(t,this.wrap,t,i,r),new Bu(t,this.wrap,t,i+1,r),new Bu(t,this.wrap,t,i,r+1),new Bu(t,this.wrap,t,i+1,r+1)]}isLessThan(e){return this.wrape.wrap)&&(this.overscaledZe.overscaledZ)&&(this.canonical.xe.canonical.x)&&this.canonical.y{let t=e.canonical.x-1,i=e.wrap;return t<0&&(t=(1<{let t=e.canonical.x+1,i=e.wrap;return t===1<new Bu(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,(0===e.canonical.y?1<new Bu(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y===(1<=0;if(0===o)return 0;o!==t.length&&(i=!1);}return i?2:1}function qu(e,t){for(const i of e.projections){const r=ju(t,e.points[0],i.axis);if(i.projection[1]r[1])return 0}return 1}function Zu(e,t){let i=0;const r=[0,0,0,0];for(let n=0;n=0&&i++;return i}class $u{constructor(e,t){this.points=e||new Array(8).fill([0,0,0]),this.planes=t||new Array(6).fill([0,0,0,0]),this.bounds=Hu.fromPoints(this.points),this.projections=[],this.frustumEdges=[Mu.sub([],this.points[2],this.points[3]),Mu.sub([],this.points[0],this.points[3]),Mu.sub([],this.points[4],this.points[0]),Mu.sub([],this.points[5],this.points[1]),Mu.sub([],this.points[6],this.points[2]),Mu.sub([],this.points[7],this.points[3])];for(const e of this.frustumEdges){const t=[0,-e[2],e[1]],i=[e[2],0,-e[0]];this.projections.push({axis:t,projection:ju(this.points,this.points[0],t)}),this.projections.push({axis:i,projection:ju(this.points,this.points[0],i)});}}static fromInvProjectionMatrix(e,t,i,r){const n=Math.pow(2,i),o=[[-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((i=>{const o=uu.transformMat4([],i,e),s=1/o[3]/t*n;return uu.mul(o,o,[s,s,r?1/o[3]:s,s])})),s=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((e=>{const t=Mu.sub([],o[e[0]],o[e[1]]),i=Mu.sub([],o[e[2]],o[e[1]]),r=Mu.normalize([],Mu.cross([],t,i)),n=-Mu.dot(r,o[e[1]]);return r.concat(n)})),a=[];for(let e=0;es[1]||s[0]>o[1])return 0}return 1}}class Hu{static fromPoints(e){const t=[1/0,1/0,1/0],i=[-1/0,-1/0,-1/0];for(const r of e)Mu.min(t,t,r),Mu.max(i,i,r);return new Hu(t,i)}static fromTileIdAndHeight(e,t,i){const r=1<e.max[t]||e.min[t]>this.max[t])return !1;return !0}intersectsAabbXY(e){return !(this.min[0]>e.max[0]||e.min[0]>this.max[0]||this.min[1]>e.max[1]||e.min[1]>this.max[1])}encapsulate(e){for(let t=0;t<3;t++)this.min[t]=Math.min(this.min[t],e.min[t]),this.max[t]=Math.max(this.max[t],e.max[t]);}encapsulatePoint(e){for(let t=0;t<3;t++)this.min[t]=Math.min(this.min[t],e[t]),this.max[t]=Math.max(this.max[t],e[t]);}closestPoint(e){return [Math.max(Math.min(this.max[0],e[0]),this.min[0]),Math.max(Math.min(this.max[1],e[1]),this.min[1]),Math.max(Math.min(this.max[2],e[2]),this.min[2])]}}Is(Hu,"Aabb");const Wu=5,Xu=6,Yu=sr/Math.PI/2,Ku=16383,Ju=64,Qu=[Ju,32,16],ed=-Yu,td=Yu,id=[new Hu([ed,ed,ed],[td,td,td]),new Hu([ed,ed,ed],[0,0,td]),new Hu([0,ed,ed],[td,0,td]),new Hu([ed,0,ed],[0,td,td]),new Hu([0,0,ed],[td,td,td])];function rd(e){return e*Yu/Od}function nd(e,t,i,r=!0){const n=Mu.scale([],e._camera.position,e.worldSize),o=[t,i,1,1];uu.transformMat4(o,o,e.pixelMatrixInverse),uu.scale(o,o,1/o[3]);const s=Mu.sub([],o,n),a=Mu.normalize([],s),l=e.globeMatrix,c=[l[12],l[13],l[14]],h=Mu.sub([],c,n),u=Mu.length(h),d=Mu.normalize([],h),p=e.worldSize/(2*Math.PI),f=Mu.dot(d,a),m=Math.asin(p/u);if(m1?null:function(e,t,i,r){const n=Math.sin(i);return e*(Math.sin((1-r)*i)/n)+t*(Math.sin(r*i)/n)}(e.a[t],e.b[t],e.angle,z(i,0,1))+e.center[t]}function ad(e){if(e.z<=1)return id[e.z+2*e.y+e.x];const t=pd(dd(e));return Hu.fromPoints(t)}function ld(e,t,i){return Mu.scale(e,e,1-i),Mu.scaleAndAdd(e,e,t,i)}function cd(e,t){const i=Ed(t.zoom);if(0===i)return ad(e);const r=dd(e),n=pd(r),o=Gd(r.getWest())*t.worldSize,s=Gd(r.getEast())*t.worldSize,a=qd(r.getNorth())*t.worldSize,l=qd(r.getSouth())*t.worldSize,c=[o,a,0],h=[s,a,0],u=[o,l,0],d=[s,l,0],p=xu.invert([],t.globeMatrix);return Mu.transformMat4(c,c,p),Mu.transformMat4(h,h,p),Mu.transformMat4(u,u,p),Mu.transformMat4(d,d,p),n[0]=ld(n[0],u,i),n[1]=ld(n[1],d,i),n[2]=ld(n[2],h,i),n[3]=ld(n[3],c,i),Hu.fromPoints(n)}function hd(e,t,i){for(const r of e)Mu.transformMat4(r,r,t),Mu.scale(r,r,i);}function ud(e,t,i,r){const n=t/e.worldSize,o=e.globeMatrix;if(i.z<=1){const e=ad(i).getCorners();return hd(e,o,n),Hu.fromPoints(e)}const s=dd(i,r),a=pd(s);hd(a,o,n);const l=Number.MAX_VALUE,c=[-l,-l,-l],h=[l,l,l];if(s.contains(e.center)){for(const e of a)Mu.min(h,h,e),Mu.max(c,c,e);c[2]=0;const t=e.point,i=[t.x*n,t.y*n,0];return Mu.min(h,h,i),Mu.max(c,c,i),new Hu(h,c)}const u=[o[12]*n,o[13]*n,o[14]*n],d=s.getCenter(),p=z(e.center.lat,-Xd,Xd),f=z(d.lat,-Xd,Xd),m=Gd(e.center.lng),_=qd(p);let g=m-Gd(d.lng);const y=_-qd(f);g>.5?g-=1:g<-.5&&(g+=1);let x=0;if(Math.abs(g)>Math.abs(y))x=g>=0?1:3;else {x=y>=0?0:2;const e=[o[4]*n,o[5]*n,o[6]*n],t=-Math.sin(w(y>=0?s.getSouth():s.getNorth()))*Yu;Mu.scaleAndAdd(u,u,e,t);}const v=a[x],b=a[(x+1)%4],T=new od(v,b,u),E=[sd(T,0)||v[0],sd(T,1)||v[1],sd(T,2)||v[2]],M=Ed(e.zoom);if(M>0){const r=function({x:e,y:t,z:i},r,n,o,s){const a=1/(1<.5?d=-1:p<-.5&&(d=1),l=((l+d)*r-(o*=r))*n+o,c=((c+d)*r-o)*n+o,h=(h*r-(s*=r))*n+s,u=(u*r-s)*n+s,[[l,u,0],[c,u,0],[c,h,0],[l,h,0]]}(i,t,e._pixelsPerMercatorPixel,m,_);for(let e=0;e0;return 0===r&&!n&&!o}function Sd(e,t,i,r){const n=t.getNorth(),o=t.getSouth(),s=t.getWest(),a=t.getEast(),l=1<0){const e=180/r;gu.multiply(p,p,[e/c+1,0,0,0,e/h+1,0,-.5*e/u,.5*e/d,1]);}return p[2]=l,p[5]=e.x,p[8]=e.y,p}function Id(e){const t=Xd-5;e=z(e,-t,t)/t*90;const i=Math.pow(Math.abs(Math.sin(w(e))),3);return Math.round(i*(Qu.length-1))}function Cd(e){const t=[0,0,0],i=xu.identity(new Float64Array(16));return xu.multiply(i,e.pixelMatrix,e.globeMatrix),Mu.transformMat4(t,t,i),new y(t[0],t[1])}function zd(e,t){const i=md(t.lat,t.lng),r=function(e){const t=md(e._center.lat,e._center.lng),i=Mu.fromValues(0,1,0);let r=Mu.cross([],i,t);const n=xu.fromRotation([],-e.angle,t);r=Mu.transformMat4(r,r,n),xu.fromRotation(n,-e._pitch,r);const o=Mu.normalize([],t);return Mu.scale(o,o,rd(e.cameraToCenterDistance/e.pixelsPerMeter)),Mu.transformMat4(o,o,n),Mu.add([],t,o)}(e),n=Mu.subtract([],r,i);return Mu.angle(n,i)}function Dd(e,t){return zd(e,t)>Math.PI/2*1.01}const Pd=w(85),Rd=Math.cos(Pd),Ld=Math.sin(Pd);class kd{constructor(e){this._createGrid(e),this._createPoles(e);}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const e of this._poleSegments)e.destroy();for(const e of this._gridSegments)e.withSkirts.destroy(),e.withoutSkirts.destroy();}_fillGridMeshWithLods(e,t){const i=new Ta,r=new Va,n=[],o=e+1+2,s=t[0]+1,a=t[0]+1+(1+t.length),l=(e,t,i)=>{let r=e===o-1?e-2:0===e?e:e-1;return r+=i?24575:0,[r,t]};for(let e=0;e90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Fd(P(this.lng,-180,180),this.lat)}toArray(){return [this.lng,this.lat]}toString(){return `LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const t=Math.PI/180,i=this.lat*t,r=e.lat*t,n=Math.sin(i)*Math.sin(r)+Math.cos(i)*Math.cos(r)*Math.cos((e.lng-this.lng)*t);return Od*Math.acos(Math.min(n,1))}toBounds(e=0){const t=360*e/40075017,i=t/Math.cos(Math.PI/180*this.lat);return new Ql(new Fd(this.lng-i,this.lat-t),new Fd(this.lng+i,this.lat+t))}toEcef(e){const t=rd(e);return md(this.lat,this.lng,Yu+t)}static convert(e){if(e instanceof Fd)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new Fd(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new Fd(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: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}var Nd=Fd;const Ud=0,Vd=25.5;function jd(e){return Bd*Math.cos(e*Math.PI/180)}function Gd(e){return (180+e)/360}function qd(e){return (180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function Zd(e,t){return e/jd(t)}function $d(e){return 360*e-180}function Hd(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function Wd(e,t){return e*jd(Hd(t))}const Xd=85.051129;function Yd(e){return Math.cos(w(z(e,-Xd,Xd)))}function Kd(e,t){const i=z(t,Ud,Vd),r=Math.pow(2,i);return Yd(e)*Bd/(512*r)}function Jd(e){return 1/Math.cos(e*Math.PI/180)}function Qd(e,t=0){const i=Math.exp(Math.PI*(1-(e.y+t/sr)/(1<=l?(tp(e,t,i,c,h,o,u,a,l),tp(e,c,h,r,n,u,s,a,l)):e.push(s);}function ip(e,t,i){let r=e[0],n=r.x,o=r.y;t(r);const s=[r];for(let a=1;ae.x+1||re.y+1)&&W("Geometry exceeds allowed extent, reduce your vector tile buffer size"),e}function lp(e,t,i){const r=e.loadGeometry(),n=e.extent,o=sr/n;if(t&&i&&i.projection.isReprojectedInTileSpace){const o=1<{const i=$d((t.x+e.x/n)/o),r=Hd((t.y+e.y/n)/o),h=c.project(i,r);e.x=(h.x*s-a)*n,e.y=(h.y*s-l)*n;};for(let t=0;t=n||i.y<0||i.y>=n||(h(i),e.push(i));r[t]=e;}}for(const e of r)for(const t of e)ap(t,o);return r}function cp(e,t){return {type:e.type,id:e.id,properties:e.properties,geometry:t?lp(e):[]}}function hp(e,t,i,r,n){e.emplaceBack(2*t+(r+1)/2,2*i+(n+1)/2);}function up(e,t,i){const r=16384;e.emplaceBack(t.x,t.y,t.z,i[0]*r,i[1]*r,i[2]*r);}class dp{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.fqid)),this.index=e.index,this.hasPattern=!1,this.projection=e.projection,this.layoutVertexArray=new Ta,this.indexArray=new Va,this.segments=new dl,this.programConfigurations=new Hl(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id));}populate(e,t,i,r){const n=this.layers[0],o=[];let s=null;"circle"===n.type&&(s=n.layout.get("circle-sort-key"));for(const{feature:t,id:n,index:a,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=cp(t,e);if(!this.layers[0]._featureFilter.filter(new ea(this.zoom),c,i))continue;const h=s?s.evaluate(c,{},i):void 0,u={id:n,properties:t.properties,type:t.type,sourceLayerIndex:l,index:a,geometry:e?c.geometry:lp(t,i,r),patterns:{},sortKey:h};o.push(u);}s&&o.sort(((e,t)=>e.sortKey-t.sortKey));let a=null;"globe"===r.projection.name&&(this.globeExtVertexArray=new Da,a=r.projection);for(const r of o){const{geometry:n,index:o,sourceLayerIndex:s}=r,l=e[o].feature;this.addFeature(r,n,o,t.availableImages,i,a,t.brightness),t.featureIndex.insert(l,n,o,s,this.index);}}update(e,t,i,r,n){const o=0!==Object.keys(e).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(e,t,o?this.stateDependentLayers:this.layers,i,r,n);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,hl.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,ul.members))),this.programConfigurations.upload(e),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy());}addFeature(e,t,i,r,n,o,s){for(const i of t)for(const t of i){const i=t.x,r=t.y;if(i<0||i>=sr||r<0||r>=sr)continue;if(o){const e=o.projectTilePoint(i,r,n),t=o.upVector(n,i,r),s=this.globeExtVertexArray;up(s,e,t),up(s,e,t),up(s,e,t),up(s,e,t);}const s=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),a=s.vertexLength;hp(this.layoutVertexArray,i,r,-1,-1),hp(this.layoutVertexArray,i,r,1,-1),hp(this.layoutVertexArray,i,r,1,1),hp(this.layoutVertexArray,i,r,-1,1),this.indexArray.emplaceBack(a,a+1,a+2),this.indexArray.emplaceBack(a,a+2,a+3),s.vertexLength+=4,s.primitiveLength+=2;}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{},r,n,s);}}function pp(e,t){for(let i=0;i1){if(gp(e,t))return !0;for(let r=0;r1?i:i.sub(t)._mult(n)._add(t))}function bp(e,t){let i,r,n,o=!1;for(let s=0;st.y!=n.y>t.y&&t.x<(n.x-r.x)*(t.y-r.y)/(n.y-r.y)+r.x&&(o=!o);}return o}function wp(e,t){let i=!1;for(let r=0,n=e.length-1;rt.y!=s.y>t.y&&t.x<(s.x-o.x)*(t.y-o.y)/(s.y-o.y)+o.x&&(i=!i);}return i}function Tp(e,t,i,r,n){for(const o of e)if(t<=o.x&&i<=o.y&&r>=o.x&&n>=o.y)return !0;const o=[new y(t,i),new y(t,n),new y(r,n),new y(r,i)];if(e.length>2)for(const t of o)if(wp(e,t))return !0;for(let t=0;tn.x&&t.x>n.x||e.yn.y&&t.y>n.y)return !1;const o=X(e,t,i[0]);return o!==X(e,t,i[1])||o!==X(e,t,i[2])||o!==X(e,t,i[3])}function Mp(e,t,i,r,n,o){let s=t.y-e.y,a=e.x-t.x;if(o=o||0){const e=s*s+a*a;if(0===e)return !0;const t=Math.sqrt(e);s/=t,a/=t;}return !((i.x-e.x)*s+(i.y-e.y)*a-o<0||(r.x-e.x)*s+(r.y-e.y)*a-o<0||(n.x-e.x)*s+(n.y-e.y)*a-o<0)}function Ap(e,t,i,r,n,o,s){return !(Mp(e,t,r,n,o,s)||Mp(t,i,r,n,o,s)||Mp(i,e,r,n,o,s)||Mp(r,n,e,t,i,s)||Mp(n,o,e,t,i,s)||Mp(o,r,e,t,i,s))}function Sp(e,t,i){const r=t.paint.get(e).value;return "constant"===r.kind?r.value:i.programConfigurations.get(t.id).getMaxValue(e)}function Ip(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function Cp(e,t,i,r,n){if(!t[0]&&!t[1])return e;const o=y.convert(t)._mult(n);"viewport"===i&&o._rotate(-r);const s=[];for(let t=0;t{const s=e.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const e=wd(s.zoom,t.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([e,0,0,e]);}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:e.transform.getCameraToCenterDistance(s.projection),u_matrix:e.translatePosMatrix(t.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:ht.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Rp,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=r,c.u_merc_center=n,c.u_tile_id=[t.canonical.x,t.canonical.y,1<{const t=[];return "map"===e.paint.get("circle-pitch-alignment")&&t.push("PITCH_WITH_MAP"),"map"===e.paint.get("circle-pitch-scale")&&t.push("SCALE_WITH_MAP"),t};function Op(e,t,i,r,n,o,s,a,l){if(o&&e.queryGeometry.isAboveHorizon)return !1;o&&(l*=e.pixelToTileUnitsFactor);const c=e.tileID.canonical,h=i.projection.upVectorScale(c,i.center.lat,i.worldSize).metersToTile;for(const u of t)for(const t of u){const u=t.add(a),d=n&&i.elevation?i.elevation.exaggeration()*n.getElevationAt(u.x,u.y,!0):0,p=i.projection.projectTilePoint(u.x,u.y,c);if(d>0){const e=i.projection.upVector(c,u.x,u.y);p.x+=e[0]*h*d,p.y+=e[1]*h*d,p.z+=e[2]*h*d;}const f=o?u:Bp(p.x,p.y,p.z,r),m=o?e.tilespaceRays.map((e=>Up(e,d))):e.queryGeometry.screenGeometry,_=uu.transformMat4([],[p.x,p.y,p.z,1],r);if(!s&&o?l*=_[3]/i.cameraToCenterDistance:s&&!o&&(l*=i.cameraToCenterDistance/_[3]),o){const e=Hd((t.y/sr+c.y)/(1<e.width||n.height>e.height||i.x>e.width-n.width||i.y>e.height-n.height)throw new RangeError("out of range source coordinates for image copy");if(n.width>t.width||n.height>t.height||r.x>t.width-n.width||r.y>t.height-n.height)throw new RangeError("out of range destination coordinates for image copy");const s=e.data,a=t.data;for(let l=0;l{t[e.evaluationKey]=o;const s=e.expression.evaluate(t);s&&(n.data[i+r+0]=Math.floor(255*s.r/s.a),n.data[i+r+1]=Math.floor(255*s.g/s.a),n.data[i+r+2]=Math.floor(255*s.b/s.a),n.data[i+r+3]=Math.floor(255*s.a));};if(e.clips)for(let t=0,n=0;t80*i){r=o=e[0],n=s=e[1];for(var f=i;fo&&(o=a),l>s&&(s=l);c=0!==(c=Math.max(o-r,s-n))?32767/c:0;}return sf(d,p,i,r,n,c,0),p}function nf(e,t,i,r,n){var o,s;if(n===If(e,t,i,r)>0)for(o=t;o=t;o-=r)s=Mf(o,e[o],e[o+1],s);return s&&xf(s,s.next)&&(Af(s),s=s.next),s}function of(e,t){if(!e)return e;t||(t=e);var i,r=e;do{if(i=!1,r.steiner||!xf(r,r.next)&&0!==yf(r.prev,r,r.next))r=r.next;else {if(Af(r),(r=t=r.prev)===r.next)break;i=!0;}}while(i||r!==t);return t}function sf(e,t,i,r,n,o,s){if(e){!s&&o&&function(e,t,i,r){var n=e;do{0===n.z&&(n.z=ff(n.x,n.y,t,i,r)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;}while(n!==e);n.prevZ.nextZ=null,n.prevZ=null,function(e){var t,i,r,n,o,s,a,l,c=1;do{for(i=e,e=null,o=null,s=0;i;){for(s++,r=i,a=0,t=0;t0||l>0&&r;)0!==a&&(0===l||!r||i.z<=r.z)?(n=i,i=i.nextZ,a--):(n=r,r=r.nextZ,l--),o?o.nextZ=n:e=n,n.prevZ=o,o=n;i=r;}o.nextZ=null,c*=2;}while(s>1)}(n);}(e,r,n,o);for(var a,l,c=e;e.prev!==e.next;)if(a=e.prev,l=e.next,o?lf(e,r,n,o):af(e))t.push(a.i/i|0),t.push(e.i/i|0),t.push(l.i/i|0),Af(e),e=l.next,c=l.next;else if((e=l)===c){s?1===s?sf(e=cf(of(e),t,i),t,i,r,n,o,2):2===s&&hf(e,t,i,r,n,o):sf(of(e),t,i,r,n,o,1);break}}}function af(e){var t=e.prev,i=e,r=e.next;if(yf(t,i,r)>=0)return !1;for(var n=t.x,o=i.x,s=r.x,a=t.y,l=i.y,c=r.y,h=no?n>s?n:s:o>s?o:s,p=a>l?a>c?a:c:l>c?l:c,f=r.next;f!==t;){if(f.x>=h&&f.x<=d&&f.y>=u&&f.y<=p&&_f(n,a,o,l,s,c,f.x,f.y)&&yf(f.prev,f,f.next)>=0)return !1;f=f.next;}return !0}function lf(e,t,i,r){var n=e.prev,o=e,s=e.next;if(yf(n,o,s)>=0)return !1;for(var a=n.x,l=o.x,c=s.x,h=n.y,u=o.y,d=s.y,p=al?a>c?a:c:l>c?l:c,_=h>u?h>d?h:d:u>d?u:d,g=ff(p,f,t,i,r),y=ff(m,_,t,i,r),x=e.prevZ,v=e.nextZ;x&&x.z>=g&&v&&v.z<=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=_&&x!==n&&x!==s&&_f(a,h,l,u,c,d,x.x,x.y)&&yf(x.prev,x,x.next)>=0)return !1;if(x=x.prevZ,v.x>=p&&v.x<=m&&v.y>=f&&v.y<=_&&v!==n&&v!==s&&_f(a,h,l,u,c,d,v.x,v.y)&&yf(v.prev,v,v.next)>=0)return !1;v=v.nextZ;}for(;x&&x.z>=g;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=_&&x!==n&&x!==s&&_f(a,h,l,u,c,d,x.x,x.y)&&yf(x.prev,x,x.next)>=0)return !1;x=x.prevZ;}for(;v&&v.z<=y;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=_&&v!==n&&v!==s&&_f(a,h,l,u,c,d,v.x,v.y)&&yf(v.prev,v,v.next)>=0)return !1;v=v.nextZ;}return !0}function cf(e,t,i){var r=e;do{var n=r.prev,o=r.next.next;!xf(n,o)&&vf(n,r,r.next,o)&&Tf(n,o)&&Tf(o,n)&&(t.push(n.i/i|0),t.push(r.i/i|0),t.push(o.i/i|0),Af(r),Af(r.next),r=e=o),r=r.next;}while(r!==e);return of(r)}function hf(e,t,i,r,n,o){var s=e;do{for(var a=s.next.next;a!==s.prev;){if(s.i!==a.i&&gf(s,a)){var l=Ef(s,a);return s=of(s,s.next),l=of(l,l.next),sf(s,t,i,r,n,o,0),void sf(l,t,i,r,n,o,0)}a=a.next;}s=s.next;}while(s!==e)}function uf(e,t){return e.x-t.x}function df(e,t){var i=function(e,t){var i,r=t,n=e.x,o=e.y,s=-1/0;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){var a=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=n&&a>s&&(s=a,i=r.x=r.x&&r.x>=h&&n!==r.x&&_f(oi.x||r.x===i.x&&pf(i,r)))&&(i=r,d=l)),r=r.next;}while(r!==c);return i}(e,t);if(!i)return t;var r=Ef(i,e);return of(r,r.next),of(i,i.next)}function pf(e,t){return yf(e.prev,e,t.prev)<0&&yf(t.next,e,e.next)<0}function ff(e,t,i,r,n){return (e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*n|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*n|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function mf(e){var t=e,i=e;do{(t.x=(e-s)*(o-a)&&(e-s)*(r-a)>=(i-s)*(t-a)&&(i-s)*(o-a)>=(n-s)*(r-a)}function gf(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&vf(i,i.next,e,t))return !0;i=i.next;}while(i!==e);return !1}(e,t)&&(Tf(e,t)&&Tf(t,e)&&function(e,t){var i=e,r=!1,n=(e.x+t.x)/2,o=(e.y+t.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&n<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next;}while(i!==e);return r}(e,t)&&(yf(e.prev,e,t.prev)||yf(e,t.prev,t))||xf(e,t)&&yf(e.prev,e,e.next)>0&&yf(t.prev,t,t.next)>0)}function yf(e,t,i){return (t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function xf(e,t){return e.x===t.x&&e.y===t.y}function vf(e,t,i,r){var n=wf(yf(e,t,i)),o=wf(yf(e,t,r)),s=wf(yf(i,r,e)),a=wf(yf(i,r,t));return n!==o&&s!==a||!(0!==n||!bf(e,i,t))||!(0!==o||!bf(e,r,t))||!(0!==s||!bf(i,e,r))||!(0!==a||!bf(i,t,r))}function bf(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function wf(e){return e>0?1:e<0?-1:0}function Tf(e,t){return yf(e.prev,e,e.next)<0?yf(e,t,e.next)>=0&&yf(e,e.prev,t)>=0:yf(e,t,e.prev)<0||yf(e,e.next,t)<0}function Ef(e,t){var i=new Sf(e.i,e.x,e.y),r=new Sf(t.i,t.x,t.y),n=e.next,o=t.prev;return e.next=t,t.prev=e,i.next=n,n.prev=i,r.next=i,i.prev=r,o.next=r,r.prev=o,r}function Mf(e,t,i,r){var n=new Sf(e,t,i);return r?(n.next=r.next,n.prev=r,r.next.prev=n,r.next=n):(n.prev=n,n.next=n),n}function Af(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ);}function Sf(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1;}function If(e,t,i,r){for(var n=0,o=t,s=i-r;o0&&i.holes.push(r+=e[n-1].length);}return i};var Cf=d(tf.exports);function zf(e,t){const i=e.length;if(i<=1)return [e];const r=[];let n,o;for(let t=0;t1)for(let e=0;ee.fqid)),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Ta,this.indexArray=new Va,this.indexArray2=new ka,this.programConfigurations=new Hl(e.layers,e.zoom),this.segments=new dl,this.segments2=new dl,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.projection=e.projection;}populate(e,t,i,r){this.hasPattern=Pf("fill",this.layers,t);const n=this.layers[0].layout.get("fill-sort-key"),o=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of e){const e=this.layers[0]._featureFilter.needGeometry,h=cp(s,e);if(!this.layers[0]._featureFilter.filter(new ea(this.zoom),h,i))continue;const u=n?n.evaluate(h,{},i,t.availableImages):void 0,d={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:e?h.geometry:lp(s,i,r),patterns:{},sortKey:u};o.push(d);}n&&o.sort(((e,t)=>e.sortKey-t.sortKey));for(const r of o){const{geometry:n,index:o,sourceLayerIndex:s}=r;if(this.hasPattern){const e=Rf("fill",this.layers,r,this.zoom,t);this.patternFeatures.push(e);}else this.addFeature(r,n,o,i,{},t.availableImages,t.brightness);t.featureIndex.insert(e[o].feature,n,o,s,this.index);}}update(e,t,i,r,n){const o=0!==Object.keys(e).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(e,t,o?this.stateDependentLayers:this.layers,i,r,n);}addFeatures(e,t,i,r,n,o){for(const e of this.patternFeatures)this.addFeature(e,e.geometry,e.index,t,i,r,o);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,ef),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,t,i,r,n,o=[],s){for(const e of zf(t,500)){let t=0;for(const i of e)t+=i.length;const i=this.segments.prepareSegment(t,this.layoutVertexArray,this.indexArray),r=i.vertexLength,n=[],o=[];for(const t of e){if(0===t.length)continue;t!==e[0]&&o.push(n.length/2);const i=this.segments2.prepareSegment(t.length,this.layoutVertexArray,this.indexArray2),r=i.vertexLength;this.layoutVertexArray.emplaceBack(t[0].x,t[0].y),this.indexArray2.emplaceBack(r+t.length-1,r),n.push(t[0].x),n.push(t[0].y);for(let e=1;e>3;}if(n--,1===r||2===r)o+=e.readSVarint(),s+=e.readSVarint(),1===r&&(t&&a.push(t),t=[]),t.push(new qf(o,s));else {if(7!==r)throw new Error("unknown command "+r);t&&t.push(t[0].clone());}}return t&&a.push(t),a},$f.prototype.bbox=function(){var e=this._pbf;e.pos=this._geometry;for(var t=e.readVarint()+e.pos,i=1,r=0,n=0,o=0,s=1/0,a=-1/0,l=1/0,c=-1/0;e.pos>3;}if(r--,1===i||2===i)(n+=e.readSVarint())a&&(a=n),(o+=e.readSVarint())c&&(c=o);else if(7!==i)throw new Error("unknown command "+i)}return [s,l,a,c]},$f.prototype.toGeoJSON=function(e,t,i){var r,n,o=this.extent*Math.pow(2,i),s=this.extent*e,a=this.extent*t,l=this.loadGeometry(),c=$f.types[this.type];function h(e){for(var t=0;t>3;t=1===r?e.readString():2===r?e.readFloat():3===r?e.readDouble():4===r?e.readVarint64():5===r?e.readVarint():6===r?e.readSVarint():7===r?e.readBoolean():null;}return t}(i));}Kf.prototype.feature=function(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];var t=this._pbf.readVarint()+this._pbf.pos;return new Xf(this._pbf,t,this.extent,this._keys,this._values)};var Qf=Yf;function em(e,t,i){if(3===e){var r=new Qf(i,i.readVarint()+i.pos);r.length&&(t[r.name]=r);}}var tm=Gf.VectorTile=function(e,t){this.layers=e.readFields(em,{},t);},im=Gf.VectorTileFeature=Zf;function rm(e,t,i,r){const n=[],o=0===r?(e,t,i,r,n,o)=>{e.push(new y(o,i+(o-t)/(r-t)*(n-i)));}:(e,t,i,r,n,o)=>{e.push(new y(t+(o-i)/(n-i)*(r-t),o));};for(const s of e){const e=[];for(const n of s){if(n.length<=2)continue;const s=[];for(let e=0;et&&o(s,a,l,c,h,t):u>i?d=t&&o(s,a,l,c,h,t),d>i&&u<=i&&o(s,a,l,c,h,i);}let a=n[n.length-1];const l=0===r?a.x:a.y;l>=t&&l<=i&&s.push(a),s.length&&(a=s[s.length-1],s[0].x===a.x&&s[0].y===a.y||s.push(s[0]),e.push(s));}e.length&&n.push(e);}return n}Gf.VectorTileLayer=Yf;class nm{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t1)return 1;for(var r=t,n=0;n<8;n++){var i=this.sampleCurveX(r)-t;if(Math.abs(i)i?s=r:o=r,r=.5*(o-s)+s;return r},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}};var d=h(p),m=y;function y(t,e){this.x=t,this.y=e;}y.prototype={clone:function(){return new y(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,r=t.y-this.y;return e*e+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),r=Math.sin(t),n=r*this.x+e*this.y;return this.x=e*this.x-r*this.y,this.y=n,this},_rotateAround:function(t,e){var r=Math.cos(t),n=Math.sin(t),i=e.y+n*(this.x-e.x)+r*(this.y-e.y);return this.x=e.x+r*(this.x-e.x)-n*(this.y-e.y),this.y=i,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},y.convert=function(t){return t instanceof y?t:Array.isArray(t)?new y(t[0],t[1]):t};var g=h(m);const x=Math.PI/180,v=180/Math.PI;function b(t){return t*x}function _(t){return t*v}const w=[[0,0],[1,0],[1,1],[0,1]];function M(t){if(t<=0)return 0;if(t>=1)return 1;const e=t*t,r=e*t;return 4*(t<.5?r:3*(t-e)+r-.75)}function A(t,e,r,n){const i=new d(t,e,r,n);return function(t){return i.solve(t)}}const S=A(.25,.1,.25,1);function I(t,e,r){return Math.min(r,Math.max(e,t))}function k(t,e,r){return (r=I((r-t)/(e-t),0,1))*r*(3-2*r)}function P(t,e,r){const n=r-e,i=((t-e)%n+n)%n+e;return i===e?r:i}function E(t,e,r){if(!t.length)return r(null,[]);let n=t.length;const i=new Array(t.length);let a=null;t.forEach(((t,s)=>{e(t,((t,e)=>{t&&(a=t),i[s]=e,0==--n&&r(a,i);}));}));}function z(t,...e){for(const r of e)for(const e in r)t[e]=r[e];return t}let T=1;function B(){return T++}function C(){return function t(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()}function R(t){return t<=1?1:Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function D(t){return !!t&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t)}function V(t,e){t.forEach((t=>{e[t]&&(e[t]=e[t].bind(e));}));}function L(t,e){return -1!==t.indexOf(e,t.length-e.length)}function F(t,e,r){const n={};for(const i in t)n[i]=e.call(r||this,t[i],i,t);return n}function N(t,e,r){const n={};for(const i in t)e.call(r||this,t[i],i,t)&&(n[i]=t[i]);return n}function O(t){return Array.isArray(t)?t.map(O):"object"==typeof t&&t?F(t,O):t}const U={};function j(t){U[t]||("undefined"!=typeof console&&console.warn(t),U[t]=!0);}function q(t,e,r){return (r.y-t.y)*(e.x-t.x)>(e.y-t.y)*(r.x-t.x)}function $(t){let e=0;for(let r,n,i=0,a=t.length,s=a-1;i@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((t,r,n,i)=>{const a=n||i;return e[r]=!a||a.toLowerCase(),""})),e["max-age"]){const t=parseInt(e["max-age"],10);isNaN(t)?delete e["max-age"]:e["max-age"]=t;}return e}let Z,K,H,W,J,Q,tt=null;function et(t){try{const e=self[t];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch(t){return !1}}function rt(t,e){return [t[4*e],t[4*e+1],t[4*e+2],t[4*e+3]]}function nt(t,e,r,n){for(;e>1;t[i]>1;t[i]<=n?e=i+1:r=i;}return e}function at(){return null==Z&&(Z=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof self.createImageBitmap),Z}const st={now:()=>void 0!==W?W:performance.now(),setNow(t){W=t;},restoreNow(){W=void 0;},frame(t){const e=requestAnimationFrame(t);return {cancel:()=>cancelAnimationFrame(e)}},getImageData(t,e=0){const{width:r,height:n}=t;J||(J=document.createElement("canvas"));const i=J.getContext("2d",{willReadFrequently:!0});if(!i)throw new Error("failed to create canvas 2d context");return (r>J.width||n>J.height)&&(J.width=r,J.height=n),i.clearRect(-e,-e,r+2*e,n+2*e),i.drawImage(t,0,0,r,n),i.getImageData(-e,-e,r+2*e,n+2*e)},resolveURL:t=>(K||(K=document.createElement("a")),K.href=t,K.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return !!window.matchMedia&&(null==H&&(H=window.matchMedia("(prefers-reduced-motion: reduce)")),H.matches)},hasCanvasFingerprintNoise(){if(void 0!==Q)return Q;if(!at())return Q=!1,!1;const t=new OffscreenCanvas(85,1),e=t.getContext("2d",{willReadFrequently:!0});let r=0;for(let n=0;nself.worker&&self.worker.referrer:()=>("blob:"===location.protocol?parent:self).location.href;const kt=function(t,e){if(!(/^file:/.test(r=t.url)||/^file:/.test(It())&&!/^\w+:/.test(r))){if(self.fetch&&self.Request&&self.AbortController&&Request.prototype.hasOwnProperty("signal"))return function(t,e){const r=new AbortController,n=new Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,referrer:It(),referrerPolicy:t.referrerPolicy,signal:r.signal});let a=!1,s=!1;const o=(l=n.url).indexOf("sku=")>0&&i(l);var l;"json"===t.type&&n.headers.set("Accept","application/json");const u=(r,i,a)=>{if(s)return;if(r&&"SecurityError"!==r.message&&j(r.toString()),i&&a)return c(i);const l=Date.now();fetch(n).then((r=>{if(r.ok){const t=o?r.clone():null;return c(r,t,l)}return e(new St(r.statusText,r.status,t.url))})).catch((r=>{"AbortError"!==r.name&&e(new Error(`${r.message} ${t.url}`));}));},c=(r,i,o)=>{("arrayBuffer"===t.type?r.arrayBuffer():"json"===t.type?r.json():r.text()).then((t=>{s||(i&&o&&function(t,e,r){if(ft(),!ct)return;const n=X(e.headers.get("Cache-Control")||"");if(n["no-store"])return;const i={status:e.status,statusText:e.statusText,headers:new Headers};e.headers.forEach(((t,e)=>i.headers.set(e,t))),n["max-age"]&&i.headers.set("Expires",new Date(r+1e3*n["max-age"]).toUTCString());const a=i.headers.get("Expires");if(!a)return;if(new Date(a).getTime()-r<42e4)return;let s=dt(t.url);if(206===e.status){const e=t.headers.get("Range");if(!e)return;i.status=200,s=mt(s,{range:e});}!function(t,e){if(void 0===ht)try{new Response(new ReadableStream),ht=!0;}catch(t){ht=!1;}ht?e(t.body):t.blob().then(e);}(e,(t=>{const e=new Response(t,i);ft(),ct&&ct.then((t=>t.put(s,e))).catch((t=>j(t.message)));}));}(n,i,o),a=!0,e(null,t,r.headers.get("Cache-Control"),r.headers.get("Expires")));})).catch((t=>{s||e(new Error(t.message));}));};return o?function(t,e){if(ft(),!ct)return e(null);ct.then((r=>{let n=dt(t.url);const i=t.headers.get("Range");i&&(n=mt(n,{range:i})),r.match(n).then((t=>{const i=function(t){if(!t)return !1;const e=new Date(t.headers.get("Expires")||0),r=X(t.headers.get("Cache-Control")||"");return e>Date.now()&&!r["no-cache"]}(t);r.delete(n),i&&r.put(n,t.clone()),e(null,t,i);})).catch(e);})).catch(e);}(n,u):u(null,null),{cancel:()=>{s=!0,a||r.abort();}}}(t,e);if(Y()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,e,void 0,!0)}var r;return function(t,e){const r=new XMLHttpRequest;r.open(t.method||"GET",t.url,!0),"arrayBuffer"===t.type&&(r.responseType="arraybuffer");for(const e in t.headers)r.setRequestHeader(e,t.headers[e]);return "json"===t.type&&(r.responseType="text",r.setRequestHeader("Accept","application/json")),r.withCredentials="include"===t.credentials,r.onerror=()=>{e(new Error(r.statusText));},r.onload=()=>{if((r.status>=200&&r.status<300||0===r.status)&&null!==r.response){let n=r.response;if("json"===t.type)try{n=JSON.parse(r.response);}catch(t){return e(t)}e(null,n,r.getResponseHeader("Cache-Control"),r.getResponseHeader("Expires"));}else e(new St(r.statusText,r.status,t.url));},r.send(t.body),{cancel:()=>r.abort()}}(t,e)},Pt=function(t,e){return kt(z(t,{type:"arrayBuffer"}),e)};function Et(t){const e=document.createElement("a");return e.href=t,e.protocol===location.protocol&&e.host===location.host}const zt="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let Tt,Bt;Tt=[],Bt=0;const Ct=function(t,e){if(gt.supported&&(t.headers||(t.headers={}),t.headers.accept="image/webp,*/*"),Bt>=n.MAX_PARALLEL_IMAGE_REQUESTS){const r={requestParameters:t,callback:e,cancelled:!1,cancel(){this.cancelled=!0;}};return Tt.push(r),r}Bt++;let r=!1;const i=()=>{if(!r)for(r=!0,Bt--;Tt.length&&Bt{i(),t?e(t):r&&(self.createImageBitmap?function(t,e){const r=new Blob([new Uint8Array(t)],{type:"image/png"});createImageBitmap(r).then((t=>{e(null,t);})).catch((t=>{e(new Error(`Could not load image because of ${t.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`));}));}(r,((t,r)=>e(t,r,n,a))):function(t,e){const r=new Image;r.onload=()=>{e(null,r),URL.revokeObjectURL(r.src),r.onload=null,requestAnimationFrame((()=>{r.src=zt;}));},r.onerror=()=>e(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 n=new Blob([new Uint8Array(t)],{type:"image/png"});r.src=t.byteLength?URL.createObjectURL(n):zt;}(r,((t,r)=>e(t,r,n,a))));}));return {cancel:()=>{a.cancel(),i();}}},Rt="01",Dt="NO_ACCESS_TOKEN",Vt=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function Lt(t){const e=t.match(Vt);if(!e)throw new Error("Unable to parse URL object");return {protocol:e[1],authority:e[2],path:e[3]||"/",params:e[4]?e[4].split("&"):[]}}function Ft(t){const e=t.params.length?`?${t.params.join("&")}`:"";return `${t.protocol}://${t.authority}${t.path}${e}`}const Nt="mapbox.eventData";function Ot(t){if(!t)return null;const e=t.split(".");if(!e||3!==e.length)return null;try{return JSON.parse(decodeURIComponent(atob(e[1]).split("").map((t=>"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2))).join("")))}catch(t){return null}}class Ut{constructor(t){this.type=t,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null;}getStorageKey(t){const e=Ot(n.ACCESS_TOKEN);let r="";return r=e&&e.u?btoa(encodeURIComponent(e.u).replace(/%([0-9A-F]{2})/g,((t,e)=>String.fromCharCode(Number("0x"+e))))):n.ACCESS_TOKEN||"",t?`${Nt}.${t}:${r}`:`${Nt}:${r}`}fetchEventData(){const t=et("localStorage"),e=this.getStorageKey(),r=this.getStorageKey("uuid");if(t)try{const t=localStorage.getItem(e);t&&(this.eventData=JSON.parse(t));const n=localStorage.getItem(r);n&&(this.anonId=n);}catch(t){j("Unable to read from LocalStorage");}}saveEventData(){const t=et("localStorage"),e=this.getStorageKey(),r=this.getStorageKey("uuid"),n=this.anonId;if(t&&n)try{localStorage.setItem(r,n),Object.keys(this.eventData).length>=1&&localStorage.setItem(e,JSON.stringify(this.eventData));}catch(t){j("Unable to write to LocalStorage");}}processRequests(t){}postEvent(t,e,r,i){if(!n.EVENTS_URL)return;const a=Lt(n.EVENTS_URL);a.params.push(`access_token=${i||n.ACCESS_TOKEN||""}`);const s={event:this.type,created:new Date(t).toISOString()},o=e?z(s,e):s,l={url:Ft(a),headers:{"Content-Type":"text/plain"},body:JSON.stringify([o])};this.pendingRequest=function(t,e){return kt(z(t,{method:"POST"}),e)}(l,(t=>{this.pendingRequest=null,r(t),this.saveEventData(),this.processRequests(i);}));}queueRequest(t,e){this.queue.push(t),this.processRequests(e);}}const jt=new class extends Ut{constructor(t){super("appUserTurnstile"),this._customAccessToken=t;}postTurnstileEvent(t,e){n.EVENTS_URL&&n.ACCESS_TOKEN&&Array.isArray(t)&&t.some((t=>a(t)||i(t)))&&this.queueRequest(Date.now(),e);}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const r=Ot(n.ACCESS_TOKEN),i=r?r.u:n.ACCESS_TOKEN;let a=i!==this.eventData.tokenU;D(this.anonId)||(this.anonId=C(),a=!0);const s=this.queue.shift();if(this.eventData.lastSuccess){const t=new Date(this.eventData.lastSuccess),e=new Date(s),r=(s-this.eventData.lastSuccess)/864e5;a=a||r>=1||r<-1||t.getDate()!==e.getDate();}else a=!0;a?this.postEvent(s,{sdkIdentifier:"mapbox-gl-js",sdkVersion:e,skuId:Rt,"enabled.telemetry":!1,userId:this.anonId},(t=>{t||(this.eventData.lastSuccess=s,this.eventData.tokenU=i);}),t):this.processRequests();}},qt=jt.postTurnstileEvent.bind(jt),$t=new class extends Ut{constructor(){super("map.load"),this.success={},this.skuToken="";}postMapLoadEvent(t,e,r,i){this.skuToken=e,this.errorCb=i,n.EVENTS_URL&&(r||n.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},r):this.errorCb(new Error(Dt)));}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;const{id:r,timestamp:n}=this.queue.shift();r&&this.success[r]||(this.anonId||this.fetchEventData(),D(this.anonId)||(this.anonId=C()),this.postEvent(n,{sdkIdentifier:"mapbox-gl-js",sdkVersion:e,skuId:Rt,skuToken:this.skuToken,userId:this.anonId},(t=>{t?this.errorCb(t):r&&(this.success[r]=!0);}),t));}remove(){this.errorCb=null;}},Gt=$t.postMapLoadEvent.bind($t),Yt=new class extends Ut{constructor(){super("gljs.performance");}postPerformanceEvent(t,e){n.EVENTS_URL&&(t||n.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:e},t);}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:r,performanceData:n}=this.queue.shift(),i=function(t){const r=performance.getEntriesByType("resource"),n=performance.getEntriesByType("mark"),i=function(t){const e={};if(t)for(const r in t)if("other"!==r)for(const n of t[r]){const t=`${r}ResolveRangeMin`,i=`${r}ResolveRangeMax`,a=`${r}RequestCount`,s=`${r}RequestCachedCount`;e[t]=Math.min(e[t]||1/0,n.startTime),e[i]=Math.max(e[i]||-1/0,n.responseEnd);const o=t=>{void 0===e[t]&&(e[t]=0),++e[t];};void 0!==n.transferSize&&0===n.transferSize&&o(s),o(a);}return e}(function(t,e){const r={};if(t)for(const n of t){const t=e(n);void 0===r[t]&&(r[t]=[]),r[t].push(n);}return r}(r,c)),a=window.devicePixelRatio,s=navigator.connection||navigator.mozConnection||navigator.webkitConnection,o=s?s.effectiveType:void 0,h={counters:[],metadata:[],attributes:[]},p=(t,e,r)=>{null!=r&&t.push({name:e,value:r.toString()});};for(const t in i)p(h.counters,t,i[t]);if(t.interactionRange[0]!==1/0&&t.interactionRange[1]!==-1/0&&(p(h.counters,"interactionRangeMin",t.interactionRange[0]),p(h.counters,"interactionRangeMax",t.interactionRange[1])),n)for(const t of Object.keys(u)){const e=u[t],r=n.find((t=>t.name===e));r&&p(h.counters,e,r.startTime);}return p(h.counters,"visibilityHidden",t.visibilityHidden),p(h.attributes,"style",function(t){if(t)for(const e of t){const t=e.name.split("?")[0];if(l(t)){const e=t.split("/").slice(-2);if(2===e.length)return `mapbox://styles/${e[0]}/${e[1]}`}}}(r)),p(h.attributes,"terrainEnabled",t.terrainEnabled?"true":"false"),p(h.attributes,"fogEnabled",t.fogEnabled?"true":"false"),p(h.attributes,"projection",t.projection),p(h.attributes,"zoom",t.zoom),p(h.metadata,"devicePixelRatio",a),p(h.metadata,"connectionEffectiveType",o),p(h.metadata,"navigatorUserAgent",navigator.userAgent),p(h.metadata,"screenWidth",window.screen.width),p(h.metadata,"screenHeight",window.screen.height),p(h.metadata,"windowWidth",window.innerWidth),p(h.metadata,"windowHeight",window.innerHeight),p(h.metadata,"mapWidth",t.width/a),p(h.metadata,"mapHeight",t.height/a),p(h.metadata,"webglRenderer",t.renderer),p(h.metadata,"webglVendor",t.vendor),p(h.metadata,"sdkVersion",e),p(h.metadata,"sdkIdentifier","mapbox-gl-js"),h}(n);for(const t of i.metadata);for(const t of i.counters);for(const t of i.attributes);this.postEvent(r,i,(()=>{}),t);}},Xt=Yt.postPerformanceEvent.bind(Yt),Zt=new class extends Ut{constructor(){super("map.auth"),this.success={},this.skuToken="";}getSession(t,e,r,i){if(!n.API_URL||!n.SESSION_PATH)return;const a=Lt(n.API_URL+n.SESSION_PATH);a.params.push(`sku=${e||""}`),a.params.push(`access_token=${i||n.ACCESS_TOKEN||""}`);const s={url:Ft(a),headers:{"Content-Type":"text/plain"}};this.pendingRequest=function(t,e){return kt(z(t,{method:"GET"}),e)}(s,(t=>{this.pendingRequest=null,r(t),this.saveEventData(),this.processRequests(i);}));}getSessionAPI(t,e,r,i){this.skuToken=e,this.errorCb=i,n.SESSION_PATH&&n.API_URL&&(r||n.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},r):this.errorCb(new Error(Dt)));}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;const{id:e,timestamp:r}=this.queue.shift();e&&this.success[e]||this.getSession(r,this.skuToken,(t=>{t?this.errorCb(t):e&&(this.success[e]=!0);}),t);}remove(){this.errorCb=null;}},Kt=Zt.getSessionAPI.bind(Zt),Ht=new Set;function Wt(t,e,r){r[t]&&-1!==r[t].indexOf(e)||(r[t]=r[t]||[],r[t].push(e));}function Jt(t,e,r){if(r&&r[t]){const n=r[t].indexOf(e);-1!==n&&r[t].splice(n,1);}}class Qt{constructor(t,e={}){z(this,e),this.type=t;}}class te extends Qt{constructor(t,e={}){super("error",z({error:t},e));}}class ee{on(t,e){return this._listeners=this._listeners||{},Wt(t,e,this._listeners),this}off(t,e){return Jt(t,e,this._listeners),Jt(t,e,this._oneTimeListeners),this}once(t,e){return e?(this._oneTimeListeners=this._oneTimeListeners||{},Wt(t,e,this._oneTimeListeners),this):new Promise((e=>this.once(t,e)))}fire(t,e){"string"==typeof t&&(t=new Qt(t,e||{}));const r=t.type;if(this.listens(r)){t.target=this;const e=this._listeners&&this._listeners[r]?this._listeners[r].slice():[];for(const r of e)r.call(this,t);const n=this._oneTimeListeners&&this._oneTimeListeners[r]?this._oneTimeListeners[r].slice():[];for(const e of n)Jt(r,e,this._oneTimeListeners),e.call(this,t);const i=this._eventedParent;i&&(z(t,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),i.fire(t));}else t instanceof te&&console.error(t.error);return this}listens(t){return !!(this._listeners&&this._listeners[t]&&this._listeners[t].length>0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t))}setEventedParent(t,e){return this._eventedParent=t,this._eventedParentData=e,this}}t.y=void 0;var re={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function ne(t){return (t=Math.round(t))<0?0:t>255?255:t}function ie(t){return ne("%"===t[t.length-1]?parseFloat(t)/100*255:parseInt(t))}function ae(t){return (e="%"===t[t.length-1]?parseFloat(t)/100:parseFloat(t))<0?0:e>1?1:e;var e;}function se(t,e,r){return r<0?r+=1:r>1&&(r-=1),6*r<1?t+(e-t)*r*6:2*r<1?e:3*r<2?t+(e-t)*(2/3-r)*6:t}try{t.y={}.parseCSSColor=function(t){var e,r=t.replace(/ /g,"").toLowerCase();if(r in re)return re[r].slice();if("#"===r[0])return 4===r.length?(e=parseInt(r.substr(1),16))>=0&&e<=4095?[(3840&e)>>4|(3840&e)>>8,240&e|(240&e)>>4,15&e|(15&e)<<4,1]:null:7===r.length&&(e=parseInt(r.substr(1),16))>=0&&e<=16777215?[(16711680&e)>>16,(65280&e)>>8,255&e,1]:null;var n=r.indexOf("("),i=r.indexOf(")");if(-1!==n&&i+1===r.length){var a=r.substr(0,n),s=r.substr(n+1,i-(n+1)).split(","),o=1;switch(a){case"rgba":if(4!==s.length)return null;o=ae(s.pop());case"rgb":return 3!==s.length?null:[ie(s[0]),ie(s[1]),ie(s[2]),o];case"hsla":if(4!==s.length)return null;o=ae(s.pop());case"hsl":if(3!==s.length)return null;var l=(parseFloat(s[0])%360+360)%360/360,u=ae(s[1]),c=ae(s[2]),h=c<=.5?c*(u+1):c+u-c*u,p=2*c-h;return [ne(255*se(p,h,l+1/3)),ne(255*se(p,h,l)),ne(255*se(p,h,l-1/3)),o];default:return null}}return null};}catch(t){}class oe{constructor(t,e,r,n=1){this.r=t,this.g=e,this.b=r,this.a=n;}static parse(e){if(!e)return;if(e instanceof oe)return e;if("string"!=typeof e)return;const r=t.y(e);return r?new oe(r[0]/255*r[3],r[1]/255*r[3],r[2]/255*r[3],r[3]):void 0}toString(){const[t,e,r,n]=this.toArray();return `rgba(${Math.round(t)},${Math.round(e)},${Math.round(r)},${n})`}toArray(){const{r:t,g:e,b:r,a:n}=this;return 0===n?[0,0,0,0]:[255*t/n,255*e/n,255*r/n,n]}toArray01(){const{r:t,g:e,b:r,a:n}=this;return 0===n?[0,0,0,0]:[t/n,e/n,r/n,n]}toArray01Scaled(t){const{r:e,g:r,b:n,a:i}=this;return 0===i?[0,0,0]:[e/i*t,r/i*t,n/i*t]}toArray01PremultipliedAlpha(){const{r:t,g:e,b:r,a:n}=this;return [t,e,r,n]}toArray01Linear(){const{r:t,g:e,b:r,a:n}=this;return 0===n?[0,0,0,0]:[Math.pow(t/n,2.2),Math.pow(e/n,2.2),Math.pow(r/n,2.2),n]}}oe.black=new oe(0,0,0,1),oe.white=new oe(1,1,1,1),oe.transparent=new oe(0,0,0,0),oe.red=new oe(1,0,0,1),oe.blue=new oe(0,0,1,1);var le=oe;function ue(t,e,r){return t*(1-r)+e*r}function ce(t,e,r){return t.map(((t,n)=>ue(t,e[n],r)))}var he=Object.freeze({__proto__:null,array:ce,color:function(t,e,r){return new le(ue(t.r,e.r,r),ue(t.g,e.g,r),ue(t.b,e.b,r),ue(t.a,e.a,r))},number:ue});function pe(t,...e){for(const r of e)for(const e in r)t[e]=r[e];return t}class fe extends Error{constructor(t,e){super(e),this.message=e,this.key=t;}}var de=fe;class me{constructor(t,e=[]){this.parent=t,this.bindings={};for(const[t,r]of e)this.bindings[t]=r;}concat(t){return new me(this,t)}get(t){if(this.bindings[t])return this.bindings[t];if(this.parent)return this.parent.get(t);throw new Error(`${t} not found in scope.`)}has(t){return !!this.bindings[t]||!!this.parent&&this.parent.has(t)}}var ye=me;const ge={kind:"null"},xe={kind:"number"},ve={kind:"string"},be={kind:"boolean"},_e={kind:"color"},we={kind:"object"},Me={kind:"value"},Ae={kind:"collator"},Se={kind:"formatted"},Ie={kind:"resolvedImage"};function ke(t,e){return {kind:"array",itemType:t,N:e}}function Pe(t){if("array"===t.kind){const e=Pe(t.itemType);return "number"==typeof t.N?`array<${e}, ${t.N}>`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const Ee=[ge,xe,ve,be,_e,Se,we,ke(Me),Ie];function ze(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!ze(t.itemType,e.itemType))&&("number"!=typeof t.N||t.N===e.N))return null}else {if(t.kind===e.kind)return null;if("value"===t.kind)for(const t of Ee)if(!ze(t,e))return null}return `Expected ${Pe(t)} but found ${Pe(e)} instead.`}function Te(t,e){return e.some((e=>e.kind===t.kind))}function Be(t,e){return e.some((e=>"null"===e?null===t:"array"===e?Array.isArray(t):"object"===e?t&&!Array.isArray(t)&&"object"==typeof t:e===typeof t))}class Ce{constructor(t,e,r){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=r,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"});}compare(t,e){return this.collator.compare(t,e)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class Re{constructor(t,e,r,n,i){this.text=t.normalize?t.normalize():t,this.image=e,this.scale=r,this.fontStack=n,this.textColor=i;}}class De{constructor(t){this.sections=t;}static fromString(t){return new De([new Re(t,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((t=>0!==t.text.length||t.image&&0!==t.image.namePrimary.length))}static factory(t){return t instanceof De?t:De.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map((t=>t.text)).join("")}serialize(){const t=["format"];for(const e of this.sections){if(e.image){t.push(["image",e.image.namePrimary]);continue}t.push(e.text);const r={};e.fontStack&&(r["text-font"]=["literal",e.fontStack.split(",")]),e.scale&&(r["font-scale"]=e.scale),e.textColor&&(r["text-color"]=["rgba"].concat(e.textColor.toArray())),t.push(r);}return t}}class Ve{constructor(t){this.namePrimary=t.namePrimary,t.nameSecondary&&(this.nameSecondary=t.nameSecondary),this.available=t.available;}toString(){return this.nameSecondary?`[${this.namePrimary},${this.nameSecondary}]`:this.namePrimary}static fromString(t,e){return t?new Ve({namePrimary:t,nameSecondary:e,available:!1}):null}serialize(){return this.nameSecondary?["image",this.namePrimary,this.nameSecondary]:["image",this.namePrimary]}}function Le(t,e,r,n){return "number"==typeof t&&t>=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof r&&r>=0&&r<=255?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid rgba value [${[t,e,r,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof n?[t,e,r,n]:[t,e,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Fe(t){if(null===t)return !0;if("string"==typeof t)return !0;if("boolean"==typeof t)return !0;if("number"==typeof t)return !0;if(t instanceof le)return !0;if(t instanceof Ce)return !0;if(t instanceof De)return !0;if(t instanceof Ve)return !0;if(Array.isArray(t)){for(const e of t)if(!Fe(e))return !1;return !0}if("object"==typeof t){for(const e in t)if(!Fe(t[e]))return !1;return !0}return !1}function Ne(t){if(null===t)return ge;if("string"==typeof t)return ve;if("boolean"==typeof t)return be;if("number"==typeof t)return xe;if(t instanceof le)return _e;if(t instanceof Ce)return Ae;if(t instanceof De)return Se;if(t instanceof Ve)return Ie;if(Array.isArray(t)){const e=t.length;let r;for(const e of t){const t=Ne(e);if(r){if(r===t)continue;r=Me;break}r=t;}return ke(r||Me,e)}return we}function Oe(t){const e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof le||t instanceof De||t instanceof Ve?t.toString():JSON.stringify(t)}class Ue{constructor(t,e){this.type=t,this.value=e;}static parse(t,e){if(2!==t.length)return e.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!Fe(t[1]))return e.error("invalid value");const r=t[1];let n=Ne(r);const i=e.expectedType;return "array"!==n.kind||0!==n.N||!i||"array"!==i.kind||"number"==typeof i.N&&0!==i.N||(n=i),new Ue(n,r)}evaluate(){return this.value}eachChild(){}outputDefined(){return !0}serialize(){return "array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof le?["rgba"].concat(this.value.toArray()):this.value instanceof De?this.value.serialize():this.value}}var je=Ue,qe=class{constructor(t){this.name="ExpressionEvaluationError",this.message=t;}toJSON(){return this.message}};const $e={string:ve,number:xe,boolean:be,object:we};class Ge{constructor(t,e){this.type=t,this.args=e;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");let r,n=1;const i=t[0];if("array"===i){let i,a;if(t.length>2){const r=t[1];if("string"!=typeof r||!(r in $e)||"object"===r)return e.error('The item type argument of "array" must be one of string, number, boolean',1);i=$e[r],n++;}else i=Me;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2])))return e.error('The length argument to "array" must be a positive integer literal',2);a=t[2],n++;}r=ke(i,a);}else r=$e[i];const a=[];for(;nt.outputDefined()))}serialize(){const t=this.type,e=[t.kind];if("array"===t.kind){const r=t.itemType;if("string"===r.kind||"number"===r.kind||"boolean"===r.kind){e.push(r.kind);const n=t.N;("number"==typeof n||this.args.length>1)&&e.push(n);}}return e.concat(this.args.map((t=>t.serialize())))}}var Ye=Ge;class Xe{constructor(t){this.type=Se,this.sections=t;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const r=t[1];if(!Array.isArray(r)&&"object"==typeof r)return e.error("First argument must be an image or text section.");const n=[];let i=!1;for(let r=1;r<=t.length-1;++r){const a=t[r];if(i&&"object"==typeof a&&!Array.isArray(a)){i=!1;let t=null;if(a["font-scale"]&&(t=e.parse(a["font-scale"],1,xe),!t))return null;let r=null;if(a["text-font"]&&(r=e.parse(a["text-font"],1,ke(ve)),!r))return null;let s=null;if(a["text-color"]&&(s=e.parse(a["text-color"],1,_e),!s))return null;const o=n[n.length-1];o.scale=t,o.font=r,o.textColor=s;}else {const a=e.parse(t[r],1,Me);if(!a)return null;const s=a.type.kind;if("string"!==s&&"value"!==s&&"null"!==s&&"resolvedImage"!==s)return e.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");i=!0,n.push({content:a,scale:null,font:null,textColor:null});}}return new Xe(n)}evaluate(t){return new De(this.sections.map((e=>{const r=e.content.evaluate(t);return Ne(r)===Ie?new Re("",r,null,null,null):new Re(Oe(r),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null)})))}eachChild(t){for(const e of this.sections)t(e.content),e.scale&&t(e.scale),e.font&&t(e.font),e.textColor&&t(e.textColor);}outputDefined(){return !1}serialize(){const t=["format"];for(const e of this.sections){t.push(e.content.serialize());const r={};e.scale&&(r["font-scale"]=e.scale.serialize()),e.font&&(r["text-font"]=e.font.serialize()),e.textColor&&(r["text-color"]=e.textColor.serialize()),t.push(r);}return t}}class Ze{constructor(t,e){this.type=Ie,this.inputPrimary=t,this.inputSecondary=e;}static parse(t,e){if(t.length<2)return e.error("Expected two or more arguments.");const r=e.parse(t[1],1,ve);if(!r)return e.error("No image name provided.");if(2===t.length)return new Ze(r);const n=e.parse(t[2],1,ve);return n?new Ze(r,n):e.error("Secondary image variant is not a string.")}evaluate(t){const e=Ve.fromString(this.inputPrimary.evaluate(t),this.inputSecondary?this.inputSecondary.evaluate(t):void 0);return e&&t.availableImages&&(e.available=t.availableImages.indexOf(e.namePrimary)>-1,e.nameSecondary&&e.available&&t.availableImages&&(e.available=t.availableImages.indexOf(e.nameSecondary)>-1)),e}eachChild(t){t(this.inputPrimary),this.inputSecondary&&t(this.inputSecondary);}outputDefined(){return !1}serialize(){return this.inputSecondary?["image",this.inputPrimary.serialize(),this.inputSecondary.serialize()]:["image",this.inputPrimary.serialize()]}}function Ke(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}const He={"to-boolean":be,"to-color":_e,"to-number":xe,"to-string":ve};class We{constructor(t,e){this.type=t,this.args=e;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const r=t[0],n=[];let i=ge;if("to-array"===r){if(!Array.isArray(t[1]))return null;const r=t[1].length;if(e.expectedType){if("array"!==e.expectedType.kind)return e.error(`Expected ${e.expectedType.kind} but found array.`);i=ke(e.expectedType.itemType,r);}else {if(!(r>0&&Fe(t[1][0])))return null;i=ke(Ne(t[1][0]),r);}for(let a=0;a4?`Invalid rbga value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:Le(e[0],e[1],e[2],e[3]),!r))return new le(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new qe(r||`Could not parse color from value '${"string"==typeof e?e:String(JSON.stringify(e))}'`)}if("number"===this.type.kind){let e=null;for(const r of this.args){if(e=r.evaluate(t),null===e)return 0;const n=Number(e);if(!isNaN(n))return n}throw new qe(`Could not convert ${JSON.stringify(e)} to number.`)}return "formatted"===this.type.kind?De.fromString(Oe(this.args[0].evaluate(t))):"resolvedImage"===this.type.kind?Ve.fromString(Oe(this.args[0].evaluate(t))):"array"===this.type.kind?this.args.map((e=>e.evaluate(t))):Oe(this.args[0].evaluate(t))}eachChild(t){this.args.forEach(t);}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){if("formatted"===this.type.kind)return new Xe([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new Ze(this.args[0]).serialize();const t="array"===this.type.kind?[]:[`to-${this.type.kind}`];return this.eachChild((e=>{t.push(e.serialize());})),t}}var Je=We;const Qe=["Unknown","Point","LineString","Polygon"];var tr=class{constructor(t,e){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null,this.scope=t,this.options=e;}id(){return this.feature&&void 0!==this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Qe[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||{}}measureLight(t){return this.globals.brightness||0}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const t=this.featureDistanceData.center,e=this.featureDistanceData.scale,{x:r,y:n}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(r*e-t[0])+this.featureDistanceData.bearing[1]*(n*e-t[1])}return 0}parseColor(t){let e=this._parseColorCache[t];return e||(e=this._parseColorCache[t]=le.parse(t)),e}getConfig(t){return this.options?this.options.get(t):null}};class er{constructor(t,e,r,n,i){this.name=t,this.type=e,this._evaluate=r,this.args=n,this._overloadIndex=i;}evaluate(t){if(!this._evaluate){const t=er.definitions[this.name];this._evaluate=Array.isArray(t)?t[2]:t.overloads[this._overloadIndex][1];}return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t);}outputDefined(){return !1}serialize(){return [this.name].concat(this.args.map((t=>t.serialize())))}static parse(t,e){const r=t[0],n=er.definitions[r];if(!n)return e.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0);const i=Array.isArray(n)?n[0]:n.type,a=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,s=[];let o=null,l=-1;for(const[n,u]of a){if(Array.isArray(n)&&n.length!==t.length-1)continue;s.push(n),l++,o=new _n(e.registry,e.path,null,e.scope,void 0,e._scope,e.options);const a=[];let c=!1;for(let e=1;et))).map(rr).join(" | "),n=[];for(let r=1;ri;){if(a-i>600){var o=a-i+1,l=n-i+1,u=Math.log(o),c=.5*Math.exp(2*u/3),h=.5*Math.sqrt(u*c*(o-c)/o)*(l-o/2<0?-1:1);t(r,n,Math.max(i,Math.floor(n-l*c/o+h)),Math.min(a,Math.floor(n+(o-l)*c/o+h)),s);}var p=r[n],f=i,d=a;for(e(r,i,n),s(r[a],p)>0&&e(r,i,a);f0;)d--;}0===s(r[i],p)?e(r,i,d):e(r,++d,a),d<=n&&(i=d+1),n<=d&&(a=d-1);}}function e(t,e,r){var n=t[e];t[e]=t[r],t[r]=n;}function r(t,e){return te?1:0}return function(e,n,i,a,s){t(e,n,i||0,a||e.length-1,s||r);}}();var sr=h(ar.exports);function or(t){let e=0;for(let r,n,i=0,a=t.length,s=a-1;i=e[2]||t[1]<=e[1]||t[3]>=e[3])}function cr(t,e,r){const n=t[0]-e[0],i=t[1]-e[1],a=t[0]-r[0],s=t[1]-r[1];return n*s-a*i==0&&n*a<=0&&i*s<=0}function hr(t,e,r=!1){let n=!1;for(let o=0,l=e.length;o(i=t)[1]!=(s=c)[1]>i[1]&&i[0]<(s[0]-a[0])*(i[1]-a[1])/(s[1]-a[1])+a[0]&&(n=!n);}}var i,a,s;return n}function pr(t,e,r,n){const i=n[0]-r[0],a=n[1]-r[1],s=(t[0]-r[0])*a-i*(t[1]-r[1]),o=(e[0]-r[0])*a-i*(e[1]-r[1]);return s>0&&o<0||s<0&&o>0}function fr(t,e,r,n){return 0!=(i=[n[0]-r[0],n[1]-r[1]])[0]*(a=[e[0]-t[0],e[1]-t[1]])[1]-i[1]*a[0]&&!(!pr(t,e,r,n)||!pr(r,n,t,e));var i,a;}const dr=8192;function mr(t,e){const r=(180+t[0])/360,n=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,i=Math.pow(2,e.z);return [Math.round(r*i*dr),Math.round(n*i*dr)]}function yr(t,e){for(let r=0;rr[2]){const e=.5*n;let i=t[0]-r[0]>e?-n:r[0]-t[0]>e?n:0;0===i&&(i=t[0]-r[2]>e?-n:r[2]-t[0]>e?n:0),t[0]+=i;}lr(e,t);}function Mr(t,e,r,n){const i=Math.pow(2,n.z)*dr,a=[n.x*dr,n.y*dr],s=[];if(!t)return s;for(const n of t)for(const t of n){const n=[t.x+a[0],t.y+a[1]];wr(n,e,r,i),s.push(n);}return s}function Ar(t,e,r,n){const i=Math.pow(2,n.z)*dr,a=[n.x*dr,n.y*dr],s=[];if(!t)return s;for(const r of t){const t=[];for(const n of r){const r=[n.x+a[0],n.y+a[1]];lr(e,r),t.push(r);}s.push(t);}if(e[2]-e[0]<=i/2){(o=e)[0]=o[1]=1/0,o[2]=o[3]=-1/0;for(const t of s)for(const n of t)wr(n,e,r,i);}var o;return s}class Sr{constructor(t,e){this.type=be,this.geojson=t,this.geometries=e;}static parse(t,e){if(2!==t.length)return e.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(Fe(t[1])){const e=t[1];if("FeatureCollection"===e.type)for(let t=0;t180;)t-=360;return t}return i.fromTile=function(t,e,r){var a=Math.PI*(1-2*(t+.5)/Math.pow(2,e)),s=Math.atan(.5*(Math.exp(a)-Math.exp(-a)))/n;return new i(s,r)},a.units.get=function(){return t},i.prototype.distance=function(t,e){var r=l(t[0]-e[0])*this.kx,n=(t[1]-e[1])*this.ky;return Math.sqrt(r*r+n*n)},i.prototype.bearing=function(t,e){var r=l(e[0]-t[0])*this.kx;return Math.atan2(r,(e[1]-t[1])*this.ky)/n},i.prototype.destination=function(t,e,r){var i=r*n;return this.offset(t,Math.sin(i)*e,Math.cos(i)*e)},i.prototype.offset=function(t,e,r){return [t[0]+e/this.kx,t[1]+r/this.ky]},i.prototype.lineDistance=function(t){for(var e=0,r=0;re)return o(i,a,(e-(r-s))/s)}return t[t.length-1]},i.prototype.pointToSegmentDistance=function(t,e,r){var n=e[0],i=e[1],a=l(r[0]-n)*this.kx,s=(r[1]-i)*this.ky,o=0;return 0===a&&0===s||((o=(l(t[0]-n)*this.kx*a+(t[1]-i)*this.ky*s)/(a*a+s*s))>1?(n=r[0],i=r[1]):o>0&&(n+=a/this.kx*o,i+=s/this.ky*o)),a=l(t[0]-n)*this.kx,s=(t[1]-i)*this.ky,Math.sqrt(a*a+s*s)},i.prototype.pointOnLine=function(t,e){for(var r,n,i,a,s=1/0,o=0;o1?(u=t[o+1][0],c=t[o+1][1]):f>0&&(u+=h/this.kx*f,c+=p/this.ky*f));var d=(h=l(e[0]-u)*this.kx)*h+(p=(e[1]-c)*this.ky)*p;di.index||n.index===i.index&&n.t>i.t){var a=n;n=i,i=a;}var o=[n.point],l=n.index+1,u=i.index;!s(r[l],o[0])&&l<=u&&o.push(r[l]);for(var c=l+1;c<=u;c++)o.push(r[c]);return s(r[u],i.point)||o.push(i.point),o},i.prototype.lineSliceAlong=function(t,e,r){for(var n=0,i=[],a=0;at&&0===i.length&&i.push(o(s,l,(t-(n-u))/u)),n>=e)return i.push(o(s,l,(e-(n-u))/u)),i;n>t&&i.push(l);}return i},i.prototype.bufferPoint=function(t,e){var r=e/this.ky,n=e/this.kx;return [t[0]-n,t[1]-r,t[0]+n,t[1]+r]},i.prototype.bufferBBox=function(t,e){var r=e/this.ky,n=e/this.kx;return [t[0]-n,t[1]-r,t[2]+n,t[3]+r]},i.prototype.insideBBox=function(t,e){return l(t[0]-e[0])>=0&&l(t[0]-e[2])<=0&&t[1]>=e[1]&&t[1]<=e[3]},Object.defineProperties(i,a),i}();var Pr=h(kr.exports),Er={exports:{}};Er.exports=function(){var t=function(t,r){if(void 0===t&&(t=[]),void 0===r&&(r=e),this.data=t,this.length=this.data.length,this.compare=r,this.length>0)for(var n=(this.length>>1)-1;n>=0;n--)this._down(n);};function e(t,e){return te?1:0}return t.prototype.push=function(t){this.data.push(t),this.length++,this._up(this.length-1);},t.prototype.pop=function(){if(0!==this.length){var t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}},t.prototype.peek=function(){return this.data[0]},t.prototype._up=function(t){for(var e=this.data,r=this.compare,n=e[t];t>0;){var i=t-1>>1,a=e[i];if(r(n,a)>=0)break;e[t]=a,t=i;}e[t]=n;},t.prototype._down=function(t){for(var e=this.data,r=this.compare,n=this.length>>1,i=e[t];t=0)break;e[t]=s,t=a;}e[t]=i;},t}();var zr=h(Er.exports),Tr=8192;function Br(t,e){return e.dist-t.dist}const Cr=100,Rr=50;function Dr(t){const e=[1/0,1/0,-1/0,-1/0];if(e.length!==t.length)return !1;for(let r=0;r=t[0]&&t[1]t[1])return [null,null];const r=Vr(t);if(e){if(2===r)return [t,null];const e=Math.floor(r/2);return [[t[0],t[0]+e],[t[0]+e,t[1]]]}{if(1===r)return [t,null];const e=Math.floor(r/2)-1;return [[t[0],t[0]+e],[t[0]+e+1,t[1]]]}}function Nr(t,e){const r=[1/0,1/0,-1/0,-1/0];if(!Lr(e,t.length))return r;for(let n=e[0];n<=e[1];++n)lr(r,t[n]);return r}function Or(t){const e=[1/0,1/0,-1/0,-1/0];for(let r=0;re[2]&&(n=t[0]-e[2]),t[1]>e[3]&&(i=t[1]-e[3]),t[3]=n)return n;if(ur(i,a)){if(Qr(t,e))return 0}else if(Qr(e,t))return 0;let s=n;for(const n of t)for(let t=0,i=n.length,a=i-1;t=a)continue;const u=i.range1;if(Vr(u)<=o){if(!Lr(u,t.length))return NaN;if(e){const e=Jr(t,u,r,n);if(0===(a=Math.min(a,e)))return a}else for(let e=u[0];e<=u[1];++e){const i=Wr(t[e],r,n);if(0===(a=Math.min(a,i)))return a}}else {const r=Fr(u,e);if(null!==r[0]){const e=Ur(Nr(t,r[0]),l,n);e=s)continue;const c=a.range1,h=a.range2;if(Vr(c)<=l&&Vr(h)<=u){if(!Lr(c,t.length)||!Lr(h,r.length))return NaN;if(e&&n?s=Math.min(s,Kr(t,c,r,h,i)):e||n?e&&!n?s=Math.min(s,Xr(r,h,t,c,i)):!e&&n&&(s=Math.min(s,Xr(t,c,r,h,i))):s=Math.min(s,Hr(t,c,r,h,i)),0===s)return s}else {const a=Fr(c,e),l=Fr(h,n);en(o,s,i,t,r,a[0],l[0]),en(o,s,i,t,r,a[0],l[1]),en(o,s,i,t,r,a[1],l[0]),en(o,s,i,t,r,a[1],l[1]);}}return s}function an(t,e,r,n,i=1/0){let a=i;const s=Nr(t,[0,t.length-1]);for(const i of r)if(!(a!==1/0&&Ur(s,Nr(i,[0,i.length-1]),n)>=a)&&(a=Math.min(a,nn(t,e,i,!0,n,a)),0===a))return a;return a}function sn(t,e,r,n,i=1/0){let a=i;const s=Nr(t,[0,t.length-1]);for(const i of r){if(a!==1/0&&Ur(s,Or(i),n)>=a)continue;const r=rn(t,e,i,n,a);if(isNaN(r))return r;if(0===(a=Math.min(a,r)))return a}return a}function on(t){return "Point"===t||"MultiPoint"===t||"LineString"===t||"MultiLineString"===t||"Polygon"===t||"MultiPolygon"===t}class ln{constructor(t,e){this.type=xe,this.geojson=t,this.geometries=e;}static parse(t,e){if(2!==t.length)return e.error(`'distance' expression requires either one argument, but found ' ${t.length-1} instead.`);if(Fe(t[1])){const e=t[1];if("FeatureCollection"===e.type){for(let t=0;tr&&(t=r),t}class pn{constructor(t,e,r){this.type=t,this.key=e,this.scope=r;}static parse(t,e){let r=e.expectedType;if(null==r&&(r=Me),t.length<2||t.length>3)return e.error("Invalid number of arguments for 'config' expression.");const n=e.parse(t[1],1);if(!(n instanceof je))return e.error("Key name of 'config' expression must be a string literal.");if(t.length>=3){const i=e.parse(t[2],2);return i instanceof je?new pn(r,Oe(n.value),Oe(i.value)):e.error("Scope of 'config' expression must be a string literal.")}return new pn(r,Oe(n.value))}evaluate(t){const e=[this.key,this.scope,t.scope].filter(Boolean).join(""),r=t.getConfig(e);if(!r)return null;const{type:n,value:i,values:a,minValue:s,maxValue:o,stepValue:l}=r,u=r.default.evaluate(t);let c=u;if(i){const e=t.scope;t.scope=(e||"").split("").slice(1).join(""),c=i.evaluate(t),t.scope=e;}return n&&(c=cn(n,c)),void 0===c||void 0===s&&void 0===o&&void 0===l||("number"==typeof c?c=hn(c,s,o,l):Array.isArray(c)&&(c=c.map((t=>"number"==typeof t?hn(t,s,o,l):t)))),void 0!==i&&void 0!==c&&a&&!a.includes(c)&&(c=u,n&&(c=cn(n,c))),(n&&n!==this.type||void 0!==c&&Ne(c)!==this.type)&&(c=cn(this.type.kind,c)),c}eachChild(){}outputDefined(){return !1}serialize(){const t=["config",this.key];return this.scope&&t.concat(this.key),t}}var fn=pn;function dn(t){if(t instanceof nr){if("get"===t.name&&1===t.args.length)return !1;if("feature-state"===t.name)return !1;if("has"===t.name&&1===t.args.length)return !1;if("properties"===t.name||"geometry-type"===t.name||"id"===t.name)return !1;if(/^filter-/.test(t.name))return !1}if(t instanceof Ir)return !1;if(t instanceof un)return !1;let e=!0;return t.eachChild((t=>{e&&!dn(t)&&(e=!1);})),e}function mn(t){if(t instanceof nr&&"feature-state"===t.name)return !1;let e=!0;return t.eachChild((t=>{e&&!mn(t)&&(e=!1);})),e}function yn(t){if(t instanceof fn)return !1;let e=!0;return t.eachChild((t=>{e&&!yn(t)&&(e=!1);})),e}function gn(t,e){if(t instanceof nr&&e.indexOf(t.name)>=0)return !1;let r=!0;return t.eachChild((t=>{r&&!gn(t,e)&&(r=!1);})),r}class xn{constructor(t,e){this.type=e.type,this.name=t,this.boundExpression=e;}static parse(t,e){if(2!==t.length||"string"!=typeof t[1])return e.error("'var' expression requires exactly one string literal argument.");const r=t[1];return e.scope.has(r)?new xn(r,e.scope.get(r)):e.error(`Unknown variable "${r}". Make sure "${r}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return !1}serialize(){return ["var",this.name]}}var vn=xn;class bn{constructor(t,e=[],r,n=new ye,i=[],a,s){this.registry=t,this.path=e,this.key=e.map((t=>`[${t}]`)).join(""),this.scope=n,this.errors=i,this.expectedType=r,this._scope=a,this.options=s;}parse(t,e,r,n,i={}){return e||r?this.concat(e,r,n)._parse(t,i):this._parse(t,i)}_parse(t,e){function r(t,e,r){return "assert"===r?new Ye(e,[t]):"coerce"===r?new Je(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const n="string"==typeof t[0]?this.registry[t[0]]:void 0;if(n){let i=n.parse(t,this);if(!i)return null;if(this.expectedType){const t=this.expectedType,n=i.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==n.kind)if("color"!==t.kind&&"formatted"!==t.kind&&"resolvedImage"!==t.kind||"value"!==n.kind&&"string"!==n.kind){if(this.checkSubtype(t,n))return null}else i=r(i,t,e.typeAnnotation||"coerce");else i=r(i,t,e.typeAnnotation||"assert");}if(!(i instanceof je)&&"resolvedImage"!==i.type.kind&&wn(i)){const t=new tr(this._scope,this.options);try{i=new je(i.type,i.evaluate(t));}catch(t){return this.error(t.message),null}}return i}return Je.parse(["to-array",t],this)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,e,r){const n="number"==typeof t?this.path.concat(t):this.path,i=r?this.scope.concat(r):this.scope;return new bn(this.registry,n,e||null,i,this.errors,this._scope,this.options)}error(t,...e){const r=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new de(r,t));}checkSubtype(t,e){const r=ze(t,e);return r&&this.error(r),r}}var _n=bn;function wn(t){if(t instanceof vn)return wn(t.boundExpression);if(t instanceof nr&&"error"===t.name)return !1;if(t instanceof ir)return !1;if(t instanceof Ir)return !1;if(t instanceof un)return !1;if(t instanceof fn)return !1;const e=t instanceof Je||t instanceof Ye;let r=!0;return t.eachChild((t=>{r=e?r&&wn(t):r&&t instanceof je;})),!!r&&dn(t)&&gn(t,["zoom","heatmap-density","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])}function Mn(t,e){const r=t.length-1;let n,i,a=0,s=r,o=0;for(;a<=s;)if(o=Math.floor((a+s)/2),n=t[o],i=t[o+1],n<=e){if(o===r||ee))throw new qe("Input is not a number.");s=o-1;}return 0}class An{constructor(t,e,r){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of r)this.labels.push(t),this.outputs.push(e);}static parse(t,e){if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");const r=e.parse(t[1],1,xe);if(!r)return null;const n=[];let i=null;e.expectedType&&"value"!==e.expectedType.kind&&(i=e.expectedType);for(let r=1;r=a)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',o);const u=e.parse(s,l,i);if(!u)return null;i=i||u.type,n.push([a,u]);}return new An(i,r,n)}evaluate(t){const e=this.labels,r=this.outputs;if(1===e.length)return r[0].evaluate(t);const n=this.input.evaluate(t);if(n<=e[0])return r[0].evaluate(t);const i=e.length;return n>=e[i-1]?r[i-1].evaluate(t):r[Mn(e,n)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e);}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){const t=["step",this.input.serialize()];for(let e=0;e0&&t.push(this.labels[e]),t.push(this.outputs[e].serialize());return t}}var Sn=An;const In=.95047,kn=1.08883,Pn=4/29,En=6/29,zn=3*En*En,Tn=En*En*En,Bn=Math.PI/180,Cn=180/Math.PI;function Rn(t){return t>Tn?Math.pow(t,1/3):t/zn+Pn}function Dn(t){return t>En?t*t*t:zn*(t-Pn)}function Vn(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function Ln(t){return (t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Fn(t){const e=Ln(t.r),r=Ln(t.g),n=Ln(t.b),i=Rn((.4124564*e+.3575761*r+.1804375*n)/In),a=Rn((.2126729*e+.7151522*r+.072175*n)/1);return {l:116*a-16,a:500*(i-a),b:200*(a-Rn((.0193339*e+.119192*r+.9503041*n)/kn)),alpha:t.a}}function Nn(t){let e=(t.l+16)/116,r=isNaN(t.a)?e:e+t.a/500,n=isNaN(t.b)?e:e-t.b/200;return e=1*Dn(e),r=In*Dn(r),n=kn*Dn(n),new le(Vn(3.2404542*r-1.5371385*e-.4985314*n),Vn(-.969266*r+1.8760108*e+.041556*n),Vn(.0556434*r-.2040259*e+1.0572252*n),t.alpha)}function On(t,e,r){const n=e-t;return t+r*(n>180||n<-180?n-360*Math.round(n/360):n)}const Un={forward:Fn,reverse:Nn,interpolate:function(t,e,r){return {l:ue(t.l,e.l,r),a:ue(t.a,e.a,r),b:ue(t.b,e.b,r),alpha:ue(t.alpha,e.alpha,r)}}},jn={forward:function(t){const{l:e,a:r,b:n}=Fn(t),i=Math.atan2(n,r)*Cn;return {h:i<0?i+360:i,c:Math.sqrt(r*r+n*n),l:e,alpha:t.a}},reverse:function(t){const e=t.h*Bn,r=t.c;return Nn({l:t.l,a:Math.cos(e)*r,b:Math.sin(e)*r,alpha:t.alpha})},interpolate:function(t,e,r){return {h:On(t.h,e.h,r),c:ue(t.c,e.c,r),l:ue(t.l,e.l,r),alpha:ue(t.alpha,e.alpha,r)}}};var qn=Object.freeze({__proto__:null,hcl:jn,lab:Un});class $n{constructor(t,e,r,n,i){this.type=t,this.operator=e,this.interpolation=r,this.input=n,this.labels=[],this.outputs=[];for(const[t,e]of i)this.labels.push(t),this.outputs.push(e);}static interpolationFactor(t,e,r,n){let i=0;if("exponential"===t.name)i=Gn(e,t.base,r,n);else if("linear"===t.name)i=Gn(e,1,r,n);else if("cubic-bezier"===t.name){const a=t.controlPoints;i=new d(a[0],a[1],a[2],a[3]).solve(Gn(e,1,r,n));}return i}static parse(t,e){let[r,n,i,...a]=t;if(!Array.isArray(n)||0===n.length)return e.error("Expected an interpolation type expression.",1);if("linear"===n[0])n={name:"linear"};else if("exponential"===n[0]){const t=n[1];if("number"!=typeof t)return e.error("Exponential interpolation requires a numeric base.",1,1);n={name:"exponential",base:t};}else {if("cubic-bezier"!==n[0])return e.error(`Unknown interpolation type ${String(n[0])}`,1,0);{const t=n.slice(1);if(4!==t.length||t.some((t=>"number"!=typeof t||t<0||t>1)))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);n={name:"cubic-bezier",controlPoints:t};}}if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");if(i=e.parse(i,2,xe),!i)return null;const s=[];let o=null;"interpolate-hcl"===r||"interpolate-lab"===r?o=_e:e.expectedType&&"value"!==e.expectedType.kind&&(o=e.expectedType);for(let t=0;t=r)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',i);const u=e.parse(n,l,o);if(!u)return null;o=o||u.type,s.push([r,u]);}return "number"===o.kind||"color"===o.kind||"array"===o.kind&&"number"===o.itemType.kind&&"number"==typeof o.N?new $n(o,r,n,i,s):e.error(`Type ${Pe(o)} is not interpolatable.`)}evaluate(t){const e=this.labels,r=this.outputs;if(1===e.length)return r[0].evaluate(t);const n=this.input.evaluate(t);if(n<=e[0])return r[0].evaluate(t);const i=e.length;if(n>=e[i-1])return r[i-1].evaluate(t);const a=Mn(e,n),s=$n.interpolationFactor(this.interpolation,n,e[a],e[a+1]),o=r[a].evaluate(t),l=r[a+1].evaluate(t);return "interpolate"===this.operator?he[this.type.kind.toLowerCase()](o,l,s):"interpolate-hcl"===this.operator?jn.reverse(jn.interpolate(jn.forward(o),jn.forward(l),s)):Un.reverse(Un.interpolate(Un.forward(o),Un.forward(l),s))}eachChild(t){t(this.input);for(const e of this.outputs)t(e);}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){let t;t="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const e=[this.operator,t,this.input.serialize()];for(let t=0;tze(n,t.type)));return new Xn(a?Me:r,i)}evaluate(t){let e,r=null,n=0;for(const i of this.args){if(n++,r=i.evaluate(t),r&&r instanceof Ve&&!r.available&&(e||(e=r),r=null,n===this.args.length))return e;if(null!==r)break}return r}eachChild(t){this.args.forEach(t);}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){const t=["coalesce"];return this.eachChild((e=>{t.push(e.serialize());})),t}}var Zn=Xn;class Kn{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e;}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const e of this.bindings)t(e[1]);t(this.result);}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);const r=[];for(let n=1;n=r.length)throw new qe(`Array index out of bounds: ${e} > ${r.length-1}.`);if(e!==Math.floor(e))throw new qe(`Array index must be an integer, but found ${e} instead.`);return r[e]}eachChild(t){t(this.index),t(this.input);}outputDefined(){return !1}serialize(){return ["at",this.index.serialize(),this.input.serialize()]}}var Jn=Wn;class Qn{constructor(t,e){this.type=be,this.needle=t,this.haystack=e;}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,Me),n=e.parse(t[2],2,Me);return r&&n?Te(r.type,[be,ve,xe,ge,Me])?new Qn(r,n):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${Pe(r.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(null==r)return !1;if(!Be(e,["boolean","string","number","null"]))throw new qe(`Expected first argument to be of type boolean, string, number or null, but found ${Pe(Ne(e))} instead.`);if(!Be(r,["string","array"]))throw new qe(`Expected second argument to be of type array or string, but found ${Pe(Ne(r))} instead.`);return r.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack);}outputDefined(){return !0}serialize(){return ["in",this.needle.serialize(),this.haystack.serialize()]}}var ti=Qn;class ei{constructor(t,e,r){this.type=xe,this.needle=t,this.haystack=e,this.fromIndex=r;}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,Me),n=e.parse(t[2],2,Me);if(!r||!n)return null;if(!Te(r.type,[be,ve,xe,ge,Me]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${Pe(r.type)} instead`);if(4===t.length){const i=e.parse(t[3],3,xe);return i?new ei(r,n,i):null}return new ei(r,n)}evaluate(t){const e=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(!Be(e,["boolean","string","number","null"]))throw new qe(`Expected first argument to be of type boolean, string, number or null, but found ${Pe(Ne(e))} instead.`);if(!Be(r,["string","array"]))throw new qe(`Expected second argument to be of type array or string, but found ${Pe(Ne(r))} instead.`);if(this.fromIndex){const n=this.fromIndex.evaluate(t);return r.indexOf(e,n)}return r.indexOf(e)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex);}outputDefined(){return !1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const t=this.fromIndex.serialize();return ["index-of",this.needle.serialize(),this.haystack.serialize(),t]}return ["index-of",this.needle.serialize(),this.haystack.serialize()]}}var ri=ei;class ni{constructor(t,e,r,n,i,a){this.inputType=t,this.type=e,this.input=r,this.cases=n,this.outputs=i,this.otherwise=a;}static parse(t,e){if(t.length<5)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return e.error("Expected an even number of arguments.");let r,n;e.expectedType&&"value"!==e.expectedType.kind&&(n=e.expectedType);const i={},a=[];for(let s=2;sNumber.MAX_SAFE_INTEGER)return u.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return u.error("Numeric branch labels must be integer values.");if(r){if(u.checkSubtype(r,Ne(t)))return null}else r=Ne(t);if(void 0!==i[String(t)])return u.error("Branch labels must be unique.");i[String(t)]=a.length;}const c=e.parse(l,s,n);if(!c)return null;n=n||c.type,a.push(c);}const s=e.parse(t[1],1,Me);if(!s)return null;const o=e.parse(t[t.length-1],t.length-1,n);return o?"value"!==s.type.kind&&e.concat(1).checkSubtype(r,s.type)?null:new ni(r,n,s,i,a,o):null}evaluate(t){const e=this.input.evaluate(t);return (Ne(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise);}outputDefined(){return this.outputs.every((t=>t.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["match",this.input.serialize()],e=Object.keys(this.cases).sort(),r=[],n={};for(const t of e){const e=n[this.cases[t]];void 0===e?(n[this.cases[t]]=r.length,r.push([this.cases[t],[t]])):r[e][1].push(t);}const i=t=>"number"===this.inputType.kind?Number(t):t;for(const[e,n]of r)t.push(1===n.length?i(n[0]):n.map(i)),t.push(this.outputs[e].serialize());return t.push(this.otherwise.serialize()),t}}var ii=ni;class ai{constructor(t,e,r){this.type=t,this.branches=e,this.otherwise=r;}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return e.error("Expected an odd number of arguments.");let r;e.expectedType&&"value"!==e.expectedType.kind&&(r=e.expectedType);const n=[];for(let i=1;ie.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["case"];return this.eachChild((e=>{t.push(e.serialize());})),t}}var si=ai;class oi{constructor(t,e,r,n){this.type=t,this.input=e,this.beginIndex=r,this.endIndex=n;}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,Me),n=e.parse(t[2],2,xe);if(!r||!n)return null;if(!Te(r.type,[ke(Me),ve,Me]))return e.error(`Expected first argument to be of type array or string, but found ${Pe(r.type)} instead`);if(4===t.length){const i=e.parse(t[3],3,xe);return i?new oi(r.type,r,n,i):null}return new oi(r.type,r,n)}evaluate(t){const e=this.input.evaluate(t),r=this.beginIndex.evaluate(t);if(!Be(e,["string","array"]))throw new qe(`Expected first argument to be of type array or string, but found ${Pe(Ne(e))} instead.`);if(this.endIndex){const n=this.endIndex.evaluate(t);return e.slice(r,n)}return e.slice(r)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex);}outputDefined(){return !1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const t=this.endIndex.serialize();return ["slice",this.input.serialize(),this.beginIndex.serialize(),t]}return ["slice",this.input.serialize(),this.beginIndex.serialize()]}}var li=oi;function ui(t,e){return "=="===t||"!="===t?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function ci(t,e,r,n){return 0===n.compare(e,r)}function hi(t,e,r){const n="=="!==t&&"!="!==t;return class i{constructor(t,e,r){this.type=be,this.lhs=t,this.rhs=e,this.collator=r,this.hasUntypedArgument="value"===t.type.kind||"value"===e.type.kind;}static parse(t,e){if(3!==t.length&&4!==t.length)return e.error("Expected two or three arguments.");const r=t[0];let a=e.parse(t[1],1,Me);if(!a)return null;if(!ui(r,a.type))return e.concat(1).error(`"${r}" comparisons are not supported for type '${Pe(a.type)}'.`);let s=e.parse(t[2],2,Me);if(!s)return null;if(!ui(r,s.type))return e.concat(2).error(`"${r}" comparisons are not supported for type '${Pe(s.type)}'.`);if(a.type.kind!==s.type.kind&&"value"!==a.type.kind&&"value"!==s.type.kind)return e.error(`Cannot compare types '${Pe(a.type)}' and '${Pe(s.type)}'.`);n&&("value"===a.type.kind&&"value"!==s.type.kind?a=new Ye(s.type,[a]):"value"!==a.type.kind&&"value"===s.type.kind&&(s=new Ye(a.type,[s])));let o=null;if(4===t.length){if("string"!==a.type.kind&&"string"!==s.type.kind&&"value"!==a.type.kind&&"value"!==s.type.kind)return e.error("Cannot use collator to compare non-string types.");if(o=e.parse(t[3],3,Ae),!o)return null}return new i(a,s,o)}evaluate(i){const a=this.lhs.evaluate(i),s=this.rhs.evaluate(i);if(n&&this.hasUntypedArgument){const e=Ne(a),r=Ne(s);if(e.kind!==r.kind||"string"!==e.kind&&"number"!==e.kind)throw new qe(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${r.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const t=Ne(a),r=Ne(s);if("string"!==t.kind||"string"!==r.kind)return e(i,a,s)}return this.collator?r(i,a,s,this.collator.evaluate(i)):e(i,a,s)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator);}outputDefined(){return !0}serialize(){const e=[t];return this.eachChild((t=>{e.push(t.serialize());})),e}}}const pi=hi("==",(function(t,e,r){return e===r}),ci),fi=hi("!=",(function(t,e,r){return e!==r}),(function(t,e,r,n){return !ci(0,e,r,n)})),di=hi("<",(function(t,e,r){return e",(function(t,e,r){return e>r}),(function(t,e,r,n){return n.compare(e,r)>0})),yi=hi("<=",(function(t,e,r){return e<=r}),(function(t,e,r,n){return n.compare(e,r)<=0})),gi=hi(">=",(function(t,e,r){return e>=r}),(function(t,e,r,n){return n.compare(e,r)>=0}));class xi{constructor(t,e,r,n,i,a){this.type=ve,this.number=t,this.locale=e,this.currency=r,this.unit=n,this.minFractionDigits=i,this.maxFractionDigits=a;}static parse(t,e){if(3!==t.length)return e.error("Expected two arguments.");const r=e.parse(t[1],1,xe);if(!r)return null;const n=t[2];if("object"!=typeof n||Array.isArray(n))return e.error("NumberFormat options argument must be an object.");let i=null;if(n.locale&&(i=e.parse(n.locale,1,ve),!i))return null;let a=null;if(n.currency&&(a=e.parse(n.currency,1,ve),!a))return null;let s=null;if(n.unit&&(s=e.parse(n.unit,1,ve),!s))return null;let o=null;if(n["min-fraction-digits"]&&(o=e.parse(n["min-fraction-digits"],1,xe),!o))return null;let l=null;return n["max-fraction-digits"]&&(l=e.parse(n["max-fraction-digits"],1,xe),!l)?null:new xi(r,i,a,s,o,l)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(t):void 0,unit:this.unit?this.unit.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.unit&&t(this.unit),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits);}outputDefined(){return !1}serialize(){const t={};return this.locale&&(t.locale=this.locale.serialize()),this.currency&&(t.currency=this.currency.serialize()),this.unit&&(t.unit=this.unit.serialize()),this.minFractionDigits&&(t["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(t["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),t]}}class vi{constructor(t){this.type=xe,this.input=t;}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const r=e.parse(t[1],1);return r?"array"!==r.type.kind&&"string"!==r.type.kind&&"value"!==r.type.kind?e.error(`Expected argument of type string or array, but found ${Pe(r.type)} instead.`):new vi(r):null}evaluate(t){const e=this.input.evaluate(t);if("string"==typeof e)return e.length;if(Array.isArray(e))return e.length;throw new qe(`Expected value to be of type string or array, but found ${Pe(Ne(e))} instead.`)}eachChild(t){t(this.input);}outputDefined(){return !1}serialize(){const t=["length"];return this.eachChild((e=>{t.push(e.serialize());})),t}}function bi(t){return function(){t=1831565813+(t|=0)|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}const _i={"==":pi,"!=":fi,">":mi,"<":di,">=":gi,"<=":yi,array:Ye,at:Jn,boolean:Ye,case:si,coalesce:Zn,collator:ir,format:Xe,image:Ze,in:ti,"index-of":ri,interpolate:Yn,"interpolate-hcl":Yn,"interpolate-lab":Yn,length:vi,let:Hn,literal:je,match:ii,number:Ye,"number-format":xi,object:Ye,slice:li,step:Sn,string:Ye,"to-boolean":Je,"to-color":Je,"to-number":Je,"to-string":Je,var:vn,within:Ir,distance:un,config:fn};function wi(t,[e,r,n,i]){e=e.evaluate(t),r=r.evaluate(t),n=n.evaluate(t);const a=i?i.evaluate(t):1,s=Le(e,r,n,a);if(s)throw new qe(s);return new le(e/255*a,r/255*a,n/255*a,a)}function Mi(t,[e,r,n,i]){e=e.evaluate(t),r=r.evaluate(t),n=n.evaluate(t);const a=i?i.evaluate(t):1,s=function(t,e,r,n){return "number"==typeof t&&t>=0&&t<=360?"number"==typeof e&&e>=0&&e<=100&&"number"==typeof r&&r>=0&&r<=100?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid hsla value [${[t,e,r,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${("number"==typeof n?[t,e,r,n]:[t,e,r]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${("number"==typeof n?[t,e,r,n]:[t,e,r]).join(", ")}]: 'h' must be between 0 and 360.`}(e,r,n,a);if(s)throw new qe(s);const o=`hsla(${e}, ${r}%, ${n}%, ${a})`,l=le.parse(o);if(!l)throw new qe(`Failed to parse HSLA color: ${o}`);return l}function Ai(t,e){return t in e}function Si(t,e){const r=e[t];return void 0===r?null:r}function Ii(t){return {type:t}}nr.register(_i,{error:[{kind:"error"},[ve],(t,[e])=>{throw new qe(e.evaluate(t))}],typeof:[ve,[Me],(t,[e])=>Pe(Ne(e.evaluate(t)))],"to-rgba":[ke(xe,4),[_e],(t,[e])=>e.evaluate(t).toArray()],rgb:[_e,[xe,xe,xe],wi],rgba:[_e,[xe,xe,xe,xe],wi],hsl:[_e,[xe,xe,xe],Mi],hsla:[_e,[xe,xe,xe,xe],Mi],has:{type:be,overloads:[[[ve],(t,[e])=>Ai(e.evaluate(t),t.properties())],[[ve,we],(t,[e,r])=>Ai(e.evaluate(t),r.evaluate(t))]]},get:{type:Me,overloads:[[[ve],(t,[e])=>Si(e.evaluate(t),t.properties())],[[ve,we],(t,[e,r])=>Si(e.evaluate(t),r.evaluate(t))]]},"feature-state":[Me,[ve],(t,[e])=>Si(e.evaluate(t),t.featureState||{})],properties:[we,[],t=>t.properties()],"geometry-type":[ve,[],t=>t.geometryType()],id:[Me,[],t=>t.id()],zoom:[xe,[],t=>t.globals.zoom],pitch:[xe,[],t=>t.globals.pitch||0],"distance-from-center":[xe,[],t=>t.distanceFromCenter()],"measure-light":[xe,[ve],(t,[e])=>t.measureLight(e.evaluate(t))],"heatmap-density":[xe,[],t=>t.globals.heatmapDensity||0],"line-progress":[xe,[],t=>t.globals.lineProgress||0],"raster-value":[xe,[],t=>t.globals.rasterValue||0],"raster-particle-speed":[xe,[],t=>t.globals.rasterParticleSpeed||0],"sky-radial-progress":[xe,[],t=>t.globals.skyRadialProgress||0],accumulated:[Me,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[xe,Ii(xe),(t,e)=>{let r=0;for(const n of e)r+=n.evaluate(t);return r}],"*":[xe,Ii(xe),(t,e)=>{let r=1;for(const n of e)r*=n.evaluate(t);return r}],"-":{type:xe,overloads:[[[xe,xe],(t,[e,r])=>e.evaluate(t)-r.evaluate(t)],[[xe],(t,[e])=>-e.evaluate(t)]]},"/":[xe,[xe,xe],(t,[e,r])=>e.evaluate(t)/r.evaluate(t)],"%":[xe,[xe,xe],(t,[e,r])=>e.evaluate(t)%r.evaluate(t)],ln2:[xe,[],()=>Math.LN2],pi:[xe,[],()=>Math.PI],e:[xe,[],()=>Math.E],"^":[xe,[xe,xe],(t,[e,r])=>Math.pow(e.evaluate(t),r.evaluate(t))],sqrt:[xe,[xe],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[xe,[xe],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[xe,[xe],(t,[e])=>Math.log(e.evaluate(t))],log2:[xe,[xe],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[xe,[xe],(t,[e])=>Math.sin(e.evaluate(t))],cos:[xe,[xe],(t,[e])=>Math.cos(e.evaluate(t))],tan:[xe,[xe],(t,[e])=>Math.tan(e.evaluate(t))],asin:[xe,[xe],(t,[e])=>Math.asin(e.evaluate(t))],acos:[xe,[xe],(t,[e])=>Math.acos(e.evaluate(t))],atan:[xe,[xe],(t,[e])=>Math.atan(e.evaluate(t))],min:[xe,Ii(xe),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[xe,Ii(xe),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[xe,[xe],(t,[e])=>Math.abs(e.evaluate(t))],round:[xe,[xe],(t,[e])=>{const r=e.evaluate(t);return r<0?-Math.round(-r):Math.round(r)}],floor:[xe,[xe],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[xe,[xe],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[be,[ve,Me],(t,[e,r])=>t.properties()[e.value]===r.value],"filter-id-==":[be,[Me],(t,[e])=>t.id()===e.value],"filter-type-==":[be,[ve],(t,[e])=>t.geometryType()===e.value],"filter-<":[be,[ve,Me],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n{const r=t.id(),n=e.value;return typeof r==typeof n&&r":[be,[ve,Me],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n>i}],"filter-id->":[be,[Me],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r>n}],"filter-<=":[be,[ve,Me],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n<=i}],"filter-id-<=":[be,[Me],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r<=n}],"filter->=":[be,[ve,Me],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n>=i}],"filter-id->=":[be,[Me],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r>=n}],"filter-has":[be,[Me],(t,[e])=>e.value in t.properties()],"filter-has-id":[be,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[be,[ke(ve)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[be,[ke(Me)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[be,[ve,ke(Me)],(t,[e,r])=>r.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[be,[ve,ke(Me)],(t,[e,r])=>function(t,e,r,n){for(;r<=n;){const i=r+n>>1;if(e[i]===t)return !0;e[i]>t?n=i-1:r=i+1;}return !1}(t.properties()[e.value],r.value,0,r.value.length-1)],all:{type:be,overloads:[[[be,be],(t,[e,r])=>e.evaluate(t)&&r.evaluate(t)],[Ii(be),(t,e)=>{for(const r of e)if(!r.evaluate(t))return !1;return !0}]]},any:{type:be,overloads:[[[be,be],(t,[e,r])=>e.evaluate(t)||r.evaluate(t)],[Ii(be),(t,e)=>{for(const r of e)if(r.evaluate(t))return !0;return !1}]]},"!":[be,[be],(t,[e])=>!e.evaluate(t)],"is-supported-script":[be,[ve],(t,[e])=>{const r=t.globals&&t.globals.isSupportedScript;return !r||r(e.evaluate(t))}],upcase:[ve,[ve],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[ve,[ve],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[ve,Ii(Me),(t,e)=>e.map((e=>Oe(e.evaluate(t)))).join("")],"resolved-locale":[ve,[Ae],(t,[e])=>e.evaluate(t).resolvedLocale()],random:[xe,[xe,xe,Me],(t,e)=>{const[r,n,i]=e.map((e=>e.evaluate(t)));if(r>n)return r;if(r===n)return r;let a;if("string"==typeof i)a=function(t){let e=0;if(0===t.length)return e;for(let r=0;r-1}function Ti(t){return "data-driven"===t["property-type"]}function Bi(t){return zi(t.expression,"measure-light")}function Ci(t){return zi(t.expression,"zoom")}function Ri(t){return !!t.expression&&t.expression.interpolated}function Di(t){return "object"==typeof t&&null!==t&&!Array.isArray(t)}function Vi(t){return t}function Li(t,e){const r="color"===e.type,n=t.stops&&"object"==typeof t.stops[0][0],i=n||!(n||void 0!==t.property),a=t.type||(Ri(e)?"exponential":"interval");if(r&&((t=pe({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],le.parse(t[1])]))),t.default=le.parse(t.default?t.default:e.default)),t.colorSpace&&"rgb"!==t.colorSpace&&!qn[t.colorSpace])throw new Error(`Unknown color space: ${t.colorSpace}`);let s,o,l;if("exponential"===a)s=Ui;else if("interval"===a)s=Oi;else if("categorical"===a){s=Ni,o=Object.create(null);for(const e of t.stops)o[e[0]]=e[1];l=typeof t.stops[0][0];}else {if("identity"!==a)throw new Error(`Unknown function type "${a}"`);s=ji;}if(n){const r={},n=[];for(let e=0;et[0])),evaluate:({zoom:r},n)=>Ui({stops:i,base:t.base},e,r).evaluate(r,n)}}if(i){const r="exponential"===a?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return {kind:"camera",interpolationType:r,interpolationFactor:Yn.interpolationFactor.bind(void 0,r),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:r})=>s(t,e,r,o,l)}}return {kind:"source",evaluate(r,n){const i=n&&n.properties?n.properties[t.property]:void 0;return void 0===i?Fi(t.default,e.default):s(t,e,i,o,l)}}}function Fi(t,e,r){return void 0!==t?t:void 0!==e?e:void 0!==r?r:void 0}function Ni(t,e,r,n,i){return Fi(typeof r===i?n[r]:void 0,t.default,e.default)}function Oi(t,e,r){if("number"!==Ke(r))return Fi(t.default,e.default);const n=t.stops.length;if(1===n)return t.stops[0][1];if(r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[n-1][0])return t.stops[n-1][1];const i=Mn(t.stops.map((t=>t[0])),r);return t.stops[i][1]}function Ui(t,e,r){const n=void 0!==t.base?t.base:1;if("number"!==Ke(r))return Fi(t.default,e.default);const i=t.stops.length;if(1===i)return t.stops[0][1];if(r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[i-1][0])return t.stops[i-1][1];const a=Mn(t.stops.map((t=>t[0])),r),s=function(t,e,r,n){const i=n-r,a=t-r;return 0===i?0:1===e?a/i:(Math.pow(e,a)-1)/(Math.pow(e,i)-1)}(r,n,t.stops[a][0],t.stops[a+1][0]),o=t.stops[a][1],l=t.stops[a+1][1];let u=he[e.type]||Vi;if(t.colorSpace&&"rgb"!==t.colorSpace){const e=qn[t.colorSpace];u=(t,r)=>e.reverse(e.interpolate(e.forward(t),e.forward(r),s));}return "function"==typeof o.evaluate?{evaluate(...t){const e=o.evaluate.apply(void 0,t),r=l.evaluate.apply(void 0,t);if(void 0!==e&&void 0!==r)return u(e,r,s)}}:u(o,l,s)}function ji(t,e,r){return "color"===e.type?r=le.parse(r):"formatted"===e.type?r=De.fromString(r.toString()):"resolvedImage"===e.type?r=Ve.fromString(r.toString()):Ke(r)===e.type||"enum"===e.type&&e.values[r]||(r=void 0),Fi(r,t.default,e.default)}class qi{constructor(t,e,r,n){this.expression=t,this._warningHistory={},this._evaluator=new tr(r,n),this._defaultValue=e?function(t){return "color"===t.type&&(Di(t.default)||Array.isArray(t.default))?new le(0,0,0,0):"color"===t.type?le.parse(t.default)||null:void 0===t.default?null:t.default}(e):null,this._enumValues=e&&"enum"===e.type?e.values:null;}evaluateWithoutErrorHandling(t,e,r,n,i,a,s,o){return this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=r,this._evaluator.canonical=n||null,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=a,this._evaluator.featureTileCoord=s||null,this._evaluator.featureDistanceData=o||null,this.expression.evaluate(this._evaluator)}evaluate(t,e,r,n,i,a,s,o){this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=r||null,this._evaluator.canonical=n||null,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=a||null,this._evaluator.featureTileCoord=s||null,this._evaluator.featureDistanceData=o||null;try{const t=this.expression.evaluate(this._evaluator);if(null==t||"number"==typeof t&&t!=t)return this._defaultValue;if(this._enumValues&&!(t in this._enumValues))throw new qe(`Expected value to be one of ${Object.keys(this._enumValues).map((t=>JSON.stringify(t))).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(t.message)),this._defaultValue}}}function $i(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in ki}function Gi(t,e,r,n){const i=new _n(ki,[],e?function(t){const e={color:_e,string:ve,number:xe,enum:ve,boolean:be,formatted:Se,resolvedImage:Ie};return "array"===t.type?ke(e[t.value]||Me,t.length):e[t.type]}(e):void 0,void 0,void 0,r,n),a=i.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return a?Pi(new qi(a,e,r,n)):Ei(i.errors)}class Yi{constructor(t,e,r){this.kind=t,this._styleExpression=e,this.isLightConstant=r,this.isStateDependent="constant"!==t&&!mn(e.expression),this.isConfigDependent=!yn(e.expression);}evaluateWithoutErrorHandling(t,e,r,n,i,a){return this._styleExpression.evaluateWithoutErrorHandling(t,e,r,n,i,a)}evaluate(t,e,r,n,i,a){return this._styleExpression.evaluate(t,e,r,n,i,a)}}class Xi{constructor(t,e,r,n,i){this.kind=t,this.zoomStops=r,this._styleExpression=e,this.isStateDependent="camera"!==t&&!mn(e.expression),this.isLightConstant=i,this.isConfigDependent=!yn(e.expression),this.interpolationType=n;}evaluateWithoutErrorHandling(t,e,r,n,i,a){return this._styleExpression.evaluateWithoutErrorHandling(t,e,r,n,i,a)}evaluate(t,e,r,n,i,a){return this._styleExpression.evaluate(t,e,r,n,i,a)}interpolationFactor(t,e,r){return this.interpolationType?Yn.interpolationFactor(this.interpolationType,t,e,r):0}}function Zi(t,e,r,n){if("error"===(t=Gi(t,e,r,n)).result)return t;const i=t.value.expression,a=dn(i);if(!a&&!Ti(e))return Ei([new de("","data expressions not supported")]);const s=gn(i,["zoom","pitch","distance-from-center"]);if(!s&&!Ci(e))return Ei([new de("","zoom expressions not supported")]);const o=gn(i,["measure-light"]);if(!o&&!Bi(e))return Ei([new de("","measure-light expression not supported")]);const l=e.expression&&e.expression.relaxZoomRestriction,u=Hi(i);return u||s||l?u instanceof de?Ei([u]):u instanceof Yn&&!Ri(e)?Ei([new de("",'"interpolate" expressions cannot be used with this property')]):Pi(u?new Xi(a?"camera":"composite",t.value,u.labels,u instanceof Yn?u.interpolation:void 0,o):new Yi(a?"constant":"source",t.value,o)):Ei([new de("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class Ki{constructor(t,e){this._parameters=t,this._specification=e,pe(this,Li(this._parameters,this._specification));}static deserialize(t){return new Ki(t._parameters,t._specification)}static serialize(t){return {_parameters:t._parameters,_specification:t._specification}}}function Hi(t){let e=null;if(t instanceof Hn)e=Hi(t.result);else if(t instanceof Zn){for(const r of t.args)if(e=Hi(r),e)break}else (t instanceof Sn||t instanceof Yn)&&t.input instanceof nr&&"zoom"===t.input.name&&(e=t);return e instanceof de||t.eachChild((t=>{const r=Hi(t);r instanceof de?e=r:e&&r&&e!==r&&(e=new de("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'));})),e}var Wi=Qi,Ji=3;function Qi(t,e,r){var n=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;var i=new Int32Array(this.arrayBuffer);t=i[0],this.d=(e=i[1])+2*(r=i[2]);for(var a=0;a=c[f+0]&&n>=c[f+1])?(s[p]=!0,a.push(u[p])):s[p]=!1;}}},Qi.prototype._forEachCell=function(t,e,r,n,i,a,s,o){for(var l=this._convertToCellCoord(t),u=this._convertToCellCoord(e),c=this._convertToCellCoord(r),h=this._convertToCellCoord(n),p=l;p<=c;p++)for(var f=u;f<=h;f++){var d=this.d*f+p;if((!o||o(this._convertFromCellCoord(p),this._convertFromCellCoord(f),this._convertFromCellCoord(p+1),this._convertFromCellCoord(f+1)))&&i.call(this,t,e,r,n,d,a,s,o))return}},Qi.prototype._convertFromCellCoord=function(t){return (t-this.padding)/this.scale},Qi.prototype._convertToCellCoord=function(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))},Qi.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var t=this.cells,e=Ji+this.cells.length+1+1,r=0,n=0;n=0||(i[r]=aa(t[r],e)));t instanceof Error&&(i.message=t.message);}if(i.$name)throw new Error("$name property is reserved for worker serialization logic.");return "Object"!==n&&(i.$name=n),i}throw new Error("can't serialize object of type "+typeof t)}function sa(t){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||na(t)||ia(t)||ArrayBuffer.isView(t)||t instanceof ImageData)return t;if(Array.isArray(t))return t.map(sa);if("object"==typeof t){const e=t.$name||"Object";if("Map"===e){const e=new Map;for(const r of Object.keys(t))"$name"!==r&&e.set(r,sa(t[r]));return e}const{klass:r}=ea[e];if(!r)throw new Error(`can't deserialize unregistered class ${e}`);if(r.deserialize)return r.deserialize(t);const n=Object.create(r.prototype);for(const e of Object.keys(t))"$name"!==e&&(n[e]=sa(t[e]));return n}throw new Error("can't deserialize object of type "+typeof t)}const oa={"Latin-1 Supplement":t=>t>=128&&t<=255,Arabic:t=>t>=1536&&t<=1791,"Arabic Supplement":t=>t>=1872&&t<=1919,"Arabic Extended-A":t=>t>=2208&&t<=2303,"Hangul Jamo":t=>t>=4352&&t<=4607,"Unified Canadian Aboriginal Syllabics":t=>t>=5120&&t<=5759,Khmer:t=>t>=6016&&t<=6143,"Unified Canadian Aboriginal Syllabics Extended":t=>t>=6320&&t<=6399,"General Punctuation":t=>t>=8192&&t<=8303,"Letterlike Symbols":t=>t>=8448&&t<=8527,"Number Forms":t=>t>=8528&&t<=8591,"Miscellaneous Technical":t=>t>=8960&&t<=9215,"Control Pictures":t=>t>=9216&&t<=9279,"Optical Character Recognition":t=>t>=9280&&t<=9311,"Enclosed Alphanumerics":t=>t>=9312&&t<=9471,"Geometric Shapes":t=>t>=9632&&t<=9727,"Miscellaneous Symbols":t=>t>=9728&&t<=9983,"Miscellaneous Symbols and Arrows":t=>t>=11008&&t<=11263,"CJK Radicals Supplement":t=>t>=11904&&t<=12031,"Kangxi Radicals":t=>t>=12032&&t<=12255,"Ideographic Description Characters":t=>t>=12272&&t<=12287,"CJK Symbols and Punctuation":t=>t>=12288&&t<=12351,Hiragana:t=>t>=12352&&t<=12447,Katakana:t=>t>=12448&&t<=12543,Bopomofo:t=>t>=12544&&t<=12591,"Hangul Compatibility Jamo":t=>t>=12592&&t<=12687,Kanbun:t=>t>=12688&&t<=12703,"Bopomofo Extended":t=>t>=12704&&t<=12735,"CJK Strokes":t=>t>=12736&&t<=12783,"Katakana Phonetic Extensions":t=>t>=12784&&t<=12799,"Enclosed CJK Letters and Months":t=>t>=12800&&t<=13055,"CJK Compatibility":t=>t>=13056&&t<=13311,"CJK Unified Ideographs Extension A":t=>t>=13312&&t<=19903,"Yijing Hexagram Symbols":t=>t>=19904&&t<=19967,"CJK Unified Ideographs":t=>t>=19968&&t<=40959,"Yi Syllables":t=>t>=40960&&t<=42127,"Yi Radicals":t=>t>=42128&&t<=42191,"Hangul Jamo Extended-A":t=>t>=43360&&t<=43391,"Hangul Syllables":t=>t>=44032&&t<=55215,"Hangul Jamo Extended-B":t=>t>=55216&&t<=55295,"Private Use Area":t=>t>=57344&&t<=63743,"CJK Compatibility Ideographs":t=>t>=63744&&t<=64255,"Arabic Presentation Forms-A":t=>t>=64336&&t<=65023,"Vertical Forms":t=>t>=65040&&t<=65055,"CJK Compatibility Forms":t=>t>=65072&&t<=65103,"Small Form Variants":t=>t>=65104&&t<=65135,"Arabic Presentation Forms-B":t=>t>=65136&&t<=65279,"Halfwidth and Fullwidth Forms":t=>t>=65280&&t<=65519,"CJK Unified Ideographs Extension B":t=>t>=131072&&t<=173791};function la(t){for(const e of t)if(ha(e.charCodeAt(0)))return !0;return !1}function ua(t){for(const e of t)if(!ca(e.charCodeAt(0)))return !1;return !0}function ca(t){return !(oa.Arabic(t)||oa["Arabic Supplement"](t)||oa["Arabic Extended-A"](t)||oa["Arabic Presentation Forms-A"](t)||oa["Arabic Presentation Forms-B"](t))}function ha(t){return !(746!==t&&747!==t&&(t<4352||!(oa["Bopomofo Extended"](t)||oa.Bopomofo(t)||oa["CJK Compatibility Forms"](t)&&!(t>=65097&&t<=65103)||oa["CJK Compatibility Ideographs"](t)||oa["CJK Compatibility"](t)||oa["CJK Radicals Supplement"](t)||oa["CJK Strokes"](t)||!(!oa["CJK Symbols and Punctuation"](t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||oa["CJK Unified Ideographs Extension A"](t)||oa["CJK Unified Ideographs"](t)||oa["Enclosed CJK Letters and Months"](t)||oa["Hangul Compatibility Jamo"](t)||oa["Hangul Jamo Extended-A"](t)||oa["Hangul Jamo Extended-B"](t)||oa["Hangul Jamo"](t)||oa["Hangul Syllables"](t)||oa.Hiragana(t)||oa["Ideographic Description Characters"](t)||oa.Kanbun(t)||oa["Kangxi Radicals"](t)||oa["Katakana Phonetic Extensions"](t)||oa.Katakana(t)&&12540!==t||!(!oa["Halfwidth and Fullwidth Forms"](t)||65288===t||65289===t||65293===t||t>=65306&&t<=65310||65339===t||65341===t||65343===t||t>=65371&&t<=65503||65507===t||t>=65512&&t<=65519)||!(!oa["Small Form Variants"](t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||oa["Unified Canadian Aboriginal Syllabics"](t)||oa["Unified Canadian Aboriginal Syllabics Extended"](t)||oa["Vertical Forms"](t)||oa["Yijing Hexagram Symbols"](t)||oa["Yi Syllables"](t)||oa["Yi Radicals"](t))))}function pa(t){return !(ha(t)||function(t){return !!(oa["Latin-1 Supplement"](t)&&(167===t||169===t||174===t||177===t||188===t||189===t||190===t||215===t||247===t)||oa["General Punctuation"](t)&&(8214===t||8224===t||8225===t||8240===t||8241===t||8251===t||8252===t||8258===t||8263===t||8264===t||8265===t||8273===t)||oa["Letterlike Symbols"](t)||oa["Number Forms"](t)||oa["Miscellaneous Technical"](t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||9003===t||t>=9085&&t<=9114||t>=9150&&t<=9165||9167===t||t>=9169&&t<=9179||t>=9186&&t<=9215)||oa["Control Pictures"](t)&&9251!==t||oa["Optical Character Recognition"](t)||oa["Enclosed Alphanumerics"](t)||oa["Geometric Shapes"](t)||oa["Miscellaneous Symbols"](t)&&!(t>=9754&&t<=9759)||oa["Miscellaneous Symbols and Arrows"](t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||oa["CJK Symbols and Punctuation"](t)||oa.Katakana(t)||oa["Private Use Area"](t)||oa["CJK Compatibility Forms"](t)||oa["Small Form Variants"](t)||oa["Halfwidth and Fullwidth Forms"](t)||8734===t||8756===t||8757===t||t>=9984&&t<=10087||t>=10102&&t<=10131||65532===t||65533===t)}(t))}function fa(t){return t>=1424&&t<=2303||oa["Arabic Presentation Forms-A"](t)||oa["Arabic Presentation Forms-B"](t)}function da(t,e){return !(!e&&fa(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||oa.Khmer(t))}function ma(t){for(const e of t)if(fa(e.charCodeAt(0)))return !0;return !1}const ya="deferred",ga="loading",xa="loaded";let va=null,ba="unavailable",_a=null;const wa=function(t){t&&"string"==typeof t&&t.indexOf("NetworkError")>-1&&(ba="error"),va&&va(t);};function Ma(){Aa.fire(new Qt("pluginStateChange",{pluginStatus:ba,pluginURL:_a}));}const Aa=new ee,Sa=function(){return ba},Ia=function(){if(ba!==ya||!_a)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");ba=ga,Ma(),_a&&Pt({url:_a},(t=>{t?wa(t):(ba=xa,Ma());}));},ka={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>ba===xa||null!=ka.applyArabicShaping,isLoading:()=>ba===ga,setState(t){ba=t.pluginStatus,_a=t.pluginURL;},isParsed:()=>null!=ka.applyArabicShaping&&null!=ka.processBidirectionalText&&null!=ka.processStyledBidirectionalText,getPluginURL:()=>_a};class Pa{constructor(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.transition=e.transition,this.pitch=e.pitch,this.brightness=e.brightness):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0);}isSupportedScript(t){return function(t,e){for(const r of t)if(!da(r.charCodeAt(0),e))return !1;return !0}(t,ka.isLoaded())}}class Ea{constructor(t,e,r,n){this.property=t,this.value=e,this.expression=function(t,e,r,n){if(Di(t))return new Ki(t,e);if($i(t)||Array.isArray(t)&&t.length>0){const i=Zi(t,e,r,n);if("error"===i.result)throw new Error(i.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return i.value}{let r=t;return "string"==typeof t&&"color"===e.type&&(r=le.parse(t)),{kind:"constant",isConfigDependent:!1,evaluate:()=>r}}}(void 0===e?t.specification.default:e,t.specification,r,n);}isDataDriven(){return "source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(t,e,r){return this.property.possiblyEvaluate(this,t,e,r)}}class za{constructor(t,e,r){this.property=t,this.value=new Ea(t,void 0,e,r);}transitioned(t,e){return new Ba(this.property,this.value,e,z({},t.transition,this.transition),t.now)}untransitioned(){return new Ba(this.property,this.value,null,{},0)}}class Ta{constructor(t,e,r){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues),this._scope=e,this._options=r,this.isConfigDependent=!1;}getValue(t){return O(this._values[t].value.value)}setValue(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new za(this._values[t].property,this._scope,this._options)),this._values[t].value=new Ea(this._values[t].property,null===e?void 0:O(e),this._scope,this._options),this.isConfigDependent=this.isConfigDependent||this._values[t].value.expression.isConfigDependent;}setTransitionOrValue(t,e){e&&(this._options=e);const r=this._properties.properties;if(t)for(const e in t){const n=t[e];if(L(e,"-transition")){const t=e.slice(0,-11);r[t]&&this.setTransition(t,n);}else r[e]&&this.setValue(e,n);}}getTransition(t){return O(this._values[t].transition)}setTransition(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new za(this._values[t].property)),this._values[t].transition=O(e)||void 0;}serialize(){const t={};for(const e of Object.keys(this._values)){const r=this.getValue(e);void 0!==r&&(t[e]=r);const n=this.getTransition(e);void 0!==n&&(t[`${e}-transition`]=n);}return t}transitioned(t,e){const r=new Ca(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].transitioned(t,e._values[n]);return r}untransitioned(){const t=new Ca(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}}class Ba{constructor(t,e,r,n,i){const a=n.delay||0,s=n.duration||0;i=i||0,this.property=t,this.value=e,this.begin=i+a,this.end=this.begin+s,t.specification.transition&&(n.delay||n.duration)&&(this.prior=r);}possiblyEvaluate(t,e,r){const n=t.now||0,i=this.value.possiblyEvaluate(t,e,r),a=this.prior;if(a){if(n>this.end)return this.prior=null,i;if(this.value.isDataDriven())return this.prior=null,i;if(n":1,">=":1,"<":1,"<=":1,"in":1,"!in":1,"all":1,"any":1,"none":1,"has":1,"!has":1}},"geometry_type":{"type":"enum","values":{"Point":1,"LineString":1,"Polygon":1}},"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":1,"exponential":1,"interval":1,"categorical":1},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":1,"lab":1,"hcl":1},"default":"rgb"},"default":{"type":"*","required":false}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"high-color":{"type":"color","property-type":"data-constant","default":"#245cdf","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"space-color":{"type":"color","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"horizon-blend":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,0.2,7,0.1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"star-intensity":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],5,0.35,6,0],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vertical-range":{"type":"array","default":[0,0],"minimum":0,"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}}},"camera":{"camera-projection":{"type":"enum","values":{"perspective":1,"orthographic":1},"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"default":"perspective","property-type":"data-constant"}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"property-type":"data-constant","expression":{"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":1,"equalEarth":1,"equirectangular":1,"lambertConformalConic":1,"mercator":1,"naturalEarth":1,"winkelTripel":1,"globe":1},"default":"mercator","required":true},"center":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-180,-90],"maximum":[180,90]},"parallels":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-90,-90],"maximum":[90,90]}},"terrain":{"source":{"type":"string","required":true},"exaggeration":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background","paint_sky","paint_model"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"fill-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-ambient-occlusion-intensity":{"property-type":"data-constant","type":"number","private":true,"default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-radius":{"property-type":"data-constant","type":"number","private":true,"default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-wall-radius":{"property-type":"data-constant","type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-radius":{"property-type":"data-constant","type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-attenuation":{"property-type":"data-constant","type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-flood-light-color":{"property-type":"data-constant","type":"color","default":"#ffffff","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-intensity":{"property-type":"data-constant","type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-wall-radius":{"property-type":"data-driven","type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-radius":{"property-type":"data-driven","type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-attenuation":{"property-type":"data-constant","type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-vertical-scale":{"property-type":"data-constant","type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-rounded-roof":{"property-type":"data-constant","type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-extrusion-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{},"property-type":"data-constant"},"fill-extrusion-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-gradient":{"type":"color","expression":{"interpolated":true,"parameters":["line-progress"]},"property-type":"color-ramp"},"line-trim-offset":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1],"property-type":"constant"},"line-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"line-border-width":{"type":"number","private":true,"default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-border-color":{"type":"color","private":true,"default":"rgba(0, 0, 0, 0)","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"expression":{"interpolated":true,"parameters":["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-driven"},"text-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-image-cross-fade":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"transition":true},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","transition":true,"overridable":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-color-saturation":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{},"property-type":"data-constant"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-color":{"type":"color","expression":{"interpolated":true,"parameters":["raster-value"]},"property-type":"color-ramp"},"raster-color-mix":{"type":"array","default":[0.2126,0.7152,0.0722,0],"length":4,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-color-range":{"type":"array","length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-resampling":{"type":"enum","values":{"linear":1,"nearest":1},"default":"linear","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"raster-array-band":{"type":"string","required":false,"property-type":"data-constant"},"raster-elevation":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_raster-particle":{"raster-particle-array-band":{"type":"string","required":false,"property-type":"data-constant"},"raster-particle-count":{"type":"number","default":512,"minimum":1,"property-type":"data-constant"},"raster-particle-color":{"type":"color","expression":{"interpolated":true,"parameters":["raster-particle-speed"]},"property-type":"color-ramp"},"raster-particle-max-speed":{"type":"number","default":1,"minimum":1,"property-type":"data-constant"},"raster-particle-speed-factor":{"type":"number","default":0.2,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-particle-fade-opacity-factor":{"type":"number","default":0.98,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-particle-reset-rate-factor":{"type":"number","default":0.8,"minimum":0,"maximum":1,"property-type":"data-constant"}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"hillshade-accent-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"hillshade-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"}},"paint_background":{"background-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":1,"atmosphere":1},"default":"atmosphere","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun-intensity":{"type":"number","default":10,"minimum":0,"maximum":100,"property-type":"data-constant"},"sky-gradient-center":{"type":"array","value":"number","default":[0,0],"length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient-radius":{"type":"number","default":90,"minimum":0,"maximum":180,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"expression":{"interpolated":true,"parameters":["sky-radial-progress"]},"property-type":"color-ramp"},"sky-atmosphere-halo-color":{"type":"color","default":"white","property-type":"data-constant"},"sky-atmosphere-color":{"type":"color","default":"white","property-type":"data-constant"},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_model":{"model-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"model-rotation":{"type":"array","value":"number","length":3,"default":[0,0,0],"period":360,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-scale":{"type":"array","value":"number","length":3,"default":[1,1,1],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-translation":{"type":"array","value":"number","length":3,"default":[0,0,0],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-color":{"type":"color","default":"#ffffff","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":true},"model-color-mix-intensity":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-type":{"type":"enum","values":{"common-3d":1,"location-indicator":1},"default":"common-3d","property-type":"data-constant"},"model-cast-shadows":{"type":"boolean","default":true,"expression":{},"property-type":"data-constant"},"model-receive-shadows":{"type":"boolean","default":true,"expression":{},"property-type":"data-constant"},"model-ambient-occlusion-intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant","transition":true},"model-emissive-strength":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-roughness":{"type":"number","default":1,"minimum":0,"maximum":1,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state"]},"transition":true},"model-height-based-emissive-strength-multiplier":{"type":"array","default":[1,1,1,1,0],"length":5,"value":"number","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{},"property-type":"data-constant"}},"transition":{"duration":{"type":"number","default":300,"minimum":0},"delay":{"type":"number","default":0,"minimum":0}},"property-type":{"data-driven":{"type":"property-type"},"color-ramp":{"type":"property-type"},"data-constant":{"type":"property-type"},"constant":{"type":"property-type"}},"promoteId":{"*":{"type":"string"}}}');function $a(t){if(!0===t||!1===t)return !0;if(!Array.isArray(t)||0===t.length)return !1;switch(t[0]){case"has":return t.length>=2&&"$id"!==t[1]&&"$type"!==t[1];case"in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]));case"!in":case"!has":case"none":return !1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==t.length||Array.isArray(t[1])||Array.isArray(t[2]);case"any":case"all":for(const e of t.slice(1))if(!$a(e)&&"boolean"!=typeof e)return !1;return !0;default:return !0}}function Ga(t,e="fill"){if(null==t)return {filter:()=>!0,needGeometry:!1,needFeature:!1};$a(t)||(t=Ja(t));const r=t;let n=!0;try{n=function(t){if(!Za(t))return t;let e=ja(t);return Xa(e),e=Ya(e),e}(r);}catch(t){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.\nThis is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md\nand paste the contents of this message in the report.\nThank you!\nFilter Expression:\n${JSON.stringify(r,null,2)}\n `);}const i=qa[`filter_${e}`],a=Gi(n,i);let s=null;if("error"===a.result)throw new Error(a.value.map((t=>`${t.key}: ${t.message}`)).join(", "));s=(t,e,r)=>a.value.evaluate(t,e,{},r);let o=null,l=null;if(n!==r){const t=Gi(r,i);if("error"===t.result)throw new Error(t.value.map((t=>`${t.key}: ${t.message}`)).join(", "));o=(e,r,n,i,a)=>t.value.evaluate(e,r,{},n,void 0,void 0,i,a),l=!dn(t.value.expression);}return {filter:s,dynamicFilter:o||void 0,needGeometry:Wa(n),needFeature:!!l}}function Ya(t){if(!Array.isArray(t))return t;const e=function(t){if(Ka.has(t[0]))for(let e=1;eYa(t)))}function Xa(t){let e=!1;const r=[];if("case"===t[0]){for(let n=1;n",">=","<","<=","to-boolean"]);function Ha(t,e){return te?1:0}function Wa(t){if(!Array.isArray(t))return !1;if("within"===t[0]||"distance"===t[0])return !0;for(let e=1;e"===e||"<="===e||">="===e?Qa(t[1],t[2],e):"any"===e?(r=t.slice(1),["any"].concat(r.map(Ja))):"all"===e?["all"].concat(t.slice(1).map(Ja)):"none"===e?["all"].concat(t.slice(1).map(Ja).map(rs)):"in"===e?ts(t[1],t.slice(2)):"!in"===e?rs(ts(t[1],t.slice(2))):"has"===e?es(t[1]):"!has"!==e||rs(es(t[1]));var r;}function Qa(t,e,r){switch(t){case"$type":return [`filter-type-${r}`,e];case"$id":return [`filter-id-${r}`,e];default:return [`filter-${r}`,t,e]}}function ts(t,e){if(0===e.length)return !1;switch(t){case"$type":return ["filter-type-in",["literal",e]];case"$id":return ["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((t=>typeof t!=typeof e[0]))?["filter-in-large",t,["literal",e.sort(Ha)]]:["filter-in-small",t,["literal",e]]}}function es(t){switch(t){case"$type":return !0;case"$id":return ["filter-has-id"];default:return ["filter-has",t]}}function rs(t){return ["!",t]}const ns="";function is(t,e){return e?`${t}${ns}${e}`:t}const as="-transition";class ss extends ee{constructor(t,e,r,n){if(super(),this.id=t.id,this.fqid=is(this.id,r),this.type=t.type,this.scope=r,this.options=n,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,this.isConfigDependent=!1,"custom"!==t.type&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,"background"!==t.type&&"sky"!==t.type&&"slot"!==t.type&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),t.slot&&(this.slot=t.slot),e.layout&&(this._unevaluatedLayout=new Ra(e.layout,this.scope,n),this.isConfigDependent=this.isConfigDependent||this._unevaluatedLayout.isConfigDependent),e.paint)){this._transitionablePaint=new Ta(e.paint,this.scope,n);for(const e in t.paint)this.setPaintProperty(e,t.paint[e]);for(const e in t.layout)this.setLayoutProperty(e,t.layout[e]);this.isConfigDependent=this.isConfigDependent||this._transitionablePaint.isConfigDependent,this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Va(e.paint);}}getLayoutProperty(t){return "visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,e){if("custom"===this.type&&"visibility"===t)return void(this.visibility=e);const r=this._unevaluatedLayout;r._properties.properties[t]&&(r.setValue(t,e),this.isConfigDependent=this.isConfigDependent||r.isConfigDependent,"visibility"===t&&this.possiblyEvaluateVisibility());}possiblyEvaluateVisibility(){this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0});}getPaintProperty(t){return L(t,as)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}setPaintProperty(t,e){const r=this._transitionablePaint,n=r._properties.properties;if(L(t,as)){const i=t.slice(0,-11);return n[i]&&r.setTransition(i,e||void 0),!1}if(!n[t])return !1;const i=r._values[t],a=i.value.isDataDriven(),s=i.value;r.setValue(t,e),this.isConfigDependent=this.isConfigDependent||r.isConfigDependent,this._handleSpecialPaintPropertyUpdate(t);const o=r._values[t].value,l=o.isDataDriven(),u=L(t,"pattern")||"line-dasharray"===t;return l||a||u||this._handleOverridablePaintPropertyUpdate(t,s,o)}_handleSpecialPaintPropertyUpdate(t){}getProgramIds(){return null}getDefaultProgramParams(t,e){return null}_handleOverridablePaintPropertyUpdate(t,e,r){return !1}isHidden(t){return !!(this.minzoom&&t=this.maxzoom)||"none"===this.visibility}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint);}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,e){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e);}serialize(){return N({id:this.id,type:this.type,slot:this.slot,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()},((t,e)=>!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)))}is3D(){return !1}isSky(){return !1}isTileClipped(){return !1}hasOffscreenPass(){return !1}hasShadowPass(){return !1}canCastShadows(){return !1}hasLightBeamPass(){return !1}cutoffRange(){return 0}tileCoverLift(){return 0}resize(){}isStateDependent(){for(const t in this.paint._values){const e=this.paint.get(t);if(e instanceof Da&&Ti(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return !0}return !1}compileFilter(){this._filterCompiled||(this._featureFilter=Ga(this.filter),this._filterCompiled=!0);}invalidateCompiledFilter(){this._filterCompiled=!1;}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}getLayerRenderingStats(){return this._stats}resetLayerRenderingStats(t){this._stats&&("shadow"===t.renderPass?this._stats.numRenderedVerticesInShadowPass=0:this._stats.numRenderedVerticesInTransparentPass=0);}}const os={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class ls{constructor(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8;}}class us{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0);}static serialize(t,e){return t._trim(),e&&(t.isTransferred=!0,e.add(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews());}clear(){this.length=0;}resize(t){this.reserve(t),this.length=t;}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const e=this.uint8;this._refreshViews(),e&&this.uint8.set(e);}}_refreshViews(){throw new Error("StructArray#_refreshViews() must be implemented by each concrete StructArray layout")}emplace(...t){throw new Error("StructArray#emplace() must be implemented by each concrete StructArray layout")}emplaceBack(...t){throw new Error("StructArray#emplaceBack() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null;}}function cs(t,e=1){let r=0,n=0;return {members:t.map((t=>{const i=os[t.type].BYTES_PER_ELEMENT,a=r=hs(r,Math.max(e,i)),s=t.components||1;return n=Math.max(n,i),r+=i*s,{name:t.name,type:t.type,components:s,offset:a}})),size:hs(r,Math.max(n,e)),alignment:e}}function hs(t,e){return Math.ceil(t/e)*e}class ps extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.int16[n+0]=e,this.int16[n+1]=r,t}}ps.prototype.bytesPerElement=4,ra(ps,"StructArrayLayout2i4");class fs extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.int16[i+0]=e,this.int16[i+1]=r,this.int16[i+2]=n,t}}fs.prototype.bytesPerElement=6,ra(fs,"StructArrayLayout3i6");class ds extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const a=4*t;return this.int16[a+0]=e,this.int16[a+1]=r,this.int16[a+2]=n,this.int16[a+3]=i,t}}ds.prototype.bytesPerElement=8,ra(ds,"StructArrayLayout4i8");class ms extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i)}emplace(t,e,r,n,i,a){const s=5*t;return this.int16[s+0]=e,this.int16[s+1]=r,this.int16[s+2]=n,this.int16[s+3]=i,this.int16[s+4]=a,t}}ms.prototype.bytesPerElement=10,ra(ms,"StructArrayLayout5i10");class ys extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,a,s){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,r,n,i,a,s)}emplace(t,e,r,n,i,a,s,o){const l=6*t,u=12*t,c=3*t;return this.int16[l+0]=e,this.int16[l+1]=r,this.uint8[u+4]=n,this.uint8[u+5]=i,this.uint8[u+6]=a,this.uint8[u+7]=s,this.float32[c+2]=o,t}}ys.prototype.bytesPerElement=12,ra(ys,"StructArrayLayout2i4ub1f12");class gs extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const a=4*t;return this.float32[a+0]=e,this.float32[a+1]=r,this.float32[a+2]=n,this.float32[a+3]=i,t}}gs.prototype.bytesPerElement=16,ra(gs,"StructArrayLayout4f16");class xs extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i)}emplace(t,e,r,n,i,a){const s=6*t,o=3*t;return this.uint16[s+0]=e,this.uint16[s+1]=r,this.uint16[s+2]=n,this.uint16[s+3]=i,this.float32[o+2]=a,t}}xs.prototype.bytesPerElement=12,ra(xs,"StructArrayLayout4ui1f12");class vs extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const a=4*t;return this.uint16[a+0]=e,this.uint16[a+1]=r,this.uint16[a+2]=n,this.uint16[a+3]=i,t}}vs.prototype.bytesPerElement=8,ra(vs,"StructArrayLayout4ui8");class bs extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,a){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,r,n,i,a)}emplace(t,e,r,n,i,a,s){const o=6*t;return this.int16[o+0]=e,this.int16[o+1]=r,this.int16[o+2]=n,this.int16[o+3]=i,this.int16[o+4]=a,this.int16[o+5]=s,t}}bs.prototype.bytesPerElement=12,ra(bs,"StructArrayLayout6i12");class _s extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,a,s,o,l,u,c,h){const p=this.length;return this.resize(p+1),this.emplace(p,t,e,r,n,i,a,s,o,l,u,c,h)}emplace(t,e,r,n,i,a,s,o,l,u,c,h,p){const f=12*t;return this.int16[f+0]=e,this.int16[f+1]=r,this.int16[f+2]=n,this.int16[f+3]=i,this.uint16[f+4]=a,this.uint16[f+5]=s,this.uint16[f+6]=o,this.uint16[f+7]=l,this.int16[f+8]=u,this.int16[f+9]=c,this.int16[f+10]=h,this.int16[f+11]=p,t}}_s.prototype.bytesPerElement=24,ra(_s,"StructArrayLayout4i4ui4i24");class ws extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,a){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,r,n,i,a)}emplace(t,e,r,n,i,a,s){const o=10*t,l=5*t;return this.int16[o+0]=e,this.int16[o+1]=r,this.int16[o+2]=n,this.float32[l+2]=i,this.float32[l+3]=a,this.float32[l+4]=s,t}}ws.prototype.bytesPerElement=20,ra(ws,"StructArrayLayout3i3f20");class Ms extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint32[1*t+0]=e,t}}Ms.prototype.bytesPerElement=4,ra(Ms,"StructArrayLayout1ul4");class As extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.uint16[n+0]=e,this.uint16[n+1]=r,t}}As.prototype.bytesPerElement=4,ra(As,"StructArrayLayout2ui4");class Ss extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,a,s,o,l,u,c,h,p){const f=this.length;return this.resize(f+1),this.emplace(f,t,e,r,n,i,a,s,o,l,u,c,h,p)}emplace(t,e,r,n,i,a,s,o,l,u,c,h,p,f){const d=20*t,m=10*t;return this.int16[d+0]=e,this.int16[d+1]=r,this.int16[d+2]=n,this.int16[d+3]=i,this.int16[d+4]=a,this.float32[m+3]=s,this.float32[m+4]=o,this.float32[m+5]=l,this.float32[m+6]=u,this.int16[d+14]=c,this.uint32[m+8]=h,this.uint16[d+18]=p,this.uint16[d+19]=f,t}}Ss.prototype.bytesPerElement=40,ra(Ss,"StructArrayLayout5i4f1i1ul2ui40");class Is extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,a,s){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,r,n,i,a,s)}emplace(t,e,r,n,i,a,s,o){const l=8*t;return this.int16[l+0]=e,this.int16[l+1]=r,this.int16[l+2]=n,this.int16[l+4]=i,this.int16[l+5]=a,this.int16[l+6]=s,this.int16[l+7]=o,t}}Is.prototype.bytesPerElement=16,ra(Is,"StructArrayLayout3i2i2i16");class ks extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i)}emplace(t,e,r,n,i,a){const s=4*t,o=8*t;return this.float32[s+0]=e,this.float32[s+1]=r,this.float32[s+2]=n,this.int16[o+6]=i,this.int16[o+7]=a,t}}ks.prototype.bytesPerElement=16,ra(ks,"StructArrayLayout2f1f2i16");class Ps extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const a=12*t,s=3*t;return this.uint8[a+0]=e,this.uint8[a+1]=r,this.float32[s+1]=n,this.float32[s+2]=i,t}}Ps.prototype.bytesPerElement=12,ra(Ps,"StructArrayLayout2ub2f12");class Es extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.uint16[i+0]=e,this.uint16[i+1]=r,this.uint16[i+2]=n,t}}Es.prototype.bytesPerElement=6,ra(Es,"StructArrayLayout3ui6");class zs extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,a,s,o,l,u,c,h,p,f,d,m,y,g,x,v,b){const _=this.length;return this.resize(_+1),this.emplace(_,t,e,r,n,i,a,s,o,l,u,c,h,p,f,d,m,y,g,x,v,b)}emplace(t,e,r,n,i,a,s,o,l,u,c,h,p,f,d,m,y,g,x,v,b,_){const w=30*t,M=15*t,A=60*t;return this.int16[w+0]=e,this.int16[w+1]=r,this.int16[w+2]=n,this.float32[M+2]=i,this.float32[M+3]=a,this.uint16[w+8]=s,this.uint16[w+9]=o,this.uint32[M+5]=l,this.uint32[M+6]=u,this.uint32[M+7]=c,this.uint16[w+16]=h,this.uint16[w+17]=p,this.uint16[w+18]=f,this.float32[M+10]=d,this.float32[M+11]=m,this.uint8[A+48]=y,this.uint8[A+49]=g,this.uint8[A+50]=x,this.uint32[M+13]=v,this.int16[w+28]=b,this.uint8[A+58]=_,t}}zs.prototype.bytesPerElement=60,ra(zs,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class Ts extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,a,s,o,l,u,c,h,p,f,d,m,y,g,x,v,b,_,w,M,A,S,I,k,P,E,z,T){const B=this.length;return this.resize(B+1),this.emplace(B,t,e,r,n,i,a,s,o,l,u,c,h,p,f,d,m,y,g,x,v,b,_,w,M,A,S,I,k,P,E,z,T)}emplace(t,e,r,n,i,a,s,o,l,u,c,h,p,f,d,m,y,g,x,v,b,_,w,M,A,S,I,k,P,E,z,T,B){const C=20*t,R=40*t,D=80*t;return this.float32[C+0]=e,this.float32[C+1]=r,this.int16[R+4]=n,this.int16[R+5]=i,this.int16[R+6]=a,this.int16[R+7]=s,this.int16[R+8]=o,this.int16[R+9]=l,this.int16[R+10]=u,this.int16[R+11]=c,this.int16[R+12]=h,this.uint16[R+13]=p,this.uint16[R+14]=f,this.uint16[R+15]=d,this.uint16[R+16]=m,this.uint16[R+17]=y,this.uint16[R+18]=g,this.uint16[R+19]=x,this.uint16[R+20]=v,this.uint16[R+21]=b,this.uint16[R+22]=_,this.uint16[R+23]=w,this.uint16[R+24]=M,this.uint16[R+25]=A,this.uint16[R+26]=S,this.uint16[R+27]=I,this.uint32[C+14]=k,this.float32[C+15]=P,this.float32[C+16]=E,this.float32[C+17]=z,this.float32[C+18]=T,this.uint8[D+76]=B,t}}Ts.prototype.bytesPerElement=80,ra(Ts,"StructArrayLayout2f9i15ui1ul4f1ub80");class Bs extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.float32[1*t+0]=e,t}}Bs.prototype.bytesPerElement=4,ra(Bs,"StructArrayLayout1f4");class Cs extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i)}emplace(t,e,r,n,i,a){const s=5*t;return this.float32[s+0]=e,this.float32[s+1]=r,this.float32[s+2]=n,this.float32[s+3]=i,this.float32[s+4]=a,t}}Cs.prototype.bytesPerElement=20,ra(Cs,"StructArrayLayout5f20");class Rs extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,a,s){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,r,n,i,a,s)}emplace(t,e,r,n,i,a,s,o){const l=7*t;return this.float32[l+0]=e,this.float32[l+1]=r,this.float32[l+2]=n,this.float32[l+3]=i,this.float32[l+4]=a,this.float32[l+5]=s,this.float32[l+6]=o,t}}Rs.prototype.bytesPerElement=28,ra(Rs,"StructArrayLayout7f28");class Ds extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const a=6*t;return this.uint32[3*t+0]=e,this.uint16[a+2]=r,this.uint16[a+3]=n,this.uint16[a+4]=i,t}}Ds.prototype.bytesPerElement=12,ra(Ds,"StructArrayLayout1ul3ui12");class Vs extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint16[1*t+0]=e,t}}Vs.prototype.bytesPerElement=2,ra(Vs,"StructArrayLayout1ui2");class Ls extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.float32[i+0]=e,this.float32[i+1]=r,this.float32[i+2]=n,t}}Ls.prototype.bytesPerElement=12,ra(Ls,"StructArrayLayout3f12");class Fs extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.float32[n+0]=e,this.float32[n+1]=r,t}}Fs.prototype.bytesPerElement=8,ra(Fs,"StructArrayLayout2f8");class Ns extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,a,s,o,l,u,c,h,p,f,d,m){const y=this.length;return this.resize(y+1),this.emplace(y,t,e,r,n,i,a,s,o,l,u,c,h,p,f,d,m)}emplace(t,e,r,n,i,a,s,o,l,u,c,h,p,f,d,m,y){const g=16*t;return this.float32[g+0]=e,this.float32[g+1]=r,this.float32[g+2]=n,this.float32[g+3]=i,this.float32[g+4]=a,this.float32[g+5]=s,this.float32[g+6]=o,this.float32[g+7]=l,this.float32[g+8]=u,this.float32[g+9]=c,this.float32[g+10]=h,this.float32[g+11]=p,this.float32[g+12]=f,this.float32[g+13]=d,this.float32[g+14]=m,this.float32[g+15]=y,t}}Ns.prototype.bytesPerElement=64,ra(Ns,"StructArrayLayout16f64");class Os extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,a,s){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,r,n,i,a,s)}emplace(t,e,r,n,i,a,s,o){const l=10*t,u=5*t;return this.uint16[l+0]=e,this.uint16[l+1]=r,this.uint16[l+2]=n,this.uint16[l+3]=i,this.float32[u+2]=a,this.float32[u+3]=s,this.float32[u+4]=o,t}}Os.prototype.bytesPerElement=20,ra(Os,"StructArrayLayout4ui3f20");class Us extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint8[1*t+0]=e,t}}Us.prototype.bytesPerElement=1,ra(Us,"StructArrayLayout1ub1");class js extends ls{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.int16[this._pos2+3]}get tileAnchorY(){return this._structArray.int16[this._pos2+4]}get x1(){return this._structArray.float32[this._pos4+3]}get y1(){return this._structArray.float32[this._pos4+4]}get x2(){return this._structArray.float32[this._pos4+5]}get y2(){return this._structArray.float32[this._pos4+6]}get padding(){return this._structArray.int16[this._pos2+14]}get featureIndex(){return this._structArray.uint32[this._pos4+8]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+18]}get bucketIndex(){return this._structArray.uint16[this._pos2+19]}}js.prototype.size=40;class qs extends Ss{get(t){return new js(this,t)}}ra(qs,"CollisionBoxArray");class $s extends ls{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(t){this._structArray.uint8[this._pos1+49]=t;}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(t){this._structArray.uint8[this._pos1+50]=t;}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(t){this._structArray.uint32[this._pos4+13]=t;}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(t){this._structArray.uint8[this._pos1+58]=t;}}$s.prototype.size=60;class Gs extends zs{get(t){return new $s(this,t)}}ra(Gs,"PlacedSymbolArray");class Ys extends ls{get tileAnchorX(){return this._structArray.float32[this._pos4+0]}get tileAnchorY(){return this._structArray.float32[this._pos4+1]}get projectedAnchorX(){return this._structArray.int16[this._pos2+4]}get projectedAnchorY(){return this._structArray.int16[this._pos2+5]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+6]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+7]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+11]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get key(){return this._structArray.uint16[this._pos2+13]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+14]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+15]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+17]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+19]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+21]}get featureIndex(){return this._structArray.uint16[this._pos2+22]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+23]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numIconVertices(){return this._structArray.uint16[this._pos2+25]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+26]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+27]}get crossTileID(){return this._structArray.uint32[this._pos4+14]}set crossTileID(t){this._structArray.uint32[this._pos4+14]=t;}get textOffset0(){return this._structArray.float32[this._pos4+15]}get textOffset1(){return this._structArray.float32[this._pos4+16]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+17]}get zOffset(){return this._structArray.float32[this._pos4+18]}set zOffset(t){this._structArray.float32[this._pos4+18]=t;}get hasIconTextFit(){return this._structArray.uint8[this._pos1+76]}}Ys.prototype.size=80;class Xs extends Ts{get(t){return new Ys(this,t)}}ra(Xs,"SymbolInstanceArray");class Zs extends Bs{getoffsetX(t){return this.float32[1*t+0]}}ra(Zs,"GlyphOffsetArray");class Ks extends ps{getx(t){return this.int16[2*t+0]}gety(t){return this.int16[2*t+1]}}ra(Ks,"SymbolLineVertexArray");class Hs extends ls{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]}get layoutVertexArrayOffset(){return this._structArray.uint16[this._pos2+4]}}Hs.prototype.size=12;class Ws extends Ds{get(t){return new Hs(this,t)}}ra(Ws,"FeatureIndexArray");class Js extends As{geta_centroid_pos0(t){return this.uint16[2*t+0]}geta_centroid_pos1(t){return this.uint16[2*t+1]}}ra(Js,"FillExtrusionCentroidArray");const Qs=cs([{name:"a_pos",components:2,type:"Int16"}],4),to=cs([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class eo{constructor(t=[]){this.segments=t;}_prepareSegment(t,e,r,n){let i=this.segments[this.segments.length-1];return t>eo.MAX_VERTEX_ARRAY_LENGTH&&j(`Max vertices per segment is ${eo.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}`),(!i||i.vertexLength+t>eo.MAX_VERTEX_ARRAY_LENGTH||i.sortKey!==n)&&(i={vertexOffset:e,primitiveOffset:r,vertexLength:0,primitiveLength:0},void 0!==n&&(i.sortKey=n),this.segments.push(i)),i}prepareSegment(t,e,r,n){return this._prepareSegment(t,e.length,r.length,n)}get(){return this.segments}destroy(){for(const t of this.segments)for(const e in t.vaos)t.vaos[e].destroy();}static simpleSegment(t,e,r,n){return new eo([{vertexOffset:t,primitiveOffset:e,vertexLength:r,primitiveLength:n,vaos:{},sortKey:0}])}}function ro(t,e){return 256*(t=I(Math.floor(t),0,255))+I(Math.floor(e),0,255)}eo.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,ra(eo,"SegmentVector");const no=cs([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),io=cs([{name:"a_dash",components:4,type:"Uint16"}]);var ao={exports:{}},so={exports:{}};!function(t){t.exports=function(t,e){var r,n,i,a,s,o,l,u;for(n=t.length-(r=3&t.length),i=e,s=3432918353,o=461845907,u=0;u>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*o+(((l>>>16)*o&65535)<<16)&4294967295)<<13|i>>>19))+((5*(i>>>16)&65535)<<16)&4294967295))+((58964+(a>>>16)&65535)<<16);switch(l=0,r){case 3:l^=(255&t.charCodeAt(u+2))<<16;case 2:l^=(255&t.charCodeAt(u+1))<<8;case 1:i^=l=(65535&(l=(l=(65535&(l^=255&t.charCodeAt(u)))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*o+(((l>>>16)*o&65535)<<16)&4294967295;}return i^=t.length,i=2246822507*(65535&(i^=i>>>16))+((2246822507*(i>>>16)&65535)<<16)&4294967295,i=3266489909*(65535&(i^=i>>>13))+((3266489909*(i>>>16)&65535)<<16)&4294967295,(i^=i>>>16)>>>0};}(so);var oo=so.exports,lo={exports:{}};!function(t){t.exports=function(t,e){for(var r,n=t.length,i=e^n,a=0;n>=4;)r=1540483477*(65535&(r=255&t.charCodeAt(a)|(255&t.charCodeAt(++a))<<8|(255&t.charCodeAt(++a))<<16|(255&t.charCodeAt(++a))<<24))+((1540483477*(r>>>16)&65535)<<16),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)^(r=1540483477*(65535&(r^=r>>>24))+((1540483477*(r>>>16)&65535)<<16)),n-=4,++a;switch(n){case 3:i^=(255&t.charCodeAt(a+2))<<16;case 2:i^=(255&t.charCodeAt(a+1))<<8;case 1:i=1540483477*(65535&(i^=255&t.charCodeAt(a)))+((1540483477*(i>>>16)&65535)<<16);}return i=1540483477*(65535&(i^=i>>>13))+((1540483477*(i>>>16)&65535)<<16),(i^=i>>>15)>>>0};}(lo);var uo=oo,co=lo.exports;ao.exports=uo,ao.exports.murmur3=uo,ao.exports.murmur2=co;var ho=h(ao.exports);class po{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1;}add(t,e,r,n){this.ids.push(fo(t)),this.positions.push(e,r,n);}eachPosition(t,e){const r=fo(t);let n=0,i=this.ids.length-1;for(;n>1;this.ids[t]>=r?i=t:n=t+1;}for(;this.ids[n]===r;)e(this.positions[3*n],this.positions[3*n+1],this.positions[3*n+2]),n++;}static serialize(t,e){const r=new Float64Array(t.ids),n=new Uint32Array(t.positions);return mo(r,n,0,r.length-1),e&&(e.add(r.buffer),e.add(n.buffer)),{ids:r,positions:n}}static deserialize(t){const e=new po;let r;e.ids=t.ids,e.positions=t.positions;for(const t of e.ids)t!==r&&e.uniqueIds.push(t),r=t;return e.indexed=!0,e}}function fo(t){const e=+t;return !isNaN(e)&&Number.MIN_SAFE_INTEGER<=e&&e<=Number.MAX_SAFE_INTEGER?e:ho(String(t))}function mo(t,e,r,n){for(;r>1];let a=r-1,s=n+1;for(;;){do{a++;}while(t[a]i);if(a>=s)break;yo(t,a,s),yo(e,3*a,3*s),yo(e,3*a+1,3*s+1),yo(e,3*a+2,3*s+2);}s-r`u_${t}`)),this.type=r;}setUniform(t,e,r,n,i){e.set(t,i,n.constantOr(this.value));}getBinding(t,e){return "color"===this.type?new Mo(t):new vo(t)}}class To{constructor(t,e){this.uniformNames=e.map((t=>`u_${t}`)),this.pattern=null,this.pixelRatio=1;}setConstantPatternPositions(t){this.pixelRatio=t.pixelRatio||1,this.pattern=t.tl.concat(t.br);}setUniform(t,e,r,n,i){const a="u_pattern"===i||"u_dash"===i?this.pattern:"u_pixel_ratio"===i?this.pixelRatio:null;a&&e.set(t,i,a);}getBinding(t,e){return "u_pattern"===e||"u_dash"===e?new wo(t):new vo(t)}}class Bo{constructor(t,e,r,n){this.expression=t,this.type=r,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===r?2:1,offset:0}))),this.paintVertexArray=new n;}populatePaintArray(t,e,r,n,i,a,s){const o=this.paintVertexArray.length,l=this.expression.evaluate(new Pa(0,{brightness:a}),e,{},i,n,s);this.paintVertexArray.resize(t),this._setPaintValue(o,t,l);}updatePaintArray(t,e,r,n,i,a,s){const o=this.expression.evaluate({zoom:0,brightness:s},r,n,void 0,i);this._setPaintValue(t,e,o);}_setPaintValue(t,e,r){if("color"===this.type){const n=Eo(r);for(let r=t;r`u_${t}_t`)),this.type=r,this.useIntegerZoom=n,this.zoom=i,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===r?4:2,offset:0}))),this.paintVertexArray=new a;}populatePaintArray(t,e,r,n,i,a,s){const o=this.expression.evaluate(new Pa(this.zoom,{brightness:a}),e,{},i,n,s),l=this.expression.evaluate(new Pa(this.zoom+1,{brightness:a}),e,{},i,n,s),u=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(u,t,o,l);}updatePaintArray(t,e,r,n,i,a,s){const o=this.expression.evaluate({zoom:this.zoom,brightness:s},r,n,void 0,i),l=this.expression.evaluate({zoom:this.zoom+1,brightness:s},r,n,void 0,i);this._setPaintValue(t,e,o,l);}_setPaintValue(t,e,r,n){if("color"===this.type){const i=Eo(r),a=Eo(n);for(let r=t;r!0)){this.binders={},this._buffers=[];const n=[];for(const i in t.paint._values){const a=t.paint.get(i);if(!r(i))continue;if(!(a instanceof Da&&Ti(a.property.specification)))continue;const s=Fo(i,t.type),o=a.value,l=a.property.specification.type,u=!!a.property.useIntegerZoom,c="line-dasharray"===i||i.endsWith("pattern"),h="line-dasharray"===i&&"constant"!==t.layout.get("line-cap").value.kind;if("constant"!==o.kind||h)if("source"===o.kind||h||c){const e=Uo(i,l,"source");this.binders[i]=c?new Ro(o,s,l,e,t.id):new Bo(o,s,l,e),n.push(`/a_${i}`);}else {const t=Uo(i,l,"composite");this.binders[i]=new Co(o,s,l,u,e,t),n.push(`/z_${i}`);}else this.binders[i]=c?new To(o.value,s):new zo(o.value,s,l),n.push(`/u_${i}`);}this.cacheKey=n.sort().join("");}getMaxValue(t){const e=this.binders[t];return e instanceof Bo||e instanceof Co?e.maxValue:0}populatePaintArrays(t,e,r,n,i,a,s){for(const o in this.binders){const l=this.binders[o];(l instanceof Bo||l instanceof Co||l instanceof Ro)&&l.populatePaintArray(t,e,r,n,i,a,s);}}setConstantPatternPositions(t){for(const e in this.binders){const r=this.binders[e];r instanceof To&&r.setConstantPatternPositions(t);}}updatePaintArrays(t,e,r,n,i,a,s,o){let l=!1;const u=Object.keys(t),c=0!==u.length,h=c?u:e.uniqueIds;for(const u in this.binders){const p=this.binders[u];if((p instanceof Bo||p instanceof Co||p instanceof Ro)&&(!0===p.expression.isStateDependent||!1===p.expression.isLightConstant)){const f=i.paint.get(u);p.expression=f.value;for(const r of h){const i=t[r.toString()];e.eachPosition(r,((t,e,r)=>{const l=n.feature(t);p.updatePaintArray(e,r,l,i,a,s,o);}));}if(!c)for(const e of r.uniqueIds){const i=t[e.toString()];r.eachPosition(e,((t,e,r)=>{const l=n.feature(t);p.updatePaintArray(e,r,l,i,a,s,o);}));}l=!0;}}return l}defines(){const t=[];for(const e in this.binders){const r=this.binders[e];(r instanceof zo||r instanceof To)&&t.push(...r.uniformNames.map((t=>`#define HAS_UNIFORM_${t}`)));}return t}getBinderAttributes(){const t=[];for(const e in this.binders){const r=this.binders[e];if(r instanceof Bo||r instanceof Co||r instanceof Ro)for(let e=0;e!0)){this.programConfigurations={};for(const n of t)this.programConfigurations[n.id]=new Do(n,e,r);this.needsUpload=!1,this._featureMap=new po,this._featureMapWithoutIds=new po,this._bufferOffset=0,this._idlessCounter=0;}populatePaintArrays(t,e,r,n,i,a,s,o){for(const r in this.programConfigurations)this.programConfigurations[r].populatePaintArrays(t,e,n,i,a,s,o);void 0!==e.id?this._featureMap.add(e.id,r,this._bufferOffset,t):(this._featureMapWithoutIds.add(this._idlessCounter,r,this._bufferOffset,t),this._idlessCounter+=1),this._bufferOffset=t,this.needsUpload=!0;}updatePaintArrays(t,e,r,n,i,a){for(const s of r)this.needsUpload=this.programConfigurations[s.id].updatePaintArrays(t,this._featureMap,this._featureMapWithoutIds,e,s,n,i,a||0)||this.needsUpload;}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const e in this.programConfigurations)this.programConfigurations[e].upload(t);this.needsUpload=!1;}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy();}}const Lo={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-emissive-strength":["emissive_strength"],"icon-emissive-strength":["emissive_strength"],"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-pattern":["pattern","pixel_ratio"],"fill-pattern":["pattern","pixel_ratio"],"fill-extrusion-pattern":["pattern","pixel_ratio"],"line-dasharray":["dash"]};function Fo(t,e){return Lo[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}const No={"line-pattern":{source:xs,composite:xs},"fill-pattern":{source:xs,composite:xs},"fill-extrusion-pattern":{source:xs,composite:xs},"line-dasharray":{source:vs,composite:vs}},Oo={color:{source:Fs,composite:gs},number:{source:Bs,composite:Fs}};function Uo(t,e,r){const n=No[t];return n&&n[r]||Oo[e][r]}ra(zo,"ConstantBinder"),ra(To,"PatternConstantBinder"),ra(Bo,"SourceExpressionBinder"),ra(Ro,"PatternCompositeBinder"),ra(Co,"CompositeExpressionBinder"),ra(Do,"ProgramConfiguration",{omit:["_buffers"]}),ra(Vo,"ProgramConfigurationSet");const jo=Tr/Math.PI/2,qo=5,$o=6,Go=16383,Yo=64,Xo=[Yo,32,16],Zo=-jo,Ko=jo;function Ho(t,e,r,n=jo){return r=b(r),[t*Math.sin(r)*n,-e*n,t*Math.cos(r)*n]}function Wo(t,e,r){return Ho(Math.cos(b(t)),Math.sin(b(t)),e,r)}const Jo=6371008.8,Qo=2*Math.PI*Jo;class tl{constructor(t,e){if(isNaN(t)||isNaN(e))throw new Error(`Invalid LngLat object: (${t}, ${e})`);if(this.lng=+t,this.lat=+e,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new tl(P(this.lng,-180,180),this.lat)}toArray(){return [this.lng,this.lat]}toString(){return `LngLat(${this.lng}, ${this.lat})`}distanceTo(t){const e=Math.PI/180,r=this.lat*e,n=t.lat*e,i=Math.sin(r)*Math.sin(n)+Math.cos(r)*Math.cos(n)*Math.cos((t.lng-this.lng)*e);return Jo*Math.acos(Math.min(i,1))}toBounds(t=0){const e=360*t/40075017,r=e/Math.cos(Math.PI/180*this.lat);return new el({lng:this.lng-r,lat:this.lat-e},{lng:this.lng+r,lat:this.lat+e})}toEcef(t){return Wo(this.lat,this.lng,jo+t*jo/Jo)}static convert(t){if(t instanceof tl)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new tl(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new tl(Number("lng"in t?t.lng:t.lon),Number(t.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}class el{constructor(t,e){t&&(e?this.setSouthWest(t).setNorthEast(e):4===t.length?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1]));}setNorthEast(t){return this._ne=t instanceof tl?new tl(t.lng,t.lat):tl.convert(t),this}setSouthWest(t){return this._sw=t instanceof tl?new tl(t.lng,t.lat):tl.convert(t),this}extend(t){const e=this._sw,r=this._ne;let n,i;if(t instanceof tl)n=t,i=t;else {if(!(t instanceof el))return Array.isArray(t)?4===t.length||t.every(Array.isArray)?this.extend(el.convert(t)):this.extend(tl.convert(t)):"object"==typeof t&&null!==t&&t.hasOwnProperty("lat")&&(t.hasOwnProperty("lon")||t.hasOwnProperty("lng"))?this.extend(tl.convert(t)):this;if(n=t._sw,i=t._ne,!n||!i)return this}return e||r?(e.lng=Math.min(n.lng,e.lng),e.lat=Math.min(n.lat,e.lat),r.lng=Math.max(i.lng,r.lng),r.lat=Math.max(i.lat,r.lat)):(this._sw=new tl(n.lng,n.lat),this._ne=new tl(i.lng,i.lat)),this}getCenter(){return new tl((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 tl(this.getWest(),this.getNorth())}getSouthEast(){return new tl(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:e,lat:r}=tl.convert(t);let n=this._sw.lng<=e&&e<=this._ne.lng;return this._sw.lng>this._ne.lng&&(n=this._sw.lng>=e&&e>=this._ne.lng),this._sw.lat<=r&&r<=this._ne.lat&&n}static convert(t){return !t||t instanceof el?t:new el(t)}}var rl={};!function(t,e){!function(t){function e(t,e,n){var i=r(256*t,256*(e=Math.pow(2,n)-e-1),n),a=r(256*(t+1),256*(e+1),n);return i[0]+","+i[1]+","+a[0]+","+a[1]}function r(t,e,r){var n=2*Math.PI*6378137/256/Math.pow(2,r);return [t*n-2*Math.PI*6378137/2,e*n-2*Math.PI*6378137/2]}t.getURL=function(t,r,n,i,a,s){return s=s||{},t+"?"+["bbox="+e(n,i,a),"format="+(s.format||"image/png"),"service="+(s.service||"WMS"),"version="+(s.version||"1.1.1"),"request="+(s.request||"GetMap"),"srs="+(s.srs||"EPSG:3857"),"width="+(s.width||256),"height="+(s.height||256),"layers="+r].join("&")},t.getTileBBox=e,t.getMercCoords=r,Object.defineProperty(t,"__esModule",{value:!0});}(e);}(0,rl);var nl=rl;class il{constructor(t,e,r){this.z=t,this.x=e,this.y=r,this.key=ol(0,t,t,e,r);}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,e){const r=nl.getTileBBox(this.x,this.y,this.z),n=function(t,e,r){let n,i="";for(let a=t;a>0;a--)n=1<this.canonical.z?new sl(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new sl(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}calculateScaledKey(t,e=!0){if(this.overscaledZ===t&&e)return this.key;if(t>this.canonical.z)return ol(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y);{const r=this.canonical.z-t;return ol(this.wrap*+e,t,t,this.canonical.x>>r,this.canonical.y>>r)}}isChildOf(t){if(t.wrap!==this.wrap)return !1;const e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ>e&&t.canonical.y===this.canonical.y>>e}children(t){if(this.overscaledZ>=t)return [new sl(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const e=this.canonical.z+1,r=2*this.canonical.x,n=2*this.canonical.y;return [new sl(e,this.wrap,e,r,n),new sl(e,this.wrap,e,r+1,n),new sl(e,this.wrap,e,r,n+1),new sl(e,this.wrap,e,r+1,n+1)]}isLessThan(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.y{let e=t.canonical.x-1,r=t.wrap;return e<0&&(e=(1<{let e=t.canonical.x+1,r=t.wrap;return e===1<new sl(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,(0===t.canonical.y?1<new sl(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y===(1<=l?(Al(t,e,r,u,c,a,h,o,l),Al(t,u,c,n,i,h,s,o,l)):t.push(s);}function Sl(t,e,r){let n=t[0],i=n.x,a=n.y;e(n);const s=[n];for(let o=1;ot.x+1||nt.y+1)&&j("Geometry exceeds allowed extent, reduce your vector tile buffer size"),t}function Tl(t,e,r){const n=t.loadGeometry(),i=t.extent,a=Tr/i;if(e&&r&&r.projection.isReprojectedInTileSpace){const a=1<{const r=ml((e.x+t.x/i)/a),n=yl((e.y+t.y/i)/a),c=u.project(r,n);t.x=(c.x*s-o)*i,t.y=(c.y*s-l)*i;};for(let e=0;e=i||r.y<0||r.y>=i||(c(r),t.push(r));n[e]=t;}}for(const t of n)for(const e of t)zl(e,a);return n}function Bl(t,e){return {type:t.type,id:t.id,properties:t.properties,geometry:e?Tl(t):[]}}function Cl(t,e,r,n,i){t.emplaceBack(2*e+(n+1)/2,2*r+(i+1)/2);}function Rl(t,e,r){const n=16384;t.emplaceBack(e.x,e.y,e.z,r[0]*n,r[1]*n,r[2]*n);}class Dl{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.hasPattern=!1,this.projection=t.projection,this.layoutVertexArray=new ps,this.indexArray=new Es,this.segments=new eo,this.programConfigurations=new Vo(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}populate(t,e,r,n){const i=this.layers[0],a=[];let s=null;"circle"===i.type&&(s=i.layout.get("circle-sort-key"));for(const{feature:e,id:i,index:o,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,u=Bl(e,t);if(!this.layers[0]._featureFilter.filter(new Pa(this.zoom),u,r))continue;const c=s?s.evaluate(u,{},r):void 0,h={id:i,properties:e.properties,type:e.type,sourceLayerIndex:l,index:o,geometry:t?u.geometry:Tl(e,r,n),patterns:{},sortKey:c};a.push(h);}s&&a.sort(((t,e)=>t.sortKey-e.sortKey));let o=null;"globe"===n.projection.name&&(this.globeExtVertexArray=new bs,o=n.projection);for(const n of a){const{geometry:i,index:a,sourceLayerIndex:s}=n,l=t[a].feature;this.addFeature(n,i,a,e.availableImages,r,o,e.brightness),e.featureIndex.insert(l,i,a,s,this.index);}}update(t,e,r,n,i){const a=0!==Object.keys(t).length;a&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,a?this.stateDependentLayers:this.layers,r,n,i);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Qs.members),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,to.members))),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy());}addFeature(t,e,r,n,i,a,s){for(const r of e)for(const e of r){const r=e.x,n=e.y;if(r<0||r>=Tr||n<0||n>=Tr)continue;if(a){const t=a.projectTilePoint(r,n,i),e=a.upVector(i,r,n),s=this.globeExtVertexArray;Rl(s,t,e),Rl(s,t,e),Rl(s,t,e),Rl(s,t,e);}const s=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),o=s.vertexLength;Cl(this.layoutVertexArray,r,n,-1,-1),Cl(this.layoutVertexArray,r,n,1,-1),Cl(this.layoutVertexArray,r,n,1,1),Cl(this.layoutVertexArray,r,n,-1,1),this.indexArray.emplaceBack(o,o+1,o+2),this.indexArray.emplaceBack(o,o+2,o+3),s.vertexLength+=4,s.primitiveLength+=2;}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,{},n,i,s);}}function Vl(t,e){for(let r=0;r1){if(Ol(t,e))return !0;for(let n=0;n1?r:r.sub(e)._mult(i)._add(e))}function $l(t,e){let r,n,i,a=!1;for(let s=0;se.y!=i.y>e.y&&e.x<(i.x-n.x)*(e.y-n.y)/(i.y-n.y)+n.x&&(a=!a);}return a}function Gl(t,e){let r=!1;for(let n=0,i=t.length-1;ne.y!=s.y>e.y&&e.x<(s.x-a.x)*(e.y-a.y)/(s.y-a.y)+a.x&&(r=!r);}return r}function Yl(t,e,r,n,i){for(const a of t)if(e<=a.x&&r<=a.y&&n>=a.x&&i>=a.y)return !0;const a=[new g(e,r),new g(e,i),new g(n,i),new g(n,r)];if(t.length>2)for(const e of a)if(Gl(t,e))return !0;for(let e=0;ei.x&&e.x>i.x||t.yi.y&&e.y>i.y)return !1;const a=q(t,e,r[0]);return a!==q(t,e,r[1])||a!==q(t,e,r[2])||a!==q(t,e,r[3])}function Zl(t,e,r,n,i,a){let s=e.y-t.y,o=t.x-e.x;if(a=a||0){const t=s*s+o*o;if(0===t)return !0;const e=Math.sqrt(t);s/=e,o/=e;}return !((r.x-t.x)*s+(r.y-t.y)*o-a<0||(n.x-t.x)*s+(n.y-t.y)*o-a<0||(i.x-t.x)*s+(i.y-t.y)*o-a<0)}function Kl(t,e,r,n,i,a,s){return !(Zl(t,e,n,i,a,s)||Zl(e,r,n,i,a,s)||Zl(r,t,n,i,a,s)||Zl(n,i,t,e,r,s)||Zl(i,a,t,e,r,s)||Zl(a,n,t,e,r,s))}function Hl(t,e,r){const n=e.paint.get(t).value;return "constant"===n.kind?n.value:r.programConfigurations.get(e.id).getMaxValue(t)}function Wl(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function Jl(t,e,r,n,i){if(!e[0]&&!e[1])return t;const a=g.convert(e)._mult(i);"viewport"===r&&a._rotate(-n);const s=[];for(let e=0;e0?(r[0]=2*(o*s+c*n+l*a-u*i)/h,r[1]=2*(l*s+c*i+u*n-o*a)/h,r[2]=2*(u*s+c*a+o*i-l*n)/h):(r[0]=2*(o*s+c*n+l*a-u*i),r[1]=2*(l*s+c*i+u*n-o*a),r[2]=2*(u*s+c*a+o*i-l*n)),Bu(t,e,r),t},Iu.getTranslation=function(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t},Iu.getScaling=Cu,Iu.getRotation=function(t,e){var r=new Pu.ARRAY_TYPE(3);Cu(r,e);var n=1/r[0],i=1/r[1],a=1/r[2],s=e[0]*n,o=e[1]*i,l=e[2]*a,u=e[4]*n,c=e[5]*i,h=e[6]*a,p=e[8]*n,f=e[9]*i,d=e[10]*a,m=s+c+d,y=0;return m>0?(y=2*Math.sqrt(m+1),t[3]=.25*y,t[0]=(h-f)/y,t[1]=(p-l)/y,t[2]=(o-u)/y):s>c&&s>d?(y=2*Math.sqrt(1+s-c-d),t[3]=(h-f)/y,t[0]=.25*y,t[1]=(o+u)/y,t[2]=(p+l)/y):c>d?(y=2*Math.sqrt(1+c-s-d),t[3]=(p-l)/y,t[0]=(o+u)/y,t[1]=.25*y,t[2]=(h+f)/y):(y=2*Math.sqrt(1+d-s-c),t[3]=(o-u)/y,t[0]=(p+l)/y,t[1]=(h+f)/y,t[2]=.25*y),t},Iu.fromRotationTranslationScale=function(t,e,r,n){var i=e[0],a=e[1],s=e[2],o=e[3],l=i+i,u=a+a,c=s+s,h=i*l,p=i*u,f=i*c,d=a*u,m=a*c,y=s*c,g=o*l,x=o*u,v=o*c,b=n[0],_=n[1],w=n[2];return t[0]=(1-(d+y))*b,t[1]=(p+v)*b,t[2]=(f-x)*b,t[3]=0,t[4]=(p-v)*_,t[5]=(1-(h+y))*_,t[6]=(m+g)*_,t[7]=0,t[8]=(f+x)*w,t[9]=(m-g)*w,t[10]=(1-(h+d))*w,t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t},Iu.fromRotationTranslationScaleOrigin=function(t,e,r,n,i){var a=e[0],s=e[1],o=e[2],l=e[3],u=a+a,c=s+s,h=o+o,p=a*u,f=a*c,d=a*h,m=s*c,y=s*h,g=o*h,x=l*u,v=l*c,b=l*h,_=n[0],w=n[1],M=n[2],A=i[0],S=i[1],I=i[2],k=(1-(m+g))*_,P=(f+b)*_,E=(d-v)*_,z=(f-b)*w,T=(1-(p+g))*w,B=(y+x)*w,C=(d+v)*M,R=(y-x)*M,D=(1-(p+m))*M;return t[0]=k,t[1]=P,t[2]=E,t[3]=0,t[4]=z,t[5]=T,t[6]=B,t[7]=0,t[8]=C,t[9]=R,t[10]=D,t[11]=0,t[12]=r[0]+A-(k*A+z*S+C*I),t[13]=r[1]+S-(P*A+T*S+R*I),t[14]=r[2]+I-(E*A+B*S+D*I),t[15]=1,t},Iu.fromQuat=function(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],s=r+r,o=n+n,l=i+i,u=r*s,c=n*s,h=n*o,p=i*s,f=i*o,d=i*l,m=a*s,y=a*o,g=a*l;return t[0]=1-h-d,t[1]=c+g,t[2]=p-y,t[3]=0,t[4]=c-g,t[5]=1-u-d,t[6]=f+m,t[7]=0,t[8]=p+y,t[9]=f-m,t[10]=1-u-h,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},Iu.frustum=function(t,e,r,n,i,a,s){var o=1/(r-e),l=1/(i-n),u=1/(a-s);return t[0]=2*a*o,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=2*a*l,t[6]=0,t[7]=0,t[8]=(r+e)*o,t[9]=(i+n)*l,t[10]=(s+a)*u,t[11]=-1,t[12]=0,t[13]=0,t[14]=s*a*2*u,t[15]=0,t},Iu.perspectiveNO=Ru,Iu.perspectiveZO=function(t,e,r,n,i){var a,s=1/Math.tan(e/2);return t[0]=s/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=s,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=i&&i!==1/0?(t[10]=i*(a=1/(n-i)),t[14]=i*n*a):(t[10]=-1,t[14]=-n),t},Iu.perspectiveFromFieldOfView=function(t,e,r,n){var i=Math.tan(e.upDegrees*Math.PI/180),a=Math.tan(e.downDegrees*Math.PI/180),s=Math.tan(e.leftDegrees*Math.PI/180),o=Math.tan(e.rightDegrees*Math.PI/180),l=2/(s+o),u=2/(i+a);return t[0]=l,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=u,t[6]=0,t[7]=0,t[8]=-(s-o)*l*.5,t[9]=(i-a)*u*.5,t[10]=n/(r-n),t[11]=-1,t[12]=0,t[13]=0,t[14]=n*r/(r-n),t[15]=0,t},Iu.orthoNO=Du,Iu.orthoZO=function(t,e,r,n,i,a,s){var o=1/(e-r),l=1/(n-i),u=1/(a-s);return t[0]=-2*o,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=u,t[11]=0,t[12]=(e+r)*o,t[13]=(i+n)*l,t[14]=a*u,t[15]=1,t},Iu.lookAt=function(t,e,r,n){var i,a,s,o,l,u,c,h,p,f,d=e[0],m=e[1],y=e[2],g=n[0],x=n[1],v=n[2],b=r[0],_=r[1],w=r[2];return Math.abs(d-b)0&&(c*=f=1/Math.sqrt(f),h*=f,p*=f);var d=l*p-u*h,m=u*c-o*p,y=o*h-l*c;return (f=d*d+m*m+y*y)>0&&(d*=f=1/Math.sqrt(f),m*=f,y*=f),t[0]=d,t[1]=m,t[2]=y,t[3]=0,t[4]=h*y-p*m,t[5]=p*d-c*y,t[6]=c*m-h*d,t[7]=0,t[8]=c,t[9]=h,t[10]=p,t[11]=0,t[12]=i,t[13]=a,t[14]=s,t[15]=1,t},Iu.str=function(t){return "mat4("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+", "+t[9]+", "+t[10]+", "+t[11]+", "+t[12]+", "+t[13]+", "+t[14]+", "+t[15]+")"},Iu.frob=function(t){return Math.hypot(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15])},Iu.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t[6]=e[6]+r[6],t[7]=e[7]+r[7],t[8]=e[8]+r[8],t[9]=e[9]+r[9],t[10]=e[10]+r[10],t[11]=e[11]+r[11],t[12]=e[12]+r[12],t[13]=e[13]+r[13],t[14]=e[14]+r[14],t[15]=e[15]+r[15],t},Iu.subtract=Vu,Iu.multiplyScalar=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*r,t[9]=e[9]*r,t[10]=e[10]*r,t[11]=e[11]*r,t[12]=e[12]*r,t[13]=e[13]*r,t[14]=e[14]*r,t[15]=e[15]*r,t},Iu.multiplyScalarAndAdd=function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t[4]=e[4]+r[4]*n,t[5]=e[5]+r[5]*n,t[6]=e[6]+r[6]*n,t[7]=e[7]+r[7]*n,t[8]=e[8]+r[8]*n,t[9]=e[9]+r[9]*n,t[10]=e[10]+r[10]*n,t[11]=e[11]+r[11]*n,t[12]=e[12]+r[12]*n,t[13]=e[13]+r[13]*n,t[14]=e[14]+r[14]*n,t[15]=e[15]+r[15]*n,t},Iu.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]},Iu.equals=function(t,e){var r=t[0],n=t[1],i=t[2],a=t[3],s=t[4],o=t[5],l=t[6],u=t[7],c=t[8],h=t[9],p=t[10],f=t[11],d=t[12],m=t[13],y=t[14],g=t[15],x=e[0],v=e[1],b=e[2],_=e[3],w=e[4],M=e[5],A=e[6],S=e[7],I=e[8],k=e[9],P=e[10],E=e[11],z=e[12],T=e[13],B=e[14],C=e[15];return Math.abs(r-x)<=Pu.EPSILON*Math.max(1,Math.abs(r),Math.abs(x))&&Math.abs(n-v)<=Pu.EPSILON*Math.max(1,Math.abs(n),Math.abs(v))&&Math.abs(i-b)<=Pu.EPSILON*Math.max(1,Math.abs(i),Math.abs(b))&&Math.abs(a-_)<=Pu.EPSILON*Math.max(1,Math.abs(a),Math.abs(_))&&Math.abs(s-w)<=Pu.EPSILON*Math.max(1,Math.abs(s),Math.abs(w))&&Math.abs(o-M)<=Pu.EPSILON*Math.max(1,Math.abs(o),Math.abs(M))&&Math.abs(l-A)<=Pu.EPSILON*Math.max(1,Math.abs(l),Math.abs(A))&&Math.abs(u-S)<=Pu.EPSILON*Math.max(1,Math.abs(u),Math.abs(S))&&Math.abs(c-I)<=Pu.EPSILON*Math.max(1,Math.abs(c),Math.abs(I))&&Math.abs(h-k)<=Pu.EPSILON*Math.max(1,Math.abs(h),Math.abs(k))&&Math.abs(p-P)<=Pu.EPSILON*Math.max(1,Math.abs(p),Math.abs(P))&&Math.abs(f-E)<=Pu.EPSILON*Math.max(1,Math.abs(f),Math.abs(E))&&Math.abs(d-z)<=Pu.EPSILON*Math.max(1,Math.abs(d),Math.abs(z))&&Math.abs(m-T)<=Pu.EPSILON*Math.max(1,Math.abs(m),Math.abs(T))&&Math.abs(y-B)<=Pu.EPSILON*Math.max(1,Math.abs(y),Math.abs(B))&&Math.abs(g-C)<=Pu.EPSILON*Math.max(1,Math.abs(g),Math.abs(C))},Iu.sub=Iu.mul=Iu.ortho=Iu.perspective=void 0;var Pu=function(t,e){if(t&&t.__esModule)return t;if(null===t||"object"!==ku(t)&&"function"!=typeof t)return {default:t};var r=Eu(void 0);if(r&&r.has(t))return r.get(t);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if("default"!==a&&Object.prototype.hasOwnProperty.call(t,a)){var s=i?Object.getOwnPropertyDescriptor(t,a):null;s&&(s.get||s.set)?Object.defineProperty(n,a,s):n[a]=t[a];}return n.default=t,r&&r.set(t,n),n}(nu);function Eu(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,r=new WeakMap;return (Eu=function(t){return t?r:e})(t)}function zu(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Tu(t,e,r){var n=e[0],i=e[1],a=e[2],s=e[3],o=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=e[9],f=e[10],d=e[11],m=e[12],y=e[13],g=e[14],x=e[15],v=r[0],b=r[1],_=r[2],w=r[3];return t[0]=v*n+b*o+_*h+w*m,t[1]=v*i+b*l+_*p+w*y,t[2]=v*a+b*u+_*f+w*g,t[3]=v*s+b*c+_*d+w*x,t[4]=(v=r[4])*n+(b=r[5])*o+(_=r[6])*h+(w=r[7])*m,t[5]=v*i+b*l+_*p+w*y,t[6]=v*a+b*u+_*f+w*g,t[7]=v*s+b*c+_*d+w*x,t[8]=(v=r[8])*n+(b=r[9])*o+(_=r[10])*h+(w=r[11])*m,t[9]=v*i+b*l+_*p+w*y,t[10]=v*a+b*u+_*f+w*g,t[11]=v*s+b*c+_*d+w*x,t[12]=(v=r[12])*n+(b=r[13])*o+(_=r[14])*h+(w=r[15])*m,t[13]=v*i+b*l+_*p+w*y,t[14]=v*a+b*u+_*f+w*g,t[15]=v*s+b*c+_*d+w*x,t}function Bu(t,e,r){var n=e[0],i=e[1],a=e[2],s=e[3],o=n+n,l=i+i,u=a+a,c=n*o,h=n*l,p=n*u,f=i*l,d=i*u,m=a*u,y=s*o,g=s*l,x=s*u;return t[0]=1-(f+m),t[1]=h+x,t[2]=p-g,t[3]=0,t[4]=h-x,t[5]=1-(c+m),t[6]=d+y,t[7]=0,t[8]=p+g,t[9]=d-y,t[10]=1-(c+f),t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function Cu(t,e){var r=e[4],n=e[5],i=e[6],a=e[8],s=e[9],o=e[10];return t[0]=Math.hypot(e[0],e[1],e[2]),t[1]=Math.hypot(r,n,i),t[2]=Math.hypot(a,s,o),t}function Ru(t,e,r,n,i){var a,s=1/Math.tan(e/2);return t[0]=s/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=s,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=i&&i!==1/0?(t[10]=(i+n)*(a=1/(n-i)),t[14]=2*i*n*a):(t[10]=-1,t[14]=-2*n),t}function Du(t,e,r,n,i,a,s){var o=1/(e-r),l=1/(n-i),u=1/(a-s);return t[0]=-2*o,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*u,t[11]=0,t[12]=(e+r)*o,t[13]=(i+n)*l,t[14]=(s+a)*u,t[15]=1,t}function Vu(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t[6]=e[6]-r[6],t[7]=e[7]-r[7],t[8]=e[8]-r[8],t[9]=e[9]-r[9],t[10]=e[10]-r[10],t[11]=e[11]-r[11],t[12]=e[12]-r[12],t[13]=e[13]-r[13],t[14]=e[14]-r[14],t[15]=e[15]-r[15],t}Iu.perspective=Ru,Iu.ortho=Du,Iu.mul=Tu,Iu.sub=Vu;var Lu={},Fu={};function Nu(t){return Nu="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Nu(t)}Object.defineProperty(Fu,"__esModule",{value:!0}),Fu.create=ju,Fu.clone=function(t){var e=new Ou.ARRAY_TYPE(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},Fu.length=qu,Fu.fromValues=function(t,e,r){var n=new Ou.ARRAY_TYPE(3);return n[0]=t,n[1]=e,n[2]=r,n},Fu.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},Fu.set=function(t,e,r,n){return t[0]=e,t[1]=r,t[2]=n,t},Fu.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t},Fu.subtract=$u,Fu.multiply=Gu,Fu.divide=Yu,Fu.ceil=function(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t},Fu.floor=function(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t},Fu.min=function(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t},Fu.max=function(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t},Fu.round=function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t[2]=Math.round(e[2]),t},Fu.scale=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t},Fu.scaleAndAdd=function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t},Fu.distance=Xu,Fu.squaredDistance=Zu,Fu.squaredLength=Ku,Fu.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t},Fu.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t},Fu.normalize=function(t,e){var r=e[0],n=e[1],i=e[2],a=r*r+n*n+i*i;return a>0&&(a=1/Math.sqrt(a)),t[0]=e[0]*a,t[1]=e[1]*a,t[2]=e[2]*a,t},Fu.dot=Hu,Fu.cross=function(t,e,r){var n=e[0],i=e[1],a=e[2],s=r[0],o=r[1],l=r[2];return t[0]=i*l-a*o,t[1]=a*s-n*l,t[2]=n*o-i*s,t},Fu.lerp=function(t,e,r,n){var i=e[0],a=e[1],s=e[2];return t[0]=i+n*(r[0]-i),t[1]=a+n*(r[1]-a),t[2]=s+n*(r[2]-s),t},Fu.hermite=function(t,e,r,n,i,a){var s=a*a,o=s*(2*a-3)+1,l=s*(a-2)+a,u=s*(a-1),c=s*(3-2*a);return t[0]=e[0]*o+r[0]*l+n[0]*u+i[0]*c,t[1]=e[1]*o+r[1]*l+n[1]*u+i[1]*c,t[2]=e[2]*o+r[2]*l+n[2]*u+i[2]*c,t},Fu.bezier=function(t,e,r,n,i,a){var s=1-a,o=s*s,l=a*a,u=o*s,c=3*a*o,h=3*l*s,p=l*a;return t[0]=e[0]*u+r[0]*c+n[0]*h+i[0]*p,t[1]=e[1]*u+r[1]*c+n[1]*h+i[1]*p,t[2]=e[2]*u+r[2]*c+n[2]*h+i[2]*p,t},Fu.random=function(t,e){e=e||1;var r=2*Ou.RANDOM()*Math.PI,n=2*Ou.RANDOM()-1,i=Math.sqrt(1-n*n)*e;return t[0]=Math.cos(r)*i,t[1]=Math.sin(r)*i,t[2]=n*e,t},Fu.transformMat4=function(t,e,r){var n=e[0],i=e[1],a=e[2],s=r[3]*n+r[7]*i+r[11]*a+r[15];return t[0]=(r[0]*n+r[4]*i+r[8]*a+r[12])/(s=s||1),t[1]=(r[1]*n+r[5]*i+r[9]*a+r[13])/s,t[2]=(r[2]*n+r[6]*i+r[10]*a+r[14])/s,t},Fu.transformMat3=function(t,e,r){var n=e[0],i=e[1],a=e[2];return t[0]=n*r[0]+i*r[3]+a*r[6],t[1]=n*r[1]+i*r[4]+a*r[7],t[2]=n*r[2]+i*r[5]+a*r[8],t},Fu.transformQuat=function(t,e,r){var n=r[0],i=r[1],a=r[2],s=e[0],o=e[1],l=e[2],u=i*l-a*o,c=a*s-n*l,h=n*o-i*s,p=i*h-a*c,f=a*u-n*h,d=n*c-i*u,m=2*r[3];return c*=m,h*=m,f*=2,d*=2,t[0]=s+(u*=m)+(p*=2),t[1]=o+c+f,t[2]=l+h+d,t},Fu.rotateX=function(t,e,r,n){var i=[],a=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],a[0]=i[0],a[1]=i[1]*Math.cos(n)-i[2]*Math.sin(n),a[2]=i[1]*Math.sin(n)+i[2]*Math.cos(n),t[0]=a[0]+r[0],t[1]=a[1]+r[1],t[2]=a[2]+r[2],t},Fu.rotateY=function(t,e,r,n){var i=[],a=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],a[0]=i[2]*Math.sin(n)+i[0]*Math.cos(n),a[1]=i[1],a[2]=i[2]*Math.cos(n)-i[0]*Math.sin(n),t[0]=a[0]+r[0],t[1]=a[1]+r[1],t[2]=a[2]+r[2],t},Fu.rotateZ=function(t,e,r,n){var i=[],a=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],a[0]=i[0]*Math.cos(n)-i[1]*Math.sin(n),a[1]=i[0]*Math.sin(n)+i[1]*Math.cos(n),a[2]=i[2],t[0]=a[0]+r[0],t[1]=a[1]+r[1],t[2]=a[2]+r[2],t},Fu.angle=function(t,e){var r=t[0],n=t[1],i=t[2],a=e[0],s=e[1],o=e[2],l=Math.sqrt(r*r+n*n+i*i)*Math.sqrt(a*a+s*s+o*o),u=l&&Hu(t,e)/l;return Math.acos(Math.min(Math.max(u,-1),1))},Fu.zero=function(t){return t[0]=0,t[1]=0,t[2]=0,t},Fu.str=function(t){return "vec3("+t[0]+", "+t[1]+", "+t[2]+")"},Fu.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]},Fu.equals=function(t,e){var r=t[0],n=t[1],i=t[2],a=e[0],s=e[1],o=e[2];return Math.abs(r-a)<=Ou.EPSILON*Math.max(1,Math.abs(r),Math.abs(a))&&Math.abs(n-s)<=Ou.EPSILON*Math.max(1,Math.abs(n),Math.abs(s))&&Math.abs(i-o)<=Ou.EPSILON*Math.max(1,Math.abs(i),Math.abs(o))},Fu.forEach=Fu.sqrLen=Fu.len=Fu.sqrDist=Fu.dist=Fu.div=Fu.mul=Fu.sub=void 0;var Ou=function(t,e){if(t&&t.__esModule)return t;if(null===t||"object"!==Nu(t)&&"function"!=typeof t)return {default:t};var r=Uu(void 0);if(r&&r.has(t))return r.get(t);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if("default"!==a&&Object.prototype.hasOwnProperty.call(t,a)){var s=i?Object.getOwnPropertyDescriptor(t,a):null;s&&(s.get||s.set)?Object.defineProperty(n,a,s):n[a]=t[a];}return n.default=t,r&&r.set(t,n),n}(nu);function Uu(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,r=new WeakMap;return (Uu=function(t){return t?r:e})(t)}function ju(){var t=new Ou.ARRAY_TYPE(3);return Ou.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function qu(t){return Math.hypot(t[0],t[1],t[2])}function $u(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function Gu(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t}function Yu(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t}function Xu(t,e){return Math.hypot(e[0]-t[0],e[1]-t[1],e[2]-t[2])}function Zu(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2];return r*r+n*n+i*i}function Ku(t){var e=t[0],r=t[1],n=t[2];return e*e+r*r+n*n}function Hu(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}Fu.sub=$u,Fu.mul=Gu,Fu.div=Yu,Fu.dist=Xu,Fu.sqrDist=Zu,Fu.len=qu,Fu.sqrLen=Ku;var Wu,Ju=(Wu=ju(),function(t,e,r,n,i,a){var s,o;for(e||(e=3),r||(r=0),o=n?Math.min(n*e+r,t.length):t.length,s=r;s0&&(s=1/Math.sqrt(s)),t[0]=r*s,t[1]=n*s,t[2]=i*s,t[3]=a*s,t},Qu.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]},Qu.cross=function(t,e,r,n){var i=r[0]*n[1]-r[1]*n[0],a=r[0]*n[2]-r[2]*n[0],s=r[0]*n[3]-r[3]*n[0],o=r[1]*n[2]-r[2]*n[1],l=r[1]*n[3]-r[3]*n[1],u=r[2]*n[3]-r[3]*n[2],c=e[0],h=e[1],p=e[2],f=e[3];return t[0]=h*u-p*l+f*o,t[1]=-c*u+p*s-f*a,t[2]=c*l-h*s+f*i,t[3]=-c*o+h*a-p*i,t},Qu.lerp=function(t,e,r,n){var i=e[0],a=e[1],s=e[2],o=e[3];return t[0]=i+n*(r[0]-i),t[1]=a+n*(r[1]-a),t[2]=s+n*(r[2]-s),t[3]=o+n*(r[3]-o),t},Qu.random=function(t,e){var r,n,i,a,s,o;e=e||1;do{s=(r=2*ec.RANDOM()-1)*r+(n=2*ec.RANDOM()-1)*n;}while(s>=1);do{o=(i=2*ec.RANDOM()-1)*i+(a=2*ec.RANDOM()-1)*a;}while(o>=1);var l=Math.sqrt((1-s)/o);return t[0]=e*r,t[1]=e*n,t[2]=e*i*l,t[3]=e*a*l,t},Qu.transformMat4=function(t,e,r){var n=e[0],i=e[1],a=e[2],s=e[3];return t[0]=r[0]*n+r[4]*i+r[8]*a+r[12]*s,t[1]=r[1]*n+r[5]*i+r[9]*a+r[13]*s,t[2]=r[2]*n+r[6]*i+r[10]*a+r[14]*s,t[3]=r[3]*n+r[7]*i+r[11]*a+r[15]*s,t},Qu.transformQuat=function(t,e,r){var n=e[0],i=e[1],a=e[2],s=r[0],o=r[1],l=r[2],u=r[3],c=u*n+o*a-l*i,h=u*i+l*n-s*a,p=u*a+s*i-o*n,f=-s*n-o*i-l*a;return t[0]=c*u+f*-s+h*-l-p*-o,t[1]=h*u+f*-o+p*-s-c*-l,t[2]=p*u+f*-l+c*-o-h*-s,t[3]=e[3],t},Qu.zero=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t},Qu.str=function(t){return "vec4("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"},Qu.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]},Qu.equals=function(t,e){var r=t[0],n=t[1],i=t[2],a=t[3],s=e[0],o=e[1],l=e[2],u=e[3];return Math.abs(r-s)<=ec.EPSILON*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(n-o)<=ec.EPSILON*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(i-l)<=ec.EPSILON*Math.max(1,Math.abs(i),Math.abs(l))&&Math.abs(a-u)<=ec.EPSILON*Math.max(1,Math.abs(a),Math.abs(u))},Qu.forEach=Qu.sqrLen=Qu.len=Qu.sqrDist=Qu.dist=Qu.div=Qu.mul=Qu.sub=void 0;var ec=function(t,e){if(t&&t.__esModule)return t;if(null===t||"object"!==tc(t)&&"function"!=typeof t)return {default:t};var r=rc(void 0);if(r&&r.has(t))return r.get(t);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if("default"!==a&&Object.prototype.hasOwnProperty.call(t,a)){var s=i?Object.getOwnPropertyDescriptor(t,a):null;s&&(s.get||s.set)?Object.defineProperty(n,a,s):n[a]=t[a];}return n.default=t,r&&r.set(t,n),n}(nu);function rc(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,r=new WeakMap;return (rc=function(t){return t?r:e})(t)}function nc(){var t=new ec.ARRAY_TYPE(4);return ec.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function ic(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t}function ac(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t[3]=e[3]*r[3],t}function sc(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t[3]=e[3]/r[3],t}function oc(t,e){return Math.hypot(e[0]-t[0],e[1]-t[1],e[2]-t[2],e[3]-t[3])}function lc(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2],a=e[3]-t[3];return r*r+n*n+i*i+a*a}function uc(t){return Math.hypot(t[0],t[1],t[2],t[3])}function cc(t){var e=t[0],r=t[1],n=t[2],i=t[3];return e*e+r*r+n*n+i*i}Qu.sub=ic,Qu.mul=ac,Qu.div=sc,Qu.dist=oc,Qu.sqrDist=lc,Qu.len=uc,Qu.sqrLen=cc;var hc=function(){var t=nc();return function(e,r,n,i,a,s){var o,l;for(r||(r=4),n||(n=0),l=i?Math.min(i*r+n,e.length):e.length,o=n;ofc.EPSILON?(t[0]=e[0]/n,t[1]=e[1]/n,t[2]=e[2]/n):(t[0]=1,t[1]=0,t[2]=0),r},Lu.getAngle=function(t,e){var r=kc(t,e);return Math.acos(2*r*r-1)},Lu.multiply=_c,Lu.rotateX=function(t,e,r){r*=.5;var n=e[0],i=e[1],a=e[2],s=e[3],o=Math.sin(r),l=Math.cos(r);return t[0]=n*l+s*o,t[1]=i*l+a*o,t[2]=a*l-i*o,t[3]=s*l-n*o,t},Lu.rotateY=function(t,e,r){r*=.5;var n=e[0],i=e[1],a=e[2],s=e[3],o=Math.sin(r),l=Math.cos(r);return t[0]=n*l-a*o,t[1]=i*l+s*o,t[2]=a*l+n*o,t[3]=s*l-i*o,t},Lu.rotateZ=function(t,e,r){r*=.5;var n=e[0],i=e[1],a=e[2],s=e[3],o=Math.sin(r),l=Math.cos(r);return t[0]=n*l+i*o,t[1]=i*l-n*o,t[2]=a*l+s*o,t[3]=s*l-a*o,t},Lu.calculateW=function(t,e){var r=e[0],n=e[1],i=e[2];return t[0]=r,t[1]=n,t[2]=i,t[3]=Math.sqrt(Math.abs(1-r*r-n*n-i*i)),t},Lu.exp=wc,Lu.ln=Mc,Lu.pow=function(t,e,r){return Mc(t,e),Ic(t,t,r),wc(t,t),t},Lu.slerp=Ac,Lu.random=function(t){var e=fc.RANDOM(),r=fc.RANDOM(),n=fc.RANDOM(),i=Math.sqrt(1-e),a=Math.sqrt(e);return t[0]=i*Math.sin(2*Math.PI*r),t[1]=i*Math.cos(2*Math.PI*r),t[2]=a*Math.sin(2*Math.PI*n),t[3]=a*Math.cos(2*Math.PI*n),t},Lu.invert=function(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],s=r*r+n*n+i*i+a*a,o=s?1/s:0;return t[0]=-r*o,t[1]=-n*o,t[2]=-i*o,t[3]=a*o,t},Lu.conjugate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t},Lu.fromMat3=Sc,Lu.fromEuler=function(t,e,r,n){var i=.5*Math.PI/180;e*=i,r*=i,n*=i;var a=Math.sin(e),s=Math.cos(e),o=Math.sin(r),l=Math.cos(r),u=Math.sin(n),c=Math.cos(n);return t[0]=a*l*c-s*o*u,t[1]=s*o*c+a*l*u,t[2]=s*l*u-a*o*c,t[3]=s*l*c+a*o*u,t},Lu.str=function(t){return "quat("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"},Lu.setAxes=Lu.sqlerp=Lu.rotationTo=Lu.equals=Lu.exactEquals=Lu.normalize=Lu.sqrLen=Lu.squaredLength=Lu.len=Lu.length=Lu.lerp=Lu.dot=Lu.scale=Lu.mul=Lu.add=Lu.set=Lu.copy=Lu.fromValues=Lu.clone=void 0;var fc=xc(nu),dc=xc(bu),mc=xc(Fu),yc=xc(Qu);function gc(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,r=new WeakMap;return (gc=function(t){return t?r:e})(t)}function xc(t,e){if(!e&&t&&t.__esModule)return t;if(null===t||"object"!==pc(t)&&"function"!=typeof t)return {default:t};var r=gc(e);if(r&&r.has(t))return r.get(t);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if("default"!==a&&Object.prototype.hasOwnProperty.call(t,a)){var s=i?Object.getOwnPropertyDescriptor(t,a):null;s&&(s.get||s.set)?Object.defineProperty(n,a,s):n[a]=t[a];}return n.default=t,r&&r.set(t,n),n}function vc(){var t=new fc.ARRAY_TYPE(4);return fc.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function bc(t,e,r){r*=.5;var n=Math.sin(r);return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=Math.cos(r),t}function _c(t,e,r){var n=e[0],i=e[1],a=e[2],s=e[3],o=r[0],l=r[1],u=r[2],c=r[3];return t[0]=n*c+s*o+i*u-a*l,t[1]=i*c+s*l+a*o-n*u,t[2]=a*c+s*u+n*l-i*o,t[3]=s*c-n*o-i*l-a*u,t}function wc(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],s=Math.sqrt(r*r+n*n+i*i),o=Math.exp(a),l=s>0?o*Math.sin(s)/s:0;return t[0]=r*l,t[1]=n*l,t[2]=i*l,t[3]=o*Math.cos(s),t}function Mc(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],s=Math.sqrt(r*r+n*n+i*i),o=s>0?Math.atan2(s,a)/s:0;return t[0]=r*o,t[1]=n*o,t[2]=i*o,t[3]=.5*Math.log(r*r+n*n+i*i+a*a),t}function Ac(t,e,r,n){var i,a,s,o,l,u=e[0],c=e[1],h=e[2],p=e[3],f=r[0],d=r[1],m=r[2],y=r[3];return (a=u*f+c*d+h*m+p*y)<0&&(a=-a,f=-f,d=-d,m=-m,y=-y),1-a>fc.EPSILON?(i=Math.acos(a),s=Math.sin(i),o=Math.sin((1-n)*i)/s,l=Math.sin(n*i)/s):(o=1-n,l=n),t[0]=o*u+l*f,t[1]=o*c+l*d,t[2]=o*h+l*m,t[3]=o*p+l*y,t}function Sc(t,e){var r,n=e[0]+e[4]+e[8];if(n>0)r=Math.sqrt(n+1),t[3]=.5*r,t[0]=(e[5]-e[7])*(r=.5/r),t[1]=(e[6]-e[2])*r,t[2]=(e[1]-e[3])*r;else {var i=0;e[4]>e[0]&&(i=1),e[8]>e[3*i+i]&&(i=2);var a=(i+1)%3,s=(i+2)%3;r=Math.sqrt(e[3*i+i]-e[3*a+a]-e[3*s+s]+1),t[i]=.5*r,t[3]=(e[3*a+s]-e[3*s+a])*(r=.5/r),t[a]=(e[3*a+i]+e[3*i+a])*r,t[s]=(e[3*s+i]+e[3*i+s])*r;}return t}Lu.clone=yc.clone,Lu.fromValues=yc.fromValues,Lu.copy=yc.copy,Lu.set=yc.set,Lu.add=yc.add,Lu.mul=_c;var Ic=yc.scale;Lu.scale=Ic;var kc=yc.dot;Lu.dot=kc,Lu.lerp=yc.lerp;var Pc=yc.length;Lu.length=Pc,Lu.len=Pc;var Ec=yc.squaredLength;Lu.squaredLength=Ec,Lu.sqrLen=Ec;var zc=yc.normalize;Lu.normalize=zc,Lu.exactEquals=yc.exactEquals,Lu.equals=yc.equals;var Tc,Bc,Cc,Rc=(Tc=mc.create(),Bc=mc.fromValues(1,0,0),Cc=mc.fromValues(0,1,0),function(t,e,r){var n=mc.dot(e,r);return n<-.999999?(mc.cross(Tc,Bc,e),mc.len(Tc)<1e-6&&mc.cross(Tc,Cc,e),mc.normalize(Tc,Tc),bc(t,Tc,Math.PI),t):n>.999999?(t[0]=0,t[1]=0,t[2]=0,t[3]=1,t):(mc.cross(Tc,e,r),t[0]=Tc[0],t[1]=Tc[1],t[2]=Tc[2],t[3]=1+n,zc(t,t))});Lu.rotationTo=Rc;var Dc,Vc,Lc=(Dc=vc(),Vc=vc(),function(t,e,r,n,i,a){return Ac(Dc,e,i,a),Ac(Vc,r,n,a),Ac(t,Dc,Vc,2*a*(1-a)),t});Lu.sqlerp=Lc;var Fc,Nc=(Fc=dc.create(),function(t,e,r,n){return Fc[0]=r[0],Fc[3]=r[1],Fc[6]=r[2],Fc[1]=n[0],Fc[4]=n[1],Fc[7]=n[2],Fc[2]=-e[0],Fc[5]=-e[1],Fc[8]=-e[2],zc(t,Sc(t,Fc))});Lu.setAxes=Nc;var Oc={};function Uc(t){return Uc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Uc(t)}Object.defineProperty(Oc,"__esModule",{value:!0}),Oc.create=function(){var t=new jc.ARRAY_TYPE(8);return jc.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[4]=0,t[5]=0,t[6]=0,t[7]=0),t[3]=1,t},Oc.clone=function(t){var e=new jc.ARRAY_TYPE(8);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e},Oc.fromValues=function(t,e,r,n,i,a,s,o){var l=new jc.ARRAY_TYPE(8);return l[0]=t,l[1]=e,l[2]=r,l[3]=n,l[4]=i,l[5]=a,l[6]=s,l[7]=o,l},Oc.fromRotationTranslationValues=function(t,e,r,n,i,a,s){var o=new jc.ARRAY_TYPE(8);o[0]=t,o[1]=e,o[2]=r,o[3]=n;var l=.5*i,u=.5*a,c=.5*s;return o[4]=l*n+u*r-c*e,o[5]=u*n+c*t-l*r,o[6]=c*n+l*e-u*t,o[7]=-l*t-u*e-c*r,o},Oc.fromRotationTranslation=Xc,Oc.fromTranslation=function(t,e){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t[4]=.5*e[0],t[5]=.5*e[1],t[6]=.5*e[2],t[7]=0,t},Oc.fromRotation=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=0,t[5]=0,t[6]=0,t[7]=0,t},Oc.fromMat4=function(t,e){var r=qc.create();$c.getRotation(r,e);var n=new jc.ARRAY_TYPE(3);return $c.getTranslation(n,e),Xc(t,r,n),t},Oc.copy=Zc,Oc.identity=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t[6]=0,t[7]=0,t},Oc.set=function(t,e,r,n,i,a,s,o,l){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t[4]=a,t[5]=s,t[6]=o,t[7]=l,t},Oc.getDual=function(t,e){return t[0]=e[4],t[1]=e[5],t[2]=e[6],t[3]=e[7],t},Oc.setDual=function(t,e){return t[4]=e[0],t[5]=e[1],t[6]=e[2],t[7]=e[3],t},Oc.getTranslation=function(t,e){var r=e[4],n=e[5],i=e[6],a=e[7],s=-e[0],o=-e[1],l=-e[2],u=e[3];return t[0]=2*(r*u+a*s+n*l-i*o),t[1]=2*(n*u+a*o+i*s-r*l),t[2]=2*(i*u+a*l+r*o-n*s),t},Oc.translate=function(t,e,r){var n=e[0],i=e[1],a=e[2],s=e[3],o=.5*r[0],l=.5*r[1],u=.5*r[2],c=e[4],h=e[5],p=e[6],f=e[7];return t[0]=n,t[1]=i,t[2]=a,t[3]=s,t[4]=s*o+i*u-a*l+c,t[5]=s*l+a*o-n*u+h,t[6]=s*u+n*l-i*o+p,t[7]=-n*o-i*l-a*u+f,t},Oc.rotateX=function(t,e,r){var n=-e[0],i=-e[1],a=-e[2],s=e[3],o=e[4],l=e[5],u=e[6],c=e[7],h=o*s+c*n+l*a-u*i,p=l*s+c*i+u*n-o*a,f=u*s+c*a+o*i-l*n,d=c*s-o*n-l*i-u*a;return qc.rotateX(t,e,r),t[4]=h*(s=t[3])+d*(n=t[0])+p*(a=t[2])-f*(i=t[1]),t[5]=p*s+d*i+f*n-h*a,t[6]=f*s+d*a+h*i-p*n,t[7]=d*s-h*n-p*i-f*a,t},Oc.rotateY=function(t,e,r){var n=-e[0],i=-e[1],a=-e[2],s=e[3],o=e[4],l=e[5],u=e[6],c=e[7],h=o*s+c*n+l*a-u*i,p=l*s+c*i+u*n-o*a,f=u*s+c*a+o*i-l*n,d=c*s-o*n-l*i-u*a;return qc.rotateY(t,e,r),t[4]=h*(s=t[3])+d*(n=t[0])+p*(a=t[2])-f*(i=t[1]),t[5]=p*s+d*i+f*n-h*a,t[6]=f*s+d*a+h*i-p*n,t[7]=d*s-h*n-p*i-f*a,t},Oc.rotateZ=function(t,e,r){var n=-e[0],i=-e[1],a=-e[2],s=e[3],o=e[4],l=e[5],u=e[6],c=e[7],h=o*s+c*n+l*a-u*i,p=l*s+c*i+u*n-o*a,f=u*s+c*a+o*i-l*n,d=c*s-o*n-l*i-u*a;return qc.rotateZ(t,e,r),t[4]=h*(s=t[3])+d*(n=t[0])+p*(a=t[2])-f*(i=t[1]),t[5]=p*s+d*i+f*n-h*a,t[6]=f*s+d*a+h*i-p*n,t[7]=d*s-h*n-p*i-f*a,t},Oc.rotateByQuatAppend=function(t,e,r){var n=r[0],i=r[1],a=r[2],s=r[3],o=e[0],l=e[1],u=e[2],c=e[3];return t[0]=o*s+c*n+l*a-u*i,t[1]=l*s+c*i+u*n-o*a,t[2]=u*s+c*a+o*i-l*n,t[3]=c*s-o*n-l*i-u*a,t[4]=(o=e[4])*s+(c=e[7])*n+(l=e[5])*a-(u=e[6])*i,t[5]=l*s+c*i+u*n-o*a,t[6]=u*s+c*a+o*i-l*n,t[7]=c*s-o*n-l*i-u*a,t},Oc.rotateByQuatPrepend=function(t,e,r){var n=e[0],i=e[1],a=e[2],s=e[3],o=r[0],l=r[1],u=r[2],c=r[3];return t[0]=n*c+s*o+i*u-a*l,t[1]=i*c+s*l+a*o-n*u,t[2]=a*c+s*u+n*l-i*o,t[3]=s*c-n*o-i*l-a*u,t[4]=n*(c=r[7])+s*(o=r[4])+i*(u=r[6])-a*(l=r[5]),t[5]=i*c+s*l+a*o-n*u,t[6]=a*c+s*u+n*l-i*o,t[7]=s*c-n*o-i*l-a*u,t},Oc.rotateAroundAxis=function(t,e,r,n){if(Math.abs(n)0){r=Math.sqrt(r);var n=e[0]/r,i=e[1]/r,a=e[2]/r,s=e[3]/r,o=e[4],l=e[5],u=e[6],c=e[7],h=n*o+i*l+a*u+s*c;t[0]=n,t[1]=i,t[2]=a,t[3]=s,t[4]=(o-n*h)/r,t[5]=(l-i*h)/r,t[6]=(u-a*h)/r,t[7]=(c-s*h)/r;}return t},Oc.str=function(t){return "quat2("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+")"},Oc.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]},Oc.equals=function(t,e){var r=t[0],n=t[1],i=t[2],a=t[3],s=t[4],o=t[5],l=t[6],u=t[7],c=e[0],h=e[1],p=e[2],f=e[3],d=e[4],m=e[5],y=e[6],g=e[7];return Math.abs(r-c)<=jc.EPSILON*Math.max(1,Math.abs(r),Math.abs(c))&&Math.abs(n-h)<=jc.EPSILON*Math.max(1,Math.abs(n),Math.abs(h))&&Math.abs(i-p)<=jc.EPSILON*Math.max(1,Math.abs(i),Math.abs(p))&&Math.abs(a-f)<=jc.EPSILON*Math.max(1,Math.abs(a),Math.abs(f))&&Math.abs(s-d)<=jc.EPSILON*Math.max(1,Math.abs(s),Math.abs(d))&&Math.abs(o-m)<=jc.EPSILON*Math.max(1,Math.abs(o),Math.abs(m))&&Math.abs(l-y)<=jc.EPSILON*Math.max(1,Math.abs(l),Math.abs(y))&&Math.abs(u-g)<=jc.EPSILON*Math.max(1,Math.abs(u),Math.abs(g))},Oc.sqrLen=Oc.squaredLength=Oc.len=Oc.length=Oc.dot=Oc.mul=Oc.setReal=Oc.getReal=void 0;var jc=Yc(nu),qc=Yc(Lu),$c=Yc(Iu);function Gc(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,r=new WeakMap;return (Gc=function(t){return t?r:e})(t)}function Yc(t,e){if(!e&&t&&t.__esModule)return t;if(null===t||"object"!==Uc(t)&&"function"!=typeof t)return {default:t};var r=Gc(e);if(r&&r.has(t))return r.get(t);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if("default"!==a&&Object.prototype.hasOwnProperty.call(t,a)){var s=i?Object.getOwnPropertyDescriptor(t,a):null;s&&(s.get||s.set)?Object.defineProperty(n,a,s):n[a]=t[a];}return n.default=t,r&&r.set(t,n),n}function Xc(t,e,r){var n=.5*r[0],i=.5*r[1],a=.5*r[2],s=e[0],o=e[1],l=e[2],u=e[3];return t[0]=s,t[1]=o,t[2]=l,t[3]=u,t[4]=n*u+i*l-a*o,t[5]=i*u+a*s-n*l,t[6]=a*u+n*o-i*s,t[7]=-n*s-i*o-a*l,t}function Zc(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t}function Kc(t,e,r){var n=e[0],i=e[1],a=e[2],s=e[3],o=r[4],l=r[5],u=r[6],c=r[7],h=e[4],p=e[5],f=e[6],d=e[7],m=r[0],y=r[1],g=r[2],x=r[3];return t[0]=n*x+s*m+i*g-a*y,t[1]=i*x+s*y+a*m-n*g,t[2]=a*x+s*g+n*y-i*m,t[3]=s*x-n*m-i*y-a*g,t[4]=n*c+s*o+i*u-a*l+h*x+d*m+p*g-f*y,t[5]=i*c+s*l+a*o-n*u+p*x+d*y+f*m-h*g,t[6]=a*c+s*u+n*l-i*o+f*x+d*g+h*y-p*m,t[7]=s*c-n*o-i*l-a*u+d*x-h*m-p*y-f*g,t}Oc.getReal=qc.copy,Oc.setReal=qc.copy,Oc.mul=Kc;var Hc=qc.dot;Oc.dot=Hc;var Wc=qc.length;Oc.length=Wc,Oc.len=Wc;var Jc=qc.squaredLength;Oc.squaredLength=Jc,Oc.sqrLen=Jc;var Qc={};function th(t){return th="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},th(t)}Object.defineProperty(Qc,"__esModule",{value:!0}),Qc.create=nh,Qc.clone=function(t){var e=new eh.ARRAY_TYPE(2);return e[0]=t[0],e[1]=t[1],e},Qc.fromValues=function(t,e){var r=new eh.ARRAY_TYPE(2);return r[0]=t,r[1]=e,r},Qc.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t},Qc.set=function(t,e,r){return t[0]=e,t[1]=r,t},Qc.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t},Qc.subtract=ih,Qc.multiply=ah,Qc.divide=sh,Qc.ceil=function(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t},Qc.floor=function(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t},Qc.min=function(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t},Qc.max=function(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t},Qc.round=function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t},Qc.scale=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t},Qc.scaleAndAdd=function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t},Qc.distance=oh,Qc.squaredDistance=lh,Qc.length=uh,Qc.squaredLength=ch,Qc.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t},Qc.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t},Qc.normalize=function(t,e){var r=e[0],n=e[1],i=r*r+n*n;return i>0&&(i=1/Math.sqrt(i)),t[0]=e[0]*i,t[1]=e[1]*i,t},Qc.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]},Qc.cross=function(t,e,r){var n=e[0]*r[1]-e[1]*r[0];return t[0]=t[1]=0,t[2]=n,t},Qc.lerp=function(t,e,r,n){var i=e[0],a=e[1];return t[0]=i+n*(r[0]-i),t[1]=a+n*(r[1]-a),t},Qc.random=function(t,e){e=e||1;var r=2*eh.RANDOM()*Math.PI;return t[0]=Math.cos(r)*e,t[1]=Math.sin(r)*e,t},Qc.transformMat2=function(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[2]*i,t[1]=r[1]*n+r[3]*i,t},Qc.transformMat2d=function(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[2]*i+r[4],t[1]=r[1]*n+r[3]*i+r[5],t},Qc.transformMat3=function(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[3]*i+r[6],t[1]=r[1]*n+r[4]*i+r[7],t},Qc.transformMat4=function(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[4]*i+r[12],t[1]=r[1]*n+r[5]*i+r[13],t},Qc.rotate=function(t,e,r,n){var i=e[0]-r[0],a=e[1]-r[1],s=Math.sin(n),o=Math.cos(n);return t[0]=i*o-a*s+r[0],t[1]=i*s+a*o+r[1],t},Qc.angle=function(t,e){var r=t[0],n=t[1],i=e[0],a=e[1],s=Math.sqrt(r*r+n*n)*Math.sqrt(i*i+a*a);return Math.acos(Math.min(Math.max(s&&(r*i+n*a)/s,-1),1))},Qc.zero=function(t){return t[0]=0,t[1]=0,t},Qc.str=function(t){return "vec2("+t[0]+", "+t[1]+")"},Qc.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]},Qc.equals=function(t,e){var r=t[0],n=t[1],i=e[0],a=e[1];return Math.abs(r-i)<=eh.EPSILON*Math.max(1,Math.abs(r),Math.abs(i))&&Math.abs(n-a)<=eh.EPSILON*Math.max(1,Math.abs(n),Math.abs(a))},Qc.forEach=Qc.sqrLen=Qc.sqrDist=Qc.dist=Qc.div=Qc.mul=Qc.sub=Qc.len=void 0;var eh=function(t,e){if(t&&t.__esModule)return t;if(null===t||"object"!==th(t)&&"function"!=typeof t)return {default:t};var r=rh(void 0);if(r&&r.has(t))return r.get(t);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if("default"!==a&&Object.prototype.hasOwnProperty.call(t,a)){var s=i?Object.getOwnPropertyDescriptor(t,a):null;s&&(s.get||s.set)?Object.defineProperty(n,a,s):n[a]=t[a];}return n.default=t,r&&r.set(t,n),n}(nu);function rh(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,r=new WeakMap;return (rh=function(t){return t?r:e})(t)}function nh(){var t=new eh.ARRAY_TYPE(2);return eh.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0),t}function ih(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t}function ah(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t}function sh(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t}function oh(t,e){return Math.hypot(e[0]-t[0],e[1]-t[1])}function lh(t,e){var r=e[0]-t[0],n=e[1]-t[1];return r*r+n*n}function uh(t){return Math.hypot(t[0],t[1])}function ch(t){var e=t[0],r=t[1];return e*e+r*r}Qc.len=uh,Qc.sub=ih,Qc.mul=ah,Qc.div=sh,Qc.dist=oh,Qc.sqrDist=lh,Qc.sqrLen=ch;var hh=function(){var t=nh();return function(e,r,n,i,a,s){var o,l;for(r||(r=2),n||(n=0),l=i?Math.min(i*r+n,e.length):e.length,o=n;o=0;if(0===s)return 0;s!==r.length&&(n=!1);}return n?2:1}function Eh(t,e){for(const r of t.projections){const n=kh(e,t.points[0],r.axis);if(r.projection[1]n[1])return 0}return 1}function zh(e,r){let n=0;const i=[0,0,0,0];for(let a=0;a=0&&n++;return n}class Th{constructor(e,r){this.points=e||new Array(8).fill([0,0,0]),this.planes=r||new Array(6).fill([0,0,0,0]),this.bounds=Bh.fromPoints(this.points),this.projections=[],this.frustumEdges=[t.N.sub([],this.points[2],this.points[3]),t.N.sub([],this.points[0],this.points[3]),t.N.sub([],this.points[4],this.points[0]),t.N.sub([],this.points[5],this.points[1]),t.N.sub([],this.points[6],this.points[2]),t.N.sub([],this.points[7],this.points[3])];for(const t of this.frustumEdges){const e=[0,-t[2],t[1]],r=[t[2],0,-t[0]];this.projections.push({axis:e,projection:kh(this.points,this.points[0],e)}),this.projections.push({axis:r,projection:kh(this.points,this.points[0],r)});}}static fromInvProjectionMatrix(e,r,n,i){const a=Math.pow(2,n),s=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map((n=>{const s=t.a7.transformMat4([],n,e),o=1/s[3]/r*a;return t.a7.mul(s,s,[o,o,i?1/s[3]:o,o])})),o=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((e=>{const r=t.N.sub([],s[e[0]],s[e[1]]),n=t.N.sub([],s[e[2]],s[e[1]]),i=t.N.normalize([],t.N.cross([],r,n)),a=-t.N.dot(i,s[e[1]]);return i.concat(a)})),l=[];for(let t=0;to[1]||o[0]>s[1])return 0}return 1}}class Bh{static fromPoints(e){const r=[1/0,1/0,1/0],n=[-1/0,-1/0,-1/0];for(const i of e)t.N.min(r,r,i),t.N.max(n,n,i);return new Bh(r,n)}static fromTileIdAndHeight(t,e,r){const n=1<t.max[e]||t.min[e]>this.max[e])return !1;return !0}intersectsAabbXY(t){return !(this.min[0]>t.max[0]||t.min[0]>this.max[0]||this.min[1]>t.max[1]||t.min[1]>this.max[1])}encapsulate(t){for(let e=0;e<3;e++)this.min[e]=Math.min(this.min[e],t.min[e]),this.max[e]=Math.max(this.max[e],t.max[e]);}encapsulatePoint(t){for(let e=0;e<3;e++)this.min[e]=Math.min(this.min[e],t[e]),this.max[e]=Math.max(this.max[e],t[e]);}closestPoint(t){return [Math.max(Math.min(this.max[0],t[0]),this.min[0]),Math.max(Math.min(this.max[1],t[1]),this.min[1]),Math.max(Math.min(this.max[2],t[2]),this.min[2])]}}ra(Bh,"Aabb");const Ch=cs([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_uv",components:2}]),{members:Rh}=Ch,Dh=cs([{name:"a_pos_3",components:3,type:"Int16"}]);var Vh=cs([{name:"a_pos",type:"Int16",components:2}]);function Lh(t){return t*jo/Jo}const Fh=[new Bh([Zo,Zo,Zo],[Ko,Ko,Ko]),new Bh([Zo,Zo,Zo],[0,0,Ko]),new Bh([0,Zo,Zo],[Ko,0,Ko]),new Bh([Zo,0,Zo],[0,Ko,Ko]),new Bh([0,0,Zo],[Ko,Ko,Ko])];function Nh(e,r,n,i=!0){const a=t.N.scale([],e._camera.position,e.worldSize),s=[r,n,1,1];t.a7.transformMat4(s,s,e.pixelMatrixInverse),t.a7.scale(s,s,1/s[3]);const o=t.N.sub([],s,a),l=t.N.normalize([],o),u=e.globeMatrix,c=[u[12],u[13],u[14]],h=t.N.sub([],c,a),p=t.N.length(h),f=t.N.normalize([],h),d=e.worldSize/(2*Math.PI),m=t.N.dot(f,l),y=Math.asin(d/p);if(y1?null:function(t,e,r,n){const i=Math.sin(r);return t*(Math.sin((1-n)*r)/i)+e*(Math.sin(n*r)/i)}(t.a[e],t.b[e],t.angle,I(r,0,1))+t.center[e]}function jh(t){if(t.z<=1)return Fh[t.z+2*t.y+t.x];const e=Xh(Yh(t));return Bh.fromPoints(e)}function qh(e,r,n){return t.N.scale(e,e,1-n),t.N.scaleAndAdd(e,e,r,n)}function $h(e,r,n){for(const i of e)t.N.transformMat4(i,i,r),t.N.scale(i,i,n);}function Gh(e,r,n,i){const a=r/e.worldSize,s=e.globeMatrix;if(n.z<=1){const t=jh(n).getCorners();return $h(t,s,a),Bh.fromPoints(t)}const o=Yh(n,i),l=Xh(o,jo+Lh(e._tileCoverLift));$h(l,s,a);const u=Number.MAX_VALUE,c=[-u,-u,-u],h=[u,u,u];if(o.contains(e.center)){for(const e of l)t.N.min(h,h,e),t.N.max(c,c,e);c[2]=0;const r=e.point,n=[r.x*a,r.y*a,0];return t.N.min(h,h,n),t.N.max(c,c,n),new Bh(h,c)}if(e._tileCoverLift>0){for(const e of l)t.N.min(h,h,e),t.N.max(c,c,e);return new Bh(h,c)}const p=[s[12]*a,s[13]*a,s[14]*a],f=o.getCenter(),d=I(e.center.lat,-xl,xl),m=I(f.lat,-xl,xl),y=pl(e.center.lng),g=fl(d);let x=y-pl(f.lng);const v=g-fl(m);x>.5?x-=1:x<-.5&&(x+=1);let _=0;if(Math.abs(x)>Math.abs(v))_=x>=0?1:3;else {_=v>=0?0:2;const e=[s[4]*a,s[5]*a,s[6]*a],r=-Math.sin(b(v>=0?o.getSouth():o.getNorth()))*jo;t.N.scaleAndAdd(p,p,e,r);}const w=l[_],M=l[(_+1)%4],A=new Oh(w,M,p),S=[Uh(A,0)||w[0],Uh(A,1)||w[1],Uh(A,2)||w[2]],k=rp(e.zoom);if(k>0){const i=function({x:t,y:e,z:r},n,i,a,s){const o=1/(1<.5?p=-1:f<-.5&&(p=1),l=((l+p)*n-(a*=n))*i+a,u=((u+p)*n-a)*i+a,c=(c*n-(s*=n))*i+s,h=(h*n-s)*i+s,[[l,h,0],[u,h,0],[u,c,0],[l,c,0]]}(n,r,e._pixelsPerMercatorPixel,y,g);for(let t=0;tMath.PI/2*1.01}const ap=b(85),sp=Math.cos(ap),op=Math.sin(ap),lp=t.a6.create(),up=t=>{const e=[];return "map"===t.paint.get("circle-pitch-alignment")&&e.push("PITCH_WITH_MAP"),"map"===t.paint.get("circle-pitch-scale")&&e.push("SCALE_WITH_MAP"),e};function cp(e,r,n,i,a,s,o,l,u){if(s&&e.queryGeometry.isAboveHorizon)return !1;s&&(u*=e.pixelToTileUnitsFactor);const c=e.tileID.canonical,h=n.projection.upVectorScale(c,n.center.lat,n.worldSize).metersToTile;for(const p of r)for(const r of p){const p=r.add(l),f=a&&n.elevation?n.elevation.exaggeration()*a.getElevationAt(p.x,p.y,!0):0,d=n.projection.projectTilePoint(p.x,p.y,c);if(f>0){const t=n.projection.upVector(c,p.x,p.y);d.x+=t[0]*h*f,d.y+=t[1]*h*f,d.z+=t[2]*h*f;}const m=s?p:hp(d.x,d.y,d.z,i),y=s?e.tilespaceRays.map((t=>dp(t,f))):e.queryGeometry.screenGeometry,g=t.a7.transformMat4([],[d.x,d.y,d.z,1],i);if(!o&&s?u*=g[3]/n.cameraToCenterDistance:o&&!s&&(u*=n.cameraToCenterDistance/g[3]),s){const t=yl((r.y/Tr+c.y)/(1<t.width||i.height>t.height||r.x>t.width-i.width||r.y>t.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>e.width||i.height>e.height||n.x>e.width-i.width||n.y>e.height-i.height)throw new RangeError("out of range destination coordinates for image copy");const o=t.data,l=e.data,u=4===a&&s;for(let s=0;s{e[t.evaluationKey]=a;const s=t.expression.evaluate(e);s&&(i.data[r+n+0]=Math.floor(255*s.r/s.a),i.data[r+n+1]=Math.floor(255*s.g/s.a),i.data[r+n+2]=Math.floor(255*s.b/s.a),i.data[r+n+3]=Math.floor(255*s.a));};if(t.clips)for(let e=0,i=0;e80*r){n=a=t[0],i=s=t[1];for(var d=r;da&&(a=o),l>s&&(s=l);u=0!==(u=Math.max(a-n,s-i))?32767/u:0;}return Cp(p,f,r,n,i,u,0),f}function Tp(t,e,r,n,i){var a,s;if(i===ef(t,e,r,n)>0)for(a=e;a=e;a-=n)s=Jp(a,t[a],t[a+1],s);return s&&Yp(s,s.next)&&(Qp(s),s=s.next),s}function Bp(t,e){if(!t)return t;e||(e=t);var r,n=t;do{if(r=!1,n.steiner||!Yp(n,n.next)&&0!==Gp(n.prev,n,n.next))n=n.next;else {if(Qp(n),(n=e=n.prev)===n.next)break;r=!0;}}while(r||n!==e);return e}function Cp(t,e,r,n,i,a,s){if(t){!s&&a&&function(t,e,r,n){var i=t;do{0===i.z&&(i.z=Up(i.x,i.y,e,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){var e,r,n,i,a,s,o,l,u=1;do{for(r=t,t=null,a=null,s=0;r;){for(s++,n=r,o=0,e=0;e0||l>0&&n;)0!==o&&(0===l||!n||r.z<=n.z)?(i=r,r=r.nextZ,o--):(i=n,n=n.nextZ,l--),a?a.nextZ=i:t=i,i.prevZ=a,a=i;r=n;}a.nextZ=null,u*=2;}while(s>1)}(i);}(t,n,i,a);for(var o,l,u=t;t.prev!==t.next;)if(o=t.prev,l=t.next,a?Dp(t,n,i,a):Rp(t))e.push(o.i/r|0),e.push(t.i/r|0),e.push(l.i/r|0),Qp(t),t=l.next,u=l.next;else if((t=l)===u){s?1===s?Cp(t=Vp(Bp(t),e,r),e,r,n,i,a,2):2===s&&Lp(t,e,r,n,i,a):Cp(Bp(t),e,r,n,i,a,1);break}}}function Rp(t){var e=t.prev,r=t,n=t.next;if(Gp(e,r,n)>=0)return !1;for(var i=e.x,a=r.x,s=n.x,o=e.y,l=r.y,u=n.y,c=ia?i>s?i:s:a>s?a:s,f=o>l?o>u?o:u:l>u?l:u,d=n.next;d!==e;){if(d.x>=c&&d.x<=p&&d.y>=h&&d.y<=f&&qp(i,o,a,l,s,u,d.x,d.y)&&Gp(d.prev,d,d.next)>=0)return !1;d=d.next;}return !0}function Dp(t,e,r,n){var i=t.prev,a=t,s=t.next;if(Gp(i,a,s)>=0)return !1;for(var o=i.x,l=a.x,u=s.x,c=i.y,h=a.y,p=s.y,f=ol?o>u?o:u:l>u?l:u,y=c>h?c>p?c:p:h>p?h:p,g=Up(f,d,e,r,n),x=Up(m,y,e,r,n),v=t.prevZ,b=t.nextZ;v&&v.z>=g&&b&&b.z<=x;){if(v.x>=f&&v.x<=m&&v.y>=d&&v.y<=y&&v!==i&&v!==s&&qp(o,c,l,h,u,p,v.x,v.y)&&Gp(v.prev,v,v.next)>=0)return !1;if(v=v.prevZ,b.x>=f&&b.x<=m&&b.y>=d&&b.y<=y&&b!==i&&b!==s&&qp(o,c,l,h,u,p,b.x,b.y)&&Gp(b.prev,b,b.next)>=0)return !1;b=b.nextZ;}for(;v&&v.z>=g;){if(v.x>=f&&v.x<=m&&v.y>=d&&v.y<=y&&v!==i&&v!==s&&qp(o,c,l,h,u,p,v.x,v.y)&&Gp(v.prev,v,v.next)>=0)return !1;v=v.prevZ;}for(;b&&b.z<=x;){if(b.x>=f&&b.x<=m&&b.y>=d&&b.y<=y&&b!==i&&b!==s&&qp(o,c,l,h,u,p,b.x,b.y)&&Gp(b.prev,b,b.next)>=0)return !1;b=b.nextZ;}return !0}function Vp(t,e,r){var n=t;do{var i=n.prev,a=n.next.next;!Yp(i,a)&&Xp(i,n,n.next,a)&&Hp(i,a)&&Hp(a,i)&&(e.push(i.i/r|0),e.push(n.i/r|0),e.push(a.i/r|0),Qp(n),Qp(n.next),n=t=a),n=n.next;}while(n!==t);return Bp(n)}function Lp(t,e,r,n,i,a){var s=t;do{for(var o=s.next.next;o!==s.prev;){if(s.i!==o.i&&$p(s,o)){var l=Wp(s,o);return s=Bp(s,s.next),l=Bp(l,l.next),Cp(s,e,r,n,i,a,0),void Cp(l,e,r,n,i,a,0)}o=o.next;}s=s.next;}while(s!==t)}function Fp(t,e){return t.x-e.x}function Np(t,e){var r=function(t,e){var r,n=e,i=t.x,a=t.y,s=-1/0;do{if(a<=n.y&&a>=n.next.y&&n.next.y!==n.y){var o=n.x+(a-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(o<=i&&o>s&&(s=o,r=n.x=n.x&&n.x>=c&&i!==n.x&&qp(ar.x||n.x===r.x&&Op(r,n)))&&(r=n,p=l)),n=n.next;}while(n!==u);return r}(t,e);if(!r)return e;var n=Wp(r,t);return Bp(n,n.next),Bp(r,r.next)}function Op(t,e){return Gp(t.prev,t,e.prev)<0&&Gp(e.next,t,t.next)<0}function Up(t,e,r,n,i){return (t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function jp(t){var e=t,r=t;do{(e.x=(t-s)*(a-o)&&(t-s)*(n-o)>=(r-s)*(e-o)&&(r-s)*(a-o)>=(i-s)*(n-o)}function $p(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&Xp(r,r.next,t,e))return !0;r=r.next;}while(r!==t);return !1}(t,e)&&(Hp(t,e)&&Hp(e,t)&&function(t,e){var r=t,n=!1,i=(t.x+e.x)/2,a=(t.y+e.y)/2;do{r.y>a!=r.next.y>a&&r.next.y!==r.y&&i<(r.next.x-r.x)*(a-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next;}while(r!==t);return n}(t,e)&&(Gp(t.prev,t,e.prev)||Gp(t,e.prev,e))||Yp(t,e)&&Gp(t.prev,t,t.next)>0&&Gp(e.prev,e,e.next)>0)}function Gp(t,e,r){return (e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function Yp(t,e){return t.x===e.x&&t.y===e.y}function Xp(t,e,r,n){var i=Kp(Gp(t,e,r)),a=Kp(Gp(t,e,n)),s=Kp(Gp(r,n,t)),o=Kp(Gp(r,n,e));return i!==a&&s!==o||!(0!==i||!Zp(t,r,e))||!(0!==a||!Zp(t,n,e))||!(0!==s||!Zp(r,t,n))||!(0!==o||!Zp(r,e,n))}function Zp(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function Kp(t){return t>0?1:t<0?-1:0}function Hp(t,e){return Gp(t.prev,t,t.next)<0?Gp(t,e,t.next)>=0&&Gp(t,t.prev,e)>=0:Gp(t,e,t.prev)<0||Gp(t,t.next,e)<0}function Wp(t,e){var r=new tf(t.i,t.x,t.y),n=new tf(e.i,e.x,e.y),i=t.next,a=e.prev;return t.next=e,e.prev=t,r.next=i,i.prev=r,n.next=r,r.prev=n,a.next=n,n.prev=a,n}function Jp(t,e,r,n){var i=new tf(t,e,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Qp(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ);}function tf(t,e,r){this.i=t,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1;}function ef(t,e,r,n){for(var i=0,a=e,s=r-n;a0&&r.holes.push(n+=t[i-1].length);}return r};var rf=h(Ep.exports);function nf(t,e){const r=t.length;if(r<=1)return [t];const n=[];let i,a;for(let e=0;e1)for(let t=0;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new ps,this.indexArray=new Es,this.indexArray2=new As,this.programConfigurations=new Vo(t.layers,t.zoom),this.segments=new eo,this.segments2=new eo,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.projection=t.projection;}populate(t,e,r,n){this.hasPattern=sf("fill",this.layers,e);const i=this.layers[0].layout.get("fill-sort-key"),a=[];for(const{feature:s,id:o,index:l,sourceLayerIndex:u}of t){const t=this.layers[0]._featureFilter.needGeometry,c=Bl(s,t);if(!this.layers[0]._featureFilter.filter(new Pa(this.zoom),c,r))continue;const h=i?i.evaluate(c,{},r,e.availableImages):void 0,p={id:o,properties:s.properties,type:s.type,sourceLayerIndex:u,index:l,geometry:t?c.geometry:Tl(s,r,n),patterns:{},sortKey:h};a.push(p);}i&&a.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of a){const{geometry:i,index:a,sourceLayerIndex:s}=n;if(this.hasPattern){const t=of("fill",this.layers,n,this.zoom,e);this.patternFeatures.push(t);}else this.addFeature(n,i,a,r,{},e.availableImages,e.brightness);e.featureIndex.insert(t[a].feature,i,a,s,this.index);}}update(t,e,r,n,i){const a=0!==Object.keys(t).length;a&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,a?this.stateDependentLayers:this.layers,r,n,i);}addFeatures(t,e,r,n,i,a){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,r,n,a);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Pp),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy());}addFeature(t,e,r,n,i,a=[],s){for(const t of nf(e,500)){let e=0;for(const r of t)e+=r.length;const r=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray),n=r.vertexLength,i=[],a=[];for(const e of t){if(0===e.length)continue;e!==t[0]&&a.push(i.length/2);const r=this.segments2.prepareSegment(e.length,this.layoutVertexArray,this.indexArray2),n=r.vertexLength;this.layoutVertexArray.emplaceBack(e[0].x,e[0].y),this.indexArray2.emplaceBack(n+e.length-1,n),i.push(e[0].x),i.push(e[0].y);for(let t=1;t>3;}if(i--,1===n||2===n)a+=t.readSVarint(),s+=t.readSVarint(),1===n&&(e&&o.push(e),e=[]),e.push(new xf(a,s));else {if(7!==n)throw new Error("unknown command "+n);e&&e.push(e[0].clone());}}return e&&o.push(e),o},bf.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,r=1,n=0,i=0,a=0,s=1/0,o=-1/0,l=1/0,u=-1/0;t.pos>3;}if(n--,1===r||2===r)(i+=t.readSVarint())o&&(o=i),(a+=t.readSVarint())u&&(u=a);else if(7!==r)throw new Error("unknown command "+r)}return [s,l,o,u]},bf.prototype.toGeoJSON=function(t,e,r){var n,i,a=this.extent*Math.pow(2,r),s=this.extent*t,o=this.extent*e,l=this.loadGeometry(),u=bf.types[this.type];function c(t){for(var e=0;e>3;e=1===n?t.readString():2===n?t.readFloat():3===n?t.readDouble():4===n?t.readVarint64():5===n?t.readVarint():6===n?t.readSVarint():7===n?t.readBoolean():null;}return e}(r));}Sf.prototype.feature=function(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];var e=this._pbf.readVarint()+this._pbf.pos;return new Mf(this._pbf,e,this.extent,this._keys,this._values)};var kf=Af;function Pf(t,e,r){if(3===t){var n=new kf(r,r.readVarint()+r.pos);n.length&&(e[n.name]=n);}}var Ef=gf.VectorTile=function(t,e){this.layers=t.readFields(Pf,{},e);},zf=gf.VectorTileFeature=vf;function Tf(t,e,r,n){const i=[],a=0===n?(t,e,r,n,i,a)=>{t.push(new g(a,r+(a-e)/(n-e)*(i-r)));}:(t,e,r,n,i,a)=>{t.push(new g(e+(a-r)/(i-r)*(n-e),a));};for(const s of t){const t=[];for(const i of s){if(i.length<=2)continue;const s=[];for(let t=0;te&&a(s,o,l,u,c,e):h>r?p=e&&a(s,o,l,u,c,e),p>r&&h<=r&&a(s,o,l,u,c,r);}let o=i[i.length-1];const l=0===n?o.x:o.y;l>=e&&l<=r&&s.push(o),s.length&&(o=s[s.length-1],s[0].x===o.x&&s[0].y===o.y||s.push(s[0]),t.push(s));}t.length&&i.push(t);}return i}function Bf(t,e){return t.x-e.x||t.y-e.y}function Cf(t,e){return 0===Bf(t.min,e.min)&&0===Bf(t.max,e.max)}function Rf(t,e){return !(t.min.x>e.max.x||t.max.xe.max.y||t.max.ynew g(t.x*a.x*Tr*o-s.x*Tr,t.y*a.y*Tr*o-s.y*Tr)));}return Lf(r,i,t.indices,0,t.indices.length,0,0)}gf.VectorTileLayer=Af;class Nf{constructor(t){this.size=t,this.minimums=[],this.maximums=[],this.leaves=[];}getElevation(t,e){const r=this.toIdx(t,e);return {min:this.minimums[r],max:this.maximums[r]}}isLeaf(t,e){return this.leaves[this.toIdx(t,e)]}toIdx(t,e){return e*this.size+t}}function Of(t,e,r,n){let i=0,a=Number.MAX_VALUE;for(let s=0;s<3;s++)if(Math.abs(n[s])<1e-15){if(r[s]e[s])return null}else {const o=1/n[s];let l=(t[s]-r[s])*o,u=(e[s]-r[s])*o;if(l>u){const t=l;l=u,u=t;}if(l>i&&(i=l),ua)return null}return i}function Uf(t,e,r,n,i,a,s,o,l,u,c){const h=n-t,p=i-e,f=a-r,d=s-t,m=o-e,y=l-r,g=c[1]*y-c[2]*m,x=c[2]*d-c[0]*y,v=c[0]*m-c[1]*d,b=h*g+p*x+f*v;if(Math.abs(b)<1e-15)return null;const _=1/b,w=u[0]-t,M=u[1]-e,A=u[2]-r,S=(w*g+M*x+A*v)*_;if(S<0||S>1)return null;const I=M*f-A*p,k=A*h-w*f,P=w*p-M*h,E=(c[0]*I+c[1]*k+c[2]*P)*_;return E<0||S+E>1?null:(d*I+m*k+y*P)*_}function jf(t,e,r){return (t-e)/(r-e)}function qf(t,e,r,n,i,a,s,o,l){const u=1<{const a=n?1:0,s=(t+1)*r-a,o=e*r,l=(e+1)*r-a;i[0]=t*r,i[1]=o,i[2]=s,i[3]=l;};let s=new Nf(n);const o=[];for(let e=0;e=1;n/=2){const t=r[r.length-1];s=new Nf(n);for(let e=0;e0;){const{idx:l,t:d,nodex:m,nodey:y,depth:g}=f.pop();if(this.leaves[l]){qf(m,y,g,e,r,n,i,h,p);const l=1<=e[2])return d}continue}let x=0;for(let t=0;t=u[c[n]]&&(c.splice(n,0,t),r=!0);r||(c[x]=t),x++;}}for(let t=0;t=this.dim+1||e<-1||e>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return (e+1)*this.stride+(t+1)}static pack(t,e){const r=[0,0,0,0],n=Hf.getUnpackVector(e);let i=Math.floor((t+n[3])/n[2]);return r[2]=i%256,i=Math.floor(i/256),r[1]=i%256,i=Math.floor(i/256),r[0]=i,r}getPixels(){return new _p({width:this.stride,height:this.stride},this.pixels)}backfillBorder(t,e,r){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let n=e*this.dim,i=e*this.dim+this.dim,a=r*this.dim,s=r*this.dim+this.dim;switch(e){case-1:n=i-1;break;case 1:i=n+1;}switch(r){case-1:a=s-1;break;case 1:s=a+1;}const o=-e*this.dim,l=-r*this.dim;for(let e=a;et.max.x&&(t.max.x=e.x,n=!0),e.yt.max.y&&(t.max.y=e.y,n=!0),((0===e.x||e.x===Tr)&&e.x===r.x)!=((0===e.y||e.y===Tr)&&e.y===r.y)&&this.processBorderOverlap(e,r),n&&this.checkBorderIntersection(e,r);}checkBorderIntersection(t,e){e.x<0!=t.x<0&&this.addBorderIntersection(0,ue(e.y,t.y,(0-e.x)/(t.x-e.x))),e.x>Tr!=t.x>Tr&&this.addBorderIntersection(1,ue(e.y,t.y,(Tr-e.x)/(t.x-e.x))),e.y<0!=t.y<0&&this.addBorderIntersection(2,ue(e.x,t.x,(0-e.y)/(t.y-e.y))),e.y>Tr!=t.y>Tr&&this.addBorderIntersection(3,ue(e.x,t.x,(Tr-e.y)/(t.y-e.y)));}addBorderIntersection(t,e){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const r=this.borders[t];er[1]&&(r[1]=e);}processBorderOverlap(t,e){if(t.x===e.x){if(t.y===e.y)return;const r=0===t.x?0:1;this.addBorderIntersection(r,e.y),this.addBorderIntersection(r,t.y);}else {const r=0===t.y?2:3;this.addBorderIntersection(r,e.x),this.addBorderIntersection(r,t.x);}}centroid(){return 0===this.accCount?new g(0,0):new g(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce(((t,e)=>t+ +(e[0]!==Number.MAX_VALUE)),0):0}}function hd(t,e){const r=t.add(e)._unit(),n=I(t.x*r.x+t.y*r.y,-1,1);var i,a,s;return i=Math.acos(n),Math.min(4,Math.max(-4,Math.tan(i)))/4*rd*((a=t).x*(s=e).y-a.y*s.x<0?-1:1)}const pd=[t=>t.x<0,t=>t.x>Tr,t=>t.y<0,t=>t.y>Tr];function fd(t,e,r,n){const i=[4];if(0===n)return i;r._mult(n);const a=t.sub(r),s=e.sub(r),o=[t,e,a,s];for(let t=0;t<4;t++)for(const e of o)if(pd[t](e)){i.push(t);break}return i}class dd{constructor(t){this.vertexArray=new ms,this.indexArray=new Es,this.programConfigurations=new Vo(t.layers,t.zoom,(t=>td.includes(t))),this._segments=new eo,this.hiddenByLandmarkVertexArray=new Us,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new eo;}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(t,e,r,n=!1){const i=t.length;if(i>2){let a=Math.max(0,this._segments.get().length-1);const s=this._segments._prepareSegment(4*i,this.vertexArray.length,2*this._segmentToGroundQuads[a].length);let o;a!==this._segments.get().length-1&&(a++,this._segmentToGroundQuads[a]=[],this._segmentToRegionTriCounts[a]=[0,0,0,0,0]);{const e=t[0],r=t[1];o=hd(e.sub(t[i-1])._perp()._unit(),r.sub(e)._perp()._unit());}for(let l=0;lt.region-e.region));for(let r=0;rt+e),0);let a=0;for(let t=0;t<=4;t++){const e=i[t];if(0!==e){let r=this.regionSegments[t];r||(r=this.regionSegments[t]=new eo);const i={vertexOffset:n.vertexOffset,primitiveOffset:n.primitiveOffset+a,vertexLength:n.vertexLength,primitiveLength:e};r.get().push(i);}a+=e;}for(let t=0;t0?this.hiddenByLandmarkVertexBuffer=t.createVertexBuffer(this.hiddenByLandmarkVertexArray,df.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1);}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let t=0;t<=4;t++){const e=this.regionSegments[t];e&&e.destroy();}}}}class md{constructor(t){this.zoom=t.zoom,this.canonical=t.canonical,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=t.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=[],this.footprintIndices=new Es,this.footprintVertices=new ps,this.footprintSegments=[],this.layoutVertexArray=new ds,this.centroidVertexArray=new Js,this.indexArray=new Es,this.programConfigurations=new Vo(t.layers,t.zoom,(t=>Qf.includes(t))),this.segments=new eo,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.groundEffect=new dd(t),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[];}populate(t,e,r,n){this.features=[],this.hasPattern=sf("fill-extrusion",this.layers,e),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=wl(r),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter;for(const{feature:i,id:a,index:s,sourceLayerIndex:o}of t){const t=this.layers[0]._featureFilter.needGeometry,l=Bl(i,t);if(!this.layers[0]._featureFilter.filter(new Pa(this.zoom),l,r))continue;const u={id:a,sourceLayerIndex:o,index:s,geometry:t?l.geometry:Tl(i,r,n),properties:i.properties,type:i.type,patterns:{}},c=this.layoutVertexArray.length;this.hasPattern?this.features.push(of("fill-extrusion",this.layers,u,this.zoom,e)):this.addFeature(u,u.geometry,s,r,{},e.availableImages,n,e.brightness),e.featureIndex.insert(i,u.geometry,s,o,this.index,c);}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0;}addFeatures(t,e,r,n,i,a){for(const t of this.features){const{geometry:s}=t;this.addFeature(t,s,t.index,e,r,n,i,a);}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles();}update(t,e,r,n,i){const a=0!==Object.keys(t).length;if(a&&!this.stateDependentLayers.length)return;const s=a?this.stateDependentLayers:this.layers;this.programConfigurations.updatePaintArrays(t,e,s,r,n,i),this.groundEffect.update(t,e,s,r,n,i);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,yf),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=t.createVertexBuffer(this.layoutVertexExtArray,mf.members,!0)),this.groundEffect.upload(t)),this.groundEffect.uploadPaintProperties(t),this.programConfigurations.upload(t),this.uploaded=!0;}uploadCentroid(t){this.groundEffect.uploadHiddenByLandmark(t),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,ff.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1);}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.groundEffect.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy());}addFeature(t,e,r,n,i,a,s,o){const l=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(t,{})/this.tileToMeter,u=[new g(0,0),new g(Tr,Tr)],c=s.projection,h="globe"===c.name,p="Polygon"===Jf[t.type],f=new cd;f.centroidDataIndex=this.centroidData.length;const d=new ud,m=this.layers[0].paint.get("fill-extrusion-base").evaluate(t,{},n)<=0,y=this.layers[0].paint.get("fill-extrusion-height").evaluate(t,{},n);d.height=y,d.vertexArrayOffset=this.layoutVertexArray.length,d.groundVertexArrayOffset=this.groundEffect.vertexArray.length,h&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new bs);const x=nf(e,500);for(let t=x.length-1;t>=0;t--){const e=x[t];(0===e.length||(v=e[0]).every((t=>t.x<=0))||v.every((t=>t.x>=Tr))||v.every((t=>t.y<=0))||v.every((t=>t.y>=Tr)))&&x.splice(t,1);}var v;let b;if(h)b=Ad(x,u,n);else {b=[];for(const t of x)b.push({polygon:t,bounds:u});}const _=p?this.edgeRadius:0,w=_>0&&this.zoom<17,M=(t,e)=>{if(0===t.length)return !1;const r=t[t.length-1];return e.x===r.x&&e.y===r.y};for(const{polygon:t,bounds:e}of b){let r=0,i=0;for(const e of t)p&&!e[0].equals(e[e.length-1])&&e.push(e[0]),i+=p?e.length-1:e.length;const a=this.segments.prepareSegment((p?5:4)*i,this.layoutVertexArray,this.indexArray);d.footprintSegIdx<0&&(d.footprintSegIdx=this.footprintSegments.length),d.polygonSegIdx<0&&(d.polygonSegIdx=this.polygonSegments.length);const s={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},o=new ld;if(o.vertexOffset=this.footprintVertices.length,o.indexOffset=3*this.footprintIndices.length,o.ringIndices=[],p){const i=[],s=[];r=a.vertexLength;for(let r=0;r4&&_d(s[s.length-2],s[0],s[1]),u=_?gd(s[s.length-2],s[0],s[1],_):0;const y=[];let g,x,v;x=s[1].sub(s[0])._perp()._unit();let b=!0;for(let t=1,i=0;t0?1:0,k=l.dist(p);if(i+k>32768&&(i=0),_){v=w.sub(p)._perp()._unit();let t=xd(l,p,w,yd(x,v),_);isNaN(t)&&(t=0);const e=p.sub(l)._unit();l=l.add(e.mult(u))._round(),p=p.add(e.mult(-t))._round(),u=t,x=v,m&&this.zoom>=17&&(M(y,l)||y.push(l),M(y,p)||y.push(p));}const P=a.vertexLength,E=s.length>4&&_d(l,p,w);let z=wd(i,o,b);if(ad(this.layoutVertexArray,l.x,l.y,S,I,0,0,z),ad(this.layoutVertexArray,l.x,l.y,S,I,0,1,z),i+=k,z=wd(i,E,!b),o=E,ad(this.layoutVertexArray,p.x,p.y,S,I,0,0,z),ad(this.layoutVertexArray,p.x,p.y,S,I,0,1,z),a.vertexLength+=4,this.indexArray.emplaceBack(P+0,P+1,P+2),this.indexArray.emplaceBack(P+1,P+3,P+2),a.primitiveLength+=2,_){const n=r+(1===t?s.length-2:t-2),i=1===t?r:n+1;if(this.indexArray.emplaceBack(P+1,n,P+3),this.indexArray.emplaceBack(n,i,P+3),a.primitiveLength+=2,void 0===g&&(g=P),!vd(w,s[t],e)){const e=t===s.length-1?g:a.vertexLength;this.indexArray.emplaceBack(P+2,P+3,e),this.indexArray.emplaceBack(P+3,e+1,e),this.indexArray.emplaceBack(P+3,i,e+1),a.primitiveLength+=3;}b=!b;}if(h){const t=this.layoutVertexExtArray,e=c.projectTilePoint(l.x,l.y,n),r=c.projectTilePoint(p.x,p.y,n),i=c.upVector(n,l.x,l.y),a=c.upVector(n,p.x,p.y);od(t,e,i),od(t,e,i),od(t,r,a),od(t,r,a);}}p&&(r+=s.length-1),m&&_&&this.zoom>=17&&(0!==y.length&&M(y,y[0])&&y.pop(),this.groundEffect.addData(y,e,l,_>0));}this.footprintSegments.push(o),s.triangleCount=this.indexArray.length-s.triangleArrayOffset,this.polygonSegments.push(s),++d.footprintSegLen,++d.polygonSegLen;}if(d.vertexCount=this.layoutVertexArray.length-d.vertexArrayOffset,d.groundVertexCount=this.groundEffect.vertexArray.length-d.groundVertexArrayOffset,0!==d.vertexCount){if(d.centroidXY=f.borders?nd:this.encodeCentroid(f,d),this.centroidData.push(d),f.borders){this.featuresOnBorder.push(f);const t=this.featuresOnBorder.length-1;for(let e=0;ethis.featuresOnBorder[e].borders[t][0]-this.featuresOnBorder[r].borders[t][0]));}splitToSubtiles(){const t=[];for(let e=0;eTr),i=2*n+(+(r.min.x+r.max.x>Tr)^n);for(let n=0;nt.triangleSegmentIdx===e.triangleSegmentIdx?t.subtile-e.subtile:t.triangleSegmentIdx-e.triangleSegmentIdx));let r=0,n=0,i=0;for(const e of t){if(e.triangleSegmentIdx!==r)break;i++;}const a=t.length;for(;n!==t.length;){r=t[n].triangleSegmentIdx;let s=0,o=n,l=n;for(let e=o;e0&&this.triangleSubSegments.push({segment:c,min:a,max:u}),o=l;for(let e=o;e[t[0]*(1-r[0])+e[0]*r[0],t[1]*(1-r[1])+e[1]*r[1]],p=[],f=[];for(const t of this.triangleSubSegments){p[0]=t.min.x/Tr,p[1]=t.min.y/Tr,f[0]=t.max.x/Tr,f[1]=t.max.y/Tr;const e=h(l,u,p),a=h(l,u,f);if(0===new Bh([e[0],e[1],n],[a[0],a[1],i]).intersectsPrecise(r)){o&&(c.segments.push(o),o=void 0);continue}const s=t.segment;o&&o.vertexOffset!==s.vertexOffset&&(c.segments.push(o),o=void 0),o?(o.vertexLength+=s.vertexLength,o.primitiveLength+=s.primitiveLength):o={vertexOffset:s.vertexOffset,primitiveLength:s.primitiveLength,vertexLength:s.vertexLength,primitiveOffset:s.primitiveOffset,sortKey:void 0,vaos:{}};}return o&&c.segments.push(o),c}encodeCentroid(t,e){const r=t.centroid(),n=e.span(),i=Math.min(7,Math.round(n.x*this.tileToMeter/10)),a=Math.min(7,Math.round(n.y*this.tileToMeter/10));return new g(I(r.x,1,Tr-1)<<3|i,I(r.y,1,Tr-1)<<3|a)}encodeBorderCentroid(t){if(!t.borders)return new g(0,0);const e=t.borders,r=Number.MAX_VALUE;if(e[0][0]!==r||e[1][0]!==r){const t=e[0][0]!==r?0:1;return new g(6|(e[0][0]!==r?0:65528),(e[t][0]+e[t][1])/2<<3|6)}{const t=e[2][0]!==r?2:3;return new g((e[t][0]+e[t][1])/2<<3|6,6|(e[2][0]!==r?0:65528))}}showCentroid(t){const e=this.centroidData[t.centroidDataIndex];e.flags&=id,e.centroidXY.x=0,e.centroidXY.y=0,this.writeCentroidToBuffer(e);}writeCentroidToBuffer(t){this.groundEffect.updateHiddenByLandmark(t);const e=t.vertexArrayOffset,r=t.vertexCount+t.vertexArrayOffset,n=t.flags&id?nd:t.centroidXY,i=this.centroidVertexArray.geta_centroid_pos0(e);if(this.centroidVertexArray.geta_centroid_pos1(e)!==n.y||i!==n.x){for(let t=e;ti.max.x||i.min.x>e.max.x||e.min.y>i.max.y||i.min.y>e.max.y))for(let a=0;ae!=l>e&&t<(this.footprintVertices.int16[2*(o+a.vertexOffset)+0]-r)*(e-s)/(l-s)+r&&(n=!n);}s=r;}}return n}getHeightAtTileCoord(t,e){let r=Number.NEGATIVE_INFINITY,n=!0;const i=4*(t+Tr)*Tr+(e+Tr);if(this.partLookup.hasOwnProperty(i)){const t=this.partLookup[i];return t?{height:t.height,hidden:!!(t.flags&id)}:void 0}for(const a of this.centroidData)t>a.max.x||a.min.x>t||e>a.max.y||a.min.y>e||this.footprintContainsPoint(t,e,a)&&a&&a.height>r&&(r=a.height,this.partLookup[i]=a,n=!!(a.flags&id));if(r!==Number.NEGATIVE_INFINITY)return {height:r,hidden:n};this.partLookup[i]=void 0;}}function yd(t,e){const r=t.add(e)._unit();return t.x*r.x+t.y*r.y}function gd(t,e,r,n){const i=e.sub(t)._perp()._unit(),a=r.sub(e)._perp()._unit();return xd(t,e,r,yd(i,a),n)}function xd(t,e,r,n,i){const a=Math.sqrt(1-n*n);return Math.min(t.dist(e)/3,e.dist(r)/3,i*a/n)}function vd(t,e,r){return t.xr[1].x&&e.x>r[1].x||t.yr[1].y&&e.y>r[1].y}function bd(t,e){return t.xe[1].x||t.ye[1].y}function _d(t,e,r){if(t.x<0||t.x>=Tr||e.x<0||e.x>=Tr||r.x<0||r.x>=Tr)return !1;const n=r.sub(e),i=n.perp(),a=t.sub(e);return (n.x*a.x+n.y*a.y)/Math.sqrt((n.x*n.x+n.y*n.y)*(a.x*a.x+a.y*a.y))>-.866&&i.x*a.x+i.y*a.y<0}function wd(t,e,r){const n=e?2|t:-3&t;return r?1|n:-2&n}function Md(){const t=Math.PI/32,e=Math.tan(t),r=Jo;return r*Math.sqrt(1+2*e*e)-r}function Ad(t,e,r){const n=1<{for(const r of t)s.push({polygon:r,bounds:e});},l=Math.ceil(Math.log2(r)),u=Math.ceil(Math.log2(n)),c=l-u,h=[];for(let t=0;t0?0:1);for(let t=0;te+1?f.push({polygons:p,bounds:t,depth:e+1}):o(p,t);}if(d.length){const t=[new g(0===r?c:n.x,1===r?c:n.y),s];h.length>e+1?f.push({polygons:d,bounds:t,depth:e+1}):o(d,t);}}return s}(t,e,Math.ceil((a-i)/11.25),Math.ceil((s-o)/11.25),1,((t,e,i)=>{if(0===t)return .5*(e+i);{const t=yl((r.y+e/Tr)/n);return (fl(.5*(yl((r.y+i/Tr)/n)+t))*n-r.y)*Tr}}))}function Sd(t,e,r,n,i,a){const s=Math.pow(2,n.z-i.z);for(let o=0;o1&&(s=t[++a]);const l=Math.abs(o-s.left),u=Math.abs(o-s.right),c=Math.min(l,u);let h;const p=e/r*(n+1);if(s.isDash){const t=n-Math.abs(p);h=Math.sqrt(c*c+t*t);}else h=n-Math.sqrt(c*c+p*p);this.image.data[i+o]=Math.max(0,Math.min(255,h+128));}}}addRegularDash(t,e){for(let e=t.length-1;e>=0;--e){const r=t[e],n=t[e+1];r.zeroLength?t.splice(e,1):n&&n.isDash===r.isDash&&(n.left=r.left,t.splice(e,1));}const r=t[0],n=t[t.length-1];r.isDash===n.isDash&&(r.left=n.left-this.width,n.right=r.right+this.width);const i=this.width*this.nextRow;let a=0,s=t[a];for(let r=0;r1&&(s=t[++a]);const n=Math.abs(r-s.left),o=Math.abs(r-s.right),l=Math.min(n,o);this.image.data[i+r]=Math.max(0,Math.min(255,(s.isDash?l:-l)+e+128));}}addDash(t,e){const r=this.getKey(t,e);if(this.positions[r])return this.positions[r];const n="round"===e,i=n?7:0,a=2*i+1;if(this.nextRow+a>this.height)return j("LineAtlas out of space"),null;0===t.length&&t.push(1);let s=0;for(let e=0;et.fqid)),this.index=t.index,this.projection=t.projection,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={};})),this.layoutVertexArray=new ys,this.layoutVertexArray2=new gs,this.indexArray=new Es,this.programConfigurations=new Vo(t.layers,t.zoom),this.segments=new eo,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}populate(t,e,r,n){this.hasPattern=sf("line",this.layers,e);const i=this.layers[0].layout.get("line-sort-key"),a=[];for(const{feature:e,id:s,index:o,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,u=Bl(e,t);if(!this.layers[0]._featureFilter.filter(new Pa(this.zoom),u,r))continue;const c=i?i.evaluate(u,{},r):void 0,h={id:s,properties:e.properties,type:e.type,sourceLayerIndex:l,index:o,geometry:t?u.geometry:Tl(e,r,n),patterns:{},sortKey:c};a.push(h);}i&&a.sort(((t,e)=>t.sortKey-e.sortKey));const{lineAtlas:s,featureIndex:o}=e,l=this.addConstantDashes(s);for(const n of a){const{geometry:i,index:a,sourceLayerIndex:u}=n;if(l&&this.addFeatureDashes(n,s),this.hasPattern){const t=of("line",this.layers,n,this.zoom,e);this.patternFeatures.push(t);}else this.addFeature(n,i,a,r,s.positions,e.availableImages,e.brightness);o.insert(t[a].feature,i,a,u,this.index);}}addConstantDashes(t){let e=!1;for(const r of this.layers){const n=r.paint.get("line-dasharray").value,i=r.layout.get("line-cap").value;if("constant"!==n.kind||"constant"!==i.kind)e=!0;else {const e=i.value,r=n.value;if(!r)continue;t.addDash(r,e);}}return e}addFeatureDashes(t,e){const r=this.zoom;for(const n of this.layers){const i=n.paint.get("line-dasharray").value,a=n.layout.get("line-cap").value;if("constant"===i.kind&&"constant"===a.kind)continue;let s,o;if("constant"===i.kind){if(s=i.value,!s)continue}else s=i.evaluate({zoom:r},t);o="constant"===a.kind?a.value:a.evaluate({zoom:r},t),e.addDash(s,o),t.patterns[n.id]=e.getKey(s,o);}}update(t,e,r,n,i){const a=0!==Object.keys(t).length;a&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,a?this.stateDependentLayers:this.layers,r,n,i);}addFeatures(t,e,r,n,i,a){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,r,n,a);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,Dd)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Cd),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy());}lineFeatureClips(t){if(t.properties&&t.properties.hasOwnProperty("mapbox_clip_start")&&t.properties.hasOwnProperty("mapbox_clip_end"))return {start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,r,n,i,a,s){const o=this.layers[0].layout,l=o.get("line-join").evaluate(t,{}),u=o.get("line-cap").evaluate(t,{}),c=o.get("line-miter-limit"),h=o.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const r of e)this.addLine(r,t,l,u,c,h);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,i,a,n,s);}addLine(t,e,r,n,i,a){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[o-1].equals(t[o-2]);)o--;let l=0;for(;l0;if(_&&e>l){const t=h.dist(p);if(t>2*u){const e=h.sub(h.sub(p)._mult(u/t)._round());this.updateDistance(p,e),this.addCurrentVertex(e,d,0,0,c),p=e;}}const M=p&&f;let A=M?r:s?"butt":n;if(M&&"round"===A&&(vi&&(A="bevel"),"bevel"===A&&(v>2&&(A="flipbevel"),v100)y=m.mult(-1);else {const t=v*d.add(m).mag()/d.sub(m).mag();y._perp()._mult(t*(w?-1:1));}this.addCurrentVertex(h,y,0,0,c),this.addCurrentVertex(h,y.mult(-1),0,0,c);}else if("bevel"===A||"fakeround"===A){const t=-Math.sqrt(v*v-1),e=w?t:0,r=w?0:t;if(p&&this.addCurrentVertex(h,d,e,r,c),"fakeround"===A){const t=Math.round(180*b/Math.PI/20);for(let e=1;e2*u){const e=h.add(f.sub(h)._mult(u/t)._round());this.updateDistance(h,e),this.addCurrentVertex(e,m,0,0,c),h=e;}}}}addCurrentVertex(t,e,r,n,i,a=!1){const s=e.y*n-e.x,o=-e.y-e.x*n;this.addHalfVertex(t,e.x+e.y*r,e.y-e.x*r,a,!1,r,i),this.addHalfVertex(t,s,o,a,!0,-n,i);}addHalfVertex({x:t,y:e},r,n,i,a,s,o){this.layoutVertexArray.emplaceBack((t<<1)+(i?1:0),(e<<1)+(a?1:0),Math.round(63*r)+128,Math.round(63*n)+128,1+(0===s?0:s<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineClips.start,this.lineClips.end);const l=o.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,l),o.primitiveLength++),a?this.e2=l:this.e1=l;}updateScaledDistance(){if(this.lineClips){const t=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=t*this.lineClips.start+this.distance;}else this.lineSoFar=this.distance;}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance();}}ra(Nd,"LineBucket",{omit:["layers","patternFeatures"]});const Od=new Oa({"line-cap":new Fa(qa.layout_line["line-cap"]),"line-join":new Fa(qa.layout_line["line-join"]),"line-miter-limit":new La(qa.layout_line["line-miter-limit"]),"line-round-limit":new La(qa.layout_line["line-round-limit"]),"line-sort-key":new Fa(qa.layout_line["line-sort-key"]),visibility:new La(qa.layout_line.visibility)});var Ud={paint:new Oa({"line-opacity":new Fa(qa.paint_line["line-opacity"]),"line-color":new Fa(qa.paint_line["line-color"]),"line-translate":new La(qa.paint_line["line-translate"]),"line-translate-anchor":new La(qa.paint_line["line-translate-anchor"]),"line-width":new Fa(qa.paint_line["line-width"]),"line-gap-width":new Fa(qa.paint_line["line-gap-width"]),"line-offset":new Fa(qa.paint_line["line-offset"]),"line-blur":new Fa(qa.paint_line["line-blur"]),"line-dasharray":new Fa(qa.paint_line["line-dasharray"]),"line-pattern":new Fa(qa.paint_line["line-pattern"]),"line-gradient":new Na(qa.paint_line["line-gradient"]),"line-trim-offset":new La(qa.paint_line["line-trim-offset"]),"line-emissive-strength":new La(qa.paint_line["line-emissive-strength"]),"line-border-width":new Fa(qa.paint_line["line-border-width"]),"line-border-color":new Fa(qa.paint_line["line-border-color"])}),layout:Od};function jd(t,e,r){return e*(Tr/(t.tileSize*Math.pow(2,r-t.tileID.overscaledZ)))}function qd(t,e){return 1/jd(t,1,e.tileZoom)}function $d(t,e,r,n){return t.translatePosMatrix(n||e.tileID.projMatrix,e,r.paint.get("line-translate"),r.paint.get("line-translate-anchor"))}const Gd=t=>{const e=[];Yd(t)&&e.push("RENDER_LINE_DASH"),t.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT");const r=t.paint.get("line-trim-offset");return 0===r[0]&&0===r[1]||e.push("RENDER_LINE_TRIM_OFFSET"),0!==t.paint.get("line-border-width").constantOr(1)&&e.push("RENDER_LINE_BORDER"),e};function Yd(t){const e=t.paint.get("line-dasharray").value;return e.value||"constant"!==e.kind}const Xd=new class extends Fa{possiblyEvaluate(t,e){return e=new Pa(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,r,n){return e=z({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,r,n)}}(Ud.paint.properties["line-width"].specification);function Zd(t,e){return e>0?e+2*t:t}Xd.useIntegerZoom=!0;const Kd=cs([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Hd=cs([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),Wd=cs([{name:"a_projected_pos",components:4,type:"Float32"}],4);cs([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Jd=cs([{name:"a_z_offset",components:1,type:"Float32"}],4),Qd=cs([{name:"a_texb",components:2,type:"Uint16"}]),tm=cs([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),em=cs([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_z_offset",components:1,type:"Float32"}]);cs([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const rm=cs([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),nm=cs([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);cs([{name:"triangle",components:3,type:"Uint16"}]),cs([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"},{type:"Uint8",name:"flipState"}]),cs([{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{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",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Float32",name:"zOffset"},{type:"Uint8",name:"hasIconTextFit"}]),cs([{type:"Float32",name:"offsetX"}]),cs([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var im=24;const am=128;function sm(t,e){const{expression:r}=e;if("constant"===r.kind)return {kind:"constant",layoutSize:r.evaluate(new Pa(t+1))};if("source"===r.kind)return {kind:"source"};{const{zoomStops:e,interpolationType:n}=r;let i=0;for(;i{t.text=function(t,e,r){const n=e.layout.get("text-transform").evaluate(r,{});return "uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),ka.applyArabicShaping&&(t=ka.applyArabicShaping(t)),t}(t.text,e,r);})),t}const hm={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function pm(t){return "︶"===t||"﹈"===t||"︸"===t||"﹄"===t||"﹂"===t||"︾"===t||"︼"===t||"︺"===t||"︘"===t||"﹀"===t||"︐"===t||"︓"===t||"︔"===t||"`"===t||" ̄"===t||"︑"===t||"︒"===t}function fm(t){return "︵"===t||"﹇"===t||"︷"===t||"﹃"===t||"﹁"===t||"︽"===t||"︻"===t||"︹"===t||"︗"===t||"︿"===t}var dm={ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ - read:function(e,t,i,r,n){var o,s,a=8*n-r-1,l=(1<>1,h=-7,u=i?n-1:0,d=i?-1:1,p=e[t+u];for(u+=d,o=p&(1<<-h)-1,p>>=-h,h+=a;h>0;o=256*o+e[t+u],u+=d,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=r;h>0;s=256*s+e[t+u],u+=d,h-=8);if(0===o)o=1-c;else {if(o===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,r),o-=c;}return (p?-1:1)*s*Math.pow(2,o-r)},write:function(e,t,i,r,n,o){var s,a,l,c=8*o-n-1,h=(1<>1,d=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,f=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=h):(s=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-s))<1&&(s--,l*=2),(t+=s+u>=1?d/l:d*Math.pow(2,1-u))*l>=2&&(s++,l/=2),s+u>=h?(a=0,s=h):s+u>=1?(a=(t*l-1)*Math.pow(2,n),s+=u):(a=t*Math.pow(2,u-1)*Math.pow(2,n),s=0));n>=8;e[i+p]=255&a,p+=f,a/=256,n-=8);for(s=s<0;e[i+p]=255&s,p+=f,s/=256,c-=8);e[i+p-f]|=128*m;}},sm=lm,am=om;function lm(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length;}lm.Varint=0,lm.Fixed64=1,lm.Bytes=2,lm.Fixed32=5;var cm=4294967296,hm=1/cm,um="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function dm(e){return e.type===lm.Bytes?e.readVarint()+e.pos:e.pos+1}function pm(e,t,i){return i?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function fm(e,t,i){var r=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));i.realloc(r);for(var n=i.pos-1;n>=e;n--)i.buf[n+r]=i.buf[n];}function mm(e,t){for(var i=0;i>>8,e[i+2]=t>>>16,e[i+3]=t>>>24;}function Am(e,t){return (e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}lm.prototype={destroy:function(){this.buf=null;},readFields:function(e,t,i){for(i=i||this.length;this.pos>3,o=this.pos;this.type=7&r,e(n,t,this),this.pos===o&&this.skip(r);}return t},readMessage:function(e,t){return this.readFields(e,t,this.readVarint()+this.pos)},readFixed32:function(){var e=Em(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=Am(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=Em(this.buf,this.pos)+Em(this.buf,this.pos+4)*cm;return this.pos+=8,e},readSFixed64:function(){var e=Em(this.buf,this.pos)+Am(this.buf,this.pos+4)*cm;return this.pos+=8,e},readFloat:function(){var e=am.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=am.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(e){var t,i,r=this.buf;return t=127&(i=r[this.pos++]),i<128?t:(t|=(127&(i=r[this.pos++]))<<7,i<128?t:(t|=(127&(i=r[this.pos++]))<<14,i<128?t:(t|=(127&(i=r[this.pos++]))<<21,i<128?t:function(e,t,i){var r,n,o=i.buf;if(r=(112&(n=o[i.pos++]))>>4,n<128)return pm(e,r,t);if(r|=(127&(n=o[i.pos++]))<<3,n<128)return pm(e,r,t);if(r|=(127&(n=o[i.pos++]))<<10,n<128)return pm(e,r,t);if(r|=(127&(n=o[i.pos++]))<<17,n<128)return pm(e,r,t);if(r|=(127&(n=o[i.pos++]))<<24,n<128)return pm(e,r,t);if(r|=(1&(n=o[i.pos++]))<<31,n<128)return pm(e,r,t);throw new Error("Expected varint not more than 10 bytes")}(t|=(15&(i=r[this.pos]))<<28,e,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var e=this.readVarint();return e%2==1?(e+1)/-2:e/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&um?function(e,t,i){return um.decode(e.subarray(t,i))}(this.buf,t,e):function(e,t,i){for(var r="",n=t;n239?4:l>223?3:l>191?2:1;if(n+h>i)break;1===h?l<128&&(c=l):2===h?128==(192&(o=e[n+1]))&&(c=(31&l)<<6|63&o)<=127&&(c=null):3===h?(s=e[n+2],128==(192&(o=e[n+1]))&&128==(192&s)&&((c=(15&l)<<12|(63&o)<<6|63&s)<=2047||c>=55296&&c<=57343)&&(c=null)):4===h&&(s=e[n+2],a=e[n+3],128==(192&(o=e[n+1]))&&128==(192&s)&&128==(192&a)&&((c=(15&l)<<18|(63&o)<<12|(63&s)<<6|63&a)<=65535||c>=1114112)&&(c=null)),null===c?(c=65533,h=1):c>65535&&(c-=65536,r+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),r+=String.fromCharCode(c),n+=h;}return r}(this.buf,t,e)},readBytes:function(){var e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t},readPackedVarint:function(e,t){if(this.type!==lm.Bytes)return e.push(this.readVarint(t));var i=dm(this);for(e=e||[];this.pos127;);else if(t===lm.Bytes)this.pos=this.readVarint()+this.pos;else if(t===lm.Fixed32)this.pos+=4;else {if(t!==lm.Fixed64)throw new Error("Unimplemented type: "+t);this.pos+=8;}},writeTag:function(e,t){this.writeVarint(e<<3|t);},realloc:function(e){for(var t=this.length||16;t268435455||e<0?function(e,t){var i,r;if(e>=0?(i=e%4294967296|0,r=e/4294967296|0):(r=~(-e/4294967296),4294967295^(i=~(-e%4294967296))?i=i+1|0:(i=0,r=r+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),function(e,t,i){i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,i.buf[i.pos]=127&(e>>>=7);}(i,0,t),function(e,t){var i=(7&e)<<4;t.buf[t.pos++]|=i|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e)))));}(r,t);}(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:function(e){this.writeVarint(e<0?2*-e-1:2*e);},writeBoolean:function(e){this.writeVarint(Boolean(e));},writeString:function(e){e=String(e),this.realloc(4*e.length),this.pos++;var t=this.pos;this.pos=function(e,t,i){for(var r,n,o=0;o55295&&r<57344){if(!n){r>56319||o+1===t.length?(e[i++]=239,e[i++]=191,e[i++]=189):n=r;continue}if(r<56320){e[i++]=239,e[i++]=191,e[i++]=189,n=r;continue}r=n-55296<<10|r-56320|65536,n=null;}else n&&(e[i++]=239,e[i++]=191,e[i++]=189,n=null);r<128?e[i++]=r:(r<2048?e[i++]=r>>6|192:(r<65536?e[i++]=r>>12|224:(e[i++]=r>>18|240,e[i++]=r>>12&63|128),e[i++]=r>>6&63|128),e[i++]=63&r|128);}return i}(this.buf,e,this.pos);var i=this.pos-t;i>=128&&fm(t,i,this),this.pos=t-1,this.writeVarint(i),this.pos+=i;},writeFloat:function(e){this.realloc(4),am.write(this.buf,e,this.pos,!0,23,4),this.pos+=4;},writeDouble:function(e){this.realloc(8),am.write(this.buf,e,this.pos,!0,52,8),this.pos+=8;},writeBytes:function(e){var t=e.length;this.writeVarint(t),this.realloc(t);for(var i=0;i=128&&fm(i,r,this),this.pos=i-1,this.writeVarint(r),this.pos+=r;},writeMessage:function(e,t,i){this.writeTag(e,lm.Bytes),this.writeRawMessage(t,i);},writePackedVarint:function(e,t){t.length&&this.writeMessage(e,mm,t);},writePackedSVarint:function(e,t){t.length&&this.writeMessage(e,_m,t);},writePackedBoolean:function(e,t){t.length&&this.writeMessage(e,xm,t);},writePackedFloat:function(e,t){t.length&&this.writeMessage(e,gm,t);},writePackedDouble:function(e,t){t.length&&this.writeMessage(e,ym,t);},writePackedFixed32:function(e,t){t.length&&this.writeMessage(e,vm,t);},writePackedSFixed32:function(e,t){t.length&&this.writeMessage(e,bm,t);},writePackedFixed64:function(e,t){t.length&&this.writeMessage(e,wm,t);},writePackedSFixed64:function(e,t){t.length&&this.writeMessage(e,Tm,t);},writeBytesField:function(e,t){this.writeTag(e,lm.Bytes),this.writeBytes(t);},writeFixed32Field:function(e,t){this.writeTag(e,lm.Fixed32),this.writeFixed32(t);},writeSFixed32Field:function(e,t){this.writeTag(e,lm.Fixed32),this.writeSFixed32(t);},writeFixed64Field:function(e,t){this.writeTag(e,lm.Fixed64),this.writeFixed64(t);},writeSFixed64Field:function(e,t){this.writeTag(e,lm.Fixed64),this.writeSFixed64(t);},writeVarintField:function(e,t){this.writeTag(e,lm.Varint),this.writeVarint(t);},writeSVarintField:function(e,t){this.writeTag(e,lm.Varint),this.writeSVarint(t);},writeStringField:function(e,t){this.writeTag(e,lm.Bytes),this.writeString(t);},writeFloatField:function(e,t){this.writeTag(e,lm.Fixed32),this.writeFloat(t);},writeDoubleField:function(e,t){this.writeTag(e,lm.Fixed64),this.writeDouble(t);},writeBooleanField:function(e,t){this.writeVarintField(e,Boolean(t));}};var Sm=d(sm);const Im=["tile","layer","source","sourceLayer","state"];class Cm{constructor(e,t,i,r,n){this.type="Feature",this._vectorTileFeature=e,this._z=t,this._x=i,this._y=r,this.properties=e.properties,this.id=n;}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(e){this._geometry=e;}toJSON(){const e={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};void 0!==this.id&&(e.id=this.id);for(const t of Im)void 0!==this[t]&&(e[t]=this[t]);return e}}class zm{constructor(){this.state={},this.stateChanges={},this.deletedStates={};}updateState(e,t,i){const r=String(t);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][r]=this.stateChanges[e][r]||{},k(this.stateChanges[e][r],i),null===this.deletedStates[e]){this.deletedStates[e]={};for(const t in this.state[e])t!==r&&(this.deletedStates[e][t]=null);}else if(this.deletedStates[e]&&null===this.deletedStates[e][r]){this.deletedStates[e][r]={};for(const t in this.state[e][r])i[t]||(this.deletedStates[e][r][t]=null);}else for(const t in i)this.deletedStates[e]&&this.deletedStates[e][r]&&null===this.deletedStates[e][r][t]&&delete this.deletedStates[e][r][t];}removeFeatureState(e,t,i){if(null===this.deletedStates[e])return;const r=String(t);if(this.deletedStates[e]=this.deletedStates[e]||{},i&&void 0!==t)null!==this.deletedStates[e][r]&&(this.deletedStates[e][r]=this.deletedStates[e][r]||{},this.deletedStates[e][r][i]=null);else if(void 0!==t)if(this.stateChanges[e]&&this.stateChanges[e][r])for(i in this.deletedStates[e][r]={},this.stateChanges[e][r])this.deletedStates[e][r][i]=null;else this.deletedStates[e][r]=null;else this.deletedStates[e]=null;}getState(e,t){const i=String(t),r=k({},(this.state[e]||{})[i],(this.stateChanges[e]||{})[i]);if(null===this.deletedStates[e])return {};if(this.deletedStates[e]){const i=this.deletedStates[e][t];if(null===i)return {};for(const e in i)delete r[e];}return r}initializeTileState(e,t){e.setFeatureState(this.state,t);}coalesceChanges(e,t){const i={};for(const e in this.stateChanges){this.state[e]=this.state[e]||{};const t={};for(const i in this.stateChanges[e])this.state[e][i]||(this.state[e][i]={}),k(this.state[e][i],this.stateChanges[e][i]),t[i]=this.state[e][i];i[e]=t;}for(const e in this.deletedStates){this.state[e]=this.state[e]||{};const t={};if(null===this.deletedStates[e])for(const i in this.state[e])t[i]={},this.state[e][i]={};else for(const i in this.deletedStates[e]){if(null===this.deletedStates[e][i])this.state[e][i]={};else if(this.state[e][i])for(const t of Object.keys(this.deletedStates[e][i]))delete this.state[e][i][t];t[i]=this.state[e][i];}i[e]=i[e]||{},k(i[e],t);}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(i).length)for(const r in e)e[r].setFeatureState(i,t);}}class Dm{constructor(e){this.size=e,this.minimums=[],this.maximums=[],this.leaves=[];}getElevation(e,t){const i=this.toIdx(e,t);return {min:this.minimums[i],max:this.maximums[i]}}isLeaf(e,t){return this.leaves[this.toIdx(e,t)]}toIdx(e,t){return t*this.size+e}}function Pm(e,t,i,r){let n=0,o=Number.MAX_VALUE;for(let s=0;s<3;s++)if(Math.abs(r[s])<1e-15){if(i[s]t[s])return null}else {const a=1/r[s];let l=(e[s]-i[s])*a,c=(t[s]-i[s])*a;if(l>c){const e=l;l=c,c=e;}if(l>n&&(n=l),co)return null}return n}function Rm(e,t,i,r,n,o,s,a,l,c,h){const u=r-e,d=n-t,p=o-i,f=s-e,m=a-t,_=l-i,g=h[1]*_-h[2]*m,y=h[2]*f-h[0]*_,x=h[0]*m-h[1]*f,v=u*g+d*y+p*x;if(Math.abs(v)<1e-15)return null;const b=1/v,w=c[0]-e,T=c[1]-t,E=c[2]-i,M=(w*g+T*y+E*x)*b;if(M<0||M>1)return null;const A=T*p-E*d,S=E*u-w*p,I=w*d-T*u,C=(h[0]*A+h[1]*S+h[2]*I)*b;return C<0||M+C>1?null:(f*A+m*S+_*I)*b}function Lm(e,t,i){return (e-t)/(i-t)}function km(e,t,i,r,n,o,s,a,l){const c=1<{const o=r?1:0,s=(e+1)*i-o,a=t*i,l=(t+1)*i-o;n[0]=e*i,n[1]=a,n[2]=s,n[3]=l;};let s=new Dm(r);const a=[];for(let t=0;t=1;r/=2){const e=i[i.length-1];s=new Dm(r);for(let t=0;t0;){const{idx:a,t:p,nodex:f,nodey:m,depth:_}=d.pop();if(this.leaves[a]){km(f,m,_,e,t,i,r,h,u);const a=1<<_,l=(f+0)/a,c=(f+1)/a,d=(m+0)/a,g=(m+1)/a,y=Fm(l,d,this.dem)*s,x=Fm(c,d,this.dem)*s,v=Fm(c,g,this.dem)*s,b=Fm(l,g,this.dem)*s,w=Rm(h[0],h[1],y,u[0],h[1],x,u[0],u[1],v,n,o),T=Rm(u[0],u[1],v,h[0],u[1],b,h[0],h[1],y,n,o),E=Math.min(null!==w?w:Number.MAX_VALUE,null!==T?T:Number.MAX_VALUE);if(E!==Number.MAX_VALUE)return E;{const e=Mu.scaleAndAdd([],n,o,p);if(Bm(y,x,b,v,Lm(e[0],h[0],u[0]),Lm(e[1],h[1],u[1]))>=e[2])return p}continue}let g=0;for(let d=0;d=l[c[i]]&&(c.splice(i,0,d),t=!0);t||(c[g]=d),g++;}}for(let e=0;e=this.dim+1||t<-1||t>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return (t+1)*this.stride+(e+1)}static pack(e,t){const i=[0,0,0,0],r=jm.getUnpackVector(t);let n=Math.floor((e+r[3])/r[2]);return i[2]=n%256,n=Math.floor(n/256),i[1]=n%256,n=Math.floor(n/256),i[0]=n,i}getPixels(){return "float"===this.encoding?new Hp({width:this.stride,height:this.stride},this.pixels):new $p({width:this.stride,height:this.stride},this.pixels)}backfillBorder(e,t,i){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let r=t*this.dim,n=t*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(t){case-1:r=n-1;break;case 1:n=r+1;}switch(i){case-1:o=s-1;break;case 1:s=o+1;}const a=-t*this.dim,l=-i*this.dim;for(let t=o;t1)return !1;const i=t.getSource().maxzoom,r=1<1)return t;const n=r.getSource().maxzoom,o=1<{const o=this.getAtTileOffset(e,n.x,n.y),s=r.upVector(e.canonical,n.x,n.y),a=r.upVectorScale(e.canonical,t,i).metersToTile;return Mu.scale(s,s,o*a),s}}getForTilePoints(e,t,i,r){if(this.isUsingMockSource())return !1;const n=qm.create(this,e,r);return !!n&&(t.forEach((e=>{e[2]=this.exaggeration()*n.getElevationAt(e[0],e[1],i);})),!0)}getMinMaxForTile(e){if(this.isUsingMockSource())return null;const t=this.findDEMTileFor(e);if(!t||!t.dem)return null;const i=t.dem.tree,r=t.tileID,n=1<=0&&r[3]>=0&&a.insert(s,r[0],r[1],r[2],r[3]);}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new tm(new Sm(this.rawTileData)).layers,this.sourceLayerCoder=new nm(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const e in this.vtLayers)this.vtFeatures[e]=[];}return this.vtLayers}query(e,t,i,r){this.loadVTLayers();const n=e.params||{},o=Ro(n.filter),s=e.tileResult,a=e.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((e,t,i,r)=>Tp(s.bufferedTilespaceGeometry,e,t,i,r)));c.sort(Hm);let h=null;a.elevation&&c.length>0&&(h=qm.create(a.elevation,this.tileID));const u={};let d;for(let a=0;a(f||(f=lp(t,this.tileID.canonical,e.tileTransform)),i.queryIntersectsFeature(s,t,r,f,this.z,e.transform,e.pixelPosMatrix,h,n))));}return u}loadMatchingFeature(e,t,i,r,n,o,s,a,l){const{featureIndex:c,bucketIndex:h,sourceLayerIndex:u,layoutVertexArrayOffset:d}=t,p=this.bucketLayerIDs[h];if(r&&!function(e,t){for(let i=0;i=0)return !0;return !1}(r,p))return;const f=this.sourceLayerCoder.decode(u),m=this.vtLayers[f].feature(c);if(i.needGeometry){const e=cp(m,!0);if(!i.filter(new ea(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!i.filter(new ea(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let t=0;t{const s=t instanceof la?t.get(o):null;return s&&s.evaluate?s.evaluate(i,r,n):s}))}function Hm(e,t){return t-e}Is(Zm,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const Wm=ba([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Xm=ba([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),Ym=ba([{name:"a_projected_pos",components:4,type:"Float32"}],4);ba([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Km=ba([{name:"a_z_offset",components:1,type:"Float32"}],4),Jm=ba([{name:"a_texb",components:2,type:"Uint16"}]),Qm=ba([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),e_=ba([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);ba([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const t_=ba([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),i_=ba([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);ba([{name:"triangle",components:3,type:"Uint16"}]),ba([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"},{type:"Uint8",name:"flipState"}]),ba([{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{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",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Float32",name:"zOffset"},{type:"Uint8",name:"hasIconTextFit"}]),ba([{type:"Float32",name:"offsetX"}]),ba([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var r_=24;const n_=128;function o_(e,t){const{expression:i}=t;if("constant"===i.kind)return {kind:"constant",layoutSize:i.evaluate(new ea(e+1))};if("source"===i.kind)return {kind:"source"};{const{zoomStops:t,interpolationType:r}=i;let n=0;for(;n{e.text=function(e,t,i){const r=t.layout.get("text-transform").evaluate(i,{});return "uppercase"===r?e=e.toLocaleUpperCase():"lowercase"===r&&(e=e.toLocaleLowerCase()),Qs.applyArabicShaping&&(e=Qs.applyArabicShaping(e)),e}(e.text,t,i);})),e}const h_={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function u_(e){return "︶"===e||"﹈"===e||"︸"===e||"﹄"===e||"﹂"===e||"︾"===e||"︼"===e||"︺"===e||"︘"===e||"﹀"===e||"︐"===e||"︓"===e||"︔"===e||"`"===e||" ̄"===e||"︑"===e||"︒"===e}function d_(e){return "︵"===e||"﹇"===e||"︷"===e||"﹃"===e||"﹁"===e||"︽"===e||"︻"===e||"︹"===e||"︗"===e||"︿"===e}const p_=3;function f_(e,t,i){t.glyphs=[],1===e&&i.readMessage(m_,t);}function m_(e,t,i){if(3===e){const{id:e,bitmap:r,width:n,height:o,left:s,top:a,advance:l}=i.readMessage(__,{});t.glyphs.push({id:e,bitmap:new Zp({width:n+2*p_,height:o+2*p_},r),metrics:{width:n,height:o,left:s,top:a,advance:l}});}else 4===e?t.ascender=i.readSVarint():5===e&&(t.descender=i.readSVarint());}function __(e,t,i){1===e?t.id=i.readVarint():2===e?t.bitmap=i.readBytes():3===e?t.width=i.readVarint():4===e?t.height=i.readVarint():5===e?t.left=i.readSVarint():6===e?t.top=i.readSVarint():7===e&&(t.advance=i.readVarint());}const g_=p_;function y_(e){let t=0,i=0;for(const r of e)t+=r.w*r.h,i=Math.max(i,r.w);e.sort(((e,t)=>t.h-e.h));const r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),i),h:1/0}];let n=0,o=0;for(const t of e)for(let e=r.length-1;e>=0;e--){const i=r[e];if(!(t.w>i.w||t.h>i.h)){if(t.x=i.x,t.y=i.y,o=Math.max(o,t.y+t.h),n=Math.max(n,t.x+t.w),t.w===i.w&&t.h===i.h){const t=r.pop();ee.hasImage(t,i))),e.dispatchRenderCallbacks(this.haveRenderCallbacks,i);for(const r in e.getUpdatedImages(i))this.patchUpdatedImage(this.iconPositions[r],e.getImage(r,i),t),this.patchUpdatedImage(this.patternPositions[r],e.getImage(r,i),t);}patchUpdatedImage(e,t,i){if(!e||!t)return;if(e.version===t.version)return;e.version=t.version;const[r,n]=e.tl;i.update(t.data,void 0,{x:r,y:n});}}Is(v_,"ImagePosition"),Is(b_,"ImageAtlas");const w_={horizontal:1,vertical:2,horizontalOnly:3},T_=-17;class E_{constructor(){this.scale=1,this.fontStack="",this.imageName=null;}static forText(e,t){const i=new E_;return i.scale=e||1,i.fontStack=t,i}static forImage(e){const t=new E_;return t.imageName=e,t}}class M_{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null;}static fromFeature(e,t){const i=new M_;for(let r=0;r=0&&i>=e&&S_[this.text.charCodeAt(i)];i--)t--;this.text=this.text.substring(e,t),this.sectionIndex=this.sectionIndex.slice(e,t);}substring(e,t){const i=new M_;return i.text=this.text.substring(e,t),i.sectionIndex=this.sectionIndex.slice(e,t),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((e,t)=>Math.max(e,this.sections[t].scale)),0)}addTextSection(e,t){this.text+=e.text,this.sections.push(E_.forText(e.scale,e.fontStack||t));const i=this.sections.length-1;for(let t=0;t=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function A_(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f){const m=M_.fromFeature(e,n);u===w_.vertical&&m.verticalizePunctuation(d);let _=[];const g=function(e,t,i,r,n,o){if(!e)return [];const s=[],a=function(e,t,i,r,n,o){let s=0;for(let i=0;i=0;let c=0;for(let i=0;i0&&o>b&&(b=o);}else {const e=i[a.fontStack];if(!e)continue;e[m]&&(E=e[m]);const r=t[a.fontStack];if(!r)continue;const o=r.glyphs[m];if(!o)continue;if(x=o.metrics,A=8203!==m?r_:0,_){const e=void 0!==r.ascender?Math.abs(r.ascender):0,t=void 0!==r.descender?Math.abs(r.descender):0,i=(e+t)*g;w-i/2;){if(s--,s<0)return !1;a-=e[s].dist(o),o=e[s];}a+=e[s].dist(e[s+1]),s++;const l=[];let c=0;for(;ar;)c-=l.shift().angleDelta;if(c>n)return !1;s++,a+=t.dist(i);}return !0}function U_(e){let t=0;for(let i=0;ic){const h=(c-l)/o,u=Wr(r.x,n.x,h),d=Wr(r.y,n.y,h),p=new F_(u,d,0,n.angleTo(r),i);return !s||N_(e,p,a,s,t)?p:void 0}l+=o;}}function q_(e,t,i,r,n,o,s,a,l){const c=V_(r,o,s),h=j_(r,n),u=h*s,d=0===e[0].x||e[0].x===l||0===e[0].y||e[0].y===l;return t-u=0&&g=0&&y=0&&d+c<=h){const i=new F_(g,y,0,m,t);r&&!N_(e,i,o,r,n)||p.push(i);}}u+=f;}return a||p.length||s||(p=Z_(e,u/2,i,r,n,o,s,!0,l)),p}function $_(e,t,i,r,n){const o=[];for(let s=0;s=r&&c.x>=r||(s.x>=r?s=new y(r,s.y+(r-s.x)/(c.x-s.x)*(c.y-s.y))._round():c.x>=r&&(c=new y(r,s.y+(r-s.x)/(c.x-s.x)*(c.y-s.y))._round()),s.y>=n&&c.y>=n||(s.y>=n?s=new y(s.x+(n-s.y)/(c.y-s.y)*(c.x-s.x),n)._round():c.y>=n&&(c=new y(s.x+(n-s.y)/(c.y-s.y)*(c.x-s.x),n)._round()),l&&s.equals(l[l.length-1])||(l=[s],o.push(l)),l.push(c)))));}}return o}Is(F_,"Anchor");const H_=1e20;function W_(e,t,i,r,n,o,s,a,l){for(let c=t;c-1);l++,o[l]=a,s[l]=c,s[l+1]=H_;}for(let a=0,l=0;a{let r=this.entries[e];r||(r=this.entries[e]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let n=r.glyphs[t];if(void 0!==n)return void i(null,{stack:e,id:t,glyph:n});if(n=this._tinySDF(r,e,t),n)return r.glyphs[t]=n,void i(null,{stack:e,id:t,glyph:n});const s=Math.floor(t/256);if(256*s>65535)return void i(new Error("glyphs > 65535 not supported"));if(r.ranges[s])return void i(null,{stack:e,id:t,glyph:n});let a=r.requests[s];a||(a=r.requests[s]=[],K_.loadGlyphRange(e,s,o,this.requestManager,((e,t)=>{if(t){r.ascender=t.ascender,r.descender=t.descender;for(const e in t.glyphs)this._doesCharSupportLocalGlyph(+e)||(r.glyphs[+e]=t.glyphs[+e]);r.ranges[s]=!0;}for(const i of a)i(e,t);delete r.requests[s];}))),a.push(((r,n)=>{r?i(r):n&&i(null,{stack:e,id:t,glyph:n.glyphs[t]||null});}));}),((e,t)=>{if(e)i(e);else if(t){const e={};for(const{stack:i,id:r,glyph:n}of t)void 0===e[i]&&(e[i]={}),void 0===e[i].glyphs&&(e[i].glyphs={}),e[i].glyphs[r]=n&&{id:n.id,bitmap:n.bitmap.clone(),metrics:n.metrics},e[i].ascender=this.entries[i].ascender,e[i].descender=this.entries[i].descender;i(null,e);}}));}_doesCharSupportLocalGlyph(e){return 0!==this.localGlyphMode&&(2===this.localGlyphMode?!!this.localFontFamily:!!this.localFontFamily&&(Rs["CJK Unified Ideographs"](e)||Rs["Hangul Syllables"](e)||Rs.Hiragana(e)||Rs.Katakana(e)||Rs["CJK Symbols and Punctuation"](e)||Rs["CJK Unified Ideographs Extension A"](e)||Rs["CJK Unified Ideographs Extension B"](e)))}_tinySDF(e,t,i){const r=this.localFontFamily;if(!r||!this._doesCharSupportLocalGlyph(i))return;let n=e.tinySDF;if(!n){let i="400";/bold/i.test(t)?i="900":/medium/i.test(t)?i="500":/light/i.test(t)&&(i="200"),n=e.tinySDF=new K_.TinySDF({fontFamily:r,fontWeight:i,fontSize:24*Y_,buffer:3*Y_,radius:8*Y_}),n.fontWeight=i;}if(this.localGlyphs[n.fontWeight][i])return this.localGlyphs[n.fontWeight][i];const o=String.fromCodePoint(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:h,glyphLeft:u,glyphTop:d,glyphAdvance:p}=n.draw(o);return this.localGlyphs[n.fontWeight][i]={id:i,bitmap:new Zp({width:a,height:l},s),metrics:{width:c/Y_,height:h/Y_,left:u/Y_,top:d/Y_-27,advance:p/Y_,localGlyph:!0}}}}K_.loadGlyphRange=function(e,t,i,r,n){const o=256*t,s=o+255,a=r.transformRequest(r.normalizeGlyphsURL(i).replace("{fontstack}",e).replace("{range}",`${o}-${s}`),ye.Glyphs);Te(a,((e,t)=>{if(e)n(e);else if(t){const e={},i=function(e){return new Sm(e).readFields(f_,{})}(t);for(const t of i.glyphs)e[t.id]=t;n(null,{glyphs:e,ascender:i.ascender,descender:i.descender});}}));},K_.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:r=.25,fontFamily:n="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=t,this.cutoff=r,this.radius=i;const a=this.size=e+4*t,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${e}px ${n}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a);}_createCanvas(e){const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:n,actualBoundingBoxRight:o}=this.ctx.measureText(e),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-n))),l=Math.min(this.size-this.buffer,s+Math.ceil(r)),c=a+2*this.buffer,h=l+2*this.buffer,u=Math.max(c*h,0),d=new Uint8ClampedArray(u),p={data:d,width:c,height:h,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:t};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(e,m,m+s);const y=f.getImageData(m,m,a,l);g.fill(H_,0,u),_.fill(0,0,u);for(let e=0;e0?e*e:0,_[r]=e<0?e*e:0;}}W_(g,0,0,c,h,c,this.f,this.v,this.z),W_(_,m,m,a,l,c,this.f,this.v,this.z);for(let e=0;ee+t[1]-t[0],f=u.reduce(p,0),m=d.reduce(p,0),_=a-f,g=l-m;let x=0,v=f,b=0,w=m,T=0,E=_,M=0,A=g;if(o.content&&r){const e=o.content;x=eg(u,0,e[0]),b=eg(d,0,e[1]),v=eg(u,e[0],e[2]),w=eg(d,e[1],e[3]),T=e[0]-x,M=e[1]-b,E=e[2]-e[0]-v,A=e[3]-e[1]-w;}const S=(r,n,a,l)=>{const u=ig(r.stretch-x,v,c,e.left),d=rg(r.fixed-T,E,r.stretch,f),p=ig(n.stretch-b,w,h,e.top),_=rg(n.fixed-M,A,n.stretch,m),g=ig(a.stretch-x,v,c,e.left),S=rg(a.fixed-T,E,a.stretch,f),I=ig(l.stretch-b,w,h,e.top),C=rg(l.fixed-M,A,l.stretch,m),z=new y(u,p),D=new y(g,p),P=new y(g,I),R=new y(u,I),L=new y(d/s,_/s),k=new y(S/s,C/s),O=t*Math.PI/180;if(O){const e=Math.sin(O),t=Math.cos(O),i=[t,-e,e,t];z._matMult(i),D._matMult(i),R._matMult(i),P._matMult(i);}const B=r.stretch+r.fixed,F=a.stretch+a.fixed,N=n.stretch+n.fixed,U=l.stretch+l.fixed,V=e.imageSecondary;return {tl:z,tr:D,bl:R,br:P,texPrimary:{x:o.paddedRect.x+J_+B,y:o.paddedRect.y+J_+N,w:F-B,h:U-N},texSecondary:V?{x:V.paddedRect.x+J_+B,y:V.paddedRect.y+J_+N,w:F-B,h:U-N}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:L,pixelOffsetBR:k,minFontScaleX:E/s/c,minFontScaleY:A/s/h,isSDF:i}};if(r&&(o.stretchX||o.stretchY)){const e=tg(u,_,f),t=tg(d,g,m);for(let i=0;io)&&(o=t.x),(!e||t.y>s)&&(s=t.y);}const l=Math.min(o-r,s-n);let c=l/2;const h=new or([],sg);if(0===l)return new y(r,n);for(let t=r;tu.d||!u.d)&&(u=r,i&&console.log("found best %d after %d probes",Math.round(1e4*r.d)/1e4,d)),r.max-u.d<=t||(c=r.h/2,h.push(new ag(r.p.x-c,r.p.y-c,c,e)),h.push(new ag(r.p.x+c,r.p.y-c,c,e)),h.push(new ag(r.p.x-c,r.p.y+c,c,e)),h.push(new ag(r.p.x+c,r.p.y+c,c,e)),d+=4);}return i&&(console.log(`num probes: ${d}`),console.log(`best distance: ${u.d}`)),u.p}function sg(e,t){return t.max-e.max}class ag{constructor(e,t,i,r){this.p=new y(e,t),this.h=i,this.d=function(e,t){let i=!1,r=1/0;for(let n=0;ne.y!=a.y>e.y&&e.x<(a.x-n.x)*(e.y-n.y)/(a.y-n.y)+n.x&&(i=!i),r=Math.min(r,vp(e,n,a));}}return (i?1:-1)*Math.sqrt(r)}(this.p,r),this.max=this.d+this.h*Math.SQRT2;}}const lg=7,cg=Number.POSITIVE_INFINITY,hg=Math.sqrt(2);function ug(e,[t,i]){let r=0,n=0;if(i===cg){t<0&&(t=0);const i=t/hg;switch(e){case"top-right":case"top-left":n=i-lg;break;case"bottom-right":case"bottom-left":n=-i+lg;break;case"bottom":n=-t+lg;break;case"top":n=t-lg;}switch(e){case"top-right":case"bottom-right":r=-i;break;case"top-left":case"bottom-left":r=i;break;case"left":r=t;break;case"right":r=-t;}}else {switch(t=Math.abs(t),i=Math.abs(i),e){case"top-right":case"top-left":case"top":n=i-lg;break;case"bottom-right":case"bottom-left":case"bottom":n=-i+lg;}switch(e){case"top-right":case"bottom-right":case"right":r=-t;break;case"top-left":case"bottom-left":case"left":r=t;}}return [r,n]}function dg(e,t,i,r,n,o,s,a,l,c,h){e.createArrays(),e.tilePixelRatio=sr/(512*e.overscaling),e.compareText={},e.iconsNeedLinear=!1;const u=e.layers[0].layout,d=e.layers[0]._unevaluatedLayout._values,p={};if("composite"===e.textSizeData.kind){const{minZoom:t,maxZoom:i}=e.textSizeData;p.compositeTextSizes=[d["text-size"].possiblyEvaluate(new ea(t),a),d["text-size"].possiblyEvaluate(new ea(i),a)];}if("composite"===e.iconSizeData.kind){const{minZoom:t,maxZoom:i}=e.iconSizeData;p.compositeIconSizes=[d["icon-size"].possiblyEvaluate(new ea(t),a),d["icon-size"].possiblyEvaluate(new ea(i),a)];}p.layoutTextSize=d["text-size"].possiblyEvaluate(new ea(l+1),a),p.layoutIconSize=d["icon-size"].possiblyEvaluate(new ea(l+1),a),p.textMaxSize=d["text-size"].possiblyEvaluate(new ea(18),a);const f="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),m=u.get("text-size");let _=!1;for(const t of e.features)if(t.icon&&t.icon.nameSecondary){_=!0;break}for(const o of e.features){const l=u.get("text-font").evaluate(o,{},a).join(","),d=m.evaluate(o,{},a),g=p.layoutTextSize.evaluate(o,{},a),y=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),x=o.text;let v,b=[0,0];if(x){const r=x.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*r_,c=u.get("text-line-height").evaluate(o,{},a)*r_,h=ks(r)?s:0,p=u.get("text-anchor").evaluate(o,{},a),m=u.get("text-variable-anchor");if(!m){const e=u.get("text-radial-offset").evaluate(o,{},a);b=e?ug(p,[e*r_,cg]):u.get("text-offset").evaluate(o,{},a).map((e=>e*r_));}let _=f?"center":u.get("text-justify").evaluate(o,{},a);const v="point"===u.get("symbol-placement"),w=v?u.get("text-max-width").evaluate(o,{},a)*r_:1/0,T=o=>{e.allowVerticalPlacement&&Ls(r)&&(y.vertical=A_(x,t,i,n,l,w,c,p,o,h,b,w_.vertical,!0,g,d));};if(!f&&m){const e="auto"===_?m.map((e=>pg(e))):[_];let r=!1;for(let o=0;o=0||!Ls(r)){const e=A_(x,t,i,n,l,w,c,p,_,h,b,w_.horizontal,!1,g,d);e&&(y.horizontal[_]=e);}T(v?"left":_);}}let w=!1;if(o.icon&&o.icon.namePrimary){const t=r[o.icon.namePrimary];t&&(v=O_(n[o.icon.namePrimary],o.icon.nameSecondary?n[o.icon.nameSecondary]:void 0,u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),w=t.sdf,void 0===e.sdfIcons?e.sdfIcons=t.sdf:e.sdfIcons!==t.sdf&&W("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(t.pixelRatio!==e.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(e.iconsNeedLinear=!0));}const T=yg(y.horizontal)||y.vertical;e.iconsInText||(e.iconsInText=!!T&&T.iconsInText),(T||v)&&fg(e,o,y,v,r,p,g,0,b,w,s,a,c,h,_);}o&&e.generateCollisionDebugBuffers(l,e.collisionBoxArray);}function pg(e){switch(e){case"right":case"top-right":case"bottom-right":return "right";case"left":case"top-left":case"bottom-left":return "left"}return "center"}function fg(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f){let m=o.textMaxSize.evaluate(t,{},u);void 0===m&&(m=s);const _=e.layers[0].layout,g=_.get("icon-offset").evaluate(t,{},u),y=yg(i.horizontal)||i.vertical,x="globe"===d.name,v=r_,b=s/v,T=e.tilePixelRatio*m/v,E=(P=e.overscaling,e.zoom>18&&P>2&&(P>>=1),Math.max(sr/(512*P),1)*_.get("symbol-spacing")),M=_.get("text-padding")*e.tilePixelRatio,A=_.get("icon-padding")*e.tilePixelRatio,S=w(_.get("text-max-angle")),I="map"===_.get("text-rotation-alignment")&&"point"!==_.get("symbol-placement"),C="map"===_.get("icon-rotation-alignment")&&"point"!==_.get("symbol-placement"),z=_.get("symbol-placement"),D=E/2;var P;const R=_.get("icon-text-fit").evaluate(t,{},u),L=_.get("icon-text-fit-padding").evaluate(t,{},u),k="none"!==R;let O;!1===e.hasAnyIconTextFit&&k&&(e.hasAnyIconTextFit=!0),r&&k&&(e.allowVerticalPlacement&&i.vertical&&(O=B_(r,i.vertical,R,L,g,b)),y&&(r=B_(r,y,R,L,g,b)));const B=(s,a,m)=>{if(a.x<0||a.x>=sr||a.y<0||a.y>=sr)return;let _=null;if(x){const{x:e,y:t,z:i}=d.projectTilePoint(a.x,a.y,m);_={anchor:new F_(e,t,i,0,void 0),up:d.upVector(m,a.x,a.y)};}!function(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,M,A){const S=e.addToLineVertexArray(t,r);let I,C,z,D,P,R,L,k=0,O=0,B=0,F=0,N=-1,U=-1;const V={};let j=wl("");const G=i?i.anchor:t,q="none"!==l.layout.get("icon-text-fit").evaluate(v,{},E);let Z=0,$=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[Z,$]=l.layout.get("text-offset").evaluate(v,{},E).map((e=>e*r_)):(Z=l.layout.get("text-radial-offset").evaluate(v,{},E)*r_,$=cg),e.allowVerticalPlacement&&n.vertical){const e=n.vertical;if(f)R=vg(e),a&&(L=vg(a));else {const i=l.layout.get("text-rotate").evaluate(v,{},E)+90;z=xg(c,G,t,h,u,d,e,p,i,m),a&&(D=xg(c,G,t,h,u,d,a,g,i));}}if(o){const r=l.layout.get("icon-rotate").evaluate(v,{},E),n=Q_(o,r,w,q),s=a?Q_(a,r,w,q):void 0;C=xg(c,G,t,h,u,d,o,g,r),k=4*n.length;const p=e.iconSizeData;let f=null;"source"===p.kind?(f=[n_*l.layout.get("icon-size").evaluate(v,{},E)],f[0]>_g&&W(`${e.layerIds[0]}: Value for "icon-size" is >= ${mg}. Reduce your "icon-size".`)):"composite"===p.kind&&(f=[n_*b.compositeIconSizes[0].evaluate(v,{},E),n_*b.compositeIconSizes[1].evaluate(v,{},E)],(f[0]>_g||f[1]>_g)&&W(`${e.layerIds[0]}: Value for "icon-size" is >= ${mg}. Reduce your "icon-size".`)),e.addSymbols(e.icon,n,f,x,y,v,!1,i,t,S.lineStartIndex,S.lineLength,-1,T,E,M,A),N=e.icon.placedSymbolArray.length-1,s&&(O=4*s.length,e.addSymbols(e.icon,s,f,x,y,v,w_.vertical,i,t,S.lineStartIndex,S.lineLength,-1,T,E,M,A),U=e.icon.placedSymbolArray.length-1);}for(const r in n.horizontal){const o=n.horizontal[r];I||(j=wl(o.text),f?P=vg(o):I=xg(c,G,t,h,u,d,o,p,l.layout.get("text-rotate").evaluate(v,{},E),m));const a=1===o.positionedLines.length;if(B+=gg(e,i,t,o,s,l,f,v,m,S,n.vertical?w_.horizontal:w_.horizontalOnly,a?Object.keys(n.horizontal):[r],V,N,b,T,E,M),a)break}n.vertical&&(F+=gg(e,i,t,n.vertical,s,l,f,v,m,S,w_.vertical,["vertical"],V,U,b,T,E,M));let H=-1;const X=(e,t)=>e?Math.max(e,t):t;H=X(P,H),H=X(R,H),H=X(L,H);const Y=H>-1?1:0;e.glyphOffsetArray.length>=cy.MAX_GLYPHS&&W("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==v.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,v.sortKey),e.symbolInstances.emplaceBack(t.x,t.y,G.x,G.y,G.z,V.right>=0?V.right:-1,V.center>=0?V.center:-1,V.left>=0?V.left:-1,V.vertical>=0?V.vertical:-1,N,U,j,void 0!==I?I:e.collisionBoxArray.length,void 0!==I?I+1:e.collisionBoxArray.length,void 0!==z?z:e.collisionBoxArray.length,void 0!==z?z+1:e.collisionBoxArray.length,void 0!==C?C:e.collisionBoxArray.length,void 0!==C?C+1:e.collisionBoxArray.length,D||e.collisionBoxArray.length,D?D+1:e.collisionBoxArray.length,h,B,F,k,O,Y,0,Z,$,H,0,q?1:0);}(e,a,_,s,i,r,n,O,e.layers[0],e.collisionBoxArray,t.index,t.sourceLayerIndex,e.index,M,I,l,0,A,C,g,t,o,c,h,u,p,f);};if("line"===z)for(const n of $_(t.geometry,0,0,sr,sr)){const t=q_(n,E,S,i.vertical||y,r,v,T,e.overscaling,sr);for(const i of t)y&&bg(e,y.text,D,i)||B(n,i,u);}else if("line-center"===z){for(const e of t.geometry)if(e.length>1){const t=G_(e,S,i.vertical||y,r,v,T);t&&B(e,t,u);}}else if("Polygon"===t.type)for(const e of zf(t.geometry,0)){const t=og(e,16);B(e[0],new F_(t.x,t.y,0,0,void 0),u);}else if("LineString"===t.type)for(const e of t.geometry)B(e,new F_(e[0].x,e[0].y,0,0,void 0),u);else if("Point"===t.type)for(const e of t.geometry)for(const t of e)B([t],new F_(t.x,t.y,0,0,void 0),u);}const mg=255,_g=mg*n_;function gg(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){const x=function(e,t,i,r,n,o,s,a){const l=[];if(0===t.positionedLines.length)return l;const c=r.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,h=function(e){const t=e[0],i=e[1],r=t*i;return r>0?[t,-i]:r<0?[-t,i]:0===t?[i,t]:[i,-t]}(i);let u=Math.abs(t.top-t.bottom);for(const e of t.positionedLines)u-=e.lineOffset;const d=t.positionedLines.length,p=u/d;let f=t.top-i[1];for(let e=0;e_g&&W(`${e.layerIds[0]}: Value for "text-size" is >= ${mg}. Reduce your "text-size".`)):"composite"===v.kind&&(b=[n_*f.compositeTextSizes[0].evaluate(a,{},_),n_*f.compositeTextSizes[1].evaluate(a,{},_)],(b[0]>_g||b[1]>_g)&&W(`${e.layerIds[0]}: Value for "text-size" is >= ${mg}. Reduce your "text-size".`)),e.addSymbols(e.text,x,b,l,s,a,h,t,i,c.lineStartIndex,c.lineLength,p,m,_,g,!1);for(const t of u)d[t]=e.text.placedSymbolArray.length-1;return 4*x.length}function yg(e){for(const t in e)return e[t];return null}function xg(e,t,i,r,n,o,s,a,l,c){let h=s.top,u=s.bottom,d=s.left,p=s.right;const f=s.collisionPadding;if(f&&(d-=f[0],h-=f[1],p+=f[2],u+=f[3]),l){const e=new y(d,h),t=new y(p,h),i=new y(d,u),r=new y(p,u),n=w(l);let o=new y(0,0);c&&(o=new y(c[0],c[1])),e._rotateAround(n,o),t._rotateAround(n,o),i._rotateAround(n,o),r._rotateAround(n,o),d=Math.min(e.x,t.x,i.x,r.x),p=Math.max(e.x,t.x,i.x,r.x),h=Math.min(e.y,t.y,i.y,r.y),u=Math.max(e.y,t.y,i.y,r.y);}return e.emplaceBack(t.x,t.y,t.z,i.x,i.y,d,h,p,u,a,r,n,o),e.length-1}function vg(e){e.collisionPadding&&(e.top-=e.collisionPadding[1],e.bottom+=e.collisionPadding[3]);const t=e.bottom-e.top;return t>0?Math.max(10,t):null}function bg(e,t,i,r){const n=e.compareText;if(t in n){const e=n[t];for(let t=e.length-1;t>=0;t--)if(r.dist(e[t])x&&(v(e,c,r,n,a,l),v(c,i,a,l,o,s));}v(u,d,r,o,n,o),v(d,p,n,o,n,s),v(p,f,n,s,r,s),v(f,u,r,s,r,o),m-=x,_-=x,g+=x,y+=x;const b=1/Math.max(g-m,y-_);return {scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:t}}function Eg(e,t,i,r,n,o,s,a,l){if("globe"===l.name)return ud(e,t,new ku(i,r,n),!1);const c=Tg({z:i,x:r,y:n},l);return new Hu([(o+c.x/c.scale)*t,t*(c.y/c.scale),s],[(o+c.x2/c.scale)*t,t*(c.y2/c.scale),a])}function Mg(e,{x:t,y:i},r=0){return new y(((t-r)*e.scale-e.x)*sr,(i*e.scale-e.y)*sr)}function Ag(e,t,i=0){return Mu.fromValues(((t.x-i)*e.scale-e.x)*sr,(t.y*e.scale-e.y)*sr,Wd(t.z,t.y))}const Sg=xu.identity(new Float32Array(16));class Ig{constructor(e){this.spec=e,this.name=e.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7];}project(e,t){return {x:0,y:0,z:0}}unproject(e,t){return new Nd(0,0)}projectTilePoint(e,t,i){return {x:e,y:t,z:0}}locationPoint(e,t,i=!0){return e._coordinatePoint(e.locationCoordinate(t),i)}pixelsPerMeter(e,t){return Zd(1,e)*t}pixelSpaceConversion(e,t,i){return 1}farthestPixelDistance(e){return wg(e,e.pixelsPerMeter)}pointCoordinate(e,t,i,r){const n=e.horizonLineFromTop(!1),o=new y(t,Math.max(n,i));return e.rayIntersectionCoordinate(e.pointRayIntersection(o,r))}pointCoordinate3D(e,t,i){const r=new y(t,i);if(e.elevation)return e.elevation.pointCoordinate(r);{const t=this.pointCoordinate(e,r.x,r.y,0);return [t.x,t.y,t.z]}}isPointAboveHorizon(e,t){if(e.elevation)return !this.pointCoordinate3D(e,t.x,t.y);const i=e.horizonLineFromTop();return t.y0?t<-Bg+i&&(t=-Bg+i):t>Bg-i&&(t=Bg-i);const o=n/Math.pow(Fg(t),r);let s=o*Math.sin(r*e),a=n-o*Math.cos(r*e);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,z:0}}unproject(e,t){e=(2*e-.5)*Math.PI,this.southernCenter&&(t=1-t),t=(2*(1-t)-.5)*Math.PI;const{n:i,f:r}=this,n=r-t,o=Math.sign(n),s=Math.sign(i)*Math.sqrt(e*e+n*n);let a=Math.atan2(e,Math.abs(n))*o;n*i<0&&(a-=Math.PI*Math.sign(e)*o);const l=z(T(a/i)+this.center[0],-180,180),c=z(T(2*Math.atan(Math.pow(r/s,1/i))-Bg),-Xd,Xd);return new Nd(l,this.southernCenter?-c:c)}}class Ug extends Ig{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null;}project(e,t){return {x:Gd(e),y:qd(t),z:0}}unproject(e,t){const i=$d(e),r=Hd(t);return new Nd(i,r)}}const Vg=w(Xd);class jg extends Ig{project(e,t){const i=(t=w(t))*t,r=i*i;return {x:.5*((e=w(e))*(.8707-.131979*i+r*(r*(.003971*i-.001529*r)-.013791))/Math.PI+.5),y:1-.5*(t*(1.007226+i*(.015085+r*(.028874*i-.044475-.005916*r)))/Math.PI+1),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI;let i=t=(2*(1-t)-1)*Math.PI,r=25,n=0,o=i*i;do{o=i*i;const e=o*o;n=(i*(1.007226+o*(.015085+e*(.028874*o-.044475-.005916*e)))-t)/(1.007226+o*(.045255+e*(.259866*o-.311325-.005916*11*e))),i=z(i-n,-Vg,Vg);}while(Math.abs(n)>1e-6&&--r>0);o=i*i;const s=z(T(e/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=T(i);return new Nd(s,a)}}const Gg=w(Xd);class qg extends Ig{project(e,t){t=w(t),e=w(e);const i=Math.cos(t),r=2/Math.PI,n=Math.acos(i*Math.cos(e/2)),o=Math.sin(n)/n,s=.5*(e*r+2*i*Math.sin(e/2)/o)||0,a=.5*(t+Math.sin(t)/o)||0;return {x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(e,t){let i=e=(2*e-.5)*Math.PI,r=t=(2*(1-t)-1)*Math.PI,n=25;const o=1e-6;let s=0,a=0;do{const n=Math.cos(r),o=Math.sin(r),l=2*o*n,c=o*o,h=n*n,u=Math.cos(i/2),d=Math.sin(i/2),p=2*u*d,f=d*d,m=1-h*u*u,_=m?1/m:0,g=m?Math.acos(n*u)*Math.sqrt(1/m):0,y=.5*(2*g*n*d+2*i/Math.PI)-e,x=.5*(g*o+r)-t,v=.5*_*(h*f+g*n*u*c)+1/Math.PI,b=_*(p*l/4-g*o*d),w=.125*_*(l*d-g*o*h*p),T=.5*_*(c*u+g*f*n)+.5,E=b*w-T*v;s=(x*b-y*T)/E,a=(y*w-x*v)/E,i=z(i-s,-Math.PI,Math.PI),r=z(r-a,-Gg,Gg);}while((Math.abs(s)>o||Math.abs(a)>o)&&--n>0);return new Nd(T(i),T(r))}}class Zg extends Ig{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(w(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0;}project(e,t){const{scale:i,cosPhi:r}=this;return {x:w(e)*r*i+.5,y:-Math.sin(w(t))/r*i+.5,z:0}}unproject(e,t){const{scale:i,cosPhi:r}=this,n=-(t-.5)/i,o=z(T((e-.5)/i)/r,-180,180),s=Math.asin(z(n*r,-1,1)),a=z(T(s),-Xd,Xd);return new Nd(o,a)}}class $g extends Ug{constructor(e){super(e),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5];}projectTilePoint(e,t,i){const r=_d(e,t,i),n=xd(ad(i));return Mu.transformMat4(r,r,n),{x:r[0],y:r[1],z:r[2]}}locationPoint(e,t){const i=md(t.lat,t.lng),r=Mu.normalize([],i),n=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(t),e._centerAltitude):e._centerAltitude,o=Zd(1,0)*sr*n;Mu.scaleAndAdd(i,i,r,o);const s=xu.identity(new Float64Array(16));return xu.multiply(s,e.pixelMatrix,e.globeMatrix),Mu.transformMat4(i,i,s),new y(i[0],i[1])}pixelsPerMeter(e,t){return Zd(1,0)*t}pixelSpaceConversion(e,t,i){const r=Zd(1,e)*t,n=Wr(Zd(1,45)*t,r,i);return this.pixelsPerMeter(e,t)/n}createTileMatrix(e,t,i){const r=vd(ad(i.canonical));return xu.multiply(new Float64Array(16),e.globeMatrix,r)}createInversionMatrix(e,t){const{center:i}=e,r=xd(ad(t));return xu.rotateY(r,r,w(i.lng)),xu.rotateX(r,r,w(i.lat)),xu.scale(r,r,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(r)}pointCoordinate(e,t,i,r){return nd(e,t,i,!0)||new ep(0,0)}pointCoordinate3D(e,t,i){const r=this.pointCoordinate(e,t,i,0);return [r.x,r.y,r.z]}isPointAboveHorizon(e,t){return !nd(e,t.x,t.y,!1)}farthestPixelDistance(e){const t=function(e,t){const i=e.cameraToCenterDistance,r=e._centerAltitude*t,n=e._camera,o=e._camera.forward(),s=Mu.add([],Mu.scale([],o,-i),[0,0,r]),a=e.worldSize/(2*Math.PI),l=[0,0,-a],c=e.width/e.height,h=Math.tan(e.fovAboveCenter),u=Mu.scale([],n.up(),h),d=Mu.scale([],n.right(),h*c),p=Mu.normalize([],Mu.add([],Mu.add([],o,u),d)),f=[];let m;if(new Uu(s,p).closestPointOnSphere(l,a,f)){const t=Mu.add([],f,l),i=Mu.sub([],t,s);m=Math.cos(e.fovAboveCenter)*Mu.length(i);}else {const e=Mu.sub([],s,l),t=Mu.sub([],l,s);Mu.normalize(t,t);const i=Mu.length(e)-a;m=Math.sqrt(i*(i+2*a));const r=Math.acos(m/(a+i))-Math.acos(Mu.dot(o,t));m*=Math.cos(r);}return 1.01*m}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),i=Ed(e.zoom);if(i>0){const r=wg(e,Zd(1,e.center.lat)*e.worldSize),n=e.worldSize/(2*Math.PI),o=Math.max(e.width,e.height)/e.worldSize*Math.PI;return Wr(t,r+n*(1-Math.cos(o)),Math.pow(i,10))}return t}upVector(e,t,i){return _d(t,i,e,1)}upVectorScale(e){return {metersToTile:rd(gd(ad(e)))}}}function Hg(e){const t=e.parallels,i=!!t&&Math.abs(t[0]+t[1])<.01;switch(e.name){case"mercator":return new Ug(e);case"equirectangular":return new Og(e);case"naturalEarth":return new jg(e);case"equalEarth":return new kg(e);case"winkelTripel":return new qg(e);case"albers":return i?new Zg(e):new Cg(e);case"lambertConformalConic":return i?new Zg(e):new Ng(e);case"globe":return new $g(e)}throw new Error(`Invalid projection name: ${e.name}`)}const Wg=new da({"symbol-placement":new ca(Ct.layout_symbol["symbol-placement"]),"symbol-spacing":new ca(Ct.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new ca(Ct.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new ha(Ct.layout_symbol["symbol-sort-key"]),"symbol-z-order":new ca(Ct.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new ca(Ct.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new ca(Ct.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new ca(Ct.layout_symbol["icon-ignore-placement"]),"icon-optional":new ca(Ct.layout_symbol["icon-optional"]),"icon-rotation-alignment":new ca(Ct.layout_symbol["icon-rotation-alignment"]),"icon-size":new ha(Ct.layout_symbol["icon-size"]),"icon-text-fit":new ha(Ct.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new ha(Ct.layout_symbol["icon-text-fit-padding"]),"icon-image":new ha(Ct.layout_symbol["icon-image"]),"icon-rotate":new ha(Ct.layout_symbol["icon-rotate"]),"icon-padding":new ca(Ct.layout_symbol["icon-padding"]),"icon-keep-upright":new ca(Ct.layout_symbol["icon-keep-upright"]),"icon-offset":new ha(Ct.layout_symbol["icon-offset"]),"icon-anchor":new ha(Ct.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new ca(Ct.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new ca(Ct.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new ca(Ct.layout_symbol["text-rotation-alignment"]),"text-field":new ha(Ct.layout_symbol["text-field"]),"text-font":new ha(Ct.layout_symbol["text-font"]),"text-size":new ha(Ct.layout_symbol["text-size"]),"text-max-width":new ha(Ct.layout_symbol["text-max-width"]),"text-line-height":new ha(Ct.layout_symbol["text-line-height"]),"text-letter-spacing":new ha(Ct.layout_symbol["text-letter-spacing"]),"text-justify":new ha(Ct.layout_symbol["text-justify"]),"text-radial-offset":new ha(Ct.layout_symbol["text-radial-offset"]),"text-variable-anchor":new ca(Ct.layout_symbol["text-variable-anchor"]),"text-anchor":new ha(Ct.layout_symbol["text-anchor"]),"text-max-angle":new ca(Ct.layout_symbol["text-max-angle"]),"text-writing-mode":new ca(Ct.layout_symbol["text-writing-mode"]),"text-rotate":new ha(Ct.layout_symbol["text-rotate"]),"text-padding":new ca(Ct.layout_symbol["text-padding"]),"text-keep-upright":new ca(Ct.layout_symbol["text-keep-upright"]),"text-transform":new ha(Ct.layout_symbol["text-transform"]),"text-offset":new ha(Ct.layout_symbol["text-offset"]),"text-allow-overlap":new ca(Ct.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new ca(Ct.layout_symbol["text-ignore-placement"]),"text-optional":new ca(Ct.layout_symbol["text-optional"]),visibility:new ca(Ct.layout_symbol.visibility)});var Xg={paint:new da({"icon-opacity":new ha(Ct.paint_symbol["icon-opacity"]),"icon-emissive-strength":new ha(Ct.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new ha(Ct.paint_symbol["text-emissive-strength"]),"icon-color":new ha(Ct.paint_symbol["icon-color"]),"icon-halo-color":new ha(Ct.paint_symbol["icon-halo-color"]),"icon-halo-width":new ha(Ct.paint_symbol["icon-halo-width"]),"icon-halo-blur":new ha(Ct.paint_symbol["icon-halo-blur"]),"icon-translate":new ca(Ct.paint_symbol["icon-translate"]),"icon-translate-anchor":new ca(Ct.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new ha(Ct.paint_symbol["icon-image-cross-fade"]),"text-opacity":new ha(Ct.paint_symbol["text-opacity"]),"text-color":new ha(Ct.paint_symbol["text-color"],{runtimeType:Gt,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new ha(Ct.paint_symbol["text-halo-color"]),"text-halo-width":new ha(Ct.paint_symbol["text-halo-width"]),"text-halo-blur":new ha(Ct.paint_symbol["text-halo-blur"]),"text-translate":new ca(Ct.paint_symbol["text-translate"]),"text-translate-anchor":new ca(Ct.paint_symbol["text-translate-anchor"])}),layout:Wg};class Yg{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:Nt,this.defaultValue=e;}evaluate(e){if(e.formattedSection){const t=this.defaultValue.property.overrides;if(t&&t.hasOverride(e.formattedSection))return t.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}}Is(Yg,"FormatSectionOverride",{omit:["defaultValue"]});class Kg extends _a{constructor(e,t){super(e,Xg,t);}recalculate(e,t){super.recalculate(e,t),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const i=this.layout.get("text-writing-mode");if(i){const e=[];for(const t of i)e.indexOf(t)<0&&e.push(t);this.layout._values["text-writing-mode"]=e;}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides();}getValueAndResolveTokens(e,t,i,r){const n=this.layout.get(e).evaluate(t,{},i,r),o=this._unevaluatedLayout._values[e];return o.isDataDriven()||yo(o.value)||!n?n:function(e,t){return t.replace(/{([^{}]+)}/g,((t,i)=>i in e?String(e[i]):""))}(t.properties,n)}createBucket(e){return new cy(e)}queryRadius(){return 0}queryIntersectsFeature(){return !1}_setPaintOverrides(){for(const e of Xg.paint.overridableProperties){if(!Kg.hasPaintOverride(this.layout,e))continue;const t=this.paint.get(e),i=new Yg(t),r=new go(i,t.property.specification);let n=null;n="constant"===t.value.kind||"source"===t.value.kind?new vo("source",r):new bo("composite",r,t.value.zoomStops,t.value._interpolationType),this.paint._values[e]=new aa(t.property,n,t.parameters);}}_handleOverridablePaintPropertyUpdate(e,t,i){return !(!this.layout||t.isDataDriven()||i.isDataDriven())&&Kg.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){const i=e.get("text-field"),r=Xg.paint.properties[t];let n=!1;const o=e=>{for(const t of e)if(r.overrides&&r.overrides.hasOverride(t))return void(n=!0)};if("constant"===i.value.kind&&i.value.value instanceof ui)o(i.value.value.sections);else if("source"===i.value.kind){const e=t=>{n||(t instanceof yi&&mi(t.value)===Ht?o(t.value.sections):t instanceof Ti?o(t.sections):t.eachChild(e));},t=i.value;t._styleExpression&&e(t._styleExpression.expression);}return n}getProgramIds(){const e=0!==this.paint.get("icon-opacity").constantOr(1),t=0!==this.paint.get("text-opacity").constantOr(1),i=[];return e&&i.push("symbolIcon"),t&&i.push("symbolSDF"),i}getDefaultProgramParams(e,t){return {config:new $l(this,t),overrideFog:!1}}}const Jg=im.types,Qg=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function ey(e,t,i,r,n,o,s,a,l,c,h,u,d){const p=a?Math.min(_g,Math.round(a[0])):0,f=a?Math.min(_g,Math.round(a[1])):0;e.emplaceBack(t,i,Math.round(32*r),Math.round(32*n),o,s,(p<<1)+(l?1:0),f,16*c,16*h,256*u,256*d);}function ty(e,t,i){e.emplaceBack(t,i);}function iy(e,t,i,r,n,o,s){e.emplaceBack(t,i,r,n,o,s);}function ry(e,t,i,r,n){const o=5*t+2;e.float32[o+0]=i,e.float32[o+1]=r,e.float32[o+2]=n;}function ny(e,t,i,r,n){e.emplaceBack(t,i,r,n),e.emplaceBack(t,i,r,n),e.emplaceBack(t,i,r,n),e.emplaceBack(t,i,r,n);}function oy(e){for(const t of e.sections)if(Vs(t.text))return !0;return !1}class sy{constructor(e){this.layoutVertexArray=new Pa,this.indexArray=new Va,this.programConfigurations=e,this.segments=new dl,this.dynamicLayoutVertexArray=new Ia,this.opacityVertexArray=new La,this.placedSymbolArray=new il,this.iconTransitioningVertexArray=new ka,this.globeExtVertexArray=new Ra,this.zOffsetVertexArray=new qa;}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length&&0===this.iconTransitioningVertexArray.length}upload(e,t,i,r,n){this.isEmpty()||(i&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Wm.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,Ym.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,Qg,!0),this.iconTransitioningVertexArray.length>0&&(this.iconTransitioningVertexBuffer=e.createVertexBuffer(this.iconTransitioningVertexArray,Jm.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,Xm.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||n)&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,Km.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||r)&&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(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy());}}Is(sy,"SymbolBuffers");class ay{constructor(e,t,i){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new i,this.segments=new dl,this.collisionVertexArray=new Na,this.collisionVertexArrayExt=new Ua;}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,Qm.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,e_.members,!0);}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy());}}Is(ay,"CollisionBuffers");class ly{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.fqid)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=xu.identity([]),this.placementViewportMatrix=xu.identity([]);const t=this.layers[0]._unevaluatedLayout._values;this.textSizeData=o_(this.zoom,t["text-size"]),this.iconSizeData=o_(this.zoom,t["icon-size"]);const i=this.layers[0].layout,r=i.get("symbol-sort-key"),n=i.get("symbol-z-order");this.canOverlap=i.get("text-allow-overlap")||i.get("icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==n&&void 0!==r.constantOr(1),this.sortFeaturesByY=("viewport-y"===n||"auto"===n&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=i.get("text-writing-mode").map((e=>w_[e])),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.sourceID=e.sourceID,this.projection=e.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=i.get("symbol-z-elevate");}createArrays(){this.text=new sy(new Hl(this.layers,this.zoom,(e=>/^text/.test(e)))),this.icon=new sy(new Hl(this.layers,this.zoom,(e=>/^icon/.test(e)))),this.glyphOffsetArray=new ol,this.lineVertexArray=new sl,this.symbolInstances=new nl;}calculateGlyphDependencies(e,t,i,r,n){for(let i=0;i0)&&("constant"!==a.value.kind||a.value.value.length>0),u="constant"!==c.value.kind||!!c.value.value||Object.keys(c.parameters).length>0,d=o.get("symbol-sort-key");if(this.features=[],!h&&!u)return;const p=t.iconDependencies,f=t.glyphDependencies,m=t.availableImages,_=new ea(this.zoom);for(const{feature:t,id:l,index:c,sourceLayerIndex:g}of e){const e=n._featureFilter.needGeometry,y=cp(t,e);if(!n._featureFilter.filter(_,y,i))continue;if(e||(y.geometry=lp(t,i,r)),s&&1!==t.type&&i.z<=5){const e=y.geometry,t=.98078528056,r=(e,r)=>{const n=_d(e.x,e.y,i,1),o=_d(r.x,r.y,i,1);return Mu.dot(n,o)=0;for(const i of x.sections)if(i.image)p[i.image.namePrimary]=!0;else {const r=Ls(x.toString()),n=i.fontStack||e,o=f[n]=f[n]||{};this.calculateGlyphDependencies(i.text,o,t,this.allowVerticalPlacement,r);}}}"line"===o.get("symbol-placement")&&(this.features=function(e){const t={},i={},r=[];let n=0;function o(t){r.push(e[t]),n++;}function s(e,t,n){const o=i[e];return delete i[e],i[t]=o,r[o].geometry[0].pop(),r[o].geometry[0]=r[o].geometry[0].concat(n[0]),o}function a(e,i,n){const o=t[i];return delete t[i],t[e]=o,r[o].geometry[0].shift(),r[o].geometry[0]=n[0].concat(r[o].geometry[0]),o}function l(e,t,i){const r=i?t[0][t[0].length-1]:t[0][0];return `${e}:${r.x}:${r.y}`}for(let c=0;ce.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((e,t)=>e.sortKey-t.sortKey));}update(e,t,i,r,n){const o=0!==Object.keys(e).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(e,t,s,i,r,n),this.icon.programConfigurations.updatePaintArrays(e,t,s,i,r,n);}updateZOffset(){const e=(e,t,r)=>{i+=t,i>e.length&&e.resize(i);for(let n=-t;n<0;n++)e.emplace(n+i,r);},t=(e,t,i)=>{r+=t,r>e.length&&e.resize(r);for(let n=-t;n<0;n++)e.emplace(n+r,i);};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let i=0,r=0;for(let i=0;i0;if((n>0||o>0)&&(e(this.text.zOffsetVertexArray,n,a),e(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:e,verticalPlacedIconSymbolIndex:i}=r;e>=0&&t(this.icon.zOffsetVertexArray,s,a),i>=0&&t(this.icon.zOffsetVertexArray,r.numVerticalIconVertices,a);}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray);}isEmpty(){return 0===this.symbolInstances.length&&!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.zOffsetBuffersNeedUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.uploaded=!0;}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy();}getProjection(){return this.projectionInstance||(this.projectionInstance=Hg(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData();}addToLineVertexArray(e,t){const i=this.lineVertexArray.length;if(void 0!==e.segment)for(const{x:e,y:i}of t)this.lineVertexArray.emplaceBack(e,i);return {lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m){const _=e.indexArray,g=e.layoutVertexArray,y=e.globeExtVertexArray,x=e.segments.prepareSegment(4*t.length,g,_,this.canOverlap?o.sortKey:void 0),v=this.glyphOffsetArray.length,b=x.vertexLength,w=this.allowVerticalPlacement&&s===w_.vertical?Math.PI/2:0,T=o.text&&o.text.sections;for(let r=0;r=0?t.rightJustifiedTextSymbolIndex:t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.leftJustifiedTextSymbolIndex>=0?t.leftJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex>=0?t.verticalPlacedTextSymbolIndex:r),o=s_(this.textSizeData,e,n)/r_;return this.tilePixelRatio*o}getSymbolInstanceIconSize(e,t,i){const r=this.icon.placedSymbolArray.get(i),n=s_(this.iconSizeData,e,r);return this.tilePixelRatio*n}_commitDebugCollisionVertexUpdate(e,t,i){e.emplaceBack(t,-i,-i),e.emplaceBack(t,i,-i),e.emplaceBack(t,i,i),e.emplaceBack(t,-i,i);}_updateTextDebugCollisionBoxes(e,t,i,r,n,o){for(let s=r;s0}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}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(e,t){const i=e.placedSymbolArray.get(t),r=i.vertexStartIndex+4*i.numGlyphs;for(let t=i.vertexStartIndex;tr[e]-r[t]||n[t]-n[e])),o}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let e=0;ethis.symbolInstances.get(t).zOffset-this.symbolInstances.get(e).zOffset))}addToSortKeyRanges(e,t){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===t?i.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:t,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 e of this.symbolInstanceIndexes){const t=this.symbolInstances.get(e);this.featureSortOrder.push(t.featureIndex);const{rightJustifiedTextSymbolIndex:i,centerJustifiedTextSymbolIndex:r,leftJustifiedTextSymbolIndex:n,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=t;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),r>=0&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),n>=0&&n!==r&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a);}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray);}}}Is(ly,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),ly.MAX_GLYPHS=65535,ly.addDynamicAttributes=ny;var cy=ly;const hy=ba([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_linesofar",components:1,type:"Float32"}],4),{members:uy}=hy,dy=ba([{name:"a_packed",components:4,type:"Float32"}]),{members:py}=dy,fy=im.types,my=Math.cos(Math.PI/180*37.5);class _y{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.fqid)),this.index=e.index,this.projection=e.projection,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((e=>{this.gradients[e.id]={};})),this.layoutVertexArray=new Sa,this.layoutVertexArray2=new Ia,this.indexArray=new Va,this.programConfigurations=new Hl(e.layers,e.zoom),this.segments=new dl,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id));}populate(e,t,i,r){this.hasPattern=Pf("line",this.layers,t);const n=this.layers[0].layout.get("line-sort-key"),o=[];for(const{feature:t,id:s,index:a,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=cp(t,e);if(!this.layers[0]._featureFilter.filter(new ea(this.zoom),c,i))continue;const h=n?n.evaluate(c,{},i):void 0,u={id:s,properties:t.properties,type:t.type,sourceLayerIndex:l,index:a,geometry:e?c.geometry:lp(t,i,r),patterns:{},sortKey:h};o.push(u);}n&&o.sort(((e,t)=>e.sortKey-t.sortKey));const{lineAtlas:s,featureIndex:a}=t,l=this.addConstantDashes(s);for(const r of o){const{geometry:n,index:o,sourceLayerIndex:c}=r;if(l&&this.addFeatureDashes(r,s),this.hasPattern){const e=Rf("line",this.layers,r,this.zoom,t);this.patternFeatures.push(e);}else this.addFeature(r,n,o,i,s.positions,t.availableImages,t.brightness);a.insert(e[o].feature,n,o,c,this.index);}}addConstantDashes(e){let t=!1;for(const i of this.layers){const r=i.paint.get("line-dasharray").value,n=i.layout.get("line-cap").value;if("constant"!==r.kind||"constant"!==n.kind)t=!0;else {const t=n.value,i=r.value;if(!i)continue;e.addDash(i,t);}}return t}addFeatureDashes(e,t){const i=this.zoom;for(const r of this.layers){const n=r.paint.get("line-dasharray").value,o=r.layout.get("line-cap").value;if("constant"===n.kind&&"constant"===o.kind)continue;let s,a;if("constant"===n.kind){if(s=n.value,!s)continue}else s=n.evaluate({zoom:i},e);a="constant"===o.kind?o.value:o.evaluate({zoom:i},e),t.addDash(s,a),e.patterns[r.id]=t.getKey(s,a);}}update(e,t,i,r,n){const o=0!==Object.keys(e).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(e,t,o?this.stateDependentLayers:this.layers,i,r,n);}addFeatures(e,t,i,r,n,o){for(const e of this.patternFeatures)this.addFeature(e,e.geometry,e.index,t,i,r,o);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,py)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,uy),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&&e.properties.hasOwnProperty("mapbox_clip_start")&&e.properties.hasOwnProperty("mapbox_clip_end"))return {start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,t,i,r,n,o,s){const a=this.layers[0].layout,l=a.get("line-join").evaluate(e,{}),c=a.get("line-cap").evaluate(e,{}),h=a.get("line-miter-limit"),u=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const i of t)this.addLine(i,e,l,c,h,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,n,o,r,s);}addLine(e,t,i,r,n,o){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let t=0;t=2&&e[a-1].equals(e[a-2]);)a--;let l=0;for(;l0;if(b&&t>l){const e=u.dist(d);if(e>2*c){const t=u.sub(u.sub(d)._mult(c/e)._round());this.updateDistance(d,t),this.addCurrentVertex(t,f,0,0,h),d=t;}}const T=d&&p;let E=T?i:s?"butt":r;if(T&&"round"===E&&(xn&&(E="bevel"),"bevel"===E&&(x>2&&(E="flipbevel"),x100)_=m.mult(-1);else {const e=x*f.add(m).mag()/f.sub(m).mag();_._perp()._mult(e*(w?-1:1));}this.addCurrentVertex(u,_,0,0,h),this.addCurrentVertex(u,_.mult(-1),0,0,h);}else if("bevel"===E||"fakeround"===E){const e=-Math.sqrt(x*x-1),t=w?e:0,i=w?0:e;if(d&&this.addCurrentVertex(u,f,t,i,h),"fakeround"===E){const e=Math.round(180*v/Math.PI/20);for(let t=1;t2*c){const t=u.add(p.sub(u)._mult(c/e)._round());this.updateDistance(u,t),this.addCurrentVertex(t,m,0,0,h),u=t;}}}}addCurrentVertex(e,t,i,r,n,o=!1){const s=t.y*r-t.x,a=-t.y-t.x*r;this.addHalfVertex(e,t.x+t.y*i,t.y-t.x*i,o,!1,i,n),this.addHalfVertex(e,s,a,o,!0,-r,n);}addHalfVertex({x:e,y:t},i,r,n,o,s,a){this.layoutVertexArray.emplaceBack((e<<1)+(n?1:0),(t<<1)+(o?1:0),Math.round(63*i)+128,Math.round(63*r)+128,1+(0===s?0:s<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineClips.start,this.lineClips.end);const l=a.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,l),a.primitiveLength++),o?this.e2=l:this.e1=l;}updateScaledDistance(){if(this.lineClips){const e=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=e*this.lineClips.start+this.distance;}else this.lineSoFar=this.distance;}updateDistance(e,t){this.distance+=e.dist(t),this.updateScaledDistance();}}Is(_y,"LineBucket",{omit:["layers","patternFeatures"]});class gy{constructor(e,t,i,r){this.context=e,this.format=i,this.texture=e.gl.createTexture(),this.update(t,r);}update(e,i,r){const{width:n,height:o}=e,{context:s}=this,{gl:a}=s,{HTMLImageElement:l,HTMLCanvasElement:c,HTMLVideoElement:h,ImageData:u,ImageBitmap:d}=t;if(a.bindTexture(a.TEXTURE_2D,this.texture),s.pixelStoreUnpackFlipY.set(!1),s.pixelStoreUnpack.set(1),s.pixelStoreUnpackPremultiplyAlpha.set(this.format===a.RGBA&&(!i||!1!==i.premultiply)),r||this.size&&this.size[0]===n&&this.size[1]===o){const{x:t,y:i}=r||{x:0,y:0};if(e instanceof l||e instanceof c||e instanceof h||e instanceof u||d&&e instanceof d)a.texSubImage2D(a.TEXTURE_2D,0,t,i,a.RGBA,a.UNSIGNED_BYTE,e);else {let r=this.format,s=a.UNSIGNED_BYTE;this.format===a.R32F&&(r=a.RED,s=a.FLOAT),a.texSubImage2D(a.TEXTURE_2D,0,t,i,n,o,r,s,e.data);}}else if(this.size=[n,o],e instanceof l||e instanceof c||e instanceof h||e instanceof u||d&&e instanceof d){let t=this.format;this.format===a.R8&&(t=a.RED),a.texImage2D(a.TEXTURE_2D,0,this.format,t,a.UNSIGNED_BYTE,e);}else {let t=this.format,i=this.format,r=a.UNSIGNED_BYTE;this.format===a.DEPTH_COMPONENT&&(t=a.DEPTH_COMPONENT16,r=a.UNSIGNED_SHORT),this.format===a.R32F&&(r=a.FLOAT,i=a.RED),a.texImage2D(a.TEXTURE_2D,0,t,n,o,0,i,r,e.data);}this.useMipmap=Boolean(i&&i.useMipmap),this.useMipmap&&a.generateMipmap(a.TEXTURE_2D);}bind(e,t){const{context:i}=this,{gl:r}=i;r.bindTexture(r.TEXTURE_2D,this.texture),e!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap?e===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_NEAREST:e),this.minFilter=e),t!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,t),this.wrapS=t);}bindExtraParam(e,t,i,r){const{context:n}=this,{gl:o}=n;o.bindTexture(o.TEXTURE_2D,this.texture),t!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,t),this.magFilter=t),e!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?e===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_NEAREST:e),this.minFilter=e),i!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),this.wrapS=i),r!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,r),this.wrapT=r);}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null;}}class yy{constructor(e,t){this.context=e,this.texture=t;}bind(e,t){const{context:i}=this,{gl:r}=i;r.bindTexture(r.TEXTURE_2D,this.texture),e!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,e),this.minFilter=e),t!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,t),this.wrapS=t);}}const xy=32,vy=33,by=new Uint16Array(8184);for(let e=0;e<2046;e++){let t=e+2,i=0,r=0,n=0,o=0,s=0,a=0;for(1&t?n=o=s=xy:i=r=a=xy;(t>>=1)>1;){const e=i+n>>1,l=r+o>>1;1&t?(n=i,o=r,i=s,r=a):(i=n,r=o,n=s,o=a),s=e,a=l;}const l=4*e;by[l+0]=i,by[l+1]=r,by[l+2]=n,by[l+3]=o;}const wy=new Uint16Array(2178),Ty=new Uint8Array(1089),Ey=new Uint16Array(1089);function My(e){return 0===e?-.03125:32===e?.03125:0}var Ay=ba([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const Sy={type:2,extent:sr,loadGeometry:()=>[[new y(0,0),new y(sr+1,0),new y(sr+1,sr+1),new y(0,sr+1),new y(0,0)]]};class Iy{constructor(e,t,i,r,n){this.tileID=e,this.uid=F(),this.uses=0,this.tileSize=t,this.tileZoom=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=n,r&&r.style&&(this._lastUpdatedBrightness=r.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",r&&r.transform&&(this.projection=r.transform.projection);}registerFadeDuration(e){const t=e+this.timeAdded;tt.getLayer(e))).filter(Boolean);if(0!==e.length){r.layers=e,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map((t=>e.filter((e=>e.id===t))[0])));for(const t of e)i[t.fqid]=r;}}return i}(e.buckets,t.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const t=this.buckets[e];if(t instanceof cy){if(this.hasSymbolBuckets=!0,!i)break;t.justReloaded=!0;}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const t=this.buckets[e];if(t instanceof cy&&t.hasRTLText){this.hasRTLText=!0,Qs.isLoading()||Qs.isLoaded()||"deferred"!==Ks()||Js();break}}this.queryPadding=0;for(const e in this.buckets){const i=this.buckets[e],r=t.style.getOwnLayer(e);if(!r)continue;const n=r.queryRadius(i);this.queryPadding=Math.max(this.queryPadding,n);}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),e.lineAtlas&&(this.lineAtlas=e.lineAtlas),this._lastUpdatedBrightness=e.brightness;}else this.collisionBoxArray=new el;}unloadVectorData(){if(this.hasData()){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded";}}getBucket(e){return this.buckets[e.fqid]}upload(e){for(const t in this.buckets){const i=this.buckets[t];i.uploadPending()&&i.upload(e);}const t=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new gy(e,this.imageAtlas.image,t.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new gy(e,this.glyphAtlasImage,t.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new gy(e,this.lineAtlas.image,t.ALPHA),this.lineAtlas.uploaded=!0);}prepare(e,t,i){if(this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture,i),!t||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const r=t.style.getBrightness();(this._lastUpdatedBrightness||r)&&(this._lastUpdatedBrightness&&r&&Math.abs(this._lastUpdatedBrightness-r)<.001||(this._lastUpdatedBrightness=r,this.updateBuckets(void 0,t)));}queryRenderedFeatures(e,t,i,r,n,o,s,a){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:r,pixelPosMatrix:s,transform:o,params:n,tileTransform:this.tileTransform},e,t,i):{}}querySourceFeatures(e,t){const i=this.latestFeatureIndex;if(!i||!i.rawTileData)return;const r=i.loadVTLayers(),n=t?t.sourceLayer:"",o=r._geojsonTileLayer||r[n];if(!o)return;const s=Ro(t&&t.filter),{z:a,x:l,y:c}=this.tileID.canonical,h={z:a,x:l,y:c};for(let t=0;te)i=!1;else if(t)if(this.expirationTime=0;e--){const t=4*e,i=by[t+0],r=by[t+1],n=by[t+2],o=by[t+3],s=i+n>>1,a=r+o>>1,l=s+a-r,c=a+i-s,h=r*vy+i,u=o*vy+n,d=a*vy+s,p=Math.hypot((wy[2*h+0]+wy[2*u+0])/2-wy[2*d+0],(wy[2*h+1]+wy[2*u+1])/2-wy[2*d+1])>=16;Ty[d]=Ty[d]||(p?1:0),e<1022&&(Ty[d]=Ty[d]||Ty[(r+c>>1)*vy+(i+l>>1)]||Ty[(o+c>>1)*vy+(n+l>>1)]);}const n=new Ma,o=new Va;let s=0;function a(e,t){const i=t*vy+e;return 0===Ey[i]&&(n.emplaceBack(wy[2*i+0],wy[2*i+1],e*sr/xy,t*sr/xy),Ey[i]=++s),Ey[i]-1}function l(e,t,i,r,n,s){const c=e+i>>1,h=t+r>>1;if(Math.abs(e-n)+Math.abs(t-s)>1&&Ty[h*vy+c])l(n,s,e,t,c,h),l(i,r,n,s,c,h);else {const l=a(e,t),c=a(i,r),h=a(n,s);o.emplaceBack(l,c,h);}}return l(0,0,xy,xy,xy,0),l(xy,xy,0,0,0,xy),{vertices:n,indices:o}}(this.tileID.canonical,t);r=e.vertices,n=e.indices;}else {r=new Ma,n=new Va;for(const{x:e,y:t}of i)r.emplaceBack(e,t,0,0);const e=Cf(r.int16,void 0,4);for(let t=0;t0&&(s=xu.invert(new Float64Array(16),t.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(e,r,t,n,s,o),this._makeGlobeTileDebugTextBuffer(e,r,t,n,s,o);}_globePoint(e,t,i,r,n,o,s){let a=_d(e,t,i);if(o){const n=1<.5?u=-1:h<-.5&&(u=1);let d=(e/sr+i.x)/n+u,p=(t/sr+i.y)/n;d=(d-l)*r._pixelsPerMercatorPixel+l,p=(p-c)*r._pixelsPerMercatorPixel+c;const f=[d*r.worldSize,p*r.worldSize,0];Mu.transformMat4(f,f,o),a=ld(a,f,s);}return Mu.transformMat4(a,a,n)}_makeGlobeTileDebugBorderBuffer(e,t,i,r,n,o){const s=new Ta,a=new Wa,l=new Ea,c=(e,c,h,u,d)=>{const p=(h-e)/(d-1),f=(u-c)/(d-1),m=s.length;for(let h=0;hh*e+t;for(let e=0;e{this.remove(e,n);}),i)),this.data[r].push(n),this.order.push(r),this.order.length>this.max){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e);}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const t=this.data[e].shift();return t.timeout&&clearTimeout(t.timeout),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),t.value}getByKey(e){const t=this.data[e];return t?t[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,t){if(!this.has(e))return this;const i=e.wrapped().key,r=void 0===t?0:this.data[i].indexOf(t),n=this.data[i][r];return this.data[i].splice(r,1),n.timeout&&clearTimeout(n.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(n.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e);}return this}filter(e){const t=[];for(const i in this.data)for(const r of this.data[i])e(r.value)||t.push(r);for(const e of t)this.remove(e.value.tileID,e);}}class zy{constructor(e,t,i,r){this.id=zy.uniqueIdxCounter,zy.uniqueIdxCounter++,this.context=e;const n=e.gl;this.buffer=n.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?n.DYNAMIC_DRAW:n.STATIC_DRAW),this.dynamicDraw||r||t.destroy();}bind(){this.context.bindElementBuffer.set(this.buffer);}updateData(e){this.id=zy.uniqueIdxCounter,zy.uniqueIdxCounter++;const t=this.context.gl;this.context.unbindVAO(),this.bind(),t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer);}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer);}}zy.uniqueIdxCounter=0;const Dy={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Py{constructor(e,t,i,r,n,o){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=r,this.instanceCount=o,this.context=e;const s=e.gl;this.buffer=s.createBuffer(),e.bindVertexBuffer.set(this.buffer),s.bufferData(s.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?s.DYNAMIC_DRAW:s.STATIC_DRAW),this.dynamicDraw||n||t.destroy();}bind(){this.context.bindVertexBuffer.set(this.buffer);}updateData(e){const t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer);}enableAttributes(e,t){for(let i=0;i0&&e.vertexAttribDivisor(n,i);}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer);}}class Ry{constructor(e){this.gl=e.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1;}get(){return this.current}set(e){}getDefault(){return this.default}setDefault(){this.set(this.default);}}class Ly extends Ry{getDefault(){return li.transparent}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.clearColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1);}}class ky extends Ry{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1);}}class Oy extends Ry{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1);}}class By extends Ry{getDefault(){return [!0,!0,!0,!0]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.colorMask(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1);}}class Fy extends Ry{getDefault(){return !0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1);}}class Ny extends Ry{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1);}}class Uy extends Ry{getDefault(){return {func:this.gl.ALWAYS,ref:0,mask:255}}set(e){const t=this.current;(e.func!==t.func||e.ref!==t.ref||e.mask!==t.mask||this.dirty)&&(this.gl.stencilFunc(e.func,e.ref,e.mask),this.current=e,this.dirty=!1);}}class Vy extends Ry{getDefault(){const e=this.gl;return [e.KEEP,e.KEEP,e.KEEP]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||this.dirty)&&(this.gl.stencilOp(e[0],e[1],e[2]),this.current=e,this.dirty=!1);}}class jy extends Ry{getDefault(){return !1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),this.current=e,this.dirty=!1;}}class Gy extends Ry{getDefault(){return [0,1]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||this.dirty)&&(this.gl.depthRange(e[0],e[1]),this.current=e,this.dirty=!1);}}class qy extends Ry{getDefault(){return !1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST),this.current=e,this.dirty=!1;}}class Zy extends Ry{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1);}}class $y extends Ry{getDefault(){return !1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.BLEND):t.disable(t.BLEND),this.current=e,this.dirty=!1;}}class Hy extends Ry{getDefault(){const e=this.gl;return [e.ONE,e.ZERO,e.ONE,e.ZERO]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.blendFuncSeparate(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1);}}class Wy extends Ry{getDefault(){return li.transparent}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.blendColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1);}}class Xy extends Ry{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquationSeparate(e,e),this.current=e,this.dirty=!1);}}class Yy extends Ry{getDefault(){return !1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE),this.current=e,this.dirty=!1;}}class Ky extends Ry{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1);}}class Jy extends Ry{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1);}}let Qy=class extends Ry{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1);}};class ex extends Ry{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1);}}class tx extends Ry{getDefault(){const e=this.gl;return [0,0,e.drawingBufferWidth,e.drawingBufferHeight]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.viewport(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1);}}class ix extends Ry{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,e),this.current=e,this.dirty=!1;}}class rx extends Ry{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindRenderbuffer(t.RENDERBUFFER,e),this.current=e,this.dirty=!1;}}class nx extends Ry{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindTexture(t.TEXTURE_2D,e),this.current=e,this.dirty=!1;}}class ox extends Ry{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindBuffer(t.ARRAY_BUFFER,e),this.current=e,this.dirty=!1;}}class sx extends Ry{getDefault(){return null}set(e){const t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1;}}class ax extends Ry{getDefault(){return null}set(e){this.gl&&(e!==this.current||this.dirty)&&(this.gl.bindVertexArray(e),this.current=e,this.dirty=!1);}}class lx extends Ry{getDefault(){return 4}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_ALIGNMENT,e),this.current=e,this.dirty=!1;}}class cx extends Ry{getDefault(){return !1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e),this.current=e,this.dirty=!1;}}class hx extends Ry{getDefault(){return !1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e),this.current=e,this.dirty=!1;}}class ux extends Ry{constructor(e,t){super(e),this.context=e,this.parent=t;}getDefault(){return null}}class dx extends ux{setDirty(){this.dirty=!0;}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1;}}class px extends ux{attachment(){return this.gl.DEPTH_ATTACHMENT}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,this.attachment(),t.RENDERBUFFER,e),this.current=e,this.dirty=!1;}}class fx extends ux{attachment(){return this.gl.DEPTH_ATTACHMENT}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,this.attachment(),t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1;}}class mx extends px{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}class _x{constructor(e,t,i,r,n){this.context=e,this.width=t,this.height=i;const o=this.framebuffer=e.gl.createFramebuffer();r&&(this.colorAttachment=new dx(e,o)),n&&(this.depthAttachmentType=n,this.depthAttachment="renderbuffer"===n?new px(e,o):new fx(e,o));}destroy(){const e=this.context.gl;if(this.colorAttachment){const t=this.colorAttachment.get();t&&e.deleteTexture(t);}if(this.depthAttachment&&this.depthAttachmentType)if("renderbuffer"===this.depthAttachmentType){const t=this.depthAttachment.get();t&&e.deleteRenderbuffer(t);}else {const t=this.depthAttachment.get();t&&e.deleteTexture(t);}e.deleteFramebuffer(this.framebuffer);}}class gx{constructor(e,t,i){this.func=e,this.mask=t,this.range=i;}}gx.ReadOnly=!1,gx.ReadWrite=!0,gx.disabled=new gx(519,gx.ReadOnly,[0,1]);const yx=7680;class xx{constructor(e,t,i,r,n,o){this.test=e,this.ref=t,this.mask=i,this.fail=r,this.depthFail=n,this.pass=o;}}xx.disabled=new xx({func:519,mask:0},0,0,yx,yx,yx);const vx=771;class bx{constructor(e,t,i,r){this.blendFunction=e,this.blendColor=t,this.mask=i,this.blendEquation=r;}}bx.Replace=[1,0,1,0],bx.disabled=new bx(bx.Replace,li.transparent,[!1,!1,!1,!1]),bx.unblended=new bx(bx.Replace,li.transparent,[!0,!0,!0,!0]),bx.alphaBlended=new bx([1,vx,1,vx],li.transparent,[!0,!0,!0,!0]),bx.multiply=new bx([774,0,774,0],li.transparent,[!0,!0,!0,!0]);const wx=1029,Tx=2305;class Ex{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i;}}Ex.disabled=new Ex(!1,wx,Tx),Ex.backCCW=new Ex(!0,wx,Tx),Ex.backCW=new Ex(!0,wx,2304),Ex.frontCW=new Ex(!0,1028,2304),Ex.frontCCW=new Ex(!0,1028,Tx);class Mx{constructor(e){this.gl=e,this.clearColor=new Ly(this),this.clearDepth=new ky(this),this.clearStencil=new Oy(this),this.colorMask=new By(this),this.depthMask=new Fy(this),this.stencilMask=new Ny(this),this.stencilFunc=new Uy(this),this.stencilOp=new Vy(this),this.stencilTest=new jy(this),this.depthRange=new Gy(this),this.depthTest=new qy(this),this.depthFunc=new Zy(this),this.blend=new $y(this),this.blendFunc=new Hy(this),this.blendColor=new Wy(this),this.blendEquation=new Xy(this),this.cullFace=new Yy(this),this.cullFaceSide=new Ky(this),this.frontFace=new Jy(this),this.program=new Qy(this),this.activeTexture=new ex(this),this.viewport=new tx(this),this.bindFramebuffer=new ix(this),this.bindRenderbuffer=new rx(this),this.bindTexture=new nx(this),this.bindVertexBuffer=new ox(this),this.bindElementBuffer=new sx(this),this.bindVertexArrayOES=new ax(this),this.pixelStoreUnpack=new lx(this),this.pixelStoreUnpackPremultiplyAlpha=new cx(this),this.pixelStoreUnpackFlipY=new hx(this),this.extTextureFilterAnisotropic=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=e.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.extTextureFilterAnisotropicForceOff=!1,this.extStandardDerivativesForceOff=!1,this.extDebugRendererInfo=e.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=e.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=e.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),this.extTextureFloatLinear=e.getExtension("OES_texture_float_linear"),this.extRenderToTextureHalfFloat=e.getExtension("EXT_color_buffer_half_float"),this.extTimerQuery=e.getExtension("EXT_disjoint_timer_query_webgl2"),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE);}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.bindVertexArrayOES.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0;}createIndexBuffer(e,t,i){return new zy(this,e,t,i)}createVertexBuffer(e,t,i,r,n){return new Py(this,e,t,i,r,n)}createRenderbuffer(e,t,i){const r=this.gl,n=r.createRenderbuffer();return this.bindRenderbuffer.set(n),r.renderbufferStorage(r.RENDERBUFFER,e,t,i),this.bindRenderbuffer.set(null),n}createFramebuffer(e,t,i,r){return new _x(this,e,t,i,r)}clear({color:e,depth:t,stencil:i,colorMask:r}){const n=this.gl;let o=0;e&&(o|=n.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set(r||[!0,!0,!0,!0])),void 0!==t&&(o|=n.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(t),this.depthMask.set(!0)),void 0!==i&&(o|=n.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),n.clear(o);}setCullFace(e){!1===e.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(e.mode),this.frontFace.set(e.frontFace));}setDepthMode(e){e.func!==this.gl.ALWAYS||e.mask?(this.depthTest.set(!0),this.depthFunc.set(e.func),this.depthMask.set(e.mask),this.depthRange.set(e.range)):this.depthTest.set(!1);}setStencilMode(e){e.test.func!==this.gl.ALWAYS||e.mask?(this.stencilTest.set(!0),this.stencilMask.set(e.mask),this.stencilOp.set([e.fail,e.depthFail,e.pass]),this.stencilFunc.set({func:e.test.func,ref:e.ref,mask:e.test.mask})):this.stencilTest.set(!1);}setColorMode(e){x(e.blendFunction,bx.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(e.blendFunction),this.blendColor.set(e.blendColor),e.blendEquation?this.blendEquation.set(e.blendEquation):this.blendEquation.setDefault()),this.colorMask.set(e.mask);}unbindVAO(){this.bindVertexArrayOES.set(null);}}class Ax extends It{constructor(e,t,i){super(),this.id=e,this._onlySymbols=i,t.on("data",(e=>{"source"===e.dataType&&"metadata"===e.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===e.dataType&&"content"===e.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform));})),t.on("error",(()=>{this._sourceErrored=!0;})),this._source=t,this._tiles={},this._cache=new Cy(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this._coveredTiles={},this._shadowCasterTiles={},this._state=new zm,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType;}onAdd(e){this.map=e,this._minTileCacheSize=void 0===this._minTileCacheSize&&e?e._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&e?e._maxTileCacheSize:this._maxTileCacheSize;}loaded(){if(this._sourceErrored)return !0;if(!this._sourceLoaded)return !1;if(!this._source.loaded())return !1;for(const e in this._tiles){const t=this._tiles[e];if("errored"!==t.state&&("loaded"!==t.state||!t.bucketsLoaded()))return !1}return !0}getSource(){return this._source}pause(){this._paused=!0;}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform);}_loadTile(e,t){return e.isSymbolTile=this._onlySymbols,e.isExtraShadowCaster=this._shadowCasterTiles[e.tileID.key],this._source.loadTile(e,t)}_unloadTile(e){if(this._source.unloadTile)return this._source.unloadTile(e,(()=>{}))}_abortTile(e){if(this._source.abortTile)return this._source.abortTile(e,(()=>{}))}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const t in this._tiles){const i=this._tiles[t];i.upload(e),i.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope);}}getIds(){return L(this._tiles).map((e=>e.tileID)).sort(Sx).map((e=>e.key))}getRenderableIds(e,t){const i=[];for(const r in this._tiles)this._isIdRenderable(+r,e,t)&&i.push(this._tiles[r]);return e?i.sort(((e,t)=>{const i=e.tileID,r=t.tileID,n=new y(i.canonical.x,i.canonical.y)._rotate(this.transform.angle),o=new y(r.canonical.x,r.canonical.y)._rotate(this.transform.angle);return i.overscaledZ-r.overscaledZ||o.y-n.y||o.x-n.x})).map((e=>e.tileID.key)):i.map((e=>e.tileID)).sort(Sx).map((e=>e.key))}hasRenderableParent(e){const t=this.findLoadedParent(e,0);return !!t&&this._isIdRenderable(t.tileID.key)}_isIdRenderable(e,t,i){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(t||!this._tiles[e].holdingForFade())&&(i||!this._shadowCasterTiles[e])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else {this._cache.reset();for(const e in this._tiles)"errored"!==this._tiles[e].state&&this._reloadTile(+e,"reloading");}}_reloadTile(e,t){const i=this._tiles[e];i&&("loading"!==i.state&&(i.state=t),this._loadTile(i,this._tileLoaded.bind(this,i,e,t)));}_tileLoaded(e,t,i,r){if(r)if(e.state="errored",404!==r.status)this._source.fire(new St(r,{tile:e}));else if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const e=this.map.painter.terrain;this.update(this.transform,e.getScaledDemTileSize(),!0),e.resetTileLookupCache(this.id);}else this.update(this.transform);else e.timeAdded=ht.now(),"expired"===i&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(t,e),"raster-dem"===this._source.type&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),this._source.fire(new At("data",{dataType:"source",tile:e,coord:e.tileID,sourceCacheId:this.id}));}_backfillDEM(e){const t=this.getRenderableIds();for(let r=0;r1||(Math.abs(i)>1&&(1===Math.abs(i+n)?i+=n:1===Math.abs(i-n)&&(i-=n)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,i,r),e.neighboringTiles&&e.neighboringTiles[o]&&(e.neighboringTiles[o].backfilled=!0)));}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,t,i,r){for(const n in this._tiles){let o=this._tiles[n];if(r[n]||!o.hasData()||o.tileID.overscaledZ<=t||o.tileID.overscaledZ>i)continue;let s=o.tileID;for(;o&&o.tileID.overscaledZ>t+1;){const e=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[e.key],o&&o.hasData()&&(s=e);}let a=s;for(;a.overscaledZ>t;)if(a=a.scaledTo(a.overscaledZ-1),e[a.key]){r[s.key]=s;break}}}findLoadedParent(e,t){if(e.key in this._loadedParentTiles){const i=this._loadedParentTiles[e.key];return i&&i.tileID.overscaledZ>=t?i:null}for(let i=e.overscaledZ-1;i>=t;i--){const t=e.scaledTo(i),r=this._getLoadedTile(t);if(r)return r}}_getLoadedTile(e){const t=this._tiles[e.key];return t&&t.hasData()?t:this._cache.getByKey(this._source.reparseOverscaled?e.wrapped().key:e.canonical.key)}updateCacheSize(e,t){t=t||this._source.tileSize;const i=Math.ceil(e.width/t)+1,r=Math.ceil(e.height/t)+1,n=Math.floor(i*r*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,n):n,s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(s);}handleWrapJump(e){const t=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);if(this._prevLng=e,t){const e={};for(const i in this._tiles){const r=this._tiles[i];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+t),e[r.tileID.key]=r;}this._tiles=e;for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e in this._tiles)this._setTileReloadTimer(+e,this._tiles[e]);}}update(e,t,i,r){if(this.transform=e,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!i)return;let n;if(this.updateCacheSize(e,t),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?n=e.getVisibleUnwrappedCoordinates(this._source.tileID).map((e=>new Bu(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y))):(n=e.coveringTiles({tileSize:t||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!i,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(n=n.filter((e=>this._source.hasTile(e))))):n=[],n.length>0&&this.castsShadows&&r&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!Ix(this._source.type)){const o=e.coveringZoomLevel({tileSize:t||this._source.tileSize,roundZoom:this._source.roundZoom&&!i}),s=Math.min(o,this._source.maxzoom),a=e.extendTileCoverForShadows(n,r,s);for(const e of a)this._shadowCasterTiles[e.key]=!0,n.push(e);}const o=this._updateRetainedTiles(n);if(Ix(this._source.type)&&0!==n.length){const e={},t={},i=Object.keys(o);for(const r of i){const i=o[r],n=this._tiles[r];if(!n||n.fadeEndTime&&n.fadeEndTime<=ht.now())continue;const s=this.findLoadedParent(i,Math.max(i.overscaledZ-Ax.maxOverzooming,this._source.minzoom));s&&(this._addTile(s.tileID),e[s.tileID.key]=s.tileID),t[r]=i;}const r=n[n.length-1].overscaledZ;for(const e in this._tiles){const i=this._tiles[e];if(o[e]||!i.hasData())continue;let n=i.tileID;for(;n.overscaledZ>r;){n=n.scaledTo(n.overscaledZ-1);const r=this._tiles[n.key];if(r&&r.hasData()&&t[n.key]){o[e]=i.tileID;break}}}for(const t in e)o[t]||(this._coveredTiles[t]=!0,o[t]=e[t]);}for(const e in o)this._tiles[e].clearFadeHold();const s=function(e,t){const i=[];for(const r in e)r in t||i.push(r);return i}(this._tiles,o);for(const e of s){const t=this._tiles[e];t.hasSymbolBuckets&&!t.holdingForFade()?t.setHoldDuration(this.map._fadeDuration):t.hasSymbolBuckets&&!t.symbolFadeFinished()||this._removeTile(+e);}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate();}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(+e);}_updateRetainedTiles(e){const t={};if(0===e.length)return t;const i={},r=e.reduce(((e,t)=>Math.min(e,t.overscaledZ)),1/0),n=e[0].overscaledZ,o=Math.max(n-Ax.maxOverzooming,this._source.minzoom),s=Math.max(n+Ax.maxUnderzooming,this._source.minzoom),a={};for(const i of e){const e=this._addTile(i);t[i.key]=i,e.hasData()||r=this._source.maxzoom){const e=r.children(this._source.maxzoom)[0],i=this.getTile(e);if(i&&i.hasData()){t[e.key]=e;continue}}else {const e=r.children(this._source.maxzoom);if(t[e[0].key]&&t[e[1].key]&&t[e[2].key]&&t[e[3].key])continue}let n=e.wasRequested();for(let s=r.overscaledZ-1;s>=o;--s){const o=r.scaledTo(s);if(i[o.key])break;if(i[o.key]=!0,e=this.getTile(o),!e&&n&&(e=this._addTile(o)),e&&(t[o.key]=o,n=e.wasRequested(),e.hasData()))break}}return t}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const t=[];let i,r=this._tiles[e].tileID;for(;r.overscaledZ>0;){if(r.key in this._loadedParentTiles){i=this._loadedParentTiles[r.key];break}t.push(r.key);const e=r.scaledTo(r.overscaledZ-1);if(i=this._getLoadedTile(e),i)break;r=e;}for(const e of t)this._loadedParentTiles[e]=i;}}_addTile(e){let t=this._tiles[e.key];if(t)return !0!==t.isExtraShadowCaster||!!this._shadowCasterTiles[e.key]||this._reloadTile(e.key,"reloading"),t;t=this._cache.getAndRemove(e),t&&(this._setTileReloadTimer(e.key,t),t.tileID=e,this._state.initializeTileState(t,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,t)));const i=Boolean(t);if(!i){const i=this.map?this.map.painter:null;t=new Iy(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,i,this._isRaster),this._loadTile(t,this._tileLoaded.bind(this,t,e.key,t.state));}return t?(t.uses++,this._tiles[e.key]=t,i||this._source.fire(new At("dataloading",{tile:t,coord:t.tileID,dataType:"source"})),t):null}_setTileReloadTimer(e,t){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const i=t.getExpiryTimeout();i&&(this._timers[e]=setTimeout((()=>{this._reloadTile(e,"expired"),delete this._timers[e];}),i));}_removeTile(e){const t=this._tiles[e];t&&(t.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),t.uses>0||(t.hasData()&&"reloading"!==t.state?this._cache.add(t.tileID,t,t.getExpiryTimeout()):(t.aborted=!0,this._abortTile(t),this._unloadTile(t))));}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(+e);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id);}tilesIn(e,t,i){const r=[],n=this.transform;if(!n)return r;const o="globe"===n.projection.name,s=Gd(n.center.lng);for(const a in this._tiles){const l=this._tiles[a];if(i&&l.clearQueryDebugViz(),l.holdingForFade())continue;let c;if(o){const e=l.tileID.canonical;if(0===e.z){const t=[Math.abs(z(s,...Cx(e,-1))-s),Math.abs(z(s,...Cx(e,1))-s)];c=[0,2*t.indexOf(Math.min(...t))-1];}else {const t=[Math.abs(z(s,...Cx(e,-1))-s),Math.abs(z(s,...Cx(e,0))-s),Math.abs(z(s,...Cx(e,1))-s)];c=[t.indexOf(Math.min(...t))-1];}}else c=[0];for(const i of c){const o=e.containsTile(l,n,t,i);o&&r.push(o);}}return r}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(e){return this._getRenderableCoordinates(e)}_getRenderableCoordinates(e,t){const i=this.getRenderableIds(e,t).map((e=>this._tiles[e].tileID));for(const e of i)e.projMatrix=this.transform.calculateProjMatrix(e.toUnwrapped());return i}sortCoordinatesByDistance(e){const t=e.slice(),i=this.transform._camera.position,r=this.transform._camera.forward(),n={};for(const e of t){const t=1/(1<n[e.key]-n[t.key])),t}hasTransition(){if(this._source.hasTransition())return !0;if(Ix(this._source.type))for(const e in this._tiles){const t=this._tiles[e];if(void 0!==t.fadeEndTime&&t.fadeEndTime>=ht.now())return !0}return !1}setFeatureState(e,t,i){this._state.updateState(e=e||"_geojsonTileLayer",t,i);}removeFeatureState(e,t,i){this._state.removeFeatureState(e=e||"_geojsonTileLayer",t,i);}getFeatureState(e,t){return this._state.getState(e=e||"_geojsonTileLayer",t)}setDependencies(e,t,i){const r=this._tiles[e];r&&r.setDependencies(t,i);}reloadTilesForDependencies(e,t){for(const i in this._tiles)this._tiles[i].hasDependency(e,t)&&this._reloadTile(+i,"reloading");this._cache.filter((i=>!i.hasDependency(e,t)));}_preloadTiles(e,t){if(!this._sourceLoaded){const i=()=>{this._sourceLoaded&&(this._source.off("data",i),this._preloadTiles(e,t));};return void this._source.on("data",i)}const i=new Map,r=Array.isArray(e)?e:[e],n=this.map.painter.terrain,o=this.usedForTerrain&&n?n.getScaledDemTileSize():this._source.tileSize;for(const e of r){const t=e.coveringTiles({tileSize:o,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const e of t)i.set(e.key,e);this.usedForTerrain&&e.updateElevation(!1);}R(Array.from(i.values()),((e,t)=>{const i=new Iy(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(i,(e=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),t(e,i);}));}),t);}}function Sx(e,t){const i=Math.abs(2*e.wrap)-+(e.wrap<0),r=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||r-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function Ix(e){return "raster"===e||"image"===e||"video"===e||"custom"===e}function Cx(e,t){const i=1<=1e-15){const e=Mu.normalize([],i);Mu.scale(r,e,Mu.dot(r,e)),t[0]=r[0],t[1]=r[1];}const n=Mu.cross([],t,e);if(Mu.len(n)<1e-15)return null;const o=Math.atan2(-n[1],n[0]);return Nx(Math.atan2(Math.sqrt(e[0]*e[0]+e[1]*e[1]),-e[2]),o)}class Vx{constructor(e,t){this.position=e,this.orientation=t;}get position(){return this._position}set position(e){if(e){const t=e instanceof ep?e:new ep(e[0],e[1],e[2]);this._renderWorldCopies&&(t.x=P(t.x,0,1)),this._position=t;}else this._position=null;}lookAtPoint(e,t){if(this.orientation=null,!this.position)return;const i=this.position,r=this._elevation?this._elevation.getAtPointOrZero(ep.fromLngLat(e)):0,n=ep.fromLngLat(e,r),o=[n.x-i.x,n.y-i.y,n.z-i.z];t||(t=[0,0,1]),t[2]=Math.abs(t[2]),this.orientation=Ux(o,t);}setPitchBearing(e,t){this.orientation=Nx(w(e),w(-t));}}class jx{constructor(e,t){this._transform=xu.identity([]),this.orientation=t,this.position=e;}get mercatorPosition(){const e=this.position;return new ep(e[0],e[1],e[2])}get position(){const e=ne(this._transform,3);return [e[0],e[1],e[2]]}set position(e){var t;e&&oe(this._transform,3,[(t=e)[0],t[1],t[2],1]);}get orientation(){return this._orientation}set orientation(e){this._orientation=e||bu.identity([]),e&&Fx(this._transform,this._orientation);}getPitchBearing(){const e=this.forward(),t=this.right();return {bearing:Math.atan2(-t[1],t[0]),pitch:Math.atan2(Math.sqrt(e[0]*e[0]+e[1]*e[1]),-e[2])}}setPitchBearing(e,t){this._orientation=Nx(e,t),Fx(this._transform,this._orientation);}forward(){const e=ne(this._transform,2);return [-e[0],-e[1],-e[2]]}up(){const e=ne(this._transform,1);return [-e[0],-e[1],-e[2]]}right(){const e=ne(this._transform,0);return [e[0],e[1],e[2]]}getCameraToWorld(e,t){const i=new Float64Array(16);return xu.invert(i,this.getWorldToCamera(e,t)),i}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(e,t,i){const r=this.position;Mu.scale(r,r,-e);const n=new Float64Array(16);return xu.fromScaling(n,[i,i,i]),xu.translate(n,n,r),n[10]*=t,n}getWorldToCamera(e,t){const i=new Float64Array(16),r=new Float64Array(4),n=this.position;return bu.conjugate(r,this._orientation),Mu.scale(n,n,-e),xu.fromQuat(i,r),xu.translate(i,i,n),i[1]*=-1,i[5]*=-1,i[9]*=-1,i[13]*=-1,i[8]*=t,i[9]*=t,i[10]*=t,i[11]*=t,i}getCameraToClipPerspective(e,t,i,r){const n=new Float64Array(16);return xu.perspective(n,e,t,i,r),n}getCameraToClipOrthographic(e,t,i,r,n,o){const s=new Float64Array(16);return xu.ortho(s,e,t,i,r,n,o),s}getDistanceToElevation(e,t=!1){const i=0===e?0:Zd(e,t?Hd(this.position[1]):this.position[1]),r=this.forward();return (i-this.position[2])/r[2]}clone(){return new jx([...this.position],[...this.orientation])}}function Gx(e,t){const i=Zx(e.projection,e.zoom,e.width,e.height),r=function(e,t,i,r,n){const o=new Nd(i.lng-180*$x,i.lat),s=new Nd(i.lng+180*$x,i.lat),a=e.project(o.lng,o.lat),l=e.project(s.lng,s.lat),c=-Math.atan2(l.y-a.y,l.x-a.x),h=ep.fromLngLat(i);h.y=z(h.y,-1+$x,1-$x);const u=h.toLngLat(),d=e.project(u.lng,u.lat),p=ep.fromLngLat(u);p.x+=$x;const f=p.toLngLat(),m=e.project(f.lng,f.lat),_=Wx(m.x-d.x,m.y-d.y,c),g=ep.fromLngLat(u);g.y+=$x;const y=g.toLngLat(),x=e.project(y.lng,y.lat),v=Wx(x.x-d.x,x.y-d.y,c),b=Math.abs(_.x)/Math.abs(v.y),w=xu.identity([]);xu.rotateZ(w,w,-c*(1-(n?0:r)));const T=xu.identity([]);return xu.scale(T,T,[1,1-(1-b)*r,1]),T[4]=-v.x/v.y*r,xu.rotateZ(T,T,c),xu.multiply(T,w,T),T}(e.projection,0,e.center,i,t),n=qx(e);return xu.scale(r,r,[n,n,1]),r}function qx(e){const t=e.projection,i=Zx(e.projection,e.zoom,e.width,e.height),r=Hx(t,e.center),n=Hx(t,Nd.convert(t.center));return Math.pow(2,r*i+(1-i)*n)}function Zx(e,t,i,r,n=1/0){const o=e.range;if(!o)return 0;const s=Math.min(n,Math.max(i,r)),a=Math.log(s/1024)/Math.LN2;return D(o[0]+a,o[1]+a,t)}const $x=1/4e4;function Hx(e,t){const i=z(t.lat,-Xd,Xd),r=new Nd(t.lng-180*$x,i),n=new Nd(t.lng+180*$x,i),o=e.project(r.lng,i),s=e.project(n.lng,i),a=ep.fromLngLat(r),l=ep.fromLngLat(n),c=s.x-o.x,h=s.y-o.y,u=l.x-a.x,d=l.y-a.y,p=Math.sqrt((u*u+d*d)/(c*c+h*h));return Math.log(p)/Math.LN2}function Wx(e,t,i){const r=Math.cos(i),n=Math.sin(i);return {x:e*r-t*n,y:e*n+t*r}}function Xx(e,t,i){return t*(sr/(e.tileSize*Math.pow(2,i-e.tileID.overscaledZ)))}const Yx={unknown:0,flipRequired:1,flipNotRequired:2},Kx=Math.tan(85*Math.PI/180);function Jx(e,t,i,r,n,o,s){const a=xu.create();if(i)if("globe"===o.name){const e=function(e,t){const{x:i,y:r}=e.point,n=Td(i,r,e.worldSize/e._pixelsPerMercatorPixel,0,0);return xu.multiply(n,n,vd(ad(t)))}(n,t);xu.multiply(a,a,e);}else {const e=fu.invert([],s);a[0]=e[0],a[1]=e[1],a[4]=e[2],a[5]=e[3],r||xu.rotateZ(a,a,n.angle);}else xu.multiply(a,n.labelPlaneMatrix,e);return a}function Qx(e,t,i,r,n,o,s){const a=Jx(e,t,i,r,n,o,s);return "globe"===o.name&&i||(a[2]=a[6]=a[10]=a[14]=0),a}function ev(e,t,i,r,n,o,s){if(i){if("globe"===o.name){const a=Jx(e,t,i,r,n,o,s);return xu.invert(a,a),xu.multiply(a,e,a),a}{const t=xu.clone(e),i=xu.identity([]);return i[0]=s[0],i[1]=s[1],i[4]=s[2],i[5]=s[3],xu.multiply(t,t,i),r||xu.rotateZ(t,t,-n.angle),t}}return n.glCoordMatrix}function tv(e,t,i,r){const n=[e,t,i,1];i?uu.transformMat4(n,n,r):dv(n,n,r);const o=n[3];return n[0]/=o,n[1]/=o,n[2]/=o,n}function iv(e,t){return Math.min(.5+e/t*.5,1.5)}function rv(e,t){const i=e[0]/e[3],r=e[1]/e[3];return i>=-t[0]&&i<=t[0]&&r>=-t[1]&&r<=t[1]}function nv(e,t,i,r,n,o,s,a,l,c){const h=i.transform,u=r?e.textSizeData:e.iconSizeData,d=a_(u,i.transform.zoom),p="globe"===h.projection.name,f=[256/i.width*2+1,256/i.height*2+1],m=r?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;m.clear();let _=null;p&&(_=r?e.text.globeExtVertexArray:e.icon.globeExtVertexArray);const g=e.lineVertexArray,x=r?e.text.placedSymbolArray:e.icon.placedSymbolArray,v=i.transform.width/i.transform.height;let b,w=!1;for(let r=0;rMath.abs(i)?{useVertical:!0}:e===w_.vertical?r>0?{needsFlipping:!0}:null:t!==Yx.unknown&&function(e,t){return 0===e||Math.abs(t/e)>Kx}(i,r)?t===Yx.flipRequired?{needsFlipping:!0}:null:i<0?{needsFlipping:!0}:null}function av(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,x){const v=t/24,b=e.lineOffsetX*v,w=e.lineOffsetY*v,{lineStartIndex:T,glyphStartIndex:E,numGlyphs:M,segment:A,writingMode:S,flipState:I}=e,C=T+e.lineLength,z=e=>{if(h){const[t,i,r]=e.up,n=c.length;ry(h,n+0,t,i,r),ry(h,n+1,t,i,r),ry(h,n+2,t,i,r),ry(h,n+3,t,i,r);}const[t,i,r]=e.point;ny(c,t,i,r,e.angle);};if(M>1){const t=ov(v,a,b,w,i,u,d,e,l,o,p,m,!1,_,g,x);if(!t)return {notEnoughRoom:!0};if(r&&!i){let[i,r,n]=t.first.point,[o,a,l]=t.last.point;[i,r]=tv(i,r,n,s),[o,a]=tv(o,a,l,s);const c=sv(S,I,(o-i)*f,a-r);if(e.flipState=c&&c.needsFlipping?Yx.flipRequired:Yx.flipNotRequired,c)return c}z(t.first);for(let e=E+1;e0?o:cv(d,r,t,1,n,void 0,_,g.canonical),a=sv(S,I,(s[0]-t[0])*f,s[1]-t[1]);if(e.flipState=a&&a.needsFlipping?Yx.flipRequired:Yx.flipNotRequired,a)return a}const t=hv(v*a.getoffsetX(E),b,w,i,u,d,A,T,C,l,o,p,m,!1,!1,_,g,x);if(!t)return {notEnoughRoom:!0};z(t);}return {}}function lv(e,t,i,r,n){const{x:o,y:s,z:a}=r.projectTilePoint(e.x,e.y,t);if(!n)return tv(o,s,a,i);const[l,c,h]=n(e);return tv(o+l,s+c,a+h,i)}function cv(e,t,i,r,n,o,s,a){const l=lv(e.sub(t)._unit()._add(e),a,n,s,o);return Mu.sub(l,i,l),Mu.normalize(l,l),Mu.scaleAndAdd(l,i,l,r)}function hv(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){const x=r?e-t:e+t;let v=x>0?1:-1,b=0;r&&(v*=-1,b=Math.PI),v<0&&(b+=Math.PI);let w=a+s+(v>0?0:1)|0,T=n,E=n,M=0,A=0;const S=Math.abs(x),I=[],C=[];let z=o,D=z;const P=()=>cv(D,z,E,S-M+1,h,d,m,_.canonical);for(;M+A<=S;){if(w+=v,w=l)return null;if(E=T,D=z,I.push(E),p&&C.push(D),z=new y(c.getx(w),c.gety(w)),T=u[w],!T){const e=lv(z,_.canonical,h,m,d);T=e[3]>0?u[w]=e:P();}M+=A,A=Mu.distance(E,T);}f&&d&&(u[w]&&(T=P(),A=Mu.distance(E,T)),u[w]=T);const R=(S-M)/A,L=z.sub(D)._mult(R)._add(D),k=Mu.sub([],T,E),O=Mu.scaleAndAdd([],E,k,R);let B=[0,0,1],F=k[0],N=k[1];if(g&&(B=m.upVector(_.canonical,L.x,L.y),0!==B[0]||0!==B[1]||1!==B[2])){const e=[B[2],0,-B[0]],t=Mu.cross([],B,e);Mu.normalize(e,e),Mu.normalize(t,t),F=Mu.dot(k,e),N=Mu.dot(k,t);}if(i){const e=Mu.cross([],B,k);Mu.normalize(e,e),Mu.scaleAndAdd(O,O,e,i*v);}const U=b+Math.atan2(N,F);return I.push(O),p&&C.push(L),{point:O,angle:U,path:I,tilePath:C,up:B}}function uv(e,t){const i=t.length,r=i+4*e;t.resize(r),t.float32.fill(-1/0,4*i,4*r);}function dv(e,t,i){const r=t[0],n=t[1];return e[0]=i[0]*r+i[4]*n+i[12],e[1]=i[1]*r+i[5]*n+i[13],e[3]=i[3]*r+i[7]*n+i[15],e}const pv=(e,t,i)=>(1-i)*e+i*t,fv=e=>e*e*e*e*e;class mv{constructor(e,t,i,r,n,o,s){this.tileSize=512,this._renderWorldCopies=void 0===n||n,this._minZoom=e||0,this._maxZoom=t||22,this._minPitch=null==i?0:i,this._maxPitch=null==r?60:r,this.setProjection(o),this.setMaxBounds(s),this.width=0,this.height=0,this._center=new Nd(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._unmodified=!0,this._edgeInsets=new Bx,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._distanceTileDataCache={},this._camera=new jx,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._pixelsPerMercatorPixel=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._horizonShift=.1,this._orthographicProjectionAtLowPitch=!1;}clone(){const e=new mv(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection());return e._elevation=this._elevation,e._centerAltitude=this._centerAltitude,e._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,e.tileSize=this.tileSize,e.mercatorFromTransition=this.mercatorFromTransition,e.width=this.width,e.height=this.height,e.cameraElevationReference=this.cameraElevationReference,e._center=this._center,e._setZoom(this.zoom),e._seaLevelZoom=this._seaLevelZoom,e.angle=this.angle,e._fov=this._fov,e._pitch=this._pitch,e._nearZ=this._nearZ,e._farZ=this._farZ,e._averageElevation=this._averageElevation,e._unmodified=this._unmodified,e._edgeInsets=this._edgeInsets.clone(),e._camera=this._camera.clone(),e._calcMatrices(),e.freezeTileCoverage=this.freezeTileCoverage,e.frustumCorners=this.frustumCorners,e}get isOrthographic(){return "globe"!==this.projection.name&&this._orthographicProjectionAtLowPitch&&this.pitch<15}get elevation(){return this._elevation}set elevation(e){this._elevation!==e&&(this._elevation=e,this._updateCameraOnTerrain(),this._calcMatrices());}get depthOcclusionForSymbolsAndCircles(){return "globe"!==this.projection.name&&!this.isOrthographic}updateElevation(e,t=!1){const i=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(null==this._seaLevelZoom||i)&&this._updateCameraOnTerrain(),(e||i)&&this._constrainCamera(t),this._calcMatrices();}getProjection(){return O(this.projection,["name","center","parallels"])}setProjection(e){this.projectionOptions=e||{name:"mercator"};const t=this.projection?this.getProjection():void 0;this.projection=Hg(this.projectionOptions);const i=!x(t,this.getProjection());return i&&this._calcMatrices(),this.mercatorFromTransition=!1,i}setOrthographicProjectionAtLowPitch(e){return this._orthographicProjectionAtLowPitch!==e&&(this._orthographicProjectionAtLowPitch=e,this._calcMatrices(),!0)}setMercatorFromTransition(){const e=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=Hg({name:"mercator"});const t=e!==this.projection.name;return t&&this._calcMatrices(),t}get minZoom(){return this._minZoom}set minZoom(e){this._minZoom!==e&&(this._minZoom=e,this.zoom=Math.max(this.zoom,e));}get maxZoom(){return this._maxZoom}set maxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.zoom=Math.min(this.zoom,e));}get minPitch(){return this._minPitch}set minPitch(e){this._minPitch!==e&&(this._minPitch=e,this.pitch=Math.max(this.pitch,e));}get maxPitch(){return this._maxPitch}set maxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.pitch=Math.min(this.pitch,e));}get renderWorldCopies(){return this._renderWorldCopies&&!0===this.projection.supportsWorldCopies}set renderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e;}get worldSize(){return this.tileSize*this.scale}get cameraWorldSizeForFog(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get cameraWorldSize(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation,!0),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return Zd(1,this.center.lat)*this.cameraWorldSizeForFog}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new y(this.width,this.height)}get bearing(){return P(this.rotation,-180,180)}set bearing(e){this.rotation=e;}get rotation(){return -this.angle/Math.PI*180}set rotation(e){const t=-e*Math.PI/180;this.angle!==t&&(this._unmodified=!1,this.angle=t,this._calcMatrices(),this.rotationMatrix=fu.create(),fu.rotate(this.rotationMatrix,this.rotationMatrix,this.angle));}get pitch(){return this._pitch/Math.PI*180}set pitch(e){const t=z(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==t&&(this._unmodified=!1,this._pitch=t,this._calcMatrices());}get aspect(){return this.width/this.height}get fov(){return this._fov/Math.PI*180}get fovX(){return this._fov}get fovY(){const e=1/Math.tan(.5*this.fovX);return 2*Math.atan(1/this.aspect/e)}set fov(e){e=Math.max(.01,Math.min(60,e)),this._fov!==e&&(this._unmodified=!1,this._fov=w(e),this._calcMatrices());}get averageElevation(){return this._averageElevation}set averageElevation(e){this._averageElevation=e,this._calcFogMatrices(),this._distanceTileDataCache={};}get zoom(){return this._zoom}set zoom(e){const t=Math.min(Math.max(e,this.minZoom),this.maxZoom);this._zoom!==t&&(this._unmodified=!1,this._setZoom(t),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices());}_setZoom(e){this._zoom=e,this.scale=this.zoomScale(e),this.tileZoom=Math.floor(e),this.zoomFraction=e-this.tileZoom;}_updateCameraOnTerrain(){const e=this.elevation?this.elevation.getAtPoint(this.locationCoordinate(this.center),Number.NEGATIVE_INFINITY):Number.NEGATIVE_INFINITY,t=this.elevation&&e===Number.NEGATIVE_INFINITY&&this.elevation.visibleDemTiles.length>0&&this.elevation.exaggeration()>0&&this._centerAltitudeValidForExaggeration;if(!this._elevation||e===Number.NEGATIVE_INFINITY&&(!t||!this._centerAltitude))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const i=this._elevation;t||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&i.exaggeration()&&this._centerAltitudeValidForExaggeration!==i.exaggeration()?(this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*i.exaggeration(),this._centerAltitudeValidForExaggeration=i.exaggeration()):(this._centerAltitude=e||0,this._centerAltitudeValidForExaggeration=i.exaggeration()),this._updateSeaLevelZoom();}_updateSeaLevelZoom(){void 0!==this._centerAltitudeValidForExaggeration&&(this._seaLevelZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize));}sampleAverageElevation(){if(!this._elevation)return 0;const e=this._elevation,t=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],i=this.horizonLineFromTop();let r=0,n=0;for(let o=0;o0,c=e.y+10,u=i.wrap-(l?0:1),d=i.wrap+(a?0:1),p=l?e.x-1:s-1,f=a?e.x+1:0;t[0]<0?(r.push(new Bu(n,d,e.z,f,e.y)),t[1]<0&&c&&(r.push(new Bu(n,o,e.z,e.x,e.y+1)),r.push(new Bu(n,d,e.z,f,e.y+1))),t[1]>0&&h&&(r.push(new Bu(n,o,e.z,e.x,e.y-1)),r.push(new Bu(n,d,e.z,f,e.y-1)))):t[0]>0?(r.push(new Bu(n,u,e.z,p,e.y)),t[1]<0&&c&&(r.push(new Bu(n,o,e.z,e.x,e.y+1)),r.push(new Bu(n,u,e.z,p,e.y+1))),t[1]>0&&h&&(r.push(new Bu(n,o,e.z,e.x,e.y-1)),r.push(new Bu(n,u,e.z,p,e.y-1)))):t[1]<0&&c?r.push(new Bu(n,o,e.z,e.x,e.y+1)):h&&r.push(new Bu(n,o,e.z,e.x,e.y-1));}if(r.length>1){r.sort(((e,t)=>e.overscaledZ-t.overscaledZ||e.wrap-t.wrap||e.canonical.z-t.canonical.z||e.canonical.x-t.canonical.x||e.canonical.y-t.canonical.y));let e=0,t=0;for(;te.isChildOf(t)))||n.push(e);return r=n.filter((t=>!e.some((e=>!!(t.overscaledZe.maxzoom&&(t=e.maxzoom);const s=this.locationCoordinate(this.center),a=this.center.lat,l=1<{const t=1/4e4,i=new ep(e.x+t,e.y,e.z),r=new ep(e.x,e.y+t,e.z),n=e.toLngLat(),o=i.toLngLat(),s=r.toLngLat(),a=this.locationCoordinate(n),l=this.locationCoordinate(o),c=this.locationCoordinate(s),h=Math.hypot(l.x-a.x,l.y-a.y),u=Math.hypot(c.x-a.x,c.y-a.y);return Math.sqrt(h*u)*w/t},M=e=>{const t=v,i=b;return {aabb:Eg(this,l,0,0,0,e,i,t,this.projection),zoom:0,x:0,y:0,minZ:i,maxZ:t,wrap:e,fullyVisible:!1}},A=[];let S=[];const I=t,C=e.reparseOverscaled?i:t,z=e=>e*e,D=z((m-this._centerAltitude)*f),P=e=>{if(!this._elevation||!e.tileID||!o)return;const t=this._elevation.getMinMaxForTile(e.tileID),i=e.aabb;t?(i.min[2]=t.min,i.max[2]=t.max,i.center[2]=(i.min[2]+i.max[2])/2):(e.shouldSplit=R(e),e.shouldSplit||(i.min[2]=i.max[2]=i.center[2]=this._centerAltitude));},R=e=>{if(e.zoom=.9)return !0}else if(n&&(o=z(e.aabb.distanceZ(_)*f)),this.projection.isReprojectedInTileSpace&&i<=5){const t=Math.pow(2,e.zoom),i=T(new ep((e.x+.5)/t,(e.y+.5)/t));s=i>.85?1:i;}const l=t*t+r*r+o,c=z((1<{if(t*z(.707)0;){const i=A.pop(),r=i.x,s=i.y;let a=i.fullyVisible;const u=()=>"globe"===this.projection.name&&(0===i.y||i.y===(1<>1),u={aabb:o?i.aabb.quadrant(e):Eg(this,l,i.zoom+1,t,c,i.wrap,i.minZ,i.maxZ,this.projection),zoom:i.zoom+1,x:t,y:c,wrap:i.wrap,fullyVisible:a,tileID:void 0,shouldSplit:void 0,minZ:i.minZ,maxZ:i.maxZ};n&&!h&&(u.tileID=new Bu(i.zoom+1===I?C:i.zoom+1,i.wrap,i.zoom+1,t,c),P(u)),A.push(u);}else {const n=i.zoom===I?C:i.zoom;if(e.minzoom&&e.minzoom>n)continue;if(!a){let e=g?i.aabb.intersectsPrecise(d):i.aabb.intersectsPreciseFlat(d);if(0===e&&u()){const t=new ku(i.zoom,r,s);e=ud(this,l,t,!0).intersectsPrecise(d);}if(0===e)continue}const o=c[0]-(.5+r+(i.wrap<{const n=[0,0,0,1],o=[sr,sr,0,1],s=this.calculateFogTileMatrix(r.tileID.toUnwrapped());uu.transformMat4(n,n,s),uu.transformMat4(o,o,s);const a=function(e,t,i){let r=0;for(let i=0;i<2;++i){const n=0;e[i]>n&&(r+=(e[i]-n)*(e[i]-n)),t[i]t&&0!==i){const t=this.calculateProjMatrix(r.tileID.toUnwrapped());let n;e.isTerrainDEM||(n=c.getMinMaxForTile(r.tileID)),n||(n={min:b,max:v});const o=function(e){const t=Math.round((e+45+360)%360/90)%4;return E[t]}(this.rotation),s=[o[0]*sr,o[1]*sr,n.max];Mu.transformMat4(s,s,t),l=(1-s[1])*this.height*.5e.distanceSq-t.distanceSq)).map((e=>e.tileID))}resize(e,t){this.width=e,this.height=t,this.pixelsToGLUnits=[2/e,-2/t],this._constrain(),this._calcMatrices();}get unmodified(){return this._unmodified}zoomScale(e){return Math.pow(2,e)}scaleZoom(e){return Math.log(e)/Math.LN2}project(e){const t=z(e.lat,-Xd,Xd),i=this.projection.project(e.lng,t);return new y(i.x*this.worldSize,i.y*this.worldSize)}unproject(e){return this.projection.unproject(e.x/this.worldSize,e.y/this.worldSize)}get point(){return this.project(this.center)}get pointMerc(){return this.point._div(this.worldSize)}get pixelsPerMeterRatio(){return this.pixelsPerMeter/Zd(1,this.center.lat)/this.worldSize}setLocationAtPoint(e,t){let i,r;const n=this.centerPoint;if("globe"===this.projection.name){const e=this.worldSize;i=(t.x-n.x)/e,r=(t.y-n.y)/e;}else {const e=this.pointCoordinate(t),o=this.pointCoordinate(n);i=e.x-o.x,r=e.y-o.y;}const o=this.locationCoordinate(e);this.setLocation(new ep(o.x-i,o.y-r));}setLocation(e){this.center=this.coordinateLocation(e),this.projection.wrap&&(this.center=this.center.wrap());}locationPoint(e){return this.projection.locationPoint(this,e)}locationPoint3D(e){return this.projection.locationPoint(this,e,!0)}pointLocation(e){return this.coordinateLocation(this.pointCoordinate(e))}pointLocation3D(e){return this.coordinateLocation(this.pointCoordinate3D(e))}locationCoordinate(e,t){const i=t?Zd(t,e.lat):void 0,r=this.projection.project(e.lng,e.lat);return new ep(r.x,r.y,i)}coordinateLocation(e){return this.projection.unproject(e.x,e.y)}pointRayIntersection(e,t){const i=null!=t?t:this._centerAltitude,r=[e.x,e.y,0,1],n=[e.x,e.y,1,1];uu.transformMat4(r,r,this.pixelMatrixInverse),uu.transformMat4(n,n,this.pixelMatrixInverse);const o=n[3];uu.scale(r,r,1/r[3]),uu.scale(n,n,1/o);const s=r[2],a=n[2];return {p0:r,p1:n,t:s===a?0:(i-s)/(a-s)}}screenPointToMercatorRay(e){const t=[e.x,e.y,0,1],i=[e.x,e.y,1,1];return uu.transformMat4(t,t,this.pixelMatrixInverse),uu.transformMat4(i,i,this.pixelMatrixInverse),uu.scale(t,t,1/t[3]),uu.scale(i,i,1/i[3]),t[2]=Zd(t[2],this._center.lat)*this.worldSize,i[2]=Zd(i[2],this._center.lat)*this.worldSize,uu.scale(t,t,1/this.worldSize),uu.scale(i,i,1/this.worldSize),new Uu([t[0],t[1],t[2]],Mu.normalize([],Mu.sub([],i,t)))}rayIntersectionCoordinate(e){const{p0:t,p1:i,t:r}=e,n=Zd(t[2],this._center.lat),o=Zd(i[2],this._center.lat);return new ep(Wr(t[0],i[0],r)/this.worldSize,Wr(t[1],i[1],r)/this.worldSize,Wr(n,o,r))}pointCoordinate(e,t=this._centerAltitude){return this.projection.pointCoordinate(this,e.x,e.y,t)}pointCoordinate3D(e){if(!this.elevation)return this.pointCoordinate(e);let t=this.projection.pointCoordinate3D(this,e.x,e.y);if(t)return new ep(t[0],t[1],t[2]);let i=0,r=this.horizonLineFromTop();if(e.y>r)return this.pointCoordinate(e);const n=.02*r,o=e.clone();for(let e=0;e<10&&r-i>n;e++){o.y=Wr(i,r,.66);const e=this.projection.pointCoordinate3D(this,o.x,o.y);e?(r=o.y,t=e):i=o.y;}return t?new ep(t[0],t[1],t[2]):this.pointCoordinate(e)}isPointAboveHorizon(e){return this.projection.isPointAboveHorizon(this,e)}isPointOnSurface(e){if(e.y<0||e.y>this.height||e.x<0||e.x>this.width)return !1;if(this.elevation||this.zoom>=Xu)return !this.isPointAboveHorizon(e);const t=this.pointCoordinate(e);return t.y>=0&&t.y<=1}_coordinatePoint(e,t){const i=t&&this.elevation?this.elevation.getAtPointOrZero(e,this._centerAltitude):this._centerAltitude,r=[e.x*this.worldSize,e.y*this.worldSize,i+e.toAltitude(),1];return uu.transformMat4(r,r,this.pixelMatrix),r[3]>0?new y(r[0]/r[3],r[1]/r[3]):new y(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:e,left:t}=this._edgeInsets,i=this.height-this._edgeInsets.bottom,r=this.width-this._edgeInsets.right,n=this.pointLocation3D(new y(t,e)),o=this.pointLocation3D(new y(r,e)),s=this.pointLocation3D(new y(r,i)),a=this.pointLocation3D(new y(t,i));let l=Math.min(n.lng,o.lng,s.lng,a.lng),c=Math.max(n.lng,o.lng,s.lng,a.lng),h=Math.min(n.lat,o.lat,s.lat,a.lat),u=Math.max(n.lat,o.lat,s.lat,a.lat);const d=Math.pow(2,-this.zoom)/16*270,p="globe"===this.projection.name?1:4,f=(e,t,i,r,n)=>{const o=(e+i)/2,s=(t+r)/2,a=new y(o,s),{lng:m,lat:_}=this.pointLocation3D(a),g=Math.max(0,l-m,h-_,m-c,_-u);l=Math.min(l,m),c=Math.max(c,m),h=Math.min(h,_),u=Math.max(u,_),(nd)&&(f(e,t,o,s,n+1),f(o,s,i,r,n+1));};if(f(t,e,r,e,1),f(r,e,r,i,1),f(r,i,t,i,1),f(t,i,t,e,1),"globe"===this.projection.name){const[e,t]=function(e){const t=xu.identity(new Float64Array(16));xu.multiply(t,e.pixelMatrix,e.globeMatrix);const i=[0,ed,0],r=[0,td,0];return Mu.transformMat4(i,i,t),Mu.transformMat4(r,r,t),[i[0]>0&&i[0]<=e.width&&i[1]>0&&i[1]<=e.height&&!Dd(e,new Nd(e.center.lat,90)),r[0]>0&&r[0]<=e.width&&r[1]>0&&r[1]<=e.height&&!Dd(e,new Nd(e.center.lat,-90))]}(this);e?(u=90,c=180,l=-180):t&&(h=-90,c=180,l=-180);}return new Ql(new Nd(l,h),new Nd(c,u))}_getBoundsRectangular(e,t){const{top:i,left:r}=this._edgeInsets,n=this.height-this._edgeInsets.bottom,o=this.width-this._edgeInsets.right,s=new y(r,i),a=new y(o,i),l=new y(o,n),c=new y(r,n);let h=this.pointCoordinate(s,e),u=this.pointCoordinate(a,e);const d=this.pointCoordinate(l,t),p=this.pointCoordinate(c,t),f=(e,t)=>(t.y-e.y)/(t.x-e.x);return h.y>1&&u.y>=0?h=new ep((1-p.y)/f(p,h)+p.x,1):h.y<0&&u.y<=1&&(h=new ep(-p.y/f(p,h)+p.x,0)),u.y>1&&h.y>=0?u=new ep((1-d.y)/f(d,u)+d.x,1):u.y<0&&h.y<=1&&(u=new ep(-d.y/f(d,u)+d.x,0)),(new Ql).extend(this.coordinateLocation(h)).extend(this.coordinateLocation(u)).extend(this.coordinateLocation(p)).extend(this.coordinateLocation(d))}_getBoundsRectangularTerrain(){const e=this.elevation;if(!e.visibleDemTiles.length||e.isUsingMockSource())return this._getBoundsRectangular(0,0);const t=e.visibleDemTiles.reduce(((e,t)=>{if(t.dem){const i=t.dem.tree;e.min=Math.min(e.min,i.minimums[0]),e.max=Math.max(e.max,i.maximums[0]);}return e}),{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(t.min*e.exaggeration(),t.max*e.exaggeration())}getBounds(){return "mercator"===this.projection.name||"equirectangular"===this.projection.name?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(e=!0){const t=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))-this.centerOffset.y,i=this.height/2-t*(1-this._horizonShift);return e?Math.max(0,i):i}getMaxBounds(){return this.maxBounds}setMaxBounds(e){this.maxBounds=e,this.minLat=-Xd,this.maxLat=Xd,this.minLng=-180,this.maxLng=180,e&&(this.minLat=e.getSouth(),this.maxLat=e.getNorth(),this.minLng=e.getWest(),this.maxLng=e.getEast(),this.maxLngh&&(s=h-l),h-ct&&(o=t-a),t-e{for(let n=0;n<16;n++)e[n]=pv(t[n],i[n],r);})(s,s,a,fv(this.pitch>=15?1:this.pitch/15));}else s=a;const l=xu.mul([],a,o);let c=xu.mul([],s,o);if(this.projection.isReprojectedInTileSpace){const e=this.locationCoordinate(this.center),t=xu.identity([]);xu.translate(t,t,[e.x*this.worldSize,e.y*this.worldSize,0]),xu.multiply(t,t,Gx(this)),xu.translate(t,t,[-e.x*this.worldSize,-e.y*this.worldSize,0]),xu.multiply(c,c,t),xu.multiply(l,l,t),this.inverseAdjustmentMatrix=function(e){const t=Gx(e,!0);return fu.invert([],[t[0],t[1],t[4],t[5]])}(this);}else this.inverseAdjustmentMatrix=[1,0,0,1];this.mercatorMatrix=xu.scale([],c,[this.worldSize,this.worldSize,this.worldSize/n,1]),this.projMatrix=c,this.invProjMatrix=xu.invert(new Float64Array(16),this.projMatrix);const h=xu.invert([],s);this.frustumCorners=Vu.fromInvProjectionMatrix(h,this.horizonLineFromTop(),this.height),this.cameraFrustum=$u.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!t);const u=new Float32Array(16);xu.identity(u),xu.scale(u,u,[1,-1,1]),xu.rotateX(u,u,this._pitch),xu.rotateZ(u,u,this.angle);const d=xu.perspective(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ);this.starsProjMatrix=xu.clone(d);const p=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;d[8]=2*-e.x/this.width,d[9]=2*(e.y+p)/this.height,this.skyboxMatrix=xu.multiply(u,d,u);const f=this.point,m=f.x,_=f.y,g=this.width%2/2,y=this.height%2/2,x=Math.cos(this.angle),v=Math.sin(this.angle),b=m-Math.round(m)+x*g+v*y,w=_-Math.round(_)+x*y+v*g,T=new Float64Array(c);if(xu.translate(T,T,[b>.5?b-1:b,w>.5?w-1:w,0]),this.alignedProjMatrix=T,c=xu.create(),xu.scale(c,c,[this.width/2,-this.height/2,1]),xu.translate(c,c,[1,-1,0]),this.labelPlaneMatrix=c,c=xu.create(),xu.scale(c,c,[1,-1,1]),xu.translate(c,c,[-1,-1,0]),xu.scale(c,c,[2/this.width,2/this.height,1]),this.glCoordMatrix=c,this.pixelMatrix=xu.multiply(new Float64Array(16),this.labelPlaneMatrix,l),this._calcFogMatrices(),this._distanceTileDataCache={},c=xu.invert(new Float64Array(16),this.pixelMatrix),!c)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=c,"globe"===this.projection.name||this.mercatorFromTransition){this.globeMatrix=function(e){const{x:t,y:i}=e.point,{lng:r,lat:n}=e._center;return Td(t,i,e.worldSize,r,n)}(this);const e=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=Mu.transformMat4(e,e,o),this.globeRadius=this.worldSize/2/Math.PI-1;}else this.globeMatrix=c;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={};}_calcFogMatrices(){this._fogTileMatrixCache={};const e=this.cameraWorldSizeForFog,t=this.cameraPixelsPerMeter,i=this._camera.position,r=1/this.height/this._pixelsPerMercatorPixel,n=[e,e,t];Mu.scale(n,n,r),Mu.scale(i,i,-1),Mu.multiply(i,i,n);const o=xu.create();xu.translate(o,o,i),xu.scale(o,o,n),this.mercatorFogMatrix=o,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(e,t,r);}_computeCameraPosition(e){const t=(e=e||this.pixelsPerMeter)/this.pixelsPerMeter,i=this._camera.forward(),r=this.point,n=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*t-e/this.worldSize*this._centerAltitude;return [r.x/this.worldSize-i[0]*n,r.y/this.worldSize-i[1]*n,e/this.worldSize*this._centerAltitude-i[2]*n]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition());}_translateCameraConstrained(e){const t=this._maxCameraBoundsDistance()*Math.cos(this._pitch),i=this._camera.position[2],r=e[2];let n=1;this.projection.wrap&&(this.center=this.center.wrap()),r>0&&(n=Math.min((t-i)/r,1)),this._camera.position=Mu.scaleAndAdd([],this._camera.position,e,n),this._updateStateFromCamera();}_updateStateFromCamera(){const e=this._camera.position,t=this._camera.forward(),{pitch:i,bearing:r}=this._camera.getPitchBearing(),n=Zd(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,o=this._mercatorZfromZoom(this._maxZoom)*Math.cos(w(this._maxPitch)),s=Math.max((e[2]-n)/Math.cos(i),o),a=this._zoomFromMercatorZ(s);Mu.scaleAndAdd(e,e,t,s),this._pitch=z(i,w(this.minPitch),w(this.maxPitch)),this.angle=P(r,-Math.PI,Math.PI),this._setZoom(z(a,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new ep(e[0],e[1],e[2])),this._unmodified=!1,this._constrain(),this._calcMatrices();}_worldSizeFromZoom(e){return Math.pow(2,e)*this.tileSize}_mercatorZfromZoom(e){return this.cameraToCenterDistance/this._worldSizeFromZoom(e)}_minimumHeightOverTerrain(){const e=Math.min((null!=this._seaLevelZoom?this._seaLevelZoom:this._zoom)+4,this._maxZoom);return this._mercatorZfromZoom(e)}_zoomFromMercatorZ(e){return this.scaleZoom(this.cameraToCenterDistance/(e*this.tileSize))}zoomFromMercatorZAdjusted(e){let t=0,i=Xu,r=0,n=1/0;for(;i-t>1e-6&&i>t;){const o=t+.5*(i-t),s=this.tileSize*Math.pow(2,o),a=this.getCameraToCenterDistance(this.projection,o,s),l=this.scaleZoom(a/(e*this.tileSize)),c=Math.abs(o-l);cl||i.y>1)return !0}return !1}isHorizonVisible(){return this.pitch+T(this.fovAboveCenter)>88||this.anyCornerOffEdge(new y(0,0),new y(this.width,this.height))}zoomDeltaToMovement(e,t){const i=Mu.length(Mu.sub([],this._camera.position,e)),r=this._zoomFromMercatorZ(i)+t;return i-this._mercatorZfromZoom(r)}getCameraPoint(){if("globe"===this.projection.name){const e=function([e,t,i],r){const n=[e,t,i,1];uu.transformMat4(n,n,r);const o=n[3]=Math.max(n[3],1e-6);return n[0]/=o,n[1]/=o,n[2]/=o,n}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new y(e[0],e[1])}{const e=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new y(0,e))}}getCameraToCenterDistance(e,t=this.zoom,i=this.worldSize){const r=Zx(e,t,this.width,this.height,1024),n=e.pixelSpaceConversion(this.center.lat,i,r);let o=.5/Math.tan(.5*this._fov)*this.height*n;return this.isOrthographic&&(o=pv(1,o,fv(this.pitch>=15?1:this.pitch/15))),o}getWorldToCameraMatrix(){const e=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?this.pixelsPerMeter:1);return "globe"===this.projection.name&&xu.multiply(e,e,this.globeMatrix),e}getFrustum(e){return $u.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,e,"meters"===this.projection.zAxisUnit)}}function _v(e,t,i){xu.identity(e),xu.rotateZ(e,e,w(t[2])),xu.rotateX(e,e,w(t[0])),xu.rotateY(e,e,w(t[1])),xu.scale(e,e,i),xu.multiply(e,e,[1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1]);}function gv(e,t,i,r,n,o,s,a){const l=[i[0]-t[0],i[1]-t[1],0],c=[r[0]-t[0],r[1]-t[1],0];if(Mu.length(l)<1e-12||Mu.length(c)<1e-12)return bu.identity(e);const h=Mu.cross([],l,c);Mu.normalize(h,h),Mu.subtract(c,r,t),l[2]=(o-n)*a,c[2]=(s-n)*a;const u=l;return Mu.cross(u,l,c),Mu.normalize(u,u),bu.rotationTo(e,h,u)}function yv(e,t,i=!1){const r=Ed(t.zoom),n=function(e,t,i){const r=t.worldSize,n=[e[12],e[13],e[14]],o=Hd(n[1]/r),s=$d(n[0]/r),a=xu.identity([]),l=Zd(1,o)*r,c=Zd(1,0)*r*Kd(o,t.zoom),h=1/bd(r);let u=c*h;if(i){const e=Zx(t.projection,t.zoom,t.width,t.height,1024);u=h*t.projection.pixelSpaceConversion(t.center.lat,r,e);}const d=md(o,s);Mu.add(d,d,Mu.scale([],Mu.normalize([],d),l*u*n[2]));const p=function(e){const t=[e[0],e[1],e[2]];let i=[0,1,0];const r=Mu.cross([],i,t);return Mu.cross(i,t,r),0===Mu.squaredLength(i)&&(i=[0,1,0],Mu.cross(r,t,i)),Mu.normalize(r,r),Mu.normalize(i,i),Mu.normalize(t,t),[r[0],r[1],r[2],0,i[0],i[1],i[2],0,t[0],t[1],t[2],0,e[0],e[1],e[2],1]}(d);xu.scale(a,a,[u,u,u*l]),xu.translate(a,a,[-n[0],-n[1],-n[2]]);const f=xu.multiply([],t.globeMatrix,p);return xu.multiply(f,f,a),xu.multiply(f,f,e),f}(e,t,i);if(r>0){const i=function(e,t){const i=t.worldSize,r=Zd(1,0)*i*Kd(t.center.lat,t.zoom)/bd(i),n=Zd(1,t.center.lat)*i,o=xu.identity([]);return xu.rotateY(o,o,w(t.center.lng)),xu.rotateX(o,o,w(t.center.lat)),xu.translate(o,o,[0,0,Yu]),xu.scale(o,o,[r,r,r*n]),xu.translate(o,o,[t.point.x-.5*i,t.point.y-.5*i,0]),xu.multiply(o,o,e),xu.multiply(o,t.globeMatrix,o)}(e,t);return function(e,t,i){const r=(e,t,i)=>{const r=Mu.length(e),n=Mu.length(t),o=ld(e,t,i);return Mu.scale(o,o,1/Mu.length(o)*Wr(r,n,i))},n=r([e[0],e[1],e[2]],[t[0],t[1],t[2]],i),o=r([e[4],e[5],e[6]],[t[4],t[5],t[6]],i),s=r([e[8],e[9],e[10]],[t[8],t[9],t[10]],i),a=ld([e[12],e[13],e[14]],[t[12],t[13],t[14]],i);return [n[0],n[1],n[2],0,o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],1]}(n,i,r)}return n}const xv=64,vv=[1,1,1];class bv{constructor(e,t,i,r){this.id=e,this.position=null!=t?new Nd(t[0],t[1]):new Nd(0,0),this.orientation=null!=i?i:[0,0,0],this.nodes=r,this.uploaded=!1,this.aabb=new Hu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[];}_applyTransformations(e,t){if(xu.multiply(e.matrix,t,e.matrix),e.meshes)for(const t of e.meshes){const i=Hu.applyTransform(t.aabb,e.matrix);this.aabb.encapsulate(i);}if(e.children)for(const t of e.children)this._applyTransformations(t,e.matrix);}computeBoundsAndApplyParent(){const e=xu.identity([]);for(const t of this.nodes)this._applyTransformations(t,e);}_positionModelOnTerrain(e,t){const i=e.elevation;if(!i)return 0;const r=Hu.projectAabbCorners(this.aabb,this.matrix),n=Zd(1,this.position.lat)*e.worldSize,o=function(e,t){const i=[0,0,1],r=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const n of r){const r=e[n.corners[0]],o=e[n.corners[1]],s=e[n.corners[2]],a=[o[0]-r[0],o[1]-r[1],t*(o[2]-r[2])],l=Mu.cross(a,a,[s[0]-r[0],s[1]-r[1],t*(s[2]-r[2])]);Mu.normalize(l,l),n.dotProductWithUp=Mu.dot(l,i);}return r.sort(((e,t)=>e.dotProductWithUp-t.dotProductWithUp)),r[0].corners}(r,n),s=r[o[0]],a=r[o[1]],l=r[o[2]],c=r[o[3]],h=i.getAtPointOrZero(new ep(s[0]/e.worldSize,s[1]/e.worldSize),0),u=i.getAtPointOrZero(new ep(a[0]/e.worldSize,a[1]/e.worldSize),0),d=i.getAtPointOrZero(new ep(l[0]/e.worldSize,l[1]/e.worldSize),0),p=i.getAtPointOrZero(new ep(c[0]/e.worldSize,c[1]/e.worldSize),0),f=(h+p)/2,m=(u+d)/2;return f>m?u=t.gl.NEAREST_MIPMAP_NEAREST}),e.uploaded=!0,e.image=null);}function Tv(e,t,i){e.indexBuffer=t.createIndexBuffer(e.indexArray,!1,!0),e.vertexBuffer=t.createVertexBuffer(e.vertexArray,zx.members,!1,!0),e.normalArray&&(e.normalBuffer=t.createVertexBuffer(e.normalArray,Lx.members,!1,!0)),e.texcoordArray&&(e.texcoordBuffer=t.createVertexBuffer(e.texcoordArray,Rx.members,!1,!0)),e.colorArray&&(e.colorBuffer=t.createVertexBuffer(e.colorArray,(12===e.colorArray.bytesPerElement?Dx:Px).members,!1,!0)),e.featureArray&&(e.pbrBuffer=t.createVertexBuffer(e.featureArray,Ox.members,!0)),e.segments=dl.simpleSegment(0,0,e.vertexArray.length,e.indexArray.length);const r=e.material;r.pbrMetallicRoughness.baseColorTexture&&wv(r.pbrMetallicRoughness.baseColorTexture,t),r.pbrMetallicRoughness.metallicRoughnessTexture&&wv(r.pbrMetallicRoughness.metallicRoughnessTexture,t),r.normalTexture&&wv(r.normalTexture,t),r.occlusionTexture&&wv(r.occlusionTexture,t,i),r.emissionTexture&&wv(r.emissionTexture,t);}function Ev(e,t,i){if(e.meshes)for(const r of e.meshes)Tv(r,t,i);if(e.children)for(const r of e.children)Ev(r,t,i);}function Mv(e){if(e.meshes)for(const t of e.meshes)t.indexArray.destroy(),t.vertexArray.destroy(),t.colorArray&&t.colorArray.destroy(),t.normalArray&&t.normalArray.destroy(),t.texcoordArray&&t.texcoordArray.destroy(),t.featureArray&&t.featureArray.destroy();if(e.children)for(const t of e.children)Mv(t);}function Av(e){if(e.meshes)for(const i of e.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((t=i.material).pbrMetallicRoughness.baseColorTexture&&t.pbrMetallicRoughness.baseColorTexture.gfxTexture&&t.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),t.pbrMetallicRoughness.metallicRoughnessTexture&&t.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&t.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),t.normalTexture&&t.normalTexture.gfxTexture&&t.normalTexture.gfxTexture.destroy(),t.emissionTexture&&t.emissionTexture.gfxTexture&&t.emissionTexture.gfxTexture.destroy(),t.occlusionTexture&&t.occlusionTexture.gfxTexture&&t.occlusionTexture.gfxTexture.destroy()));var t;if(e.children)for(const t of e.children)Av(t);}class Sv{constructor(e,t){this.feature=e,this.instancedDataOffset=t,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0];}}class Iv{constructor(){this.instancedDataArray=new Ya,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={};}}class Cv{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.fqid)),this.projection=e.projection,this.index=e.index,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0};}populate(e,t,i,r){this.tileToMeter=Qd(i);const n=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of e){const e=cp(o,n);if(!this.layers[0]._featureFilter.filter(new ea(this.zoom),e,i))continue;const c={id:s,sourceLayerIndex:l,index:a,geometry:n?e.geometry:lp(o,i,r),properties:o.properties,type:o.type,patterns:{}},h=this.addFeature(c,c.geometry,e);h&&t.featureIndex.insert(o,c.geometry,a,l,this.index,this.instancesPerModel[h].instancedDataArray.length);}this.lookup=null;}update(e,t,i,r){for(const t in this.instancesPerModel){const i=this.instancesPerModel[t];for(const t in e)i.idToFeaturesIndex.hasOwnProperty(t)&&this.evaluate(i.features[i.idToFeaturesIndex[t]],e[t],i,!0);}this.maxHeight=0;}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return !1;let e=!1;for(const t in this.instancesPerModel){const i=this.instancesPerModel[t];for(const t of i.features){const r=this.layers[0],n=t.feature,o=this.canonical,s=r.paint.get("model-rotation").evaluate(n,{},o),a=r.paint.get("model-scale").evaluate(n,{},o),l=r.paint.get("model-translation").evaluate(n,{},o);Mu.exactEquals(t.rotation,s)&&Mu.exactEquals(t.scale,a)&&Mu.exactEquals(t.translation,l)||(this.evaluate(t,t.featureStates,i,!0),e=!0);}}return e}isEmpty(){for(const e in this.instancesPerModel)if(0!==this.instancesPerModel[e].instancedDataArray.length)return !1;return !0}uploadPending(){return !this.uploaded}upload(e){if(!this.uploaded)for(const t in this.instancesPerModel){const i=this.instancesPerModel[t];i.instancedDataArray.length<0||0===i.instancedDataArray.length||(i.instancedDataBuffer?i.instancedDataBuffer.updateData(i.instancedDataArray):i.instancedDataBuffer=e.createVertexBuffer(i.instancedDataArray,kx.members,!0,void 0,this.instanceCount));}this.uploaded=!0;}destroy(){for(const e in this.instancesPerModel){const t=this.instancesPerModel[e];0!==t.instancedDataArray.length&&t.instancedDataBuffer&&t.instancedDataBuffer.destroy();}}addFeature(e,t,i){const r=this.layers[0],n=r.layout.get("model-id").evaluate(i,{},this.canonical);if(!n)return W(`modelId is not evaluated for layer ${r.id} and it is not going to get rendered.`),n;this.instancesPerModel[n]||(this.instancesPerModel[n]=new Iv);const o=this.instancesPerModel[n],s=o.instancedDataArray,a=new Sv(i,s.length);for(const e of t)for(const t of e){if(t.x<0||t.x>=sr||t.y<0||t.y>=sr)continue;const e=(this.lookupDim-1)/sr,i=this.lookupDim*(t.y*e|0)+t.x*e|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1;}this.instanceCount++;const r=s.length;s.resize(r+1),o.instancesEvaluatedElevation.push(0),s.float32[16*r]=t.x,s.float32[16*r+1]=t.y;}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(e.id&&(o.idToFeaturesIndex[e.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),n}evaluate(e,t,i,r){const n=this.layers[0],o=e.feature,s=this.canonical,a=e.rotation=n.paint.get("model-rotation").evaluate(o,t,s),l=e.scale=n.paint.get("model-scale").evaluate(o,t,s),c=e.translation=n.paint.get("model-translation").evaluate(o,t,s),h=n.paint.get("model-color").evaluate(o,t,s);h.a=n.paint.get("model-color-mix-intensity").evaluate(o,t,s);const u=[];this.maxVerticalOffset10?this.tileToMeter:Qd(s,p)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=u[0],a[o+8]=u[1],a[o+9]=u[2],a[o+10]=u[4],a[o+11]=u[5],a[o+12]=u[6],a[o+13]=u[8],a[o+14]=u[9],a[o+15]=u[10],i.instancesEvaluatedElevation[n]=c[2];}}}Is(Cv,"ModelBucket",{omit:["layers"]}),Is(Iv,"PerModelAttributes"),Is(Sv,"ModelFeature");const zv=new da({visibility:new ca(Ct.layout_model.visibility),"model-id":new ha(Ct.layout_model["model-id"])});var Dv={paint:new da({"model-opacity":new ca(Ct.paint_model["model-opacity"]),"model-rotation":new ha(Ct.paint_model["model-rotation"]),"model-scale":new ha(Ct.paint_model["model-scale"]),"model-translation":new ha(Ct.paint_model["model-translation"]),"model-color":new ha(Ct.paint_model["model-color"]),"model-color-mix-intensity":new ha(Ct.paint_model["model-color-mix-intensity"]),"model-type":new ca(Ct.paint_model["model-type"]),"model-cast-shadows":new ca(Ct.paint_model["model-cast-shadows"]),"model-receive-shadows":new ca(Ct.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new ca(Ct.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new ha(Ct.paint_model["model-emissive-strength"]),"model-roughness":new ha(Ct.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new ha(Ct.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new ca(Ct.paint_model["model-cutoff-fade-range"])}),layout:zv};const Pv=new Float32Array(262144),Rv=new Uint8Array(262144);function Lv(e){let t=0;if(e.meshes)for(const i of e.meshes)t=Math.max(t,i.aabb.max[2]);if(e.children)for(const i of e.children)t=Math.max(t,Lv(i));return t}const kv=["","wall","door","roof","window","lamp","logo"];class Ov{constructor(e){this.node=e,this.evaluatedRMEA=[[1,0,0,1],[1,0,0,1],[1,0,0,1],[1,0,0,1],[.4,1,0,1],[1,0,0,1],[1,0,0,1]],this.hiddenByReplacement=!1,this.evaluatedScale=[1,1,1],this.evaluatedColor=[],this.emissionHeightBasedParams=[],this.feature={type:"Point",id:e.id,geometry:[],properties:{height:Lv(e)}};}}class Bv{constructor(e,t,i,r){this.nodes=e,this.id=t,this.modelTraits|=1,this.uploaded=!1,this.hasPattern=!1,i&&(this.modelTraits|=4),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=r,this.dirty=!0,this.needsUpload=!1;}update(){console.log("Update 3D model bucket");}populate(){console.log("populate 3D model bucket");}uploadPending(){return !this.uploaded||this.needsUpload}upload(e){if(!this.needsUpload)return;const t=this.getNodesInfo();for(const i of t){const t=i.node;this.uploaded?this.updatePbrBuffer(t):Ev(t,e,!0);}for(const e of t)Mv(e.node);this.uploaded=!0,this.needsUpload=!1;}updatePbrBuffer(e){let t=!1;if(!e.meshes)return t;for(const i of e.meshes)i.pbrBuffer&&(i.pbrBuffer.updateData(i.featureArray),t=!0);return t}needsReEvaluation(e,t,i){const r=e.transform.projectionOptions,n=e.style.getBrightness(),o=this.brightness!==n;return !!(!this.uploaded||this.dirty||r.name!==this.projection.name||Fv(i.paint.get("model-color").value,o)||Fv(i.paint.get("model-color-mix-intensity").value,o)||Fv(i.paint.get("model-roughness").value,o)||Fv(i.paint.get("model-emissive-strength").value,o)||Fv(i.paint.get("model-height-based-emissive-strength-multiplier").value,o))&&(this.projection=r,this.brightness=n,!0)}evaluateScale(e,t){if(e.transform.zoom===this.zoom)return;this.zoom=e.transform.zoom;const i=this.getNodesInfo(),r=this.id.canonical;for(const e of i){const i=e.feature;e.evaluatedScale=t.paint.get("model-scale").evaluate(i,{},r);}}evaluate(e){const t=this.getNodesInfo();for(const i of t){if(!i.node.meshes)continue;const t=i.feature,r=i.node.meshes&&i.node.meshes[0].featureData,n=i.evaluatedColor[2],o=i.evaluatedRMEA[2],s=this.id.canonical;if(i.hasTranslucentParts=!1,r){for(let r=0;r=e)continue;const u=Pv[c],d=Math.abs(u);d>a&&(s=u,a=d,l=n,h=t);}if(a>.1){const o=1-(e+.5*Math.abs(l*h))/c;let a=t._dem.get(r,i)+s*o;const u=t._dem.get(r+l,i+h),d=t._dem.get(r-l,i-h,!0);(a-u)*(a-d)>0&&(a=(u+d)/2),Pv[n]=t._dem.set(r,i,a),Rv[n]=e;}}}}}s&&(t._demTile.needsDEMTextureUpload=!0,t._dem._timestamp=ht.now());}getNodesInfo(){if(!this.nodesInfo){this.nodesInfo=[];for(const e of this.nodes)this.nodesInfo.push(new Ov(e));this.freeNodes();}return this.nodesInfo}freeNodes(){if(this.nodes){for(const e of this.nodes)Av(e);this.nodes.splice(0,this.nodes.length);}}destroy(){this.freeNodes();const e=this.getNodesInfo();for(const t of e)Mv(t.node),Av(t.node);}isEmpty(){return !this.nodes.length}updateReplacement(e,t){if(t.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=t.updateTime;const i=t.getReplacementRegionsForTile(e.toUnwrapped()),r=this.getNodesInfo();for(let e=0;ee.footprint===t.footprint));}}getHeightAtTileCoord(e,t){const i=this.getNodesInfo(),r=[];for(let n=0;ns.aabb.max[0]||t>s.aabb.max[1])continue;const a=(e-s.aabb.min[0])/(s.aabb.max[0]-s.aabb.min[0])*xv|0,l=Math.min(63,(t-s.aabb.min[1])/(s.aabb.max[1]-s.aabb.min[1])*xv|0)*xv+Math.min(63,a);if(!(s.heightmap[l]<0&&o.node.footprint)){if(o.hiddenByReplacement)return;return {height:s.heightmap[l],maxHeight:o.feature.properties.height,hidden:!1,verticalScale:o.evaluatedScale[2]}}if(o.node.footprint.grid.query(new y(e,t),new y(e,t),r),r.length>0)return {height:void 0,maxHeight:o.feature.properties.height,hidden:o.hiddenByReplacement,verticalScale:o.evaluatedScale[2]}}}}function Fv(e,t){return !e.isLightConstant&&t}function Nv(e,t,i,r,n,o,s,a){let l=(61440&t|(61440&t)>>4)>>8,c=(3840&t|(3840&t)>>4)>>4,h=240&t|(240&t)>>4;i[3]>0&&(l=Wr(l,255*i[0],i[3]),c=Wr(c,255*i[1],i[3]),h=Wr(h,255*i[2],i[3]));const u=l<<8|c,d=h<<8|Math.floor(255*r[3]),p=function(e){const t=z(e,0,2);return Math.min(Math.round(.5*t*255),255)}(r[2])<<8|15*r[0]<<4|15*r[1],f=z(n[0],0,1),m=z(n[1],0,1),_=z(n[2],0,1),g=z(n[3],0,1);let y,x,v,b;if(f!==m&&s!==o&&m!==f){const e=s-o;x=1/(e*(m-f)),v=-(o+e*f)/(e*(m-f));const t=z(n[4],-1,1);b=Math.pow(10,t),y=255*_<<8|255*g;}else y=65535,x=0,v=1,b=1;if(e.emplaceBack(u,d,p,y,x,v,b),a){const e=a.length;a.clear();for(let t=0;t>16&65535,c=e.evaluatedRMEA[a],h=e.evaluatedColor[a],u=e.emissionHeightBasedParams[a];if(o&&2===a&&i.lights&&(r=new Ka,r.resize(10*i.lights.length)),Nv(n.featureArray,l,h,c,u,n.aabb.min[2],n.aabb.max[2],r),r&&o){o=!1;const e=i.meshes[i.lightMeshIndex];e.featureArray=r,e.featureArray._trim();}}n.featureArray._trim(),r++;}}Is(Bv,"Tiled3dModelBucket",{omit:["layers"]}),Is(Ov,"Tiled3dModelFeature");class Vv{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[];}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[];}get updateTime(){return this._updateTime}getReplacementRegionsForTile(e){const t=Zv(new y(0,0),new y(sr,sr),e),i=[];for(const r of this._activeRegions){if(r.hiddenByOverlap)continue;if(!qv(t,r))continue;const n=$v(r.min,r.max,e);i.push({min:n.min,max:n.max,sourceId:this._sourceIds[r.priority],footprint:r.footprint,footprintTileId:r.tileId});}return i}setSources(e){this._setSources(e.map((e=>({getSourceId:()=>e.cache.id,getFootprints:()=>{const t=[];for(const i of e.cache.getVisibleCoordinates()){const r=e.cache.getTile(i).buckets[e.layer];if(r)for(const e of r.getNodesInfo()){const r=e.node;r.footprint&&t.push({footprint:r.footprint,id:i.toUnwrapped()});}}return t}}))));}_addSource(e){const t=e.getFootprints();if(0!==t.length){for(const e of t){if(!e.footprint)continue;const t=Zv(e.footprint.min,e.footprint.max,e.id);this._activeRegions.push({min:t.min,max:t.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:e.id,footprint:e.footprint});}this._sourceIds.push(e.getSourceId());}}_computeReplacement(){this._activeRegions.sort(((e,t)=>e.priority-t.priority||jv(e.min,t.min)||jv(e.max,t.max)));let e=this._activeRegions.length!==this._prevRegions.length;if(!e){let t=0,i=0;for(;!e&&t!==this._activeRegions.length;){const r=this._activeRegions[t],n=this._prevRegions[i];e=r.priority!==n.priority||!Gv(r,n),++t,++i;}}if(e){++this._updateTime;const e=e=>{const t=this._activeRegions;if(e>=t.length)return e;const i=t[e].priority;for(;e1){let t=0,i=e(t);for(;t!==i;){let r=t;const n=t;for(;r!==i;){const e=this._activeRegions[r];e.hiddenByOverlap=!1;for(let t=0;t=0;t--)this._addSource(e[t]);this._computeReplacement();}}function jv(e,t){return e.x-t.x||e.y-t.y}function Gv(e,t){return 0===jv(e.min,t.min)&&0===jv(e.max,t.max)}function qv(e,t){return !(e.min.x>t.max.x||e.max.xt.max.y||e.max.ynew y(e.x*o.x*sr*a-s.x*sr,e.y*o.y*sr*a-s.y*sr)));}return Hv(i,n,e.indices,0,e.indices.length,0,0)}const Xv=im.types,Yv=["fill-extrusion-base","fill-extrusion-height","fill-extrusion-color","fill-extrusion-pattern","fill-extrusion-flood-light-wall-radius"],Kv=["fill-extrusion-flood-light-ground-radius"],Jv=Math.pow(2,13),Qv=Math.pow(2,15)-1,eb=new y(0,1),tb=2147483648;function ib(e,t,i,r,n,o,s,a){e.emplaceBack((t<<1)+s,(i<<1)+o,(Math.floor(r*Jv)<<1)+n,Math.round(a));}function rb(e,t,i,r,n,o){e.emplaceBack(t.x,t.y,(i.x<<1)+r,(i.y<<1)+n,o);}function nb(e,t,i){const r=16384;e.emplaceBack(t.x,t.y,t.z,i[0]*r,i[1]*r,i[2]*r);}class ob{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0;}}class sb{constructor(){this.centroidXY=new y(0,0),this.vertexArrayOffset=0,this.vertexCount=0,this.groundVertexArrayOffset=0,this.groundVertexCount=0,this.flags=0,this.footprintSegIdx=-1,this.footprintSegLen=0,this.min=new y(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new y(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0;}span(){return new y(this.max.x-this.min.x,this.max.y-this.min.y)}}class ab{constructor(){this.acc=new y(0,0),this.accCount=0,this.centroidDataIndex=0;}startRing(e,t){e.min.x===Number.MAX_VALUE&&(e.min.x=e.max.x=t.x,e.min.y=e.max.y=t.y);}appendEdge(e,t,i){this.accCount++,this.acc._add(t);let r=!!this.borders;t.xe.max.x&&(e.max.x=t.x,r=!0),t.ye.max.y&&(e.max.y=t.y,r=!0),((0===t.x||t.x===sr)&&t.x===i.x)!=((0===t.y||t.y===sr)&&t.y===i.y)&&this.processBorderOverlap(t,i),r&&this.checkBorderIntersection(t,i);}checkBorderIntersection(e,t){t.x<0!=e.x<0&&this.addBorderIntersection(0,Wr(t.y,e.y,(0-t.x)/(e.x-t.x))),t.x>sr!=e.x>sr&&this.addBorderIntersection(1,Wr(t.y,e.y,(sr-t.x)/(e.x-t.x))),t.y<0!=e.y<0&&this.addBorderIntersection(2,Wr(t.x,e.x,(0-t.y)/(e.y-t.y))),t.y>sr!=e.y>sr&&this.addBorderIntersection(3,Wr(t.x,e.x,(sr-t.y)/(e.y-t.y)));}addBorderIntersection(e,t){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const i=this.borders[e];ti[1]&&(i[1]=t);}processBorderOverlap(e,t){if(e.x===t.x){if(e.y===t.y)return;const i=0===e.x?0:1;this.addBorderIntersection(i,t.y),this.addBorderIntersection(i,e.y);}else {const i=0===e.y?2:3;this.addBorderIntersection(i,t.x),this.addBorderIntersection(i,e.x);}}centroid(){return 0===this.accCount?new y(0,0):new y(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce(((e,t)=>e+ +(t[0]!==Number.MAX_VALUE)),0):0}}function lb(e,t){const i=e.add(t)._unit(),r=z(e.x*i.x+e.y*i.y,-1,1);var n,o,s;return n=Math.acos(r),Math.min(4,Math.max(-4,Math.tan(n)))/4*Qv*((o=e).x*(s=t).y-o.y*s.x<0?-1:1)}const cb=[e=>e.x<0,e=>e.x>sr,e=>e.y<0,e=>e.y>sr];function hb(e,t,i,r){const n=[4];if(0===r)return n;i._mult(r);const o=e.sub(i),s=t.sub(i),a=[e,t,o,s];for(let e=0;e<4;e++)for(const t of a)if(cb[e](t)){n.push(e);break}return n}class ub{constructor(e){this.vertexArray=new Aa,this.indexArray=new Va,this.programConfigurations=new Hl(e.layers,e.zoom,(e=>Kv.includes(e))),this._segments=new dl,this.hiddenByLandmarkVertexArray=new Ja,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new dl;}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(e,t,i,r=!1){const n=e.length;if(n>2){let o=Math.max(0,this._segments.get().length-1);const s=this._segments._prepareSegment(4*n,this.vertexArray.length,2*this._segmentToGroundQuads[o].length);let a;o!==this._segments.get().length-1&&(o++,this._segmentToGroundQuads[o]=[],this._segmentToRegionTriCounts[o]=[0,0,0,0,0]);{const t=e[0],i=e[1];a=lb(t.sub(e[n-1])._perp()._unit(),i.sub(t)._perp()._unit());}for(let l=0;le.region-t.region));for(let i=0;ie+t),0);let o=0;for(let e=0;e<=4;e++){const t=n[e];if(0!==t){let i=this.regionSegments[e];i||(i=this.regionSegments[e]=new dl);const n={vertexOffset:r.vertexOffset,primitiveOffset:r.primitiveOffset+o,vertexLength:r.vertexLength,primitiveLength:t};i.get().push(n);}o+=t;}for(let e=0;e0?this.hiddenByLandmarkVertexBuffer=e.createVertexBuffer(this.hiddenByLandmarkVertexArray,Uf.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1);}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let e=0;e<=4;e++){const t=this.regionSegments[e];t&&t.destroy();}}}}class db{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.fqid)),this.index=e.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=e.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=[],this.footprintIndices=new Va,this.footprintVertices=new Ta,this.footprintSegments=[],this.layoutVertexArray=new Ma,this.centroidVertexArray=new cl,this.indexArray=new Va,this.programConfigurations=new Hl(e.layers,e.zoom,(e=>Yv.includes(e))),this.segments=new dl,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.groundEffect=new ub(e),this.maxHeight=0,this.partLookup={};}populate(e,t,i,r){this.features=[],this.hasPattern=Pf("fill-extrusion",this.layers,t),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=Qd(i),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter;for(const{feature:n,id:o,index:s,sourceLayerIndex:a}of e){const e=this.layers[0]._featureFilter.needGeometry,l=cp(n,e);if(!this.layers[0]._featureFilter.filter(new ea(this.zoom),l,i))continue;const c={id:o,sourceLayerIndex:a,index:s,geometry:e?l.geometry:lp(n,i,r),properties:n.properties,type:n.type,patterns:{}},h=this.layoutVertexArray.length;this.hasPattern?this.features.push(Rf("fill-extrusion",this.layers,c,this.zoom,t)):this.addFeature(c,c.geometry,s,i,{},t.availableImages,r,t.brightness),t.featureIndex.insert(n,c.geometry,s,a,this.index,h);}this.sortBorders(),this.groundEffect.prepareBorderSegments();}addFeatures(e,t,i,r,n,o){for(const e of this.features){const{geometry:s}=e;this.addFeature(e,s,e.index,t,i,r,n,o);}this.sortBorders();}update(e,t,i,r,n){const o=0!==Object.keys(e).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.programConfigurations.updatePaintArrays(e,t,s,i,r,n),this.groundEffect.update(e,t,s,i,r,n);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,jf),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=e.createVertexBuffer(this.layoutVertexExtArray,Vf.members,!0)),this.groundEffect.upload(e)),this.groundEffect.uploadPaintProperties(e),this.programConfigurations.upload(e),this.uploaded=!0;}uploadCentroid(e){this.groundEffect.uploadHiddenByLandmark(e),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,Nf.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1);}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.groundEffect.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy());}addFeature(e,t,i,r,n,o,s,a){const l=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(e,{})/this.tileToMeter,c=[new y(0,0),new y(sr,sr)],h=s.projection,u="globe"===h.name,d="Polygon"===Xv[e.type],p=new ab;p.centroidDataIndex=this.centroidData.length;const f=new sb,m=this.layers[0].paint.get("fill-extrusion-base").evaluate(e,{},r)<=0,_=this.layers[0].paint.get("fill-extrusion-height").evaluate(e,{},r);f.height=_,f.vertexArrayOffset=this.layoutVertexArray.length,f.groundVertexArrayOffset=this.groundEffect.vertexArray.length,u&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new Da);const g=zf(t,500);for(let e=g.length-1;e>=0;e--){const t=g[e];(0===t.length||(x=t[0]).every((e=>e.x<=0))||x.every((e=>e.x>=sr))||x.every((e=>e.y<=0))||x.every((e=>e.y>=sr)))&&g.splice(e,1);}var x;let v;if(u)v=bb(g,c,r);else {v=[];for(const e of g)v.push({polygon:e,bounds:c});}const b=d?this.edgeRadius:0,w=b>0&&this.zoom<17,T=(e,t)=>{if(0===e.length)return !1;const i=e[e.length-1];return t.x===i.x&&t.y===i.y};for(const{polygon:e,bounds:t}of v){let i=0,n=0;for(const t of e)d&&!t[0].equals(t[t.length-1])&&t.push(t[0]),n+=d?t.length-1:t.length;const o=this.segments.prepareSegment((d?5:4)*n,this.layoutVertexArray,this.indexArray);f.footprintSegIdx<0&&(f.footprintSegIdx=this.footprintSegments.length);const s=new ob;if(s.vertexOffset=this.footprintVertices.length,s.indexOffset=3*this.footprintIndices.length,s.ringIndices=[],d){const n=[],a=[];i=o.vertexLength;for(let i=0;i4&&yb(s[s.length-2],s[0],s[1]),c=b?fb(s[s.length-2],s[0],s[1],b):0;const _=[];let g,y,x;y=s[1].sub(s[0])._perp()._unit();let v=!0;for(let e=1,n=0;e0?1:0,S=l.dist(d);if(n+S>32768&&(n=0),b){x=w.sub(d)._perp()._unit();let e=mb(l,d,w,pb(y,x),b);isNaN(e)&&(e=0);const t=d.sub(l)._unit();l=l.add(t.mult(c))._round(),d=d.add(t.mult(-e))._round(),c=e,y=x,m&&this.zoom>=17&&(T(_,l)||_.push(l),T(_,d)||_.push(d));}const I=o.vertexLength,C=s.length>4&&yb(l,d,w);let z=xb(n,a,v);if(ib(this.layoutVertexArray,l.x,l.y,M,A,0,0,z),ib(this.layoutVertexArray,l.x,l.y,M,A,0,1,z),n+=S,z=xb(n,C,!v),a=C,ib(this.layoutVertexArray,d.x,d.y,M,A,0,0,z),ib(this.layoutVertexArray,d.x,d.y,M,A,0,1,z),o.vertexLength+=4,this.indexArray.emplaceBack(I+0,I+1,I+2),this.indexArray.emplaceBack(I+1,I+3,I+2),o.primitiveLength+=2,b){const r=i+(1===e?s.length-2:e-2),n=1===e?i:r+1;if(this.indexArray.emplaceBack(I+1,r,I+3),this.indexArray.emplaceBack(r,n,I+3),o.primitiveLength+=2,void 0===g&&(g=I),!_b(w,s[e],t)){const t=e===s.length-1?g:o.vertexLength;this.indexArray.emplaceBack(I+2,I+3,t),this.indexArray.emplaceBack(I+3,t+1,t),this.indexArray.emplaceBack(I+3,n,t+1),o.primitiveLength+=3;}v=!v;}if(u){const e=this.layoutVertexExtArray,t=h.projectTilePoint(l.x,l.y,r),i=h.projectTilePoint(d.x,d.y,r),n=h.upVector(r,l.x,l.y),o=h.upVector(r,d.x,d.y);nb(e,t,n),nb(e,t,n),nb(e,i,o),nb(e,i,o);}}d&&(i+=s.length-1),m&&b&&this.zoom>=17&&(0!==_.length&&T(_,_[0])&&_.pop(),this.groundEffect.addData(_,t,l,b>0));}this.footprintSegments.push(s),++f.footprintSegLen;}if(f.vertexCount=this.layoutVertexArray.length-f.vertexArrayOffset,f.groundVertexCount=this.groundEffect.vertexArray.length-f.groundVertexArrayOffset,0!==f.vertexCount){if(f.centroidXY=p.borders?eb:this.encodeCentroid(p,f),this.centroidData.push(f),p.borders){this.featuresOnBorder.push(p);const e=this.featuresOnBorder.length-1;for(let t=0;tthis.featuresOnBorder[t].borders[e][0]-this.featuresOnBorder[i].borders[e][0]));}encodeCentroid(e,t){const i=e.centroid(),r=t.span(),n=Math.min(7,Math.round(r.x*this.tileToMeter/10)),o=Math.min(7,Math.round(r.y*this.tileToMeter/10));return new y(z(i.x,1,sr-1)<<3|n,z(i.y,1,sr-1)<<3|o)}showCentroid(e){const t=this.centroidData[e.centroidDataIndex];t.flags&=tb,t.centroidXY.x=0,t.centroidXY.y=0,this.writeCentroidToBuffer(t);}writeCentroidToBuffer(e){this.groundEffect.updateHiddenByLandmark(e);const t=e.vertexArrayOffset,i=e.vertexCount+e.vertexArrayOffset,r=e.flags&tb?eb:e.centroidXY,n=this.centroidVertexArray.geta_centroid_pos0(t);if(this.centroidVertexArray.geta_centroid_pos1(t)!==r.y||n!==r.x){for(let e=t;en.max.x||n.min.x>t.max.x||t.min.y>n.max.y||n.min.y>t.max.y))for(let o=0;ot!=l>t&&e<(this.footprintVertices.int16[2*(a+o.vertexOffset)+0]-i)*(t-s)/(l-s)+i&&(r=!r);}s=i;}}return r}getHeightAtTileCoord(e,t){let i=Number.NEGATIVE_INFINITY,r=!0;const n=4*(e+sr)*sr+(t+sr);if(this.partLookup.hasOwnProperty(n)){const e=this.partLookup[n];return e?{height:e.height,hidden:!!(e.flags&tb)}:void 0}for(const o of this.centroidData)e>o.max.x||o.min.x>e||t>o.max.y||o.min.y>t||this.footprintContainsPoint(e,t,o)&&o&&o.height>i&&(i=o.height,this.partLookup[n]=o,r=!!(o.flags&tb));if(i!==Number.NEGATIVE_INFINITY)return {height:i,hidden:r};this.partLookup[n]=void 0;}}function pb(e,t){const i=e.add(t)._unit();return e.x*i.x+e.y*i.y}function fb(e,t,i,r){const n=t.sub(e)._perp()._unit(),o=i.sub(t)._perp()._unit();return mb(e,t,i,pb(n,o),r)}function mb(e,t,i,r,n){const o=Math.sqrt(1-r*r);return Math.min(e.dist(t)/3,t.dist(i)/3,n*o/r)}function _b(e,t,i){return e.xi[1].x&&t.x>i[1].x||e.yi[1].y&&t.y>i[1].y}function gb(e,t){return e.xt[1].x||e.yt[1].y}function yb(e,t,i){if(e.x<0||e.x>=sr||t.x<0||t.x>=sr||i.x<0||i.x>=sr)return !1;const r=i.sub(t),n=r.perp(),o=e.sub(t);return (r.x*o.x+r.y*o.y)/Math.sqrt((r.x*r.x+r.y*r.y)*(o.x*o.x+o.y*o.y))>-.866&&n.x*o.x+n.y*o.y<0}function xb(e,t,i){const r=t?2|e:-3&e;return i?1|r:-2&r}function vb(){const e=Math.PI/32,t=Math.tan(e),i=Od;return i*Math.sqrt(1+2*t*t)-i}function bb(e,t,i){const r=1<{for(const i of e)s.push({polygon:i,bounds:t});},l=Math.ceil(Math.log2(i)),c=Math.ceil(Math.log2(r)),h=l-c,u=[];for(let e=0;e0?0:1);for(let e=0;et+1?p.push({polygons:d,bounds:e,depth:t+1}):a(d,e);}if(f.length){const e=[new y(0===i?h:r.x,1===i?h:r.y),s];u.length>t+1?p.push({polygons:f,bounds:e,depth:t+1}):a(f,e);}}return s}(e,t,Math.ceil((o-n)/11.25),Math.ceil((s-a)/11.25),1,((e,t,n)=>{if(0===e)return .5*(t+n);{const e=Hd((i.y+t/sr)/r);return (qd(.5*(Hd((i.y+n/sr)/r)+e))*r-i.y)*sr}}))}function wb(e,t,i,r,n,o){const s=Math.pow(2,r.z-n.z);for(let a=0;a{const a=e.transform,l=a.calculatePixelsToTileUnitsMatrix(t);return {u_matrix:Lb(e,t,i,r),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:n,u_texsize:Ob(i)?t.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:Rb(t,e.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_emissive_strength:i.paint.get("line-emissive-strength")}},Pb=(e,t,i,r,n)=>{const o=e.transform;return {u_matrix:Lb(e,t,i,r),u_texsize:t.imageAtlasTexture.size,u_pixels_to_tile_units:o.calculatePixelsToTileUnitsMatrix(t),u_device_pixel_ratio:n,u_image:0,u_tile_units_to_pixels:Rb(t,o),u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]],u_alpha_discard_threshold:0}};function Rb(e,t){return 1/Xx(e,1,t.tileZoom)}function Lb(e,t,i,r){return e.translatePosMatrix(r||t.tileID.projMatrix,t,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}const kb=e=>{const t=[];Ob(e)&&t.push("RENDER_LINE_DASH"),e.paint.get("line-gradient")&&t.push("RENDER_LINE_GRADIENT");const i=e.paint.get("line-trim-offset");return 0===i[0]&&0===i[1]||t.push("RENDER_LINE_TRIM_OFFSET"),0!==e.paint.get("line-border-width").constantOr(1)&&t.push("RENDER_LINE_BORDER"),t};function Ob(e){const t=e.paint.get("line-dasharray").value;return t.value||"constant"!==t.kind}const Bb=new class extends ha{possiblyEvaluate(e,t){return t=new ea(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,transition:t.transition}),super.possiblyEvaluate(e,t)}evaluate(e,t,i,r){return t=k({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,i,r)}}(zb.paint.properties["line-width"].specification);function Fb(e,t){return t>0?t+2*e:e}Bb.useIntegerZoom=!0;const Nb=new da({visibility:new ca(Ct.layout_background.visibility)});var Ub={paint:new da({"background-color":new ca(Ct.paint_background["background-color"]),"background-pattern":new ca(Ct.paint_background["background-pattern"]),"background-opacity":new ca(Ct.paint_background["background-opacity"]),"background-emissive-strength":new ca(Ct.paint_background["background-emissive-strength"])}),layout:Nb};const Vb=new da({visibility:new ca(Ct.layout_raster.visibility)});var jb={paint:new da({"raster-opacity":new ca(Ct.paint_raster["raster-opacity"]),"raster-color":new ua(Ct.paint_raster["raster-color"]),"raster-color-mix":new ca(Ct.paint_raster["raster-color-mix"]),"raster-color-range":new ca(Ct.paint_raster["raster-color-range"]),"raster-hue-rotate":new ca(Ct.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new ca(Ct.paint_raster["raster-brightness-min"]),"raster-brightness-max":new ca(Ct.paint_raster["raster-brightness-max"]),"raster-saturation":new ca(Ct.paint_raster["raster-saturation"]),"raster-contrast":new ca(Ct.paint_raster["raster-contrast"]),"raster-resampling":new ca(Ct.paint_raster["raster-resampling"]),"raster-fade-duration":new ca(Ct.paint_raster["raster-fade-duration"])}),layout:Vb};function Gb(e,t,i,r,n,o,s,a){const l=[e,i,n,t,r,o,1,1,1],c=[s,a,1],h=gu.adjoint([],l),[u,d,p]=Mu.transformMat3(c,c,gu.transpose(h,h));return gu.multiply(l,[u,0,0,0,d,0,0,0,p],l)}class qb extends It{constructor(e,t,i,r){super(),this.id=e,this.dispatcher=i,this.coordinates=t.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(r),this.options=t,this._dirty=!1;}load(e,i){if(this._loaded=i||!1,this.fire(new At("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return e&&(this.coordinates=e),this._loaded=!0,void this._finishLoading();this._imageRequest=Ie(this.map._requestManager.transformRequest(this.url,ye.Image),((i,r)=>{if(this._imageRequest=null,this._loaded=!0,i)this.fire(new St(i));else if(r){const{HTMLImageElement:i}=t;this.image=r instanceof i?ht.getImageData(r):r,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,e&&(this.coordinates=e),this._finishLoading();}}));}loaded(){return this._loaded}updateImage(e){return this.image&&e.url?(this._imageRequest&&e.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=e.url,this.load(e.coordinates,this._loaded),this):this}setTexture(e){if(!(e.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new yy(this.map.painter.context,e.handle),this.width=e.dimensions[0],this.height=e.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new At("data",{dataType:"source",sourceDataType:"metadata"})));}onAdd(e){this.map=e,this.load();}onRemove(){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof yy||this.texture.destroy();}setCoordinates(e){if(this.coordinates=e,this._boundsArray=void 0,!e.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let t=e[0][1],i=e[0][1];for(const r of e)r[1]>i&&(i=r[1]),r[1]Xd?this.onNorthPole=!0:r<-Xd&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const t=e.map(ep.fromLngLat);this.tileID=function(e){let t=1/0,i=1/0,r=-1/0,n=-1/0;for(const o of e)t=Math.min(t,o.x),i=Math.min(i,o.y),r=Math.max(r,o.x),n=Math.max(n,o.y);const o=Math.max(r-t,n-i),s=Math.max(0,Math.floor(-Math.log(o)/Math.LN2)),a=Math.pow(2,s);return new ku(s,Math.floor((t+r)/2*a),Math.floor((i+n)/2*a))}(t),this.minzoom=this.maxzoom=this.tileID.z;}return this.fire(new At("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0;}_prepareData(e){for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture);}if(this._boundsArray)return;const t=Tg(this.tileID,this.map.transform.projection),[i,r,n,o]=this.coordinates.map((e=>{const i=t.projection.project(e[0],e[1]);return Mg(t,i)._round()}));this.perspectiveTransform=function(e,t,i,r,n,o,s,a,l,c){const h=Gb(0,0,e,0,0,t,e,t),u=Gb(i,r,n,o,s,a,l,c);return gu.multiply(u,gu.adjoint(h,h),u),[u[6]/u[8]*e/sr,u[7]/u[8]*t/sr]}(this.width,this.height,i.x,i.y,r.x,r.y,o.x,o.y,n.x,n.y);const s=this._boundsArray=new Ma;s.emplaceBack(i.x,i.y,0,0),s.emplaceBack(r.x,r.y,sr,0),s.emplaceBack(o.x,o.y,0,sr),s.emplaceBack(n.x,n.y,sr,sr),this.boundsBuffer&&this.boundsBuffer.destroy(),this.boundsBuffer=e.createVertexBuffer(s,Ay.members),this.boundsSegments=dl.simpleSegment(0,0,4,2);}prepare(){const e=0!==Object.keys(this.tiles).length;if(this.tileID&&!e)return;const t=this.map.painter.context,i=t.gl;!this._dirty||this.texture instanceof yy||(this.texture?this.texture.update(this.image):(this.texture=new gy(t,this.image,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE)),this._dirty=!1),e&&this._prepareData(t);}loadTile(e,t){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={},t(null)):(e.state="errored",t(null));}serialize(){return {type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return !1}}class Zb extends _a{constructor(e){super(e,{}),this.implementation=e,e.slot&&(this.slot=e.slot);}is3D(){return "3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}isLayerDraped(e){return void 0!==this.implementation.renderToTile}shouldRedrape(){return !!this.implementation.shouldRerenderTiles&&this.implementation.shouldRerenderTiles()}recalculate(){}updateTransitions(){}hasTransition(){return !1}serialize(){}onAdd(e){this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl);}onRemove(e){this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl);}}const $b=new da({visibility:new ca(Ct.layout_sky.visibility)});var Hb={paint:new da({"sky-type":new ca(Ct.paint_sky["sky-type"]),"sky-atmosphere-sun":new ca(Ct.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new ca(Ct.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new ca(Ct.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new ca(Ct.paint_sky["sky-gradient-radius"]),"sky-gradient":new ua(Ct.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new ca(Ct.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new ca(Ct.paint_sky["sky-atmosphere-color"]),"sky-opacity":new ca(Ct.paint_sky["sky-opacity"])}),layout:$b};function Wb(e,t,i){const r=[0,0,1],n=bu.identity([]);return bu.rotateY(n,n,i?-w(e)+Math.PI:w(e)),bu.rotateX(n,n,-w(t)),Mu.transformQuat(r,r,n),Mu.normalize(r,r)}var Xb={paint:new da({})};const Yb={circle:class extends _a{constructor(e,t){super(e,Pp,t);}createBucket(e){return new dp(e)}queryRadius(e){const t=e;return Sp("circle-radius",this,t)+Sp("circle-stroke-width",this,t)+Ip(this.paint.get("circle-translate"))}queryIntersectsFeature(e,t,i,r,n,o,s,a){const l=zp(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),c=this.paint.get("circle-radius").evaluate(t,i)+this.paint.get("circle-stroke-width").evaluate(t,i);return Op(e,r,o,s,a,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),l,c)}getProgramIds(){return ["circle"]}getDefaultProgramParams(e,t){const i=kp(this);return {config:new $l(this,t),defines:i,overrideFog:!1}}},heatmap:class extends _a{createBucket(e){return new Vp(e)}constructor(e,t){super(e,Xp,t),this._updateColorRamp();}_handleSpecialPaintPropertyUpdate(e){"heatmap-color"===e&&this._updateColorRamp();}_updateColorRamp(){this.colorRamp=Yp({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null;}resize(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null);}queryRadius(e){return Sp("heatmap-radius",this,e)}queryIntersectsFeature(e,t,i,r,n,o,s,a){const l=this.paint.get("heatmap-radius").evaluate(t,i);return Op(e,r,o,s,a,!0,!0,new y(0,0),l)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return ["heatmap","heatmapTexture"]}getDefaultProgramParams(e,t){return "heatmap"===e?{config:new $l(this,t),overrideFog:!1}:{}}},hillshade:class extends _a{constructor(e,t){super(e,Jp,t);}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return ["hillshade","hillshadePrepare"]}getDefaultProgramParams(e,t){return {overrideFog:!1}}},fill:class extends _a{constructor(e,t){super(e,Of,t);}getProgramIds(){const e=this.paint.get("fill-pattern"),t=e&&e.constantOr(1),i=[t?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&i.push(t&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),i}getDefaultProgramParams(e,t){return {config:new $l(this,t),overrideFog:!1}}recalculate(e,t){super.recalculate(e,t);const i=this.paint._values["fill-outline-color"];"constant"===i.value.kind&&void 0===i.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"]);}createBucket(e){return new Lf(e)}queryRadius(){return Ip(this.paint.get("fill-translate"))}queryIntersectsFeature(e,t,i,r,n,o){return !e.queryGeometry.isAboveHorizon&&mp(Cp(e.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),r)}isTileClipped(){return !0}},"fill-extrusion":class extends _a{constructor(e,t){super(e,Eb,t);}createBucket(e){return new db(e)}queryRadius(){return Ip(this.paint.get("fill-extrusion-translate"))}is3D(){return !0}hasShadowPass(){return !0}cutoffRange(){return this.paint.get("fill-extrusion-cutoff-fade-range")}canCastShadows(){return !0}getProgramIds(){return [this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}queryIntersectsFeature(e,t,i,r,n,o,s,a,l){const c=zp(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),h=this.paint.get("fill-extrusion-height").evaluate(t,i),u=this.paint.get("fill-extrusion-base").evaluate(t,i),d=[0,0],p=a&&o.elevation,f=o.elevation?o.elevation.exaggeration():1,m=e.tile.getBucket(this);if(p&&m instanceof db){const e=m.centroidVertexArray,t=l+1;te.polygon)).flat());const _=p?a:null,[g,x]=function(e,t,i,r,n,o,s,a,l,c,h){return "globe"===e.projection.name?function(e,t,i,r,n,o,s,a,l,c,h){const u=[],d=[],p=e.projection.upVectorScale(h,e.center.lat,e.worldSize).metersToTile,f=[0,0,0,1],m=[0,0,0,1],_=(e,t,i,r)=>{e[0]=t,e[1]=i,e[2]=r,e[3]=1;},g=vb();i>0&&(i+=g),r+=g;for(const g of t){const t=[],y=[];for(const u of g){const d=u.x+n.x,g=u.y+n.y,x=e.projection.projectTilePoint(d,g,h),v=e.projection.upVector(h,u.x,u.y);let b=i,w=r;if(s){const e=Ib(d,g,i,r,s,a,l,c);b+=e.base,w+=e.top;}0!==i?_(f,x.x+v[0]*p*b,x.y+v[1]*p*b,x.z+v[2]*p*b):_(f,x.x,x.y,x.z),_(m,x.x+v[0]*p*w,x.y+v[1]*p*w,x.z+v[2]*p*w),Mu.transformMat4(f,f,o),Mu.transformMat4(m,m,o),t.push(new Mb(f[0],f[1],f[2])),y.push(new Mb(m[0],m[1],m[2]));}u.push(t),d.push(y);}return [u,d]}(e,t,i,r,n,o,s,a,l,c,h):s?function(e,t,i,r,n,o,s,a,l){const c=[],h=[],u=[0,0,0,1];for(const d of e){const e=[],p=[];for(const c of d){const h=c.x+r.x,d=c.y+r.y,f=Ib(h,d,t,i,o,s,a,l);u[0]=h,u[1]=d,u[2]=f.base,u[3]=1,uu.transformMat4(u,u,n),u[3]=Math.max(u[3],1e-5);const m=new Mb(u[0]/u[3],u[1]/u[3],u[2]/u[3]);u[0]=h,u[1]=d,u[2]=f.top,u[3]=1,uu.transformMat4(u,u,n),u[3]=Math.max(u[3],1e-5);const _=new Mb(u[0]/u[3],u[1]/u[3],u[2]/u[3]);e.push(m),p.push(_);}c.push(e),h.push(p);}return [c,h]}(t,i,r,n,o,s,a,l,c):function(e,t,i,r,n){const o=[],s=[],a=n[8]*t,l=n[9]*t,c=n[10]*t,h=n[11]*t,u=n[8]*i,d=n[9]*i,p=n[10]*i,f=n[11]*i;for(const t of e){const e=[],i=[];for(const o of t){const t=o.x+r.x,s=o.y+r.y,m=n[0]*t+n[4]*s+n[12],_=n[1]*t+n[5]*s+n[13],g=n[2]*t+n[6]*s+n[14],y=n[3]*t+n[7]*s+n[15],x=m+a,v=_+l,b=g+c,w=Math.max(y+h,1e-5),T=m+u,E=_+d,M=g+p,A=Math.max(y+f,1e-5);e.push(new Mb(x/w,v/w,b/w)),i.push(new Mb(T/A,E/A,M/A));}o.push(e),s.push(i);}return [o,s]}(t,i,r,n,o)}(o,r,u,h,c,s,_,d,f,o.center.lat,e.tileID.canonical),v=e.queryGeometry;return function(e,t,i){let r=1/0;mp(i,t)&&(r=Sb(i,t[0]));for(let n=0;n=3)for(let t=0;t=0)r=t;else {const n=e.points[i-4];r=Xr(n,t,n[2]/(n[2]-t[2]));}if(cw(this.state,r[0],r[1],0,this._transform)>=sw)return !0}return !1}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}_validate(e,t,i){return (!i||!1!==i.validate)&&ws(this,e.call(hs,k({value:t,style:{glyphs:!0,sprite:!0},styleSpec:Ct})))}}class pw{constructor(e){this._callback=e,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback();});}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._callback();}),0));}remove(){this._channel=void 0,this._callback=()=>{};}}class fw{constructor(){this.tasks={},this.taskQueue=[],j(["process"],this),this.invoker=new pw(this.process),this.nextId=0;}add(e,t){const i=this.nextId++,r=function({type:e,isSymbolTile:t,zoom:i}){return i=i||0,"message"===e?0:"maybePrepare"!==e||t?"parseTile"!==e||t?"parseTile"===e&&t?300-i:"maybePrepare"===e&&t?400-i:500:200-i:100-i}(t);if(0===r){Q();try{e();}finally{}return {cancel:()=>{}}}return this.tasks[i]={fn:e,metadata:t,priority:r,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i];}}}process(){Q();try{if(this.taskQueue=this.taskQueue.filter((e=>!!this.tasks[e])),!this.taskQueue.length)return;const e=this.pick();if(null===e)return;const t=this.tasks[e];if(delete this.tasks[e],this.taskQueue.length&&this.invoker.trigger(),!t)return;t.fn();}finally{}}pick(){let e=null,t=1/0;for(let i=0;i{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:r,sourceMapId:this.mapId});}}}receive(e){const t=e.data,i=t.id;if(i&&(!t.targetMapId||this.mapId===t.targetMapId))if(""===t.type){const e=this.cancelCallbacks[i];delete this.cancelCallbacks[i],e&&e.cancel();}else if(t.mustQueue||Q()){const e=this.callbacks[i];this.cancelCallbacks[i]=this.scheduler.add((()=>this.processTask(i,t)),e&&e.metadata||{type:"message"});}else this.processTask(i,t);}processTask(e,t){if(""===t.type){const i=this.callbacks[e];delete this.callbacks[e],i&&(t.error?i(Ps(t.error)):i(null,Ps(t.data)));}else {const i=new Set,r=t.hasCallback?(t,r)=>{delete this.cancelCallbacks[e],this.target.postMessage({id:e,type:"",sourceMapId:this.mapId,error:t?Ds(t):null,data:Ds(r,i)},i);}:e=>{},n=Ps(t.data);if(this.parent[t.type])this.parent[t.type](t.sourceMapId,n,r);else if(this.parent.getWorkerSource){const e=t.type.split(".");this.parent.getWorkerSource(t.sourceMapId,e[0],n.source,n.scope)[e[1]](n,r);}else r(new Error(`Could not find function ${t.type}`));}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1);}}class _w{constructor(e,t){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=F();const i=this.workerPool.acquire(this.id);for(let e=0;e{this.ready=!0;}));}broadcast(e,t,i){R(this.actors,((i,r)=>{i.send(e,t,r);}),i=i||function(){});}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((e=>{e.remove();})),this.actors=[],this.workerPool.release(this.id);}}_w.Actor=mw;class gw extends It{constructor(e,t,i,r){super(),this.scope=i,this._options=e,this.properties=new la(t),this._transitionable=new ra(t,new Map(r)),this._transitionable.setTransitionOrValue(e.properties),this._transitioning=this._transitionable.untransitioned();}updateConfig(e){this._transitionable.setTransitionOrValue(this._options.properties,new Map(e));}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}get(){return this._options.properties=this._transitionable.serialize(),this._options}set(e,t){this._options=e,this._transitionable.setTransitionOrValue(e.properties,t);}shadowsEnabled(){return !!this.properties&&!0===this.properties.get("cast-shadows")}}const yw=new da({color:new ca(Ct.properties_light_ambient.color),intensity:new ca(Ct.properties_light_ambient.intensity)}),xw=new da({direction:new class{constructor(e){this.specification=e;}possiblyEvaluate(e,t){return function([e,t]){const i=K([1,e,t]);return {x:i.x,y:i.y,z:i.z}}(e.expression.evaluate(t))}interpolate(e,t,i){return {x:Wr(e.x,t.x,i),y:Wr(e.y,t.y,i),z:Wr(e.z,t.z,i)}}}(Ct.properties_light_directional.direction),color:new ca(Ct.properties_light_directional.color),intensity:new ca(Ct.properties_light_directional.intensity),"cast-shadows":new ca(Ct.properties_light_directional["cast-shadows"]),"shadow-intensity":new ca(Ct.properties_light_directional["shadow-intensity"])});class vw{constructor(e,t,i,r){this.screenBounds=e,this.cameraPoint=t,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=i,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,r);}static createFromScreenPoints(e,t){let i,r;if(e instanceof y||"number"==typeof e[0]){const n=y.convert(e);i=[n],r=t.isPointAboveHorizon(n);}else {const n=y.convert(e[0]),o=y.convert(e[1]);i=[n,o],r=S(n,o).every((e=>t.isPointAboveHorizon(e)));}return new vw(i,t.getCameraPoint(),r,t)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(e){return S(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],e)}bufferedCameraGeometry(e){const t=this.screenBounds[0],i=1===this.screenBounds.length?this.screenBounds[0].add(new y(1,1)):this.screenBounds[1],r=S(t,i,0,!1);return this.cameraPoint.y>i.y&&(this.cameraPoint.x>t.x&&this.cameraPoint.x=i.x?r[2]=this.cameraPoint:this.cameraPoint.x<=t.x&&(r[3]=this.cameraPoint)),function(e,t){const i=[];for(let r=0;rt.y)+(n.y>i.y))+((n.x>t.x)+(n.x>i.x))){case 0:r[0]=n,r[4]=n.clone();break;case 1:r.splice(1,0,n);break;case 2:r[1]=n;break;case 3:r.splice(4,0,n);break;case 5:r.splice(2,0,n);break;case 6:r[3]=n;break;case 7:r.splice(3,0,n);break;case 8:r[2]=n;}return r}containsTile(e,t,i,r=0){const n=e.queryPadding/t._pixelsPerMercatorPixel+1,o=i?this._bufferedCameraMercator(n,t):this._bufferedScreenMercator(n,t);let s=e.tileID.wrap+(o.unwrapped?r:0);const a=o.polygon.map((t=>Mg(e.tileTransform,t,s)));if(!Tp(a,0,0,sr,sr))return;s=e.tileID.wrap+(this.screenGeometryMercator.unwrapped?r:0);const l=this.screenGeometryMercator.polygon.map((t=>Ag(e.tileTransform,t,s))),c=l.map((e=>new y(e[0],e[1]))),h=t.getFreeCameraOptions().position||new ep(0,0,0),u=Ag(e.tileTransform,h,s),d=l.map((e=>{const t=Mu.sub(e,e,u);return Mu.normalize(t,t),new Uu(u,t)})),p=Xx(e,1,t.zoom)*t._pixelsPerMercatorPixel;return {queryGeometry:this,tilespaceGeometry:c,tilespaceRays:d,bufferedTilespaceGeometry:a,bufferedTilespaceBounds:(f=A(a),f.min.x=z(f.min.x,0,sr),f.min.y=z(f.min.y,0,sr),f.max.x=z(f.max.x,0,sr),f.max.y=z(f.max.y,0,sr),f),tile:e,tileID:e.tileID,pixelToTileUnitsFactor:p};var f;}_bufferedScreenMercator(e,t){const i=Tw(e);if(this._screenRaycastCache[i])return this._screenRaycastCache[i];{let r;return r="globe"===t.projection.name?this._projectAndResample(this.bufferedScreenGeometry(e),t):{polygon:this.bufferedScreenGeometry(e).map((e=>t.pointCoordinate3D(e))),unwrapped:!0},this._screenRaycastCache[i]=r,r}}_bufferedCameraMercator(e,t){const i=Tw(e);if(this._cameraRaycastCache[i])return this._cameraRaycastCache[i];{let r;return r="globe"===t.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(e),t):{polygon:this.bufferedCameraGeometry(e).map((e=>t.pointCoordinate3D(e))),unwrapped:!0},this._cameraRaycastCache[i]=r,r}}_projectAndResample(e,t){const i=function(e,t){const i=xu.multiply([],t.pixelMatrix,t.globeMatrix),r=[0,-Yu,0,1],n=[0,Yu,0,1],o=[0,0,0,1];uu.transformMat4(r,r,i),uu.transformMat4(n,n,i),uu.transformMat4(o,o,i);const s=new y(r[0]/r[3],r[1]/r[3]),a=new y(n[0]/n[3],n[1]/n[3]),l=wp(e,s)&&r[3]1?bw(e.slice(0,u),t):[],f=unew y(ww(e.x),e.y))),f=f.map((e=>new y(ww(e.x),e.y)));const m=[...p];0===m.length&&m.push(f[f.length-1]);const _=Wr(m[m.length-1].y,(0===f.length?p[0]:f[0]).y,d);let g;return g=l?[new y(0,_),new y(0,0),new y(1,0),new y(1,_)]:[new y(1,_),new y(1,1),new y(0,1),new y(0,_)],m.push(...g),0===f.length?m.push(p[0]):m.push(...f),{polygon:m.map((e=>new ep(e.x,e.y))),unwrapped:!1}}(e,t);if(i)return i;const r=function(e,t){let i=!1,r=-1/0,n=0;for(let t=0;tr&&(r=e[t].x,n=t);for(let t=0;t.5&&(o.x{e.x-=1;})),{polygon:e,unwrapped:i}}(bw(e,t).map((e=>new y(ww(e.x),e.y))),t);return {polygon:r.polygon.map((e=>new ep(e.x,e.y))),unwrapped:r.unwrapped}}}function bw(e,t){return ip(e,(e=>{const i=t.pointCoordinate3D(e);e.x=i.x,e.y=i.y;}),1/256)}function ww(e){return e<0?1+e%1:e%1}function Tw(e){return 100*e|0}function Ew(e,t,i,r,n){const o=function(i,r){if(i)return n(i);if(r){e.url&&r.tiles&&e.tiles&&delete e.tiles;const i=O(k(r,e),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);r.vector_layers&&(i.vectorLayers=r.vector_layers,i.vectorLayerIds=i.vectorLayers.map((e=>e.id))),i.tiles=t.canonicalizeTileset(i,e.url),n(null,i);}};return e.url?we(t.transformRequest(t.normalizeSourceURL(e.url,null,i,r),ye.Source),o):ht.frame((()=>o(null,e)))}class Mw{constructor(e,t,i){this.bounds=Ql.convert(this.validateBounds(e)),this.minzoom=t||0,this.maxzoom=i||24;}validateBounds(e){return Array.isArray(e)&&4===e.length?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(e){const t=Math.pow(2,e.z),i=Math.floor(Gd(this.bounds.getWest())*t),r=Math.floor(qd(this.bounds.getNorth())*t),n=Math.ceil(Gd(this.bounds.getEast())*t),o=Math.ceil(qd(this.bounds.getSouth())*t);return e.x>=i&&e.x=r&&e.y1&&(s=e[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),h=Math.min(l,c);let u;const d=t/i*(r+1);if(s.isDash){const e=r-Math.abs(d);u=Math.sqrt(h*h+e*e);}else u=r-Math.sqrt(h*h+d*d);this.image.data[n+a]=Math.max(0,Math.min(255,u+128));}}}addRegularDash(e,t){for(let t=e.length-1;t>=0;--t){const i=e[t],r=e[t+1];i.zeroLength?e.splice(t,1):r&&r.isDash===i.isDash&&(r.left=i.left,e.splice(t,1));}const i=e[0],r=e[e.length-1];i.isDash===r.isDash&&(i.left=r.left-this.width,r.right=i.right+this.width);const n=this.width*this.nextRow;let o=0,s=e[o];for(let i=0;i1&&(s=e[++o]);const r=Math.abs(i-s.left),a=Math.abs(i-s.right),l=Math.min(r,a);this.image.data[n+i]=Math.max(0,Math.min(255,(s.isDash?l:-l)+t+128));}}addDash(e,t){const i=this.getKey(e,t);if(this.positions[i])return this.positions[i];const r="round"===t,n=r?7:0,o=2*n+1;if(this.nextRow+o>this.height)return W("LineAtlas out of space"),null;0===e.length&&e.push(1);let s=0;for(let t=0;t=t.maxzoom||"none"!==t.visibility&&(zw(e,this.zoom,c.brightness,i),(a[t.id]=t.createBucket({index:s.bucketLayerIDs.length,layers:e,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:d,sourceID:this.source,projection:this.projection.spec})).populate(p,c,this.tileID.canonical,this.tileTransform),s.bucketLayerIDs.push(e.map((e=>e.id)))));}}let u,d,p,f;l.trim();const m={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},_=()=>{if(u)return n(u);if(this.extraShadowCaster)this.status="done",n(null,{buckets:L(a).filter((e=>!e.isEmpty())),featureIndex:s,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:c.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(d&&p&&f){const e=new Iw(d),t=new b_(p,f);for(const r in a){const n=a[r];n instanceof cy?(zw(n.layers,this.zoom,c.brightness,i),dg(n,d,e.positions,p,t.iconPositions,this.showCollisionBoxes,i,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):n.hasPattern&&(n instanceof _y||n instanceof Lf||n instanceof db)&&(zw(n.layers,this.zoom,c.brightness,i),n.addFeatures(c,this.tileID.canonical,t.patternPositions,i,this.tileTransform,this.brightness));}this.status="done",n(null,{buckets:L(a).filter((e=>!e.isEmpty())),featureIndex:s,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:l,imageAtlas:t,brightness:c.brightness});}};if(!this.extraShadowCaster){const e=q(c.glyphDependencies,(e=>Object.keys(e).map(Number)));Object.keys(e).length?r.send("getGlyphs",{uid:this.uid,stacks:e,scope:this.scope},((e,t)=>{u||(u=e,d=t,_());}),void 0,!1,m):d={};const t=Object.keys(c.iconDependencies);t.length?r.send("getImages",{icons:t,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((e,t)=>{u||(u=e,p=t,_());}),void 0,!1,m):p={};const i=Object.keys(c.patternDependencies);i.length?r.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((e,t)=>{u||(u=e,f=t,_());}),void 0,!1,m):f={};}_();}}function zw(e,t,i,r){const n=new ea(t,{brightness:i});for(const t of e)t.recalculate(n,r);}class Dw{constructor(e){this.entries={},this.scheduler=e;}request(e,t,i,r){const n=this.entries[e]=this.entries[e]||{callbacks:[]};if(n.result){const[e,i]=n.result;return this.scheduler?this.scheduler.add((()=>{r(e,i);}),t):r(e,i),()=>{}}return n.callbacks.push(r),n.cancel||(n.cancel=i(((i,r)=>{n.result=[i,r];for(const e of n.callbacks)this.scheduler?this.scheduler.add((()=>{e(i,r);}),t):e(i,r);setTimeout((()=>delete this.entries[e]),3e3);}))),()=>{n.result||(n.callbacks=n.callbacks.filter((e=>e!==r)),n.callbacks.length||(n.cancel(),delete this.entries[e]));}}}function Pw(e,t,i){const r=JSON.stringify(e.request);return e.data&&(this.deduped.entries[r]={result:[null,e.data]}),this.deduped.request(r,{type:"parseTile",isSymbolTile:e.isSymbolTile,zoom:e.tileZoom},(t=>{const r=Te(e.request,((e,r,n,o)=>{e?t(e):r&&t(null,{vectorTile:i?void 0:new tm(new Sm(r)),rawData:r,cacheControl:n,expires:o});}));return ()=>{r.cancel(),t();}}),t)}class Rw extends It{constructor(e,t,i,r){if(super(),this.id=e,this.dispatcher=i,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,k(this,O(t,["url","scheme","tileSize","promoteId"])),this._options=k({type:"vector"},t),this._collectResourceTiming=!!t.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(r),this._tileWorkers={},this._deduped=new Dw;}load(e){this._loaded=!1,this.fire(new At("dataloading",{dataType:"source"}));const t=Array.isArray(this.map._language)?this.map._language.join():this.map._language,i=this.map._worldview;this._tileJSONRequest=Ew(this._options,this.map._requestManager,t,i,((r,n)=>{this._tileJSONRequest=null,this._loaded=!0,r?(t&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${t}`),i&&2!==i.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${i}`),this.fire(new St(r))):n&&(k(this,n),n.bounds&&(this.tileBounds=new Mw(n.bounds,this.minzoom,this.maxzoom)),Ge(n.tiles,this.map._requestManager._customAccessToken),this.fire(new At("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new At("data",{dataType:"source",sourceDataType:"content"}))),e&&e(r);}));}loaded(){return this._loaded}hasTile(e){return !this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load();}reload(){this.cancelTileJSONRequest();const e=pa(this.id,this.scope);this.load((()=>this.map.style.clearSource(e)));}setTiles(e){return this._options.tiles=e,this.reload(),this}setUrl(e){return this.url=e,this._options.url=e,this.reload(),this}onRemove(){this.cancelTileJSONRequest();}serialize(){return k({},this._options)}loadTile(e,t){const i=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme)),r={request:this.map._requestManager.transformRequest(i,ye.Tile),data:void 0,uid:e.uid,tileID:e.tileID,tileZoom:e.tileZoom,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,pixelRatio:ht.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:e.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:e.isExtraShadowCaster};if(r.request.collectResourceTiming=this._collectResourceTiming,e.actor&&"expired"!==e.state)"loading"===e.state?e.reloadCallback=t:e.request=e.actor.send("reloadTile",r,n.bind(this));else if(e.actor=this._tileWorkers[i]=this._tileWorkers[i]||this.dispatcher.getActor(),this.dispatcher.ready)e.request=e.actor.send("loadTile",r,n.bind(this),void 0,!0);else {const t=Pw.call({deduped:this._deduped},r,((t,i)=>{t||!i?n.call(this,t):(r.data={cacheControl:i.cacheControl,expires:i.expires,rawData:i.rawData.slice(0)},e.actor&&e.actor.send("loadTile",r,n.bind(this),void 0,!0));}),!0);e.request={cancel:t};}function n(i,r){return delete e.request,e.aborted?t(null):i&&404!==i.status?t(i):(r&&r.resourceTiming&&(e.resourceTiming=r.resourceTiming),this.map._refreshExpiredTiles&&r&&e.setExpiryData(r),e.loadVectorData(r,this.map.painter),ge(this.dispatcher),t(null),void(e.reloadCallback&&(this.loadTile(e,e.reloadCallback),e.reloadCallback=null)))}}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.actor&&e.actor.send("abortTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope});}unloadTile(e){e.unloadVectorData(),e.actor&&e.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope});}hasTransition(){return !1}afterUpdate(){this._tileWorkers={};}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null);}}class Lw extends It{constructor(e,t,i,r){super(),this.id=e,this.dispatcher=i,this.setEventedParent(r),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=k({type:"raster"},t),k(this,O(t,["url","scheme","tileSize"]));}load(e){this._loaded=!1,this.fire(new At("dataloading",{dataType:"source"})),this._tileJSONRequest=Ew(this._options,this.map._requestManager,null,null,((t,i)=>{this._tileJSONRequest=null,this._loaded=!0,t?this.fire(new St(t)):i&&(k(this,i),i.bounds&&(this.tileBounds=new Mw(i.bounds,this.minzoom,this.maxzoom)),Ge(i.tiles),this.fire(new At("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new At("data",{dataType:"source",sourceDataType:"content"}))),e&&e(t);}));}loaded(){return this._loaded}onAdd(e){this.map=e,this.load();}reload(){this.cancelTileJSONRequest();const e=pa(this.id,this.scope);this.load((()=>this.map.style.clearSource(e)));}setTiles(e){return this._options.tiles=e,this.reload(),this}setUrl(e){return this.url=e,this._options.url=e,this.reload(),this}onRemove(){this.cancelTileJSONRequest();}serialize(){return k({},this._options)}hasTile(e){return !this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e,t){const i=ht.devicePixelRatio>=2,r=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme),i,this.tileSize);e.request=Ie(this.map._requestManager.transformRequest(r,ye.Tile),((i,r,n,o)=>(delete e.request,e.aborted?(e.state="unloaded",t(null)):i?(e.state="errored",t(i)):r?(this.map._refreshExpiredTiles&&e.setExpiryData({cacheControl:n,expires:o}),e.setTexture(r,this.map.painter),e.state="loaded",ge(this.dispatcher),void t(null)):t(null))));}static loadTileData(e,t,i){e.setTexture(t,i);}static unloadTileData(e,t){e.texture&&t.saveTileTexture(e.texture);}abortTile(e,t){e.request&&(e.request.cancel(),delete e.request),t();}unloadTile(e,t){e.texture&&this.map.painter.saveTileTexture(e.texture),t();}hasTransition(){return !1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null);}}let kw;function Ow(){return null!=cI.workerClass?new cI.workerClass:new t.Worker(cI.workerUrl)}const Bw="mapboxgl_preloaded_worker_pool";class Fw{constructor(){this.active={};}acquire(e){if(!this.workers)for(this.workers=[];this.workers.length{e.terminate();})),this.workers=null);}isPreloaded(){return !!this.active[Bw]}numActive(){return Object.keys(this.active).length}}let Nw;function Uw(){return Nw||(Nw=new Fw),Nw}Fw.workerCount=2;let Vw,jw,Gw,qw=null;function Zw(){return Q()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:jw||n.DRACO_URL}const $w=5123,Hw=5126,Ww={5120:Int8Array,5121:Uint8Array,5122:Int16Array,[$w]:Uint16Array,5125:Uint32Array,[Hw]:Float32Array},Xw={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",[$w]:"DT_UINT16",5125:"DT_UINT32",[Hw]:"DT_FLOAT32"},Yw={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function Kw(e,t,i){const r=i.json.bufferViews.length,n=i.buffers.length;t.bufferView=r,i.json.bufferViews[r]={buffer:n,byteLength:e.byteLength},i.buffers[n]=e;}const Jw="KHR_draco_mesh_compression";function Qw(e,t){const i=e.extensions&&e.extensions[Jw];if(!i)return;const r=new Gw.Decoder,n=nT(t,i.bufferView),o=new Gw.Mesh;if(!r.DecodeArrayToMesh(n,n.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=t.json.accessors[e.indices],a=Ww[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,c=Gw._malloc(l);a===Uint16Array?r.GetTrianglesUInt16Array(o,l,c):r.GetTrianglesUInt32Array(o,l,c),Kw(Gw.memory.buffer.slice(c,c+l),s,t),Gw._free(c);for(const n of Object.keys(i.attributes)){const s=r.GetAttributeByUniqueId(o,i.attributes[n]),a=t.json.accessors[e.attributes[n]],l=Xw[a.componentType],c=a.count*Yw[a.type]*Ww[a.componentType].BYTES_PER_ELEMENT,h=Gw._malloc(c);r.GetAttributeDataArrayForAllPoints(o,s,Gw[l],c,h),Kw(Gw.memory.buffer.slice(h,h+c),a,t),Gw._free(h);}r.destroy(),o.destroy(),delete e.extensions[Jw];}const eT=1179937895,tT=new TextDecoder("utf8");function iT(e,t){return new URL(e,t).href}function rT(e,t,i,r){return fetch(iT(e.uri,r)).then((e=>e.arrayBuffer())).then((e=>{t.buffers[i]=e;}))}function nT(e,t){const i=e.json.bufferViews[t];return new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function oT(e,i,r,n){if(e.uri){const o=iT(e.uri,n);return fetch(o).then((e=>e.blob())).then((e=>t.createImageBitmap(e))).then((e=>{i.images[r]=e;}))}if(void 0!==e.bufferView){const n=nT(i,e.bufferView),o=new t.Blob([n],{type:e.mimeType});return t.createImageBitmap(o).then((e=>{i.images[r]=e;}))}}function sT(e,t=0,i){const r={json:null,images:[],buffers:[]};if(new Uint32Array(e,t,1)[0]===eT){const i=new Uint32Array(e,t);let n=2;const o=(i[n++]>>2)-3,s=i[n++]>>2;if(n++,r.json=JSON.parse(tT.decode(i.subarray(n,n+s))),n+=s,n{const e=[],t=a&&a.includes(Jw);if(t&&e.push(function(){if(!Gw)return Vw||(Vw=function(e){let t,i=null;function r(){t=new Uint8Array(i.buffer);}function n(){throw new Error("Unexpected Draco error.")}const o={a:{a:n,d:function(e,i,r){return t.copyWithin(e,i,i+r)},c:function(e){const n=t.length,o=Math.max(e>>>0,Math.ceil(1.2*n)),s=Math.ceil((o-n)/65536);try{return i.grow(s),r(),!0}catch(e){return !1}},b:n}};return (WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(e,o):e.then((e=>e.arrayBuffer())).then((e=>WebAssembly.instantiate(e,o)))).then((e=>{const{Rb:n,Qb:o,P:s,T:a,X:l,Ja:c,La:h,Qa:u,Va:d,Wa:p,eb:f,jb:m,f:_,e:g,yb:y,zb:x,Ab:v,Bb:b,Db:w,Gb:T}=e.instance.exports;i=g;const E=(()=>{let e=0,i=0,r=0,s=0;return a=>{r&&(n(s),n(e),i+=r,r=e=0),e||(i+=128,e=o(i));const l=a.length+7&-8;let c=e;l>=i&&(r=l,c=s=o(l));for(let e=0;e{Gw=e,Vw=void 0;})))}()),o)for(let t=0;t{if(t&&s)for(const{primitives:e}of s)for(const t of e)Qw(t,r);return r}))}))}function aT(e){return fetch(e).then((e=>e.arrayBuffer())).then((t=>sT(t,0,e)))}class lT{constructor(e,t,i){if(this.triangleCount=t.length/3,this.min=new y(0,0),this.max=new y(0,0),this.xScale=0,this.yScale=0,this.cellsX=0,this.cellsY=0,this.cells=[],this.payload=[],0===this.triangleCount||0===e.length||0===i)return;const r=e.map((e=>e.x)),n=e.map((e=>e.y));this.min=new y(Math.min(...r),Math.min(...n)),this.max=new y(Math.max(...r),Math.max(...n));const o=this.max.sub(this.min);o.x=Math.max(o.x,1),o.y=Math.max(o.y,1);const s=Math.max(o.x,o.y)/i;this.cellsX=Math.max(1,Math.ceil(o.x/s)),this.cellsY=Math.max(1,Math.ceil(o.y/s)),this.xScale=1/s,this.yScale=1/s;const a=[];for(let i=0;ie.cellIdx-t.cellIdx||e.triIdx-t.triIdx));let l=0;for(;lthis.max.x||this.min.x>t.x)return;if(e.y>this.max.y||this.min.y>t.y)return;this.lookup||(this.lookup=new Uint8Array(Math.ceil(this.triangleCount/8)));for(let e=0;e0){for(let n=0;n0){o.texcoordArray=new Xa;const e=t.json.accessors[n.TEXCOORD_0];o.texcoordArray.reserve(e.count);const i=hT(t,e);for(let t=0;t1&&r[r.length-1].equals(r[0])&&r.pop();let n=0;for(let e=0;e0&&r.reverse();const o=Cf(r.flatMap((e=>[e.x,e.y])),[]);return 0===o.length?null:{vertices:r,indices:o}}function mT(e){const t=[],i=[];let r=0;for(const n of e){r=t.length;const e=n.vertexArray.float32,o=n.indexArray.uint16;for(let i=0;i0&&([i[e+1],i[e+2]]=[i[e+2],i[e+1]]);}return {vertices:t,indices:i}}function _T(e){const i=function(e,i){const r=[],n=t.WebGL2RenderingContext;if(e.json.textures)for(const t of e.json.textures){const o={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==t.sampler&&Object.assign(o,e.json.samplers[t.sampler]),r.push({image:i[t.source],sampler:o,uploaded:!1});}return r}(e,e.images),r=function(e,t){const i=[];for(const r of e.json.meshes){const n=[];for(const i of r.primitives)n.push(uT(i,e,t));i.push(n);}return i}(e,i),{scenes:n,scene:o,nodes:s}=e.json,a=n?n[o||0].nodes:s,l=[];for(const t of a)l.push(dT(s[t],e,r));return function(e,t,i){const r={},n=new Set;for(let o=0;o0){const t=Array.from(n.values()).sort(((e,t)=>e-t));for(let i=t.length-1;i>=0;i--)e.splice(t[i],1);}}(l,a,e.json.nodes),l}function gT(e){e.heightmap=new Float32Array(4096),e.heightmap.fill(-1);const t=e.vertexArray.float32,i=e.aabb.min[0]-1,r=e.aabb.min[1]-1,n=xv/(e.aabb.max[0]-i+2),o=xv/(e.aabb.max[1]-r+2);for(let s=0;se.heightmap[c*xv+l]&&(e.heightmap[c*xv+l]=a);}}function yT(e,t){const i={};i.indexArray=new Va,i.indexArray.reserve(4*e.length),i.vertexArray=new Ua,i.vertexArray.reserve(10*e.length),i.colorArray=new Ia,i.vertexArray.reserve(10*e.length);let r=0;for(const n of e){const e=Math.min(10,Math.max(4,1.3*n.height))*t,o=[-n.normal[1],n.normal[0],0],s=Math.min(.29,.1*n.width/n.depth),a=n.width-2*n.depth*t*(s+.01),l=Mu.scaleAndAdd([],n.pos,o,a/2),c=Mu.scaleAndAdd([],n.pos,o,-a/2),h=[l[0],l[1],l[2]+n.height],u=[c[0],c[1],c[2]+n.height],d=Mu.scaleAndAdd([],n.normal,o,s);Mu.scale(d,d,e);const p=Mu.scaleAndAdd([],n.normal,o,-s);Mu.scale(p,p,e),Mu.add(d,l,d),Mu.add(p,c,p),l[2]+=.1,c[2]+=.1,i.vertexArray.emplaceBack(d[0],d[1],d[2]),i.vertexArray.emplaceBack(p[0],p[1],p[2]),i.vertexArray.emplaceBack(l[0],l[1],l[2]),i.vertexArray.emplaceBack(c[0],c[1],c[2]),i.vertexArray.emplaceBack(h[0],h[1],h[2]),i.vertexArray.emplaceBack(u[0],u[1],u[2]),i.vertexArray.emplaceBack(l[0],l[1],l[2]),i.vertexArray.emplaceBack(c[0],c[1],c[2]),i.vertexArray.emplaceBack(d[0],d[1],d[2]),i.vertexArray.emplaceBack(p[0],p[1],p[2]);const f=a/e/2;i.colorArray.emplaceBack(-f-s,-1,f,.8),i.colorArray.emplaceBack(f+s,-1,f,.8),i.colorArray.emplaceBack(-f,0,f,1.3),i.colorArray.emplaceBack(f,0,f,1.3),i.colorArray.emplaceBack(f+s,-.8,f,.7),i.colorArray.emplaceBack(f+s,-.8,f,.7),i.colorArray.emplaceBack(0,0,f,1.3),i.colorArray.emplaceBack(0,0,f,1.3),i.colorArray.emplaceBack(f+s,-1.2,f,.8),i.colorArray.emplaceBack(f+s,-1.2,f,.8),i.indexArray.emplaceBack(6+r,4+r,8+r),i.indexArray.emplaceBack(7+r,9+r,5+r),i.indexArray.emplaceBack(0+r,1+r,2+r),i.indexArray.emplaceBack(1+r,3+r,2+r),r+=10;}const n={defined:!0,emissiveFactor:[0,0,0]},o={};return o.baseColorFactor=li.white,n.pbrMetallicRoughness=o,i.material=n,i.aabb=new Hu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),i}Is(lT,"TriangleGridIndex");const xT={vector:Rw,raster:Lw,"raster-dem":class extends Lw{constructor(e,t,i,r){super(e,t,i,r),this.type="raster-dem",this.maxzoom=22,this._options=k({type:"raster-dem"},t),this.encoding=t.encoding||"mapbox";}loadTile(e,i){const r=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);e.request=Ie(this.map._requestManager.transformRequest(r,ye.Tile),function(r,s,a,l){if(delete e.request,e.aborted)e.state="unloaded",i(null);else if(r)e.state="errored",i(r);else if(s){this.map._refreshExpiredTiles&&e.setExpiryData({cacheControl:a,expires:l});const i=t.ImageBitmap&&s instanceof t.ImageBitmap&&(null==kw&&(kw=t.OffscreenCanvas&&new t.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof t.createImageBitmap),kw),r=1-(s.width-((c=s.width)<=1?1:Math.pow(2,Math.floor(Math.log(c)/Math.LN2))))/2;r<1||e.neighboringTiles||(e.neighboringTiles=this._getNeighboringTiles(e.tileID));const h=i?s:ht.getImageData(s,r),u={uid:e.uid,coord:e.tileID,source:this.id,scope:this.scope,rawImageData:h,encoding:this.encoding,padding:r,convertToFloat:n};e.actor&&"expired"!==e.state||(e.actor=this.dispatcher.getActor(),e.actor.send("loadDEMTile",u,o.bind(this),void 0,!0));}var c;}.bind(this));const n=this.map?.painter?.terrainUseFloatDEM();function o(t,r){t&&(e.state="errored",i(t)),r&&(e.dem=r,e.dem.onDeserialize(),e.needsHillshadePrepare=!0,e.needsDEMTextureUpload=!0,e.state="loaded",i(null));}}_getNeighboringTiles(e){const t=e.canonical,i=Math.pow(2,t.z),r=(t.x-1+i)%i,n=0===t.x?e.wrap-1:e.wrap,o=(t.x+1+i)%i,s=t.x+1===i?e.wrap+1:e.wrap,a={};return a[new Bu(e.overscaledZ,n,t.z,r,t.y).key]={backfilled:!1},a[new Bu(e.overscaledZ,s,t.z,o,t.y).key]={backfilled:!1},t.y>0&&(a[new Bu(e.overscaledZ,n,t.z,r,t.y-1).key]={backfilled:!1},a[new Bu(e.overscaledZ,e.wrap,t.z,t.x,t.y-1).key]={backfilled:!1},a[new Bu(e.overscaledZ,s,t.z,o,t.y-1).key]={backfilled:!1}),t.y+1{if(this._loaded=!0,this._pendingLoad=null,e)this.fire(new St(e));else {const e={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&t&&t.resourceTiming&&t.resourceTiming[this.id]&&(e.resourceTiming=t.resourceTiming[this.id]),this.fire(new At("data",e)),this._metadataFired=!0;}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1);}));}loaded(){return this._loaded}loadTile(e,t){const i=e.actor?"reloadTile":"loadTile";e.actor=this.actor;const r={type:this.type,uid:e.uid,tileID:e.tileID,tileZoom:e.tileZoom,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,scope:this.scope,pixelRatio:ht.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,brightness:this.map.style&&this.map.style.getBrightness()||0};e.request=this.actor.send(i,r,((r,n)=>(delete e.request,e.unloadVectorData(),e.aborted?t(null):r?t(r):(e.loadVectorData(n,this.map.painter,"reloadTile"===i),t(null)))),void 0,"loadTile"===i);}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.aborted=!0;}unloadTile(e){e.unloadVectorData(),this.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope});}onRemove(){this._pendingLoad&&this._pendingLoad.cancel();}serialize(){return k({},this._options,{type:this.type,data:this._data})}hasTransition(){return !1}},video:class extends qb{constructor(e,t,i,r){super(e,t,i,r),this.roundZoom=!0,this.type="video",this.options=t;}load(){this._loaded=!1;const e=this.options;this.urls=[];for(const t of e.urls)this.urls.push(this.map._requestManager.transformRequest(t,ye.Source).url);!function(e,i){const r=t.document.createElement("video");r.muted=!0,r.onloadstart=function(){i(null,r);};for(let i=0;i{this._loaded=!0,e?this.fire(new St(e)):t&&(this.video=t,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",(()=>{this.map.triggerRepaint();})),this.map&&this.video.play(),this._finishLoading());}));}pause(){this.video&&this.video.pause();}play(){this.video&&this.video.play();}seek(e){if(this.video){const t=this.video.seekable;et.end(0)?this.fire(new St(new zt(`sources.${this.id}`,null,`Playback for this video can be set only between the ${t.start(0)} and ${t.end(0)}-second mark.`))):this.video.currentTime=e;}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)));}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const e=this.map.painter.context,t=e.gl;this.texture?this.video.paused||(this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE),t.texSubImage2D(t.TEXTURE_2D,0,0,0,t.RGBA,t.UNSIGNED_BYTE,this.video)):(this.texture=new gy(e,this.video,t.RGBA),this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(e);}serialize(){return {type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:qb,model:class extends It{constructor(e,t,i,r){super(),this.id=e,this.type="model",this.models=[],this._loaded=!1,this._options=t;}load(){const e=[];for(const t in this._options.models){const i=this._options.models[t],r=aT(this.map._requestManager.transformRequest(i.uri,ye.Model).url).then((e=>{if(!e)return;const r=_T(e),n=new bv(t,i.position,i.orientation,r);n.computeBoundsAndApplyParent(),this.models.push(n);})).catch((e=>{this.fire(new St(new Error(`Could not load model ${t} from ${i.uri}: ${e.message}`)));}));e.push(r);}return Promise.allSettled(e).then((()=>{this._loaded=!0,this.fire(new At("data",{dataType:"source",sourceDataType:"metadata"}));})).catch((e=>{this.fire(new St(new Error(`Could not load models: ${e.message}`)));}))}onAdd(e){this.map=e,this.load();}hasTransition(){return !1}loaded(){return this._loaded}getModels(){return this.models}loadTile(e,t){}serialize(){return {type:"model"}}},"batched-model":class extends It{constructor(e,t,i,r){super(),this.type="batched-model",this.id=e,this.tileSize=512,this._options=t,this.tiles=this._options.tiles,this.maxzoom=t.maxzoom||19,this.minzoom=t.minzoom||0,this.roundZoom=!0,this.usedInConflation=!0,this.dispatcher=i,this.reparseOverscaled=!1,this.scheme="xyz",this._loaded=!1,this.setEventedParent(r);}onAdd(e){this.map=e,this.load();}load(e){this._loaded=!1,this.fire(new At("dataloading",{dataType:"source"}));const t=Array.isArray(this.map._language)?this.map._language.join():this.map._language,i=this.map._worldview;this._tileJSONRequest=Ew(this._options,this.map._requestManager,t,i,((r,n)=>{this._tileJSONRequest=null,this._loaded=!0,r?(t&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${t}`),i&&2!==i.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${i}`),this.fire(new St(r))):n&&(k(this,n),n.bounds&&(this.tileBounds=new Mw(n.bounds,this.minzoom,this.maxzoom)),Ge(n.tiles,this.map._requestManager._customAccessToken),this.fire(new At("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new At("data",{dataType:"source",sourceDataType:"content"}))),e&&e(r);}));}hasTransition(){return !1}hasTile(e){return !this.tileBounds||this.tileBounds.contains(e.canonical)}loaded(){return this._loaded}loadTile(e,t){const i=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme)),r={request:this.map._requestManager.transformRequest(i,ye.Tile),data:void 0,uid:e.uid,tileID:e.tileID,tileZoom:e.tileZoom,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,isSymbolTile:e.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0};if(e.actor&&"expired"!==e.state)if("loading"===e.state)e.reloadCallback=t;else {if(e.buckets){const t=Object.values(e.buckets);for(const e of t)e.dirty=!0;return void(e.state="loaded")}e.request=e.actor.send("reloadTile",r,n.bind(this));}else e.actor=this.dispatcher.getActor(),e.request=e.actor.send("loadTile",r,n.bind(this),void 0,!0);function n(i,r){return e.aborted?t(null):i&&404!==i.status?t(i):(r&&(r.resourceTiming&&(e.resourceTiming=r.resourceTiming),this.map._refreshExpiredTiles&&e.setExpiryData(r),e.buckets={...e.buckets,...r.buckets}),e.state="loaded",void t(null))}}serialize(){return k({},this._options)}},canvas:class extends qb{constructor(e,i,r,n){super(e,i,r,n),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some((e=>!Array.isArray(e)||2!==e.length||e.some((e=>"number"!=typeof e))))||this.fire(new St(new zt(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new St(new zt(`sources.${e}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new St(new zt(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof t.HTMLCanvasElement||this.fire(new St(new zt(`sources.${e}`,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 St(new zt(`sources.${e}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate;}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof t.HTMLCanvasElement?this.options.canvas:t.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new St(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(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play();}onRemove(){this.pause();}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const t=this.map.painter.context;this.texture?!e&&!this._playing||this.texture instanceof yy||this.texture.update(this.canvas,{premultiply:!0}):this.texture=new gy(t,this.canvas,t.gl.RGBA,{premultiply:!0}),this._prepareData(t);}serialize(){return {type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const e of [this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return !0;return !1}},custom:class extends It{constructor(e,t,i,r){super(),this.id=e,this.type="custom",this._dataType="raster",this._dispatcher=i,this._implementation=t,this.setEventedParent(r),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new St(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new St(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new Mw(this._implementation.bounds,this.minzoom,this.maxzoom)),t.update=this._update.bind(this),t.clearTiles=this._clearTiles.bind(this),t.coveringTiles=this._coveringTiles.bind(this),k(this,O(t,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]));}serialize(){return O(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new At("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new At("data",{dataType:"source",sourceDataType:"content"}));}loaded(){return this._loaded}onAdd(e){this._map=e,this._loaded=!1,this.fire(new At("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(e),this.load();}onRemove(e){this._implementation.onRemove&&this._implementation.onRemove(e);}hasTile(e){if(this._implementation.hasTile){const{x:t,y:i,z:r}=e.canonical;return this._implementation.hasTile({x:t,y:i,z:r})}return !this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e,i){const{x:r,y:n,z:o}=e.tileID.canonical,s=new t.AbortController;e.request=Promise.resolve(this._implementation.loadTile({x:r,y:n,z:o},{signal:s.signal})).then(function(r){return delete e.request,e.aborted?(e.state="unloaded",i(null)):void 0===r?(e.state="errored",i(null)):null===r?(this.loadTileData(e,{width:this.tileSize,height:this.tileSize,data:null}),e.state="loaded",i(null)):function(e){return e instanceof t.ImageData||e instanceof t.HTMLCanvasElement||e instanceof t.ImageBitmap||e instanceof t.HTMLImageElement}(r)?(this.loadTileData(e,r),e.state="loaded",void i(null)):(e.state="errored",i(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}.bind(this)).catch((t=>{20!==t.code&&(e.state="errored",i(t));})),e.request.cancel=()=>s.abort();}loadTileData(e,t){Lw.loadTileData(e,t,this._map.painter);}unloadTileData(e){Lw.unloadTileData(e,this._map.painter);}unloadTile(e,t){if(this.unloadTileData(e),this._implementation.unloadTile){const{x:t,y:i,z:r}=e.tileID.canonical;this._implementation.unloadTile({x:t,y:i,z:r});}t();}abortTile(e,t){e.request&&e.request.cancel&&(e.request.cancel(),delete e.request),t();}hasTransition(){return !1}_coveringTiles(){return this._map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map((e=>({x:e.canonical.x,y:e.canonical.y,z:e.canonical.z})))}_clearTiles(){const e=pa(this.id,this.scope);this._map.style.clearSource(e);}_update(){this.fire(new At("data",{dataType:"source",sourceDataType:"content"}));}}},vT=function(e,t,i,r){const n=new xT[t.type](e,t,i,r);if(n.id!==e)throw new Error(`Expected Source id to be ${e} instead of ${n.id}`);return j(["load","abort","unload","serialize","prepare"],n),n};function bT(e,t){const i=xu.identity([]);return xu.scale(i,i,[.5*e.width,.5*-e.height,1]),xu.translate(i,i,[1,-1,0]),xu.multiply(i,i,e.calculateProjMatrix(t.toUnwrapped())),Float32Array.from(i)}function wT(e,t,i,r,n,o,s,a=!1){const l=e.tilesIn(r,s,a);l.sort(ET);const c=[];for(const r of l)c.push({wrappedTileID:r.tile.tileID.wrapped().key,queryResults:r.tile.queryRenderedFeatures(t,i,e._state,r,n,o,bT(e.transform,r.tile.tileID),a)});const h=function(e){const t={},i={};for(const r of e){const e=r.queryResults,n=r.wrappedTileID,o=i[n]=i[n]||{};for(const i in e){const r=e[i],n=o[i]=o[i]||{},s=t[i]=t[i]||[];for(const e of r)n[e.featureIndex]||(n[e.featureIndex]=!0,s.push(e));}}return t}(c);for(const t in h)h[t].forEach((t=>{const i=t.feature,r=i.layer;r&&"background"!==r.type&&"sky"!==r.type&&"slot"!==r.type&&(i.source=r.source,r["source-layer"]&&(i.sourceLayer=r["source-layer"]),i.state=void 0!==i.id?e.getFeatureState(r["source-layer"],i.id):{});}));return h}function TT(e,t){const i=e.getRenderableIds().map((t=>e.getTileByID(t))),r=[],n={};for(let e=0;e0?i.paint.get("fill-extrusion-vertical-scale"):0);let o=r?r.getTile(t):null;if(!o&&r&&t.canonical.z>r.getSource().minzoom){let e=t.scaledTo(Math.min(r.getSource().maxzoom,t.overscaledZ-1));for(;e.overscaledZ>=r.getSource().minzoom&&(o=r.getTile(e),!o&&0!==e.overscaledZ);)e=e.scaledTo(e.overscaledZ-1);}this.currentBuildingBuckets.push({bucket:o?o.getBucket(i):null,tileID:o?o.tileID:t,verticalScale:n});}e.hasAnyZOffset=!1;let i=!1;for(let r=0;r{e in t&&(i[e]=t[e]);})),i}function IT(e){e=e.slice();const t=Object.create(null);for(let i=0;i0?(r-o)/s:0;return this.points[n].mult(1-a).add(this.points[t].mult(a))}}class FT{constructor(e,t,i){const r=this.boxCells=[],n=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let e=0;ethis.width||r<0||t>this.height)return !n&&[];const s=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=r){if(n)return !0;for(let e=0;e0:s}_queryCircle(e,t,i,r,n){const o=e-i,s=e+i,a=t-i,l=t+i;if(s<0||o>this.width||l<0||a>this.height)return !r&&[];const c=[];return this._forEachCell(o,a,s,l,this._queryCellCircle,c,{hitTest:r,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}},n),r?c.length>0:c}query(e,t,i,r,n){return this._query(e,t,i,r,!1,n)}hitTest(e,t,i,r,n){return this._query(e,t,i,r,!0,n)}hitTestCircle(e,t,i,r){return this._queryCircle(e,t,i,!0,r)}_queryCell(e,t,i,r,n,o,s,a){const l=s.seenUids,c=this.boxCells[n];if(null!==c){const n=this.bboxes;for(const h of c)if(!l.box[h]){l.box[h]=!0;const c=4*h;if(e<=n[c+2]&&t<=n[c+3]&&i>=n[c+0]&&r>=n[c+1]&&(!a||a(this.boxKeys[h]))){if(s.hitTest)return o.push(!0),!0;o.push({key:this.boxKeys[h],x1:n[c],y1:n[c+1],x2:n[c+2],y2:n[c+3]});}}}const h=this.circleCells[n];if(null!==h){const n=this.circles;for(const c of h)if(!l.circle[c]){l.circle[c]=!0;const h=3*c;if(this._circleAndRectCollide(n[h],n[h+1],n[h+2],e,t,i,r)&&(!a||a(this.circleKeys[c]))){if(s.hitTest)return o.push(!0),!0;{const e=n[h],t=n[h+1],i=n[h+2];o.push({key:this.circleKeys[c],x1:e-i,y1:t-i,x2:e+i,y2:t+i});}}}}}_queryCellCircle(e,t,i,r,n,o,s,a){const l=s.circle,c=s.seenUids,h=this.boxCells[n];if(null!==h){const e=this.bboxes;for(const t of h)if(!c.box[t]){c.box[t]=!0;const i=4*t;if(this._circleAndRectCollide(l.x,l.y,l.radius,e[i+0],e[i+1],e[i+2],e[i+3])&&(!a||a(this.boxKeys[t])))return o.push(!0),!0}}const u=this.circleCells[n];if(null!==u){const e=this.circles;for(const t of u)if(!c.circle[t]){c.circle[t]=!0;const i=3*t;if(this._circlesCollide(e[i],e[i+1],e[i+2],l.x,l.y,l.radius)&&(!a||a(this.circleKeys[t])))return o.push(!0),!0}}}_forEachCell(e,t,i,r,n,o,s,a){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),h=this._convertToXCellCoord(i),u=this._convertToYCellCoord(r);for(let d=l;d<=h;d++)for(let l=c;l<=u;l++)if(n.call(this,e,t,i,r,this.xCellCount*l+d,o,s,a))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,t,i,r,n,o){const s=r-e,a=n-t,l=i+o;return l*l>s*s+a*a}_circleAndRectCollide(e,t,i,r,n,o,s){const a=(o-r)/2,l=Math.abs(e-(r+a));if(l>a+i)return !1;const c=(s-n)/2,h=Math.abs(t-(n+c));if(h>c+i)return !1;if(l<=a||h<=c)return !0;const u=l-a,d=h-c;return u*u+d*d<=i*i}}const NT=100;class UT{constructor(e,t,i=new FT(e.width+200,e.height+200,25),r=new FT(e.width+200,e.height+200,25)){this.transform=e,this.grid=i,this.ignoredGrid=r,this.pitchfactor=Math.cos(e._pitch)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+NT,this.screenBottomBoundary=e.height+NT,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.fogState=t;}placeCollisionBox(e,t,i,r,n,o,s,a){let l=i.projectedAnchorX,c=i.projectedAnchorY,h=i.projectedAnchorZ;const u=i.elevation,d=i.tileID,p=e.getProjection();if(u&&d){const[e,t,r]=p.upVector(d.canonical,i.tileAnchorX,i.tileAnchorY),n=p.upVectorScale(d.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;l+=e*u*n,c+=t*u*n,h+=r*u*n;}const f=this.projectAndGetPerspectiveRatio(s,l,c,h,i.tileID,"globe"===p.name||!!u||this.transform.pitch>0,p),m=o*f.perspectiveRatio,_=(i.x1*t+r.x-i.padding)*m+f.point.x,g=(i.y1*t+r.y-i.padding)*m+f.point.y,y=(i.x2*t+r.x+i.padding)*m+f.point.x,x=(i.y2*t+r.y+i.padding)*m+f.point.y,v=f.perspectiveRatio<=.55||f.occluded;return !this.isInsideGrid(_,g,y,x)||!n&&this.grid.hitTest(_,g,y,x,a)||v?{box:[],offscreen:!1,occluded:f.occluded}:{box:[_,g,y,x],offscreen:this.isOffscreen(_,g,y,x),occluded:!1}}placeCollisionCircles(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f){const m=[],_=this.transform.elevation,g=e.getProjection(),x=_?_.getAtTileOffsetFunc(f,this.transform.center.lat,this.transform.worldSize,g):null,v=new y(i.tileAnchorX,i.tileAnchorY);let{x:b,y:w,z:T}=g.projectTilePoint(v.x,v.y,f.canonical);if(x){const[e,t,i]=x(v);b+=e,w+=t,T+=i;}const E="globe"===g.name,M=this.projectAndGetPerspectiveRatio(s,b,w,T,f,E||!!_||this.transform.pitch>0,g),{perspectiveRatio:A}=M,S=(h?o/A:o*A)/r_,I=tv(b,w,T,a),C=M.signedDistanceFromCamera>0?ov(S,n,i.lineOffsetX*S,i.lineOffsetY*S,!1,I,v,i,r,a,{},_&&!h?x:null,h&&!!_,g,f,h):null;let z=!1,D=!1,P=!0;if(C&&!M.occluded){const e=.5*d*A+p,i=new y(-100,-100),r=new y(this.screenRightBoundary,this.screenBottomBoundary),n=new BT,{first:o,last:s}=C,a=o.path.length;let h=[];for(let e=a-1;e>=1;e--)h.push(o.path[e]);for(let e=1;e(x&&!E&&(i=x(re[3]<=0))&&(h=[]));let _=[];if(h.length>0){let e=1/0,t=-1/0,n=1/0,o=-1/0;for(const i of h)e=Math.min(e,i[0]),n=Math.min(n,i[1]),t=Math.max(t,i[0]),o=Math.max(o,i[1]);t>=i.x&&e<=r.x&&o>=i.y&&n<=r.y&&(_=[h.map((e=>new y(e[0],e[1])))],(er.x||nr.y)&&(_=$_(_,i.x,i.y,r.x,r.y)));}for(const i of _){n.reset(i,.25*e);let r=0;r=n.length<=.5*e?1:Math.ceil(n.paddedLength/f)+1;for(let i=0;i0){if(uu.transformMat4(a,a,e),this.fogState&&n&&"globe"!==s.name){const e=function(e,t,i,r,n,o){const s=o.calculateFogTileMatrix(n),a=[t,i,r];return Mu.transformMat4(a,a,s),aw(e,Mu.length(a),o.pitch,o._fov)}(this.fogState,t,i,r,n.toUnwrapped(),this.transform);l=e>.9;}}else dv(a,a,e);const c=a[3];return {point:new y((a[0]/c+1)/2*this.transform.width+NT,(-a[1]/c+1)/2*this.transform.height+NT),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(s)/c*.5,1.5),signedDistanceFromCamera:c,occluded:o&&a[2]>c||l}}isOffscreen(e,t,i,r){return i=this.screenRightBoundary||rthis.screenBottomBoundary}isInsideGrid(e,t,i,r){return i>=0&&e=0&&te.collisionGroupID===t};}return this.collisionGroups[e]}}function YT(e,t,i,r,n){const{horizontalAlign:o,verticalAlign:s}=L_(e),a=-(o-.5)*t,l=-(s-.5)*i,c=ug(e,r);return new y(a+c[0]*n,l+c[1]*n)}function KT(e,t,i,r,n){const o=new y(e,t);return i&&o._rotate(r?n:-n),o}class JT{constructor(e,t,i,r,n,o){this.transform=e.clone(),this.projection=e.projection.name,this.collisionIndex=new UT(this.transform,n),this.buildingIndex=o,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=t,this.retainedQueryData={},this.collisionGroups=new XT(i),this.collisionCircleArrays={},this.prevPlacement=r,r&&(r.prevPlacement=void 0),this.placedOrientations={};}getBucketParts(e,t,i,r){const n=i.getBucket(t),o=i.latestFeatureIndex;if(!n||!o||t.fqid!==n.layerIds[0])return;const s=n.layers[0].layout,a=i.collisionBoxArray,l=Math.pow(2,this.transform.zoom-i.tileID.overscaledZ),c=i.tileSize/sr,h=i.tileID.toUnwrapped();this.transform.setProjection(n.projection);const u=(d=i.tileID,p=n.getProjection(),f=this.transform,p.name===this.projection?f.calculateProjMatrix(d.toUnwrapped()):VT(f,p,d));var d,p,f;const m="map"===s.get("text-pitch-alignment"),_="map"===s.get("text-rotation-alignment");t.compileFilter();const g=t.dynamicFilter(),y=t.dynamicFilterNeedsFeature(),x=this.transform.calculatePixelsToTileUnitsMatrix(i),v=Qx(u,i.tileID.canonical,m,_,this.transform,n.getProjection(),x);let b=null;if(m){const e=ev(u,i.tileID.canonical,m,_,this.transform,n.getProjection(),x);b=xu.multiply([],this.transform.labelPlaneMatrix,e);}let w=null;g&&i.latestFeatureIndex&&(w={unwrappedTileID:h,dynamicFilter:g,dynamicFilterNeedsFeature:y,featureIndex:i.latestFeatureIndex}),this.retainedQueryData[n.bucketInstanceId]=new WT(n.bucketInstanceId,o,n.sourceLayerIndex,n.index,i.tileID);const T={bucket:n,layout:s,posMatrix:u,textLabelPlaneMatrix:v,labelToScreenMatrix:b,clippingData:w,scale:l,textPixelRatio:c,holdingForFade:i.holdingForFade(),collisionBoxArray:a,partiallyEvaluatedTextSize:a_(n.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:a_(n.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(n.sourceID)};if(r)for(const t of n.sortKeyRanges){const{sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n}=t;e.push({sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n,parameters:T});}else e.push({symbolInstanceStart:0,symbolInstanceEnd:n.symbolInstances.length,parameters:T});}attemptAnchorPlacement(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){const{textOffset0:y,textOffset1:x,crossTileID:v}=u,b=[y,x],w=YT(e,i,r,b,n),T=this.collisionIndex.placeCollisionBox(p,n,t,KT(w.x,w.y,o,s,this.transform.angle),h,a,l,c.predicate);if(m){const e=p.getSymbolInstanceIconSize(g,this.transform.zoom,u.placedIconSymbolIndex);if(0===this.collisionIndex.placeCollisionBox(p,e,m,KT(w.x,w.y,o,s,this.transform.angle),h,a,l,c.predicate).box.length)return}if(T.box.length>0){let t;return this.prevPlacement&&this.prevPlacement.variableOffsets[v]&&this.prevPlacement.placements[v]&&this.prevPlacement.placements[v].text&&(t=this.prevPlacement.variableOffsets[v].anchor),this.variableOffsets[v]={textOffset:b,width:i,height:r,anchor:e,textScale:n,prevAnchor:t},this.markUsedJustification(p,e,u,f),p.allowVerticalPlacement&&(this.markUsedOrientation(p,f,u),this.placedOrientations[v]=f),{shift:w,placedGlyphBoxes:T}}}placeLayerBucketPart(e,t,i,r){const{bucket:n,layout:o,posMatrix:s,textLabelPlaneMatrix:a,labelToScreenMatrix:l,clippingData:c,textPixelRatio:h,holdingForFade:u,collisionBoxArray:d,partiallyEvaluatedTextSize:p,partiallyEvaluatedIconSize:f,collisionGroup:m}=e.parameters,_=o.get("text-optional"),g=o.get("icon-optional"),x=o.get("text-allow-overlap"),v=o.get("icon-allow-overlap"),b="map"===o.get("text-rotation-alignment"),w="map"===o.get("text-pitch-alignment"),T="viewport-y"===o.get("symbol-z-order"),E=o.get("symbol-z-elevate");this.transform.setProjection(n.projection);let M=x&&(v||!n.hasIconData()||g),A=v&&(x||!n.hasTextData()||_);!n.collisionArrays&&d&&n.deserializeCollisionBoxes(d),i&&r&&n.updateCollisionDebugBuffers(this.transform.zoom,d);const S=(e,r,d)=>{const{crossTileID:T,numVerticalGlyphVertices:E}=e;if(c){const i={zoom:this.transform.zoom,pitch:this.transform.pitch};let r=null;if(c.dynamicFilterNeedsFeature){const t=this.retainedQueryData[n.bucketInstanceId];r=c.featureIndex.loadFeature({featureIndex:e.featureIndex,bucketIndex:t.bucketIndex,sourceLayerIndex:t.sourceLayerIndex,layoutVertexArrayOffset:0});}if(!(0, c.dynamicFilter)(i,r,this.retainedQueryData[n.bucketInstanceId].tileID.canonical,new y(e.tileAnchorX,e.tileAnchorY),this.transform.calculateDistanceTileData(c.unwrappedTileID)))return this.placements[T]=new $T(!1,!1,!1,!0),void t.add(T)}if(t.has(T))return;if(u)return void(this.placements[T]=new $T(!1,!1,!1));let S=!1,I=!1,C=!0,z=!1,D=!1,P=null,R={box:null,offscreen:null,occluded:null},L={box:null,offscreen:null,occluded:null},k=null,O=null,B=null,F=0,N=0,U=0;d.textFeatureIndex?F=d.textFeatureIndex:e.useRuntimeCollisionCircles&&(F=e.featureIndex),d.verticalTextFeatureIndex&&(N=d.verticalTextFeatureIndex);const V=t=>{t.tileID=this.retainedQueryData[n.bucketInstanceId].tileID;const i=this.transform.elevation;t.elevation=e.zOffset+(i?i.getAtTileOffset(t.tileID,t.tileAnchorX,t.tileAnchorY):0);},j=d.textBox;if(j){V(j);const t=t=>{let i=w_.horizontal;if(n.allowVerticalPlacement&&!t&&this.prevPlacement){const t=this.prevPlacement.placedOrientations[T];t&&(this.placedOrientations[T]=t,i=t,this.markUsedOrientation(n,i,e));}return i},i=(e,t)=>{if(n.allowVerticalPlacement&&E>0&&d.verticalTextBox){for(const i of n.writingModes)if(i===w_.vertical?(R=t(),L=R):R=e(),R&&R.box&&R.box.length)break}else R=e();};if(o.get("text-variable-anchor")){let a=o.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[T]){const e=this.prevPlacement.variableOffsets[T];a.indexOf(e.anchor)>0&&(a=a.filter((t=>t!==e.anchor)),a.unshift(e.anchor));}const l=(t,i,o)=>{const l=n.getSymbolInstanceTextSize(p,e,this.transform.zoom,r),c=(t.x2-t.x1)*l+2*t.padding,u=(t.y2-t.y1)*l+2*t.padding,d=e.hasIconTextFit&&!v?i:null;d&&V(d);let _={box:[],offscreen:!1,occluded:!1};const g=x?2*a.length:a.length;for(let i=0;i=a.length,e,r,n,o,d,p,f);if(g&&(_=g.placedGlyphBoxes,_&&_.box&&_.box.length)){S=!0,P=g.shift;break}}return _};i((()=>l(j,d.iconBox,w_.horizontal)),(()=>{const e=d.verticalTextBox;return e&&V(e),n.allowVerticalPlacement&&!(R&&R.box&&R.box.length)&&E>0&&e?l(e,d.verticalIconBox,w_.vertical):{box:null,offscreen:null,occluded:null}})),R&&(S=R.box,C=R.offscreen,z=R.occluded);const c=t(!(!R||!R.box));if(!S&&this.prevPlacement){const t=this.prevPlacement.variableOffsets[T];t&&(this.variableOffsets[T]=t,this.markUsedJustification(n,t.anchor,e,c));}}else {const o=(t,i)=>{const o=n.getSymbolInstanceTextSize(p,e,this.transform.zoom,r),a=this.collisionIndex.placeCollisionBox(n,o,t,new y(0,0),x,h,s,m.predicate);return a&&a.box&&a.box.length&&(this.markUsedOrientation(n,i,e),this.placedOrientations[T]=i),a};i((()=>o(j,w_.horizontal)),(()=>{const e=d.verticalTextBox;return n.allowVerticalPlacement&&E>0&&e?(V(e),o(e,w_.vertical)):{box:null,offscreen:null,occluded:null}})),t(!!(R&&R.box&&R.box.length));}}if(k=R,S=k&&k.box&&k.box.length>0,C=k&&k.offscreen,z=k&&k.occluded,e.useRuntimeCollisionCircles){const t=n.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex),r=s_(n.textSizeData,p,t),c=o.get("text-padding");O=this.collisionIndex.placeCollisionCircles(n,x,t,n.lineVertexArray,n.glyphOffsetArray,r,s,a,l,i,w,m.predicate,e.collisionCircleDiameter*r/r_,c,this.retainedQueryData[n.bucketInstanceId].tileID),S=x||O.circles.length>0&&!O.collisionDetected,C=C&&O.offscreen,z=O.occluded;}if(d.iconFeatureIndex&&(U=d.iconFeatureIndex),d.iconBox){const t=t=>{V(t);const i=e.hasIconTextFit&&P?KT(P.x,P.y,b,w,this.transform.angle):new y(0,0),r=n.getSymbolInstanceIconSize(f,this.transform.zoom,e.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(n,r,t,i,v,h,s,m.predicate)};L&&L.box&&L.box.length&&d.verticalIconBox?(B=t(d.verticalIconBox),I=B.box.length>0):(B=t(d.iconBox),I=B.box.length>0),C=C&&B.offscreen,D=B.occluded;}const G=_||0===e.numHorizontalGlyphVertices&&0===E,q=g||0===e.numIconVertices;if(G||q?q?G||(I=I&&S):S=I&&S:I=S=I&&S,S&&k&&k.box&&this.collisionIndex.insertCollisionBox(k.box,o.get("text-ignore-placement"),n.bucketInstanceId,L&&L.box&&N?N:F,m.ID),I&&B&&this.collisionIndex.insertCollisionBox(B.box,o.get("icon-ignore-placement"),n.bucketInstanceId,U,m.ID),O&&(S&&this.collisionIndex.insertCollisionCircles(O.circles,o.get("text-ignore-placement"),n.bucketInstanceId,F,m.ID),i)){const e=n.bucketInstanceId;let t=this.collisionCircleArrays[e];void 0===t&&(t=this.collisionCircleArrays[e]=new HT);for(let e=0;e=0;--t){const i=e[t];S(n.symbolInstances.get(i),i,n.collisionArrays[i]);}n.hasAnyZOffset&&W(`${n.layerIds[0]} layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y`);}else if(n.hasAnyZOffset){const e=n.getSortedIndexesByZOffset();for(let t=0;t=0&&(e.text.placedSymbolArray.get(n).crossTileID=h>=0&&n!==h?0:l),o>=0&&(e.text.placedSymbolArray.get(o).crossTileID=h>=0&&o!==h?0:l),s>=0&&(e.text.placedSymbolArray.get(s).crossTileID=h>=0&&s!==h?0:l),a>=0&&(e.text.placedSymbolArray.get(a).crossTileID=h>=0&&a!==h?0:l);}markUsedOrientation(e,t,i){const r=t===w_.horizontal||t===w_.horizontalOnly?t:0,n=t===w_.vertical?t:0,{leftJustifiedTextSymbolIndex:o,centerJustifiedTextSymbolIndex:s,rightJustifiedTextSymbolIndex:a,verticalPlacedTextSymbolIndex:l}=i,c=e.text.placedSymbolArray;o>=0&&(c.get(o).placedOrientation=r),s>=0&&(c.get(s).placedOrientation=r),a>=0&&(c.get(a).placedOrientation=r),l>=0&&(c.get(l).placedOrientation=n);}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const t=this.prevPlacement;let i=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;const r=t?t.symbolFadeChange(e):1,n=t?t.opacities:{},o=t?t.variableOffsets:{},s=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],o=n[e];o?(this.opacities[e]=new ZT(o,r,t.text,t.icon,null,t.clipped),i=i||t.text!==o.text.placed||t.icon!==o.icon.placed):(this.opacities[e]=new ZT(null,r,t.text,t.icon,t.skipFade,t.clipped),i=i||t.text||t.icon);}for(const e in n){const t=n[e];if(!this.opacities[e]){const n=new ZT(t,r,!1,!1);n.isHidden()||(this.opacities[e]=n,i=i||t.text.placed||t.icon.placed);}}for(const e in o)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=o[e]);for(const e in s)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=s[e]);i?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e);}updateLayerOpacities(e,t){const i=new Set;for(const r of t){const t=r.getBucket(e);t&&r.latestFeatureIndex&&e.fqid===t.layerIds[0]&&(this.updateBucketOpacities(t,i,r.collisionBoxArray),t.layers[0].layout.get("symbol-z-elevate")&&this.buildingIndex&&(this.buildingIndex.updateZOffset(t,r.tileID),t.updateZOffset()));}}updateBucketOpacities(e,t,i){e.hasTextData()&&e.text.opacityVertexArray.clear(),e.hasIconData()&&e.icon.opacityVertexArray.clear(),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const r=e.layers[0].layout,n=!!e.layers[0].dynamicFilter(),o=new ZT(null,0,!1,!1,!0),s=r.get("text-allow-overlap"),a=r.get("icon-allow-overlap"),l=r.get("text-variable-anchor"),c="map"===r.get("text-rotation-alignment"),h="map"===r.get("text-pitch-alignment"),u=new ZT(null,0,s&&(a||!e.hasIconData()||r.get("icon-optional")),a&&(s||!e.hasTextData()||r.get("text-optional")),!0);!e.collisionArrays&&i&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(i);const d=(e,t,i)=>{for(let r=0;r0||a>0,v=m>0,b=this.placedOrientations[f],w=b===w_.vertical,T=b===w_.horizontal||b===w_.horizontalOnly;if(!x&&!v||g.isHidden()||p++,x){const t=aE(g.text);d(e.text,s,w?lE:t),d(e.text,a,T?lE:t);const i=g.text.isHidden(),{leftJustifiedTextSymbolIndex:n,centerJustifiedTextSymbolIndex:o,rightJustifiedTextSymbolIndex:l,verticalPlacedTextSymbolIndex:c}=r,h=e.text.placedSymbolArray,u=i||w?1:0;n>=0&&(h.get(n).hidden=u),o>=0&&(h.get(o).hidden=u),l>=0&&(h.get(l).hidden=u),c>=0&&(h.get(c).hidden=i||T?1:0);const p=this.variableOffsets[f];p&&this.markUsedJustification(e,p.anchor,r,b);const m=this.placedOrientations[f];m&&(this.markUsedJustification(e,"left",r,m),this.markUsedOrientation(e,m,r));}if(v){const t=aE(g.icon),{placedIconSymbolIndex:i,verticalPlacedIconSymbolIndex:n}=r,o=e.icon.placedSymbolArray,s=g.icon.isHidden()?1:0;i>=0&&(d(e.icon,m,w?lE:t),o.get(i).hidden=s),n>=0&&(d(e.icon,r.numVerticalIconVertices,T?lE:t),o.get(n).hidden=s);}if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const t=e.collisionArrays[i];if(t){let i=new y(0,0),o=!0;if(t.textBox||t.verticalTextBox){if(l){const e=this.variableOffsets[f];e?(i=YT(e.anchor,e.width,e.height,e.textOffset,e.textScale),c&&i._rotate(h?this.transform.angle:-this.transform.angle)):o=!1;}n&&(o=!g.clipped),t.textBox&&QT(e.textCollisionBox.collisionVertexArray,g.text.placed,!o||w,i.x,i.y),t.verticalTextBox&&QT(e.textCollisionBox.collisionVertexArray,g.text.placed,!o||T,i.x,i.y);}const s=o&&Boolean(!T&&t.verticalIconBox);t.iconBox&&QT(e.iconCollisionBox.collisionVertexArray,g.icon.placed,s,r.hasIconTextFit?i.x:0,r.hasIconTextFit?i.y:0),t.verticalIconBox&&QT(e.iconCollisionBox.collisionVertexArray,g.icon.placed,!s,r.hasIconTextFit?i.x:0,r.hasIconTextFit?i.y:0);}}}if(e.fullyClipped=0===p,e.sortFeatures(this.transform.angle),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.bucketInstanceId in this.collisionCircleArrays){const t=this.collisionCircleArrays[e.bucketInstanceId];e.placementInvProjMatrix=t.invProjMatrix,e.placementViewportMatrix=t.viewportMatrix,e.collisionCircleArray=t.circles,delete this.collisionCircleArrays[e.bucketInstanceId];}}symbolFadeChange(e){return 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTimee}setStale(){this.stale=!0;}}function QT(e,t,i,r,n){e.emplaceBack(t?1:0,i?1:0,r||0,n||0),e.emplaceBack(t?1:0,i?1:0,r||0,n||0),e.emplaceBack(t?1:0,i?1:0,r||0,n||0),e.emplaceBack(t?1:0,i?1:0,r||0,n||0);}const eE=Math.pow(2,25),tE=Math.pow(2,24),iE=Math.pow(2,17),rE=Math.pow(2,16),nE=Math.pow(2,9),oE=Math.pow(2,8),sE=Math.pow(2,1);function aE(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;const t=e.placed?1:0,i=Math.floor(127*e.opacity);return i*eE+t*tE+i*iE+t*rE+i*nE+t*oE+i*sE+t}const lE=0;class cE{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&void 0!==e.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[];}continuePlacement(e,t,i,r,n){const o=this._bucketParts;for(;this._currentTileIndexe.sortKey-t.sortKey)));this._currentPartIndex{const e=ht.now()-n;return !this._forceFullPlacement&&e>2};for(;this._currentPlacementIndex>=0;){const n=t[e[this._currentPlacementIndex]],s=this.placement.collisionIndex.transform.zoom;if("symbol"===n.type&&(!n.minzoom||n.minzoom<=s)&&(!n.maxzoom||n.maxzoom>s)){const e=n,t=e.layout.get("symbol-z-elevate"),s=this._inProgressLayer=this._inProgressLayer||new cE(e),a=pa(n.source,n.scope);if(s.continuePlacement(t?r[a]:i[a],this.placement,this._showCollisionBoxes,n,o))return;delete this._inProgressLayer;}this._currentPlacementIndex--;}this._done=!0;}commit(e){return this.placement.commit(e),this.placement}}const uE=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class dE{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[t,i]=new Uint8Array(e,0,2);if(219!==t)throw new Error("Data does not appear to be in a KDBush format.");const r=i>>4;if(1!==r)throw new Error(`Got v${r} data when expected v1.`);const n=uE[15&i];if(!n)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(e,2,1),[s]=new Uint32Array(e,4,1);return new dE(s,o,n,e)}constructor(e,t=64,i=Float64Array,r){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=i,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const n=uE.indexOf(this.ArrayType),o=2*e*this.ArrayType.BYTES_PER_ELEMENT,s=e*this.IndexArrayType.BYTES_PER_ELEMENT,a=(8-s%8)%8;if(n<0)throw new Error(`Unexpected typed array class: ${i}.`);r&&r instanceof ArrayBuffer?(this.data=r,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+s+a,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+o+s+a),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+s+a,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+n]),new Uint16Array(this.data,2,1)[0]=t,new Uint32Array(this.data,4,1)[0]=e);}add(e,t){const i=this._pos>>1;return this.ids[i]=i,this.coords[this._pos++]=e,this.coords[this._pos++]=t,i}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return pE(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,i,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:o,nodeSize:s}=this,a=[0,n.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,h=a.pop()||0,u=a.pop()||0;if(h-u<=s){for(let s=u;s<=h;s++){const a=o[2*s],c=o[2*s+1];a>=e&&a<=i&&c>=t&&c<=r&&l.push(n[s]);}continue}const d=u+h>>1,p=o[2*d],f=o[2*d+1];p>=e&&p<=i&&f>=t&&f<=r&&l.push(n[d]),(0===c?e<=p:t<=f)&&(a.push(u),a.push(d-1),a.push(1-c)),(0===c?i>=p:r>=f)&&(a.push(d+1),a.push(h),a.push(1-c));}return l}within(e,t,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:n,nodeSize:o}=this,s=[0,r.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,h=s.pop()||0,u=s.pop()||0;if(h-u<=o){for(let i=u;i<=h;i++)gE(n[2*i],n[2*i+1],e,t)<=l&&a.push(r[i]);continue}const d=u+h>>1,p=n[2*d],f=n[2*d+1];gE(p,f,e,t)<=l&&a.push(r[d]),(0===c?e-i<=p:t-i<=f)&&(s.push(u),s.push(d-1),s.push(1-c)),(0===c?e+i>=p:t+i>=f)&&(s.push(d+1),s.push(h),s.push(1-c));}return a}}function pE(e,t,i,r,n,o){if(n-r<=i)return;const s=r+n>>1;fE(e,t,s,r,n,o),pE(e,t,i,r,s-1,1-o),pE(e,t,i,s+1,n,1-o);}function fE(e,t,i,r,n,o){for(;n>r;){if(n-r>600){const s=n-r+1,a=i-r+1,l=Math.log(s),c=.5*Math.exp(2*l/3),h=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2<0?-1:1);fE(e,t,i,Math.max(r,Math.floor(i-a*c/s+h)),Math.min(n,Math.floor(i+(s-a)*c/s+h)),o);}const s=t[2*i+o];let a=r,l=n;for(mE(e,t,r,i),t[2*n+o]>s&&mE(e,t,r,n);as;)l--;}t[2*r+o]===s?mE(e,t,r,l):(l++,mE(e,t,l,n)),l<=i&&(r=l+1),i<=l&&(n=l-1);}}function mE(e,t,i,r){_E(e,i,r),_E(t,2*i,2*r),_E(t,2*i+1,2*r+1);}function _E(e,t,i){const r=e[t];e[t]=e[i],e[i]=r;}function gE(e,t,i,r){const n=e-i,o=t-r;return n*n+o*o}const yE=512/sr/2;class xE{constructor(e,t,i){this.tileID=e,this.bucketInstanceId=i,this.index=new dE(t.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const r=e.canonical.x*sr,n=e.canonical.y*sr;for(let e=0;ee.overscaledZ)for(const i in n){const o=n[i];o.tileID.isChildOf(e)&&o.findMatches(t.symbolInstances,e,r);}else {const o=n[e.scaledTo(Number(i)).key];o&&o.findMatches(t.symbolInstances,e,r);}}for(let e=0;e{t[e]=!0;}));for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e];}}var TE="\n#define EPSILON 0.0000001\n#define PI 3.141592653589793\n#define EXTENT 8192.0\n#define HALF_PI PI/2.0\n#define QUARTER_PI PI/4.0\n#define RAD_TO_DEG 180.0/PI\n#define DEG_TO_RAD PI/180.0\n#define GLOBE_RADIUS EXTENT/PI/2.0\nvec3 linearTosRGB(vec3 color)\n{return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn)\n{return pow(srgbIn,vec3(2.2));}vec3 linearProduct(vec3 srgbIn,vec3 k)\n{return srgbIn*pow(k,vec3(1./2.2));}\n#if __VERSION__ >=300\n#define _HANDLE_WIREFRAME_DEPTH gl_FragDepth=gl_FragCoord.z-0.0001;\n#else\n#define _HANDLE_WIREFRAME_DEPTH\n#endif\n#ifdef DEBUG_WIREFRAME\n#define HANDLE_WIREFRAME_DEBUG \\\ngl_FragColor=vec4(0.7,0.0,0.0,0.7); \\\n_HANDLE_WIREFRAME_DEPTH;\n#else\n#define HANDLE_WIREFRAME_DEBUG\n#endif\n#ifdef RENDER_CUTOFF\nfloat cutoff_opacity(vec4 cutoff_params,float depth) {float near=cutoff_params.x;float far=cutoff_params.y;float cutoffStart=cutoff_params.z;float cutoffEnd=cutoff_params.w-0.0001;float linearDepth=(depth-near)/(far-near);return clamp((linearDepth-cutoffStart)/(cutoffEnd-cutoffStart),0.0,1.0);}\n#endif",EE="attribute highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;varying highp vec3 v_uv;void main() {const mat3 half_neg_pi_around_x=mat3(1.0,0.0, 0.0,0.0,0.0,-1.0,0.0,1.0, 0.0);v_uv=half_neg_pi_around_x*a_pos_3f;vec4 pos=u_matrix*vec4(a_pos_3f,1.0);gl_Position=pos.xyww;}",ME="\n#define ELEVATION_SCALE 7.0\n#define ELEVATION_OFFSET 450.0\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix(\nmix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;}\n#else\nvec3 elevationVector(vec2 pos) { return vec3(0,0,1); }\n#endif\nconst float skirtOffset=24575.0;vec3 decomposeToPosAndSkirt(vec2 posWithComposedSkirt)\n{float skirt=float(posWithComposedSkirt.x >=skirtOffset);vec2 pos=posWithComposedSkirt-vec2(skirt*skirtOffset,0.0);return vec3(pos,skirt);}\n#ifdef TERRAIN\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nuniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;\n#else\nuniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;\n#endif\nuniform vec4 u_dem_unpack;uniform vec2 u_dem_tl;uniform vec2 u_dem_tl_prev;uniform float u_dem_scale;uniform float u_dem_scale_prev;uniform float u_dem_size;uniform float u_dem_lerp;uniform float u_exaggeration;uniform float u_meter_to_dem;uniform mat4 u_label_plane_matrix_inv;uniform sampler2D u_depth;uniform vec2 u_depth_size_inv;vec4 tileUvToDemSample(vec2 uv,float dem_size,float dem_scale,vec2 dem_tl) {vec2 pos=dem_size*(uv*dem_scale+dem_tl)+1.0;vec2 f=fract(pos);return vec4((pos-f+0.5)/(dem_size+2.0),f);}float decodeElevation(vec4 v) {return dot(vec4(v.xyz*255.0,-1.0),u_dem_unpack);}float currentElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale+u_dem_tl)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture(u_dem,pos).r;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale,u_dem_tl);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem,pos));float tr=decodeElevation(texture2D(u_dem,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}float prevElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale_prev+u_dem_tl_prev)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture(u_dem_prev,pos).r;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale_prev,u_dem_tl_prev);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem_prev,pos));float tr=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem_prev,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}\n#ifdef TERRAIN_VERTEX_MORPHING\nfloat elevation(vec2 apos) {\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\nfloat nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}\n#else\nfloat elevation(vec2 apos) {\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\nreturn currentElevation(apos);}\n#endif\nhighp float unpack_depth(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;float depth=unpack_depth(texture2D(u_depth,(coord.xy+1.0)*0.5));return coord.z > depth+0.0005;}float occlusionFade(vec4 frag) {vec3 coord=frag.xyz/frag.w;vec3 df=vec3(5.0*u_depth_size_inv,0.0);vec2 uv=0.5*coord.xy+0.5;vec4 depth=vec4(\nunpack_depth(texture2D(u_depth,uv-df.xz)),unpack_depth(texture2D(u_depth,uv+df.xz)),unpack_depth(texture2D(u_depth,uv-df.zy)),unpack_depth(texture2D(u_depth,uv+df.zy))\n);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z-0.001)-depth),0.0,1.0));}vec4 fourSample(vec2 pos,vec2 off) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nfloat tl=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(off.x,0.0)).r;float bl=texture(u_dem,pos+vec2(0.0,off.y)).r;float br=texture(u_dem,pos+off).r;\n#else\nvec4 demtl=vec4(texture2D(u_dem,pos).xyz*255.0,-1.0);float tl=dot(demtl,u_dem_unpack);vec4 demtr=vec4(texture2D(u_dem,pos+vec2(off.x,0.0)).xyz*255.0,-1.0);float tr=dot(demtr,u_dem_unpack);vec4 dembl=vec4(texture2D(u_dem,pos+vec2(0.0,off.y)).xyz*255.0,-1.0);float bl=dot(dembl,u_dem_unpack);vec4 dembr=vec4(texture2D(u_dem,pos+off).xyz*255.0,-1.0);float br=dot(dembr,u_dem_unpack);\n#endif\nreturn vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);}\n#else\nfloat elevation(vec2 pos) { return 0.0; }bool isOccluded(vec4 frag) { return false; }float occlusionFade(vec4 frag) { return 1.0; }\n#endif",AE="#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump mat4 u_fog_matrix;varying vec3 v_fog_pos;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}vec3 fog_position(vec3 pos) {return (u_fog_matrix*vec4(pos,1.0)).xyz;}vec3 fog_position(vec2 pos) {return fog_position(vec3(pos,0.0));}float fog(vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));return opacity*fog_horizon_blending(pos/depth);}\n#endif",SE="#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump vec2 u_fog_vertical_limit;uniform mediump float u_fog_temporal_offset;varying vec3 v_fog_pos;uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform highp vec2 u_viewport;uniform float u_globe_transition;uniform int u_is_globe;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}float globe_glow_progress() {highp vec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float sdf=length(closest_point-u_globe_pos)/u_globe_radius;return sdf+PI*0.5;}float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos) {float depth=length(pos);float opacity;if (u_is_globe==1) {float glow_progress=globe_glow_progress();float t=mix(glow_progress,depth,u_globe_transition);opacity=fog_opacity(fog_range(t));} else {opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);}return mix(color,u_fog_color.rgb,opacity);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec4 fog_apply_premultiplied(vec4 color,vec3 pos,float heightMeters) {float verticalProgress=(u_fog_vertical_limit.x > 0.0 || u_fog_vertical_limit.y > 0.0) ? smoothstep(u_fog_vertical_limit.x,u_fog_vertical_limit.y,heightMeters) : 0.0;float opacityLimit=1.0-smoothstep(0.9,1.0,fog_opacity(pos));return mix(fog_apply_premultiplied(color,pos),color,min(verticalProgress,opacityLimit));}vec3 fog_dither(vec3 color) {\n#ifdef FOG_DITHERING\nvec2 dither_seed=gl_FragCoord.xy+u_fog_temporal_offset;return dither(color,dither_seed);\n#else\nreturn color;\n#endif\n}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}\n#endif",IE="#ifdef RENDER_SHADOWS\nuniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_normal_offset;vec3 shadow_normal_offset(vec3 normal) {float tileInMeters=u_shadow_normal_offset[0];vec3 n=vec3(-normal.xy,tileInMeters*normal.z);float dotScale=min(1.0-dot(normal,u_shadow_direction),1.0)*0.5+0.5;return n*dotScale;}vec3 shadow_normal_offset_model(vec3 normal) {float dotScale=min(1.0-dot(normal,u_shadow_direction),1.0)*0.5+0.5;return normal*dotScale;}float shadow_normal_offset_multiplier0() {return u_shadow_normal_offset[1];}float shadow_normal_offset_multiplier1() {return u_shadow_normal_offset[2];}\n#endif//RENDER_SHADOWS",CE="#ifdef RENDER_SHADOWS\n#if defined(NATIVE) && __VERSION__ >=300\n#define TEXTURE_GATHER\n#endif\n#ifdef DEPTH_TEXTURE\nuniform highp sampler2D u_shadowmap_0;uniform highp sampler2D u_shadowmap_1;\n#else\nuniform sampler2D u_shadowmap_0;uniform sampler2D u_shadowmap_1;\n#endif\nuniform float u_shadow_intensity;uniform float u_shadow_map_resolution;uniform float u_shadow_texel_size;uniform highp vec3 u_shadow_normal_offset;uniform vec2 u_fade_range;uniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_bias;highp float shadow_sample_1(highp vec2 uv,highp float compare) {highp float shadow_depth;\n#ifdef DEPTH_TEXTURE\nshadow_depth=texture2D(u_shadowmap_1,uv).r;\n#else\nshadow_depth=unpack_depth(texture2D(u_shadowmap_1,uv))*0.5+0.5;\n#endif\nreturn step(shadow_depth,compare);}highp float shadow_sample_0(highp vec2 uv,highp float compare) {highp float shadow_depth;\n#ifdef DEPTH_TEXTURE\nshadow_depth=texture2D(u_shadowmap_0,uv).r;\n#else\nshadow_depth=unpack_depth(texture2D(u_shadowmap_0,uv))*0.5+0.5;\n#endif\nreturn step(shadow_depth,compare);}float shadow_occlusion_1(highp vec4 pos,highp float bias) {highp vec2 uv=pos.xy;return shadow_sample_1(uv,pos.z-bias);}float shadow_occlusion_0(highp vec4 pos,highp float bias) {highp float compare0=pos.z-bias;\n#ifdef TEXTURE_GATHER\nhighp vec2 uv=pos.xy;highp vec4 samples=textureGather(u_shadowmap_0,uv,0);lowp vec4 stepSamples=step(samples,vec4(compare0));\n#else\nhighp vec2 uv00=pos.xy-vec2(0.5*u_shadow_texel_size);highp vec2 uv10=uv00+vec2(u_shadow_texel_size,0.0);highp vec2 uv01=uv00+vec2(0.0,u_shadow_texel_size);highp vec2 uv11=uv01+vec2(u_shadow_texel_size,0.0);lowp vec4 stepSamples=vec4(\nshadow_sample_0(uv01,compare0),shadow_sample_0(uv11,compare0),shadow_sample_0(uv10,compare0),shadow_sample_0(uv00,compare0)\n);\n#endif\nvec2 f=fract(pos.xy*u_shadow_map_resolution-vec2(0.5));lowp vec2 lerpx=mix(stepSamples.wx,stepSamples.zy,f.xx);return mix(lerpx.x,lerpx.y,f.y);}float shadow_occlusion(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,highp float bias) {\n#ifdef SHADOWS_SINGLE_CASCADE\nlight_view_pos0.xyz=light_view_pos0.xyz/light_view_pos0.w*0.5+0.5;return shadow_occlusion_0(light_view_pos0,bias);\n#else\nlight_view_pos0.xyz/=light_view_pos0.w;light_view_pos1.xyz/=light_view_pos1.w;vec4 uv=vec4(light_view_pos0.xy,light_view_pos1.xy);vec4 abs_bounds=abs(uv);if (abs_bounds.x < 1.0 && abs_bounds.y < 1.0) {light_view_pos0.xyz=light_view_pos0.xyz*0.5+0.5;return shadow_occlusion_0(light_view_pos0,bias);}if (abs_bounds.z >=1.0 || abs_bounds.w >=1.0) {return 0.0;}light_view_pos1.xyz=light_view_pos1.xyz*0.5+0.5;float occlusion1=shadow_occlusion_1(light_view_pos1,bias);return mix(occlusion1,0.0,smoothstep(u_fade_range.x,u_fade_range.y,view_depth));\n#endif\n}highp float calculate_shadow_bias(float NDotL) {\n#ifdef NORMAL_OFFSET\nreturn 0.5*u_shadow_bias.x;\n#else\nreturn 0.5*(u_shadow_bias.x+clamp(u_shadow_bias.y*tan(acos(NDotL)),0.0,u_shadow_bias.z));\n#endif\n}float shadowed_light_factor_normal(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=calculate_shadow_bias(NDotL);float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor_normal_unbiased(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return 1.0-(u_shadow_intensity*occlusion);}float shadow_occlusion(float ndotl,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=calculate_shadow_bias(ndotl);return shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);}\n#endif";const zE=[];OE(TE,zE);const DE={"_prelude_fog.vertex.glsl":AE,"_prelude_terrain.vertex.glsl":ME,"_prelude_shadow.vertex.glsl":IE,"_prelude_fog.fragment.glsl":SE,"_prelude_shadow.fragment.glsl":CE,"_prelude_lighting.glsl":"\n#ifdef LIGHTING_3D_MODE\nuniform mediump vec3 u_lighting_ambient_color;uniform mediump vec3 u_lighting_directional_dir;uniform mediump vec3 u_lighting_directional_color;uniform mediump vec3 u_ground_radiance;float calculate_ambient_directional_factor(vec3 normal) {float NdotL=dot(normal,u_lighting_directional_dir);const float factor_reduction_max=0.3;float dir_luminance=dot(u_lighting_directional_color,vec3(0.2126,0.7152,0.0722));float directional_factor_min=1.0-factor_reduction_max*min(dir_luminance,1.0);float ambient_directional_factor=mix(directional_factor_min,1.0,min((NdotL+1.0),1.0));const float vertical_factor_min=0.92;float vertical_factor=mix(vertical_factor_min,1.0,normal.z*0.5+0.5);return vertical_factor*ambient_directional_factor;}vec3 apply_lighting(vec3 color,vec3 normal,float dir_factor) {float ambient_directional_factor=calculate_ambient_directional_factor(normal);vec3 ambient_contrib=ambient_directional_factor*u_lighting_ambient_color;vec3 directional_contrib=u_lighting_directional_color*dir_factor;return linearProduct(color,ambient_contrib+directional_contrib);}vec4 apply_lighting(vec4 color,vec3 normal,float dir_factor) {return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting(vec3 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return apply_lighting(color.rgb,normal,dir_factor);}vec4 apply_lighting(vec4 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting_ground(vec3 color) {return color*u_ground_radiance;}vec4 apply_lighting_ground(vec4 color) {return vec4(apply_lighting_ground(color.rgb),color.a);}float calculate_NdotL(vec3 normal) {const float ext=0.70710678118;return (clamp(dot(normal,u_lighting_directional_dir),-ext,1.0)+ext)/(1.0+ext);}vec4 apply_lighting_with_emission_ground(vec4 color,float emissive_strength) {return mix(apply_lighting_ground(color),color,emissive_strength);}vec3 compute_flood_lighting(vec3 flood_light_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=flood_light_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);float occlusion_ramp=smoothstep(0.0,0.2,1.0-occlusion);return mix(fully_occluded_color,flood_light_color,occlusion_ramp);}vec3 compute_emissive_draped(vec3 unlit_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=unlit_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);return mix(fully_occluded_color,unlit_color,1.0-occlusion);}\n#endif//LIGHTING_3D_MODE"},PE={};BE("",ME),BE(SE,AE),BE(CE,IE);const RE=BE("\n#if __VERSION__ >=300\n#define varying in\n#define gl_FragColor glFragColor\n#define texture2D texture\n#define textureCube texture\nout vec4 glFragColor;\n#endif\nhighp vec3 hash(highp vec2 p) {highp vec3 p3=fract(p.xyx*vec3(443.8975,397.2973,491.1871));p3+=dot(p3,p3.yxz+19.19);return fract((p3.xxy+p3.yzz)*p3.zyx);}vec3 dither(vec3 color,highp vec2 seed) {vec3 rnd=hash(seed)+hash(seed+0.59374)-0.5;return color+rnd/255.0;}highp float unpack_depth(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}highp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}\n#ifdef INDICATOR_CUTOUT\nuniform vec2 u_indicator_cutout_centers;uniform vec4 u_indicator_cutout_params;\n#endif\nvec4 applyCutout(vec4 color) {\n#ifdef INDICATOR_CUTOUT\nfloat holeMinOpacity=u_indicator_cutout_params.x;float holeRadius=max(u_indicator_cutout_params.y,0.0);float holeAspectRatio=u_indicator_cutout_params.z;float fadeStart=u_indicator_cutout_params.w;float distA=distance(vec2(gl_FragCoord.x,gl_FragCoord.y*holeAspectRatio),vec2(u_indicator_cutout_centers[0],u_indicator_cutout_centers[1]*holeAspectRatio));return color*min(smoothstep(fadeStart,holeRadius,distA)+holeMinOpacity,1.0);\n#else\nreturn color;\n#endif\n}\n#ifdef RENDER_CUTOFF\nuniform highp vec4 u_cutoff_params;varying float v_cutoff_opacity;\n#endif","\n#if __VERSION__ >=300\n#define attribute in\n#define varying out\n#define texture2D texture\n#endif\nfloat wrap(float n,float min,float max) {float d=max-min;float w=mod(mod(n-min,d)+d,d)+min;return (w==min) ? max : w;}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {\n#ifndef PROJECTED_POS_ON_VIEWPORT\nfloat tiles=tile_id.z;vec2 mercator=(tile_anchor/EXTENT+tile_id.xy)/tiles;mercator-=mercator_center;mercator.x=wrap(mercator.x,-0.5,0.5);vec4 mercator_tile=vec4(mercator.xy*EXTENT,EXTENT/(2.0*PI),1.0);mercator_tile=matrix*mercator_tile;return mercator_tile.xyz;\n#else\nreturn vec3(0.0);\n#endif\n}vec3 mix_globe_mercator(vec3 globe,vec3 mercator,float t) {return mix(globe,mercator,t);}mat3 globe_mercator_surface_vectors(vec3 pos_normal,vec3 up_dir,float zoom_transition) {vec3 normal=zoom_transition==0.0 ? pos_normal : normalize(mix(pos_normal,up_dir,zoom_transition));vec3 xAxis=normalize(vec3(normal.z,0.0,-normal.x));vec3 yAxis=normalize(cross(normal,xAxis));return mat3(xAxis,yAxis,normal);}\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(\nunpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}\n#ifdef RENDER_CUTOFF\nuniform vec4 u_cutoff_params;varying float v_cutoff_opacity;\n#endif\nconst vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);//Normalized device coordinate that is not rendered."),LE=TE;var kE={background:BE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec4 u_color;uniform float u_opacity;\n#ifdef LIGHTING_3D_MODE\nvarying vec4 v_color;\n#endif\nvoid main() {vec4 out_color;\n#ifdef LIGHTING_3D_MODE\nout_color=v_color;\n#else\nout_color=u_color;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_lighting.glsl"\nattribute vec2 a_pos;uniform mat4 u_matrix;\n#ifdef LIGHTING_3D_MODE\nuniform mediump vec4 u_color;varying vec4 v_color;uniform float u_emissive_strength;\n#endif\nvoid main() {gl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef LIGHTING_3D_MODE\nv_color=apply_lighting_with_emission_ground(u_color,u_emissive_strength);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),backgroundPattern:BE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_pattern_tl;uniform vec2 u_pattern_br;uniform vec2 u_texsize;uniform float u_opacity;uniform float u_emissive_strength;uniform sampler2D u_image;varying vec2 v_pos;void main() {vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(u_pattern_tl/u_texsize,u_pattern_br/u_texsize,imagecoord);vec4 out_color=texture2D(u_image,pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pattern_size;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_pattern_size,u_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),circle:BE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nvarying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nuniform float u_emissive_strength;void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(\nantialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)\n);vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_apply_premultiplied(out_color,v_fog_pos);\n#endif\ngl_FragColor=out_color*(v_visibility*opacity_t);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#define NUM_VISIBILITY_RINGS 2\n#define INV_SQRT2 0.70710678\n#define ELEVATION_BIAS 0.0001\n#define NUM_SAMPLES_PER_RING 16\nuniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nvarying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1,-1),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1,-1),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1,1),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1,1),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) {\n#if defined(TERRAIN)\nreturn elevation(pos)+ELEVATION_BIAS;\n#else\nreturn 0.0;\n#endif\n}vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale,mat3 surface_vectors) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale);\n#ifdef PITCH_WITH_MAP\n#ifdef PROJECTION_GLOBE_VIEW\nreturn u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) );\n#else\nreturn u_matrix*( world_center+vec4(sample_offset,0,0) );\n#endif\n#else\nreturn projected_center+vec4(sample_offset,0,0);\n#endif\n}float get_sample_step() {\n#ifdef PITCH_WITH_MAP\nreturn 2.0*PI/float(NUM_SAMPLES_PER_RING);\n#else\nreturn PI/float(NUM_SAMPLES_PER_RING);\n#endif\n}void main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);vec4 world_center;mat3 surface_vectors;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=a_pos_normal_3/16384.0;surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*circle_elevation(circle_center);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*circle_elevation(circle_center);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);world_center=vec4(pos,1);\n#else \nsurface_vectors=mat3(1.0);float height=circle_elevation(circle_center);world_center=vec4(circle_center,height,1);\n#endif\nvec4 projected_center=u_matrix*world_center;float view_scale=0.0;\n#ifdef PITCH_WITH_MAP\n#ifdef SCALE_WITH_MAP\nview_scale=1.0;\n#else\nview_scale=projected_center.w/u_camera_to_center_distance;\n#endif\n#else\n#ifdef SCALE_WITH_MAP\nview_scale=u_camera_to_center_distance;\n#else\nview_scale=projected_center.w;\n#endif\n#endif\ngl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0;\n#ifdef TERRAIN\nfloat step=get_sample_step();vec4 occlusion_world_center;vec4 occlusion_projected_center;\n#ifdef PITCH_WITH_MAP\nfloat cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);occlusion_world_center=vec4(circle_center,cantilevered_height,1);occlusion_projected_center=u_matrix*occlusion_world_center;\n#else\nocclusion_world_center=world_center;occlusion_projected_center=projected_center;\n#endif\nfor(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,surface_vectors);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING);\n#else\nvisibility=1.0;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nvisibility=1.0;\n#endif\nv_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);\n#ifdef FOG\nv_fog_pos=fog_position(world_center.xyz);\n#endif\n}'),clippingMask:BE("void main() {gl_FragColor=vec4(1.0);}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:BE('#include "_prelude_fog.fragment.glsl"\nuniform highp float u_intensity;varying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0);\n#ifdef FOG\nif (u_is_globe==0) {gl_FragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);}\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nvarying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 unscaled_extrude=vec2(mod(a_pos,2.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 tilePos=floor(a_pos*0.5);vec3 pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(tilePos)*elevation(tilePos);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#else\npos=vec3(tilePos+extrude,elevation(tilePos));\n#endif\ngl_Position=u_matrix*vec4(pos,1);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),heatmapTexture:BE("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main() {float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(0.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}","attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=a_pos*0.5+0.5;}"),collisionBox:BE("varying float v_placed;varying float v_notUsed;void main() {vec4 red =vec4(1.0,0.0,0.0,1.0);vec4 blue=vec4(0.0,0.0,1.0,0.5);gl_FragColor =mix(red,blue,step(0.5,v_placed))*0.5;gl_FragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}",'#include "_prelude_terrain.vertex.glsl"\nattribute vec3 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;attribute float a_size_scale;attribute vec2 a_padding;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;varying float v_placed;varying float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_pos+elevationVector(a_anchor_pos)*elevation(a_anchor_pos),1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,1.5);gl_Position=projectedPoint;gl_Position.xy+=(a_extrude*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}'),collisionCircle:BE("varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);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);gl_FragColor=color*alpha*opacity_t;}","attribute vec2 a_pos_2f;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos_2f;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(\nmix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:BE("uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}",'#include "_prelude_terrain.vertex.glsl"\nattribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;\n#endif\nvarying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {float h=elevation(a_pos);v_uv=a_pos/8192.0;\n#ifdef PROJECTION_GLOBE_VIEW\ngl_Position=u_matrix*vec4(a_pos_3+elevationVector(a_pos)*h,1);\n#else\ngl_Position=u_matrix*vec4(a_pos*u_overlay_scale,h,1);\n#endif\n}'),fill:BE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nuniform float u_emissive_strength;void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nvec4 out_color=color;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nattribute vec2 a_pos;uniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillOutline:BE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nvarying vec2 v_pos;uniform float u_emissive_strength;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nattribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillOutlinePattern:BE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_emissive_strength;varying vec2 v_pos;varying vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);float dist=length(v_pos_world-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=texture2D(u_image,pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos;varying vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);v_pos_world=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillPattern:BE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;varying vec2 v_pos;uniform float u_emissive_strength;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec4 out_color=texture2D(u_image,pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillExtrusion:BE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nvarying vec4 v_color;\n#ifdef RENDER_SHADOWS\nvarying highp vec4 v_pos_light_view_0;varying highp vec4 v_pos_light_view_1;varying float v_depth;\n#endif\nuniform lowp float u_opacity;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;varying vec2 v_ao;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nvarying vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nvarying highp vec3 v_normal;\n#endif\nuniform vec3 u_flood_light_color;uniform highp float u_vertical_scale;uniform float u_flood_light_intensity;uniform vec3 u_ground_shadow_factor;\n#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)\nvarying float v_flood_radius;varying float v_has_floodlight;\n#endif\nvarying float v_height;void main() {\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nvec3 normal=normalize(v_normal);\n#endif\nfloat z;vec4 color=v_color;\n#ifdef ZERO_ROOF_RADIUS\nz=float(normal.z > 0.00001);\n#ifdef LIGHTING_3D_MODE\nnormal=mix(normal,vec3(0.0,0.0,1.0),z);\n#else\ncolor=mix(v_color,v_roof_color,z);\n#endif\n#endif\nfloat h=max(0.0,v_height);float ao_shade=1.0;\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h_floors=h/(u_ao[1]*u_vertical_scale);float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);ao_shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;\n#ifdef ZERO_ROOF_RADIUS\nconcave*=(1.0-z);\n#endif\nfloat x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);ao_shade*=mix(1.0,x_shade*x_shade*x_shade,concave);\n#ifdef LIGHTING_3D_MODE\n#ifdef FLOOD_LIGHT\ncolor.rgb*=mix(ao_shade,1.0,v_has_floodlight);\n#else\ncolor.rgb*=ao_shade;\n#endif\n#else\ncolor.rgb*=ao_shade;\n#endif\n#endif\n#ifdef LIGHTING_3D_MODE\nfloat flood_radiance=0.0;\n#ifdef FLOOD_LIGHT\nflood_radiance=(1.0-min(h/v_flood_radius,1.0))*u_flood_light_intensity*v_has_floodlight;\n#endif\n#ifdef RENDER_SHADOWS\n#ifdef FLOOD_LIGHT\nfloat ndotl_unclamped=dot(normal,u_shadow_direction);float ndotl=max(0.0,ndotl_unclamped);float occlusion=ndotl_unclamped < 0.0 ? 1.0 : shadow_occlusion(ndotl,v_pos_light_view_0,v_pos_light_view_1,v_depth);vec3 litColor=apply_lighting(color.rgb,normal,(1.0-u_shadow_intensity*occlusion)*ndotl);vec3 floodLitColor=compute_flood_lighting(u_flood_light_color*u_opacity,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=mix(litColor,floodLitColor,flood_radiance);\n#else\nfloat shadowed_lighting_factor=shadowed_light_factor_normal(normal,v_pos_light_view_0,v_pos_light_view_1,v_depth);color.rgb=apply_lighting(color.rgb,normal,shadowed_lighting_factor);\n#endif\n#else\ncolor.rgb=apply_lighting(color.rgb,normal);\n#ifdef FLOOD_LIGHT\ncolor.rgb=mix(color.rgb,u_flood_light_color*u_opacity,flood_radiance);\n#endif\n#endif\ncolor*=u_opacity;\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos,h));\n#endif\n#ifdef RENDER_CUTOFF\ncolor*=v_cutoff_opacity;\n#endif\n#ifdef INDICATOR_CUTOUT\ncolor=applyCutout(color);\n#endif\ngl_FragColor=color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#include "_prelude_lighting.glsl"\n#if __VERSION__ >=300\n#ifdef RENDER_CUTOFF\ninvariant gl_Position;\n#endif\n#endif\nuniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_edge_radius;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\nuniform highp float u_vertical_scale;varying vec4 v_color;\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;varying highp vec4 v_pos_light_view_0;varying highp vec4 v_pos_light_view_1;varying float v_depth;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nvarying vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nvarying highp vec3 v_normal;\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;varying vec2 v_ao;\n#endif\n#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)\nvarying float v_flood_radius;varying float v_has_floodlight;\n#endif\nvarying float v_height;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define highp float flood_light_wall_radius\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize highp float flood_light_wall_radius\nbase*=u_vertical_scale;height*=u_vertical_scale;vec4 pos_nx=floor(a_pos_normal_ed*0.5);vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nv_normal=normal;\n#endif\nbase=max(0.0,base);height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\nfloat ele=0.0;float h=0.0;float c_ele;vec3 pos;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);pos=vec3(pos_nx.xy,h);\n#else\nh=t > 0.0 ? height : base;pos=vec3(pos_nx.xy,h);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*h);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);h=h-ele;v_height=h;\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=pos;vec3 shd_pos1=pos;\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(normal);shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\nfloat NdotL=0.0;float colorvalue=0.0;\n#ifndef LIGHTING_3D_MODE\ncolorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),NdotL);if (normal.y !=0.0) {float r=0.84;r=mix(0.7,0.98,1.0-u_lightintensity);NdotL*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}\n#endif\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec2(mix(concave,-concave,start),y_ground);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\n#ifdef LIGHTING_3D_MODE\n#ifdef FLOOD_LIGHT\nfloat is_wall=1.0-float(t > 0.0 && top_up_ny.y > 0.0);v_has_floodlight=float(flood_light_wall_radius > 0.0 && is_wall > 0.0);v_flood_radius=flood_light_wall_radius*u_vertical_scale;\n#endif\nv_color=vec4(color.rgb,1.0);\n#else\nv_color=vec4(0.0,0.0,0.0,1.0);v_color.rgb+=clamp(color.rgb*NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nfloat roofNdotL=clamp(u_lightpos.z,0.0,1.0);roofNdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),roofNdotL);v_roof_color=vec4(0.0,0.0,0.0,1.0);v_roof_color.rgb+=clamp(color.rgb*roofNdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_roof_color*=u_opacity;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n}'),fillExtrusionDepth:BE("varying highp float v_depth;void main() {\n#ifndef DEPTH_TEXTURE\ngl_FragColor=pack_depth(v_depth);\n#endif\n}",'#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_edge_radius;uniform float u_vertical_scale;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\nvarying highp float v_depth;void main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\nbase*=u_vertical_scale;height*=u_vertical_scale;vec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;base=max(0.0,base);height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\nvec3 pos;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base);pos=vec3(pos_nx.xy,h);\n#else\npos=vec3(pos_nx.xy,t > 0.0 ? height : base);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);v_depth=gl_Position.z/gl_Position.w;}'),fillExtrusionPattern:BE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;varying vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nvarying vec3 v_normal;\n#endif\nvarying vec2 v_pos;varying vec4 v_lighting;uniform lowp float u_opacity;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define mediump vec4 pattern\n#pragma mapbox: define highp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize highp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec4 out_color=texture2D(u_image,pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color,normalize(v_normal))*u_opacity;\n#else\nout_color=out_color*v_lighting;\n#endif\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);out_color.rgb=out_color.rgb*shade;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color);\n#endif\ngl_FragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_lighting.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform float u_tile_units_to_pixels;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\nvarying vec2 v_pos;varying vec4 v_lighting;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;varying vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nvarying vec3 v_normal;\n#endif\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define mediump vec4 pattern\n#pragma mapbox: define highp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize highp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec4 pos_nx=floor(a_pos_normal_ed*0.5);mediump vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;mediump vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=a_pos_normal_ed.w;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\nfloat ele=0.0;float h=z;vec3 p;float c_ele;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);p=vec3(pos_nx.xy,h);\n#else\np=vec3(pos_nx.xy,z);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);vec2 pos=normal.z==1.0\n? pos_nx.xy\n: vec2(edgedistance,z*u_height_factor);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float NdotL=0.0;\n#ifdef LIGHTING_3D_MODE\nNdotL=calculate_NdotL(normal);\n#else\nNdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),NdotL);\n#endif\nif (normal.y !=0.0) {float r=0.84;\n#ifndef LIGHTING_3D_MODE\nr=mix(0.7,0.98,1.0-u_lightintensity);\n#endif\nNdotL*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\n#ifdef LIGHTING_3D_MODE\nv_normal=normal;\n#else\nv_lighting.rgb+=clamp(NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;\n#endif \n#ifdef FOG\nv_fog_pos=fog_position(p);\n#endif\n}'),groundShadow:BE('#include "_prelude_shadow.fragment.glsl"\n#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec3 u_ground_shadow_factor;varying vec4 v_pos_light_view_0;varying vec4 v_pos_light_view_1;varying float v_depth;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\nvoid main() {float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);vec3 shadow=mix(u_ground_shadow_factor,vec3(1.0),light);\n#ifdef RENDER_CUTOFF\nshadow=mix(vec3(1.0),shadow,cutoff_opacity(u_cutoff_params,v_depth));\n#endif\n#ifdef FOG\nshadow=mix(shadow,vec3(1.0),v_fog_opacity);\n#endif\n#ifdef INDICATOR_CUTOUT\nshadow=mix(shadow,vec3(1.0),1.0-applyCutout(vec4(1.0)).r);\n#endif\ngl_FragColor=vec4(shadow,1.0);}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;attribute vec2 a_pos;varying vec4 v_pos_light_view_0;varying vec4 v_pos_light_view_1;varying float v_depth;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\nvoid main() {gl_Position=u_matrix*vec4(a_pos,0.0,1.0);v_pos_light_view_0=u_light_matrix_0*vec4(a_pos,0.0,1.0);v_pos_light_view_1=u_light_matrix_1*vec4(a_pos,0.0,1.0);v_depth=gl_Position.w;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);v_fog_opacity=fog(v_fog_pos);\n#endif\n}'),fillExtrusionGroundEffect:BE("uniform highp float u_ao_pass;uniform highp float u_opacity;uniform highp float u_flood_light_intensity;uniform highp vec3 u_flood_light_color;uniform highp float u_attenuation;uniform sampler2D u_fb;uniform float u_fb_size;\n#ifdef SDF_SUBPASS\nvarying highp vec2 v_pos;varying highp vec4 v_line_segment;varying highp float v_flood_light_radius_tile;varying highp vec2 v_ao;float line_df(highp vec2 a,highp vec2 b,highp vec2 p) {highp vec2 ba=b-a;highp vec2 pa=p-a;highp float r=clamp(dot(pa,ba)/dot(ba,ba),0.0,1.0);return length(pa-r*ba);}\n#ifdef FOG\nvarying highp float v_fog;\n#endif\n#endif\nvoid main() {\n#ifdef CLEAR_SUBPASS\nvec4 color=vec4(1.0);\n#ifdef CLEAR_FROM_TEXTURE\ncolor=texture2D(u_fb,gl_FragCoord.xy/vec2(u_fb_size));\n#endif\ngl_FragColor=color;\n#else\n#ifdef SDF_SUBPASS\nhighp float d=line_df(v_line_segment.xy,v_line_segment.zw,v_pos);highp float effect_radius=mix(v_flood_light_radius_tile,v_ao.y,u_ao_pass);d/=effect_radius;d=min(d,1.0);d=1.0-pow(1.0-d,u_attenuation);highp float effect_intensity=mix(u_flood_light_intensity,v_ao.x,u_ao_pass);highp float fog=1.0;\n#ifdef FOG\nfog=v_fog;\n#endif\n#ifdef RENDER_CUTOFF\nfog*=v_cutoff_opacity;\n#endif\ngl_FragColor=vec4(vec3(0.0),mix(1.0,d,effect_intensity*u_opacity*fog));\n#else\nvec4 color=mix(vec4(u_flood_light_color,1.0),vec4(vec3(0.0),1.0),u_ao_pass);\n#ifdef OVERDRAW_INSPECTOR\ncolor=vec4(1.0);\n#endif\ngl_FragColor=color;HANDLE_WIREFRAME_DEBUG;\n#endif\n#endif\n}",'#include "_prelude_fog.vertex.glsl"\nattribute highp vec4 a_pos_end;attribute highp float a_angular_offset_factor;attribute highp float a_hidden_by_landmark;\n#ifdef SDF_SUBPASS\nvarying highp vec2 v_pos;varying highp vec4 v_line_segment;varying highp float v_flood_light_radius_tile;varying highp vec2 v_ao;\n#ifdef FOG\nvarying highp float v_fog;\n#endif\n#endif\nuniform highp float u_flood_light_intensity;uniform highp mat4 u_matrix;uniform highp float u_ao_pass;uniform highp float u_meter_to_tile;uniform highp float u_edge_radius;uniform highp vec2 u_ao;\n#pragma mapbox: define highp float flood_light_ground_radius\nconst float TANGENT_CUTOFF=4.0;const float NORM=32767.0;void main() {\n#pragma mapbox: initialize highp float flood_light_ground_radius\nvec2 p=a_pos_end.xy;vec2 q=floor(a_pos_end.zw*0.5);vec2 start_bottom=a_pos_end.zw-q*2.0;float fl_ground_radius=flood_light_ground_radius;\n#ifdef FORCE_ABS_FL_GROUND_RADIUS\nfl_ground_radius=abs(flood_light_ground_radius);\n#endif\nfloat flood_radius_tile=fl_ground_radius*u_meter_to_tile;vec2 v=normalize(q-p);float ao_radius=u_ao.y/3.5;float effect_radius=mix(flood_radius_tile,ao_radius,u_ao_pass)+u_edge_radius;float angular_offset_factor=a_angular_offset_factor/NORM*TANGENT_CUTOFF;float angular_offset=angular_offset_factor*effect_radius;float top=1.0-start_bottom.y;float side=(0.5-start_bottom.x)*2.0;vec2 extrusion_parallel=v*side*mix(1.0,angular_offset,top);vec2 perp=vec2(v.y,-v.x);vec2 extrusion_perp=perp*effect_radius*top;vec3 pos=vec3(mix(q,p,start_bottom.x),0.0);pos.xy+=extrusion_parallel+extrusion_perp;\n#ifdef SDF_SUBPASS\nv_pos=pos.xy;v_line_segment=vec4(p,q)+perp.xyxy*u_edge_radius;v_flood_light_radius_tile=flood_radius_tile;v_ao=vec2(u_ao.x,ao_radius);\n#ifdef FOG\nv_fog_pos=fog_position(pos);v_fog=1.0-fog(v_fog_pos);\n#endif\n#endif\nfloat hidden_by_landmark=0.0;\n#ifdef HAS_CENTROID\nhidden_by_landmark=a_hidden_by_landmark;\n#endif\nfloat isFloodlit=float(fl_ground_radius > 0.0 && u_flood_light_intensity > 0.0);float hidden=mix(1.0-isFloodlit,isFloodlit,u_ao_pass);hidden+=hidden_by_landmark;gl_Position=mix(u_matrix*vec4(pos,1.0),AWAY,float(hidden > 0.0));\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n}'),hillshadePrepare:BE("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nreturn texture(u_image,coord).r/4.0;\n#else\nvec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;\n#endif\n}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y));float b=getElevation(v_pos+vec2(0,-epsilon.y));float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y));float d=getElevation(v_pos+vec2(-epsilon.x,0));float e=getElevation(v_pos+vec2(epsilon.x,0));float f=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float g=getElevation(v_pos+vec2(0,epsilon.y));float h=getElevation(v_pos+vec2(epsilon.x,epsilon.y));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(\n(c+e+e+h)-(a+d+d+f),(f+g+g+h)-(a+b+b+c)\n)/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(\nderiv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);}","uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying 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:BE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;uniform float u_emissive_strength;void main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;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_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef LIGHTING_3D_MODE\ngl_FragColor=apply_lighting_with_emission_ground(gl_FragColor,u_emissive_strength);\n#endif\n#ifdef FOG\ngl_FragColor=fog_dither(fog_apply_premultiplied(gl_FragColor,v_fog_pos));\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),line:BE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec4 v_uv;\n#ifdef RENDER_LINE_DASH\nuniform sampler2D u_dash_image;varying vec2 v_tex;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;\n#endif\nfloat luminance(vec3 c) {return (c.r+c.r+c.b+c.g+c.g+c.g)*0.1667;}uniform float u_emissive_strength;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\nfloat linearstep(float edge0,float edge1,float x) {return clamp((x-edge0)/(edge1-edge0),0.0,1.0);}void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);\n#ifdef RENDER_LINE_DASH\nfloat sdfdist=texture2D(u_dash_image,v_tex).a;float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/dash.z;alpha*=linearstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);\n#endif\nhighp vec4 out_color;\n#ifdef RENDER_LINE_GRADIENT\nout_color=texture2D(u_gradient_image,v_uv.xy);\n#else\nout_color=color;\n#endif\nfloat trimmed=1.0;\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float start=v_uv[2];highp float end=v_uv[3];highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=(start+(v_uv.x)*(end-start));if (trim_end > trim_start) {if (line_progress <=trim_end && line_progress >=trim_start) {out_color=vec4(0,0,0,0);trimmed=0.0;}}\n#endif\nif (u_alpha_discard_threshold !=0.0) {if (alpha < u_alpha_discard_threshold) {discard;}}\n#ifdef RENDER_LINE_BORDER\nfloat edgeBlur=(border_width+1.0/u_device_pixel_ratio);float alpha2=clamp(min(dist-(v_width2.t-edgeBlur),v_width2.s-dist)/edgeBlur,0.0,1.0);if (alpha2 < 1.) {float smoothAlpha=smoothstep(0.6,1.0,alpha2);if (border_color.a==0.0) { \nfloat Y=(out_color.a > 0.01) ? luminance(out_color.rgb/out_color.a) : 1.;float adjustment=(Y > 0.) ? 0.5/Y : 0.45;if (out_color.a > 0.25 && Y < 0.25) {vec3 borderColor=(Y > 0.) ? out_color.rgb : vec3(1,1,1)*out_color.a;out_color.rgb=out_color.rgb+borderColor*(adjustment*(1.0-smoothAlpha));} else {out_color.rgb*=(0.6 +0.4*smoothAlpha);}} else {out_color.rgb=mix(border_color.rgb*border_color.a*trimmed,out_color.rgb,smoothAlpha);}}\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nout_color*=(alpha*opacity);\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color);\n#endif\ngl_FragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#define EXTRUDE_SCALE 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nattribute highp vec4 a_packed;\n#endif\n#ifdef RENDER_LINE_DASH\nattribute float a_linesofar;\n#endif\nuniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp vec4 v_uv;\n#ifdef RENDER_LINE_DASH\nuniform vec2 u_texsize;uniform float u_tile_units_to_pixels;varying vec2 v_tex;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform float u_image_height;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;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*EXTRUDE_SCALE;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*EXTRUDE_SCALE*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nfloat a_uv_x=a_packed[0];float a_split_index=a_packed[1];highp float a_clip_start=a_packed[2];highp float a_clip_end=a_packed[3];\n#ifdef RENDER_LINE_GRADIENT\nhighp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec4(a_uv_x,a_split_index*texel_height-half_texel_height,a_clip_start,a_clip_end);\n#else\nv_uv=vec4(a_uv_x,0.0,a_clip_start,a_clip_end);\n#endif\n#endif\n#ifdef RENDER_LINE_DASH\nfloat scale=dash.z==0.0 ? 0.0 : u_tile_units_to_pixels/dash.z;float height=dash.y;v_tex=vec2(a_linesofar*scale/floorwidth,(-normal.y*height+dash.x+0.5)/u_texsize.y);\n#endif\nv_width2=vec2(outset,inset);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),linePattern:BE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_tile_units_to_pixels;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;vec2 pattern_size=vec2(display_size.x/u_tile_units_to_pixels,display_size.y);float aspect=display_size.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=mod(v_linesofar/pattern_size.x*aspect,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(x,y));vec4 color=texture2D(u_image,pos);\n#ifdef LIGHTING_3D_MODE\ncolor=apply_lighting_ground(color);\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ncolor*=(alpha*opacity);\n#ifdef INDICATOR_CUTOUT\ncolor=applyCutout(color);\n#endif\ngl_FragColor=color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_linesofar;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;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);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),raster:BE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying 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;\n#ifdef RASTER_COLOR\nuniform sampler2D u_color_ramp;uniform highp vec2 u_colorization_scale;uniform highp vec4 u_colorization_mix;highp vec4 colormap (highp float value) {highp float scaled_value=value*u_colorization_scale.y+u_colorization_scale.x;highp vec2 coords=vec2(scaled_value,0.5);return texture2D(u_color_ramp,coords);}\n#endif\nvoid main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);vec4 color;\n#ifdef RASTER_COLOR\nhighp vec4 fadedColor=mix(color0,color1,u_fade_t);color=colormap(dot(vec4(fadedColor.rgb,1),u_colorization_mix));color.a*=fadedColor.a;if (color.a > 0.0) {color.rgb/=color.a;}\n#else\nif (color0.a > 0.0) {color0.rgb/=color0.a;}if (color1.a > 0.0) {color1.rgb/=color1.a;}color=mix(color0,color1,u_fade_t);\n#endif\ncolor.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(\ndot(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);vec3 out_color=mix(u_high_vec,u_low_vec,rgb);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_ground(out_color);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply(out_color,v_fog_pos));\n#endif\ngl_FragColor=vec4(out_color*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_globe_pos;attribute vec2 a_uv;\n#else\nattribute vec2 a_pos;attribute vec2 a_texture_pos;\n#endif\nvarying vec2 v_pos0;varying vec2 v_pos1;void main() {vec2 uv;\n#ifdef PROJECTION_GLOBE_VIEW\ngl_Position=u_matrix*u_globe_matrix*vec4(a_globe_pos,1.0);uv=a_uv;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(a_globe_pos,1.0)).xyz);\n#endif\n#else\nfloat w=1.0+dot(a_texture_pos,u_perspective_transform);gl_Position=u_matrix*vec4(a_pos*w,0,w);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\nuv=a_texture_pos/8192.0;\n#endif\nv_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}'),symbolIcon:BE('#include "_prelude_lighting.glsl"\nuniform sampler2D u_texture;\n#ifdef ICON_TRANSITION\nuniform float u_icon_transition;\n#endif\nvarying float v_fade_opacity;varying vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nvarying vec2 v_tex_b;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float emissive_strength\nlowp float alpha=opacity*v_fade_opacity;vec4 out_color;\n#ifdef ICON_TRANSITION\nvec4 a=texture2D(u_texture,v_tex_a)*(1.0-u_icon_transition);vec4 b=texture2D(u_texture,v_tex_b)*u_icon_transition;out_color=(a+b)*alpha;\n#else\nout_color=texture2D(u_texture,v_tex_a)*alpha;\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#endif\ngl_FragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\nattribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_projected_pos;attribute float a_fade_opacity;\n#ifdef Z_OFFSET\nattribute float a_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;\n#endif\n#ifdef ICON_TRANSITION\nattribute vec2 a_texb;\n#endif\nuniform 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 bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;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 vec3 u_up_vector;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nvarying vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nvarying vec2 v_tex_b;\n#endif\nvarying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float emissive_strength\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_min_font_scale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[3];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 tile_anchor=a_pos;float e=elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjected_point;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetProjected_point=u_matrix*vec4(a_globe_anchor+displacement,1);\n#else\noffsetProjected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);\n#endif\nvec2 a=projected_point.xy/projected_point.w;vec2 b=offsetProjected_point.xy/offsetProjected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp 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);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_min_font_scale,font_scale)+a_pxoffset/16.0);\n#ifdef TERRAIN\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nvec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float out_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change))*projection_transition_fade;float alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,hidden);\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,hidden);\n#endif\nv_tex_a=a_tex/u_texsize;\n#ifdef ICON_TRANSITION\nv_tex_b=a_texb/u_texsize;\n#endif\nv_fade_opacity=out_fade_opacity;}'),symbolSDF:BE('#include "_prelude_lighting.glsl"\n#define SDF_PX 8.0\nuniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;uniform bool u_is_halo;\n#if __VERSION__ >=300\nflat varying float v_draw_halo;\n#endif\nvarying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\n#pragma mapbox: initialize lowp float emissive_strength\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float 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 buff=(256.0-64.0)/256.0;bool draw_halo;\n#if __VERSION__ >=300\ndraw_halo=v_draw_halo > 0.0;\n#else\ndraw_halo=u_is_halo;\n#endif\nif (draw_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=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);vec4 out_color=color*(alpha*opacity*fade_opacity);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#endif\ngl_FragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\nattribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_projected_pos;attribute float a_fade_opacity;\n#ifdef Z_OFFSET\nattribute float a_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;\n#endif\nuniform 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_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;uniform bool u_is_halo;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\n#if __VERSION__ >=300\nflat varying float v_draw_halo;\n#endif\nvarying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\n#pragma mapbox: initialize lowp float emissive_strength\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;highp float segment_angle=-a_projected_pos[3];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 tile_anchor=a_pos;float e=elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetprojected_point;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetprojected_point=u_matrix*vec4(a_globe_anchor+displacement,1);\n#else\noffsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);\n#endif\nvec2 a=projected_point.xy/projected_point.w;vec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp 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);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset);\n#ifdef TERRAIN\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nvec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));float out_fade_opacity=interpolated_fade_opacity*projection_transition_fade;float alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,hidden);\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,hidden);\n#endif\nfloat gamma_scale=gl_Position.w;\n#if __VERSION__ >=300\nv_draw_halo=(u_is_halo && float(gl_InstanceID)==0.0) ? 1.0 : 0.0;\n#endif\nv_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,out_fade_opacity);}'),symbolTextAndIcon:BE('#include "_prelude_lighting.glsl"\n#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_halo;\n#if __VERSION__ >=300\nflat varying float v_draw_halo;\n#endif\nvarying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\n#pragma mapbox: initialize lowp float emissive_strength\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;bool draw_halo;\n#if __VERSION__ >=300\ndraw_halo=v_draw_halo > 0.0;\n#else\ndraw_halo=u_is_halo;\n#endif\nif (draw_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=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);vec4 out_color=color*(alpha*opacity*fade_opacity);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#endif\ngl_FragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\nattribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_projected_pos;attribute float a_fade_opacity;\n#ifdef Z_OFFSET\nattribute float a_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;\n#endif\nuniform 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_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;uniform vec2 u_texsize_icon;uniform bool u_is_halo;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\n#if __VERSION__ >=300\nflat varying float v_draw_halo;\n#endif\nvarying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\n#pragma mapbox: initialize lowp float emissive_strength\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;highp float segment_angle=-a_projected_pos[3];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 tile_anchor=a_pos;float e=elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offset_projected_point=u_matrix*vec4(a_pos+vec2(1,0),0,1);vec2 a=projected_point.xy/projected_point.w;vec2 b=offset_projected_point.xy/offset_projected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp 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);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*font_scale);\n#ifdef TERRAIN\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nfloat out_fade_opacity=interpolated_fade_opacity*projection_transition_fade;float alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,hidden);\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,hidden);\n#endif\nfloat gamma_scale=gl_Position.w;\n#if __VERSION__ >=300\nv_draw_halo=(u_is_halo && float(gl_InstanceID)==0.0) ? 1.0 : 0.0;\n#endif\nv_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,out_fade_opacity,is_sdf);}'),terrainRaster:BE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image0;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nvarying vec4 v_pos_light_view_0;varying vec4 v_pos_light_view_1;varying float v_depth;\n#endif\nuniform vec3 u_ground_shadow_factor;void main() {vec4 image_color=texture2D(u_image0,v_pos0);vec4 color;\n#ifdef LIGHTING_3D_MODE\nconst vec3 normal=vec3(0.0,0.0,1.0);\n#ifdef RENDER_SHADOWS\nfloat cutoffOpacity=1.0;\n#ifdef RENDER_CUTOFF\ncutoffOpacity=cutoff_opacity(u_cutoff_params,v_depth);\n#endif\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nvec3 unlit_base=image_color.rgb*(1.0-image_color.a);vec3 emissive_base=image_color.rgb*image_color.a;float ndotl=u_shadow_direction.z;float occlusion=ndotl < 0.0 ? 1.0 : shadow_occlusion(v_pos_light_view_0,v_pos_light_view_1,v_depth,0.0);ndotl=max(0.0,ndotl);vec3 lit=apply_lighting(unlit_base,normal,mix(1.0,(1.0-(u_shadow_intensity*occlusion))*ndotl,cutoffOpacity));vec3 emissive=compute_emissive_draped(emissive_base,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=lit+emissive;color.a=1.0;\n#else\nfloat lighting_factor=shadowed_light_factor_normal_unbiased(normal,v_pos_light_view_0,v_pos_light_view_1,v_depth);color=apply_lighting(image_color,normal,mix(1.0,lighting_factor,cutoffOpacity));\n#endif\n#else\nfloat lighting_factor=u_lighting_directional_dir.z;color=apply_lighting(image_color,normal,lighting_factor);\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\ncolor.rgb=mix(color.rgb,image_color.rgb,image_color.a);color.a=1.0;\n#endif\n#endif\n#else\ncolor=image_color;\n#endif\n#ifdef FOG\n#ifdef ZERO_EXAGGERATION\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#else\ncolor=fog_dither(fog_apply_from_vert(color,v_fog_opacity));\n#endif\n#endif\ngl_FragColor=color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_skirt_height;attribute vec2 a_pos;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;varying vec4 v_pos_light_view_0;varying vec4 v_pos_light_view_1;varying float v_depth;\n#endif\nvoid main() {vec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;vec2 decodedPos=decomposedPosAndSkirt.xy;float elevation=elevation(decodedPos)-skirt*u_skirt_height;v_pos0=decodedPos/8192.0;gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);\n#ifdef FOG\n#ifdef ZERO_EXAGGERATION\nv_fog_pos=fog_position(decodedPos);\n#else\nv_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));\n#endif\n#endif\n#ifdef RENDER_SHADOWS\nvec3 pos=vec3(decodedPos,elevation);v_pos_light_view_0=u_light_matrix_0*vec4(pos,1.);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1.);v_depth=gl_Position.w;\n#endif\n}'),terrainDepth:BE("#ifdef GL_ES\nprecision highp float;\n#endif\nvarying float v_depth;void main() {gl_FragColor=pack_depth(v_depth);}",'#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;attribute vec2 a_pos;varying float v_depth;void main() {float elevation=elevation(a_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}'),skybox:BE('#include "_prelude_fog.fragment.glsl"\nvarying lowp vec3 v_uv;uniform lowp samplerCube u_cubemap;uniform lowp float u_opacity;uniform highp float u_temporal_offset;uniform highp vec3 u_sun_direction;float sun_disk(highp vec3 ray_direction,highp vec3 sun_direction) {highp float cos_angle=dot(normalize(ray_direction),sun_direction);const highp float cos_sun_angular_diameter=0.99996192306;const highp float smoothstep_delta=1e-5;return smoothstep(\ncos_sun_angular_diameter-smoothstep_delta,cos_sun_angular_diameter+smoothstep_delta,cos_angle);}float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec3 uv=v_uv;const float y_bias=0.015;uv.y+=y_bias;uv.y=pow(abs(uv.y),1.0/5.0);uv.y=map(uv.y,0.0,1.0,-1.0,1.0);vec3 sky_color=textureCube(u_cubemap,uv).rgb;\n#ifdef FOG\nsky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color);\n#endif\nsky_color.rgb=dither(sky_color.rgb,gl_FragCoord.xy+u_temporal_offset);sky_color+=0.1*sun_disk(v_uv,u_sun_direction);gl_FragColor=vec4(sky_color*u_opacity,u_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}',EE),skyboxGradient:BE('#include "_prelude_fog.fragment.glsl"\nvarying highp vec3 v_uv;uniform lowp sampler2D u_color_ramp;uniform highp vec3 u_center_direction;uniform lowp float u_radius;uniform lowp float u_opacity;uniform highp float u_temporal_offset;void main() {float progress=acos(dot(normalize(v_uv),u_center_direction))/u_radius;vec4 color=texture2D(u_color_ramp,vec2(progress,0.5));\n#ifdef FOG\ncolor.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a;\n#endif\ncolor*=u_opacity;color.rgb=dither(color.rgb,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}',EE),skyboxCapture:BE("\nvarying highp vec3 v_position;uniform highp float u_sun_intensity;uniform highp float u_luminance;uniform lowp vec3 u_sun_direction;uniform highp vec4 u_color_tint_r;uniform highp vec4 u_color_tint_m;\n#ifdef GL_ES\nprecision highp float;\n#endif\n#define BETA_R vec3(5.5e-6,13.0e-6,22.4e-6)\n#define BETA_M vec3(21e-6,21e-6,21e-6)\n#define MIE_G 0.76\n#define DENSITY_HEIGHT_SCALE_R 8000.0\n#define DENSITY_HEIGHT_SCALE_M 1200.0\n#define PLANET_RADIUS 6360e3\n#define ATMOSPHERE_RADIUS 6420e3\n#define SAMPLE_STEPS 10\n#define DENSITY_STEPS 4\nfloat ray_sphere_exit(vec3 orig,vec3 dir,float radius) {float a=dot(dir,dir);float b=2.0*dot(dir,orig);float c=dot(orig,orig)-radius*radius;float d=sqrt(b*b-4.0*a*c);return (-b+d)/(2.0*a);}vec3 extinction(vec2 density) {return exp(-vec3(BETA_R*u_color_tint_r.a*density.x+BETA_M*u_color_tint_m.a*density.y));}vec2 local_density(vec3 point) {float height=max(length(point)-PLANET_RADIUS,0.0);float exp_r=exp(-height/DENSITY_HEIGHT_SCALE_R);float exp_m=exp(-height/DENSITY_HEIGHT_SCALE_M);return vec2(exp_r,exp_m);}float phase_ray(float cos_angle) {return (3.0/(16.0*PI))*(1.0+cos_angle*cos_angle);}float phase_mie(float cos_angle) {return (3.0/(8.0*PI))*((1.0-MIE_G*MIE_G)*(1.0+cos_angle*cos_angle))/((2.0+MIE_G*MIE_G)*pow(1.0+MIE_G*MIE_G-2.0*MIE_G*cos_angle,1.5));}vec2 density_to_atmosphere(vec3 point,vec3 light_dir) {float ray_len=ray_sphere_exit(point,light_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(DENSITY_STEPS);vec2 density_point_to_atmosphere=vec2(0.0);for (int i=0; i < DENSITY_STEPS;++i) {vec3 point_on_ray=point+light_dir*((float(i)+0.5)*step_len);density_point_to_atmosphere+=local_density(point_on_ray)*step_len;;}return density_point_to_atmosphere;}vec3 atmosphere(vec3 ray_dir,vec3 sun_direction,float sun_intensity) {vec2 density_orig_to_point=vec2(0.0);vec3 scatter_r=vec3(0.0);vec3 scatter_m=vec3(0.0);vec3 origin=vec3(0.0,PLANET_RADIUS,0.0);float ray_len=ray_sphere_exit(origin,ray_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(SAMPLE_STEPS);for (int i=0; i < SAMPLE_STEPS;++i) {vec3 point_on_ray=origin+ray_dir*((float(i)+0.5)*step_len);vec2 density=local_density(point_on_ray)*step_len;density_orig_to_point+=density;vec2 density_point_to_atmosphere=density_to_atmosphere(point_on_ray,sun_direction);vec2 density_orig_to_atmosphere=density_orig_to_point+density_point_to_atmosphere;vec3 extinction=extinction(density_orig_to_atmosphere);scatter_r+=density.x*extinction;scatter_m+=density.y*extinction;}float cos_angle=dot(ray_dir,sun_direction);float phase_r=phase_ray(cos_angle);float phase_m=phase_mie(cos_angle);vec3 beta_r=BETA_R*u_color_tint_r.rgb*u_color_tint_r.a;vec3 beta_m=BETA_M*u_color_tint_m.rgb*u_color_tint_m.a;return (scatter_r*phase_r*beta_r+scatter_m*phase_m*beta_m)*sun_intensity;}const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;vec3 uncharted2_tonemap(vec3 x) {return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}void main() {vec3 ray_direction=v_position;ray_direction.y=pow(ray_direction.y,5.0);const float y_bias=0.015;ray_direction.y+=y_bias;vec3 color=atmosphere(normalize(ray_direction),u_sun_direction,u_sun_intensity);float white_scale=1.0748724675633854;color=uncharted2_tonemap((log2(2.0/pow(u_luminance,4.0)))*color)*white_scale;gl_FragColor=vec4(color,1.0);}","attribute highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;varying highp vec3 v_position;float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec4 pos=vec4(u_matrix_3f*a_pos_3f,1.0);v_position=pos.xyz;v_position.y*=-1.0;v_position.y=map(v_position.y,-1.0,1.0,0.0,1.0);gl_Position=vec4(a_pos_3f.xy,0.0,1.0);}"),globeRaster:BE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image0;varying vec2 v_pos0;\n#ifndef FOG\nuniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform vec2 u_viewport;\n#endif\nvoid main() {vec4 color;\n#ifdef CUSTOM_ANTIALIASING\nvec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);vec3 dir=normalize(ray_dir);vec3 closest_point=dot(u_globe_pos,dir)*dir;float norm_dist_from_center=1.0-length(closest_point-u_globe_pos)/u_globe_radius;const float antialias_pixel=2.0;float antialias_factor=antialias_pixel*fwidth(norm_dist_from_center);float antialias=smoothstep(0.0,antialias_factor,norm_dist_from_center);vec4 raster=texture2D(u_image0,v_pos0);\n#ifdef LIGHTING_3D_MODE\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nraster=apply_lighting_with_emission_ground(raster,raster.a);color=vec4(raster.rgb*antialias,antialias);\n#else\nraster=apply_lighting_ground(raster);color=vec4(raster.rgb*antialias,raster.a*antialias);\n#endif\n#else\ncolor=vec4(raster.rgb*antialias,raster.a*antialias);\n#endif\n#else\ncolor=texture2D(u_image0,v_pos0);\n#ifdef LIGHTING_3D_MODE\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\ncolor=apply_lighting_with_emission_ground(color,color.a);color.a=1.0;\n#else\ncolor=apply_lighting_ground(color);\n#endif\n#endif\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_proj_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;uniform mat3 u_grid_matrix;uniform float u_skirt_height;\n#ifdef GLOBE_POLES\nattribute vec3 a_globe_pos;attribute vec2 a_uv;\n#else\nattribute vec2 a_pos;\n#endif\nvarying vec2 v_pos0;float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(QUARTER_PI+lat/2.0*DEG_TO_RAD))))/360.0;}vec3 latLngToECEF(vec2 latLng) {latLng=DEG_TO_RAD*latLng;float cosLat=cos(latLng[0]);float sinLat=sin(latLng[0]);float cosLng=cos(latLng[1]);float sinLng=sin(latLng[1]);float sx=cosLat*sinLng*GLOBE_RADIUS;float sy=-sinLat*GLOBE_RADIUS;float sz=cosLat*cosLng*GLOBE_RADIUS;return vec3(sx,sy,sz);}void main() {\n#ifdef GLOBE_POLES\nvec3 globe_pos=a_globe_pos;vec2 uv=a_uv;\n#else\nfloat tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=mercatorX*tiles-idx;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY);\n#endif\nv_pos0=uv;vec2 tile_pos=uv*EXTENT;vec3 globe_derived_up_vector=normalize(globe_pos)*u_tile_up_scale;\n#ifdef GLOBE_POLES\nvec3 up_vector=globe_derived_up_vector;\n#else\nvec3 up_vector=elevationVector(tile_pos);\n#endif\nfloat height=elevation(tile_pos);globe_pos+=up_vector*height;\n#ifndef GLOBE_POLES\nglobe_pos-=globe_derived_up_vector*u_skirt_height*decomposed_pos_and_skirt.z;\n#endif\n#ifdef GLOBE_POLES\nvec4 interpolated_pos=u_globe_matrix*vec4(globe_pos,1.0);\n#else\nvec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {merc_world_pos=vec4(merc_pos,height-u_skirt_height*decomposed_pos_and_skirt.z,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0);\n#endif\ngl_Position=u_proj_matrix*interpolated_pos;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n}'),globeAtmosphere:BE('#include "_prelude_fog.fragment.glsl"\nuniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec4 u_color;uniform vec4 u_high_color;uniform vec4 u_space_color;uniform float u_horizon_angle;varying highp vec3 v_ray_dir;varying highp vec3 v_horizon_dir;void main() {highp vec3 dir=normalize(v_ray_dir);float globe_pos_dot_dir;\n#ifdef PROJECTION_GLOBE_VIEW\nglobe_pos_dot_dir=dot(u_globe_pos,dir);highp vec3 closest_point_forward=abs(globe_pos_dot_dir)*dir;float norm_dist_from_center=length(closest_point_forward-u_globe_pos)/u_globe_radius;if (norm_dist_from_center < 0.98) {\n#ifdef ALPHA_PASS\ngl_FragColor=vec4(0,0,0,0);return;\n#else\n#ifdef NATIVE\ngl_FragColor=vec4(1,1,1,1);\n#else\ngl_FragColor=vec4(0,0,0,1);\n#endif\nreturn;\n#endif\n}\n#endif\nhighp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ?\n0.0 : max(acos(clamp(dot(dir,horizon_dir),-1.0,1.0)),0.0);float horizon_angle;\n#ifdef PROJECTION_GLOBE_VIEW\nhighp vec3 closest_point=globe_pos_dot_dir*dir;highp float closest_point_to_center=length(closest_point-u_globe_pos);highp float theta=asin(clamp(closest_point_to_center/length(u_globe_pos),-1.0,1.0));horizon_angle=globe_pos_dot_dir < 0.0 ?\nPI-theta-u_horizon_angle : theta-u_horizon_angle;float angle_t=pow(u_transition,10.0);horizon_angle=mix(horizon_angle,horizon_angle_mercator,angle_t);\n#else\nhorizon_angle=horizon_angle_mercator;\n#endif\nhorizon_angle/=PI;float t=exp(-horizon_angle/u_fadeout_range);float alpha_0=u_color.a;float alpha_1=u_high_color.a;float alpha_2=u_space_color.a;vec3 color_stop_0=u_color.rgb;vec3 color_stop_1=u_high_color.rgb;vec3 color_stop_2=u_space_color.rgb;\n#ifdef ALPHA_PASS\nfloat a0=mix(alpha_2,1.0,alpha_1);float a1=mix(a0,1.0,alpha_0);float a2=mix(a0,a1,t);float a =mix(alpha_2,a2,t);gl_FragColor=vec4(1.0,1.0,1.0,a);\n#else\nvec3 c0=mix(color_stop_2,color_stop_1,alpha_1);vec3 c1=mix(c0,color_stop_0,alpha_0);vec3 c2=mix(c0,c1,t);vec3 c=c2;\n#ifndef NATIVE\nc=dither(c,gl_FragCoord.xy+u_temporal_offset);\n#endif\ngl_FragColor=vec4(c*t,t);\n#endif\n}',"attribute vec3 a_pos;attribute vec2 a_uv;uniform vec3 u_frustum_tl;uniform vec3 u_frustum_tr;uniform vec3 u_frustum_br;uniform vec3 u_frustum_bl;uniform float u_horizon;varying highp vec3 v_ray_dir;varying highp vec3 v_horizon_dir;void main() {v_ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,a_uv.x),mix(u_frustum_bl,u_frustum_br,a_uv.x),a_uv.y);v_horizon_dir=mix(\nmix(u_frustum_tl,u_frustum_bl,u_horizon),mix(u_frustum_tr,u_frustum_br,u_horizon),a_uv.x);gl_Position=vec4(a_pos,1.0);}"),model:BE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform float u_opacity;uniform vec3 u_lightcolor;uniform vec3 u_lightpos;uniform float u_lightintensity;uniform vec4 u_baseColorFactor;uniform vec4 u_emissiveFactor;uniform float u_metallicFactor;uniform float u_roughnessFactor;uniform float u_emissive_strength;varying highp vec4 v_position_height;varying lowp vec4 v_color_mix;\n#ifdef RENDER_SHADOWS\nvarying vec4 v_pos_light_view_0;varying vec4 v_pos_light_view_1;varying float v_depth_shadows;\n#endif\n#pragma mapbox: define-attribute highp vec3 normal_3f\n#pragma mapbox: define-attribute highp vec3 color_3f\n#pragma mapbox: define-attribute highp vec4 color_4f\n#pragma mapbox: define-attribute highp vec2 uv_2f\n#pragma mapbox: initialize-attribute highp vec3 normal_3f\n#pragma mapbox: initialize-attribute highp vec3 color_3f\n#pragma mapbox: initialize-attribute highp vec4 color_4f\n#pragma mapbox: initialize-attribute highp vec2 uv_2f\n#ifdef HAS_ATTRIBUTE_a_pbr\nvarying lowp vec4 v_roughness_metallic_emissive_alpha;varying mediump vec4 v_height_based_emission_params;\n#endif\n#ifdef HAS_TEXTURE_u_baseColorTexture\nuniform sampler2D u_baseColorTexture;uniform bool u_baseTextureIsAlpha;uniform bool u_alphaMask;uniform float u_alphaCutoff;\n#endif\n#ifdef HAS_TEXTURE_u_metallicRoughnessTexture\nuniform sampler2D u_metallicRoughnessTexture;\n#endif\n#ifdef HAS_TEXTURE_u_occlusionTexture\nuniform sampler2D u_occlusionTexture;uniform float u_aoIntensity;\n#endif\n#ifdef HAS_TEXTURE_u_normalTexture\nuniform sampler2D u_normalTexture;\n#endif\n#ifdef HAS_TEXTURE_u_emissionTexture\nuniform sampler2D u_emissionTexture;\n#endif\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nvarying highp float v_depth;uniform sampler2D u_depthTexture;uniform vec2 u_inv_depth_size;bool isOccluded() {vec2 coord=gl_FragCoord.xy*u_inv_depth_size;highp float depth=unpack_depth(texture2D(u_depthTexture,coord));return v_depth > depth+0.0005;}\n#endif\nconst float M_PI=3.141592653589793;\n#define saturate(_x) clamp(_x,0.,1.)\nfloat calculate_NdotL(vec3 normal,vec3 lightDir) {const float ext=0.70710678118;return (clamp(dot(normal,lightDir),-ext,1.0)+ext)/(1.0+ext);}vec3 getDiffuseShadedColor(vec3 albedo,vec3 normal,vec3 lightDir,vec3 lightColor)\n{\n#ifdef LIGHTING_3D_MODE\nvec3 transformed_normal=vec3(-normal.xy,normal.z);float lighting_factor;\n#ifdef RENDER_SHADOWS\nlighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);\n#else\nlighting_factor=saturate(dot(transformed_normal,u_lighting_directional_dir));\n#endif\nreturn apply_lighting(albedo,transformed_normal,lighting_factor);\n#else\nvec3 n=normal;float colorvalue=((albedo.x*0.2126)+(albedo.y*0.7152))+(albedo.z*0.0722);vec3 c=vec3(0.03,0.03,0.03);float directional=clamp(dot(n,vec3(lightDir)),0.0,1.0);directional=mix(1.0-u_lightintensity,max((1.0-colorvalue)+u_lightintensity,1.0),directional);vec3 c3=c+clamp((albedo*directional)*lightColor,mix(vec3(0.0),vec3(0.3),vec3(1.0)-lightColor),vec3(1.0));return c3;\n#endif\n}vec4 getBaseColor() {vec4 albedo=u_baseColorFactor;\n#ifdef HAS_ATTRIBUTE_a_color_3f\nalbedo*=vec4(color_3f,1.0);\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\n#else\n#ifdef HAS_ATTRIBUTE_a_color_4f\nalbedo*=color_4f;\n#endif\n#endif\n#if defined (HAS_TEXTURE_u_baseColorTexture) && defined (HAS_ATTRIBUTE_a_uv_2f)\nvec4 texColor=texture2D(u_baseColorTexture,uv_2f);if(u_alphaMask) {if (texColor.w < u_alphaCutoff) {discard;}}\n#ifdef UNPREMULT_TEXTURE_IN_SHADER\nif(texColor.w > 0.0) {texColor.rgb/=texColor.w;}texColor.w=1.0;\n#endif\ntexColor.rgb=sRGBToLinear(texColor.rgb);if(u_baseTextureIsAlpha) {if (texColor.w < 0.5) {discard;}albedo*=mix(vec4(texColor.rgb,texColor.a),vec4(texColor.a),float(u_baseTextureIsAlpha));} else {albedo*=texColor;}\n#endif\nreturn vec4(mix(albedo.rgb,v_color_mix.rgb,v_color_mix.a),albedo.a);}highp mat3 cotangentFrame(highp vec3 N,highp vec3 p,highp vec2 uv ) {\n#ifdef HAS_TEXTURE_u_normalTexture\nhighp vec3 dp1=vec3(dFdx(p.x),dFdx(p.y),dFdx(p.z));highp vec3 dp2=vec3(dFdy(p.x),dFdy(p.y),dFdy(p.z));highp vec2 duv1=vec2(dFdx(uv.x),dFdx(uv.y));highp vec2 duv2=vec2(dFdy(uv.x),dFdy(uv.y));highp vec3 dp2perp=cross( dp2,N );highp vec3 dp1perp=cross( N,dp1 );highp vec3 T=dp2perp*duv1.x+dp1perp*duv2.x;highp vec3 B=dp2perp*duv1.y+dp1perp*duv2.y;highp float lengthT=dot(T,T);highp float lengthB=dot(B,B);highp float maxLength=max(lengthT,lengthB);highp float invmax=inversesqrt( maxLength );highp mat3 res=mat3( T*invmax,B*invmax,N );return res;\n#else\nreturn mat3(1.0);\n#endif\n}highp vec3 getNormal(){highp vec3 n;\n#ifdef HAS_ATTRIBUTE_a_normal_3f\nn=normalize(normal_3f);\n#else\nhighp vec3 fdx=vec3(dFdx(v_position_height.x),dFdx(v_position_height.y),dFdx(v_position_height.z));highp vec3 fdy=vec3(dFdy(v_position_height.x),dFdy(v_position_height.y),dFdy(v_position_height.z));n=normalize(cross(fdx,fdy))*-1.0;\n#endif\n#if defined(HAS_TEXTURE_u_normalTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\nvec3 nMap=texture2D( u_normalTexture,uv_2f).xyz;nMap=normalize(2.0*nMap-vec3(1.0));highp vec3 v=normalize(-v_position_height.xyz);highp mat3 TBN=cotangentFrame(n,v,uv_2f);n=normalize(TBN*nMap);\n#endif\nreturn n;}struct Material {float perceptualRoughness;float alphaRoughness;float metallic;vec3 f90;vec4 baseColor;vec3 diffuseColor;vec3 specularColor;highp vec3 normal;};Material getPBRMaterial() {Material mat;mat.baseColor=getBaseColor();mat.perceptualRoughness=u_roughnessFactor;mat.metallic=u_metallicFactor;\n#ifdef HAS_ATTRIBUTE_a_pbr\nmat.perceptualRoughness=v_roughness_metallic_emissive_alpha.x;mat.metallic=v_roughness_metallic_emissive_alpha.y;mat.baseColor.w*=v_roughness_metallic_emissive_alpha.w;\n#endif\n#if defined(HAS_TEXTURE_u_metallicRoughnessTexture) && defined(HAS_ATTRIBUTE_a_uv_2f) \nvec4 mrSample=texture2D(u_metallicRoughnessTexture,uv_2f);mat.perceptualRoughness*=mrSample.g;mat.metallic*=mrSample.b;\n#endif\nconst float c_minRoughness=0.04;mat.perceptualRoughness=clamp(mat.perceptualRoughness,c_minRoughness,1.0);mat.metallic=saturate(mat.metallic);mat.alphaRoughness=mat.perceptualRoughness*mat.perceptualRoughness;const vec3 f0=vec3(0.04);mat.diffuseColor=mat.baseColor.rgb*(vec3(1.0)-f0);mat.diffuseColor*=1.0-mat.metallic;mat.specularColor=mix(f0,mat.baseColor.rgb,mat.metallic);highp float reflectance=max(max(mat.specularColor.r,mat.specularColor.g),mat.specularColor.b);highp float reflectance90=saturate(reflectance*25.0);mat.f90=vec3(reflectance90);mat.normal=getNormal();return mat;}float V_GGX(float NdotL,float NdotV,float roughness)\n{float a2=roughness*roughness;float GGXV=NdotL*sqrt(NdotV*NdotV*(1.0-a2)+a2);float GGXL=NdotV*sqrt(NdotL*NdotL*(1.0-a2)+a2);return 0.5/(GGXV+GGXL);}float V_GGXFast(float NdotL,float NdotV,float roughness) {float a=roughness;float GGXV=NdotL*(NdotV*(1.0-a)+a);float GGXL=NdotV*(NdotL*(1.0-a)+a);return 0.5/(GGXV+GGXL);}vec3 F_Schlick(vec3 specularColor,vec3 f90,float VdotH)\n{return specularColor+(f90-specularColor)*pow(clamp(1.0-VdotH,0.0,1.0),5.0);}vec3 F_SchlickFast(vec3 specularColor,float VdotH)\n{float x=1.0-VdotH;float x4=x*x*x*x;return specularColor+(1.0-specularColor)*x4*x;}float D_GGX(highp float NdotH,float alphaRoughness)\n{highp float a4=alphaRoughness*alphaRoughness;highp float f=(NdotH*a4-NdotH)*NdotH+1.0;return a4/(M_PI*f*f);}vec3 diffuseBurley(Material mat,float LdotH,float NdotL,float NdotV)\n{float f90=2.0*LdotH*LdotH*mat.alphaRoughness-0.5;return (mat.diffuseColor/M_PI)*(1.0+f90*pow((1.0-NdotL),5.0))*(1.0+f90*pow((1.0-NdotV),5.0));}vec3 diffuseLambertian(Material mat)\n{\n#ifdef LIGHTING_3D_MODE\nreturn mat.diffuseColor;\n#else\nreturn mat.diffuseColor/M_PI;\n#endif\n}vec3 EnvBRDFApprox(vec3 specularColor,float roughness,highp float NdotV)\n{vec4 c0=vec4(-1,-0.0275,-0.572,0.022);vec4 c1=vec4(1,0.0425,1.04,-0.04);highp vec4 r=roughness*c0+c1;highp float a004=min(r.x*r.x,exp2(-9.28*NdotV))*r.x+r.y;vec2 AB=vec2(-1.04,1.04)*a004+r.zw;return specularColor*AB.x+AB.y;}vec3 computeIndirectLightContribution(Material mat,float NdotV,vec3 normal)\n{vec3 env_light=vec3(0.65,0.65,0.65);\n#ifdef LIGHTING_3D_MODE\nfloat ambient_factor=calculate_ambient_directional_factor(normal);env_light=u_lighting_ambient_color*ambient_factor;\n#endif\nvec3 envBRDF=EnvBRDFApprox(mat.specularColor,mat.perceptualRoughness,NdotV);vec3 indirectSpecular= envBRDF*env_light;vec3 indirectDiffuse=mat.diffuseColor*env_light;return indirectSpecular+indirectDiffuse;}vec3 computeLightContribution(Material mat,vec3 lightPosition,vec3 lightColor)\n{highp vec3 n=mat.normal;highp vec3 v=normalize(-v_position_height.xyz);highp vec3 l=normalize(lightPosition);highp vec3 h=normalize(v+l);float NdotV=clamp(abs(dot(n,v)),0.001,1.0);float NdotL=saturate(dot(n,l));highp float NdotH=saturate(dot(n,h));float VdotH=saturate(dot(v,h));vec3 f=F_SchlickFast(mat.specularColor,VdotH);float g=V_GGXFast(NdotL,NdotV,mat.alphaRoughness);float d=D_GGX(NdotH,mat.alphaRoughness);vec3 diffuseTerm=(1.0-f)*diffuseLambertian(mat);vec3 specularTerm=f*g*d;vec3 transformed_normal=vec3(-n.xy,n.z);float lighting_factor;\n#ifdef RENDER_SHADOWS\nlighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);\n#else\nlighting_factor=NdotL;\n#endif\nvec3 directLightColor=(specularTerm+diffuseTerm)*lighting_factor*lightColor;vec3 indirectLightColor=computeIndirectLightContribution(mat,NdotV,transformed_normal);vec3 color=(saturate(directLightColor)+indirectLightColor);float intensityFactor=1.0;\n#if !defined(LIGHTING_3D_MODE)\nconst vec3 luminosityFactor=vec3(0.2126,0.7152,0.0722);float luminance=dot(diffuseTerm,luminosityFactor);intensityFactor=mix((1.0-u_lightintensity),max((1.0-luminance+u_lightintensity),1.0),NdotL);\n#endif\ncolor*=intensityFactor;return color;}void main() {\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nif (isOccluded()) {discard;}\n#endif\nvec3 lightDir=u_lightpos;vec3 lightColor=u_lightcolor;\n#ifdef LIGHTING_3D_MODE\nlightDir=u_lighting_directional_dir;lightDir.xy=-lightDir.xy;lightColor=u_lighting_directional_color;\n#endif\nvec4 finalColor;\n#ifdef DIFFUSE_SHADED\nvec3 N=getNormal();vec3 diffuse=getDiffuseShadedColor(getBaseColor().rgb,N,lightDir,lightColor);\n#ifdef HAS_TEXTURE_u_occlusionTexture\nfloat ao=(texture2D(u_occlusionTexture,uv_2f).r-1.0)*u_aoIntensity+1.0;diffuse*=ao;\n#endif\nfinalColor=vec4(diffuse,1.0)*u_opacity;\n#else\nMaterial mat=getPBRMaterial();vec3 color=computeLightContribution(mat,lightDir,lightColor);\n#if defined (HAS_TEXTURE_u_occlusionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\nfloat ao=(texture2D(u_occlusionTexture,uv_2f).x-1.0)*u_aoIntensity+1.0;color*=ao;\n#endif\nvec4 emissive=u_emissiveFactor;\n#if defined(HAS_TEXTURE_u_emissionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\nemissive.rgb*=sRGBToLinear(texture2D(u_emissionTexture,uv_2f).rgb);\n#endif\ncolor+=emissive.rgb;float opacity=mat.baseColor.w*u_opacity;\n#ifdef HAS_ATTRIBUTE_a_pbr\nfloat resEmission=v_roughness_metallic_emissive_alpha.z;resEmission*=v_height_based_emission_params.z+v_height_based_emission_params.w*pow(clamp(v_height_based_emission_params.x,0.0,1.0),v_height_based_emission_params.y);color=mix(color,v_color_mix.rgb,min(1.0,resEmission));\n#ifdef HAS_ATTRIBUTE_a_color_4f\nfloat distance=length(vec2(1.3*max(0.0,abs(color_4f.x)-color_4f.z),color_4f.y));distance+= mix(0.5,0.0,clamp(resEmission-1.0,0.0,1.0));opacity*=v_roughness_metallic_emissive_alpha.w*saturate(1.0-distance*distance);\n#endif\n#endif\ncolor=mix(color,mat.baseColor.rgb,u_emissive_strength);color=linearTosRGB(color);color*=opacity;finalColor=vec4(color,opacity);\n#endif\n#ifdef FOG\nfinalColor=fog_dither(fog_apply_premultiplied(finalColor,v_fog_pos,v_position_height.w));\n#endif\n#ifdef RENDER_CUTOFF\nfinalColor*=v_cutoff_opacity;\n#endif\n#ifdef INDICATOR_CUTOUT\nfinalColor=applyCutout(finalColor);\n#endif\ngl_FragColor=finalColor;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nattribute vec3 a_pos_3f;\n#pragma mapbox: define-attribute highp vec3 normal_3f\n#pragma mapbox: define-attribute highp vec2 uv_2f\n#pragma mapbox: define-attribute highp vec3 color_3f\n#pragma mapbox: define-attribute highp vec4 color_4f\n#pragma mapbox: define-attribute-vertex-shader-only highp vec4 pbr\n#pragma mapbox: define-attribute-vertex-shader-only highp vec3 heightBasedEmissiveStrength\nuniform mat4 u_matrix;uniform mat4 u_lighting_matrix;uniform vec3 u_camera_pos;uniform vec4 u_color_mix;\n#ifdef INSTANCED_ARRAYS\nattribute vec4 a_normal_matrix0;attribute vec4 a_normal_matrix1;attribute vec4 a_normal_matrix2;attribute vec4 a_normal_matrix3;\n#else\nuniform highp mat4 u_normal_matrix;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;varying vec4 v_pos_light_view_0;varying vec4 v_pos_light_view_1;varying float v_depth_shadows;\n#endif\nvarying vec4 v_position_height;varying lowp vec4 v_color_mix;\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nvarying highp float v_depth;\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\nvarying lowp vec4 v_roughness_metallic_emissive_alpha;varying mediump vec4 v_height_based_emission_params;\n#endif\nvoid main() {\n#pragma mapbox: initialize-attribute highp vec3 normal_3f\n#pragma mapbox: initialize-attribute highp vec2 uv_2f\n#pragma mapbox: initialize-attribute highp vec3 color_3f\n#pragma mapbox: initialize-attribute highp vec4 color_4f\n#pragma mapbox: initialize-attribute-custom highp vec4 pbr\n#pragma mapbox: initialize-attribute-custom highp vec3 heightBasedEmissiveStrength\nhighp mat4 normal_matrix;\n#ifdef INSTANCED_ARRAYS\nnormal_matrix=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);\n#else\nnormal_matrix=u_normal_matrix;\n#endif\nvec3 local_pos;mat3 rs;\n#ifdef MODEL_POSITION_ON_GPU\nvec3 pos_color=normal_matrix[0].xyz;vec4 translate=normal_matrix[1];vec3 pos_a=floor(pos_color);vec3 rgb=1.05*(pos_color-pos_a);float color_mix=pos_a.z/100.0;v_color_mix=vec4(sRGBToLinear(rgb),color_mix);float meter_to_tile=normal_matrix[0].w;vec4 pos=vec4(pos_a.xy,translate.z,1.0);rs[0].x=normal_matrix[1].w;rs[0].yz=normal_matrix[2].xy;rs[1].xy=normal_matrix[2].zw;rs[1].z=normal_matrix[3].x;rs[2].xyz=normal_matrix[3].yzw;vec4 pos_node=u_lighting_matrix*vec4(a_pos_3f,1.0);vec3 rotated_pos_node=rs*pos_node.xyz;vec3 pos_model_tile=(rotated_pos_node+vec3(translate.xy,0.0))*vec3(meter_to_tile,meter_to_tile,1.0);pos.xyz+=pos_model_tile;local_pos=pos.xyz;gl_Position=u_matrix*pos;pos.z*=meter_to_tile;v_position_height.xyz=pos.xyz-u_camera_pos;\n#else\nlocal_pos=a_pos_3f;gl_Position=u_matrix*vec4(a_pos_3f,1);v_position_height.xyz=vec3(u_lighting_matrix*vec4(a_pos_3f,1));v_color_mix=vec4(sRGBToLinear(u_color_mix.rgb),u_color_mix.a);\n#endif\nv_position_height.w=a_pos_3f.z;\n#ifdef HAS_ATTRIBUTE_a_pbr\nvec4 albedo_c=decode_color(pbr.xy);vec2 e_r_m=unpack_float(pbr.z);vec2 r_m= unpack_float(e_r_m.y*16.0);r_m.r=r_m.r*16.0;v_color_mix=vec4(albedo_c.rgb,1.0);v_roughness_metallic_emissive_alpha=vec4(vec3(r_m,e_r_m.x)/255.0,albedo_c.a);v_roughness_metallic_emissive_alpha.z*=2.0;float heightBasedRelativeIntepolation=a_pos_3f.z*heightBasedEmissiveStrength.x+heightBasedEmissiveStrength.y;v_height_based_emission_params.x=heightBasedRelativeIntepolation;v_height_based_emission_params.y=heightBasedEmissiveStrength.z;vec2 emissionMultiplierValues=unpack_float(pbr.w)/256.0;v_height_based_emission_params.z=emissionMultiplierValues.x;v_height_based_emission_params.w=emissionMultiplierValues.y-emissionMultiplierValues.x;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(local_pos);\n#endif\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef HAS_ATTRIBUTE_a_normal_3f\n#ifdef MODEL_POSITION_ON_GPU\nfloat x_squared_scale=dot(rs[0],rs[0]);float y_squared_scale=dot(rs[1],rs[1]);float z_squared_scale=dot(rs[2],rs[2]);vec3 squared_scale=vec3(x_squared_scale,y_squared_scale,z_squared_scale);normal_3f=rs*((u_lighting_matrix*vec4(normal_3f,0.0)).xyz/squared_scale);normal_3f=normalize(normal_3f);\n#else\nnormal_3f=vec3(normal_matrix*vec4(normal_3f,0));\n#endif\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\n#ifdef HAS_ATTRIBUTE_a_color_4f\nv_roughness_metallic_emissive_alpha.w=clamp(color_4f.a*v_roughness_metallic_emissive_alpha.w*(v_roughness_metallic_emissive_alpha.z-1.0),0.0,1.0);\n#endif\n#endif\n#ifdef RENDER_SHADOWS\nvec3 shadow_pos=local_pos;\n#ifdef NORMAL_OFFSET\n#ifdef HAS_ATTRIBUTE_a_normal_3f\n#ifdef MODEL_POSITION_ON_GPU\nvec3 offset=shadow_normal_offset(vec3(-normal_3f.xy,normal_3f.z));shadow_pos+=offset*shadow_normal_offset_multiplier0();\n#else\nvec3 offset=shadow_normal_offset_model(normalize(normal_3f));shadow_pos+=offset*shadow_normal_offset_multiplier0();\n#endif\n#endif\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shadow_pos,1);v_pos_light_view_1=u_light_matrix_1*vec4(shadow_pos,1);v_depth_shadows=gl_Position.w;\n#endif\n}'),modelDepth:BE("varying highp float v_depth;void main() {\n#ifndef DEPTH_TEXTURE\ngl_FragColor=pack_depth(v_depth);\n#endif\n}","attribute vec3 a_pos_3f;uniform mat4 u_matrix;varying highp float v_depth;\n#ifdef MODEL_POSITION_ON_GPU\n#ifdef INSTANCED_ARRAYS\nattribute vec4 a_normal_matrix0;attribute vec4 a_normal_matrix1;attribute vec4 a_normal_matrix2;attribute vec4 a_normal_matrix3;\n#else\nuniform highp mat4 u_instance;\n#endif\nuniform highp mat4 u_node_matrix;\n#endif\nvoid main() {\n#ifdef MODEL_POSITION_ON_GPU\nhighp mat4 instance;\n#ifdef INSTANCED_ARRAYS\ninstance=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);\n#else\ninstance=u_instance;\n#endif\nvec3 pos_color=instance[0].xyz;vec4 translate=instance[1];vec3 pos_a=floor(pos_color);float meter_to_tile=instance[0].w;vec4 pos=vec4(pos_a.xy,translate.z,1.0);mat3 rs;rs[0].x=instance[1].w;rs[0].yz=instance[2].xy;rs[1].xy=instance[2].zw;rs[1].z=instance[3].x;rs[2].xyz=instance[3].yzw;vec4 pos_node=u_node_matrix*vec4(a_pos_3f,1.0);vec3 rotated_pos_node=rs*pos_node.xyz;vec3 pos_model_tile=(rotated_pos_node+vec3(translate.xy,0.0))*vec3(meter_to_tile,meter_to_tile,1.0);pos.xyz+=pos_model_tile;gl_Position=u_matrix*pos;\n#else\ngl_Position=u_matrix*vec4(a_pos_3f,1);\n#endif\nv_depth=gl_Position.z/gl_Position.w;}"),stars:BE("varying highp vec2 v_uv;varying mediump float v_intensity;float shapeCircle(in vec2 uv)\n{float beginFade=0.6;float lengthFromCenter=length(v_uv);return 1.0-clamp((lengthFromCenter-beginFade)/(1.0-beginFade),0.0,1.0);}void main() {float alpha=shapeCircle(v_uv);vec3 color=vec3(1.0,1.0,1.0);alpha*=v_intensity;gl_FragColor=vec4(color*alpha,alpha);HANDLE_WIREFRAME_DEBUG;}","\nattribute vec3 a_pos_3f;attribute vec2 a_uv;attribute float a_size_scale;attribute float a_fade_opacity;uniform mat4 u_matrix;uniform vec3 u_up;uniform vec3 u_right;uniform float u_intensity_multiplier;varying highp vec2 v_uv;varying mediump float v_intensity;void main() {v_uv=a_uv;v_intensity=a_fade_opacity*u_intensity_multiplier;vec3 pos=a_pos_3f;pos+=a_uv.x*u_right*a_size_scale;pos+=a_uv.y*u_up*a_size_scale;gl_Position=u_matrix*vec4(pos,1.0);}")};function OE(e,t){const i=e.replace(/\s*\/\/[^\n]*\n/g,"\n").split("\n");for(let e of i)if(e=e.trim(),"#"===e[0]&&e.includes("if")&&!e.includes("endif")){e=e.replace("#","").replace(/ifdef|ifndef|elif|if/g,"").replace(/!|defined|\(|\)|\|\||&&/g,"").replace(/\s+/g," ").trim();const i=e.split(" ");for(const e of i)t.includes(e)||t.push(e);}}function BE(e,t){const i=/#include\s+"([^"]+)"/g,r=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g;let n=t.match(/attribute(\S*) (highp |mediump |lowp )?([\w]+) ([\w]+)/g);n&&(n=n.filter(((e,t)=>n.indexOf(e)===t)));const o={},s=[],a=[];e=e.replace(i,((e,t)=>(a.push(t),""))),t=t.replace(i,((e,t)=>(s.push(t),"")));let l=[...zE];OE(e,l),OE(t,l);for(const e of [...s,...a])DE[e]||console.error(`Undefined include: ${e}`),PE[e]||(PE[e]=[],OE(DE[e],PE[e])),l=[...l,...PE[e]];return {fragmentSource:e=e.replace(r,((e,t,i,r,n)=>(o[n]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nvarying ${i} ${r} ${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"initialize"===t?`\n#ifdef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = u_${n};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n varying ${i} ${r} ${n};\n#endif\n`:"initialize-attribute"===t?"":void 0))),vertexSource:t=t.replace(r,((e,t,i,r,n)=>{const s="float"===r?"vec2":r,a=n.match(/color/)?"color":s;return "define-attribute-vertex-shader-only"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\nattribute ${i} ${r} a_${n};\n#endif\n`:o[n]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nattribute ${i} ${s} a_${n};\nvarying ${i} ${r} ${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"initialize"===t?"vec4"===a?`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = a_${n};\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = unpack_mix_${a}(a_${n}, u_${n}_t);\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n attribute ${i} ${r} a_${n};\n varying ${i} ${r} ${n};\n#endif\n`:"initialize-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n ${n} = a_${n};\n#endif\n`:void 0:"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nattribute ${i} ${s} a_${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"define-instanced"===t?"mat4"===a?`\n#ifdef INSTANCED_ARRAYS\nattribute vec4 a_${n}0;\nattribute vec4 a_${n}1;\nattribute vec4 a_${n}2;\nattribute vec4 a_${n}3;\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:`\n#ifdef INSTANCED_ARRAYS\nattribute ${i} ${s} a_${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"initialize-attribute-custom"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n ${i} ${r} ${n} = a_${n};\n#endif\n`:"vec4"===a?`\n#ifndef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = a_${n};\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = unpack_mix_${a}(a_${n}, u_${n}_t);\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`})),staticAttributes:n,usedDefines:l,vertexIncludes:s,fragmentIncludes:a}}class FE{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null;}bind(e,t,i,r,n,o,s,a){this.context=e;let l=this.boundPaintVertexBuffers.length!==r.length;for(let e=0;!l&&e{const n=i.paint.get("hillshade-shadow-color"),o=i.paint.get("hillshade-highlight-color"),s=i.paint.get("hillshade-accent-color"),a=i.paint.get("hillshade-emissive-strength");let l=w(i.paint.get("hillshade-illumination-direction"));if("viewport"===i.paint.get("hillshade-illumination-anchor"))l-=e.transform.angle;else if(e.style&&e.style.enable3dLights()&&e.style.directionalLight){const t=e.style.directionalLight.properties.get("direction");l=w(J(t.x,t.y,t.z)[1]);}const c=!e.options.moving;return {u_matrix:r||e.transform.calculateProjMatrix(t.tileID.toUnwrapped(),c),u_image:0,u_latrange:NE(0,t.tileID),u_light:[i.paint.get("hillshade-exaggeration"),l],u_shadow:n,u_highlight:o,u_emissive_strength:a,u_accent:s}})(e,i,r,e.terrain?t.projMatrix:null);e.uploadCommonUniforms(a,u,t.toUnwrapped());const{tileBoundsBuffer:p,tileBoundsIndexBuffer:f,tileBoundsSegments:m}=e.getTileBoundsBuffers(i);u.draw(e,l.TRIANGLES,n,o,s,Ex.disabled,d,r.id,p,f,m);}function VE(e,t,i){if(!t.needsDEMTextureUpload)return;const r=e.context,n=r.gl;r.pixelStoreUnpackPremultiplyAlpha.set(!1),t.demTexture=t.demTexture||e.getTileTexture(i.stride);const o=i.getPixels();t.demTexture?t.demTexture.update(o,{premultiply:!1}):t.demTexture=new gy(r,o,e.terrainUseFloatDEM()?n.R32F:n.RGBA,{premultiply:!1}),t.needsDEMTextureUpload=!1;}function jE(e,t,i){const r=e.context,n=r.gl;if(!t.dem)return;const o=t.dem;if(r.activeTexture.set(n.TEXTURE1),VE(e,t,o),!t.demTexture)return;t.demTexture.bind(n.NEAREST,n.CLAMP_TO_EDGE);const s=o.dim;r.activeTexture.set(n.TEXTURE0);let a=t.hillshadeFBO;if(!a){const e=new gy(r,{width:s,height:s,data:null},n.RGBA);e.bind(n.LINEAR,n.CLAMP_TO_EDGE),a=t.hillshadeFBO=r.createFramebuffer(s,s,!0,"renderbuffer"),a.colorAttachment.set(e.texture);}r.bindFramebuffer.set(a.framebuffer),r.viewport.set([0,0,s,s]);const{tileBoundsBuffer:l,tileBoundsIndexBuffer:c,tileBoundsSegments:h}=e.getMercatorTileBoundsBuffers(),u=[];e.terrainUseFloatDEM()&&u.push("TERRAIN_DEM_FLOAT_FORMAT"),e.getOrCreateProgram("hillshadePrepare",{defines:u}).draw(e,n.TRIANGLES,gx.disabled,xx.disabled,bx.unblended,Ex.disabled,((e,t)=>{const i=t.stride,r=xu.create();return xu.ortho(r,0,sr,-sr,0,0,1),xu.translate(r,r,[0,-sr,0]),{u_matrix:r,u_image:1,u_dimension:[i,i],u_zoom:e.overscaledZ,u_unpack:t.unpackVector}})(t.tileID,o),i.id,l,c,h),t.needsHillshadePrepare=!1;}const GE=e=>({u_matrix:new kl(e),u_image0:new Il(e),u_skirt_height:new Cl(e),u_ground_shadow_factor:new Dl(e)}),qE=(e,t,i)=>({u_matrix:e,u_image0:0,u_skirt_height:t,u_ground_shadow_factor:i}),ZE=(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f)=>({u_proj_matrix:Float32Array.from(e),u_globe_matrix:t,u_normalize_matrix:Float32Array.from(r),u_merc_matrix:i,u_zoom_transition:n,u_merc_center:o,u_image0:0,u_frustum_tl:s,u_frustum_tr:a,u_frustum_br:l,u_frustum_bl:c,u_globe_pos:h,u_globe_radius:u,u_viewport:d,u_grid_matrix:f?Float32Array.from(f):new Float32Array(9),u_skirt_height:p}),$E=(e,t)=>{if(t>0&&e.terrain&&W("Cutoff is currently disabled on terrain"),t<=0||e.terrain)return {shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,0]}};const i=e.transform,r=Math.max(Math.abs(i._zoom-(e.minCutoffZoom-1)),1),n=i.isLODDisabled(!1)?D(60,45,i.pitch):D(30,15,i.pitch),o=i._farZ-i._nearZ,s=t*i.height,a=((1-(l=n))*(.75*i.cameraToCenterDistance)+l*(i._farZ+s))*r;var l;return {shouldRenderCutoff:n<1,uniformValues:{u_cutoff_params:[i._nearZ,i._farZ,(a-i._nearZ)/o,(a-s-i._nearZ)/o]}}};function HE(e,t){return null!=e&&null!=t&&!(!e.hasData()||!t.hasData())&&null!=e.demTexture&&null!=t.demTexture&&e.tileID.key!==t.tileID.key}const WE=new class{constructor(){this.operations={};}newMorphing(e,t,i,r,n){if(e in this.operations){const t=this.operations[e];t.to.tileID.key!==i.tileID.key&&(t.queued=i);}else this.operations[e]={startTime:r,phase:0,duration:n,from:t,to:i,queued:null};}getMorphValuesForProxy(e){if(!(e in this.operations))return null;const t=this.operations[e];return {from:t.from,to:t.to,phase:t.phase}}update(e){for(const t in this.operations){const i=this.operations[t];for(i.phase=(e-i.startTime)/i.duration;i.phase>=1||!this._validOp(i);)if(!this._nextOp(i,e)){delete this.operations[t];break}}}_nextOp(e,t){return !!e.queued&&(e.from=e.to,e.to=e.queued,e.queued=null,e.phase=0,e.startTime=t,!0)}_validOp(e){return e.from.hasData()&&e.to.hasData()}},XE={0:null,1:"TERRAIN_VERTEX_MORPHING"};function YE(e,t,i){if(0===t)return 0;const r=t<1&&514===i?.25/t:1;return 6*Math.pow(1.5,22-e)*Math.max(t,1)*r}function KE(e,t){const i=1<({u_matrix:e});function QE(e,t,i,r,n){if(n>0){const o=ht.now(),s=(o-e.timeAdded)/n,a=t?(o-t.timeAdded)/n:-1,l=i.getSource(),c=r.coveringZoomLevel({tileSize:l.tileSize,roundZoom:l.roundZoom}),h=!t||Math.abs(t.tileID.overscaledZ-c)>Math.abs(e.tileID.overscaledZ-c),u=h&&e.refreshedUponExpiration?1:z(h?s:1-a,0,1);return e.refreshedUponExpiration&&s>=1&&(e.refreshedUponExpiration=!1),t?{opacity:1,mix:1-u}:{opacity:u,mix:0}}return {opacity:1,mix:0}}class eM extends Ax{constructor(e){const t={type:"raster-dem",maxzoom:e.transform.maxZoom},i=new _w(Uw(),null),r=vT("mock-dem",t,i,e.style);super("mock-dem",r,!1),r.setEventedParent(this),this._sourceLoaded=!0;}_loadTile(e,t){e.state="loaded",t(null);}}class tM extends Ax{constructor(e){const t=vT("proxy",{type:"geojson",maxzoom:e.transform.maxZoom},new _w(Uw(),null),e.style);super("proxy",t,!1),t.setEventedParent(this),this.map=this.getSource().map=e,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={};}update(e,t,i){if(e.freezeTileCoverage)return;this.transform=e;const r=e.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce(((t,i)=>{if(t[i.key]="",!this._tiles[i.key]){const t=new Iy(i,this._source.tileSize*i.overscaleFactor(),e.tileZoom);t.state="loaded",this._tiles[i.key]=t;}return t}),{});for(const e in this._tiles)e in r||(this.freeFBO(e),this._tiles[e].unloadVectorData(),delete this._tiles[e]);}freeFBO(e){const t=this.proxyCachedFBO[e];if(void 0!==t){const i=Object.values(t);this.renderCachePool.push(...i),delete this.proxyCachedFBO[e];}}deallocRenderCache(){this.renderCache.forEach((e=>e.fb.destroy())),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={};}}class iM extends Bu{constructor(e,t,i){super(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y),this.proxyTileKey=t,this.projMatrix=i;}}class rM extends Gm{constructor(e,t){super(),this.painter=e,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[i,r,n]=function(e){const t=new Ta,i=new Va,r=131;t.reserve(17161),i.reserve(33800);const n=sr/128,o=sr+n/2,s=o+n;for(let e=-n;eo||e<0||e>o?24575:0,n=z(Math.round(i),0,sr),s=z(Math.round(e),0,sr);t.emplaceBack(n+r,s);}const a=(e,t)=>{const n=t*r+e;i.emplaceBack(n+1,n,n+r),i.emplaceBack(n+r,n+r+1,n+1);};for(let e=1;e<129;e++)for(let t=1;t<129;t++)a(t,e);return [0,129].forEach((e=>{for(let t=0;t<130;t++)a(t,e),a(e,t);})),[t,i,32768]}(),o=e.context;this.gridBuffer=o.createVertexBuffer(i,Pu.members),this.gridIndexBuffer=o.createIndexBuffer(r),this.gridSegments=dl.simpleSegment(0,0,i.length,r.length),this.gridNoSkirtSegments=dl.simpleSegment(0,0,i.length,n),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new tM(t.map),this.orthoMatrix=xu.create(),xu.ortho(this.orthoMatrix,"globe"===this.painter.transform.projection.name?.015:0,sr,0,sr,0,1);const s=o.gl;this._overlapStencilMode=new xx({func:s.GEQUAL,mask:255},0,255,s.KEEP,s.KEEP,s.REPLACE),this._previousZoom=e.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=t,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new eM(t.map),this._pendingGroundEffectLayers=[];}set style(e){e.on("data",this._onStyleDataEvent.bind(this)),this._style=e,this._style.map.on("moveend",(()=>{this._clearLineLayersFromRenderCache();}));}update(e,t,i){if(e&&e.terrain){this._style!==e&&(this.style=e,this._evaluationZoom=void 0);const r=e.terrain.properties,n=0===e.terrain.drapeRenderMode,o=e.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=ht.now();const s=e.terrain&&e.terrain.scope,a=r.get("source"),l=n?this._mockSourceCache:e.getSourceCache(a,s);if(!l)return void W(`Couldn't find terrain source "${a}".`);if(this.sourceCache=l,this._exaggeration=o?this.calculateExaggeration(t):r.get("exaggeration"),!t.projection.requiresDraping&&o&&0===this._exaggeration)return void this._disable();this.enabled=!0;const c=()=>{this.sourceCache.used&&W(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source.\nThis leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const e=this.getScaledDemTileSize();this.sourceCache.update(t,e,!0),this.resetTileLookupCache(this.sourceCache.id);};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,c(),this._initializing=!0),c(),t.updateElevation(!0,i),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(t),this._emptyDEMTextureDirty=!0,this._previousZoom=t.zoom;}else this._disable();}calculateExaggeration(e){const t=this._previousCameraAltitude,i=e.getFreeCameraOptions().position.z/e.pixelsPerMeter*e.worldSize;this._previousCameraAltitude=i;const r=null!=t?i-t:Number.MAX_VALUE;if(Math.abs(r)<2)return this._exaggeration;const n=e.zoom,o=this._style.terrain;if(!this._previousUpdateTimestamp)return o.getExaggeration(n);let s=n-this._previousZoom;const a=this._previousUpdateTimestamp;let l=n;null!=this._evaluationZoom&&(l=this._evaluationZoom,Math.abs(n-l)>.5&&(s=.5*(n-l+s)),s*r<0&&(l+=s)),this._evaluationZoom=l;const c=o.getExaggeration(l),h=c===o.getExaggeration(Math.max(0,l-.1));if(h&&Math.abs(c-this._exaggeration)<.01)return c;let u=Math.min(.1,.00375*(this._updateTimestamp-a));return (h||c<.1||Math.abs(s)<1e-4)&&(u=Math.min(.2,4*u)),Wr(this._exaggeration,c,u)}resetTileLookupCache(e){this._findCoveringTileCache[e]={};}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_onStyleDataEvent(e){e.coord&&"source"===e.dataType?this._clearRenderCacheForTile(e.sourceCacheId,e.coord):"style"===e.dataType&&(this.invalidateRenderCache=!0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this._previousCameraAltitude=void 0);}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const e in this._style._mergedSourceCaches)this._style._mergedSourceCaches[e].usedForTerrain=!1;}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach((e=>e.fb.destroy())),this.pool=[],this._depthFBO&&(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),this.framebufferCopyTexture&&this.framebufferCopyTexture.destroy();}_source(){return this.enabled?this.sourceCache:null}isUsingMockSource(){return this.sourceCache===this._mockSourceCache}exaggeration(){return this._exaggeration}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const e=2*this.proxySourceCache.getSource().tileSize;return [e,e]}set useVertexMorphing(e){this._useVertexMorphing=e;}updateTileBinding(e){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const t=this.proxySourceCache,i=this.painter.transform;this._initializing&&(this._initializing=0===i._centerAltitude&&-1===this.getAtPointOrZero(ep.fromLngLat(i.center),-1),this._emptyDEMTextureDirty=!this._initializing);const r=this.proxyCoords=t.getIds().map((e=>{const r=t.getTileByID(e).tileID;return r.projMatrix=i.calculateProjMatrix(r.toUnwrapped()),r}));!function(e,t){const i=t.transform.pointCoordinate(t.transform.getCameraPoint()),r=new y(i.x,i.y);e.sort(((e,t)=>{if(t.overscaledZ-e.overscaledZ)return t.overscaledZ-e.overscaledZ;const i=new y(e.canonical.x+(1<{this.proxyToSource[e.key]={};})),this.terrainTileForTile={};const o=this._style._mergedSourceCaches;for(const t in o){const i=o[t];if(!i.used)continue;if(i!==this.sourceCache&&this.resetTileLookupCache(i.id),this._setupProxiedCoordsForOrtho(i,e[t],n),i.usedForTerrain)continue;const r=e[t];i.getSource().reparseOverscaled&&this._assignTerrainTiles(r);}this.proxiedCoords[t.id]=r.map((e=>new iM(e,e.key,this.orthoMatrix))),this._assignTerrainTiles(r),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(n),this.renderingToTexture=!1;const s={};this._visibleDemTiles=[];for(const e of this.proxyCoords){const t=this.terrainTileForTile[e.key];if(!t)continue;const i=t.tileID.key;i in s||(this._visibleDemTiles.push(t),s[i]=i);}}_assignTerrainTiles(e){this._initializing||e.forEach((e=>{if(this.terrainTileForTile[e.key])return;const t=this._findTileCoveringTileID(e,this.sourceCache);t&&(this.terrainTileForTile[e.key]=t);}));}_prepareDEMTextures(){const e=this.painter.context,t=e.gl;for(const i in this.terrainTileForTile){const r=this.terrainTileForTile[i],n=r.dem;!n||r.demTexture&&!r.needsDEMTextureUpload||(e.activeTexture.set(t.TEXTURE1),VE(this.painter,r,n));}}_prepareDemTileUniforms(e,t,i,r){if(!t||null==t.demTexture)return !1;const n=e.tileID.canonical,o=Math.pow(2,t.tileID.canonical.z-n.z),s=r||"";return i[`u_dem_tl${s}`]=[n.x*o%1,n.y*o%1],i[`u_dem_scale${s}`]=o,!0}get emptyDEMTexture(){return !this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const e=this.painter.context,t=e.gl;if(!this._emptyDepthBufferTexture){const i=new $p({width:1,height:1},Uint8Array.of(255,255,255,255));this._emptyDepthBufferTexture=new gy(e,i,t.RGBA,{premultiply:!1});}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let e=0;const t=this._visibleDemTiles.reduce(((t,i)=>{if(!i.dem)return t;const r=i.dem.tree.minimums[0];return r>0&&e++,t+r}),0);return e?t/e:0}_updateEmptyDEMTexture(){const e=this.painter.context,t=e.gl;e.activeTexture.set(t.TEXTURE2);const i=this._getLoadedAreaMinimum(),[r,n]=(()=>{if(this.painter.terrainUseFloatDEM()){const e=new Hp({width:1,height:1},new Float32Array([i]));return [t.R32F,e]}{const e=new $p({width:1,height:1},new Uint8Array(jm.pack(i,this.sourceCache.getSource().encoding)));return [t.RGBA,e]}})();this._emptyDEMTextureDirty=!1;let o=this._emptyDEMTexture;return o?o.update(n,{premultiply:!1}):o=this._emptyDEMTexture=new gy(e,n,r,{premultiply:!1}),o}setupElevationDraw(e,t,i){const r=this.painter.context,n=r.gl,o=(s=this.sourceCache.getSource().encoding,{u_dem:2,u_dem_prev:4,u_dem_unpack:jm.getUnpackVector(s),u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_exaggeration:0});var s;o.u_exaggeration=this.exaggeration();let a=null,l=null,c=1;if(i&&i.morphing&&this._useVertexMorphing){const t=i.morphing.srcDemTile,r=i.morphing.dstDemTile;c=i.morphing.phase,t&&r&&(this._prepareDemTileUniforms(e,t,o,"_prev")&&(l=t),this._prepareDemTileUniforms(e,r,o)&&(a=r));}const h=e=>e&&e.demTexture&&this.painter.terrainUseFloatDEM()?n.LINEAR:n.NEAREST,u=e=>{o.u_dem_size=1===e.size[0]?1:e.size[0]-2;};if(l&&a)r.activeTexture.set(n.TEXTURE2),a.demTexture.bind(h(a),n.CLAMP_TO_EDGE),r.activeTexture.set(n.TEXTURE4),l.demTexture.bind(h(l),n.CLAMP_TO_EDGE),a.demTexture&&u(a.demTexture),o.u_dem_lerp=c;else {a=this.terrainTileForTile[e.tileID.key],r.activeTexture.set(n.TEXTURE2);const t=this._prepareDemTileUniforms(e,a,o)?a.demTexture:this.emptyDEMTexture;t.bind(h(a),n.CLAMP_TO_EDGE),u(t);}if(r.activeTexture.set(n.TEXTURE3),i&&i.useDepthForOcclusion?(this._depthTexture&&this._depthTexture.bind(n.NEAREST,n.CLAMP_TO_EDGE),this._depthFBO&&(o.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height])):(this.emptyDepthBufferTexture.bind(n.NEAREST,n.CLAMP_TO_EDGE),o.u_depth_size_inv=[1,1]),i&&i.useMeterToDem&&a){const e=(1<{if(l===i)return;const r=[XE[i],"PROJECTION_GLOBE_VIEW"];h&&r.push("CUSTOM_ANTIALIASING");const n=e.isTileAffectedByFog(t);a=e.getOrCreateProgram("globeRaster",{defines:r,overrideFog:n}),l=i;},d=e.colorModeForRenderPass(),p=new gx(s.LEQUAL,gx.ReadWrite,e.depthRangeFor3D);WE.update(n);const f=function(e){const t=e.pixelsPerMeter,i=t/Zd(1,e.center.lat),r=xu.identity(new Float64Array(16));return xu.translate(r,r,[e.point.x,e.point.y,0]),xu.scale(r,r,[i,i,t]),Float32Array.from(r)}(c),m=[Gd(c.center.lng),qd(c.center.lat)],_=e.globeSharedBuffers,g=[c.width*ht.devicePixelRatio,c.height*ht.devicePixelRatio],y=Float32Array.from(c.globeMatrix),x={useDenormalizedUpVectorScale:!0};{const c=e.transform,h=YE(c.zoom,t.exaggeration(),t.sourceCache._source.tileSize);l=-1;const v=s.TRIANGLES;for(const l of r){const r=i.getTile(l),b=xx.disabled,w=t.prevTerrainTileForTile[l.key],T=t.terrainTileForTile[l.key];HE(w,T)&&WE.newMorphing(l.key,w,T,n,250),o.activeTexture.set(s.TEXTURE0),r.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE);const E=WE.getMorphValuesForProxy(l.key),A=E?1:0;E&&Pt(x,{morphing:{srcDemTile:E.from,dstDemTile:E.to,phase:M(E.phase)}});const S=dd(l.canonical),I=Id(S.getCenter().lat),C=Sd(l.canonical,S,I,c.worldSize/c._pixelsPerMercatorPixel),z=xd(ad(l.canonical)),D=ZE(c.projMatrix,y,f,z,Ed(c.zoom),m,c.frustumCorners.TL,c.frustumCorners.TR,c.frustumCorners.BR,c.frustumCorners.BL,c.globeCenterInViewSpace,c.globeRadius,g,h,C);if(u(l,A),a&&(t.setupElevationDraw(r,a,x),e.uploadCommonUniforms(o,a,l.toUnwrapped()),_)){const[t,i,r]=_.getGridBuffers(I,0!==h);a.draw(e,v,p,b,d,Ex.backCCW,D,"globe_raster",t,i,r);}}}if(_&&(e.renderDefaultNorthPole||e.renderDefaultSouthPole)){const n=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];h&&n.push("CUSTOM_ANTIALIASING"),a=e.getOrCreateProgram("globeRaster",{defines:n});for(const n of r){const{x:r,y:l,z:h}=n.canonical,u=0===l,f=l===(1<t.draw(e,s.TRIANGLES,p,xx.disabled,d,Ex.disabled,ZE(c.projMatrix,_,_,T,0,m,c.frustumCorners.TL,c.frustumCorners.TR,c.frustumCorners.BR,c.frustumCorners.BL,c.globeCenterInViewSpace,c.globeRadius,g,0),"globe_pole_raster",i,b,w);t.setupElevationDraw(l,a,x),e.uploadCommonUniforms(o,a,n.toUnwrapped()),u&&e.renderDefaultNorthPole&&E(a,y),f&&e.renderDefaultSouthPole&&(_=xu.scale(xu.create(),_,[1,-1,1]),E(a,v));}}}}(e,t,i,r,n);else {const o=e.context,s=o.gl;let a,l;const c=e.shadowRenderer,h=$E(e,e.longestCutoffRange),u=t=>{if(l===t)return;const i=[];i.push(XE[t]),h.shouldRenderCutoff&&i.push("RENDER_CUTOFF"),a=e.getOrCreateProgram("terrainRaster",{defines:i}),l=t;},d=e.colorModeForRenderPass(),p=new gx(s.LEQUAL,gx.ReadWrite,e.depthRangeFor3D);WE.update(n);const f=e.transform,m=YE(f.zoom,t.exaggeration(),t.sourceCache._source.tileSize);let _=[0,0,0];if(c){const t=e.style.directionalLight,i=e.style.ambientLight;t&&i&&(_=BA(t,i));}{l=-1;const g=s.TRIANGLES,[y,x]=[t.gridIndexBuffer,t.gridSegments];for(const l of r){const r=i.getTile(l),v=xx.disabled,b=t.prevTerrainTileForTile[l.key],w=t.terrainTileForTile[l.key];HE(b,w)&&WE.newMorphing(l.key,b,w,n,250),o.activeTexture.set(s.TEXTURE0),r.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE,s.LINEAR_MIPMAP_NEAREST);const T=WE.getMorphValuesForProxy(l.key),E=T?1:0;let A;T&&(A={morphing:{srcDemTile:T.from,dstDemTile:T.to,phase:M(T.phase)}});const S=qE(l.projMatrix,KE(l.canonical,f.renderWorldCopies)?m/10:m,_);if(u(E),!a)continue;t.setupElevationDraw(r,a,A);const I=l.toUnwrapped();c&&c.setupShadows(I,a),e.uploadCommonUniforms(o,a,I,null,h),a.draw(e,g,p,v,d,Ex.backCCW,S,"terrain_raster",t.gridBuffer,y,x);}}}}(t,this,this.proxySourceCache,e,this._updateTimestamp),this.renderingToTexture=!0,t.gpuTimingDeferredRenderEnd(),e.splice(0,e.length));}renderBatch(e){if(0===this._drapedRenderBatches.length)return e+1;this.renderingToTexture=!0;const t=this.painter,i=this.painter.context,r=this.proxySourceCache,n=this.proxiedCoords[r.id],o=this._drapedRenderBatches.shift(),s=t.style.order,a=[];let l=0;for(const c of n){const n=r.getTileByID(c.proxyTileKey),h=r.proxyCachedFBO[c.key]?r.proxyCachedFBO[c.key][e]:void 0,u=void 0!==h?r.renderCache[h]:this.pool[l++],d=void 0!==h;if(n.texture=u.tex,d&&!u.dirty){a.push(n.tileID);continue}let p;i.bindFramebuffer.set(u.fb.framebuffer),this.renderedToTile=!1,u.dirty&&(i.clear({color:li.transparent,stencil:0}),u.dirty=!1);for(let e=o.start;e<=o.end;++e){const r=t.style._mergedLayers[s[e]];if(r.isHidden(t.transform.zoom))continue;const n=t.style.getLayerSourceCache(r),o=n?this.proxyToSource[c.key][n.id]:[c];if(!o)continue;const a=o;i.viewport.set([0,0,u.fb.width,u.fb.height]),p!==(n?n.id:null)&&(this._setupStencil(u,o,r,n),p=n?n.id:null),t.renderLayer(t,n,r,a);}if(0===this._drapedRenderBatches.length)for(const e of this._pendingGroundEffectLayers){const r=t.style._mergedLayers[s[e]];if(r.isHidden(t.transform.zoom))continue;const n=t.style.getLayerSourceCache(r),o=n?this.proxyToSource[c.key][n.id]:[c];if(!o)continue;const a=o;i.viewport.set([0,0,u.fb.width,u.fb.height]),p!==(n?n.id:null)&&(this._setupStencil(u,o,r,n),p=n?n.id:null),t.renderLayer(t,n,r,a);}this.renderedToTile?(u.dirty=!0,a.push(n.tileID)):d||--l,5===l&&(l=0,this.renderToBackBuffer(a));}return this.renderToBackBuffer(a),this.renderingToTexture=!1,i.bindFramebuffer.set(null),i.viewport.set([0,0,t.width,t.height]),o.end+1}postRender(){}isLayerOrderingCorrect(e){const t=e.order.length;let i=-1,r=t;for(let n=0;ni}getMinElevationBelowMSL(){let e=0;return this._visibleDemTiles.filter((e=>e.dem)).forEach((t=>{e=Math.min(e,t.dem.tree.minimums[0]);})),0===e?e:(e-30)*this._exaggeration}raycast(e,t,i){if(!this._visibleDemTiles)return null;const r=this._visibleDemTiles.filter((e=>e.dem)).map((r=>{const n=r.tileID,o=1<(null!==e.t?e.t:Number.MAX_VALUE)-(null!==t.t?t.t:Number.MAX_VALUE)));for(const n of r){if(null==n.t)return null;const r=n.tile.dem.tree.raycast(n.minx,n.miny,n.maxx,n.maxy,e,t,i);if(null!=r)return r}return null}_createFBO(){const e=this.painter.context,t=e.gl,i=this.drapeBufferSize;e.activeTexture.set(t.TEXTURE0);const r=new gy(e,{width:i[0],height:i[1],data:null},t.RGBA);r.bind(t.LINEAR,t.CLAMP_TO_EDGE);const n=e.createFramebuffer(i[0],i[1],!0,null);return n.colorAttachment.set(r.texture),n.depthAttachment=new mx(e,n.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=e.createRenderbuffer(e.gl.DEPTH_STENCIL,i[0],i[1]),this._stencilRef=0,n.depthAttachment.set(this._sharedDepthStencil),e.clear({stencil:0})):n.depthAttachment.set(this._sharedDepthStencil),e.extTextureFilterAnisotropic&&!e.extTextureFilterAnisotropicForceOff&&t.texParameterf(t.TEXTURE_2D,e.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,e.extTextureFilterAnisotropicMax),{fb:n,tex:r,dirty:!1}}_initFBOPool(){for(;this.pool.length{const t=this._style._mergedLayers[e],i=t.isHidden(this.painter.transform.zoom);return "custom"===t.type?!i&&t.shouldRedrape():!i&&t.hasTransition()}))}_clearLineLayersFromRenderCache(){let e=!1;for(const t of this._style.getSources())if(t instanceof Rw){e=!0;break}if(!e)return;const t={};for(let e=0;et>e.end));t||W("fill-extrusion with flood lighting and/or ground ambient occlusion should be moved to be on top of all draped layers.");}this._drapedRenderBatches=i;}_setupRenderCache(e){const t=this.proxySourceCache;if(this._shouldDisableRenderCache()||this.invalidateRenderCache){if(this.invalidateRenderCache=!1,t.renderCache.length>t.renderCachePool.length){const e=Object.values(t.proxyCachedFBO);t.proxyCachedFBO={};for(let i=0;i=0;n--){const o=i[n];if(t.getTileByID(o.key),void 0!==t.proxyCachedFBO[o.key]){const i=e[o.key],n=this.proxyToSource[o.key];let s=0;for(const e in n){const t=n[e],o=i[e];if(!o||o.length!==t.length||t.some(((t,i)=>t!==o[i]||r[e]&&r[e].hasOwnProperty(t.key)))){s=-1;break}++s;}for(const e in t.proxyCachedFBO[o.key])t.renderCache[t.proxyCachedFBO[o.key][e]].dirty=s<0||s!==Object.values(i).length;}}const n=[...this._drapedRenderBatches];n.sort(((e,t)=>t.end-t.start-(e.end-e.start)));for(const e of n)for(const r of i){if(t.proxyCachedFBO[r.key])continue;let i=t.renderCachePool.pop();void 0===i&&t.renderCache.length<50&&(i=t.renderCache.length,t.renderCache.push(this._createFBO())),void 0!==i&&(t.proxyCachedFBO[r.key]={},t.proxyCachedFBO[r.key][e.start]=i,t.renderCache[i].dirty=!0);}this._tilesDirty={};}_setupStencil(e,t,i,r){if(!r||!this._sourceTilesOverlap[r.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const n=this.painter.context,o=n.gl;if(t.length<=1)return void(this._overlapStencilType=!1);let s;if(i.isTileClipped())s=t.length,this._overlapStencilMode.test={func:o.EQUAL,mask:255},this._overlapStencilType="Clip";else {if(!(t[0].overscaledZ>t[t.length-1].overscaledZ))return void(this._overlapStencilType=!1);s=1,this._overlapStencilMode.test={func:o.GREATER,mask:255},this._overlapStencilType="Mask";}this._stencilRef+s>255&&(n.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=s,this._overlapStencilMode.ref=this._stencilRef,i.isTileClipped()&&this._renderTileClippingMasks(t,this._overlapStencilMode.ref);}clipOrMaskOverlapStencilType(){return "Clip"===this._overlapStencilType||"Mask"===this._overlapStencilType}stencilModeForRTTOverlap(e){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[e.key]),this._overlapStencilMode):xx.disabled}_renderTileClippingMasks(e,t){const i=this.painter,r=this.painter.context,n=r.gl;i._tileClippingMaskIDs={},r.setColorMode(bx.disabled),r.setDepthMode(gx.disabled);const o=i.getOrCreateProgram("clippingMask");for(const r of e){const e=i._tileClippingMaskIDs[r.key]=--t;o.draw(i,n.TRIANGLES,gx.disabled,new xx({func:n.ALWAYS,mask:0},e,255,n.KEEP,n.KEEP,n.REPLACE),bx.disabled,Ex.disabled,JE(r.projMatrix),"$clipping",i.tileExtentBuffer,i.quadTriangleIndexBuffer,i.tileExtentSegments);}}pointCoordinate(e){const t=this.painter.transform;if(e.x<0||e.x>t.width||e.y<0||e.y>t.height)return null;const i=[e.x,e.y,1,1];uu.transformMat4(i,i,t.pixelMatrixInverse),uu.scale(i,i,1/i[3]),i[0]/=t.worldSize,i[1]/=t.worldSize;const r=t._camera.position,n=Zd(1,t.center.lat),o=[r[0],r[1],r[2]/n,0],s=Mu.subtract([],i.slice(0,3),o);Mu.normalize(s,s);const a=this.raycast(o,s,this._exaggeration);return null!==a&&a?(Mu.scaleAndAdd(o,o,s,a),o[3]=o[2],o[2]*=n,o):null}drawDepth(){const e=this.painter,t=e.context,i=this.proxySourceCache,r=Math.ceil(e.width),n=Math.ceil(e.height);if(!this._depthFBO||this._depthFBO.width===r&&this._depthFBO.height===n||(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),!this._depthFBO){const e=t.gl,i=t.createFramebuffer(r,n,!0,"renderbuffer");t.activeTexture.set(e.TEXTURE0);const o=new gy(t,{width:r,height:n,data:null},e.RGBA);o.bind(e.NEAREST,e.CLAMP_TO_EDGE),i.colorAttachment.set(o.texture);const s=t.createRenderbuffer(t.gl.DEPTH_COMPONENT16,r,n);i.depthAttachment.set(s),this._depthFBO=i,this._depthTexture=o;}t.bindFramebuffer.set(this._depthFBO.framebuffer),t.viewport.set([0,0,r,n]),function(e,t,i,r){if("globe"===e.transform.projection.name)return;const n=e.context,o=n.gl;n.clear({depth:1});const s=e.getOrCreateProgram("terrainDepth"),a=new gx(o.LESS,gx.ReadWrite,e.depthRangeFor3D);for(const n of r){const r=i.getTile(n),l=qE(n.projMatrix,0,[0,0,0]);t.setupElevationDraw(r,s),s.draw(e,o.TRIANGLES,a,xx.disabled,bx.unblended,Ex.backCCW,l,"terrain_depth",t.gridBuffer,t.gridIndexBuffer,t.gridNoSkirtSegments);}}(e,this,i,this.proxyCoords);}_setupProxiedCoordsForOrtho(e,t,i){if(e.getSource()instanceof qb)return this._setupProxiedCoordsForImageSource(e,t,i);this._findCoveringTileCache[e.id]=this._findCoveringTileCache[e.id]||{};const r=this.proxiedCoords[e.id]=[],n=this.proxyCoords;for(let t=0;t(e.min.x=Math.min(e.min.x,t.x-a.x),e.min.y=Math.min(e.min.y,t.y-a.y),e.max.x=Math.max(e.max.x,t.x-a.x),e.max.y=Math.max(e.max.y,t.y-a.y),e)),{min:new y(Number.MAX_VALUE,Number.MAX_VALUE),max:new y(-Number.MAX_VALUE,-Number.MAX_VALUE)}),c=(e,t)=>{const i=e.wrap+e.canonical.x/(1<o+l.max.x||r+ns+l.max.y};for(let o=0;oe.key===t.tileID.key));if(e)return e}if(t.tileID.key!==e.key){const i=e.canonical.z-t.tileID.canonical.z;let n,o,s;r=xu.create();const a=t.tileID.wrap-e.wrap<0?(n=sr>>i,o=n*((t.tileID.canonical.x<=r){const i=e.canonical.z-r;t.getSource().reparseOverscaled?(s=Math.max(e.canonical.z+2,t.transform.tileZoom),o=new Bu(s,e.wrap,r,e.canonical.x>>i,e.canonical.y>>i)):0!==i&&(s=r,o=new Bu(s,e.wrap,r,e.canonical.x>>i,e.canonical.y>>i));}o.key!==e.key&&(l.push(o.key),i=t.getTile(o));}const c=e=>{l.forEach((t=>{r[t]=e;})),l.length=0;};for(s-=1;s>=a&&(!i||!i.hasData());s--){i&&c(i.tileID.key);const e=o.calculateScaledKey(s);if(i=t.getTileByID(e),i&&i.hasData())break;const n=r[e];if(null===n)break;void 0===n?l.push(e):i=t.getTileByID(n);}return c(i?i.tileID.key:null),i&&i.hasData()?i:null}findDEMTileFor(e){return this.enabled?this._findTileCoveringTileID(e,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0;}_clearRenderCacheForTile(e,t){let i=this._tilesDirty[e];i||(i=this._tilesDirty[e]={}),i[t.key]=!0;}}function nM(e,t,i){const r=function(e,t,i){const r=Mu.dot(t,e),n=Mu.dot(i,[.2126,.7152,.0722]),o=(e,t,i)=>(1-i)*e+i*t,s=o(1-.3*Math.min(n,1),1,Math.min(r+1,1));return o(.92,1,Math.asin(z(t[2],-1,1))/Math.PI+.5)*s}(e,[0,0,1],t),n=[0,0,0];Mu.scale(n,i.slice(0,3),r);const o=[0,0,0];Mu.scale(o,t.slice(0,3),e[2]);const s=[0,0,0];return Mu.add(s,n,o),ae(s)}const oM=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],sM=["stars","fillExtrusion","fillExtrusionGroundEffect","model","symbolSDF","symbolIcon","symbolTextAndIcon"];class aM{static cacheKey(e,t,i,r){let n=`${t}${r?r.cacheKey:""}`;for(const t of i)e.usedDefines.includes(t)&&(n+=`/${t}`);return n}constructor(e,t,i,r,n,o){const s=e.gl;this.program=s.createProgram(),this.configuration=r,this.name=t,this.fixedDefines=[...o];const a=function(e){const t=[];for(let i=0;i`#define ${e}`)));const u="#version 300 es\n";let d=u+h.concat("\n#ifdef GL_ES\nprecision mediump float;\n#else\n\n#if !defined(lowp)\n#define lowp\n#endif\n\n#if !defined(mediump)\n#define mediump\n#endif\n\n#if !defined(highp)\n#define highp\n#endif\n\n#endif",LE,RE.fragmentSource).join("\n");for(const e of i.fragmentIncludes)d+=`\n${DE[e]}`;d+=`\n${i.fragmentSource}`;let p=u+h.concat("\n#ifdef GL_ES\nprecision highp float;\n#else\n\n#if !defined(lowp)\n#define lowp\n#endif\n\n#if !defined(mediump)\n#define mediump\n#endif\n\n#if !defined(highp)\n#define highp\n#endif\n\n#endif",LE,RE.vertexSource).join("\n");for(const e of i.vertexIncludes)p+=`\n${DE[e]}`;p+=`\n${i.vertexSource}`;const f=s.createShader(s.FRAGMENT_SHADER);if(s.isContextLost())return void(this.failedToCreate=!0);s.shaderSource(f,d),s.compileShader(f),s.attachShader(this.program,f);const m=s.createShader(s.VERTEX_SHADER);if(s.isContextLost())this.failedToCreate=!0;else {s.shaderSource(m,p),s.compileShader(m),s.attachShader(this.program,m),this.attributes={},this.numAttributes=c.length;for(let e=0;e({u_dem:new Il(e),u_dem_prev:new Il(e),u_dem_unpack:new Pl(e),u_dem_tl:new zl(e),u_dem_scale:new Cl(e),u_dem_tl_prev:new zl(e),u_dem_scale_prev:new Cl(e),u_dem_size:new Cl(e),u_dem_lerp:new Cl(e),u_exaggeration:new Cl(e),u_depth:new Il(e),u_depth_size_inv:new zl(e),u_meter_to_dem:new Cl(e),u_label_plane_matrix_inv:new kl(e)}))(e)),o.includes("GLOBE")&&(this.globeUniforms=(e=>({u_tile_tl_up:new Dl(e),u_tile_tr_up:new Dl(e),u_tile_br_up:new Dl(e),u_tile_bl_up:new Dl(e),u_tile_up_scale:new Cl(e)}))(e)),o.includes("FOG")&&(this.fogUniforms=(e=>({u_fog_matrix:new kl(e),u_fog_range:new zl(e),u_fog_color:new Pl(e),u_fog_horizon_blend:new Cl(e),u_fog_vertical_limit:new zl(e),u_fog_temporal_offset:new Cl(e),u_frustum_tl:new Dl(e),u_frustum_tr:new Dl(e),u_frustum_br:new Dl(e),u_frustum_bl:new Dl(e),u_globe_pos:new Dl(e),u_globe_radius:new Cl(e),u_globe_transition:new Cl(e),u_is_globe:new Il(e),u_viewport:new zl(e)}))(e)),o.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(e=>({u_cutoff_params:new Pl(e)}))(e)),o.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(e=>({u_lighting_ambient_color:new Dl(e),u_lighting_directional_dir:new Dl(e),u_lighting_directional_color:new Dl(e),u_ground_radiance:new Dl(e)}))(e)),o.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(e=>({u_light_matrix_0:new kl(e),u_light_matrix_1:new kl(e),u_fade_range:new zl(e),u_shadow_normal_offset:new Dl(e),u_shadow_intensity:new Cl(e),u_shadow_texel_size:new Cl(e),u_shadow_map_resolution:new Cl(e),u_shadow_direction:new Dl(e),u_shadow_bias:new Dl(e),u_shadowmap_0:new Il(e),u_shadowmap_1:new Il(e)}))(e));}}setTerrainUniformValues(e,t){if(!this.terrainUniforms)return;const i=this.terrainUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e]&&i[e].set(this.program,e,t[e]);}}setGlobeUniformValues(e,t){if(!this.globeUniforms)return;const i=this.globeUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e]&&i[e].set(this.program,e,t[e]);}}setFogUniformValues(e,t){if(!this.fogUniforms)return;const i=this.fogUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e]);}}setCutoffUniformValues(e,t){if(!this.cutoffUniforms)return;const i=this.cutoffUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e]);}}setLightsUniformValues(e,t){if(!this.lightsUniforms)return;const i=this.lightsUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e]);}}setShadowUniformValues(e,t){if(this.failedToCreate||!this.shadowUniforms)return;const i=this.shadowUniforms;e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e]);}_drawDebugWireframe(e,t,i,r,n,o,s,a,l,c){const h=e.options.wireframe;if(!1===h.terrain&&!1===h.layers2D&&!1===h.layers3D)return;const u=e.context;if(!(()=>!(!h.terrain||"terrainRaster"!==this.name&&"globeRaster"!==this.name)||!(!h.layers2D||e._terrain&&e._terrain.renderingToTexture||!oM.includes(this.name))||!(!h.layers3D||!sM.includes(this.name)))())return;const d=u.gl,p=e.wireframeDebugCache.getLinesFromTrianglesBuffer(e.frameCounter,n,u);if(!p)return;const f=[...this.fixedDefines];f.push("DEBUG_WIREFRAME");const m=e.getOrCreateProgram(this.name,{config:this.configuration,defines:f});u.program.set(m.program);const _=(e,t,i)=>{if(t[e]&&i[e])for(const r in t[e])i[e][r]&&i[e][r].set(i.program,r,t[e][r].current);};l&&l.setUniforms(m.program,u,m.binderUniforms,s,{zoom:a}),_("fixedUniforms",this,m),_("terrainUniforms",this,m),_("globeUniforms",this,m),_("fogUniforms",this,m),_("lightsUniforms",this,m),_("shadowUniforms",this,m),p.bind(),u.setColorMode(new bx([d.ONE,d.ONE_MINUS_SRC_ALPHA,d.ZERO,d.ONE],li.transparent,[!0,!0,!0,!1])),u.setDepthMode(new gx(t.func===d.LESS?d.LEQUAL:t.func,gx.ReadOnly,t.range)),u.setStencilMode(xx.disabled);const g=3*o.primitiveLength*2,y=3*o.primitiveOffset*2*2;c&&c>1?d.drawElementsInstanced(d.LINES,g,d.UNSIGNED_SHORT,y,c):d.drawElements(d.LINES,g,d.UNSIGNED_SHORT,y),n.bind(),u.program.set(this.program),u.setDepthMode(t),u.setStencilMode(i),u.setColorMode(r);}draw(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m){const _=e.context,g=_.gl;if(this.failedToCreate)return;_.program.set(this.program),_.setDepthMode(i),_.setStencilMode(r),_.setColorMode(n),_.setCullFace(o);for(const e of Object.keys(this.fixedUniforms))this.fixedUniforms[e].set(this.program,e,s[e]);p&&p.setUniforms(this.program,_,this.binderUniforms,u,{zoom:d});const y={[g.LINES]:2,[g.TRIANGLES]:3,[g.LINE_STRIP]:1}[t],x=m&&m>0?1:void 0;for(const o of h.get()){const s=o.vaos||(o.vaos={});(s[a]||(s[a]=new FE)).bind(_,this,l,p?p.getPaintVertexBuffers():[],c,o.vertexOffset,f||[],x),m&&m>1?g.drawElementsInstanced(t,o.primitiveLength*y,g.UNSIGNED_SHORT,o.primitiveOffset*y*2,m):g.drawElements(t,o.primitiveLength*y,g.UNSIGNED_SHORT,o.primitiveOffset*y*2),t===g.TRIANGLES&&this._drawDebugWireframe(e,i,r,n,c,o,u,d,p,m);}}}function lM(e,t){const i=Math.pow(2,t.tileID.overscaledZ),r=t.tileSize*Math.pow(2,e.transform.tileZoom)/i,n=r*(t.tileID.canonical.x+t.tileID.wrap*i),o=r*t.tileID.canonical.y;return {u_image:0,u_texsize:t.imageAtlasTexture.size,u_tile_units_to_pixels:1/Xx(t,1,e.transform.tileZoom),u_pixel_coord_upper:[n>>16,o>>16],u_pixel_coord_lower:[65535&n,65535&o]}}const cM=xu.create(),hM=(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f)=>{const m=t.style.light,_=m.properties.get("position"),g=[_.x,_.y,_.z],y=gu.create();"viewport"===m.properties.get("anchor")&&(gu.fromRotation(y,-t.transform.angle),Mu.transformMat3(g,g,y));const x=m.properties.get("color"),v=t.transform,b={u_matrix:e,u_lightpos:g,u_lightintensity:m.properties.get("intensity"),u_lightcolor:[x.r,x.g,x.b],u_vertical_gradient:+i,u_opacity:r,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:cM,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_ao:n,u_edge_radius:o,u_flood_light_color:u,u_vertical_scale:d,u_flood_light_intensity:p,u_ground_shadow_factor:f};return "globe"===v.projection.name&&(b.u_tile_id=[s.canonical.x,s.canonical.y,1<({u_matrix:e,u_edge_radius:t,u_vertical_scale:i}),dM=(e,t,i,r,n,o,s,a,l,c,h,u,d,p)=>{const f=hM(e,t,i,r,n,o,s,l,c,h,u,d,p,1,[0,0,0]),m={u_height_factor:-Math.pow(2,s.overscaledZ)/a.tileSize/8};return k(f,lM(t,a),m)},pM=(e,t)=>({u_matrix:e,u_emissive_strength:t}),fM=(e,t,i,r)=>k(pM(e,t),lM(i,r)),mM=(e,t,i)=>({u_matrix:e,u_world:i,u_emissive_strength:t}),_M=(e,t,i,r,n)=>k(fM(e,t,i,r),{u_world:n}),gM=(e,t,i,r)=>{const n=sr/i.tileSize;return {u_matrix:e,u_camera_to_center_distance:t.getCameraToCenterDistance(r),u_extrude_scale:[t.pixelsToGLUnits[0]/n,t.pixelsToGLUnits[1]/n]}},yM=(e,t,i=1)=>({u_matrix:e,u_color:t,u_overlay:0,u_overlay_scale:i}),xM=xu.create(),vM=(e,t,i,r,n,o,s)=>{const a=e.transform,l="globe"===a.projection.name,c=l?wd(a.zoom,t.canonical)*a._pixelsPerMercatorPixel:Xx(i,1,o),h={u_matrix:t.projMatrix,u_extrude_scale:c,u_intensity:s,u_inv_rot_matrix:xM,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(l){h.u_inv_rot_matrix=r,h.u_merc_center=n,h.u_tile_id=[t.canonical.x,t.canonical.y,1<{return {u_matrix:e,u_normalize_matrix:t,u_globe_matrix:i,u_tl_parent:r,u_scale_parent:n,u_fade_t:o.mix,u_opacity:o.opacity*s.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:s.paint.get("raster-brightness-min"),u_brightness_high:s.paint.get("raster-brightness-max"),u_saturation_factor:(d=s.paint.get("raster-saturation"),d>0?1-1/(1.001-d):-d),u_contrast_factor:(u=s.paint.get("raster-contrast"),u>0?1/(1-u):1+u),u_spin_weights:wM(s.paint.get("raster-hue-rotate")),u_perspective_transform:a,u_colorization_mix:c,u_colorization_scale:TM(h),u_color_ramp:l};var u,d;};function wM(e){e*=Math.PI/180;const t=Math.sin(e),i=Math.cos(e);return [(2*i+1)/3,(-Math.sqrt(3)*t-i+1)/3,(Math.sqrt(3)*t-i+1)/3]}function TM([e,t]){if(e===t)return [e,t];const i=(t+e)/2,r=(t-e)/2*256/255;return [-(e=i-r)/((t=i+r)-e),1/(t-e)]}const EM=xu.create(),MM=(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_)=>{const g=n.transform,y={u_is_size_zoom_constant:+("constant"===e||"source"===e),u_is_size_feature_constant:+("constant"===e||"camera"===e),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:g.getCameraToCenterDistance(m),u_rotate_symbol:+i,u_aspect_ratio:g.width/g.height,u_fade_change:n.options.fadeDuration?n.symbolFadeChange:1,u_matrix:o,u_label_plane_matrix:s,u_coord_matrix:a,u_is_text:+l,u_pitch_with_map:+r,u_texsize:c,u_texture:0,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:EM,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:EM,u_up_vector:[0,-1,0],u_icon_transition:_||0};return "globe"===m.name&&(y.u_tile_id=[h.canonical.x,h.canonical.y,1<k(MM(e,t,i,r,n,o,s,a,l,c,u,d,p,f,m,_),{u_gamma_scale:r?n.transform.getCameraToCenterDistance(_)*Math.cos(n.terrain?0:n.transform._pitch):1,u_device_pixel_ratio:ht.devicePixelRatio,u_is_halo:+h,undefined:void 0}),SM=(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m)=>k(AM(e,t,i,r,n,o,s,a,!0,l,!0,h,u,d,p,f,m),{u_texsize_icon:c,u_texture_icon:1}),IM=(e,t,i,r)=>({u_matrix:e,u_emissive_strength:t,u_opacity:i,u_color:r}),CM=(e,t,i,r,n,o,s)=>k(function(e,t,i,r){const n=i.imageManager.getPattern(e.toString(),t),{width:o,height:s}=i.imageManager.getPixelSize(t),a=Math.pow(2,r.tileID.overscaledZ),l=r.tileSize*Math.pow(2,i.transform.tileZoom)/a,c=l*(r.tileID.canonical.x+r.tileID.wrap*a),h=l*r.tileID.canonical.y;return {u_image:0,u_pattern_tl:n.tl,u_pattern_br:n.br,u_texsize:[o,s],u_pattern_size:n.displaySize,u_tile_units_to_pixels:1/Xx(r,1,i.transform.tileZoom),u_pixel_coord_upper:[c>>16,h>>16],u_pixel_coord_lower:[65535&c,65535&h]}}(n,o,r,s),{u_matrix:e,u_emissive_strength:t,u_opacity:i}),zM={BaseColor:5,MetallicRoughness:6,Normal:7,Occlusion:8,Emission:9,ShadowMap0:10},DM=(e,t,i,r,n,o,s,a,l,c,h,u=[0,0,0])=>{const d=r.style.light,p=d.properties.get("position"),f=[-p.x,-p.y,p.z],m=gu.create();"viewport"===d.properties.get("anchor")&&(gu.fromRotation(m,-r.transform.angle),Mu.transformMat3(f,f,m));const _="MASK"===c.alphaMode,g=d.properties.get("color"),y=h.paint.get("model-ambient-occlusion-intensity"),x=h.paint.get("model-color").constantOr(li.white),v=h.paint.get("model-color-mix-intensity").constantOr(0);return {u_matrix:e,u_lighting_matrix:t,u_normal_matrix:i,u_lightpos:f,u_lightintensity:d.properties.get("intensity"),u_lightcolor:[g.r,g.g,g.b],u_camera_pos:u,u_opacity:n,u_baseTextureIsAlpha:0,u_alphaMask:+_,u_alphaCutoff:c.alphaCutoff,u_baseColorFactor:[o.r,o.g,o.b,o.a],u_emissiveFactor:[s[0],s[1],s[2],1],u_metallicFactor:a,u_roughnessFactor:l,u_baseColorTexture:zM.BaseColor,u_metallicRoughnessTexture:zM.MetallicRoughness,u_normalTexture:zM.Normal,u_occlusionTexture:zM.Occlusion,u_emissionTexture:zM.Emission,u_color_mix:[x.r,x.g,x.b,v],u_aoIntensity:y}},PM=new Float32Array(16),RM=(e,t=PM,i=PM)=>({u_matrix:e,u_instance:t,u_node_matrix:i}),LM={fillExtrusion:e=>({u_matrix:new kl(e),u_lightpos:new Dl(e),u_lightintensity:new Cl(e),u_lightcolor:new Dl(e),u_vertical_gradient:new Cl(e),u_opacity:new Cl(e),u_edge_radius:new Cl(e),u_ao:new zl(e),u_tile_id:new Dl(e),u_zoom_transition:new Cl(e),u_inv_rot_matrix:new kl(e),u_merc_center:new zl(e),u_up_dir:new Dl(e),u_height_lift:new Cl(e),u_flood_light_color:new Dl(e),u_vertical_scale:new Cl(e),u_flood_light_intensity:new Cl(e),u_ground_shadow_factor:new Dl(e)}),fillExtrusionDepth:e=>({u_matrix:new kl(e),u_edge_radius:new Cl(e),u_vertical_scale:new Cl(e)}),fillExtrusionPattern:e=>({u_matrix:new kl(e),u_lightpos:new Dl(e),u_lightintensity:new Cl(e),u_lightcolor:new Dl(e),u_vertical_gradient:new Cl(e),u_height_factor:new Cl(e),u_edge_radius:new Cl(e),u_ao:new zl(e),u_tile_id:new Dl(e),u_zoom_transition:new Cl(e),u_inv_rot_matrix:new kl(e),u_merc_center:new zl(e),u_up_dir:new Dl(e),u_height_lift:new Cl(e),u_image:new Il(e),u_texsize:new zl(e),u_pixel_coord_upper:new zl(e),u_pixel_coord_lower:new zl(e),u_tile_units_to_pixels:new Cl(e),u_opacity:new Cl(e)}),fillExtrusionGroundEffect:e=>({u_matrix:new kl(e),u_opacity:new Cl(e),u_ao_pass:new Cl(e),u_meter_to_tile:new Cl(e),u_ao:new zl(e),u_flood_light_intensity:new Cl(e),u_flood_light_color:new Dl(e),u_attenuation:new Cl(e),u_edge_radius:new Cl(e),u_fb:new Il(e),u_fb_size:new Cl(e)}),fill:e=>({u_matrix:new kl(e),u_emissive_strength:new Cl(e)}),fillPattern:e=>({u_matrix:new kl(e),u_emissive_strength:new Cl(e),u_image:new Il(e),u_texsize:new zl(e),u_pixel_coord_upper:new zl(e),u_pixel_coord_lower:new zl(e),u_tile_units_to_pixels:new Cl(e)}),fillOutline:e=>({u_matrix:new kl(e),u_emissive_strength:new Cl(e),u_world:new zl(e)}),fillOutlinePattern:e=>({u_matrix:new kl(e),u_emissive_strength:new Cl(e),u_world:new zl(e),u_image:new Il(e),u_texsize:new zl(e),u_pixel_coord_upper:new zl(e),u_pixel_coord_lower:new zl(e),u_tile_units_to_pixels:new Cl(e)}),circle:e=>({u_camera_to_center_distance:new Cl(e),u_extrude_scale:new Nl(e),u_device_pixel_ratio:new Cl(e),u_matrix:new kl(e),u_inv_rot_matrix:new kl(e),u_merc_center:new zl(e),u_tile_id:new Dl(e),u_zoom_transition:new Cl(e),u_up_dir:new Dl(e),u_emissive_strength:new Cl(e)}),collisionBox:e=>({u_matrix:new kl(e),u_camera_to_center_distance:new Cl(e),u_extrude_scale:new zl(e)}),collisionCircle:e=>({u_matrix:new kl(e),u_inv_matrix:new kl(e),u_camera_to_center_distance:new Cl(e),u_viewport_size:new zl(e)}),debug:e=>({u_color:new Rl(e),u_matrix:new kl(e),u_overlay:new Il(e),u_overlay_scale:new Cl(e)}),clippingMask:e=>({u_matrix:new kl(e)}),heatmap:e=>({u_extrude_scale:new Cl(e),u_intensity:new Cl(e),u_matrix:new kl(e),u_inv_rot_matrix:new kl(e),u_merc_center:new zl(e),u_tile_id:new Dl(e),u_zoom_transition:new Cl(e),u_up_dir:new Dl(e)}),heatmapTexture:e=>({u_image:new Il(e),u_color_ramp:new Il(e),u_opacity:new Cl(e)}),hillshade:e=>({u_matrix:new kl(e),u_image:new Il(e),u_latrange:new zl(e),u_light:new zl(e),u_shadow:new Rl(e),u_highlight:new Rl(e),u_emissive_strength:new Cl(e),u_accent:new Rl(e)}),hillshadePrepare:e=>({u_matrix:new kl(e),u_image:new Il(e),u_dimension:new zl(e),u_zoom:new Cl(e),u_unpack:new Pl(e)}),line:e=>({u_matrix:new kl(e),u_pixels_to_tile_units:new Nl(e),u_device_pixel_ratio:new Cl(e),u_units_to_pixels:new zl(e),u_dash_image:new Il(e),u_gradient_image:new Il(e),u_image_height:new Cl(e),u_texsize:new zl(e),u_tile_units_to_pixels:new Cl(e),u_alpha_discard_threshold:new Cl(e),u_trim_offset:new zl(e),u_emissive_strength:new Cl(e)}),linePattern:e=>({u_matrix:new kl(e),u_texsize:new zl(e),u_pixels_to_tile_units:new Nl(e),u_device_pixel_ratio:new Cl(e),u_image:new Il(e),u_units_to_pixels:new zl(e),u_tile_units_to_pixels:new Cl(e),u_alpha_discard_threshold:new Cl(e)}),raster:e=>({u_matrix:new kl(e),u_normalize_matrix:new kl(e),u_globe_matrix:new kl(e),u_tl_parent:new zl(e),u_scale_parent:new Cl(e),u_fade_t:new Cl(e),u_opacity:new Cl(e),u_image0:new Il(e),u_image1:new Il(e),u_brightness_low:new Cl(e),u_brightness_high:new Cl(e),u_saturation_factor:new Cl(e),u_contrast_factor:new Cl(e),u_spin_weights:new Dl(e),u_perspective_transform:new zl(e),u_colorization_mix:new Pl(e),u_colorization_scale:new zl(e),u_color_ramp:new Il(e)}),symbolIcon:e=>({u_is_size_zoom_constant:new Il(e),u_is_size_feature_constant:new Il(e),u_size_t:new Cl(e),u_size:new Cl(e),u_camera_to_center_distance:new Cl(e),u_rotate_symbol:new Il(e),u_aspect_ratio:new Cl(e),u_fade_change:new Cl(e),u_matrix:new kl(e),u_label_plane_matrix:new kl(e),u_coord_matrix:new kl(e),u_is_text:new Il(e),u_pitch_with_map:new Il(e),u_texsize:new zl(e),u_tile_id:new Dl(e),u_zoom_transition:new Cl(e),u_inv_rot_matrix:new kl(e),u_merc_center:new zl(e),u_camera_forward:new Dl(e),u_tile_matrix:new kl(e),u_up_vector:new Dl(e),u_ecef_origin:new Dl(e),u_texture:new Il(e),u_icon_transition:new Cl(e)}),symbolSDF:e=>({u_is_size_zoom_constant:new Il(e),u_is_size_feature_constant:new Il(e),u_size_t:new Cl(e),u_size:new Cl(e),u_camera_to_center_distance:new Cl(e),u_rotate_symbol:new Il(e),u_aspect_ratio:new Cl(e),u_fade_change:new Cl(e),u_matrix:new kl(e),u_label_plane_matrix:new kl(e),u_coord_matrix:new kl(e),u_is_text:new Il(e),u_pitch_with_map:new Il(e),u_texsize:new zl(e),u_texture:new Il(e),u_gamma_scale:new Cl(e),u_device_pixel_ratio:new Cl(e),u_tile_id:new Dl(e),u_zoom_transition:new Cl(e),u_inv_rot_matrix:new kl(e),u_merc_center:new zl(e),u_camera_forward:new Dl(e),u_tile_matrix:new kl(e),u_up_vector:new Dl(e),u_ecef_origin:new Dl(e),u_is_halo:new Il(e)}),symbolTextAndIcon:e=>({u_is_size_zoom_constant:new Il(e),u_is_size_feature_constant:new Il(e),u_size_t:new Cl(e),u_size:new Cl(e),u_camera_to_center_distance:new Cl(e),u_rotate_symbol:new Il(e),u_aspect_ratio:new Cl(e),u_fade_change:new Cl(e),u_matrix:new kl(e),u_label_plane_matrix:new kl(e),u_coord_matrix:new kl(e),u_is_text:new Il(e),u_pitch_with_map:new Il(e),u_texsize:new zl(e),u_texsize_icon:new zl(e),u_texture:new Il(e),u_texture_icon:new Il(e),u_gamma_scale:new Cl(e),u_device_pixel_ratio:new Cl(e),u_is_halo:new Il(e)}),background:e=>({u_matrix:new kl(e),u_emissive_strength:new Cl(e),u_opacity:new Cl(e),u_color:new Rl(e)}),backgroundPattern:e=>({u_matrix:new kl(e),u_emissive_strength:new Cl(e),u_opacity:new Cl(e),u_image:new Il(e),u_pattern_tl:new zl(e),u_pattern_br:new zl(e),u_texsize:new zl(e),u_pattern_size:new zl(e),u_pixel_coord_upper:new zl(e),u_pixel_coord_lower:new zl(e),u_tile_units_to_pixels:new Cl(e)}),terrainRaster:GE,terrainDepth:GE,skybox:e=>({u_matrix:new kl(e),u_sun_direction:new Dl(e),u_cubemap:new Il(e),u_opacity:new Cl(e),u_temporal_offset:new Cl(e)}),skyboxGradient:e=>({u_matrix:new kl(e),u_color_ramp:new Il(e),u_center_direction:new Dl(e),u_radius:new Cl(e),u_opacity:new Cl(e),u_temporal_offset:new Cl(e)}),skyboxCapture:e=>({u_matrix_3f:new Bl(e),u_sun_direction:new Dl(e),u_sun_intensity:new Cl(e),u_color_tint_r:new Pl(e),u_color_tint_m:new Pl(e),u_luminance:new Cl(e)}),globeRaster:e=>({u_proj_matrix:new kl(e),u_globe_matrix:new kl(e),u_normalize_matrix:new kl(e),u_merc_matrix:new kl(e),u_zoom_transition:new Cl(e),u_merc_center:new zl(e),u_image0:new Il(e),u_grid_matrix:new Bl(e),u_skirt_height:new Cl(e),u_frustum_tl:new Dl(e),u_frustum_tr:new Dl(e),u_frustum_br:new Dl(e),u_frustum_bl:new Dl(e),u_globe_pos:new Dl(e),u_globe_radius:new Cl(e),u_viewport:new zl(e)}),globeAtmosphere:e=>({u_frustum_tl:new Dl(e),u_frustum_tr:new Dl(e),u_frustum_br:new Dl(e),u_frustum_bl:new Dl(e),u_horizon:new Cl(e),u_transition:new Cl(e),u_fadeout_range:new Cl(e),u_color:new Pl(e),u_high_color:new Pl(e),u_space_color:new Pl(e),u_temporal_offset:new Cl(e),u_horizon_angle:new Cl(e)}),model:e=>({u_matrix:new kl(e),u_lighting_matrix:new kl(e),u_normal_matrix:new kl(e),u_lightpos:new Dl(e),u_lightintensity:new Cl(e),u_lightcolor:new Dl(e),u_camera_pos:new Dl(e),u_opacity:new Cl(e),u_baseColorFactor:new Pl(e),u_emissiveFactor:new Pl(e),u_metallicFactor:new Cl(e),u_roughnessFactor:new Cl(e),u_baseTextureIsAlpha:new Il(e),u_alphaMask:new Il(e),u_alphaCutoff:new Cl(e),u_baseColorTexture:new Il(e),u_metallicRoughnessTexture:new Il(e),u_normalTexture:new Il(e),u_occlusionTexture:new Il(e),u_emissionTexture:new Il(e),u_color_mix:new Pl(e),u_aoIntensity:new Cl(e)}),modelDepth:e=>({u_matrix:new kl(e),u_instance:new kl(e),u_node_matrix:new kl(e)}),groundShadow:e=>({u_matrix:new kl(e),u_ground_shadow_factor:new Dl(e)}),stars:e=>({u_matrix:new kl(e),u_up:new Dl(e),u_right:new Dl(e),u_intensity_multiplier:new Cl(e)})};let kM;function OM(e,t,i,r,n,o,s){const a=e.context,l=a.gl,c=e.transform,h=e.getOrCreateProgram("collisionBox"),u=[];let d=0,p=0;for(let a=0;a0){const e=xu.create(),t=y;xu.mul(e,_.placementInvProjMatrix,c.glCoordMatrix),xu.mul(e,e,_.placementViewportMatrix),u.push({circleArray:v,circleOffset:p,transform:t,invTransform:e,projection:_.getProjection()}),d+=v.length/4,p=d;}x&&(e.terrain&&e.terrain.setupElevationDraw(m,h),h.draw(e,l.LINES,gx.disabled,xx.disabled,e.colorModeForRenderPass(),Ex.disabled,gM(y,c,m,_.getProjection()),i.id,x.layoutVertexBuffer,x.indexBuffer,x.segments,null,c.zoom,null,[x.collisionVertexBuffer,x.collisionVertexBufferExt]));}if(!s||!u.length)return;const f=e.getOrCreateProgram("collisionCircle"),m=new Fa;m.resize(4*d),m._trim();let _=0;for(const e of u)for(let t=0;t=0&&(f[x.associatedIconIndex]={x:E,y:M,z:A,angle:D});}else uv(w,d);}if(h){p.clear();const t=e.icon.placedSymbolArray;for(let e=0;e0&&J.push("ICON_TRANSITION"),h.zOffsetVertexBuffer&&J.push("Z_OFFSET");const Q=d&&0!==i.paint.get(n?"text-halo-width":"icon-halo-width").constantOr(1);let ee;ee=d?l.iconsInText?SM(b.kind,C,y,_,e,H,W,X,z,L,a,F,w,Y,B,l.getProjection()):AM(b.kind,C,y,_,e,H,W,X,n,z,!0,a,F,w,Y,B,l.getProjection()):MM(b.kind,C,y,_,e,H,W,X,n,z,a,F,w,Y,B,l.getProjection(),K);const te={program:e.getOrCreateProgram(UM(d,n,l),{config:u,defines:J}),buffers:h,uniformValues:ee,atlasTexture:D,atlasTextureIcon:k,atlasInterpolation:P,atlasInterpolationIcon:R,isSDF:d,hasHalo:Q,tile:r,labelPlaneMatrixInv:j};if(x&&l.canOverlap){v=!0;const e=h.segments.get();for(const t of e)M.push({segments:new dl([t]),sortKey:t.sortKey,state:te});}else M.push({segments:h.segments,sortKey:0,state:te});}v&&M.sort(((e,t)=>e.sortKey-t.sortKey));for(const t of M){const r=t.state;if(e.terrain&&e.terrain.setupElevationDraw(r.tile,r.program,{useDepthForOcclusion:f.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:r.labelPlaneMatrixInv}),d.activeTexture.set(p.TEXTURE0),r.atlasTexture.bind(r.atlasInterpolation,p.CLAMP_TO_EDGE),r.atlasTextureIcon&&(d.activeTexture.set(p.TEXTURE1),r.atlasTextureIcon&&r.atlasTextureIcon.bind(r.atlasInterpolationIcon,p.CLAMP_TO_EDGE)),e.uploadCommonLightUniforms(e.context,r.program),r.hasHalo){const n=r.uniformValues;n.u_is_halo=1,jM(r.buffers,t.segments,i,e,r.program,b,h,u,n,2),n.u_is_halo=0;}else {if(r.isSDF){const n=r.uniformValues;r.hasHalo&&(n.u_is_halo=1,jM(r.buffers,t.segments,i,e,r.program,b,h,u,n,1)),n.u_is_halo=0;}jM(r.buffers,t.segments,i,e,r.program,b,h,u,r.uniformValues,1);}}}function jM(e,t,i,r,n,o,s,a,l,c){const h=[e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer,e.iconTransitioningVertexBuffer,e.globeExtVertexBuffer,e.zOffsetVertexBuffer];n.draw(r,r.context.gl.TRIANGLES,o,s,a,Ex.disabled,l,i.id,e.layoutVertexBuffer,e.indexBuffer,t,i.paint,r.transform.zoom,e.programConfigurations.get(i.id),h,c);}function GM(e,t,i,r,n,o,s){const a=e.context.gl,l=i.paint.get("fill-pattern"),c=l&&l.constantOr(1);let h,u,d,p,f;s?(u=c&&!i.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",h=a.LINES):(u=c?"fillPattern":"fill",h=a.TRIANGLES);for(const m of r){const r=t.getTile(m);if(c&&!r.patternsLoaded())continue;const _=r.getBucket(i);if(!_)continue;e.prepareDrawTile();const g=_.programConfigurations.get(i.id),y=e.isTileAffectedByFog(m),x=e.getOrCreateProgram(u,{config:g,overrideFog:y});c&&(e.context.activeTexture.set(a.TEXTURE0),r.imageAtlasTexture.bind(a.LINEAR,a.CLAMP_TO_EDGE),g.updatePaintBuffers());const v=l.constantOr(null);if(v&&r.imageAtlas){const e=r.imageAtlas.patternPositions[v.toString()];e&&g.setConstantPatternPositions(e);}const b=e.translatePosMatrix(m.projMatrix,r,i.paint.get("fill-translate"),i.paint.get("fill-translate-anchor")),w=i.paint.get("fill-emissive-strength");if(s){p=_.indexBuffer2,f=_.segments2;const t=e.terrain&&e.terrain.renderingToTexture?e.terrain.drapeBufferSize:[a.drawingBufferWidth,a.drawingBufferHeight];d="fillOutlinePattern"===u&&c?_M(b,w,e,r,t):mM(b,w,t);}else p=_.indexBuffer,f=_.segments,d=c?fM(b,w,e,r):pM(b,w);e.uploadCommonUniforms(e.context,x,m.toUnwrapped()),x.draw(e,h,n,e.stencilModeForClipping(m),o,Ex.disabled,d,i.id,_.layoutVertexBuffer,p,f,i.paint,e.transform.zoom,g,void 0);}}function qM(e,t,i,r,n,o,s,a){const l=e.context,c=l.gl,h=e.transform,u=i.paint.get("fill-extrusion-pattern"),d=u.constantOr(1),p=i.paint.get("fill-extrusion-opacity"),f=e.style.enable3dLights(),m=i.paint.get(f&&!d?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),_=[i.paint.get("fill-extrusion-ambient-occlusion-intensity"),m],g=i.layout.get("fill-extrusion-edge-radius"),y=g>0&&!i.paint.get("fill-extrusion-rounded-roof"),x=y?0:g,v="globe"===h.projection.name?vb():0,b="globe"===h.projection.name,w=b?Ed(h.zoom):0,T=[Gd(h.center.lng),qd(h.center.lat)],E=i.paint.get("fill-extrusion-flood-light-color").toArray01().slice(0,3),M=i.paint.get("fill-extrusion-flood-light-intensity"),A=i.paint.get("fill-extrusion-vertical-scale"),S=$E(e,i.paint.get("fill-extrusion-cutoff-fade-range")),I=[];let C;b&&I.push("PROJECTION_GLOBE_VIEW"),_[0]>0&&I.push("FAUX_AO"),y&&I.push("ZERO_ROOF_RADIUS"),a&&I.push("HAS_CENTROID"),M>0&&I.push("FLOOD_LIGHT"),S.shouldRenderCutoff&&I.push("RENDER_CUTOFF");const z="shadow"===e.renderPass,D=e.shadowRenderer,P=z&&!!D;e.shadowRenderer&&(e.shadowRenderer.useNormalOffset=!0);let R=[0,0,0];if(D){const t=e.style.directionalLight,i=e.style.ambientLight;t&&i&&(R=BA(t,i)),C=I.concat(["SHADOWS_SINGLE_CASCADE"]);}const L=P?"fillExtrusionDepth":d?"fillExtrusionPattern":"fillExtrusion";for(const f of r){const r=t.getTile(f),m=r.getBucket(i);if(!m||m.projection.name!==h.projection.name)continue;let g=!1;D&&(g=0===D.getMaxCascadeForTile(f.toUnwrapped()));const y=e.isTileAffectedByFog(f),P=m.programConfigurations.get(i.id),k=e.getOrCreateProgram(L,{config:P,defines:g?C:I,overrideFog:y});if(e.terrain){const t=e.terrain;e.style.terrainSetForDrapingOnly(),t.setupElevationDraw(r,k,{useMeterToDem:!0});}if(!m.centroidVertexBuffer){const e=k.attributes.a_centroid_pos;void 0!==e&&c.vertexAttrib2f(e,0,0);}!z&&D&&D.setupShadows(r.tileID.toUnwrapped(),k,"vector-tile",r.tileID.overscaledZ),d&&(e.context.activeTexture.set(c.TEXTURE0),r.imageAtlasTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE),P.updatePaintBuffers());const O=u.constantOr(null);if(O&&r.imageAtlas){const e=r.imageAtlas.patternPositions[O.toString()];e&&P.setConstantPatternPositions(e);}const B=i.paint.get("fill-extrusion-vertical-gradient");let F;if(z&&D){if(YM(r.tileID,m,e))continue;const t=D.calculateShadowPassMatrixFromTile(r.tileID.toUnwrapped());F=uM(t,x,A);}else {const t=e.translatePosMatrix(f.projMatrix,r,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),n=h.projection.createInversionMatrix(h,f.canonical);F=d?dM(t,e,B,p,_,x,f,r,v,w,T,n,E,A):hM(t,e,B,p,_,x,f,v,w,T,n,E,A,M,R);}e.uploadCommonUniforms(l,k,f.toUnwrapped(),null,S);const N=[];(e.terrain||a)&&N.push(m.centroidVertexBuffer),b&&N.push(m.layoutVertexExtBuffer),k.draw(e,l.gl.TRIANGLES,n,o,s,Ex.backCCW,F,i.id,m.layoutVertexBuffer,m.indexBuffer,m.segments,i.paint,e.transform.zoom,P,N);}e.shadowRenderer&&(e.shadowRenderer.useNormalOffset=!1);}function ZM(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y){const x=e.context,v=x.gl,b=e.transform,w=e.transform.zoom,T=[],E=$E(e,i.paint.get("fill-extrusion-cutoff-fade-range"));"clear"===c?(T.push("CLEAR_SUBPASS"),y&&(T.push("CLEAR_FROM_TEXTURE"),x.activeTexture.set(v.TEXTURE0),y.bind(v.LINEAR,v.CLAMP_TO_EDGE))):"sdf"===c&&T.push("SDF_SUBPASS"),_&&T.push("HAS_CENTROID"),E.shouldRenderCutoff&&T.push("RENDER_CUTOFF");const M=i.layout.get("fill-extrusion-edge-radius"),A=(t,r,c,g,v)=>{const b=r.programConfigurations.get(i.id),A=e.isTileAffectedByFog(t),S=e.getOrCreateProgram("fillExtrusionGroundEffect",{config:b,defines:T,overrideFog:A}),I=((e,t,i,r,n,o,s,a,l,c,h)=>({u_matrix:t,u_opacity:i,u_ao_pass:r?1:0,u_meter_to_tile:n,u_ao:o,u_flood_light_intensity:s,u_flood_light_color:a,u_attenuation:l,u_edge_radius:c,u_fb:0,u_fb_size:h}))(0,g,h,l,v,[u,d*v],p,f,m,w>=17?0:M*v,y?y.size[0]:0),C=[];_&&C.push(r.hiddenByLandmarkVertexBuffer),e.uploadCommonUniforms(x,S,t.toUnwrapped(),null,E),S.draw(e,x.gl.TRIANGLES,n,o,s,a,I,i.id,r.vertexBuffer,r.indexBuffer,c,i.paint,w,b,C);};for(const n of r){const r=t.getTile(n),o=r.getBucket(i);if(!o||o.projection.name!==b.projection.name||!o.groundEffect||o.groundEffect&&!o.groundEffect.hasData())continue;const s=o.groundEffect,a=1/o.tileToMeter;{const t=e.translatePosMatrix(n.projMatrix,r,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),o=s.getDefaultSegment();A(n,s,o,t,a);}if(g)for(let o=0;o<4;o++){const s=Nu[o](n),l=t.getTile(s);if(!l)continue;const c=l.getBucket(i);if(!c||c.projection.name!==b.projection.name||!c.groundEffect||c.groundEffect&&!c.groundEffect.hasData())continue;const h=c.groundEffect;let u,d;0===o?(u=[-sr,0,0],d=1):1===o?(u=[sr,0,0],d=0):2===o?(u=[0,-sr,0],d=3):(u=[0,sr,0],d=2);const p=h.regionSegments[d];if(!p)continue;const f=new Float32Array(16);xu.translate(f,n.projMatrix,u),A(n,h,p,e.translatePosMatrix(f,r,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),a);}}}function $M(e,t,i,r,n,o,s){0===r.centroidVertexArray.length&&r.createCentroidsBuffer();const a=o?o.findDEMTileFor(i):null;if(!(a&&a.dem||s))return;const l=e=>{const i=t.getSource().minzoom,r=e=>{const i=t.getTileByID(e);if(i&&i.hasData())return i.getBucket(n)},o=[0,-1,1];for(const t of o){if(e.overscaledZ+t(c[0]=Math.min(e.min.y,t.min.y),c[1]=Math.max(e.max.y,t.max.y),c[2]=sr-t.min.x>e.max.x?t.min.x-sr:e.max.x,c),u=(e,t)=>(c[0]=Math.min(e.min.x,t.min.x),c[1]=Math.max(e.max.x,t.max.x),c[2]=sr-t.min.y>e.max.y?t.min.y-sr:e.max.y,c),d=[(e,t)=>h(e,t),(e,t)=>h(t,e),(e,t)=>u(e,t),(e,t)=>u(t,e)],p=(e,t,r,n,s,l,c)=>{if(!o)return 0;const h=[[l?r:e,l?e:r,0],[l?r:t,l?t:r,0]],u=c<0?sr+c:c,d=[l?u:(e+t)/2,l?(e+t)/2:u,0];return 0===r&&c<0||0!==r&&c>0?o.getForTilePoints(s,[d],!0,n):h.push(d),o.getForTilePoints(i,h,!0,a),Math.max(h[0][2],h[1][2],d[2])/o.exaggeration()};for(let e=0;e<4;e++){const t=r.borderFeatureIndices[e];if(0===t.length)continue;const n=Nu[e](i),a=l(n);if(!(a&&a instanceof db))continue;if(r.borderDoneWithNeighborZ[e]===a.canonical.z)continue;0===a.centroidVertexArray.length&&a.createCentroidsBuffer();const c=o?o.findDEMTileFor(n):null;if(!(c&&c.dem||s))continue;const h=(e<2?1:5)-e,u=a.borderDoneWithNeighborZ[h]!==r.canonical.z,g=a.borderFeatureIndices[h];let x=0;if(r.canonical.z!==a.canonical.z){for(const e of t)r.showCentroid(r.featuresOnBorder[e]);if(u)for(const e of g)a.showCentroid(a.featuresOnBorder[e]);r.borderDoneWithNeighborZ[e]=a.canonical.z,a.borderDoneWithNeighborZ[h]=r.canonical.z;}for(const i of t){const t=r.featuresOnBorder[i],o=r.centroidData[t.centroidDataIndex],l=t.borders[e];let u;for(;xl[0]+3||e[0]>l[0]-3)break;a.showCentroid(u),x++;}if(u&&xl[1]-3)&&(v++,++x!==g.length);)u=a.featuresOnBorder[g[x]];if(u=a.featuresOnBorder[g[i]],v>1){const e=u.borders[h];Math.abs(l[0]-e[0])<3&&Math.abs(l[1]-e[1])<3&&(v=1,x=i+1);}else if(0===v){r.showCentroid(t);continue}const b=a.centroidData[u.centroidDataIndex];s&&1===v&&(((m=o).flags|(_=b).flags)&tb?(m.flags|=tb,_.flags|=tb):(m.flags&=2147483647,_.flags&=2147483647));let w=new y(0,0);if(v>1)x=i;else if(c&&c.dem&&!(t.intersectsCount()>1||u.intersectsCount()>1)){const t=d[e](o,b),i=e%2?sr-1:0;f=p(t[0],Math.min(sr-1,t[1]),i,c,n,e<2,t[2]),w=new y(Math.ceil(7*(f+450)),0);}o.centroidXY=b.centroidXY=w,r.writeCentroidToBuffer(o),a.writeCentroidToBuffer(b);}else r.showCentroid(t);}r.borderDoneWithNeighborZ[e]=a.canonical.z,a.borderDoneWithNeighborZ[h]=r.canonical.z;}var f,m,_;(r.needsCentroidUpdate||!r.centroidVertexBuffer&&0!==r.centroidVertexArray.length)&&r.uploadCentroid(e);}const HM=[1,0,0],WM=[0,1,0],XM=[0,0,1];function YM(e,t,i){const r=i.transform,n=i.shadowRenderer;if(!n)return !0;const o=e.toUnwrapped(),s=r.tileSize*n._cascades[i.currentShadowCascade].scale;let a=t.maxHeight;if(r.elevation){const t=r.elevation.getMinMaxForTile(e);t&&(a+=t.max);}const l=[...n.shadowDirection];l[2]=-l[2];const c=n.computeSimplifiedTileShadowVolume(o,a,s,l);if(!c)return !1;const h=[HM,WM,XM,l,[l[0],0,l[2]],[0,l[1],l[2]]],u="globe"===r.projection.name,d=r.scaleZoom(s),p=$u.fromInvProjectionMatrix(r.invProjMatrix,r.worldSize,d,!u),f=n.getCurrentCascadeFrustum();return 0===p.intersectsPrecise(c.vertices,c.planes,h)||0===f.intersectsPrecise(c.vertices,c.planes,h)}const KM=new li(1,0,0,1),JM=new li(0,1,0,1),QM=new li(0,0,1,1),eA=new li(1,0,1,1),tA=new li(0,1,1,1);function iA(e,t,i){const r=e.context,n=e.transform,o=r.gl,s="globe"===n.projection.name,a=s?["PROJECTION_GLOBE_VIEW"]:[];let l=i.projMatrix;if(s&&Ed(n.zoom)>0){const e=vd(cd(i.canonical,n));l=xu.multiply(new Float32Array(16),n.globeMatrix,e),xu.multiply(l,n.projMatrix,l);}const c=e.getOrCreateProgram("debug",{defines:a}),h=t.getTileByID(i.key);e.terrain&&e.terrain.setupElevationDraw(h,c);const u=gx.disabled,d=xx.disabled,p=e.colorModeForRenderPass(),f="$debug";r.activeTexture.set(o.TEXTURE0),e.emptyTexture.bind(o.LINEAR,o.CLAMP_TO_EDGE),s?h._makeGlobeTileDebugBuffers(e.context,n):h._makeDebugTileBoundsBuffers(e.context,n.projection);const m=h._tileDebugBuffer||e.debugBuffer,_=h._tileDebugIndexBuffer||e.debugIndexBuffer,g=h._tileDebugSegments||e.debugSegments;c.draw(e,o.LINE_STRIP,u,d,p,Ex.disabled,yM(l,li.red),f,m,_,g,null,null,null,[h._globeTileDebugBorderBuffer]);const y=h.latestRawTileData,x=Math.floor((y&&y.byteLength||0)/1024),v=t.getTile(i).tileSize,b=512/Math.min(v,512)*(i.overscaledZ/n.zoom)*.5;let w=i.canonical.toString();i.overscaledZ!==i.canonical.z&&(w+=` => ${i.overscaledZ}`),w+=` ${x}kb`,function(e,t){e.initDebugOverlayCanvas();const i=e.debugOverlayCanvas,r=e.context.gl,n=e.debugOverlayCanvas.getContext("2d");n.clearRect(0,0,i.width,i.height),n.shadowColor="white",n.shadowBlur=2,n.lineWidth=1.5,n.strokeStyle="white",n.textBaseline="top",n.font="bold 36px Open Sans, sans-serif",n.fillText(t,5,5),n.strokeText(t,5,5),e.debugOverlayTexture.update(i),e.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE);}(e,w);const T=h._tileDebugTextBuffer||e.debugBuffer,E=h._tileDebugTextIndexBuffer||e.quadTriangleIndexBuffer,M=h._tileDebugTextSegments||e.debugSegments;c.draw(e,o.TRIANGLES,u,d,bx.alphaBlended,Ex.disabled,yM(l,li.transparent,b),f,T,E,M,null,null,null,[h._globeTileDebugTextBuffer]);}function rA(e,t,i,r){oA(e,0,t+i/2,e.transform.width,i,r);}function nA(e,t,i,r){oA(e,t-i/2,0,i,e.transform.height,r);}function oA(e,t,i,r,n,o){const s=e.context,a=s.gl;a.enable(a.SCISSOR_TEST),a.scissor(t*ht.devicePixelRatio,i*ht.devicePixelRatio,r*ht.devicePixelRatio,n*ht.devicePixelRatio),s.clear({color:o}),a.disable(a.SCISSOR_TEST);}const sA=ba([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:aA}=sA;function lA(e,t,i,r){e.emplaceBack(t,i,r);}class cA{constructor(e){this.vertexArray=new Ua,this.indices=new Va,lA(this.vertexArray,-1,-1,1),lA(this.vertexArray,1,-1,1),lA(this.vertexArray,-1,1,1),lA(this.vertexArray,1,1,1),lA(this.vertexArray,-1,-1,-1),lA(this.vertexArray,1,-1,-1),lA(this.vertexArray,-1,1,-1),lA(this.vertexArray,1,1,-1),this.indices.emplaceBack(5,1,3),this.indices.emplaceBack(3,7,5),this.indices.emplaceBack(6,2,0),this.indices.emplaceBack(0,4,6),this.indices.emplaceBack(2,6,7),this.indices.emplaceBack(7,3,2),this.indices.emplaceBack(5,4,0),this.indices.emplaceBack(0,1,5),this.indices.emplaceBack(0,2,3),this.indices.emplaceBack(3,1,0),this.indices.emplaceBack(7,6,4),this.indices.emplaceBack(4,5,7),this.vertexBuffer=e.createVertexBuffer(this.vertexArray,aA),this.indexBuffer=e.createIndexBuffer(this.indices),this.segment=dl.simpleSegment(0,0,36,12);}}function hA(e,t,i,r,n,o){const s=e.context.gl,a=t.paint.get("sky-atmosphere-color"),l=t.paint.get("sky-atmosphere-halo-color"),c=t.paint.get("sky-atmosphere-sun-intensity"),h=((e,t,i,r,n)=>({u_matrix_3f:e,u_sun_direction:t,u_sun_intensity:i,u_color_tint_r:[r.r,r.g,r.b,r.a],u_color_tint_m:[n.r,n.g,n.b,n.a],u_luminance:5e-5}))(gu.fromMat4(gu.create(),r),n,c,a,l);s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+o,t.skyboxTexture,0),i.draw(e,s.TRIANGLES,gx.disabled,xx.disabled,bx.unblended,Ex.frontCW,h,"skyboxCapture",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment);}const uA=ba([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class dA{constructor(e){const t=new Za;t.emplaceBack(-1,1,1,0,0),t.emplaceBack(1,1,1,1,0),t.emplaceBack(1,-1,1,1,1),t.emplaceBack(-1,-1,1,0,1);const i=new Va;i.emplaceBack(0,1,2),i.emplaceBack(2,3,0),this.vertexBuffer=e.createVertexBuffer(t,uA.members),this.indexBuffer=e.createIndexBuffer(i),this.segments=dl.simpleSegment(0,0,4,2);}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy();}}const pA=ba([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_size_scale",components:1},{type:"Float32",name:"a_fade_opacity",components:1}]);class fA{constructor(){this.colorModeAlphaBlendedWriteRGB=new bx([1,vx,1,vx],li.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new bx([1,0,1,0],li.transparent,[!1,!1,!1,!0]);}update(e){const t=e.context;if(!this.atmosphereBuffer){this.atmosphereBuffer=new dA(t);const e=100,i=200,r=function(e){const t=$n(30),i=[];for(let e=0;e<16e3;++e){const e=2*Math.PI*t(),r=Math.acos(1-2*t())-.5*Math.PI;i.push(Mu.fromValues(Math.cos(r)*Math.cos(e),Math.cos(r)*Math.sin(e),Math.sin(r)));}return i}(),n=$n(300),o=new $a,s=new Va;let a=0;for(let t=0;t{const h="globe"===n.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];t&&h.push("ALPHA_PASS");const d=e.getOrCreateProgram("globeAtmosphere",{defines:h}),f=((e,t,i,r,n,o,s,a,l,c,h,u)=>({u_frustum_tl:e,u_frustum_tr:t,u_frustum_br:i,u_frustum_bl:r,u_horizon:n,u_transition:o,u_fadeout_range:s,u_color:a,u_high_color:l,u_space_color:c,u_temporal_offset:h,u_horizon_angle:u}))(n.frustumCorners.TL,n.frustumCorners.TR,n.frustumCorners.BR,n.frustumCorners.BL,n.frustumCorners.horizon,s,u,a,l,c,p,_);e.uploadCommonUniforms(i,d);const m=this.atmosphereBuffer;m&&d.draw(e,r.TRIANGLES,o,xx.disabled,t?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,Ex.backCW,f,t?"atmosphere_glow_alpha":"atmosphere_glow",m.vertexBuffer,m.indexBuffer,m.segments);};g(!1),g(!0);}drawStars(e,t){const i=z(t.properties.get("star-intensity"),0,1);if(0===i)return;const r=e.context,n=r.gl,o=e.transform,s=e.getOrCreateProgram("stars"),a=bu.identity([]);bu.rotateX(a,a,-o._pitch),bu.rotateZ(a,a,-o.angle),bu.rotateX(a,a,w(o._center.lat)),bu.rotateY(a,a,-w(o._center.lng));const l=xu.fromQuat(new Float32Array(16),a),c=xu.multiply([],o.starsProjMatrix,l),h=gu.fromMat4([],l),u=gu.invert([],h),d=[0,1,0];Mu.transformMat3(d,d,u),Mu.scale(d,d,.15);const p=[1,0,0];Mu.transformMat3(p,p,u),Mu.scale(p,p,.15);const f=((e,t,i,r)=>({u_matrix:Float32Array.from(e),u_up:t,u_right:i,u_intensity_multiplier:r}))(c,d,p,i);e.uploadCommonUniforms(r,s),this.starsVx&&this.starsIdx&&s.draw(e,n.TRIANGLES,gx.disabled,xx.disabled,this.colorModeAlphaBlendedWriteRGB,Ex.disabled,f,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments);}}function mA(e,t){const i=[...e],r=t.cameraWorldSizeForFog/t.worldSize,n=xu.identity([]);return xu.scale(n,n,[r,r,1]),xu.multiply(i,n,i),xu.multiply(i,t.worldToFogMatrix,i),i}function _A(e,t,i,r){const n=i.material,o=r.context,{baseColorTexture:s,metallicRoughnessTexture:a}=n.pbrMetallicRoughness,{normalTexture:l,occlusionTexture:c,emissionTexture:h}=n;function u(t,i,r){if(t&&(e.push(i),o.activeTexture.set(o.gl.TEXTURE0+r),t.gfxTexture)){const{minFilter:e,magFilter:i,wrapS:r,wrapT:n}=t.sampler;t.gfxTexture.bindExtraParam(e,i,r,n);}}u(s,"HAS_TEXTURE_u_baseColorTexture",zM.BaseColor),u(a,"HAS_TEXTURE_u_metallicRoughnessTexture",zM.MetallicRoughness),u(l,"HAS_TEXTURE_u_normalTexture",zM.Normal),u(c,"HAS_TEXTURE_u_occlusionTexture",zM.Occlusion),u(h,"HAS_TEXTURE_u_emissionTexture",zM.Emission),i.texcoordBuffer&&(e.push("HAS_ATTRIBUTE_a_uv_2f"),t.push(i.texcoordBuffer)),i.colorBuffer&&(e.push(12===i.colorBuffer.itemSize?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),t.push(i.colorBuffer)),i.normalBuffer&&(e.push("HAS_ATTRIBUTE_a_normal_3f"),t.push(i.normalBuffer)),i.pbrBuffer&&(e.push("HAS_ATTRIBUTE_a_pbr"),e.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),t.push(i.pbrBuffer)),"OPAQUE"!==n.alphaMode&&"MASK"!==n.alphaMode||e.push("UNPREMULT_TEXTURE_IN_SHADER"),n.defined||e.push("DIFFUSE_SHADED"),e.push("USE_STANDARD_DERIVATIVES");}function gA(e,t,i,r,n,o){const s=i.paint.get("model-opacity"),a=t.context,l=new gx(t.context.gl.LEQUAL,gx.ReadWrite,t.depthRangeFor3D),c=t.transform,h=e.mesh,u=h.material,d=u.pbrMetallicRoughness,p=t.style.fog;let f;f="pixels"===t.transform.projection.zAxisUnit?[...e.nodeModelMatrix]:xu.multiply([],r.zScaleMatrix,e.nodeModelMatrix),xu.multiply(f,r.negCameraPosMatrix,f);const m=xu.invert([],f);xu.transpose(m,m);const _=DM(new Float32Array(e.worldViewProjection),new Float32Array(f),new Float32Array(m),t,s,d.baseColorFactor,u.emissiveFactor,d.metallicFactor,d.roughnessFactor,u,i),g={defines:[]},y=[];_A(g.defines,y,h,t);const x=t.shadowRenderer;x&&(x.useNormalOffset=!1);let v=null;if(p){const i=mA(e.nodeModelMatrix,t.transform);if(v=new Float32Array(i),"globe"!==c.projection.name){const e=h.aabb.min,t=h.aabb.max,[r,n]=p.getOpacityForBounds(i,e[0],e[1],t[0],t[1]);g.overrideFog=r>=sw||n>=sw;}}const b=$E(t,i.paint.get("model-cutoff-fade-range"));b.shouldRenderCutoff&&g.defines.push("RENDER_CUTOFF");const w=t.getOrCreateProgram("model",g);t.uploadCommonUniforms(a,w,null,v,b),"shadow"!==t.renderPass&&x&&x.setupShadowsFromMatrix(e.nodeModelMatrix,w),w.draw(t,a.gl.TRIANGLES,l,n,o,h.material.doubleSided?Ex.disabled:Ex.backCCW,_,i.id,h.vertexBuffer,h.indexBuffer,h.segments,i.paint,t.transform.zoom,void 0,y);}function yA(e,t,i,r,n,o,s){let a;a="globe"===e.projection.name?yv(i,e):[...i],xu.multiply(a,a,t.matrix);const l=xu.multiply([],r,a);if(t.meshes)for(const e of t.meshes){if("BLEND"!==e.material.alphaMode){s.push({mesh:e,depth:0,modelIndex:n,worldViewProjection:l,nodeModelMatrix:a});continue}const t=Mu.transformMat4([],e.centroid,l);t[2]>0&&o.push({mesh:e,depth:t[2],modelIndex:n,worldViewProjection:l,nodeModelMatrix:a});}if(t.children)for(const a of t.children)yA(e,a,i,r,n,o,s);}function xA(e,t,i,r){const n=i.shadowRenderer;if(!n)return;const o=n.getShadowPassDepthMode(),s=n.getShadowPassColorMode(),a=n.calculateShadowPassMatrixFromMatrix(t),l=RM(a);i.getOrCreateProgram("modelDepth",{defines:["DEPTH_TEXTURE"]}).draw(i,i.context.gl.TRIANGLES,o,xx.disabled,s,Ex.backCCW,l,r.id,e.vertexBuffer,e.indexBuffer,e.segments,r.paint,i.transform.zoom,void 0,void 0);}function vA(e,t,i){const r=t.updateZoomBasedPaintProperties(),n=function(e,t,i){let r,n,o,s=e.terrain?e.terrain.exaggeration():0;if(e.terrain&&s>0){const t=e.terrain,n=t.findDEMTileFor(i);n&&n.dem?r=qm.create(t,i,n):s=0;}if(0===s&&(t.terrainElevationMin=0,t.terrainElevationMax=0),s===t.validForExaggeration&&(0===s||r&&r._demTile&&r._demTile.tileID===t.validForDEMTile.id&&r._dem._timestamp===t.validForDEMTile.timestamp))return !1;for(const e in t.instancesPerModel){const i=t.instancesPerModel[e];for(let e=0;ec&&(c=t.max);}const h=z(r.x,o,s)-r.x,u=z(r.y,a,l)-r.y,d=Zd(c,t.center.lat)-r.z;return t._zoomFromMercatorZ(Math.sqrt(h*h+u*u+d*d))}function TA(e,t,i,r,n,o,s){const a=e.context,l="shadow"===e.renderPass,c=e.shadowRenderer,h=l&&c?c.getShadowPassDepthMode():new gx(a.gl.LEQUAL,gx.ReadWrite,e.depthRangeFor3D),u=e.isTileAffectedByFog(o);if(i.meshes)for(const d of i.meshes){const p=["MODEL_POSITION_ON_GPU"],f=[];let m,_,g;r.instancedDataArray.length>20&&p.push("INSTANCED_ARRAYS");const y=$E(e,t.paint.get("model-cutoff-fade-range"));if(y.shouldRenderCutoff&&p.push("RENDER_CUTOFF"),l&&c)m=e.getOrCreateProgram("modelDepth",{defines:p}),_=RM(s.shadowTileMatrix,s.shadowTileMatrix,Float32Array.from(i.matrix)),g=c.getShadowPassColorMode();else {_A(p,f,d,e),m=e.getOrCreateProgram("model",{defines:p,overrideFog:u});const r=d.material,l=r.pbrMetallicRoughness,h=t.paint.get("model-opacity");_=DM(o.projMatrix,Float32Array.from(i.matrix),new Float32Array(16),e,h,l.baseColorFactor,r.emissiveFactor,l.metallicFactor,l.roughnessFactor,r,t,n),c&&(s.shadowUniformsInitialized?m.setShadowUniformValues(a,c.getShadowUniformValues()):(c.setupShadows(o.toUnwrapped(),m,"model-tile",o.overscaledZ),s.shadowUniformsInitialized=!0)),g=y.shouldRenderCutoff||h<1||"OPAQUE"!==r.alphaMode?bx.alphaBlended:bx.unblended;}e.uploadCommonUniforms(a,m,o.toUnwrapped(),null,y);const x=d.material.doubleSided?Ex.disabled:Ex.backCCW;if(r.instancedDataArray.length>20)f.push(r.instancedDataBuffer),m.draw(e,a.gl.TRIANGLES,h,xx.disabled,g,x,_,t.id,d.vertexBuffer,d.indexBuffer,d.segments,t.paint,e.transform.zoom,void 0,f,r.instancedDataArray.length);else {const i=l?"u_instance":"u_normal_matrix";for(let n=0;n30&&(i.buf.destroy(),this._storage.delete(t));}destroy(){for(const[e,t]of this._storage)t.buf.destroy(),this._storage.delete(e);}}const IA={symbol:function(e,t,i,r,n){if("translucent"!==e.renderPass)return;const o=xx.disabled,s=e.colorModeForRenderPass();i.layout.get("text-variable-anchor")&&function(e,t,i,r,n,o,s){const a=t.transform,l="map"===n,c="map"===o;for(const t of e){const e=r.getTile(t),n=e.getBucket(i);if(!n||!n.text||!n.text.segments.get().length)continue;const o=a_(n.textSizeData,a.zoom),h=GT(t,n.getProjection(),a),u=a.calculatePixelsToTileUnitsMatrix(e),d=Jx(h,e.tileID.canonical,c,l,a,n.getProjection(),u),p=n.hasIconTextFit()&&n.hasIconData();if(o){const i=Math.pow(2,a.zoom-e.tileID.overscaledZ);NM(n,l,c,s,l_,a,d,t,i,o,p);}}}(r,e,i,t,i.layout.get("text-rotation-alignment"),i.layout.get("text-pitch-alignment"),n),0!==i.paint.get("icon-opacity").constantOr(1)&&VM(e,t,i,r,!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"),o,s),0!==i.paint.get("text-opacity").constantOr(1)&&VM(e,t,i,r,!0,i.paint.get("text-translate"),i.paint.get("text-translate-anchor"),i.layout.get("text-rotation-alignment"),i.layout.get("text-pitch-alignment"),i.layout.get("text-keep-upright"),o,s),t.map.showCollisionBoxes&&(OM(e,t,i,r,i.paint.get("text-translate"),i.paint.get("text-translate-anchor"),!0),OM(e,t,i,r,i.paint.get("icon-translate"),i.paint.get("icon-translate-anchor"),!1));},circle:function(e,t,i,r){if("translucent"!==e.renderPass)return;const n=i.paint.get("circle-opacity"),o=i.paint.get("circle-stroke-width"),s=i.paint.get("circle-stroke-opacity"),a=void 0!==i.layout.get("circle-sort-key").constantOr(1),l=i.paint.get("circle-emissive-strength");if(0===n.constantOr(1)&&(0===o.constantOr(1)||0===s.constantOr(1)))return;const c=e.context,h=c.gl,u=e.transform,d=e.depthModeForSublayer(0,gx.ReadOnly),p=xx.disabled,f=e.colorModeForDrapableLayerRenderPass(l),m="globe"===u.projection.name,_=[Gd(u.center.lng),qd(u.center.lat)],g=[];for(let n=0;ne.sortKey-t.sortKey));const y={useDepthForOcclusion:u.depthOcclusionForSymbolsAndCircles};for(const t of g){const{programConfiguration:r,program:n,layoutVertexBuffer:o,globeExtVertexBuffer:s,indexBuffer:a,uniformValues:l,tile:m}=t.state,_=t.segments;e.terrain&&e.terrain.setupElevationDraw(m,n,y),e.uploadCommonUniforms(c,n,m.tileID.toUnwrapped()),n.draw(e,h.TRIANGLES,d,p,f,Ex.disabled,l,i.id,o,a,_,i.paint,u.zoom,r,[s]);}},heatmap:function(e,t,i,r){if(0!==i.paint.get("heatmap-opacity"))if("offscreen"===e.renderPass){const n=e.context,o=n.gl,s=xx.disabled,a=new bx([o.ONE,o.ONE,o.ONE,o.ONE],li.transparent,[!0,!0,!0,!0]);!function(e,t,i,r){const n=e.gl,o=t.width*r,s=t.height*r;e.activeTexture.set(n.TEXTURE1),e.viewport.set([0,0,o,s]);let a=i.heatmapFbo;if(!a||a&&(a.width!==o||a.height!==s)){a&&a.destroy();const t=n.createTexture();n.bindTexture(n.TEXTURE_2D,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),a=i.heatmapFbo=e.createFramebuffer(o,s,!0,null),function(e,t,i,r,n,o){const s=e.gl;s.texImage2D(s.TEXTURE_2D,0,e.extRenderToTextureHalfFloat?s.RGBA16F:s.RGBA,n,o,0,s.RGBA,e.extRenderToTextureHalfFloat?s.HALF_FLOAT:s.UNSIGNED_BYTE,null),r.colorAttachment.set(i);}(e,0,t,a,o,s);}else n.bindTexture(n.TEXTURE_2D,a.colorAttachment.get()),e.bindFramebuffer.set(a.framebuffer);}(n,e,i,"globe"===e.transform.projection.name?.5:.25),n.clear({color:li.transparent});const l=e.transform,c="globe"===l.projection.name,h=c?["PROJECTION_GLOBE_VIEW"]:[],u=c?Ex.frontCCW:Ex.disabled,d=[Gd(l.center.lng),qd(l.center.lat)];for(let p=0;p({u_image:0,u_color_ramp:1,u_opacity:t.paint.get("heatmap-opacity")}))(0,t),t.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,t.paint,e.transform.zoom);}(e,i));},line:function(e,t,i,r){if("translucent"!==e.renderPass)return;const n=i.paint.get("line-opacity"),o=i.paint.get("line-width");if(0===n.constantOr(1)||0===o.constantOr(1))return;const s=i.paint.get("line-emissive-strength"),a=e.depthModeForSublayer(0,gx.ReadOnly),l=e.colorModeForDrapableLayerRenderPass(s),c=e.terrain&&e.terrain.renderingToTexture?1:ht.devicePixelRatio,h=i.paint.get("line-dasharray"),u=h.constantOr(1),d=i.layout.get("line-cap"),p=i.paint.get("line-pattern"),f=p.constantOr(1),m=i.paint.get("line-pattern").constantOr(1),_=1!==i.paint.get("line-opacity").constantOr(1);let g=!m&&_;const y=i.paint.get("line-gradient"),x=f?"linePattern":"line",v=e.context,b=v.gl,w=kb(i);e.terrain&&e.terrain.clipOrMaskOverlapStencilType()&&(g=!1);for(const n of r){const r=t.getTile(n);if(f&&!r.patternsLoaded())continue;const o=r.getBucket(i);if(!o)continue;e.prepareDrawTile();const s=o.programConfigurations.get(i.id),m=e.isTileAffectedByFog(n),_=e.getOrCreateProgram(x,{config:s,defines:w,overrideFog:m}),T=p.constantOr(null);if(T&&r.imageAtlas){const e=r.imageAtlas.patternPositions[T.toString()];e&&s.setConstantPatternPositions(e);}const E=h.constantOr(null),M=d.constantOr(null);if(!f&&E&&M&&r.lineAtlas){const e=r.lineAtlas.getDash(E,M);e&&s.setConstantPatternPositions(e);}let[A,S]=i.paint.get("line-trim-offset");if("round"===M||"square"===M){const e=1;A!==S&&(0===A&&(A-=e),1===S&&(S+=e));}const I=e.terrain?n.projMatrix:null,C=f?Pb(e,r,i,I,c):Db(e,r,i,I,o.lineClipsArray.length,c,[A,S]);if(y){const r=o.gradients[i.id];let s=r.texture;if(i.gradientVersion!==r.version){let a=256;if(i.stepInterpolant){const i=t.getSource().maxzoom,r=n.canonical.z===i?Math.ceil(1<{_.draw(e,b.TRIANGLES,a,t,l,Ex.disabled,C,i.id,o.layoutVertexBuffer,o.indexBuffer,o.segments,i.paint,e.transform.zoom,s,[o.layoutVertexBuffer2]);};if(g){const t=e.stencilModeForClipping(n).ref;0===t&&e.terrain&&v.clear({stencil:0});const i={func:b.EQUAL,mask:255};C.u_alpha_discard_threshold=.8,D(new xx(i,t,255,b.KEEP,b.KEEP,b.INVERT)),C.u_alpha_discard_threshold=0,D(new xx(i,t,255,b.KEEP,b.KEEP,b.KEEP));}else D(e.stencilModeForClipping(n));}g&&(e.resetStencilClippingMasks(),e.terrain&&v.clear({stencil:0}));},fill:function(e,t,i,r){const n=i.paint.get("fill-color"),o=i.paint.get("fill-opacity");if(0===o.constantOr(1))return;const s=i.paint.get("fill-emissive-strength"),a=e.colorModeForDrapableLayerRenderPass(s),l=i.paint.get("fill-pattern"),c=e.opaquePassEnabledForLayer()&&!l.constantOr(1)&&1===n.constantOr(li.transparent).a&&1===o.constantOr(0)?"opaque":"translucent";if(e.renderPass===c){const n=e.depthModeForSublayer(1,"opaque"===e.renderPass?gx.ReadWrite:gx.ReadOnly);GM(e,t,i,r,n,a,!1);}if("translucent"===e.renderPass&&i.paint.get("fill-antialias")){const n=e.depthModeForSublayer(i.getPaintProperty("fill-outline-color")?2:0,gx.ReadOnly);GM(e,t,i,r,n,a,!0);}},"fill-extrusion":function(e,t,i,r){const n=i.paint.get("fill-extrusion-opacity"),o=e.context,s=o.gl,a=e.terrain,l=a&&a.renderingToTexture,c=i.paint.get("fill-extrusion-cutoff-fade-range");if(0===n)return;const h=e.conflationActive&&e.layerUsedInConflation(i,t.getSource());if(h&&function(e,t,i,r){for(const n of r){const r=t.getTile(n).getBucket(i);r&&(r.updateReplacement(n,e.replacementSource),r.uploadCentroid(e.context));}}(e,t,i,r),a||h)for(const n of r){const r=t.getTile(n).getBucket(i);r&&$M(e.context,t,n,r,i,a,h);}if("shadow"===e.renderPass&&e.shadowRenderer){const o=e.shadowRenderer;if(a&&n<.65&&i._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof bo)return;const s=o.getShadowPassDepthMode(),l=o.getShadowPassColorMode();qM(e,t,i,r,s,xx.disabled,l,h);}else if("translucent"===e.renderPass){const u=!i.paint.get("fill-extrusion-pattern").constantOr(1);if(!l){const o=new gx(e.context.gl.LEQUAL,gx.ReadWrite,e.depthRangeFor3D);0===c&&1===n&&u?qM(e,t,i,r,o,xx.disabled,bx.unblended,h):(qM(e,t,i,r,o,xx.disabled,bx.disabled,h),qM(e,t,i,r,o,e.stencilModeFor3D(),e.colorModeForRenderPass(),h),e.resetStencilClippingMasks());}if(e.style.enable3dLights()&&u&&(!a&&"globe"!==e.transform.projection.name||l)){const n=i.paint.get("fill-extrusion-opacity"),c=i.paint.get("fill-extrusion-ambient-occlusion-intensity"),u=i.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),d=i.paint.get("fill-extrusion-flood-light-intensity"),p=i.paint.get("fill-extrusion-flood-light-color").toArray01().slice(0,3),f=c>0&&u>0,m=d>0,_=(e,t,i)=>(1-i)*e+i*t,g=o=>{const a=e.depthModeForSublayer(1,gx.ReadOnly,s.LEQUAL,!0),l=i.paint.get(o?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),f=_(.1,3,l),m=e._showOverdrawInspector;if(!m){const l=new xx({func:s.ALWAYS,mask:255},255,255,s.KEEP,s.KEEP,s.REPLACE),m=new bx([s.ONE,s.ONE,s.ONE,s.ONE],li.transparent,[!1,!1,!1,!0],s.MIN);ZM(e,t,i,r,a,l,m,Ex.disabled,o,"sdf",n,c,u,d,p,f,h,!1);}{const l=m?xx.disabled:new xx({func:s.EQUAL,mask:255},255,255,s.KEEP,s.DECR,s.DECR),_=m?e.colorModeForRenderPass():new bx([s.ONE_MINUS_DST_ALPHA,s.DST_ALPHA,s.ONE,s.ONE],li.transparent,[!0,!0,!0,!0]);ZM(e,t,i,r,a,l,_,Ex.disabled,o,"color",n,c,u,d,p,f,h,!1);}};if(l){const l=(o,a,l)=>{const f=e.depthModeForSublayer(1,gx.ReadOnly,s.LEQUAL,!1),m=i.paint.get(o?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),g=_(.1,3,m);{const l=new bx([s.ONE,s.ONE,s.ONE,s.ONE],li.transparent,[!1,!1,!1,!0]);ZM(e,t,i,r,f,xx.disabled,l,Ex.disabled,o,"clear",n,c,u,d,p,g,h,a);}{const l=new xx({func:s.ALWAYS,mask:255},255,255,s.KEEP,s.KEEP,s.REPLACE),m=new bx([s.ONE,s.ONE,s.ONE,s.ONE],li.transparent,[!1,!1,!1,!0],s.MIN);ZM(e,t,i,r,f,l,m,Ex.disabled,o,"sdf",n,c,u,d,p,g,h,a);}{const l=o?s.ZERO:s.ONE_MINUS_DST_ALPHA,m=new xx({func:s.EQUAL,mask:255},255,255,s.KEEP,s.DECR,s.DECR),_=new bx([l,s.DST_ALPHA,s.ONE_MINUS_DST_ALPHA,s.ZERO],li.transparent,[!0,!0,!0,!0]);ZM(e,t,i,r,f,m,_,Ex.disabled,o,"color",n,c,u,d,p,g,h,a);}{const m=new bx([s.ONE,s.ONE,s.ONE,o?s.ZERO:s.ONE],li.transparent,[!1,!1,!1,!0],o?s.FUNC_ADD:s.MAX);ZM(e,t,i,r,f,xx.disabled,m,Ex.disabled,o,"clear",n,c,u,d,p,g,h,a,l);}};if(f||m){let t;if(e.prepareDrawTile(),a){const e=a.drapeBufferSize[0],i=a.drapeBufferSize[1];t=a.framebufferCopyTexture,t&&(!t||t.size[0]===e&&t.size[1]===i)||(t&&t.destroy(),t=a.framebufferCopyTexture=new gy(o,new $p({width:e,height:i}),s.RGBA)),t.bind(s.LINEAR,s.CLAMP_TO_EDGE),s.copyTexImage2D(s.TEXTURE_2D,0,s.RGBA,0,0,e,i,0);}f&&l(!0,!1,t),m&&l(!1,!0,t);}}else f&&g(!0),m&&g(!1);}}},hillshade:function(e,t,i,r){if("offscreen"!==e.renderPass&&"translucent"!==e.renderPass)return;const n=e.context,o=e.terrain&&e.terrain.renderingToTexture,[s,a]="translucent"!==e.renderPass||o?[{},r]:e.stencilConfigForOverlap(r);for(const r of a){const n=t.getTile(r);if(n.needsHillshadePrepare&&"offscreen"===e.renderPass)jE(e,n,i);else if("translucent"===e.renderPass){const t=e.depthModeForSublayer(0,gx.ReadOnly),a=i.paint.get("hillshade-emissive-strength"),l=e.colorModeForDrapableLayerRenderPass(a),c=o&&e.terrain?e.terrain.stencilModeForRTTOverlap(r):s[r.overscaledZ];UE(e,r,n,i,t,c,l);}}n.viewport.set([0,0,e.width,e.height]),e.resetStencilClippingMasks();},raster:function(e,t,i,r,n,o){if("translucent"!==e.renderPass)return;if(0===i.paint.get("raster-opacity"))return;const s=e.context,a=s.gl,l=t.getSource(),c=function(e,t,i){const r=[];let n,o;if(e.paint.get("raster-color")){r.push("RASTER_COLOR"),n=e.paint.get("raster-color-mix"),o=e.paint.get("raster-color-range"),t.activeTexture.set(i.TEXTURE2);let s=e.colorRampTexture;s||(s=e.colorRampTexture=new gy(t,e.colorRamp,i.RGBA)),s.bind(i.LINEAR,i.CLAMP_TO_EDGE);}return {mix:n,range:o,defines:r}}(i,s,a),h=c.defines;let u=!1;if(l instanceof qb&&!r.length){if("globe"!==e.transform.projection.name)return;if(l.onNorthPole)u=!0,h.push("PROJECTION_GLOBE_VIEW");else {if(!l.onSouthPole)return;u=!0,h.push("PROJECTION_GLOBE_VIEW");}}const d=e.colorModeForDrapableLayerRenderPass(),p=e.terrain&&e.terrain.renderingToTexture,f=!e.options.moving,m="nearest"===i.paint.get("raster-resampling")?a.NEAREST:a.LINEAR;if(u){const r=t.getSource();if(!(r instanceof qb))return;const n=r.texture;if(!n)return;const o=e.globeSharedBuffers;if(!o)return;const l=new gx(a.LEQUAL,gx.ReadWrite,e.depthRangeFor3D),h=Float32Array.from(e.transform.projMatrix);let u=Md(0,0,e.transform);const p=Float32Array.from(xd(ad(new ku(0,0,0)))),f={opacity:1,mix:0};e.terrain&&e.terrain.prepareDrawTile(),s.activeTexture.set(a.TEXTURE0),n.bind(m,a.CLAMP_TO_EDGE),s.activeTexture.set(a.TEXTURE1),n.bind(m,a.CLAMP_TO_EDGE),n.useMipmap&&s.extTextureFilterAnisotropic&&e.transform.pitch>20&&a.texParameterf(a.TEXTURE_2D,s.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,s.extTextureFilterAnisotropicMax);const[_,g,y,x]=o.getPoleBuffers(0,!0);let v;r.onNorthPole?(v=_,e.renderDefaultNorthPole=!1):(u=xu.scale(xu.create(),u,[1,-1,1]),v=g,e.renderDefaultSouthPole=!1);const b=bM(h,p,u,[0,0],1,f,i,r.perspectiveTransform||[0,0],2,c.mix||[0,0,0,0],c.range||[0,0]),w=e.getOrCreateProgram("raster",{defines:c.defines});return e.uploadCommonUniforms(s,w,null),void w.draw(e,a.TRIANGLES,l,xx.disabled,d,Ex.disabled,b,i.id,v,y,x)}if(!r.length)return;const[_,g]=l instanceof qb||p?[{},r]:e.stencilConfigForOverlap(r),y=g[g.length-1].overscaledZ;for(const r of g){const n=p?gx.disabled:e.depthModeForSublayer(r.overscaledZ-y,1===i.paint.get("raster-opacity")?gx.ReadWrite:gx.ReadOnly,a.LESS),h=r.toUnwrapped(),u=t.getTile(r);if(p&&(!u||!u.hasData()))continue;if(!u.texture)continue;const g=p?r.projMatrix:e.transform.calculateProjMatrix(h,f),x=e.terrain&&p?e.terrain.stencilModeForRTTOverlap(r):_[r.overscaledZ],v=o?0:i.paint.get("raster-fade-duration");u.registerFadeDuration(v);const b=t.findLoadedParent(r,0),w=QE(u,b,t,e.transform,v);let T,E;e.terrain&&e.terrain.prepareDrawTile(),s.activeTexture.set(a.TEXTURE0),u.texture.bind(m,a.CLAMP_TO_EDGE),s.activeTexture.set(a.TEXTURE1),b?(b.texture.bind(m,a.CLAMP_TO_EDGE),T=Math.pow(2,b.tileID.overscaledZ-u.tileID.overscaledZ),E=[u.tileID.canonical.x*T%1,u.tileID.canonical.y*T%1]):u.texture.bind(m,a.CLAMP_TO_EDGE),u.texture.useMipmap&&s.extTextureFilterAnisotropic&&e.transform.pitch>20&&a.texParameterf(a.TEXTURE_2D,s.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,s.extTextureFilterAnisotropicMax);const M=l instanceof qb?l.perspectiveTransform:[0,0],A=new Float32Array(16),S=bM(g,A,A,E||[0,0],T||1,w,i,M,2,c.mix||[0,0,0,0],c.range||[0,0]),I=e.isTileAffectedByFog(r),C=e.getOrCreateProgram("raster",{defines:c.defines,overrideFog:I});if(e.uploadCommonUniforms(s,C,h),l instanceof qb)l.boundsBuffer&&l.boundsSegments&&C.draw(e,a.TRIANGLES,n,xx.disabled,d,Ex.disabled,S,i.id,l.boundsBuffer,e.quadTriangleIndexBuffer,l.boundsSegments);else {const{tileBoundsBuffer:t,tileBoundsIndexBuffer:r,tileBoundsSegments:o}=e.getTileBoundsBuffers(u);C.draw(e,a.TRIANGLES,n,x,d,Ex.disabled,S,i.id,t,r,o);}}e.resetStencilClippingMasks();},background:function(e,t,i,r){const n=i.paint.get("background-color"),o=i.paint.get("background-opacity"),s=i.paint.get("background-emissive-strength");if(0===o)return;const a=e.context,l=a.gl,c=e.transform,h=c.tileSize,u=i.paint.get("background-pattern");if(e.isPatternMissing(u,i.scope))return;const d=!u&&1===n.a&&1===o&&e.opaquePassEnabledForLayer()?"opaque":"translucent";if(e.renderPass!==d)return;const p=xx.disabled,f=e.depthModeForSublayer(0,"opaque"===d?gx.ReadWrite:gx.ReadOnly),m=e.colorModeForDrapableLayerRenderPass(s),_=u?"backgroundPattern":"background";let g,y=r;y||(g=e.getBackgroundTiles(),y=Object.values(g).map((e=>e.tileID))),u&&(a.activeTexture.set(l.TEXTURE0),e.imageManager.bind(e.context,i.scope));for(const d of y){const y=e.isTileAffectedByFog(d),x=e.getOrCreateProgram(_,{overrideFog:y}),v=d.toUnwrapped(),b=r?d.projMatrix:e.transform.calculateProjMatrix(v);e.prepareDrawTile();const w=t?t.getTile(d):g?g[d.key]:new Iy(d,h,c.zoom,e),T=u?CM(b,s,o,e,u,i.scope,{tileID:d,tileSize:h}):IM(b,s,o,n);e.uploadCommonUniforms(a,x,v);const{tileBoundsBuffer:E,tileBoundsIndexBuffer:M,tileBoundsSegments:A}=e.getTileBoundsBuffers(w);x.draw(e,l.TRIANGLES,f,p,m,Ex.disabled,T,i.id,E,M,A);}},sky:function(e,t,i){const r=e._atmosphere?Ed(e.transform.zoom):1,n=i.paint.get("sky-opacity")*r;if(0===n)return;const o=e.context,s=i.paint.get("sky-type"),a=new gx(o.gl.LEQUAL,gx.ReadOnly,[0,1]),l=e.frameCounter/1e3%1;"atmosphere"===s?"offscreen"===e.renderPass?i.needsSkyboxCapture(e)&&(function(e,t,i,r){const n=e.context,o=n.gl;let s=t.skyboxFbo;if(!s){s=t.skyboxFbo=n.createFramebuffer(32,32,!0,null),t.skyboxGeometry=new cA(n),t.skyboxTexture=n.gl.createTexture(),o.bindTexture(o.TEXTURE_CUBE_MAP,t.skyboxTexture),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_MIN_FILTER,o.LINEAR),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_MAG_FILTER,o.LINEAR);for(let e=0;e<6;++e)o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,o.RGBA,32,32,0,o.RGBA,o.UNSIGNED_BYTE,null);}n.bindFramebuffer.set(s.framebuffer),n.viewport.set([0,0,32,32]);const a=t.getCenter(e,!0),l=e.getOrCreateProgram("skyboxCapture"),c=new Float64Array(16);xu.identity(c),xu.rotateY(c,c,.5*-Math.PI),hA(e,t,l,c,a,0),xu.identity(c),xu.rotateY(c,c,.5*Math.PI),hA(e,t,l,c,a,1),xu.identity(c),xu.rotateX(c,c,.5*-Math.PI),hA(e,t,l,c,a,2),xu.identity(c),xu.rotateX(c,c,.5*Math.PI),hA(e,t,l,c,a,3),xu.identity(c),hA(e,t,l,c,a,4),xu.identity(c),xu.rotateY(c,c,Math.PI),hA(e,t,l,c,a,5),n.viewport.set([0,0,e.width,e.height]);}(e,i),i.markSkyboxValid(e)):"sky"===e.renderPass&&function(e,t,i,r,n){const o=e.context,s=o.gl,a=e.transform,l=e.getOrCreateProgram("skybox");o.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_CUBE_MAP,t.skyboxTexture);const c=((e,t,i,r,n)=>({u_matrix:e,u_sun_direction:t,u_cubemap:0,u_opacity:r,u_temporal_offset:n}))(a.skyboxMatrix,t.getCenter(e,!1),0,r,n);e.uploadCommonUniforms(o,l),l.draw(e,s.TRIANGLES,i,xx.disabled,e.colorModeForRenderPass(),Ex.backCW,c,"skybox",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment);}(e,i,a,n,l):"gradient"===s&&"sky"===e.renderPass&&function(e,t,i,r,n){const o=e.context,s=o.gl,a=e.transform,l=e.getOrCreateProgram("skyboxGradient");t.skyboxGeometry||(t.skyboxGeometry=new cA(o)),o.activeTexture.set(s.TEXTURE0);let c=t.colorRampTexture;c||(c=t.colorRampTexture=new gy(o,t.colorRamp,s.RGBA)),c.bind(s.LINEAR,s.CLAMP_TO_EDGE);const h=((e,t,i,r,n)=>({u_matrix:e,u_color_ramp:0,u_center_direction:t,u_radius:w(i),u_opacity:r,u_temporal_offset:n}))(a.skyboxMatrix,t.getCenter(e,!1),t.paint.get("sky-gradient-radius"),r,n);e.uploadCommonUniforms(o,l),l.draw(e,s.TRIANGLES,i,xx.disabled,e.colorModeForRenderPass(),Ex.backCW,h,"skyboxGradient",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment);}(e,i,a,n,l);},debug:function(e,t,i){for(let r=0;r{s&&(s.useNormalOffset=!0,a||(s.enabled=!0));},c=t.getSource();if("light-beam"===e.renderPass&&"batched-model"!==c.type)return;if("vector"===c.type||"geojson"===c.type)return function(e,t,i,r){const n=e.transform;if("mercator"!==n.projection.name)return void W(`Drawing 3D models for ${n.projection.name} projection is not yet implemented`);const o=n.getFreeCameraOptions().position;if(!e.modelManager)return;const s=e.modelManager,a=e.shadowRenderer;if(!i._unevaluatedLayout._values.hasOwnProperty("model-id"))return;const l=i._unevaluatedLayout._values["model-id"],c={...i.layout.get("model-id").parameters};for(const h of r){const r=t.getTile(h).getBucket(i);if(!r||r.projection.name!==n.projection.name)continue;const u=wA(h,n);c.zoom=u;const d=l.possiblyEvaluate(c);if(vA(e,r,h),bA.shadowUniformsInitialized=!1,bA.useSingleShadowCascade=!!a&&0===a.getMaxCascadeForTile(h.toUnwrapped()),"shadow"===e.renderPass&&a){if(1===e.currentShadowCascade&&r.isInsideFirstShadowMapFrustum)continue;const t=n.calculatePosMatrix(h.toUnwrapped(),n.worldSize);if(bA.tileMatrix.set(t),bA.shadowTileMatrix=Float32Array.from(a.calculateShadowPassMatrixFromMatrix(t)),bA.aabb.min.fill(0),bA.aabb.max[0]=bA.aabb.max[1]=sr,bA.aabb.max[2]=0,MA(r,bA,e,i.scope))continue}const p=1<0&&(t=d.evaluate(n.features[0].feature,{}));const o=s.getModel(t,i.scope);if(o&&o.uploaded)for(const t of o.nodes)TA(e,i,t,n,f,h,bA);}}}(e,t,i,r),void l();if(!c.loaded())return;if("batched-model"===c.type)return function(e,t,i,r){const n=e.context,o=e.transform,s=e.style.fog,a=e.shadowRenderer;if("mercator"!==o.projection.name)return void W(`Drawing 3D landmark models for ${o.projection.name} projection is not yet implemented`);const l=e.transform.getFreeCameraOptions().position,c=Mu.scale([],[l.x,l.y,l.z],e.transform.worldSize);Mu.negate(c,c);const h=xu.identity([]),u=Kd(o.center.lat,o.zoom),d=xu.fromScaling([],[1,1,1/u]);xu.translate(h,h,c);const p=i.paint.get("model-opacity"),f=new gx(n.gl.LEQUAL,gx.ReadWrite,e.depthRangeFor3D),m=new gx(n.gl.LEQUAL,gx.ReadOnly,e.depthRangeFor3D),_=function(l,c){for(const u of r){const r=t.getTile(u).getBucket(i);if(!r||!r.uploaded)continue;let _=!1;a&&(_=0===a.getMaxCascadeForTile(u.toUnwrapped()));const g=o.calculatePosMatrix(u.toUnwrapped(),o.worldSize),y=r.modelTraits;for(const t of r.getNodesInfo()){if(t.hiddenByReplacement)continue;if(!t.node.meshes)continue;const r=t.node,x="light-beam"===e.renderPass,v=[...g],b=t.evaluatedScale;let w=0;e.terrain&&r.elevation&&(w=r.elevation*e.terrain.exaggeration()),xu.translate(v,v,[(r.anchor?r.anchor[0]:0)*(b[0]-1),(r.anchor?r.anchor[1]:0)*(b[1]-1),w]),b!==vv&&xu.scale(v,v,b),xu.multiply(v,v,r.matrix);const T=xu.multiply([],d,v);xu.multiply(T,h,T);const E=xu.invert([],T);xu.transpose(E,E),xu.scale(E,E,EA);const M=xu.multiply([],o.projMatrix,v);for(let h=0;h=sw||n>=sw;}}const I=e.getOrCreateProgram("model",b);!A&&a&&(a.useNormalOffset=!!d.normalBuffer,a.setupShadowsFromMatrix(v,I,a.useNormalOffset)),e.uploadCommonUniforms(n,I,u.toUnwrapped(),S);const C=d.material,z=C.pbrMetallicRoughness;z.metallicFactor=.9,z.roughnessFactor=.5;const D=DM(new Float32Array(M),new Float32Array(T),new Float32Array(E),e,p,z.baseColorFactor,C.emissiveFactor,z.metallicFactor,z.roughnessFactor,C,i);I.draw(e,n.gl.TRIANGLES,c&&!g?f:m,xx.disabled,l?g||p<1||t.hasTranslucentParts?bx.alphaBlended:bx.unblended:bx.disabled,Ex.backCCW,D,i.id,d.vertexBuffer,d.indexBuffer,d.segments,i.paint,e.transform.zoom,void 0,w);}}}};(((function(e,t,i,r){const n=e.terrain?e.terrain.exaggeration():0,o=e.transform.zoom;for(const s of r){const r=t.getTile(s).getBucket(i);r&&(e.conflationActive&&r.updateReplacement(s,e.replacementSource),r.evaluateScale(e,i),e.terrain&&n>0&&r.elevationUpdate(e.terrain,n,s,i.source),r.needsReEvaluation(e,o,i)&&r.evaluate(i));}})))(e,t,i,r),1===p?_(!0,!0):(_(!1,!0),_(!0,!1));}(e,t,i,r),void l();const h=c.getModels(),u=[],d=e.transform.getFreeCameraOptions().position,p=Mu.scale([],[d.x,d.y,d.z],e.transform.worldSize);Mu.negate(p,p);const f=[],m=[];let _=0;for(const t of h){const r=i.paint.get("model-rotation").constantOr(null),n=i.paint.get("model-scale").constantOr(null),o=i.paint.get("model-translation").constantOr(null);t.computeModelMatrix(e,r,n,o,!0,!0,!1);const s=xu.identity([]),a=Kd(t.position.lat,e.transform.zoom),l=xu.fromScaling([],[1,1,1/a]);xu.translate(s,s,p),u.push({zScaleMatrix:l,negCameraPosMatrix:s});for(const i of t.nodes)yA(e.transform,i,t.matrix,e.transform.projMatrix,_,f,m);_++;}if(f.sort(((e,t)=>t.depth-e.depth)),"shadow"!==e.renderPass){if(1===n)for(const t of m)gA(t,e,i,u[t.modelIndex],xx.disabled,e.colorModeForRenderPass());else {for(const t of m)gA(t,e,i,u[t.modelIndex],xx.disabled,bx.disabled);for(const t of m)gA(t,e,i,u[t.modelIndex],e.stencilModeFor3D(),e.colorModeForRenderPass());e.resetStencilClippingMasks();}for(const t of f)gA(t,e,i,u[t.modelIndex],xx.disabled,e.colorModeForRenderPass());l();}else {for(const t of m)xA(t.mesh,t.nodeModelMatrix,e,i);for(const t of f)xA(t.mesh,t.nodeModelMatrix,e,i);l();}}},CA={modelUpload:function(e,t,i){const r=t.getSource();if(!r.loaded())return;if("vector"===r.type||"geojson"===r.type)return void(e.modelManager&&e.modelManager.upload(e,i));if("batched-model"===r.type)return;const n=r.getModels();for(const t of n)t.upload(e.context);}};class zA{constructor(e,t){this.context=new Mx(e),this.transform=t,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.setup(),this.numSublayers=Ax.maxUnderzooming+Ax.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.deferredRenderGpuTimeQueries=[],this.gpuTimers={},this.frameCounter=0,this._backgroundTiles={},this.conflationActive=!1,this.replacementSource=new Vv,this.longestCutoffRange=0,this.minCutoffZoom=0,this._fogVisible=!1,this._cachedTileFogOpacities={},this._shadowRenderer=new LA(this),this._wireframeDebugCache=new SA,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0;}updateTerrain(e,t){const i=!!e&&!!e.terrain&&this.transform.projection.supportsTerrain;if(!(i||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new rM(this,e));const r=this._terrain;this.transform.elevation=i?r:null,r.update(e,this.transform,t),this.transform.elevation&&!r.enabled&&(this.transform.elevation=null);}_updateFog(e){const t=e.fog;if(!t||"globe"===this.transform.projection.name||t.getOpacity(this.transform.pitch)<1||t.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[i,r]=t.getFovAdjustedRange(this.transform._fov);if(i>r)return void(this.transform.fogCullDistSq=null);const n=i+.78*(r-i);this.transform.fogCullDistSq=n*n;}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}get shadowRenderer(){return this._shadowRenderer&&this._shadowRenderer.enabled?this._shadowRenderer:null}get wireframeDebugCache(){return this._wireframeDebugCache}resize(e,t){if(this.width=e*ht.devicePixelRatio,this.height=t*ht.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style.order)this.style._mergedLayers[e].resize();}setup(){const e=this.context,i=new Ta;i.emplaceBack(0,0),i.emplaceBack(sr,0),i.emplaceBack(0,sr),i.emplaceBack(sr,sr),this.tileExtentBuffer=e.createVertexBuffer(i,Pu.members),this.tileExtentSegments=dl.simpleSegment(0,0,4,2);const r=new Ta;r.emplaceBack(0,0),r.emplaceBack(sr,0),r.emplaceBack(0,sr),r.emplaceBack(sr,sr),this.debugBuffer=e.createVertexBuffer(r,Pu.members),this.debugSegments=dl.simpleSegment(0,0,4,5);const n=new Ta;n.emplaceBack(-1,-1),n.emplaceBack(1,-1),n.emplaceBack(-1,1),n.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(n,Pu.members),this.viewportSegments=dl.simpleSegment(0,0,4,2);const o=new Ma;o.emplaceBack(0,0,0,0),o.emplaceBack(sr,0,sr,0),o.emplaceBack(0,sr,0,sr),o.emplaceBack(sr,sr,sr,sr),this.mercatorBoundsBuffer=e.createVertexBuffer(o,Ay.members),this.mercatorBoundsSegments=dl.simpleSegment(0,0,4,2);const s=new Va;s.emplaceBack(0,1,2),s.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(s);const a=new Wa;for(const e of [0,1,3,2,0])a.emplaceBack(e);this.debugIndexBuffer=e.createIndexBuffer(a),this.emptyTexture=new gy(e,new $p({width:1,height:1},Uint8Array.of(0,0,0,0)),e.gl.RGBA),this.identityMat=xu.create();const l=this.context.gl;this.stencilClearMode=new xx({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.loadTimeStamps.push(t.performance.now());}getMercatorTileBoundsBuffers(){return {tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(e){return e._makeTileBoundsBuffers(this.context,this.transform.projection),e._tileBoundsBuffer?{tileBoundsBuffer:e._tileBoundsBuffer,tileBoundsIndexBuffer:e._tileBoundsIndexBuffer,tileBoundsSegments:e._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const e=this.context.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.getOrCreateProgram("clippingMask").draw(this,e.TRIANGLES,gx.disabled,this.stencilClearMode,bx.disabled,Ex.disabled,JE(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments);}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={});}_renderTileClippingMasks(e,t,i){if(!t||this.currentStencilSource===t.id||!e.isTileClipped()||!i||0===i.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let e=!1;for(const t of i)if(void 0===this._tileClippingMaskIDs[t.key]){e=!0;break}if(!e)return}this.currentStencilSource=t.id;const r=this.context,n=r.gl;this.nextStencilID+i.length>256&&this.clearStencil(),r.setColorMode(bx.disabled),r.setDepthMode(gx.disabled);const o=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const e of i){const i=t.getTile(e),r=this._tileClippingMaskIDs[e.key]=this.nextStencilID++,{tileBoundsBuffer:s,tileBoundsIndexBuffer:a,tileBoundsSegments:l}=this.getTileBoundsBuffers(i);o.draw(this,n.TRIANGLES,gx.disabled,new xx({func:n.ALWAYS,mask:0},r,255,n.KEEP,n.KEEP,n.REPLACE),bx.disabled,Ex.disabled,JE(e.projMatrix),"$clipping",s,a,l);}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,t=this.context.gl;return new xx({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(e);const t=this.context.gl;return new xx({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}stencilConfigForOverlap(e){const t=this.context.gl,i=e.sort(((e,t)=>t.overscaledZ-e.overscaledZ)),r=i[i.length-1].overscaledZ,n=i[0].overscaledZ-r+1;if(n>1){this.currentStencilSource=void 0,this.nextStencilID+n>256&&this.clearStencil();const e={};for(let i=0;ithis.style&&this.style.enable3dLights()&&this.terrain&&this.terrain.renderingToTexture)()&&"translucent"===this.renderPass?new bx([t.ONE,t.ONE_MINUS_SRC_ALPHA,t.CONSTANT_ALPHA,t.ONE_MINUS_SRC_ALPHA],new li(0,0,0,void 0===e?0:e),[!0,!0,!0,!0]):this.colorModeForRenderPass()}depthModeForSublayer(e,t,i,r=!1){if(!this.opaquePassEnabledForLayer()&&!r)return gx.disabled;const n=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new gx(i||this.context.gl.LEQUAL,t,[n,n])}opaquePassEnabledForLayer(){return this.currentLayerr[e])),s=this.style._mergedSourceCaches;this.imageManager=e.imageManager,this.modelManager=e.modelManager,this.symbolFadeChange=e.placement.symbolFadeChange(ht.now()),this.imageManager.beginFrame();let a=0,l=!1;for(const e in s){const t=s[e];t.used&&(t.prepare(this.context),t.getSource().usedInConflation&&++a);}const c={},h={},u={},d={},p={};for(const e in s){const t=s[e];c[e]=t.getVisibleCoordinates(),h[e]=c[e].slice().reverse(),u[e]=t.getVisibleCoordinates(!0).reverse(),d[e]=t.getShadowCasterCoordinates(),p[e]=t.sortCoordinatesByDistance(c[e]);}const f=e=>{const t=this.style.getLayerSourceCache(e);return t&&t.used?t.getSource():null};if(a){const e=[];for(const t of o)this.layerUsedInConflation(t,f(t))&&e.push(t);if(e&&e.length>1){const t=[];for(const i of e){const e=this.style.getLayerSourceCache(i);e&&e.used&&e.getSource().usedInConflation&&t.push({layer:i.fqid,cache:e});}this.replacementSource.setSources(t),l=!0;}}l||this.replacementSource.clear(),this.conflationActive=l,this.minCutoffZoom=0,this.longestCutoffRange=0;for(const e of o){const t=e.cutoffRange();if(this.longestCutoffRange=Math.max(t,this.longestCutoffRange),t>0){const t=f(e);t&&(this.minCutoffZoom=Math.max(t.minzoom,this.minCutoffZoom)),e.minzoom&&(this.minCutoffZoom=Math.max(e.minzoom,this.minCutoffZoom));}}this.opaquePassCutoff=1/0;for(let e=0;e{if(i.showOverdrawInspector)return li.black;if(this.style.fog&&this.transform.projection.supportsFog&&!y){const e=this.style.fog.properties.get("color").toArray01();return new li(...e)}if(this.style.fog&&this.transform.projection.supportsFog&&y){const e=this.style.fog.properties.get("space-color").toArray01();return new li(...e)}return li.transparent})();if(this.context.clear({color:x,depth:1}),this.clearStencil(),this._showOverdrawInspector=i.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&y&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=n.length-1;this.currentLayer>=0;this.currentLayer--){const t=o[this.currentLayer],i=e.getLayerSourceCache(t);if(t.isSky())continue;const r=i?(t.is3D()?p:h)[i.id]:void 0;this._renderTileClippingMasks(t,i,r),this.renderLayer(this,i,t,r);}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&y&&this._atmosphere.drawAtmosphereGlow(this,this.style.fog),this.renderPass="sky",(!this._atmosphere||Ed(this.transform.zoom)>0)&&("globe"===this.transform.projection.name||this.transform.isHorizonVisible()))for(this.currentLayer=0;this.currentLayer0&&t.hasShadowPass()&&0==--v&&(_.drawGroundShadows(),this.firstLightBeamLayer<=this.currentLayer)){const t=this.currentLayer;for(this.renderPass="light-beam",this.currentLayer=this.firstLightBeamLayer;this.currentLayer<=t;this.currentLayer++){const t=o[this.currentLayer];if(!t.hasLightBeamPass())continue;const i=e.getLayerSourceCache(t);this.renderLayer(this,i,t,i?h[i.id]:void 0);}this.currentLayer=t,this.renderPass="translucent";}++this.currentLayer;}if(this.terrain&&this.terrain.postRender(),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){let t=null;o.forEach((i=>{const r=e.getLayerSourceCache(i);r&&!i.isHidden(this.transform.zoom)&&r.getVisibleCoordinates().length&&(!t||t.getSource().maxzoom0?t.pop():null}isPatternMissing(e,t){return null===e||void 0!==e&&!this.imageManager.getPattern(e.toString(),t)}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture}terrainUseFloatDEM(){return null!=this.context.extTextureFloatLinear}currentGlobalDefines(e,t,i){const r=void 0===i?this.terrain&&this.terrain.renderingToTexture:i,n=this.terrain&&0===this.terrain.exaggeration(),o=[];return this.style&&this.style.enable3dLights()&&("globeRaster"===e||"terrainRaster"===e?(o.push("LIGHTING_3D_MODE"),o.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):r||o.push("LIGHTING_3D_MODE")),"shadow"===this.renderPass?this._shadowMapDebug||o.push("DEPTH_TEXTURE"):this.shadowRenderer&&(this.shadowRenderer.useNormalOffset?o.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"):o.push("RENDER_SHADOWS","DEPTH_TEXTURE")),this.terrainRenderModeElevated()&&(o.push("TERRAIN"),this.terrainUseFloatDEM()&&o.push("TERRAIN_DEM_FLOAT_FORMAT"),n&&o.push("ZERO_EXAGGERATION")),"globe"===this.transform.projection.name&&o.push("GLOBE"),!this._fogVisible||r||void 0!==t&&!t||o.push("FOG","FOG_DITHERING"),r&&o.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&o.push("OVERDRAW_INSPECTOR"),o}getOrCreateProgram(e,t){this.cache=this.cache||{};const i=t&&t.defines||[],r=t&&t.config,n=this.currentGlobalDefines(e,t&&t.overrideFog,t&&t.overrideRtt).concat(i),o=aM.cacheKey(kE[e],e,n,r);return this.cache[o]||(this.cache[o]=new aM(this.context,e,kE[e],r,LM[e],n)),this.cache[o]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.frontFace.setDefault(),this.context.cullFaceSide.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault();}setBaseState(){const e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD);}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=t.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new gy(this.context,this.debugOverlayCanvas,this.context.gl.RGBA));}destroy(){this._terrain&&this._terrain.destroy(),this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this._wireframeDebugCache.destroy();}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile();}uploadCommonLightUniforms(e,t){if(this.style.enable3dLights()){const i=this.style.directionalLight,r=this.style.ambientLight;if(i&&r){const n=((e,t)=>{const i=e.properties.get("direction"),r=e.properties.get("color").toArray01(),n=e.properties.get("intensity"),o=t.properties.get("color").toArray01(),s=t.properties.get("intensity"),a=[i.x,i.y,i.z],l=se(o,s),c=se(r,n);return {u_lighting_ambient_color:l,u_lighting_directional_dir:a,u_lighting_directional_color:c,u_ground_radiance:nM(a,c,l)}})(i,r);t.setLightsUniformValues(e,n);}}}uploadCommonUniforms(e,t,i,r,n){if(this.uploadCommonLightUniforms(e,t),this.terrain&&this.terrain.renderingToTexture)return;const o=this.style.fog;if(o){const n=o.getOpacity(this.transform.pitch),s=((e,t,i,r,n,o,s,a,l,c,h,u)=>{const d=e.transform,p=t.properties.get("color").toArray01();p[3]=r;const f=e.frameCounter/1e3%1,[m,_]=t.properties.get("vertical-range");return {u_fog_matrix:i?d.calculateFogTileMatrix(i):u||e.identityMat,u_fog_range:t.getFovAdjustedRange(d._fov),u_fog_color:p,u_fog_horizon_blend:t.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(m,_),_],u_fog_temporal_offset:f,u_frustum_tl:n,u_frustum_tr:o,u_frustum_br:s,u_frustum_bl:a,u_globe_pos:l,u_globe_radius:c,u_viewport:h,u_globe_transition:Ed(d.zoom),u_is_globe:+("globe"===d.projection.name)}})(this,o,i,n,this.transform.frustumCorners.TL,this.transform.frustumCorners.TR,this.transform.frustumCorners.BR,this.transform.frustumCorners.BL,this.transform.globeCenterInViewSpace,this.transform.globeRadius,[this.transform.width*ht.devicePixelRatio,this.transform.height*ht.devicePixelRatio],r);t.setFogUniformValues(e,s);}n&&t.setCutoffUniformValues(e,n.uniformValues);}setTileLoadedFlag(e){this.tileLoaded=e;}saveCanvasCopy(){const e=this.canvasCopy();e&&(this.frameCopies.push(e),this.tileLoaded=!1);}canvasCopy(){const e=this.context.gl,t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.copyTexImage2D(e.TEXTURE_2D,0,e.RGBA,0,0,e.drawingBufferWidth,e.drawingBufferHeight,0),t}getCanvasCopiesAndTimestamps(){return {canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return !1;const e=this.style&&this.style.fog;return !!e&&0!==e.getOpacity(this.transform.pitch)}getBackgroundTiles(){const e=this._backgroundTiles,t=this._backgroundTiles={},i=this.transform.coveringTiles({tileSize:512});for(const r of i)t[r.key]=e[r.key]||new Iy(r,512,this.transform.tileZoom,this);return t}clearBackgroundTiles(){this._backgroundTiles={};}layerUsedInConflation(e,t){return !(!e.is3D()||e.minzoom&&e.minzoom>this.transform.zoom||"building"!==e.sourceLayer&&(!t||"batched-model"!==t.type))}isTileAffectedByFog(e){if(!this.style||!this.style.fog)return !1;if("globe"===this.transform.projection.name)return !0;let t=this._cachedTileFogOpacities[e.key];return t||(this._cachedTileFogOpacities[e.key]=t=this.style.fog.getOpacityForTile(e)),t[0]>=sw||t[1]>=sw}}const DA=2048;class PA{constructor(e,t){this.aabb=e,this.lastCascade=t;}}class RA{add(e,t){const i=this.receivers[e.key];void 0!==i?(i.aabb.min[0]=Math.min(i.aabb.min[0],t.min[0]),i.aabb.min[1]=Math.min(i.aabb.min[1],t.min[1]),i.aabb.min[2]=Math.min(i.aabb.min[2],t.min[2]),i.aabb.max[0]=Math.max(i.aabb.max[0],t.max[0]),i.aabb.max[1]=Math.max(i.aabb.max[1],t.max[1]),i.aabb.max[2]=Math.max(i.aabb.max[2],t.max[2])):this.receivers[e.key]=new PA(t,null);}clear(){this.receivers={};}get(e){return this.receivers[e.key]}computeRequiredCascades(e,t,i){const r=Hu.fromPoints(e.points);let n=0;for(const e in this.receivers){const o=this.receivers[e];if(!o)continue;if(!r.intersectsAabb(o.aabb))continue;o.aabb.min=r.closestPoint(o.aabb.min),o.aabb.max=r.closestPoint(o.aabb.max);const s=o.aabb.getCorners();for(let e=0;e1||o[1]<-1||o[1]>1){r=!1;break}}if(o.lastCascade=e,n=Math.max(n,e),r)break}}return n+1}}class LA{constructor(e){this.painter=e,this._enabled=!1,this._shadowLayerCount=0,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new RA,this._depthMode=new gx(e.context.gl.LEQUAL,gx.ReadWrite,[0,1]),this._uniformValues={u_light_matrix_0:new Float32Array(16),u_light_matrix_1:new Float32Array(16),u_shadow_intensity:0,u_fade_range:[0,0],u_shadow_normal_offset:[1,1,1],u_shadow_texel_size:1,u_shadow_map_resolution:1,u_shadow_direction:[0,0,1],u_shadow_bias:[36e-5,.0012,.012],u_shadowmap_0:0,u_shadowmap_1:0},this.useNormalOffset=!1;}destroy(){for(const e of this._cascades)e.texture.destroy(),e.framebuffer.destroy();this._cascades=[];}updateShadowParameters(e,t){const i=this.painter;if(this._enabled=!1,this._shadowLayerCount=0,this._receivers.clear(),!t||!t.properties)return;const r=t.properties.get("shadow-intensity");if(!t.shadowsEnabled()||r<=0)return;if(this._shadowLayerCount=i.style.order.reduce(((t,r)=>{const n=i.style._mergedLayers[r];return t+(n.hasShadowPass()&&!n.isHidden(e.zoom)?1:0)}),0),this._enabled=this._shadowLayerCount>0,!this._enabled)return;const n=i.context,o=DA,s=DA;if(0===this._cascades.length)for(let e=0;e<2;++e){const e=i._shadowMapDebug,t=n.gl,r=n.createFramebuffer(o,s,e,"texture"),a=new gy(n,{width:o,height:s,data:null},t.DEPTH_COMPONENT);if(r.depthAttachment.set(a.texture),e){const e=new gy(n,{width:o,height:s,data:null},t.RGBA);r.colorAttachment.set(e.texture);}this._cascades.push({framebuffer:r,texture:a,matrix:[],far:0,boundingSphereRadius:0,frustum:new $u,scale:0});}this.shadowDirection=OA(t);let a=0;if(e.elevation){const t=e.elevation,i=[1e4,-1e4];t.visibleDemTiles.filter((e=>e.dem)).forEach((e=>{const t=e.dem.tree;i[0]=Math.min(i[0],t.minimums[0]),i[1]=Math.max(i[1],t.maximums[0]);})),1e4!==i[0]&&(a=(i[1]-i[0])*t.exaggeration());}const l=1.5*e.cameraToCenterDistance,c=3*l,h=new Float64Array(16);for(let t=0;t<2;++t){const i=this._cascades[t];let r=e.height/50,n=1;0===t?n=l:(r=l,n=c);const[o,s]=FA(e,this.shadowDirection,r,n,DA,a);i.scale=e.scale,i.matrix=o,i.boundingSphereRadius=s,xu.invert(h,i.matrix),i.frustum=$u.fromInvProjectionMatrix(h,1,0,!0),i.far=n;}this._uniformValues.u_fade_range=[.75*this._cascades[1].far,this._cascades[1].far],this._uniformValues.u_shadow_intensity=r,this._uniformValues.u_shadow_direction=[this.shadowDirection[0],this.shadowDirection[1],this.shadowDirection[2]],this._uniformValues.u_shadow_texel_size=.00048828125,this._uniformValues.u_shadow_map_resolution=DA,this._uniformValues.u_shadowmap_0=zM.ShadowMap0,this._uniformValues.u_shadowmap_1=zM.ShadowMap0+1,this._groundShadowTiles=i.transform.coveringTiles({tileSize:512,renderWorldCopies:!0});const u=i.transform.elevation;for(const e of this._groundShadowTiles){let t={min:0,max:0};if(u){const i=u.getMinMaxForTile(e);i&&(t=i);}this.addShadowReceiver(e.toUnwrapped(),t.min,t.max);}}get enabled(){return this._enabled}set enabled(e){this._enabled=e;}drawShadowPass(e,t){if(!this._enabled)return;const i=this.painter,r=i.context;this._numCascadesToRender=this._receivers.computeRequiredCascades(i.transform.getFrustum(0),i.transform.worldSize,this._cascades),r.viewport.set([0,0,DA,DA]);for(let n=0;n=0)return {};const n=function(e,t,i){const r=i/(1<0&&(Mu.add(n[1],n[1],[r[0]*o,0,0]),Mu.add(n[2],n[2],[r[0]*o,0,0])),r[1]<0?(Mu.add(n[0],n[0],[0,r[1]*o,0]),Mu.add(n[1],n[1],[0,r[1]*o,0])):r[1]>0&&(Mu.add(n[2],n[2],[0,r[1]*o,0]),Mu.add(n[3],n[3],[0,r[1]*o,0]));const s={};return s.vertices=n,s.planes=[kA(n[1],n[0],n[4]),kA(n[2],n[1],n[5]),kA(n[3],n[2],n[6]),kA(n[0],n[3],n[7])],s}addShadowReceiver(e,t,i){this._receivers.add(e,Hu.fromTileIdAndHeight(e,t,i));}getMaxCascadeForTile(e){const t=this._receivers.get(e);return t&&t.lastCascade?t.lastCascade:0}}function kA(e,t,i){const r=Mu.sub([],i,t),n=Mu.sub([],e,t),o=Mu.cross([],r,n),s=Mu.length(o);return 0===s?[0,0,1,0]:(Mu.scale(o,o,1/s),[o[0],o[1],o[2],-Mu.dot(o,t)])}function OA(e){const t=e.properties.get("direction"),i=J(t.x,t.y,t.z);i[2]=z(i[2],0,75);const r=K([i[0],i[1],i[2]]);return Mu.fromValues(r.x,r.y,r.z)}function BA(e,t){const i=e.properties.get("color"),r=e.properties.get("intensity"),n=e.properties.get("direction"),o=[n.x,n.y,n.z],s=t.properties.get("color"),a=t.properties.get("intensity"),l=Math.max(Mu.dot([0,0,1],o),0),c=[0,0,0];Mu.scale(c,s.toArray01Linear().slice(0,3),a);const h=[0,0,0];return Mu.scale(h,i.toArray01Linear().slice(0,3),l*r),ae([c[0]>0?c[0]/(c[0]+h[0]):0,c[1]>0?c[1]/(c[1]+h[1]):0,c[2]>0?c[2]/(c[2]+h[2]):0])}function FA(e,t,i,r,n,o){const s=e.zoom,a=e.scale,l=e.worldSize,c=1/l,h=e.aspect,u=Math.sqrt(1+h*h)*Math.tan(.5*e.fovX),d=u*u,p=r-i,f=r+i;let m,_;d>p/f?(m=r,_=r*u):(m=.5*f*(1+d),_=.5*Math.sqrt(p*p+2*(r*r+i*i)*d+f*f*d*d));const g=e.projection.pixelsPerMeter(e.center.lat,l),y=e._camera.getCameraToWorldMercator(),x=[0,0,-m*c];Mu.transformMat4(x,x,y);let v=_*c;const b=e._edgeInsets;if(!(0===b.left&&0===b.top&&0===b.right&&0===b.bottom||b.left===b.right&&b.top===b.bottom)){const t=e._camera.getWorldToCamera(e.worldSize,"meters"===e.projection.zAxisUnit?g:1),n=e._camera.getCameraToClipPerspective(e._fov,e.width/e.height,i,r);n[8]=2*-e.centerOffset.x/e.width,n[9]=2*e.centerOffset.y/e.height;const o=new Float64Array(16);xu.mul(o,n,t);const c=new Float64Array(16);xu.invert(c,o);const h=$u.fromInvProjectionMatrix(c,l,s,!0);for(const t of h.points){const i=((w=t)[0]/=a,w[1]/=a,w[2]=Zd(w[2],e._center.lat),w);v=Math.max(v,Mu.len(Mu.subtract([],x,i)));}}var w;v*=n/(n-1);const T=Math.acos(t[2]),E=Math.atan2(-t[0],-t[1]),M=new jx;M.position=x,M.setPitchBearing(T,E);const A=M.getWorldToCamera(l,g),S=v*l,I=Math.min(e._mercatorZfromZoom(17)*l*-2,-2*S),C=M.getCameraToClipOrthographic(-S,S,-S,S,I,(S+o*g)/t[2]),z=new Float64Array(16);xu.multiply(z,C,A);const D=Mu.fromValues(Math.floor(1e6*x[0])/1e6*l,Math.floor(1e6*x[1])/1e6*l,0),P=.5*n,R=[0,0,0];Mu.transformMat4(R,D,z),Mu.scale(R,R,P);const L=[Math.floor(R[0]),Math.floor(R[1]),Math.floor(R[2])],k=[0,0,0];Mu.sub(k,R,L),Mu.scale(k,k,-1/P);const O=new Float64Array(16);return xu.identity(O),xu.translate(O,O,k),xu.multiply(z,O,z),[z,S]}class NA extends It{constructor(e){super(),this.requestManager=e,this.models={"":{}},this.numModelsLoading={};}loadModel(e,t){return aT(this.requestManager.transformRequest(t,ye.Model).url).then((t=>{if(!t)return;const i=_T(t),r=new bv(e,void 0,void 0,i);return r.computeBoundsAndApplyParent(),r})).catch((i=>{this.fire(new St(new Error(`Could not load model ${e} from ${t}: ${i.message}`)));}))}load(e,t){this.models[t]||(this.models[t]={});const i=Object.keys(e);this.numModelsLoading[t]=(this.numModelsLoading[t]||0)+i.length;const r=[];for(const t of i)r.push(this.loadModel(t,e[t]));Promise.allSettled(r).then((e=>{for(let r=0;r{this.fire(new St(new Error(`Could not load models: ${e.message}`)));}));}isLoaded(){for(const e in this.numModelsLoading)if(this.numModelsLoading[e]>0)return !1;return !0}hasModel(e,t){return !!this.getModel(e,t)}getModel(e,t){return this.models[t]||(this.models[t]={}),this.models[t][e]}addModel(e,t,i){this.models[i]||(this.models[i]={}),this.hasModel(e,i)&&this.removeModel(e,i),this.load({[e]:this.requestManager.normalizeModelURL(t)},i);}addModels(e,t){const i={};for(const t in e)i[t]=this.requestManager.normalizeModelURL(e[t]);this.load(i,t);}removeModel(e,t){this.models[t]||(this.models[t]={});const i=this.models[t][e];delete this.models[t][e],i.destroy();}listModels(e){return this.models[e]||(this.models[e]={}),Object.keys(this.models[e])}upload(e,t){this.models[t]||(this.models[t]={});for(const i in this.models[t])this.models[t][i].upload(e.context);}}const UA=(e,t)=>ws(e,t&&t.filter((e=>"source.canvas"!==e.identifier))),VA=O(CT,["addLayer","removeLayer","setLights","setPaintProperty","setLayoutProperty","setSlot","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection","setCamera","addImport","removeImport","setImportUrl","setImportData","setImportConfig"]),jA=O(CT,["setCenter","setZoom","setBearing","setPitch"]),GA={version:8,layers:[],sources:{}},qA={duration:300,delay:0},ZA=new Set(["fill","line","background","hillshade","raster"]);class $A extends It{constructor(e,t={}){super(),this.map=e,this.scope=t.scope||"",this.fragments=[],this.importDepth=t.importDepth||0,this.importsCache=t.importsCache||new Map,this.resolvedImports=t.resolvedImports||new Set,this.transition=k({},qA),this._buildingIndex=new MT(this),this.crossTileSymbolIndex=new wE,this._mergedOrder=[],this._drapedFirstOrder=[],this._mergedLayers={},this._mergedSourceCaches={},this._mergedOtherSourceCaches={},this._mergedSymbolSourceCaches={},this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this._changes=t.styleChanges||new ga,this.dispatcher=t.dispatcher?t.dispatcher:new _w(Uw(),this),t.imageManager?this.imageManager=t.imageManager:(this.imageManager=new Qb,this.imageManager.setEventedParent(this)),this.imageManager.createScope(this.scope),this.glyphManager=t.glyphManager?t.glyphManager:new K_(e._requestManager,t.localFontFamily?2:t.localIdeographFontFamily?1:0,t.localFontFamily||t.localIdeographFontFamily),t.modelManager?this.modelManager=t.modelManager:(this.modelManager=new NA(e._requestManager),this.modelManager.setEventedParent(this)),this._layers={},this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._loaded=!1,this._precompileDone=!1,this._shouldPrecompile=!1,this._availableImages=[],this._order=[],this._markersNeedUpdate=!1,this.options=new Map,this._configDependentLayers=new Set,this.dispatcher.broadcast("setReferrer",ve());const i=this;this._rtlTextPluginCallback=$A.registerForPluginStateChange((e=>{i.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:e.pluginStatus,pluginURL:e.pluginURL},((e,t)=>{if(Ws(e),t&&t.every((e=>e)))for(const e in i._sourceCaches){const t=i._sourceCaches[e],r=t.getSource().type;"vector"!==r&&"geojson"!==r||t.reload();}}));})),this.on("data",(e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const t=this.getOwnSource(e.sourceId);if(t&&t.vectorLayerIds)for(const e in this._layers){const i=this._layers[e];i.source===t.id&&this._validateLayer(i);}}));}loadURL(e,t={}){this.fire(new At("dataloading",{dataType:"style"}));const i="boolean"==typeof t.validate?t.validate:!De(e);e=this.map._requestManager.normalizeStyleURL(e,t.accessToken),this.resolvedImports.add(e);const r=this.importsCache.get(e);if(r)return this._load(r,i);const n=this.map._requestManager.transformRequest(e,ye.Style);this._request=we(n,((t,r)=>{if(this._request=null,t)this.fire(new St(t));else if(r)return this.importsCache.set(e,r),this._load(r,i)}));}loadJSON(e,t={}){this.fire(new At("dataloading",{dataType:"style"})),this._request=ht.frame((()=>{this._request=null,this._load(e,!1!==t.validate);}));}loadEmpty(){this.fire(new At("dataloading",{dataType:"style"})),this._load(GA,!1);}_loadImports(e,t){if(this.importDepth>=4)return W("Style doesn't support nesting deeper than 5"),this._reloadImports();const i=[];for(const r of e){const e=this._createFragmentStyle(r),n=new Promise((t=>e.on("style.import.load",t)));if(i.push(n),this.resolvedImports.has(r.url)){e.loadEmpty();continue}const o=r.data||this.importsCache.get(r.url);o?e.loadJSON(o,{validate:t}):r.url?e.loadURL(r.url,{validate:t}):e.loadEmpty(),this.fragments.push({style:e,id:r.id,config:r.config});}Promise.all(i).then((()=>this._reloadImports()));}_createFragmentStyle(e){const t=this.scope?pa(e.id,this.scope):e.id,i=new $A(this.map,{scope:t,styleChanges:this._changes,importDepth:this.importDepth+1,importsCache:this.importsCache,resolvedImports:new Set(this.resolvedImports),dispatcher:this.dispatcher,imageManager:this.imageManager,glyphManager:this.glyphManager,modelManager:this.modelManager});return i.setEventedParent(this.map,{style:i}),i.setConfig(e.config),i}_reloadImports(){this.mergeAll(),this._updateMapProjection(),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options});const e=this.isRootStyle();this._shouldPrecompile=e,this.fire(new At("data",{dataType:"style"})),this.fire(new At(e?"style.load":"style.import.load"));}_load(e,t){const i=e.schema;if(this.isRootStyle()&&(e.fragment||i&&!1!==e.fragment)){const i=k({},GA,{imports:[{id:"basemap",data:e,url:""}]});return void this._load(i,t)}if(this.updateSchema(i),t&&UA(this,hs(e)))return;this._loaded=!0,this.stylesheet=$(e);for(const t in e.sources)this.addSource(t,e.sources[t],{validate:!1});this._changes.changed=!1,e.sprite?this._loadSprite(e.sprite):(this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0})),this.glyphManager.setURL(e.glyphs,this.scope);const r=IT(this.stylesheet.layers);if(this._order=r.map((e=>e.id)),this.stylesheet.light&&W("The `light` root property is deprecated, prefer using `lights` with `flat` light type instead."),this.stylesheet.lights)if(1===this.stylesheet.lights.length&&"flat"===this.stylesheet.lights[0].type){const e=this.stylesheet.lights[0];this.light=new tw(e.properties,e.id);}else this.setLights(this.stylesheet.lights);this.light||(this.light=new tw(this.stylesheet.light)),this._layers={},this._serializedLayers={};for(const e of r){const t=Kb(e,this.options);t.setScope(this.scope),t.isConfigDependent&&this._configDependentLayers.add(t.fqid),t.setEventedParent(this,{layer:{id:t.id}}),this._layers[t.id]=t,this._layers[t.id]=t,this._serializedLayers[t.id]=t.serialize();const i=this.getOwnLayerSourceCache(t),r=!!this.directionalLight&&this.directionalLight.shadowsEnabled();i&&t.canCastShadows()&&r&&(i.castsShadows=!0);}this.stylesheet.models&&this.modelManager.addModels(this.stylesheet.models,this.scope);const n=this.stylesheet.terrain;if(n&&!this.terrainSetForDrapingOnly()&&this._createTerrain(n,1),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this.stylesheet.transition&&this.setTransition(this.stylesheet.transition),this.mergeAll(),this._updateMapProjection(),this.map._triggerCameraUpdate(this.camera),this.fire(new At("data",{dataType:"style"})),e.imports)this._loadImports(e.imports,t);else {this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options});const e=this.isRootStyle();this._shouldPrecompile=e,this.fire(new At(e?"style.load":"style.import.load"));}}isRootStyle(){return 0===this.importDepth}mergeAll(){let e,t,i,r,n,o,s,a;this.forEachFragmentStyle((l=>{if(l.stylesheet){if(null!=l.light&&(e=l.light),l.stylesheet.lights)for(const e of l.stylesheet.lights)"ambient"===e.type&&null!=l.ambientLight&&(t=l.ambientLight),"directional"===e.type&&null!=l.directionalLight&&(i=l.directionalLight);(l.stylesheet.terrain||l.stylesheet.projection&&"globe"===l.stylesheet.projection.name)&&null!=l.terrain&&(!r||r&&0===r.drapeRenderMode||1===l.terrain.drapeRenderMode)&&(r=l.terrain),l.stylesheet.fog&&null!=l.fog&&(n=l.fog),null!=l.stylesheet.camera&&(a=l.stylesheet.camera),null!=l.stylesheet.projection&&(o=l.stylesheet.projection),null!=l.stylesheet.transition&&(s=l.stylesheet.transition);}})),this.light=e,this.ambientLight=t,this.directionalLight=i,this.terrain=r,this.fog=n,this.camera=a||{"camera-projection":"perspective"},this.projection=o||{name:"mercator"},this.transition=k({},qA,s),this.mergeSources(),this.mergeLayers();}forEachFragmentStyle(e){const t=i=>{for(const e of i.fragments)t(e.style);e(i);};t(this);}mergeTerrain(){let e;this.forEachFragmentStyle((t=>{null!=t.terrain&&(!e||e&&0===e.drapeRenderMode||1===t.terrain.drapeRenderMode)&&(e=t.terrain);})),this.terrain=e;}mergeProjection(){let e;this.forEachFragmentStyle((t=>{null!=t.stylesheet.projection&&(e=t.stylesheet.projection);})),this.projection=e||{name:"mercator"};}mergeSources(){const e={},t={},i={};this.forEachFragmentStyle((r=>{for(const t in r._sourceCaches){const i=pa(t,r.scope);e[i]=r._sourceCaches[t];}for(const e in r._otherSourceCaches){const i=pa(e,r.scope);t[i]=r._otherSourceCaches[e];}for(const e in r._symbolSourceCaches){const t=pa(e,r.scope);i[t]=r._symbolSourceCaches[e];}})),this._mergedSourceCaches=e,this._mergedOtherSourceCaches=t,this._mergedSymbolSourceCaches=i;}mergeLayers(){const e={},t=[],i={};this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle((i=>{for(const r of i._order){const n=i._layers[r];if("slot"===n.type){const t=fa(r);if(e[t])continue;e[t]=[];}n.slot&&e[n.slot]?e[n.slot].push(n):t.push(n);}})),this._mergedOrder=[];const r=(t=[])=>{for(const n of t)if("slot"===n.type){const t=fa(n.id);e[t]&&r(e[t]);}else {const e=pa(n.id,n.scope);this._mergedOrder.push(e),i[e]=n,n.is3D()&&(this._has3DLayers=!0),"circle"===n.type&&(this._hasCircleLayers=!0),"symbol"===n.type&&(this._hasSymbolLayers=!0);}};r(t),this._mergedLayers=i,this.updateDrapeFirstLayers(),this._buildingIndex.processLayersChanged();}terrainSetForDrapingOnly(){return !!this.terrain&&0===this.terrain.drapeRenderMode}getCamera(){return this.stylesheet.camera}setCamera(e){return this.stylesheet.camera=k({},this.stylesheet.camera,e),this.camera=this.stylesheet.camera,this}setProjection(e){e?this.stylesheet.projection=e:delete this.stylesheet.projection,this.mergeProjection(),this._updateMapProjection();}applyProjectionUpdate(){this._loaded&&(this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),this.map.transform.projection.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null));}_updateMapProjection(){this.isRootStyle()&&(this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.projection));}_loadSprite(e){this._spriteRequest=function(e,t,i){let r,n,o;const s=ht.devicePixelRatio>1?"@2x":"";let a=we(t.transformRequest(t.normalizeSpriteURL(e,s,".json"),ye.SpriteJSON),((e,t)=>{a=null,o||(o=e,r=t,c());})),l=Ie(t.transformRequest(t.normalizeSpriteURL(e,s,".png"),ye.SpriteImage),((e,t)=>{l=null,o||(o=e,n=t,c());}));function c(){if(o)i(o);else if(r&&n){const e=ht.getImageData(n),t={};for(const i in r){const{width:n,height:o,x:s,y:a,sdf:l,pixelRatio:c,stretchX:h,stretchY:u,content:d}=r[i],p=new $p({width:n,height:o});$p.copy(e,p,{x:s,y:a},{x:0,y:0},{width:n,height:o}),t[i]={data:p,pixelRatio:c,sdf:l,stretchX:h,stretchY:u,content:d};}i(null,t);}}return {cancel(){a&&(a.cancel(),a=null),l&&(l.cancel(),l=null);}}}(e,this.map._requestManager,((e,t)=>{if(this._spriteRequest=null,e)this.fire(new St(e));else if(t)for(const e in t)this.imageManager.addImage(e,this.scope,t[e]);this.imageManager.setLoaded(!0,this.scope),this._availableImages=this.imageManager.listImages(this.scope),this.dispatcher.broadcast("setImages",{scope:this.scope,images:this._availableImages}),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new At("data",{dataType:"style"}));}));}_validateLayer(e){const t=this.getOwnSource(e.source);if(!t)return;const i=e.sourceLayer;i&&("geojson"===t.type||t.vectorLayerIds&&-1===t.vectorLayerIds.indexOf(i))&&this.fire(new St(new Error(`Source layer "${i}" does not exist on source "${t.id}" as specified by style layer "${e.id}"`)));}loaded(){if(!this._loaded)return !1;if(Object.keys(this._changes.updatedSourceCaches).length)return !1;for(const e in this._sourceCaches)if(!this._sourceCaches[e].loaded())return !1;if(!this.imageManager.isLoaded())return !1;if(!this.modelManager.isLoaded())return !1;for(const{style:e}of this.fragments)if(!e.loaded())return !1;return !0}_serializeImports(){if(this.stylesheet.imports)return this.stylesheet.imports.map(((e,t)=>{const i=this.fragments[t];return i&&i.style&&(e.data=i.style.serialize()),e}))}_serializeSources(){const e={};for(const t in this._sourceCaches){const i=this._sourceCaches[t].getSource();e[i.id]||(e[i.id]=i.serialize());}return e}_serializeLayers(e){const t=[];for(const i of e){const e=this._layers[i];e&&"custom"!==e.type&&t.push(e.serialize());}return t}hasLightTransitions(){return !(!this.light||!this.light.hasTransition())||!(!this.ambientLight||!this.ambientLight.hasTransition())||!(!this.directionalLight||!this.directionalLight.hasTransition())}hasFogTransition(){return !!this.fog&&this.fog.hasTransition()}hasTransitions(){if(this.hasLightTransitions())return !0;if(this.hasFogTransition())return !0;for(const e in this._sourceCaches)if(this._sourceCaches[e].hasTransition())return !0;for(const e in this._layers)if(this._layers[e].hasTransition())return !0;return !1}get order(){return this.terrain?this._drapedFirstOrder:this._mergedOrder}isLayerDraped(e){return !!this.terrain&&("function"==typeof e.isLayerDraped?e.isLayerDraped(this.getLayerSourceCache(e)):ZA.has(e.type))}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}_checkLayer(e){const t=this.getOwnLayer(e);if(t)return t;this.fire(new St(new Error(`The layer '${e}' does not exist in the map's style.`)));}_checkSource(e){const t=this.getOwnSource(e);if(t)return t;this.fire(new St(new Error(`The source '${e}' does not exist in the map's style.`)));}update(e){if(!this._loaded)return;this.ambientLight&&this.ambientLight.recalculate(e),this.directionalLight&&this.directionalLight.recalculate(e);const t=this.calculateLightsBrightness();e.brightness=t||0,t!==this._brightness&&(this._brightness=t,this.dispatcher.broadcast("setBrightness",t));const i=this._changes.changed;if(this._changes.changed){const t=this._changes.getLayerUpdatesByScope();for(const e in t){const{updatedIds:i,removedIds:r}=t[e];(i||r)&&this._updateWorkerLayers(e,i,r);}this.updateSourceCaches(),this._updateTilesForChangedImages(),this.updateLayers(e),this.light&&this.light.updateTransitions(e),this.ambientLight&&this.ambientLight.updateTransitions(e),this.directionalLight&&this.directionalLight.updateTransitions(e),this.fog&&this.fog.updateTransitions(e),this._changes.reset();}const r={};for(const e in this._mergedSourceCaches){const t=this._mergedSourceCaches[e];r[e]=t.used,t.used=!1;}for(const t of this._mergedOrder){const i=this._mergedLayers[t];if(i.recalculate(e,this._availableImages),!i.isHidden(e.zoom)){const e=this.getOwnLayerSourceCache(i);e&&(e.used=!0);}if(!this._precompileDone&&this._shouldPrecompile)for(let t=i.minzoom||0;t<(i.maxzoom||25.5);t++){const t=this.map.painter;if(t){const r=i.getProgramIds();if(!r)continue;for(const n of r){const r=i.getDefaultProgramParams(n,e.zoom);r&&(t.style=this,this.fog&&(t._fogVisible=!0,r.overrideFog=!0,t.getOrCreateProgram(n,r)),t._fogVisible=!1,r.overrideFog=!1,t.getOrCreateProgram(n,r),(this.stylesheet.terrain||this.stylesheet.projection&&"globe"===this.stylesheet.projection.name)&&(r.overrideRtt=!0,t.getOrCreateProgram(n,r)));}}}}this._shouldPrecompile&&(this._precompileDone=!0);for(const e in r){const t=this._mergedSourceCaches[e];r[e]!==t.used&&t.getSource().fire(new At("data",{sourceDataType:"visibility",dataType:"source",sourceId:t.getSource().id}));}this.light&&this.light.recalculate(e),this.terrain&&this.terrain.recalculate(e),this.fog&&this.fog.recalculate(e),this.z=e.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),i&&this.fire(new At("data",{dataType:"style"}));for(const{style:t}of this.fragments)t.update(e);}_updateTilesForChangedImages(){const e=Array.from(this._changes.changedImages.keys());if(e.length){for(const t in this._sourceCaches)this._sourceCaches[t].reloadTilesForDependencies(["icons","patterns"],e);this._changes.changedImages.clear();}}_updateWorkerLayers(e,t,i){const r=this.getFragmentStyle(e);this.dispatcher.broadcast("updateLayers",{layers:t?r._serializeLayers(t):[],scope:e,removedIds:i||[],options:r.options});}setState(e){if(this._checkLoaded(),UA(this,hs(e)))return !1;(e=$(e)).layers=IT(e.layers);const t=function(e,t){if(!e)return [{command:CT.setStyle,args:[t]}];let i=[];try{if(!x(e.version,t.version))return [{command:CT.setStyle,args:[t]}];x(e.center,t.center)||i.push({command:CT.setCenter,args:[t.center]}),x(e.zoom,t.zoom)||i.push({command:CT.setZoom,args:[t.zoom]}),x(e.bearing,t.bearing)||i.push({command:CT.setBearing,args:[t.bearing]}),x(e.pitch,t.pitch)||i.push({command:CT.setPitch,args:[t.pitch]}),x(e.sprite,t.sprite)||i.push({command:CT.setSprite,args:[t.sprite]}),x(e.glyphs,t.glyphs)||i.push({command:CT.setGlyphs,args:[t.glyphs]}),x(e.transition,t.transition)||i.push({command:CT.setTransition,args:[t.transition]}),x(e.light,t.light)||i.push({command:CT.setLight,args:[t.light]}),x(e.fog,t.fog)||i.push({command:CT.setFog,args:[t.fog]}),x(e.projection,t.projection)||i.push({command:CT.setProjection,args:[t.projection]}),x(e.lights,t.lights)||i.push({command:CT.setLights,args:[t.lights]}),x(e.camera,t.camera)||i.push({command:CT.setCamera,args:[t.camera]});const r={},n=[];!function(e,t,i,r){let n;for(n in t=t||{},e=e||{})e.hasOwnProperty(n)&&(t.hasOwnProperty(n)||DT(n,i,r));for(n in t){if(!t.hasOwnProperty(n))continue;const o=t[n];e.hasOwnProperty(n)?x(e[n],o)||("geojson"===e[n].type&&"geojson"===o.type&&RT(e,t,n)?i.push({command:CT.setGeoJSONSourceData,args:[n,o.data]}):PT(n,t,i,r)):zT(n,t,i);}}(e.sources,t.sources,n,r);const o=[];e.layers&&e.layers.forEach((e=>{e.source&&r[e.source]?i.push({command:CT.removeLayer,args:[e.id]}):o.push(e);}));let s=e.terrain;s&&r[s.source]&&(i.push({command:CT.setTerrain,args:[void 0]}),s=void 0),i=i.concat(n),x(s,t.terrain)||i.push({command:CT.setTerrain,args:[t.terrain]}),function(e,t,i){t=t||[];const r=(e=e||[]).map(kT),n=t.map(kT),o=e.reduce(OT,{}),s=t.reduce(OT,{}),a=r.slice(),l=Object.create(null);let c,h,u,d,p,f,m;for(c=0,h=0;c!(e.command in jA)));if(0===t.length)return !1;const i=t.filter((e=>!(e.command in VA)));if(i.length>0)throw new Error(`Unimplemented: ${i.map((e=>e.command)).join(", ")}.`);return t.forEach((e=>{this[e.command].apply(this,e.args);})),this.stylesheet=e,this.mergeAll(),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),!0}addImage(e,t){return this.getImage(e)?this.fire(new St(new Error("An image with this name already exists."))):(this.imageManager.addImage(e,this.scope,t),this._afterImageUpdated(e),this)}updateImage(e,t){this.imageManager.updateImage(e,this.scope,t);}getImage(e){return this.imageManager.getImage(e,this.scope)}removeImage(e){return this.getImage(e)?(this.imageManager.removeImage(e,this.scope),this._afterImageUpdated(e),this):this.fire(new St(new Error("No image with this name exists.")))}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(this.scope),this._changes.changedImages.add(e),this._changes.changed=!0,this.dispatcher.broadcast("setImages",{scope:this.scope,images:this._availableImages}),this.fire(new At("data",{dataType:"style"}));}listImages(){return this._checkLoaded(),this._availableImages.slice()}addModel(e,t,i={}){return this._checkLoaded(),this._validate(vs,`models.${e}`,t,null,i)||(this.modelManager.addModel(e,t,this.scope),this._changes.changed=!0),this}hasModel(e){return this.modelManager.hasModel(e,this.scope)}removeModel(e){return this.hasModel(e)?(this.modelManager.removeModel(e,this.scope),this):this.fire(new St(new Error("No model with this ID exists.")))}listModels(){return this._checkLoaded(),this.modelManager.listModels(this.scope)}addSource(e,t,i={}){if(this._checkLoaded(),void 0!==this.getOwnSource(e))throw new Error(`There is already a source with ID "${e}".`);if(!t.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(t).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(t.type)>=0&&this._validate(us,`sources.${e}`,t,null,i))return;this.map&&this.map._collectResourceTiming&&(t.collectResourceTiming=!0);const r=vT(e,t,this.dispatcher,this);r.scope=this.scope,r.setEventedParent(this,(()=>({isSourceLoaded:this._isSourceCacheLoaded(r.id),source:r.serialize(),sourceId:r.id})));const n=e=>{const t=(e?"symbol:":"other:")+r.id,i=pa(t,this.scope),n=this._sourceCaches[t]=new Ax(i,r,e);(e?this._symbolSourceCaches:this._otherSourceCaches)[r.id]=n,n.onAdd(this.map);};n(!1),"vector"!==t.type&&"geojson"!==t.type||n(!0),r.onAdd&&r.onAdd(this.map),this.mergeSources(),this._changes.changed=!0;}removeSource(e){this._checkLoaded();const t=this.getOwnSource(e);if(!t)throw new Error("There is no source with this ID");for(const t in this._layers)if(this._layers[t].source===e)return this.fire(new St(new Error(`Source "${e}" cannot be removed while layer "${t}" is using it.`)));if(this.terrain&&this.terrain.get().source===e)return this.fire(new St(new Error(`Source "${e}" cannot be removed while terrain is using it.`)));const i=this.getOwnSourceCaches(e);for(const e of i){const t=fa(e.id);delete this._sourceCaches[t],delete this._changes.updatedSourceCaches[e.id],e.fire(new At("data",{sourceDataType:"metadata",dataType:"source",sourceId:e.getSource().id})),e.setEventedParent(null),e.clearTiles();}return delete this._otherSourceCaches[e],delete this._symbolSourceCaches[e],this.mergeSources(),t.setEventedParent(null),t.onRemove&&t.onRemove(this.map),this._changes.changed=!0,this}setGeoJSONSourceData(e,t){this._checkLoaded(),this.getOwnSource(e).setData(t),this._changes.changed=!0;}getOwnSource(e){const t=this.getOwnSourceCache(e);return t&&t.getSource()}getOwnSources(){const e=[];for(const t in this._otherSourceCaches){const i=this.getOwnSourceCache(t);i&&e.push(i.getSource());}return e}setLights(e){if(this._checkLoaded(),!e)return delete this.ambientLight,void delete this.directionalLight;const t=this._getTransitionParameters();for(const i of e){if(this._validate(ps,"lights",i))return;switch(i.type){case"ambient":if(this.ambientLight){const e=this.ambientLight;e.set(i),e.updateTransitions(t);}else this.ambientLight=new gw(i,yw,this.scope,this.options);break;case"directional":if(this.directionalLight){const e=this.directionalLight;e.set(i),e.updateTransitions(t);}else this.directionalLight=new gw(i,xw,this.scope,this.options);}}const i=new ea(this.z||0,t);this.ambientLight&&this.ambientLight.recalculate(i),this.directionalLight&&this.directionalLight.recalculate(i),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast("setBrightness",this._brightness);}calculateLightsBrightness(){const e=this.directionalLight,t=this.ambientLight;if(!e||!t)return;const i=e=>.2126*(e[0]<=.03928?e[0]/12.92:Math.pow((e[0]+.055)/1.055,2.4))+.7152*(e[1]<=.03928?e[1]/12.92:Math.pow((e[1]+.055)/1.055,2.4))+.0722*(e[2]<=.03928?e[2]/12.92:Math.pow((e[2]+.055)/1.055,2.4)),r=e.properties.get("color").toArray01(),n=e.properties.get("intensity"),o=e.properties.get("direction"),s=1-J(o.x,o.y,o.z)[2]/90,a=i(r)*n*s,l=t.properties.get("color").toArray01(),c=t.properties.get("intensity");return (a+i(l)*c)/2}getBrightness(){return this._brightness}getLights(){if(!this.enable3dLights())return null;const e=[];return this.directionalLight&&e.push(this.directionalLight.get()),this.ambientLight&&e.push(this.ambientLight.get()),e}enable3dLights(){return !!this.ambientLight&&!!this.directionalLight}getFragmentStyle(e){if(!e)return this;const t=this.fragments.find((({id:t})=>t===e));if(!t)throw new Error(`Style import not found: ${e}`);return t.style}setConfigProperty(e,t,i){const r=xo(i);if("success"!==r.result)return void UA(this,r.value);const n=r.value.expression,o=this.getFragmentStyle(e);o.options.set(t,n),o.updateConfigDependencies();}setConfig(e,t){if(this.options.clear(),e){for(const t in e){const i=xo(e[t]);"success"===i.result&&this.options.set(t,i.value.expression);}this.updateSchema(t);}}updateSchema(e){if(e)for(const t in e){if(this.options.has(t))continue;const i=xo(e[t].default);"success"===i.result&&this.options.set(t,i.value.expression);}}updateConfigDependencies(){for(const e of this._configDependentLayers){const t=this.getLayer(e);t&&(t.possiblyEvaluateVisibility(),this._updateLayer(t));}this.ambientLight&&this.ambientLight.scope===this.scope&&this.ambientLight.updateConfig(this.options),this.directionalLight&&this.directionalLight.scope===this.scope&&this.directionalLight.updateConfig(this.options),this._changes.changed=!0;}addLayer(e,t,i={}){this._checkLoaded();const r=e.id;if(this._layers[r])return void this.fire(new St(new Error(`Layer with id "${r}" already exists on this map`)));let n;if("custom"===e.type){if(UA(this,function(e){const t=[],i=e.id;return void 0===i&&t.push({message:`layers.${i}: missing required property "id"`}),void 0===e.render&&t.push({message:`layers.${i}: missing required method "render"`}),e.renderingMode&&"2d"!==e.renderingMode&&"3d"!==e.renderingMode&&t.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),t}(e)))return;n=Kb(e,this.options);}else {if("object"==typeof e.source&&(this.addSource(r,e.source),e=k(e=$(e),{source:r})),this._validate(_s,`layers.${r}`,e,{arrayIndex:-1},i))return;n=Kb(e,this.options),this._validateLayer(n),n.setEventedParent(this,{layer:{id:r}}),this._serializedLayers[n.id]=n.serialize();}n.isConfigDependent&&this._configDependentLayers.add(n.fqid),n.setScope(this.scope);const o=t?this._order.indexOf(t):this._order.length;if(t&&-1===o)return void this.fire(new St(new Error(`Layer with id "${t}" does not exist on this map.`)));this._order.splice(o,0,r),this._layerOrderChanged=!0,this._layers[r]=n;const s=this.getOwnLayerSourceCache(n),a=!!this.directionalLight&&this.directionalLight.shadowsEnabled();s&&n.canCastShadows()&&a&&(s.castsShadows=!0);const l=this._changes.getRemovedLayer(n);if(l&&n.source&&s&&"custom"!==n.type){this._changes.discardLayerRemoval(n);const e=pa(n.source,n.scope);l.type!==n.type?this._changes.updatedSourceCaches[e]="clear":(this._changes.updatedSourceCaches[e]="reload",s.pause());}this._updateLayer(n),n.onAdd&&n.onAdd(this.map),n.scope=this.scope,this.mergeLayers();}moveLayer(e,t){if(this._checkLoaded(),this._changes.changed=!0,!this._checkLayer(e))return;if(e===t)return;const i=this._order.indexOf(e);this._order.splice(i,1);const r=t?this._order.indexOf(t):this._order.length;t&&-1===r?this.fire(new St(new Error(`Layer with id "${t}" does not exist on this map.`))):(this._order.splice(r,0,e),this._layerOrderChanged=!0,this.mergeLayers());}removeLayer(e){this._checkLoaded();const t=this._checkLayer(e);if(!t)return;t.setEventedParent(null);const i=this._order.indexOf(e);this._order.splice(i,1),delete this._layers[e],delete this._serializedLayers[e],this._changes.changed=!0,this._layerOrderChanged=!0,this._configDependentLayers.delete(t.fqid),this._changes.removeLayer(t);const r=this.getOwnLayerSourceCache(t);if(r&&r.castsShadows){let e=!1;for(const i in this._layers)if(this._layers[i].source===t.source&&this._layers[i].canCastShadows()){e=!0;break}r.castsShadows=e;}t.onRemove&&t.onRemove(this.map),this.mergeLayers();}getOwnLayer(e){return this._layers[e]}hasLayer(e){return e in this._mergedLayers}hasLayerType(e){for(const t in this._layers)if(this._layers[t].type===e)return !0;return !1}setLayerZoomRange(e,t,i){this._checkLoaded();const r=this._checkLayer(e);r&&(r.minzoom===t&&r.maxzoom===i||(null!=t&&(r.minzoom=t),null!=i&&(r.maxzoom=i),this._updateLayer(r)));}setSlot(e,t){this._checkLoaded();const i=this._checkLayer(e);i&&i.slot!==t&&(i.slot=t,this._updateLayer(i));}setFilter(e,t,i={}){this._checkLoaded();const r=this._checkLayer(e);if(r&&!x(r.filter,t))return null==t?(r.filter=void 0,void this._updateLayer(r)):void(this._validate(gs,`layers.${r.id}.filter`,t,{layerType:r.type},i)||(r.filter=$(t),this._updateLayer(r)))}getFilter(e){const t=this._checkLayer(e);if(t)return $(t.filter)}setLayoutProperty(e,t,i,r={}){this._checkLoaded();const n=this._checkLayer(e);n&&(x(n.getLayoutProperty(t),i)||(n.setLayoutProperty(t,i,r),n.isConfigDependent&&this._configDependentLayers.add(n.fqid),this._updateLayer(n)));}getLayoutProperty(e,t){const i=this._checkLayer(e);if(i)return i.getLayoutProperty(t)}setPaintProperty(e,t,i,r={}){this._checkLoaded();const n=this._checkLayer(e);if(!n)return;if(x(n.getPaintProperty(t),i))return;const o=n.setPaintProperty(t,i,r);n.isConfigDependent&&this._configDependentLayers.add(n.fqid),o&&this._updateLayer(n),this._changes.changed=!0,this._changes.updatedPaintProps.add(n.fqid);}getPaintProperty(e,t){const i=this._checkLayer(e);if(i)return i.getPaintProperty(t)}setFeatureState(e,t){this._checkLoaded();const i=e.source,r=e.sourceLayer,n=this._checkSource(i);if(!n)return;const o=n.type;if("geojson"===o&&r)return void this.fire(new St(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===o&&!r)return void this.fire(new St(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===e.id&&this.fire(new St(new Error("The feature id parameter must be provided.")));const s=this.getOwnSourceCaches(i);for(const i of s)i.setFeatureState(r,e.id,t);}removeFeatureState(e,t){this._checkLoaded();const i=e.source,r=this._checkSource(i);if(!r)return;const n=r.type,o="vector"===n?e.sourceLayer:void 0;if("vector"===n&&!o)return void this.fire(new St(new Error("The sourceLayer parameter must be provided for vector source types.")));if(t&&"string"!=typeof e.id&&"number"!=typeof e.id)return void this.fire(new St(new Error("A feature id is required to remove its specific state property.")));const s=this.getOwnSourceCaches(i);for(const i of s)i.removeFeatureState(o,e.id,t);}getFeatureState(e){this._checkLoaded();const t=e.source,i=e.sourceLayer,r=this._checkSource(t);if(r){if("vector"!==r.type||i)return void 0===e.id&&this.fire(new St(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(t)[0].getFeatureState(i,e.id);this.fire(new St(new Error("The sourceLayer parameter must be provided for vector source types.")));}}setTransition(e){return this.stylesheet.transition=k({},this.stylesheet.transition,e),this.transition=this.stylesheet.transition,this}getTransition(){return k({},this.stylesheet.transition)}serialize(){this._checkLoaded();const e=this.getTerrain(),t=e&&this.terrain&&this.terrain.scope===this.scope?e:void 0;return Z({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,imports:this._serializeImports(),schema:this.stylesheet.schema,camera:this.stylesheet.camera,light:this.stylesheet.light,lights:this.stylesheet.lights,terrain:t,fog:this.stylesheet.fog,center:this.stylesheet.center,zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,projection:this.stylesheet.projection,sources:this._serializeSources(),layers:this._serializeLayers(this._order)},(e=>void 0!==e))}_updateLayer(e){this._changes.updateLayer(e);const t=this.getLayerSourceCache(e),i=pa(e.source,e.scope);e.source&&!this._changes.updatedSourceCaches[i]&&t&&"raster"!==t.getSource().type&&(this._changes.updatedSourceCaches[i]="reload",t.pause()),this._changes.changed=!0,e.invalidateCompiledFilter();}_flattenAndSortRenderedFeatures(e){const t=e=>"fill-extrusion"===this._mergedLayers[e].type,i=this.order,r={},n=[];for(let o=i.length-1;o>=0;o--){const s=i[o];if(t(s)){r[s]=o;for(const t of e){const e=t[s];if(e)for(const t of e)n.push(t);}}}n.sort(((e,t)=>t.intersectionZ-e.intersectionZ));const o=[];for(let s=i.length-1;s>=0;s--){const a=i[s];if(t(a))for(let e=n.length-1;e>=0;e--){const t=n[e].feature;if(r[t.layer.id]{const t=this.getLayer(e);return t&&t.is3D()})):this.has3DLayers(),a=vw.createFromScreenPoints(e,i);for(const e in this._mergedSourceCaches){const l=this._mergedSourceCaches[e].getSource();if(!l||l.scope!==t.scope)continue;const c=this._mergedSourceCaches[e].getSource().id;t.layers&&!r[c]||n.push(wT(this._mergedSourceCaches[e],this._mergedLayers,o,a,t,i,s,!!this.map._showQueryGeometry));}return this.placement&&n.push(function(e,t,i,r,n,o,s){const a={},l=o.queryRenderedSymbols(r),c=[];for(const e of Object.keys(l).map(Number))c.push(s[e]);c.sort(ET);for(const i of c){const r=i.featureIndex.lookupSymbolFeatures(l[i.bucketInstanceId],t,i.bucketIndex,i.sourceLayerIndex,n.filter,n.layers,n.availableImages,e);for(const e in r){const t=a[e]=a[e]||[],n=r[e];n.sort(((e,t)=>{const r=i.featureSortOrder;if(r){const i=r.indexOf(e.featureIndex);return r.indexOf(t.featureIndex)-i}return t.featureIndex-e.featureIndex}));for(const e of n)t.push(e);}}for(const t in a)a[t].forEach((r=>{const n=r.feature,o=i(e[t]);if(!o)return;const s=o.getFeatureState(n.layer["source-layer"],n.id);n.source=n.layer.source,n.layer["source-layer"]&&(n.sourceLayer=n.layer["source-layer"]),n.state=s;}));return a}(this._mergedLayers,o,this.getLayerSourceCache.bind(this),a.screenGeometry,t,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(n)}querySourceFeatures(e,t){t&&t.filter&&this._validate(gs,"querySourceFeatures.filter",t.filter,null,t);const i=this.getOwnSourceCaches(e);let r=[];for(const e of i)r=r.concat(TT(e,t));return r}addSourceType(e,t,i){return $A.getSourceType(e)?i(new Error(`A source type called "${e}" already exists.`)):($A.setSourceType(e,t),t.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:e,url:t.workerSourceURL},i):i(null,null))}getFlatLight(){return this.light.getLight()}setFlatLight(e,t,i={}){this._checkLoaded();const r=this.light.getLight();let n=!1;for(const t in e)if(!x(e[t],r[t])){n=!0;break}if(!n)return;const o=this._getTransitionParameters();this.light.setLight(e,t,i),this.light.updateTransitions(o);}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0);}setTerrain(e,t=1){if(this._checkLoaded(),!e)return delete this.terrain,delete this.stylesheet.terrain,this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);let i=e;if(1===t){if("object"==typeof i.source){const e="terrain-dem-src";this.addSource(e,i.source),i=$(i),i=k(i,{source:e});}if(this._validate(fs,"terrain",i))return}if(!this.terrain||this.terrain&&t!==this.terrain.drapeRenderMode){if(!i)return;this._createTerrain(i,t),this.fire(new At("data",{dataType:"style"}));}else {const t=this.terrain,r=t.get();for(const e of Object.keys(Ct.terrain))!i.hasOwnProperty(e)&&Ct.terrain[e].default&&(i[e]=Ct.terrain[e].default);for(const i in e)if(!x(e[i],r[i])){t.set(e),this.stylesheet.terrain=e;const i=this._getTransitionParameters({duration:0});t.updateTransitions(i),this.fire(new At("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0;}_createFog(e){const t=this.fog=new dw(e,this.map.transform);this.stylesheet.fog=t.get();const i=this._getTransitionParameters({duration:0});t.updateTransitions(i);}_updateMarkersOpacity(){0!==this.map._markers.length&&this.map._requestDomTask((()=>{for(const e of this.map._markers)e._evaluateOpacity();}));}getFog(){return this.fog?this.fog.get():null}setFog(e){if(this._checkLoaded(),!e)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const t=this.fog;if(!x(t.get(),e)){t.set(e),this.stylesheet.fog=t.get();const i=this._getTransitionParameters({duration:0});t.updateTransitions(i);}}else this._createFog(e);this._markersNeedUpdate=!0;}_getTransitionParameters(e){return {now:ht.now(),transition:k(this.transition,e)}}updateDrapeFirstLayers(){if(!this.terrain)return;const e=[],t=[];for(const i in this._mergedLayers)this.isLayerDraped(this._mergedLayers[i])?e.push(i):t.push(i);this._drapedFirstOrder=[],this._drapedFirstOrder.push(...e),this._drapedFirstOrder.push(...t);}_createTerrain(e,t){const i=this.terrain=new rw(e,t);i.setScope(this.scope),this.stylesheet.terrain=e,this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();const r=this._getTransitionParameters({duration:0});i.updateTransitions(r);}_force3DLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"fill-extrusion"===t.type&&this._updateLayer(t);}}_forceSymbolLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"symbol"===t.type&&this._updateLayer(t);}}_validate(e,t,i,r,n={}){if(n&&!1===n.validate)return !1;const o=k({},this.serialize());return UA(this,e.call(hs,k({key:t,style:o,value:i,styleSpec:Ct},r)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),Ys.off("pluginStateChange",this._rtlTextPluginCallback);for(const e in this._mergedLayers)this._mergedLayers[e].setEventedParent(null);for(const e in this._mergedSourceCaches)this._mergedSourceCaches[e].clearTiles(),this._mergedSourceCaches[e].setEventedParent(null);this.setEventedParent(null),delete this.fog,delete this.terrain,delete this.ambientLight,delete this.directionalLight,this.isRootStyle()&&(this.imageManager.setEventedParent(null),this.modelManager.setEventedParent(null),this.dispatcher.remove());}clearSource(e){const t=this.getSourceCaches(e);for(const e of t)e.clearTiles();}clearSources(){for(const e in this._mergedSourceCaches)this._mergedSourceCaches[e].clearTiles();}reloadSource(e){const t=this.getSourceCaches(e);for(const e of t)e.resume(),e.reload();}updateSources(e){let t;this.directionalLight&&(t=OA(this.directionalLight));for(const i in this._mergedSourceCaches)this._mergedSourceCaches[i].update(e,void 0,void 0,t);}_generateCollisionBoxes(){for(const e in this._sourceCaches){const t=this._sourceCaches[e];t.resume(),t.reload();}}_updatePlacement(e,t,i,r,n=!1){let o=!1,s=!1;const a={},l={};for(const t of this._mergedOrder){const i=this._mergedLayers[t];if("symbol"!==i.type)continue;const r=pa(i.source,i.scope);let n=a[r];if(!n){const e=this.getLayerSourceCache(i);if(!e)continue;const t=e.getRenderableIds(!0).map((t=>e.getTileByID(t)));l[r]=t.slice(),n=a[r]=t.sort(((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1)));}const s=this.crossTileSymbolIndex.addLayer(i,n,e.center.lng,e.projection);o=o||s;}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder),n=n||this._layerOrderChanged||0===i,this._layerOrderChanged&&this.fire(new At("neworder")),(n||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(ht.now(),e.zoom))&&(this.pauseablePlacement=new hE(e,this._mergedOrder,n,t,i,r,this.placement,this.fog&&e.projection.supportsFog?this.fog.state:null,this._buildingIndex),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,a,l),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(ht.now()),s=!0),o&&this.pauseablePlacement.placement.setStale()),s||o)for(const e of this._mergedOrder){const t=this._mergedLayers[e];"symbol"===t.type&&this.placement.updateLayerOpacities(t,a[pa(t.source,t.scope)]);}return !this.pauseablePlacement.isDone()||this.placement.hasTransitions(ht.now())}_releaseSymbolFadeTiles(){for(const e in this._sourceCaches)this._sourceCaches[e].releaseSymbolFadeTiles();}addImport(e){this._checkLoaded();const t=this.stylesheet.imports=this.stylesheet.imports||[],i=t.findIndex((({id:t})=>t===e.id));return -1!==i?this.fire(new St(new Error(`Import with id '${e.id}' already exists in the map's style.`))):(t.push(e),this._loadImports([e],!0),this)}setImportUrl(e,t){this._checkLoaded();const i=this.stylesheet.imports||[],r=this.getImportIndex(e);if(-1===r)return this;i[r].url=t;const n=this.fragments[r];n.style=this._createFragmentStyle({id:e,url:t});const o=new Promise((e=>n.style.on("style.import.load",e)));return n.style.loadURL(t),o.then((()=>this._reloadImports())),this}setImportData(e,t){this._checkLoaded();const i=this.getImportIndex(e),r=this.stylesheet.imports||[];return -1===i?this:t?(this.fragments[i].style.setState(t),this._reloadImports(),this):(delete r[i].data,this.setImportUrl(e,r[i].url))}setImportConfig(e,t){this._checkLoaded();const i=this.getImportIndex(e),r=this.stylesheet.imports||[];if(-1===i)return this;t?r[i].config=t:delete r[i].config;const n=this.fragments[i],o=n.style.stylesheet&&n.style.stylesheet.schema;return n.config=t,n.style.setConfig(t,o),n.style.updateConfigDependencies(),this}removeImport(e){this._checkLoaded();const t=this.stylesheet.imports||[],i=this.getImportIndex(e);return -1===i||(t.splice(i,1),this.fragments[i].style._remove(),this.fragments.splice(i,1),this._reloadImports()),this}getImportIndex(e){const t=(this.stylesheet.imports||[]).findIndex((t=>t.id===e));return -1===t&&this.fire(new St(new Error(`Import '${e}' does not exist in the map's style and cannot be updated.`))),t}getLayer(e){return this._mergedLayers[e]}getSources(){const e=[];for(const t in this._mergedOtherSourceCaches){const i=this._mergedOtherSourceCaches[t];i&&e.push(i.getSource());}return e}getSource(e,t){const i=this.getSourceCache(e,t);return i&&i.getSource()}getLayerSource(e){const t=this.getLayerSourceCache(e);return t&&t.getSource()}getSourceCache(e,t){const i=pa(e,t);return this._mergedOtherSourceCaches[i]}getLayerSourceCache(e){const t=pa(e.source,e.scope);return "symbol"===e.type?this._mergedSymbolSourceCaches[t]:this._mergedOtherSourceCaches[t]}getSourceCaches(e){const t=[];return this._mergedOtherSourceCaches[e]&&t.push(this._mergedOtherSourceCaches[e]),this._mergedSymbolSourceCaches[e]&&t.push(this._mergedSymbolSourceCaches[e]),t}updateSourceCaches(){for(const e in this._changes.updatedSourceCaches){const t=this._changes.updatedSourceCaches[e];"reload"===t?this.reloadSource(e):"clear"===t&&this.clearSource(e);}}updateLayers(e){for(const t of this._changes.updatedPaintProps){const i=this.getLayer(t);i&&i.updateTransitions(e);}}getImages(e,t,i){this.imageManager.getImages(t.icons,t.scope,i),this._updateTilesForChangedImages();const r=e=>{e&&e.setDependencies(t.tileID.key,t.type,t.icons);};r(this._otherSourceCaches[t.source]),r(this._symbolSourceCaches[t.source]);}getGlyphs(e,t,i){this.glyphManager.getGlyphs(t.stacks,t.scope,i);}getResource(e,t,i){return be(t,i)}getOwnSourceCache(e){return this._otherSourceCaches[e]}getOwnLayerSourceCache(e){return "symbol"===e.type?this._symbolSourceCaches[e.source]:this._otherSourceCaches[e.source]}getOwnSourceCaches(e){const t=[];return this._otherSourceCaches[e]&&t.push(this._otherSourceCaches[e]),this._symbolSourceCaches[e]&&t.push(this._symbolSourceCaches[e]),t}_isSourceCacheLoaded(e){const t=this.getOwnSourceCaches(e);return 0===t.length?(this.fire(new St(new Error(`There is no source with ID '${e}'`))),!1):t.every((e=>e.loaded()))}has3DLayers(){return this._has3DLayers}hasSymbolLayers(){return this._hasSymbolLayers}hasCircleLayers(){return this._hasCircleLayers}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches");}destroy(){this._clearWorkerCaches(),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain);}}function HA(e,t){let i=!1,r=null;const n=()=>{r=null,i&&(e(),r=setTimeout(n,t),i=!1);};return ()=>(i=!0,r||n(),r)}$A.getSourceType=function(e){return xT[e]},$A.setSourceType=function(e,t){xT[e]=t;},$A.registerForPluginStateChange=function(e){return e({pluginStatus:$s,pluginURL:Hs}),Ys.on("pluginStateChange",e),e};class WA{constructor(e){this._hashName=e&&encodeURIComponent(e),j(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=HA(this._updateHashUnthrottled.bind(this),300);}addTo(e){return this._map=e,t.addEventListener("hashchange",this._onHashChange,!1),e.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),t.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(){const e=this._map;if(!e)return "";const i=XA(e);if(this._hashName){const e=this._hashName;let r=!1;const n=t.location.hash.slice(1).split("&").map((t=>{const n=t.split("=")[0];return n===e?(r=!0,`${n}=${i}`):t})).filter((e=>e));return r||n.push(`${e}=${i}`),`#${n.join("&")}`}return `#${i}`}_getCurrentHash(){const e=t.location.hash.replace("#","");if(this._hashName){let t;return e.split("&").map((e=>e.split("="))).forEach((e=>{e[0]===this._hashName&&(t=e);})),(t&&t[1]||"").split("/")}return e.split("/")}_onHashChange(){const e=this._map;if(!e)return !1;const t=this._getCurrentHash();if(t.length>=3&&!t.some((e=>isNaN(e)))){const i=e.dragRotate.isEnabled()&&e.touchZoomRotate.isEnabled()?+(t[3]||0):e.getBearing();return e.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:i,pitch:+(t[4]||0)}),!0}return !1}_updateHashUnthrottled(){const e=t.location.href.replace(/(#.+)?$/,this.getHashString());t.history.replaceState(t.history.state,null,e);}}function XA(e,t){const i=e.getCenter(),r=Math.round(100*e.getZoom())/100,n=Math.ceil((r*Math.LN2+Math.log(512/360/.5))/Math.LN10),o=Math.pow(10,n),s=Math.round(i.lng*o)/o,a=Math.round(i.lat*o)/o,l=e.getBearing(),c=e.getPitch();let h=t?`/${s}/${a}/${r}`:`${r}/${a}/${s}`;return (l||c)&&(h+="/"+Math.round(10*l)/10),c&&(h+=`/${Math.round(c)}`),h}const YA={linearity:.3,easing:I(0,0,.3,1)},KA=k({deceleration:2500,maxSpeed:1400},YA),JA=k({deceleration:20,maxSpeed:1400},YA),QA=k({deceleration:1e3,maxSpeed:360},YA),eS=k({deceleration:1e3,maxSpeed:90},YA);class tS{constructor(e){this._map=e,this.clear();}clear(){this._inertiaBuffer=[];}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:ht.now(),settings:e});}_drainInertiaBuffer(){const e=this._inertiaBuffer,t=ht.now();for(;e.length>0&&t-e[0].time>160;)e.shift();}_onMoveEnd(e){if(this._map._prefersReducedMotion())return;if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const t={zoom:0,bearing:0,pitch:0,pan:new y(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)t.zoom+=e.zoomDelta||0,t.bearing+=e.bearingDelta||0,t.pitch+=e.pitchDelta||0,e.panDelta&&t.pan._add(e.panDelta),e.around&&(t.around=e.around),e.pinchAround&&(t.pinchAround=e.pinchAround);const i=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,r={};if(t.pan.mag()){const n=rS(t.pan.mag(),i,k({},KA,e||{}));r.offset=t.pan.mult(n.amount/t.pan.mag()),r.center=this._map.transform.center,iS(r,n);}if(t.zoom){const e=rS(t.zoom,i,JA);r.zoom=this._map.transform.zoom+e.amount,iS(r,e);}if(t.bearing){const e=rS(t.bearing,i,QA);r.bearing=this._map.transform.bearing+z(e.amount,-179,179),iS(r,e);}if(t.pitch){const e=rS(t.pitch,i,eS);r.pitch=this._map.transform.pitch+e.amount,iS(r,e);}if(r.zoom||r.bearing){const e=void 0===t.pinchAround?t.around:t.pinchAround;r.around=e?this._map.unproject(e):this._map.getCenter();}return this.clear(),r.noMoveStart=!0,r}}function iS(e,t){(!e.duration||e.durationt.unproject(e))),s=n.reduce(((e,t,i,r)=>e.add(t.div(r.length))),new y(0,0));super(e,{points:n,point:s,lngLats:o,lngLat:t.unproject(s),originalEvent:i}),this._defaultPrevented=!1;}}class sS extends At{preventDefault(){this._defaultPrevented=!0;}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i){super(e,{originalEvent:i}),this._defaultPrevented=!1;}}class aS{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance;}reset(){this._mousedownPos=void 0;}wheel(e){return this._firePreventable(new sS(e.type,this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new nS(e.type,this._map,e))}mouseup(e){this._map.fire(new nS(e.type,this._map,e));}preclick(e){const t=k({},e);t.type="preclick",this._map.fire(new nS(t.type,this._map,t));}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||(this.preclick(e),this._map.fire(new nS(e.type,this._map,e)));}dblclick(e){return this._firePreventable(new nS(e.type,this._map,e))}mouseover(e){this._map.fire(new nS(e.type,this._map,e));}mouseout(e){this._map.fire(new nS(e.type,this._map,e));}touchstart(e){return this._firePreventable(new oS(e.type,this._map,e))}touchmove(e){this._map.fire(new oS(e.type,this._map,e));}touchend(e){this._map.fire(new oS(e.type,this._map,e));}touchcancel(e){this._map.fire(new oS(e.type,this._map,e));}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return {}}isEnabled(){return !0}isActive(){return !1}enable(){}disable(){}}class lS{constructor(e){this._map=e;}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0;}mousemove(e){this._map.fire(new nS(e.type,this._map,e));}mousedown(){this._delayContextMenu=!0;}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new nS("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent);}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._map.fire(new nS(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault();}isEnabled(){return !0}isActive(){return !1}enable(){}disable(){}}class cS{constructor(e,t){this._map=e,this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=t.clickTolerance||1;}isEnabled(){return !!this._enabled}isActive(){return !!this._active}enable(){this.isEnabled()||(this._enabled=!0);}disable(){this.isEnabled()&&(this._enabled=!1);}mousedown(e,t){this.isEnabled()&&e.shiftKey&&0===e.button&&(_t(),this._startPos=this._lastPos=t,this._active=!0);}mousemoveWindow(e,t){if(!this._active)return;const i=t,r=this._startPos,n=this._lastPos;if(!r||!n||n.equals(i)||!this._box&&i.dist(r){this._box&&(this._box.style.transform=`translate(${o}px,${a}px)`,this._box.style.width=s-o+"px",this._box.style.height=l-a+"px");}));}mouseupWindow(e,t){if(!this._active)return;const i=this._startPos,r=t;if(i&&0===e.button){if(this.reset(),xt(),i.x!==r.x||i.y!==r.y)return this._map.fire(new At("boxzoomend",{originalEvent:e})),{cameraAnimation:e=>e.fitScreenCoordinates(i,r,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",e);}}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e));}blur(){this.reset();}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),gt(),delete this._startPos,delete this._lastPos;}_fireEvent(e,t){return this._map.fire(new At(e,{originalEvent:t}))}}function hS(e,t){const i={};for(let r=0;rthis.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=e.timeStamp),i.length===this.numTouches&&(this.centroid=function(e){const t=new y(0,0);for(const i of e)t._add(i);return t.div(e.length)}(t),this.touches=hS(i,t)));}touchmove(e,t,i){if(this.aborted||!this.centroid)return;const r=hS(i,t);for(const e in this.touches){const t=r[e];(!t||t.dist(this.touches[e])>30)&&(this.aborted=!0);}}touchend(e,t,i){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class dS{constructor(e){this.singleTap=new uS(e),this.numTaps=e.numTaps,this.reset();}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset();}touchstart(e,t,i){this.singleTap.touchstart(e,t,i);}touchmove(e,t,i){this.singleTap.touchmove(e,t,i);}touchend(e,t,i){const r=this.singleTap.touchend(e,t,i);if(r){const t=e.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(r)<30;if(t&&i||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}}class pS{constructor(){this._zoomIn=new dS({numTouches:1,numTaps:2}),this._zoomOut=new dS({numTouches:2,numTaps:1}),this.reset();}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset();}touchstart(e,t,i){this._zoomIn.touchstart(e,t,i),this._zoomOut.touchstart(e,t,i);}touchmove(e,t,i){this._zoomIn.touchmove(e,t,i),this._zoomOut.touchmove(e,t,i);}touchend(e,t,i){const r=this._zoomIn.touchend(e,t,i),n=this._zoomOut.touchend(e,t,i);return r?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()+1,around:t.unproject(r)},{originalEvent:e})}):n?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()-1,around:t.unproject(n)},{originalEvent:e})}):void 0}touchcancel(){this.reset();}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}const fS={0:1,2:2};class mS{constructor(e){this.reset(),this._clickTolerance=e.clickTolerance||1;}blur(){this.reset();}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0;}_correctButton(e,t){return !1}_move(e,t){return {}}mousedown(e,t){if(this._lastPoint)return;const i=wt(e);this._correctButton(e,i)&&(this._lastPoint=t,this._eventButton=i);}mousemoveWindow(e,t){const i=this._lastPoint;if(i)if(e.preventDefault(),null!=this._eventButton&&function(e,t){const i=fS[t];return void 0===e.buttons||(e.buttons&i)!==i}(e,this._eventButton))this.reset();else if(this._moved||!(t.dist(i)0&&(this._active=!0);const r=hS(i,t),n=new y(0,0),o=new y(0,0);let s=0;for(const e in r){const t=r[e],i=this._touches[e];i&&(n._add(t),o._add(t.sub(i)),s++,r[e]=t);}if(this._touches=r,s{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.setAttribute("role","null");}),500);}}class vS{constructor(){this.reset();}reset(){this._active=!1,this._firstTwoTouches=void 0;}_start(e){}_move(e,t,i){return {}}touchstart(e,t,i){this._firstTwoTouches||i.length<2||(this._firstTwoTouches=[i[0].identifier,i[1].identifier],this._start([t[0],t[1]]));}touchmove(e,t,i){const r=this._firstTwoTouches;if(!r)return;e.preventDefault();const[n,o]=r,s=bS(i,t,n),a=bS(i,t,o);if(!s||!a)return;const l=this._aroundCenter?null:s.add(a).div(2);return this._move([s,a],l,e)}touchend(e,t,i){if(!this._firstTwoTouches)return;const[r,n]=this._firstTwoTouches,o=bS(i,t,r),s=bS(i,t,n);o&&s||(this._active&&xt(),this.reset());}touchcancel(){this.reset();}enable(e){this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}function bS(e,t,i){for(let r=0;rMath.abs(e.x)}class SS extends vS{constructor(e){super(),this._map=e;}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0;}_start(e){this._lastPoints=e,AS(e[0].sub(e[1]))&&(this._valid=!1);}_move(e,t,i){const r=this._lastPoints;if(!r)return;const n=e[0].sub(r[0]),o=e[1].sub(r[1]);return this._map._cooperativeGestures&&!ie()&&i.touches.length<3||(this._valid=this.gestureBeginsVertically(n,o,i.timeStamp),!this._valid)?void 0:(this._lastPoints=e,this._active=!0,{pitchDelta:(n.y+o.y)/2*-.5})}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;const r=e.mag()>=2,n=t.mag()>=2;if(!r&&!n)return;if(!r||!n)return null==this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const o=e.y>0==t.y>0;return AS(e)&&AS(t)&&o}}const IS={panStep:100,bearingStep:15,pitchStep:10};class CS{constructor(){const e=IS;this._panStep=e.panStep,this._bearingStep=e.bearingStep,this._pitchStep=e.pitchStep,this._rotationDisabled=!1;}blur(){this.reset();}reset(){this._active=!1;}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,i=0,r=0,n=0,o=0;switch(e.keyCode){case 61:case 107:case 171:case 187:t=1;break;case 189:case 109:case 173:t=-1;break;case 37:e.shiftKey?i=-1:(e.preventDefault(),n=-1);break;case 39:e.shiftKey?i=1:(e.preventDefault(),n=1);break;case 38:e.shiftKey?r=1:(e.preventDefault(),o=-1);break;case 40:e.shiftKey?r=-1:(e.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(i=0,r=0),{cameraAnimation:s=>{const a=s.getZoom();s.easeTo({duration:300,easeId:"keyboardHandler",easing:zS,zoom:t?Math.round(a)+t*(e.shiftKey?2:1):a,bearing:s.getBearing()+i*this._bearingStep,pitch:s.getPitch()+r*this._pitchStep,offset:[-n*this._panStep,-o*this._panStep],center:s.getCenter()},{originalEvent:e});}}}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 zS(e){return e*(2-e)}const DS=4.000244140625;class PS{constructor(e,t){this._map=e,this._el=e.getCanvasContainer(),this._handler=t,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,j(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this);}setZoomRate(e){this._defaultZoomRate=e;}setWheelZoomRate(e){this._wheelZoomRate=e;}isEnabled(){return !!this._enabled}isActive(){return this._active||void 0!==this._finishTimeout}isZooming(){return !!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around,this._map._cooperativeGestures&&this._addScrollZoomBlocker());}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()));}wheel(e){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(e.ctrlKey||e.metaKey||this.isZooming()||ie()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer));}let i=e.deltaMode===t.WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const r=ht.now(),n=r-(this._lastWheelEventTime||0);this._lastWheelEventTime=r,0!==i&&i%DS==0?this._type="wheel":0!==i&&Math.abs(i)<4?this._type="trackpad":n>400?(this._type=null,this._lastValue=i,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(n*i)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,i+=this._lastValue)),e.shiftKey&&i&&(i/=4),this._type&&(this._lastWheelEvent=e,this._delta-=i,this._active||this._start(e)),e.preventDefault();}_onTimeout(e){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e);}_start(e){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 t=vt(this._el,e);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:t,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame());}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const e=this._map.transform;"wheel"===this._type&&e.projection.wrap&&(e._center.lng>=180||e._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const t=()=>e._terrainEnabled()&&this._aroundCoord?e.computeZoomRelativeTo(this._aroundCoord):e.zoom;if(0!==this._delta){const i="wheel"===this._type&&Math.abs(this._delta)>DS?this._wheelZoomRate:this._defaultZoomRate;let r=2/(1+Math.exp(-Math.abs(this._delta*i)));this._delta<0&&0!==r&&(r=1/r);const n=t(),o=Math.pow(2,n),s="number"==typeof this._targetZoom?e.zoomScale(this._targetZoom):o;this._targetZoom=Math.min(e.maxZoom,Math.max(e.minZoom,e.scaleZoom(s*r))),"wheel"===this._type&&(this._startZoom=n,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0;}const i="number"==typeof this._targetZoom?this._targetZoom:t(),r=this._startZoom,n=this._easing;let o,s=!1;if("wheel"===this._type&&r&&n){const e=Math.min((ht.now()-this._lastWheelEventTime)/200,1);o=Wr(r,i,n(e)),e<1?this._frameId||(this._frameId=!0):s=!0;}else o=i,s=!0;this._active=!0,s&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout;}),200));let a=o-t();return a*this._lastDelta<0&&(a=0),{noInertia:!0,needsRenderFrame:!s,zoomDelta:a,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let t=C;if(this._prevEase){const e=this._prevEase,i=(ht.now()-e.start)/e.duration,r=e.easing(i+.01)-e.easing(i),n=.27/Math.sqrt(r*r+1e-4)*.01;t=I(n,Math.sqrt(.0729-n*n),.25,1);}return this._prevEase={start:ht.now(),duration:e,easing:t},t}blur(){this.reset();}reset(){this._active=!1;}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=ut("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(t.navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`);}_showBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout((()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","null");}),200);}}class RS{constructor(e,t){this._clickZoom=e,this._tapZoom=t;}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 LS{constructor(){this.reset();}reset(){this._active=!1;}blur(){this.reset();}dblclick(e,t){return e.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:i.getZoom()+(e.shiftKey?-1:1),around:i.unproject(t)},{originalEvent:e});}}}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class kS{constructor(){this._tap=new dS({numTouches:1,numTaps:1}),this.reset();}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset();}touchstart(e,t,i){this._swipePoint||(this._tapTime&&e.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?i.length>0&&(this._swipePoint=t[0],this._swipeTouch=i[0].identifier):this._tap.touchstart(e,t,i));}touchmove(e,t,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const r=t[0],n=r.y-this._swipePoint.y;return this._swipePoint=r,e.preventDefault(),this._active=!0,{zoomDelta:n/128}}}else this._tap.touchmove(e,t,i);}touchend(e,t,i){this._tapTime?this._swipePoint&&0===i.length&&this.reset():this._tap.touchend(e,t,i)&&(this._tapTime=e.timeStamp);}touchcancel(){this.reset();}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class OS{constructor(e,t,i){this._el=e,this._mousePan=t,this._touchPan=i;}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("mapboxgl-touch-drag-pan");}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("mapboxgl-touch-drag-pan");}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class BS{constructor(e,t,i){this._pitchWithRotate=e.pitchWithRotate,this._mouseRotate=t,this._mousePitch=i;}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable();}disable(){this._mouseRotate.disable(),this._mousePitch.disable();}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class FS{constructor(e,t,i,r){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0;}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("mapboxgl-touch-zoom-rotate");}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("mapboxgl-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();}}const NS=e=>e.zoom||e.drag||e.pitch||e.rotate;class US extends At{}class VS{constructor(){this.constants=[1,1,.01],this.radius=0;}setup(e,t){const i=Mu.sub([],t,e);this.radius=Mu.length(i[2]<0?Mu.div([],i,this.constants):[i[0],i[1],0]);}projectRay(e){Mu.div(e,e,this.constants),Mu.normalize(e,e),Mu.mul(e,e,this.constants);const t=Mu.scale([],e,this.radius);if(t[2]>0){const e=Mu.scale([],[0,0,1],Mu.dot(t,[0,0,1])),i=Mu.scale([],Mu.normalize([],[t[0],t[1],0]),this.radius),r=Mu.add([],t,Mu.scale([],Mu.sub([],Mu.add([],i,e),t),2));t[0]=r[0],t[1]=r[1];}return t}}function jS(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta}class GS{constructor(e,i){this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new tS(e),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new VS,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(i),j(["handleEvent","handleWindowEvent"],this);const r=this._el;this._listeners=[[r,"touchstart",{passive:!0}],[r,"touchmove",{passive:!1}],[r,"touchend",void 0],[r,"touchcancel",void 0],[r,"mousedown",void 0],[r,"mousemove",void 0],[r,"mouseup",void 0],[t.document,"mousemove",{capture:!0}],[t.document,"mouseup",void 0],[r,"mouseover",void 0],[r,"mouseout",void 0],[r,"dblclick",void 0],[r,"click",void 0],[r,"keydown",{capture:!1}],[r,"keyup",void 0],[r,"wheel",{passive:!1}],[r,"contextmenu",void 0],[t,"blur",void 0]];for(const[e,i,r]of this._listeners)e.addEventListener(i,e===t.document?this.handleWindowEvent:this.handleEvent,r);}destroy(){for(const[e,i,r]of this._listeners)e.removeEventListener(i,e===t.document?this.handleWindowEvent:this.handleEvent,r);}_addDefaultHandlers(e){const t=this._map,i=t.getCanvasContainer();this._add("mapEvent",new aS(t,e));const r=t.boxZoom=new cS(t,e);this._add("boxZoom",r);const n=new pS,o=new LS;t.doubleClickZoom=new RS(o,n),this._add("tapZoom",n),this._add("clickZoom",o);const s=new kS;this._add("tapDragZoom",s);const a=t.touchPitch=new SS(t);this._add("touchPitch",a);const l=new gS(e),c=new yS(e);t.dragRotate=new BS(e,l,c),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",c,["mouseRotate"]);const h=new _S(e),u=new xS(t,e);t.dragPan=new OS(i,h,u),this._add("mousePan",h),this._add("touchPan",u,["touchZoom","touchRotate"]);const d=new MS,p=new TS;t.touchZoomRotate=new FS(i,p,d,s),this._add("touchRotate",d,["touchPan","touchZoom"]),this._add("touchZoom",p,["touchPan","touchRotate"]),this._add("blockableMapEvent",new lS(t));const f=t.scrollZoom=new PS(t,this);this._add("scrollZoom",f,["mousePan"]);const m=t.keyboard=new CS;this._add("keyboard",m);for(const i of ["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])e.interactive&&e[i]&&t[i].enable(e[i]);}_add(e,t,i){this._handlers.push({handlerName:e,handler:t,allowed:i}),this._handlersById[e]=t;}stop(e){if(!this._updatingCamera){for(const{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[],this._originalZoom=void 0;}}isActive(){for(const{handler:e}of this._handlers)if(e.isActive())return !0;return !1}isZooming(){return !!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return !!this._eventsInProgress.rotate}isMoving(){return !!NS(this._eventsInProgress)||this.isZooming()}_isDragging(){return !!this._eventsInProgress.drag}_blockedByActive(e,t,i){for(const r in e)if(r!==i&&(!t||t.indexOf(r)<0))return !0;return !1}handleWindowEvent(e){this.handleEvent(e,`${e.type}Window`);}_getMapTouches(e){const t=[];for(const i of e)this._el.contains(i.target)&&t.push(i);return t}handleEvent(e,t){this._updatingCamera=!0;const i="renderFrame"===e.type,r=i?void 0:e,n={needsRenderFrame:!1},o={},s={},a=e.touches?this._getMapTouches(e.touches):void 0,l=a?bt(this._el,a):i?void 0:vt(this._el,e);for(const{handlerName:i,handler:c,allowed:h}of this._handlers){if(!c.isEnabled())continue;let u;this._blockedByActive(s,h,i)?c.reset():c[t||e.type]&&(u=c[t||e.type](e,l,a),this.mergeHandlerResult(n,o,u,i,r),u&&u.needsRenderFrame&&this._triggerRenderFrame()),(u||c.isActive())&&(s[i]=c);}const c={};for(const e in this._previousActiveHandlers)s[e]||(c[e]=r);this._previousActiveHandlers=s,(Object.keys(c).length||jS(n))&&(this._changes.push([n,o,c]),this._triggerRenderFrame()),(Object.keys(s).length||jS(n))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:h}=n;h&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],h(this._map));}mergeHandlerResult(e,t,i,r,n){if(!i)return;k(e,i);const o={handlerName:r,originalEvent:i.originalEvent||n};void 0!==i.zoomDelta&&(t.zoom=o),void 0!==i.panDelta&&(t.drag=o),void 0!==i.pitchDelta&&(t.pitch=o),void 0!==i.bearingDelta&&(t.rotate=o);}_applyChanges(){const e={},t={},i={};for(const[r,n,o]of this._changes)r.panDelta&&(e.panDelta=(e.panDelta||new y(0,0))._add(r.panDelta)),r.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+r.zoomDelta),r.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+r.bearingDelta),r.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+r.pitchDelta),void 0!==r.around&&(e.around=r.around),void 0!==r.aroundCoord&&(e.aroundCoord=r.aroundCoord),void 0!==r.pinchAround&&(e.pinchAround=r.pinchAround),r.noInertia&&(e.noInertia=r.noInertia),k(t,n),k(i,o);this._updateMapTransform(e,t,i),this._changes=[];}_updateMapTransform(e,t,i){const r=this._map,n=r.transform,o=e=>[e.x,e.y,e.z];if((e=>{const t=this._eventsInProgress.drag;return t&&!this._handlersById[t.handlerName].isActive()})()&&!jS(e)){const e=n.zoom;n.cameraElevationReference="sea",null!=this._originalZoom&&n._orthographicProjectionAtLowPitch&&"globe"!==n.projection.name&&0===n.pitch?(n.cameraElevationReference="ground",n.zoom=this._originalZoom):(n.recenterOnTerrain(),n.cameraElevationReference="ground"),e!==n.zoom&&this._map._update(!0);}if(n._isCameraConstrained&&r._stop(!0),!jS(e))return void this._fireEvents(t,i,!0);let{panDelta:s,zoomDelta:a,bearingDelta:l,pitchDelta:c,around:h,aroundCoord:u,pinchAround:d}=e;n._isCameraConstrained&&(a>0&&(a=0),n._isCameraConstrained=!1),void 0!==d&&(h=d),(a||(e=>t[e]&&!this._eventsInProgress[e])("drag"))&&h&&(this._dragOrigin=o(n.pointCoordinate3D(h)),this._originalZoom=n.zoom,this._trackingEllipsoid.setup(n._camera.position,this._dragOrigin)),n.cameraElevationReference="sea",r._stop(!0),h=h||r.transform.centerPoint,l&&(n.bearing+=l),c&&(n.pitch+=c),n._updateCameraState();const p=[0,0,0];if(s)if("mercator"===n.projection.name){const e=this._trackingEllipsoid.projectRay(n.screenPointToMercatorRay(h).dir),t=this._trackingEllipsoid.projectRay(n.screenPointToMercatorRay(h.sub(s)).dir);p[0]=t[0]-e[0],p[1]=t[1]-e[1];}else {const e=n.pointCoordinate(h);if("globe"===n.projection.name){s=s.rotate(-n.angle);const t=n._pixelsPerMercatorPixel/n.worldSize;p[0]=-s.x*Jd(Hd(e.y))*t,p[1]=-s.y*Jd(n.center.lat)*t;}else {const t=n.pointCoordinate(h.sub(s));e&&t&&(p[0]=t.x-e.x,p[1]=t.y-e.y);}}const f=n.zoom,m=[0,0,0];if(a){const e=o(u||n.pointCoordinate3D(h)),t={dir:Mu.normalize([],Mu.sub([],e,n._camera.position))};if(t.dir[2]<0){const i=n.zoomDeltaToMovement(e,a);Mu.scale(m,t.dir,i);}}const _=Mu.add(p,p,m);n._translateCameraConstrained(_),a&&Math.abs(n.zoom-f)>1e-4&&n.recenterOnTerrain(),n.cameraElevationReference="ground",this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(t,i,!0);}_fireEvents(e,t,i){const r=NS(this._eventsInProgress),n=NS(e),o={};for(const t in e){const{originalEvent:i}=e[t];this._eventsInProgress[t]||(o[`${t}start`]=i),this._eventsInProgress[t]=e[t];}!r&&n&&this._fireEvent("movestart",n.originalEvent);for(const e in o)this._fireEvent(e,o[e]);n&&this._fireEvent("move",n.originalEvent);for(const t in e){const{originalEvent:i}=e[t];this._fireEvent(t,i);}const s={};let a;for(const e in this._eventsInProgress){const{handlerName:i,originalEvent:r}=this._eventsInProgress[e];this._handlersById[i].isActive()||(delete this._eventsInProgress[e],a=t[i]||r,s[`${e}end`]=a);}for(const e in s)this._fireEvent(e,s[e]);const l=NS(this._eventsInProgress);if(i&&(r||n)&&!l){this._updatingCamera=!0;const e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),t=e=>0!==e&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new US("renderFrame",{timeStamp:e})),this._applyChanges();}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame());}}const qS="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class ZS extends It{constructor(e,t){super(),this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=t.bearingSnap,this._respectPrefersReducedMotion=!1!==t.respectPrefersReducedMotion,j(["_renderFrameCallback"],this);}getCenter(){return new Nd(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}panBy(e,t,i){return e=y.convert(e).mult(-1),this.panTo(this.transform.center,k({offset:e},t),i)}panTo(e,t,i){return this.easeTo(k({center:e},t),i)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(e,t,i){return this.easeTo(k({zoom:e},t),i)}zoomIn(e,t){return this.zoomTo(this.getZoom()+1,e,t),this}zoomOut(e,t){return this.zoomTo(this.getZoom()-1,e,t),this}getBearing(){return this.transform.bearing}setBearing(e,t){return this.jumpTo({bearing:e},t),this}getPadding(){return this.transform.padding}setPadding(e,t){return this.jumpTo({padding:e},t),this}rotateTo(e,t,i){return this.easeTo(k({bearing:e},t),i)}resetNorth(e,t){return this.rotateTo(0,k({duration:1e3},e),t),this}resetNorthPitch(e,t){return this.easeTo(k({bearing:0,pitch:0,duration:1e3},e),t),this}snapToNorth(e,t){return Math.abs(this.getBearing())e.aspect?i/(2*Math.tan(.5*e.fovX)*e.aspect):r/(2*Math.tan(.5*e.fovY)*e.aspect)}_cameraForBoundsOnGlobe(e,t,i,r,n,o){const s=e.clone(),a=this._extendCameraOptions(o);s.bearing=r,s.pitch=n;const l=Nd.convert(t),c=Nd.convert(i),h=.5*(l.lat+c.lat),u=.5*(l.lng+c.lng),d=md(h,u),p=Mu.normalize([],d),f=Mu.normalize([],Mu.cross([],p,[0,1,0])),m=Mu.cross([],f,p),_=[f[0],f[1],f[2],0,m[0],m[1],m[2],0,p[0],p[1],p[2],0,0,0,0,1],g=[d,md(l.lat,l.lng),md(c.lat,l.lng),md(c.lat,c.lng),md(l.lat,c.lng),md(h,l.lng),md(h,c.lng),md(l.lat,u),md(c.lat,u)];let y=Hu.fromPoints(g.map((e=>[Mu.dot(f,e),Mu.dot(m,e),Mu.dot(p,e)])));const x=Mu.transformMat4([],y.center,_);0===Mu.squaredLength(x)&&Mu.set(x,0,0,1),Mu.normalize(x,x),Mu.scale(x,x,Yu),s.center=function([e,t,i]){const r=Math.hypot(e,t,i),n=Math.atan2(e,i),o=.5*Math.PI-Math.acos(-t/r);return new Nd(T(n),T(o))}(x);const v=s.getWorldToCameraMatrix(),b=xu.invert(new Float64Array(16),v);y=Hu.applyTransform(y,xu.multiply([],v,_)),Mu.transformMat4(x,x,v);const w=.5*(y.max[2]-y.min[2]),E=this._minimumAABBFrustumDistance(s,y),M=Mu.scale([],[0,0,1],w),A=Mu.add(M,x,M),S=E+(0===s.pitch?0:Mu.distance(x,A)),I=s.globeCenterInViewSpace,C=Mu.sub([],x,[I[0],I[1],I[2]]);Mu.normalize(C,C),Mu.scale(C,C,S);const z=Mu.add([],x,C);Mu.transformMat4(z,z,b);const D=Od/Yu,P=Mu.length(z),R=Zd(Math.max(P*D-Od,Number.EPSILON),0),L=Math.min(s.zoomFromMercatorZAdjusted(R),a.maxZoom);return L>.5*(Wu+Xu)?(s.setProjection({name:"mercator"}),s.zoom=L,this._cameraForBounds(s,t,i,r,n,o)):{center:s.center,zoom:L,bearing:r,pitch:n}}queryTerrainElevation(e,t){const i=this.transform.elevation;return i?(t=k({},{exaggerated:!0},t),i.getAtPoint(ep.fromLngLat(e),null,t.exaggerated)):null}_cameraForBounds(e,t,i,r,n,o){if("globe"===e.projection.name)return this._cameraForBoundsOnGlobe(e,t,i,r,n,o);const s=e.clone(),a=this._extendCameraOptions(o),l=s.padding;s.bearing=r,s.pitch=n;const c=Nd.convert(t),h=Nd.convert(i),u=new Nd(c.lng,h.lat),d=new Nd(h.lng,c.lat),p=s.project(c),f=s.project(h),m=this.queryTerrainElevation(c),_=this.queryTerrainElevation(h),g=this.queryTerrainElevation(u),x=this.queryTerrainElevation(d),v=[[p.x,p.y,Math.min(m||0,_||0,g||0,x||0)],[f.x,f.y,Math.max(m||0,_||0,g||0,x||0)]];let b=Hu.fromPoints(v);const T=s.getWorldToCameraMatrix(),E=xu.invert(new Float64Array(16),T);b=Hu.applyTransform(b,T);const M=Mu.sub([],b.max,b.min),A=l.left||0,S=l.right||0,I=l.bottom||0,C=l.top||0,{left:z,right:D,top:P,bottom:R}=a.padding,L=.5*(A+S),k=.5*(C+I),O=Math.min(s.scaleZoom(s.scale*Math.min((s.width-(A+S+z+D))/M[0],(s.height-(I+C+R+P))/M[1])),a.maxZoom),B=s.scale/s.zoomScale(O);b=new Hu([b.min[0]-(z+L)*B,b.min[1]-(R+k)*B,b.min[2]],[b.max[0]+(D+L)*B,b.max[1]+(P+k)*B,b.max[2]]);const F=.5*M[2],N=this._minimumAABBFrustumDistance(s,b),U=[0,0,1,0];uu.transformMat4(U,U,T),uu.normalize(U,U);const V=Mu.scale([],U,N+F),j=Mu.add([],b.center,V),G=("number"==typeof a.offset.x&&"number"==typeof a.offset.y?new y(a.offset.x,a.offset.y):y.convert(a.offset)).rotate(-w(r));b.center[0]-=G.x*B,b.center[1]+=G.y*B,Mu.transformMat4(b.center,b.center,E),Mu.transformMat4(j,j,E);const q=[b.center[0],b.center[1],j[2]*s.pixelsPerMeter];Mu.scale(q,q,1/s.worldSize);const Z=$d(q[0]),$=Hd(q[1]),H=Math.min(s._zoomFromMercatorZ(q[2]),a.maxZoom),W=new Nd(Z,$);return s.mercatorFromTransition&&H<.5*(Wu+Xu)?(s.setProjection({name:"globe"}),s.zoom=H,this._cameraForBounds(s,t,i,r,n,o)):{center:W,zoom:H,bearing:r,pitch:n}}fitBounds(e,t,i){const r=this.cameraForBounds(e,t);return this._fitInternal(r,t,i)}fitScreenCoordinates(e,t,i,r,n){const o=y.convert(e),s=y.convert(t),a=new y(Math.min(o.x,s.x),Math.min(o.y,s.y)),l=new y(Math.max(o.x,s.x),Math.max(o.y,s.y));if("mercator"===this.transform.projection.name&&this.transform.anyCornerOffEdge(o,s))return this;const c=this.transform.pointLocation3D(a),h=this.transform.pointLocation3D(l),u=this.transform.pointLocation3D(new y(a.x,l.y)),d=this.transform.pointLocation3D(new y(l.x,a.y)),p=[Math.min(c.lng,h.lng,u.lng,d.lng),Math.min(c.lat,h.lat,u.lat,d.lat)],f=[Math.max(c.lng,h.lng,u.lng,d.lng),Math.max(c.lat,h.lat,u.lat,d.lat)],m=r&&r.pitch?r.pitch:this.getPitch(),_=this._cameraForBounds(this.transform,p,f,i,m,r);return this._fitInternal(_,r,n)}_fitInternal(e,t,i){return e?(delete(t=k(e,t)).padding,t.linear?this.easeTo(t,i):this.flyTo(t,i)):this}jumpTo(e,t){this.stop();const i=e.preloadOnly?this.transform.clone():this.transform;let r=!1,n=!1,o=!1;return "zoom"in e&&i.zoom!==+e.zoom&&(r=!0,i.zoom=+e.zoom),void 0!==e.center&&(i.center=Nd.convert(e.center)),"bearing"in e&&i.bearing!==+e.bearing&&(n=!0,i.bearing=+e.bearing),"pitch"in e&&i.pitch!==+e.pitch&&(o=!0,i.pitch=+e.pitch),null==e.padding||i.isPaddingEqual(e.padding)||(i.padding=e.padding),e.preloadOnly?(this._preloadTiles(i),this):(this.fire(new At("movestart",t)).fire(new At("move",t)),r&&this.fire(new At("zoomstart",t)).fire(new At("zoom",t)).fire(new At("zoomend",t)),n&&this.fire(new At("rotatestart",t)).fire(new At("rotate",t)).fire(new At("rotateend",t)),o&&this.fire(new At("pitchstart",t)).fire(new At("pitch",t)).fire(new At("pitchend",t)),this.fire(new At("moveend",t)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||W(qS),this.transform.getFreeCameraOptions()}setFreeCameraOptions(e,t){const i=this.transform;if(!i.projection.supportsFreeCamera)return W(qS),this;this.stop();const r=i.zoom,n=i.pitch,o=i.bearing;i.setFreeCameraOptions(e);const s=r!==i.zoom,a=n!==i.pitch,l=o!==i.bearing;return this.fire(new At("movestart",t)).fire(new At("move",t)),s&&this.fire(new At("zoomstart",t)).fire(new At("zoom",t)).fire(new At("zoomend",t)),l&&this.fire(new At("rotatestart",t)).fire(new At("rotate",t)).fire(new At("rotateend",t)),a&&this.fire(new At("pitchstart",t)).fire(new At("pitch",t)).fire(new At("pitchend",t)),this.fire(new At("moveend",t)),this}easeTo(e,t){this._stop(!1,e.easeId),(!1===(e=k({offset:[0,0],duration:500,easing:C},e)).animate||this._prefersReducedMotion(e))&&(e.duration=0);const i=this.transform,r=this.getZoom(),n=this.getBearing(),o=this.getPitch(),s=this.getPadding(),a="zoom"in e?+e.zoom:r,l="bearing"in e?this._normalizeBearing(e.bearing,n):n,c="pitch"in e?+e.pitch:o,h="padding"in e?e.padding:i.padding,u=y.convert(e.offset);let d,p,f;if("globe"===i.projection.name){const t=ep.fromLngLat(i.center),r=u.rotate(-i.angle);t.x+=r.x/i.worldSize,t.y+=r.y/i.worldSize;const n=t.toLngLat(),o=Nd.convert(e.center||n);this._normalizeCenter(o),d=i.centerPoint.add(r),p=new y(t.x,t.y).mult(i.worldSize),f=new y(Gd(o.lng),qd(o.lat)).mult(i.worldSize).sub(p);}else {d=i.centerPoint.add(u);const t=i.pointLocation(d),r=Nd.convert(e.center||t);this._normalizeCenter(r),p=i.project(t),f=i.project(r).sub(p);}const m=i.zoomScale(a-r);let _,g;e.around&&(_=Nd.convert(e.around),g=i.locationPoint(_));const x=this._zooming||a!==r,v=this._rotating||n!==l,b=this._pitching||c!==o,w=!i.isPaddingEqual(h),T=i=>y=>{if(x&&(i.zoom=Wr(r,a,y)),v&&(i.bearing=Wr(n,l,y)),b&&(i.pitch=Wr(o,c,y)),w&&(i.interpolatePadding(s,h,y),d=i.centerPoint.add(u)),_)i.setLocationAtPoint(_,g);else {const e=i.zoomScale(i.zoom-r),t=a>r?Math.min(2,m):Math.max(.5,m),n=Math.pow(t,1-y),o=i.unproject(p.add(f.mult(y*n)).mult(e));i.setLocationAtPoint(i.renderWorldCopies?o.wrap():o,d);}return e.preloadOnly||this._fireMoveEvents(t),i};if(e.preloadOnly){const t=this._emulate(T,e.duration,i);return this._preloadTiles(t),this}const E={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=x,this._rotating=v,this._pitching=b,this._padding=w,this._easeId=e.easeId,this._prepareEase(t,e.noMoveStart,E),this._ease(T(i),(e=>{"sea"===i.cameraElevationReference&&i.recenterOnTerrain(),this._afterEase(t,e);}),e),this}_prepareEase(e,t,i={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&0===this.transform.pitch&&"globe"!==this.transform.projection.name&&(this.transform.cameraElevationReference="ground"),t||i.moving||this.fire(new At("movestart",e)),this._zooming&&!i.zooming&&this.fire(new At("zoomstart",e)),this._rotating&&!i.rotating&&this.fire(new At("rotatestart",e)),this._pitching&&!i.pitching&&this.fire(new At("pitchstart",e));}_fireMoveEvents(e){this.fire(new At("move",e)),this._zooming&&this.fire(new At("zoom",e)),this._rotating&&this.fire(new At("rotate",e)),this._pitching&&this.fire(new At("pitch",e));}_afterEase(e,t){if(this._easeId&&t&&this._easeId===t)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const i=this._zooming,r=this._rotating,n=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,i&&this.fire(new At("zoomend",e)),r&&this.fire(new At("rotateend",e)),n&&this.fire(new At("pitchend",e)),this.fire(new At("moveend",e));}flyTo(e,t){if(this._prefersReducedMotion(e)){const i=O(e,["center","zoom","bearing","pitch","around"]);return this.jumpTo(i,t)}this.stop(),e=k({offset:[0,0],speed:1.2,curve:1.42,easing:C},e);const i=this.transform,r=this.getZoom(),n=this.getBearing(),o=this.getPitch(),s=this.getPadding(),a="zoom"in e?z(+e.zoom,i.minZoom,i.maxZoom):r,l="bearing"in e?this._normalizeBearing(e.bearing,n):n,c="pitch"in e?+e.pitch:o,h="padding"in e?e.padding:i.padding,u=i.zoomScale(a-r),d=y.convert(e.offset);let p=i.centerPoint.add(d);const f=i.pointLocation(p),m=Nd.convert(e.center||f);this._normalizeCenter(m);const _=i.project(f),g=i.project(m).sub(_);let x=e.curve;const v=Math.max(i.width,i.height),b=v/u,w=g.mag();if("minZoom"in e){const t=z(Math.min(e.minZoom,r,a),i.minZoom,i.maxZoom),n=v/i.zoomScale(t-r);x=Math.sqrt(n/w*2);}const T=x*x;function E(e){const t=(b*b-v*v+(e?-1:1)*T*T*w*w)/(2*(e?b:v)*T*w);return Math.log(Math.sqrt(t*t+1)-t)}function M(e){return (Math.exp(e)-Math.exp(-e))/2}function A(e){return (Math.exp(e)+Math.exp(-e))/2}const S=E(0);let I=function(e){return A(S)/A(S+x*e)},D=function(e){return v*((A(S)*(M(t=S+x*e)/A(t))-M(S))/T)/w;var t;},P=(E(1)-S)/x;if(Math.abs(w)<1e-6||!isFinite(P)){if(Math.abs(v-b)<1e-6)return this.easeTo(e,t);const i=be.maxDuration&&(e.duration=0);const R=n!==l,L=c!==o,B=!i.isPaddingEqual(h),F=i=>u=>{const f=u*P,y=1/I(f);i.zoom=1===u?a:r+i.scaleZoom(y),R&&(i.bearing=Wr(n,l,u)),L&&(i.pitch=Wr(o,c,u)),B&&(i.interpolatePadding(s,h,u),p=i.centerPoint.add(d));const x=1===u?m:i.unproject(_.add(g.mult(D(f))).mult(y));return i.setLocationAtPoint(i.renderWorldCopies?x.wrap():x,p),i._updateCameraOnTerrain(),e.preloadOnly||this._fireMoveEvents(t),i};if(e.preloadOnly){const t=this._emulate(F,e.duration,i);return this._preloadTiles(t),this}return this._zooming=!0,this._rotating=R,this._pitching=L,this._padding=B,this._prepareEase(t,!1),this._ease(F(i),(()=>this._afterEase(t)),e),this}isEasing(){return !!this._easeFrameId}stop(){return this._stop()}_stop(e,t){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const e=this._onEaseEnd;this._onEaseEnd=void 0,e.call(this,t);}if(!e){const e=this.handlers;e&&e.stop(!1);}return this}_ease(e,t,i){!1===i.animate||0===i.duration?(e(1),t()):(this._easeStart=ht.now(),this._easeOptions=i,this._onEaseFrame=e,this._onEaseEnd=t,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback));}_renderFrameCallback(){const e=Math.min((ht.now()-this._easeStart)/this._easeOptions.duration,1),t=this._onEaseFrame;t&&t(this._easeOptions.easing(e)),e<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop();}_normalizeBearing(e,t){e=P(e,-180,180);const i=Math.abs(e-t);return Math.abs(e-360-t)180?-360:i<-180?360:0;}_prefersReducedMotion(e){return this._respectPrefersReducedMotion&&ht.prefersReducedMotion&&!(e&&e.essential)}_emulate(e,t,i){const r=Math.ceil(15*t/1e3),n=[],o=e(i.clone());for(let e=0;e<=r;e++){const t=o(e/r);n.push(t.clone());}return n}}class $S{constructor(e={}){this.options=e,j(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this);}getDefaultPosition(){return "bottom-right"}onAdd(e){const t=this.options&&this.options.compact;return this._map=e,this._container=ut("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=ut("button","mapboxgl-ctrl-attrib-button",this._container),ut("span","mapboxgl-ctrl-icon",this._compactButton).setAttribute("aria-hidden","true"),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=ut("div","mapboxgl-ctrl-attrib-inner",this._container),t&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),void 0===t&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0,this._attribHTML=void 0;}_setElementTitle(e,t){const i=this._map._getUIString(`AttributionControl.${t}`);e.setAttribute("aria-label",i),e.removeAttribute("title"),e.firstElementChild&&e.firstElementChild.setAttribute("title",i);}_toggleAttribution(){this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","false")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"));}_updateEditLink(){let e=this._editLink;e||(e=this._editLink=this._container.querySelector(".mapbox-improve-map"));const t=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||n.ACCESS_TOKEN}];if(e){const i=t.reduce(((e,i,r)=>(i.value&&(e+=`${i.key}=${i.value}${re.length-t.length)),e=e.filter(((t,i)=>{for(let r=i+1;r=0)return !1;return !0})),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=[...this.options.customAttribution,...e]:e.unshift(this.options.customAttribution));const i=e.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,e.length?(this._innerContainer.innerHTML=i,this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null);}_updateCompact(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact","mapboxgl-compact-show");}}class HS{constructor(){j(["_updateLogo","_updateCompact"],this);}onAdd(e){this._map=e,this._container=ut("div","mapboxgl-ctrl");const t=ut("a","mapboxgl-ctrl-logo");return t.target="_blank",t.rel="noopener nofollow",t.href="https://www.mapbox.com/",t.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),t.setAttribute("rel","noopener nofollow"),this._container.appendChild(t),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact);}getDefaultPosition(){return "bottom-left"}_updateLogo(e){e&&"metadata"!==e.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none");}_logoRequired(){if(!this._map.style)return !0;const e=this._map.style._sourceCaches;if(0===Object.entries(e).length)return !0;for(const t in e){const i=e[t].getSource();if(i.hasOwnProperty("mapbox_logo")&&!i.mapbox_logo)return !1}return !0}_updateCompact(){const e=this._container.children;if(e.length){const t=e[0];this._map.getCanvasContainer().offsetWidth<250?t.classList.add("mapboxgl-compact"):t.classList.remove("mapboxgl-compact");}}}class WS{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1;}add(e){const t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){const t=this._currentlyRunning,i=t?this._queue.concat(t):this._queue;for(const t of i)if(t.id===e)return void(t.cancelled=!0)}run(e=0){const t=this._currentlyRunning=this._queue;this._queue=[];for(const i of t)if(!i.cancelled&&(i.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1;}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[];}}function XS(e,t,i){if(e=new Nd(e.lng,e.lat),t){const r=new Nd(e.lng-360,e.lat),n=new Nd(e.lng+360,e.lat),o=360*Math.ceil(Math.abs(e.lng-i.center.lng)/360),s=i.locationPoint(e).distSqr(t),a=t.x<0||t.y<0||t.x>i.width||t.y>i.height;i.locationPoint(r).distSqr(t)180;){const t=i.locationPoint(e);if(t.x>=0&&t.y>=0&&t.x<=i.width&&t.y<=i.height)break;e.lng>i.center.lng?e.lng-=360:e.lng+=360;}return e}const YS={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%)"};class KS extends It{constructor(e,i){if(super(),(e instanceof t.HTMLElement||i)&&(e=k({element:e},i)),j(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this),this._anchor=e&&e.anchor||"center",this._color=e&&e.color||"#3FB1CE",this._scale=e&&e.scale||1,this._draggable=e&&e.draggable||!1,this._clickTolerance=e&&e.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=e&&e.rotation||0,this._rotationAlignment=e&&e.rotationAlignment||"auto",this._pitchAlignment=e&&e.pitchAlignment&&e.pitchAlignment||"auto",this._updateMoving=()=>this._update(!0),this._occludedOpacity=e&&e.occludedOpacity||.2,e&&e.element)this._element=e.element,this._offset=y.convert(e&&e.offset||[0,0]);else {this._defaultMarker=!0,this._element=ut("div");const t=41,i=27,r=dt("svg",{display:"block",height:t*this._scale+"px",width:i*this._scale+"px",viewBox:`0 0 ${i} ${t}`},this._element),n=dt("radialGradient",{id:"shadowGradient"},dt("defs",{},r));dt("stop",{offset:"10%","stop-opacity":.4},n),dt("stop",{offset:"100%","stop-opacity":.05},n),dt("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},r),dt("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},r),dt("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},r),dt("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},r),this._offset=y.convert(e&&e.offset||[0,-14]);}this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.hasAttribute("role")||this._element.setAttribute("role","img"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",(e=>{e.preventDefault();})),this._element.addEventListener("mousedown",(e=>{e.preventDefault();}));const r=this._element.classList;for(const e in YS)r.remove(`mapboxgl-marker-anchor-${e}`);r.add(`mapboxgl-marker-anchor-${this._anchor}`);const n=e&&e.className?e.className.trim().split(/\s+/):[];r.add(...n),this._popup=null;}addTo(e){return e===this._map||(this.remove(),this._map=e,e.getCanvasContainer().appendChild(this._element),e.on("move",this._updateMoving),e.on("moveend",this._update),e.on("remove",this._clearFadeTimer),e._addMarker(this),this.setDraggable(this._draggable),this._update(),e.on("click",this._onMapClick)),this}remove(){const e=this._map;return e&&(e.off("click",this._onMapClick),e.off("move",this._updateMoving),e.off("moveend",this._update),e.off("mousedown",this._addDragHandler),e.off("touchstart",this._addDragHandler),e.off("mouseup",this._onUp),e.off("touchend",this._onUp),e.off("mousemove",this._onMove),e.off("touchmove",this._onMove),e.off("remove",this._clearFadeTimer),e._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=Nd.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeAttribute("role"),this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),e){if(!("offset"in e.options)){const t=38.1,i=13.5,r=Math.sqrt(Math.pow(i,2)/2);e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-t],"bottom-left":[r,-1*(t-i+r)],"bottom-right":[-r,-1*(t-i+r)],left:[i,-1*(t-i)],right:[-i,-1*(t-i)]}:this._offset;}this._popup=e,e._marker=this,this._lngLat&&this._popup.setLngLat(this._lngLat),this._element.setAttribute("role","button"),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress),this._element.setAttribute("aria-expanded","false");}return this}_onKeyPress(e){const t=e.code,i=e.charCode||e.keyCode;"Space"!==t&&"Enter"!==t&&32!==i&&13!==i||this.togglePopup();}_onMapClick(e){const t=e.originalEvent.target,i=this._element;this._popup&&(t===i||i.contains(t))&&this.togglePopup();}getPopup(){return this._popup}togglePopup(){const e=this._popup;return e?(e.isOpen()?(e.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(e.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const e=this._map,t=this._pos;if(!e||!t)return !1;const i=e.unproject(t),r=e.getFreeCameraOptions();if(!r.position)return !1;const n=r.position.toLngLat();return n.distanceTo(i)<.9*n.distanceTo(this._lngLat)}_evaluateOpacity(){const e=this._map;if(!e)return;const t=this._pos;if(!t||t.x<0||t.x>e.transform.width||t.y<0||t.y>e.transform.height)return void this._clearFadeTimer();const i=e.unproject(t);let r;e._showingGlobe()&&Dd(e.transform,this._lngLat)?r=0:(r=1-e._queryFogOpacity(i),e.transform._terrainEnabled()&&e.getTerrain()&&this._behindTerrain()&&(r*=this._occludedOpacity)),this._element.style.opacity=`${r}`,this._element.style.pointerEvents=r>0?"auto":"none",this._popup&&this._popup._setOpacity(r),this._fadeTimer=null;}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null);}_updateDOM(){const e=this._pos;if(!e||!this._map)return;const t=this._offset.mult(this._scale);this._element.style.transform=`\n translate(${e.x}px,${e.y}px)\n ${YS[this._anchor]}\n ${this._calculateXYTransform()} ${this._calculateZTransform()}\n translate(${t.x}px,${t.y}px)\n `;}_calculateXYTransform(){const e=this._pos,t=this._map,i=this.getPitchAlignment();if(!t||!e||"map"!==i)return "";if(!t._showingGlobe()){const e=t.getPitch();return e?`rotateX(${e}deg)`:""}const r=T(zd(t.transform,this._lngLat)),n=e.sub(Cd(t.transform)),o=Math.abs(n.x)+Math.abs(n.y);if(0===o)return "";const s=r/o;return `rotateX(${-n.y*s}deg) rotateY(${n.x*s}deg)`}_calculateZTransform(){const e=this._pos,t=this._map;if(!t||!e)return "";let i=0;const r=this.getRotationAlignment();if("map"===r)if(t._showingGlobe()){const e=t.project(new Nd(this._lngLat.lng,this._lngLat.lat+.001)),r=t.project(new Nd(this._lngLat.lng,this._lngLat.lat-.001)).sub(e);i=T(Math.atan2(r.y,r.x))-90;}else i=-t.getBearing();else if("horizon"===r){const r=D(4,6,t.getZoom()),n=Cd(t.transform);n.y+=r*t.transform.height;const o=e.sub(n),s=T(Math.atan2(o.y,o.x));i=(s>90?s-270:s+90)*(1-r);}return i+=this._rotation,i?`rotateZ(${i}deg)`:""}_update(e){t.cancelAnimationFrame(this._updateFrameId);const i=this._map;i&&(i.transform.renderWorldCopies&&(this._lngLat=XS(this._lngLat,this._pos,i.transform)),this._pos=i.project(this._lngLat),!0===e?this._updateFrameId=t.requestAnimationFrame((()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM());})):this._pos=this._pos.round(),i._requestDomTask((()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(i._showingGlobe()||i.getTerrain()||i.getFog())&&!this._fadeTimer&&(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)));})));}getOffset(){return this._offset}setOffset(e){return this._offset=y.convert(e),this._update(),this}addClassName(e){return this._element.classList.add(e),this}removeClassName(e){return this._element.classList.remove(e),this}toggleClassName(e){return this._element.classList.toggle(e)}_onMove(e){const t=this._map;if(!t)return;const i=this._pointerdownPos,r=this._positionDelta;if(i&&r){if(!this._isDragging){const r=this._clickTolerance||t._clickTolerance;if(e.point.dist(i)=this._endTime)return this._end;const t=M((e-this._startTime)/(this._endTime-this._startTime));return this._start*(1-t)+this._end*t}isEasing(e){return e>=this._startTime&&e<=this._endTime}jumpTo(e){this._startTime=-1/0,this._endTime=-1/0,this._start=e,this._end=e;}easeTo(e,t,i){this._start=this.getValue(t),this._end=e,this._startTime=t,this._endTime=t+i;}}const iI={"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":"Mapbox logo","Map.Title":"Map","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use ⌘ + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"},rI={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:85,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,performanceMetricsCollection:!0,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,antialias:!1,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,minTileCacheSize:null,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,transformRequest:null,accessToken:null,fadeDuration:300,respectPrefersReducedMotion:!0,crossSourceCollisions:!0,collectResourceTiming:!1,testMode:!1},nI={showCompass:!0,showZoom:!0,visualizePitch:!1};class oI{constructor(e,t,i=!1){this._clickTolerance=10,this.element=t,this.mouseRotate=new gS({clickTolerance:e.dragRotate._mouseRotate._clickTolerance}),this.map=e,i&&(this.mousePitch=new yS({clickTolerance:e.dragRotate._mousePitch._clickTolerance})),j(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),t.addEventListener("mousedown",this.mousedown),t.addEventListener("touchstart",this.touchstart,{passive:!1}),t.addEventListener("touchmove",this.touchmove),t.addEventListener("touchend",this.touchend),t.addEventListener("touchcancel",this.reset);}down(e,t){this.mouseRotate.mousedown(e,t),this.mousePitch&&this.mousePitch.mousedown(e,t),_t();}move(e,t){const i=this.map,r=this.mouseRotate.mousemoveWindow(e,t),n=r&&r.bearingDelta;if(n&&i.setBearing(i.getBearing()+n),this.mousePitch){const r=this.mousePitch.mousemoveWindow(e,t),n=r&&r.pitchDelta;n&&i.setPitch(i.getPitch()+n);}}off(){const e=this.element;e.removeEventListener("mousedown",this.mousedown),e.removeEventListener("touchstart",this.touchstart,{passive:!1}),e.removeEventListener("touchmove",this.touchmove),e.removeEventListener("touchend",this.touchend),e.removeEventListener("touchcancel",this.reset),this.offTemp();}offTemp(){gt(),t.removeEventListener("mousemove",this.mousemove),t.removeEventListener("mouseup",this.mouseup);}mousedown(e){this.down(k({},e,{ctrlKey:!0,preventDefault:()=>e.preventDefault()}),vt(this.element,e)),t.addEventListener("mousemove",this.mousemove),t.addEventListener("mouseup",this.mouseup);}mousemove(e){this.move(e,vt(this.element,e));}mouseup(e){this.mouseRotate.mouseupWindow(e),this.mousePitch&&this.mousePitch.mouseupWindow(e),this.offTemp();}touchstart(e){1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=bt(this.element,e.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>e.preventDefault()},this._startPos));}touchmove(e){1!==e.targetTouches.length?this.reset():(this._lastPos=bt(this.element,e.targetTouches)[0],this.move({preventDefault:()=>e.preventDefault()},this._lastPos));}touchend(e){0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)e.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=e.minPitch&&null!=e.maxPitch&&e.minPitch>e.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=e.minPitch&&e.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=e.maxPitch&&e.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(e.antialias&&function(e){const t=e.navigator?e.navigator.userAgent:null;return !!function(e){if(null==te){const t=e.navigator?e.navigator.userAgent:null;te=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")));}return te}(e)&&t&&(t.match("Version/15.4")||t.match("Version/15.5")||t.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))}(t)&&(e.antialias=!1,W("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new mv(e.minZoom,e.maxZoom,e.minPitch,e.maxPitch,e.renderWorldCopies),e),this._interactive=e.interactive,this._minTileCacheSize=e.minTileCacheSize,this._maxTileCacheSize=e.maxTileCacheSize,this._failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=e.preserveDrawingBuffer,this._antialias=e.antialias,this._trackResize=e.trackResize,this._bearingSnap=e.bearingSnap,this._refreshExpiredTiles=e.refreshExpiredTiles,this._fadeDuration=e.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=e.crossSourceCollisions,this._collectResourceTiming=e.collectResourceTiming,this._language=this._parseLanguage(e.language),this._worldview=e.worldview,this._renderTaskQueue=new WS,this._domRenderTaskQueue=new WS,this._controls=[],this._markers=[],this._popups=[],this._mapId=F(),this._locale=k({},iI,e.locale),this._clickTolerance=e.clickTolerance,this._cooperativeGestures=e.cooperativeGestures,this._performanceMetricsCollection=e.performanceMetricsCollection,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new tI(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._requestManager=new ze(e.transformRequest,e.accessToken,e.testMode),this._silenceAuthErrors=!!e.testMode,"string"==typeof e.container){if(this._container=t.document.getElementById(e.container),!this._container)throw new Error(`Container '${e.container.toString()}' not found.`)}else {if(!(e.container instanceof t.HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=e.container;}if(this._container.childNodes.length>0&&W("The map container element should be empty, otherwise the map's interactivity will be negatively impacted. If you want to display a message when WebGL is not supported, use the Mapbox GL Supported plugin instead."),e.maxBounds&&this.setMaxBounds(e.maxBounds),j(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),void 0===this.painter)throw new Error("Failed to initialize WebGL.");if(this.on("move",(()=>this._update(!1))),this.on("moveend",(()=>this._update(!1))),this.on("zoom",(()=>this._update(!0))),void 0!==t&&(this._fullscreenchangeEvent="onfullscreenchange"in t.document?"fullscreenchange":"webkitfullscreenchange",t.addEventListener("online",this._onWindowOnline,!1),t.addEventListener("resize",this._onWindowResize,!1),t.addEventListener("orientationchange",this._onWindowResize,!1),t.addEventListener(this._fullscreenchangeEvent,this._onWindowResize,!1),t.addEventListener("visibilitychange",this._onVisibilityChange,!1)),this.handlers=new GS(this,e),this._localFontFamily=e.localFontFamily,this._localIdeographFontFamily=e.localIdeographFontFamily,(e.style||!e.testMode)&&this.setStyle(e.style||n.DEFAULT_STYLE,{localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),e.projection&&this.setProjection(e.projection),e.hash&&(this._hash=new WA("string"==typeof e.hash&&e.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){this.jumpTo({center:e.center,zoom:e.zoom,bearing:e.bearing,pitch:e.pitch});const t=e.bounds;t&&(this.resize(),this.fitBounds(t,k({},e.fitBoundsOptions,{duration:0})));}this.resize(),e.attributionControl&&this.addControl(new $S({customAttribution:e.customAttribution})),this._logoControl=new HS,this.addControl(this._logoControl,e.logoPosition),this.on("style.load",(()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet);})),this.on("data",(e=>{this._update("style"===e.dataType),this.fire(new At(`${e.dataType}data`,e));})),this.on("dataloading",(e=>{this.fire(new At(`${e.dataType}dataloading`,e));}));}_getMapId(){return this._mapId}addControl(e,t){if(void 0===t&&(t=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e||!e.onAdd)return this.fire(new St(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const i=e.onAdd(this);this._controls.push(e);const r=this._controlPositions[t];return -1!==t.indexOf("bottom")?r.insertBefore(i,r.firstChild):r.appendChild(i),this}removeControl(e){if(!e||!e.onRemove)return this.fire(new St(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const t=this._controls.indexOf(e);return t>-1&&this._controls.splice(t,1),e.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(e){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));const t=!this._moving;return t&&this.fire(new At("movestart",e)).fire(new At("move",e)),this.fire(new At("resize",e)),t&&this.fire(new At("moveend",e)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(e){return this.transform.setMaxBounds(Ql.convert(e)),this._update()}setMinZoom(e){if((e=null==e?-2:e)>=-2&&e<=this.transform.maxZoom)return this.transform.minZoom=e,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=e,this._update(),this.getZoom()>e?this.setZoom(e):this.fire(new At("zoomstart")).fire(new At("zoom")).fire(new At("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(e){if((e=null==e?0:e)<0)throw new Error("minPitch must be greater than or equal to 0");if(e>=0&&e<=this.transform.maxPitch)return this.transform.minPitch=e,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(e>=this.transform.minPitch)return this.transform.maxPitch=e,this._update(),this.getPitch()>e?this.setPitch(e):this.fire(new At("pitchstart")).fire(new At("pitch")).fire(new At("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.renderWorldCopies=e,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(e){return "auto"===e?t.navigator.language:Array.isArray(e)?0===e.length?void 0:e.map((e=>"auto"===e?t.navigator.language:e)):e}setLanguage(e){const t=this._parseLanguage(e);if(!this.style||t===this._language)return this;this._language=t,this.style.clearSources();for(const e of this._controls)e._setLanguage&&e._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(e){return this.style&&e!==this._worldview?(this._worldview=e,this.style.clearSources(),this):this}getProjection(){return this.transform.mercatorFromTransition?{name:"globe",center:[0,0]}:this.transform.getProjection()}_showingGlobe(){return "globe"===this.transform.projection.name}setProjection(e){return this._lazyInitEmptyStyle(),e?"string"==typeof e&&(e={name:e}):e=null,this._useExplicitProjection=!!e,this._prioritizeAndUpdateProjection(e,this.style.projection)}_updateProjectionTransition(){if("globe"!==this.getProjection().name)return;const e=this.transform,t=e.projection.name;let i;"globe"===t&&e.zoom>=Xu?(e.setMercatorFromTransition(),i=!0):"mercator"===t&&e.zoom=Xu?this.transform.setMercatorFromTransition():this.transform.setProjection(e),this.style.applyProjectionUpdate(),t&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(e){return this.transform.locationPoint3D(Nd.convert(e))}unproject(e){return this.transform.pointLocation3D(y.convert(e))}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}_isDragging(){return this.handlers&&this.handlers._isDragging()||!1}_createDelegatedListener(e,t,i){if("mouseenter"===e||"mouseover"===e){let r=!1;const n=n=>{const o=t.filter((e=>this.getLayer(e))),s=o.length?this.queryRenderedFeatures(n.point,{layers:o}):[];s.length?r||(r=!0,i.call(this,new nS(e,this,n.originalEvent,{features:s}))):r=!1;},o=()=>{r=!1;};return {layers:new Set(t),listener:i,delegates:{mousemove:n,mouseout:o}}}if("mouseleave"===e||"mouseout"===e){let r=!1;const n=n=>{const o=t.filter((e=>this.getLayer(e)));(o.length?this.queryRenderedFeatures(n.point,{layers:o}):[]).length?r=!0:r&&(r=!1,i.call(this,new nS(e,this,n.originalEvent)));},o=t=>{r&&(r=!1,i.call(this,new nS(e,this,t.originalEvent)));};return {layers:new Set(t),listener:i,delegates:{mousemove:n,mouseout:o}}}{const r=e=>{const r=t.filter((e=>this.getLayer(e))),n=r.length?this.queryRenderedFeatures(e.point,{layers:r}):[];n.length&&(e.features=n,i.call(this,e),delete e.features);};return {layers:new Set(t),listener:i,delegates:{[e]:r}}}}on(e,t,i){if(void 0===i)return super.on(e,t);if(Array.isArray(t)||(t=[t]),t)for(const e of t)if(!this._isValidId(e))return this;const r=this._createDelegatedListener(e,t,i);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(r);for(const e in r.delegates)this.on(e,r.delegates[e]);return this}once(e,t,i){if(void 0===i)return super.once(e,t);if(Array.isArray(t)||(t=[t]),t)for(const e of t)if(!this._isValidId(e))return this;const r=this._createDelegatedListener(e,t,i);for(const e in r.delegates)this.once(e,r.delegates[e]);return this}off(e,t,i){if(void 0===i)return super.off(e,t);t=new Set(Array.isArray(t)?t:[t]);for(const e of t)if(!this._isValidId(e))return this;const r=(e,t)=>{if(e.size!==t.size)return !1;for(const i of e)if(!t.has(i))return !1;return !0},n=this._delegatedListeners?this._delegatedListeners[e]:void 0;return n&&(e=>{for(let n=0;n{e?this.fire(new St(e)):i&&this._updateDiff(i,t);}));}else "object"==typeof e&&this._updateDiff(e,t);}_updateDiff(e,t){try{this.style.setState(e)&&this._update(!0);}catch(i){W(`Unable to perform style diff: ${i.message||i.error||i}. Rebuilding the style from scratch.`),this._updateStyle(e,t);}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(W("There is no style added to the map."),!1)}_isValidId(e){return !function(e){return e.indexOf("")>=0}(e)||(this.fire(new St(new Error(`IDs can't contain special symbols: "${e}".`))),!1)}addSource(e,t){return this._isValidId(e)?(this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)):this}isSourceLoaded(e){return !!this._isValidId(e)&&!!this.style&&this.style._isSourceCacheLoaded(e)}areTilesLoaded(){const e=this.style&&this.style._sourceCaches;for(const t in e){const i=e[t]._tiles;for(const e in i){const t=i[e];if("loaded"!==t.state&&"errored"!==t.state)return !1}}return !0}addSourceType(e,t,i){this._lazyInitEmptyStyle(),this.style.addSourceType(e,t,i);}removeSource(e){return this._isValidId(e)?(this.style.removeSource(e),this._updateTerrain(),this._update(!0)):this}getSource(e){return this._isValidId(e)?this.style.getOwnSource(e):null}addImage(e,i,{pixelRatio:r=1,sdf:n=!1,stretchX:o,stretchY:s,content:a}={}){if(this._lazyInitEmptyStyle(),i instanceof t.HTMLImageElement||t.ImageBitmap&&i instanceof t.ImageBitmap){const{width:t,height:l,data:c}=ht.getImageData(i);this.style.addImage(e,{data:new $p({width:t,height:l},c),pixelRatio:r,stretchX:o,stretchY:s,content:a,sdf:n,version:0});}else if(void 0===i.width||void 0===i.height)this.fire(new St(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`")));else {const{width:t,height:l}=i,c=i;this.style.addImage(e,{data:new $p({width:t,height:l},new Uint8Array(c.data)),pixelRatio:r,stretchX:o,stretchY:s,content:a,sdf:n,version:0,userImage:c}),c.onAdd&&c.onAdd(this,e);}}updateImage(e,i){this._lazyInitEmptyStyle();const r=this.style.getImage(e);if(!r)return void this.fire(new St(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const n=i instanceof t.HTMLImageElement||t.ImageBitmap&&i instanceof t.ImageBitmap?ht.getImageData(i):i,{width:o,height:s}=n;void 0!==o&&void 0!==s?o===r.data.width&&s===r.data.height?(r.data.replace(n.data,!(i instanceof t.HTMLImageElement||t.ImageBitmap&&i instanceof t.ImageBitmap)),this.style.updateImage(e,r)):this.fire(new St(new Error(`The width and height of the updated image (${o}, ${s})\n must be that same as the previous version of the image\n (${r.data.width}, ${r.data.height})`))):this.fire(new St(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`")));}hasImage(e){return e?!!this.style&&!!this.style.getImage(e):(this.fire(new St(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e);}loadImage(e,i){Ie(this._requestManager.transformRequest(e,ye.Image),((e,r)=>{i(e,r instanceof t.HTMLImageElement?ht.getImageData(r):r);}));}listImages(){return this.style.listImages()}addModel(e,t){this._lazyInitEmptyStyle(),this.style.addModel(e,t);}hasModel(e){return e?this.style.hasModel(e):(this.fire(new St(new Error("Missing required model id"))),!1)}removeModel(e){this.style.removeModel(e);}listModels(){return this.style.listModels()}addLayer(e,t){return this._isValidId(e.id)?(this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)):this}moveLayer(e,t){return this._isValidId(e)?(this.style.moveLayer(e,t),this._update(!0)):this}removeLayer(e){return this._isValidId(e)?(this.style.removeLayer(e),this._update(!0)):this}getLayer(e){return this._isValidId(e)?this.style.getOwnLayer(e):null}setLayerZoomRange(e,t,i){return this._isValidId(e)?(this.style.setLayerZoomRange(e,t,i),this._update(!0)):this}setFilter(e,t,i={}){return this._isValidId(e)?(this.style.setFilter(e,t,i),this._update(!0)):this}getFilter(e){return this._isValidId(e)?this.style.getFilter(e):null}setPaintProperty(e,t,i,r={}){return this._isValidId(e)?(this.style.setPaintProperty(e,t,i,r),this._update(!0)):this}getPaintProperty(e,t){return this._isValidId(e)?this.style.getPaintProperty(e,t):null}setLayoutProperty(e,t,i,r={}){return this._isValidId(e)?(this.style.setLayoutProperty(e,t,i,r),this._update(!0)):this}getLayoutProperty(e,t){return this._isValidId(e)?this.style.getLayoutProperty(e,t):null}setConfigProperty(e,t,i){return this.style.setConfigProperty(e,t,i),this._update(!0)}setLights(e){if(this._lazyInitEmptyStyle(),e&&1===e.length&&"flat"===e[0].type){const t=e[0];t.properties?this.style.setFlatLight(t.properties,t.id,{}):this.style.setFlatLight({},"flat");}else this.style.setLights(e),this.painter.terrain&&(this.painter.terrain.invalidateRenderCache=!0);return this._update(!0)}getLights(){const e=this.style.getLights()||[];return 0===e.length&&e.push({id:this.style.light.id,type:"flat",properties:this.style.getFlatLight()}),e}setLight(e,t={}){return console.log("The `map.setLight` function is deprecated, prefer using `map.setLights` with `flat` light type instead."),this.setLights([{id:"flat",type:"flat",properties:e}])}getLight(){return console.log("The `map.getLight` function is deprecated, prefer using `map.getLights` instead."),this.style.getFlatLight()}setTerrain(e){return this._lazyInitEmptyStyle(),!e&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(e),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(e){return this._lazyInitEmptyStyle(),this.style.setFog(e),this._update(!0)}getFog(){return this.style?this.style.getFog():null}setCamera(e){return this.style.setCamera(e),this._triggerCameraUpdate(e)}_triggerCameraUpdate(e){return this._update(this.transform.setOrthographicProjectionAtLowPitch("orthographic"===e["camera-projection"]))}getCamera(){return this.style.camera}_queryFogOpacity(e){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(Nd.convert(e),this.transform):0}setFeatureState(e,t){return this._isValidId(e.source)?(this.style.setFeatureState(e,t),this._update()):this}removeFeatureState(e,t){return this._isValidId(e.source)?(this.style.removeFeatureState(e,t),this._update()):this}getFeatureState(e){return this._isValidId(e.source)?this.style.getFeatureState(e):null}_updateContainerDimensions(){if(!this._container)return;const e=this._container.getBoundingClientRect().width||400,i=this._container.getBoundingClientRect().height||300;let r,n,o,s=this._container;for(;s&&(!n||!o);){const e=t.getComputedStyle(s).transform;e&&"none"!==e&&(r=e.match(/matrix.*\((.+)\)/)[1].split(", "),r[0]&&"0"!==r[0]&&"1"!==r[0]&&(n=r[0]),r[3]&&"0"!==r[3]&&"1"!==r[3]&&(o=r[3])),s=s.parentElement;}this._containerWidth=n?Math.abs(e/n):e,this._containerHeight=o?Math.abs(i/o):i;}_detectMissingCSS(){"rgb(250, 128, 114)"!==t.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&W("This page appears to be missing CSS declarations for Mapbox GL JS, which may cause the map to display incorrectly. Please ensure your page includes mapbox-gl.css, as described in https://www.mapbox.com/mapbox-gl-js/api/.");}_setupContainer(){const e=this._container;e.classList.add("mapboxgl-map"),(this._missingCSSCanary=ut("div","mapboxgl-canary",e)).style.visibility="hidden",this._detectMissingCSS();const t=this._canvasContainer=ut("div","mapboxgl-canvas-container",e);this._canvas=ut("canvas","mapboxgl-canvas",t),this._interactive&&(t.classList.add("mapboxgl-interactive"),this._canvas.setAttribute("tabindex","0")),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const i=this._controlContainer=ut("div","mapboxgl-control-container",e),r=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((e=>{r[e]=ut("div",`mapboxgl-ctrl-${e}`,i);})),this._container.addEventListener("scroll",this._onMapScroll,!1);}_resizeCanvas(e,t){const i=ht.devicePixelRatio||1;this._canvas.width=i*Math.ceil(e),this._canvas.height=i*Math.ceil(t),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${t}px`;}_addMarker(e){this._markers.push(e);}_removeMarker(e){const t=this._markers.indexOf(e);-1!==t&&this._markers.splice(t,1);}_addPopup(e){this._popups.push(e);}_removePopup(e){const t=this._popups.indexOf(e);-1!==t&&this._popups.splice(t,1);}_setupPainter(){const e=k({},rt.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),t=this._canvas.getContext("webgl2",e);t?(Ke(t,!0),this.painter=new zA(t,this.transform),this.on("data",(e=>{"source"===e.dataType&&this.painter.setTileLoadedFlag(!0);})),o.testSupport(t)):this.fire(new St(new Error("Failed to initialize WebGL")));}_contextLost(e){e.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new At("webglcontextlost",{originalEvent:e}));}_contextRestored(e){this._setupPainter(),this.resize(),this._update(),this.fire(new At("webglcontextrestored",{originalEvent:e}));}_onMapScroll(e){if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}loaded(){return !this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(e){return this.style?(this._styleDirty=this._styleDirty||e,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e);}_requestDomTask(e){!this.loaded()||this.loaded()&&!this.isMoving()?e():this._domRenderTaskQueue.add(e);}_render(e){let i;this.fire(new At("renderstart"));const r=this.painter.context.extTimerQuery,n=ht.now(),o=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(i=o.createQuery(),o.beginQuery(r.TIME_ELAPSED_EXT,i)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&(this._interactionRange[0]=Math.min(this._interactionRange[0],t.performance.now()),this._interactionRange[1]=Math.max(this._interactionRange[1],t.performance.now())),this._renderTaskQueue.run(e),this._domRenderTaskQueue.run(e),this._removed)return;this._updateProjectionTransition();const s=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const e=this.transform.zoom,t=this.transform.pitch,i=ht.now(),r=new ea(e,{now:i,fadeDuration:s,pitch:t,transition:this.style.transition});this.style.update(r);}this.style&&this.style.hasFogTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let a=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),a=this._updateAverageElevation(n),this.style.updateSources(this.transform),this._forceMarkerAndPopupUpdate()):a=this._updateAverageElevation(n),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,s,this._crossSourceCollisions),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,wireframe:{terrain:this.showTerrainWireframe,layers2D:this.showLayers2DWireframe,layers3D:this.showLayers3DWireframe},showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,showTileAABBs:this.showTileAABBs,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:s,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),gpuTimingDeferredRender:!!this.listens("gpu-timing-deferred-render"),speedIndexTiming:this.speedIndexTiming}),this.fire(new At("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new At("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),i){const e=ht.now()-n;o.endQuery(r.TIME_ELAPSED_EXT),setTimeout((()=>{const r=o.getQueryParameter(i,o.QUERY_RESULT)/1e6;o.deleteQuery(i),this.fire(new At("gpu-timing-frame",{cpuTime:e,gpuTime:r})),t.performance.mark("frame-gpu",{startTime:n,detail:{gpuTime:r}});}),50);}if(this.listens("gpu-timing-layer")){const e=this.painter.collectGpuTimers();setTimeout((()=>{const t=this.painter.queryGpuTimers(e);this.fire(new At("gpu-timing-layer",{layerTimes:t}));}),50);}if(this.listens("gpu-timing-deferred-render")){const e=this.painter.collectDeferredRenderGpuQueries();setTimeout((()=>{const t=this.painter.queryGpuTimeDeferredRender(e);this.fire(new At("gpu-timing-deferred-render",{gpuTime:t}));}),50);}const l=this._sourcesDirty||this._styleDirty||this._placementDirty||a;if(l||this._repaint)this.triggerRepaint();else {const e=!this.isMoving()&&this.loaded();if(e&&(a=this._updateAverageElevation(n,!0)),a)this.triggerRepaint();else if(this._triggerFrame(!1),e&&(this.fire(new At("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const e=this._calculateSpeedIndex();this.fire(new At("speedindexcompleted",{speedIndex:e})),this.speedIndexTiming=!1;}}!this._loaded||this._fullyLoaded||l||(this._fullyLoaded=!0,Qe.mark(Je.fullLoad),this._performanceMetricsCollection&&He(this._requestManager._customAccessToken,{width:this.painter.width,height:this.painter.height,interactionRange:this._interactionRange,visibilityHidden:this._visibilityHidden,terrainEnabled:!!this.painter.style.getTerrain(),fogEnabled:!!this.painter.style.getFog(),projection:this.getProjection().name,zoom:this.transform.zoom,renderer:this.painter.context.renderer,vendor:this.painter.context.vendor}),this._authenticate());}_forceMarkerAndPopupUpdate(e){for(const t of this._markers)e&&!this.getRenderWorldCopies()&&(t._lngLat=t._lngLat.wrap()),t._update();for(const t of this._popups)!e||this.getRenderWorldCopies()||t._trackPointer||(t._lngLat=t._lngLat.wrap()),t._update();}_updateAverageElevation(e,t=!1){const i=e=>(this.transform.averageElevation=e,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&i(0);const r=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(r||(t||e-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(e)){const t=this.transform.averageElevation;let n=this.transform.sampleAverageElevation();this.transform.elevation&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(n)?n=0:this._averageElevationLastSampledAt=e;const o=Math.abs(t-n);if(o>1){if(this._isInitialLoad||r)return this._averageElevation.jumpTo(n),i(n);this._averageElevation.easeTo(n,e,300);}else if(o>1e-4)return this._averageElevation.jumpTo(n),i(n)}return !!this._averageElevation.isEasing(e)&&i(this._averageElevation.getValue(e))}_authenticate(){Xe(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(e=>{if(e&&(e.message===Ce||401===e.status)){const e=this.painter.context.gl;Ke(e,!1),this._logoControl instanceof HS&&this._logoControl._updateLogo(),e&&e.clear(e.DEPTH_BUFFER_BIT|e.COLOR_BUFFER_BIT|e.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new St(new Error("A valid Mapbox access token is required to use Mapbox GL JS. To create an account or a new access token, visit https://account.mapbox.com/")));}})),Ze(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(()=>{}));}_updateTerrain(){const e=this._isDragging();this.painter.updateTerrain(this.style,e);}_calculateSpeedIndex(){const e=this.painter.canvasCopy(),t=this.painter.getCanvasCopiesAndTimestamps();t.timeStamps.push(performance.now());const i=this.painter.context.gl,r=i.createFramebuffer();function n(e){i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,e,0);const t=new Uint8Array(i.drawingBufferWidth*i.drawingBufferHeight*4);return i.readPixels(0,0,i.drawingBufferWidth,i.drawingBufferHeight,i.RGBA,i.UNSIGNED_BYTE,t),t}return i.bindFramebuffer(i.FRAMEBUFFER,r),this._canvasPixelComparison(n(e),t.canvasCopies.map(n),t.timeStamps)}_canvasPixelComparison(e,t,i){let r=i[1]-i[0];const n=e.length/4;for(let o=0;o{const t=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,t&&this._render(e);})));}_preloadTiles(e){return R(this.style?Object.values(this.style._sourceCaches):[],((t,i)=>t._preloadTiles(e,i)),(()=>{this.triggerRepaint();})),this}_onWindowOnline(){this._update();}_onWindowResize(e){this._trackResize&&this.resize({originalEvent:e})._update();}_onVisibilityChange(){"hidden"===t.document.visibilityState&&this._visibilityHidden++;}get showTileBoundaries(){return !!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._update());}get showTerrainWireframe(){return !!this._showTerrainWireframe}set showTerrainWireframe(e){this._showTerrainWireframe!==e&&(this._showTerrainWireframe=e,this._update());}get showLayers2DWireframe(){return !!this._showLayers2DWireframe}set showLayers2DWireframe(e){this._showLayers2DWireframe!==e&&(this._showLayers2DWireframe=e,this._update());}get showLayers3DWireframe(){return !!this._showLayers3DWireframe}set showLayers3DWireframe(e){this._showLayers3DWireframe!==e&&(this._showLayers3DWireframe=e,this._update());}get speedIndexTiming(){return !!this._speedIndexTiming}set speedIndexTiming(e){this._speedIndexTiming!==e&&(this._speedIndexTiming=e,this._update());}get showPadding(){return !!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._update());}get showCollisionBoxes(){return !!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,e?this.style._generateCollisionBoxes():this._update());}get showOverdrawInspector(){return !!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._update());}get repaint(){return !!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this.triggerRepaint());}get vertices(){return !!this._vertices}set vertices(e){this._vertices=e,this._update();}get showTileAABBs(){return !!this._showTileAABBs}set showTileAABBs(e){this._showTileAABBs!==e&&(this._showTileAABBs=e,e&&this._update());}_setCacheLimits(e,t){!function(e,t){ce=e,he=t;}(e,t);}get version(){return i}},NavigationControl:class{constructor(e){this.options=k({},nI,e),this._container=ut("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this.options.showZoom&&(j(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",(e=>{this._map&&this._map.zoomIn({},{originalEvent:e});})),ut("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",(e=>{this._map&&this._map.zoomOut({},{originalEvent:e});})),ut("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(j(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",(e=>{const t=this._map;t&&(this.options.visualizePitch?t.resetNorthPitch({},{originalEvent:e}):t.resetNorth({},{originalEvent:e}));})),this._compassIcon=ut("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"));}_updateZoomButtons(){const e=this._map;if(!e)return;const t=e.getZoom(),i=t===e.getMaxZoom(),r=t===e.getMinZoom();this._zoomInButton.disabled=i,this._zoomOutButton.disabled=r,this._zoomInButton.setAttribute("aria-disabled",i.toString()),this._zoomOutButton.setAttribute("aria-disabled",r.toString());}_rotateCompassArrow(){const e=this._map;if(!e)return;const t=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(e.transform.pitch*(Math.PI/180)),.5)}) rotateX(${e.transform.pitch}deg) rotateZ(${e.transform.angle*(180/Math.PI)}deg)`:`rotate(${e.transform.angle*(180/Math.PI)}deg)`;e._requestDomTask((()=>{this._compassIcon&&(this._compassIcon.style.transform=t);}));}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),e.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&e.on("pitch",this._rotateCompassArrow),e.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new oI(e,this._compass,this.options.visualizePitch)),this._container}onRemove(){const e=this._map;e&&(this._container.remove(),this.options.showZoom&&e.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&e.off("pitch",this._rotateCompassArrow),e.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0);}_createButton(e,t){const i=ut("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}_setButtonTitle(e,t){if(!this._map)return;const i=this._map._getUIString(`NavigationControl.${t}`);e.setAttribute("aria-label",i),e.firstElementChild&&e.firstElementChild.setAttribute("title",i);}},GeolocateControl:class extends It{constructor(e){super(),this.options=k({geolocation:t.navigator.geolocation},sI,e),j(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=HA(this._updateMarkerRotation,20),this._numberOfWatches=0;}onAdd(e){return this._map=e,this._container=ut("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){void 0!==this._geolocationWatchID&&(this.options.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,this._numberOfWatches=0,this._noTimeout=!1;}_checkGeolocationSupport(e){const i=(t=!!this.options.geolocation)=>{this._supportsGeolocation=t,e(t);};void 0!==this._supportsGeolocation?e(this._supportsGeolocation):void 0!==t.navigator.permissions?t.navigator.permissions.query({name:"geolocation"}).then((e=>i("denied"!==e.state))).catch((()=>i())):i();}_isOutOfMapMaxBounds(e){const t=this._map.getMaxBounds(),i=e.coords;return !!t&&(i.longitudet.getEast()||i.latitudet.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");}}_onSuccess(e){if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new At("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(e),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(e),this.options.showUserLocation&&this._userLocationDotMarker.removeClassName("mapboxgl-user-location-dot-stale"),this.fire(new At("geolocate",e)),this._finish();}}_updateCamera(e){const t=new Nd(e.coords.longitude,e.coords.latitude),i=e.coords.accuracy,r=k({bearing:this._map.getBearing()},this.options.fitBoundsOptions);this._map.fitBounds(t.toBounds(i),r,{geolocateSource:!0});}_updateMarker(e){if(e){const t=new Nd(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(t).addTo(this._map),this._userLocationDotMarker.setLngLat(t).addTo(this._map),this._accuracy=e.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius();}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove();}_updateCircleRadius(){const e=this._map.transform,t=Zd(1,e._center.lat)*e.worldSize,i=Math.ceil(2*this._accuracy*t);this._circleElement.style.width=`${i}px`,this._circleElement.style.height=`${i}px`;}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius();}_updateMarkerRotation(){this._userLocationDotMarker&&"number"==typeof this._heading?(this._userLocationDotMarker.setRotation(this._heading),this._userLocationDotMarker.addClassName("mapboxgl-user-location-show-heading")):(this._userLocationDotMarker.removeClassName("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0));}_onError(e){if(this._map){if(this.options.trackUserLocation)if(1===e.code){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e),void 0!==this._geolocationWatchID&&this._clearWatch();}else {if(3===e.code&&this._noTimeout)return;this._setErrorState();}"OFF"!==this._watchState&&this.options.showUserLocation&&this._userLocationDotMarker.addClassName("mapboxgl-user-location-dot-stale"),this.fire(new At("error",e)),this._finish();}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0;}_setupUI(e){if(void 0!==this._map){if(this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this._geolocateButton=ut("button","mapboxgl-ctrl-geolocate",this._container),ut("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!1===e){W("Geolocation support is not available so the GeolocateControl will be disabled.");const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e);}else {const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e);}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=ut("div","mapboxgl-user-location"),this._dotElement.appendChild(ut("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(ut("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new KS({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=ut("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new KS({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(e=>{e.geolocateSource||"ACTIVE_LOCK"!==this._watchState||e.originalEvent&&"resize"===e.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new At("trackuserlocationend")));}));}}_onDeviceOrientation(e){this._userLocationDotMarker&&(e.webkitCompassHeading?this._heading=e.webkitCompassHeading:!0===e.absolute&&(this._heading=-1*e.alpha),this._updateMarkerRotationThrottled());}trigger(){if(!this._setup)return 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 At("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":this._numberOfWatches--,this._noTimeout=!1,this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this.fire(new At("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new At("trackuserlocationstart"));}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error");}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let e;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(e={maximumAge:6e5,timeout:0},this._noTimeout=!0):(e=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,e),this.options.showUserHeading&&this._addDeviceOrientationListener();}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return !0}_addDeviceOrientationListener(){const e=()=>{t.addEventListener("ondeviceorientationabsolute"in t?"deviceorientationabsolute":"deviceorientation",this._onDeviceOrientation);};void 0!==t.DeviceMotionEvent&&"function"==typeof t.DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((t=>{"granted"===t&&e();})).catch(console.error):e();}_clearWatch(){this.options.geolocation.clearWatch(this._geolocationWatchID),t.removeEventListener("deviceorientation",this._onDeviceOrientation),t.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null);}},AttributionControl:$S,ScaleControl:class{constructor(e){this.options=k({},aI,e),this._isNumberFormatSupported=function(){try{return new Intl.NumberFormat("en",{style:"unit",unitDisplay:"short",unit:"meter"}),!0}catch(e){return !1}}(),j(["_update","_setScale","setUnit"],this);}getDefaultPosition(){return "bottom-left"}_update(){const e=this.options.maxWidth||100,t=this._map,i=t._containerHeight/2,r=t._containerWidth/2-e/2,n=t.unproject([r,i]),o=t.unproject([r+e,i]),s=n.distanceTo(o);if("imperial"===this.options.unit){const t=3.2808*s;t>5280?this._setScale(e,t/5280,"mile"):this._setScale(e,t,"foot");}else "nautical"===this.options.unit?this._setScale(e,s/1852,"nautical-mile"):s>=1e3?this._setScale(e,s/1e3,"kilometer"):this._setScale(e,s,"meter");}_setScale(e,t,i){this._map._requestDomTask((()=>{const r=function(e){const t=Math.pow(10,`${Math.floor(e)}`.length-1);let i=e/t;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(e){const t=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*t)/t}(i),t*i}(t),n=r/t;this._container.innerHTML=this._isNumberFormatSupported&&"nautical-mile"!==i?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:i}).format(r):`${r} ${lI[i]}`,this._container.style.width=e*n+"px";}));}onAdd(e){return this._map=e,this._language=e.getLanguage(),this._container=ut("div","mapboxgl-ctrl mapboxgl-ctrl-scale",e.getContainer()),this._container.dir="auto",this._map.on("move",this._update),this._update(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._update),this._map=void 0;}_setLanguage(e){this._language=e,this._update();}setUnit(e){this.options.unit=e,this._update();}},FullscreenControl:class{constructor(e){this._fullscreen=!1,e&&e.container&&(e.container instanceof t.HTMLElement?this._container=e.container:W("Full screen control 'container' must be a DOM element.")),j(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in t.document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in t.document&&(this._fullscreenchange="webkitfullscreenchange");}onAdd(e){return this._map=e,this._container||(this._container=this._map.getContainer()),this._controlContainer=ut("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",W("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,t.document.removeEventListener(this._fullscreenchange,this._changeIcon);}_checkFullscreenSupport(){return !(!t.document.fullscreenEnabled&&!t.document.webkitFullscreenEnabled)}_setupUI(){const e=this._fullscreenButton=ut("button","mapboxgl-ctrl-fullscreen",this._controlContainer);ut("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),t.document.addEventListener(this._fullscreenchange,this._changeIcon);}_updateTitle(){const e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",e);}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(t.document.fullscreenElement||t.document.webkitFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle());}_onClickFullscreen(){this._isFullscreen()?t.document.exitFullscreen?t.document.exitFullscreen():t.document.webkitCancelFullScreen&&t.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen();}},Popup:class extends It{constructor(e){super(),this.options=k(Object.create(JS),e),j(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(e&&e.className?e.className.trim().split(/\s+/):[]);}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&e.on("preclick",this._onClose),this.options.closeOnMove&&e.on("move",this._onClose),e.on("remove",this.remove),this._update(),e._addPopup(this),this._focusFirstElement(),this._trackPointer?(e.on("mousemove",this._onMouseEvent),e.on("mouseup",this._onMouseEvent),e._canvasContainer.classList.add("mapboxgl-track-pointer")):e.on("move",this._update),this.fire(new At("open")),this}isOpen(){return !!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const e=this._map;return e&&(e.off("move",this._update),e.off("move",this._onClose),e.off("preclick",this._onClose),e.off("click",this._onClose),e.off("remove",this.remove),e.off("mousemove",this._onMouseEvent),e.off("mouseup",this._onMouseEvent),e.off("drag",this._onMouseEvent),e._canvasContainer&&e._canvasContainer.classList.remove("mapboxgl-track-pointer"),e._removePopup(this),this._map=void 0),this.fire(new At("close")),this}getLngLat(){return this._lngLat}setLngLat(e){this._lngLat=Nd.convert(e),this._pos=null,this._trackPointer=!1,this._update();const t=this._map;return t&&(t.on("move",this._update),t.off("mousemove",this._onMouseEvent),t._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const e=this._map;return e&&(e.off("move",this._update),e.on("mousemove",this._onMouseEvent),e.on("drag",this._onMouseEvent),e._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(t.document.createTextNode(e))}setHTML(e){const i=t.document.createDocumentFragment(),r=t.document.createElement("body");let n;for(r.innerHTML=e;n=r.firstChild,n;)i.appendChild(n);return this.setDOMContent(i)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){let t=this._content;if(t)for(;t.hasChildNodes();)t.firstChild&&t.removeChild(t.firstChild);else t=this._content=ut("div","mapboxgl-popup-content",this._container||void 0);if(t.appendChild(e),this.options.closeButton){const e=this._closeButton=ut("button","mapboxgl-popup-close-button",t);e.type="button",e.setAttribute("aria-label","Close popup"),e.setAttribute("aria-hidden","true"),e.innerHTML="×",e.addEventListener("click",this._onClose);}return this._update(),this._focusFirstElement(),this}addClassName(e){return this._classList.add(e),this._updateClassList(),this}removeClassName(e){return this._classList.delete(e),this._updateClassList(),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){let t;return this._classList.delete(e)?t=!1:(this._classList.add(e),t=!0),this._updateClassList(),t}_onMouseEvent(e){this._update(e.point);}_getAnchor(e){if(this.options.anchor)return this.options.anchor;const t=this._map,i=this._container,r=this._pos;if(!t||!i||!r)return "bottom";const n=i.offsetWidth,o=i.offsetHeight,s=r.xt.transform.width-n/2;if(r.y+et.transform.height-o){if(s)return "bottom-left";if(a)return "bottom-right"}return s?"left":a?"right":"bottom"}_updateClassList(){const e=this._container;if(!e)return;const t=[...this._classList];t.push("mapboxgl-popup"),this._anchor&&t.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&t.push("mapboxgl-popup-track-pointer"),e.className=t.join(" ");}_update(e){const t=this._map,i=this._content;if(!t||!this._lngLat&&!this._trackPointer||!i)return;let r=this._container;if(r||(r=this._container=ut("div","mapboxgl-popup",t.getContainer()),this._tip=ut("div","mapboxgl-popup-tip",r),r.appendChild(i)),this.options.maxWidth&&r.style.maxWidth!==this.options.maxWidth&&(r.style.maxWidth=this.options.maxWidth),t.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=XS(this._lngLat,this._pos,t.transform)),!this._trackPointer||e){const i=this._pos=this._trackPointer&&e?e:t.project(this._lngLat),r=eI(this.options.offset),n=this._anchor=this._getAnchor(r.y),o=eI(this.options.offset,n),s=i.add(o).round();t._requestDomTask((()=>{this._container&&n&&(this._container.style.transform=`${YS[n]} translate(${s.x}px,${s.y}px)`);}));}if(!this._marker&&t._showingGlobe()){const e=Dd(t.transform,this._lngLat)?0:1;this._setOpacity(e);}this._updateClassList();}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(QS);e&&e.focus();}_onClose(){this.remove();}_setOpacity(e){this._container&&(this._container.style.opacity=`${e}`),this._content&&(this._content.style.pointerEvents=e?"auto":"none");}},Marker:KS,Style:$A,LngLat:Nd,LngLatBounds:Ql,Point:y,MercatorCoordinate:ep,FreeCameraOptions:Vx,Evented:It,config:n,prewarm:function(){Uw().acquire(Bw);},clearPrewarmedResources:function(){const e=Nw;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(Bw),Nw=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()"));},get accessToken(){return n.ACCESS_TOKEN},set accessToken(e){n.ACCESS_TOKEN=e;},get baseApiUrl(){return n.API_URL},set baseApiUrl(e){n.API_URL=e;},get workerCount(){return Fw.workerCount},set workerCount(e){Fw.workerCount=e;},get maxParallelImageRequests(){return n.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(e){n.MAX_PARALLEL_IMAGE_REQUESTS=e;},clearStorage(e){!function(e){if(!pe())return;const i=t.caches.delete(le);e&&i.catch(e).then((()=>e()));}(e);},workerUrl:"",workerClass:null,get dracoUrl(){return Zw()},set dracoUrl(e){!function(e){jw=ht.resolveURL(e),qw||(qw=new _w(Uw(),new It)),qw.broadcast("setDracoUrl",jw);}(e);},setNow:ht.setNow,restoreNow:ht.restoreNow};e.A=mw,e.D=jm,e.E=sr,e.F=Zm,e.K=dE,e.O=Bu,e.P=y,e.T=Bv,e.V=im,e.a=Gf,e.b=sm,e.c=Kb,e.d=class extends It{constructor(e,t,i,r,n,o){super(),this.actor=e,this.layerIndex=t,this.availableImages=i,this.loadVectorData=n||Pw,this.loading={},this.loaded={},this.deduped=new Dw(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler,this.brightness=o;}loadTile(e,t){const i=e.uid,r=e&&e.request,n=r&&r.collectResourceTiming,o=this.loading[i]=new Cw(e);o.abort=this.loadVectorData(e,((s,a)=>{const l=!this.loading[i];if(delete this.loading[i],l||s||!a)return o.status="done",l||(this.loaded[i]=o),t(s);const c=a.rawData,h={};a.expires&&(h.expires=a.expires),a.cacheControl&&(h.cacheControl=a.cacheControl),o.vectorTile=a.vectorTile||new tm(new Sm(c));const u=()=>{o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,((e,i)=>{if(e||!i)return t(e);const o={};if(n){const e=it(r);e.length>0&&(o.resourceTiming=JSON.parse(JSON.stringify(e)));}t(null,k({rawTileData:c.slice(0)},i,h,o));}));};this.isSpriteLoaded?u():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(u,{type:"parseTile",isSymbolTile:e.isSymbolTile,zoom:e.tileZoom}):u();})),this.loaded=this.loaded||{},this.loaded[i]=o;}));}reloadTile(e,t){const i=this.loaded,r=e.uid,n=this;if(i&&i[r]){const o=i[r];o.showCollisionBoxes=e.showCollisionBoxes,o.projection=e.projection,o.brightness=e.brightness,o.tileTransform=Tg(e.tileID.canonical,e.projection),o.extraShadowCaster=e.extraShadowCaster;const s=(e,i)=>{const r=o.reloadCallback;r&&(delete o.reloadCallback,o.parse(o.vectorTile,n.layerIndex,this.availableImages,n.actor,r)),t(e,i);};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s());}}abortTile(e,t){const i=e.uid,r=this.loading[i];r&&(r.abort&&r.abort(),delete this.loading[i]),t();}removeTile(e,t){const i=this.loaded,r=e.uid;i&&i[r]&&delete i[r],t();}},e.e=xo,e.f=it,e.g=d,e.h=we,e.i=Te,e.j=function(e,t){const i=_T(e);for(const e of i){for(const t of e.meshes)gT(t);e.lights&&(e.lightMeshIndex=e.meshes.length,e.meshes.push(yT(e.lights,t)));}return i},e.k=ea,e.l=function(e){let t=0;if(new Uint32Array(e,0,1)[0]!==eT){const i=new Uint32Array(e,0,7),[,,r,n,o,s]=i;t=i.byteLength+n+o+s+o,(r!==e.byteLength||t>=e.byteLength)&&W("Invalid b3dm header information.");}return sT(e,t)},e.m=Hg,e.n=Qs,e.o=At,e.p=_,e.q=function(e){fe(),ue&&ue.then((t=>{t.keys().then((i=>{for(let r=0;r>1,c=-7,h=r?i-1:0,p=r?-1:1,f=t[e+h];for(h+=p,a=f&(1<<-c)-1,f>>=-c,c+=o;c>0;a=256*a+t[e+h],h+=p,c-=8);for(s=a&(1<<-c)-1,a>>=-c,c+=n;c>0;s=256*s+t[e+h],h+=p,c-=8);if(0===a)a=1-u;else {if(a===l)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,n),a-=u;}return (f?-1:1)*s*Math.pow(2,a-n)},write:function(t,e,r,n,i,a){var s,o,l,u=8*a-i-1,c=(1<>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:a-1,d=n?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(o=isNaN(e)?1:0,s=c):(s=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-s))<1&&(s--,l*=2),(e+=s+h>=1?p/l:p*Math.pow(2,1-h))*l>=2&&(s++,l/=2),s+h>=c?(o=0,s=c):s+h>=1?(o=(e*l-1)*Math.pow(2,i),s+=h):(o=e*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;t[r+f]=255&o,f+=d,o/=256,i-=8);for(s=s<0;t[r+f]=255&s,f+=d,s/=256,u-=8);t[r+f-d]|=128*m;}},mm=gm,ym=dm;function gm(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length;}gm.Varint=0,gm.Fixed64=1,gm.Bytes=2,gm.Fixed32=5;var xm=4294967296,vm=1/xm,bm="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function _m(t){return t.type===gm.Bytes?t.readVarint()+t.pos:t.pos+1}function wm(t,e,r){return r?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function Mm(t,e,r){var n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));r.realloc(n);for(var i=r.pos-1;i>=t;i--)r.buf[i+n]=r.buf[i];}function Am(t,e){for(var r=0;r>>8,t[r+2]=e>>>16,t[r+3]=e>>>24;}function Dm(t,e){return (t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}gm.prototype={destroy:function(){this.buf=null;},readFields:function(t,e,r){for(r=r||this.length;this.pos>3,a=this.pos;this.type=7&n,t(i,e,this),this.pos===a&&this.skip(n);}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=Cm(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=Dm(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=Cm(this.buf,this.pos)+Cm(this.buf,this.pos+4)*xm;return this.pos+=8,t},readSFixed64:function(){var t=Cm(this.buf,this.pos)+Dm(this.buf,this.pos+4)*xm;return this.pos+=8,t},readFloat:function(){var t=ym.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=ym.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,r,n=this.buf;return e=127&(r=n[this.pos++]),r<128?e:(e|=(127&(r=n[this.pos++]))<<7,r<128?e:(e|=(127&(r=n[this.pos++]))<<14,r<128?e:(e|=(127&(r=n[this.pos++]))<<21,r<128?e:function(t,e,r){var n,i,a=r.buf;if(n=(112&(i=a[r.pos++]))>>4,i<128)return wm(t,n,e);if(n|=(127&(i=a[r.pos++]))<<3,i<128)return wm(t,n,e);if(n|=(127&(i=a[r.pos++]))<<10,i<128)return wm(t,n,e);if(n|=(127&(i=a[r.pos++]))<<17,i<128)return wm(t,n,e);if(n|=(127&(i=a[r.pos++]))<<24,i<128)return wm(t,n,e);if(n|=(1&(i=a[r.pos++]))<<31,i<128)return wm(t,n,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(r=n[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&bm?function(t,e,r){return bm.decode(t.subarray(e,r))}(this.buf,e,t):function(t,e,r){for(var n="",i=e;i239?4:l>223?3:l>191?2:1;if(i+c>r)break;1===c?l<128&&(u=l):2===c?128==(192&(a=t[i+1]))&&(u=(31&l)<<6|63&a)<=127&&(u=null):3===c?(s=t[i+2],128==(192&(a=t[i+1]))&&128==(192&s)&&((u=(15&l)<<12|(63&a)<<6|63&s)<=2047||u>=55296&&u<=57343)&&(u=null)):4===c&&(s=t[i+2],o=t[i+3],128==(192&(a=t[i+1]))&&128==(192&s)&&128==(192&o)&&((u=(15&l)<<18|(63&a)<<12|(63&s)<<6|63&o)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,c=1):u>65535&&(u-=65536,n+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),n+=String.fromCharCode(u),i+=c;}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==gm.Bytes)return t.push(this.readVarint(e));var r=_m(this);for(t=t||[];this.pos127;);else if(e===gm.Bytes)this.pos=this.readVarint()+this.pos;else if(e===gm.Fixed32)this.pos+=4;else {if(e!==gm.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8;}},writeTag:function(t,e){this.writeVarint(t<<3|e);},realloc:function(t){for(var e=this.length||16;e268435455||t<0?function(t,e){var r,n;if(t>=0?(r=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(r=~(-t%4294967296))?r=r+1|0:(r=0,n=n+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,r){r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,r.buf[r.pos]=127&(t>>>=7);}(r,0,e),function(t,e){var r=(7&t)<<4;e.buf[e.pos++]|=r|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))));}(n,e);}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))));},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t);},writeBoolean:function(t){this.writeVarint(Boolean(t));},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,r){for(var n,i,a=0;a55295&&n<57344){if(!i){n>56319||a+1===e.length?(t[r++]=239,t[r++]=191,t[r++]=189):i=n;continue}if(n<56320){t[r++]=239,t[r++]=191,t[r++]=189,i=n;continue}n=i-55296<<10|n-56320|65536,i=null;}else i&&(t[r++]=239,t[r++]=191,t[r++]=189,i=null);n<128?t[r++]=n:(n<2048?t[r++]=n>>6|192:(n<65536?t[r++]=n>>12|224:(t[r++]=n>>18|240,t[r++]=n>>12&63|128),t[r++]=n>>6&63|128),t[r++]=63&n|128);}return r}(this.buf,t,this.pos);var r=this.pos-e;r>=128&&Mm(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r;},writeFloat:function(t){this.realloc(4),ym.write(this.buf,t,this.pos,!0,23,4),this.pos+=4;},writeDouble:function(t){this.realloc(8),ym.write(this.buf,t,this.pos,!0,52,8),this.pos+=8;},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var r=0;r=128&&Mm(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n;},writeMessage:function(t,e,r){this.writeTag(t,gm.Bytes),this.writeRawMessage(e,r);},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,Am,e);},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,Sm,e);},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,Pm,e);},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,Im,e);},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,km,e);},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,Em,e);},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,zm,e);},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,Tm,e);},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,Bm,e);},writeBytesField:function(t,e){this.writeTag(t,gm.Bytes),this.writeBytes(e);},writeFixed32Field:function(t,e){this.writeTag(t,gm.Fixed32),this.writeFixed32(e);},writeSFixed32Field:function(t,e){this.writeTag(t,gm.Fixed32),this.writeSFixed32(e);},writeFixed64Field:function(t,e){this.writeTag(t,gm.Fixed64),this.writeFixed64(e);},writeSFixed64Field:function(t,e){this.writeTag(t,gm.Fixed64),this.writeSFixed64(e);},writeVarintField:function(t,e){this.writeTag(t,gm.Varint),this.writeVarint(e);},writeSVarintField:function(t,e){this.writeTag(t,gm.Varint),this.writeSVarint(e);},writeStringField:function(t,e){this.writeTag(t,gm.Bytes),this.writeString(e);},writeFloatField:function(t,e){this.writeTag(t,gm.Fixed32),this.writeFloat(e);},writeDoubleField:function(t,e){this.writeTag(t,gm.Fixed64),this.writeDouble(e);},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e));}};var Vm=h(mm);const Lm=3;function Fm(t,e,r){e.glyphs=[],1===t&&r.readMessage(Nm,e);}function Nm(t,e,r){if(3===t){const{id:t,bitmap:n,width:i,height:a,left:s,top:o,advance:l}=r.readMessage(Om,{});e.glyphs.push({id:t,bitmap:new vp({width:i+2*Lm,height:a+2*Lm},n),metrics:{width:i,height:a,left:s,top:o,advance:l}});}else 4===t?e.ascender=r.readSVarint():5===t&&(e.descender=r.readSVarint());}function Om(t,e,r){1===t?e.id=r.readVarint():2===t?e.bitmap=r.readBytes():3===t?e.width=r.readVarint():4===t?e.height=r.readVarint():5===t?e.left=r.readSVarint():6===t?e.top=r.readSVarint():7===t&&(e.advance=r.readVarint());}const Um=Lm,jm={horizontal:1,vertical:2,horizontalOnly:3};class qm{constructor(){this.scale=1,this.fontStack="",this.imageName=null;}static forText(t,e){const r=new qm;return r.scale=t||1,r.fontStack=e,r}static forImage(t){const e=new qm;return e.imageName=t,e}}class $m{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null;}static fromFeature(t,e){const r=new $m;for(let n=0;n=0&&r>=t&&Ym[this.text.charCodeAt(r)];r--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e);}substring(t,e){const r=new $m;return r.text=this.text.substring(t,e),r.sectionIndex=this.sectionIndex.slice(t,e),r.sections=this.sections,r}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(qm.forText(t.scale,t.fontStack||e));const r=this.sections.length-1;for(let e=0;e=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Gm(t,e,r,n,i,a,s,o,l,u,c,h,p,f,d){const m=$m.fromFeature(t,i);h===jm.vertical&&m.verticalizePunctuation(p);let y=[];const g=function(t,e,r,n,i,a){if(!t)return [];const s=[],o=function(t,e,r,n,i,a){let s=0;for(let r=0;r=0;let u=0;for(let r=0;r0&&a>_&&(_=a);}else {const t=r[o.fontStack];if(!t)continue;t[m]&&(A=t[m]);const n=e[o.fontStack];if(!n)continue;const a=n.glyphs[m];if(!a)continue;if(v=a.metrics,I=8203!==m?im:0,y){const t=void 0!==n.ascender?Math.abs(n.ascender):0,e=void 0!==n.descender?Math.abs(n.descender):0,r=(t+e)*g;w-r/2;){if(s--,s<0)return !1;o-=t[s].dist(a),a=t[s];}o+=t[s].dist(t[s+1]),s++;const l=[];let u=0;for(;on;)u-=l.shift().angleDelta;if(u>i)return !1;s++,o+=e.dist(r);}return !0}function ay(t){let e=0;for(let r=0;ru){const c=(u-l)/a,h=ue(n.x,i.x,c),p=ue(n.y,i.y,c),f=new ny(h,p,0,i.angleTo(n),r);return !s||iy(t,f,o,s,e)?f:void 0}l+=a;}}function uy(t,e,r,n,i,a,s,o,l){const u=sy(n,a,s),c=oy(n,i),h=c*s,p=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-h=0&&g=0&&x=0&&p+u<=c){const r=new ny(g,x,0,m,e);n&&!iy(t,r,a,n,i)||f.push(r);}}h+=d;}return o||f.length||s||(f=cy(t,h/2,r,n,i,a,s,!0,l)),f}function hy(t,e,r,n,i){const a=[];for(let s=0;s=n&&u.x>=n||(s.x>=n?s=new g(n,s.y+(n-s.x)/(u.x-s.x)*(u.y-s.y))._round():u.x>=n&&(u=new g(n,s.y+(n-s.x)/(u.x-s.x)*(u.y-s.y))._round()),s.y>=i&&u.y>=i||(s.y>=i?s=new g(s.x+(i-s.y)/(u.y-s.y)*(u.x-s.x),i)._round():u.y>=i&&(u=new g(s.x+(i-s.y)/(u.y-s.y)*(u.x-s.x),i)._round()),l&&s.equals(l[l.length-1])||(l=[s],a.push(l)),l.push(u)))));}}return a}function py(t){let e=0,r=0;for(const n of t)e+=n.w*n.h,r=Math.max(r,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),r),h:1/0}];let i=0,a=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const r=n[t];if(!(e.w>r.w||e.h>r.h)){if(e.x=r.x,e.y=r.y,a=Math.max(a,e.y+e.h),i=Math.max(i,e.x+e.w),e.w===r.w&&e.h===r.h){const e=n.pop();tt.hasImage(e,r))),t.dispatchRenderCallbacks(this.haveRenderCallbacks,r);for(const n in t.getUpdatedImages(r))this.patchUpdatedImage(this.iconPositions[n],t.getImage(n,r),e),this.patchUpdatedImage(this.patternPositions[n],t.getImage(n,r),e);}patchUpdatedImage(t,e,r){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[n,i]=t.tl,a=!!Object.keys(this.patternPositions).length;r.update(e.data,{useMipmap:a},{x:n,y:i});}}ra(dy,"ImagePosition"),ra(my,"ImageAtlas");const yy=1e20;function gy(t,e,r,n,i,a,s,o,l){for(let u=e;u-1);l++,a[l]=o,s[l]=u,s[l+1]=yy;}for(let o=0,l=0;o{let n=this.entries[t];n||(n=this.entries[t]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let i=n.glyphs[e];if(void 0!==i)return void r(null,{stack:t,id:e,glyph:i});if(i=this._tinySDF(n,t,e),i)return n.glyphs[e]=i,void r(null,{stack:t,id:e,glyph:i});const s=Math.floor(e/256);if(256*s>65535)return void r(new Error("glyphs > 65535 not supported"));if(n.ranges[s])return void r(null,{stack:t,id:e,glyph:i});let o=n.requests[s];o||(o=n.requests[s]=[],_y.loadGlyphRange(t,s,a,this.requestManager,((t,e)=>{if(e){n.ascender=e.ascender,n.descender=e.descender;for(const t in e.glyphs)this._doesCharSupportLocalGlyph(+t)||(n.glyphs[+t]=e.glyphs[+t]);n.ranges[s]=!0;}for(const r of o)r(t,e);delete n.requests[s];}))),o.push(((n,i)=>{n?r(n):i&&r(null,{stack:t,id:e,glyph:i.glyphs[e]||null});}));}),((t,e)=>{if(t)r(t);else if(e){const t={};for(const{stack:r,id:n,glyph:i}of e)void 0===t[r]&&(t[r]={}),void 0===t[r].glyphs&&(t[r].glyphs={}),t[r].glyphs[n]=i&&{id:i.id,bitmap:i.bitmap.clone(),metrics:i.metrics},t[r].ascender=this.entries[r].ascender,t[r].descender=this.entries[r].descender;r(null,t);}}));}_doesCharSupportLocalGlyph(t){return this.localGlyphMode!==by.none&&(this.localGlyphMode===by.all?!!this.localFontFamily:!!this.localFontFamily&&(oa["CJK Unified Ideographs"](t)||oa["Hangul Syllables"](t)||oa.Hiragana(t)||oa.Katakana(t)||oa["CJK Symbols and Punctuation"](t)||oa["CJK Unified Ideographs Extension A"](t)||oa["CJK Unified Ideographs Extension B"](t)))}_tinySDF(t,e,r){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(r))return;let i=t.tinySDF;if(!i){let r="400";/bold/i.test(e)?r="900":/medium/i.test(e)?r="500":/light/i.test(e)&&(r="200"),i=t.tinySDF=new _y.TinySDF({fontFamily:n,fontWeight:r,fontSize:24*vy,buffer:3*vy,radius:8*vy}),i.fontWeight=r;}if(this.localGlyphs[i.fontWeight][r])return this.localGlyphs[i.fontWeight][r];const a=String.fromCodePoint(r),{data:s,width:o,height:l,glyphWidth:u,glyphHeight:c,glyphLeft:h,glyphTop:p,glyphAdvance:f}=i.draw(a);return this.localGlyphs[i.fontWeight][r]={id:r,bitmap:new vp({width:o,height:l},s),metrics:{width:u/vy,height:c/vy,left:h/vy,top:p/vy-27,advance:f/vy,localGlyph:!0}}}}_y.loadGlyphRange=function(t,e,r,n,i){const a=256*e,s=a+255,o=n.transformRequest(n.normalizeGlyphsURL(r).replace("{fontstack}",t).replace("{range}",`${a}-${s}`),At.Glyphs);Pt(o,((t,e)=>{if(t)i(t);else if(e){const t={},r=function(t){return new Vm(t).readFields(Fm,{})}(e);for(const e of r.glyphs)t[e.id]=e;i(null,{glyphs:t,ascender:r.ascender,descender:r.descender});}}));},_y.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:r=8,cutoff:n=.25,fontFamily:i="sans-serif",fontWeight:a="normal",fontStyle:s="normal"}={}){this.buffer=e,this.cutoff=n,this.radius=r;const o=this.size=t+4*e,l=this._createCanvas(o),u=this.ctx=l.getContext("2d",{willReadFrequently:!0});u.font=`${s} ${a} ${t}px ${i}`,u.textBaseline="alphabetic",u.textAlign="left",u.fillStyle="black",this.gridOuter=new Float64Array(o*o),this.gridInner=new Float64Array(o*o),this.f=new Float64Array(o),this.z=new Float64Array(o+1),this.v=new Uint16Array(o);}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:r,actualBoundingBoxDescent:n,actualBoundingBoxLeft:i,actualBoundingBoxRight:a}=this.ctx.measureText(t),s=Math.ceil(r),o=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(a-i))),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),u=o+2*this.buffer,c=l+2*this.buffer,h=Math.max(u*c,0),p=new Uint8ClampedArray(h),f={data:p,width:u,height:c,glyphWidth:o,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:e};if(0===o||0===l)return f;const{ctx:d,buffer:m,gridInner:y,gridOuter:g}=this;d.clearRect(m,m,o,l),d.fillText(t,m,m+s);const x=d.getImageData(m,m,o,l);g.fill(yy,0,h),y.fill(0,0,h);for(let t=0;t0?t*t:0,y[n]=t<0?t*t:0;}}gy(g,0,0,u,c,u,this.f,this.v,this.z),gy(y,m,m,o,l,u,this.f,this.v,this.z);for(let t=0;tt+e[1]-e[0],d=h.reduce(f,0),m=p.reduce(f,0),y=o-d,x=l-m;let v=0,b=d,_=0,w=m,M=0,A=y,S=0,I=x;if(a.content&&n){const t=a.content;v=Ay(h,0,t[0]),_=Ay(p,0,t[1]),b=Ay(h,t[0],t[2]),w=Ay(p,t[1],t[3]),M=t[0]-v,S=t[1]-_,A=t[2]-t[0]-b,I=t[3]-t[1]-w;}const k=(n,i,o,l)=>{const h=Iy(n.stretch-v,b,u,t.left),p=ky(n.fixed-M,A,n.stretch,d),f=Iy(i.stretch-_,w,c,t.top),y=ky(i.fixed-S,I,i.stretch,m),x=Iy(o.stretch-v,b,u,t.left),k=ky(o.fixed-M,A,o.stretch,d),P=Iy(l.stretch-_,w,c,t.top),E=ky(l.fixed-S,I,l.stretch,m),z=new g(h,f),T=new g(x,f),B=new g(x,P),C=new g(h,P),R=new g(p/s,y/s),D=new g(k/s,E/s),V=e*Math.PI/180;if(V){const t=Math.sin(V),e=Math.cos(V),r=[e,-t,t,e];z._matMult(r),T._matMult(r),C._matMult(r),B._matMult(r);}const L=n.stretch+n.fixed,F=o.stretch+o.fixed,N=i.stretch+i.fixed,O=l.stretch+l.fixed,U=t.imageSecondary;return {tl:z,tr:T,bl:C,br:B,texPrimary:{x:a.paddedRect.x+wy+L,y:a.paddedRect.y+wy+N,w:F-L,h:O-N},texSecondary:U?{x:U.paddedRect.x+wy+L,y:U.paddedRect.y+wy+N,w:F-L,h:O-N}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:R,pixelOffsetBR:D,minFontScaleX:A/s/u,minFontScaleY:I/s/c,isSDF:r}};if(n&&(a.stretchX||a.stretchY)){const t=Sy(h,y,d),e=Sy(p,x,m);for(let r=0;ra)&&(a=e.x),(!t||e.y>s)&&(s=e.y);}const l=Math.min(a-n,s-i);let u=l/2;const c=new zr([],zy);if(0===l)return new g(n,i);for(let e=n;eh.d||!h.d)&&(h=n,r&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,p)),n.max-h.d<=e||(u=n.h/2,c.push(new Ty(n.p.x-u,n.p.y-u,u,t)),c.push(new Ty(n.p.x+u,n.p.y-u,u,t)),c.push(new Ty(n.p.x-u,n.p.y+u,u,t)),c.push(new Ty(n.p.x+u,n.p.y+u,u,t)),p+=4);}return r&&(console.log(`num probes: ${p}`),console.log(`best distance: ${h.d}`)),h.p}function zy(t,e){return e.max-t.max}class Ty{constructor(t,e,r,n){this.p=new g(t,e),this.h=r,this.d=function(t,e){let r=!1,n=1/0;for(let i=0;it.y!=o.y>t.y&&t.x<(o.x-i.x)*(t.y-i.y)/(o.y-i.y)+i.x&&(r=!r),n=Math.min(n,ql(t,i,o));}}return (r?1:-1)*Math.sqrt(n)}(this.p,n),this.max=this.d+this.h*Math.SQRT2;}}const By=Number.POSITIVE_INFINITY,Cy=Math.sqrt(2);function Ry(t,[e,r]){let n=0,i=0;if(r===By){e<0&&(e=0);const r=e/Cy;switch(t){case"top-right":case"top-left":i=r-7;break;case"bottom-right":case"bottom-left":i=7-r;break;case"bottom":i=7-e;break;case"top":i=e-7;}switch(t){case"top-right":case"bottom-right":n=-r;break;case"top-left":case"bottom-left":n=r;break;case"left":n=e;break;case"right":n=-e;}}else {switch(e=Math.abs(e),r=Math.abs(r),t){case"top-right":case"top-left":case"top":i=r-7;break;case"bottom-right":case"bottom-left":case"bottom":i=7-r;}switch(t){case"top-right":case"bottom-right":case"right":n=-e;break;case"top-left":case"bottom-left":case"left":n=e;}}return [n,i]}function Dy(t){switch(t){case"right":case"top-right":case"bottom-right":return "right";case"left":case"top-left":case"bottom-left":return "left"}return "center"}function Vy(t,e,r,n,i,a,s,o,l,u,c,h,p,f,d){let m=a.textMaxSize.evaluate(e,{},h);void 0===m&&(m=s);const y=t.layers[0].layout,g=y.get("icon-offset").evaluate(e,{},h),x=Oy(r.horizontal)||r.vertical,v="globe"===p.name,_=im,w=s/_,M=t.tilePixelRatio*m/_,A=(B=t.overscaling,t.zoom>18&&B>2&&(B>>=1),Math.max(Tr/(512*B),1)*y.get("symbol-spacing")),S=y.get("text-padding")*t.tilePixelRatio,I=y.get("icon-padding")*t.tilePixelRatio,k=b(y.get("text-max-angle")),P="map"===y.get("text-rotation-alignment")&&"point"!==y.get("symbol-placement"),E="map"===y.get("icon-rotation-alignment")&&"point"!==y.get("symbol-placement"),z=y.get("symbol-placement"),T=A/2;var B;const C=y.get("icon-text-fit").evaluate(e,{},h),R=y.get("icon-text-fit-padding").evaluate(e,{},h),D="none"!==C;let V;!1===t.hasAnyIconTextFit&&D&&(t.hasAnyIconTextFit=!0),n&&D&&(t.allowVerticalPlacement&&r.vertical&&(V=ry(n,r.vertical,C,R,g,w)),x&&(n=ry(n,x,C,R,g,w)));const L=(s,o,m)=>{if(o.x<0||o.x>=Tr||o.y<0||o.y>=Tr)return;let y=null;if(v){const{x:t,y:e,z:r}=p.projectTilePoint(o.x,o.y,m);y={anchor:new ny(t,e,r,0,void 0),up:p.upVector(m,o.x,o.y)};}!function(t,e,r,n,i,a,s,o,l,u,c,h,p,f,d,m,y,g,x,v,b,_,w,M,A,S,I){const k=t.addToLineVertexArray(e,n);let P,E,z,T,B,C,R,D=0,V=0,L=0,F=0,N=-1,O=-1;const U={};let q=ho("");const $=r?r.anchor:e,G="none"!==l.layout.get("icon-text-fit").evaluate(b,{},A);let Y=0,X=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[Y,X]=l.layout.get("text-offset").evaluate(b,{},A).map((t=>t*im)):(Y=l.layout.get("text-radial-offset").evaluate(b,{},A)*im,X=By),t.allowVerticalPlacement&&i.vertical){const t=i.vertical;if(d)C=jy(t),o&&(R=jy(o));else {const r=l.layout.get("text-rotate").evaluate(b,{},A)+90;z=Uy(u,$,e,c,h,p,t,f,r,m),o&&(T=Uy(u,$,e,c,h,p,o,g,r));}}if(a){const n=l.layout.get("icon-rotate").evaluate(b,{},A),i=My(a,n,w,G),s=o?My(o,n,w,G):void 0;E=Uy(u,$,e,c,h,p,a,g,n),D=4*i.length;const f=t.iconSizeData;let d=null;"source"===f.kind?(d=[am*l.layout.get("icon-size").evaluate(b,{},A)],d[0]>Fy&&j(`${t.layerIds[0]}: Value for "icon-size" is >= ${Ly}. Reduce your "icon-size".`)):"composite"===f.kind&&(d=[am*_.compositeIconSizes[0].evaluate(b,{},A),am*_.compositeIconSizes[1].evaluate(b,{},A)],(d[0]>Fy||d[1]>Fy)&&j(`${t.layerIds[0]}: Value for "icon-size" is >= ${Ly}. Reduce your "icon-size".`)),t.addSymbols(t.icon,i,d,v,x,b,!1,r,e,k.lineStartIndex,k.lineLength,-1,M,A,S,I),N=t.icon.placedSymbolArray.length-1,s&&(V=4*s.length,t.addSymbols(t.icon,s,d,v,x,b,jm.vertical,r,e,k.lineStartIndex,k.lineLength,-1,M,A,S,I),O=t.icon.placedSymbolArray.length-1);}for(const n in i.horizontal){const a=i.horizontal[n];P||(q=ho(a.text),d?B=jy(a):P=Uy(u,$,e,c,h,p,a,f,l.layout.get("text-rotate").evaluate(b,{},A),m));const o=1===a.positionedLines.length;if(L+=Ny(t,r,e,a,s,l,d,b,m,k,i.vertical?jm.horizontal:jm.horizontalOnly,o?Object.keys(i.horizontal):[n],U,N,_,M,A,S),o)break}i.vertical&&(F+=Ny(t,r,e,i.vertical,s,l,d,b,m,k,jm.vertical,["vertical"],U,O,_,M,A,S));let Z=-1;const K=(t,e)=>t?Math.max(t,e):e;Z=K(B,Z),Z=K(C,Z),Z=K(R,Z);const H=Z>-1?1:0;t.glyphOffsetArray.length>=65535&&j("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==b.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,b.sortKey),t.symbolInstances.emplaceBack(e.x,e.y,$.x,$.y,$.z,U.right>=0?U.right:-1,U.center>=0?U.center:-1,U.left>=0?U.left:-1,U.vertical>=0?U.vertical:-1,N,O,q,void 0!==P?P:t.collisionBoxArray.length,void 0!==P?P+1:t.collisionBoxArray.length,void 0!==z?z:t.collisionBoxArray.length,void 0!==z?z+1:t.collisionBoxArray.length,void 0!==E?E:t.collisionBoxArray.length,void 0!==E?E+1:t.collisionBoxArray.length,T||t.collisionBoxArray.length,T?T+1:t.collisionBoxArray.length,c,L,F,D,V,H,0,Y,X,Z,0,G?1:0);}(t,o,y,s,r,n,i,V,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,S,P,l,0,I,E,g,e,a,u,c,h,f,d);};if("line"===z)for(const i of hy(e.geometry,0,0,Tr,Tr)){const e=uy(i,A,k,r.vertical||x,n,_,M,t.overscaling,Tr);for(const r of e)x&&qy(t,x.text,T,r)||L(i,r,h);}else if("line-center"===z){for(const t of e.geometry)if(t.length>1){const e=ly(t,k,r.vertical||x,n,_,M);e&&L(t,e,h);}}else if("Polygon"===e.type)for(const t of nf(e.geometry,0)){const e=Ey(t,16);L(t[0],new ny(e.x,e.y,0,0,void 0),h);}else if("LineString"===e.type)for(const t of e.geometry)L(t,new ny(t[0].x,t[0].y,0,0,void 0),h);else if("Point"===e.type)for(const t of e.geometry)for(const e of t)L([e],new ny(e.x,e.y,0,0,void 0),h);}const Ly=255,Fy=Ly*am;function Ny(t,e,r,n,i,a,s,o,l,u,c,h,p,f,d,m,y,x){const v=function(t,e,r,n,i,a,s,o){const l=[];if(0===e.positionedLines.length)return l;const u=n.layout.get("text-rotate").evaluate(a,{})*Math.PI/180,c=function(t){const e=t[0],r=t[1],n=e*r;return n>0?[e,-r]:n<0?[-e,r]:0===e?[r,e]:[r,-e]}(r);let h=Math.abs(e.top-e.bottom);for(const t of e.positionedLines)h-=t.lineOffset;const p=e.positionedLines.length,f=h/p;let d=e.top-r[1];for(let t=0;tFy&&j(`${t.layerIds[0]}: Value for "text-size" is >= ${Ly}. Reduce your "text-size".`)):"composite"===b.kind&&(_=[am*d.compositeTextSizes[0].evaluate(o,{},y),am*d.compositeTextSizes[1].evaluate(o,{},y)],(_[0]>Fy||_[1]>Fy)&&j(`${t.layerIds[0]}: Value for "text-size" is >= ${Ly}. Reduce your "text-size".`)),t.addSymbols(t.text,v,_,l,s,o,c,e,r,u.lineStartIndex,u.lineLength,f,m,y,x,!1);for(const e of h)p[e]=t.text.placedSymbolArray.length-1;return 4*v.length}function Oy(t){for(const e in t)return t[e];return null}function Uy(t,e,r,n,i,a,s,o,l,u){let c=s.top,h=s.bottom,p=s.left,f=s.right;const d=s.collisionPadding;if(d&&(p-=d[0],c-=d[1],f+=d[2],h+=d[3]),l){const t=new g(p,c),e=new g(f,c),r=new g(p,h),n=new g(f,h),i=b(l);let a=new g(0,0);u&&(a=new g(u[0],u[1])),t._rotateAround(i,a),e._rotateAround(i,a),r._rotateAround(i,a),n._rotateAround(i,a),p=Math.min(t.x,e.x,r.x,n.x),f=Math.max(t.x,e.x,r.x,n.x),c=Math.min(t.y,e.y,r.y,n.y),h=Math.max(t.y,e.y,r.y,n.y);}return t.emplaceBack(e.x,e.y,e.z,r.x,r.y,p,c,f,h,o,n,i,a),t.length-1}function jy(t){t.collisionPadding&&(t.top-=t.collisionPadding[1],t.bottom+=t.collisionPadding[3]);const e=t.bottom-t.top;return e>0?Math.max(10,e):null}function qy(t,e,r,n){const i=t.compareText;if(e in i){const t=i[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])v&&(b(t,u,n,i,o,l),b(u,r,o,l,a,s));}b(h,p,n,a,i,a),b(p,f,i,a,i,s),b(f,d,i,s,n,s),b(d,h,n,s,n,a),m-=v,y-=v,g+=v,x+=v;const _=1/Math.max(g-m,x-y);return {scale:_,x:m*_,y:y*_,x2:g*_,y2:x*_,projection:e}}function Yy(t,{x:e,y:r},n=0){return new g(((e-n)*t.scale-t.x)*Tr,(r*t.scale-t.y)*Tr)}const Xy=t.a6.identity(new Float32Array(16));class Zy{constructor(t){this.spec=t,this.name=t.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7];}project(t,e){return {x:0,y:0,z:0}}unproject(t,e){return new tl(0,0)}projectTilePoint(t,e,r){return {x:t,y:e,z:0}}locationPoint(t,e,r=!0){return t._coordinatePoint(t.locationCoordinate(e),r)}pixelsPerMeter(t,e){return dl(1,t)*e}pixelSpaceConversion(t,e,r){return 1}farthestPixelDistance(t){return $y(t,t.pixelsPerMeter)}pointCoordinate(t,e,r,n){const i=t.horizonLineFromTop(!1),a=new g(e,Math.max(i,r));return t.rayIntersectionCoordinate(t.pointRayIntersection(a,n))}pointCoordinate3D(t,e,r){const n=new g(e,r);if(t.elevation)return t.elevation.pointCoordinate(n);{const e=this.pointCoordinate(t,n.x,n.y,0);return [e.x,e.y,e.z]}}isPointAboveHorizon(t,e){if(t.elevation)return !this.pointCoordinate3D(t,e.x,e.y);const r=t.horizonLineFromTop();return e.y0?e<-ng+r&&(e=-ng+r):e>ng-r&&(e=ng-r);const a=i/Math.pow(ig(e),n);let s=a*Math.sin(n*t),o=i-a*Math.cos(n*t);return s=.5*(s/Math.PI+.5),o=.5*(o/Math.PI+.5),{x:s,y:this.southernCenter?o:1-o,z:0}}unproject(t,e){t=(2*t-.5)*Math.PI,this.southernCenter&&(e=1-e),e=(2*(1-e)-.5)*Math.PI;const{n:r,f:n}=this,i=n-e,a=Math.sign(i),s=Math.sign(r)*Math.sqrt(t*t+i*i);let o=Math.atan2(t,Math.abs(i))*a;i*r<0&&(o-=Math.PI*Math.sign(t)*a);const l=I(_(o/r)+this.center[0],-180,180),u=I(_(2*Math.atan(Math.pow(n/s,1/r))-ng),-xl,xl);return new tl(l,this.southernCenter?-u:u)}}class sg extends Zy{constructor(t){super(t),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null;}project(t,e){return {x:pl(t),y:fl(e),z:0}}unproject(t,e){const r=ml(t),n=yl(e);return new tl(r,n)}}const og=b(xl);class lg extends Zy{project(t,e){const r=(e=b(e))*e,n=r*r;return {x:.5*((t=b(t))*(.8707-.131979*r+n*(n*(.003971*r-.001529*n)-.013791))/Math.PI+.5),y:1-.5*(e*(1.007226+r*(.015085+n*(.028874*r-.044475-.005916*n)))/Math.PI+1),z:0}}unproject(t,e){t=(2*t-.5)*Math.PI;let r=e=(2*(1-e)-1)*Math.PI,n=25,i=0,a=r*r;do{a=r*r;const t=a*a;i=(r*(1.007226+a*(.015085+t*(.028874*a-.044475-.005916*t)))-e)/(1.007226+a*(.045255+t*(.259866*a-.311325-.005916*11*t))),r=I(r-i,-og,og);}while(Math.abs(i)>1e-6&&--n>0);a=r*r;const s=I(_(t/(.8707+a*(a*(a*a*a*(.003971-.001529*a)-.013791)-.131979))),-180,180),o=_(r);return new tl(s,o)}}const ug=b(xl);class cg extends Zy{project(t,e){e=b(e),t=b(t);const r=Math.cos(e),n=2/Math.PI,i=Math.acos(r*Math.cos(t/2)),a=Math.sin(i)/i,s=.5*(t*n+2*r*Math.sin(t/2)/a)||0,o=.5*(e+Math.sin(e)/a)||0;return {x:.5*(s/Math.PI+.5),y:1-.5*(o/Math.PI+1),z:0}}unproject(t,e){let r=t=(2*t-.5)*Math.PI,n=e=(2*(1-e)-1)*Math.PI,i=25;const a=1e-6;let s=0,o=0;do{const i=Math.cos(n),a=Math.sin(n),l=2*a*i,u=a*a,c=i*i,h=Math.cos(r/2),p=Math.sin(r/2),f=2*h*p,d=p*p,m=1-c*h*h,y=m?1/m:0,g=m?Math.acos(i*h)*Math.sqrt(1/m):0,x=.5*(2*g*i*p+2*r/Math.PI)-t,v=.5*(g*a+n)-e,b=.5*y*(c*d+g*i*h*u)+1/Math.PI,_=y*(f*l/4-g*a*p),w=.125*y*(l*p-g*a*c*f),M=.5*y*(u*h+g*d*i)+.5,A=_*w-M*b;s=(v*_-x*M)/A,o=(x*w-v*b)/A,r=I(r-s,-Math.PI,Math.PI),n=I(n-o,-ug,ug);}while((Math.abs(s)>a||Math.abs(o)>a)&&--i>0);return new tl(_(r),_(n))}}class hg extends Zy{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(b(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0;}project(t,e){const{scale:r,cosPhi:n}=this;return {x:b(t)*n*r+.5,y:-Math.sin(b(e))/n*r+.5,z:0}}unproject(t,e){const{scale:r,cosPhi:n}=this,i=-(e-.5)/r,a=I(_((t-.5)/r)/n,-180,180),s=Math.asin(I(i*n,-1,1)),o=I(_(s),-xl,xl);return new tl(a,o)}}class pg extends sg{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5];}projectTilePoint(e,r,n){const i=Zh(e,r,n),a=Wh(jh(n));return t.N.transformMat4(i,i,a),{x:i[0],y:i[1],z:i[2]}}locationPoint(e,r){const n=Wo(r.lat,r.lng),i=t.N.normalize([],n),a=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(r),e._centerAltitude):e._centerAltitude,s=dl(1,0)*Tr*a;t.N.scaleAndAdd(n,n,i,s);const o=t.a6.identity(new Float64Array(16));return t.a6.multiply(o,e.pixelMatrix,e.globeMatrix),t.N.transformMat4(n,n,o),new g(n[0],n[1])}pixelsPerMeter(t,e){return dl(1,0)*e}pixelSpaceConversion(t,e,r){const n=dl(1,t)*e,i=ue(dl(1,45)*e,n,r);return this.pixelsPerMeter(t,e)/i}createTileMatrix(e,r,n){const i=Jh(jh(n.canonical));return t.a6.multiply(new Float64Array(16),e.globeMatrix,i)}createInversionMatrix(e,r){const{center:n}=e,i=Wh(jh(r));return t.a6.rotateY(i,i,b(n.lng)),t.a6.rotateX(i,i,b(n.lat)),t.a6.scale(i,i,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(i)}pointCoordinate(t,e,r,n){return Nh(t,e,r,!0)||new Ml(0,0)}pointCoordinate3D(t,e,r){const n=this.pointCoordinate(t,e,r,0);return [n.x,n.y,n.z]}isPointAboveHorizon(t,e){return !Nh(t,e.x,e.y,!1)}farthestPixelDistance(e){const r=function(e,r){const n=e.cameraToCenterDistance,i=e._centerAltitude*r,a=e._camera,s=e._camera.forward(),o=t.N.add([],t.N.scale([],s,-n),[0,0,i]),l=e.worldSize/(2*Math.PI),u=[0,0,-l],c=e.width/e.height,h=Math.tan(e.fovAboveCenter),p=t.N.scale([],a.up(),h),f=t.N.scale([],a.right(),h*c),d=t.N.normalize([],t.N.add([],t.N.add([],s,p),f)),m=[];let y;if(new Sh(o,d).closestPointOnSphere(u,l,m)){const r=t.N.add([],m,u),n=t.N.sub([],r,o);y=Math.cos(e.fovAboveCenter)*t.N.length(n);}else {const e=t.N.sub([],o,u),r=t.N.sub([],u,o);t.N.normalize(r,r);const n=t.N.length(e)-l;y=Math.sqrt(n*(n+2*l));const i=Math.acos(y/(l+n))-Math.acos(t.N.dot(s,r));y*=Math.cos(i);}return 1.01*y}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),n=rp(e.zoom);if(n>0){const t=$y(e,dl(1,e.center.lat)*e.worldSize),i=e.worldSize/(2*Math.PI),a=Math.max(e.width,e.height)/e.worldSize*Math.PI;return ue(r,t+i*(1-Math.cos(a)),Math.pow(n,10))}return r}upVector(t,e,r){return Zh(e,r,t,1)}upVectorScale(t){return {metersToTile:Lh(Kh(jh(t)))}}}function fg(t){const e=t.parallels,r=!!e&&Math.abs(e[0]+e[1])<.01;switch(t.name){case"mercator":return new sg(t);case"equirectangular":return new rg(t);case"naturalEarth":return new lg(t);case"equalEarth":return new eg(t);case"winkelTripel":return new cg(t);case"albers":return r?new hg(t):new Ky(t);case"lambertConformalConic":return r?new hg(t):new ag(t);case"globe":return new pg(t)}throw new Error(`Invalid projection name: ${t.name}`)}const dg=zf.types,mg=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function yg(t,e,r,n,i,a,s,o,l,u,c,h,p){const f=o?Math.min(Fy,Math.round(o[0])):0,d=o?Math.min(Fy,Math.round(o[1])):0;t.emplaceBack(e,r,Math.round(32*n),Math.round(32*i),a,s,(f<<1)+(l?1:0),d,16*u,16*c,256*h,256*p);}function gg(t,e,r){t.emplaceBack(e,r);}function xg(t,e,r,n,i,a,s){t.emplaceBack(e,r,n,i,a,s);}function vg(t,e,r,n,i){t.emplaceBack(e,r,n,i),t.emplaceBack(e,r,n,i),t.emplaceBack(e,r,n,i),t.emplaceBack(e,r,n,i);}function bg(t){for(const e of t.sections)if(ma(e.text))return !0;return !1}class _g{constructor(t){this.layoutVertexArray=new _s,this.indexArray=new Es,this.programConfigurations=t,this.segments=new eo,this.dynamicLayoutVertexArray=new gs,this.opacityVertexArray=new Ms,this.placedSymbolArray=new Gs,this.iconTransitioningVertexArray=new As,this.globeExtVertexArray=new ws,this.zOffsetVertexArray=new Bs;}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length&&0===this.iconTransitioningVertexArray.length}upload(t,e,r,n,i){this.isEmpty()||(r&&(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Kd.members),this.indexBuffer=t.createIndexBuffer(this.indexArray,e),this.dynamicLayoutVertexBuffer=t.createVertexBuffer(this.dynamicLayoutVertexArray,Wd.members,!0),this.opacityVertexBuffer=t.createVertexBuffer(this.opacityVertexArray,mg,!0),this.iconTransitioningVertexArray.length>0&&(this.iconTransitioningVertexBuffer=t.createVertexBuffer(this.iconTransitioningVertexArray,Qd.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,Hd.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||i)&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,Jd.members,!0)),this.opacityVertexBuffer.itemSize=1),(r||n)&&this.programConfigurations.upload(t));}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy());}}ra(_g,"SymbolBuffers");class wg{constructor(t,e,r){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new r,this.segments=new eo,this.collisionVertexArray=new Ps,this.collisionVertexArrayExt=new gs;}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,tm.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,em.members,!0);}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy());}}ra(wg,"CollisionBuffers");class Mg{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=t.a6.identity([]),this.placementViewportMatrix=t.a6.identity([]);const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=sm(this.zoom,r["text-size"]),this.iconSizeData=sm(this.zoom,r["icon-size"]);const n=this.layers[0].layout,i=n.get("symbol-sort-key"),a=n.get("symbol-z-order");this.canOverlap=n.get("text-allow-overlap")||n.get("icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==a&&void 0!==i.constantOr(1),this.sortFeaturesByY=("viewport-y"===a||"auto"===a&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get("text-writing-mode").map((t=>jm[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=e.sourceID,this.projection=e.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=n.get("symbol-z-elevate");}createArrays(){this.text=new _g(new Vo(this.layers,this.zoom,(t=>/^text/.test(t)))),this.icon=new _g(new Vo(this.layers,this.zoom,(t=>/^icon/.test(t)))),this.glyphOffsetArray=new Zs,this.lineVertexArray=new Ks,this.symbolInstances=new Xs;}calculateGlyphDependencies(t,e,r,n,i){for(let r=0;r0)&&("constant"!==l.value.kind||l.value.value.length>0),p="constant"!==c.value.kind||!!c.value.value||Object.keys(c.parameters).length>0,f=s.get("symbol-sort-key");if(this.features=[],!h&&!p)return;const d=r.iconDependencies,m=r.glyphDependencies,y=r.availableImages,g=new Pa(this.zoom);for(const{feature:r,id:u,index:c,sourceLayerIndex:x}of e){const e=a._featureFilter.needGeometry,v=Bl(r,e);if(!a._featureFilter.filter(g,v,n))continue;if(e||(v.geometry=Tl(r,n,i)),o&&1!==r.type&&n.z<=5){const e=v.geometry,r=.98078528056,i=(e,i)=>{const a=Zh(e.x,e.y,n,1),s=Zh(i.x,i.y,n,1);return t.N.dot(a,s)=0;for(const r of b.sections)if(r.image)d[r.image.namePrimary]=!0;else {const n=la(b.toString()),i=r.fontStack||t,a=m[i]=m[i]||{};this.calculateGlyphDependencies(r.text,a,e,this.allowVerticalPlacement,n);}}}"line"===s.get("symbol-placement")&&(this.features=function(t){const e={},r={},n=[];let i=0;function a(e){n.push(t[e]),i++;}function s(t,e,i){const a=r[t];return delete r[t],r[e]=a,n[a].geometry[0].pop(),n[a].geometry[0]=n[a].geometry[0].concat(i[0]),a}function o(t,r,i){const a=e[r];return delete e[r],e[t]=a,n[a].geometry[0].shift(),n[a].geometry[0]=i[0].concat(n[a].geometry[0]),a}function l(t,e,r){const n=r?e[0][e[0].length-1]:e[0][0];return `${t}:${n.x}:${n.y}`}for(let u=0;ut.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey));}update(t,e,r,n,i){const a=0!==Object.keys(t).length;if(a&&!this.stateDependentLayers.length)return;const s=a?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(t,e,s,r,n,i),this.icon.programConfigurations.updatePaintArrays(t,e,s,r,n,i);}updateZOffset(){const t=(t,e,n)=>{r+=e,r>t.length&&t.resize(r);for(let i=-e;i<0;i++)t.emplace(i+r,n);},e=(t,e,r)=>{n+=e,n>t.length&&t.resize(n);for(let i=-e;i<0;i++)t.emplace(i+n,r);};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let r=0,n=0;for(let r=0;r0;if((i>0||a>0)&&(t(this.text.zOffsetVertexArray,i,o),t(this.text.zOffsetVertexArray,a,o)),l){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:r}=n;t>=0&&e(this.icon.zOffsetVertexArray,s,o),r>=0&&e(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,o);}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray);}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return !this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.uploaded=!0;}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy();}getProjection(){return this.projectionInstance||(this.projectionInstance=fg(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData();}addToLineVertexArray(t,e){const r=this.lineVertexArray.length;if(void 0!==t.segment)for(const{x:t,y:r}of e)this.lineVertexArray.emplaceBack(t,r);return {lineStartIndex:r,lineLength:this.lineVertexArray.length-r}}addSymbols(t,e,r,n,i,a,s,o,l,u,c,h,p,f,d,m){const y=t.indexArray,g=t.layoutVertexArray,x=t.globeExtVertexArray,v=t.segments.prepareSegment(4*e.length,g,y,this.canOverlap?a.sortKey:void 0),b=this.glyphOffsetArray.length,_=v.vertexLength,w=this.allowVerticalPlacement&&s===jm.vertical?Math.PI/2:0,M=a.text&&a.text.sections;for(let n=0;n=0?e.rightJustifiedTextSymbolIndex:e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.leftJustifiedTextSymbolIndex>=0?e.leftJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex>=0?e.verticalPlacedTextSymbolIndex:n),a=om(this.textSizeData,t,i)/im;return this.tilePixelRatio*a}getSymbolInstanceIconSize(t,e,r){const n=this.icon.placedSymbolArray.get(r),i=om(this.iconSizeData,t,n);return this.tilePixelRatio*i}_commitDebugCollisionVertexUpdate(t,e,r,n){t.emplaceBack(e,-r,-r,n),t.emplaceBack(e,r,-r,n),t.emplaceBack(e,r,r,n),t.emplaceBack(e,-r,r,n);}_updateTextDebugCollisionBoxes(t,e,r,n,i,a){for(let s=n;s0}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}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(t,e){const r=t.placedSymbolArray.get(e),n=r.vertexStartIndex+4*r.numGlyphs;for(let e=r.vertexStartIndex;en[t]-n[e]||i[e]-i[t])),a}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let t=0;tthis.symbolInstances.get(e).zOffset-this.symbolInstances.get(t).zOffset))}addToSortKeyRanges(t,e){const r=this.sortKeyRanges[this.sortKeyRanges.length-1];r&&r.sortKey===e?r.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1});}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex);const{rightJustifiedTextSymbolIndex:r,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:i,verticalPlacedTextSymbolIndex:a,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:o}=e;r>=0&&this.addIndicesForPlacedSymbol(this.text,r),n>=0&&n!==r&&this.addIndicesForPlacedSymbol(this.text,n),i>=0&&i!==n&&i!==r&&this.addIndicesForPlacedSymbol(this.text,i),a>=0&&this.addIndicesForPlacedSymbol(this.text,a),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),o>=0&&this.addIndicesForPlacedSymbol(this.icon,o);}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray);}}}ra(Mg,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Mg.addDynamicAttributes=vg;const Ag=new Oa({"symbol-placement":new La(qa.layout_symbol["symbol-placement"]),"symbol-spacing":new La(qa.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new La(qa.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Fa(qa.layout_symbol["symbol-sort-key"]),"symbol-z-order":new La(qa.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new La(qa.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new La(qa.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new La(qa.layout_symbol["icon-ignore-placement"]),"icon-optional":new La(qa.layout_symbol["icon-optional"]),"icon-rotation-alignment":new La(qa.layout_symbol["icon-rotation-alignment"]),"icon-size":new Fa(qa.layout_symbol["icon-size"]),"icon-text-fit":new Fa(qa.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Fa(qa.layout_symbol["icon-text-fit-padding"]),"icon-image":new Fa(qa.layout_symbol["icon-image"]),"icon-rotate":new Fa(qa.layout_symbol["icon-rotate"]),"icon-padding":new La(qa.layout_symbol["icon-padding"]),"icon-keep-upright":new La(qa.layout_symbol["icon-keep-upright"]),"icon-offset":new Fa(qa.layout_symbol["icon-offset"]),"icon-anchor":new Fa(qa.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new La(qa.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new La(qa.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new La(qa.layout_symbol["text-rotation-alignment"]),"text-field":new Fa(qa.layout_symbol["text-field"]),"text-font":new Fa(qa.layout_symbol["text-font"]),"text-size":new Fa(qa.layout_symbol["text-size"]),"text-max-width":new Fa(qa.layout_symbol["text-max-width"]),"text-line-height":new Fa(qa.layout_symbol["text-line-height"]),"text-letter-spacing":new Fa(qa.layout_symbol["text-letter-spacing"]),"text-justify":new Fa(qa.layout_symbol["text-justify"]),"text-radial-offset":new Fa(qa.layout_symbol["text-radial-offset"]),"text-variable-anchor":new La(qa.layout_symbol["text-variable-anchor"]),"text-anchor":new Fa(qa.layout_symbol["text-anchor"]),"text-max-angle":new La(qa.layout_symbol["text-max-angle"]),"text-writing-mode":new La(qa.layout_symbol["text-writing-mode"]),"text-rotate":new Fa(qa.layout_symbol["text-rotate"]),"text-padding":new La(qa.layout_symbol["text-padding"]),"text-keep-upright":new La(qa.layout_symbol["text-keep-upright"]),"text-transform":new Fa(qa.layout_symbol["text-transform"]),"text-offset":new Fa(qa.layout_symbol["text-offset"]),"text-allow-overlap":new La(qa.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new La(qa.layout_symbol["text-ignore-placement"]),"text-optional":new La(qa.layout_symbol["text-optional"]),visibility:new La(qa.layout_symbol.visibility)});var Sg={paint:new Oa({"icon-opacity":new Fa(qa.paint_symbol["icon-opacity"]),"icon-emissive-strength":new Fa(qa.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new Fa(qa.paint_symbol["text-emissive-strength"]),"icon-color":new Fa(qa.paint_symbol["icon-color"]),"icon-halo-color":new Fa(qa.paint_symbol["icon-halo-color"]),"icon-halo-width":new Fa(qa.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Fa(qa.paint_symbol["icon-halo-blur"]),"icon-translate":new La(qa.paint_symbol["icon-translate"]),"icon-translate-anchor":new La(qa.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new Fa(qa.paint_symbol["icon-image-cross-fade"]),"text-opacity":new Fa(qa.paint_symbol["text-opacity"]),"text-color":new Fa(qa.paint_symbol["text-color"],{runtimeType:_e,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new Fa(qa.paint_symbol["text-halo-color"]),"text-halo-width":new Fa(qa.paint_symbol["text-halo-width"]),"text-halo-blur":new Fa(qa.paint_symbol["text-halo-blur"]),"text-translate":new La(qa.paint_symbol["text-translate"]),"text-translate-anchor":new La(qa.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new La(qa.paint_symbol["icon-color-saturation"])}),layout:Ag};class Ig{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:ge,this.defaultValue=t;}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression);}outputDefined(){return !1}serialize(){return null}}ra(Ig,"FormatSectionOverride",{omit:["defaultValue"]});class kg extends ss{constructor(t,e,r){super(t,Sg,e,r);}recalculate(t,e){super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const r=this.layout.get("text-writing-mode");if(r){const t=[];for(const e of r)t.indexOf(e)<0&&t.push(e);this.layout._values["text-writing-mode"]=t;}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides();}getValueAndResolveTokens(t,e,r,n){const i=this.layout.get(t).evaluate(e,{},r,n),a=this._unevaluatedLayout._values[t];return a.isDataDriven()||$i(a.value)||!i?i:function(t,e){return e.replace(/{([^{}]+)}/g,((e,r)=>r in t?String(t[r]):""))}(e.properties,i)}createBucket(t){return new Mg(t)}queryRadius(){return 0}queryIntersectsFeature(){return !1}_setPaintOverrides(){for(const t of Sg.paint.overridableProperties){if(!kg.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),r=new Ig(e),n=new qi(r,e.property.specification,this.scope,this.options);let i=null;i="constant"===e.value.kind||"source"===e.value.kind?new Yi("source",n):new Xi("composite",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new Da(e.property,i,e.parameters);}}_handleOverridablePaintPropertyUpdate(t,e,r){return !(!this.layout||e.isDataDriven()||r.isDataDriven())&&kg.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const r=t.get("text-field"),n=Sg.paint.properties[e];let i=!1;const a=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(i=!0)};if("constant"===r.value.kind&&r.value.value instanceof De)a(r.value.value.sections);else if("source"===r.value.kind){const t=e=>{i||(e instanceof je&&Ne(e.value)===Se?a(e.value.sections):e instanceof Xe?a(e.sections):e.eachChild(t));},e=r.value;e._styleExpression&&t(e._styleExpression.expression);}return i}getProgramIds(){const t=0!==this.paint.get("icon-opacity").constantOr(1),e=0!==this.paint.get("text-opacity").constantOr(1),r=[];return t&&r.push("symbolIcon"),e&&r.push("symbolSDF"),r}getDefaultProgramParams(t,e){return {config:new Do(this,e),overrideFog:!1}}}const Pg=new Oa({visibility:new La(qa.layout_background.visibility)});var Eg={paint:new Oa({"background-color":new La(qa.paint_background["background-color"]),"background-pattern":new La(qa.paint_background["background-pattern"]),"background-opacity":new La(qa.paint_background["background-opacity"]),"background-emissive-strength":new La(qa.paint_background["background-emissive-strength"])}),layout:Pg};const zg=new Oa({visibility:new La(qa.layout_raster.visibility)});var Tg={paint:new Oa({"raster-opacity":new La(qa.paint_raster["raster-opacity"]),"raster-color":new Na(qa.paint_raster["raster-color"]),"raster-color-mix":new La(qa.paint_raster["raster-color-mix"]),"raster-color-range":new La(qa.paint_raster["raster-color-range"]),"raster-hue-rotate":new La(qa.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new La(qa.paint_raster["raster-brightness-min"]),"raster-brightness-max":new La(qa.paint_raster["raster-brightness-max"]),"raster-saturation":new La(qa.paint_raster["raster-saturation"]),"raster-contrast":new La(qa.paint_raster["raster-contrast"]),"raster-resampling":new La(qa.paint_raster["raster-resampling"]),"raster-fade-duration":new La(qa.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new La(qa.paint_raster["raster-emissive-strength"]),"raster-array-band":new La(qa.paint_raster["raster-array-band"]),"raster-elevation":new La(qa.paint_raster["raster-elevation"])}),layout:zg},Bg=cs([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class Cg{constructor(t,e,r,n){this.context=t,this.format=r,this.texture=t.gl.createTexture(),this.update(e,n);}update(t,e,r){const{width:n,height:i}=t,{context:a}=this,{gl:s}=a;if(s.bindTexture(s.TEXTURE_2D,this.texture),a.pixelStoreUnpackFlipY.set(!1),a.pixelStoreUnpack.set(1),a.pixelStoreUnpackPremultiplyAlpha.set(this.format===s.RGBA&&(!e||!1!==e.premultiply)),r||this.size&&this.size[0]===n&&this.size[1]===i){const{x:e,y:a}=r||{x:0,y:0};if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap)s.texSubImage2D(s.TEXTURE_2D,0,e,a,s.RGBA,s.UNSIGNED_BYTE,t);else {let r=this.format,o=s.UNSIGNED_BYTE;this.format===s.R32F&&(r=s.RED,o=s.FLOAT),s.texSubImage2D(s.TEXTURE_2D,0,e,a,n,i,r,o,t.data);}}else if(this.size=[n,i],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap){let e=this.format;this.format===s.R8&&(e=s.RED),s.texImage2D(s.TEXTURE_2D,0,this.format,e,s.UNSIGNED_BYTE,t);}else {let e=this.format,r=this.format,a=s.UNSIGNED_BYTE;this.format===s.DEPTH_COMPONENT&&(e=s.DEPTH_COMPONENT16,a=s.UNSIGNED_SHORT),this.format===s.R8&&(r=s.RED),this.format===s.R32F&&(a=s.FLOAT,r=s.RED),s.texImage2D(s.TEXTURE_2D,0,e,n,i,0,r,a,t.data);}this.useMipmap=Boolean(e&&e.useMipmap),this.useMipmap&&s.generateMipmap(s.TEXTURE_2D);}bind(t,e,r=!1){const{context:n}=this,{gl:i}=n;i.bindTexture(i.TEXTURE_2D,this.texture),t!==this.minFilter&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,this.useMipmap&&!r?t===i.NEAREST?i.NEAREST_MIPMAP_NEAREST:i.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),e!==this.wrapS&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,e),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,e),this.wrapS=e);}bindExtraParam(t,e,r,n){const{context:i}=this,{gl:a}=i;a.bindTexture(a.TEXTURE_2D,this.texture),e!==this.magFilter&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,e),this.magFilter=e),t!==this.minFilter&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,this.useMipmap?t===a.NEAREST?a.NEAREST_MIPMAP_NEAREST:a.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),r!==this.wrapS&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,r),this.wrapS=r),n!==this.wrapT&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,n),this.wrapT=n);}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null;}}class Rg{constructor(t,e){this.context=t,this.texture=e;}bind(t,e){const{context:r}=this,{gl:n}=r;n.bindTexture(n.TEXTURE_2D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,e),this.wrapS=e);}}function Dg(e,r,n,i,a,s,o,l){const u=[e,r,1,n,i,1,a,s,1],c=[o,l,1],h=t.co.adjoint([],u),[p,f,d]=t.N.transformMat3(c,c,h);return t.co.multiply(u,u,[p,0,0,0,f,0,0,0,d])}function Vg(e,r,n,i,a,s,o,l){const u=function(e,r,n,i,a,s,o,l){const u=Dg(0,0,1,0,1,1,0,1),c=Dg(e,r,n,i,a,s,o,l),h=t.co.adjoint([],u);return t.co.multiply(c,c,h)}(e,r,n,i,a,s,o,l);return [u[2]/u[8]/Tr,u[5]/u[8]/Tr]}function Lg(t){return [t[0],Math.min(Math.max(t[1],-xl),xl)]}class Fg extends ee{constructor(t,e,r,n){super(),this.id=t,this.dispatcher=r,this.coordinates=e.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(n),this.options=e,this._dirty=!1;}load(t,e){if(this._loaded=e||!1,this.fire(new Qt("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();this._imageRequest=Ct(this.map._requestManager.transformRequest(this.url,At.Image),((e,r)=>{this._imageRequest=null,this._loaded=!0,e?this.fire(new te(e)):r&&(this.image=r instanceof HTMLImageElement?st.getImageData(r):r,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),this._finishLoading());}));}loaded(){return this._loaded}updateImage(t){return t.url?(this._imageRequest&&t.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=t.url,this.load(t.coordinates,this._loaded),this):this}setTexture(t){if(!(t.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new Rg(this.map.painter.context,t.handle),this.width=t.dimensions[0],this.height=t.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Qt("data",{dataType:"source",sourceDataType:"metadata"})));}onAdd(t){this.map=t,this.load();}onRemove(){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Rg||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy());}setCoordinates(t){if(this.coordinates=t,this._boundsArray=void 0,this._unsupportedCoords=!1,!t.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let e=t[0][1],r=t[0][1];for(const n of t)n[1]>r&&(r=n[1]),n[1]xl?this.onNorthPole=!0:n<-xl&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const e=t.map(Ml.fromLngLat);this.tileID=function(t){let e=1/0,r=1/0,n=-1/0,i=-1/0;for(const a of t)e=Math.min(e,a.x),r=Math.min(r,a.y),n=Math.max(n,a.x),i=Math.max(i,a.y);const a=Math.max(n-e,i-r),s=Math.max(0,Math.floor(-Math.log(a)/Math.LN2)),o=Math.pow(2,s);let l=Math.floor((e+n)/2*o);return l>1&&(l-=1),new il(s,l,Math.floor((r+i)/2*o))}(e),this.minzoom=this.maxzoom=this.tileID.z;}return this.fire(new Qt("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1;}_prepareData(e){for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture);}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const r=Gy(new il(0,0,0),this.map.transform.projection),n=[r.projection.project(this.coordinates[0][0],this.coordinates[0][1]),r.projection.project(this.coordinates[1][0],this.coordinates[1][1]),r.projection.project(this.coordinates[2][0],this.coordinates[2][1]),r.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(t){const e=t[1].x-t[0].x,r=t[1].y-t[0].y,n=t[2].x-t[1].x,i=t[2].y-t[1].y,a=t[3].x-t[2].x,s=t[3].y-t[2].y,o=t[0].x-t[3].x,l=t[0].y-t[3].y,u=e*i-n*r,c=n*s-a*i,h=a*l-o*s,p=o*r-e*l;return u>0&&c>0&&h>0&&p>0||u<0&&c<0&&h<0&&p<0}(n))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);const i=Gy(this.tileID,this.map.transform.projection),[a,s,o,l]=this.coordinates.map((t=>{const e=i.projection.project(t[0],t[1]);return Yy(i,e)._round()}));this.perspectiveTransform=Vg(a.x,a.y,s.x,s.y,o.x,o.y,l.x,l.y);const u=this._boundsArray=new ds;u.emplaceBack(a.x,a.y,0,0),u.emplaceBack(s.x,s.y,Tr,0),u.emplaceBack(l.x,l.y,0,Tr),u.emplaceBack(o.x,o.y,Tr,Tr),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=e.createVertexBuffer(u,Bg.members),this.boundsSegments=eo.simpleSegment(0,0,4,2);const c=[],h=[Lg((p=this.coordinates)[0]),Lg(p[1]),Lg(p[2]),Lg(p[3])];var p;const[f,d,m,y]=function(t){let e=t[0][0],r=e,n=t[0][1],i=n;for(let a=1;ar&&(r=t[a][0]),t[a][1]i&&(i=t[a][1]);return [e,n,r-e,i-n]}(h);{const i=new ds,[a,s,o,l]=function(t){let e=t[0].x,r=e,n=t[0].y,i=n;for(let a=1;ar&&(r=t[a].x),t[a].yi&&(i=t[a].y);return [e,n,r-e,i-n]}(n),u=t=>[(t.x-a)/o,(t.y-s)/l],[h,p,g,x]=n.map(u),v=function(e,r,n,i,a,s,o,l){const u=Dg(0,0,1,0,1,1,0,1),c=Dg(e,r,n,i,a,s,o,l),h=t.co.adjoint([],c);return t.co.multiply(u,u,h)}(h[0],h[1],p[0],p[1],g[0],g[1],x[0],x[1]);this.elevatedGlobePerspectiveTransform=Vg(h[0],h[1],p[0],p[1],g[0],g[1],x[0],x[1]);const b=(e,r)=>{c.push(e.lng);const n=Math.round((e.lng-f)/m*Tr),a=Math.round((e.lat-d)/y*Tr),s=u(r),o=t.N.transformMat3([],[s[0],s[1],1],v),l=Math.round(o[0]/o[2]*Tr),h=Math.round(o[1]/o[2]*Tr);i.emplaceBack(n,a,l,h);},_=n[3].x-n[0].x,w=n[3].y-n[0].y,M=n[2].x-n[1].x,A=n[2].y-n[1].y;for(let t=0;t<65;t++){const e=t/64,i=[n[0].x+e*_,n[0].y+e*w],a=[n[1].x+e*M,n[1].y+e*A],s=a[0]-i[0],o=a[1]-i[1];for(let t=0;t<65;t++){const e=t/64,n={x:i[0]+s*e,y:i[1]+o*e,z:0};b(r.projection.unproject(n.x,n.y),n);}}this.elevatedGlobeVertexBuffer=e.createVertexBuffer(i,Bg.members);}{this.maxLongitudeTriangleSize=0;let t=[],r=new Es;const n=(e,n,i)=>{r.emplaceBack(e,n,i);const a=c[e],s=c[n],o=c[i],l=Math.min(Math.min(a,s),o),u=Math.max(Math.max(a,s),o)-l;u>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=u),t.push(l+u/2);};for(let t=0;t<64;t++)for(let e=0;e<64;e++){const r=65*t+e,i=r+1,a=r+65,s=a+1;n(r,a,i),n(i,a,s);}[t,r]=function(t,e){const r=Array.from({length:t.length},((t,e)=>e));r.sort(((e,r)=>t[e]-t[r]));const n=[],i=new Es;for(let a=0;at+360*Math.round((e-t)/360))(t+180,r[0]);const i=new eo,a=(t,r)=>{i.segments.push({vertexOffset:0,primitiveOffset:t,vertexLength:e.segments[0].vertexLength,primitiveLength:r,sortKey:void 0,vaos:{}});},s=.51*this.maxLongitudeTriangleSize;if(Math.abs(r[0]-n)<=s){const t=it(r,0,r.length,n+s);return t===r.length||a(t,nt(r,t+1,r.length,n+360-s)-t),i}n{this.colorRampTexture&&this.colorRampTexture.destroy(),this.transformFeedbackObject&&t.painter.context.gl.deleteTransformFeedback(this.transformFeedbackObject),this.tileFramebuffer&&this.tileFramebuffer.destroy();},this.lastInvalidatedAt=st.now();}hasColorMap(){return !!this._transitionablePaint._values["raster-particle-color"].value.value}getProgramIds(){return ["rasterParticle"]}hasOffscreenPass(){return "none"!==this.visibility}isLayerDraped(t){return !1}_handleSpecialPaintPropertyUpdate(t){"raster-particle-color"!==t&&"raster-particle-max-speed"!==t||(this._updateColorRamp(),this._invalidateAnimationState()),"raster-particle-count"===t&&this._invalidateAnimationState();}_updateColorRamp(){if(!this.hasColorMap())return;const t=this._transitionablePaint._values["raster-particle-color"].value.expression,e=this._transitionablePaint._values["raster-particle-max-speed"].value.expression.evaluate({zoom:0});this.colorRamp=Ap({expression:t,evaluationKey:"rasterParticleSpeed",image:this.colorRamp,clips:[{start:0,end:e}],resolution:256}),this.colorRampTexture=null;}_invalidateAnimationState(){this.lastInvalidatedAt=st.now();}}class $g extends ss{constructor(t,e){super(t,{},e),this.implementation=t,t.slot&&(this.slot=t.slot);}is3D(){return "3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}isLayerDraped(t){return void 0!==this.implementation.renderToTile}shouldRedrape(){return !!this.implementation.shouldRerenderTiles&&this.implementation.shouldRerenderTiles()}recalculate(){}updateTransitions(){}hasTransition(){return !1}serialize(){}onAdd(t){this.implementation.onAdd&&this.implementation.onAdd(t,t.painter.context.gl);}onRemove(t){this.implementation.onRemove&&this.implementation.onRemove(t,t.painter.context.gl);}}const Gg=new Oa({visibility:new La(qa.layout_sky.visibility)});var Yg={paint:new Oa({"sky-type":new La(qa.paint_sky["sky-type"]),"sky-atmosphere-sun":new La(qa.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new La(qa.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new La(qa.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new La(qa.paint_sky["sky-gradient-radius"]),"sky-gradient":new Na(qa.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new La(qa.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new La(qa.paint_sky["sky-atmosphere-color"]),"sky-opacity":new La(qa.paint_sky["sky-opacity"])}),layout:Gg};function Xg(e,r,n){const i=[0,0,1],a=t.bi.identity([]);return t.bi.rotateY(a,a,n?-b(e)+Math.PI:b(e)),t.bi.rotateX(a,a,-b(r)),t.N.transformQuat(i,i,a),t.N.normalize(i,i)}var Zg={paint:new Oa({})};function Kg(e,r){const n=Wg(e.projection,e.zoom,e.width,e.height),i=function(e,r,n,i,a){const s=new tl(n.lng-180*Jg,n.lat),o=new tl(n.lng+180*Jg,n.lat),l=e.project(s.lng,s.lat),u=e.project(o.lng,o.lat),c=-Math.atan2(u.y-l.y,u.x-l.x),h=Ml.fromLngLat(n);h.y=I(h.y,-1+Jg,1-Jg);const p=h.toLngLat(),f=e.project(p.lng,p.lat),d=Ml.fromLngLat(p);d.x+=Jg;const m=d.toLngLat(),y=e.project(m.lng,m.lat),g=tx(y.x-f.x,y.y-f.y,c),x=Ml.fromLngLat(p);x.y+=Jg;const v=x.toLngLat(),b=e.project(v.lng,v.lat),_=tx(b.x-f.x,b.y-f.y,c),w=Math.abs(g.x)/Math.abs(_.y),M=t.a6.identity([]);t.a6.rotateZ(M,M,-c*(1-(a?0:i)));const A=t.a6.identity([]);return t.a6.scale(A,A,[1,1-(1-w)*i,1]),A[4]=-_.x/_.y*i,t.a6.rotateZ(A,A,c),t.a6.multiply(A,M,A),A}(e.projection,0,e.center,n,r),a=Hg(e);return t.a6.scale(i,i,[a,a,1]),i}function Hg(t){const e=t.projection,r=Wg(t.projection,t.zoom,t.width,t.height),n=Qg(e,t.center),i=Qg(e,tl.convert(e.center));return Math.pow(2,n*r+(1-r)*i)}function Wg(t,e,r,n,i=1/0){const a=t.range;if(!a)return 0;const s=Math.min(i,Math.max(r,n)),o=Math.log(s/1024)/Math.LN2;return k(a[0]+o,a[1]+o,e)}const Jg=1/4e4;function Qg(t,e){const r=I(e.lat,-xl,xl),n=new tl(e.lng-180*Jg,r),i=new tl(e.lng+180*Jg,r),a=t.project(n.lng,r),s=t.project(i.lng,r),o=Ml.fromLngLat(n),l=Ml.fromLngLat(i),u=s.x-a.x,c=s.y-a.y,h=l.x-o.x,p=l.y-o.y,f=Math.sqrt((h*h+p*p)/(u*u+c*c));return Math.log(f)/Math.LN2}function tx(t,e,r){const n=Math.cos(r),i=Math.sin(r);return {x:t*n-e*i,y:t*i+e*n}}function ex(e,r,n){t.a6.identity(e),t.a6.rotateZ(e,e,b(r[2])),t.a6.rotateX(e,e,b(r[0])),t.a6.rotateY(e,e,b(r[1])),t.a6.scale(e,e,n),t.a6.multiply(e,e,[1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1]);}function rx(e,r,n,i,a,s,o,l){const u=[n[0]-r[0],n[1]-r[1],0],c=[i[0]-r[0],i[1]-r[1],0];if(t.N.length(u)<1e-12||t.N.length(c)<1e-12)return t.bi.identity(e);const h=t.N.cross([],u,c);t.N.normalize(h,h),t.N.subtract(c,i,r),u[2]=(s-a)*l,c[2]=(o-a)*l;const p=u;return t.N.cross(p,u,c),t.N.normalize(p,p),t.bi.rotationTo(e,h,p)}function nx(e,r,n=!1){const i=rp(r.zoom),a=function(e,r,n){const i=r.worldSize,a=[e[12],e[13],e[14]],s=yl(a[1]/i),o=ml(a[0]/i),l=t.a6.identity([]),u=dl(1,s)*i,c=dl(1,0)*i*bl(s,r.zoom),h=1/Qh(i);let p=c*h;if(n){const t=Wg(r.projection,r.zoom,r.width,r.height,1024);p=h*r.projection.pixelSpaceConversion(r.center.lat,i,t);}const f=Wo(s,o);t.N.add(f,f,t.N.scale([],t.N.normalize([],f),u*p*a[2]));const d=function(e){const r=[e[0],e[1],e[2]];let n=[0,1,0];const i=t.N.cross([],n,r);return t.N.cross(n,r,i),0===t.N.squaredLength(n)&&(n=[0,1,0],t.N.cross(i,r,n)),t.N.normalize(i,i),t.N.normalize(n,n),t.N.normalize(r,r),[i[0],i[1],i[2],0,n[0],n[1],n[2],0,r[0],r[1],r[2],0,e[0],e[1],e[2],1]}(f);t.a6.scale(l,l,[p,p,p*u]),t.a6.translate(l,l,[-a[0],-a[1],-a[2]]);const m=t.a6.multiply([],r.globeMatrix,d);return t.a6.multiply(m,m,l),t.a6.multiply(m,m,e),m}(e,r,n);if(i>0){const n=function(e,r){const n=r.worldSize,i=dl(1,0)*n*bl(r.center.lat,r.zoom)/Qh(n),a=dl(1,r.center.lat)*n,s=t.a6.identity([]);return t.a6.rotateY(s,s,b(r.center.lng)),t.a6.rotateX(s,s,b(r.center.lat)),t.a6.translate(s,s,[0,0,jo]),t.a6.scale(s,s,[i,i,i*a]),t.a6.translate(s,s,[r.point.x-.5*n,r.point.y-.5*n,0]),t.a6.multiply(s,s,e),t.a6.multiply(s,r.globeMatrix,s)}(e,r);return function(e,r,n){const i=(e,r,n)=>{const i=t.N.length(e),a=t.N.length(r),s=qh(e,r,n);return t.N.scale(s,s,1/t.N.length(s)*ue(i,a,n))},a=i([e[0],e[1],e[2]],[r[0],r[1],r[2]],n),s=i([e[4],e[5],e[6]],[r[4],r[5],r[6]],n),o=i([e[8],e[9],e[10]],[r[8],r[9],r[10]],n),l=qh([e[12],e[13],e[14]],[r[12],r[13],r[14]],n);return [a[0],a[1],a[2],0,s[0],s[1],s[2],0,o[0],o[1],o[2],0,l[0],l[1],l[2],1]}(a,n,i)}return a}function ix(t,e,r,n){const i=Bh.projectAabbCorners(n,r);let a=Number.MAX_VALUE,s=-1;for(let t=0;tnew g(i[t][0],i[t][1]);let l;switch(s){case 0:case 6:l=[o(1),o(5),o(4),o(7),o(3),o(2),o(1)];break;case 1:case 7:l=[o(0),o(4),o(5),o(6),o(2),o(3),o(0)];break;case 3:case 5:l=[o(1),o(0),o(4),o(7),o(6),o(2),o(1)];break;default:l=[o(1),o(5),o(6),o(7),o(3),o(0),o(1)];}if(Vl(t,l))return a}const ax=cs([{name:"a_pos_3f",components:3,type:"Float32"}]),sx=cs([{name:"a_color_3f",components:3,type:"Float32"}]),ox=cs([{name:"a_color_4f",components:4,type:"Float32"}]),lx=cs([{name:"a_uv_2f",components:2,type:"Float32"}]),ux=cs([{name:"a_normal_3f",components:3,type:"Float32"}]),cx=cs([{name:"a_normal_matrix0",components:4,type:"Float32"},{name:"a_normal_matrix1",components:4,type:"Float32"},{name:"a_normal_matrix2",components:4,type:"Float32"},{name:"a_normal_matrix3",components:4,type:"Float32"}]),hx=cs([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);class px{constructor(t,e){this.feature=t,this.instancedDataOffset=e,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0];}}class fx{constructor(){this.instancedDataArray=new Ns,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={};}}class dx{constructor(t){this.zoom=t.zoom,this.canonical=t.canonical,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.projection=t.projection,this.index=t.index,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0};}populate(t,e,r,n){this.tileToMeter=wl(r);const i=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:a,id:s,index:o,sourceLayerIndex:l}of t){const t=Bl(a,i);if(!this.layers[0]._featureFilter.filter(new Pa(this.zoom),t,r))continue;const u={id:s,sourceLayerIndex:l,index:o,geometry:i?t.geometry:Tl(a,r,n),properties:a.properties,type:a.type,patterns:{}},c=this.addFeature(u,u.geometry,t);c&&e.featureIndex.insert(a,u.geometry,o,l,this.index,this.instancesPerModel[c].instancedDataArray.length,Tr/32);}this.lookup=null;}update(t,e,r,n){for(const e in this.instancesPerModel){const r=this.instancesPerModel[e];for(const e in t)r.idToFeaturesIndex.hasOwnProperty(e)&&this.evaluate(r.features[r.idToFeaturesIndex[e]],t[e],r,!0);}this.maxHeight=0;}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return !1;let e=!1;for(const r in this.instancesPerModel){const n=this.instancesPerModel[r];for(const r of n.features){const i=this.layers[0],a=r.feature,s=this.canonical,o=i.paint.get("model-rotation").evaluate(a,{},s),l=i.paint.get("model-scale").evaluate(a,{},s),u=i.paint.get("model-translation").evaluate(a,{},s);t.N.exactEquals(r.rotation,o)&&t.N.exactEquals(r.scale,l)&&t.N.exactEquals(r.translation,u)||(this.evaluate(r,r.featureStates,n,!0),e=!0);}}return e}isEmpty(){for(const t in this.instancesPerModel)if(0!==this.instancesPerModel[t].instancedDataArray.length)return !1;return !0}uploadPending(){return !this.uploaded}upload(t){if(!this.uploaded)for(const e in this.instancesPerModel){const r=this.instancesPerModel[e];r.instancedDataArray.length<0||0===r.instancedDataArray.length||(r.instancedDataBuffer?r.instancedDataBuffer.updateData(r.instancedDataArray):r.instancedDataBuffer=t.createVertexBuffer(r.instancedDataArray,cx.members,!0,void 0,this.instanceCount));}this.uploaded=!0;}destroy(){for(const t in this.instancesPerModel){const e=this.instancesPerModel[t];0!==e.instancedDataArray.length&&e.instancedDataBuffer&&e.instancedDataBuffer.destroy();}}addFeature(t,e,r){const n=this.layers[0],i=n.layout.get("model-id").evaluate(r,{},this.canonical);if(!i)return j(`modelId is not evaluated for layer ${n.id} and it is not going to get rendered.`),i;this.instancesPerModel[i]||(this.instancesPerModel[i]=new fx);const a=this.instancesPerModel[i],s=a.instancedDataArray,o=new px(r,s.length);for(const t of e)for(const e of t){if(e.x<0||e.x>=Tr||e.y<0||e.y>=Tr)continue;const t=(this.lookupDim-1)/Tr,r=this.lookupDim*(e.y*t|0)+e.x*t|0;if(this.lookup){if(0!==this.lookup[r])continue;this.lookup[r]=1;}this.instanceCount++;const n=s.length;s.resize(n+1),a.instancesEvaluatedElevation.push(0),s.float32[16*n]=e.x,s.float32[16*n+1]=e.y;}return o.instancedDataCount=a.instancedDataArray.length-o.instancedDataOffset,o.instancedDataCount>0&&(t.id&&(a.idToFeaturesIndex[t.id]=a.features.length),a.features.push(o),this.evaluate(o,{},a,!1)),i}evaluate(t,e,r,n){const i=this.layers[0],a=t.feature,s=this.canonical,o=t.rotation=i.paint.get("model-rotation").evaluate(a,e,s),l=t.scale=i.paint.get("model-scale").evaluate(a,e,s),u=t.translation=i.paint.get("model-translation").evaluate(a,e,s),c=i.paint.get("model-color").evaluate(a,e,s);c.a=i.paint.get("model-color-mix-intensity").evaluate(a,e,s);const h=[];this.maxVerticalOffset10?this.tileToMeter:wl(s,f)),o[a+4]=u[0],o[a+5]=u[1],o[a+6]=u[2]+l,o[a+7]=h[0],o[a+8]=h[1],o[a+9]=h[2],o[a+10]=h[4],o[a+11]=h[5],o[a+12]=h[6],o[a+13]=h[8],o[a+14]=h[9],o[a+15]=h[10],r.instancesEvaluatedElevation[i]=u[2];}}}ra(dx,"ModelBucket",{omit:["layers"]}),ra(fx,"PerModelAttributes"),ra(px,"ModelFeature");const mx=new Oa({visibility:new La(qa.layout_model.visibility),"model-id":new Fa(qa.layout_model["model-id"])});var yx={paint:new Oa({"model-opacity":new La(qa.paint_model["model-opacity"]),"model-rotation":new Fa(qa.paint_model["model-rotation"]),"model-scale":new Fa(qa.paint_model["model-scale"]),"model-translation":new Fa(qa.paint_model["model-translation"]),"model-color":new Fa(qa.paint_model["model-color"]),"model-color-mix-intensity":new Fa(qa.paint_model["model-color-mix-intensity"]),"model-type":new La(qa.paint_model["model-type"]),"model-cast-shadows":new La(qa.paint_model["model-cast-shadows"]),"model-receive-shadows":new La(qa.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new La(qa.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new Fa(qa.paint_model["model-emissive-strength"]),"model-roughness":new Fa(qa.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new Fa(qa.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new La(qa.paint_model["model-cutoff-fade-range"])}),layout:mx};const gx=64,xx={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function vx(e,r,n,i,a,s,o,l,u,c=!1){const h=n.zoom,p=n.project(i),f=bl(i.lat,h),d=1/f;t.a6.identity(e),t.a6.translate(e,e,[p.x+o[0]*d,p.y+o[1]*d,o[2]]);let m=1,y=1;const g=n.worldSize;if(c){if("mercator"===n.projection.name){let e=0;n.elevation&&(e=n.elevation.getAtPointOrZero(new Ml(p.x/g,p.y/g),0));const r=t.a7.transformMat4([],[p.x,p.y,e,1],n.projMatrix)[3]/n.cameraToCenterDistance;m=r,y=r*bl(n.center.lat,h);}else if("globe"===n.projection.name){const r=nx(e,n),a=t.a6.multiply([],n.projMatrix,r),s=[0,0,0,1];t.a7.transformMat4(s,s,a);const o=s[3]/n.cameraToCenterDistance,l=rp(h),u=n.projection.pixelsPerMeter(i.lat,g)*bl(i.lat,h),c=n.projection.pixelsPerMeter(n.center.lat,g)*bl(n.center.lat,h);m=o/ue(u,vl(n.center.lat),l),y=o*f/u,m*=c,y*=c;}}else m=d;t.a6.scale(e,e,[m,m,y]);const x=[...e],v=r.orientation,b=[];if(ex(b,[v[0]+a[0],v[1]+a[1],v[2]+a[2]],s),t.a6.multiply(e,x,b),l&&n.elevation){let a=0;const s=[];if(u&&n.elevation){a=function(e,r,n,i,a){const s=r.elevation;if(!s)return 0;const o=Bh.projectAabbCorners(n,i),l=dl(1,a.lat)*r.worldSize,u=function(e,r){const n=[0,0,1],i=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const a of i){const i=e[a.corners[0]],s=e[a.corners[1]],o=e[a.corners[2]],l=[s[0]-i[0],s[1]-i[1],r*(s[2]-i[2])],u=t.N.cross(l,l,[o[0]-i[0],o[1]-i[1],r*(o[2]-i[2])]);t.N.normalize(u,u),a.dotProductWithUp=t.N.dot(u,n);}return i.sort(((t,e)=>t.dotProductWithUp-e.dotProductWithUp)),i[0].corners}(o,l),c=o[u[0]],h=o[u[1]],p=o[u[2]],f=o[u[3]],d=s.getAtPointOrZero(new Ml(c[0]/r.worldSize,c[1]/r.worldSize),0),m=s.getAtPointOrZero(new Ml(h[0]/r.worldSize,h[1]/r.worldSize),0),y=s.getAtPointOrZero(new Ml(p[0]/r.worldSize,p[1]/r.worldSize),0),g=s.getAtPointOrZero(new Ml(f[0]/r.worldSize,f[1]/r.worldSize),0),x=(d+g)/2,v=(m+y)/2;return x>v?m=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null);}function _x(t,e,r){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,ax.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,ux.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,lx.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?sx:ox).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,hx.members,!0)),t.segments=eo.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const n=t.material;n.pbrMetallicRoughness.baseColorTexture&&bx(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&bx(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&bx(n.normalTexture,e),n.occlusionTexture&&bx(n.occlusionTexture,e,r),n.emissionTexture&&bx(n.emissionTexture,e);}function wx(t,e,r){if(t.meshes)for(const n of t.meshes)_x(n,e,r);if(t.children)for(const n of t.children)wx(n,e,r);}function Mx(t){if(t.meshes)for(const e of t.meshes)e.indexArray.destroy(),e.vertexArray.destroy(),e.colorArray&&e.colorArray.destroy(),e.normalArray&&e.normalArray.destroy(),e.texcoordArray&&e.texcoordArray.destroy(),e.featureArray&&e.featureArray.destroy();if(t.children)for(const e of t.children)Mx(e);}function Ax(t){if(t.meshes)for(const r of t.meshes)r.vertexBuffer&&(r.vertexBuffer.destroy(),r.indexBuffer.destroy(),r.normalBuffer&&r.normalBuffer.destroy(),r.texcoordBuffer&&r.texcoordBuffer.destroy(),r.colorBuffer&&r.colorBuffer.destroy(),r.pbrBuffer&&r.pbrBuffer.destroy(),r.segments.destroy(),r.material&&((e=r.material).pbrMetallicRoughness.baseColorTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),e.pbrMetallicRoughness.metallicRoughnessTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),e.normalTexture&&e.normalTexture.gfxTexture&&e.normalTexture.gfxTexture.destroy(),e.emissionTexture&&e.emissionTexture.gfxTexture&&e.emissionTexture.gfxTexture.destroy(),e.occlusionTexture&&e.occlusionTexture.gfxTexture&&e.occlusionTexture.gfxTexture.destroy()));var e;if(t.children)for(const e of t.children)Ax(e);}class Sx{constructor(t){this._callback=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback();});}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._callback();}),0));}remove(){this._channel=void 0,this._callback=()=>{};}}class Ix{constructor(){this.tasks={},this.taskQueue=[],V(["process"],this),this.invoker=new Sx(this.process),this.nextId=0;}add(t,e){const r=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:r}){return r=r||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-r:"maybePrepare"===t&&e?400-r:500:200-r:100-r}(e);if(0===n){Y();try{t();}finally{}return null}return this.tasks[r]={fn:t,metadata:e,priority:n,id:r},this.taskQueue.push(r),this.invoker.trigger(),{cancel:()=>{delete this.tasks[r];}}}process(){Y();try{if(this.taskQueue=this.taskQueue.filter((t=>!!this.tasks[t])),!this.taskQueue.length)return;const t=this.pick();if(null===t)return;const e=this.tasks[t];if(delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),!e)return;e.fn();}finally{}}pick(){let t=null,e=1/0;for(let r=0;r{r&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:n,sourceMapId:this.mapId});}}}receive(t){const e=t.data,r=e.id;if(r&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){const t=this.cancelCallbacks[r];delete this.cancelCallbacks[r],t&&t.cancel();}else if(e.mustQueue||Y()){const t=this.callbacks[r],n=this.scheduler.add((()=>this.processTask(r,e)),t&&t.metadata||{type:"message"});n&&(this.cancelCallbacks[r]=n);}else this.processTask(r,e);}processTask(t,e){if(delete this.cancelCallbacks[t],""===e.type){const r=this.callbacks[t];delete this.callbacks[t],r&&(e.error?r(sa(e.error)):r(null,sa(e.data)));}else {const r=new Set,n=e.hasCallback?(e,n)=>{this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?aa(e):null,data:aa(n,r)},r);}:t=>{},i=sa(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,i,n);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],i.source,i.scope)[t[1]](i,n);}else n(new Error(`Could not find function ${e.type}`));}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1);}}class Px{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=B();const r=this.workerPool.acquire(this.id);for(let t=0;t{this.ready=!0;}));}broadcast(t,e,r){E(this.actors,((r,n)=>{r.send(t,e,n);}),r=r||function(){});}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((t=>{t.remove();})),this.actors=[],this.workerPool.release(this.id);}}Px.Actor=kx;var Ex={workerUrl:"",workerClass:null,workerParams:void 0};function zx(){return null!=Ex.workerClass?new Ex.workerClass:new self.Worker(Ex.workerUrl,Ex.workerParams)}const Tx="mapboxgl_preloaded_worker_pool";class Bx{constructor(){this.active={};}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{t.terminate();})),this.workers=null);}isPreloaded(){return !!this.active[Tx]}numActive(){return Object.keys(this.active).length}}let Cx;function Rx(){return Cx||(Cx=new Bx),Cx}Bx.workerCount=2;let Dx,Vx,Lx,Fx,Nx,Ox=null;function Ux(){return Y()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:Vx||n.DRACO_URL}function jx(){if(Y()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(Fx)return Fx;const t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]);if("object"!=typeof WebAssembly)throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return Fx=WebAssembly.validate(t)?n.MESHOPT_SIMD_URL:n.MESHOPT_URL,Fx}const qx={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},$x={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},Gx={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function Yx(t,e,r){const n=r.json.bufferViews.length,i=r.buffers.length;e.bufferView=n,r.json.bufferViews[n]={buffer:i,byteLength:t.byteLength},r.buffers[i]=t;}const Xx="KHR_draco_mesh_compression";function Zx(t,e){const r=t.extensions&&t.extensions[Xx];if(!r)return;const n=new Lx.Decoder,i=ev(e,r.bufferView),a=new Lx.Mesh;if(!n.DecodeArrayToMesh(i,i.byteLength,a))throw new Error("Failed to decode Draco mesh");const s=e.json.accessors[t.indices],o=qx[s.componentType],l=s.count*o.BYTES_PER_ELEMENT,u=Lx._malloc(l);o===Uint16Array?n.GetTrianglesUInt16Array(a,l,u):n.GetTrianglesUInt32Array(a,l,u),Yx(Lx.memory.buffer.slice(u,u+l),s,e),Lx._free(u);for(const i of Object.keys(r.attributes)){const s=n.GetAttributeByUniqueId(a,r.attributes[i]),o=e.json.accessors[t.attributes[i]],l=$x[o.componentType],u=o.count*Gx[o.type]*qx[o.componentType].BYTES_PER_ELEMENT,c=Lx._malloc(u);n.GetAttributeDataArrayForAllPoints(a,s,Lx[l],u,c),Yx(Lx.memory.buffer.slice(c,c+u),o,e),Lx._free(c);}n.destroy(),a.destroy(),delete t.extensions[Xx];}const Kx="EXT_meshopt_compression";function Hx(t,e){if(!t.extensions||!t.extensions[Kx])return;const r=t.extensions[Kx],n=new Uint8Array(e.buffers[r.buffer],r.byteOffset||0,r.byteLength||0),i=new Uint8Array(r.count*r.byteStride);Nx.decodeGltfBuffer(i,r.count,r.byteStride,n,r.mode,r.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=i.buffer,delete t.extensions[Kx];}const Wx=1179937895,Jx=new TextDecoder("utf8");function Qx(t,e){return new URL(t,e).href}function tv(t,e,r,n){return fetch(Qx(t.uri,n)).then((t=>t.arrayBuffer())).then((t=>{e.buffers[r]=t;}))}function ev(t,e){const r=t.json.bufferViews[e];return new Uint8Array(t.buffers[r.buffer],r.byteOffset||0,r.byteLength)}function rv(t,e,r,n){if(t.uri){const i=Qx(t.uri,n);return fetch(i).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{e.images[r]=t;}))}if(void 0!==t.bufferView){const n=ev(e,t.bufferView),i=new Blob([n],{type:t.mimeType});return createImageBitmap(i).then((t=>{e.images[r]=t;}))}}function nv(t,e=0,r){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===Wx){const r=new Uint32Array(t,e);let i=2;const a=(r[i++]>>2)-3,s=r[i++]>>2;if(i++,n.json=JSON.parse(Jx.decode(r.subarray(i,i+s))),i+=s,i{const t=[],e=o&&o.includes(Xx),i=o&&o.includes(Kx);if(e&&t.push(function(){if(!Lx)return Dx||(Dx=function(t){let e,r=null;function n(){e=new Uint8Array(r.buffer);}function i(){throw new Error("Unexpected Draco error.")}const a={a:{a:i,d:function(t,r,n){return e.copyWithin(t,r,r+n)},c:function(t){const i=e.length,a=Math.max(t>>>0,Math.ceil(1.2*i)),s=Math.ceil((a-i)/65536);try{return r.grow(s),n(),!0}catch(t){return !1}},b:i}};return (WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,a):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,a)))).then((t=>{const{Rb:i,Qb:a,P:s,T:o,X:l,Ja:u,La:c,Qa:h,Va:p,Wa:f,eb:d,jb:m,f:y,e:g,yb:x,zb:v,Ab:b,Bb:_,Db:w,Gb:M}=t.instance.exports;r=g;const A=(()=>{let t=0,r=0,n=0,s=0;return o=>{n&&(i(s),i(t),r+=n,n=t=0),t||(r+=128,t=a(r));const l=o.length+7&-8;let u=t;l>=r&&(n=l,u=s=a(l));for(let t=0;t{Lx=t,Dx=void 0;})))}()),i&&t.push(function(){if(Nx)return;const t=function(t){let e;const r=WebAssembly.instantiateStreaming(t,{}).then((t=>{e=t.instance,e.exports.__wasm_call_ctors();})),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},i={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return {ready:r,supported:!0,decodeGltfBuffer(t,r,a,s,o,l){!function(t,e,r,n,i,a,s){const o=t.exports.sbrk,l=n+3&-4,u=o(l*i),c=o(a.length),h=new Uint8Array(t.exports.memory.buffer);h.set(a,c);const p=e(u,n,i,c,a.length);if(0===p&&s&&s(u,l,i),r.set(h.subarray(u,u+n*i)),o(u-o(0)),0!==p)throw new Error(`Malformed buffer data: ${p}`)}(e,e.exports[i[o]],t,r,a,s,e.exports[n[l]]);}}}(fetch(jx()));return t.ready.then((()=>{Nx=t;}))}()),a)for(let e=0;e{if(e&&s)for(const{primitives:t}of s)for(const e of t)Zx(e,n);if(i&&s&&l)for(const t of l)Hx(t,n);return n}))}))}class iv{constructor(t,e,r){if(this.triangleCount=e.length/3,this.min=new g(0,0),this.max=new g(0,0),this.xScale=0,this.yScale=0,this.cellsX=0,this.cellsY=0,this.cells=[],this.payload=[],0===this.triangleCount||0===t.length||0===r)return;const n=t.map((t=>t.x)),i=t.map((t=>t.y));this.min=new g(Math.min(...n),Math.min(...i)),this.max=new g(Math.max(...n),Math.max(...i));const a=this.max.sub(this.min);a.x=Math.max(a.x,1),a.y=Math.max(a.y,1);const s=Math.max(a.x,a.y)/r;this.cellsX=Math.max(1,Math.ceil(a.x/s)),this.cellsY=Math.max(1,Math.ceil(a.y/s)),this.xScale=1/s,this.yScale=1/s;const o=[];for(let r=0;rt.cellIdx-e.cellIdx||t.triIdx-e.triIdx));let l=0;for(;lthis.max.x||this.min.x>e.x)return;if(t.y>this.max.y||this.min.y>e.y)return;this.lookup||(this.lookup=new Uint8Array(Math.ceil(this.triangleCount/8)));for(let t=0;t0){for(let i=0;i0){a.texcoordArray=new Fs;const t=e.json.accessors[i.TEXCOORD_0];a.texcoordArray.resize(t.count);const r=sv(e,t);ov(e,t,a.texcoordArray,r);}if(void 0!==i._FEATURE_ID_RGBA4444){const t=e.json.accessors[i._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(a.featureData=sv(e,t));}void 0!==i._FEATURE_RGBA4444&&(a.featureData=new Uint32Array(sv(e,e.json.accessors[i._FEATURE_RGBA4444]).buffer));const h=t.material;return a.material=function(t,e){const{emissiveFactor:r=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:i=.5,normalTexture:a,occlusionTexture:s,emissiveTexture:o,doubleSided:l}=t,{baseColorFactor:u=[1,1,1,1],metallicFactor:c=1,roughnessFactor:h=1,baseColorTexture:p,metallicRoughnessTexture:f}=t.pbrMetallicRoughness||{},d=s?e[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&d){const t=s.extensions.KHR_texture_transform;d.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]];}return {pbrMetallicRoughness:{baseColorFactor:new le(...u),metallicFactor:c,roughnessFactor:h,baseColorTexture:p?e[p.index]:void 0,metallicRoughnessTexture:f?e[f.index]:void 0},doubleSided:l,emissiveFactor:r,alphaMode:n,alphaCutoff:i,normalTexture:a?e[a.index]:void 0,occlusionTexture:d,emissionTexture:o?e[o.index]:void 0,defined:void 0===t.defined}}(void 0!==h?e.json.materials[h]:{defined:!1},r),a}function uv(e,r,n){const{matrix:i,rotation:a,translation:s,scale:o,mesh:l,extras:u,children:c}=e,h={};if(h.matrix=i||t.a6.fromRotationTranslationScale([],a||[0,0,0,1],s||[0,0,0],o||[1,1,1]),void 0!==l){h.meshes=n[l];const t=h.anchor=[0,0];for(const e of h.meshes){const{min:r,max:n}=e.aabb;t[0]+=r[0]+n[0],t[1]+=r[1]+n[1];}t[0]=Math.floor(t[0]/h.meshes.length/2),t[1]=Math.floor(t[1]/h.meshes.length/2);}if(u&&(u.id&&(h.id=u.id),u.lights&&(h.lights=function(t){if(!t.length)return [];const e=function(t){const e=atob(t),r=new Uint8Array(e.length);for(let t=0;t1&&n[n.length-1].equals(n[0])&&n.pop();let i=0;for(let t=0;t0&&n.reverse();const a=rf(n.flatMap((t=>[t.x,t.y])),[]);return 0===a.length?null:{vertices:n,indices:a}}function pv(t){const e=[],r=[];let n=0;for(const i of t){n=e.length;const t=i.vertexArray.float32,a=i.indexArray.uint16;for(let r=0;r0&&([r[t+1],r[t+2]]=[r[t+2],r[t+1]]);}return {vertices:e,indices:r}}function fv(t){const e=function(t,e){const r=[],n=WebGL2RenderingContext;if(t.json.textures)for(const i of t.json.textures){const a={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==i.sampler&&Object.assign(a,t.json.samplers[i.sampler]),r.push({image:e[i.source],sampler:a,uploaded:!1});}return r}(t,t.images),r=function(t,e){const r=[];for(const n of t.json.meshes){const i=[];for(const r of n.primitives)i.push(lv(r,t,e));r.push(i);}return r}(t,e),{scenes:n,scene:i,nodes:a}=t.json,s=n?n[i||0].nodes:a,o=[];for(const e of s)o.push(uv(a[e],t,r));return function(t,e,r){const n={},i=new Set;for(let a=0;a0){const e=Array.from(i.values()).sort(((t,e)=>t-e));for(let r=e.length-1;r>=0;r--)t.splice(e[r],1);}}(o,s,t.json.nodes),o}function dv(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,r=t.aabb.min[0]-1,n=t.aabb.min[1]-1,i=gx/(t.aabb.max[0]-r+2),a=gx/(t.aabb.max[1]-n+2);for(let s=0;st.heightmap[u*gx+l]&&(t.heightmap[u*gx+l]=o);}}function mv(e,r){const n={};n.indexArray=new Es,n.indexArray.reserve(4*e.length),n.vertexArray=new Ls,n.vertexArray.reserve(10*e.length),n.colorArray=new gs,n.vertexArray.reserve(10*e.length);let i=0;for(const a of e){const e=Math.min(10,Math.max(4,1.3*a.height))*r,s=[-a.normal[1],a.normal[0],0],o=Math.min(.29,.1*a.width/a.depth),l=a.width-2*a.depth*r*(o+.01),u=t.N.scaleAndAdd([],a.pos,s,l/2),c=t.N.scaleAndAdd([],a.pos,s,-l/2),h=[u[0],u[1],u[2]+a.height],p=[c[0],c[1],c[2]+a.height],f=t.N.scaleAndAdd([],a.normal,s,o);t.N.scale(f,f,e);const d=t.N.scaleAndAdd([],a.normal,s,-o);t.N.scale(d,d,e),t.N.add(f,u,f),t.N.add(d,c,d),u[2]+=.1,c[2]+=.1,n.vertexArray.emplaceBack(f[0],f[1],f[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(u[0],u[1],u[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(h[0],h[1],h[2]),n.vertexArray.emplaceBack(p[0],p[1],p[2]),n.vertexArray.emplaceBack(u[0],u[1],u[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]);const m=l/e/2;n.colorArray.emplaceBack(-m-o,-1,m,.8),n.colorArray.emplaceBack(m+o,-1,m,.8),n.colorArray.emplaceBack(-m,0,m,1.3),n.colorArray.emplaceBack(m,0,m,1.3),n.colorArray.emplaceBack(m+o,-.8,m,.7),n.colorArray.emplaceBack(m+o,-.8,m,.7),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(m+o,-1.2,m,.8),n.colorArray.emplaceBack(m+o,-1.2,m,.8),n.indexArray.emplaceBack(6+i,4+i,8+i),n.indexArray.emplaceBack(7+i,9+i,5+i),n.indexArray.emplaceBack(0+i,1+i,2+i),n.indexArray.emplaceBack(1+i,3+i,2+i),i+=10;}const a={defined:!0,emissiveFactor:[0,0,0]},s={};return s.baseColorFactor=le.white,a.pbrMetallicRoughness=s,n.material=a,n.aabb=new Bh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),n}ra(iv,"TriangleGridIndex");class yv{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e=0&&n[3]>=0&&l.insert(o,n[0],n[1],n[2],n[3]);}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Ef(new Vm(this.rawTileData)).layers,this.sourceLayerCoder=new yv(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const t in this.vtLayers)this.vtFeatures[t]=[];}return this.vtLayers}query(t,e,r,n){this.loadVTLayers();const i=t.params||{},a=Ga(i.filter),s=t.tileResult,o=t.transform,l=s.bufferedTilespaceBounds,u=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,r,n)=>Yl(s.bufferedTilespaceGeometry,t,e,r,n)));u.sort(_v);let c=null;o.elevation&&u.length>0&&(c=Wf.create(o.elevation,this.tileID));const h={};let p;for(let l=0;l(m||(m=Tl(e,this.tileID.canonical,t.tileTransform)),r.queryIntersectsFeature(s,e,n,m,this.z,t.transform,t.pixelPosMatrix,c,i))));}return h}loadMatchingFeature(t,e,r,n,i,a,s,o,l){const{featureIndex:u,bucketIndex:c,sourceLayerIndex:h,layoutVertexArrayOffset:p}=e,f=this.bucketLayerIDs[c];if(n&&!function(t,e){for(let r=0;r=0)return !0;return !1}(n,f))return;const d=this.sourceLayerCoder.decode(h),m=this.vtLayers[d].feature(u);if(r.needGeometry){const t=Bl(m,!0);if(!r.filter(new Pa(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!r.filter(new Pa(this.tileID.overscaledZ),m))return;const y=this.getId(m,d);for(let e=0;e{const s=e instanceof Va?e.get(a):null;return s&&s.evaluate?s.evaluate(r,n,i):s}))}function _v(t,e){return e-t}ra(vv,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const wv=new Float32Array(262144),Mv=new Uint8Array(262144);function Av(t){let e=0;if(t.meshes)for(const r of t.meshes)e=Math.max(e,r.aabb.max[2]);if(t.children)for(const r of t.children)e=Math.max(e,Av(r));return e}function Sv(t,e,r){if(t.meshes)for(const n of t.meshes)n.aabb.min[0]!==1/0&&r.insert(e,n.aabb.min[0],n.aabb.min[1],n.aabb.max[0],n.aabb.max[1]);if(t.children)for(const n of t.children)Sv(n,e,r);}const Iv=["","wall","door","roof","window","lamp","logo"];class kv{constructor(t){this.node=t,this.evaluatedRMEA=[[1,0,0,1],[1,0,0,1],[1,0,0,1],[1,0,0,1],[.4,1,0,1],[1,0,0,1],[1,0,0,1]],this.hiddenByReplacement=!1,this.evaluatedScale=[1,1,1],this.evaluatedColor=[],this.emissionHeightBasedParams=[],this.feature={type:"Point",id:t.id,geometry:[],properties:{height:Av(t)}};}getLocalBounds(){if(!this.node.meshes)return new Bh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);if(!this.aabb){let t=0;const e=new Bh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const r of this.node.meshes)this.node.lightMeshIndex!==t&&e.encapsulate(r.aabb),t++;this.aabb=e;}return this.aabb}}class Pv{constructor(t,e,r,n,i,a){this.id=e,this.modelTraits|=xx.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,r&&(this.modelTraits|=xx.HasMapboxMeshFeatures),n&&(this.modelTraits|=xx.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=i,this.dirty=!0,this.needsUpload=!1,this.nodesInfo=[];for(const e of t)this.nodesInfo.push(new kv(e)),Sv(e,a.featureIndexArray.length,a.grid),a.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,a.bucketLayerIDs.length-1,0);}update(){console.log("Update 3D model bucket");}populate(){console.log("populate 3D model bucket");}uploadPending(){return !this.uploaded||this.needsUpload}upload(t){if(!this.needsUpload)return;const e=this.getNodesInfo();for(const r of e){const e=r.node;this.uploaded?this.updatePbrBuffer(e):wx(e,t,!0);}for(const t of e)Mx(t.node);this.uploaded=!0,this.needsUpload=!1;}updatePbrBuffer(t){let e=!1;if(!t.meshes)return e;for(const r of t.meshes)r.pbrBuffer&&(r.pbrBuffer.updateData(r.featureArray),e=!0);return e}needsReEvaluation(t,e,r){const n=t.transform.projectionOptions,i=t.style.getBrightness(),a=this.brightness!==i;return !!(!this.uploaded||this.dirty||n.name!==this.projection.name||Ev(r.paint.get("model-color").value,a)||Ev(r.paint.get("model-color-mix-intensity").value,a)||Ev(r.paint.get("model-roughness").value,a)||Ev(r.paint.get("model-emissive-strength").value,a)||Ev(r.paint.get("model-height-based-emissive-strength-multiplier").value,a))&&(this.projection=n,this.brightness=i,!0)}evaluateScale(t,e){if(t.transform.zoom===this.zoom)return;this.zoom=t.transform.zoom;const r=this.getNodesInfo(),n=this.id.canonical;for(const t of r){const r=t.feature;t.evaluatedScale=e.paint.get("model-scale").evaluate(r,{},n);}}evaluate(t){const e=this.getNodesInfo();for(const r of e){if(!r.node.meshes)continue;const e=r.feature,n=r.node.meshes&&r.node.meshes[0].featureData,i=r.evaluatedColor[2],a=r.evaluatedRMEA[2],s=this.id.canonical;if(r.hasTranslucentParts=!1,n){for(let n=0;n=t)continue;const h=wv[u],p=Math.abs(h);p>o&&(s=h,o=p,l=i,c=e);}if(o>.1){const a=1-(t+.5*Math.abs(l*c))/u;let o=e._dem.get(n,r)+s*a;const h=e._dem.get(n+l,r+c),p=e._dem.get(n-l,r-c,!0);(o-h)*(o-p)>0&&(o=(h+p)/2),wv[i]=e._dem.set(n,r,o),Mv[i]=t;}}}}}s&&(e._demTile.needsDEMTextureUpload=!0,e._dem._timestamp=st.now());}getNodesInfo(){return this.nodesInfo}destroy(){const t=this.getNodesInfo();for(const e of t)Mx(e.node),Ax(e.node);}isEmpty(){return !this.nodesInfo.length}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const r=e.getReplacementRegionsForTile(t.toUnwrapped()),n=this.getNodesInfo();for(let t=0;tt.footprint===e.footprint));}}getHeightAtTileCoord(t,e){const r=this.getNodesInfo(),n=[];for(let i=0;is.aabb.max[0]||e>s.aabb.max[1])continue;const o=(t-s.aabb.min[0])/(s.aabb.max[0]-s.aabb.min[0])*gx|0,l=Math.min(63,(e-s.aabb.min[1])/(s.aabb.max[1]-s.aabb.min[1])*gx|0)*gx+Math.min(63,o);if(!(s.heightmap[l]<0&&a.node.footprint)){if(a.hiddenByReplacement)return;return {height:s.heightmap[l],maxHeight:a.feature.properties.height,hidden:!1,verticalScale:a.evaluatedScale[2]}}if(a.node.footprint.grid.query(new g(t,e),new g(t,e),n),n.length>0)return {height:void 0,maxHeight:a.feature.properties.height,hidden:a.hiddenByReplacement,verticalScale:a.evaluatedScale[2]}}}}function Ev(t,e){return !t.isLightConstant&&e}function zv(t,e,r,n,i,a,s,o){let l=(61440&e|(61440&e)>>4)>>8,u=(3840&e|(3840&e)>>4)>>4,c=240&e|(240&e)>>4;r[3]>0&&(l=ue(l,255*r[0],r[3]),u=ue(u,255*r[1],r[3]),c=ue(c,255*r[2],r[3]));const h=l<<8|u,p=c<<8|Math.floor(255*n[3]),f=function(t){const e=I(t,0,2);return Math.min(Math.round(.5*e*255),255)}(n[2])<<8|15*n[0]<<4|15*n[1],d=I(i[0],0,1),m=I(i[1],0,1),y=I(i[2],0,1),g=I(i[3],0,1);let x,v,b,_;if(d!==m&&s!==a&&m!==d){const t=s-a;v=1/(t*(m-d)),b=-(a+t*d)/(t*(m-d));const e=I(i[4],-1,1);_=Math.pow(10,e),x=255*y<<8|255*g;}else x=65535,v=0,b=1,_=1;if(t.emplaceBack(h,p,f,x,v,b,_),o){const t=o.length;o.clear();for(let e=0;e>16&65535,o=a?e>>16&65535:65535&e,l=(15&o)<8?15&o:0,u=t.evaluatedRMEA[l],c=t.evaluatedColor[l],h=t.emissionHeightBasedParams[l];let p;if(s&&2===l&&n.lights&&(p=new Os,p.resize(10*n.lights.length)),zv(r.featureArray,i,c,u,h,r.aabb.min[2],r.aabb.max[2],p),p&&s){s=!1;const t=n.meshes[n.lightMeshIndex];t.featureArray=p,t.featureArray._trim();}}r.featureArray._trim(),i++;}}function Bv(t,e,r,n){const i=1<t.polygon)).flat());const x=d?l:null,[v,b]=function(e,r,n,i,a,s,o,l,u,c,h){return "globe"===e.projection.name?function(e,r,n,i,a,s,o,l,u,c,h){const p=[],f=[],d=e.projection.upVectorScale(h,e.center.lat,e.worldSize).metersToTile,m=[0,0,0,1],y=[0,0,0,1],g=(t,e,r,n)=>{t[0]=e,t[1]=r,t[2]=n,t[3]=1;},x=Md();n>0&&(n+=x),i+=x;for(const x of r){const r=[],v=[];for(const p of x){const f=p.x+a.x,x=p.y+a.y,b=e.projection.projectTilePoint(f,x,h),_=e.projection.upVector(h,p.x,p.y);let w=n,M=i;if(o){const t=Td(f,x,n,i,o,l,u,c);w+=t.base,M+=t.top;}0!==n?g(m,b.x+_[0]*d*w,b.y+_[1]*d*w,b.z+_[2]*d*w):g(m,b.x,b.y,b.z),g(y,b.x+_[0]*d*M,b.y+_[1]*d*M,b.z+_[2]*d*M),t.N.transformMat4(m,m,s),t.N.transformMat4(y,y,s),r.push(new Pd(m[0],m[1],m[2])),v.push(new Pd(y[0],y[1],y[2]));}p.push(r),f.push(v);}return [p,f]}(e,r,n,i,a,s,o,l,u,c,h):o?function(e,r,n,i,a,s,o,l,u){const c=[],h=[],p=[0,0,0,1];for(const f of e){const e=[],d=[];for(const c of f){const h=c.x+i.x,f=c.y+i.y,m=Td(h,f,r,n,s,o,l,u);p[0]=h,p[1]=f,p[2]=m.base,p[3]=1,t.a7.transformMat4(p,p,a),p[3]=Math.max(p[3],1e-5);const y=new Pd(p[0]/p[3],p[1]/p[3],p[2]/p[3]);p[0]=h,p[1]=f,p[2]=m.top,p[3]=1,t.a7.transformMat4(p,p,a),p[3]=Math.max(p[3],1e-5);const g=new Pd(p[0]/p[3],p[1]/p[3],p[2]/p[3]);e.push(y),d.push(g);}c.push(e),h.push(d);}return [c,h]}(r,n,i,a,s,o,l,u,c):function(t,e,r,n,i){const a=[],s=[],o=i[8]*e,l=i[9]*e,u=i[10]*e,c=i[11]*e,h=i[8]*r,p=i[9]*r,f=i[10]*r,d=i[11]*r;for(const e of t){const t=[],r=[];for(const a of e){const e=a.x+n.x,s=a.y+n.y,m=i[0]*e+i[4]*s+i[12],y=i[1]*e+i[5]*s+i[13],g=i[2]*e+i[6]*s+i[14],x=i[3]*e+i[7]*s+i[15],v=m+o,b=y+l,_=g+u,w=Math.max(x+c,1e-5),M=m+h,A=y+p,S=g+f,I=Math.max(x+d,1e-5);t.push(new Pd(v/w,b/w,_/w)),r.push(new Pd(M/I,A/I,S/I));}a.push(t),s.push(r);}return [a,s]}(r,n,i,a,s)}(s,i,p,h,c,o,x,f,m,s.center.lat,e.tileID.canonical),_=e.queryGeometry;return function(t,e,r){let n=1/0;Fl(r,e)&&(n=zd(r,e[0]));for(let i=0;i=3)for(let e=0;e + * @license BSD-3-Clause + * @version 11.2.5 + */ + class Vv{constructor(t=0,e=0,r=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=t,this.resetTtl=r,this.size=0,this.ttl=e;}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(t){if(this.has(t)){const e=this.items[t];delete this.items[t],this.size--,null!==e.prev&&(e.prev.next=e.next),null!==e.next&&(e.next.prev=e.prev),this.first===e&&(this.first=e.next),this.last===e&&(this.last=e.prev);}return this}entries(t=this.keys()){return t.map((t=>[t,this.get(t)]))}evict(t=!1){if(t||this.size>0){const t=this.first;delete this.items[t.key],0==--this.size?(this.first=null,this.last=null):(this.first=t.next,this.first.prev=null);}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){let e;if(this.has(t)){const r=this.items[t];this.ttl>0&&r.expiry<=Date.now()?this.delete(t):(e=r.value,this.set(t,e,!0));}return e}has(t){return t in this.items}keys(){const t=[];let e=this.first;for(;null!==e;)t.push(e.key),e=e.next;return t}set(t,e,r=!1,n=this.resetTtl){let i;if(r||this.has(t)){if(i=this.items[t],i.value=e,!1===r&&n&&(i.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.last!==i){const t=this.last,e=i.next,r=i.prev;this.first===i&&(this.first=i.next),i.next=null,i.prev=this.last,t.next=i,null!==r&&(r.next=e),null!==e&&(e.prev=r);}}else this.max>0&&this.size===this.max&&this.evict(!0),i=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},1==++this.size?this.first=i:this.last.next=i;return this.last=i,this}values(t=this.keys()){return t.map((t=>this.get(t)))}}function Lv(t,e){if(4!==e.length)throw new Error(`Expected data of dimension 4 but got ${e.length}.`);let r=e[3];for(let n=2;n>=1;n--){const i=1===n?1:0,a=2===n?1:0;for(let n=0;n>>1^-(1&t[e]);return t}function Nv(t,e){switch(e){case"uint32":return t;case"uint16":for(let e=0;e>4|(61440&r)>>8|(240&n)<<4|61440&n,t[e+1]=15&r|(3840&r)>>4|(15&n)<<8|(3840&n)<<4;}return t;case"uint8":for(let e=0;e>6|(192&n)>>4|(192&i)>>2|192&a,t[e+1]=(48&r)>>4|(48&n)>>2|48&i|(48&a)<<2,t[e+2]=(12&r)>>2|12&n|(12&i)<<2|(12&a)<<4,t[e+3]=3&r|(3&n)<<2|(3&i)<<4|(3&a)<<6;}return t;default:throw new Error(`Invalid pixel format, "${e}"`)}}class Ov extends Error{constructor(t){super(t),this.name="MRTError";}}var Uv=Uint8Array,jv=Uint16Array,qv=Int32Array,$v=new Uv([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Gv=new Uv([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Yv=new Uv([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Xv=function(t,e){for(var r=new jv(31),n=0;n<31;++n)r[n]=e+=1<>1|(21845&Qv)<<1;Jv[Qv]=((65280&(tb=(61680&(tb=(52428&tb)>>2|(13107&tb)<<2))>>4|(3855&tb)<<4))>>8|(255&tb)<<8)>>1;}var eb=function(t,e,r){for(var n=t.length,i=0,a=new jv(e);i>l]=u;}else for(s=new jv(n),i=0;i>15-t[i]);return s},rb=new Uv(288);for(Qv=0;Qv<144;++Qv)rb[Qv]=8;for(Qv=144;Qv<256;++Qv)rb[Qv]=9;for(Qv=256;Qv<280;++Qv)rb[Qv]=7;for(Qv=280;Qv<288;++Qv)rb[Qv]=8;var nb=new Uv(32);for(Qv=0;Qv<32;++Qv)nb[Qv]=5;var ib=eb(rb,9,1),ab=eb(nb,5,1),sb=function(t){for(var e=t[0],r=1;re&&(e=t[r]);return e},ob=function(t,e,r){var n=e/8|0;return (t[n]|t[n+1]<<8)>>(7&e)&r},lb=function(t,e){var r=e/8|0;return (t[r]|t[r+1]<<8|t[r+2]<<16)>>(7&e)},ub=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],cb=function(t,e,r){var n=new Error(e||ub[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,cb),!r)throw n;return n},hb=new Uv(0),pb="undefined"!=typeof TextDecoder&&new TextDecoder;try{pb.decode(hb,{stream:!0});}catch(t){}const fb={gzip_data:"gzip"};const db={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},mb={uint32:1,uint16:2,uint8:4},yb={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};class gb{constructor(t=1){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=t;}getLayer(t){return this.layers[t]}getHeaderLength(t){const e=new Uint8Array(t),r=new DataView(t);if(13!==e[0])throw new Ov("File is not a valid MRT.");return r.getUint32(1,!0)}parseHeader(t){const e=new Uint8Array(t),r=this.getHeaderLength(t);if(e.length= ${r} but got buffer of length ${e.length}`);const n=new Vm(e.subarray(0,r)),i=Rv.read(n);if(!isNaN(this.x)&&(this.x!==i.x||this.y!==i.y||this.z!==i.z))throw new Ov(`Invalid attempt to parse header ${i.z}/${i.x}/${i.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=i.x,this.y=i.y,this.z=i.z;for(const t of i.layers)this.layers[t.name]=new xb(t,{cacheSize:this._cacheSize});return this}createDecodingTask(t){const e=[],r=this.getLayer(t.layerName);for(let n=0;nt.lastBlock)continue;if(r._blocksInProgress.has(n))continue;const o={layerName:r.name,firstByte:a,lastByte:s,pixelFormat:r.pixelFormat,blockIndex:n,blockShape:[i.bands.length].concat(r.bandShape),buffer:r.buffer,codec:i.codec.codec,filters:i.filters.map((t=>t.filter))};r._blocksInProgress.add(n),e.push(o);}return new vb(e,(()=>{e.forEach((t=>r._blocksInProgress.delete(t.blockIndex)));}),((t,n)=>{if(e.forEach((t=>r._blocksInProgress.delete(t.blockIndex))),t)throw t;n.forEach((t=>{this.getLayer(t.layerName).processDecodedData(t);}));}))}}class xb{constructor({version:t,name:e,units:r,tilesize:n,pixel_format:i,buffer:a,data_index:s},o){if(this.version=t,1!==this.version)throw new Ov(`Cannot parse raster layer encoded with MRT version ${t}`);this.name=e,this.units=r,this.tileSize=n,this.buffer=a,this.pixelFormat=db[i],this.dataIndex=s,this.bandShape=[n+2*a,n+2*a,mb[this.pixelFormat]],this._decodedBlocks=function(t=1e3,e=0,r=!1){if(isNaN(t)||t<0)throw new TypeError("Invalid max value");if(isNaN(e)||e<0)throw new TypeError("Invalid ttl value");if("boolean"!=typeof r)throw new TypeError("Invalid resetTtl value");return new Vv(t,e,r)}(o?o.cacheSize:5),this._blocksInProgress=new Set;}processDecodedData(t){const e=t.blockIndex.toString();this._decodedBlocks.get(e)||this._decodedBlocks.set(e,t.data);}getBlockForBand(t){let e=0;switch(typeof t){case"string":for(const[r,n]of this.dataIndex.entries()){for(const[i,a]of n.bands.entries())if(a===t)return {bandIndex:e+i,blockIndex:r,blockBandIndex:i};e+=n.bands.length;}break;case"number":for(const[r,n]of this.dataIndex.entries()){if(t>=e&&t=0}hasDataForBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0&&!!this._decodedBlocks.get(e.toString())}getBandView(t){const{blockIndex:e,blockBandIndex:r}=this.getBlockForBand(t),n=this._decodedBlocks.get(e.toString());if(!n)throw new Ov(`Data for band ${JSON.stringify(t)} of layer "${this.name}" not decoded.`);const i=this.dataIndex[e],a=this.bandShape.reduce(((t,e)=>t*e),1),s=r*a,o=n.subarray(s,s+a);return {data:o,bytes:new Uint8Array(o.buffer).subarray(o.byteOffset,o.byteOffset+o.byteLength),tileSize:this.tileSize,buffer:this.buffer,offset:i.offset,scale:i.scale}}}class vb{constructor(t,e,r){this.tasks=t,this._onCancel=e,this._onComplete=r,this._finalized=!1;}cancel(){this._finalized||(this._onCancel(),this._finalized=!0);}complete(t,e){this._finalized||(this._onComplete(t,e),this._finalized=!0);}}gb.performDecoding=function(t,e){return Promise.all(e.tasks.map((e=>{const{layerName:r,firstByte:n,lastByte:i,pixelFormat:a,blockShape:s,blockIndex:o,filters:l,codec:u}=e,c=new Uint8Array(t).subarray(n,i+1),h=new Uint32Array(s[0]*s[1]*s[2]);let p;if("gzip_data"!==u)throw new Error(`Unhandled codec: ${u}`);return p=function(t,e){if(!globalThis.DecompressionStream&&"gzip_data"===e)return Promise.resolve(((a=function(t){31==t[0]&&139==t[1]&&8==t[2]||cb(6,"invalid gzip data");var e=t[3],r=10;4&e&&(r+=2+(t[10]|t[11]<<8));for(var n=(e>>3&1)+(e>>4&1);n>0;n-=!t[r++]);return r+(2&e)}(i=t))+8>i.length&&cb(6,"invalid gzip data"),function(t,e,r,n){var i=t.length;if(!i||e.f&&!e.l)return r||new Uv(0);var a=!r,s=a||2!=e.i,o=e.i;a&&(r=new Uv(3*i));var l=function(t){var e=r.length;if(t>e){var n=new Uv(Math.max(2*e,t));n.set(r),r=n;}},u=e.f||0,c=e.p||0,h=e.b||0,p=e.l,f=e.d,d=e.m,m=e.n,y=8*i;do{if(!p){u=ob(t,c,1);var g=ob(t,c+1,3);if(c+=3,!g){var x=t[(E=4+((c+7)/8|0))-4]|t[E-3]<<8,v=E+x;if(v>i){o&&cb(0);break}s&&l(h+x),r.set(t.subarray(E,v),h),e.b=h+=x,e.p=c=8*v,e.f=u;continue}if(1==g)p=ib,f=ab,d=9,m=5;else if(2==g){var b=ob(t,c,31)+257,_=ob(t,c+10,15)+4,w=b+ob(t,c+5,31)+1;c+=14;for(var M=new Uv(w),A=new Uv(19),S=0;S<_;++S)A[Yv[S]]=ob(t,c+3*S,7);c+=3*_;var I=sb(A),k=(1<>4)<16)M[S++]=E;else {var T=0,B=0;for(16==E?(B=3+ob(t,c,3),c+=2,T=M[S-1]):17==E?(B=3+ob(t,c,7),c+=3):18==E&&(B=11+ob(t,c,127),c+=7);B--;)M[S++]=T;}}var C=M.subarray(0,b),R=M.subarray(b);d=sb(C),m=sb(R),p=eb(C,d,1),f=eb(R,m,1);}else cb(1);if(c>y){o&&cb(0);break}}s&&l(h+131072);for(var D=(1<>4;if((c+=15&T)>y){o&&cb(0);break}if(T||cb(2),F<256)r[h++]=F;else {if(256==F){L=c,p=null;break}var N=F-254;F>264&&(N=ob(t,c,(1<<(j=$v[S=F-257]))-1)+Kv[S],c+=j);var O=f[lb(t,c)&V],U=O>>4;if(O||cb(3),c+=15&O,R=Wv[U],U>3){var j=Gv[U];R+=lb(t,c)&(1<y){o&&cb(0);break}s&&l(h+131072);var q=h+N;if(ht.length)&&(r=t.length),new Uv(t.subarray(e,r))}(r,0,h):r.subarray(0,h)}(i.subarray(a,-8),{i:2},new Uv(((r=i)[(n=r.length)-4]|r[n-3]<<8|r[n-2]<<16|r[n-1]<<24)>>>0),void 0)));var r,n,i,a;const s=fb[e];if(!s)throw new Error(`Unhandled codec: ${e}`);const o=new globalThis.DecompressionStream(s);return new Response(new Blob([t]).stream().pipeThrough(o)).arrayBuffer().then((t=>new Uint8Array(t)))}(c,u).then((t=>{const e=Dv.read(new Vm(t));if("uint32_values"===e.values)return e.uint32_values.readValuesInto(h),new(yb[a])(h.buffer);throw new Error(`Unhandled numeric data "${e.values}"`)})),p.then((t=>{for(let e=l.length-1;e>=0;e--)switch(l[e]){case"delta_filter":Lv(t,s);break;case"zigzag_filter":Fv(t);break;case"bitshuffle_filter":Nv(t,a);break;default:throw new Error(`Unhandled filter "${l[e]}"`)}return {layerName:r,blockIndex:o,data:t}})).catch((t=>{throw t}))})))},ra(vb,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]});const bb=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class _b{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[e,r]=new Uint8Array(t,0,2);if(219!==e)throw new Error("Data does not appear to be in a KDBush format.");const n=r>>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const i=bb[15&r];if(!i)throw new Error("Unrecognized array type.");const[a]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new _b(s,a,i,t)}constructor(t,e=64,r=Float64Array,n){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+e,2),65535),this.ArrayType=r,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const i=bb.indexOf(this.ArrayType),a=2*t*this.ArrayType.BYTES_PER_ELEMENT,s=t*this.IndexArrayType.BYTES_PER_ELEMENT,o=(8-s%8)%8;if(i<0)throw new Error(`Unexpected typed array class: ${r}.`);n&&n instanceof ArrayBuffer?(this.data=n,this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+s+o,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+a+s+o),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+s+o,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+i]),new Uint16Array(this.data,2,1)[0]=e,new Uint32Array(this.data,4,1)[0]=t);}add(t,e){const r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=t,this.coords[this._pos++]=e,r}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return wb(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,r,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:i,coords:a,nodeSize:s}=this,o=[0,i.length-1,0],l=[];for(;o.length;){const u=o.pop()||0,c=o.pop()||0,h=o.pop()||0;if(c-h<=s){for(let s=h;s<=c;s++){const o=a[2*s],u=a[2*s+1];o>=t&&o<=r&&u>=e&&u<=n&&l.push(i[s]);}continue}const p=h+c>>1,f=a[2*p],d=a[2*p+1];f>=t&&f<=r&&d>=e&&d<=n&&l.push(i[p]),(0===u?t<=f:e<=d)&&(o.push(h),o.push(p-1),o.push(1-u)),(0===u?r>=f:n>=d)&&(o.push(p+1),o.push(c),o.push(1-u));}return l}within(t,e,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:i,nodeSize:a}=this,s=[0,n.length-1,0],o=[],l=r*r;for(;s.length;){const u=s.pop()||0,c=s.pop()||0,h=s.pop()||0;if(c-h<=a){for(let r=h;r<=c;r++)Ib(i[2*r],i[2*r+1],t,e)<=l&&o.push(n[r]);continue}const p=h+c>>1,f=i[2*p],d=i[2*p+1];Ib(f,d,t,e)<=l&&o.push(n[p]),(0===u?t-r<=f:e-r<=d)&&(s.push(h),s.push(p-1),s.push(1-u)),(0===u?t+r>=f:e+r>=d)&&(s.push(p+1),s.push(c),s.push(1-u));}return o}}function wb(t,e,r,n,i,a){if(i-n<=r)return;const s=n+i>>1;Mb(t,e,s,n,i,a),wb(t,e,r,n,s-1,1-a),wb(t,e,r,s+1,i,1-a);}function Mb(t,e,r,n,i,a){for(;i>n;){if(i-n>600){const s=i-n+1,o=r-n+1,l=Math.log(s),u=.5*Math.exp(2*l/3),c=.5*Math.sqrt(l*u*(s-u)/s)*(o-s/2<0?-1:1);Mb(t,e,r,Math.max(n,Math.floor(r-o*u/s+c)),Math.min(i,Math.floor(r+(s-o)*u/s+c)),a);}const s=e[2*r+a];let o=n,l=i;for(Ab(t,e,n,r),e[2*i+a]>s&&Ab(t,e,n,i);os;)l--;}e[2*n+a]===s?Ab(t,e,n,l):(l++,Ab(t,e,l,i)),l<=r&&(n=l+1),r<=l&&(i=l-1);}}function Ab(t,e,r,n){Sb(t,r,n),Sb(e,2*r,2*n),Sb(e,2*r+1,2*n+1);}function Sb(t,e,r){const n=t[e];t[e]=t[r],t[r]=n;}function Ib(t,e,r,n){const i=t-r,a=e-n;return i*i+a*a}t.$=Yy,t.A=Di,t.B=Bi,t.C=nr,t.D=qa,t.E=ee,t.F=Oa,t.G=La,t.H=class{constructor(t){this.specification=t;}possiblyEvaluate(t,e){return G(t.expression.evaluate(e))}interpolate(t,e,r){return {x:ue(t.x,e.x,r),y:ue(t.y,e.y,r),z:ue(t.z,e.z,r),azimuthal:ue(t.azimuthal,e.azimuthal,r),polar:ue(t.polar,e.polar,r)}}},t.I=dy,t.J=Ta,t.K=Pa,t.L=Ml,t.M=class{constructor(t,e,r,n){this.id=t,this.position=null!=e?new tl(e[0],e[1]):new tl(0,0),this.orientation=null!=r?r:[0,0,0],this.nodes=n,this.uploaded=!1,this.aabb=new Bh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[];}_applyTransformations(e,r){if(t.a6.multiply(e.matrix,r,e.matrix),e.meshes)for(const t of e.meshes){const r=Bh.applyTransform(t.aabb,e.matrix);this.aabb.encapsulate(r);}if(e.children)for(const t of e.children)this._applyTransformations(t,e.matrix);}computeBoundsAndApplyParent(){const e=t.a6.identity([]);for(const t of this.nodes)this._applyTransformations(t,e);}computeModelMatrix(t,e,r,n,i,a,s=!1){vx(this.matrix,this,t.transform,this.position,e,r,n,i,a,s);}upload(t){if(!this.uploaded){for(const e of this.nodes)wx(e,t);for(const t of this.nodes)Mx(t);this.uploaded=!0;}}destroy(){for(const t of this.nodes)Ax(t);}},t.O=k,t.P=g,t.Q=Va,t.R=At,t.S=rp,t.T=Cg,t.U=ue,t.V=Tr,t.W=ce,t.X=class{constructor(t){this.specification=t;}possiblyEvaluate(t,e){return function([t,e]){const r=G([1,t,e]);return {x:r.x,y:r.y,z:r.z}}(t.expression.evaluate(e))}interpolate(t,e,r){return {x:ue(t.x,e.x,r),y:ue(t.y,e.y,r),z:ue(t.z,e.z,r)}}},t.Y=function(t,e,r=0,n=!0){const i=new g(r,r),a=t.sub(i),s=e.add(i),o=[a,new g(s.x,a.y),s,new g(a.x,s.y)];return n&&o.push(a.clone()),o},t.Z=Xi,t._=function(t,e){const r=[];for(let n=0;n{n(t,r);}),e):n(t,r),()=>{}}return i.callbacks.push(n),i.cancel||(i.cancel=r(((r,n)=>{i.result=[r,n];for(const t of i.callbacks)this.scheduler?this.scheduler.add((()=>{t(r,n);}),e):t(r,n);setTimeout((()=>delete this.entries[t]),3e3);}))),()=>{i.result||(i.callbacks=i.callbacks.filter((t=>t!==n)),i.callbacks.length||(i.cancel(),delete this.entries[t]));}}},t.ag=is,t.ah=function(t,e,r){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=Pt(t.request,((t,n,i,a)=>{t?e(t):n&&e(null,{vectorTile:r?void 0:new Ef(new Vm(n)),rawData:n,cacheControl:i,expires:a});}));return ()=>{n.cancel(),e();}}),e)},t.ai=function(t){yt++,yt>ut&&(t.getActor().send("enforceCacheSizeLimit",lt),yt=0);},t.aj=qt,t.ak=at,t.al=function(t){return t<=1?1:Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},t.am=sl,t.an=Og,t.ao=qg,t.ap=Fg,t.aq=function(t,e){const r=document.createElement("video");r.muted=!0,r.onloadstart=function(){e(null,r);};for(let e=0;e{}}},t.ar=Rg,t.as=Gy,t.at=ml,t.au=yl,t.av=ds,t.aw=Es,t.ax=le,t.ay=cs,t.az=Ls,t.b=Qt,t.b$=wa,t.b0=function(t,e){const r=[];for(const n in t)n in e||r.push(n);return r},t.b1=E,t.b2=["type","source","source-layer","minzoom","maxzoom","filter","layout"],t.b3=function(e,r){const{x:n,y:i}=e.point,a=ep(n,i,e.worldSize/e._pixelsPerMercatorPixel,0,0);return t.a6.multiply(a,a,Jh(jh(r)))},t.b5=lm,t.b6=jm,t.b7=om,t.b8=function(t,e,r,n,i){const a=5*e+2;t.float32[a+0]=r,t.float32[a+1]=n,t.float32[a+2]=i;},t.b9=vg,t.bA=Wg,t.bB=Kg,t.bC=function(e){const r=Kg(e,!0);return t.b4.invert([],[r[0],r[1],r[4],r[5]])},t.bD=Ih,t.bE=function(t){const{x:e,y:r}=t.point,{lng:n,lat:i}=t._center;return ep(e,r,t.worldSize,n,i)},t.bF=_,t.bG=qo,t.bH=function(t){const e=Math.round((t+45+360)%360/90)%4;return w[e]},t.bI=45,t.bJ=hl,t.bK=So,t.bL=bo,t.bM=_o,t.bN=vo,t.bO=xo,t.bP=wo,t.bQ=function(t,e,r){const n=Math.sqrt(t*t+e*e+r*r),i=n>0?Math.acos(r/n)*v:0;let a=0!==t||0!==e?Math.atan2(-e,-t)*v+90:0;return a<0&&(a+=360),[n,a,i]},t.bR=wl,t.bS=Bh,t.bT=G,t.bU=function(t){return [Math.pow(t[0],1/2.2),Math.pow(t[1],1/2.2),Math.pow(t[2],1/2.2)]},t.bV=function(t){return t({pluginStatus:ba,pluginURL:_a}),Aa.on("pluginStateChange",t),t},t.bW=Px,t.bX=Rx,t.bY=_y,t.bZ=by,t.b_=It,t.ba=hy,t.bb=Vl,t.bc=im,t.bd=Ry,t.be=Dy,t.bf=Qm,t.bg=_b,t.bh=P,t.bj=b,t.bk=rt,t.bl=dl,t.bm=function(t,e,r){t[4*e+0]=r[0],t[4*e+1]=r[1],t[4*e+2]=r[2],t[4*e+3]=r[3];},t.bn=tl,t.bo=fg,t.bp=al,t.bq=Th,t.br=Hg,t.bs=il,t.bt=Gh,t.bu=function(t,e,r,n,i,a,s,o,l){if("globe"===l.name)return Gh(t,e,new il(r,n,i),!1);const u=Gy({z:r,x:n,y:i},l);return new Bh([(a+u.x/u.scale)*e,e*(u.y/u.scale),s],[(a+u.x2/u.scale)*e,e*(u.y2/u.scale),o])},t.bv=function(t,e,r){let n=0;for(let i=0;i<2;++i){const a=r?r[i]:0;t[i]>a&&(n+=(t[i]-a)*(t[i]-a)),e[i]0&&n[0]<=e.width&&n[1]>0&&n[1]<=e.height&&!ip(e,new tl(e.center.lat,90)),i[0]>0&&i[0]<=e.width&&i[1]>0&&i[1]<=e.height&&!ip(e,new tl(e.center.lat,-90))]},t.bz=function(e,r){const{scale:n}=e.tileTransform,i=n*Tr/(e.tileSize*Math.pow(2,r.zoom-e.tileID.overscaledZ+e.tileID.canonical.z));return t.b4.scale(new Float32Array(4),r.inverseAdjustmentMatrix,[i,i])},t.c=fv,t.c$=function(){return !!document.fullscreenElement||!!document.webkitFullscreenElement},t.c0=a,t.c1=O,t.c2=function(t,e,r){return "custom"===t.type?new $g(t,e):new Cv[t.type](t,e,r)},t.c3=function(t){const e=t.indexOf(ns);return e>=0?t.slice(0,e):t},t.c4=function(t){return t.indexOf(ns)>=0},t.c5=function(t){const e=t.indexOf(ns);return e>=0?t.slice(e+1):""},t.c6=function(t){const e=[],r=t.id;return void 0===r&&e.push({message:`layers.${r}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${r}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${r}: property "renderingMode" must be either "2d" or "3d"`}),e},t.c7=N,t.c8=Aa,t.c9=kt,t.cA=Gd,t.cB=(t,e,r,n,i,a)=>{const s=t.transform;return {u_matrix:$d(t,e,r,n),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:i,u_image:0,u_tile_units_to_pixels:qd(e,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:a}},t.cC=(t,e,r,n,i,a,s)=>{const o=t.transform,l=o.calculatePixelsToTileUnitsMatrix(e);return {u_matrix:$d(t,e,r,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:a,u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:i,u_texsize:Yd(r)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:qd(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_emissive_strength:r.paint.get("line-emissive-strength")}},t.cD=R,t.cE=Ap,t.cF=Md,t.cG=ll,t.cH=md,t.cI=id,t.cJ=450,t.cK=7,t.cL=Ng,t.cM=256,t.cN=Jh,t.cO=Cs,t.cP=Rs,t.cQ=function(t,e,r,n,i){return I((t-e)/(r-e)*(i-n)+n,n,i)},t.cR=bl,t.cS=nx,t.cT=[1,1,1],t.cU=Wf,t.cV=xx,t.cW=As,t.cX=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[];}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[];}get updateTime(){return this._updateTime}getReplacementRegionsForTile(t){const e=Df(new g(0,0),new g(Tr,Tr),t),r=[];for(const n of this._activeRegions){if(n.hiddenByOverlap)continue;if(!Rf(e,n))continue;const i=Vf(n.min,n.max,t);r.push({min:i.min,max:i.max,sourceId:this._sourceIds[n.priority],footprint:n.footprint,footprintTileId:n.tileId});}return r}setSources(t){this._setSources(t.map((t=>({getSourceId:()=>t.cache.id,getFootprints:()=>{const e=[];for(const r of t.cache.getVisibleCoordinates()){const n=t.cache.getTile(r).buckets[t.layer];if(n)for(const t of n.getNodesInfo()){const n=t.node;n.footprint&&e.push({footprint:n.footprint,id:r.toUnwrapped()});}}return e}}))));}_addSource(t){const e=t.getFootprints();if(0!==e.length){for(const t of e){if(!t.footprint)continue;const e=Df(t.footprint.min,t.footprint.max,t.id);this._activeRegions.push({min:e.min,max:e.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:t.id,footprint:t.footprint});}this._sourceIds.push(t.getSourceId());}}_computeReplacement(){this._activeRegions.sort(((t,e)=>t.priority-e.priority||Bf(t.min,e.min)||Bf(t.max,e.max)));let t=this._activeRegions.length!==this._prevRegions.length;if(!t){let e=0,r=0;for(;!t&&e!==this._activeRegions.length;){const n=this._activeRegions[e],i=this._prevRegions[r];t=n.priority!==i.priority||!Cf(n,i),++e,++r;}}if(t){++this._updateTime;const t=t=>{const e=this._activeRegions;if(t>=e.length)return t;const r=e[t].priority;for(;t1){let e=0,r=t(e);for(;e!==r;){let n=e;const i=e;for(;n!==r;){const t=this._activeRegions[n];t.hiddenByOverlap=!1;for(let e=0;e=0;e--)this._addSource(t[e]);this._computeReplacement();}},t.cY=class{constructor(t){this._createGrid(t),this._createPoles(t);}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy();}_fillGridMeshWithLods(t,e){const r=new ps,n=new Es,i=[],a=t+1+2,s=e[0]+1,o=e[0]+1+(1+e.length),l=(t,e,r)=>{let n=t===a-1?t-2:0===t?t:t-1;return n+=r?24575:0,[n,e]};for(let t=0;t0;return 0===n&&!i&&!a},t.ce=function(e){const r=e.pixelsPerMeter,n=r/dl(1,e.center.lat),i=t.a6.identity(new Float64Array(16));return t.a6.translate(i,i,[e.point.x,e.point.y,0]),t.a6.scale(i,i,[n,n,r]),Float32Array.from(i)},t.cf=Yh,t.cg=function(t){const e=xl-5;t=I(t,-e,e)/e*90;const r=Math.pow(Math.abs(Math.sin(b(t))),3);return Math.round(r*(Xo.length-1))},t.ch=function(e,r,n,i){const a=r.getNorth(),s=r.getSouth(),o=r.getWest(),l=r.getEast(),u=1<0){const e=180/i;t.co.multiply(d,d,[e/c+1,0,0,0,e/h+1,0,-.5*e/p,.5*e/f,1]);}return d[2]=u,d[5]=e.x,d[8]=e.y,d},t.ci=jh,t.cj=function(e,r,n){const i=t.a6.identity(new Float64Array(16)),a=(r/(1<1)return !1;const r=e.getSource().maxzoom,n=1<1)return e;const i=n.getSource().maxzoom,a=1<{const s=this.getAtTileOffset(e,a.x,a.y),o=i.upVector(e.canonical,a.x,a.y),l=i.upVectorScale(e.canonical,r,n).metersToTile;return t.N.scale(o,o,s*l),o}}getForTilePoints(t,e,r,n){if(this.isUsingMockSource())return !1;const i=Wf.create(this,t,n);return !!i&&(e.forEach((t=>{t[2]=this.exaggeration()*i.getElevationAt(t[0],t[1],r);})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const r=e.dem.tree,n=e.tileID,i=1<({u_camera_to_center_distance:new vo(t),u_extrude_scale:new Po(t),u_device_pixel_ratio:new vo(t),u_matrix:new So(t),u_inv_rot_matrix:new So(t),u_merc_center:new bo(t),u_tile_id:new _o(t),u_zoom_transition:new vo(t),u_up_dir:new _o(t),u_emissive_strength:new vo(t)}),t.ct=t=>({u_matrix:new So(t),u_pixels_to_tile_units:new Po(t),u_device_pixel_ratio:new vo(t),u_units_to_pixels:new bo(t),u_dash_image:new xo(t),u_gradient_image:new xo(t),u_image_height:new vo(t),u_texsize:new bo(t),u_tile_units_to_pixels:new vo(t),u_alpha_discard_threshold:new vo(t),u_trim_offset:new bo(t),u_emissive_strength:new vo(t)}),t.cu=t=>({u_matrix:new So(t),u_texsize:new bo(t),u_pixels_to_tile_units:new Po(t),u_device_pixel_ratio:new vo(t),u_image:new xo(t),u_units_to_pixels:new bo(t),u_tile_units_to_pixels:new vo(t),u_alpha_discard_threshold:new vo(t),u_trim_offset:new bo(t)}),t.cv=ks,t.cw=nm,t.cx=um,t.cy=up,t.cz=(t,e,r,n,i,a)=>{const s=t.transform,o="globe"===s.projection.name;let l;if("map"===a.paint.get("circle-pitch-alignment"))if(o){const t=tp(s.zoom,e.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([t,0,0,t]);}else l=s.calculatePixelsToTileUnitsMatrix(r);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const u={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(s.projection),u_matrix:t.translatePosMatrix(e.projMatrix,r,a.paint.get("circle-translate"),a.paint.get("circle-translate-anchor")),u_device_pixel_ratio:st.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:lp,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:a.paint.get("circle-emissive-strength")};if(o){u.u_inv_rot_matrix=n,u.u_merc_center=i,u.u_tile_id=[e.canonical.x,e.canonical.y,1<t*im));}let y=d?"center":h.get("text-justify").evaluate(a,{},o);const b="point"===h.get("symbol-placement"),w=b?h.get("text-max-width").evaluate(a,{},o)*im:1/0,M=a=>{t.allowVerticalPlacement&&la(n)&&(x.vertical=Gm(v,e,r,i,l,w,u,f,a,c,_,jm.vertical,!0,g,p));};if(!d&&m){const t="auto"===y?m.map((t=>Dy(t))):[y];let n=!1;for(let a=0;a=0||!la(n)){const t=Gm(v,e,r,i,l,w,u,f,y,c,_,jm.horizontal,!1,g,p);t&&(x.horizontal[y]=t);}M(b?"left":y);}}let w=!1;if(a.icon&&a.icon.namePrimary){const e=n[a.icon.namePrimary];e&&(b=ey(i[a.icon.namePrimary],a.icon.nameSecondary?i[a.icon.nameSecondary]:void 0,h.get("icon-offset").evaluate(a,{},o),h.get("icon-anchor").evaluate(a,{},o)),w=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&j("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==h.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0));}const M=Oy(x.horizontal)||x.vertical;t.iconsInText||(t.iconsInText=!!M&&M.iconsInText),(M||b)&&Vy(t,a,x,b,n,f,g,0,_,w,s,o,u,c,y);}a&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray);},t.dH=Ef,t.dI=Vm,t.dJ=Hf,t.dK=h,t.dL=zf,t.dM=gf,t.dN=m,t.dO=mm,t.dP=function(t){let e=0;if(new Uint32Array(t,0,1)[0]!==Wx){const r=new Uint32Array(t,0,7),[,,n,i,a,s]=r;e=r.byteLength+i+a+s+a,(n!==t.byteLength||e>=t.byteLength)&&j("Invalid b3dm header information.");}return nv(t,e)},t.dQ=function(t,e){const r=fv(t);for(const t of r){for(const e of t.meshes)dv(e);t.lights&&(t.lightMeshIndex=t.meshes.length,t.meshes.push(mv(t.lights,e)));}return r},t.dR=Pv,t.dS=kx,t.dT=ka,t.dU=function(t){ft(),ct&&ct.then((e=>{e.keys().then((r=>{for(let n=0;nthis._skuTokenExpiresAt}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}normalizeStyleURL(t,r){if(!a(t))return t;const n=Lt(t);return n.params.push(`sdk=js-${e}`),n.path=`/styles/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||r)}normalizeGlyphsURL(t,e){if(!a(t))return t;const r=Lt(t);return r.path=`/fonts/v1${r.path}`,this._makeAPIURL(r,this._customAccessToken||e)}normalizeModelURL(t,e){if(!a(t))return t;const r=Lt(t);return r.path=`/models/v1${r.path}`,this._makeAPIURL(r,this._customAccessToken||e)}normalizeSourceURL(t,e,r,n){if(!a(t))return t;const i=Lt(t);return i.path=`/v4/${i.authority}.json`,i.params.push("secure"),r&&i.params.push(`language=${r}`),n&&i.params.push(`worldview=${n}`),this._makeAPIURL(i,this._customAccessToken||e)}normalizeSpriteURL(t,e,r,n){const i=Lt(t);return a(t)?(i.path=`/styles/v1${i.path}/sprite${e}${r}`,this._makeAPIURL(i,this._customAccessToken||n)):(i.path+=`${e}${r}`,Ft(i))}normalizeTileURL(t,e,r){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!a(t))return t;const i=Lt(t);i.path=i.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${e||r&&"raster"!==i.authority&&512===r?"@2x":""}${gt.supported?".webp":"$1"}`),"raster"===i.authority?i.path=`/${n.RASTER_URL_PREFIX}${i.path}`:"rasterarrays"===i.authority?i.path=`/${n.RASTERARRAYS_URL_PREFIX}${i.path}`:(i.path=i.path.replace(/^.+\/v4\//,"/"),i.path=`/${n.TILE_URL_VERSION}${i.path}`);const s=this._customAccessToken||function(t){for(const e of t){const t=e.match(/^access_token=(.*)$/);if(t)return t[1]}return null}(i.params)||n.ACCESS_TOKEN;return n.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&i.params.push(`sku=${this._skuToken}`),this._makeAPIURL(i,s)}canonicalizeTileURL(t,e){const r=Lt(t);if(!r.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!r.path.match(/\.[\w]+$/))return t;let i="mapbox://";r.path.match(/^\/raster\/v1\//)?i+=`raster/${r.path.replace(`/${n.RASTER_URL_PREFIX}/`,"")}`:r.path.match(/^\/rasterarrays\/v1\//)?i+=`rasterarrays/${r.path.replace(`/${n.RASTERARRAYS_URL_PREFIX}/`,"")}`:i+=`tiles/${r.path.replace(`/${n.TILE_URL_VERSION}/`,"")}`;let a=r.params;return e&&(a=a.filter((t=>!t.match(/^access_token=/)))),a.length&&(i+=`?${a.join("&")}`),i}canonicalizeTileset(t,e){const r=!!e&&a(e),n=[];for(const e of t.tiles||[])i(e)?n.push(this.canonicalizeTileURL(e,r)):n.push(e);return n}_makeAPIURL(t,e){const r="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",i=Lt(n.API_URL);if(t.protocol=i.protocol,t.authority=i.authority,"http"===t.protocol){const e=t.params.indexOf("secure");e>=0&&t.params.splice(e,1);}if("/"!==i.path&&(t.path=`${i.path}${t.path}`),!n.REQUIRE_ACCESS_TOKEN)return Ft(t);if(e=e||n.ACCESS_TOKEN,!this._silenceAuthErrors){if(!e)throw new Error(`An API access token is required to use Mapbox GL. ${r}`);if("s"===e[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${r}`)}return t.params=t.params.filter((t=>-1===t.indexOf("access_token"))),t.params.push(`access_token=${e||""}`),Ft(t)}},t.db=function(t,e){e?Ht.add(t):Ht.delete(t);},t.dc=gt,t.dd=Xt,t.de=Kt,t.df=Dt,t.dg=Gt,t.dh=function(t){Ht.delete(t);},t.di=Zt,t.dj=$t,t.dk=e,t.dl=function(t,e){lt=t,ut=e;},t.dm=function(t,e,r=!1){if(ba===ya||ba===ga||ba===xa)throw new Error("setRTLTextPlugin cannot be called multiple times.");_a=st.resolveURL(t),ba=ya,va=e,Ma(),r||Ia();},t.dn=Sa,t.dp=function(){Rx().acquire(Tx);},t.dq=function(){const t=Cx;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(Tx),Cx=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"));},t.dr=Bx,t.ds=function(t){const e=pt();if(!e)return;const r=e.delete(ot);t&&r.catch(t).then((()=>t()));},t.dt=Ex,t.du=Ux,t.dv=function(t){Vx=st.resolveURL(t),Ox||(Ox=new Px(Rx(),new ee)),Ox.broadcast("setDracoUrl",Vx);},t.dw=jx,t.dx=function(t){Fx=st.resolveURL(t),Ox||(Ox=new Px(Rx(),new ee)),Ox.broadcast("setMeshoptUrl",Fx);},t.dy=ra,t.dz=vp,t.e=z,t.f=st,t.g=function(t,e){return kt(z(t,{type:"json"}),e)},t.h=bp,t.i=Ke,t.j=pe,t.k=Ti,t.l=function(t){return fetch(t).then((t=>t.arrayBuffer())).then((e=>nv(e,0,t)))},t.m=Ci,t.n=$i,t.o=ja,t.p=py,t.q=Zi,t.r=Gi,t.s=Ri,t.t=mn,t.u=Ua,t.v=gn,t.w=j,t.x=dn,t.z=$a;})); - define(["./shared"],(function(e){function t(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e||null==e)return JSON.stringify(e);if(Array.isArray(e)){let r="[";for(const o of e)r+=`${t(o)},`;return `${r}]`}let r="{";for(const o of Object.keys(e).sort())r+=`${o}:${t(e[o])},`;return `${r}}`}function r(r){let o="";for(const i of e.r)o+=`/${t(r[i])}`;return o}class o{constructor(e){this.keyCache={},e&&this.replace(e);}replace(e,t){this._layerConfigs={},this._layers={},this.update(e,[],t);}update(t,o,i){this._options=i;for(const r of t){this._layerConfigs[r.id]=r;const t=this._layers[r.id]=e.c(r,this._options);t.setScope(this.scope),t.compileFilter(),this.keyCache[r.id]&&delete this.keyCache[r.id];}for(const e of o)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const s=function(e,t){const o={};for(let i=0;ithis._layers[e.id])),r=t[0];if("none"===r.visibility)continue;const o=r.source||"";let i=this.familiesBySource[o];i||(i=this.familiesBySource[o]={});const s=r.sourceLayer||"_geojsonTileLayer";let n=i[s];n||(n=i[s]=[]),n.push(t);}}}class i{loadTile(t,r){const{uid:o,encoding:i,rawImageData:s,padding:n}=t,a=e.w.ImageBitmap&&s instanceof e.w.ImageBitmap?this.getImageData(s,n):s;r(null,new e.D(o,a,i,t.convertToFloat,n<1));}getImageData(e,t){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(e.width,e.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=e.width,this.offscreenCanvas.height=e.height,this.offscreenCanvasContext.drawImage(e,0,0,e.width,e.height);const r=this.offscreenCanvasContext.getImageData(-t,-t,e.width+2*t,e.height+2*t);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),r}}function s(e,t){if(0!==e.length){n(e[0],t);for(var r=1;r=Math.abs(a)?r-l+a:a-l+r,r=l;}r+o>=0!=!!t&&e.reverse();}var a=e.g((function e(t,r){var o,i=t&&t.type;if("FeatureCollection"===i)for(o=0;o>31}function b(e,t){for(var r=e.loadGeometry(),o=e.type,i=0,s=0,n=r.length,a=0;ae},_=Math.fround||(T=new Float32Array(1),e=>(T[0]=+e,T[0]));var T;const L=3,C=5,O=6;class j{constructor(e){this.options=Object.assign(Object.create(P),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[];}load(e){const{log:t,minZoom:r,maxZoom:o}=this.options;t&&console.time("total time");const i=`prepare ${e.length} points`;t&&console.time(i),this.points=e;const s=[];for(let t=0;t=r;e--){const r=+Date.now();n=this.trees[e]=this._createTree(this._cluster(n,e)),t&&console.log("z%d: %d clusters in %dms",e,n.numItems,+Date.now()-r);}return t&&console.timeEnd("total time"),this}getClusters(e,t){let r=((e[0]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,e[1]));let i=180===e[2]?180:((e[2]+180)%360+360)%360-180;const s=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)r=-180,i=180;else if(r>i){const e=this.getClusters([r,o,180,s],t),n=this.getClusters([-180,o,i,s],t);return e.concat(n)}const n=this.trees[this._limitZoom(t)],a=n.range(z(r),D(s),z(i),D(o)),l=n.data,h=[];for(const e of a){const t=this.stride*e;h.push(l[t+C]>1?F(l,t,this.clusterProps):this.points[l[t+L]]);}return h}getChildren(e){const t=this._getOriginId(e),r=this._getOriginZoom(e),o="No cluster with the specified id.",i=this.trees[r];if(!i)throw new Error(o);const s=i.data;if(t*this.stride>=s.length)throw new Error(o);const n=this.options.radius/(this.options.extent*Math.pow(2,r-1)),a=i.within(s[t*this.stride],s[t*this.stride+1],n),l=[];for(const t of a){const r=t*this.stride;s[r+4]===e&&l.push(s[r+C]>1?F(s,r,this.clusterProps):this.points[s[r+L]]);}if(0===l.length)throw new Error(o);return l}getLeaves(e,t,r){const o=[];return this._appendLeaves(o,e,t=t||10,r=r||0,0),o}getTile(e,t,r){const o=this.trees[this._limitZoom(e)],i=Math.pow(2,e),{extent:s,radius:n}=this.options,a=n/s,l=(r-a)/i,h=(r+1+a)/i,u={features:[]};return this._addTileFeatures(o.range((t-a)/i,l,(t+1+a)/i,h),o.data,t,r,i,u),0===t&&this._addTileFeatures(o.range(1-a/i,l,1,h),o.data,i,r,i,u),t===i-1&&this._addTileFeatures(o.range(0,l,a/i,h),o.data,-1,r,i,u),u.features.length?u:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const r=this.getChildren(e);if(t++,1!==r.length)break;e=r[0].properties.cluster_id;}return t}_appendLeaves(e,t,r,o,i){const s=this.getChildren(t);for(const t of s){const s=t.properties;if(s&&s.cluster?i+s.point_count<=o?i+=s.point_count:i=this._appendLeaves(e,s.cluster_id,r,o,i):i1;let l,h,u;if(a)l=Z(t,e,this.clusterProps),h=t[e],u=t[e+1];else {const r=this.points[t[e+L]];l=r.properties;const[o,i]=r.geometry.coordinates;h=z(o),u=D(i);}const c={type:1,geometry:[[Math.round(this.options.extent*(h*i-r)),Math.round(this.options.extent*(u*i-o))]],tags:l};let f;f=a||this.options.generateId?t[e+L]:this.points[t[e+L]].id,void 0!==f&&(c.id=f),s.features.push(c);}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){const{radius:r,extent:o,reduce:i,minPoints:s}=this.options,n=r/(o*Math.pow(2,t)),a=e.data,l=[],h=this.stride;for(let r=0;rt&&(d+=a[r+C]);}if(d>f&&d>=s){let e,s=o*f,n=u*f,p=-1;const g=((r/h|0)<<5)+(t+1)+this.points.length;for(const o of c){const l=o*h;if(a[l+2]<=t)continue;a[l+2]=t;const u=a[l+C];s+=a[l]*u,n+=a[l+1]*u,a[l+4]=g,i&&(e||(e=this._map(a,r,!0),p=this.clusterProps.length,this.clusterProps.push(e)),i(e,this._map(a,l)));}a[r+4]=g,l.push(s/d,n/d,1/0,g,-1,d),i&&l.push(p);}else {for(let e=0;e1)for(const e of c){const r=e*h;if(!(a[r+2]<=t)){a[r+2]=t;for(let e=0;e>5}_getOriginZoom(e){return (e-this.points.length)%32}_map(e,t,r){if(e[t+C]>1){const o=this.clusterProps[e[t+O]];return r?Object.assign({},o):o}const o=this.points[e[t+L]].properties,i=this.options.map(o);return r&&i===o?Object.assign({},i):i}}function F(e,t,r){return {type:"Feature",id:e[t+L],properties:Z(e,t,r),geometry:{type:"Point",coordinates:[(o=e[t],360*(o-.5)),E(e[t+1])]}};var o;}function Z(e,t,r){const o=e[t+C],i=o>=1e4?`${Math.round(o/1e3)}k`:o>=1e3?Math.round(o/100)/10+"k":o,s=e[t+O],n=-1===s?{}:Object.assign({},r[s]);return Object.assign(n,{cluster:!0,cluster_id:e[t+L],point_count:o,point_count_abbreviated:i})}function z(e){return e/360+.5}function D(e){const t=Math.sin(e*Math.PI/180),r=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return r<0?0:r>1?1:r}function E(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}var N={exports:{}};N.exports=function(){function e(r,o,i,s){for(var n,a=s,l=i-o>>1,h=i-o,u=r[o],c=r[o+1],f=r[i],d=r[i+1],p=o+3;pa)n=p,a=g;else if(g===a){var m=Math.abs(p-l);ms&&(n-o>3&&e(r,o,n,s),r[n+2]=a,i-n>3&&e(r,n,i,s));}function t(e,t,r,o,i,s){var n=i-r,a=s-o;if(0!==n||0!==a){var l=((e-r)*n+(t-o)*a)/(n*n+a*a);l>1?(r=i,o=s):l>0&&(r+=n*l,o+=a*l);}return (n=e-r)*n+(a=t-o)*a}function r(e,t,r,i){var s={id:void 0===e?null:e,type:t,geometry:r,tags:i,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(e){var t=e.geometry,r=e.type;if("Point"===r||"MultiPoint"===r||"LineString"===r)o(e,t);else if("Polygon"===r||"MultiLineString"===r)for(var i=0;i0&&(a+=i?(s*f-c*n)/2:Math.sqrt(Math.pow(c-s,2)+Math.pow(f-n,2))),s=c,n=f;}var d=r.length-3;r[2]=1,e(r,0,d,o),r[d+2]=1,r.size=Math.abs(a),r.start=0,r.end=r.size;}function a(e,t,r,o){for(var i=0;i1?1:r}function u(e,t,o,i,s,n,a,l){if(i/=t,n>=(o/=t)&&a=i)return null;for(var h=[],u=0;u=o&&v=i)){var w=[];if("Point"===m||"MultiPoint"===m)c(g,w,o,i,s);else if("LineString"===m)f(g,w,o,i,s,!1,l.lineMetrics);else if("MultiLineString"===m)p(g,w,o,i,s,!1);else if("Polygon"===m)p(g,w,o,i,s,!0);else if("MultiPolygon"===m)for(var x=0;x=r&&n<=o&&(t.push(e[s]),t.push(e[s+1]),t.push(e[s+2]));}}function f(e,t,r,o,i,s,n){for(var a,l,h=d(e),u=0===i?m:y,c=e.start,f=0;fr&&(l=u(h,p,v,x,S,r),n&&(h.start=c+a*l)):M>o?b=r&&(l=u(h,p,v,x,S,r),I=!0),b>o&&M<=o&&(l=u(h,p,v,x,S,o),I=!0),!s&&I&&(n&&(h.end=c+a*l),t.push(h),h=d(e)),n&&(c+=a);}var k=e.length-3;p=e[k],v=e[k+1],w=e[k+2],(M=0===i?p:v)>=r&&M<=o&&g(h,p,v,w),k=h.length-3,s&&k>=3&&(h[k]!==h[0]||h[k+1]!==h[1])&&g(h,h[0],h[1],h[2]),h.length&&t.push(h);}function d(e){var t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function p(e,t,r,o,i,s){for(var n=0;nn.maxX&&(n.maxX=u),c>n.maxY&&(n.maxY=c);}return n}function b(e,t,r,o){var i=t.geometry,s=t.type,n=[];if("Point"===s||"MultiPoint"===s)for(var a=0;a0&&t.size<(i?n:o))r.numPoints+=t.length/3;else {for(var a=[],l=0;ln)&&(r.numSimplified++,a.push(t[l]),a.push(t[l+1])),r.numPoints++;i&&function(e,t){for(var r=0,o=0,i=e.length,s=i-2;o0===t)for(o=0,i=e.length;o24)throw new Error("maxZoom should be in the 0-24 range");if(t.promoteId&&t.generateId)throw new Error("promoteId and generateId cannot be used together.");var o=function(e,t){var r=[];if("FeatureCollection"===e.type)for(var o=0;o1&&console.time("creation"),d=this.tiles[f]=M(e,t,r,o,l),this.tileCoords.push({z:t,x:r,y:o}),h)){h>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,r,o,d.numFeatures,d.numPoints,d.numSimplified),console.timeEnd("creation"));var p="z"+t;this.stats[p]=(this.stats[p]||0)+1,this.total++;}if(d.source=e,i){if(t===l.maxZoom||t===i)continue;var g=1<1&&console.time("clipping");var m,y,v,w,x,S,b=.5*l.buffer/l.extent,I=.5-b,k=.5+b,_=1+b;m=y=v=w=null,x=u(e,c,r-b,r+k,0,d.minX,d.maxX,l),S=u(e,c,r+I,r+_,0,d.minX,d.maxX,l),e=null,x&&(m=u(x,c,o-b,o+k,1,d.minY,d.maxY,l),y=u(x,c,o+I,o+_,1,d.minY,d.maxY,l),x=null),S&&(v=u(S,c,o-b,o+k,1,d.minY,d.maxY,l),w=u(S,c,o+I,o+_,1,d.minY,d.maxY,l),S=null),h>1&&console.timeEnd("clipping"),a.push(m||[],t+1,2*r,2*o),a.push(y||[],t+1,2*r,2*o+1),a.push(v||[],t+1,2*r+1,2*o),a.push(w||[],t+1,2*r+1,2*o+1);}}},k.prototype.getTile=function(e,t,r){var o=this.options,i=o.extent,s=o.debug;if(e<0||e>24)return null;var n=1<1&&console.log("drilling down to z%d-%d-%d",e,t,r);for(var l,h=e,u=t,c=r;!l&&h>0;)h--,u=Math.floor(u/2),c=Math.floor(c/2),l=this.tiles[P(h,u,c)];return l&&l.source?(s>1&&console.log("found parent tile z%d-%d-%d",h,u,c),s>1&&console.time("drilling down"),this.splitTile(l.source,h,u,c,e,t,r),s>1&&console.timeEnd("drilling down"),this.tiles[a]?x(this.tiles[a],i):null):null},function(e,t){return new k(e,t)}}();var J=e.g(N.exports);function Y(t,r){const o=t.tileID.canonical;if(!this._geoJSONIndex)return r(null,null);const i=this._geoJSONIndex.getTile(o.z,o.x,o.y);if(!i)return r(null,null);const s=new class{constructor(t){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=e.E,this.length=t.length,this._features=t;}feature(t){return new class{constructor(t){this._feature=t,this.extent=e.E,this.type=t.type,this.properties=t.tags,"id"in t&&!isNaN(t.id)&&(this.id=parseInt(t.id,10));}loadGeometry(){if(1===this._feature.type){const t=[];for(const r of this._feature.geometry)t.push([new e.P(r[0],r[1])]);return t}{const t=[];for(const r of this._feature.geometry){const o=[];for(const t of r)o.push(new e.P(t[0],t[1]));t.push(o);}return t}}toGeoJSON(e,t,r){return l.call(this,e,t,r)}}(this._features[t])}}(i.features);let n=k(s);0===n.byteOffset&&n.byteLength===n.buffer.byteLength||(n=new Uint8Array(n)),r(null,{vectorTile:s,rawData:n.buffer});}class G extends e.d{constructor(e,t,r,o,i,s){super(e,t,r,o,Y,s),i&&(this.loadGeoJSON=i);}loadData(t,r){const o=t&&t.request,i=o&&o.collectResourceTiming;this.loadGeoJSON(t,((s,n)=>{if(s||!n)return r(s);if("object"!=typeof n)return r(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));{a(n,!0);try{if(t.filter){const r=e.e(t.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===r.result)throw new Error(r.value.map((e=>`${e.key}: ${e.message}`)).join(", "));const o=n.features.filter((e=>r.value.evaluate({zoom:0},e)));n={type:"FeatureCollection",features:o};}this._geoJSONIndex=t.cluster?new j(function({superclusterOptions:t,clusterProperties:r}){if(!r||!t)return t;const o={},i={},s={accumulated:null,zoom:0},n={properties:null},a=Object.keys(r);for(const t of a){const[s,n]=r[t],a=e.e(n),l=e.e("string"==typeof s?[s,["accumulated"],["get",t]]:s);o[t]=a.value,i[t]=l.value;}return t.map=e=>{n.properties=e;const t={};for(const e of a)t[e]=o[e].evaluate(s,n);return t},t.reduce=(e,t)=>{n.properties=t;for(const t of a)s.accumulated=e[t],e[t]=i[t].evaluate(s,n);},t}(t)).load(n.features):J(n,t.geojsonVtOptions);}catch(s){return r(s)}this.loaded={};const l={};if(i){const r=e.f(o);r&&(l.resourceTiming={},l.resourceTiming[t.source]=JSON.parse(JSON.stringify(r)));}r(null,l);}}));}reloadTile(e,t){const r=this.loaded;return r&&r[e.uid]?super.reloadTile(e,t):this.loadTile(e,t)}loadGeoJSON(t,r){if(t.request)e.h(t.request,r);else {if("string"!=typeof t.data)return r(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));try{return r(null,JSON.parse(t.data))}catch(e){return r(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(e,t){try{t(null,this._geoJSONIndex.getClusterExpansionZoom(e.clusterId));}catch(e){t(e);}}getClusterChildren(e,t){try{t(null,this._geoJSONIndex.getChildren(e.clusterId));}catch(e){t(e);}}getClusterLeaves(e,t){try{t(null,this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset));}catch(e){t(e);}}}class W{constructor(t,r){this.tileID=new e.O(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.tileZoom=t.tileZoom,this.uid=t.uid,this.zoom=t.zoom,this.canonical=t.tileID.canonical,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.projection=t.projection,this.brightness=r;}parse(t,r,o,i){this.status="parsing";const s=new e.O(o.tileID.overscaledZ,o.tileID.wrap,o.tileID.canonical.z,o.tileID.canonical.x,o.tileID.canonical.y),n={},a=r.familiesBySource[o.source],l=new e.F(s,o.promoteId);return l.bucketLayerIDs=[],e.l(t).then((t=>{if(!t)return i(new Error("Could not parse tile"));const r=e.j(t,1/e.t(o.tileID.canonical)),h=t.json.extensionsUsed&&t.json.extensionsUsed.includes("MAPBOX_mesh_features"),u=new e.k(this.zoom,{brightness:this.brightness});for(const o in a)for(const i of a[o]){const o=i[0],a=t.json.extensionsUsed;o.recalculate(u,[]);const l=new e.T(r,s,a&&a.includes("MAPBOX_mesh_features"),this.brightness);h||(l.needsUpload=!0),n[o.fqid]=l,l.evaluate(o);}this.status="done",i(null,{buckets:n,featureIndex:l});})).catch((e=>i(new Error(e.message))))}}class X{constructor(e,t,r,o,i,s){this.actor=e,this.layerIndex=t,this.brightness=s,this.loading={},this.loaded={};}loadTile(t,r){const o=t.uid,i=this.loading[o]=new W(t,this.brightness);e.i(t.request,((e,s)=>{const n=!this.loading[o];return delete this.loading[o],n||e?(i.status="done",n||(this.loaded[o]=i),r(e)):s&&0!==s.byteLength?void i.parse(s,this.layerIndex,t,((e,t)=>{i.status="done",this.loaded=this.loaded||{},this.loaded[o]=i,e||!t?r(e):r(null,t);})):(i.status="done",this.loaded[o]=i,r())}));}reloadTile(e,t){const r=this.loaded,o=e.uid;if(r&&r[o]){const i=r[o];i.projection=e.projection,i.brightness=e.brightness;const s=(r,o)=>{i.reloadCallback&&(delete i.reloadCallback,this.loadTile(e,t)),t(r,o);};"parsing"===i.status?i.reloadCallback=s:"done"===i.status&&this.loadTile(e,t);}}abortTile(e,t){const r=e.uid;this.loading[r]&&delete this.loading[r],t();}removeTile(e,t){const r=this.loaded,o=e.uid;r&&r[o]&&delete r[o],t();}}class V{constructor(t){this.self=t,this.actor=new e.A(t,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=e.m({name:"mercator"}),this.workerSourceTypes={vector:e.d,geojson:G,"batched-model":X},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(e,t)=>{if(this.workerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.workerSourceTypes[e]=t;},this.self.registerRTLTextPlugin=t=>{if(e.n.isParsed())throw new Error("RTL text plugin already registered.");e.n.applyArabicShaping=t.applyArabicShaping,e.n.processBidirectionalText=t.processBidirectionalText,e.n.processStyledBidirectionalText=t.processStyledBidirectionalText;};}clearCaches(e,t,r){delete this.layerIndexes[e],delete this.availableImages[e],delete this.workerSources[e],delete this.demWorkerSources[e],r();}checkIfReady(e,t,r){r();}setReferrer(e,t){this.referrer=t;}spriteLoaded(t,{scope:r,isLoaded:o}){if(this.isSpriteLoaded[t]||(this.isSpriteLoaded[t]={}),this.isSpriteLoaded[t][r]=o,this.workerSources[t]&&this.workerSources[t][r])for(const i in this.workerSources[t][r]){const s=this.workerSources[t][r][i];for(const t in s)s[t]instanceof e.d&&(s[t].isSpriteLoaded=o,s[t].fire(new e.o("isSpriteLoaded")));}}setImages(e,{scope:t,images:r},o){if(this.availableImages[e]||(this.availableImages[e]={}),this.availableImages[e][t]=r,this.workerSources[e]&&this.workerSources[e][t]){for(const o in this.workerSources[e][t]){const i=this.workerSources[e][t][o];for(const e in i)i[e].availableImages=r;}o();}else o();}setProjection(t,r){this.projections[t]=e.m(r);}setBrightness(e,t,r){this.brightness=t,r();}setLayers(e,t,r){this.getLayerIndex(e,t.scope).replace(t.layers,t.options),r();}updateLayers(e,t,r){this.getLayerIndex(e,t.scope).update(t.layers,t.removedIds,t.options),r();}loadTile(e,t,r){t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t.type,t.source,t.scope).loadTile(t,r);}loadDEMTile(e,t,r){this.getDEMWorkerSource(e,t.source,t.scope).loadTile(t,r);}reloadTile(e,t,r){t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t.type,t.source,t.scope).reloadTile(t,r);}abortTile(e,t,r){this.getWorkerSource(e,t.type,t.source,t.scope).abortTile(t,r);}removeTile(e,t,r){this.getWorkerSource(e,t.type,t.source,t.scope).removeTile(t,r);}removeSource(e,t,r){if(!(this.workerSources[e]&&this.workerSources[e][t.scope]&&this.workerSources[e][t.scope][t.type]&&this.workerSources[e][t.scope][t.type][t.source]))return;const o=this.workerSources[e][t.scope][t.type][t.source];delete this.workerSources[e][t.scope][t.type][t.source],void 0!==o.removeSource?o.removeSource(t,r):r();}loadWorkerSource(e,t,r){try{this.self.importScripts(t.url),r();}catch(e){r(e.toString());}}syncRTLPluginState(t,r,o){try{e.n.setState(r);const t=e.n.getPluginURL();if(e.n.isLoaded()&&!e.n.isParsed()&&null!=t){this.self.importScripts(t);const r=e.n.isParsed();o(r?void 0:new Error(`RTL Text Plugin failed to import scripts from ${t}`),r);}}catch(e){o(e.toString());}}setDracoUrl(e,t){this.dracoUrl=t;}getAvailableImages(e,t){this.availableImages[e]||(this.availableImages[e]={});let r=this.availableImages[e][t];return r||(r=[]),r}getLayerIndex(e,t){this.layerIndexes[e]||(this.layerIndexes[e]={});let r=this.layerIndexes[e][t];return r||(r=this.layerIndexes[e][t]=new o,r.scope=t),r}getWorkerSource(e,t,r,o){if(this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][o]||(this.workerSources[e][o]={}),this.workerSources[e][o][t]||(this.workerSources[e][o][t]={}),this.isSpriteLoaded[e]||(this.isSpriteLoaded[e]={}),!this.workerSources[e][o][t][r]){const i={send:(t,r,o,i,s,n)=>{this.actor.send(t,r,o,e,s,n);},scheduler:this.actor.scheduler};this.workerSources[e][o][t][r]=new this.workerSourceTypes[t](i,this.getLayerIndex(e,o),this.getAvailableImages(e,o),this.isSpriteLoaded[e][o],void 0,this.brightness);}return this.workerSources[e][o][t][r]}getDEMWorkerSource(e,t,r){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][r]||(this.demWorkerSources[e][r]={}),this.demWorkerSources[e][r][t]||(this.demWorkerSources[e][r][t]=new i),this.demWorkerSources[e][r][t]}enforceCacheSizeLimit(t,r){e.q(r);}getWorkerPerformanceMetrics(e,t,r){r(void 0,void 0);}}return "undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new V(self)),V})); + define(["./shared"],(function(e){function t(e){const t=e?e.url.toString():void 0;return t?performance.getEntriesByName(t):[]}function s(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e||null==e)return JSON.stringify(e);if(Array.isArray(e)){let t="[";for(const i of e)t+=`${s(i)},`;return `${t}]`}let t="{";for(const i of Object.keys(e).sort())t+=`${i}:${s(e[i])},`;return `${t}}`}function i(t){let i="";for(const o of e.b2)i+=`/${s(t[o])}`;return i}class o{constructor(e){this.keyCache={},this._layers={},this._layerConfigs={},e&&this.replace(e);}replace(e,t){this._layerConfigs={},this._layers={},this.update(e,[],t);}update(t,s,o){this._options=o;for(const s of t)this._layerConfigs[s.id]=s,(this._layers[s.id]=e.c2(s,this.scope,this._options)).compileFilter(),this.keyCache[s.id]&&delete this.keyCache[s.id];for(const e of s)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const r=function(e,t){const s={};for(let o=0;othis._layers[e.id])),s=t[0];if("none"===s.visibility)continue;const i=s.source||"";let o=this.familiesBySource[i];o||(o=this.familiesBySource[i]={});const r=s.sourceLayer||"_geojsonTileLayer";let n=o[r];n||(n=o[r]=[]),n.push(t);}}}const r=1*e.dA;class n{constructor(t){const s={},i=[];for(const e in t){const o=t[e],n=s[e]={};for(const e in o.glyphs){const t=o.glyphs[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const s=t.metrics.localGlyph?r:1,a={x:0,y:0,w:t.bitmap.width+2*s,h:t.bitmap.height+2*s};i.push(a),n[e]=a;}}const{w:o,h:n}=e.p(i),a=new e.dz({width:o||1,height:n||1});for(const i in t){const o=t[i];for(const t in o.glyphs){const n=o.glyphs[+t];if(!n||0===n.bitmap.width||0===n.bitmap.height)continue;const l=s[i][t],h=n.metrics.localGlyph?r:1;e.dz.copy(n.bitmap,a,{x:0,y:0},{x:l.x+h,y:l.y+h},n.bitmap);}}this.image=a,this.positions=s;}}e.dy(n,"GlyphAtlas");class a{constructor(t){this.tileID=new e.am(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.tileZoom=t.tileZoom,this.uid=t.uid,this.zoom=t.zoom,this.canonical=t.tileID.canonical,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.scope=t.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=t.showCollisionBoxes,this.collectResourceTiming=!!t.collectResourceTiming,this.promoteId=t.promoteId,this.isSymbolTile=t.isSymbolTile,this.tileTransform=e.as(t.tileID.canonical,t.projection),this.projection=t.projection,this.brightness=t.brightness,this.extraShadowCaster=!!t.extraShadowCaster;}parse(t,s,i,o,r){this.status="parsing",this.data=t,this.collisionBoxArray=new e.aD;const a=new e.dB(Object.keys(t.layers).sort()),h=new e.dC(this.tileID,this.promoteId);h.bucketLayerIDs=[];const c={},u=new e.dD(256,256),d={featureIndex:h,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:i,brightness:this.brightness},p=s.familiesBySource[this.source];for(const s in p){const o=t.layers[s];if(!o)continue;let r=!1,n=!1,u=!1;for(const e of p[s])"symbol"===e[0].type?r=!0:n=!0,e[0].is3D()&&"model"!==e[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!r)continue;if(!1===this.isSymbolTile&&!n)continue;1===o.version&&e.w(`Vector tile source "${this.source}" layer "${s}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=a.encode(s),g=[];for(let e=0;e=t.maxzoom||"none"!==t.visibility&&(l(e,this.zoom,d.brightness,i),(c[t.id]=t.createBucket({index:h.bucketLayerIDs.length,layers:e,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:f,sourceID:this.source,projection:this.projection.spec})).populate(g,d,this.tileID.canonical,this.tileTransform),h.bucketLayerIDs.push(e.map((e=>e.id)))));}}let f,g,m,y;u.trim();const v={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},x=()=>{if(f)return this.status="done",r(f);if(this.extraShadowCaster)this.status="done",r(null,{buckets:e.a$(c).filter((e=>!e.isEmpty())),featureIndex:h,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:d.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(g&&m&&y){const t=new n(g),s=new e.dF(m,y);for(const o in c){const r=c[o];r instanceof e.aE?(l(r.layers,this.zoom,d.brightness,i),e.dG(r,g,t.positions,m,s.iconPositions,this.showCollisionBoxes,i,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):r.hasPattern&&(r instanceof e.aK||r instanceof e.aL||r instanceof e.cH)&&(l(r.layers,this.zoom,d.brightness,i),r.addFeatures(d,this.tileID.canonical,s.patternPositions,i,this.tileTransform,this.brightness));}this.status="done",r(null,{buckets:e.a$(c).filter((e=>!e.isEmpty())),featureIndex:h,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:t.image,lineAtlas:u,imageAtlas:s,brightness:d.brightness});}};if(!this.extraShadowCaster){const t=e.dE(d.glyphDependencies,(e=>Object.keys(e).map(Number)));Object.keys(t).length?o.send("getGlyphs",{uid:this.uid,stacks:t,scope:this.scope},((e,t)=>{f||(f=e,g=t,x());}),void 0,!1,v):g={};const s=Object.keys(d.iconDependencies);s.length?o.send("getImages",{icons:s,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((e,t)=>{f||(f=e,m=t,x());}),void 0,!1,v):m={};const i=Object.keys(d.patternDependencies);i.length?o.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((e,t)=>{f||(f=e,y=t,x());}),void 0,!1,v):y={};}x();}}function l(t,s,i,o){const r=new e.K(s,{brightness:i});for(const e of t)e.recalculate(r,o);}class h extends e.E{constructor(t,s,i,o,r,n){super(),this.actor=t,this.layerIndex=s,this.availableImages=i,this.loadVectorData=r||e.ah,this.loading={},this.loaded={},this.deduped=new e.af(t.scheduler),this.isSpriteLoaded=o,this.scheduler=t.scheduler,this.brightness=n;}loadTile(s,i){const o=s.uid,r=s&&s.request,n=r&&r.collectResourceTiming,l=this.loading[o]=new a(s);l.abort=this.loadVectorData(s,((a,h)=>{const c=!this.loading[o];if(delete this.loading[o],c||a||!h)return l.status="done",c||(this.loaded[o]=l),i(a);const u=h.rawData,d={};h.expires&&(d.expires=h.expires),h.cacheControl&&(d.cacheControl=h.cacheControl),l.vectorTile=h.vectorTile||new e.dH(new e.dI(u));const p=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((s,o)=>{if(s||!o)return i(s);const a={};if(n){const e=t(r);e.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(e)));}i(null,e.e({rawTileData:u.slice(0)},o,d,a));}));};this.isSpriteLoaded?p():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:s.isSymbolTile,zoom:s.tileZoom}):p();})),this.loaded=this.loaded||{},this.loaded[o]=l;}));}reloadTile(t,s){const i=this.loaded,o=t.uid,r=this;if(i&&i[o]){const n=i[o];n.showCollisionBoxes=t.showCollisionBoxes,n.projection=t.projection,n.brightness=t.brightness,n.tileTransform=e.as(t.tileID.canonical,t.projection),n.extraShadowCaster=t.extraShadowCaster;const a=(e,t)=>{const i=n.reloadCallback;i&&(delete n.reloadCallback,n.parse(n.vectorTile,r.layerIndex,this.availableImages,r.actor,i)),s(e,t);};"parsing"===n.status?n.reloadCallback=a:"done"===n.status&&(n.vectorTile?n.parse(n.vectorTile,this.layerIndex,this.availableImages,this.actor,a):a());}else s(null,void 0);}abortTile(e,t){const s=e.uid,i=this.loading[s];i&&(i.abort&&i.abort(),delete this.loading[s]),t();}removeTile(e,t){const s=this.loaded,i=e.uid;s&&s[i]&&delete s[i],t();}}class c{loadTile(t,s){const{uid:i,encoding:o,rawImageData:r,padding:n}=t,a=ImageBitmap&&r instanceof ImageBitmap?this.getImageData(r,n):r;s(null,new e.dJ(i,a,o,n<1));}getImageData(e,t){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(e.width,e.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=e.width,this.offscreenCanvas.height=e.height,this.offscreenCanvasContext.drawImage(e,0,0,e.width,e.height);const s=this.offscreenCanvasContext.getImageData(-t,-t,e.width+2*t,e.height+2*t);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),s}}class u{decodeRasterArray({task:t,buffer:s},i){e.aZ.performDecoding(s,t).then((e=>{i(null,e);}),(e=>{i(e);}));}}function d(e,t){if(0!==e.length){p(e[0],t);for(var s=1;s=Math.abs(a)?s-l+a:a-l+s,s=l;}s+i>=0!=!!t&&e.reverse();}var f=e.dK((function e(t,s){var i,o=t&&t.type;if("FeatureCollection"===o)for(i=0;i>31}function j(e,t){for(var s=e.loadGeometry(),i=e.type,o=0,r=0,n=s.length,a=0;ae},A=Math.fround||(E=new Float32Array(1),e=>(E[0]=+e,E[0]));var E;const F=3,N=5,B=6;class W{constructor(e){this.options=Object.assign(Object.create(Z),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[];}load(e){const{log:t,minZoom:s,maxZoom:i}=this.options;t&&console.time("total time");const o=`prepare ${e.length} points`;t&&console.time(o),this.points=e;const r=[];for(let t=0;t=s;e--){const s=+Date.now();n=this.trees[e]=this._createTree(this._cluster(n,e)),t&&console.log("z%d: %d clusters in %dms",e,n.numItems,+Date.now()-s);}return t&&console.timeEnd("total time"),this}getClusters(e,t){let s=((e[0]+180)%360+360)%360-180;const i=Math.max(-90,Math.min(90,e[1]));let o=180===e[2]?180:((e[2]+180)%360+360)%360-180;const r=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)s=-180,o=180;else if(s>o){const e=this.getClusters([s,i,180,r],t),n=this.getClusters([-180,i,o,r],t);return e.concat(n)}const n=this.trees[this._limitZoom(t)],a=n.range(R(s),Y(r),R(o),Y(i)),l=n.data,h=[];for(const e of a){const t=this.stride*e;h.push(l[t+N]>1?G(l,t,this.clusterProps):this.points[l[t+F]]);}return h}getChildren(e){const t=this._getOriginId(e),s=this._getOriginZoom(e),i="No cluster with the specified id.",o=this.trees[s];if(!o)throw new Error(i);const r=o.data;if(t*this.stride>=r.length)throw new Error(i);const n=this.options.radius/(this.options.extent*Math.pow(2,s-1)),a=o.within(r[t*this.stride],r[t*this.stride+1],n),l=[];for(const t of a){const s=t*this.stride;r[s+4]===e&&l.push(r[s+N]>1?G(r,s,this.clusterProps):this.points[r[s+F]]);}if(0===l.length)throw new Error(i);return l}getLeaves(e,t,s){const i=[];return this._appendLeaves(i,e,t=t||10,s=s||0,0),i}getTile(e,t,s){const i=this.trees[this._limitZoom(e)],o=Math.pow(2,e),{extent:r,radius:n}=this.options,a=n/r,l=(s-a)/o,h=(s+1+a)/o,c={features:[]};return this._addTileFeatures(i.range((t-a)/o,l,(t+1+a)/o,h),i.data,t,s,o,c),0===t&&this._addTileFeatures(i.range(1-a/o,l,1,h),i.data,o,s,o,c),t===o-1&&this._addTileFeatures(i.range(0,l,a/o,h),i.data,-1,s,o,c),c.features.length?c:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const s=this.getChildren(e);if(t++,1!==s.length)break;e=s[0].properties.cluster_id;}return t}_appendLeaves(e,t,s,i,o){const r=this.getChildren(t);for(const t of r){const r=t.properties;if(r&&r.cluster?o+r.point_count<=i?o+=r.point_count:o=this._appendLeaves(e,r.cluster_id,s,i,o):o1;let l,h,c;if(a)l=J(t,e,this.clusterProps),h=t[e],c=t[e+1];else {const s=this.points[t[e+F]];l=s.properties;const[i,o]=s.geometry.coordinates;h=R(i),c=Y(o);}const u={type:1,geometry:[[Math.round(this.options.extent*(h*o-s)),Math.round(this.options.extent*(c*o-i))]],tags:l};let d;d=a||this.options.generateId?t[e+F]:this.points[t[e+F]].id,void 0!==d&&(u.id=d),r.features.push(u);}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){const{radius:s,extent:i,reduce:o,minPoints:r}=this.options,n=s/(i*Math.pow(2,t)),a=e.data,l=[],h=this.stride;for(let s=0;st&&(p+=a[s+N]);}if(p>d&&p>=r){let e,r=i*d,n=c*d,f=-1;const g=(s/h<<5)+(t+1)+this.points.length;for(const i of u){const l=i*h;if(a[l+2]<=t)continue;a[l+2]=t;const c=a[l+N];r+=a[l]*c,n+=a[l+1]*c,a[l+4]=g,o&&(e||(e=this._map(a,s,!0),f=this.clusterProps.length,this.clusterProps.push(e)),o(e,this._map(a,l)));}a[s+4]=g,l.push(r/p,n/p,1/0,g,-1,p),o&&l.push(f);}else {for(let e=0;e1)for(const e of u){const s=e*h;if(!(a[s+2]<=t)){a[s+2]=t;for(let e=0;e>5}_getOriginZoom(e){return (e-this.points.length)%32}_map(e,t,s){if(e[t+N]>1){const i=this.clusterProps[e[t+B]];return s?Object.assign({},i):i}const i=this.points[e[t+F]].properties,o=this.options.map(i);return s&&o===i?Object.assign({},o):o}}function G(e,t,s){return {type:"Feature",id:e[t+F],properties:J(e,t,s),geometry:{type:"Point",coordinates:[(i=e[t],360*(i-.5)),X(e[t+1])]}};var i;}function J(e,t,s){const i=e[t+N],o=i>=1e4?`${Math.round(i/1e3)}k`:i>=1e3?Math.round(i/100)/10+"k":i,r=e[t+B],n=-1===r?{}:Object.assign({},s[r]);return Object.assign(n,{cluster:!0,cluster_id:e[t+F],point_count:i,point_count_abbreviated:o})}function R(e){return e/360+.5}function Y(e){const t=Math.sin(e*Math.PI/180),s=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return s<0?0:s>1?1:s}function X(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}var V={exports:{}};V.exports=function(){function e(s,i,o,r){for(var n,a=r,l=o-i>>1,h=o-i,c=s[i],u=s[i+1],d=s[o],p=s[o+1],f=i+3;fa)n=f,a=g;else if(g===a){var m=Math.abs(f-l);mr&&(n-i>3&&e(s,i,n,r),s[n+2]=a,o-n>3&&e(s,n,o,r));}function t(e,t,s,i,o,r){var n=o-s,a=r-i;if(0!==n||0!==a){var l=((e-s)*n+(t-i)*a)/(n*n+a*a);l>1?(s=o,i=r):l>0&&(s+=n*l,i+=a*l);}return (n=e-s)*n+(a=t-i)*a}function s(e,t,s,o){var r={id:void 0===e?null:e,type:t,geometry:s,tags:o,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(e){var t=e.geometry,s=e.type;if("Point"===s||"MultiPoint"===s||"LineString"===s)i(e,t);else if("Polygon"===s||"MultiLineString"===s)for(var o=0;o0&&(a+=o?(r*d-u*n)/2:Math.sqrt(Math.pow(u-r,2)+Math.pow(d-n,2))),r=u,n=d;}var p=s.length-3;s[2]=1,e(s,0,p,i),s[p+2]=1,s.size=Math.abs(a),s.start=0,s.end=s.size;}function a(e,t,s,i){for(var o=0;o1?1:s}function c(e,t,i,o,r,n,a,l){if(o/=t,n>=(i/=t)&&a=o)return null;for(var h=[],c=0;c=i&&v=o)){var x=[];if("Point"===m||"MultiPoint"===m)u(g,x,i,o,r);else if("LineString"===m)d(g,x,i,o,r,!1,l.lineMetrics);else if("MultiLineString"===m)f(g,x,i,o,r,!1);else if("Polygon"===m)f(g,x,i,o,r,!0);else if("MultiPolygon"===m)for(var w=0;w=s&&n<=i&&(t.push(e[r]),t.push(e[r+1]),t.push(e[r+2]));}}function d(e,t,s,i,o,r,n){for(var a,l,h=p(e),c=0===o?m:y,u=e.start,d=0;ds&&(l=c(h,f,v,w,S,s),n&&(h.start=u+a*l)):b>i?I=s&&(l=c(h,f,v,w,S,s),M=!0),I>i&&b<=i&&(l=c(h,f,v,w,S,i),M=!0),!r&&M&&(n&&(h.end=u+a*l),t.push(h),h=p(e)),n&&(u+=a);}var k=e.length-3;f=e[k],v=e[k+1],x=e[k+2],(b=0===o?f:v)>=s&&b<=i&&g(h,f,v,x),k=h.length-3,r&&k>=3&&(h[k]!==h[0]||h[k+1]!==h[1])&&g(h,h[0],h[1],h[2]),h.length&&t.push(h);}function p(e){var t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function f(e,t,s,i,o,r){for(var n=0;nn.maxX&&(n.maxX=c),u>n.maxY&&(n.maxY=u);}return n}function I(e,t,s,i){var o=t.geometry,r=t.type,n=[];if("Point"===r||"MultiPoint"===r)for(var a=0;a0&&t.size<(o?n:i))s.numPoints+=t.length/3;else {for(var a=[],l=0;ln)&&(s.numSimplified++,a.push(t[l]),a.push(t[l+1])),s.numPoints++;o&&function(e,t){for(var s=0,i=0,o=e.length,r=o-2;i0===t)for(i=0,o=e.length;i24)throw new Error("maxZoom should be in the 0-24 range");if(t.promoteId&&t.generateId)throw new Error("promoteId and generateId cannot be used together.");var i=function(e,t){var s=[];if("FeatureCollection"===e.type)for(var i=0;i1&&console.time("creation"),p=this.tiles[d]=b(e,t,s,i,l),this.tileCoords.push({z:t,x:s,y:i}),h)){h>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,s,i,p.numFeatures,p.numPoints,p.numSimplified),console.timeEnd("creation"));var f="z"+t;this.stats[f]=(this.stats[f]||0)+1,this.total++;}if(p.source=e,o){if(t===l.maxZoom||t===o)continue;var g=1<1&&console.time("clipping");var m,y,v,x,w,S,I=.5*l.buffer/l.extent,M=.5-I,k=.5+I,P=1+I;m=y=v=x=null,w=c(e,u,s-I,s+k,0,p.minX,p.maxX,l),S=c(e,u,s+M,s+P,0,p.minX,p.maxX,l),e=null,w&&(m=c(w,u,i-I,i+k,1,p.minY,p.maxY,l),y=c(w,u,i+M,i+P,1,p.minY,p.maxY,l),w=null),S&&(v=c(S,u,i-I,i+k,1,p.minY,p.maxY,l),x=c(S,u,i+M,i+P,1,p.minY,p.maxY,l),S=null),h>1&&console.timeEnd("clipping"),a.push(m||[],t+1,2*s,2*i),a.push(y||[],t+1,2*s,2*i+1),a.push(v||[],t+1,2*s+1,2*i),a.push(x||[],t+1,2*s+1,2*i+1);}}},k.prototype.getTile=function(e,t,s){var i=this.options,o=i.extent,r=i.debug;if(e<0||e>24)return null;var n=1<1&&console.log("drilling down to z%d-%d-%d",e,t,s);for(var l,h=e,c=t,u=s;!l&&h>0;)h--,c=Math.floor(c/2),u=Math.floor(u/2),l=this.tiles[T(h,c,u)];return l&&l.source?(r>1&&console.log("found parent tile z%d-%d-%d",h,c,u),r>1&&console.time("drilling down"),this.splitTile(l.source,h,c,u,e,t,s),r>1&&console.timeEnd("drilling down"),this.tiles[a]?w(this.tiles[a],o):null):null},function(e,t){return new k(e,t)}}();var $=e.dK(V.exports);function U(e,t){const s=e.tileID.canonical;if(!this._geoJSONIndex)return t(null,null);const i=this._geoJSONIndex.getTile(s.z,s.x,s.y);if(!i)return t(null,null);const o=new y(i.features);let r=z(o);0===r.byteOffset&&r.byteLength===r.buffer.byteLength||(r=new Uint8Array(r)),t(null,{vectorTile:o,rawData:r.buffer});}class q extends h{constructor(e,t,s,i,o,r){super(e,t,s,i,U,r),o&&(this.loadGeoJSON=o);}loadData(s,i){const o=s&&s.request,r=o&&o.collectResourceTiming;this.loadGeoJSON(s,((n,a)=>{if(n||!a)return i(n);if("object"!=typeof a)return i(new Error(`Input data given to '${s.source}' is not a valid GeoJSON object.`));{f(a,!0);try{if(s.filter){const t=e.r(s.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===t.result)throw new Error(t.value.map((e=>`${e.key}: ${e.message}`)).join(", "));const i=a.features.filter((e=>t.value.evaluate({zoom:0},e)));a={type:"FeatureCollection",features:i};}this._geoJSONIndex=s.cluster?new W(function({superclusterOptions:t,clusterProperties:s}){if(!s||!t)return t;const i={},o={},r={accumulated:null,zoom:0},n={properties:null},a=Object.keys(s);for(const t of a){const[r,n]=s[t],a=e.r(n),l=e.r("string"==typeof r?[r,["accumulated"],["get",t]]:r);i[t]=a.value,o[t]=l.value;}return t.map=e=>{n.properties=e;const t={};for(const e of a)t[e]=i[e].evaluate(r,n);return t},t.reduce=(e,t)=>{n.properties=t;for(const t of a)r.accumulated=e[t],e[t]=o[t].evaluate(r,n);},t}(s)).load(a.features):$(a,s.geojsonVtOptions);}catch(n){return i(n)}this.loaded={};const l={};if(r){const e=t(o);e&&(l.resourceTiming={},l.resourceTiming[s.source]=JSON.parse(JSON.stringify(e)));}i(null,l);}}));}reloadTile(e,t){const s=this.loaded;return s&&s[e.uid]?super.reloadTile(e,t):this.loadTile(e,t)}loadGeoJSON(t,s){if(t.request)e.g(t.request,s);else {if("string"!=typeof t.data)return s(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));try{return s(null,JSON.parse(t.data))}catch(e){return s(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(e,t){try{t(null,this._geoJSONIndex.getClusterExpansionZoom(e.clusterId));}catch(e){t(e);}}getClusterChildren(e,t){try{t(null,this._geoJSONIndex.getChildren(e.clusterId));}catch(e){t(e);}}getClusterLeaves(e,t){try{t(null,this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset));}catch(e){t(e);}}}class K{constructor(t,s){this.tileID=new e.am(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.tileZoom=t.tileZoom,this.uid=t.uid,this.zoom=t.zoom,this.canonical=t.tileID.canonical,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.projection=t.projection,this.brightness=s;}parse(t,s,i,o){this.status="parsing";const r=new e.am(i.tileID.overscaledZ,i.tileID.wrap,i.tileID.canonical.z,i.tileID.canonical.x,i.tileID.canonical.y),n={},a=s.familiesBySource[i.source],l=new e.dC(r,i.promoteId);return l.bucketLayerIDs=[],l.is3DTile=!0,e.dP(t).then((t=>{if(!t)return o(new Error("Could not parse tile"));const s=e.dQ(t,1/e.bR(i.tileID.canonical)),h=t.json.extensionsUsed&&t.json.extensionsUsed.includes("MAPBOX_mesh_features")||t.json.asset.extras&&t.json.asset.extras.MAPBOX_mesh_features,c=t.json.extensionsUsed&&t.json.extensionsUsed.includes("EXT_meshopt_compression"),u=new e.K(this.zoom,{brightness:this.brightness});for(const t in a)for(const i of a[t]){const t=i[0];l.bucketLayerIDs.push(i.map((e=>e.id))),t.recalculate(u,[]);const o=new e.dR(s,r,h,c,this.brightness,l);h||(o.needsUpload=!0),n[t.fqid]=o,o.evaluate(t);}this.status="done",o(null,{buckets:n,featureIndex:l});})).catch((e=>o(new Error(e.message))))}}class H{constructor(e,t,s,i,o,r){this.actor=e,this.layerIndex=t,this.brightness=r,this.loading={},this.loaded={};}loadTile(t,s){const i=t.uid,o=this.loading[i]=new K(t,this.brightness);e.a_(t.request,((e,r)=>{const n=!this.loading[i];return delete this.loading[i],n||e?(o.status="done",n||(this.loaded[i]=o),s(e)):r&&0!==r.byteLength?void o.parse(r,this.layerIndex,t,((e,t)=>{o.status="done",this.loaded=this.loaded||{},this.loaded[i]=o,e||!t?s(e):s(null,t);})):(o.status="done",this.loaded[i]=o,s())}));}reloadTile(e,t){const s=this.loaded,i=e.uid;if(s&&s[i]){const o=s[i];o.projection=e.projection,o.brightness=e.brightness;const r=(s,i)=>{o.reloadCallback&&(delete o.reloadCallback,this.loadTile(e,t)),t(s,i);};"parsing"===o.status?o.reloadCallback=r:"done"===o.status&&this.loadTile(e,t);}}abortTile(e,t){const s=e.uid;this.loading[s]&&delete this.loading[s],t();}removeTile(e,t){const s=this.loaded,i=e.uid;s&&s[i]&&delete s[i],t();}}class Q{constructor(t){this.self=t,this.actor=new e.dS(t,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=e.bo({name:"mercator"}),this.workerSourceTypes={vector:h,geojson:q,"batched-model":H},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(e,t)=>{if(this.workerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.workerSourceTypes[e]=t;},this.self.registerRTLTextPlugin=t=>{if(e.dT.isParsed())throw new Error("RTL text plugin already registered.");e.dT.applyArabicShaping=t.applyArabicShaping,e.dT.processBidirectionalText=t.processBidirectionalText,e.dT.processStyledBidirectionalText=t.processStyledBidirectionalText;};}clearCaches(e,t,s){delete this.layerIndexes[e],delete this.availableImages[e],delete this.workerSources[e],delete this.demWorkerSources[e],delete this.rasterArrayWorkerSource,s();}checkIfReady(e,t,s){s();}setReferrer(e,t){this.referrer=t;}spriteLoaded(t,{scope:s,isLoaded:i}){if(this.isSpriteLoaded[t]||(this.isSpriteLoaded[t]={}),this.isSpriteLoaded[t][s]=i,this.workerSources[t]&&this.workerSources[t][s])for(const o in this.workerSources[t][s]){const r=this.workerSources[t][s][o];for(const t in r)r[t]instanceof h&&(r[t].isSpriteLoaded=i,r[t].fire(new e.b("isSpriteLoaded")));}}setImages(e,{scope:t,images:s},i){if(this.availableImages[e]||(this.availableImages[e]={}),this.availableImages[e][t]=s,this.workerSources[e]&&this.workerSources[e][t]){for(const i in this.workerSources[e][t]){const o=this.workerSources[e][t][i];for(const e in o)o[e].availableImages=s;}i();}else i();}setProjection(t,s){this.projections[t]=e.bo(s);}setBrightness(e,t,s){this.brightness=t,s();}setLayers(e,t,s){this.getLayerIndex(e,t.scope).replace(t.layers,t.options),s();}updateLayers(e,t,s){this.getLayerIndex(e,t.scope).update(t.layers,t.removedIds,t.options),s();}loadTile(e,t,s){t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t.type,t.source,t.scope).loadTile(t,s);}loadDEMTile(e,t,s){this.getDEMWorkerSource(e,t.source,t.scope).loadTile(t,s);}decodeRasterArray(e,t,s){this.getRasterArrayWorkerSource().decodeRasterArray(t,s);}reloadTile(e,t,s){t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t.type,t.source,t.scope).reloadTile(t,s);}abortTile(e,t,s){this.getWorkerSource(e,t.type,t.source,t.scope).abortTile(t,s);}removeTile(e,t,s){this.getWorkerSource(e,t.type,t.source,t.scope).removeTile(t,s);}removeSource(e,t,s){if(!(this.workerSources[e]&&this.workerSources[e][t.scope]&&this.workerSources[e][t.scope][t.type]&&this.workerSources[e][t.scope][t.type][t.source]))return;const i=this.workerSources[e][t.scope][t.type][t.source];delete this.workerSources[e][t.scope][t.type][t.source],void 0!==i.removeSource?i.removeSource(t,s):s();}loadWorkerSource(e,t,s){try{this.self.importScripts(t.url),s();}catch(e){s(e.toString());}}syncRTLPluginState(t,s,i){try{e.dT.setState(s);const t=e.dT.getPluginURL();if(e.dT.isLoaded()&&!e.dT.isParsed()&&null!=t){this.self.importScripts(t);const s=e.dT.isParsed();i(s?void 0:new Error(`RTL Text Plugin failed to import scripts from ${t}`),s);}}catch(e){i(e.toString());}}setDracoUrl(e,t){this.dracoUrl=t;}getAvailableImages(e,t){this.availableImages[e]||(this.availableImages[e]={});let s=this.availableImages[e][t];return s||(s=[]),s}getLayerIndex(e,t){this.layerIndexes[e]||(this.layerIndexes[e]={});let s=this.layerIndexes[e][t];return s||(s=this.layerIndexes[e][t]=new o,s.scope=t),s}getWorkerSource(e,t,s,i){if(this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][i]||(this.workerSources[e][i]={}),this.workerSources[e][i][t]||(this.workerSources[e][i][t]={}),this.isSpriteLoaded[e]||(this.isSpriteLoaded[e]={}),!this.workerSources[e][i][t][s]){const o={send:(t,s,i,o,r,n)=>{this.actor.send(t,s,i,e,r,n);},scheduler:this.actor.scheduler};this.workerSources[e][i][t][s]=new this.workerSourceTypes[t](o,this.getLayerIndex(e,i),this.getAvailableImages(e,i),this.isSpriteLoaded[e][i],void 0,this.brightness);}return this.workerSources[e][i][t][s]}getDEMWorkerSource(e,t,s){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][s]||(this.demWorkerSources[e][s]={}),this.demWorkerSources[e][s][t]||(this.demWorkerSources[e][s][t]=new c),this.demWorkerSources[e][s][t]}getRasterArrayWorkerSource(){return this.rasterArrayWorkerSource||(this.rasterArrayWorkerSource=new u),this.rasterArrayWorkerSource}enforceCacheSizeLimit(t,s){e.dU(s);}getWorkerPerformanceMetrics(e,t,s){s(void 0,void 0);}}return "undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new Q(self)),Q})); - define(["./shared"],(function(e){return e.s})); + define(["./shared"],(function(e){function t(e,i){if(Array.isArray(e)){if(!Array.isArray(i)||e.length!==i.length)return !1;for(let o=0;o{window.removeEventListener("click",d,!0);}),0);}function p(e,t){const i=e.getBoundingClientRect();return g(e,i,t)}function f(e,t){const i=e.getBoundingClientRect(),o=[];for(let r=0;r=0?0:e.button}function g(t,i,o){const r=t.offsetWidth===i.width?1:t.offsetWidth/i.width;return new e.P((o.clientX-i.left)*r,(o.clientY-i.top)*r)}class v{constructor(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps=new Set,this._updatedImages=new Set;}isDirty(){return this._changed}setDirty(){this._changed=!0;}getUpdatedSourceCaches(){return this._updatedSourceCaches}updateSourceCache(e,t){this._updatedSourceCaches[e]=t,this.setDirty();}discardSourceCacheUpdate(e){delete this._updatedSourceCaches[e];}updateLayer(e){const t=e.scope;this._updatedLayers[t]=this._updatedLayers[t]||new Set,this._updatedLayers[t].add(e.id),this.setDirty();}removeLayer(e){const t=e.scope;this._removedLayers[t]=this._removedLayers[t]||{},this._updatedLayers[t]=this._updatedLayers[t]||new Set,this._removedLayers[t][e.id]=e,this._updatedLayers[t].delete(e.id),this._updatedPaintProps.delete(e.fqid),this.setDirty();}getRemovedLayer(e){return this._removedLayers[e.scope]?this._removedLayers[e.scope][e.id]:null}discardLayerRemoval(e){this._removedLayers[e.scope]&&delete this._removedLayers[e.scope][e.id];}getLayerUpdatesByScope(){const e={};for(const t in this._updatedLayers)e[t]=e[t]||{},e[t].updatedIds=Array.from(this._updatedLayers[t].values());for(const t in this._removedLayers)e[t]=e[t]||{},e[t].removedIds=Object.keys(this._removedLayers[t]);return e}getUpdatedPaintProperties(){return this._updatedPaintProps}updatePaintProperties(e){this._updatedPaintProps.add(e.fqid),this.setDirty();}getUpdatedImages(){return Array.from(this._updatedImages.values())}updateImage(e){this._updatedImages.add(e),this.setDirty();}resetUpdatedImages(){this._updatedImages.clear();}reset(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps.clear(),this._updatedImages.clear();}}class x extends e.E{constructor(e){super(),this.requestManager=e,this.models={"":{}},this.numModelsLoading={};}loadModel(t,i){return e.l(this.requestManager.transformRequest(i,e.R.Model).url).then((i=>{if(!i)return;const o=e.c(i),r=new e.M(t,void 0,void 0,o);return r.computeBoundsAndApplyParent(),r})).catch((o=>{this.fire(new e.a(new Error(`Could not load model ${t} from ${i}: ${o.message}`)));}))}load(t,i){this.models[i]||(this.models[i]={});const o=Object.keys(t);this.numModelsLoading[i]=(this.numModelsLoading[i]||0)+o.length;const r=[];for(const e of o)r.push(this.loadModel(e,t[e]));Promise.allSettled(r).then((t=>{for(let e=0;e{this.fire(new e.a(new Error(`Could not load models: ${t.message}`)));}));}isLoaded(){for(const e in this.numModelsLoading)if(this.numModelsLoading[e]>0)return !1;return !0}hasModel(e,t){return !!this.getModel(e,t)}getModel(e,t){return this.models[t]||(this.models[t]={}),this.models[t][e]}addModel(e,t,i){this.models[i]||(this.models[i]={}),this.hasModel(e,i)&&this.removeModel(e,i),this.load({[e]:this.requestManager.normalizeModelURL(t)},i);}addModels(e,t){const i={};for(const t in e)i[t]=this.requestManager.normalizeModelURL(e[t]);this.load(i,t);}removeModel(e,t){this.models[t]||(this.models[t]={});const i=this.models[t][e];delete this.models[t][e],i.destroy();}listModels(e){return this.models[e]||(this.models[e]={}),Object.keys(this.models[e])}upload(e,t){this.models[t]||(this.models[t]={});for(const i in this.models[t])this.models[t][i].upload(e.context);}}class y{constructor(){this.state={},this.stateChanges={},this.deletedStates={};}updateState(t,i,o){const r=String(i);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][r]=this.stateChanges[t][r]||{},e.e(this.stateChanges[t][r],o),null===this.deletedStates[t]){this.deletedStates[t]={};for(const e in this.state[t])e!==r&&(this.deletedStates[t][e]=null);}else if(this.deletedStates[t]&&null===this.deletedStates[t][r]){this.deletedStates[t][r]={};for(const e in this.state[t][r])o[e]||(this.deletedStates[t][r][e]=null);}else for(const e in o)this.deletedStates[t]&&this.deletedStates[t][r]&&null===this.deletedStates[t][r][e]&&delete this.deletedStates[t][r][e];}removeFeatureState(e,t,i){if(null===this.deletedStates[e])return;const o=String(t);if(this.deletedStates[e]=this.deletedStates[e]||{},i&&void 0!==t)null!==this.deletedStates[e][o]&&(this.deletedStates[e][o]=this.deletedStates[e][o]||{},this.deletedStates[e][o][i]=null);else if(void 0!==t)if(this.stateChanges[e]&&this.stateChanges[e][o])for(i in this.deletedStates[e][o]={},this.stateChanges[e][o])this.deletedStates[e][o][i]=null;else this.deletedStates[e][o]=null;else this.deletedStates[e]=null;}getState(t,i){const o=String(i),r=e.e({},(this.state[t]||{})[o],(this.stateChanges[t]||{})[o]);if(null===this.deletedStates[t])return {};if(this.deletedStates[t]){const e=this.deletedStates[t][i];if(null===e)return {};for(const t in e)delete r[t];}return r}initializeTileState(e,t){e.setFeatureState(this.state,t);}coalesceChanges(t,i){const o={};for(const t in this.stateChanges){this.state[t]=this.state[t]||{};const i={};for(const o in this.stateChanges[t])this.state[t][o]||(this.state[t][o]={}),e.e(this.state[t][o],this.stateChanges[t][o]),i[o]=this.state[t][o];o[t]=i;}for(const t in this.deletedStates){this.state[t]=this.state[t]||{};const i={};if(null===this.deletedStates[t])for(const e in this.state[t])i[e]={},this.state[t][e]={};else for(const e in this.deletedStates[t]){if(null===this.deletedStates[t][e])this.state[t][e]={};else if(this.state[t][e])for(const i of Object.keys(this.deletedStates[t][e]))delete this.state[t][e][i];i[e]=this.state[t][e];}o[t]=o[t]||{},e.e(o[t],i);}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(o).length)for(const e in t)t[e].setFeatureState(o,i);}}function b(e){const{userImage:t}=e;return !!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class w extends e.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded={},this.requestors=[],this.patterns={},this.atlasImage={},this.atlasTexture={},this.dirty=!0;}createScope(t){this.images[t]={},this.loaded[t]=!1,this.updatedImages[t]={},this.patterns[t]={},this.callbackDispatchedThisFrame[t]={},this.atlasImage[t]=new e.h({width:1,height:1});}isLoaded(){for(const e in this.loaded)if(!this.loaded[e])return !1;return !0}setLoaded(e,t){if(this.loaded[t]!==e&&(this.loaded[t]=e,e)){for(const{ids:e,callback:i}of this.requestors)this._notify(e,t,i);this.requestors=[];}}hasImage(e,t){return !!this.getImage(e,t)}getImage(e,t){return this.images[t][e]}addImage(e,t,i){this._validate(e,i)&&(this.images[t][e]=i);}_validate(t,i){let o=!0;return this._validateStretch(i.stretchX,i.data&&i.data.width)||(this.fire(new e.a(new Error(`Image "${t}" has invalid "stretchX" value`))),o=!1),this._validateStretch(i.stretchY,i.data&&i.data.height)||(this.fire(new e.a(new Error(`Image "${t}" has invalid "stretchY" value`))),o=!1),this._validateContent(i.content,i)||(this.fire(new e.a(new Error(`Image "${t}" has invalid "content" value`))),o=!1),o}_validateStretch(e,t){if(!e)return !0;let i=0;for(const o of e){if(o[0]s)return [new T(i,o,`${o} is greater than the maximum value ${s}`)]}return []}function D(t){const i=t.valueSpec,o=e.u(t.value.type);let r,s,n,a={};const l="categorical"!==o&&void 0===t.value.property,c=!l,h="array"===e.i(t.value.stops)&&"array"===e.i(t.value.stops[0])&&"object"===e.i(t.value.stops[0][0]),u=S({key:t.key,value:t.value,valueSpec:t.styleSpec.function,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===o)return [new T(t.key,t.value,'identity function may not have a "stops" property')];let i=[];const r=t.value;return i=i.concat(C({key:t.key,value:r,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:d})),"array"===e.i(r)&&0===r.length&&i.push(new T(t.key,r,"array must have at least one stop")),i},default:function(e){return $({key:e.key,value:e.value,valueSpec:i,style:e.style,styleSpec:e.styleSpec})}}});return "identity"===o&&l&&u.push(new T(t.key,t.value,'missing required property "property"')),"identity"===o||t.value.stops||u.push(new T(t.key,t.value,'missing required property "stops"')),"exponential"===o&&t.valueSpec.expression&&!e.s(t.valueSpec)&&u.push(new T(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(c&&!e.k(t.valueSpec)?u.push(new T(t.key,t.value,"property functions not supported")):l&&!e.m(t.valueSpec)&&u.push(new T(t.key,t.value,"zoom functions not supported"))),"categorical"!==o&&!h||void 0!==t.value.property||u.push(new T(t.key,t.value,'"property" property is required')),u;function d(t){let o=[];const r=t.value,l=t.key;if("array"!==e.i(r))return [new T(l,r,`array expected, ${e.i(r)} found`)];if(2!==r.length)return [new T(l,r,`array length 2 expected, length ${r.length} found`)];if(h){if("object"!==e.i(r[0]))return [new T(l,r,`object expected, ${e.i(r[0])} found`)];if(void 0===r[0].zoom)return [new T(l,r,"object stop key must have zoom")];if(void 0===r[0].value)return [new T(l,r,"object stop key must have value")];const i=e.u(r[0].zoom);if("number"!=typeof i)return [new T(l,r[0].zoom,"stop zoom values must be numbers")];if(n&&n>i)return [new T(l,r[0].zoom,"stop zoom values must appear in ascending order")];i!==n&&(n=i,s=void 0,a={}),o=o.concat(S({key:`${l}[0]`,value:r[0],valueSpec:{zoom:{}},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:I,value:_}}));}else o=o.concat(_({key:`${l}[0]`,value:r[0],valueSpec:{},style:t.style,styleSpec:t.styleSpec},r));return e.n(e.o(r[1]))?o.concat([new T(`${l}[1]`,r[1],"expressions are not allowed in function stops.")]):o.concat($({key:`${l}[1]`,value:r[1],valueSpec:i,style:t.style,styleSpec:t.styleSpec}))}function _(t,n){const l=e.i(t.value),c=e.u(t.value),h=null!==t.value?t.value:n;if(r){if(l!==r)return [new T(t.key,h,`${l} stop domain type must match previous stop domain type ${r}`)]}else r=l;if("number"!==l&&"string"!==l&&"boolean"!==l&&"number"!=typeof c&&"string"!=typeof c&&"boolean"!=typeof c)return [new T(t.key,h,"stop domain value must be a number, string, or boolean")];if("number"!==l&&"categorical"!==o){let r=`number expected, ${l} found`;return e.k(i)&&void 0===o&&(r+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new T(t.key,h,r)]}return "categorical"!==o||"number"!==l||"number"==typeof c&&isFinite(c)&&Math.floor(c)===c?"categorical"!==o&&"number"===l&&"number"==typeof c&&"number"==typeof s&&void 0!==s&&cnew T(`${t.key}${e.key}`,t.value,e.message)));const o=i.value.expression||i.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!o.outputDefined())return [new T(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===t.expressionContext&&"layout"===t.propertyType&&!e.t(o))return [new T(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext)return A(o,t);if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!e.v(o,["zoom","feature-state"]))return [new T(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!e.x(o))return [new T(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return []}function A(t,i){const o=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(i.valueSpec&&i.valueSpec.expression)for(const e of i.valueSpec.expression.parameters)o.delete(e);if(0===o.size)return [];const r=[];return t instanceof e.C&&o.has(t.name)?[new T(i.key,i.value,`["${t.name}"] expression is not supported in a filter for a ${i.object.type} layer with id: ${i.object.id}`)]:(t.eachChild((e=>{r.push(...A(e,i));})),r)}function R(t){const i=t.key,o=t.value,r=t.valueSpec,s=[];return Array.isArray(r.values)?-1===r.values.indexOf(e.u(o))&&s.push(new T(i,o,`expected one of [${r.values.join(", ")}], ${JSON.stringify(o)} found`)):-1===Object.keys(r.values).indexOf(e.u(o))&&s.push(new T(i,o,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(o)} found`)),s}function P(t){return e.z(e.o(t.value))?L(e.j({},t,{expressionContext:"filter",valueSpec:t.styleSpec[`filter_${t.layerType||"fill"}`]})):M(t)}function M(t){const i=t.value,o=t.key;if("array"!==e.i(i))return [new T(o,i,`array expected, ${e.i(i)} found`)];const r=t.styleSpec;let s,n=[];if(i.length<1)return [new T(o,i,"filter array must have at least 1 element")];switch(n=n.concat(R({key:`${o}[0]`,value:i[0],valueSpec:r.filter_operator,style:t.style,styleSpec:t.styleSpec})),e.u(i[0])){case"<":case"<=":case">":case">=":i.length>=2&&"$type"===e.u(i[1])&&n.push(new T(o,i,`"$type" cannot be use with operator "${i[0]}"`));case"==":case"!=":3!==i.length&&n.push(new T(o,i,`filter array for operator "${i[0]}" must have 3 elements`));case"in":case"!in":i.length>=2&&(s=e.i(i[1]),"string"!==s&&n.push(new T(`${o}[1]`,i[1],`string expected, ${s} found`)));for(let a=2;a{e in o&&i.push(new T(r,o[e],`"${e}" is prohibited for ref layers`));})),s.layers.forEach((i=>{e.u(i.id)===l&&(t=i);})),t?t.ref?i.push(new T(r,o.ref,"ref cannot reference another ref layer")):a=e.u(t.type):"string"==typeof l&&i.push(new T(r,o.ref,`ref layer "${l}" not found`));}else if("background"!==a&&"sky"!==a&&"slot"!==a)if(o.source){const t=s.sources&&s.sources[o.source],n=t&&e.u(t.type);t?"vector"===n&&"raster"===a?i.push(new T(r,o.source,`layer "${o.id}" requires a raster source`)):"raster"===n&&"raster"!==a?i.push(new T(r,o.source,`layer "${o.id}" requires a vector source`)):"vector"!==n||o["source-layer"]?"raster-dem"===n&&"hillshade"!==a?i.push(new T(r,o.source,"raster-dem source can only be used with layer type 'hillshade'.")):"raster-array"!==n||["raster","raster-particle"].includes(a)?"line"!==a||!o.paint||!o.paint["line-gradient"]&&!o.paint["line-trim-offset"]||"geojson"===n&&t.lineMetrics?"raster-particle"===a&&"raster-array"!==n&&i.push(new T(r,o.source,`layer "${o.id}" requires a 'raster-array' source.`)):i.push(new T(r,o,`layer "${o.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):i.push(new T(r,o.source,"raster-array source can only be used with layer type 'raster'.")):i.push(new T(r,o,`layer "${o.id}" must specify a "source-layer"`)):i.push(new T(r,o.source,`source "${o.source}" not found`));}else i.push(new T(r,o,'missing required property "source"'));return i=i.concat(S({key:r,value:o,valueSpec:n.layer,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":()=>[],type:()=>$({key:`${r}.type`,value:o.type,valueSpec:n.layer.type,style:t.style,styleSpec:t.styleSpec,object:o,objectKey:"type"}),filter:t=>P(e.j({layerType:a},t)),layout:t=>S({layer:o,key:t.key,value:t.value,valueSpec:{},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":t=>F(e.j({layerType:a},t))}}),paint:t=>S({layer:o,key:t.key,value:t.value,valueSpec:{},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":t=>O(e.j({layerType:a,layer:o},t))}})}})),i}function k(t){const i=t.value,o=t.key,r=e.i(i);return "string"!==r?[new T(o,i,`string expected, ${r} found`)]:[]}const N={promoteId:function({key:t,value:i}){if("string"===e.i(i))return k({key:t,value:i});{const e=[];for(const o in i)e.push(...k({key:`${t}.${o}`,value:i[o]}));return e}}};function U(t){const i=t.value,o=t.key,r=t.styleSpec,s=t.style;if(!i.type)return [new T(o,i,'"type" is required')];const n=e.u(i.type);let a=[];switch(["vector","raster","raster-dem","raster-array"].includes(n)&&(i.url||i.tiles||a.push(new E(o,i,'Either "url" or "tiles" is required.'))),n){case"vector":case"raster":case"raster-dem":case"raster-array":return a=a.concat(S({key:o,value:i,valueSpec:r[`source_${n.replace("-","_")}`],style:t.style,styleSpec:r,objectElementValidators:N})),a;case"geojson":if(a=S({key:o,value:i,valueSpec:r.source_geojson,style:s,styleSpec:r,objectElementValidators:N}),i.cluster)for(const e in i.clusterProperties){const[t,r]=i.clusterProperties[e],s="string"==typeof t?[t,["accumulated"],["get",e]]:t;a.push(...L({key:`${o}.${e}.map`,value:r,expressionContext:"cluster-map"})),a.push(...L({key:`${o}.${e}.reduce`,value:s,expressionContext:"cluster-reduce"}));}return a;case"video":return S({key:o,value:i,valueSpec:r.source_video,style:s,styleSpec:r});case"image":return S({key:o,value:i,valueSpec:r.source_image,style:s,styleSpec:r});case"canvas":return [new T(o,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return R({key:`${o}.type`,value:i.type,valueSpec:{values:G(r)},style:s,styleSpec:r})}}function G(e){return e.source.reduce(((t,i)=>{const o=e[i];return "enum"===o.type.type&&(t=t.concat(Object.keys(o.type.values))),t}),[])}function j(t){const i=t.value;let o=[];if(!i)return o;const r=e.i(i);return "string"!==r?(o=o.concat([new T(t.key,i,`string expected, "${r}" found`)]),o):(function(e){const t=-1===e.indexOf("://");try{return new URL(e,t?"http://example.com":void 0),!0}catch(e){return !1}}(i)||(o=o.concat([new T(t.key,i,`invalid url "${i}"`)])),o)}function V(t){const i=t.value,o=t.styleSpec,r=o.light,s=t.style;let n=[];const a=e.i(i);if(void 0===i)return n;if("object"!==a)return n=n.concat([new T("light",i,`object expected, ${a} found`)]),n;for(const e in i){const t=e.match(/^(.*)-transition$/);n=n.concat(t&&r[t[1]]&&r[t[1]].transition?$({key:e,value:i[e],valueSpec:o.transition,style:s,styleSpec:o}):r[e]?$({key:e,value:i[e],valueSpec:r[e],style:s,styleSpec:o}):[new T(e,i[e],`unknown property "${e}"`)]);}return n}function Z(t){const i=t.value;let o=[];if(!i)return o;const r=e.i(i);if("object"!==r)return o=o.concat([new T("light-3d",i,`object expected, ${r} found`)]),o;const s=t.styleSpec,n=s["light-3d"],a=t.key,l=t.style,c=t.style.lights;for(const e of ["type","id"])if(!(e in i))return o=o.concat([new T("light-3d",i,`missing property ${e} on light`)]),o;if(i.type&&c)for(let r=0;r[],array:C,boolean:function(t){const i=t.value,o=t.key,r=e.i(i);return "boolean"!==r?[new T(o,i,`boolean expected, ${r} found`)]:[]},number:I,color:function(t){const i=t.key,o=t.value,r=e.i(o);return "string"!==r?[new T(i,o,`color expected, ${r} found`)]:null===e.y(o)?[new T(i,o,`color expected, "${o}" found`)]:[]},enum:R,filter:P,function:D,layer:B,object:S,source:U,model:j,light:V,"light-3d":Z,terrain:H,fog:W,string:k,formatted:function(e){return 0===k(e).length?[]:L(e)},resolvedImage:function(e){return 0===k(e).length?[]:L(e)},projection:function(t){const i=t.value,o=t.styleSpec,r=o.projection,s=t.style;let n=[];const a=e.i(i);if("object"===a)for(const e in i)n=n.concat($({key:e,value:i[e],valueSpec:r[e],style:s,styleSpec:o}));else "string"!==a&&(n=n.concat([new T("projection",i,`object or string expected, ${a} found`)]));return n},import:function(t){const{value:i,styleSpec:o}=t,{data:r,...s}=i;Object.defineProperty(s,"__line__",{value:i.__line__,enumerable:!1});let n=S(e.j({},t,{value:s,valueSpec:o.import}));return ""===e.u(s.id)&&n.push(new T(`${t.key}.id`,s,"import id can't be an empty string")),r&&(n=n.concat(K(r,o,{key:`${t.key}.data`}))),n}};function $(t,i=!1){const o=t.value,r=t.valueSpec,s=t.styleSpec;if(r.expression&&e.A(e.u(o)))return D(t);if(r.expression&&e.n(e.o(o)))return L(t);if(r.type&&q[r.type]){const o=q[r.type](t);return !0===i&&o.length>0&&"array"===e.i(t.value)?L(t):o}return S(e.j({},t,{valueSpec:r.type?s[r.type]:r}))}function X(e){const t=e.value,i=e.key,o=k(e);return o.length||(-1===t.indexOf("{fontstack}")&&o.push(new T(i,t,'"glyphs" url must include a "{fontstack}" token')),-1===t.indexOf("{range}")&&o.push(new T(i,t,'"glyphs" url must include a "{range}" token'))),o}function K(t,i=e.D,o={}){return $({key:o.key||"",value:t,valueSpec:i.$root,styleSpec:i,style:t,objectElementValidators:{glyphs:X,"*":()=>[]}})}function Y(t,i=e.D){return le(K(t,i))}const J=e=>le(U(e)),Q=e=>le(V(e)),ee=e=>le(Z(e)),te=e=>le(H(e)),ie=e=>le(W(e)),oe=e=>le(B(e)),re=e=>le(P(e)),se=e=>le(O(e)),ne=e=>le(F(e)),ae=e=>le(j(e));function le(e){return e.slice().sort(((e,t)=>e.line&&t.line?e.line-t.line:0))}function ce(t,i){let o=!1;if(i&&i.length)for(const r of i)r instanceof E?e.w(r.message):(t.fire(new e.a(new Error(r.message))),o=!0);return o}const he=new e.F({anchor:new e.G(e.D.light.anchor),position:new e.H(e.D.light.position),color:new e.G(e.D.light.color),intensity:new e.G(e.D.light.intensity)});class ue extends e.E{constructor(t,i="flat"){super(),this._transitionable=new e.J(he),this.setLight(t,i),this._transitioning=this._transitionable.untransitioned();}getLight(){return this._transitionable.serialize()}setLight(e,t,i={}){this._validate(Q,e,i)||(this._transitionable.setTransitionOrValue(e),this.id=t);}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}_validate(t,i,o){return (!o||!1!==o.validate)&&ce(this,t.call(Y,e.e({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.D})))}}const de=new e.F({source:new e.G(e.D.terrain.source),exaggeration:new e.G(e.D.terrain.exaggeration)});let _e=class extends e.E{constructor(t,i,o,r){super(),this.scope=o,this._transitionable=new e.J(de,o,r),this._transitionable.setTransitionOrValue(t,r),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=i;}get(){return this._transitionable.serialize()}set(e,t){this._transitionable.setTransitionOrValue(e,t);}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}getExaggeration(t){return this._transitioning.possiblyEvaluate(new e.K(t)).get("exaggeration")}isZoomDependent(){const t=this._transitionable._values.exaggeration;return null!=t&&null!=t.value&&null!=t.value.expression&&t.value.expression instanceof e.Z}};const pe=45,fe=65,me=.05;function ge(t,i,o,r){const s=e.O(pe,fe,o),[n,a]=ve(t,r);let l=1-Math.min(1,Math.exp((i-n)/(a-n)*-6));return l*=l*l,l=Math.min(1,1.00747*l),l*s*t.alpha}function ve(e,t){const i=.5/Math.tan(.5*t);return [e.range[0]+i,e.range[1]+i]}function xe(t,i,o,r,s){const n=e.N.transformMat4([],[i,o,r],s.mercatorFogMatrix);return ge(t,e.N.length(n),s.pitch,s._fov)}function ye(t,i,o,r,s,n,a){const l=[[o,r,0],[s,r,0],[s,n,0],[o,n,0]];let c=Number.MAX_VALUE,h=-Number.MAX_VALUE;for(const t of l){const o=e.N.transformMat4([],t,i),r=e.N.length(o);c=Math.min(c,r),h=Math.max(h,r);}return [ge(t,c,a.pitch,a._fov),ge(t,h,a.pitch,a._fov)]}const be=new e.F({range:new e.G(e.D.fog.range),color:new e.G(e.D.fog.color),"high-color":new e.G(e.D.fog["high-color"]),"space-color":new e.G(e.D.fog["space-color"]),"horizon-blend":new e.G(e.D.fog["horizon-blend"]),"star-intensity":new e.G(e.D.fog["star-intensity"]),"vertical-range":new e.G(e.D.fog["vertical-range"])});class we extends e.E{constructor(t,i,o,r){super(),this._transitionable=new e.J(be,o,new Map(r)),this.set(t,r),this._transitioning=this._transitionable.untransitioned(),this._transform=i,this.properties=new e.Q(be);}get state(){const t=this._transform,i="globe"===t.projection.name,o=e.S(t.zoom),r=this.properties.get("range"),s=[.5,3];return {range:i?[e.U(s[0],r[0],o),e.U(s[1],r[1],o)]:r,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(t,i,o={}){if(this._validate(ie,t,o))return;const r=e.e({},t);for(const t of Object.keys(e.D.fog))void 0===r[t]&&(r[t]=e.D.fog[t].default);this._options=r,this._transitionable.setTransitionOrValue(this._options,i);}getOpacity(t){if(!this._transform.projection.supportsFog)return 0;const i=this.properties&&this.properties.get("color")||1;return ("globe"===this._transform.projection.name?1:e.O(pe,fe,t))*i.a}getOpacityAtLatLng(t,i){return this._transform.projection.supportsFog?function(t,i,o){const r=e.L.fromLngLat(i),s=o.elevation?o.elevation.getAtPointOrZero(r):0;return xe(t,r.x,r.y,s,o)}(this.state,t,i):0}getOpacityForTile(t){if(!this._transform.projection.supportsFog)return [1,1];const i=this._transform.calculateFogTileMatrix(t.toUnwrapped());return ye(this.state,i,0,0,e.V,e.V,this._transform)}getOpacityForBounds(e,t,i,o,r){return this._transform.projection.supportsFog?ye(this.state,e,t,i,o,r,this._transform):[1,1]}getFovAdjustedRange(e){return this._transform.projection.supportsFog?ve(this.state,e):[0,1]}isVisibleOnFrustum(t){if(!this._transform.projection.supportsFog)return !1;const i=[4,5,6,7];for(const o of i){const i=t.points[o];let r;if(i[2]>=0)r=i;else {const s=t.points[o-4];r=e.W(s,i,s[2]/(s[2]-i[2]));}if(xe(this.state,r[0],r[1],0,this._transform)>=me)return !0}return !1}updateConfig(e){this._transitionable.setTransitionOrValue(this._options,new Map(e));}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}_validate(t,i,o){return (!o||!1!==o.validate)&&ce(this,t.call(Y,e.e({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.D})))}}class Te extends e.E{constructor(t,i,o,r){super(),this.scope=o,this._options=t,this.properties=new e.Q(i),this._transitionable=new e.J(i,o,new Map(r)),this._transitionable.setTransitionOrValue(t.properties),this._transitioning=this._transitionable.untransitioned();}updateConfig(e){this._transitionable.setTransitionOrValue(this._options.properties,new Map(e));}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}get(){return this._options.properties=this._transitionable.serialize(),this._options}set(e,t){this._options=e,this._transitionable.setTransitionOrValue(e.properties,t);}shadowsEnabled(){return !!this.properties&&!0===this.properties.get("cast-shadows")}}const Ee=new e.F({color:new e.G(e.D.properties_light_ambient.color),intensity:new e.G(e.D.properties_light_ambient.intensity)}),Se=new e.F({direction:new e.X(e.D.properties_light_directional.direction),color:new e.G(e.D.properties_light_directional.color),intensity:new e.G(e.D.properties_light_directional.intensity),"cast-shadows":new e.G(e.D.properties_light_directional["cast-shadows"]),"shadow-intensity":new e.G(e.D.properties_light_directional["shadow-intensity"])});class Ce{constructor(e,t,i,o){this.screenBounds=e,this.cameraPoint=t,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=i,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,o);}static createFromScreenPoints(t,i){let o,r;if(t instanceof e.P||"number"==typeof t[0]){const s=e.P.convert(t);o=[s],r=i.isPointAboveHorizon(s);}else {const s=e.P.convert(t[0]),n=e.P.convert(t[1]);o=[s,n],r=e.Y(s,n).every((e=>i.isPointAboveHorizon(e)));}return new Ce(o,i.getCameraPoint(),r,i)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(t){return e.Y(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],t)}bufferedCameraGeometry(t){const i=this.screenBounds[0],o=1===this.screenBounds.length?this.screenBounds[0].add(new e.P(1,1)):this.screenBounds[1],r=e.Y(i,o,0,!1);return this.cameraPoint.y>o.y&&(this.cameraPoint.x>i.x&&this.cameraPoint.x=o.x?r[2]=this.cameraPoint:this.cameraPoint.x<=i.x&&(r[3]=this.cameraPoint)),e._(r,t)}bufferedCameraGeometryGlobe(t){const i=this.screenBounds[0],o=1===this.screenBounds.length?this.screenBounds[0].add(new e.P(1,1)):this.screenBounds[1],r=e.Y(i,o,t),s=this.cameraPoint.clone();switch(3*((s.y>i.y)+(s.y>o.y))+((s.x>i.x)+(s.x>o.x))){case 0:r[0]=s,r[4]=s.clone();break;case 1:r.splice(1,0,s);break;case 2:r[1]=s;break;case 3:r.splice(4,0,s);break;case 5:r.splice(2,0,s);break;case 6:r[3]=s;break;case 7:r.splice(3,0,s);break;case 8:r[2]=s;}return r}containsTile(t,i,o,r=0){const s=t.queryPadding/i._pixelsPerMercatorPixel+1,n=o?this._bufferedCameraMercator(s,i):this._bufferedScreenMercator(s,i);let a=t.tileID.wrap+(n.unwrapped?r:0);const l=n.polygon.map((i=>e.$(t.tileTransform,i,a)));if(!e.a0(l,0,0,e.V,e.V))return;a=t.tileID.wrap+(this.screenGeometryMercator.unwrapped?r:0);const c=this.screenGeometryMercator.polygon.map((i=>e.a1(t.tileTransform,i,a))),h=c.map((t=>new e.P(t[0],t[1]))),u=i.getFreeCameraOptions().position||new e.L(0,0,0),d=e.a1(t.tileTransform,u,a),_=c.map((t=>{const i=e.N.sub(t,t,d);return e.N.normalize(i,i),new e.a2(d,i)})),p=e.a3(t,1,i.zoom)*i._pixelsPerMercatorPixel;return {queryGeometry:this,tilespaceGeometry:h,tilespaceRays:_,bufferedTilespaceGeometry:l,bufferedTilespaceBounds:(f=e.a4(l),f.min.x=e.aa(f.min.x,0,e.V),f.min.y=e.aa(f.min.y,0,e.V),f.max.x=e.aa(f.max.x,0,e.V),f.max.y=e.aa(f.max.y,0,e.V),f),tile:t,tileID:t.tileID,pixelToTileUnitsFactor:p};var f;}_bufferedScreenMercator(e,t){const i=Le(e);if(this._screenRaycastCache[i])return this._screenRaycastCache[i];{let o;return o="globe"===t.projection.name?this._projectAndResample(this.bufferedScreenGeometry(e),t):{polygon:this.bufferedScreenGeometry(e).map((e=>t.pointCoordinate3D(e))),unwrapped:!0},this._screenRaycastCache[i]=o,o}}_bufferedCameraMercator(e,t){const i=Le(e);if(this._cameraRaycastCache[i])return this._cameraRaycastCache[i];{let o;return o="globe"===t.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(e),t):{polygon:this.bufferedCameraGeometry(e).map((e=>t.pointCoordinate3D(e))),unwrapped:!0},this._cameraRaycastCache[i]=o,o}}_projectAndResample(t,i){const o=function(t,i){const o=e.a6.multiply([],i.pixelMatrix,i.globeMatrix),r=[0,-e.ab,0,1],s=[0,e.ab,0,1],n=[0,0,0,1];e.a7.transformMat4(r,r,o),e.a7.transformMat4(s,s,o),e.a7.transformMat4(n,n,o);const a=new e.P(r[0]/r[3],r[1]/r[3]),l=new e.P(s[0]/s[3],s[1]/s[3]),c=e.a8(t,a)&&r[3]1?Ie(t.slice(0,d),i):[],f=dnew e.P(De(t.x),t.y))),f=f.map((t=>new e.P(De(t.x),t.y)));const m=[...p];0===m.length&&m.push(f[f.length-1]);const g=e.U(m[m.length-1].y,(0===f.length?p[0]:f[0]).y,_);let v;return v=c?[new e.P(0,g),new e.P(0,0),new e.P(1,0),new e.P(1,g)]:[new e.P(1,g),new e.P(1,1),new e.P(0,1),new e.P(0,g)],m.push(...v),0===f.length?m.push(p[0]):m.push(...f),{polygon:m.map((t=>new e.L(t.x,t.y))),unwrapped:!1}}(t,i);if(o)return o;const r=function(t,i){let o=!1,r=-1/0,s=0;for(let e=0;er&&(r=t[e].x,s=e);for(let e=0;e.5&&(r.x{e.x-=1;})),{polygon:t,unwrapped:o}}(Ie(t,i).map((t=>new e.P(De(t.x),t.y))),i);return {polygon:r.polygon.map((t=>new e.L(t.x,t.y))),unwrapped:r.unwrapped}}}function Ie(t,i){return e.a9(t,(e=>{const t=i.pointCoordinate3D(e);e.x=t.x,e.y=t.y;}),1/256)}function De(e){return e<0?1+e%1:e%1}function Le(e){return 100*e|0}function Ae(t,i,o,r,s){const n=function(o,r){if(o)return s(o);if(r){t.url&&r.tiles&&t.tiles&&delete t.tiles;const o=e.ac(e.e(r,t),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);r.vector_layers&&(o.vectorLayers=r.vector_layers,o.vectorLayerIds=o.vectorLayers.map((e=>e.id))),r.raster_layers&&(o.rasterLayers=r.raster_layers,o.rasterLayerIds=o.rasterLayers.map((e=>e.id))),o.tiles=i.canonicalizeTileset(o,t.url),s(null,o);}};return t.url?e.g(i.transformRequest(i.normalizeSourceURL(t.url,null,o,r),e.R.Source),n):e.f.frame((()=>n(null,t)))}class Re{constructor(t,i,o){this.bounds=e.ad.convert(this.validateBounds(t)),this.minzoom=i||0,this.maxzoom=o||24;}validateBounds(e){return Array.isArray(e)&&4===e.length?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(t){const i=Math.pow(2,t.z),o=Math.floor(e.a5(this.bounds.getWest())*i),r=Math.floor(e.ae(this.bounds.getNorth())*i),s=Math.ceil(e.a5(this.bounds.getEast())*i),n=Math.ceil(e.ae(this.bounds.getSouth())*i);return t.x>=o&&t.x=r&&t.y{this._tileJSONRequest=null,this._loaded=!0,r?(i&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${i}`),o&&2!==o.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${o}`),this.fire(new e.a(r))):s&&(e.e(this,s),s.bounds&&(this.tileBounds=new Re(s.bounds,this.minzoom,this.maxzoom)),e.aj(s.tiles,this.map._requestManager._customAccessToken),this.fire(new e.b("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.b("data",{dataType:"source",sourceDataType:"content"}))),t&&t(r);}));}loaded(){return this._loaded}hasTile(e){return !this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load();}reload(){this.cancelTileJSONRequest();const t=e.ag(this.id,this.scope);this.load((()=>this.map.style.clearSource(t)));}setTiles(e){return this._options.tiles=e,this.reload(),this}setUrl(e){return this.url=e,this._options.url=e,this.reload(),this}onRemove(){this.cancelTileJSONRequest();}serialize(){return e.e({},this._options)}loadTile(t,i){const o=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),r={request:this.map._requestManager.transformRequest(o,e.R.Tile),data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,pixelRatio:e.f.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:t.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:t.isExtraShadowCaster};if(r.request.collectResourceTiming=this._collectResourceTiming,t.actor&&"expired"!==t.state)"loading"===t.state?t.reloadCallback=i:t.request=t.actor.send("reloadTile",r,s.bind(this));else if(t.actor=this._tileWorkers[o]=this._tileWorkers[o]||this.dispatcher.getActor(),this.dispatcher.ready)t.request=t.actor.send("loadTile",r,s.bind(this),void 0,!0);else {const i=e.ah.call({deduped:this._deduped},r,((e,i)=>{e||!i?s.call(this,e):(r.data={cacheControl:i.cacheControl,expires:i.expires,rawData:i.rawData.slice(0)},t.actor&&t.actor.send("loadTile",r,s.bind(this),void 0,!0));}),!0);t.request={cancel:i};}function s(o,r){return delete t.request,t.aborted?i(null):o&&404!==o.status?i(o):(r&&r.resourceTiming&&(t.resourceTiming=r.resourceTiming),this.map._refreshExpiredTiles&&r&&t.setExpiryData(r),t.loadVectorData(r,this.map.painter),e.ai(this.dispatcher),i(null),void(t.reloadCallback&&(this.loadTile(t,t.reloadCallback),t.reloadCallback=null)))}}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.actor&&e.actor.send("abortTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope});}unloadTile(e){e.actor&&e.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),e.destroy();}hasTransition(){return !1}afterUpdate(){this._tileWorkers={};}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null);}}class Me extends e.E{constructor(t,i,o,r){super(),this.id=t,this.dispatcher=o,this.setEventedParent(r),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=e.e({type:"raster"},i),e.e(this,e.ac(i,["url","scheme","tileSize"]));}load(t){this._loaded=!1,this.fire(new e.b("dataloading",{dataType:"source"})),this._tileJSONRequest=Ae(this._options,this.map._requestManager,null,null,((i,o)=>{this._tileJSONRequest=null,this._loaded=!0,i?this.fire(new e.a(i)):o&&(e.e(this,o),o.bounds&&(this.tileBounds=new Re(o.bounds,this.minzoom,this.maxzoom)),e.aj(o.tiles),this.fire(new e.b("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.b("data",{dataType:"source",sourceDataType:"content"}))),t&&t(i);}));}loaded(){return this._loaded}onAdd(e){this.map=e,this.load();}reload(){this.cancelTileJSONRequest();const t=e.ag(this.id,this.scope);this.load((()=>this.map.style.clearSource(t)));}setTiles(e){return this._options.tiles=e,this.reload(),this}setUrl(e){return this.url=e,this._options.url=e,this.reload(),this}onRemove(){this.cancelTileJSONRequest();}serialize(){return e.e({},this._options)}hasTile(e){return !this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(t,i){const o=e.f.devicePixelRatio>=2,r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),o,this.tileSize);t.request=e.d(this.map._requestManager.transformRequest(r,e.R.Tile),((o,r,s,n)=>(delete t.request,t.aborted?(t.state="unloaded",i(null)):o?(t.state="errored",i(o)):r?(this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:s,expires:n}),t.setTexture(r,this.map.painter),t.state="loaded",e.ai(this.dispatcher),void i(null)):i(null))));}abortTile(e,t){e.request&&(e.request.cancel(),delete e.request),t();}unloadTile(t,i){t.texture&&t.texture instanceof e.T?(t.destroy(!0),t.texture&&t.texture instanceof e.T&&this.map.painter.saveTileTexture(t.texture)):t.destroy(),i();}hasTransition(){return !1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null);}}class ze extends Me{constructor(t,i,o,r){super(t,i,o,r),this.type="raster-array",this.maxzoom=22,this._options=e.e({type:"raster-array"},i);}triggerRepaint(e){const t=this.map.painter._terrain,i=this.map.style.getSourceCache(this.id);t&&t.enabled&&i&&t._clearRenderCacheForTile(i.id,e.tileID),this.map.triggerRepaint();}loadTile(t,i){const o=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),r=this.map._requestManager.transformRequest(o,e.R.Tile);t.requestParams=r,t.actor||(t.actor=this.dispatcher.getActor()),t.request=t.fetchHeader(void 0,((e,o,r,s)=>{if(delete t.request,t.aborted)return t.state="unloaded",i(null);if(e){if(20===e.code)return;return t.state="errored",i(e)}this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:r,expires:s}),t.state="empty",i(null);}));}unloadTile(t){const i=t.texture;i&&i instanceof e.T?(t.destroy(!0),this.map.painter.saveTileTexture(i)):(t.destroy(),t.flushQueues(),t._isHeaderLoaded=!1,delete t._mrt,delete t.textureDescriptor),t.fbo&&(t.fbo.destroy(),delete t.fbo),delete t.request,delete t.requestParams,delete t.neighboringTiles,t.state="unloaded";}prepareTile(t,i,o){t._isHeaderLoaded&&("empty"!==t.state&&(t.state="reloading"),t.fetchBand(i,o,((i,o)=>{if(i)return t.state="errored",this.fire(new e.a(i)),void this.triggerRepaint(t);o&&(t.setTexture(o,this.map.painter),t.state="loaded",this.triggerRepaint(t));})));}getInitialBand(e){if(!this.rasterLayers)return 0;const t=this.rasterLayers.find((({id:t})=>t===e)),i=t&&t.fields,o=i&&i.bands&&i.bands;return o?o[0]:0}getTextureDescriptor(t,i,o){if(!t)return;const r=i.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(!r)return;let s=null;i instanceof e.an?s=i.paint.get("raster-array-band"):i instanceof e.ao&&(s=i.paint.get("raster-particle-array-band"));const n=s||this.getInitialBand(r);if(null!=n)if(t.textureDescriptor){if(!t.updateNeeded(r,n)||o)return Object.assign({},t.textureDescriptor,{texture:t.texture})}else this.prepareTile(t,r,n);}}const Oe=32,Fe=33,Be=new Uint16Array(8184);for(let e=0;e<2046;e++){let t=e+2,i=0,o=0,r=0,s=0,n=0,a=0;for(1&t?r=s=n=Oe:i=o=a=Oe;(t>>=1)>1;){const e=i+r>>1,l=o+s>>1;1&t?(r=i,s=o,i=n,o=a):(i=r,o=s,r=n,s=a),n=e,a=l;}const l=4*e;Be[l+0]=i,Be[l+1]=o,Be[l+2]=r,Be[l+3]=s;}const ke=new Uint16Array(2178),Ne=new Uint8Array(1089),Ue=new Uint16Array(1089);function Ge(e){return 0===e?-.03125:32===e?.03125:0}class je{constructor(e,t,i,o){this.id=je.uniqueIdxCounter,je.uniqueIdxCounter++,this.context=e;const r=e.gl;this.buffer=r.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||o||t.destroy();}bind(){this.context.bindElementBuffer.set(this.buffer);}updateData(e){this.id=je.uniqueIdxCounter,je.uniqueIdxCounter++;const t=this.context.gl;this.context.unbindVAO(),this.bind(),t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer);}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer);}}je.uniqueIdxCounter=0;const Ve={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Ze{constructor(e,t,i,o,r,s){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=o,this.instanceCount=s,this.context=e;const n=e.gl;this.buffer=n.createBuffer(),e.bindVertexBuffer.set(this.buffer),n.bufferData(n.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?n.DYNAMIC_DRAW:n.STATIC_DRAW),this.dynamicDraw||r||t.destroy();}bind(){this.context.bindVertexBuffer.set(this.buffer);}updateData(e){const t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer);}enableAttributes(e,t){for(let i=0;i0&&e.vertexAttribDivisor(r,i);}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer);}}class He{constructor(e){this.gl=e.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1;}get(){return this.current}set(e){}getDefault(){return this.default}setDefault(){this.set(this.default);}}class We extends He{getDefault(){return e.ax.transparent}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.clearColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1);}}class qe extends He{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1);}}class $e extends He{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1);}}class Xe extends He{getDefault(){return [!0,!0,!0,!0]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.colorMask(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1);}}class Ke extends He{getDefault(){return !0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1);}}class Ye extends He{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1);}}class Je extends He{getDefault(){return {func:this.gl.ALWAYS,ref:0,mask:255}}set(e){const t=this.current;(e.func!==t.func||e.ref!==t.ref||e.mask!==t.mask||this.dirty)&&(this.gl.stencilFunc(e.func,e.ref,e.mask),this.current=e,this.dirty=!1);}}class Qe extends He{getDefault(){const e=this.gl;return [e.KEEP,e.KEEP,e.KEEP]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||this.dirty)&&(this.gl.stencilOp(e[0],e[1],e[2]),this.current=e,this.dirty=!1);}}class et extends He{getDefault(){return !1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),this.current=e,this.dirty=!1;}}class tt extends He{getDefault(){return [0,1]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||this.dirty)&&(this.gl.depthRange(e[0],e[1]),this.current=e,this.dirty=!1);}}class it extends He{getDefault(){return !1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST),this.current=e,this.dirty=!1;}}class ot extends He{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1);}}class rt extends He{getDefault(){return !1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.BLEND):t.disable(t.BLEND),this.current=e,this.dirty=!1;}}class st extends He{getDefault(){const e=this.gl;return [e.ONE,e.ZERO,e.ONE,e.ZERO]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.blendFuncSeparate(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1);}}class nt extends He{getDefault(){return e.ax.transparent}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.blendColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1);}}class at extends He{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquationSeparate(e,e),this.current=e,this.dirty=!1);}}class lt extends He{getDefault(){return !1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE),this.current=e,this.dirty=!1;}}class ct extends He{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1);}}class ht extends He{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1);}}let ut=class extends He{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1);}};class dt extends He{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1);}}class _t extends He{getDefault(){const e=this.gl;return [0,0,e.drawingBufferWidth,e.drawingBufferHeight]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.viewport(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1);}}class pt extends He{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,e),this.current=e,this.dirty=!1;}}class ft extends He{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindRenderbuffer(t.RENDERBUFFER,e),this.current=e,this.dirty=!1;}}class mt extends He{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindTexture(t.TEXTURE_2D,e),this.current=e,this.dirty=!1;}}class gt extends He{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindBuffer(t.ARRAY_BUFFER,e),this.current=e,this.dirty=!1;}}class vt extends He{getDefault(){return null}set(e){const t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1;}}class xt extends He{getDefault(){return null}set(e){this.gl&&(e!==this.current||this.dirty)&&(this.gl.bindVertexArray(e),this.current=e,this.dirty=!1);}}class yt extends He{getDefault(){return 4}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_ALIGNMENT,e),this.current=e,this.dirty=!1;}}class bt extends He{getDefault(){return !1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e),this.current=e,this.dirty=!1;}}class wt extends He{getDefault(){return !1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e),this.current=e,this.dirty=!1;}}class Tt extends He{constructor(e,t){super(e),this.context=e,this.parent=t;}getDefault(){return null}}class Et extends Tt{setDirty(){this.dirty=!0;}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1;}}class St extends Tt{attachment(){return this.gl.DEPTH_ATTACHMENT}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,this.attachment(),t.RENDERBUFFER,e),this.current=e,this.dirty=!1;}}class Ct extends Tt{attachment(){return this.gl.DEPTH_ATTACHMENT}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,this.attachment(),t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1;}}class It extends St{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}class Dt{constructor(e,t,i,o,r){this.context=e,this.width=t,this.height=i;const s=this.framebuffer=e.gl.createFramebuffer();o&&(this.colorAttachment=new Et(e,s)),r&&(this.depthAttachmentType=r,this.depthAttachment="renderbuffer"===r?new St(e,s):new Ct(e,s));}destroy(){const e=this.context.gl;if(this.colorAttachment){const t=this.colorAttachment.get();t&&e.deleteTexture(t);}if(this.depthAttachment&&this.depthAttachmentType)if("renderbuffer"===this.depthAttachmentType){const t=this.depthAttachment.get();t&&e.deleteRenderbuffer(t);}else {const t=this.depthAttachment.get();t&&e.deleteTexture(t);}e.deleteFramebuffer(this.framebuffer);}}class Lt{constructor(e,t,i){this.func=e,this.mask=t,this.range=i;}}Lt.ReadOnly=!1,Lt.ReadWrite=!0,Lt.disabled=new Lt(519,Lt.ReadOnly,[0,1]);const At=7680;class Rt{constructor(e,t,i,o,r,s){this.test=e,this.ref=t,this.mask=i,this.fail=o,this.depthFail=r,this.pass=s;}}Rt.disabled=new Rt({func:519,mask:0},0,0,At,At,At);const Pt=771;class Mt{constructor(e,t,i,o){this.blendFunction=e,this.blendColor=t,this.mask=i,this.blendEquation=o;}}Mt.Replace=[1,0,1,0],Mt.disabled=new Mt(Mt.Replace,e.ax.transparent,[!1,!1,!1,!1]),Mt.unblended=new Mt(Mt.Replace,e.ax.transparent,[!0,!0,!0,!0]),Mt.alphaBlended=new Mt([1,Pt,1,Pt],e.ax.transparent,[!0,!0,!0,!0]),Mt.multiply=new Mt([774,0,774,0],e.ax.transparent,[!0,!0,!0,!0]);const zt=1029,Ot=2305;class Ft{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i;}}Ft.disabled=new Ft(!1,zt,Ot),Ft.backCCW=new Ft(!0,zt,Ot),Ft.backCW=new Ft(!0,zt,2304),Ft.frontCW=new Ft(!0,1028,2304),Ft.frontCCW=new Ft(!0,1028,Ot);class Bt{constructor(e,t){this.gl=e,this.clearColor=new We(this),this.clearDepth=new qe(this),this.clearStencil=new $e(this),this.colorMask=new Xe(this),this.depthMask=new Ke(this),this.stencilMask=new Ye(this),this.stencilFunc=new Je(this),this.stencilOp=new Qe(this),this.stencilTest=new et(this),this.depthRange=new tt(this),this.depthTest=new it(this),this.depthFunc=new ot(this),this.blend=new rt(this),this.blendFunc=new st(this),this.blendColor=new nt(this),this.blendEquation=new at(this),this.cullFace=new lt(this),this.cullFaceSide=new ct(this),this.frontFace=new ht(this),this.program=new ut(this),this.activeTexture=new dt(this),this.viewport=new _t(this),this.bindFramebuffer=new pt(this),this.bindRenderbuffer=new ft(this),this.bindTexture=new mt(this),this.bindVertexBuffer=new gt(this),this.bindElementBuffer=new vt(this),this.bindVertexArrayOES=new xt(this),this.pixelStoreUnpack=new yt(this),this.pixelStoreUnpackPremultiplyAlpha=new bt(this),this.pixelStoreUnpackFlipY=new wt(this),this.options=t?{...t}:{},this.options.extTextureFilterAnisotropicForceOff||(this.extTextureFilterAnisotropic=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=e.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT))),this.extDebugRendererInfo=e.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=e.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=e.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),this.options.extTextureFloatLinearForceOff||(this.extTextureFloatLinear=e.getExtension("OES_texture_float_linear")),this.extRenderToTextureHalfFloat=e.getExtension("EXT_color_buffer_half_float"),this.extTimerQuery=e.getExtension("EXT_disjoint_timer_query_webgl2"),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),this.maxPointSize=e.getParameter(e.ALIASED_POINT_SIZE_RANGE)[1];}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.bindVertexArrayOES.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0;}createIndexBuffer(e,t,i){return new je(this,e,t,i)}createVertexBuffer(e,t,i,o,r){return new Ze(this,e,t,i,o,r)}createRenderbuffer(e,t,i){const o=this.gl,r=o.createRenderbuffer();return this.bindRenderbuffer.set(r),o.renderbufferStorage(o.RENDERBUFFER,e,t,i),this.bindRenderbuffer.set(null),r}createFramebuffer(e,t,i,o){return new Dt(this,e,t,i,o)}clear({color:e,depth:t,stencil:i,colorMask:o}){const r=this.gl;let s=0;e&&(s|=r.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set(o||[!0,!0,!0,!0])),void 0!==t&&(s|=r.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(t),this.depthMask.set(!0)),void 0!==i&&(s|=r.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),r.clear(s);}setCullFace(e){!1===e.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(e.mode),this.frontFace.set(e.frontFace));}setDepthMode(e){e.func!==this.gl.ALWAYS||e.mask?(this.depthTest.set(!0),this.depthFunc.set(e.func),this.depthMask.set(e.mask),this.depthRange.set(e.range)):this.depthTest.set(!1);}setStencilMode(e){e.test.func!==this.gl.ALWAYS||e.mask?(this.stencilTest.set(!0),this.stencilMask.set(e.mask),this.stencilOp.set([e.fail,e.depthFail,e.pass]),this.stencilFunc.set({func:e.test.func,ref:e.ref,mask:e.test.mask})):this.stencilTest.set(!1);}setColorMode(e){t(e.blendFunction,Mt.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(e.blendFunction),this.blendColor.set(e.blendColor),e.blendEquation?this.blendEquation.set(e.blendEquation):this.blendEquation.setDefault()),this.colorMask.set(e.mask);}unbindVAO(){this.bindVertexArrayOES.set(null);}}var kt=e.ay([{name:"a_pos",type:"Float32",components:3}]);class Nt{constructor(t,i,o,r){const s={width:o[0],height:o[1],data:null},n=t.gl;this.targetColorTexture=new e.T(t,s,n.RGBA,{useMipmap:!1}),this.backgroundColorTexture=new e.T(t,s,n.RGBA,{useMipmap:!1}),this.context=t,this.setNumParticles(i,r),this.lastInvalidatedAt=0;}setNumParticles(t,i){if(this.numParticles===i)return;(this.particleVertices0||this.particleVertices1||this.particleSegment)&&(this.particleVertices0.destroy(),this.particleVertices1.destroy(),this.particleSegment.destroy());const o=new e.az;o.reserve(Math.round(i));const r=e.aA(t.key);for(let e=0;e[[new e.P(0,0),new e.P(e.V+1,0),new e.P(e.V+1,e.V+1),new e.P(0,e.V+1),new e.P(0,0)]]};class Gt{constructor(t,i,o,r,s){this.tileID=t,this.uid=e.aC(),this.uses=0,this.tileSize=i,this.tileZoom=o,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=s,r&&r.style&&(this._lastUpdatedBrightness=r.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",r&&r.transform&&(this.projection=r.transform.projection);}registerFadeDuration(t){const i=t+this.timeAdded;it.getLayer(e))).filter(Boolean);if(0!==e.length){o.layers=e,o.stateDependentLayerIds&&(o.stateDependentLayers=o.stateDependentLayerIds.map((t=>e.filter((e=>e.id===t))[0])));for(const t of e)i[t.fqid]=o;}}return i}(t.buckets,i.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const i=this.buckets[t];if(i instanceof e.aE){if(this.hasSymbolBuckets=!0,!o)break;i.justReloaded=!0;}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const i=this.buckets[t];if(i instanceof e.aE&&i.hasRTLText){this.hasRTLText=!0,e.aF();break}}this.queryPadding=0;for(const e in this.buckets){const t=this.buckets[e],o=i.style.getOwnLayer(e);if(!o)continue;const r=o.queryRadius(t);this.queryPadding=Math.max(this.queryPadding,r);}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),t.lineAtlas&&(this.lineAtlas=t.lineAtlas),this._lastUpdatedBrightness=t.brightness;}else this.collisionBoxArray=new e.aD;}unloadVectorData(){if(this.hasData()){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded";}}getBucket(e){return this.buckets[e.fqid]}upload(t){for(const e in this.buckets){const i=this.buckets[e];i.uploadPending()&&i.upload(t);}const i=t.gl,o=this.imageAtlas;if(o&&!o.uploaded){const r=!!Object.keys(o.patternPositions).length;this.imageAtlasTexture=new e.T(t,o.image,i.RGBA,{useMipmap:r}),this.imageAtlas.uploaded=!0;}this.glyphAtlasImage&&(this.glyphAtlasTexture=new e.T(t,this.glyphAtlasImage,i.R8),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new e.T(t,this.lineAtlas.image,i.R8),this.lineAtlas.uploaded=!0);}prepare(e,t,i){if(this.imageAtlas&&this.imageAtlasTexture&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture,i),!t||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const o=t.style.getBrightness();(this._lastUpdatedBrightness||o)&&(this._lastUpdatedBrightness&&o&&Math.abs(this._lastUpdatedBrightness-o)<.001||(this._lastUpdatedBrightness=o,this.updateBuckets(void 0,t)));}queryRenderedFeatures(e,t,i,o,r,s,n,a){return this.latestFeatureIndex&&(this.latestFeatureIndex.rawTileData||this.latestFeatureIndex.is3DTile)?this.latestFeatureIndex.query({tileResult:o,pixelPosMatrix:n,transform:s,params:r,tileTransform:this.tileTransform},e,t,i):{}}querySourceFeatures(t,i){const o=this.latestFeatureIndex;if(!o||!o.rawTileData)return;const r=o.loadVTLayers(),s=i?i.sourceLayer:"",n=r._geojsonTileLayer||r[s];if(!n)return;const a=e.aG(i&&i.filter),{z:l,x:c,y:h}=this.tileID.canonical,u={z:l,x:c,y:h};for(let i=0;ie)t=!1;else if(i)if(this.expirationTime=0;e--){const t=4*e,i=Be[t+0],o=Be[t+1],r=Be[t+2],s=Be[t+3],n=i+r>>1,a=o+s>>1,l=n+a-o,c=a+i-n,h=o*Fe+i,u=s*Fe+r,d=a*Fe+n,_=Math.hypot((ke[2*h+0]+ke[2*u+0])/2-ke[2*d+0],(ke[2*h+1]+ke[2*u+1])/2-ke[2*d+1])>=16;Ne[d]=Ne[d]||(_?1:0),e<1022&&(Ne[d]=Ne[d]||Ne[(o+c>>1)*Fe+(i+l>>1)]||Ne[(s+c>>1)*Fe+(r+l>>1)]);}const s=new e.av,n=new e.aw;let a=0;function l(t,i){const o=i*Fe+t;return 0===Ue[o]&&(s.emplaceBack(ke[2*o+0],ke[2*o+1],t*e.V/Oe,i*e.V/Oe),Ue[o]=++a),Ue[o]-1}function c(e,t,i,o,r,s){const a=e+i>>1,h=t+o>>1;if(Math.abs(e-r)+Math.abs(t-s)>1&&Ne[h*Fe+a])c(r,s,e,t,a,h),c(i,o,r,s,a,h);else {const a=l(e,t),c=l(i,o),h=l(r,s);n.emplaceBack(a,c,h);}}return c(0,0,Oe,Oe,Oe,0),c(Oe,Oe,0,0,0,Oe),{vertices:s,indices:n}}(this.tileID.canonical,i);r=t.vertices,s=t.indices;}else {r=new e.av,s=new e.aw;for(const{x:e,y:t}of o)r.emplaceBack(e,t,0,0);const t=e.aQ(r.int16,void 0,4);for(let e=0;e0&&(l=e.a6.invert(new Float64Array(16),i.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(t,r,i,n,l,a),this._makeGlobeTileDebugTextBuffer(t,r,i,n,l,a);}_globePoint(t,i,o,r,s,n,a){let l=e.aU(t,i,o);if(n){const s=1<.5?d=-1:u<-.5&&(d=1);let _=(t/e.V+o.x)/s+d,p=(i/e.V+o.y)/s;_=(_-c)*r._pixelsPerMercatorPixel+c,p=(p-h)*r._pixelsPerMercatorPixel+h;const f=[_*r.worldSize,p*r.worldSize,0];e.N.transformMat4(f,f,n),l=e.aV(l,f,a);}return e.N.transformMat4(l,l,s)}_makeGlobeTileDebugBorderBuffer(t,i,o,r,s,n){const a=new e.aN,l=new e.aO,c=new e.aW,h=(e,t,h,u,d)=>{const _=(h-e)/(d-1),p=(u-t)/(d-1),f=a.length;for(let h=0;hu*e+t;for(let e=0;e0&&(l[new e.am(t.overscaledZ,s,i.z,r,i.y-1).key]={backfilled:!1},l[new e.am(t.overscaledZ,t.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new e.am(t.overscaledZ,a,i.z,n,i.y-1).key]={backfilled:!1}),i.y+1{if(this._loaded=!0,this._pendingLoad=null,t)this.fire(new e.a(t));else {const t={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&i&&i.resourceTiming&&i.resourceTiming[this.id]&&(t.resourceTiming=i.resourceTiming[this.id]),this.fire(new e.b("data",t)),this._metadataFired=!0;}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1);}));}loaded(){return this._loaded}loadTile(t,i){const o=t.actor?"reloadTile":"loadTile";t.actor=this.actor;const r={type:this.type,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,scope:this.scope,pixelRatio:e.f.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,brightness:this.map.style&&this.map.style.getBrightness()||0};t.request=this.actor.send(o,r,((e,r)=>(delete t.request,t.destroy(),t.aborted?i(null):e?i(e):(t.loadVectorData(r,this.map.painter,"reloadTile"===o),i(null)))),void 0,"loadTile"===o);}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.aborted=!0;}unloadTile(e){this.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),e.destroy();}onRemove(){this._pendingLoad&&this._pendingLoad.cancel();}serialize(){return e.e({},this._options,{type:this.type,data:this._data})}hasTransition(){return !1}},video:class extends e.ap{constructor(e,t,i,o){super(e,t,i,o),this.roundZoom=!0,this.type="video",this.options=t;}load(){this._loaded=!1;const t=this.options;this.urls=[];for(const i of t.urls)this.urls.push(this.map._requestManager.transformRequest(i,e.R.Source).url);e.aq(this.urls,((t,i)=>{this._loaded=!0,t?this.fire(new e.a(t)):i&&(this.video=i,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",(()=>{this.map.triggerRepaint();})),this.map&&this.video.play(),this._finishLoading());}));}pause(){this.video&&this.video.pause();}play(){this.video&&this.video.play();}seek(t){if(this.video){const i=this.video.seekable;ti.end(0)?this.fire(new e.a(new T(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.end(0)}-second mark.`))):this.video.currentTime=t;}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)));}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const t=this.map.painter.context,i=t.gl;this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new e.T(t,this.video,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(t);}serialize(){return {type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:e.ap,model:class extends e.E{constructor(e,t,i,o){super(),this.id=e,this.type="model",this.models=[],this._loaded=!1,this._options=t;}load(){const t=[];for(const i in this._options.models){const o=this._options.models[i],r=e.l(this.map._requestManager.transformRequest(o.uri,e.R.Model).url).then((t=>{if(!t)return;const r=e.c(t),s=new e.M(i,o.position,o.orientation,r);s.computeBoundsAndApplyParent(),this.models.push(s);})).catch((t=>{this.fire(new e.a(new Error(`Could not load model ${i} from ${o.uri}: ${t.message}`)));}));t.push(r);}return Promise.allSettled(t).then((()=>{this._loaded=!0,this.fire(new e.b("data",{dataType:"source",sourceDataType:"metadata"}));})).catch((t=>{this.fire(new e.a(new Error(`Could not load models: ${t.message}`)));}))}onAdd(e){this.map=e,this.load();}hasTransition(){return !1}loaded(){return this._loaded}getModels(){return this.models}loadTile(e,t){}serialize(){return {type:"model"}}},"batched-model":class extends e.E{constructor(e,t,i,o){super(),this.type="batched-model",this.id=e,this.tileSize=512,this._options=t,this.tiles=this._options.tiles,this.maxzoom=t.maxzoom||19,this.minzoom=t.minzoom||0,this.roundZoom=!0,this.usedInConflation=!0,this.dispatcher=i,this.reparseOverscaled=!1,this.scheme="xyz",this._loaded=!1,this.setEventedParent(o);}onAdd(e){this.map=e,this.load();}load(t){this._loaded=!1,this.fire(new e.b("dataloading",{dataType:"source"}));const i=Array.isArray(this.map._language)?this.map._language.join():this.map._language,o=this.map._worldview;this._tileJSONRequest=Ae(this._options,this.map._requestManager,i,o,((r,s)=>{this._tileJSONRequest=null,this._loaded=!0,r?(i&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${i}`),o&&2!==o.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${o}`),this.fire(new e.a(r))):s&&(e.e(this,s),s.bounds&&(this.tileBounds=new Re(s.bounds,this.minzoom,this.maxzoom)),e.aj(s.tiles,this.map._requestManager._customAccessToken),this.fire(new e.b("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.b("data",{dataType:"source",sourceDataType:"content"}))),t&&t(r);}));}hasTransition(){return !1}hasTile(e){return !this.tileBounds||this.tileBounds.contains(e.canonical)}loaded(){return this._loaded}loadTile(t,i){const o=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),r={request:this.map._requestManager.transformRequest(o,e.R.Tile),data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,isSymbolTile:t.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0};if(t.actor&&"expired"!==t.state)if("loading"===t.state)t.reloadCallback=i;else {if(t.buckets){const e=Object.values(t.buckets);for(const t of e)t.dirty=!0;return void(t.state="loaded")}t.request=t.actor.send("reloadTile",r,s.bind(this));}else t.actor=this.dispatcher.getActor(),t.request=t.actor.send("loadTile",r,s.bind(this),void 0,!0);function s(e,o){return t.aborted?i(null):e&&404!==e.status?i(e):(o&&(o.resourceTiming&&(t.resourceTiming=o.resourceTiming),this.map._refreshExpiredTiles&&t.setExpiryData(o),t.buckets={...t.buckets,...o.buckets},o.featureIndex&&(t.latestFeatureIndex=o.featureIndex)),t.state="loaded",void i(null))}}serialize(){return e.e({},this._options)}},canvas:class extends e.ap{constructor(t,i,o,r){super(t,i,o,r),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some((e=>!Array.isArray(e)||2!==e.length||e.some((e=>"number"!=typeof e))))||this.fire(new e.a(new T(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new e.a(new T(`sources.${t}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new e.a(new T(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof HTMLCanvasElement||this.fire(new e.a(new T(`sources.${t}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new e.a(new T(`sources.${t}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate;}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new e.a(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(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play();}onRemove(){this.pause();}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const i=this.map.painter.context;this.texture?!t&&!this._playing||this.texture instanceof e.ar||this.texture.update(this.canvas,{premultiply:!0}):this.texture=new e.T(i,this.canvas,i.gl.RGBA,{premultiply:!0}),this._prepareData(i);}serialize(){return {type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const e of [this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return !0;return !1}},custom:class extends e.E{constructor(t,i,o,r){super(),this.id=t,this.type="custom",this._dataType="raster",this._dispatcher=o,this._implementation=i,this.setEventedParent(r),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new e.a(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new e.a(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new Re(this._implementation.bounds,this.minzoom,this.maxzoom)),i.update=this._update.bind(this),i.clearTiles=this._clearTiles.bind(this),i.coveringTiles=this._coveringTiles.bind(this),e.e(this,e.ac(i,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]));}serialize(){return e.ac(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new e.b("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.b("data",{dataType:"source",sourceDataType:"content"}));}loaded(){return this._loaded}onAdd(t){this._map=t,this._loaded=!1,this.fire(new e.b("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(t),this.load();}onRemove(e){this._implementation.onRemove&&this._implementation.onRemove(e);}hasTile(e){if(this._implementation.hasTile){const{x:t,y:i,z:o}=e.canonical;return this._implementation.hasTile({x:t,y:i,z:o})}return !this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e,t){const{x:i,y:o,z:r}=e.tileID.canonical,s=new AbortController;e.request=Promise.resolve(this._implementation.loadTile({x:i,y:o,z:r},{signal:s.signal})).then(function(i){return delete e.request,e.aborted?(e.state="unloaded",t(null)):void 0===i?(e.state="errored",t(null)):null===i?(this.loadTileData(e,{width:this.tileSize,height:this.tileSize,data:null}),e.state="loaded",t(null)):function(e){return e instanceof ImageData||e instanceof HTMLCanvasElement||e instanceof ImageBitmap||e instanceof HTMLImageElement}(i)?(this.loadTileData(e,i),e.state="loaded",void t(null)):(e.state="errored",t(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}.bind(this)).catch((i=>{20!==i.code&&(e.state="errored",t(i));})),e.request.cancel=()=>s.abort();}loadTileData(e,t){e.setTexture(t,this._map.painter);}unloadTile(t,i){if(t.texture&&t.texture instanceof e.T?(t.destroy(!0),t.texture&&t.texture instanceof e.T&&this._map.painter.saveTileTexture(t.texture)):t.destroy(),this._implementation.unloadTile){const{x:e,y:i,z:o}=t.tileID.canonical;this._implementation.unloadTile({x:e,y:i,z:o});}i();}abortTile(e,t){e.request&&e.request.cancel&&(e.request.cancel(),delete e.request),t();}hasTransition(){return !1}_coveringTiles(){return this._map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map((e=>({x:e.canonical.x,y:e.canonical.y,z:e.canonical.z})))}_clearTiles(){const t=e.ag(this.id,this.scope);this._map.style.clearSource(t);}_update(){this.fire(new e.b("data",{dataType:"source",sourceDataType:"content"}));}}},Vt=function(t,i,o,r){const s=new jt[i.type](t,i,o,r);if(s.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${s.id}`);return e.aY(["load","abort","unload","serialize","prepare"],s),s};function Zt(t,i){const o=e.a6.identity([]);return e.a6.scale(o,o,[.5*t.width,.5*-t.height,1]),e.a6.translate(o,o,[1,-1,0]),e.a6.multiply(o,o,t.calculateProjMatrix(i.toUnwrapped())),Float32Array.from(o)}function Ht(e,t,i,o,r,s,n,a=!1){const l=e.tilesIn(o,n,a);l.sort(qt);const c=[];for(const o of l)c.push({wrappedTileID:o.tile.tileID.wrapped().key,queryResults:o.tile.queryRenderedFeatures(t,i,e._state,o,r,s,Zt(e.transform,o.tile.tileID),a)});const h=function(e){const t={},i={};for(const o of e){const e=o.queryResults,r=o.wrappedTileID,s=i[r]=i[r]||{};for(const i in e){const o=e[i],r=s[i]=s[i]||{},n=t[i]=t[i]||[];for(const e of o)r[e.featureIndex]||(r[e.featureIndex]=!0,n.push(e));}}return t}(c);for(const t in h)h[t].forEach((t=>{const i=t.feature,o=i.layer;o&&"background"!==o.type&&"sky"!==o.type&&"slot"!==o.type&&(i.source=o.source,o["source-layer"]&&(i.sourceLayer=o["source-layer"]),i.state=void 0!==i.id?e.getFeatureState(o["source-layer"],i.id):{});}));return h}function Wt(e,t){const i=e.getRenderableIds().map((t=>e.getTileByID(t))),o=[],r={};for(let e=0;e{if(e)i(e);else try{const e=o.getHeaderLength(r);if(e>t)return void(this.request=this.fetchHeader(e,i));o.parseHeader(r),this._isHeaderLoaded=!0;let a=0;for(const e of Object.values(o.layers))a=Math.max(a,e.dataIndex[e.dataIndex.length-1].last_byte);r.byteLength>=a&&(this.entireBuffer=r),i(null,this.entireBuffer||r,s,n);}catch(e){i(e);}})),this.request}fetchBand(t,i,o){const r=this._mrt;if(!this._isHeaderLoaded||!r)return void o(new Error("Tile header is not ready"));const s=this.actor;if(!s)return void o(new Error("Can't fetch tile band without an actor"));let n;const a=(e,r)=>{n.complete(e,r),e?o(e):(this.updateTextureDescriptor(t,i),o(null,this.textureDescriptor&&this.textureDescriptor.img));},l=(e,t)=>{if(e)return o(e);const i=s.send("decodeRasterArray",{buffer:t,task:n},a,void 0,!0);this._workQueue.push((()=>{i&&i.cancel(),n.cancel();}));},c=r.getLayer(t);if(!c)return void o(new Error(`Unknown sourceLayer "${t}"`));if(c.hasDataForBand(i))return this.updateTextureDescriptor(t,i),void o(null,this.textureDescriptor?this.textureDescriptor.img:null);const h=c.getDataRange([i]);if(n=r.createDecodingTask(h),!n||n.tasks.length)if(this.flushQueues(),this.entireBuffer)l(null,this.entireBuffer.slice(h.firstByte,h.lastByte+1));else {const t=Object.assign({},this.requestParams,{headers:{Range:`bytes=${h.firstByte}-${h.lastByte}`}}),i=e.a_(t,l);this._fetchQueue.push((()=>{i.cancel(),n.cancel();}));}else o(null);}updateNeeded(e,t){return (!this.textureDescriptor||this.textureDescriptor.band!==t||this.textureDescriptor.layer!==e)&&"errored"!==this.state}updateTextureDescriptor(t,i){if(!this._mrt)return;const o=this._mrt.getLayer(t);if(!o||!o.hasBand(i)||!o.hasDataForBand(i))return;const{bytes:r,tileSize:s,buffer:n,offset:a,scale:l}=o.getBandView(i),c=s+2*n,h={data:r,width:c,height:c},u=this.texture;u&&u instanceof e.T&&u.update(h,{useMipmap:!1,premultiply:!1}),this.textureDescriptor={layer:t,band:i,img:h,buffer:n,offset:a,tileSize:s,format:o.pixelFormat,mix:[l,256*l,65536*l,16777216*l]};}}class Xt{constructor(e,t){this.max=e,this.onRemove=t,this.reset();}reset(){for(const e in this.data)for(const t of this.data[e])t.timeout&&clearTimeout(t.timeout),this.onRemove(t.value);return this.data={},this.order=[],this}add(e,t,i){const o=e.wrapped().key;void 0===this.data[o]&&(this.data[o]=[]);const r={value:t,timeout:void 0};if(void 0!==i&&(r.timeout=setTimeout((()=>{this.remove(e,r);}),i)),this.data[o].push(r),this.order.push(o),this.order.length>this.max){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e);}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const t=this.data[e].shift();return t.timeout&&clearTimeout(t.timeout),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),t.value}getByKey(e){const t=this.data[e];return t?t[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,t){if(!this.has(e))return this;const i=e.wrapped().key,o=void 0===t?0:this.data[i].indexOf(t),r=this.data[i][o];return this.data[i].splice(o,1),r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(r.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e);}return this}filter(e){const t=[];for(const i in this.data)for(const o of this.data[i])e(o.value)||t.push(o);for(const e of t)this.remove(e.value.tileID,e);}}class Kt extends e.E{constructor(e,t,i){super(),this.id=e,this._onlySymbols=i,t.on("data",(e=>{"source"===e.dataType&&"metadata"===e.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===e.dataType&&"content"===e.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform));})),t.on("error",(()=>{this._sourceErrored=!0;})),this._source=t,this._tiles={},this._cache=new Xt(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new y,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"raster-array"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType;}onAdd(e){this.map=e,this._minTileCacheSize=void 0===this._minTileCacheSize&&e?e._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&e?e._maxTileCacheSize:this._maxTileCacheSize;}loaded(){if(this._sourceErrored)return !0;if(!this._sourceLoaded)return !1;if(!this._source.loaded())return !1;for(const e in this._tiles){const t=this._tiles[e];if("errored"!==t.state&&("loaded"!==t.state||!t.bucketsLoaded()))return !1}return !0}getSource(){return this._source}pause(){this._paused=!0;}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform);}_loadTile(e,t){return e.isSymbolTile=this._onlySymbols,e.isExtraShadowCaster=this._shadowCasterTiles[e.tileID.key],this._source.loadTile(e,t)}_unloadTile(e){if(this._source.unloadTile)return this._source.unloadTile(e,(()=>{}))}_abortTile(e){if(this._source.abortTile)return this._source.abortTile(e,(()=>{}))}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const t in this._tiles){const i=this._tiles[t];i.upload(e),i.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope);}}getIds(){return e.a$(this._tiles).map((e=>e.tileID)).sort(Yt).map((e=>e.key))}getRenderableIds(t,i){const o=[];for(const e in this._tiles)this._isIdRenderable(+e,t,i)&&o.push(this._tiles[e]);return t?o.sort(((t,i)=>{const o=t.tileID,r=i.tileID,s=new e.P(o.canonical.x,o.canonical.y)._rotate(this.transform.angle),n=new e.P(r.canonical.x,r.canonical.y)._rotate(this.transform.angle);return o.overscaledZ-r.overscaledZ||n.y-s.y||n.x-s.x})).map((e=>e.tileID.key)):o.map((e=>e.tileID)).sort(Yt).map((e=>e.key))}hasRenderableParent(e){const t=this.findLoadedParent(e,0);return !!t&&this._isIdRenderable(t.tileID.key)}_isIdRenderable(e,t,i){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(t||!this._tiles[e].holdingForFade())&&(i||!this._shadowCasterTiles[e])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else {this._cache.reset();for(const e in this._tiles)"errored"!==this._tiles[e].state&&this._reloadTile(+e,"reloading");}}_reloadTile(e,t){const i=this._tiles[e];i&&("loading"!==i.state&&(i.state=t),this._loadTile(i,this._tileLoaded.bind(this,i,e,t)));}_tileLoaded(t,i,o,r){if(r)if(t.state="errored",404!==r.status)this._source.fire(new e.a(r,{tile:t}));else {if(!(t.tileID.key in this._loadedParentTiles))return void this._source.fire(new e.b("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id}));if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const e=this.map.painter.terrain;this.update(this.transform,e.getScaledDemTileSize(),!0),e.resetTileLookupCache(this.id);}else this.update(this.transform);}else t.timeAdded=e.f.now(),"expired"===o&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(i,t),"raster-dem"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),this._source.fire(new e.b("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id}));}_backfillDEM(e){const t=this.getRenderableIds();for(let o=0;o1||(Math.abs(i)>1&&(1===Math.abs(i+r)?i+=r:1===Math.abs(i-r)&&(i-=r)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,i,o),e.neighboringTiles&&e.neighboringTiles[s]&&(e.neighboringTiles[s].backfilled=!0)));}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,t,i,o){for(const r in this._tiles){let s=this._tiles[r];if(o[r]||!s.hasData()||s.tileID.overscaledZ<=t||s.tileID.overscaledZ>i)continue;let n=s.tileID;for(;s&&s.tileID.overscaledZ>t+1;){const e=s.tileID.scaledTo(s.tileID.overscaledZ-1);s=this._tiles[e.key],s&&s.hasData()&&(n=e);}let a=n;for(;a.overscaledZ>t;)if(a=a.scaledTo(a.overscaledZ-1),e[a.key]){o[n.key]=n;break}}}findLoadedParent(e,t){if(e.key in this._loadedParentTiles){const i=this._loadedParentTiles[e.key];return i&&i.tileID.overscaledZ>=t?i:null}for(let i=e.overscaledZ-1;i>=t;i--){const t=e.scaledTo(i),o=this._getLoadedTile(t);if(o)return o}}_getLoadedTile(e){const t=this._tiles[e.key];return t&&t.hasData()?t:this._cache.getByKey(this._source.reparseOverscaled?e.wrapped().key:e.canonical.key)}updateCacheSize(e,t){t=t||this._source.tileSize;const i=Math.ceil(e.width/t)+1,o=Math.ceil(e.height/t)+1,r=Math.floor(i*o*5),s="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,r):r,n="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,s):s;this._cache.setMaxSize(n);}handleWrapJump(e){const t=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);if(this._prevLng=e,t){const e={};for(const i in this._tiles){const o=this._tiles[i];o.tileID=o.tileID.unwrapTo(o.tileID.wrap+t),e[o.tileID.key]=o;}this._tiles=e;for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e in this._tiles)this._setTileReloadTimer(+e,this._tiles[e]);}}update(t,i,o,r){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!o)return;let s;if(this.updateCacheSize(t,i),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={},this.used||this.usedForTerrain)if(this._source.tileID)s=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new e.am(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y)));else if(0!==this.tileCoverLift){const r=t.clone();r.tileCoverLift=this.tileCoverLift,s=r.coveringTiles({tileSize:i||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!o,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.minzoom<=1&&"globe"===t.projection.name&&(s.push(new e.am(1,0,1,0,0)),s.push(new e.am(1,0,1,1,0)),s.push(new e.am(1,0,1,0,1)),s.push(new e.am(1,0,1,1,1)));}else s=t.coveringTiles({tileSize:i||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!o,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(s=s.filter((e=>this._source.hasTile(e))));else s=[];if(s.length>0&&this.castsShadows&&r&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!Jt(this._source.type)){const e=t.coveringZoomLevel({tileSize:i||this._source.tileSize,roundZoom:this._source.roundZoom&&!o}),n=Math.min(e,this._source.maxzoom),a=t.extendTileCoverForShadows(s,r,n);for(const e of a)this._shadowCasterTiles[e.key]=!0,s.push(e);}const n=this._updateRetainedTiles(s);if(Jt(this._source.type)&&0!==s.length){const t={},i={},o=Object.keys(n);for(const r of o){const o=n[r],s=this._tiles[r];if(!s||s.fadeEndTime&&s.fadeEndTime<=e.f.now())continue;const a=this.findLoadedParent(o,Math.max(o.overscaledZ-Kt.maxOverzooming,this._source.minzoom));a&&(this._addTile(a.tileID),t[a.tileID.key]=a.tileID),i[r]=o;}const r=s[s.length-1].overscaledZ;for(const e in this._tiles){const t=this._tiles[e];if(n[e]||!t.hasData())continue;let o=t.tileID;for(;o.overscaledZ>r;){o=o.scaledTo(o.overscaledZ-1);const r=this._tiles[o.key];if(r&&r.hasData()&&i[o.key]){n[e]=t.tileID;break}}}for(const e in t)n[e]||(this._coveredTiles[e]=!0,n[e]=t[e]);}for(const e in n)this._tiles[e].clearFadeHold();const a=e.b0(this._tiles,n);for(const e of a){const t=this._tiles[e];t.hasSymbolBuckets&&!t.holdingForFade()?t.setHoldDuration(this.map._fadeDuration):t.hasSymbolBuckets&&!t.symbolFadeFinished()||this._removeTile(+e);}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate();}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(+e);}_updateRetainedTiles(e){const t={};if(0===e.length)return t;const i={},o=e.reduce(((e,t)=>Math.min(e,t.overscaledZ)),1/0),r=e[0].overscaledZ,s=Math.max(r-Kt.maxOverzooming,this._source.minzoom),n=Math.max(r+Kt.maxUnderzooming,this._source.minzoom),a={};for(const i of e){const e=this._addTile(i);t[i.key]=i,e.hasData()||o=this._source.maxzoom){const e=o.children(this._source.maxzoom)[0],i=this.getTile(e);if(i&&i.hasData()){t[e.key]=e;continue}}else {const e=o.children(this._source.maxzoom);if(t[e[0].key]&&t[e[1].key]&&t[e[2].key]&&t[e[3].key])continue}let r=e.wasRequested();for(let n=o.overscaledZ-1;n>=s;--n){const s=o.scaledTo(n);if(i[s.key])break;if(i[s.key]=!0,e=this.getTile(s),!e&&r&&(e=this._addTile(s)),e&&(t[s.key]=s,r=e.wasRequested(),e.hasData()))break}}return t}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const t=[];let i,o=this._tiles[e].tileID;for(;o.overscaledZ>0;){if(o.key in this._loadedParentTiles){i=this._loadedParentTiles[o.key];break}t.push(o.key);const e=o.scaledTo(o.overscaledZ-1);if(i=this._getLoadedTile(e),i)break;o=e;}for(const e of t)this._loadedParentTiles[e]=i;}}_addTile(t){let i=this._tiles[t.key];if(i)return !0!==i.isExtraShadowCaster||!!this._shadowCasterTiles[t.key]||this._reloadTile(t.key,"reloading"),i;i=this._cache.getAndRemove(t),i&&(this._setTileReloadTimer(t.key,i),i.tileID=t,this._state.initializeTileState(i,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,i)));const o=Boolean(i);if(!o){const e=this.map?this.map.painter:null,o=this._source.tileSize*t.overscaleFactor();i="raster-array"===this._source.type?new $t(t,o,this.transform.tileZoom,e,this._isRaster):new Gt(t,o,this.transform.tileZoom,e,this._isRaster),this._loadTile(i,this._tileLoaded.bind(this,i,t.key,i.state));}return i?(i.uses++,this._tiles[t.key]=i,o||this._source.fire(new e.b("dataloading",{tile:i,coord:i.tileID,dataType:"source"})),i):null}_setTileReloadTimer(e,t){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const i=t.getExpiryTimeout();i&&(this._timers[e]=setTimeout((()=>{this._reloadTile(e,"expired"),delete this._timers[e];}),i));}_removeTile(e){const t=this._tiles[e];t&&(t.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),t.uses>0||(t.hasData()&&"reloading"!==t.state||"empty"===t.state?this._cache.add(t.tileID,t,t.getExpiryTimeout()):(t.aborted=!0,this._abortTile(t),this._unloadTile(t))));}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(+e);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id);}tilesIn(t,i,o){const r=[],s=this.transform;if(!s)return r;const n="globe"===s.projection.name,a=e.a5(s.center.lng);for(const l in this._tiles){const c=this._tiles[l];if(o&&c.clearQueryDebugViz(),c.holdingForFade())continue;let h;if(n){const t=c.tileID.canonical;if(0===t.z){const i=[Math.abs(e.aa(a,...Qt(t,-1))-a),Math.abs(e.aa(a,...Qt(t,1))-a)];h=[0,2*i.indexOf(Math.min(...i))-1];}else {const i=[Math.abs(e.aa(a,...Qt(t,-1))-a),Math.abs(e.aa(a,...Qt(t,0))-a),Math.abs(e.aa(a,...Qt(t,1))-a)];h=[i.indexOf(Math.min(...i))-1];}}else h=[0];for(const e of h){const o=t.containsTile(c,s,i,e);o&&r.push(o);}}return r}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(e){return this._getRenderableCoordinates(e)}_getRenderableCoordinates(e,t){const i=this.getRenderableIds(e,t).map((e=>this._tiles[e].tileID)),o="globe"===this.transform.projection.name;for(const e of i)e.projMatrix=this.transform.calculateProjMatrix(e.toUnwrapped()),e.expandedProjMatrix=o?this.transform.calculateProjMatrix(e.toUnwrapped(),!1,!0):e.projMatrix;return i}sortCoordinatesByDistance(e){const t=e.slice(),i=this.transform._camera.position,o=this.transform._camera.forward(),r={};for(const e of t){const t=1/(1<r[e.key]-r[t.key])),t}hasTransition(){if(this._source.hasTransition())return !0;if(Jt(this._source.type))for(const t in this._tiles){const i=this._tiles[t];if(void 0!==i.fadeEndTime&&i.fadeEndTime>=e.f.now())return !0}return !1}setFeatureState(e,t,i){this._state.updateState(e=e||"_geojsonTileLayer",t,i);}removeFeatureState(e,t,i){this._state.removeFeatureState(e=e||"_geojsonTileLayer",t,i);}getFeatureState(e,t){return this._state.getState(e=e||"_geojsonTileLayer",t)}setDependencies(e,t,i){const o=this._tiles[e];o&&o.setDependencies(t,i);}reloadTilesForDependencies(e,t){for(const i in this._tiles)this._tiles[i].hasDependency(e,t)&&this._reloadTile(+i,"reloading");this._cache.filter((i=>!i.hasDependency(e,t)));}_preloadTiles(t,i){if(!this._sourceLoaded){const e=()=>{this._sourceLoaded&&(this._source.off("data",e),this._preloadTiles(t,i));};return void this._source.on("data",e)}const o=new Map,r=Array.isArray(t)?t:[t],s=this.map.painter.terrain,n=this.usedForTerrain&&s?s.getScaledDemTileSize():this._source.tileSize;for(const e of r){const t=e.coveringTiles({tileSize:n,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const e of t)o.set(e.key,e);this.usedForTerrain&&e.updateElevation(!1);}const a=Array.from(o.values());e.b1(a,((e,t)=>{const i=new Gt(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(i,(e=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),t(e,i);}));}),i);}}function Yt(e,t){const i=Math.abs(2*e.wrap)-+(e.wrap<0),o=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||o-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function Jt(e){return "raster"===e||"image"===e||"video"===e||"custom"===e}function Qt(e,t){const i=1<0:"model"===i.type&&(o=!i.isHidden(e)&&i.paint.get("model-opacity")>0),this.layersGotHidden=this.layersGotHidden||!o&&t.visible,t.visible=o;}}updateZOffset(e,t){this.currentBuildingBuckets=[];for(const e of this.layers){const i=e.layer,o=this.style.getLayerSourceCache(i);let r=1;"fill-extrusion"===i.type&&(r=e.visible?i.paint.get("fill-extrusion-vertical-scale"):0);let s=o?o.getTile(t):null;if(!s&&o&&t.canonical.z>o.getSource().minzoom){let e=t.scaledTo(Math.min(o.getSource().maxzoom,t.overscaledZ-1));for(;e.overscaledZ>=o.getSource().minzoom&&(s=o.getTile(e),!s&&0!==e.overscaledZ);)e=e.scaledTo(e.overscaledZ-1);}this.currentBuildingBuckets.push({bucket:s?s.getBucket(i):null,tileID:s?s.tileID:t,verticalScale:r});}e.hasAnyZOffset=!1;let i=!1;for(let o=0;o{e in i&&(o[e]=i[e]);})),o}function ii(e){e=e.slice();const t=Object.create(null);for(let i=0;i0?(r-n)/a:0;return this.points[s].mult(1-l).add(this.points[i].mult(l))}}class di{constructor(e,t,i){const o=this.boxCells=[],r=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let e=0;ethis.width||o<0||t>this.height)return !r&&[];const n=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=o){if(r)return !0;for(let e=0;e0:n}_queryCircle(e,t,i,o,r){const s=e-i,n=e+i,a=t-i,l=t+i;if(n<0||s>this.width||l<0||a>this.height)return !o&&[];const c=[];return this._forEachCell(s,a,n,l,this._queryCellCircle,c,{hitTest:o,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}},r),o?c.length>0:c}query(e,t,i,o,r){return this._query(e,t,i,o,!1,r)}hitTest(e,t,i,o,r){return this._query(e,t,i,o,!0,r)}hitTestCircle(e,t,i,o){return this._queryCircle(e,t,i,!0,o)}_queryCell(e,t,i,o,r,s,n,a){const l=n.seenUids,c=this.boxCells[r];if(null!==c){const r=this.bboxes;for(const h of c)if(!l.box[h]){l.box[h]=!0;const c=4*h;if(e<=r[c+2]&&t<=r[c+3]&&i>=r[c+0]&&o>=r[c+1]&&(!a||a(this.boxKeys[h]))){if(n.hitTest)return s.push(!0),!0;s.push({key:this.boxKeys[h],x1:r[c],y1:r[c+1],x2:r[c+2],y2:r[c+3]});}}}const h=this.circleCells[r];if(null!==h){const r=this.circles;for(const c of h)if(!l.circle[c]){l.circle[c]=!0;const h=3*c;if(this._circleAndRectCollide(r[h],r[h+1],r[h+2],e,t,i,o)&&(!a||a(this.circleKeys[c]))){if(n.hitTest)return s.push(!0),!0;{const e=r[h],t=r[h+1],i=r[h+2];s.push({key:this.circleKeys[c],x1:e-i,y1:t-i,x2:e+i,y2:t+i});}}}}}_queryCellCircle(e,t,i,o,r,s,n,a){const l=n.circle,c=n.seenUids,h=this.boxCells[r];if(null!==h){const e=this.bboxes;for(const t of h)if(!c.box[t]){c.box[t]=!0;const i=4*t;if(this._circleAndRectCollide(l.x,l.y,l.radius,e[i+0],e[i+1],e[i+2],e[i+3])&&(!a||a(this.boxKeys[t])))return s.push(!0),!0}}const u=this.circleCells[r];if(null!==u){const e=this.circles;for(const t of u)if(!c.circle[t]){c.circle[t]=!0;const i=3*t;if(this._circlesCollide(e[i],e[i+1],e[i+2],l.x,l.y,l.radius)&&(!a||a(this.circleKeys[t])))return s.push(!0),!0}}}_forEachCell(e,t,i,o,r,s,n,a){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),h=this._convertToXCellCoord(i),u=this._convertToYCellCoord(o);for(let d=l;d<=h;d++)for(let l=c;l<=u;l++)if(r.call(this,e,t,i,o,this.xCellCount*l+d,s,n,a))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,t,i,o,r,s){const n=o-e,a=r-t,l=i+s;return l*l>n*n+a*a}_circleAndRectCollide(e,t,i,o,r,s,n){const a=(s-o)/2,l=Math.abs(e-(o+a));if(l>a+i)return !1;const c=(n-r)/2,h=Math.abs(t-(r+c));if(h>c+i)return !1;if(l<=a||h<=c)return !0;const u=l-a,d=h-c;return u*u+d*d<=i*i}}const _i={unknown:0,flipRequired:1,flipNotRequired:2},pi=Math.tan(85*Math.PI/180);function fi(t,i,o,r,s,n,a){const l=e.a6.create();if(o)if("globe"===n.name){const t=e.b3(s,i);e.a6.multiply(l,l,t);}else {const t=e.b4.invert([],a);l[0]=t[0],l[1]=t[1],l[4]=t[2],l[5]=t[3],r||e.a6.rotateZ(l,l,s.angle);}else e.a6.multiply(l,s.labelPlaneMatrix,t);return l}function mi(e,t,i,o,r,s,n){const a=fi(e,t,i,o,r,s,n);return "globe"===s.name&&i||(a[2]=a[6]=a[10]=a[14]=0),a}function gi(t,i,o,r,s,n,a){if(o){if("globe"===n.name){const l=fi(t,i,o,r,s,n,a);return e.a6.invert(l,l),e.a6.multiply(l,t,l),l}{const i=e.a6.clone(t),o=e.a6.identity([]);return o[0]=a[0],o[1]=a[1],o[4]=a[2],o[5]=a[3],e.a6.multiply(i,i,o),r||e.a6.rotateZ(i,i,-s.angle),i}}return s.glCoordMatrix}function vi(t,i,o,r){const s=[t,i,o,1];o?e.a7.transformMat4(s,s,r):Li(s,s,r);const n=s[3];return s[0]/=n,s[1]/=n,s[2]/=n,s}function xi(e,t){return Math.min(.5+e/t*.5,1.5)}function yi(e,t){const i=e[0]/e[3],o=e[1]/e[3];return i>=-t[0]&&i<=t[0]&&o>=-t[1]&&o<=t[1]}function bi(t,i,o,r,s,n,a,l,c,h){const u=o.transform,d=r?t.textSizeData:t.iconSizeData,_=e.b5(d,o.transform.zoom),p="globe"===u.projection.name,f=[256/o.width*2+1,256/o.height*2+1],m=r?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;m.clear();let g=null;p&&(g=r?t.text.globeExtVertexArray:t.icon.globeExtVertexArray);const v=t.lineVertexArray,x=r?t.text.placedSymbolArray:t.icon.placedSymbolArray,y=o.transform.width/o.transform.height;let b,w=!1;for(let r=0;rMath.abs(o)?{useVertical:!0}:t===e.b6.vertical?r>0?{needsFlipping:!0}:null:i!==_i.unknown&&function(e,t){return 0===e||Math.abs(t/e)>pi}(o,r)?i===_i.flipRequired?{needsFlipping:!0}:null:o<0?{needsFlipping:!0}:null}function Ei(t,i,o,r,s,n,a,l,c,h,u,d,_,p,f,m,g,v,x){const y=i/24,b=t.lineOffsetX*y,w=t.lineOffsetY*y,{lineStartIndex:T,glyphStartIndex:E,numGlyphs:S,segment:C,writingMode:I,flipState:D}=t,L=T+t.lineLength,A=t=>{if(u){const[i,o,r]=t.up,s=h.length;e.b8(u,s+0,i,o,r),e.b8(u,s+1,i,o,r),e.b8(u,s+2,i,o,r),e.b8(u,s+3,i,o,r);}const[i,o,r]=t.point;e.b9(h,i,o,r,t.angle);};if(S>1){const e=wi(y,l,b,w,o,d,_,t,c,n,p,m,!1,g,v,x);if(!e)return {notEnoughRoom:!0};if(r&&!o){let[i,o,r]=e.first.point,[s,n,l]=e.last.point;[i,o]=vi(i,o,r,a),[s,n]=vi(s,n,l,a);const c=Ti(I,D,(s-i)*f,n-o);if(t.flipState=c&&c.needsFlipping?_i.flipRequired:_i.flipNotRequired,c)return c}A(e.first);for(let e=E+1;e0?n:Ci(_,r,i,1,s,void 0,g,v.canonical),l=Ti(I,D,(a[0]-i[0])*f,a[1]-i[1]);if(t.flipState=l&&l.needsFlipping?_i.flipRequired:_i.flipNotRequired,l)return l}const i=Ii(y*l.getoffsetX(E),b,w,o,d,_,C,T,L,c,n,p,m,!1,!1,g,v,x);if(!i)return {notEnoughRoom:!0};A(i);}return {}}function Si(e,t,i,o,r){const{x:s,y:n,z:a}=o.projectTilePoint(e.x,e.y,t);if(!r)return vi(s,n,a,i);const[l,c,h]=r(e);return vi(s+l,n+c,a+h,i)}function Ci(t,i,o,r,s,n,a,l){const c=Si(t.sub(i)._unit()._add(t),l,s,a,n);return e.N.sub(c,o,c),e.N.normalize(c,c),e.N.scaleAndAdd(c,o,c,r)}function Ii(t,i,o,r,s,n,a,l,c,h,u,d,_,p,f,m,g,v){const x=r?t-i:t+i;let y=x>0?1:-1,b=0;r&&(y*=-1,b=Math.PI),y<0&&(b+=Math.PI);let w=l+a+(y>0?0:1)|0,T=s,E=s,S=0,C=0;const I=Math.abs(x),D=[],L=[];let A=n,R=A;const P=()=>Ci(R,A,E,I-S+1,u,_,m,g.canonical);for(;S+C<=I;){if(w+=y,w=c)return null;if(E=T,R=A,D.push(E),p&&L.push(R),A=new e.P(h.getx(w),h.gety(w)),T=d[w],!T){const e=Si(A,g.canonical,u,m,_);T=e[3]>0?d[w]=e:P();}S+=C,C=e.N.distance(E,T);}f&&_&&(d[w]&&(T=P(),C=e.N.distance(E,T)),d[w]=T);const M=(I-S)/C,z=A.sub(R)._mult(M)._add(R),O=e.N.sub([],T,E),F=e.N.scaleAndAdd([],E,O,M);let B=[0,0,1],k=O[0],N=O[1];if(v&&(B=m.upVector(g.canonical,z.x,z.y),0!==B[0]||0!==B[1]||1!==B[2])){const t=[B[2],0,-B[0]],i=e.N.cross([],B,t);e.N.normalize(t,t),e.N.normalize(i,i),k=e.N.dot(O,t),N=e.N.dot(O,i);}if(o){const t=e.N.cross([],B,O);e.N.normalize(t,t),e.N.scaleAndAdd(F,F,t,o*y);}const U=b+Math.atan2(N,k);return D.push(F),p&&L.push(z),{point:F,angle:U,path:D,tilePath:L,up:B}}function Di(e,t){const i=t.length,o=i+4*e;t.resize(o),t.float32.fill(-1/0,4*i,4*o);}function Li(e,t,i){const o=t[0],r=t[1];return e[0]=i[0]*o+i[4]*r+i[12],e[1]=i[1]*o+i[5]*r+i[13],e[3]=i[3]*o+i[7]*r+i[15],e}const Ai=100;class Ri{constructor(e,t,i=new di(e.width+200,e.height+200,25),o=new di(e.width+200,e.height+200,25)){this.transform=e,this.grid=i,this.ignoredGrid=o,this.pitchfactor=Math.cos(e._pitch)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+Ai,this.screenBottomBoundary=e.height+Ai,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.fogState=t;}placeCollisionBox(e,t,i,o,r,s,n,a){let l=i.projectedAnchorX,c=i.projectedAnchorY,h=i.projectedAnchorZ;const u=i.elevation,d=i.tileID,_=e.getProjection();if(u&&d){const[e,t,o]=_.upVector(d.canonical,i.tileAnchorX,i.tileAnchorY),r=_.upVectorScale(d.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;l+=e*u*r,c+=t*u*r,h+=o*u*r;}const p=this.projectAndGetPerspectiveRatio(n,l,c,h,i.tileID,"globe"===_.name||!!u||this.transform.pitch>0,_),f=s*p.perspectiveRatio,m=(i.x1*t+o.x-i.padding)*f+p.point.x,g=(i.y1*t+o.y-i.padding)*f+p.point.y,v=(i.x2*t+o.x+i.padding)*f+p.point.x,x=(i.y2*t+o.y+i.padding)*f+p.point.y,y=p.perspectiveRatio<=.55||p.occluded;return !this.isInsideGrid(m,g,v,x)||!r&&this.grid.hitTest(m,g,v,x,a)||y?{box:[],offscreen:!1,occluded:p.occluded}:{box:[m,g,v,x],offscreen:this.isOffscreen(m,g,v,x),occluded:!1}}placeCollisionCircles(t,i,o,r,s,n,a,l,c,h,u,d,_,p,f){const m=[],g=this.transform.elevation,v=t.getProjection(),x=g?g.getAtTileOffsetFunc(f,this.transform.center.lat,this.transform.worldSize,v):null,y=new e.P(o.tileAnchorX,o.tileAnchorY);let{x:b,y:w,z:T}=v.projectTilePoint(y.x,y.y,f.canonical);if(x){const[e,t,i]=x(y);b+=e,w+=t,T+=i;}const E="globe"===v.name,S=this.projectAndGetPerspectiveRatio(a,b,w,T,f,E||!!g||this.transform.pitch>0,v),{perspectiveRatio:C}=S,I=(u?n/C:n*C)/e.bc,D=vi(b,w,T,l),L=S.signedDistanceFromCamera>0?wi(I,s,o.lineOffsetX*I,o.lineOffsetY*I,!1,D,y,o,r,l,{},g&&!u?x:null,u&&!!g,v,f,u):null;let A=!1,R=!1,P=!0;if(L&&!S.occluded){const t=.5*_*C+p,o=new e.P(-100,-100),r=new e.P(this.screenRightBoundary,this.screenBottomBoundary),s=new ui,{first:n,last:a}=L,l=n.path.length;let u=[];for(let e=l-1;e>=1;e--)u.push(n.path[e]);for(let e=1;e(x&&!E&&(i=x(oe[3]<=0))&&(u=[]));let g=[];if(u.length>0){let t=1/0,i=-1/0,s=1/0,n=-1/0;for(const e of u)t=Math.min(t,e[0]),s=Math.min(s,e[1]),i=Math.max(i,e[0]),n=Math.max(n,e[1]);i>=o.x&&t<=r.x&&n>=o.y&&s<=r.y&&(g=[u.map((t=>new e.P(t[0],t[1])))],(tr.x||sr.y)&&(g=e.ba(g,o.x,o.y,r.x,r.y)));}for(const e of g){s.reset(e,.25*t);let o=0;o=s.length<=.5*t?1:Math.ceil(s.paddedLength/f)+1;for(let e=0;e0){if(e.a7.transformMat4(l,l,t),this.fogState&&s&&"globe"!==a.name){const t=function(t,i,o,r,s,n){const a=n.calculateFogTileMatrix(s),l=[i,o,r];return e.N.transformMat4(l,l,a),ge(t,e.N.length(l),n.pitch,n._fov)}(this.fogState,i,o,r,s.toUnwrapped(),this.transform);c=t>.9;}}else Li(l,l,t);const h=l[3];return {point:new e.P((l[0]/h+1)/2*this.transform.width+Ai,(-l[1]/h+1)/2*this.transform.height+Ai),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(a)/h*.5,1.5),signedDistanceFromCamera:h,occluded:n&&l[2]>h||c}}isOffscreen(e,t,i,o){return i=this.screenRightBoundary||othis.screenBottomBoundary}isInsideGrid(e,t,i,o){return i>=0&&e=0&&te.collisionGroupID===t};}return this.collisionGroups[e]}}function Gi(t,i,o,r,s){const{horizontalAlign:n,verticalAlign:a}=e.bf(t),l=-(n-.5)*i,c=-(a-.5)*o,h=e.bd(t,r);return new e.P(l+h[0]*s,c+h[1]*s)}function ji(t,i,o,r,s){const n=new e.P(t,i);return o&&n._rotate(r?s:-s),n}class Vi{constructor(e,t,i,o,r,s){this.transform=e.clone(),this.projection=e.projection.name,this.collisionIndex=new Ri(this.transform,r),this.buildingIndex=s,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=t,this.retainedQueryData={},this.collisionGroups=new Ui(i),this.collisionCircleArrays={},this.prevPlacement=o,o&&(o.prevPlacement=void 0),this.placedOrientations={};}getBucketParts(t,i,o,r){const s=o.getBucket(i),n=o.latestFeatureIndex;if(!s||!n||i.fqid!==s.layerIds[0])return;const a=s.layers[0].layout,l=o.collisionBoxArray,c=Math.pow(2,this.transform.zoom-o.tileID.overscaledZ),h=o.tileSize/e.V,u=o.tileID.toUnwrapped();this.transform.setProjection(s.projection);const d=(_=o.tileID,p=s.getProjection(),f=this.transform,p.name===this.projection?f.calculateProjMatrix(_.toUnwrapped()):Pi(f,p,_));var _,p,f;const m="map"===a.get("text-pitch-alignment"),g="map"===a.get("text-rotation-alignment");i.compileFilter();const v=i.dynamicFilter(),x=i.dynamicFilterNeedsFeature(),y=this.transform.calculatePixelsToTileUnitsMatrix(o),b=mi(d,o.tileID.canonical,m,g,this.transform,s.getProjection(),y);let w=null;if(m){const t=gi(d,o.tileID.canonical,m,g,this.transform,s.getProjection(),y);w=e.a6.multiply([],this.transform.labelPlaneMatrix,t);}let T=null;v&&o.latestFeatureIndex&&(T={unwrappedTileID:u,dynamicFilter:v,dynamicFilterNeedsFeature:x,featureIndex:o.latestFeatureIndex}),this.retainedQueryData[s.bucketInstanceId]=new Ni(s.bucketInstanceId,n,s.sourceLayerIndex,s.index,o.tileID);const E={bucket:s,layout:a,posMatrix:d,textLabelPlaneMatrix:b,labelToScreenMatrix:w,clippingData:T,scale:c,textPixelRatio:h,holdingForFade:o.holdingForFade(),collisionBoxArray:l,partiallyEvaluatedTextSize:e.b5(s.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:e.b5(s.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(s.sourceID)};if(r)for(const e of s.sortKeyRanges){const{sortKey:i,symbolInstanceStart:o,symbolInstanceEnd:r}=e;t.push({sortKey:i,symbolInstanceStart:o,symbolInstanceEnd:r,parameters:E});}else t.push({symbolInstanceStart:0,symbolInstanceEnd:s.symbolInstances.length,parameters:E});}attemptAnchorPlacement(e,t,i,o,r,s,n,a,l,c,h,u,d,_,p,f,m,g){const{textOffset0:v,textOffset1:x,crossTileID:y}=u,b=[v,x],w=Gi(e,i,o,b,r),T=this.collisionIndex.placeCollisionBox(_,r,t,ji(w.x,w.y,s,n,this.transform.angle),h,a,l,c.predicate);if(f){const e=_.getSymbolInstanceIconSize(g,this.transform.zoom,u.placedIconSymbolIndex);if(0===this.collisionIndex.placeCollisionBox(_,e,f,ji(w.x,w.y,s,n,this.transform.angle),h,a,l,c.predicate).box.length)return}if(T.box.length>0){let t;return this.prevPlacement&&this.prevPlacement.variableOffsets[y]&&this.prevPlacement.placements[y]&&this.prevPlacement.placements[y].text&&(t=this.prevPlacement.variableOffsets[y].anchor),this.variableOffsets[y]={textOffset:b,width:i,height:o,anchor:e,textScale:r,prevAnchor:t},this.markUsedJustification(_,e,u,p),_.allowVerticalPlacement&&(this.markUsedOrientation(_,p,u),this.placedOrientations[y]=p),{shift:w,placedGlyphBoxes:T}}}placeLayerBucketPart(t,i,o,r){const{bucket:s,layout:n,posMatrix:a,textLabelPlaneMatrix:l,labelToScreenMatrix:c,clippingData:h,textPixelRatio:u,holdingForFade:d,collisionBoxArray:_,partiallyEvaluatedTextSize:p,partiallyEvaluatedIconSize:f,collisionGroup:m}=t.parameters,g=n.get("text-optional"),v=n.get("icon-optional"),x=n.get("text-allow-overlap"),y=n.get("icon-allow-overlap"),b="map"===n.get("text-rotation-alignment"),w="map"===n.get("text-pitch-alignment"),T="viewport-y"===n.get("symbol-z-order"),E=n.get("symbol-z-elevate");this.transform.setProjection(s.projection);let S=x&&(y||!s.hasIconData()||v),C=y&&(x||!s.hasTextData()||g);!s.collisionArrays&&_&&s.deserializeCollisionBoxes(_),o&&r&&s.updateCollisionDebugBuffers(this.transform.zoom,_);const I=(t,r,_)=>{const{crossTileID:T,numVerticalGlyphVertices:E}=t;if(h){const o={zoom:this.transform.zoom,pitch:this.transform.pitch};let r=null;if(h.dynamicFilterNeedsFeature){const e=this.retainedQueryData[s.bucketInstanceId];r=h.featureIndex.loadFeature({featureIndex:t.featureIndex,bucketIndex:e.bucketIndex,sourceLayerIndex:e.sourceLayerIndex,layoutVertexArrayOffset:0});}if(!(0, h.dynamicFilter)(o,r,this.retainedQueryData[s.bucketInstanceId].tileID.canonical,new e.P(t.tileAnchorX,t.tileAnchorY),this.transform.calculateDistanceTileData(h.unwrappedTileID)))return this.placements[T]=new Bi(!1,!1,!1,!0),void i.add(T)}if(i.has(T))return;if(d)return void(this.placements[T]=new Bi(!1,!1,!1));let I=!1,D=!1,L=!0,A=!1,R=!1,P=null,M={box:null,offscreen:null,occluded:null},z={box:null,offscreen:null,occluded:null},O=null,F=null,B=null,k=0,N=0,U=0;_.textFeatureIndex?k=_.textFeatureIndex:t.useRuntimeCollisionCircles&&(k=t.featureIndex),_.verticalTextFeatureIndex&&(N=_.verticalTextFeatureIndex);const G=e=>{e.tileID=this.retainedQueryData[s.bucketInstanceId].tileID;const i=this.transform.elevation;e.elevation=t.zOffset+(i?i.getAtTileOffset(e.tileID,e.tileAnchorX,e.tileAnchorY):0);},j=_.textBox;if(j){G(j);const i=i=>{let o=e.b6.horizontal;if(s.allowVerticalPlacement&&!i&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[T];e&&(this.placedOrientations[T]=e,o=e,this.markUsedOrientation(s,o,t));}return o},o=(t,i)=>{if(s.allowVerticalPlacement&&E>0&&_.verticalTextBox){for(const o of s.writingModes)if(o===e.b6.vertical?(M=i(),z=M):M=t(),M&&M.box&&M.box.length)break}else M=t();};if(n.get("text-variable-anchor")){let l=n.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[T]){const e=this.prevPlacement.variableOffsets[T];l.indexOf(e.anchor)>0&&(l=l.filter((t=>t!==e.anchor)),l.unshift(e.anchor));}const c=(e,i,o)=>{const n=s.getSymbolInstanceTextSize(p,t,this.transform.zoom,r),c=(e.x2-e.x1)*n+2*e.padding,h=(e.y2-e.y1)*n+2*e.padding,d=t.hasIconTextFit&&!y?i:null;d&&G(d);let _={box:[],offscreen:!1,occluded:!1};const g=x?2*l.length:l.length;for(let i=0;i=l.length,t,r,s,o,d,p,f);if(g&&(_=g.placedGlyphBoxes,_&&_.box&&_.box.length)){I=!0,P=g.shift;break}}return _};o((()=>c(j,_.iconBox,e.b6.horizontal)),(()=>{const t=_.verticalTextBox;return t&&G(t),s.allowVerticalPlacement&&!(M&&M.box&&M.box.length)&&E>0&&t?c(t,_.verticalIconBox,e.b6.vertical):{box:null,offscreen:null,occluded:null}})),M&&(I=M.box,L=M.offscreen,A=M.occluded);const h=i(!(!M||!M.box));if(!I&&this.prevPlacement){const e=this.prevPlacement.variableOffsets[T];e&&(this.variableOffsets[T]=e,this.markUsedJustification(s,e.anchor,t,h));}}else {const n=(i,o)=>{const n=s.getSymbolInstanceTextSize(p,t,this.transform.zoom,r),l=this.collisionIndex.placeCollisionBox(s,n,i,new e.P(0,0),x,u,a,m.predicate);return l&&l.box&&l.box.length&&(this.markUsedOrientation(s,o,t),this.placedOrientations[T]=o),l};o((()=>n(j,e.b6.horizontal)),(()=>{const t=_.verticalTextBox;return s.allowVerticalPlacement&&E>0&&t?(G(t),n(t,e.b6.vertical)):{box:null,offscreen:null,occluded:null}})),i(!!(M&&M.box&&M.box.length));}}if(O=M,I=O&&O.box&&O.box.length>0,L=O&&O.offscreen,A=O&&O.occluded,t.useRuntimeCollisionCircles){const i=s.text.placedSymbolArray.get(t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex),r=e.b7(s.textSizeData,p,i),h=n.get("text-padding");F=this.collisionIndex.placeCollisionCircles(s,x,i,s.lineVertexArray,s.glyphOffsetArray,r,a,l,c,o,w,m.predicate,t.collisionCircleDiameter*r/e.bc,h,this.retainedQueryData[s.bucketInstanceId].tileID),I=x||F.circles.length>0&&!F.collisionDetected,L=L&&F.offscreen,A=F.occluded;}if(_.iconFeatureIndex&&(U=_.iconFeatureIndex),_.iconBox){const i=i=>{G(i);const o=t.hasIconTextFit&&P?ji(P.x,P.y,b,w,this.transform.angle):new e.P(0,0),r=s.getSymbolInstanceIconSize(f,this.transform.zoom,t.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(s,r,i,o,y,u,a,m.predicate)};z&&z.box&&z.box.length&&_.verticalIconBox?(B=i(_.verticalIconBox),D=B.box.length>0):(B=i(_.iconBox),D=B.box.length>0),L=L&&B.offscreen,R=B.occluded;}const V=g||0===t.numHorizontalGlyphVertices&&0===E,Z=v||0===t.numIconVertices;if(V||Z?Z?V||(D=D&&I):I=D&&I:D=I=D&&I,I&&O&&O.box&&this.collisionIndex.insertCollisionBox(O.box,n.get("text-ignore-placement"),s.bucketInstanceId,z&&z.box&&N?N:k,m.ID),D&&B&&this.collisionIndex.insertCollisionBox(B.box,n.get("icon-ignore-placement"),s.bucketInstanceId,U,m.ID),F&&(I&&this.collisionIndex.insertCollisionCircles(F.circles,n.get("text-ignore-placement"),s.bucketInstanceId,k,m.ID),o)){const e=s.bucketInstanceId;let t=this.collisionCircleArrays[e];void 0===t&&(t=this.collisionCircleArrays[e]=new ki);for(let e=0;e=0;--e){const i=t[e];I(s.symbolInstances.get(i),i,s.collisionArrays[i]);}s.hasAnyZOffset&&e.w(`${s.layerIds[0]} layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y`);}else if(s.hasAnyZOffset){const e=s.getSortedIndexesByZOffset();for(let t=0;t=0&&(t.text.placedSymbolArray.get(s).crossTileID=u>=0&&s!==u?0:c),n>=0&&(t.text.placedSymbolArray.get(n).crossTileID=u>=0&&n!==u?0:c),a>=0&&(t.text.placedSymbolArray.get(a).crossTileID=u>=0&&a!==u?0:c),l>=0&&(t.text.placedSymbolArray.get(l).crossTileID=u>=0&&l!==u?0:c);}markUsedOrientation(t,i,o){const r=i===e.b6.horizontal||i===e.b6.horizontalOnly?i:0,s=i===e.b6.vertical?i:0,{leftJustifiedTextSymbolIndex:n,centerJustifiedTextSymbolIndex:a,rightJustifiedTextSymbolIndex:l,verticalPlacedTextSymbolIndex:c}=o,h=t.text.placedSymbolArray;n>=0&&(h.get(n).placedOrientation=r),a>=0&&(h.get(a).placedOrientation=r),l>=0&&(h.get(l).placedOrientation=r),c>=0&&(h.get(c).placedOrientation=s);}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const t=this.prevPlacement;let i=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;const o=t?t.symbolFadeChange(e):1,r=t?t.opacities:{},s=t?t.variableOffsets:{},n=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],s=r[e];s?(this.opacities[e]=new Fi(s,o,t.text,t.icon,null,t.clipped),i=i||t.text!==s.text.placed||t.icon!==s.icon.placed):(this.opacities[e]=new Fi(null,o,t.text,t.icon,t.skipFade,t.clipped),i=i||t.text||t.icon);}for(const e in r){const t=r[e];if(!this.opacities[e]){const r=new Fi(t,o,!1,!1);r.isHidden()||(this.opacities[e]=r,i=i||t.text.placed||t.icon.placed);}}for(const e in s)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=s[e]);for(const e in n)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=n[e]);i?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e);}updateLayerOpacities(e,t){const i=new Set;for(const o of t){const t=o.getBucket(e);t&&o.latestFeatureIndex&&e.fqid===t.layerIds[0]&&(this.updateBucketOpacities(t,i,o.collisionBoxArray),t.layers[0].layout.get("symbol-z-elevate")&&this.buildingIndex&&(this.buildingIndex.updateZOffset(t,o.tileID),t.updateZOffset()));}}updateBucketOpacities(t,i,o){t.hasTextData()&&t.text.opacityVertexArray.clear(),t.hasIconData()&&t.icon.opacityVertexArray.clear(),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const r=t.layers[0].layout,s=!!t.layers[0].dynamicFilter(),n=new Fi(null,0,!1,!1,!0),a=r.get("text-allow-overlap"),l=r.get("icon-allow-overlap"),c=r.get("text-variable-anchor"),h="map"===r.get("text-rotation-alignment"),u="map"===r.get("text-pitch-alignment"),d=new Fi(null,0,a&&(l||!t.hasIconData()||r.get("icon-optional")),l&&(a||!t.hasTextData()||r.get("text-optional")),!0);!t.collisionArrays&&o&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(o);const _=(e,t,i)=>{for(let o=0;o0||l>0,y=m>0,b=this.placedOrientations[f],w=b===e.b6.vertical,T=b===e.b6.horizontal||b===e.b6.horizontalOnly;if(!x&&!y||v.isHidden()||p++,x){const e=Ji(v.text);_(t.text,a,w?Qi:e),_(t.text,l,T?Qi:e);const i=v.text.isHidden(),{leftJustifiedTextSymbolIndex:o,centerJustifiedTextSymbolIndex:s,rightJustifiedTextSymbolIndex:n,verticalPlacedTextSymbolIndex:c}=r,h=t.text.placedSymbolArray,u=i||w?1:0;o>=0&&(h.get(o).hidden=u),s>=0&&(h.get(s).hidden=u),n>=0&&(h.get(n).hidden=u),c>=0&&(h.get(c).hidden=i||T?1:0);const d=this.variableOffsets[f];d&&this.markUsedJustification(t,d.anchor,r,b);const p=this.placedOrientations[f];p&&(this.markUsedJustification(t,"left",r,p),this.markUsedOrientation(t,p,r));}if(y){const e=Ji(v.icon),{placedIconSymbolIndex:i,verticalPlacedIconSymbolIndex:o}=r,s=t.icon.placedSymbolArray,n=v.icon.isHidden()?1:0;i>=0&&(_(t.icon,m,w?Qi:e),s.get(i).hidden=n),o>=0&&(_(t.icon,r.numVerticalIconVertices,T?Qi:e),s.get(o).hidden=n);}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const i=t.collisionArrays[o];if(i){let o=new e.P(0,0),n=!0;if(i.textBox||i.verticalTextBox){if(c){const e=this.variableOffsets[f];e?(o=Gi(e.anchor,e.width,e.height,e.textOffset,e.textScale),h&&o._rotate(u?this.transform.angle:-this.transform.angle)):n=!1;}s&&(n=!v.clipped),i.textBox&&Zi(t.textCollisionBox.collisionVertexArray,v.text.placed,!n||w,o.x,o.y),i.verticalTextBox&&Zi(t.textCollisionBox.collisionVertexArray,v.text.placed,!n||T,o.x,o.y);}const a=n&&Boolean(!T&&i.verticalIconBox);i.iconBox&&Zi(t.iconCollisionBox.collisionVertexArray,v.icon.placed,a,r.hasIconTextFit?o.x:0,r.hasIconTextFit?o.y:0),i.verticalIconBox&&Zi(t.iconCollisionBox.collisionVertexArray,v.icon.placed,!a,r.hasIconTextFit?o.x:0,r.hasIconTextFit?o.y:0);}}}if(t.fullyClipped=0===p,t.sortFeatures(this.transform.angle),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.bucketInstanceId in this.collisionCircleArrays){const e=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=e.invProjMatrix,t.placementViewportMatrix=e.viewportMatrix,t.collisionCircleArray=e.circles,delete this.collisionCircleArrays[t.bucketInstanceId];}}symbolFadeChange(e){return 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTimee}setStale(){this.stale=!0;}}function Zi(e,t,i,o,r){e.emplaceBack(t?1:0,i?1:0,o||0,r||0),e.emplaceBack(t?1:0,i?1:0,o||0,r||0),e.emplaceBack(t?1:0,i?1:0,o||0,r||0),e.emplaceBack(t?1:0,i?1:0,o||0,r||0);}const Hi=Math.pow(2,25),Wi=Math.pow(2,24),qi=Math.pow(2,17),$i=Math.pow(2,16),Xi=Math.pow(2,9),Ki=Math.pow(2,8),Yi=Math.pow(2,1);function Ji(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;const t=e.placed?1:0,i=Math.floor(127*e.opacity);return i*Hi+t*Wi+i*qi+t*$i+i*Xi+t*Ki+i*Yi+t}const Qi=0;class eo{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&void 0!==e.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[];}continuePlacement(e,t,i,o,r){const s=this._bucketParts;for(;this._currentTileIndexe.sortKey-t.sortKey)));this._currentPartIndex{const t=e.f.now()-s;return !this._forceFullPlacement&&t>2};for(;this._currentPlacementIndex>=0;){const s=i[t[this._currentPlacementIndex]],a=this.placement.collisionIndex.transform.zoom;if("symbol"===s.type&&(!s.minzoom||s.minzoom<=a)&&(!s.maxzoom||s.maxzoom>a)){const t=s,i=t.layout.get("symbol-z-elevate"),a=this._inProgressLayer=this._inProgressLayer||new eo(t),l=e.ag(s.source,s.scope);if(a.continuePlacement(i?r[l]:o[l],this.placement,this._showCollisionBoxes,s,n))return;delete this._inProgressLayer;}this._currentPlacementIndex--;}this._done=!0;}commit(e){return this.placement.commit(e),this.placement}}const io=512/e.V/2;class oo{constructor(t,i,o){this.tileID=t,this.bucketInstanceId=o,this.index=new e.bg(i.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const r=t.canonical.x*e.V,s=t.canonical.y*e.V;for(let e=0;ee.overscaledZ)for(const i in r){const s=r[i];s.tileID.isChildOf(e)&&s.findMatches(t.symbolInstances,e,o);}else {const s=r[e.scaledTo(Number(i)).key];s&&s.findMatches(t.symbolInstances,e,o);}}for(let e=0;e{t[e]=!0;}));for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e];}}class ao{constructor(e=0,t=0,i=0,o=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(i)||i<0||isNaN(o)||o<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=t,this.left=i,this.right=o;}interpolate(t,i,o){return null!=i.top&&null!=t.top&&(this.top=e.U(t.top,i.top,o)),null!=i.bottom&&null!=t.bottom&&(this.bottom=e.U(t.bottom,i.bottom,o)),null!=i.left&&null!=t.left&&(this.left=e.U(t.left,i.left,o)),null!=i.right&&null!=t.right&&(this.right=e.U(t.right,i.right,o)),this}getCenter(t,i){const o=e.aa((this.left+t-this.right)/2,0,t),r=e.aa((this.top+i-this.bottom)/2,0,i);return new e.P(o,r)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new ao(this.top,this.bottom,this.left,this.right)}toJSON(){return {top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function lo(t,i){const o=e.bk(t,3);e.a6.fromQuat(t,i),e.bm(t,3,o);}function co(t,i){const o=e.bi.identity([]);return e.bi.rotateZ(o,o,-i),e.bi.rotateX(o,o,-t),o}function ho(t,i){const o=[t[0],t[1],0],r=[i[0],i[1],0];if(e.N.length(o)>=1e-15){const t=e.N.normalize([],o);e.N.scale(r,t,e.N.dot(r,t)),i[0]=r[0],i[1]=r[1];}const s=e.N.cross([],i,t);if(e.N.len(s)<1e-15)return null;const n=Math.atan2(-s[1],s[0]);return co(Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2]),n)}class uo{constructor(e,t){this.position=e,this.orientation=t;}get position(){return this._position}set position(t){if(t){const i=t instanceof e.L?t:new e.L(t[0],t[1],t[2]);this._renderWorldCopies&&(i.x=e.bh(i.x,0,1)),this._position=i;}else this._position=null;}lookAtPoint(t,i){if(this.orientation=null,!this.position)return;const o=this.position,r=this._elevation?this._elevation.getAtPointOrZero(e.L.fromLngLat(t)):0,s=e.L.fromLngLat(t,r),n=[s.x-o.x,s.y-o.y,s.z-o.z];i||(i=[0,0,1]),i[2]=Math.abs(i[2]),this.orientation=ho(n,i);}setPitchBearing(t,i){this.orientation=co(e.bj(t),e.bj(-i));}}class _o{constructor(t,i){this._transform=e.a6.identity([]),this.orientation=i,this.position=t;}get mercatorPosition(){const t=this.position;return new e.L(t[0],t[1],t[2])}get position(){const t=e.bk(this._transform,3);return [t[0],t[1],t[2]]}set position(t){var i;t&&e.bm(this._transform,3,[(i=t)[0],i[1],i[2],1]);}get orientation(){return this._orientation}set orientation(t){this._orientation=t||e.bi.identity([]),t&&lo(this._transform,this._orientation);}getPitchBearing(){const e=this.forward(),t=this.right();return {bearing:Math.atan2(-t[1],t[0]),pitch:Math.atan2(Math.sqrt(e[0]*e[0]+e[1]*e[1]),-e[2])}}setPitchBearing(e,t){this._orientation=co(e,t),lo(this._transform,this._orientation);}forward(){const t=e.bk(this._transform,2);return [-t[0],-t[1],-t[2]]}up(){const t=e.bk(this._transform,1);return [-t[0],-t[1],-t[2]]}right(){const t=e.bk(this._transform,0);return [t[0],t[1],t[2]]}getCameraToWorld(t,i){const o=new Float64Array(16);return e.a6.invert(o,this.getWorldToCamera(t,i)),o}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(t,i,o){const r=this.position;e.N.scale(r,r,-t);const s=new Float64Array(16);return e.a6.fromScaling(s,[o,o,o]),e.a6.translate(s,s,r),s[10]*=i,s}getWorldToCamera(t,i){const o=new Float64Array(16),r=new Float64Array(4),s=this.position;return e.bi.conjugate(r,this._orientation),e.N.scale(s,s,-t),e.a6.fromQuat(o,r),e.a6.translate(o,o,s),o[1]*=-1,o[5]*=-1,o[9]*=-1,o[13]*=-1,o[8]*=i,o[9]*=i,o[10]*=i,o[11]*=i,o}getCameraToClipPerspective(t,i,o,r){const s=new Float64Array(16);return e.a6.perspective(s,t,i,o,r),s}getCameraToClipOrthographic(t,i,o,r,s,n){const a=new Float64Array(16);return e.a6.ortho(a,t,i,o,r,s,n),a}getDistanceToElevation(t,i=!1){const o=0===t?0:e.bl(t,i?e.au(this.position[1]):this.position[1]),r=this.forward();return (o-this.position[2])/r[2]}clone(){return new _o([...this.position],[...this.orientation])}}const po=(e,t,i)=>(1-i)*e+i*t,fo=e=>e*e*e*e*e;class mo{constructor(t,i,o,r,s,n,a){this.tileSize=512,this._renderWorldCopies=void 0===s||s,this._minZoom=t||0,this._maxZoom=i||22,this._minPitch=null==o?0:o,this._maxPitch=null==r?60:r,this.setProjection(n),this.setMaxBounds(a),this.width=0,this.height=0,this._center=new e.bn(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._unmodified=!0,this._edgeInsets=new ao,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new _o,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._pixelsPerMercatorPixel=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._tileCoverLift=0,this._horizonShift=.1,this._orthographicProjectionAtLowPitch=!1;}clone(){const e=new mo(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection());return e._elevation=this._elevation,e._centerAltitude=this._centerAltitude,e._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,e.tileSize=this.tileSize,e.mercatorFromTransition=this.mercatorFromTransition,e.width=this.width,e.height=this.height,e.cameraElevationReference=this.cameraElevationReference,e._center=this._center,e._setZoom(this.zoom),e._seaLevelZoom=this._seaLevelZoom,e.angle=this.angle,e._fov=this._fov,e._pitch=this._pitch,e._nearZ=this._nearZ,e._farZ=this._farZ,e._averageElevation=this._averageElevation,e._orthographicProjectionAtLowPitch=this._orthographicProjectionAtLowPitch,e._unmodified=this._unmodified,e._edgeInsets=this._edgeInsets.clone(),e._camera=this._camera.clone(),e._calcMatrices(),e.freezeTileCoverage=this.freezeTileCoverage,e.frustumCorners=this.frustumCorners,e}get isOrthographic(){return "globe"!==this.projection.name&&this._orthographicProjectionAtLowPitch&&this.pitch<15}get elevation(){return this._elevation}set elevation(e){this._elevation!==e&&(this._elevation=e,this._updateCameraOnTerrain(),this._calcMatrices());}get depthOcclusionForSymbolsAndCircles(){return "globe"!==this.projection.name&&!this.isOrthographic}updateElevation(e,t=!1){const i=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(null==this._seaLevelZoom||i)&&this._updateCameraOnTerrain(),(e||i)&&this._constrainCamera(t),this._calcMatrices();}getProjection(){return e.ac(this.projection,["name","center","parallels"])}setProjection(i){this.projectionOptions=i||{name:"mercator"};const o=this.projection?this.getProjection():void 0;this.projection=e.bo(this.projectionOptions);const r=!t(o,this.getProjection());return r&&this._calcMatrices(),this.mercatorFromTransition=!1,r}setOrthographicProjectionAtLowPitch(e){return this._orthographicProjectionAtLowPitch!==e&&(this._orthographicProjectionAtLowPitch=e,this._calcMatrices(),!0)}setMercatorFromTransition(){const t=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=e.bo({name:"mercator"});const i=t!==this.projection.name;return i&&this._calcMatrices(),i}get minZoom(){return this._minZoom}set minZoom(e){this._minZoom!==e&&(this._minZoom=e,this.zoom=Math.max(this.zoom,e));}get maxZoom(){return this._maxZoom}set maxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.zoom=Math.min(this.zoom,e));}get minPitch(){return this._minPitch}set minPitch(e){this._minPitch!==e&&(this._minPitch=e,this.pitch=Math.max(this.pitch,e));}get maxPitch(){return this._maxPitch}set maxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.pitch=Math.min(this.pitch,e));}get renderWorldCopies(){return this._renderWorldCopies&&!0===this.projection.supportsWorldCopies}set renderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e;}get worldSize(){return this.tileSize*this.scale}get cameraWorldSizeForFog(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get cameraWorldSize(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation,!0),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return e.bl(1,this.center.lat)*this.cameraWorldSizeForFog}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new e.P(this.width,this.height)}get bearing(){return e.bh(this.rotation,-180,180)}set bearing(e){this.rotation=e;}get rotation(){return -this.angle/Math.PI*180}set rotation(t){const i=-t*Math.PI/180;this.angle!==i&&(this._unmodified=!1,this.angle=i,this._calcMatrices(),this.rotationMatrix=e.b4.create(),e.b4.rotate(this.rotationMatrix,this.rotationMatrix,this.angle));}get pitch(){return this._pitch/Math.PI*180}set pitch(t){const i=e.aa(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==i&&(this._unmodified=!1,this._pitch=i,this._calcMatrices());}get aspect(){return this.width/this.height}get fov(){return this._fov/Math.PI*180}get fovX(){return this._fov}get fovY(){const e=1/Math.tan(.5*this.fovX);return 2*Math.atan(1/this.aspect/e)}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=e.bj(t),this._calcMatrices());}get averageElevation(){return this._averageElevation}set averageElevation(e){this._averageElevation=e,this._calcFogMatrices(),this._distanceTileDataCache={};}get zoom(){return this._zoom}set zoom(e){const t=Math.min(Math.max(e,this.minZoom),this.maxZoom);this._zoom!==t&&(this._unmodified=!1,this._setZoom(t),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices());}_setZoom(e){this._zoom=e,this.scale=this.zoomScale(e),this.tileZoom=Math.floor(e),this.zoomFraction=e-this.tileZoom;}get tileCoverLift(){return this._tileCoverLift}set tileCoverLift(e){this._tileCoverLift!==e&&(this._tileCoverLift=e);}_updateCameraOnTerrain(){const e=this.elevation?this.elevation.getAtPoint(this.locationCoordinate(this.center),Number.NEGATIVE_INFINITY):Number.NEGATIVE_INFINITY,t=this.elevation&&e===Number.NEGATIVE_INFINITY&&this.elevation.visibleDemTiles.length>0&&this.elevation.exaggeration()>0&&this._centerAltitudeValidForExaggeration;if(!this._elevation||e===Number.NEGATIVE_INFINITY&&(!t||!this._centerAltitude))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const i=this._elevation;t||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&i.exaggeration()&&this._centerAltitudeValidForExaggeration!==i.exaggeration()?(this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*i.exaggeration(),this._centerAltitudeValidForExaggeration=i.exaggeration()):(this._centerAltitude=e||0,this._centerAltitudeValidForExaggeration=i.exaggeration()),this._updateSeaLevelZoom();}_updateSeaLevelZoom(){void 0!==this._centerAltitudeValidForExaggeration&&(this._seaLevelZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize));}sampleAverageElevation(){if(!this._elevation)return 0;const t=this._elevation,i=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],o=this.horizonLineFromTop();let r=0,s=0;for(let n=0;n0,h=t.y+10,d=o.wrap-(c?0:1),_=o.wrap+(l?0:1),p=c?t.x-1:a-1,f=l?t.x+1:0;i[0]<0?(r.push(new e.am(s,_,t.z,f,t.y)),i[1]<0&&h&&(r.push(new e.am(s,n,t.z,t.x,t.y+1)),r.push(new e.am(s,_,t.z,f,t.y+1))),i[1]>0&&u&&(r.push(new e.am(s,n,t.z,t.x,t.y-1)),r.push(new e.am(s,_,t.z,f,t.y-1)))):i[0]>0?(r.push(new e.am(s,d,t.z,p,t.y)),i[1]<0&&h&&(r.push(new e.am(s,n,t.z,t.x,t.y+1)),r.push(new e.am(s,d,t.z,p,t.y+1))),i[1]>0&&u&&(r.push(new e.am(s,n,t.z,t.x,t.y-1)),r.push(new e.am(s,d,t.z,p,t.y-1)))):i[1]<0&&h?r.push(new e.am(s,n,t.z,t.x,t.y+1)):u&&r.push(new e.am(s,n,t.z,t.x,t.y-1));}if(r.length>1){r.sort(((e,t)=>e.overscaledZ-t.overscaledZ||e.wrap-t.wrap||e.canonical.z-t.canonical.z||e.canonical.x-t.canonical.x||e.canonical.y-t.canonical.y));let e=0,t=0;for(;te.isChildOf(t)))||s.push(e);return r=s.filter((e=>!t.some((t=>!!(e.overscaledZt.maxzoom&&(i=t.maxzoom);const a=this.locationCoordinate(this.center),l=this.center.lat,c=1<{const i=1/4e4,o=new e.L(t.x+i,t.y,t.z),r=new e.L(t.x,t.y+i,t.z),s=t.toLngLat(),n=o.toLngLat(),a=r.toLngLat(),l=this.locationCoordinate(s),c=this.locationCoordinate(n),h=this.locationCoordinate(a),u=Math.hypot(c.x-l.x,c.y-l.y),d=Math.hypot(h.x-l.x,h.y-l.y);return Math.sqrt(u*d)*T/i},S=t=>{const i=b,o=w;return {aabb:e.bu(this,c,0,0,0,t,o,i,this.projection),zoom:0,x:0,y:0,minZ:o,maxZ:i,wrap:t,fullyVisible:!1}},C=[];let I=[];const D=i,L=t.reparseOverscaled?o:i,A=e=>e*e,R=A((m-this._centerAltitude)*f),P=e=>{if(!this._elevation||!e.tileID||!n)return;const t=this._elevation.getMinMaxForTile(e.tileID),i=e.aabb;t?(i.min[2]=t.min,i.max[2]=t.max,i.center[2]=(i.min[2]+i.max[2])/2):(e.shouldSplit=M(e),e.shouldSplit||(i.min[2]=i.max[2]=i.center[2]=this._centerAltitude));},M=t=>{if(t.zoom=.9)return !0}else if(s&&(n=A(t.aabb.distanceZ(g)*f)),this.projection.isReprojectedInTileSpace&&o<=5){const i=Math.pow(2,t.zoom),o=E(new e.L((t.x+.5)/i,(t.y+.5)/i));a=o>.85?1:o;}const c=i*i+r*r+n,h=A((1<{if(t*A(.707)0;){const o=C.pop(),r=o.x,a=o.y;let l=o.fullyVisible;const d=()=>"globe"===this.projection.name&&(0===o.y||o.y===(1<>1),d={aabb:n?o.aabb.quadrant(t):e.bu(this,c,o.zoom+1,i,h,o.wrap,o.minZ,o.maxZ,this.projection),zoom:o.zoom+1,x:i,y:h,wrap:o.wrap,fullyVisible:l,tileID:void 0,shouldSplit:void 0,minZ:o.minZ,maxZ:o.maxZ};s&&!u&&(d.tileID=new e.am(o.zoom+1===D?L:o.zoom+1,o.wrap,o.zoom+1,i,h),P(d)),C.push(d);}else {const s=o.zoom===D?L:o.zoom;if(t.minzoom&&t.minzoom>s)continue;if(!l){let t=v?o.aabb.intersectsPrecise(_):o.aabb.intersectsPreciseFlat(_);if(0===t&&d()){const i=new e.bs(o.zoom,r,a);t=e.bt(this,c,i,!0).intersectsPrecise(_);}if(0===t)continue}const n=h[0]-(.5+r+(o.wrap<{const s=[0,0,0,1],n=[e.V,e.V,0,1],a=this.calculateFogTileMatrix(r.tileID.toUnwrapped());e.a7.transformMat4(s,s,a),e.a7.transformMat4(n,n,a);const l=e.a7.min([],s,n),c=e.a7.max([],s,n),h=e.bv(l,c);if(0===h)return !0;let u=!1;const d=this._elevation;if(d&&h>i&&0!==o){const i=this.calculateProjMatrix(r.tileID.toUnwrapped());let s;t.isTerrainDEM||(s=d.getMinMaxForTile(r.tileID)),s||(s={min:w,max:b});const n=e.bH(this.rotation),a=[n[0]*e.V,n[1]*e.V,s.max];e.N.transformMat4(a,a,i),u=(1-a[1])*this.height*.5e.distanceSq-t.distanceSq)).map((e=>e.tileID))}resize(e,t){this.width=e,this.height=t,this.pixelsToGLUnits=[2/e,-2/t],this._constrain(),this._calcMatrices();}get unmodified(){return this._unmodified}zoomScale(e){return Math.pow(2,e)}scaleZoom(e){return Math.log(e)/Math.LN2}project(t){const i=e.aa(t.lat,-e.bw,e.bw),o=this.projection.project(t.lng,i);return new e.P(o.x*this.worldSize,o.y*this.worldSize)}unproject(e){return this.projection.unproject(e.x/this.worldSize,e.y/this.worldSize)}get point(){return this.project(this.center)}get pointMerc(){return this.point._div(this.worldSize)}get pixelsPerMeterRatio(){return this.pixelsPerMeter/e.bl(1,this.center.lat)/this.worldSize}setLocationAtPoint(t,i){let o,r;const s=this.centerPoint;if("globe"===this.projection.name){const e=this.worldSize;o=(i.x-s.x)/e,r=(i.y-s.y)/e;}else {const e=this.pointCoordinate(i),t=this.pointCoordinate(s);o=e.x-t.x,r=e.y-t.y;}const n=this.locationCoordinate(t);this.setLocation(new e.L(n.x-o,n.y-r));}setLocation(e){this.center=this.coordinateLocation(e),this.projection.wrap&&(this.center=this.center.wrap());}locationPoint(e){return this.projection.locationPoint(this,e)}locationPoint3D(e){return this.projection.locationPoint(this,e,!0)}pointLocation(e){return this.coordinateLocation(this.pointCoordinate(e))}pointLocation3D(e){return this.coordinateLocation(this.pointCoordinate3D(e))}locationCoordinate(t,i){const o=i?e.bl(i,t.lat):void 0,r=this.projection.project(t.lng,t.lat);return new e.L(r.x,r.y,o)}coordinateLocation(e){return this.projection.unproject(e.x,e.y)}pointRayIntersection(t,i){const o=null!=i?i:this._centerAltitude,r=[t.x,t.y,0,1],s=[t.x,t.y,1,1];e.a7.transformMat4(r,r,this.pixelMatrixInverse),e.a7.transformMat4(s,s,this.pixelMatrixInverse);const n=s[3];e.a7.scale(r,r,1/r[3]),e.a7.scale(s,s,1/n);const a=r[2],l=s[2];return {p0:r,p1:s,t:a===l?0:(o-a)/(l-a)}}screenPointToMercatorRay(t){const i=[t.x,t.y,0,1],o=[t.x,t.y,1,1];return e.a7.transformMat4(i,i,this.pixelMatrixInverse),e.a7.transformMat4(o,o,this.pixelMatrixInverse),e.a7.scale(i,i,1/i[3]),e.a7.scale(o,o,1/o[3]),i[2]=e.bl(i[2],this._center.lat)*this.worldSize,o[2]=e.bl(o[2],this._center.lat)*this.worldSize,e.a7.scale(i,i,1/this.worldSize),e.a7.scale(o,o,1/this.worldSize),new e.a2([i[0],i[1],i[2]],e.N.normalize([],e.N.sub([],o,i)))}rayIntersectionCoordinate(t){const{p0:i,p1:o,t:r}=t,s=e.bl(i[2],this._center.lat),n=e.bl(o[2],this._center.lat);return new e.L(e.U(i[0],o[0],r)/this.worldSize,e.U(i[1],o[1],r)/this.worldSize,e.U(s,n,r))}pointCoordinate(e,t=this._centerAltitude){return this.projection.pointCoordinate(this,e.x,e.y,t)}pointCoordinate3D(t){if(!this.elevation)return this.pointCoordinate(t);let i=this.projection.pointCoordinate3D(this,t.x,t.y);if(i)return new e.L(i[0],i[1],i[2]);let o=0,r=this.horizonLineFromTop();if(t.y>r)return this.pointCoordinate(t);const s=.02*r,n=t.clone();for(let t=0;t<10&&r-o>s;t++){n.y=e.U(o,r,.66);const t=this.projection.pointCoordinate3D(this,n.x,n.y);t?(r=n.y,i=t):o=n.y;}return i?new e.L(i[0],i[1],i[2]):this.pointCoordinate(t)}isPointAboveHorizon(e){return this.projection.isPointAboveHorizon(this,e)}isPointOnSurface(t){if(t.y<0||t.y>this.height||t.x<0||t.x>this.width)return !1;if(this.elevation||this.zoom>=e.bx)return !this.isPointAboveHorizon(t);const i=this.pointCoordinate(t);return i.y>=0&&i.y<=1}_coordinatePoint(t,i){const o=i&&this.elevation?this.elevation.getAtPointOrZero(t,this._centerAltitude):this._centerAltitude,r=[t.x*this.worldSize,t.y*this.worldSize,o+t.toAltitude(),1];return e.a7.transformMat4(r,r,this.pixelMatrix),r[3]>0?new e.P(r[0]/r[3],r[1]/r[3]):new e.P(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:t,left:i}=this._edgeInsets,o=this.height-this._edgeInsets.bottom,r=this.width-this._edgeInsets.right,s=this.pointLocation3D(new e.P(i,t)),n=this.pointLocation3D(new e.P(r,t)),a=this.pointLocation3D(new e.P(r,o)),l=this.pointLocation3D(new e.P(i,o));let c=Math.min(s.lng,n.lng,a.lng,l.lng),h=Math.max(s.lng,n.lng,a.lng,l.lng),u=Math.min(s.lat,n.lat,a.lat,l.lat),d=Math.max(s.lat,n.lat,a.lat,l.lat);const _=Math.pow(2,-this.zoom)/16*270,p="globe"===this.projection.name?1:4,f=(t,i,o,r,s)=>{const n=(t+o)/2,a=(i+r)/2,l=new e.P(n,a),{lng:m,lat:g}=this.pointLocation3D(l),v=Math.max(0,c-m,u-g,m-h,g-d);c=Math.min(c,m),h=Math.max(h,m),u=Math.min(u,g),d=Math.max(d,g),(s_)&&(f(t,i,n,a,s+1),f(n,a,o,r,s+1));};if(f(i,t,r,t,1),f(r,t,r,o,1),f(r,o,i,o,1),f(i,o,i,t,1),"globe"===this.projection.name){const[t,i]=e.by(this);t?(d=90,h=180,c=-180):i&&(u=-90,h=180,c=-180);}return new e.ad(new e.bn(c,u),new e.bn(h,d))}_getBoundsRectangular(t,i){const{top:o,left:r}=this._edgeInsets,s=this.height-this._edgeInsets.bottom,n=this.width-this._edgeInsets.right,a=new e.P(r,o),l=new e.P(n,o),c=new e.P(n,s),h=new e.P(r,s);let u=this.pointCoordinate(a,t),d=this.pointCoordinate(l,t);const _=this.pointCoordinate(c,i),p=this.pointCoordinate(h,i),f=(e,t)=>(t.y-e.y)/(t.x-e.x);return u.y>1&&d.y>=0?u=new e.L((1-p.y)/f(p,u)+p.x,1):u.y<0&&d.y<=1&&(u=new e.L(-p.y/f(p,u)+p.x,0)),d.y>1&&u.y>=0?d=new e.L((1-_.y)/f(_,d)+_.x,1):d.y<0&&u.y<=1&&(d=new e.L(-_.y/f(_,d)+_.x,0)),(new e.ad).extend(this.coordinateLocation(u)).extend(this.coordinateLocation(d)).extend(this.coordinateLocation(p)).extend(this.coordinateLocation(_))}_getBoundsRectangularTerrain(){const e=this.elevation;if(!e.visibleDemTiles.length||e.isUsingMockSource())return this._getBoundsRectangular(0,0);const t=e.visibleDemTiles.reduce(((e,t)=>{if(t.dem){const i=t.dem.tree;e.min=Math.min(e.min,i.minimums[0]),e.max=Math.max(e.max,i.maximums[0]);}return e}),{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(t.min*e.exaggeration(),t.max*e.exaggeration())}getBounds(){return "mercator"===this.projection.name||"equirectangular"===this.projection.name?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(e=!0){const t=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))-this.centerOffset.y,i=this.height/2-t*(1-this._horizonShift);return e?Math.max(0,i):i}getMaxBounds(){return this.maxBounds}setMaxBounds(t){this.maxBounds=t,this.minLat=-e.bw,this.maxLat=e.bw,this.minLng=-180,this.maxLng=180,t&&(this.minLat=t.getSouth(),this.maxLat=t.getNorth(),this.minLng=t.getWest(),this.maxLng=t.getEast(),this.maxLngu&&(a=u-c),u-ht&&(n=t-l),t-e{for(let r=0;r<16;r++)e[r]=po(t[r],i[r],o);})(a,a,l,fo(this.pitch>=15?1:this.pitch/15));}else a=l;const c=e.a6.mul([],l,n);let h=e.a6.mul([],a,n);if(this.projection.isReprojectedInTileSpace){const t=this.locationCoordinate(this.center),i=e.a6.identity([]);e.a6.translate(i,i,[t.x*this.worldSize,t.y*this.worldSize,0]),e.a6.multiply(i,i,e.bB(this)),e.a6.translate(i,i,[-t.x*this.worldSize,-t.y*this.worldSize,0]),e.a6.multiply(h,h,i),e.a6.multiply(c,c,i),this.inverseAdjustmentMatrix=e.bC(this);}else this.inverseAdjustmentMatrix=[1,0,0,1];if(this.mercatorMatrix=e.a6.scale([],h,[this.worldSize,this.worldSize,this.worldSize/s,1]),this.projMatrix=h,this.invProjMatrix=e.a6.invert(new Float64Array(16),this.projMatrix),i){const i=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);i[8]=2*-t.x/this.width,i[9]=2*t.y/this.height,this.expandedFarZProjMatrix=e.a6.mul([],i,n);}else this.expandedFarZProjMatrix=this.projMatrix;const u=e.a6.invert([],a);this.frustumCorners=e.bD.fromInvProjectionMatrix(u,this.horizonLineFromTop(),this.height),this.cameraFrustum=e.bq.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!i);const d=new Float32Array(16);e.a6.identity(d),e.a6.scale(d,d,[1,-1,1]),e.a6.rotateX(d,d,this._pitch),e.a6.rotateZ(d,d,this.angle);const _=e.a6.perspective(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ);this.starsProjMatrix=e.a6.clone(_);const p=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;_[8]=2*-t.x/this.width,_[9]=2*(t.y+p)/this.height,this.skyboxMatrix=e.a6.multiply(d,_,d);const f=this.point,m=f.x,g=f.y,v=this.width%2/2,x=this.height%2/2,y=Math.cos(this.angle),b=Math.sin(this.angle),w=m-Math.round(m)+y*v+b*x,T=g-Math.round(g)+y*x+b*v,E=new Float64Array(h);if(e.a6.translate(E,E,[w>.5?w-1:w,T>.5?T-1:T,0]),this.alignedProjMatrix=E,h=e.a6.create(),e.a6.scale(h,h,[this.width/2,-this.height/2,1]),e.a6.translate(h,h,[1,-1,0]),this.labelPlaneMatrix=h,h=e.a6.create(),e.a6.scale(h,h,[1,-1,1]),e.a6.translate(h,h,[-1,-1,0]),e.a6.scale(h,h,[2/this.width,2/this.height,1]),this.glCoordMatrix=h,this.pixelMatrix=e.a6.multiply(new Float64Array(16),this.labelPlaneMatrix,c),this._calcFogMatrices(),this._distanceTileDataCache={},h=e.a6.invert(new Float64Array(16),this.pixelMatrix),!h)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=h,"globe"===this.projection.name||this.mercatorFromTransition){this.globeMatrix=e.bE(this);const t=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=e.N.transformMat4(t,t,n),this.globeRadius=this.worldSize/2/Math.PI-1;}else this.globeMatrix=h;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={};}_calcFogMatrices(){this._fogTileMatrixCache={};const t=this.cameraWorldSizeForFog,i=this.cameraPixelsPerMeter,o=this._camera.position,r=1/this.height/this._pixelsPerMercatorPixel,s=[t,t,i];e.N.scale(s,s,r),e.N.scale(o,o,-1),e.N.multiply(o,o,s);const n=e.a6.create();e.a6.translate(n,n,o),e.a6.scale(n,n,s),this.mercatorFogMatrix=n,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(t,i,r);}_computeCameraPosition(e){const t=(e=e||this.pixelsPerMeter)/this.pixelsPerMeter,i=this._camera.forward(),o=this.point,r=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*t-e/this.worldSize*this._centerAltitude;return [o.x/this.worldSize-i[0]*r,o.y/this.worldSize-i[1]*r,e/this.worldSize*this._centerAltitude-i[2]*r]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition());}_translateCameraConstrained(t){const i=this._maxCameraBoundsDistance()*Math.cos(this._pitch),o=this._camera.position[2],r=t[2];let s=1;this.projection.wrap&&(this.center=this.center.wrap()),r>0&&(s=Math.min((i-o)/r,1)),this._camera.position=e.N.scaleAndAdd([],this._camera.position,t,s),this._updateStateFromCamera();}_updateStateFromCamera(){const t=this._camera.position,i=this._camera.forward(),{pitch:o,bearing:r}=this._camera.getPitchBearing(),s=e.bl(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,n=this._mercatorZfromZoom(this._maxZoom)*Math.cos(e.bj(this._maxPitch)),a=Math.max((t[2]-s)/Math.cos(o),n),l=this._zoomFromMercatorZ(a);e.N.scaleAndAdd(t,t,i,a),this._pitch=e.aa(o,e.bj(this.minPitch),e.bj(this.maxPitch)),this.angle=e.bh(r,-Math.PI,Math.PI),this._setZoom(e.aa(l,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new e.L(t[0],t[1],t[2])),this._unmodified=!1,this._constrain(),this._calcMatrices();}_worldSizeFromZoom(e){return Math.pow(2,e)*this.tileSize}_mercatorZfromZoom(e){return this.cameraToCenterDistance/this._worldSizeFromZoom(e)}_minimumHeightOverTerrain(){const e=Math.min(null!=this._seaLevelZoom?this._seaLevelZoom:this._zoom,this._maxZoom)+4;return this._mercatorZfromZoom(e)}_zoomFromMercatorZ(e){return this.scaleZoom(this.cameraToCenterDistance/(e*this.tileSize))}zoomFromMercatorZAdjusted(t){let i=0,o=e.bx,r=0,s=1/0;for(;o-i>1e-6&&o>i;){const e=i+.5*(o-i),n=this.tileSize*Math.pow(2,e),a=this.getCameraToCenterDistance(this.projection,e,n),l=this.scaleZoom(a/(t*this.tileSize)),c=Math.abs(e-l);cc||i.y>1)return !0}return !1}isHorizonVisible(){return this.pitch+e.bF(this.fovAboveCenter)>88||this.anyCornerOffEdge(new e.P(0,0),new e.P(this.width,this.height))}zoomDeltaToMovement(t,i){const o=e.N.length(e.N.sub([],this._camera.position,t)),r=this._zoomFromMercatorZ(o)+i;return o-this._mercatorZfromZoom(r)}getCameraPoint(){if("globe"===this.projection.name){const t=function([t,i,o],r){const s=[t,i,o,1];e.a7.transformMat4(s,s,r);const n=s[3]=Math.max(s[3],1e-6);return s[0]/=n,s[1]/=n,s[2]/=n,s}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new e.P(t[0],t[1])}{const t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new e.P(0,t))}}getCameraToCenterDistance(t,i=this.zoom,o=this.worldSize){const r=e.bA(t,i,this.width,this.height,1024),s=t.pixelSpaceConversion(this.center.lat,o,r);let n=.5/Math.tan(.5*this._fov)*this.height*s;return this.isOrthographic&&(n=po(1,n,fo(this.pitch>=15?1:this.pitch/15))),n}getWorldToCameraMatrix(){const t=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?this.pixelsPerMeter:1);return "globe"===this.projection.name&&e.a6.multiply(t,t,this.globeMatrix),t}getFrustum(t){return e.bq.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,t,"meters"===this.projection.zAxisUnit)}}const go={BaseColor:5,MetallicRoughness:6,Normal:7,Occlusion:8,Emission:9,ShadowMap0:10},vo=(t,i)=>{if(i>0&&t.terrain&&e.w("Cutoff is currently disabled on terrain"),i<=0||t.terrain)return {shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};const o=t.transform,r=Math.max(Math.abs(o._zoom-(t.minCutoffZoom-1)),1),s=o.isLODDisabled(!1)?e.O(60,45,o.pitch):e.O(30,15,o.pitch),n=o._farZ-o._nearZ,a=i*o.height,l=((1-(c=s))*o.cameraToCenterDistance+c*(o._farZ+a))*r;var c;return {shouldRenderCutoff:s<1,uniformValues:{u_cutoff_params:[o._nearZ,o._farZ,(l-o._nearZ)/n,(l-a-o._nearZ)/n]}}},xo={cascadeCount:2,shadowMapResolution:2048};class yo{constructor(e,t){this.aabb=e,this.lastCascade=t;}}class bo{add(e,t){const i=this.receivers[e.key];void 0!==i?(i.aabb.min[0]=Math.min(i.aabb.min[0],t.min[0]),i.aabb.min[1]=Math.min(i.aabb.min[1],t.min[1]),i.aabb.min[2]=Math.min(i.aabb.min[2],t.min[2]),i.aabb.max[0]=Math.max(i.aabb.max[0],t.max[0]),i.aabb.max[1]=Math.max(i.aabb.max[1],t.max[1]),i.aabb.max[2]=Math.max(i.aabb.max[2],t.max[2])):this.receivers[e.key]=new yo(t,null);}clear(){this.receivers={};}get(e){return this.receivers[e.key]}computeRequiredCascades(t,i,o){const r=e.bS.fromPoints(t.points);let s=0;for(const t in this.receivers){const n=this.receivers[t];if(!n)continue;if(!r.intersectsAabb(n.aabb))continue;n.aabb.min=r.closestPoint(n.aabb.min),n.aabb.max=r.closestPoint(n.aabb.max);const a=n.aabb.getCorners();for(let t=0;t1||n[1]<-1||n[1]>1){r=!1;break}}if(n.lastCascade=t,s=Math.max(s,t),r)break}}return s+1}}class wo{constructor(e){this.painter=e,this._enabled=!1,this._shadowLayerCount=0,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new bo,this._depthMode=new Lt(e.context.gl.LEQUAL,Lt.ReadWrite,[0,1]),this._uniformValues={u_light_matrix_0:new Float32Array(16),u_light_matrix_1:new Float32Array(16),u_shadow_intensity:0,u_fade_range:[0,0],u_shadow_normal_offset:[1,1,1],u_shadow_texel_size:1,u_shadow_map_resolution:1,u_shadow_direction:[0,0,1],u_shadow_bias:[36e-5,.0012,.012],u_shadowmap_0:0,u_shadowmap_1:0},this.useNormalOffset=!1,e.tp.registerParameter(xo,["Shadows"],"cascadeCount",{min:1,max:2,step:1}),e.tp.registerParameter(xo,["Shadows"],"shadowMapResolution",{min:32,max:2048,step:32});}destroy(){for(const e of this._cascades)e.texture.destroy(),e.framebuffer.destroy();this._cascades=[];}updateShadowParameters(t,i){const o=this.painter;if(this._enabled=!1,this._shadowLayerCount=0,this._receivers.clear(),!i||!i.properties)return;const r=i.properties.get("shadow-intensity");if(!i.shadowsEnabled()||r<=0)return;if(this._shadowLayerCount=o.style.order.reduce(((e,i)=>{const r=o.style._mergedLayers[i];return e+(r.hasShadowPass()&&!r.isHidden(t.zoom)?1:0)}),0),this._enabled=this._shadowLayerCount>0,!this._enabled)return;const s=o.context,n=xo.shadowMapResolution,a=xo.shadowMapResolution;if(0===this._cascades.length||xo.shadowMapResolution!==this._cascades[0].texture.size[0]){this._cascades=[];for(let t=0;te.dem)).forEach((e=>{const t=e.dem.tree;i[0]=Math.min(i[0],t.minimums[0]),i[1]=Math.max(i[1],t.maximums[0]);})),1e4!==i[0]&&(l=(i[1]-i[0])*e.exaggeration());}const c=1.5*t.cameraToCenterDistance,h=3*c,u=new Float64Array(16);for(let i=0;i=0)return {};const s=function(t,i,o){const r=o/(1<0&&(e.N.add(s[1],s[1],[r[0]*n,0,0]),e.N.add(s[2],s[2],[r[0]*n,0,0])),r[1]<0?(e.N.add(s[0],s[0],[0,r[1]*n,0]),e.N.add(s[1],s[1],[0,r[1]*n,0])):r[1]>0&&(e.N.add(s[2],s[2],[0,r[1]*n,0]),e.N.add(s[3],s[3],[0,r[1]*n,0]));const a={};return a.vertices=s,a.planes=[To(s[1],s[0],s[4]),To(s[2],s[1],s[5]),To(s[3],s[2],s[6]),To(s[0],s[3],s[7])],a}addShadowReceiver(t,i,o){this._receivers.add(t,e.bS.fromTileIdAndHeight(t,i,o));}getMaxCascadeForTile(e){const t=this._receivers.get(e);return t&&t.lastCascade?t.lastCascade:0}}function To(t,i,o){const r=e.N.sub([],o,i),s=e.N.sub([],t,i),n=e.N.cross([],r,s),a=e.N.length(n);return 0===a?[0,0,1,0]:(e.N.scale(n,n,1/a),[n[0],n[1],n[2],-e.N.dot(n,i)])}function Eo(t){const i=t.properties.get("direction"),o=e.bQ(i.x,i.y,i.z);o[2]=e.aa(o[2],0,75);const r=e.bT([o[0],o[1],o[2]]);return e.N.fromValues(r.x,r.y,r.z)}function So(t,i){const o=t.properties.get("color"),r=t.properties.get("intensity"),s=t.properties.get("direction"),n=[s.x,s.y,s.z],a=i.properties.get("color"),l=i.properties.get("intensity"),c=Math.max(e.N.dot([0,0,1],n),0),h=[0,0,0];e.N.scale(h,a.toArray01Linear().slice(0,3),l);const u=[0,0,0];return e.N.scale(u,o.toArray01Linear().slice(0,3),c*r),e.bU([h[0]>0?h[0]/(h[0]+u[0]):0,h[1]>0?h[1]/(h[1]+u[1]):0,h[2]>0?h[2]/(h[2]+u[2]):0])}function Co(t,i,o,r,s,n){const a=t.zoom,l=t.scale,c=t.worldSize,h=1/c,u=t.aspect,d=Math.sqrt(1+u*u)*Math.tan(.5*t.fovX),_=d*d,p=r-o,f=r+o;let m,g;_>p/f?(m=r,g=r*d):(m=.5*f*(1+_),g=.5*Math.sqrt(p*p+2*(r*r+o*o)*_+f*f*_*_));const v=t.projection.pixelsPerMeter(t.center.lat,c),x=t._camera.getCameraToWorldMercator(),y=[0,0,-m*h];e.N.transformMat4(y,y,x);let b=g*h;const w=t._edgeInsets;if(!(0===w.left&&0===w.top&&0===w.right&&0===w.bottom||w.left===w.right&&w.top===w.bottom)){const i=t._camera.getWorldToCamera(t.worldSize,"meters"===t.projection.zAxisUnit?v:1),s=t._camera.getCameraToClipPerspective(t._fov,t.width/t.height,o,r);s[8]=2*-t.centerOffset.x/t.width,s[9]=2*t.centerOffset.y/t.height;const n=new Float64Array(16);e.a6.mul(n,s,i);const h=new Float64Array(16);e.a6.invert(h,n);const u=e.bq.fromInvProjectionMatrix(h,c,a,!0);for(const i of u.points){const o=((T=i)[0]/=l,T[1]/=l,T[2]=e.bl(T[2],t._center.lat),T);b=Math.max(b,e.N.len(e.N.subtract([],y,o)));}}var T;b*=s/(s-1);const E=Math.acos(i[2]),S=Math.atan2(-i[0],-i[1]),C=new _o;C.position=y,C.setPitchBearing(E,S);const I=C.getWorldToCamera(c,v),D=b*c,L=Math.min(t._mercatorZfromZoom(17)*c*-2,-2*D),A=C.getCameraToClipOrthographic(-D,D,-D,D,L,(D+n*v)/i[2]),R=new Float64Array(16);e.a6.multiply(R,A,I);const P=e.N.fromValues(Math.floor(1e6*y[0])/1e6*c,Math.floor(1e6*y[1])/1e6*c,0),M=.5*s,z=[0,0,0];e.N.transformMat4(z,P,R),e.N.scale(z,z,M);const O=[Math.floor(z[0]),Math.floor(z[1]),Math.floor(z[2])],F=[0,0,0];e.N.sub(F,z,O),e.N.scale(F,F,-1/M);const B=new Float64Array(16);return e.a6.identity(B),e.a6.translate(B,B,F),e.a6.multiply(R,B,R),[R,D]}const Io=(e,t)=>ce(e,t&&t.filter((e=>"source.canvas"!==e.identifier))),Do=e.ac(oi,["addLayer","removeLayer","setLights","setPaintProperty","setLayoutProperty","setSlot","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection","setCamera","addImport","removeImport","updateImport"]),Lo=e.ac(oi,["setCenter","setZoom","setBearing","setPitch"]),Ao={version:8,layers:[],sources:{}},Ro={duration:300,delay:0},Po=new Set(["fill","line","background","hillshade","raster"]);class Mo extends e.E{constructor(t,i={}){super(),this.map=t,this.scope=i.scope||"",this.fragments=[],this.importDepth=i.importDepth||0,this.importsCache=i.importsCache||new Map,this.resolvedImports=i.resolvedImports||new Set,this.transition=e.e({},Ro),this._buildingIndex=new ei(this),this.crossTileSymbolIndex=new no,this._mergedOrder=[],this._drapedFirstOrder=[],this._mergedLayers={},this._mergedSourceCaches={},this._mergedOtherSourceCaches={},this._mergedSymbolSourceCaches={},this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this._changes=i.styleChanges||new v,this.dispatcher=i.dispatcher?i.dispatcher:new e.bW(e.bX(),this),i.imageManager?this.imageManager=i.imageManager:(this.imageManager=new w,this.imageManager.setEventedParent(this)),this.imageManager.createScope(this.scope),this.glyphManager=i.glyphManager?i.glyphManager:new e.bY(t._requestManager,i.localFontFamily?e.bZ.all:i.localIdeographFontFamily?e.bZ.ideographs:e.bZ.none,i.localFontFamily||i.localIdeographFontFamily),i.modelManager?this.modelManager=i.modelManager:(this.modelManager=new x(t._requestManager),this.modelManager.setEventedParent(this)),this._layers={},this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._loaded=!1,this._precompileDone=!1,this._shouldPrecompile=!1,this._availableImages=[],this._order=[],this._markersNeedUpdate=!1,this.options=i.configOptions?i.configOptions:new Map,this._configDependentLayers=i.configDependentLayers?i.configDependentLayers:new Set,this._config=i.config,this.dispatcher.broadcast("setReferrer",e.b_());const o=this;this._rtlTextPluginCallback=Mo.registerForPluginStateChange((t=>{o.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:t.pluginStatus,pluginURL:t.pluginURL},((t,i)=>{if(e.b$(t),i&&i.every((e=>e)))for(const e in o._sourceCaches){const t=o._sourceCaches[e],i=t.getSource().type;"vector"!==i&&"geojson"!==i||t.reload();}}));})),this.on("data",(e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const t=this.getOwnSource(e.sourceId);if(t&&t.vectorLayerIds)for(const e in this._layers){const i=this._layers[e];i.source===t.id&&this._validateLayer(i);}}));}loadURL(t,i={}){this.fire(new e.b("dataloading",{dataType:"style"}));const o="boolean"==typeof i.validate?i.validate:!e.c0(t);t=this.map._requestManager.normalizeStyleURL(t,i.accessToken),this.resolvedImports.add(t);const r=this.importsCache.get(t);if(r)return this._load(r,o);const s=this.map._requestManager.transformRequest(t,e.R.Style);this._request=e.g(s,((i,r)=>{if(this._request=null,i)this.fire(new e.a(i));else if(r)return this.importsCache.set(t,r),this._load(r,o)}));}loadJSON(t,i={}){this.fire(new e.b("dataloading",{dataType:"style"})),this._request=e.f.frame((()=>{this._request=null,this._load(t,!1!==i.validate);}));}loadEmpty(){this.fire(new e.b("dataloading",{dataType:"style"})),this._load(Ao,!1);}_loadImports(t,i,o){if(this.importDepth>=4)return e.w("Style doesn't support nesting deeper than 5"),Promise.resolve();const r=[];for(const e of t){const t=this._createFragmentStyle(e),s=new Promise((e=>{t.once("style.import.load",e),t.once("error",e);})).then((()=>this.mergeAll()));if(r.push(s),this.resolvedImports.has(e.url)){t.loadEmpty();continue}const n=e.data||this.importsCache.get(e.url);n?t.loadJSON(n,{validate:i}):e.url?t.loadURL(e.url,{validate:i}):t.loadEmpty();const a={style:t,id:e.id,config:e.config};if(o){const e=this.fragments.findIndex((({id:e})=>e===o));this.fragments=this.fragments.slice(0,e).concat(a).concat(this.fragments.slice(e));}else this.fragments.push(a);}return Promise.allSettled(r)}_createFragmentStyle(t){const i=this.scope?e.ag(t.id,this.scope):t.id,o=new Mo(this.map,{scope:i,styleChanges:this._changes,importDepth:this.importDepth+1,importsCache:this.importsCache,resolvedImports:new Set(this.resolvedImports),dispatcher:this.dispatcher,imageManager:this.imageManager,glyphManager:this.glyphManager,modelManager:this.modelManager,config:t.config,configOptions:this.options,configDependentLayers:this._configDependentLayers});return o.setEventedParent(this.map,{style:o}),o}_reloadImports(){this.mergeAll(),this._updateMapProjection(),this.updateConfigDependencies(),this.map._triggerCameraUpdate(this.camera),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options});const t=this.isRootStyle();this._shouldPrecompile=t,this.fire(new e.b(t?"style.load":"style.import.load"));}_load(t,i){const o=t.schema;if(this.isRootStyle()&&(t.fragment||o&&!1!==t.fragment)){const o=e.e({},Ao,{imports:[{id:"basemap",data:t,url:""}]});return void this._load(o,i)}if(this.setConfig(this._config,o),i&&Io(this,Y(t)))return;this._loaded=!0,this.stylesheet=e.c1(t);for(const e in t.sources)this.addSource(e,t.sources[e],{validate:!1,isInitialLoad:!0});t.sprite?this._loadSprite(t.sprite):(this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0})),this.glyphManager.setURL(t.glyphs,this.scope);const r=ii(this.stylesheet.layers);if(this._order=r.map((e=>e.id)),this.stylesheet.light&&e.w("The `light` root property is deprecated, prefer using `lights` with `flat` light type instead."),this.stylesheet.lights)if(1===this.stylesheet.lights.length&&"flat"===this.stylesheet.lights[0].type){const e=this.stylesheet.lights[0];this.light=new ue(e.properties,e.id);}else this.setLights(this.stylesheet.lights);this.light||(this.light=new ue(this.stylesheet.light)),this._layers={},this._serializedLayers={};for(const t of r){const i=e.c2(t,this.scope,this.options);i.isConfigDependent&&this._configDependentLayers.add(i.fqid),i.setEventedParent(this,{layer:{id:i.id}}),this._layers[i.id]=i,this._serializedLayers[i.id]=i.serialize();const o=this.getOwnLayerSourceCache(i),r=!!this.directionalLight&&this.directionalLight.shadowsEnabled();o&&i.canCastShadows()&&r&&(o.castsShadows=!0);}this.stylesheet.models&&this.modelManager.addModels(this.stylesheet.models,this.scope);const s=this.stylesheet.terrain;s&&(void 0===this.disableElevatedTerrain&&(this.disableElevatedTerrain=e.f.hasCanvasFingerprintNoise()),this.disableElevatedTerrain?e.w("Terrain and hillshade are disabled because of Canvas2D limitations when fingerprinting protection is enabled (e.g. in private browsing mode)."):this.terrainSetForDrapingOnly()||this._createTerrain(s,1)),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this.stylesheet.transition&&this.setTransition(this.stylesheet.transition),this.fire(new e.b("data",{dataType:"style"})),t.imports?this._loadImports(t.imports,i).then((()=>this._reloadImports())):this._reloadImports();}isRootStyle(){return 0===this.importDepth}mergeAll(){let t,i,o,r,s,n,a,l;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle((e=>{if(e.stylesheet){if(null!=e.light&&(t=e.light),e.stylesheet.lights)for(const t of e.stylesheet.lights)"ambient"===t.type&&null!=e.ambientLight&&(i=e.ambientLight),"directional"===t.type&&null!=e.directionalLight&&(o=e.directionalLight);r=this._prioritizeTerrain(r,e.terrain,e.stylesheet.terrain),e.stylesheet.fog&&null!=e.fog&&(s=e.fog),null!=e.stylesheet.camera&&(l=e.stylesheet.camera),null!=e.stylesheet.projection&&(n=e.stylesheet.projection),null!=e.stylesheet.transition&&(a=e.stylesheet.transition);}})),this.light=t,this.ambientLight=i,this.directionalLight=o,this.fog=s,null===r?delete this.terrain:this.terrain=r,this.camera=l||{"camera-projection":"perspective"},this.projection=n||{name:"mercator"},this.transition=e.e({},Ro,a),this.mergeSources(),this.mergeLayers();}forEachFragmentStyle(e){const t=i=>{for(const e of i.fragments)t(e.style);e(i);};t(this);}_prioritizeTerrain(e,t,i){const o=e&&0===e.drapeRenderMode;return null===i?t&&0===t.drapeRenderMode?t:o?e:null:null!=t&&(!e||o||t&&1===t.drapeRenderMode)?t:e}mergeTerrain(){let e;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle((t=>{e=this._prioritizeTerrain(e,t.terrain,t.stylesheet.terrain);})),null===e?delete this.terrain:this.terrain=e;}mergeProjection(){let e;this.forEachFragmentStyle((t=>{null!=t.stylesheet.projection&&(e=t.stylesheet.projection);})),this.projection=e||{name:"mercator"};}mergeSources(){const t={},i={},o={};this.forEachFragmentStyle((r=>{for(const i in r._sourceCaches){const o=e.ag(i,r.scope);t[o]=r._sourceCaches[i];}for(const t in r._otherSourceCaches){const o=e.ag(t,r.scope);i[o]=r._otherSourceCaches[t];}for(const t in r._symbolSourceCaches){const i=e.ag(t,r.scope);o[i]=r._symbolSourceCaches[t];}})),this._mergedSourceCaches=t,this._mergedOtherSourceCaches=i,this._mergedSymbolSourceCaches=o;}mergeLayers(){const t={},i=[],o={};this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle((o=>{for(const r of o._order){const s=o._layers[r];if("slot"===s.type){const i=e.c3(r);if(t[i])continue;t[i]=[];}s.slot&&t[s.slot]?t[s.slot].push(s):i.push(s);}})),this._mergedOrder=[];const r=(i=[])=>{for(const s of i)if("slot"===s.type){const i=e.c3(s.id);t[i]&&r(t[i]);}else {const t=e.ag(s.id,s.scope);this._mergedOrder.push(t),o[t]=s,s.is3D()&&(this._has3DLayers=!0),"circle"===s.type&&(this._hasCircleLayers=!0),"symbol"===s.type&&(this._hasSymbolLayers=!0);}};r(i),this._mergedLayers=o,this.updateDrapeFirstLayers(),this._buildingIndex.processLayersChanged();}terrainSetForDrapingOnly(){return !!this.terrain&&0===this.terrain.drapeRenderMode}getCamera(){return this.stylesheet.camera}setCamera(t){return this.stylesheet.camera=e.e({},this.stylesheet.camera,t),this.camera=this.stylesheet.camera,this}setProjection(e){e?this.stylesheet.projection=e:delete this.stylesheet.projection,this.mergeProjection(),this._updateMapProjection();}applyProjectionUpdate(){this._loaded&&(this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),this.map.transform.projection.requiresDraping?(this.getTerrain()||this.stylesheet.terrain)&&!this.disableElevatedTerrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null,0));}_updateMapProjection(){this.isRootStyle()&&(this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.projection));}_loadSprite(t){this._spriteRequest=function(t,i,o){let r,s,n;const a=e.f.devicePixelRatio>1?"@2x":"";let l=e.g(i.transformRequest(i.normalizeSpriteURL(t,a,".json"),e.R.SpriteJSON),((e,t)=>{l=null,n||(n=e,r=t,h());})),c=e.d(i.transformRequest(i.normalizeSpriteURL(t,a,".png"),e.R.SpriteImage),((e,t)=>{c=null,n||(n=e,s=t,h());}));function h(){if(n)o(n);else if(r&&s){const t=e.f.getImageData(s),i={};for(const o in r){const{width:s,height:n,x:a,y:l,sdf:c,pixelRatio:h,stretchX:u,stretchY:d,content:_}=r[o],p=new e.h({width:s,height:n});e.h.copy(t,p,{x:a,y:l},{x:0,y:0},{width:s,height:n}),i[o]={data:p,pixelRatio:h,sdf:c,stretchX:u,stretchY:d,content:_};}o(null,i);}}return {cancel(){l&&(l.cancel(),l=null),c&&(c.cancel(),c=null);}}}(t,this.map._requestManager,((t,i)=>{if(this._spriteRequest=null,t)this.fire(new e.a(t));else if(i)for(const e in i)this.imageManager.addImage(e,this.scope,i[e]);this.imageManager.setLoaded(!0,this.scope),this._availableImages=this.imageManager.listImages(this.scope),this.dispatcher.broadcast("setImages",{scope:this.scope,images:this._availableImages}),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new e.b("data",{dataType:"style"}));}));}_validateLayer(t){const i=this.getOwnSource(t.source);if(!i)return;const o=t.sourceLayer;o&&("geojson"===i.type||i.vectorLayerIds&&-1===i.vectorLayerIds.indexOf(o))&&this.fire(new e.a(new Error(`Source layer "${o}" does not exist on source "${i.id}" as specified by style layer "${t.id}"`)));}loaded(){if(!this._loaded)return !1;if(Object.keys(this._changes.getUpdatedSourceCaches()).length)return !1;for(const e in this._sourceCaches)if(!this._sourceCaches[e].loaded())return !1;if(!this.imageManager.isLoaded())return !1;if(!this.modelManager.isLoaded())return !1;for(const{style:e}of this.fragments)if(!e.loaded())return !1;return !0}_serializeImports(){if(this.stylesheet.imports)return this.stylesheet.imports.map(((e,t)=>{const i=this.fragments[t];return i&&i.style&&(e.data=i.style.serialize()),e}))}_serializeSources(){const e={};for(const t in this._sourceCaches){const i=this._sourceCaches[t].getSource();e[i.id]||(e[i.id]=i.serialize());}return e}_serializeLayers(e){const t=[];for(const i of e){const e=this._layers[i];e&&"custom"!==e.type&&t.push(e.serialize());}return t}hasLightTransitions(){return !(!this.light||!this.light.hasTransition())||!(!this.ambientLight||!this.ambientLight.hasTransition())||!(!this.directionalLight||!this.directionalLight.hasTransition())}hasFogTransition(){return !!this.fog&&this.fog.hasTransition()}hasTransitions(){if(this.hasLightTransitions())return !0;if(this.hasFogTransition())return !0;for(const e in this._sourceCaches)if(this._sourceCaches[e].hasTransition())return !0;for(const e in this._layers)if(this._layers[e].hasTransition())return !0;return !1}get order(){return this.terrain?this._drapedFirstOrder:this._mergedOrder}isLayerDraped(e){return !!this.terrain&&("function"==typeof e.isLayerDraped?e.isLayerDraped(this.getLayerSourceCache(e)):Po.has(e.type))}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}_checkLayer(t){const i=this.getOwnLayer(t);if(i)return i;this.fire(new e.a(new Error(`The layer '${t}' does not exist in the map's style.`)));}_checkSource(t){const i=this.getOwnSource(t);if(i)return i;this.fire(new e.a(new Error(`The source '${t}' does not exist in the map's style.`)));}update(t){if(!this._loaded)return;this.ambientLight&&this.ambientLight.recalculate(t),this.directionalLight&&this.directionalLight.recalculate(t);const i=this.calculateLightsBrightness();t.brightness=i||0,i!==this._brightness&&(this._brightness=i,this.dispatcher.broadcast("setBrightness",i));const o=this._changes.isDirty();if(this._changes.isDirty()){const e=this._changes.getLayerUpdatesByScope();for(const t in e){const{updatedIds:i,removedIds:o}=e[t];(i||o)&&this._updateWorkerLayers(t,i,o);}this.updateSourceCaches(),this._updateTilesForChangedImages(),this.updateLayers(t),this.light&&this.light.updateTransitions(t),this.ambientLight&&this.ambientLight.updateTransitions(t),this.directionalLight&&this.directionalLight.updateTransitions(t),this.fog&&this.fog.updateTransitions(t),this._changes.reset();}const r={};for(const e in this._mergedSourceCaches){const t=this._mergedSourceCaches[e];r[e]=t.used,t.used=!1,t.tileCoverLift=0;}for(const e of this._mergedOrder){const i=this._mergedLayers[e];if(i.recalculate(t,this._availableImages),!i.isHidden(t.zoom)){const e=this.getLayerSourceCache(i);e&&(e.used=!0,e.tileCoverLift=Math.max(e.tileCoverLift,i.tileCoverLift()));}if(!this._precompileDone&&this._shouldPrecompile)for(let e=i.minzoom||0;e<(i.maxzoom||25.5);e++){const e=this.map.painter;if(e){const o=i.getProgramIds();if(!o)continue;for(const r of o){const o=i.getDefaultProgramParams(r,t.zoom);o&&(e.style=this,this.fog&&(e._fogVisible=!0,o.overrideFog=!0,e.getOrCreateProgram(r,o)),e._fogVisible=!1,o.overrideFog=!1,e.getOrCreateProgram(r,o),(this.stylesheet.terrain||this.stylesheet.projection&&"globe"===this.stylesheet.projection.name)&&(o.overrideRtt=!0,e.getOrCreateProgram(r,o)));}}}}this._shouldPrecompile&&(this._precompileDone=!0);for(const t in r){const i=this._mergedSourceCaches[t];r[t]!==i.used&&i.getSource().fire(new e.b("data",{sourceDataType:"visibility",dataType:"source",sourceId:i.getSource().id}));}this.light&&this.light.recalculate(t),this.terrain&&this.terrain.recalculate(t),this.fog&&this.fog.recalculate(t),this.z=t.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),o&&this.fire(new e.b("data",{dataType:"style"}));}_updateTilesForChangedImages(){const e=this._changes.getUpdatedImages();if(e.length){for(const t in this._sourceCaches)this._sourceCaches[t].reloadTilesForDependencies(["icons","patterns"],e);this._changes.resetUpdatedImages();}}_updateWorkerLayers(e,t,i){const o=this.getFragmentStyle(e);o&&this.dispatcher.broadcast("updateLayers",{layers:t?o._serializeLayers(t):[],scope:e,removedIds:i||[],options:o.options});}setState(i){if(this._checkLoaded(),Io(this,Y(i)))return !1;(i=e.c1(i)).layers=ii(i.layers);const o=function(e,i){if(!e)return [{command:oi.setStyle,args:[i]}];let o=[];try{if(!t(e.version,i.version))return [{command:oi.setStyle,args:[i]}];t(e.center,i.center)||o.push({command:oi.setCenter,args:[i.center]}),t(e.zoom,i.zoom)||o.push({command:oi.setZoom,args:[i.zoom]}),t(e.bearing,i.bearing)||o.push({command:oi.setBearing,args:[i.bearing]}),t(e.pitch,i.pitch)||o.push({command:oi.setPitch,args:[i.pitch]}),t(e.sprite,i.sprite)||o.push({command:oi.setSprite,args:[i.sprite]}),t(e.glyphs,i.glyphs)||o.push({command:oi.setGlyphs,args:[i.glyphs]}),t(e.imports,i.imports)||function(e=[],i=[],o){i=i||[];const r=(e=e||[]).map(ci),s=i.map(ci),n=e.reduce(hi,{}),a=i.reduce(hi,{}),l=r.slice();let c,h,u,d;for(c=0,h=0;c{e.source&&r[e.source]?o.push({command:oi.removeLayer,args:[e.id]}):n.push(e);}));let a=e.terrain;a&&r[a.source]&&(o.push({command:oi.setTerrain,args:[void 0]}),a=void 0),o=o.concat(s),t(a,i.terrain)||o.push({command:oi.setTerrain,args:[i.terrain]}),function(e,i,o){i=i||[];const r=(e=e||[]).map(ci),s=i.map(ci),n=e.reduce(hi,{}),a=i.reduce(hi,{}),l=r.slice(),c=Object.create(null);let h,u,d,_,p,f,m;for(h=0,u=0;h!(e.command in Lo)));if(0===o.length)return !1;const r=o.filter((e=>!(e.command in Do)));if(r.length>0)throw new Error(`Unimplemented: ${r.map((e=>e.command)).join(", ")}.`);return o.forEach((e=>{this[e.command].apply(this,e.args);})),this.stylesheet=i,this.mergeAll(),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),!0}addImage(t,i){return this.getImage(t)?this.fire(new e.a(new Error("An image with this name already exists."))):(this.imageManager.addImage(t,this.scope,i),this._afterImageUpdated(t),this)}updateImage(e,t){this.imageManager.updateImage(e,this.scope,t);}getImage(e){return this.imageManager.getImage(e,this.scope)}removeImage(t){return this.getImage(t)?(this.imageManager.removeImage(t,this.scope),this._afterImageUpdated(t),this):this.fire(new e.a(new Error("No image with this name exists.")))}_afterImageUpdated(t){this._availableImages=this.imageManager.listImages(this.scope),this._changes.updateImage(t),this.dispatcher.broadcast("setImages",{scope:this.scope,images:this._availableImages}),this.fire(new e.b("data",{dataType:"style"}));}listImages(){return this._checkLoaded(),this._availableImages.slice()}addModel(e,t,i={}){return this._checkLoaded(),this._validate(ae,`models.${e}`,t,null,i)||(this.modelManager.addModel(e,t,this.scope),this._changes.setDirty()),this}hasModel(e){return this.modelManager.hasModel(e,this.scope)}removeModel(t){return this.hasModel(t)?(this.modelManager.removeModel(t,this.scope),this):this.fire(new e.a(new Error("No model with this ID exists.")))}listModels(){return this._checkLoaded(),this.modelManager.listModels(this.scope)}addSource(t,i,o={}){if(this._checkLoaded(),void 0!==this.getOwnSource(t))throw new Error(`There is already a source with ID "${t}".`);if(!i.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(i.type)>=0&&this._validate(J,`sources.${t}`,i,null,o))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const r=Vt(t,i,this.dispatcher,this);r.scope=this.scope,r.setEventedParent(this,(()=>({isSourceLoaded:this._isSourceCacheLoaded(r.id),source:r.serialize(),sourceId:r.id})));const s=t=>{const i=(t?"symbol:":"other:")+r.id,o=e.ag(i,this.scope),s=this._sourceCaches[i]=new Kt(o,r,t);(t?this._symbolSourceCaches:this._otherSourceCaches)[r.id]=s,s.onAdd(this.map);};s(!1),"vector"!==i.type&&"geojson"!==i.type||s(!0),r.onAdd&&r.onAdd(this.map),o.isInitialLoad||(this.mergeSources(),this._changes.setDirty());}removeSource(t){this._checkLoaded();const i=this.getOwnSource(t);if(!i)throw new Error("There is no source with this ID");for(const i in this._layers)if(this._layers[i].source===t)return this.fire(new e.a(new Error(`Source "${t}" cannot be removed while layer "${i}" is using it.`)));if(this.terrain&&this.terrain.scope===this.scope&&this.terrain.get().source===t)return this.fire(new e.a(new Error(`Source "${t}" cannot be removed while terrain is using it.`)));const o=this.getOwnSourceCaches(t);for(const t of o){const i=e.c3(t.id);delete this._sourceCaches[i],this._changes.discardSourceCacheUpdate(t.id),t.fire(new e.b("data",{sourceDataType:"metadata",dataType:"source",sourceId:t.getSource().id})),t.setEventedParent(null),t.clearTiles();}return delete this._otherSourceCaches[t],delete this._symbolSourceCaches[t],this.mergeSources(),i.setEventedParent(null),i.onRemove&&i.onRemove(this.map),this._changes.setDirty(),this}setGeoJSONSourceData(e,t){this._checkLoaded(),this.getOwnSource(e).setData(t),this._changes.setDirty();}getOwnSource(e){const t=this.getOwnSourceCache(e);return t&&t.getSource()}getOwnSources(){const e=[];for(const t in this._otherSourceCaches){const i=this.getOwnSourceCache(t);i&&e.push(i.getSource());}return e}areTilesLoaded(){const e=this._mergedSourceCaches;for(const t in e){const i=e[t]._tiles;for(const e in i){const t=i[e];if("loaded"!==t.state&&"errored"!==t.state)return !1}}return !0}setLights(t){if(this._checkLoaded(),!t)return delete this.ambientLight,void delete this.directionalLight;const i=this._getTransitionParameters();for(const e of t){if(this._validate(ee,"lights",e))return;switch(e.type){case"ambient":if(this.ambientLight){const t=this.ambientLight;t.set(e),t.updateTransitions(i);}else this.ambientLight=new Te(e,Ee,this.scope,this.options);break;case"directional":if(this.directionalLight){const t=this.directionalLight;t.set(e),t.updateTransitions(i);}else this.directionalLight=new Te(e,Se,this.scope,this.options);}}const o=new e.K(this.z||0,i);this.ambientLight&&this.ambientLight.recalculate(o),this.directionalLight&&this.directionalLight.recalculate(o),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast("setBrightness",this._brightness);}calculateLightsBrightness(){const t=this.directionalLight,i=this.ambientLight;if(!t||!i)return;const o=e=>.2126*(e[0]<=.03928?e[0]/12.92:Math.pow((e[0]+.055)/1.055,2.4))+.7152*(e[1]<=.03928?e[1]/12.92:Math.pow((e[1]+.055)/1.055,2.4))+.0722*(e[2]<=.03928?e[2]/12.92:Math.pow((e[2]+.055)/1.055,2.4)),r=t.properties.get("color").toArray01(),s=t.properties.get("intensity"),n=t.properties.get("direction"),a=1-e.bQ(n.x,n.y,n.z)[2]/90,l=o(r)*s*a,c=i.properties.get("color").toArray01(),h=i.properties.get("intensity");return (l+o(c)*h)/2}getBrightness(){return this._brightness}getLights(){if(!this.enable3dLights())return null;const e=[];return this.directionalLight&&e.push(this.directionalLight.get()),this.ambientLight&&e.push(this.ambientLight.get()),e}enable3dLights(){return !!this.ambientLight&&!!this.directionalLight}getFragmentStyle(t){if(!t)return this;if(e.c4(t)){const i=e.c5(t),o=this.fragments.find((({id:e})=>e===i));if(!o)throw new Error(`Style import not found: ${t}`);const r=e.c3(t);return o.style.getFragmentStyle(r)}{const e=this.fragments.find((({id:e})=>e===t));if(!e)throw new Error(`Style import not found: ${t}`);return e.style}}getConfigProperty(t,i){const o=this.getFragmentStyle(t);if(!o)return null;const r=e.ag(i,o.scope),s=o.options.get(r),n=s?s.value||s.default:null;return n?n.serialize():null}setConfigProperty(t,i,o){const r=e.r(o);if("success"!==r.result)return void Io(this,r.value);const s=r.value.expression,n=this.getFragmentStyle(t);if(!n)return;const a=e.ag(i,n.scope),l=n.options.get(a);l&&(this.options.set(a,{...l,value:s}),this.updateConfigDependencies());}setConfig(t,i){if(this._config=t,t||i)if(i)for(const o in i){let r,s;const n=e.r(i[o].default);if("success"===n.result&&(r=n.value.expression),t&&void 0!==t[o]){const i=e.r(t[o]);"success"===i.result&&(s=i.value.expression);}const{minValue:a,maxValue:l,stepValue:c,type:h,values:u}=i[o];if(r){const t=e.ag(o,this.scope);this.options.set(t,{default:r,value:s,minValue:a,maxValue:l,stepValue:c,type:h,values:u});}else this.fire(new e.a(new Error(`No schema defined for config option "${o}".`)));}else this.fire(new e.a(new Error("Attempting to set config for a style without schema.")));}updateConfigDependencies(){for(const e of this._configDependentLayers){const t=this.getLayer(e);t&&(t.possiblyEvaluateVisibility(),this._updateLayer(t));}this.ambientLight&&this.ambientLight.updateConfig(this.options),this.directionalLight&&this.directionalLight.updateConfig(this.options),this.fog&&this.fog.updateConfig(this.options),this._changes.setDirty();}addLayer(t,i,o={}){this._checkLoaded();const r=t.id;if(this._layers[r])return void this.fire(new e.a(new Error(`Layer with id "${r}" already exists on this map`)));let s;if("custom"===t.type){if(Io(this,e.c6(t)))return;s=e.c2(t,this.scope,this.options);}else {if("object"==typeof t.source&&(this.addSource(r,t.source),t=e.c1(t),t=e.e(t,{source:r})),this._validate(oe,`layers.${r}`,t,{arrayIndex:-1},o))return;s=e.c2(t,this.scope,this.options),this._validateLayer(s),s.setEventedParent(this,{layer:{id:r}}),this._serializedLayers[s.id]=s.serialize();}s.isConfigDependent&&this._configDependentLayers.add(s.fqid);let n=this._order.length;if(i){const t=this._order.indexOf(i);if(-1===t)return void this.fire(new e.a(new Error(`Layer with id "${i}" does not exist on this map.`)));s.slot===this._layers[i].slot?n=t:e.w(`Layer with id "${i}" has a different slot. Layers can only be rearranged within the same slot.`);}this._order.splice(n,0,r),this._layerOrderChanged=!0,this._layers[r]=s;const a=this.getOwnLayerSourceCache(s),l=!!this.directionalLight&&this.directionalLight.shadowsEnabled();a&&s.canCastShadows()&&l&&(a.castsShadows=!0);const c=this._changes.getRemovedLayer(s);if(c&&s.source&&a&&"custom"!==s.type){this._changes.discardLayerRemoval(s);const t=e.ag(s.source,s.scope);c.type!==s.type?this._changes.updateSourceCache(t,"clear"):(this._changes.updateSourceCache(t,"reload"),a.pause());}this._updateLayer(s),s.onAdd&&s.onAdd(this.map),s.scope=this.scope,this.mergeLayers();}moveLayer(t,i){this._checkLoaded();const o=this._checkLayer(t);if(!o)return;if(t===i)return;const r=this._order.indexOf(t);this._order.splice(r,1);let s=this._order.length;if(i){const t=this._order.indexOf(i);if(-1===t)return void this.fire(new e.a(new Error(`Layer with id "${i}" does not exist on this map.`)));o.slot===this._layers[i].slot?s=t:e.w(`Layer with id "${i}" has a different slot. Layers can only be rearranged within the same slot.`);}this._order.splice(s,0,t),this._changes.setDirty(),this._layerOrderChanged=!0,this.mergeLayers();}removeLayer(e){this._checkLoaded();const t=this._checkLayer(e);if(!t)return;t.setEventedParent(null);const i=this._order.indexOf(e);this._order.splice(i,1),delete this._layers[e],delete this._serializedLayers[e],this._changes.setDirty(),this._layerOrderChanged=!0,this._configDependentLayers.delete(t.fqid),this._changes.removeLayer(t);const o=this.getOwnLayerSourceCache(t);if(o&&o.castsShadows){let e=!1;for(const i in this._layers)if(this._layers[i].source===t.source&&this._layers[i].canCastShadows()){e=!0;break}o.castsShadows=e;}t.onRemove&&t.onRemove(this.map),this.mergeLayers();}getOwnLayer(e){return this._layers[e]}hasLayer(e){return e in this._mergedLayers}hasLayerType(e){for(const t in this._layers)if(this._layers[t].type===e)return !0;return !1}setLayerZoomRange(e,t,i){this._checkLoaded();const o=this._checkLayer(e);o&&(o.minzoom===t&&o.maxzoom===i||(null!=t&&(o.minzoom=t),null!=i&&(o.maxzoom=i),this._updateLayer(o)));}setSlot(e,t){this._checkLoaded();const i=this._checkLayer(e);i&&i.slot!==t&&(i.slot=t,this._updateLayer(i));}setFilter(i,o,r={}){this._checkLoaded();const s=this._checkLayer(i);if(s&&!t(s.filter,o))return null==o?(s.filter=void 0,void this._updateLayer(s)):void(this._validate(re,`layers.${s.id}.filter`,o,{layerType:s.type},r)||(s.filter=e.c1(o),this._updateLayer(s)))}getFilter(t){const i=this._checkLayer(t);if(i)return e.c1(i.filter)}setLayoutProperty(i,o,r,s={}){this._checkLoaded();const n=this._checkLayer(i);if(n&&!t(n.getLayoutProperty(o),r)){if(null!=r&&(!s||!1!==s.validate)&&Io(n,ne.call(Y,{key:`layers.${i}.layout.${o}`,layerType:n.type,objectKey:o,value:r,styleSpec:e.D,style:{glyphs:!0,sprite:!0}})))return;n.setLayoutProperty(o,r),n.isConfigDependent&&this._configDependentLayers.add(n.fqid),this._updateLayer(n);}}getLayoutProperty(e,t){const i=this._checkLayer(e);if(i)return i.getLayoutProperty(t)}setPaintProperty(i,o,r,s={}){this._checkLoaded();const n=this._checkLayer(i);if(!n)return;if(t(n.getPaintProperty(o),r))return;if(null!=r&&(!s||!1!==s.validate)&&Io(n,se.call(Y,{key:`layers.${i}.paint.${o}`,layerType:n.type,objectKey:o,value:r,styleSpec:e.D})))return;const a=n.setPaintProperty(o,r);n.isConfigDependent&&this._configDependentLayers.add(n.fqid),a&&this._updateLayer(n),this._changes.updatePaintProperties(n);}getPaintProperty(e,t){const i=this._checkLayer(e);if(i)return i.getPaintProperty(t)}setFeatureState(t,i){this._checkLoaded();const o=t.source,r=t.sourceLayer,s=this._checkSource(o);if(!s)return;const n=s.type;if("geojson"===n&&r)return void this.fire(new e.a(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===n&&!r)return void this.fire(new e.a(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===t.id&&this.fire(new e.a(new Error("The feature id parameter must be provided.")));const a=this.getOwnSourceCaches(o);for(const e of a)e.setFeatureState(r,t.id,i);}removeFeatureState(t,i){this._checkLoaded();const o=t.source,r=this._checkSource(o);if(!r)return;const s=r.type,n="vector"===s?t.sourceLayer:void 0;if("vector"===s&&!n)return void this.fire(new e.a(new Error("The sourceLayer parameter must be provided for vector source types.")));if(i&&"string"!=typeof t.id&&"number"!=typeof t.id)return void this.fire(new e.a(new Error("A feature id is required to remove its specific state property.")));const a=this.getOwnSourceCaches(o);for(const e of a)e.removeFeatureState(n,t.id,i);}getFeatureState(t){this._checkLoaded();const i=t.source,o=t.sourceLayer,r=this._checkSource(i);if(r){if("vector"!==r.type||o)return void 0===t.id&&this.fire(new e.a(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(i)[0].getFeatureState(o,t.id);this.fire(new e.a(new Error("The sourceLayer parameter must be provided for vector source types.")));}}setTransition(t){return this.stylesheet.transition=e.e({},this.stylesheet.transition,t),this.transition=this.stylesheet.transition,this}getTransition(){return e.e({},this.stylesheet.transition)}serialize(){this._checkLoaded();const t=this.getTerrain(),i=t&&this.terrain&&this.terrain.scope===this.scope?t:this.stylesheet.terrain;return e.c7({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,imports:this._serializeImports(),schema:this.stylesheet.schema,camera:this.stylesheet.camera,light:this.stylesheet.light,lights:this.stylesheet.lights,terrain:i,fog:this.stylesheet.fog,center:this.stylesheet.center,zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,projection:this.stylesheet.projection,sources:this._serializeSources(),layers:this._serializeLayers(this._order)},(e=>void 0!==e))}_updateLayer(t){this._changes.updateLayer(t);const i=this.getLayerSourceCache(t),o=e.ag(t.source,t.scope),r=this._changes.getUpdatedSourceCaches();t.source&&!r[o]&&i&&"raster"!==i.getSource().type&&(this._changes.updateSourceCache(o,"reload"),i.pause()),t.invalidateCompiledFilter();}_flattenAndSortRenderedFeatures(e){const t=e=>"fill-extrusion"===this._mergedLayers[e].type||"model"===this._mergedLayers[e].type,i=this.order,o={},r=[];for(let s=i.length-1;s>=0;s--){const n=i[s];if(t(n)){o[n]=s;for(const t of e){const e=t[n];if(e)for(const t of e)r.push(t);}}}r.sort(((e,t)=>t.intersectionZ-e.intersectionZ));const s=[];for(let n=i.length-1;n>=0;n--){const a=i[n];if(t(a))for(let e=r.length-1;e>=0;e--){const t=r[e].feature;if(o[t.layer.id]{const t=this.getLayer(e);return t&&t.is3D()})):this.has3DLayers(),l=Ce.createFromScreenPoints(t,o);for(const e in this._mergedSourceCaches){const t=this._mergedSourceCaches[e].getSource();if(!t||t.scope!==i.scope)continue;const c=this._mergedSourceCaches[e].getSource().id;i.layers&&!r[c]||s.push(Ht(this._mergedSourceCaches[e],this._mergedLayers,n,l,i,o,a,!!this.map._showQueryGeometry));}return this.placement&&s.push(function(e,t,i,o,r,s,n){const a={},l=s.queryRenderedSymbols(o),c=[];for(const e of Object.keys(l).map(Number))c.push(n[e]);c.sort(qt);for(const i of c){const o=i.featureIndex.lookupSymbolFeatures(l[i.bucketInstanceId],t,i.bucketIndex,i.sourceLayerIndex,r.filter,r.layers,r.availableImages,e);for(const e in o){const t=a[e]=a[e]||[],r=o[e];r.sort(((e,t)=>{const o=i.featureSortOrder;if(o){const i=o.indexOf(e.featureIndex);return o.indexOf(t.featureIndex)-i}return t.featureIndex-e.featureIndex}));for(const e of r)t.push(e);}}for(const t in a)a[t].forEach((o=>{const r=o.feature,s=i(e[t]);if(!s)return;const n=s.getFeatureState(r.layer["source-layer"],r.id);r.source=r.layer.source,r.layer["source-layer"]&&(r.sourceLayer=r.layer["source-layer"]),r.state=n;}));return a}(this._mergedLayers,n,this.getLayerSourceCache.bind(this),l.screenGeometry,i,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(s)}querySourceFeatures(e,t){t&&t.filter&&this._validate(re,"querySourceFeatures.filter",t.filter,null,t);const i=this.getOwnSourceCaches(e);let o=[];for(const e of i)o=o.concat(Wt(e,t));return o}addSourceType(e,t,i){return Mo.getSourceType(e)?i(new Error(`A source type called "${e}" already exists.`)):(Mo.setSourceType(e,t),t.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:e,url:t.workerSourceURL},i):i(null,null))}getFlatLight(){return this.light.getLight()}setFlatLight(e,i,o={}){this._checkLoaded();const r=this.light.getLight();let s=!1;for(const i in e)if(!t(e[i],r[i])){s=!0;break}if(!s)return;const n=this._getTransitionParameters();this.light.setLight(e,i,o),this.light.updateTransitions(n);}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0);}setTerrain(i,o=1){if(this._checkLoaded(),!i)return this.terrainSetForDrapingOnly()&&0!==o||delete this.terrain,null===i?this.stylesheet.terrain=null:delete this.stylesheet.terrain,this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);let r=i;const s=null==i.source;if(1===o){if("object"==typeof r.source){const t="terrain-dem-src";this.addSource(t,r.source),r=e.c1(r),r=e.e(r,{source:t});}const t=e.e({},r),i={};if(this.terrain&&s){t.source=this.terrain.get().source;const e=this.terrain?this.getFragmentStyle(this.terrain.scope):null;e&&(i.style=e.serialize());}if(this._validate(te,"terrain",t,i))return}if(!this.terrain||this.terrain.scope!==this.scope&&!s||this.terrain&&o!==this.terrain.drapeRenderMode){if(!r)return;this._createTerrain(r,o),this.fire(new e.b("data",{dataType:"style"}));}else {const o=this.terrain,s=o.get();for(const t of Object.keys(e.D.terrain))!r.hasOwnProperty(t)&&e.D.terrain[t].default&&(r[t]=e.D.terrain[t].default);for(const r in i)if(!t(i[r],s[r])){o.set(i,this.options),this.stylesheet.terrain=i;const t=this._getTransitionParameters({duration:0});o.updateTransitions(t),this.fire(new e.b("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0;}_createFog(e){const t=this.fog=new we(e,this.map.transform,this.scope,this.options);this.stylesheet.fog=t.get();const i=this._getTransitionParameters({duration:0});t.updateTransitions(i);}_updateMarkersOpacity(){0!==this.map._markers.length&&this.map._requestDomTask((()=>{for(const e of this.map._markers)e._evaluateOpacity();}));}getFog(){return this.fog?this.fog.get():null}setFog(e){if(this._checkLoaded(),!e)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const i=this.fog;if(!t(i.get(),e)){i.set(e,this.options),this.stylesheet.fog=i.get();const t=this._getTransitionParameters({duration:0});i.updateTransitions(t);}}else this._createFog(e);this._markersNeedUpdate=!0;}_getTransitionParameters(t){return {now:e.f.now(),transition:e.e(this.transition,t)}}updateDrapeFirstLayers(){if(!this.terrain)return;const e=[],t=[];for(const i in this._mergedLayers)this.isLayerDraped(this._mergedLayers[i])?e.push(i):t.push(i);this._drapedFirstOrder=[],this._drapedFirstOrder.push(...e),this._drapedFirstOrder.push(...t);}_createTerrain(e,t){const i=this.terrain=new _e(e,t,this.scope,this.options);1===t&&(this.stylesheet.terrain=e),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();const o=this._getTransitionParameters({duration:0});i.updateTransitions(o);}_force3DLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"fill-extrusion"===t.type&&this._updateLayer(t);}}_forceSymbolLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"symbol"===t.type&&this._updateLayer(t);}}_validate(t,i,o,r,s={}){if(s&&!1===s.validate)return !1;const n=e.e({},this.serialize());return Io(this,t.call(Y,e.e({key:i,style:n,value:o,styleSpec:e.D},r)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),e.c8.off("pluginStateChange",this._rtlTextPluginCallback);for(const e in this._mergedLayers)this._mergedLayers[e].setEventedParent(null);for(const e in this._mergedSourceCaches)this._mergedSourceCaches[e].clearTiles(),this._mergedSourceCaches[e].setEventedParent(null);this.setEventedParent(null),delete this.fog,delete this.terrain,delete this.ambientLight,delete this.directionalLight,this.isRootStyle()&&(this.imageManager.setEventedParent(null),this.modelManager.setEventedParent(null),this.dispatcher.remove());}clearSource(e){const t=this.getSourceCaches(e);for(const e of t)e.clearTiles();}clearSources(){for(const e in this._mergedSourceCaches)this._mergedSourceCaches[e].clearTiles();}reloadSource(e){const t=this.getSourceCaches(e);for(const e of t)e.resume(),e.reload();}reloadSources(){for(const e of this.getSources())e.reload&&e.reload();}updateSources(e){let t;this.directionalLight&&(t=Eo(this.directionalLight));for(const i in this._mergedSourceCaches)this._mergedSourceCaches[i].update(e,void 0,void 0,t);}_generateCollisionBoxes(){for(const e in this._sourceCaches){const t=this._sourceCaches[e];t.resume(),t.reload();}}_updatePlacement(t,i,o,r,s=!1){let n=!1,a=!1;const l={},c={};for(const i of this._mergedOrder){const o=this._mergedLayers[i];if("symbol"!==o.type)continue;const r=e.ag(o.source,o.scope);let s=l[r];if(!s){const e=this.getLayerSourceCache(o);if(!e)continue;const t=e.getRenderableIds(!0).map((t=>e.getTileByID(t)));c[r]=t.slice(),s=l[r]=t.sort(((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1)));}const a=this.crossTileSymbolIndex.addLayer(o,s,t.center.lng,t.projection);n=n||a;}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder),s=s||this._layerOrderChanged||0===o,this._layerOrderChanged&&this.fire(new e.b("neworder")),(s||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(e.f.now(),t.zoom))&&(this.pauseablePlacement=new to(t,this._mergedOrder,s,i,o,r,this.placement,this.fog&&t.projection.supportsFog?this.fog.state:null,this._buildingIndex),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,l,c),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(e.f.now()),a=!0),n&&this.pauseablePlacement.placement.setStale()),a||n){this._buildingIndex.onNewFrame(t.zoom);for(const t of this._mergedOrder){const i=this._mergedLayers[t];"symbol"===i.type&&this.placement.updateLayerOpacities(i,l[e.ag(i.source,i.scope)]);}}return !this.pauseablePlacement.isDone()||this.placement.hasTransitions(e.f.now())}_releaseSymbolFadeTiles(){for(const e in this._sourceCaches)this._sourceCaches[e].releaseSymbolFadeTiles();}addImport(t,i){this._checkLoaded();const o=this.stylesheet.imports=this.stylesheet.imports||[];if(-1!==o.findIndex((({id:e})=>e===t.id)))return this.fire(new e.a(new Error(`Import with id '${t.id}' already exists in the map's style.`)));if(!i)return o.push(t),this._loadImports([t],!0),this;const r=o.findIndex((({id:e})=>e===i));return -1===r?this.fire(new e.a(new Error(`Import with id "${i}" does not exist on this map.`))):(this.stylesheet.imports=o.slice(0,r).concat(t).concat(o.slice(r)),this._loadImports([t],!0,i),this)}updateImport(e,i){this._checkLoaded();const o=this.stylesheet.imports||[],r=this.getImportIndex(e);return -1===r?this:"string"==typeof i?(this.setImportUrl(e,i),this):(i.url&&i.url!==o[r].url&&this.setImportUrl(e,i.url),t(i.config,o[r].config)||this.setImportConfig(e,i.config),t(i.data,o[r].data)||this.setImportData(e,i.data),this)}moveImport(e,t){this._checkLoaded();let i=this.stylesheet.imports||[];const o=this.getImportIndex(e);if(-1===o)return this;const r=this.getImportIndex(t);if(-1===r)return this;const s=i[o],n=this.fragments[o];return i=i.filter((({id:t})=>t!==e)),this.fragments=this.fragments.filter((({id:t})=>t!==e)),this.stylesheet.imports=i.slice(0,r).concat(s).concat(i.slice(r)),this.fragments=this.fragments.slice(0,r).concat(n).concat(this.fragments.slice(r)),this.mergeLayers(),this}setImportUrl(e,t){this._checkLoaded();const i=this.stylesheet.imports||[],o=this.getImportIndex(e);if(-1===o)return this;i[o].url=t;const r=this.fragments[o];return r.style=this._createFragmentStyle(i[o]),r.style.on("style.import.load",(()=>this.mergeAll())),r.style.loadURL(t),this}setImportData(e,t){this._checkLoaded();const i=this.getImportIndex(e),o=this.stylesheet.imports||[];return -1===i?this:t?(this.fragments[i].style.setState(t),this._reloadImports(),this):(delete o[i].data,this.setImportUrl(e,o[i].url))}setImportConfig(e,t){this._checkLoaded();const i=this.getImportIndex(e),o=this.stylesheet.imports||[];if(-1===i)return this;t?o[i].config=t:delete o[i].config;const r=this.fragments[i],s=r.style.stylesheet&&r.style.stylesheet.schema;return r.config=t,r.style.setConfig(t,s),this.updateConfigDependencies(),this}removeImport(e){this._checkLoaded();const t=this.stylesheet.imports||[],i=this.getImportIndex(e);return -1===i||(t.splice(i,1),this.fragments[i].style._remove(),this.fragments.splice(i,1),this._reloadImports()),this}getImportIndex(t){const i=(this.stylesheet.imports||[]).findIndex((e=>e.id===t));return -1===i&&this.fire(new e.a(new Error(`Import '${t}' does not exist in the map's style and cannot be updated.`))),i}getLayer(e){return this._mergedLayers[e]}getSources(){const e=[];for(const t in this._mergedOtherSourceCaches){const i=this._mergedOtherSourceCaches[t];i&&e.push(i.getSource());}return e}getSource(e,t){const i=this.getSourceCache(e,t);return i&&i.getSource()}getLayerSource(e){const t=this.getLayerSourceCache(e);return t&&t.getSource()}getSourceCache(t,i){const o=e.ag(t,i);return this._mergedOtherSourceCaches[o]}getLayerSourceCache(t){const i=e.ag(t.source,t.scope);return "symbol"===t.type?this._mergedSymbolSourceCaches[i]:this._mergedOtherSourceCaches[i]}getSourceCaches(e){const t=[];return this._mergedOtherSourceCaches[e]&&t.push(this._mergedOtherSourceCaches[e]),this._mergedSymbolSourceCaches[e]&&t.push(this._mergedSymbolSourceCaches[e]),t}updateSourceCaches(){const e=this._changes.getUpdatedSourceCaches();for(const t in e){const i=e[t];"reload"===i?this.reloadSource(t):"clear"===i&&this.clearSource(t);}}updateLayers(e){const t=this._changes.getUpdatedPaintProperties();for(const i of t){const t=this.getLayer(i);t&&t.updateTransitions(e);}}getImages(e,t,i){this.imageManager.getImages(t.icons,t.scope,i),this._updateTilesForChangedImages();const o=e=>{e&&e.setDependencies(t.tileID.key,t.type,t.icons);};o(this._otherSourceCaches[t.source]),o(this._symbolSourceCaches[t.source]);}getGlyphs(e,t,i){this.glyphManager.getGlyphs(t.stacks,t.scope,i);}getResource(t,i,o){return e.c9(i,o)}getOwnSourceCache(e){return this._otherSourceCaches[e]}getOwnLayerSourceCache(e){return "symbol"===e.type?this._symbolSourceCaches[e.source]:this._otherSourceCaches[e.source]}getOwnSourceCaches(e){const t=[];return this._otherSourceCaches[e]&&t.push(this._otherSourceCaches[e]),this._symbolSourceCaches[e]&&t.push(this._symbolSourceCaches[e]),t}_isSourceCacheLoaded(t){const i=this.getOwnSourceCaches(t);return 0===i.length?(this.fire(new e.a(new Error(`There is no source with ID '${t}'`))),!1):i.every((e=>e.loaded()))}has3DLayers(){return this._has3DLayers}hasSymbolLayers(){return this._hasSymbolLayers}hasCircleLayers(){return this._hasCircleLayers}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches");}destroy(){this._clearWorkerCaches(),this.fragments.forEach((e=>{e.style._remove();})),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain);}}Mo.getSourceType=function(e){return jt[e]},Mo.setSourceType=function(e,t){jt[e]=t;},Mo.registerForPluginStateChange=e.bV;var zo="\n#define EPSILON 0.0000001\n#define PI 3.141592653589793\n#ifdef RENDER_CUTOFF\nfloat cutoff_opacity(vec4 cutoff_params,float depth) {float near=cutoff_params.x;float far=cutoff_params.y;float cutoffStart=cutoff_params.z;float cutoffEnd=cutoff_params.w;float linearDepth=(depth-near)/(far-near);return clamp((linearDepth-cutoffStart)/(cutoffEnd-cutoffStart),0.0,1.0);}\n#endif",Oo="\nout vec4 glFragColor;highp float unpack_depth(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}highp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}\n#ifdef INDICATOR_CUTOUT\nuniform vec2 u_indicator_cutout_centers;uniform vec4 u_indicator_cutout_params;\n#endif\nvec4 applyCutout(vec4 color) {\n#ifdef INDICATOR_CUTOUT\nfloat holeMinOpacity=u_indicator_cutout_params.x;float holeRadius=max(u_indicator_cutout_params.y,0.0);float holeAspectRatio=u_indicator_cutout_params.z;float fadeStart=u_indicator_cutout_params.w;float distA=distance(vec2(gl_FragCoord.x,gl_FragCoord.y*holeAspectRatio),vec2(u_indicator_cutout_centers[0],u_indicator_cutout_centers[1]*holeAspectRatio));return color*min(smoothstep(fadeStart,holeRadius,distA)+holeMinOpacity,1.0);\n#else\nreturn color;\n#endif\n}\n#ifdef DEBUG_WIREFRAME\n#define HANDLE_WIREFRAME_DEBUG \\\nglFragColor=vec4(0.7,0.0,0.0,0.7); \\\ngl_FragDepth=gl_FragCoord.z-0.0001;\n#else\n#define HANDLE_WIREFRAME_DEBUG\n#endif\n#ifdef RENDER_CUTOFF\nuniform highp vec4 u_cutoff_params;in float v_cutoff_opacity;\n#endif\nvec4 textureLodCustom(sampler2D image,vec2 pos,vec2 lod_coord) {vec2 size=vec2(textureSize(image,0));vec2 dx=dFdx(lod_coord.xy*size);vec2 dy=dFdy(lod_coord.xy*size);float delta_max_sqr=max(dot(dx,dx),dot(dy,dy));float lod=0.5*log2(delta_max_sqr);return textureLod(image,pos,lod);}",Fo="\n#define EXTENT 8192.0\n#define RAD_TO_DEG 180.0/PI\n#define DEG_TO_RAD PI/180.0\n#define GLOBE_RADIUS EXTENT/PI/2.0\nfloat wrap(float n,float min,float max) {float d=max-min;float w=mod(mod(n-min,d)+d,d)+min;return (w==min) ? max : w;}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {\n#ifndef PROJECTED_POS_ON_VIEWPORT\nfloat tiles=tile_id.z;vec2 mercator=(tile_anchor/EXTENT+tile_id.xy)/tiles;mercator-=mercator_center;mercator.x=wrap(mercator.x,-0.5,0.5);vec4 mercator_tile=vec4(mercator.xy*EXTENT,EXTENT/(2.0*PI),1.0);mercator_tile=matrix*mercator_tile;return mercator_tile.xyz;\n#else\nreturn vec3(0.0);\n#endif\n}vec3 mix_globe_mercator(vec3 globe,vec3 mercator,float t) {return mix(globe,mercator,t);}mat3 globe_mercator_surface_vectors(vec3 pos_normal,vec3 up_dir,float zoom_transition) {vec3 normal=zoom_transition==0.0 ? pos_normal : normalize(mix(pos_normal,up_dir,zoom_transition));vec3 xAxis=normalize(vec3(normal.z,0.0,-normal.x));vec3 yAxis=normalize(cross(normal,xAxis));return mat3(xAxis,yAxis,normal);}\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(\nunpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(PI/4.0+lat/2.0*DEG_TO_RAD))))/360.0;}vec3 latLngToECEF(vec2 latLng) {latLng=DEG_TO_RAD*latLng;float cosLat=cos(latLng[0]);float sinLat=sin(latLng[0]);float cosLng=cos(latLng[1]);float sinLng=sin(latLng[1]);float sx=cosLat*sinLng*GLOBE_RADIUS;float sy=-sinLat*GLOBE_RADIUS;float sz=cosLat*cosLng*GLOBE_RADIUS;return vec3(sx,sy,sz);}\n#ifdef RENDER_CUTOFF\nuniform vec4 u_cutoff_params;out float v_cutoff_opacity;\n#endif\nconst vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);const float skirtOffset=24575.0;vec3 decomposeToPosAndSkirt(vec2 posWithComposedSkirt)\n{float skirt=float(posWithComposedSkirt.x >=skirtOffset);vec2 pos=posWithComposedSkirt-vec2(skirt*skirtOffset,0.0);return vec3(pos,skirt);}",Bo="in highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;out highp vec3 v_uv;void main() {const mat3 half_neg_pi_around_x=mat3(1.0,0.0, 0.0,0.0,0.0,-1.0,0.0,1.0, 0.0);v_uv=half_neg_pi_around_x*a_pos_3f;vec4 pos=u_matrix*vec4(a_pos_3f,1.0);gl_Position=pos.xyww;}",ko="\n#define ELEVATION_SCALE 7.0\n#define ELEVATION_OFFSET 450.0\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix(\nmix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;}\n#else\nvec3 elevationVector(vec2 pos) { return vec3(0,0,1); }\n#endif\n#ifdef TERRAIN\nuniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;uniform vec2 u_dem_tl;uniform vec2 u_dem_tl_prev;uniform float u_dem_scale;uniform float u_dem_scale_prev;uniform float u_dem_size;uniform float u_dem_lerp;uniform float u_exaggeration;uniform float u_meter_to_dem;uniform mat4 u_label_plane_matrix_inv;uniform sampler2D u_depth;uniform vec2 u_depth_size_inv;vec4 tileUvToDemSample(vec2 uv,float dem_size,float dem_scale,vec2 dem_tl) {vec2 pos=dem_size*(uv*dem_scale+dem_tl)+1.0;vec2 f=fract(pos);return vec4((pos-f+0.5)/(dem_size+2.0),f);}float currentElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale+u_dem_tl)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture(u_dem,pos).r;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale,u_dem_tl);vec2 pos=r.xy;vec2 f=r.zw;float tl=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(dd,0)).r;float bl=texture(u_dem,pos+vec2(0,dd)).r;float br=texture(u_dem,pos+vec2(dd,dd)).r;return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}float prevElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale_prev+u_dem_tl_prev)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture(u_dem_prev,pos).r;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale_prev,u_dem_tl_prev);vec2 pos=r.xy;vec2 f=r.zw;float tl=texture(u_dem_prev,pos).r;float tr=texture(u_dem_prev,pos+vec2(dd,0)).r;float bl=texture(u_dem_prev,pos+vec2(0,dd)).r;float br=texture(u_dem_prev,pos+vec2(dd,dd)).r;return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}\n#ifdef TERRAIN_VERTEX_MORPHING\nfloat elevation(vec2 apos) {\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\nfloat nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}\n#else\nfloat elevation(vec2 apos) {\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\nreturn currentElevation(apos);}\n#endif\nhighp float unpack_depth(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;float depth=unpack_depth(texture(u_depth,(coord.xy+1.0)*0.5));return coord.z > depth+0.0005;}float occlusionFade(vec4 frag) {vec3 coord=frag.xyz/frag.w;vec3 df=vec3(5.0*u_depth_size_inv,0.0);vec2 uv=0.5*coord.xy+0.5;vec4 depth=vec4(\nunpack_depth(texture(u_depth,uv-df.xz)),unpack_depth(texture(u_depth,uv+df.xz)),unpack_depth(texture(u_depth,uv-df.zy)),unpack_depth(texture(u_depth,uv+df.zy))\n);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z-0.001)-depth),0.0,1.0));}vec4 fourSample(vec2 pos,vec2 off) {float tl=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(off.x,0.0)).r;float bl=texture(u_dem,pos+vec2(0.0,off.y)).r;float br=texture(u_dem,pos+off).r;return vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);}\n#else\nfloat elevation(vec2 pos) { return 0.0; }bool isOccluded(vec4 frag) { return false; }float occlusionFade(vec4 frag) { return 1.0; }\n#endif",No="#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump mat4 u_fog_matrix;out vec3 v_fog_pos;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}vec3 fog_position(vec3 pos) {return (u_fog_matrix*vec4(pos,1.0)).xyz;}vec3 fog_position(vec2 pos) {return fog_position(vec3(pos,0.0));}float fog(vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));return opacity*fog_horizon_blending(pos/depth);}\n#endif",Uo="highp vec3 hash(highp vec2 p) {highp vec3 p3=fract(p.xyx*vec3(443.8975,397.2973,491.1871));p3+=dot(p3,p3.yxz+19.19);return fract((p3.xxy+p3.yzz)*p3.zyx);}vec3 dither(vec3 color,highp vec2 seed) {vec3 rnd=hash(seed)+hash(seed+0.59374)-0.5;return color+rnd/255.0;}\n#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump vec2 u_fog_vertical_limit;uniform mediump float u_fog_temporal_offset;in vec3 v_fog_pos;uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform highp vec2 u_viewport;uniform float u_globe_transition;uniform int u_is_globe;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}float globe_glow_progress() {highp vec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float sdf=length(closest_point-u_globe_pos)/u_globe_radius;return sdf+PI*0.5;}float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos,float opacity_limit) {float depth=length(pos);float opacity;if (u_is_globe==1) {float glow_progress=globe_glow_progress();float t=mix(glow_progress,depth,u_globe_transition);opacity=fog_opacity(fog_range(t));} else {opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);}return mix(color,u_fog_color.rgb,min(opacity,opacity_limit));}vec3 fog_apply(vec3 color,vec3 pos) {return fog_apply(color,pos,1.0);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec4 fog_apply_premultiplied(vec4 color,vec3 pos,float heightMeters) {float verticalProgress=(u_fog_vertical_limit.x > 0.0 || u_fog_vertical_limit.y > 0.0) ? smoothstep(u_fog_vertical_limit.x,u_fog_vertical_limit.y,heightMeters) : 0.0;float opacityLimit=1.0-smoothstep(0.9,1.0,fog_opacity(pos));return mix(fog_apply_premultiplied(color,pos),color,min(verticalProgress,opacityLimit));}vec3 fog_dither(vec3 color) {\n#ifdef FOG_DITHERING\nvec2 dither_seed=gl_FragCoord.xy+u_fog_temporal_offset;return dither(color,dither_seed);\n#else\nreturn color;\n#endif\n}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}\n#endif",Go="#ifdef RASTER_ARRAY\nuniform sampler2D u_image0;uniform sampler2D u_image1;const vec4 NODATA=vec4(1);ivec4 _raTexLinearCoord(highp vec2 texCoord,highp vec2 texResolution,out highp vec2 fxy) {texCoord=texCoord*texResolution-0.5;fxy=fract(texCoord);texCoord-=fxy;return ivec4(texCoord.xxyy+vec2(1.5,0.5).xyxy);}vec2 _raTexLinearMix(highp vec2 fxy,highp vec4 colorMix,highp float colorOffset,highp vec4 t00,highp vec4 t10,highp vec4 t01,highp vec4 t11) {vec2 c00=t00==NODATA ? vec2(0) : vec2(colorOffset+dot(t00,colorMix),1);vec2 c10=t10==NODATA ? vec2(0) : vec2(colorOffset+dot(t10,colorMix),1);vec2 c01=t01==NODATA ? vec2(0) : vec2(colorOffset+dot(t01,colorMix),1);vec2 c11=t11==NODATA ? vec2(0) : vec2(colorOffset+dot(t11,colorMix),1);return mix(mix(c01,c11,fxy.x),mix(c00,c10,fxy.x),fxy.y);}vec2 raTexture2D_image0_linear(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec2 fxy;ivec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texelFetch(u_image0,c.yz,0),texelFetch(u_image0,c.xz,0),texelFetch(u_image0,c.yw,0),texelFetch(u_image0,c.xw,0)\n);}vec2 raTexture2D_image1_linear(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec2 fxy;ivec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texelFetch(u_image1,c.yz,0),texelFetch(u_image1,c.xz,0),texelFetch(u_image1,c.yw,0),texelFetch(u_image1,c.xw,0)\n);}vec2 raTexture2D_image0_nearest(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec4 t=texelFetch(u_image0,ivec2(texCoord*texResolution),0);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);}vec2 raTexture2D_image1_nearest(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec4 t=texelFetch(u_image1,ivec2(texCoord*texResolution),0);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);}\n#endif",jo="#ifdef RASTER_ARRAY\nuniform sampler2D u_velocity;uniform vec2 u_velocity_res;uniform float u_max_speed;const vec2 INVALID_VELOCITY=vec2(-1);uniform vec2 u_texture_offset;uniform float u_data_offset;uniform vec4 u_data_scale;vec2 lookup_velocity(vec2 uv) {uv=u_texture_offset.x+u_texture_offset.y*uv;vec2 fxy;ivec4 c=_raTexLinearCoord(uv,u_velocity_res,fxy);vec4 tl=texelFetch(u_velocity,c.yz,0);vec4 tr=texelFetch(u_velocity,c.xz,0);vec4 bl=texelFetch(u_velocity,c.yw,0);vec4 br=texelFetch(u_velocity,c.xw,0);if (tl==NODATA) {return INVALID_VELOCITY;}if (tr==NODATA) {return INVALID_VELOCITY;}if (bl==NODATA) {return INVALID_VELOCITY;}if (br==NODATA) {return INVALID_VELOCITY;}vec4 t=mix(mix(bl,br,fxy.x),mix(tl,tr,fxy.x),fxy.y);\n#ifdef DATA_FORMAT_UINT32\nvec2 velocity=vec2(u_data_offset+dot(t,u_data_scale),0);return velocity;\n#else\nvec2 velocity=vec2(u_data_offset+dot(t.rg,u_data_scale.yx),-(u_data_offset+dot(t.ba,u_data_scale.yx)));\n#endif\nreturn velocity/max(u_max_speed,length(velocity));}\n#endif",Vo="#ifdef RENDER_SHADOWS\nuniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_normal_offset;vec3 shadow_normal_offset(vec3 normal) {float tileInMeters=u_shadow_normal_offset[0];vec3 n=vec3(-normal.xy,tileInMeters*normal.z);float dotScale=min(1.0-dot(normal,u_shadow_direction),1.0)*0.5+0.5;return n*dotScale;}vec3 shadow_normal_offset_model(vec3 normal) {float dotScale=min(1.0-dot(normal,u_shadow_direction),1.0)*0.5+0.5;return normal*dotScale;}float shadow_normal_offset_multiplier0() {return u_shadow_normal_offset[1];}float shadow_normal_offset_multiplier1() {return u_shadow_normal_offset[2];}\n#endif//RENDER_SHADOWS",Zo="#ifdef RENDER_SHADOWS\n#ifdef DEPTH_TEXTURE\nuniform highp sampler2D u_shadowmap_0;uniform highp sampler2D u_shadowmap_1;\n#else\nuniform sampler2D u_shadowmap_0;uniform sampler2D u_shadowmap_1;\n#endif\nuniform float u_shadow_intensity;uniform float u_shadow_map_resolution;uniform float u_shadow_texel_size;uniform highp vec3 u_shadow_normal_offset;uniform vec2 u_fade_range;uniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_bias;highp float shadow_sample_1(highp vec2 uv,highp float compare) {highp float shadow_depth;\n#ifdef DEPTH_TEXTURE\nshadow_depth=texture(u_shadowmap_1,uv).r;\n#else\nshadow_depth=unpack_depth(texture(u_shadowmap_1,uv))*0.5+0.5;\n#endif\nreturn step(shadow_depth,compare);}highp float shadow_sample_0(highp vec2 uv,highp float compare) {highp float shadow_depth;\n#ifdef DEPTH_TEXTURE\nshadow_depth=texture(u_shadowmap_0,uv).r;\n#else\nshadow_depth=unpack_depth(texture(u_shadowmap_0,uv))*0.5+0.5;\n#endif\nreturn step(shadow_depth,compare);}float shadow_occlusion_1(highp vec4 pos,highp float bias) {highp vec2 uv=pos.xy;return shadow_sample_1(uv,pos.z-bias);}float shadow_occlusion_0(highp vec4 pos,highp float bias) {highp float compare0=pos.z-bias;\n#ifdef NATIVE\nhighp vec2 uv=pos.xy;highp vec4 samples=textureGather(u_shadowmap_0,uv,0);lowp vec4 stepSamples=step(samples,vec4(compare0));\n#else\nhighp vec2 uv00=pos.xy-vec2(0.5*u_shadow_texel_size);highp vec2 uv10=uv00+vec2(u_shadow_texel_size,0.0);highp vec2 uv01=uv00+vec2(0.0,u_shadow_texel_size);highp vec2 uv11=uv01+vec2(u_shadow_texel_size,0.0);lowp vec4 stepSamples=vec4(\nshadow_sample_0(uv01,compare0),shadow_sample_0(uv11,compare0),shadow_sample_0(uv10,compare0),shadow_sample_0(uv00,compare0)\n);\n#endif\nvec2 f=fract(pos.xy*u_shadow_map_resolution-vec2(0.5));lowp vec2 lerpx=mix(stepSamples.wx,stepSamples.zy,f.xx);return mix(lerpx.x,lerpx.y,f.y);}float shadow_occlusion(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,highp float bias) {\n#ifdef SHADOWS_SINGLE_CASCADE\nlight_view_pos0.xyz=light_view_pos0.xyz/light_view_pos0.w*0.5+0.5;return shadow_occlusion_0(light_view_pos0,bias);\n#else\nlight_view_pos0.xyz/=light_view_pos0.w;light_view_pos1.xyz/=light_view_pos1.w;vec4 uv=vec4(light_view_pos0.xy,light_view_pos1.xy);vec4 abs_bounds=abs(uv);if (abs_bounds.x < 1.0 && abs_bounds.y < 1.0) {light_view_pos0.xyz=light_view_pos0.xyz*0.5+0.5;return shadow_occlusion_0(light_view_pos0,bias);}if (abs_bounds.z >=1.0 || abs_bounds.w >=1.0) {return 0.0;}light_view_pos1.xyz=light_view_pos1.xyz*0.5+0.5;float occlusion1=shadow_occlusion_1(light_view_pos1,bias);return mix(occlusion1,0.0,smoothstep(u_fade_range.x,u_fade_range.y,view_depth));\n#endif\n}highp float calculate_shadow_bias(float NDotL) {\n#ifdef NORMAL_OFFSET\nreturn 0.5*u_shadow_bias.x;\n#else\nreturn 0.5*(u_shadow_bias.x+clamp(u_shadow_bias.y*tan(acos(NDotL)),0.0,u_shadow_bias.z));\n#endif\n}float shadowed_light_factor_normal(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=calculate_shadow_bias(NDotL);float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor_normal_unbiased(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return 1.0-(u_shadow_intensity*occlusion);}float shadow_occlusion(float ndotl,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=calculate_shadow_bias(ndotl);return shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);}\n#endif";const Ho=[];Yo(zo,Ho),Yo(Fo,Ho),Yo(Oo,Ho);const Wo={"_prelude_fog.vertex.glsl":No,"_prelude_terrain.vertex.glsl":ko,"_prelude_shadow.vertex.glsl":Vo,"_prelude_fog.fragment.glsl":Uo,"_prelude_shadow.fragment.glsl":Zo,"_prelude_lighting.glsl":"\n#ifdef LIGHTING_3D_MODE\nuniform mediump vec3 u_lighting_ambient_color;uniform mediump vec3 u_lighting_directional_dir;uniform mediump vec3 u_lighting_directional_color;uniform mediump vec3 u_ground_radiance;float calculate_ambient_directional_factor(vec3 normal) {float NdotL=dot(normal,u_lighting_directional_dir);const float factor_reduction_max=0.3;float dir_luminance=dot(u_lighting_directional_color,vec3(0.2126,0.7152,0.0722));float directional_factor_min=1.0-factor_reduction_max*min(dir_luminance,1.0);float ambient_directional_factor=mix(directional_factor_min,1.0,min((NdotL+1.0),1.0));const float vertical_factor_min=0.92;float vertical_factor=mix(vertical_factor_min,1.0,normal.z*0.5+0.5);return vertical_factor*ambient_directional_factor;}vec3 linearProduct(vec3 srgbIn,vec3 k) {return srgbIn*pow(k,vec3(1./2.2));}vec3 apply_lighting(vec3 color,vec3 normal,float dir_factor) {float ambient_directional_factor=calculate_ambient_directional_factor(normal);vec3 ambient_contrib=ambient_directional_factor*u_lighting_ambient_color;vec3 directional_contrib=u_lighting_directional_color*dir_factor;return linearProduct(color,ambient_contrib+directional_contrib);}vec4 apply_lighting(vec4 color,vec3 normal,float dir_factor) {return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting(vec3 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return apply_lighting(color.rgb,normal,dir_factor);}vec4 apply_lighting(vec4 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting_ground(vec3 color) {return color*u_ground_radiance;}vec4 apply_lighting_ground(vec4 color) {return vec4(apply_lighting_ground(color.rgb),color.a);}float calculate_NdotL(vec3 normal) {const float ext=0.70710678118;return (clamp(dot(normal,u_lighting_directional_dir),-ext,1.0)+ext)/(1.0+ext);}vec4 apply_lighting_with_emission_ground(vec4 color,float emissive_strength) {return mix(apply_lighting_ground(color),color,emissive_strength);}vec3 compute_flood_lighting(vec3 flood_light_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=flood_light_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);float occlusion_ramp=smoothstep(0.0,0.2,1.0-occlusion);return mix(fully_occluded_color,flood_light_color,occlusion_ramp);}vec3 compute_emissive_draped(vec3 unlit_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=unlit_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);return mix(fully_occluded_color,unlit_color,1.0-occlusion);}\n#endif//LIGHTING_3D_MODE","_prelude_raster_array.glsl":Go,"_prelude_raster_particle.glsl":jo},qo={};Jo("",ko),Jo(Uo,No),Jo(Zo,Vo),Jo(Go,""),Jo(jo,"");const $o=Jo(Oo,Fo),Xo=zo;var Ko={background:Jo('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec4 u_color;uniform float u_opacity;\n#ifdef LIGHTING_3D_MODE\nin vec4 v_color;\n#endif\nvoid main() {vec4 out_color;\n#ifdef LIGHTING_3D_MODE\nout_color=v_color;\n#else\nout_color=u_color;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_lighting.glsl"\nin vec2 a_pos;uniform mat4 u_matrix;\n#ifdef LIGHTING_3D_MODE\nuniform mediump vec4 u_color;out vec4 v_color;uniform float u_emissive_strength;\n#endif\nvoid main() {gl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef LIGHTING_3D_MODE\nv_color=apply_lighting_with_emission_ground(u_color,u_emissive_strength);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),backgroundPattern:Jo('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_pattern_tl;uniform vec2 u_pattern_br;uniform vec2 u_texsize;uniform float u_opacity;uniform float u_emissive_strength;uniform sampler2D u_image;in vec2 v_pos;void main() {vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(u_pattern_tl/u_texsize,u_pattern_br/u_texsize,imagecoord);vec4 out_color=textureLodCustom(u_image,pos,v_pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pattern_size;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_pattern_size,u_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),circle:Jo('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin vec3 v_data;in float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nuniform float u_emissive_strength;void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(\nantialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)\n);vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_apply_premultiplied(out_color,v_fog_pos);\n#endif\nglFragColor=out_color*(v_visibility*opacity_t);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#define NUM_VISIBILITY_RINGS 2\n#define INV_SQRT2 0.70710678\n#define ELEVATION_BIAS 0.0001\n#define NUM_SAMPLES_PER_RING 16\nuniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;in vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nout vec3 v_data;out float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1,-1),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1,-1),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1,1),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1,1),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) {\n#if defined(TERRAIN)\nreturn elevation(pos)+ELEVATION_BIAS;\n#else\nreturn 0.0;\n#endif\n}vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale,mat3 surface_vectors) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale);\n#ifdef PITCH_WITH_MAP\n#ifdef PROJECTION_GLOBE_VIEW\nreturn u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) );\n#else\nreturn u_matrix*( world_center+vec4(sample_offset,0,0) );\n#endif\n#else\nreturn projected_center+vec4(sample_offset,0,0);\n#endif\n}float get_sample_step() {\n#ifdef PITCH_WITH_MAP\nreturn 2.0*PI/float(NUM_SAMPLES_PER_RING);\n#else\nreturn PI/float(NUM_SAMPLES_PER_RING);\n#endif\n}void main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);vec4 world_center;mat3 surface_vectors;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=a_pos_normal_3/16384.0;surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*circle_elevation(circle_center);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*circle_elevation(circle_center);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);world_center=vec4(pos,1);\n#else \nsurface_vectors=mat3(1.0);float height=circle_elevation(circle_center);world_center=vec4(circle_center,height,1);\n#endif\nvec4 projected_center=u_matrix*world_center;float view_scale=0.0;\n#ifdef PITCH_WITH_MAP\n#ifdef SCALE_WITH_MAP\nview_scale=1.0;\n#else\nview_scale=projected_center.w/u_camera_to_center_distance;\n#endif\n#else\n#ifdef SCALE_WITH_MAP\nview_scale=u_camera_to_center_distance;\n#else\nview_scale=projected_center.w;\n#endif\n#endif\ngl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0;\n#ifdef TERRAIN\nfloat step=get_sample_step();vec4 occlusion_world_center;vec4 occlusion_projected_center;\n#ifdef PITCH_WITH_MAP\nfloat cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);occlusion_world_center=vec4(circle_center,cantilevered_height,1);occlusion_projected_center=u_matrix*occlusion_world_center;\n#else\nocclusion_world_center=world_center;occlusion_projected_center=projected_center;\n#endif\nfor(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,surface_vectors);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING);\n#else\nvisibility=1.0;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nvisibility=1.0;\n#endif\nv_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);\n#ifdef FOG\nv_fog_pos=fog_position(world_center.xyz);\n#endif\n}'),clippingMask:Jo("void main() {glFragColor=vec4(1.0);}","in vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:Jo('#include "_prelude_fog.fragment.glsl"\nuniform highp float u_intensity;in vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);glFragColor=vec4(val,1.0,1.0,1.0);\n#ifdef FOG\nif (u_is_globe==0) {glFragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;in vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nout vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 unscaled_extrude=vec2(mod(a_pos,2.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 tilePos=floor(a_pos*0.5);vec3 pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(tilePos)*elevation(tilePos);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#else\npos=vec3(tilePos+extrude,elevation(tilePos));\n#endif\ngl_Position=u_matrix*vec4(pos,1);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),heatmapTexture:Jo("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));glFragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(0.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}","in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=a_pos*0.5+0.5;}"),collisionBox:Jo("in float v_placed;in float v_notUsed;void main() {vec4 red =vec4(1.0,0.0,0.0,1.0);vec4 blue=vec4(0.0,0.0,1.0,0.5);glFragColor =mix(red,blue,step(0.5,v_placed))*0.5;glFragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}",'#include "_prelude_terrain.vertex.glsl"\nin vec3 a_pos;in vec2 a_anchor_pos;in vec2 a_extrude;in vec2 a_placed;in vec2 a_shift;in float a_size_scale;in vec2 a_padding;in float a_z_offset;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;out float v_placed;out float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_pos+elevationVector(a_anchor_pos)*(a_z_offset+elevation(a_anchor_pos)),1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,1.5);gl_Position=projectedPoint;gl_Position.xy+=(a_extrude*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}'),collisionCircle:Jo("in float v_radius;in vec2 v_extrude;in float v_perspective_ratio;in float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);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);glFragColor=color*alpha*opacity_t;}","in vec2 a_pos_2f;in float a_radius;in vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;out float v_radius;out vec2 v_extrude;out float v_perspective_ratio;out float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos_2f;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(\nmix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:Jo("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);glFragColor=mix(u_color,overlay_color,overlay_color.a);}",'#include "_prelude_terrain.vertex.glsl"\nin vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;\n#endif\nout vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {float h=elevation(a_pos);v_uv=a_pos/8192.0;\n#ifdef PROJECTION_GLOBE_VIEW\ngl_Position=u_matrix*vec4(a_pos_3+elevationVector(a_pos)*h,1);\n#else\ngl_Position=u_matrix*vec4(a_pos*u_overlay_scale,h,1);\n#endif\n}'),fill:Jo('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nuniform float u_emissive_strength;void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nvec4 out_color=color;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nin vec2 a_pos;uniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillOutline:Jo('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin highp vec2 v_pos;uniform float u_emissive_strength;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nin vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;out highp vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillOutlinePattern:Jo('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_emissive_strength;in highp vec2 v_pos;in highp vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);float dist=length(v_pos_world-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in vec2 a_pos;out highp vec2 v_pos;out highp vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);v_pos_world=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillPattern:Jo('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;in vec2 v_pos;uniform float u_emissive_strength;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in vec2 a_pos;out vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillExtrusion:Jo('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin vec4 v_color;in vec4 v_flat;\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;\n#endif\nuniform lowp float u_opacity;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;in vec2 v_ao;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nin vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nin highp vec3 v_normal;\n#endif\nuniform vec3 u_flood_light_color;uniform highp float u_vertical_scale;uniform float u_flood_light_intensity;uniform vec3 u_ground_shadow_factor;\n#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)\nin float v_flood_radius;in float v_has_floodlight;\n#endif\nuniform float u_emissive_strength;in float v_height;void main() {\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nvec3 normal=normalize(v_normal);\n#endif\nfloat z;vec4 color=v_color;\n#ifdef ZERO_ROOF_RADIUS\nz=float(normal.z > 0.00001);\n#ifdef LIGHTING_3D_MODE\nnormal=mix(normal,vec3(0.0,0.0,1.0),z);\n#else\ncolor=mix(v_color,v_roof_color,z);\n#endif\n#endif\nfloat h=max(0.0,v_height);float ao_shade=1.0;\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h_floors=h/(u_ao[1]*u_vertical_scale);float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);ao_shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;\n#ifdef ZERO_ROOF_RADIUS\nconcave*=(1.0-z);\n#endif\nfloat x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);ao_shade*=mix(1.0,x_shade*x_shade*x_shade,concave);\n#ifdef LIGHTING_3D_MODE\n#ifdef FLOOD_LIGHT\ncolor.rgb*=mix(ao_shade,1.0,v_has_floodlight);\n#else\ncolor.rgb*=ao_shade;\n#endif\n#else\ncolor.rgb*=ao_shade;\n#endif\n#endif\n#ifdef LIGHTING_3D_MODE\nfloat flood_radiance=0.0;\n#ifdef FLOOD_LIGHT\nflood_radiance=(1.0-min(h/v_flood_radius,1.0))*u_flood_light_intensity*v_has_floodlight;\n#endif\n#ifdef RENDER_SHADOWS\n#ifdef FLOOD_LIGHT\nfloat ndotl_unclamped=dot(normal,u_shadow_direction);float ndotl=max(0.0,ndotl_unclamped);float occlusion=ndotl_unclamped < 0.0 ? 1.0 : shadow_occlusion(ndotl,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);vec3 litColor=apply_lighting(color.rgb,normal,(1.0-u_shadow_intensity*occlusion)*ndotl);vec3 floodLitColor=compute_flood_lighting(u_flood_light_color*u_opacity,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=mix(litColor,floodLitColor,flood_radiance);\n#else\nfloat shadowed_lighting_factor=shadowed_light_factor_normal(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);color.rgb=apply_lighting(color.rgb,normal,shadowed_lighting_factor);\n#endif\n#else\ncolor.rgb=apply_lighting(color.rgb,normal);\n#ifdef FLOOD_LIGHT\ncolor.rgb=mix(color.rgb,u_flood_light_color*u_opacity,flood_radiance);\n#endif\n#endif\ncolor.rgb=mix(color.rgb,v_flat.rgb,u_emissive_strength);color*=u_opacity;\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos,h));\n#endif\n#ifdef INDICATOR_CUTOUT\ncolor=applyCutout(color);\n#endif\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#include "_prelude_lighting.glsl"\nuniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_edge_radius;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\nuniform highp float u_vertical_scale;out vec4 v_color;out vec4 v_flat;\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out float v_depth;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nout vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nout highp vec3 v_normal;\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;out vec2 v_ao;\n#endif\n#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)\nout float v_flood_radius;out float v_has_floodlight;\n#endif\nout float v_height;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define highp float flood_light_wall_radius\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize highp float flood_light_wall_radius\nbase*=u_vertical_scale;height*=u_vertical_scale;vec4 pos_nx=floor(a_pos_normal_ed*0.5);vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nv_normal=normal;\n#endif\nbase=max(0.0,base);float attr_height=height;height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\nfloat ele=0.0;float h=0.0;float c_ele=0.0;vec3 pos;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);pos=vec3(pos_nx.xy,h);\n#else\nh=t > 0.0 ? height : base;pos=vec3(pos_nx.xy,h);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*h);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat cutoff=1.0;vec3 scaled_pos=pos;\n#ifdef RENDER_CUTOFF\nvec3 centroid_random=vec3(centroid_pos.xy,centroid_pos.x+centroid_pos.y+1.0);vec3 ground_pos=centroid_pos.x==0.0 ? pos.xyz : (centroid_random/8.0);vec4 ground=u_matrix*vec4(ground_pos.xy,ele,1.0);cutoff=max(0.01,cutoff_opacity(u_cutoff_params,ground.z));if (centroid_pos.y !=0.0 && centroid_pos.x !=0.0) {vec3 g=floor(ground_pos);vec3 mod_=centroid_random-g*8.0;float seed=min(1.0,0.1*(min(3.5,max(mod_.x+mod_.y,0.2*attr_height))*0.35+mod_.z));if (cutoff < 0.8-seed) {cutoff=0.0;}}float cutoff_scale=cutoff;scaled_pos.z=mix(c_ele,h,cutoff_scale);\n#endif\nfloat hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (cutoff < 0.01 && centroid_pos.x !=0.0));gl_Position=mix(u_matrix*vec4(scaled_pos,1),AWAY,hidden);h=h-ele;v_height=h;\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=pos;vec3 shd_pos1=pos;\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(normal);shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);\n#endif\nfloat NdotL=0.0;float colorvalue=0.0;\n#ifndef LIGHTING_3D_MODE\ncolorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),NdotL);if (normal.y !=0.0) {float r=0.84;r=mix(0.7,0.98,1.0-u_lightintensity);NdotL*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}\n#endif\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec2(mix(concave,-concave,start),y_ground);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\n#ifdef LIGHTING_3D_MODE\n#ifdef FLOOD_LIGHT\nfloat is_wall=1.0-float(t > 0.0 && top_up_ny.y > 0.0);v_has_floodlight=float(flood_light_wall_radius > 0.0 && is_wall > 0.0);v_flood_radius=flood_light_wall_radius*u_vertical_scale;\n#endif\nv_color=vec4(color.rgb,1.0);v_flat=vec4(linearProduct(color.rgb,vec3(calculate_NdotL(normal))),1.0);\n#else\nv_color=vec4(0.0,0.0,0.0,1.0);v_color.rgb+=clamp(color.rgb*NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nfloat roofNdotL=clamp(u_lightpos.z,0.0,1.0);roofNdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),roofNdotL);v_roof_color=vec4(0.0,0.0,0.0,1.0);v_roof_color.rgb+=clamp(color.rgb*roofNdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_roof_color*=u_opacity;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),fillExtrusionDepth:Jo("in highp float v_depth;void main() {\n#ifndef DEPTH_TEXTURE\nglFragColor=pack_depth(v_depth);\n#endif\n}",'#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_edge_radius;uniform float u_vertical_scale;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\nout highp float v_depth;void main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\nbase*=u_vertical_scale;height*=u_vertical_scale;vec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;base=max(0.0,base);height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\nvec3 pos;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base);pos=vec3(pos_nx.xy,h);\n#else\npos=vec3(pos_nx.xy,t > 0.0 ? height : base);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);v_depth=gl_Position.z/gl_Position.w;}'),fillExtrusionPattern:Jo('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;in vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nin vec3 v_normal;\n#endif\nin vec2 v_pos;in vec4 v_lighting;uniform lowp float u_opacity;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define mediump vec4 pattern\n#pragma mapbox: define highp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize highp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color,normalize(v_normal))*u_opacity;\n#else\nout_color=out_color*v_lighting;\n#endif\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);out_color.rgb=out_color.rgb*shade;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_lighting.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform float u_tile_units_to_pixels;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\nout vec2 v_pos;out vec4 v_lighting;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;out vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nout vec3 v_normal;\n#endif\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define mediump vec4 pattern\n#pragma mapbox: define highp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize highp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec4 pos_nx=floor(a_pos_normal_ed*0.5);mediump vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;mediump vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=a_pos_normal_ed.w;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\nfloat ele=0.0;float h=z;vec3 p;float c_ele;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);p=vec3(pos_nx.xy,h);\n#else\np=vec3(pos_nx.xy,z);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);vec2 pos=normal.z==1.0\n? pos_nx.xy\n: vec2(edgedistance,z*u_height_factor);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float NdotL=0.0;\n#ifdef LIGHTING_3D_MODE\nNdotL=calculate_NdotL(normal);\n#else\nNdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),NdotL);\n#endif\nif (normal.y !=0.0) {float r=0.84;\n#ifndef LIGHTING_3D_MODE\nr=mix(0.7,0.98,1.0-u_lightintensity);\n#endif\nNdotL*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\n#ifdef LIGHTING_3D_MODE\nv_normal=normal;\n#else\nv_lighting.rgb+=clamp(NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;\n#endif \n#ifdef FOG\nv_fog_pos=fog_position(p);\n#endif\n}'),groundShadow:Jo('#include "_prelude_shadow.fragment.glsl"\nprecision highp float;uniform vec3 u_ground_shadow_factor;in vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;\n#ifdef FOG\nin float v_fog_opacity;\n#endif\nvoid main() {float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);vec3 shadow=mix(u_ground_shadow_factor,vec3(1.0),light);\n#ifdef RENDER_CUTOFF\nshadow=mix(vec3(1.0),shadow,cutoff_opacity(u_cutoff_params,1.0/gl_FragCoord.w));\n#endif\n#ifdef FOG\nshadow=mix(shadow,vec3(1.0),v_fog_opacity);\n#endif\n#ifdef INDICATOR_CUTOUT\nshadow=mix(shadow,vec3(1.0),1.0-applyCutout(vec4(1.0)).r);\n#endif\nglFragColor=vec4(shadow,1.0);}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;in vec2 a_pos;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1;\n#ifdef FOG\nout float v_fog_opacity;\n#endif\nvoid main() {gl_Position=u_matrix*vec4(a_pos,0.0,1.0);v_pos_light_view_0=u_light_matrix_0*vec4(a_pos,0.0,1.0);v_pos_light_view_1=u_light_matrix_1*vec4(a_pos,0.0,1.0);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);v_fog_opacity=fog(v_fog_pos);\n#endif\n}'),fillExtrusionGroundEffect:Jo("uniform highp float u_ao_pass;uniform highp float u_opacity;uniform highp float u_flood_light_intensity;uniform highp vec3 u_flood_light_color;uniform highp float u_attenuation;uniform sampler2D u_fb;uniform float u_fb_size;\n#ifdef SDF_SUBPASS\nin highp vec2 v_pos;in highp vec4 v_line_segment;in highp float v_flood_light_radius_tile;in highp vec2 v_ao;float line_df(highp vec2 a,highp vec2 b,highp vec2 p) {highp vec2 ba=b-a;highp vec2 pa=p-a;highp float r=clamp(dot(pa,ba)/dot(ba,ba),0.0,1.0);return length(pa-r*ba);}\n#ifdef FOG\nin highp float v_fog;\n#endif\n#endif\nvoid main() {\n#ifdef CLEAR_SUBPASS\nvec4 color=vec4(1.0);\n#ifdef CLEAR_FROM_TEXTURE\ncolor=texture(u_fb,gl_FragCoord.xy/vec2(u_fb_size));\n#endif\nglFragColor=color;\n#else\n#ifdef SDF_SUBPASS\nhighp float d=line_df(v_line_segment.xy,v_line_segment.zw,v_pos);highp float effect_radius=mix(v_flood_light_radius_tile,v_ao.y,u_ao_pass);d/=effect_radius;d=min(d,1.0);d=1.0-pow(1.0-d,u_attenuation);highp float effect_intensity=mix(u_flood_light_intensity,v_ao.x,u_ao_pass);highp float fog=1.0;\n#ifdef FOG\nfog=v_fog;\n#endif\n#ifdef RENDER_CUTOFF\nfog*=v_cutoff_opacity;\n#endif\nglFragColor=vec4(vec3(0.0),mix(1.0,d,effect_intensity*u_opacity*fog));\n#else\nvec4 color=mix(vec4(u_flood_light_color,1.0),vec4(vec3(0.0),1.0),u_ao_pass);\n#ifdef OVERDRAW_INSPECTOR\ncolor=vec4(1.0);\n#endif\nglFragColor=color;\n#endif\nHANDLE_WIREFRAME_DEBUG;\n#endif\n}",'#include "_prelude_fog.vertex.glsl"\nin highp vec4 a_pos_end;in highp float a_angular_offset_factor;in highp float a_hidden_by_landmark;\n#ifdef SDF_SUBPASS\nout highp vec2 v_pos;out highp vec4 v_line_segment;out highp float v_flood_light_radius_tile;out highp vec2 v_ao;\n#ifdef FOG\nout highp float v_fog;\n#endif\n#endif\nuniform highp float u_flood_light_intensity;uniform highp mat4 u_matrix;uniform highp float u_ao_pass;uniform highp float u_meter_to_tile;uniform highp float u_edge_radius;uniform highp vec2 u_ao;\n#pragma mapbox: define highp float flood_light_ground_radius\nconst float TANGENT_CUTOFF=4.0;const float NORM=32767.0;void main() {\n#pragma mapbox: initialize highp float flood_light_ground_radius\nvec2 p=a_pos_end.xy;vec2 q=floor(a_pos_end.zw*0.5);vec2 start_bottom=a_pos_end.zw-q*2.0;float fl_ground_radius=flood_light_ground_radius;fl_ground_radius=abs(flood_light_ground_radius);float direction=flood_light_ground_radius < 0.0 ?-1.0 : 1.0;float flood_radius_tile=fl_ground_radius*u_meter_to_tile;vec2 v=normalize(q-p);float ao_radius=u_ao.y/3.5;float effect_radius=mix(flood_radius_tile,ao_radius,u_ao_pass)+u_edge_radius;float angular_offset_factor=a_angular_offset_factor/NORM*TANGENT_CUTOFF;float angular_offset=direction*angular_offset_factor*effect_radius;float top=1.0-start_bottom.y;float side=(0.5-start_bottom.x)*2.0;vec2 extrusion_parallel=v*side*mix(1.0,angular_offset,top);vec2 perp=vec2(v.y,-v.x);vec2 extrusion_perp=direction*perp*effect_radius*top;vec3 pos=vec3(mix(q,p,start_bottom.x),0.0);pos.xy+=extrusion_parallel+extrusion_perp;\n#ifdef SDF_SUBPASS\nv_pos=pos.xy;v_line_segment=vec4(p,q)+perp.xyxy*u_edge_radius;v_flood_light_radius_tile=flood_radius_tile;v_ao=vec2(u_ao.x,ao_radius);\n#ifdef FOG\nv_fog_pos=fog_position(pos);v_fog=1.0-fog(v_fog_pos);\n#endif\n#endif\nfloat hidden_by_landmark=0.0;\n#ifdef HAS_CENTROID\nhidden_by_landmark=a_hidden_by_landmark;\n#endif\nfloat isFloodlit=float(fl_ground_radius > 0.0 && u_flood_light_intensity > 0.0);float hidden=mix(1.0-isFloodlit,isFloodlit,u_ao_pass);hidden+=hidden_by_landmark;gl_Position=mix(u_matrix*vec4(pos,1.0),AWAY,float(hidden > 0.0));\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n}'),hillshadePrepare:Jo("precision highp float;uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;float getElevation(vec2 coord) {return texture(u_image,coord).r/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y));float b=getElevation(v_pos+vec2(0,-epsilon.y));float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y));float d=getElevation(v_pos+vec2(-epsilon.x,0));float e=getElevation(v_pos+vec2(epsilon.x,0));float f=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float g=getElevation(v_pos+vec2(0,epsilon.y));float h=getElevation(v_pos+vec2(epsilon.x,epsilon.y));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(\n(c+e+e+h)-(a+d+d+f),(f+g+g+h)-(a+b+b+c)\n)/pow(2.0,exaggeration+(19.2562-u_zoom));glFragColor=clamp(vec4(\nderiv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);}","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:Jo('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;uniform float u_emissive_strength;void main() {vec4 pixel=texture(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;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_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);glFragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef LIGHTING_3D_MODE\nglFragColor=apply_lighting_with_emission_ground(glFragColor,u_emissive_strength);\n#endif\n#ifdef FOG\nglFragColor=fog_dither(fog_apply_premultiplied(glFragColor,v_fog_pos));\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;in vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),line:Jo('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec4 v_uv;\n#ifdef RENDER_LINE_DASH\nuniform sampler2D u_dash_image;in vec2 v_tex;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;\n#endif\nfloat luminance(vec3 c) {return (c.r+c.r+c.b+c.g+c.g+c.g)*0.1667;}uniform float u_emissive_strength;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\nfloat linearstep(float edge0,float edge1,float x) {return clamp((x-edge0)/(edge1-edge0),0.0,1.0);}void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);\n#ifdef RENDER_LINE_DASH\nfloat sdfdist=texture(u_dash_image,v_tex).r;float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/dash.z;alpha*=linearstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);\n#endif\nhighp vec4 out_color;\n#ifdef RENDER_LINE_GRADIENT\nout_color=texture(u_gradient_image,v_uv.xy);\n#else\nout_color=color;\n#endif\nfloat trimmed=1.0;\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float start=v_uv[2];highp float end=v_uv[3];highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=(start+(v_uv.x)*(end-start));if (trim_end > trim_start) {if (line_progress <=trim_end && line_progress >=trim_start) {out_color=vec4(0,0,0,0);trimmed=0.0;}}\n#endif\nif (u_alpha_discard_threshold !=0.0) {if (alpha < u_alpha_discard_threshold) {discard;}}\n#ifdef RENDER_LINE_BORDER\nfloat edgeBlur=(border_width+1.0/u_device_pixel_ratio);float alpha2=clamp(min(dist-(v_width2.t-edgeBlur),v_width2.s-dist)/edgeBlur,0.0,1.0);if (alpha2 < 1.) {float smoothAlpha=smoothstep(0.6,1.0,alpha2);if (border_color.a==0.0) { \nfloat Y=(out_color.a > 0.01) ? luminance(out_color.rgb/out_color.a) : 1.;float adjustment=(Y > 0.) ? 0.5/Y : 0.45;if (out_color.a > 0.25 && Y < 0.25) {vec3 borderColor=(Y > 0.) ? out_color.rgb : vec3(1,1,1)*out_color.a;out_color.rgb=out_color.rgb+borderColor*(adjustment*(1.0-smoothAlpha));} else {out_color.rgb*=(0.6 +0.4*smoothAlpha);}} else {out_color.rgb=mix(border_color.rgb*border_color.a*trimmed,out_color.rgb,smoothAlpha);}}\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nout_color*=(alpha*opacity);\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#define EXTRUDE_SCALE 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nin highp vec4 a_packed;\n#endif\n#ifdef RENDER_LINE_DASH\nin float a_linesofar;\n#endif\nuniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;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 vec4 v_uv;\n#ifdef RENDER_LINE_DASH\nuniform vec2 u_texsize;uniform float u_tile_units_to_pixels;out vec2 v_tex;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform float u_image_height;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;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*EXTRUDE_SCALE;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*EXTRUDE_SCALE*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nfloat a_uv_x=a_packed[0];float a_split_index=a_packed[1];highp float a_clip_start=a_packed[2];highp float a_clip_end=a_packed[3];\n#ifdef RENDER_LINE_GRADIENT\nhighp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec4(a_uv_x,a_split_index*texel_height-half_texel_height,a_clip_start,a_clip_end);\n#else\nv_uv=vec4(a_uv_x,0.0,a_clip_start,a_clip_end);\n#endif\n#endif\n#ifdef RENDER_LINE_DASH\nfloat scale=dash.z==0.0 ? 0.0 : u_tile_units_to_pixels/dash.z;float height=dash.y;v_tex=vec2(a_linesofar*scale/floorwidth,(-normal.y*height+dash.x+0.5)/u_texsize.y);\n#endif\nv_width2=vec2(outset,inset);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),linePattern:Jo('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_tile_units_to_pixels;uniform highp vec2 u_trim_offset;uniform sampler2D u_image;in vec2 v_normal;in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;in float v_width;\n#ifdef RENDER_LINE_TRIM_OFFSET\nin highp vec4 v_uv;\n#endif\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;vec2 pattern_size=vec2(display_size.x/u_tile_units_to_pixels,display_size.y);float aspect=display_size.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 pattern_x=v_linesofar/pattern_size.x*aspect;float x=mod(pattern_x,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(x,y));vec2 lod_pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(pattern_x,y));vec4 color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float start=v_uv[2];highp float end=v_uv[3];highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=(start+(v_uv.x)*(end-start));if (trim_end > trim_start) {if (line_progress <=trim_end && line_progress >=trim_start) {color=vec4(0,0,0,0);}}\n#endif\n#ifdef LIGHTING_3D_MODE\ncolor=apply_lighting_ground(color);\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ncolor*=(alpha*opacity);\n#ifdef INDICATOR_CUTOUT\ncolor=applyCutout(color);\n#endif\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;\n#ifdef RENDER_LINE_TRIM_OFFSET\nin highp vec4 a_packed;\n#endif\nin float a_linesofar;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;out float v_width;\n#ifdef RENDER_LINE_TRIM_OFFSET\nout highp vec4 v_uv;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;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);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nfloat a_uv_x=a_packed[0];highp float a_clip_start=a_packed[2];highp float a_clip_end=a_packed[3];v_uv=vec4(a_uv_x,0.0,a_clip_start,a_clip_end);\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),raster:Jo('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_raster_array.glsl"\nuniform float u_fade_t;uniform float u_opacity;uniform highp float u_raster_elevation;uniform highp float u_zoom_transition;in vec2 v_pos0;in vec2 v_pos1;in float v_depth;\n#ifdef PROJECTION_GLOBE_VIEW\nin float v_split_fade;\n#endif\nuniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;uniform float u_emissive_strength;\n#ifndef RASTER_ARRAY\nuniform sampler2D u_image0;uniform sampler2D u_image1;\n#endif\n#ifdef RASTER_COLOR\nuniform sampler2D u_color_ramp;uniform highp vec4 u_colorization_mix;uniform highp float u_colorization_offset;uniform vec2 u_texture_res;\n#endif\nvoid main() {vec4 color0,color1,color;vec2 value;\n#ifdef RASTER_COLOR\n#ifdef RASTER_ARRAY\n#ifdef RASTER_ARRAY_LINEAR\nvalue=mix(\nraTexture2D_image0_linear(v_pos0,u_texture_res,u_colorization_mix,u_colorization_offset),raTexture2D_image1_linear(v_pos1,u_texture_res,u_colorization_mix,u_colorization_offset),u_fade_t\n);\n#else\nvalue=mix(\nraTexture2D_image0_nearest(v_pos0,u_texture_res,u_colorization_mix,u_colorization_offset),raTexture2D_image1_nearest(v_pos1,u_texture_res,u_colorization_mix,u_colorization_offset),u_fade_t\n);\n#endif\nif (value.y > 0.0) value.x/=value.y;\n#else\ncolor=mix(texture(u_image0,v_pos0),texture(u_image1,v_pos1),u_fade_t);value=vec2(u_colorization_offset+dot(color.rgb,u_colorization_mix.rgb),color.a);\n#endif\ncolor=texture(u_color_ramp,vec2(value.x,0.5));if (color.a > 0.0) color.rgb/=color.a;color.a*=value.y;\n#else\ncolor0=texture(u_image0,v_pos0);color1=texture(u_image1,v_pos1);if (color0.a > 0.0) color0.rgb/=color0.a;if (color1.a > 0.0) color1.rgb/=color1.a;color=mix(color0,color1,u_fade_t);\n#endif\ncolor.a*=u_opacity;\n#ifdef GLOBE_POLES\ncolor.a*=1.0-smoothstep(0.0,0.05,u_zoom_transition);\n#endif\nvec3 rgb=color.rgb;rgb=vec3(\ndot(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);vec3 out_color=mix(u_high_vec,u_low_vec,rgb);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),u_emissive_strength).rgb;\n#endif\n#ifdef FOG\nhighp float fog_limit_high_meters=1000000.0;highp float fog_limit_low_meters=600000.0;float fog_limit=1.0-smoothstep(fog_limit_low_meters,fog_limit_high_meters,u_raster_elevation);out_color=fog_dither(fog_apply(out_color,v_fog_pos,fog_limit));\n#endif\nglFragColor=vec4(out_color*color.a,color.a);\n#ifdef PROJECTION_GLOBE_VIEW\nglFragColor*=mix(1.0,1.0-smoothstep(0.0,0.05,u_zoom_transition),smoothstep(0.8,0.9,v_split_fade));\n#endif\n#ifdef RENDER_CUTOFF\nglFragColor=glFragColor*cutoff_opacity(u_cutoff_params,v_depth);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform mat3 u_grid_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;uniform vec2 u_texture_offset;uniform float u_raster_elevation;uniform float u_zoom_transition;uniform vec2 u_merc_center;\n#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8\n#ifdef GLOBE_POLES\nin vec3 a_globe_pos;in vec2 a_uv;\n#else\nin vec2 a_pos;in vec2 a_texture_pos;\n#endif\nout vec2 v_pos0;out vec2 v_pos1;out float v_depth;\n#ifdef PROJECTION_GLOBE_VIEW\nout float v_split_fade;\n#endif\nvoid main() {vec2 uv;\n#ifdef GLOBE_POLES\nvec3 globe_pos=a_globe_pos;globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;gl_Position=u_matrix*u_globe_matrix*vec4(globe_pos ,1.0);uv=a_uv;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(a_globe_pos,1.0)).xyz);\n#endif\n#else\nfloat w=1.0+dot(a_texture_pos,u_perspective_transform);uv=a_texture_pos/8192.0;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);vec3 globe_pos=latLngToECEF(latLng.xy);globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);float mercatorY=mercatorYfromLat(latLng[0]);float mercatorX=mercatorXfromLng(latLng[1]); \nv_split_fade=0.0;if (u_zoom_transition > 0.0) {vec2 merc_pos=vec2(mercatorX,mercatorY);merc_world_pos=vec4(merc_pos,u_raster_elevation,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;float opposite_merc_center=mod(u_merc_center.x+0.5,1.0);float dist_from_poles=(abs(mercatorY-0.5)*2.0);float range=0.1;v_split_fade=abs(opposite_merc_center-mercatorX);v_split_fade=clamp(1.0-v_split_fade,0.0,1.0);v_split_fade=max(smoothstep(1.0-range,1.0,dist_from_poles),max(smoothstep(1.0-range,1.0,v_split_fade),smoothstep(1.0-range,1.0,1.0-v_split_fade)));}float tiles=u_grid_matrix[0][2];if (tiles > 0.0) {float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];float uvY=mercatorY*tiles-idy;float uvX=mercatorX*tiles-idx;uv=vec2(uvX,uvY);}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition)*w,w);gl_Position=u_matrix*interpolated_pos;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n#else\ngl_Position=u_matrix*vec4(a_pos*w,u_raster_elevation*w,w);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n#endif\n#endif\nv_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;v_pos0=u_texture_offset.x+u_texture_offset.y*v_pos0;v_pos1=u_texture_offset.x+u_texture_offset.y*v_pos1;\n#ifdef RENDER_CUTOFF\nv_depth=gl_Position.z;\n#endif\n}'),rasterParticle:Jo('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform float u_fade_t;uniform float u_opacity;uniform highp float u_raster_elevation;in vec2 v_pos0;in vec2 v_pos1;uniform sampler2D u_image0;uniform sampler2D u_image1;void main() {vec4 color0,color1,color;color0=texture(u_image0,v_pos0);color1=texture(u_image1,v_pos1);if (color0.a > 0.0) color0.rgb/=color0.a;if (color1.a > 0.0) color1.rgb/=color1.a;color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 out_color=color.rgb;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),0.0).rgb;\n#endif\n#ifdef FOG\nhighp float fog_limit_high_meters=1000000.0;highp float fog_limit_low_meters=600000.0;float fog_limit=1.0-smoothstep(fog_limit_low_meters,fog_limit_high_meters,u_raster_elevation);out_color=fog_dither(fog_apply(out_color,v_fog_pos,fog_limit));\n#endif\nglFragColor=vec4(out_color*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform mat3 u_grid_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_raster_elevation;uniform float u_zoom_transition;uniform vec2 u_merc_center;\n#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8\nin vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {float w=1.0;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float mercatorX=mercatorXfromLng(latLng[1]);float tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];float uvX=mercatorX*tiles-idx;float uvY=mercatorY*tiles-idy;vec2 uv=vec2(uvX,uvY);vec3 globe_pos=latLngToECEF(latLng.xy);globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {vec2 merc_pos=vec2(mercatorX,mercatorY);merc_world_pos=vec4(merc_pos,u_raster_elevation,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition)*w,w);gl_Position=u_matrix*interpolated_pos;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n#else\nvec2 uv=a_texture_pos/8192.0;gl_Position=u_matrix*vec4(a_pos*w,u_raster_elevation*w,w);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n#endif\nv_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}'),rasterParticleDraw:Jo("precision highp float;uniform sampler2D u_color_ramp;in float v_particle_speed;void main() {glFragColor=texture(u_color_ramp,vec2(v_particle_speed,0.5));}",'precision highp float;\n#include "_prelude_raster_array.glsl"\n#include "_prelude_raster_particle.glsl"\nin vec3 a_pos;uniform vec2 u_tile_offset;out float v_particle_speed;void main() {vec2 pos=a_pos.xy+u_tile_offset;vec2 tex_coords=fract(pos);gl_PointSize=1.0;vec2 velocity=lookup_velocity(tex_coords);if (velocity==INVALID_VELOCITY) {v_particle_speed=0.0;gl_Position=vec4(2.0,2.0,2.0,1.0);} else {v_particle_speed=length(velocity);gl_Position=vec4(2.0*pos-vec2(1.0),0.0,1.0);}}'),rasterParticleTexture:Jo("uniform sampler2D u_texture;uniform float u_opacity;in vec2 v_tex_pos;void main() {vec4 color=texture(u_texture,v_tex_pos);glFragColor=vec4(floor(255.0*color*u_opacity)/255.0);}","in vec2 a_pos;out vec2 v_tex_pos;void main() {v_tex_pos=0.5*a_pos+vec2(0.5);gl_Position=vec4(a_pos,0.0,1.0);}"),rasterParticleUpdate:Jo("void main() {}",'#include "_prelude_raster_array.glsl"\n#include "_prelude_raster_particle.glsl"\nin vec3 a_pos;uniform float u_speed_factor;uniform float u_lifetime_delta;uniform float u_rand_seed;out vec3 v_new_particle;const vec3 rand_constants=vec3(12.9898,78.233,4375.85453);float rand(const vec2 co) {float t=dot(rand_constants.xy,co);return fract(sin(t)*(rand_constants.z+t));}void main() {float lifetime=a_pos.z;vec2 pos=a_pos.xy;vec2 uv=clamp(pos,vec2(0.0),vec2(1.0));vec2 velocity=lookup_velocity(uv);float next_lifetime=lifetime-u_lifetime_delta;float t=step(0.0,next_lifetime);\n#ifdef DATA_FORMAT_UINT32\nvec2 dp=vec2(0);\n#else\nvec2 dp=velocity==INVALID_VELOCITY ? vec2(0) : velocity*u_speed_factor;\n#endif\nvec2 seed=pos*u_rand_seed;vec2 next_pos=pos+dp;vec2 random_pos=vec2(rand(seed+1.3),rand(seed+2.1));v_new_particle=vec3(\nvec2(mix(random_pos,next_pos,t)),mix(1.0,next_lifetime,t)\n);}'),symbolIcon:Jo('#include "_prelude_lighting.glsl"\nuniform sampler2D u_texture;\n#ifdef ICON_TRANSITION\nuniform float u_icon_transition;\n#endif\nin float v_fade_opacity;in vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nin vec2 v_tex_b;\n#endif\nuniform mediump float u_icon_saturation;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float emissive_strength\nlowp float alpha=opacity*v_fade_opacity;vec4 out_color;\n#ifdef ICON_TRANSITION\nvec4 a=texture(u_texture,v_tex_a)*(1.0-u_icon_transition);vec4 b=texture(u_texture,v_tex_b)*u_icon_transition;out_color=(a+b)*alpha;\n#else\nout_color=texture(u_texture,v_tex_a)*alpha;\n#endif\n#ifdef SATURATION\nvec3 luma=vec3(dot(out_color.rgb,vec3(0.2126,0.7152,0.0722)));out_color.rgb=mix(luma,out_color.rgb,u_icon_saturation);\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\nin vec4 a_pos_offset;in vec4 a_tex_size;in vec4 a_pixeloffset;in vec4 a_projected_pos;in float a_fade_opacity;\n#ifdef Z_OFFSET\nin float a_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_globe_anchor;in vec3 a_globe_normal;\n#endif\n#ifdef ICON_TRANSITION\nin vec2 a_texb;\n#endif\nuniform 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 bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;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 vec3 u_up_vector;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nout vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nout vec2 v_tex_b;\n#endif\nout float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float emissive_strength\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_min_font_scale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[3];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 tile_anchor=a_pos;float e=elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjected_point;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetProjected_point=u_matrix*vec4(a_globe_anchor+displacement,1);\n#else\noffsetProjected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);\n#endif\nvec2 a=projected_point.xy/projected_point.w;vec2 b=offsetProjected_point.xy/offsetProjected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp 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);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_min_font_scale,font_scale)+a_pxoffset/16.0);\n#ifdef TERRAIN\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nvec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float out_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change))*projection_transition_fade;float alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,hidden);\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,hidden);\n#endif\nv_tex_a=a_tex/u_texsize;\n#ifdef ICON_TRANSITION\nv_tex_b=a_texb/u_texsize;\n#endif\nv_fade_opacity=out_fade_opacity;}'),symbolSDF:Jo('#include "_prelude_lighting.glsl"\n#define SDF_PX 8.0\nuniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;uniform bool u_is_halo;in float v_draw_halo;in vec2 v_data0;in vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\n#pragma mapbox: initialize lowp float emissive_strength\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float 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 buff=(256.0-64.0)/256.0;bool draw_halo=v_draw_halo > 0.0;if (draw_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).r;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);vec4 out_color=color*(alpha*opacity*fade_opacity);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\nin vec4 a_pos_offset;in vec4 a_tex_size;in vec4 a_pixeloffset;in vec4 a_projected_pos;in float a_fade_opacity;\n#ifdef Z_OFFSET\nin float a_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_globe_anchor;in vec3 a_globe_normal;\n#endif\nuniform 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_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;uniform bool u_is_halo;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nout float v_draw_halo;out vec2 v_data0;out vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\n#pragma mapbox: initialize lowp float emissive_strength\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;highp float segment_angle=-a_projected_pos[3];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 tile_anchor=a_pos;float e=elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetprojected_point;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetprojected_point=u_matrix*vec4(a_globe_anchor+displacement,1);\n#else\noffsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);\n#endif\nvec2 a=projected_point.xy/projected_point.w;vec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp 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);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset);\n#ifdef TERRAIN\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nvec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));float out_fade_opacity=interpolated_fade_opacity*projection_transition_fade;float alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,hidden);\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,hidden);\n#endif\nfloat gamma_scale=gl_Position.w;v_draw_halo=(u_is_halo && float(gl_InstanceID)==0.0) ? 1.0 : 0.0;v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,out_fade_opacity);}'),symbolTextAndIcon:Jo('#include "_prelude_lighting.glsl"\n#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_halo;in float v_draw_halo;in vec4 v_data0;in vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\n#pragma mapbox: initialize lowp float emissive_strength\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;glFragColor=texture(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;bool draw_halo=v_draw_halo > 0.0;if (draw_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).r;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);vec4 out_color=color*(alpha*opacity*fade_opacity);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\nin vec4 a_pos_offset;in vec4 a_tex_size;in vec4 a_projected_pos;in float a_fade_opacity;\n#ifdef Z_OFFSET\nin float a_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_globe_anchor;in vec3 a_globe_normal;\n#endif\nuniform 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_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;uniform vec2 u_texsize_icon;uniform bool u_is_halo;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nout float v_draw_halo;out vec4 v_data0;out vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\n#pragma mapbox: initialize lowp float emissive_strength\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;highp float segment_angle=-a_projected_pos[3];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 tile_anchor=a_pos;float e=elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offset_projected_point=u_matrix*vec4(a_pos+vec2(1,0),0,1);vec2 a=projected_point.xy/projected_point.w;vec2 b=offset_projected_point.xy/offset_projected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp 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);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*font_scale);\n#ifdef TERRAIN\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nfloat out_fade_opacity=interpolated_fade_opacity*projection_transition_fade;float alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,hidden);\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,hidden);\n#endif\nfloat gamma_scale=gl_Position.w;v_draw_halo=(u_is_halo && float(gl_InstanceID)==0.0) ? 1.0 : 0.0;v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,out_fade_opacity,is_sdf);}'),terrainRaster:Jo('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image0;in vec2 v_pos0;\n#ifdef FOG\nin float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nin vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;\n#endif\nuniform vec3 u_ground_shadow_factor;void main() {vec4 image_color=texture(u_image0,v_pos0);vec4 color;\n#ifdef LIGHTING_3D_MODE\nconst vec3 normal=vec3(0.0,0.0,1.0);\n#ifdef RENDER_SHADOWS\nfloat cutoffOpacity=1.0;\n#ifdef RENDER_CUTOFF\ncutoffOpacity=cutoff_opacity(u_cutoff_params,1.0/gl_FragCoord.w);\n#endif\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nvec3 unlit_base=image_color.rgb*(1.0-image_color.a);vec3 emissive_base=image_color.rgb*image_color.a;float ndotl=u_shadow_direction.z;float occlusion=ndotl < 0.0 ? 1.0 : shadow_occlusion(v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,0.0);ndotl=max(0.0,ndotl);vec3 lit=apply_lighting(unlit_base,normal,mix(1.0,(1.0-(u_shadow_intensity*occlusion))*ndotl,cutoffOpacity));vec3 emissive=compute_emissive_draped(emissive_base,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=lit+emissive;color.a=1.0;\n#else\nfloat lighting_factor=shadowed_light_factor_normal_unbiased(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);color=apply_lighting(image_color,normal,mix(1.0,lighting_factor,cutoffOpacity));\n#endif\n#else\nfloat lighting_factor=u_lighting_directional_dir.z;color=apply_lighting(image_color,normal,lighting_factor);\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\ncolor.rgb=mix(color.rgb,image_color.rgb,image_color.a);color.a=1.0;\n#endif\n#endif\n#else\ncolor=image_color;\n#endif\n#ifdef FOG\n#ifdef ZERO_EXAGGERATION\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#else\ncolor=fog_dither(fog_apply_from_vert(color,v_fog_opacity));\n#endif\n#endif\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_skirt_height;in vec2 a_pos;out vec2 v_pos0;\n#ifdef FOG\nout float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1;out float v_depth;\n#endif\nvoid main() {vec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;vec2 decodedPos=decomposedPosAndSkirt.xy;float elevation=elevation(decodedPos)-skirt*u_skirt_height;v_pos0=decodedPos/8192.0;gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);\n#ifdef FOG\n#ifdef ZERO_EXAGGERATION\nv_fog_pos=fog_position(decodedPos);\n#else\nv_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));\n#endif\n#endif\n#ifdef RENDER_SHADOWS\nvec3 pos=vec3(decodedPos,elevation);v_pos_light_view_0=u_light_matrix_0*vec4(pos,1.);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1.);\n#endif\n}'),terrainDepth:Jo("precision highp float;in float v_depth;void main() {glFragColor=pack_depth(v_depth);}",'#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;in vec2 a_pos;out float v_depth;void main() {float elevation=elevation(a_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}'),skybox:Jo('#include "_prelude_fog.fragment.glsl"\nin lowp vec3 v_uv;uniform lowp samplerCube u_cubemap;uniform lowp float u_opacity;uniform highp float u_temporal_offset;uniform highp vec3 u_sun_direction;float sun_disk(highp vec3 ray_direction,highp vec3 sun_direction) {highp float cos_angle=dot(normalize(ray_direction),sun_direction);const highp float cos_sun_angular_diameter=0.99996192306;const highp float smoothstep_delta=1e-5;return smoothstep(\ncos_sun_angular_diameter-smoothstep_delta,cos_sun_angular_diameter+smoothstep_delta,cos_angle);}float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec3 uv=v_uv;const float y_bias=0.015;uv.y+=y_bias;uv.y=pow(abs(uv.y),1.0/5.0);uv.y=map(uv.y,0.0,1.0,-1.0,1.0);vec3 sky_color=texture(u_cubemap,uv).rgb;\n#ifdef FOG\nsky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color);\n#endif\nsky_color.rgb=dither(sky_color.rgb,gl_FragCoord.xy+u_temporal_offset);sky_color+=0.1*sun_disk(v_uv,u_sun_direction);glFragColor=vec4(sky_color*u_opacity,u_opacity);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}',Bo),skyboxGradient:Jo('#include "_prelude_fog.fragment.glsl"\nin highp vec3 v_uv;uniform lowp sampler2D u_color_ramp;uniform highp vec3 u_center_direction;uniform lowp float u_radius;uniform lowp float u_opacity;uniform highp float u_temporal_offset;void main() {float progress=acos(dot(normalize(v_uv),u_center_direction))/u_radius;vec4 color=texture(u_color_ramp,vec2(progress,0.5));\n#ifdef FOG\ncolor.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a;\n#endif\ncolor*=u_opacity;color.rgb=dither(color.rgb,gl_FragCoord.xy+u_temporal_offset);glFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}',Bo),skyboxCapture:Jo("\nin highp vec3 v_position;uniform highp float u_sun_intensity;uniform highp float u_luminance;uniform lowp vec3 u_sun_direction;uniform highp vec4 u_color_tint_r;uniform highp vec4 u_color_tint_m;precision highp float;\n#define BETA_R vec3(5.5e-6,13.0e-6,22.4e-6)\n#define BETA_M vec3(21e-6,21e-6,21e-6)\n#define MIE_G 0.76\n#define DENSITY_HEIGHT_SCALE_R 8000.0\n#define DENSITY_HEIGHT_SCALE_M 1200.0\n#define PLANET_RADIUS 6360e3\n#define ATMOSPHERE_RADIUS 6420e3\n#define SAMPLE_STEPS 10\n#define DENSITY_STEPS 4\nfloat ray_sphere_exit(vec3 orig,vec3 dir,float radius) {float a=dot(dir,dir);float b=2.0*dot(dir,orig);float c=dot(orig,orig)-radius*radius;float d=sqrt(b*b-4.0*a*c);return (-b+d)/(2.0*a);}vec3 extinction(vec2 density) {return exp(-vec3(BETA_R*u_color_tint_r.a*density.x+BETA_M*u_color_tint_m.a*density.y));}vec2 local_density(vec3 point) {float height=max(length(point)-PLANET_RADIUS,0.0);float exp_r=exp(-height/DENSITY_HEIGHT_SCALE_R);float exp_m=exp(-height/DENSITY_HEIGHT_SCALE_M);return vec2(exp_r,exp_m);}float phase_ray(float cos_angle) {return (3.0/(16.0*PI))*(1.0+cos_angle*cos_angle);}float phase_mie(float cos_angle) {return (3.0/(8.0*PI))*((1.0-MIE_G*MIE_G)*(1.0+cos_angle*cos_angle))/((2.0+MIE_G*MIE_G)*pow(1.0+MIE_G*MIE_G-2.0*MIE_G*cos_angle,1.5));}vec2 density_to_atmosphere(vec3 point,vec3 light_dir) {float ray_len=ray_sphere_exit(point,light_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(DENSITY_STEPS);vec2 density_point_to_atmosphere=vec2(0.0);for (int i=0; i < DENSITY_STEPS;++i) {vec3 point_on_ray=point+light_dir*((float(i)+0.5)*step_len);density_point_to_atmosphere+=local_density(point_on_ray)*step_len;;}return density_point_to_atmosphere;}vec3 atmosphere(vec3 ray_dir,vec3 sun_direction,float sun_intensity) {vec2 density_orig_to_point=vec2(0.0);vec3 scatter_r=vec3(0.0);vec3 scatter_m=vec3(0.0);vec3 origin=vec3(0.0,PLANET_RADIUS,0.0);float ray_len=ray_sphere_exit(origin,ray_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(SAMPLE_STEPS);for (int i=0; i < SAMPLE_STEPS;++i) {vec3 point_on_ray=origin+ray_dir*((float(i)+0.5)*step_len);vec2 density=local_density(point_on_ray)*step_len;density_orig_to_point+=density;vec2 density_point_to_atmosphere=density_to_atmosphere(point_on_ray,sun_direction);vec2 density_orig_to_atmosphere=density_orig_to_point+density_point_to_atmosphere;vec3 extinction=extinction(density_orig_to_atmosphere);scatter_r+=density.x*extinction;scatter_m+=density.y*extinction;}float cos_angle=dot(ray_dir,sun_direction);float phase_r=phase_ray(cos_angle);float phase_m=phase_mie(cos_angle);vec3 beta_r=BETA_R*u_color_tint_r.rgb*u_color_tint_r.a;vec3 beta_m=BETA_M*u_color_tint_m.rgb*u_color_tint_m.a;return (scatter_r*phase_r*beta_r+scatter_m*phase_m*beta_m)*sun_intensity;}const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;vec3 uncharted2_tonemap(vec3 x) {return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}void main() {vec3 ray_direction=v_position;ray_direction.y=pow(ray_direction.y,5.0);const float y_bias=0.015;ray_direction.y+=y_bias;vec3 color=atmosphere(normalize(ray_direction),u_sun_direction,u_sun_intensity);float white_scale=1.0748724675633854;color=uncharted2_tonemap((log2(2.0/pow(u_luminance,4.0)))*color)*white_scale;glFragColor=vec4(color,1.0);}","in highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;out highp vec3 v_position;float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec4 pos=vec4(u_matrix_3f*a_pos_3f,1.0);v_position=pos.xyz;v_position.y*=-1.0;v_position.y=map(v_position.y,-1.0,1.0,0.0,1.0);gl_Position=vec4(a_pos_3f.xy,0.0,1.0);}"),globeRaster:Jo('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image0;uniform float u_far_z_cutoff;in vec2 v_pos0;\n#ifndef FOG\nuniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform vec2 u_viewport;\n#endif\nvoid main() {vec4 color;\n#ifdef CUSTOM_ANTIALIASING\nvec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);vec3 dir=normalize(ray_dir);vec3 closest_point=dot(u_globe_pos,dir)*dir;float norm_dist_from_center=1.0-length(closest_point-u_globe_pos)/u_globe_radius;const float antialias_pixel=2.0;float antialias_factor=antialias_pixel*fwidth(norm_dist_from_center);float antialias=smoothstep(0.0,antialias_factor,norm_dist_from_center);vec4 raster=texture(u_image0,v_pos0);\n#ifdef LIGHTING_3D_MODE\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nraster=apply_lighting_with_emission_ground(raster,raster.a);color=vec4(raster.rgb*antialias,antialias);\n#else\nraster=apply_lighting_ground(raster);color=vec4(raster.rgb*antialias,raster.a*antialias);\n#endif\n#else\ncolor=vec4(raster.rgb*antialias,raster.a*antialias);\n#endif\n#else\ncolor=texture(u_image0,v_pos0);\n#ifdef LIGHTING_3D_MODE\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\ncolor=apply_lighting_with_emission_ground(color,color.a);color.a=1.0;\n#else\ncolor=apply_lighting_ground(color);\n#endif\n#endif\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ncolor*=1.0-step(u_far_z_cutoff,1.0/gl_FragCoord.w);glFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_proj_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;uniform mat3 u_grid_matrix;uniform float u_skirt_height;\n#ifdef GLOBE_POLES\nin vec3 a_globe_pos;in vec2 a_uv;\n#else\nin vec2 a_pos;\n#endif\nout vec2 v_pos0;void main() {\n#ifdef GLOBE_POLES\nvec3 globe_pos=a_globe_pos;vec2 uv=a_uv;\n#else\nfloat tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=mercatorX*tiles-idx;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY);\n#endif\nv_pos0=uv;vec2 tile_pos=uv*EXTENT;vec3 globe_derived_up_vector=normalize(globe_pos)*u_tile_up_scale;\n#ifdef GLOBE_POLES\nvec3 up_vector=globe_derived_up_vector;\n#else\nvec3 up_vector=elevationVector(tile_pos);\n#endif\nfloat height=elevation(tile_pos);globe_pos+=up_vector*height;\n#ifndef GLOBE_POLES\nglobe_pos-=globe_derived_up_vector*u_skirt_height*decomposed_pos_and_skirt.z;\n#endif\n#ifdef GLOBE_POLES\nvec4 interpolated_pos=u_globe_matrix*vec4(globe_pos,1.0);\n#else\nvec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {merc_world_pos=vec4(merc_pos,height-u_skirt_height*decomposed_pos_and_skirt.z,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0);\n#endif\ngl_Position=u_proj_matrix*interpolated_pos;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n}'),globeAtmosphere:Jo('#include "_prelude_fog.fragment.glsl"\nuniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec4 u_color;uniform vec4 u_high_color;uniform vec4 u_space_color;uniform float u_horizon_angle;in highp vec3 v_ray_dir;in highp vec3 v_horizon_dir;void main() {highp vec3 dir=normalize(v_ray_dir);float globe_pos_dot_dir;\n#ifdef PROJECTION_GLOBE_VIEW\nglobe_pos_dot_dir=dot(u_globe_pos,dir);highp vec3 closest_point_forward=abs(globe_pos_dot_dir)*dir;float norm_dist_from_center=length(closest_point_forward-u_globe_pos)/u_globe_radius;if (norm_dist_from_center < 0.98) {\n#ifdef ALPHA_PASS\nglFragColor=vec4(0,0,0,0);return;\n#else\n#ifdef NATIVE\nglFragColor=vec4(1,1,1,1);\n#else\nglFragColor=vec4(0,0,0,1);\n#endif\nreturn;\n#endif\n}\n#endif\nhighp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ?\n0.0 : max(acos(clamp(dot(dir,horizon_dir),-1.0,1.0)),0.0);float horizon_angle;\n#ifdef PROJECTION_GLOBE_VIEW\nhighp vec3 closest_point=globe_pos_dot_dir*dir;highp float closest_point_to_center=length(closest_point-u_globe_pos);highp float theta=asin(clamp(closest_point_to_center/length(u_globe_pos),-1.0,1.0));horizon_angle=globe_pos_dot_dir < 0.0 ?\nPI-theta-u_horizon_angle : theta-u_horizon_angle;float angle_t=pow(u_transition,10.0);horizon_angle=mix(horizon_angle,horizon_angle_mercator,angle_t);\n#else\nhorizon_angle=horizon_angle_mercator;\n#endif\nhorizon_angle/=PI;float t=exp(-horizon_angle/u_fadeout_range);float alpha_0=u_color.a;float alpha_1=u_high_color.a;float alpha_2=u_space_color.a;vec3 color_stop_0=u_color.rgb;vec3 color_stop_1=u_high_color.rgb;vec3 color_stop_2=u_space_color.rgb;\n#ifdef ALPHA_PASS\nfloat a0=mix(alpha_2,1.0,alpha_1);float a1=mix(a0,1.0,alpha_0);float a2=mix(a0,a1,t);float a =mix(alpha_2,a2,t);glFragColor=vec4(1.0,1.0,1.0,a);\n#else\nvec3 c0=mix(color_stop_2,color_stop_1,alpha_1);vec3 c1=mix(c0,color_stop_0,alpha_0);vec3 c2=mix(c0,c1,t);vec3 c=c2;\n#ifndef NATIVE\nc=dither(c,gl_FragCoord.xy+u_temporal_offset);\n#endif\nglFragColor=vec4(c*t,t);\n#endif\n}',"in vec3 a_pos;in vec2 a_uv;uniform vec3 u_frustum_tl;uniform vec3 u_frustum_tr;uniform vec3 u_frustum_br;uniform vec3 u_frustum_bl;uniform float u_horizon;out highp vec3 v_ray_dir;out highp vec3 v_horizon_dir;void main() {v_ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,a_uv.x),mix(u_frustum_bl,u_frustum_br,a_uv.x),a_uv.y);v_horizon_dir=mix(\nmix(u_frustum_tl,u_frustum_bl,u_horizon),mix(u_frustum_tr,u_frustum_br,u_horizon),a_uv.x);gl_Position=vec4(a_pos,1.0);}"),model:Jo('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform float u_opacity;uniform vec3 u_lightcolor;uniform vec3 u_lightpos;uniform float u_lightintensity;uniform vec4 u_baseColorFactor;uniform vec4 u_emissiveFactor;uniform float u_metallicFactor;uniform float u_roughnessFactor;uniform float u_emissive_strength;in highp vec4 v_position_height;in lowp vec4 v_color_mix;\n#ifdef RENDER_SHADOWS\nin vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;in float v_depth_shadows;\n#endif\n#ifdef OCCLUSION_TEXTURE_TRANSFORM\nuniform vec4 u_occlusionTextureTransform;\n#endif\n#pragma mapbox: define-attribute highp vec3 normal_3f\n#pragma mapbox: define-attribute highp vec3 color_3f\n#pragma mapbox: define-attribute highp vec4 color_4f\n#pragma mapbox: define-attribute highp vec2 uv_2f\n#pragma mapbox: initialize-attribute highp vec3 normal_3f\n#pragma mapbox: initialize-attribute highp vec3 color_3f\n#pragma mapbox: initialize-attribute highp vec4 color_4f\n#pragma mapbox: initialize-attribute highp vec2 uv_2f\n#ifdef HAS_ATTRIBUTE_a_pbr\nin lowp vec4 v_roughness_metallic_emissive_alpha;in mediump vec4 v_height_based_emission_params;\n#endif\n#ifdef HAS_TEXTURE_u_baseColorTexture\nuniform sampler2D u_baseColorTexture;uniform bool u_baseTextureIsAlpha;uniform bool u_alphaMask;uniform float u_alphaCutoff;\n#endif\n#ifdef HAS_TEXTURE_u_metallicRoughnessTexture\nuniform sampler2D u_metallicRoughnessTexture;\n#endif\n#ifdef HAS_TEXTURE_u_occlusionTexture\nuniform sampler2D u_occlusionTexture;uniform float u_aoIntensity;\n#endif\n#ifdef HAS_TEXTURE_u_normalTexture\nuniform sampler2D u_normalTexture;\n#endif\n#ifdef HAS_TEXTURE_u_emissionTexture\nuniform sampler2D u_emissionTexture;\n#endif\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nin highp float v_depth;uniform sampler2D u_depthTexture;uniform vec2 u_inv_depth_size;bool isOccluded() {vec2 coord=gl_FragCoord.xy*u_inv_depth_size;highp float depth=unpack_depth(texture(u_depthTexture,coord));return v_depth > depth+0.0005;}\n#endif\n#define saturate(_x) clamp(_x,0.,1.)\nvec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}float calculate_NdotL(vec3 normal,vec3 lightDir) {const float ext=0.70710678118;return (clamp(dot(normal,lightDir),-ext,1.0)+ext)/(1.0+ext);}vec3 getDiffuseShadedColor(vec3 albedo,vec3 normal,vec3 lightDir,vec3 lightColor)\n{\n#ifdef LIGHTING_3D_MODE\nvec3 transformed_normal=vec3(-normal.xy,normal.z);float lighting_factor;\n#ifdef RENDER_SHADOWS\nlighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);\n#else\nlighting_factor=saturate(dot(transformed_normal,u_lighting_directional_dir));\n#endif\nreturn apply_lighting(albedo,transformed_normal,lighting_factor);\n#else\nvec3 n=normal;float colorvalue=((albedo.x*0.2126)+(albedo.y*0.7152))+(albedo.z*0.0722);vec3 c=vec3(0.03,0.03,0.03);float directional=clamp(dot(n,vec3(lightDir)),0.0,1.0);directional=mix(1.0-u_lightintensity,max((1.0-colorvalue)+u_lightintensity,1.0),directional);vec3 c3=c+clamp((albedo*directional)*lightColor,mix(vec3(0.0),vec3(0.3),vec3(1.0)-lightColor),vec3(1.0));return c3;\n#endif\n}vec4 getBaseColor() {vec4 albedo=u_baseColorFactor;\n#ifdef HAS_ATTRIBUTE_a_color_3f\nalbedo*=vec4(color_3f,1.0);\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\n#else\n#ifdef HAS_ATTRIBUTE_a_color_4f\nalbedo*=color_4f;\n#endif\n#endif\n#if defined (HAS_TEXTURE_u_baseColorTexture) && defined (HAS_ATTRIBUTE_a_uv_2f)\nvec4 texColor=texture(u_baseColorTexture,uv_2f);if(u_alphaMask) {if (texColor.w < u_alphaCutoff) {discard;}}\n#ifdef UNPREMULT_TEXTURE_IN_SHADER\nif(texColor.w > 0.0) {texColor.rgb/=texColor.w;}texColor.w=1.0;\n#endif\nif(u_baseTextureIsAlpha) {if (texColor.r < 0.5) {discard;}} else {texColor.rgb=sRGBToLinear(texColor.rgb);albedo*=texColor;}\n#endif\nreturn vec4(mix(albedo.rgb,v_color_mix.rgb,v_color_mix.a),albedo.a);}highp mat3 cotangentFrame(highp vec3 N,highp vec3 p,highp vec2 uv ) {\n#ifdef HAS_TEXTURE_u_normalTexture\nhighp vec3 dp1=vec3(dFdx(p.x),dFdx(p.y),dFdx(p.z));highp vec3 dp2=vec3(dFdy(p.x),dFdy(p.y),dFdy(p.z));highp vec2 duv1=vec2(dFdx(uv.x),dFdx(uv.y));highp vec2 duv2=vec2(dFdy(uv.x),dFdy(uv.y));highp vec3 dp2perp=cross( dp2,N );highp vec3 dp1perp=cross( N,dp1 );highp vec3 T=dp2perp*duv1.x+dp1perp*duv2.x;highp vec3 B=dp2perp*duv1.y+dp1perp*duv2.y;highp float lengthT=dot(T,T);highp float lengthB=dot(B,B);highp float maxLength=max(lengthT,lengthB);highp float invmax=inversesqrt( maxLength );highp mat3 res=mat3( T*invmax,B*invmax,N );return res;\n#else\nreturn mat3(1.0);\n#endif\n}highp vec3 getNormal(){highp vec3 n;\n#ifdef HAS_ATTRIBUTE_a_normal_3f\nn=normalize(normal_3f);\n#else\nhighp vec3 fdx=vec3(dFdx(v_position_height.x),dFdx(v_position_height.y),dFdx(v_position_height.z));highp vec3 fdy=vec3(dFdy(v_position_height.x),dFdy(v_position_height.y),dFdy(v_position_height.z));n=normalize(cross(fdx,fdy))*-1.0;\n#endif\n#if defined(HAS_TEXTURE_u_normalTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\nvec3 nMap=texture( u_normalTexture,uv_2f).xyz;nMap=normalize(2.0*nMap-vec3(1.0));highp vec3 v=normalize(-v_position_height.xyz);highp mat3 TBN=cotangentFrame(n,v,uv_2f);n=normalize(TBN*nMap);\n#endif\nreturn n;}struct Material {float perceptualRoughness;float alphaRoughness;float metallic;vec3 f90;vec4 baseColor;vec3 diffuseColor;vec3 specularColor;highp vec3 normal;};Material getPBRMaterial() {Material mat;mat.baseColor=getBaseColor();mat.perceptualRoughness=u_roughnessFactor;mat.metallic=u_metallicFactor;\n#ifdef HAS_ATTRIBUTE_a_pbr\nmat.perceptualRoughness=v_roughness_metallic_emissive_alpha.x;mat.metallic=v_roughness_metallic_emissive_alpha.y;mat.baseColor.w*=v_roughness_metallic_emissive_alpha.w;\n#endif\n#if defined(HAS_TEXTURE_u_metallicRoughnessTexture) && defined(HAS_ATTRIBUTE_a_uv_2f) \nvec4 mrSample=texture(u_metallicRoughnessTexture,uv_2f);mat.perceptualRoughness*=mrSample.g;mat.metallic*=mrSample.b;\n#endif\nconst float c_minRoughness=0.04;mat.perceptualRoughness=clamp(mat.perceptualRoughness,c_minRoughness,1.0);mat.metallic=saturate(mat.metallic);mat.alphaRoughness=mat.perceptualRoughness*mat.perceptualRoughness;const vec3 f0=vec3(0.04);mat.diffuseColor=mat.baseColor.rgb*(vec3(1.0)-f0);mat.diffuseColor*=1.0-mat.metallic;mat.specularColor=mix(f0,mat.baseColor.rgb,mat.metallic);highp float reflectance=max(max(mat.specularColor.r,mat.specularColor.g),mat.specularColor.b);highp float reflectance90=saturate(reflectance*25.0);mat.f90=vec3(reflectance90);mat.normal=getNormal();return mat;}float V_GGX(float NdotL,float NdotV,float roughness)\n{float a2=roughness*roughness;float GGXV=NdotL*sqrt(NdotV*NdotV*(1.0-a2)+a2);float GGXL=NdotV*sqrt(NdotL*NdotL*(1.0-a2)+a2);return 0.5/(GGXV+GGXL);}float V_GGXFast(float NdotL,float NdotV,float roughness) {float a=roughness;float GGXV=NdotL*(NdotV*(1.0-a)+a);float GGXL=NdotV*(NdotL*(1.0-a)+a);return 0.5/(GGXV+GGXL);}vec3 F_Schlick(vec3 specularColor,vec3 f90,float VdotH)\n{return specularColor+(f90-specularColor)*pow(clamp(1.0-VdotH,0.0,1.0),5.0);}vec3 F_SchlickFast(vec3 specularColor,float VdotH)\n{float x=1.0-VdotH;float x4=x*x*x*x;return specularColor+(1.0-specularColor)*x4*x;}float D_GGX(highp float NdotH,float alphaRoughness)\n{highp float a4=alphaRoughness*alphaRoughness;highp float f=(NdotH*a4-NdotH)*NdotH+1.0;return a4/(PI*f*f);}vec3 diffuseBurley(Material mat,float LdotH,float NdotL,float NdotV)\n{float f90=2.0*LdotH*LdotH*mat.alphaRoughness-0.5;return (mat.diffuseColor/PI)*(1.0+f90*pow((1.0-NdotL),5.0))*(1.0+f90*pow((1.0-NdotV),5.0));}vec3 diffuseLambertian(Material mat)\n{\n#ifdef LIGHTING_3D_MODE\nreturn mat.diffuseColor;\n#else\nreturn mat.diffuseColor/PI;\n#endif\n}vec3 EnvBRDFApprox(vec3 specularColor,float roughness,highp float NdotV)\n{vec4 c0=vec4(-1,-0.0275,-0.572,0.022);vec4 c1=vec4(1,0.0425,1.04,-0.04);highp vec4 r=roughness*c0+c1;highp float a004=min(r.x*r.x,exp2(-9.28*NdotV))*r.x+r.y;vec2 AB=vec2(-1.04,1.04)*a004+r.zw;return specularColor*AB.x+AB.y;}vec3 computeIndirectLightContribution(Material mat,float NdotV,vec3 normal)\n{vec3 env_light=vec3(0.65,0.65,0.65);\n#ifdef LIGHTING_3D_MODE\nfloat ambient_factor=calculate_ambient_directional_factor(normal);env_light=u_lighting_ambient_color*ambient_factor;\n#endif\nvec3 envBRDF=EnvBRDFApprox(mat.specularColor,mat.perceptualRoughness,NdotV);vec3 indirectSpecular= envBRDF*env_light;vec3 indirectDiffuse=mat.diffuseColor*env_light;return indirectSpecular+indirectDiffuse;}vec3 computeLightContribution(Material mat,vec3 lightPosition,vec3 lightColor)\n{highp vec3 n=mat.normal;highp vec3 v=normalize(-v_position_height.xyz);highp vec3 l=normalize(lightPosition);highp vec3 h=normalize(v+l);float NdotV=clamp(abs(dot(n,v)),0.001,1.0);float NdotL=saturate(dot(n,l));highp float NdotH=saturate(dot(n,h));float VdotH=saturate(dot(v,h));vec3 f=F_SchlickFast(mat.specularColor,VdotH);float g=V_GGXFast(NdotL,NdotV,mat.alphaRoughness);float d=D_GGX(NdotH,mat.alphaRoughness);vec3 diffuseTerm=(1.0-f)*diffuseLambertian(mat);vec3 specularTerm=f*g*d;vec3 transformed_normal=vec3(-n.xy,n.z);float lighting_factor;\n#ifdef RENDER_SHADOWS\nlighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);\n#else\nlighting_factor=NdotL;\n#endif\nvec3 directLightColor=(specularTerm+diffuseTerm)*lighting_factor*lightColor;vec3 indirectLightColor=computeIndirectLightContribution(mat,NdotV,transformed_normal);vec3 color=(saturate(directLightColor)+indirectLightColor);float intensityFactor=1.0;\n#if !defined(LIGHTING_3D_MODE)\nconst vec3 luminosityFactor=vec3(0.2126,0.7152,0.0722);float luminance=dot(diffuseTerm,luminosityFactor);intensityFactor=mix((1.0-u_lightintensity),max((1.0-luminance+u_lightintensity),1.0),NdotL);\n#endif\ncolor*=intensityFactor;return color;}void main() {\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nif (isOccluded()) {discard;}\n#endif\nvec3 lightDir=u_lightpos;vec3 lightColor=u_lightcolor;\n#ifdef LIGHTING_3D_MODE\nlightDir=u_lighting_directional_dir;lightDir.xy=-lightDir.xy;lightColor=u_lighting_directional_color;\n#endif\nvec4 finalColor;\n#ifdef DIFFUSE_SHADED\nvec3 N=getNormal();vec3 baseColor=getBaseColor().rgb;vec3 diffuse=getDiffuseShadedColor(baseColor,N,lightDir,lightColor);\n#ifdef HAS_TEXTURE_u_occlusionTexture\nfloat ao=(texture(u_occlusionTexture,uv_2f).r-1.0)*u_aoIntensity+1.0;diffuse*=ao;\n#endif\nfinalColor=vec4(mix(diffuse,baseColor,u_emissive_strength),1.0)*u_opacity;\n#else\nMaterial mat=getPBRMaterial();vec3 color=computeLightContribution(mat,lightDir,lightColor);float ao=1.0;\n#if defined (HAS_TEXTURE_u_occlusionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\n#ifdef OCCLUSION_TEXTURE_TRANSFORM\nvec2 uv=uv_2f.xy*u_occlusionTextureTransform.zw+u_occlusionTextureTransform.xy;\n#else\nvec2 uv=uv_2f;\n#endif\nao=(texture(u_occlusionTexture,uv).x-1.0)*u_aoIntensity+1.0;color*=ao;\n#endif\nvec4 emissive=u_emissiveFactor;\n#if defined(HAS_TEXTURE_u_emissionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\nemissive.rgb*=sRGBToLinear(texture(u_emissionTexture,uv_2f).rgb);\n#endif\ncolor+=emissive.rgb;float opacity=mat.baseColor.w*u_opacity;\n#ifdef HAS_ATTRIBUTE_a_pbr\nfloat resEmission=v_roughness_metallic_emissive_alpha.z;resEmission*=v_height_based_emission_params.z+v_height_based_emission_params.w*pow(clamp(v_height_based_emission_params.x,0.0,1.0),v_height_based_emission_params.y);color=mix(color,v_color_mix.rgb,min(1.0,resEmission));\n#ifdef HAS_ATTRIBUTE_a_color_4f\nfloat distance=length(vec2(1.3*max(0.0,abs(color_4f.x)-color_4f.z),color_4f.y));distance+= mix(0.5,0.0,clamp(resEmission-1.0,0.0,1.0));opacity*=v_roughness_metallic_emissive_alpha.w*saturate(1.0-distance*distance);\n#endif\n#endif\nvec3 unlitColor=mat.baseColor.rgb*ao+emissive.rgb;color=mix(color,unlitColor,u_emissive_strength);color=linearTosRGB(color);color*=opacity;finalColor=vec4(color,opacity);\n#endif\n#ifdef FOG\nfinalColor=fog_dither(fog_apply_premultiplied(finalColor,v_fog_pos,v_position_height.w));\n#endif\n#ifdef RENDER_CUTOFF\nfinalColor*=v_cutoff_opacity;\n#endif\n#ifdef INDICATOR_CUTOUT\nfinalColor=applyCutout(finalColor);\n#endif\nglFragColor=finalColor;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin vec3 a_pos_3f;\n#pragma mapbox: define-attribute highp vec3 normal_3f\n#pragma mapbox: define-attribute highp vec2 uv_2f\n#pragma mapbox: define-attribute highp vec3 color_3f\n#pragma mapbox: define-attribute highp vec4 color_4f\n#pragma mapbox: define-attribute-vertex-shader-only highp vec4 pbr\n#pragma mapbox: define-attribute-vertex-shader-only highp vec3 heightBasedEmissiveStrength\nuniform mat4 u_matrix;uniform mat4 u_lighting_matrix;uniform vec3 u_camera_pos;uniform vec4 u_color_mix;\n#ifdef INSTANCED_ARRAYS\nin vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3;\n#else\nuniform highp mat4 u_normal_matrix;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1;out float v_depth_shadows;\n#endif\nout vec4 v_position_height;out lowp vec4 v_color_mix;\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nout highp float v_depth;\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\nout lowp vec4 v_roughness_metallic_emissive_alpha;out mediump vec4 v_height_based_emission_params;\n#endif\nvec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() {\n#pragma mapbox: initialize-attribute highp vec3 normal_3f\n#pragma mapbox: initialize-attribute highp vec2 uv_2f\n#pragma mapbox: initialize-attribute highp vec3 color_3f\n#pragma mapbox: initialize-attribute highp vec4 color_4f\n#pragma mapbox: initialize-attribute-custom highp vec4 pbr\n#pragma mapbox: initialize-attribute-custom highp vec3 heightBasedEmissiveStrength\nhighp mat4 normal_matrix;\n#ifdef INSTANCED_ARRAYS\nnormal_matrix=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);\n#else\nnormal_matrix=u_normal_matrix;\n#endif\nvec3 local_pos;mat3 rs;\n#ifdef MODEL_POSITION_ON_GPU\nvec3 pos_color=normal_matrix[0].xyz;vec4 translate=normal_matrix[1];vec3 pos_a=floor(pos_color);vec3 rgb=1.05*(pos_color-pos_a);float color_mix=pos_a.z/100.0;v_color_mix=vec4(sRGBToLinear(rgb),color_mix);float meter_to_tile=normal_matrix[0].w;vec4 pos=vec4(pos_a.xy,translate.z,1.0);rs[0].x=normal_matrix[1].w;rs[0].yz=normal_matrix[2].xy;rs[1].xy=normal_matrix[2].zw;rs[1].z=normal_matrix[3].x;rs[2].xyz=normal_matrix[3].yzw;vec4 pos_node=u_lighting_matrix*vec4(a_pos_3f,1.0);vec3 rotated_pos_node=rs*pos_node.xyz;vec3 pos_model_tile=(rotated_pos_node+vec3(translate.xy,0.0))*vec3(meter_to_tile,meter_to_tile,1.0);pos.xyz+=pos_model_tile;local_pos=pos.xyz;gl_Position=u_matrix*pos;pos.z*=meter_to_tile;v_position_height.xyz=pos.xyz-u_camera_pos;\n#else\nlocal_pos=a_pos_3f;gl_Position=u_matrix*vec4(a_pos_3f,1);v_position_height.xyz=vec3(u_lighting_matrix*vec4(a_pos_3f,1));v_color_mix=vec4(sRGBToLinear(u_color_mix.rgb),u_color_mix.a);\n#endif\nv_position_height.w=a_pos_3f.z;\n#ifdef HAS_ATTRIBUTE_a_pbr\nvec4 albedo_c=decode_color(pbr.xy);vec2 e_r_m=unpack_float(pbr.z);vec2 r_m= unpack_float(e_r_m.y*16.0);r_m.r=r_m.r*16.0;v_color_mix=vec4(albedo_c.rgb,1.0);v_roughness_metallic_emissive_alpha=vec4(vec3(r_m,e_r_m.x)/255.0,albedo_c.a);v_roughness_metallic_emissive_alpha.z*=2.0;float heightBasedRelativeIntepolation=a_pos_3f.z*heightBasedEmissiveStrength.x+heightBasedEmissiveStrength.y;v_height_based_emission_params.x=heightBasedRelativeIntepolation;v_height_based_emission_params.y=heightBasedEmissiveStrength.z;vec2 emissionMultiplierValues=unpack_float(pbr.w)/256.0;v_height_based_emission_params.z=emissionMultiplierValues.x;v_height_based_emission_params.w=emissionMultiplierValues.y-emissionMultiplierValues.x;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(local_pos);\n#endif\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef HAS_ATTRIBUTE_a_normal_3f\n#ifdef MODEL_POSITION_ON_GPU\nfloat x_squared_scale=dot(rs[0],rs[0]);float y_squared_scale=dot(rs[1],rs[1]);float z_squared_scale=dot(rs[2],rs[2]);vec3 squared_scale=vec3(x_squared_scale,y_squared_scale,z_squared_scale);normal_3f=rs*((u_lighting_matrix*vec4(normal_3f,0.0)).xyz/squared_scale);normal_3f=normalize(normal_3f);\n#else\nnormal_3f=vec3(normal_matrix*vec4(normal_3f,0));\n#endif\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\n#ifdef HAS_ATTRIBUTE_a_color_4f\nv_roughness_metallic_emissive_alpha.w=clamp(color_4f.a*v_roughness_metallic_emissive_alpha.w*(v_roughness_metallic_emissive_alpha.z-1.0),0.0,1.0);\n#endif\n#endif\n#ifdef RENDER_SHADOWS\nvec3 shadow_pos=local_pos;\n#ifdef NORMAL_OFFSET\n#ifdef HAS_ATTRIBUTE_a_normal_3f\n#ifdef MODEL_POSITION_ON_GPU\nvec3 offset=shadow_normal_offset(vec3(-normal_3f.xy,normal_3f.z));shadow_pos+=offset*shadow_normal_offset_multiplier0();\n#else\nvec3 offset=shadow_normal_offset_model(normalize(normal_3f));shadow_pos+=offset*shadow_normal_offset_multiplier0();\n#endif\n#endif\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shadow_pos,1);v_pos_light_view_1=u_light_matrix_1*vec4(shadow_pos,1);v_depth_shadows=gl_Position.w;\n#endif\n}'),modelDepth:Jo("in highp float v_depth;void main() {\n#ifndef DEPTH_TEXTURE\nglFragColor=pack_depth(v_depth);\n#endif\n}","in vec3 a_pos_3f;uniform mat4 u_matrix;out highp float v_depth;\n#ifdef MODEL_POSITION_ON_GPU\n#ifdef INSTANCED_ARRAYS\nin vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3;\n#else\nuniform highp mat4 u_instance;\n#endif\nuniform highp mat4 u_node_matrix;\n#endif\nvoid main() {\n#ifdef MODEL_POSITION_ON_GPU\nhighp mat4 instance;\n#ifdef INSTANCED_ARRAYS\ninstance=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);\n#else\ninstance=u_instance;\n#endif\nvec3 pos_color=instance[0].xyz;vec4 translate=instance[1];vec3 pos_a=floor(pos_color);float meter_to_tile=instance[0].w;vec4 pos=vec4(pos_a.xy,translate.z,1.0);mat3 rs;rs[0].x=instance[1].w;rs[0].yz=instance[2].xy;rs[1].xy=instance[2].zw;rs[1].z=instance[3].x;rs[2].xyz=instance[3].yzw;vec4 pos_node=u_node_matrix*vec4(a_pos_3f,1.0);vec3 rotated_pos_node=rs*pos_node.xyz;vec3 pos_model_tile=(rotated_pos_node+vec3(translate.xy,0.0))*vec3(meter_to_tile,meter_to_tile,1.0);pos.xyz+=pos_model_tile;gl_Position=u_matrix*pos;\n#else\ngl_Position=u_matrix*vec4(a_pos_3f,1);\n#endif\nv_depth=gl_Position.z/gl_Position.w;}"),stars:Jo("in highp vec2 v_uv;in mediump float v_intensity;float shapeCircle(in vec2 uv)\n{float beginFade=0.6;float lengthFromCenter=length(v_uv);return 1.0-clamp((lengthFromCenter-beginFade)/(1.0-beginFade),0.0,1.0);}void main() {float alpha=shapeCircle(v_uv);vec3 color=vec3(1.0,1.0,1.0);alpha*=v_intensity;glFragColor=vec4(color*alpha,alpha);HANDLE_WIREFRAME_DEBUG;}","\nin vec3 a_pos_3f;in vec2 a_uv;in float a_size_scale;in float a_fade_opacity;uniform mat4 u_matrix;uniform vec3 u_up;uniform vec3 u_right;uniform float u_intensity_multiplier;out highp vec2 v_uv;out mediump float v_intensity;void main() {v_uv=a_uv;v_intensity=a_fade_opacity*u_intensity_multiplier;vec3 pos=a_pos_3f;pos+=a_uv.x*u_right*a_size_scale;pos+=a_uv.y*u_up*a_size_scale;gl_Position=u_matrix*vec4(pos,1.0);}")};function Yo(e,t){const i=e.replace(/\s*\/\/[^\n]*\n/g,"\n").split("\n");for(let e of i)if(e=e.trim(),"#"===e[0]&&e.includes("if")&&!e.includes("endif")){e=e.replace("#","").replace(/ifdef|ifndef|elif|if/g,"").replace(/!|defined|\(|\)|\|\||&&/g,"").replace(/\s+/g," ").trim();const i=e.split(" ");for(const e of i)t.includes(e)||t.push(e);}}function Jo(e,t){const i=/#include\s+"([^"]+)"/g,o=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g;let r=t.match(/(attribute(\S*)|(^\s*|;)in) (highp |mediump |lowp )?([\w]+) ([\w]+)/gm);r&&(r=r.map((e=>{const t=e.split(" ");return t[t.length-1]})),r=[...new Set(r)]);const s={},n=[],a=[];if(e=e.replace(i,((e,t)=>(a.push(t),""))),(t=t.replace(i,((e,t)=>(n.push(t),"")))).includes("flat out"))return void console.error('The usage of "flat" qualifier is disallowed, see: https://bugs.webkit.org/show_bug.cgi?id=268071');let l=[...Ho];Yo(e,l),Yo(t,l);for(const e of [...n,...a])Wo[e]||console.error(`Undefined include: ${e}`),qo[e]||(qo[e]=[],Yo(Wo[e],qo[e])),l=[...l,...qo[e]];return {fragmentSource:e=e.replace(o,((e,t,i,o,r)=>(s[r]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${r}\nin ${i} ${o} ${r};\n#else\nuniform ${i} ${o} u_${r};\n#endif\n`:"initialize"===t?`\n#ifdef HAS_UNIFORM_u_${r}\n ${i} ${o} ${r} = u_${r};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${r}\n in ${i} ${o} ${r};\n#endif\n`:"initialize-attribute"===t?"":void 0))),vertexSource:t=t.replace(o,((e,t,i,o,r)=>{const n="float"===o?"vec2":o,a=r.match(/color/)?"color":n;return "define-attribute-vertex-shader-only"===t?`\n#ifdef HAS_ATTRIBUTE_a_${r}\nin ${i} ${o} a_${r};\n#endif\n`:s[r]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${r}\nuniform lowp float u_${r}_t;\nin ${i} ${n} a_${r};\nout ${i} ${o} ${r};\n#else\nuniform ${i} ${o} u_${r};\n#endif\n`:"initialize"===t?"vec4"===a?`\n#ifndef HAS_UNIFORM_u_${r}\n ${r} = a_${r};\n#else\n ${i} ${o} ${r} = u_${r};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${r}\n ${r} = unpack_mix_${a}(a_${r}, u_${r}_t);\n#else\n ${i} ${o} ${r} = u_${r};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${r}\n in ${i} ${o} a_${r};\n out ${i} ${o} ${r};\n#endif\n`:"initialize-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${r}\n ${r} = a_${r};\n#endif\n`:void 0:"define"===t?`\n#ifndef HAS_UNIFORM_u_${r}\nuniform lowp float u_${r}_t;\nin ${i} ${n} a_${r};\n#else\nuniform ${i} ${o} u_${r};\n#endif\n`:"define-instanced"===t?"mat4"===a?`\n#ifdef INSTANCED_ARRAYS\nin vec4 a_${r}0;\nin vec4 a_${r}1;\nin vec4 a_${r}2;\nin vec4 a_${r}3;\n#else\nuniform ${i} ${o} u_${r};\n#endif\n`:`\n#ifdef INSTANCED_ARRAYS\nin ${i} ${n} a_${r};\n#else\nuniform ${i} ${o} u_${r};\n#endif\n`:"initialize-attribute-custom"===t?`\n#ifdef HAS_ATTRIBUTE_a_${r}\n ${i} ${o} ${r} = a_${r};\n#endif\n`:"vec4"===a?`\n#ifndef HAS_UNIFORM_u_${r}\n ${i} ${o} ${r} = a_${r};\n#else\n ${i} ${o} ${r} = u_${r};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${r}\n ${i} ${o} ${r} = unpack_mix_${a}(a_${r}, u_${r}_t);\n#else\n ${i} ${o} ${r} = u_${r};\n#endif\n`})),staticAttributes:r,usedDefines:l,vertexIncludes:n,fragmentIncludes:a}}class Qo{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null;}bind(e,t,i,o,r,s,n,a){this.context=e;let l=this.boundPaintVertexBuffers.length!==o.length;for(let e=0;!l&&e{const s=o.paint.get("hillshade-shadow-color"),n=o.paint.get("hillshade-highlight-color"),a=o.paint.get("hillshade-accent-color"),l=o.paint.get("hillshade-emissive-strength");let c=e.bj(o.paint.get("hillshade-illumination-direction"));if("viewport"===o.paint.get("hillshade-illumination-anchor"))c-=t.transform.angle;else if(t.style&&t.style.enable3dLights()&&t.style.directionalLight){const i=t.style.directionalLight.properties.get("direction"),o=e.bQ(i.x,i.y,i.z);c=e.bj(o[1]);}const h=!t.options.moving;return {u_matrix:r||t.transform.calculateProjMatrix(i.tileID.toUnwrapped(),h),u_image:0,u_latrange:er(0,i.tileID),u_light:[o.paint.get("hillshade-exaggeration"),c],u_shadow:s,u_highlight:n,u_emissive_strength:l,u_accent:a}})(t,o,r,t.terrain?i.projMatrix:null);t.uploadCommonUniforms(l,d,i.toUnwrapped());const{tileBoundsBuffer:p,tileBoundsIndexBuffer:f,tileBoundsSegments:m}=t.getTileBoundsBuffers(o);d.draw(t,c.TRIANGLES,s,n,a,Ft.disabled,_,r.id,p,f,m);}function ir(t,i,o){if(!i.needsDEMTextureUpload)return;const r=t.context,s=r.gl;r.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture=i.demTexture||t.getTileTexture(o.stride);const n=o.getPixels();i.demTexture?i.demTexture.update(n,{premultiply:!1}):i.demTexture=new e.T(r,n,s.R32F,{premultiply:!1}),i.needsDEMTextureUpload=!1;}function or(t,i,o){const r=t.context,s=r.gl;if(!i.dem)return;const n=i.dem;if(r.activeTexture.set(s.TEXTURE1),ir(t,i,n),!i.demTexture)return;i.demTexture.bind(s.NEAREST,s.CLAMP_TO_EDGE);const a=n.dim;r.activeTexture.set(s.TEXTURE0);let l=i.hillshadeFBO;if(!l){const t=new e.T(r,{width:a,height:a,data:null},s.RGBA);t.bind(s.LINEAR,s.CLAMP_TO_EDGE),l=i.hillshadeFBO=r.createFramebuffer(a,a,!0,"renderbuffer"),l.colorAttachment.set(t.texture);}r.bindFramebuffer.set(l.framebuffer),r.viewport.set([0,0,a,a]);const{tileBoundsBuffer:c,tileBoundsIndexBuffer:h,tileBoundsSegments:u}=t.getMercatorTileBoundsBuffers(),d=[];t.linearFloatFilteringSupported()&&d.push("TERRAIN_DEM_FLOAT_FORMAT"),t.getOrCreateProgram("hillshadePrepare",{defines:d}).draw(t,s.TRIANGLES,Lt.disabled,Rt.disabled,Mt.unblended,Ft.disabled,((t,i)=>{const o=i.stride,r=e.a6.create();return e.a6.ortho(r,0,e.V,-e.V,0,0,1),e.a6.translate(r,r,[0,-e.V,0]),{u_matrix:r,u_image:1,u_dimension:[o,o],u_zoom:t.overscaledZ}})(i.tileID,n),o.id,c,h,u),i.needsHillshadePrepare=!1;}const rr=t=>({u_matrix:new e.bK(t),u_image0:new e.bO(t),u_skirt_height:new e.bN(t),u_ground_shadow_factor:new e.bM(t)}),sr=(e,t,i)=>({u_matrix:e,u_image0:0,u_skirt_height:t,u_ground_shadow_factor:i}),nr=(e,t,i,o,r,s,n,a,l,c,h,u,d,_,p,f)=>({u_proj_matrix:Float32Array.from(e),u_globe_matrix:t,u_normalize_matrix:Float32Array.from(o),u_merc_matrix:i,u_zoom_transition:r,u_merc_center:s,u_image0:0,u_frustum_tl:n,u_frustum_tr:a,u_frustum_br:l,u_frustum_bl:c,u_globe_pos:h,u_globe_radius:u,u_viewport:d,u_grid_matrix:f?Float32Array.from(f):new Float32Array(9),u_skirt_height:_,u_far_z_cutoff:p});function ar(e,t){return null!=e&&null!=t&&!(!e.hasData()||!t.hasData())&&null!=e.demTexture&&null!=t.demTexture&&e.tileID.key!==t.tileID.key}const lr=new class{constructor(){this.operations={};}newMorphing(e,t,i,o,r){if(e in this.operations){const t=this.operations[e];t.to.tileID.key!==i.tileID.key&&(t.queued=i);}else this.operations[e]={startTime:o,phase:0,duration:r,from:t,to:i,queued:null};}getMorphValuesForProxy(e){if(!(e in this.operations))return null;const t=this.operations[e];return {from:t.from,to:t.to,phase:t.phase}}update(e){for(const t in this.operations){const i=this.operations[t];for(i.phase=(e-i.startTime)/i.duration;i.phase>=1||!this._validOp(i);)if(!this._nextOp(i,e)){delete this.operations[t];break}}}_nextOp(e,t){return !!e.queued&&(e.from=e.to,e.to=e.queued,e.queued=null,e.phase=0,e.startTime=t,!0)}_validOp(e){return e.from.hasData()&&e.to.hasData()}},cr={0:null,1:"TERRAIN_VERTEX_MORPHING"};function hr(e,t,i){if(0===t)return 0;const o=t<1&&514===i?.25/t:1;return 6*Math.pow(1.5,22-e)*Math.max(t,1)*o}function ur(e,t){const i=1<({u_matrix:e});function _r(t,i,o,r,s){if(s>0){const n=e.f.now(),a=(n-t.timeAdded)/s,l=i?(n-i.timeAdded)/s:-1,c=o.getSource(),h=r.coveringZoomLevel({tileSize:c.tileSize,roundZoom:c.roundZoom}),u=!i||Math.abs(i.tileID.overscaledZ-h)>Math.abs(t.tileID.overscaledZ-h),d=u&&t.refreshedUponExpiration?1:e.aa(u?a:1-l,0,1);return t.refreshedUponExpiration&&a>=1&&(t.refreshedUponExpiration=!1),i?{opacity:1,mix:1-d}:{opacity:d,mix:0}}return {opacity:1,mix:0}}class pr extends Kt{constructor(t){const i={type:"raster-dem",maxzoom:t.transform.maxZoom},o=new e.bW(e.bX(),null),r=Vt("mock-dem",i,o,t.style);super("mock-dem",r,!1),r.setEventedParent(this),this._sourceLoaded=!0;}_loadTile(e,t){e.state="loaded",t(null);}}class fr extends Kt{constructor(t){const i=Vt("proxy",{type:"geojson",maxzoom:t.transform.maxZoom},new e.bW(e.bX(),null),t.style);super("proxy",i,!1),i.setEventedParent(this),this.map=this.getSource().map=t,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={};}update(e,t,i){if(e.freezeTileCoverage)return;this.transform=e;const o=e.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce(((t,i)=>{if(t[i.key]="",!this._tiles[i.key]){const t=new Gt(i,this._source.tileSize*i.overscaleFactor(),e.tileZoom);t.state="loaded",this._tiles[i.key]=t;}return t}),{});for(const e in this._tiles)e in o||(this.freeFBO(e),this._tiles[e].unloadVectorData(),delete this._tiles[e]);}freeFBO(e){const t=this.proxyCachedFBO[e];if(void 0!==t){const i=Object.values(t);this.renderCachePool.push(...i),delete this.proxyCachedFBO[e];}}deallocRenderCache(){this.renderCache.forEach((e=>e.fb.destroy())),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={};}}class mr extends e.am{constructor(e,t,i){super(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y),this.proxyTileKey=t,this.projMatrix=i;}}class gr extends e.ck{constructor(t,i){super(),this._debugParams={sortTilesHiZFirst:!0,disableRenderCache:!1},t.tp.registerParameter(this._debugParams,["Terrain"],"sortTilesHiZFirst",{},(()=>{this._style.map.triggerRepaint();})),t.tp.registerParameter(this._debugParams,["Terrain"],"disableRenderCache",{},(()=>{this._style.map.triggerRepaint();})),t.tp.registerButton(["Terrain"],"Invalidate Render Cache",(()=>{this.invalidateRenderCache=!0,this._style.map.triggerRepaint();})),this.painter=t,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[o,r,s]=function(t){const i=new e.aN,o=new e.aw,r=131;i.reserve(17161),o.reserve(33800);const s=e.V/128,n=e.V+s/2,a=n+s;for(let t=-s;tn||t<0||t>n?24575:0,s=e.aa(Math.round(o),0,e.V),a=e.aa(Math.round(t),0,e.V);i.emplaceBack(s+r,a);}const l=(e,t)=>{const i=t*r+e;o.emplaceBack(i+1,i,i+r),o.emplaceBack(i+r,i+r+1,i+1);};for(let e=1;e<129;e++)for(let t=1;t<129;t++)l(t,e);return [0,129].forEach((e=>{for(let t=0;t<130;t++)l(t,e),l(e,t);})),[i,o,32768]}(),n=t.context;this.gridBuffer=n.createVertexBuffer(o,e.aP.members),this.gridIndexBuffer=n.createIndexBuffer(r),this.gridSegments=e.aB.simpleSegment(0,0,o.length,r.length),this.gridNoSkirtSegments=e.aB.simpleSegment(0,0,o.length,s),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new fr(i.map),this.orthoMatrix=e.a6.create(),e.a6.ortho(this.orthoMatrix,"globe"===this.painter.transform.projection.name?.015:0,e.V,0,e.V,0,1);const a=n.gl;this._overlapStencilMode=new Rt({func:a.GEQUAL,mask:255},0,255,a.KEEP,a.KEEP,a.REPLACE),this._previousZoom=t.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=i,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new pr(i.map),this._pendingGroundEffectLayers=[];}set style(e){e.on("data",this._onStyleDataEvent.bind(this)),this._style=e,this._style.map.on("moveend",(()=>{this._clearLineLayersFromRenderCache();}));}update(t,i,o){if(t&&t.terrain){this._style!==t&&(this.style=t,this._evaluationZoom=void 0);const r=t.terrain.properties,s=0===t.terrain.drapeRenderMode,n=t.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=e.f.now();const a=t.terrain&&t.terrain.scope,l=r.get("source"),c=s?this._mockSourceCache:t.getSourceCache(l,a);if(!c)return void e.w(`Couldn't find terrain source "${l}".`);if(this.sourceCache=c,this._exaggeration=n?this.calculateExaggeration(i):r.get("exaggeration"),!i.projection.requiresDraping&&n&&0===this._exaggeration)return void this._disable();this.enabled=!0;const h=()=>{this.sourceCache.used&&e.w(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source.\nThis leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const t=this.getScaledDemTileSize();this.sourceCache.update(i,t,!0),this.resetTileLookupCache(this.sourceCache.id);};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,h(),this._initializing=!0),h(),i.updateElevation(!0,o),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(i),this._emptyDEMTextureDirty=!0,this._previousZoom=i.zoom;}else this._disable();}calculateExaggeration(t){const i=this._previousCameraAltitude,o=t.getFreeCameraOptions().position.z/t.pixelsPerMeter*t.worldSize;this._previousCameraAltitude=o;const r=null!=i?o-i:Number.MAX_VALUE;if(Math.abs(r)<2)return this._exaggeration;const s=t.zoom,n=this._style.terrain;if(!this._previousUpdateTimestamp)return n.getExaggeration(s);let a=s-this._previousZoom;const l=this._previousUpdateTimestamp;let c=s;null!=this._evaluationZoom&&(c=this._evaluationZoom,Math.abs(s-c)>.5&&(a=.5*(s-c+a)),a*r<0&&(c+=a)),this._evaluationZoom=c;const h=n.getExaggeration(c),u=h===n.getExaggeration(Math.max(0,c-.1));if(u&&Math.abs(h-this._exaggeration)<.01)return h;let d=Math.min(.1,.00375*(this._updateTimestamp-l));return (u||h<.1||Math.abs(a)<1e-4)&&(d=Math.min(.2,4*d)),e.U(this._exaggeration,h,d)}resetTileLookupCache(e){this._findCoveringTileCache[e]={};}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_onStyleDataEvent(e){e.coord&&"source"===e.dataType?this._clearRenderCacheForTile(e.sourceCacheId,e.coord):"style"===e.dataType&&(this.invalidateRenderCache=!0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this._previousCameraAltitude=void 0);}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const e in this._style._mergedSourceCaches)this._style._mergedSourceCaches[e].usedForTerrain=!1;}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach((e=>e.fb.destroy())),this.pool=[],this._depthFBO&&(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),this.framebufferCopyTexture&&this.framebufferCopyTexture.destroy();}_source(){return this.enabled?this.sourceCache:null}isUsingMockSource(){return this.sourceCache===this._mockSourceCache}exaggeration(){return this._exaggeration}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const e=2*this.proxySourceCache.getSource().tileSize;return [e,e]}set useVertexMorphing(e){this._useVertexMorphing=e;}updateTileBinding(t){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const i=this.proxySourceCache,o=this.painter.transform;this._initializing&&(this._initializing=0===o._centerAltitude&&-1===this.getAtPointOrZero(e.L.fromLngLat(o.center),-1),this._emptyDEMTextureDirty=!this._initializing);const r=this.proxyCoords=i.getIds().map((e=>{const t=i.getTileByID(e).tileID;return t.projMatrix=o.calculateProjMatrix(t.toUnwrapped()),t}));!function(t,i){const o=i.transform.pointCoordinate(i.transform.getCameraPoint()),r=new e.P(o.x,o.y);t.sort(((t,i)=>{if(i.overscaledZ-t.overscaledZ)return i.overscaledZ-t.overscaledZ;const o=new e.P(t.canonical.x+(1<{this.proxyToSource[e.key]={};})),this.terrainTileForTile={};const n=this._style._mergedSourceCaches;for(const e in n){const i=n[e];if(!i.used)continue;if(i!==this.sourceCache&&this.resetTileLookupCache(i.id),this._setupProxiedCoordsForOrtho(i,t[e],s),i.usedForTerrain)continue;const o=t[e];i.getSource().reparseOverscaled&&this._assignTerrainTiles(o);}this.proxiedCoords[i.id]=r.map((e=>new mr(e,e.key,this.orthoMatrix))),this._assignTerrainTiles(r),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(s),this.renderingToTexture=!1;const a={};this._visibleDemTiles=[];for(const e of this.proxyCoords){const t=this.terrainTileForTile[e.key];if(!t)continue;const i=t.tileID.key;i in a||(this._visibleDemTiles.push(t),a[i]=i);}}_assignTerrainTiles(e){this._initializing||e.forEach((e=>{if(this.terrainTileForTile[e.key])return;const t=this._findTileCoveringTileID(e,this.sourceCache);t&&(this.terrainTileForTile[e.key]=t);}));}_prepareDEMTextures(){const e=this.painter.context,t=e.gl;for(const i in this.terrainTileForTile){const o=this.terrainTileForTile[i],r=o.dem;!r||o.demTexture&&!o.needsDEMTextureUpload||(e.activeTexture.set(t.TEXTURE1),ir(this.painter,o,r));}}_prepareDemTileUniforms(e,t,i,o){if(!t||null==t.demTexture)return !1;const r=e.tileID.canonical,s=Math.pow(2,t.tileID.canonical.z-r.z),n=o||"";return i[`u_dem_tl${n}`]=[r.x*s%1,r.y*s%1],i[`u_dem_scale${n}`]=s,!0}get emptyDEMTexture(){return !this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const t=this.painter.context,i=t.gl;if(!this._emptyDepthBufferTexture){const o=new e.h({width:1,height:1},Uint8Array.of(255,255,255,255));this._emptyDepthBufferTexture=new e.T(t,o,i.RGBA,{premultiply:!1});}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let e=0;const t=this._visibleDemTiles.reduce(((t,i)=>{if(!i.dem)return t;const o=i.dem.tree.minimums[0];return o>0&&e++,t+o}),0);return e?t/e:0}_updateEmptyDEMTexture(){const t=this.painter.context,i=t.gl;t.activeTexture.set(i.TEXTURE2);const o=this._getLoadedAreaMinimum(),[r,s]=(()=>{const t=new e.cm({width:1,height:1},new Float32Array([o]));return [i.R32F,t]})();this._emptyDEMTextureDirty=!1;let n=this._emptyDEMTexture;return n?n.update(s,{premultiply:!1}):n=this._emptyDEMTexture=new e.T(t,s,r,{premultiply:!1}),n}setupElevationDraw(t,i,o){const r=this.painter.context,s=r.gl,n={u_dem:2,u_dem_prev:4,u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_exaggeration:0};n.u_exaggeration=this.exaggeration();let a=null,l=null,c=1;if(o&&o.morphing&&this._useVertexMorphing){const e=o.morphing.srcDemTile,i=o.morphing.dstDemTile;c=o.morphing.phase,e&&i&&(this._prepareDemTileUniforms(t,e,n,"_prev")&&(l=e),this._prepareDemTileUniforms(t,i,n)&&(a=i));}const h=e=>e&&e.demTexture&&this.painter.linearFloatFilteringSupported()?s.LINEAR:s.NEAREST,u=e=>{n.u_dem_size=1===e.size[0]?1:e.size[0]-2;};if(l&&a)r.activeTexture.set(s.TEXTURE2),a.demTexture.bind(h(a),s.CLAMP_TO_EDGE),r.activeTexture.set(s.TEXTURE4),l.demTexture.bind(h(l),s.CLAMP_TO_EDGE),a.demTexture&&u(a.demTexture),n.u_dem_lerp=c;else {a=this.terrainTileForTile[t.tileID.key],r.activeTexture.set(s.TEXTURE2);const e=this._prepareDemTileUniforms(t,a,n)?a.demTexture:this.emptyDEMTexture;e.bind(h(a),s.CLAMP_TO_EDGE),u(e);}if(r.activeTexture.set(s.TEXTURE3),o&&o.useDepthForOcclusion?(this._depthTexture&&this._depthTexture.bind(s.NEAREST,s.CLAMP_TO_EDGE),this._depthFBO&&(n.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height])):(this.emptyDepthBufferTexture.bind(s.NEAREST,s.CLAMP_TO_EDGE),n.u_depth_size_inv=[1,1]),o&&o.useMeterToDem&&a){const t=(1<{if(c===i)return;const o=[cr[i],"PROJECTION_GLOBE_VIEW"];u&&o.push("CUSTOM_ANTIALIASING");const r=t.isTileAffectedByFog(e);l=t.getOrCreateProgram("globeRaster",{defines:o,overrideFog:r}),c=i;},_=t.colorModeForRenderPass(),p=new Lt(a.LEQUAL,Lt.ReadWrite,t.depthRangeFor3D);lr.update(s);const f=e.ce(h),m=[e.a5(h.center.lng),e.ae(h.center.lat)],g=t.globeSharedBuffers,v=[h.width*e.f.devicePixelRatio,h.height*e.f.devicePixelRatio],x=Float32Array.from(h.globeMatrix),y={useDenormalizedUpVectorScale:!0};{const h=t.transform,u=hr(h.zoom,i.exaggeration(),i.sourceCache._source.tileSize);c=-1;const b=a.TRIANGLES;for(const c of r){const r=o.getTile(c),w=Rt.disabled,T=i.prevTerrainTileForTile[c.key],E=i.terrainTileForTile[c.key];ar(T,E)&&lr.newMorphing(c.key,T,E,s,250),n.activeTexture.set(a.TEXTURE0),r.texture&&r.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const S=lr.getMorphValuesForProxy(c.key),C=S?1:0;S&&e.j(y,{morphing:{srcDemTile:S.from,dstDemTile:S.to,phase:e.cc(S.phase)}});const I=e.cf(c.canonical),D=e.cg(I.getCenter().lat),L=e.ch(c.canonical,I,D,h.worldSize/h._pixelsPerMercatorPixel),A=e.aT(e.ci(c.canonical)),R=nr(h.expandedFarZProjMatrix,x,f,A,e.S(h.zoom),m,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,v,u,h._farZ,L);if(d(c,C),l&&(i.setupElevationDraw(r,l,y),t.uploadCommonUniforms(n,l,c.toUnwrapped()),g)){const[e,i,o]=g.getGridBuffers(D,0!==u);l.draw(t,b,p,w,_,Ft.backCCW,R,"globe_raster",e,i,o);}}}if(g&&(t.renderDefaultNorthPole||t.renderDefaultSouthPole)){const s=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];u&&s.push("CUSTOM_ANTIALIASING"),l=t.getOrCreateProgram("globeRaster",{defines:s});for(const s of r){const{x:r,y:c,z:u}=s.canonical,d=0===c,f=c===(1<e.draw(t,a.TRIANGLES,p,Rt.disabled,_,Ft.disabled,nr(h.expandedFarZProjMatrix,g,g,E,0,m,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,v,0,h._farZ),"globe_pole_raster",i,w,T);i.setupElevationDraw(c,l,y),t.uploadCommonUniforms(n,l,s.toUnwrapped()),d&&t.renderDefaultNorthPole&&S(l,x),f&&t.renderDefaultSouthPole&&(g=e.a6.scale(e.a6.create(),g,[1,-1,1]),S(l,b));}}}}(t,i,o,r,s);else {const n=t.context,a=n.gl;let l,c;const h=t.shadowRenderer,u=vo(t,t.longestCutoffRange),d=e=>{if(c===e)return;const i=[];i.push(cr[e]),u.shouldRenderCutoff&&i.push("RENDER_CUTOFF"),l=t.getOrCreateProgram("terrainRaster",{defines:i}),c=e;},_=t.colorModeForRenderPass(),p=new Lt(a.LEQUAL,Lt.ReadWrite,t.depthRangeFor3D);lr.update(s);const f=t.transform,m=hr(f.zoom,i.exaggeration(),i.sourceCache._source.tileSize);let g=[0,0,0];if(h){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(g=So(e,i));}{c=-1;const v=a.TRIANGLES,[x,y]=[i.gridIndexBuffer,i.gridSegments];for(const c of r){const r=o.getTile(c),b=Rt.disabled,w=i.prevTerrainTileForTile[c.key],T=i.terrainTileForTile[c.key];ar(w,T)&&lr.newMorphing(c.key,w,T,s,250),n.activeTexture.set(a.TEXTURE0),r.texture&&r.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const E=lr.getMorphValuesForProxy(c.key),S=E?1:0;let C;E&&(C={morphing:{srcDemTile:E.from,dstDemTile:E.to,phase:e.cc(E.phase)}});const I=sr(c.projMatrix,ur(c.canonical,f.renderWorldCopies)?m/10:m,g);if(d(S),!l)continue;i.setupElevationDraw(r,l,C);const D=c.toUnwrapped();h&&h.setupShadows(D,l),t.uploadCommonUniforms(n,l,D,null,u),l.draw(t,v,p,b,_,Ft.backCCW,I,"terrain_raster",i.gridBuffer,x,y);}}}}(i,this,this.proxySourceCache,t,this._updateTimestamp),this.renderingToTexture=!0,i.gpuTimingDeferredRenderEnd(),t.splice(0,t.length));}renderBatch(t){if(0===this._drapedRenderBatches.length)return t+1;this.renderingToTexture=!0;const i=this.painter,o=this.painter.context,r=this.proxySourceCache,s=this.proxiedCoords[r.id],n=this._drapedRenderBatches.shift(),a=i.style.order,l=[];let c=0;for(const h of s){const s=r.getTileByID(h.proxyTileKey),u=r.proxyCachedFBO[h.key]?r.proxyCachedFBO[h.key][t]:void 0,d=void 0!==u?r.renderCache[u]:this.pool[c++],_=void 0!==u;if(s.texture=d.tex,_&&!d.dirty){l.push(s.tileID);continue}let p;o.bindFramebuffer.set(d.fb.framebuffer),this.renderedToTile=!1,d.dirty&&(o.clear({color:e.ax.transparent,stencil:0}),d.dirty=!1);for(let e=n.start;e<=n.end;++e){const t=i.style._mergedLayers[a[e]];if(t.isHidden(i.transform.zoom))continue;const r=i.style.getLayerSourceCache(t),s=r?this.proxyToSource[h.key][r.id]:[h];if(!s)continue;const n=s;o.viewport.set([0,0,d.fb.width,d.fb.height]),p!==(r?r.id:null)&&(this._setupStencil(d,s,t,r),p=r?r.id:null),i.renderLayer(i,r,t,n);}if(0===this._drapedRenderBatches.length)for(const e of this._pendingGroundEffectLayers){const t=i.style._mergedLayers[a[e]];if(t.isHidden(i.transform.zoom))continue;const r=i.style.getLayerSourceCache(t),s=r?this.proxyToSource[h.key][r.id]:[h];if(!s)continue;const n=s;o.viewport.set([0,0,d.fb.width,d.fb.height]),p!==(r?r.id:null)&&(this._setupStencil(d,s,t,r),p=r?r.id:null),i.renderLayer(i,r,t,n);}this.renderedToTile?(d.dirty=!0,l.push(s.tileID)):_||--c,5===c&&(c=0,this.renderToBackBuffer(l));}return this.renderToBackBuffer(l),this.renderingToTexture=!1,o.bindFramebuffer.set(null),o.viewport.set([0,0,i.width,i.height]),n.end+1}postRender(){}isLayerOrderingCorrect(e){const t=e.order.length;let i=-1,o=t;for(let r=0;ri}getMinElevationBelowMSL(){let e=0;return this._visibleDemTiles.filter((e=>e.dem)).forEach((t=>{e=Math.min(e,t.dem.tree.minimums[0]);})),0===e?e:(e-30)*this._exaggeration}raycast(e,t,i){if(!this._visibleDemTiles)return null;const o=this._visibleDemTiles.filter((e=>e.dem)).map((o=>{const r=o.tileID,s=1<(null!==e.t?e.t:Number.MAX_VALUE)-(null!==t.t?t.t:Number.MAX_VALUE)));for(const r of o){if(null==r.t)return null;const o=r.tile.dem.tree.raycast(r.minx,r.miny,r.maxx,r.maxy,e,t,i);if(null!=o)return o}return null}_createFBO(){const t=this.painter.context,i=t.gl,o=this.drapeBufferSize;t.activeTexture.set(i.TEXTURE0);const r=new e.T(t,{width:o[0],height:o[1],data:null},i.RGBA);r.bind(i.LINEAR,i.CLAMP_TO_EDGE);const s=t.createFramebuffer(o[0],o[1],!0,null);return s.colorAttachment.set(r.texture),s.depthAttachment=new It(t,s.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=t.createRenderbuffer(t.gl.DEPTH_STENCIL,o[0],o[1]),this._stencilRef=0,s.depthAttachment.set(this._sharedDepthStencil),t.clear({stencil:0})):s.depthAttachment.set(this._sharedDepthStencil),t.extTextureFilterAnisotropic&&i.texParameterf(i.TEXTURE_2D,t.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,t.extTextureFilterAnisotropicMax),{fb:s,tex:r,dirty:!1}}_initFBOPool(){for(;this.pool.length{const t=this._style._mergedLayers[e],i=t.isHidden(this.painter.transform.zoom);return "custom"===t.type?!i&&t.shouldRedrape():!i&&t.hasTransition()}))}_clearLineLayersFromRenderCache(){let t=!1;for(const e of this._style.getSources())if(e instanceof Pe){t=!0;break}if(!t)return;const i={};for(let t=0;te>t.end))||e.w("fill-extrusion with flood lighting and/or ground ambient occlusion should be moved to be on top of all draped layers.");}this._drapedRenderBatches=o;}_setupRenderCache(e){const t=this.proxySourceCache;if(this._shouldDisableRenderCache()||this.invalidateRenderCache){if(this.invalidateRenderCache=!1,t.renderCache.length>t.renderCachePool.length){const e=Object.values(t.proxyCachedFBO);t.proxyCachedFBO={};for(let i=0;i=0;r--){const s=i[r];if(t.getTileByID(s.key),void 0!==t.proxyCachedFBO[s.key]){const i=e[s.key],r=this.proxyToSource[s.key];let n=0;for(const e in r){const t=r[e],s=i[e];if(!s||s.length!==t.length||t.some(((t,i)=>t!==s[i]||o[e]&&o[e].hasOwnProperty(t.key)))){n=-1;break}++n;}for(const e in t.proxyCachedFBO[s.key])t.renderCache[t.proxyCachedFBO[s.key][e]].dirty=n<0||n!==Object.values(i).length;}}const r=[...this._drapedRenderBatches];r.sort(((e,t)=>t.end-t.start-(e.end-e.start)));for(const e of r)for(const o of i){if(t.proxyCachedFBO[o.key])continue;let i=t.renderCachePool.pop();void 0===i&&t.renderCache.length<50&&(i=t.renderCache.length,t.renderCache.push(this._createFBO())),void 0!==i&&(t.proxyCachedFBO[o.key]={},t.proxyCachedFBO[o.key][e.start]=i,t.renderCache[i].dirty=!0);}this._tilesDirty={};}_setupStencil(e,t,i,o){if(!o||!this._sourceTilesOverlap[o.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const r=this.painter.context,s=r.gl;if(t.length<=1)return void(this._overlapStencilType=!1);let n;if(i.isTileClipped())n=t.length,this._overlapStencilMode.test={func:s.EQUAL,mask:255},this._overlapStencilType="Clip";else {if(!(t[0].overscaledZ>t[t.length-1].overscaledZ))return void(this._overlapStencilType=!1);n=1,this._overlapStencilMode.test={func:s.GREATER,mask:255},this._overlapStencilType="Mask";}this._stencilRef+n>255&&(r.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=n,this._overlapStencilMode.ref=this._stencilRef,i.isTileClipped()&&this._renderTileClippingMasks(t,this._overlapStencilMode.ref);}clipOrMaskOverlapStencilType(){return "Clip"===this._overlapStencilType||"Mask"===this._overlapStencilType}stencilModeForRTTOverlap(e){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[e.key]),this._overlapStencilMode):Rt.disabled}_renderTileClippingMasks(e,t){const i=this.painter,o=this.painter.context,r=o.gl;i._tileClippingMaskIDs={},o.setColorMode(Mt.disabled),o.setDepthMode(Lt.disabled);const s=i.getOrCreateProgram("clippingMask");for(const o of e){const e=i._tileClippingMaskIDs[o.key]=--t;s.draw(i,r.TRIANGLES,Lt.disabled,new Rt({func:r.ALWAYS,mask:0},e,255,r.KEEP,r.KEEP,r.REPLACE),Mt.disabled,Ft.disabled,dr(o.projMatrix),"$clipping",i.tileExtentBuffer,i.quadTriangleIndexBuffer,i.tileExtentSegments);}}pointCoordinate(t){const i=this.painter.transform;if(t.x<0||t.x>i.width||t.y<0||t.y>i.height)return null;const o=[t.x,t.y,1,1];e.a7.transformMat4(o,o,i.pixelMatrixInverse),e.a7.scale(o,o,1/o[3]),o[0]/=i.worldSize,o[1]/=i.worldSize;const r=i._camera.position,s=e.bl(1,i.center.lat),n=[r[0],r[1],r[2]/s,0],a=e.N.subtract([],o.slice(0,3),n);e.N.normalize(a,a);const l=this.raycast(n,a,this._exaggeration);return null!==l&&l?(e.N.scaleAndAdd(n,n,a,l),n[3]=n[2],n[2]*=s,n):null}drawDepth(){const t=this.painter,i=t.context,o=this.proxySourceCache,r=Math.ceil(t.width),s=Math.ceil(t.height);if(!this._depthFBO||this._depthFBO.width===r&&this._depthFBO.height===s||(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),!this._depthFBO){const t=i.gl,o=i.createFramebuffer(r,s,!0,"renderbuffer");i.activeTexture.set(t.TEXTURE0);const n=new e.T(i,{width:r,height:s,data:null},t.RGBA);n.bind(t.NEAREST,t.CLAMP_TO_EDGE),o.colorAttachment.set(n.texture);const a=i.createRenderbuffer(i.gl.DEPTH_COMPONENT16,r,s);o.depthAttachment.set(a),this._depthFBO=o,this._depthTexture=n;}i.bindFramebuffer.set(this._depthFBO.framebuffer),i.viewport.set([0,0,r,s]),function(e,t,i,o){if("globe"===e.transform.projection.name)return;const r=e.context,s=r.gl;r.clear({depth:1});const n=e.getOrCreateProgram("terrainDepth"),a=new Lt(s.LESS,Lt.ReadWrite,e.depthRangeFor3D);for(const r of o){const o=i.getTile(r),l=sr(r.projMatrix,0,[0,0,0]);t.setupElevationDraw(o,n),n.draw(e,s.TRIANGLES,a,Rt.disabled,Mt.unblended,Ft.backCCW,l,"terrain_depth",t.gridBuffer,t.gridIndexBuffer,t.gridNoSkirtSegments);}}(t,this,o,this.proxyCoords);}_setupProxiedCoordsForOrtho(t,i,o){if(t.getSource()instanceof e.ap)return this._setupProxiedCoordsForImageSource(t,i,o);this._findCoveringTileCache[t.id]=this._findCoveringTileCache[t.id]||{};const r=this.proxiedCoords[t.id]=[],s=this.proxyCoords;for(let e=0;et.overscaledZ-e.overscaledZ));}_setupProxiedCoordsForImageSource(t,i,o){if(!t.getSource().loaded())return;const r=this.proxiedCoords[t.id]=[],s=this.proxyCoords,n=t.getSource(),a=n.tileID;if(!a)return;const l=new e.P(a.x,a.y)._div(1<(e.min.x=Math.min(e.min.x,t.x-l.x),e.min.y=Math.min(e.min.y,t.y-l.y),e.max.x=Math.max(e.max.x,t.x-l.x),e.max.y=Math.max(e.max.y,t.y-l.y),e)),{min:new e.P(Number.MAX_VALUE,Number.MAX_VALUE),max:new e.P(-Number.MAX_VALUE,-Number.MAX_VALUE)}),h=(t,i)=>{const o=t.wrap+t.canonical.x/(1<n+c.max.x||r+sa+c.max.y};for(let e=0;ee.key===i.tileID.key));if(e)return e}if(i.tileID.key!==t.key){const o=t.canonical.z-i.tileID.canonical.z;let s,n,a;r=e.a6.create();const l=i.tileID.wrap-t.wrap<0?(s=e.V>>o,n=s*((i.tileID.canonical.x<=r){const o=t.canonical.z-r;i.getSource().reparseOverscaled?(a=Math.max(t.canonical.z+2,i.transform.tileZoom),n=new e.am(a,t.wrap,r,t.canonical.x>>o,t.canonical.y>>o)):0!==o&&(a=r,n=new e.am(a,t.wrap,r,t.canonical.x>>o,t.canonical.y>>o));}n.key!==t.key&&(c.push(n.key),o=i.getTile(n));}const h=e=>{c.forEach((t=>{r[t]=e;})),c.length=0;};for(a-=1;a>=l&&(!o||!o.hasData());a--){o&&h(o.tileID.key);const e=n.calculateScaledKey(a);if(o=i.getTileByID(e),o&&o.hasData())break;const t=r[e];if(null===t)break;void 0===t?c.push(e):o=i.getTileByID(t);}return h(o?o.tileID.key:null),o&&o.hasData()?o:null}findDEMTileFor(e){return this.enabled?this._findTileCoveringTileID(e,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0;}_clearRenderCacheForTile(e,t){let i=this._tilesDirty[e];i||(i=this._tilesDirty[e]={}),i[t.key]=!0;}}function vr(t,i,o){const r=function(t,i,o){const r=e.N.dot(i,t),s=e.N.dot(o,[.2126,.7152,.0722]),n=(e,t,i)=>(1-i)*e+i*t,a=n(1-.3*Math.min(s,1),1,Math.min(r+1,1));return n(.92,1,Math.asin(e.aa(i[2],-1,1))/Math.PI+.5)*a}(t,[0,0,1],i),s=[0,0,0];e.N.scale(s,o.slice(0,3),r);const n=[0,0,0];e.N.scale(n,i.slice(0,3),t[2]);const a=[0,0,0];return e.N.add(a,s,n),e.bU(a)}const xr=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],yr=["stars","fillExtrusion","fillExtrusionGroundEffect","model","symbolSDF","symbolIcon","symbolTextAndIcon"];class br{static cacheKey(e,t,i,o){let r=`${t}${o?o.cacheKey:""}`;for(const t of i)e.usedDefines.includes(t)&&(r+=`/${t}`);return r}constructor(t,i,o,r,s,n,a){const l=t.gl;this.program=l.createProgram(),this.configuration=r,this.name=i,this.fixedDefines=[...n];const c=r?r.getBinderAttributes():[],h=(o.staticAttributes||[]).concat(c);let u=r?r.defines():[];u=u.concat(n.map((e=>`#define ${e}`)));const d="#version 300 es\n";let _=d+u.concat("precision mediump float;",Xo,$o.fragmentSource).join("\n");for(const e of o.fragmentIncludes)_+=`\n${Wo[e]}`;_+=`\n${o.fragmentSource}`;let p=d+u.concat("precision highp float;",Xo,$o.vertexSource).join("\n");for(const e of o.vertexIncludes)p+=`\n${Wo[e]}`;p+=`\n${o.vertexSource}`;const f=l.createShader(l.FRAGMENT_SHADER);if(l.isContextLost())return void(this.failedToCreate=!0);l.shaderSource(f,_),l.compileShader(f),l.attachShader(this.program,f);const m=l.createShader(l.VERTEX_SHADER);if(l.isContextLost())this.failedToCreate=!0;else {l.shaderSource(m,p),l.compileShader(m),l.attachShader(this.program,m),this.attributes={},this.numAttributes=h.length;for(let e=0;e0&&l.transformFeedbackVaryings(this.program,a.shaderVaryings,a.bufferMode),l.linkProgram(this.program),l.deleteShader(m),l.deleteShader(f),this.fixedUniforms=s(t),this.binderUniforms=r?r.getUniforms(t):[],n.includes("TERRAIN")&&(this.terrainUniforms=(t=>({u_dem:new e.bO(t),u_dem_prev:new e.bO(t),u_dem_tl:new e.bL(t),u_dem_scale:new e.bN(t),u_dem_tl_prev:new e.bL(t),u_dem_scale_prev:new e.bN(t),u_dem_size:new e.bN(t),u_dem_lerp:new e.bN(t),u_exaggeration:new e.bN(t),u_depth:new e.bO(t),u_depth_size_inv:new e.bL(t),u_meter_to_dem:new e.bN(t),u_label_plane_matrix_inv:new e.bK(t)}))(t)),n.includes("GLOBE")&&(this.globeUniforms=(t=>({u_tile_tl_up:new e.bM(t),u_tile_tr_up:new e.bM(t),u_tile_br_up:new e.bM(t),u_tile_bl_up:new e.bM(t),u_tile_up_scale:new e.bN(t)}))(t)),n.includes("FOG")&&(this.fogUniforms=(t=>({u_fog_matrix:new e.bK(t),u_fog_range:new e.bL(t),u_fog_color:new e.bP(t),u_fog_horizon_blend:new e.bN(t),u_fog_vertical_limit:new e.bL(t),u_fog_temporal_offset:new e.bN(t),u_frustum_tl:new e.bM(t),u_frustum_tr:new e.bM(t),u_frustum_br:new e.bM(t),u_frustum_bl:new e.bM(t),u_globe_pos:new e.bM(t),u_globe_radius:new e.bN(t),u_globe_transition:new e.bN(t),u_is_globe:new e.bO(t),u_viewport:new e.bL(t)}))(t)),n.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(t=>({u_cutoff_params:new e.bP(t)}))(t)),n.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(t=>({u_lighting_ambient_color:new e.bM(t),u_lighting_directional_dir:new e.bM(t),u_lighting_directional_color:new e.bM(t),u_ground_radiance:new e.bM(t)}))(t)),n.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(t=>({u_light_matrix_0:new e.bK(t),u_light_matrix_1:new e.bK(t),u_fade_range:new e.bL(t),u_shadow_normal_offset:new e.bM(t),u_shadow_intensity:new e.bN(t),u_shadow_texel_size:new e.bN(t),u_shadow_map_resolution:new e.bN(t),u_shadow_direction:new e.bM(t),u_shadow_bias:new e.bM(t),u_shadowmap_0:new e.bO(t),u_shadowmap_1:new e.bO(t)}))(t));}}setTerrainUniformValues(e,t){if(!this.terrainUniforms)return;const i=this.terrainUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e]&&i[e].set(this.program,e,t[e]);}}setGlobeUniformValues(e,t){if(!this.globeUniforms)return;const i=this.globeUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e]&&i[e].set(this.program,e,t[e]);}}setFogUniformValues(e,t){if(!this.fogUniforms)return;const i=this.fogUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e]);}}setCutoffUniformValues(e,t){if(!this.cutoffUniforms)return;const i=this.cutoffUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e]);}}setLightsUniformValues(e,t){if(!this.lightsUniforms)return;const i=this.lightsUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e]);}}setShadowUniformValues(e,t){if(this.failedToCreate||!this.shadowUniforms)return;const i=this.shadowUniforms;e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e]);}_drawDebugWireframe(t,i,o,r,s,n,a,l,c,h){const u=t.options.wireframe;if(!1===u.terrain&&!1===u.layers2D&&!1===u.layers3D)return;const d=t.context;if(!(()=>!(!u.terrain||"terrainRaster"!==this.name&&"globeRaster"!==this.name)||!(!u.layers2D||t._terrain&&t._terrain.renderingToTexture||!xr.includes(this.name))||!(!u.layers3D||!yr.includes(this.name)))())return;const _=d.gl,p=t.wireframeDebugCache.getLinesFromTrianglesBuffer(t.frameCounter,s,d);if(!p)return;const f=[...this.fixedDefines];f.push("DEBUG_WIREFRAME");const m=t.getOrCreateProgram(this.name,{config:this.configuration,defines:f});d.program.set(m.program);const g=(e,t,i)=>{if(t[e]&&i[e])for(const o in t[e])i[e][o]&&i[e][o].set(i.program,o,t[e][o].current);};c&&c.setUniforms(m.program,d,m.binderUniforms,a,{zoom:l}),g("fixedUniforms",this,m),g("terrainUniforms",this,m),g("globeUniforms",this,m),g("fogUniforms",this,m),g("lightsUniforms",this,m),g("shadowUniforms",this,m),p.bind(),d.setColorMode(new Mt([_.ONE,_.ONE_MINUS_SRC_ALPHA,_.ZERO,_.ONE],e.ax.transparent,[!0,!0,!0,!1])),d.setDepthMode(new Lt(i.func===_.LESS?_.LEQUAL:i.func,Lt.ReadOnly,i.range)),d.setStencilMode(Rt.disabled);const v=3*n.primitiveLength*2,x=3*n.primitiveOffset*2*2;h&&h>1?_.drawElementsInstanced(_.LINES,v,_.UNSIGNED_SHORT,x,h):_.drawElements(_.LINES,v,_.UNSIGNED_SHORT,x),s.bind(),d.program.set(this.program),d.setDepthMode(i),d.setStencilMode(o),d.setColorMode(r);}draw(e,t,i,o,r,s,n,a,l,c,h,u,d,_,p,f,m){const g=e.context,v=g.gl;if(this.failedToCreate)return;g.program.set(this.program),g.setDepthMode(i),g.setStencilMode(o),g.setColorMode(r),g.setCullFace(s);for(const e of Object.keys(this.fixedUniforms))this.fixedUniforms[e].set(this.program,e,n[e]);_&&_.setUniforms(this.program,g,this.binderUniforms,u,{zoom:d});const x={[v.POINTS]:1,[v.LINES]:2,[v.TRIANGLES]:3,[v.LINE_STRIP]:1}[t],y=m&&m.length>0;if(y){for(const e of m)v.bindBufferBase(v.TRANSFORM_FEEDBACK_BUFFER,e.targetIndex,e.buffer.buffer);v.beginTransformFeedback(t);}const b=f&&f>0?1:void 0;for(const s of h.get()){const n=s.vaos||(s.vaos={});(n[a]||(n[a]=new Qo)).bind(g,this,l,_?_.getPaintVertexBuffers():[],c,s.vertexOffset,p||[],b),f&&f>1?v.drawElementsInstanced(t,s.primitiveLength*x,v.UNSIGNED_SHORT,s.primitiveOffset*x*2,f):c?v.drawElements(t,s.primitiveLength*x,v.UNSIGNED_SHORT,s.primitiveOffset*x*2):v.drawArrays(t,s.vertexOffset,s.vertexLength),t===v.TRIANGLES&&c&&this._drawDebugWireframe(e,i,o,r,c,s,u,d,_,f);}y&&v.endTransformFeedback();}}function wr(t,i){const o=Math.pow(2,i.tileID.overscaledZ),r=i.tileSize*Math.pow(2,t.transform.tileZoom)/o,s=r*(i.tileID.canonical.x+i.tileID.wrap*o),n=r*i.tileID.canonical.y;return {u_image:0,u_texsize:i.imageAtlasTexture?i.imageAtlasTexture.size:[0,0],u_tile_units_to_pixels:1/e.a3(i,1,t.transform.tileZoom),u_pixel_coord_upper:[s>>16,n>>16],u_pixel_coord_lower:[65535&s,65535&n]}}const Tr=e.a6.create(),Er=(t,i,o,r,s,n,a,l,c,h,u,d,_,p,f,m)=>{const g=i.style.light,v=g.properties.get("position"),x=[v.x,v.y,v.z],y=e.co.create();"viewport"===g.properties.get("anchor")&&(e.co.fromRotation(y,-i.transform.angle),e.N.transformMat3(x,x,y));const b=g.properties.get("color"),w=i.transform,T={u_matrix:t,u_lightpos:x,u_lightintensity:g.properties.get("intensity"),u_lightcolor:[b.r,b.g,b.b],u_vertical_gradient:+o,u_opacity:r,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Tr,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_ao:s,u_edge_radius:n,u_flood_light_color:d,u_vertical_scale:_,u_flood_light_intensity:p,u_ground_shadow_factor:f,u_emissive_strength:m};return "globe"===w.projection.name&&(T.u_tile_id=[a.canonical.x,a.canonical.y,1<({u_matrix:e,u_edge_radius:t,u_vertical_scale:i}),Cr=(t,i,o,r,s,n,a,l,c,h,u,d,_,p)=>{const f=Er(t,i,o,r,s,n,a,c,h,u,d,_,p,1,[0,0,0],0),m={u_height_factor:-Math.pow(2,a.overscaledZ)/l.tileSize/8};return e.e(f,wr(i,l),m)},Ir=(e,t)=>({u_matrix:e,u_emissive_strength:t}),Dr=(t,i,o,r)=>e.e(Ir(t,i),wr(o,r)),Lr=(e,t,i)=>({u_matrix:e,u_world:i,u_emissive_strength:t}),Ar=(t,i,o,r,s)=>e.e(Dr(t,i,o,r),{u_world:s}),Rr=(t,i,o,r)=>{const s=e.V/o.tileSize;return {u_matrix:t,u_camera_to_center_distance:i.getCameraToCenterDistance(r),u_extrude_scale:[i.pixelsToGLUnits[0]/s,i.pixelsToGLUnits[1]/s]}},Pr=(e,t,i=1)=>({u_matrix:e,u_color:t,u_overlay:0,u_overlay_scale:i}),Mr=e.a6.create(),zr=(t,i,o,r,s,n,a)=>{const l=t.transform,c="globe"===l.projection.name,h=c?e.cp(l.zoom,i.canonical)*l._pixelsPerMercatorPixel:e.a3(o,1,n),u={u_matrix:i.projMatrix,u_extrude_scale:h,u_intensity:a,u_inv_rot_matrix:Mr,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(c){u.u_inv_rot_matrix=r,u.u_merc_center=s,u.u_tile_id=[i.canonical.x,i.canonical.y,1<{return {u_matrix:t,u_normalize_matrix:i,u_globe_matrix:o,u_merc_matrix:r,u_grid_matrix:s,u_tl_parent:n,u_scale_parent:h,u_fade_t:u.mix,u_opacity:u.opacity*d.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:d.paint.get("raster-brightness-min"),u_brightness_high:d.paint.get("raster-brightness-max"),u_saturation_factor:(T=d.paint.get("raster-saturation"),T>0?1-1/(1.001-T):-T),u_contrast_factor:(w=d.paint.get("raster-contrast"),w>0?1/(1-w):1+w),u_spin_weights:kr(d.paint.get("raster-hue-rotate")),u_perspective_transform:_,u_raster_elevation:p,u_zoom_transition:a,u_merc_center:l,u_cutoff_params:c,u_colorization_mix:Or(e.cq,m,v),u_colorization_offset:Fr(e.cq,g,v),u_color_ramp:f,u_texture_offset:[y/(x+2*y),x/(x+2*y)],u_texture_res:[x+2*y,x+2*y],u_emissive_strength:b};var w,T;};function kr(e){e*=Math.PI/180;const t=Math.sin(e),i=Math.cos(e);return [(2*i+1)/3,(-Math.sqrt(3)*t-i+1)/3,(Math.sqrt(3)*t-i+1)/3]}const Nr=(e,t,i,o,r,s,n,a,l,c,h,u)=>({u_matrix:e,u_normalize_matrix:t,u_globe_matrix:i,u_merc_matrix:o,u_grid_matrix:r,u_tl_parent:s,u_scale_parent:c,u_fade_t:h.mix,u_opacity:h.opacity,u_image0:0,u_image1:1,u_raster_elevation:u,u_zoom_transition:n,u_merc_center:a,u_cutoff_params:l}),Ur=(e,t,i,o,r,s,n,a)=>({u_tile_offset:e,u_velocity:t,u_color_ramp:o,u_velocity_res:i,u_max_speed:r,u_texture_offset:s,u_data_scale:n,u_data_offset:a}),Gr=(e,t,i,o,r,s,n,a)=>({u_velocity:e,u_velocity_res:t,u_max_speed:i,u_speed_factor:o,u_lifetime_delta:r,u_rand_seed:Math.random(),u_texture_offset:s,u_data_scale:n,u_data_offset:a}),jr=e.a6.create(),Vr=(t,i,o,r,s,n,a,l,c,h,u,d,_,p,f,m,g,v)=>{const x=s.transform,y={u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:i?i.uSizeT:0,u_size:i?i.uSize:0,u_camera_to_center_distance:x.getCameraToCenterDistance(m),u_rotate_symbol:+o,u_aspect_ratio:x.width/x.height,u_fade_change:s.options.fadeDuration?s.symbolFadeChange:1,u_matrix:n,u_label_plane_matrix:a,u_coord_matrix:l,u_is_text:+c,u_pitch_with_map:+r,u_texsize:h,u_texture:0,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:jr,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:jr,u_up_vector:[0,-1,0],u_icon_transition:v||0,u_icon_saturation:g};return "globe"===m.name&&(y.u_tile_id=[u.canonical.x,u.canonical.y,1<e.e(Vr(t,i,o,r,s,n,a,l,c,h,d,_,p,f,m,g,1),{u_gamma_scale:r?s.transform.getCameraToCenterDistance(g)*Math.cos(s.terrain?0:s.transform._pitch):1,u_device_pixel_ratio:e.f.devicePixelRatio,u_is_halo:+u,undefined:void 0}),Hr=(t,i,o,r,s,n,a,l,c,h,u,d,_,p,f,m)=>e.e(Zr(t,i,o,r,s,n,a,l,!0,c,!0,u,d,_,p,f,m),{u_texsize_icon:h,u_texture_icon:1}),Wr=(e,t,i,o)=>({u_matrix:e,u_emissive_strength:t,u_opacity:i,u_color:o}),qr=(t,i,o,r,s,n,a)=>e.e(function(t,i,o,r){const s=o.imageManager.getPattern(t.toString(),i),{width:n,height:a}=o.imageManager.getPixelSize(i),l=Math.pow(2,r.tileID.overscaledZ),c=r.tileSize*Math.pow(2,o.transform.tileZoom)/l,h=c*(r.tileID.canonical.x+r.tileID.wrap*l),u=c*r.tileID.canonical.y;return {u_image:0,u_pattern_tl:s.tl,u_pattern_br:s.br,u_texsize:[n,a],u_pattern_size:s.displaySize,u_tile_units_to_pixels:1/e.a3(r,1,o.transform.tileZoom),u_pixel_coord_upper:[h>>16,u>>16],u_pixel_coord_lower:[65535&h,65535&u]}}(s,n,r,a),{u_matrix:t,u_emissive_strength:i,u_opacity:o}),$r=(t,i,o,r,s,n,a,l,c,h,u,d,_=[0,0,0],p)=>{const f=r.style.light,m=f.properties.get("position"),g=[-m.x,-m.y,m.z],v=e.co.create();"viewport"===f.properties.get("anchor")&&(e.co.fromRotation(v,-r.transform.angle),e.N.transformMat3(g,g,v));const x="MASK"===h.alphaMode,y=f.properties.get("color"),b=d.paint.get("model-ambient-occlusion-intensity"),w=d.paint.get("model-color").constantOr(e.ax.white),T=d.paint.get("model-color-mix-intensity").constantOr(0);return {u_matrix:t,u_lighting_matrix:i,u_normal_matrix:o,u_lightpos:g,u_lightintensity:f.properties.get("intensity"),u_lightcolor:[y.r,y.g,y.b],u_camera_pos:_,u_opacity:s,u_baseTextureIsAlpha:0,u_alphaMask:+x,u_alphaCutoff:h.alphaCutoff,u_baseColorFactor:[n.r,n.g,n.b,n.a],u_emissiveFactor:[a[0],a[1],a[2],1],u_metallicFactor:l,u_roughnessFactor:c,u_baseColorTexture:go.BaseColor,u_metallicRoughnessTexture:go.MetallicRoughness,u_normalTexture:go.Normal,u_occlusionTexture:go.Occlusion,u_emissionTexture:go.Emission,u_color_mix:[w.r,w.g,w.b,T],u_aoIntensity:b,u_emissive_strength:u,u_occlusionTextureTransform:p||[0,0,0,0]}},Xr=new Float32Array(16),Kr=(e,t=Xr,i=Xr)=>({u_matrix:e,u_instance:t,u_node_matrix:i}),Yr={fillExtrusion:t=>({u_matrix:new e.bK(t),u_lightpos:new e.bM(t),u_lightintensity:new e.bN(t),u_lightcolor:new e.bM(t),u_vertical_gradient:new e.bN(t),u_opacity:new e.bN(t),u_edge_radius:new e.bN(t),u_ao:new e.bL(t),u_tile_id:new e.bM(t),u_zoom_transition:new e.bN(t),u_inv_rot_matrix:new e.bK(t),u_merc_center:new e.bL(t),u_up_dir:new e.bM(t),u_height_lift:new e.bN(t),u_flood_light_color:new e.bM(t),u_vertical_scale:new e.bN(t),u_flood_light_intensity:new e.bN(t),u_ground_shadow_factor:new e.bM(t),u_emissive_strength:new e.bN(t)}),fillExtrusionDepth:t=>({u_matrix:new e.bK(t),u_edge_radius:new e.bN(t),u_vertical_scale:new e.bN(t)}),fillExtrusionPattern:t=>({u_matrix:new e.bK(t),u_lightpos:new e.bM(t),u_lightintensity:new e.bN(t),u_lightcolor:new e.bM(t),u_vertical_gradient:new e.bN(t),u_height_factor:new e.bN(t),u_edge_radius:new e.bN(t),u_ao:new e.bL(t),u_tile_id:new e.bM(t),u_zoom_transition:new e.bN(t),u_inv_rot_matrix:new e.bK(t),u_merc_center:new e.bL(t),u_up_dir:new e.bM(t),u_height_lift:new e.bN(t),u_image:new e.bO(t),u_texsize:new e.bL(t),u_pixel_coord_upper:new e.bL(t),u_pixel_coord_lower:new e.bL(t),u_tile_units_to_pixels:new e.bN(t),u_opacity:new e.bN(t)}),fillExtrusionGroundEffect:t=>({u_matrix:new e.bK(t),u_opacity:new e.bN(t),u_ao_pass:new e.bN(t),u_meter_to_tile:new e.bN(t),u_ao:new e.bL(t),u_flood_light_intensity:new e.bN(t),u_flood_light_color:new e.bM(t),u_attenuation:new e.bN(t),u_edge_radius:new e.bN(t),u_fb:new e.bO(t),u_fb_size:new e.bN(t)}),fill:t=>({u_matrix:new e.bK(t),u_emissive_strength:new e.bN(t)}),fillPattern:t=>({u_matrix:new e.bK(t),u_emissive_strength:new e.bN(t),u_image:new e.bO(t),u_texsize:new e.bL(t),u_pixel_coord_upper:new e.bL(t),u_pixel_coord_lower:new e.bL(t),u_tile_units_to_pixels:new e.bN(t)}),fillOutline:t=>({u_matrix:new e.bK(t),u_emissive_strength:new e.bN(t),u_world:new e.bL(t)}),fillOutlinePattern:t=>({u_matrix:new e.bK(t),u_emissive_strength:new e.bN(t),u_world:new e.bL(t),u_image:new e.bO(t),u_texsize:new e.bL(t),u_pixel_coord_upper:new e.bL(t),u_pixel_coord_lower:new e.bL(t),u_tile_units_to_pixels:new e.bN(t)}),circle:e.cs,collisionBox:t=>({u_matrix:new e.bK(t),u_camera_to_center_distance:new e.bN(t),u_extrude_scale:new e.bL(t)}),collisionCircle:t=>({u_matrix:new e.bK(t),u_inv_matrix:new e.bK(t),u_camera_to_center_distance:new e.bN(t),u_viewport_size:new e.bL(t)}),debug:t=>({u_color:new e.ca(t),u_matrix:new e.bK(t),u_overlay:new e.bO(t),u_overlay_scale:new e.bN(t)}),clippingMask:t=>({u_matrix:new e.bK(t)}),heatmap:t=>({u_extrude_scale:new e.bN(t),u_intensity:new e.bN(t),u_matrix:new e.bK(t),u_inv_rot_matrix:new e.bK(t),u_merc_center:new e.bL(t),u_tile_id:new e.bM(t),u_zoom_transition:new e.bN(t),u_up_dir:new e.bM(t)}),heatmapTexture:t=>({u_image:new e.bO(t),u_color_ramp:new e.bO(t),u_opacity:new e.bN(t)}),hillshade:t=>({u_matrix:new e.bK(t),u_image:new e.bO(t),u_latrange:new e.bL(t),u_light:new e.bL(t),u_shadow:new e.ca(t),u_highlight:new e.ca(t),u_emissive_strength:new e.bN(t),u_accent:new e.ca(t)}),hillshadePrepare:t=>({u_matrix:new e.bK(t),u_image:new e.bO(t),u_dimension:new e.bL(t),u_zoom:new e.bN(t)}),line:e.ct,linePattern:e.cu,raster:t=>({u_matrix:new e.bK(t),u_normalize_matrix:new e.bK(t),u_globe_matrix:new e.bK(t),u_merc_matrix:new e.bK(t),u_grid_matrix:new e.cb(t),u_tl_parent:new e.bL(t),u_scale_parent:new e.bN(t),u_fade_t:new e.bN(t),u_opacity:new e.bN(t),u_image0:new e.bO(t),u_image1:new e.bO(t),u_brightness_low:new e.bN(t),u_brightness_high:new e.bN(t),u_saturation_factor:new e.bN(t),u_contrast_factor:new e.bN(t),u_spin_weights:new e.bM(t),u_perspective_transform:new e.bL(t),u_raster_elevation:new e.bN(t),u_zoom_transition:new e.bN(t),u_merc_center:new e.bL(t),u_cutoff_params:new e.bP(t),u_colorization_mix:new e.bP(t),u_colorization_offset:new e.bN(t),u_color_ramp:new e.bO(t),u_texture_offset:new e.bL(t),u_texture_res:new e.bL(t),u_emissive_strength:new e.bN(t)}),rasterParticle:t=>({u_matrix:new e.bK(t),u_normalize_matrix:new e.bK(t),u_globe_matrix:new e.bK(t),u_merc_matrix:new e.bK(t),u_grid_matrix:new e.cb(t),u_tl_parent:new e.bL(t),u_scale_parent:new e.bN(t),u_fade_t:new e.bN(t),u_opacity:new e.bN(t),u_image0:new e.bO(t),u_image1:new e.bO(t),u_raster_elevation:new e.bN(t),u_zoom_transition:new e.bN(t),u_merc_center:new e.bL(t),u_cutoff_params:new e.bP(t)}),rasterParticleTexture:t=>({u_texture:new e.bO(t),u_opacity:new e.bN(t)}),rasterParticleDraw:t=>({u_tile_offset:new e.bL(t),u_velocity:new e.bO(t),u_color_ramp:new e.bO(t),u_velocity_res:new e.bL(t),u_max_speed:new e.bN(t),u_texture_offset:new e.bL(t),u_data_scale:new e.bP(t),u_data_offset:new e.bN(t)}),rasterParticleUpdate:t=>({u_velocity:new e.bO(t),u_velocity_res:new e.bL(t),u_max_speed:new e.bN(t),u_speed_factor:new e.bN(t),u_lifetime_delta:new e.bN(t),u_rand_seed:new e.bN(t),u_texture_offset:new e.bL(t),u_data_scale:new e.bP(t),u_data_offset:new e.bN(t)}),symbolIcon:t=>({u_is_size_zoom_constant:new e.bO(t),u_is_size_feature_constant:new e.bO(t),u_size_t:new e.bN(t),u_size:new e.bN(t),u_camera_to_center_distance:new e.bN(t),u_rotate_symbol:new e.bO(t),u_aspect_ratio:new e.bN(t),u_fade_change:new e.bN(t),u_matrix:new e.bK(t),u_label_plane_matrix:new e.bK(t),u_coord_matrix:new e.bK(t),u_is_text:new e.bO(t),u_pitch_with_map:new e.bO(t),u_texsize:new e.bL(t),u_tile_id:new e.bM(t),u_zoom_transition:new e.bN(t),u_inv_rot_matrix:new e.bK(t),u_merc_center:new e.bL(t),u_camera_forward:new e.bM(t),u_tile_matrix:new e.bK(t),u_up_vector:new e.bM(t),u_ecef_origin:new e.bM(t),u_texture:new e.bO(t),u_icon_transition:new e.bN(t),u_icon_saturation:new e.bN(t)}),symbolSDF:t=>({u_is_size_zoom_constant:new e.bO(t),u_is_size_feature_constant:new e.bO(t),u_size_t:new e.bN(t),u_size:new e.bN(t),u_camera_to_center_distance:new e.bN(t),u_rotate_symbol:new e.bO(t),u_aspect_ratio:new e.bN(t),u_fade_change:new e.bN(t),u_matrix:new e.bK(t),u_label_plane_matrix:new e.bK(t),u_coord_matrix:new e.bK(t),u_is_text:new e.bO(t),u_pitch_with_map:new e.bO(t),u_texsize:new e.bL(t),u_texture:new e.bO(t),u_gamma_scale:new e.bN(t),u_device_pixel_ratio:new e.bN(t),u_tile_id:new e.bM(t),u_zoom_transition:new e.bN(t),u_inv_rot_matrix:new e.bK(t),u_merc_center:new e.bL(t),u_camera_forward:new e.bM(t),u_tile_matrix:new e.bK(t),u_up_vector:new e.bM(t),u_ecef_origin:new e.bM(t),u_is_halo:new e.bO(t)}),symbolTextAndIcon:t=>({u_is_size_zoom_constant:new e.bO(t),u_is_size_feature_constant:new e.bO(t),u_size_t:new e.bN(t),u_size:new e.bN(t),u_camera_to_center_distance:new e.bN(t),u_rotate_symbol:new e.bO(t),u_aspect_ratio:new e.bN(t),u_fade_change:new e.bN(t),u_matrix:new e.bK(t),u_label_plane_matrix:new e.bK(t),u_coord_matrix:new e.bK(t),u_is_text:new e.bO(t),u_pitch_with_map:new e.bO(t),u_texsize:new e.bL(t),u_texsize_icon:new e.bL(t),u_texture:new e.bO(t),u_texture_icon:new e.bO(t),u_gamma_scale:new e.bN(t),u_device_pixel_ratio:new e.bN(t),u_is_halo:new e.bO(t)}),background:t=>({u_matrix:new e.bK(t),u_emissive_strength:new e.bN(t),u_opacity:new e.bN(t),u_color:new e.ca(t)}),backgroundPattern:t=>({u_matrix:new e.bK(t),u_emissive_strength:new e.bN(t),u_opacity:new e.bN(t),u_image:new e.bO(t),u_pattern_tl:new e.bL(t),u_pattern_br:new e.bL(t),u_texsize:new e.bL(t),u_pattern_size:new e.bL(t),u_pixel_coord_upper:new e.bL(t),u_pixel_coord_lower:new e.bL(t),u_tile_units_to_pixels:new e.bN(t)}),terrainRaster:rr,terrainDepth:rr,skybox:t=>({u_matrix:new e.bK(t),u_sun_direction:new e.bM(t),u_cubemap:new e.bO(t),u_opacity:new e.bN(t),u_temporal_offset:new e.bN(t)}),skyboxGradient:t=>({u_matrix:new e.bK(t),u_color_ramp:new e.bO(t),u_center_direction:new e.bM(t),u_radius:new e.bN(t),u_opacity:new e.bN(t),u_temporal_offset:new e.bN(t)}),skyboxCapture:t=>({u_matrix_3f:new e.cb(t),u_sun_direction:new e.bM(t),u_sun_intensity:new e.bN(t),u_color_tint_r:new e.bP(t),u_color_tint_m:new e.bP(t),u_luminance:new e.bN(t)}),globeRaster:t=>({u_proj_matrix:new e.bK(t),u_globe_matrix:new e.bK(t),u_normalize_matrix:new e.bK(t),u_merc_matrix:new e.bK(t),u_zoom_transition:new e.bN(t),u_merc_center:new e.bL(t),u_image0:new e.bO(t),u_grid_matrix:new e.cb(t),u_skirt_height:new e.bN(t),u_far_z_cutoff:new e.bN(t),u_frustum_tl:new e.bM(t),u_frustum_tr:new e.bM(t),u_frustum_br:new e.bM(t),u_frustum_bl:new e.bM(t),u_globe_pos:new e.bM(t),u_globe_radius:new e.bN(t),u_viewport:new e.bL(t)}),globeAtmosphere:t=>({u_frustum_tl:new e.bM(t),u_frustum_tr:new e.bM(t),u_frustum_br:new e.bM(t),u_frustum_bl:new e.bM(t),u_horizon:new e.bN(t),u_transition:new e.bN(t),u_fadeout_range:new e.bN(t),u_color:new e.bP(t),u_high_color:new e.bP(t),u_space_color:new e.bP(t),u_temporal_offset:new e.bN(t),u_horizon_angle:new e.bN(t)}),model:t=>({u_matrix:new e.bK(t),u_lighting_matrix:new e.bK(t),u_normal_matrix:new e.bK(t),u_lightpos:new e.bM(t),u_lightintensity:new e.bN(t),u_lightcolor:new e.bM(t),u_camera_pos:new e.bM(t),u_opacity:new e.bN(t),u_baseColorFactor:new e.bP(t),u_emissiveFactor:new e.bP(t),u_metallicFactor:new e.bN(t),u_roughnessFactor:new e.bN(t),u_baseTextureIsAlpha:new e.bO(t),u_alphaMask:new e.bO(t),u_alphaCutoff:new e.bN(t),u_baseColorTexture:new e.bO(t),u_metallicRoughnessTexture:new e.bO(t),u_normalTexture:new e.bO(t),u_occlusionTexture:new e.bO(t),u_emissionTexture:new e.bO(t),u_color_mix:new e.bP(t),u_aoIntensity:new e.bN(t),u_emissive_strength:new e.bN(t),u_occlusionTextureTransform:new e.bP(t)}),modelDepth:t=>({u_matrix:new e.bK(t),u_instance:new e.bK(t),u_node_matrix:new e.bK(t)}),groundShadow:t=>({u_matrix:new e.bK(t),u_ground_shadow_factor:new e.bM(t)}),stars:t=>({u_matrix:new e.bK(t),u_up:new e.bM(t),u_right:new e.bM(t),u_intensity_multiplier:new e.bN(t)})};let Jr;function Qr(t,i,o,r,s,n,a){const l=t.context,c=l.gl,h=t.transform,u=t.getOrCreateProgram("collisionBox"),d=[];let _=0,p=0;for(let l=0;l0){const t=e.a6.create(),i=x;e.a6.mul(t,g.placementInvProjMatrix,h.glCoordMatrix),e.a6.mul(t,t,g.placementViewportMatrix),d.push({circleArray:b,circleOffset:p,transform:i,invTransform:t,projection:g.getProjection()}),_+=b.length/4,p=_;}y&&(t.terrain&&t.terrain.setupElevationDraw(m,u),u.draw(t,c.LINES,Lt.disabled,Rt.disabled,t.colorModeForRenderPass(),Ft.disabled,Rr(x,h,m,g.getProjection()),o.id,y.layoutVertexBuffer,y.indexBuffer,y.segments,null,h.zoom,null,[y.collisionVertexBuffer,y.collisionVertexBufferExt]));}if(!a||!d.length)return;const f=t.getOrCreateProgram("collisionCircle"),m=new e.cv;m.resize(4*_),m._trim();let g=0;for(const e of d)for(let t=0;t=0&&(f[y.associatedIconIndex]={x:S,y:C,z:I,angle:P});}else Di(T,_);}if(u){p.clear();const i=t.icon.placedSymbolArray;for(let t=0;t{const i=w&&"point"!==o.layout.get("symbol-placement"),a=[],c=i||D,u=o.paint.get("icon-image-cross-fade").constantOr(0);t.terrainRenderModeElevated()&&E&&a.push("PITCH_WITH_MAP_TERRAIN"),d&&(a.push("PROJECTION_GLOBE_VIEW"),c&&a.push("PROJECTED_POS_ON_VIEWPORT")),u>0&&a.push("ICON_TRANSITION"),n.icon.zOffsetVertexBuffer&&a.push("Z_OFFSET"),v<1&&a.push("SATURATION");const g=n.icon.programConfigurations.get(o.id),x=t.getOrCreateProgram(n.sdfIcons?"symbolSDF":"symbolIcon",{config:g,defines:a});let T;const S=r.imageAtlasTexture?r.imageAtlasTexture.size:[0,0],C=n.iconSizeData,I=e.b5(C,b.zoom),A=E||0!==b.pitch,P=fi(p,r.tileID.canonical,E,w,b,n.getProjection(),f),O=gi(p,r.tileID.canonical,E,w,b,n.getProjection(),f),F=t.translatePosMatrix(O,r,l,h,!0),B=t.translatePosMatrix(p,r,l,h),k=c?es:P,N=w&&!E&&!i;let U=M;!R&&!b.mercatorFromTransition||w||(U=ts(b));const G=d?U:M;T=n.sdfIcons&&!n.iconsInText?Zr(C.kind,I,N,E,t,B,k,F,!1,S,!0,s,_,L,z,G,n.getProjection()):Vr(C.kind,I,N,E,t,B,k,F,!1,S,s,_,L,z,G,n.getProjection(),v,u);const j=r.imageAtlasTexture?r.imageAtlasTexture:null,V=1!==o.layout.get("icon-size").constantOr(0)||n.iconsNeedLinear,Z=n.sdfIcons||t.options.rotating||t.options.zooming||V||A?y.LINEAR:y.NEAREST,H=n.sdfIcons&&0!==o.paint.get("icon-halo-width").constantOr(1),W=t.terrain&&E&&i?e.a6.invert(e.a6.create(),P):es;if(i&&n.icon){const e=b.elevation,i=e?e.getAtTileOffsetFunc(s,b.center.lat,b.worldSize,n.getProjection()):null,o=mi(p,r.tileID.canonical,E,w,b,n.getProjection(),f);bi(n,p,t,!1,o,O,E,m,i,s);}return {program:x,buffers:n.icon,uniformValues:T,atlasTexture:j,atlasTextureIcon:null,atlasInterpolation:Z,atlasInterpolationIcon:null,isSDF:n.sdfIcons,hasHalo:H,tile:r,labelPlaneMatrixInv:W}},F=()=>{const i=T&&"point"!==o.layout.get("symbol-placement"),a=[],l=i||A||D;t.terrainRenderModeElevated()&&S&&a.push("PITCH_WITH_MAP_TERRAIN"),d&&(a.push("PROJECTION_GLOBE_VIEW"),l&&a.push("PROJECTED_POS_ON_VIEWPORT")),n.text.zOffsetVertexBuffer&&a.push("Z_OFFSET");const h=n.text.programConfigurations.get(o.id),m=t.getOrCreateProgram(n.iconsInText?"symbolTextAndIcon":"symbolSDF",{config:h,defines:a});let v,x=[0,0],w=null;const E=n.textSizeData;n.iconsInText&&(x=r.imageAtlasTexture?r.imageAtlasTexture.size:[0,0],w=r.imageAtlasTexture?r.imageAtlasTexture:null,v=S||0!==b.pitch||t.options.rotating||t.options.zooming||"composite"===E.kind||"camera"===E.kind?y.LINEAR:y.NEAREST);const C=r.glyphAtlasTexture?r.glyphAtlasTexture.size:[0,0],I=e.b5(E,b.zoom),P=fi(p,r.tileID.canonical,S,T,b,n.getProjection(),f),O=gi(p,r.tileID.canonical,S,T,b,n.getProjection(),f),F=t.translatePosMatrix(O,r,c,u,!0),B=t.translatePosMatrix(p,r,c,u),k=l?es:P,N=T&&!S&&!i;let U=M;!R&&!b.mercatorFromTransition||T||(U=ts(b));const G=d?U:M;let j;j=n.iconsInText?Hr(E.kind,I,N,S,t,B,k,F,C,x,s,_,L,z,G,n.getProjection()):Zr(E.kind,I,N,S,t,B,k,F,!0,C,!0,s,_,L,z,G,n.getProjection());const V=r.glyphAtlasTexture?r.glyphAtlasTexture:null,Z=y.LINEAR,H=0!==o.paint.get("text-halo-width").constantOr(1),W=t.terrain&&S&&i?e.a6.invert(e.a6.create(),P):es;if(i&&n.text){const e=b.elevation,i=e?e.getAtTileOffsetFunc(s,b.center.lat,b.worldSize,n.getProjection()):null,o=mi(p,r.tileID.canonical,S,T,b,n.getProjection(),f);bi(n,p,t,!0,o,O,S,g,i,s);}return {program:m,buffers:n.text,uniformValues:j,atlasTexture:V,atlasTextureIcon:w,atlasInterpolation:Z,atlasInterpolationIcon:v,isSDF:!0,hasHalo:H,tile:r,labelPlaneMatrixInv:W}},B=n.icon.segments.get().length,k=n.text.segments.get().length,N=B&&!a.onlyText?O():null,U=k&&!a.onlyIcons?F():null,G=o.paint.get("icon-opacity").constantOr(1),j=o.paint.get("text-opacity").constantOr(1);if(C&&n.canOverlap){I=!0;const t=G&&!a.onlyText?n.icon.segments.get():[],i=j&&!a.onlyIcons?n.text.segments.get():[];for(const i of t)P.push({segments:new e.aB([i]),sortKey:i.sortKey,state:N});for(const t of i)P.push({segments:new e.aB([t]),sortKey:t.sortKey,state:U});}else a.onlyText||P.push({segments:G?n.icon.segments:new e.aB([]),sortKey:0,state:N}),a.onlyIcons||P.push({segments:j?n.text.segments:new e.aB([]),sortKey:0,state:U});}I&&P.sort(((e,t)=>e.sortKey-t.sortKey));for(const e of P){const i=e.state;if(i)if(t.terrain&&t.terrain.setupElevationDraw(i.tile,i.program,{useDepthForOcclusion:b.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:i.labelPlaneMatrixInv}),x.activeTexture.set(y.TEXTURE0),i.atlasTexture&&i.atlasTexture.bind(i.atlasInterpolation,y.CLAMP_TO_EDGE,!0),i.atlasTextureIcon&&(x.activeTexture.set(y.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,y.CLAMP_TO_EDGE,!0)),t.uploadCommonLightUniforms(t.context,i.program),i.hasHalo){const r=i.uniformValues;r.u_is_halo=1,ss(i.buffers,e.segments,o,t,i.program,D,s,n,r,2),r.u_is_halo=0;}else {if(i.isSDF){const r=i.uniformValues;i.hasHalo&&(r.u_is_halo=1,ss(i.buffers,e.segments,o,t,i.program,D,s,n,r,1)),r.u_is_halo=0;}ss(i.buffers,e.segments,o,t,i.program,D,s,n,i.uniformValues,1);}}}function ss(e,t,i,o,r,s,n,a,l,c){const h=[e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer,e.iconTransitioningVertexBuffer,e.globeExtVertexBuffer,e.zOffsetVertexBuffer];r.draw(o,o.context.gl.TRIANGLES,s,n,a,Ft.disabled,l,i.id,e.layoutVertexBuffer,e.indexBuffer,t,i.paint,o.transform.zoom,e.programConfigurations.get(i.id),h,c);}function ns(e,t,i,o,r,s,n){const a=e.context.gl,l=i.paint.get("fill-pattern"),c=l&&l.constantOr(1);let h,u,d,_,p;n?(u=c&&!i.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",h=a.LINES):(u=c?"fillPattern":"fill",h=a.TRIANGLES);for(const f of o){const o=t.getTile(f);if(c&&!o.patternsLoaded())continue;const m=o.getBucket(i);if(!m)continue;e.prepareDrawTile();const g=m.programConfigurations.get(i.id),v=e.isTileAffectedByFog(f),x=e.getOrCreateProgram(u,{config:g,overrideFog:v});c&&(e.context.activeTexture.set(a.TEXTURE0),o.imageAtlasTexture&&o.imageAtlasTexture.bind(a.LINEAR,a.CLAMP_TO_EDGE),g.updatePaintBuffers());const y=l.constantOr(null);if(y&&o.imageAtlas){const e=o.imageAtlas.patternPositions[y.toString()];e&&g.setConstantPatternPositions(e);}const b=e.translatePosMatrix(f.projMatrix,o,i.paint.get("fill-translate"),i.paint.get("fill-translate-anchor")),w=i.paint.get("fill-emissive-strength");if(n){_=m.indexBuffer2,p=m.segments2;const t=e.terrain&&e.terrain.renderingToTexture?e.terrain.drapeBufferSize:[a.drawingBufferWidth,a.drawingBufferHeight];d="fillOutlinePattern"===u&&c?Ar(b,w,e,o,t):Lr(b,w,t);}else _=m.indexBuffer,p=m.segments,d=c?Dr(b,w,e,o):Ir(b,w);e.uploadCommonUniforms(e.context,x,f.toUnwrapped()),x.draw(e,h,r,e.stencilModeForClipping(f),s,Ft.disabled,d,i.id,m.layoutVertexBuffer,_,p,i.paint,e.transform.zoom,g,void 0);}}function as(t,i,o,r,s,n,a,l){o.resetLayerRenderingStats(t);const c=t.context,h=c.gl,u=t.transform,d=o.paint.get("fill-extrusion-pattern"),_=d.constantOr(1),p=o.paint.get("fill-extrusion-opacity"),f=t.style.enable3dLights(),m=o.paint.get(f&&!_?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),g=[o.paint.get("fill-extrusion-ambient-occlusion-intensity"),m],v=o.layout.get("fill-extrusion-edge-radius"),x=v>0&&!o.paint.get("fill-extrusion-rounded-roof"),y=x?0:v,b="globe"===u.projection.name?e.cF():0,w="globe"===u.projection.name,T=w?e.S(u.zoom):0,E=[e.a5(u.center.lng),e.ae(u.center.lat)],S=o.paint.get("fill-extrusion-flood-light-color").toArray01().slice(0,3),C=o.paint.get("fill-extrusion-flood-light-intensity"),I=o.paint.get("fill-extrusion-vertical-scale"),D=vo(t,o.paint.get("fill-extrusion-cutoff-fade-range")),L=o.paint.get("fill-extrusion-emissive-strength"),A=[];let R;w&&A.push("PROJECTION_GLOBE_VIEW"),g[0]>0&&A.push("FAUX_AO"),x&&A.push("ZERO_ROOF_RADIUS"),l&&A.push("HAS_CENTROID"),C>0&&A.push("FLOOD_LIGHT"),D.shouldRenderCutoff&&A.push("RENDER_CUTOFF");const P="shadow"===t.renderPass,M=t.shadowRenderer,z=P&&!!M;t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!0);let O=[0,0,0];if(M){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(O=So(e,i)),R=A.concat(["SHADOWS_SINGLE_CASCADE"]);}const F=z?"fillExtrusionDepth":_?"fillExtrusionPattern":"fillExtrusion",B=o.getLayerRenderingStats();for(const e of r){const r=i.getTile(e),f=r.getBucket(o);if(!f||f.projection.name!==u.projection.name)continue;let m=!1;M&&(m=0===M.getMaxCascadeForTile(e.toUnwrapped()));const v=t.isTileAffectedByFog(e),x=f.programConfigurations.get(o.id),z=t.getOrCreateProgram(F,{config:x,defines:m?R:A,overrideFog:v});if(t.terrain&&t.terrain.setupElevationDraw(r,z,{useMeterToDem:!0}),!f.centroidVertexBuffer){const e=z.attributes.a_centroid_pos;void 0!==e&&h.vertexAttrib2f(e,0,0);}!P&&M&&M.setupShadows(r.tileID.toUnwrapped(),z,"vector-tile",r.tileID.overscaledZ),_&&(t.context.activeTexture.set(h.TEXTURE0),r.imageAtlasTexture&&r.imageAtlasTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),x.updatePaintBuffers());const k=d.constantOr(null);if(k&&r.imageAtlas){const e=r.imageAtlas.patternPositions[k.toString()];e&&x.setConstantPatternPositions(e);}const N=o.paint.get("fill-extrusion-vertical-gradient");let U;if(P&&M){if(_s(r.tileID,f,t))continue;const e=M.calculateShadowPassMatrixFromTile(r.tileID.toUnwrapped());U=Sr(e,y,I);}else {const i=t.translatePosMatrix(e.expandedProjMatrix,r,o.paint.get("fill-extrusion-translate"),o.paint.get("fill-extrusion-translate-anchor")),s=u.projection.createInversionMatrix(u,e.canonical);U=_?Cr(i,t,N,p,g,y,e,r,b,T,E,s,S,I):Er(i,t,N,p,g,y,e,b,T,E,s,S,I,C,O,L);}t.uploadCommonUniforms(c,z,e.toUnwrapped(),null,D);let G=f.segments;if("mercator"===u.projection.name&&!P&&(G=f.getVisibleSegments(r.tileID,t.terrain,t.transform.getFrustum(0)),!G.get().length))continue;if(B)if(P)for(const e of G.get())B.numRenderedVerticesInShadowPass+=e.primitiveLength;else for(const e of G.get())B.numRenderedVerticesInTransparentPass+=e.primitiveLength;const j=[];(t.terrain||l)&&j.push(f.centroidVertexBuffer),w&&j.push(f.layoutVertexExtBuffer),z.draw(t,c.gl.TRIANGLES,s,n,a,Ft.backCCW,U,o.id,f.layoutVertexBuffer,f.indexBuffer,G,o.paint,t.transform.zoom,x,j);}t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!1);}function ls(t,i,o,r,s,n,a,l,c,h,u,d,_,p,f,m,g,v,x){const y=t.context,b=y.gl,w=t.transform,T=t.transform.zoom,E=[],S=vo(t,o.paint.get("fill-extrusion-cutoff-fade-range"));"clear"===h?(E.push("CLEAR_SUBPASS"),x&&(E.push("CLEAR_FROM_TEXTURE"),y.activeTexture.set(b.TEXTURE0),x.bind(b.LINEAR,b.CLAMP_TO_EDGE))):"sdf"===h&&E.push("SDF_SUBPASS"),g&&E.push("HAS_CENTROID"),S.shouldRenderCutoff&&E.push("RENDER_CUTOFF");const C=o.layout.get("fill-extrusion-edge-radius"),I=(e,i,r,h,v)=>{const b=i.programConfigurations.get(o.id),w=t.isTileAffectedByFog(e),I=t.getOrCreateProgram("fillExtrusionGroundEffect",{config:b,defines:E,overrideFog:w}),D=((e,t,i,o,r,s,n,a,l,c,h)=>({u_matrix:t,u_opacity:i,u_ao_pass:o?1:0,u_meter_to_tile:r,u_ao:s,u_flood_light_intensity:n,u_flood_light_color:a,u_attenuation:l,u_edge_radius:c,u_fb:0,u_fb_size:h}))(0,h,u,c,v,[d,_*v],p,f,m,T>=17?0:C*v,x?x.size[0]:0),L=[];g&&L.push(i.hiddenByLandmarkVertexBuffer),t.uploadCommonUniforms(y,I,e.toUnwrapped(),null,S),I.draw(t,y.gl.TRIANGLES,s,n,a,l,D,o.id,i.vertexBuffer,i.indexBuffer,r,o.paint,T,b,L);};for(const s of r){const r=i.getTile(s),n=r.getBucket(o);if(!n||n.projection.name!==w.projection.name||!n.groundEffect||n.groundEffect&&!n.groundEffect.hasData())continue;const a=n.groundEffect,l=1/n.tileToMeter;{const e=t.translatePosMatrix(s.projMatrix,r,o.paint.get("fill-extrusion-translate"),o.paint.get("fill-extrusion-translate-anchor")),i=a.getDefaultSegment();I(s,a,i,e,l);}if(v)for(let n=0;n<4;n++){const a=e.cG[n](s),c=i.getTile(a);if(!c)continue;const h=c.getBucket(o);if(!h||h.projection.name!==w.projection.name||!h.groundEffect||h.groundEffect&&!h.groundEffect.hasData())continue;const u=h.groundEffect;let d,_;0===n?(d=[-e.V,0,0],_=1):1===n?(d=[e.V,0,0],_=0):2===n?(d=[0,-e.V,0],_=3):(d=[0,e.V,0],_=2);const p=u.regionSegments[_];if(!p)continue;const f=new Float32Array(16);e.a6.translate(f,s.projMatrix,d),I(s,u,p,t.translatePosMatrix(f,r,o.paint.get("fill-extrusion-translate"),o.paint.get("fill-extrusion-translate-anchor")),l);}}}function cs(t,i,o,r,s,n,a){0===r.centroidVertexArray.length&&r.createCentroidsBuffer();const l=n?n.findDEMTileFor(o):null;if(!(l&&l.dem||a))return;const c=t=>new e.P(Math.ceil((t+e.cJ)*e.cK),0),h=e=>{const t=i.getSource().minzoom,o=e=>{const t=i.getTileByID(e);if(t&&t.hasData())return t.getBucket(s)},r=[0,-1,1];for(const i of r){if(e.overscaledZ+i(u[0]=Math.min(t.min.y,i.min.y),u[1]=Math.max(t.max.y,i.max.y),u[2]=e.V-i.min.x>t.max.x?i.min.x-e.V:t.max.x,u),_=(t,i)=>(u[0]=Math.min(t.min.x,i.min.x),u[1]=Math.max(t.max.x,i.max.x),u[2]=e.V-i.min.y>t.max.y?i.min.y-e.V:t.max.y,u),p=[(e,t)=>d(e,t),(e,t)=>d(t,e),(e,t)=>_(e,t),(e,t)=>_(t,e)],f=(t,i,r,s,a,c,h)=>{if(!n)return 0;const u=[[c?r:t,c?t:r,0],[c?r:i,c?i:r,0]],d=h<0?e.V+h:h,_=[c?d:(t+i)/2,c?(t+i)/2:d,0];return 0===r&&h<0||0!==r&&h>0?n.getForTilePoints(a,[_],!0,s):u.push(_),n.getForTilePoints(o,u,!0,l),Math.max(u[0][2],u[1][2],_[2])/n.exaggeration()};for(let t=0;t<4;t++){const i=r.borderFeatureIndices[t];if(0===i.length)continue;const s=e.cG[t](o),l=h(s);if(!(l&&l instanceof e.cH))continue;if(r.borderDoneWithNeighborZ[t]===l.canonical.z)continue;0===l.centroidVertexArray.length&&l.createCentroidsBuffer();const u=n?n.findDEMTileFor(s):null;if(!(u&&u.dem||a))continue;const d=(t<2?1:5)-t,_=l.borderDoneWithNeighborZ[d]!==r.canonical.z,v=l.borderFeatureIndices[d];let x=0;if(r.canonical.z!==l.canonical.z){for(const e of i)r.showCentroid(r.featuresOnBorder[e]);if(_)for(const e of v)l.showCentroid(l.featuresOnBorder[e]);r.borderDoneWithNeighborZ[t]=l.canonical.z,l.borderDoneWithNeighborZ[d]=r.canonical.z;}for(const o of i){const i=r.featuresOnBorder[o],n=r.centroidData[i.centroidDataIndex],h=i.borders[t];let _;for(;xh[0]+3||e[0]>h[0]-3)break;l.showCentroid(_),x++;}if(_&&xh[1]-3)&&(y++,++x!==v.length);)_=l.featuresOnBorder[v[x]];if(_=l.featuresOnBorder[v[o]],y>1){const e=_.borders[d];Math.abs(h[0]-e[0])<3&&Math.abs(h[1]-e[1])<3&&(y=1,x=o+1);}else if(0===y){r.showCentroid(i);continue}const b=l.centroidData[_.centroidDataIndex];a&&1===y&&(((m=n).flags|(g=b).flags)&e.cI?(m.flags|=e.cI,g.flags|=e.cI):(m.flags&=~e.cI,g.flags&=~e.cI));const w=i.intersectsCount()>1||_.intersectsCount()>1;if(y>1)x=o,n.centroidXY=b.centroidXY=new e.P(0,0);else if(u&&u.dem&&!w){const i=p[t](n,b),o=t%2?e.V-1:0,r=f(i[0],Math.min(e.V-1,i[1]),o,u,s,t<2,i[2]);n.centroidXY=b.centroidXY=c(r);}else w?n.centroidXY=b.centroidXY=new e.P(0,0):(n.centroidXY=r.encodeBorderCentroid(i),b.centroidXY=l.encodeBorderCentroid(_));r.writeCentroidToBuffer(n),l.writeCentroidToBuffer(b);}else r.showCentroid(i);}r.borderDoneWithNeighborZ[t]=l.canonical.z,l.borderDoneWithNeighborZ[d]=r.canonical.z;}var m,g;(r.needsCentroidUpdate||!r.centroidVertexBuffer&&0!==r.centroidVertexArray.length)&&r.uploadCentroid(t);}const hs=[1,0,0],us=[0,1,0],ds=[0,0,1];function _s(t,i,o){const r=o.transform,s=o.shadowRenderer;if(!s)return !0;const n=t.toUnwrapped(),a=r.tileSize*s._cascades[o.currentShadowCascade].scale;let l=i.maxHeight;if(r.elevation){const e=r.elevation.getMinMaxForTile(t);e&&(l+=e.max);}const c=[...s.shadowDirection];c[2]=-c[2];const h=s.computeSimplifiedTileShadowVolume(n,l,a,c);if(!h)return !1;const u=[hs,us,ds,c,[c[0],0,c[2]],[0,c[1],c[2]]],d="globe"===r.projection.name,_=r.scaleZoom(a),p=e.bq.fromInvProjectionMatrix(r.invProjMatrix,r.worldSize,_,!d),f=s.getCurrentCascadeFrustum();return 0===p.intersectsPrecise(h.vertices,h.planes,u)||0===f.intersectsPrecise(h.vertices,h.planes,u)}function ps(t){return [t[0]*e.cL,t[1]*e.cL,t[2]*e.cL,0]}function fs(t,i,o,r,s,n,a,l,c){const h=r.getSource(),u=o.globeSharedBuffers;if(!u)return;let d,_,p;if(i&&(d=r.getTile(i)),h instanceof e.ap?(_=h.texture,p=e.cj(0,0,o.transform)):d&&i&&(_=d.texture,p=e.cj(i.canonical.z,i.canonical.x,o.transform)),!_||!p)return;t||(p=e.a6.scale(e.a6.create(),p,[1,-1,1]));const f=o.context,m=f.gl,g="nearest"===s.paint.get("raster-resampling")?m.NEAREST:m.LINEAR,v=o.colorModeForDrapableLayerRenderPass(n),x=a.defines;x.push("GLOBE_POLES");const y=new Lt(m.LEQUAL,Lt.ReadWrite,o.depthRangeFor3D),b=Float32Array.from(o.transform.expandedFarZProjMatrix),w=Float32Array.from(e.aT(e.ci(new e.bs(0,0,0))));o.terrain&&o.terrain.prepareDrawTile(),f.activeTexture.set(m.TEXTURE0),_.bind(g,m.CLAMP_TO_EDGE),f.activeTexture.set(m.TEXTURE1),_.bind(g,m.CLAMP_TO_EDGE),_.useMipmap&&f.extTextureFilterAnisotropic&&o.transform.pitch>20&&m.texParameterf(m.TEXTURE_2D,f.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,f.extTextureFilterAnisotropicMax);const[T,E,S,C]=i?u.getPoleBuffers(i.canonical.z,!1):u.getPoleBuffers(0,!0),I=s.paint.get("raster-elevation");let D;t?(D=T,o.renderDefaultNorthPole=0!==I):(D=E,o.renderDefaultSouthPole=0!==I);const L=ps(a.mix),A=((e,t,i,o,r,s,n,a,l,c,h,u,d)=>Br(e,t,i,new Float32Array(16),new Float32Array(9),[0,0],o,[0,0],[0,0,0,0],1,{opacity:1,mix:0},s,[0,0]||[0,0],a,2,c,h,u,1,0,d))(b,w,p,e.S(o.transform.zoom),0,s,0,I,0,L,a.offset,a.range,n),R=o.getOrCreateProgram("raster",{defines:x});o.uploadCommonUniforms(f,R,null),R.draw(o,m.TRIANGLES,y,c,v,l,A,s.id,D,S,C);}function ms(e){const t=e._nearZ,i=e.projection.farthestPixelDistance(e),o=i-t,r=.2*e.height,s=t+r;return [t,i,(s-r-t)/o,(s-t)/o]}function gs(e,t,i,o){if(e)return t instanceof ze&&e instanceof $t?t.getTextureDescriptor(e,i,!0):{texture:e.texture,mix:ps(o.mix),offset:o.offset,buffer:0,tileSize:1}}function vs(t,i,o){if(!t)return null;const r=i.getTextureDescriptor(t,o,!0);if(!r)return null;let{texture:s,mix:n,offset:a,tileSize:l,buffer:c,format:h}=r;if(!s||!h)return null;let u=!1;return "uint32"===h&&(u=!0,n[3]=0,n=Or(e.cM,n,[0,o.paint.get("raster-particle-max-speed")]),a=Fr(e.cM,a,[0,o.paint.get("raster-particle-max-speed")])),{texture:s,textureOffset:[c/(l+2*c),l/(l+2*c)],tileSize:l,scalarData:u,scale:n,offset:a,defines:["RASTER_ARRAY",{uint8:"DATA_FORMAT_UINT8",uint16:"DATA_FORMAT_UINT16",uint32:"DATA_FORMAT_UINT32"}[h]]}}function xs(e){const t=e._nearZ,i=e.projection.farthestPixelDistance(e),o=i-t,r=.2*e.height,s=t+r;return [t,i,(s-r-t)/o,(s-t)/o]}const ys=new e.ax(1,0,0,1),bs=new e.ax(0,1,0,1),ws=new e.ax(0,0,1,1),Ts=new e.ax(1,0,1,1),Es=new e.ax(0,1,1,1);function Ss(t,i,o,r,s,n,a){const l=t.context,c=t.transform,h=l.gl,u="globe"===c.projection.name,d=u?["PROJECTION_GLOBE_VIEW"]:[];let _=e.a6.clone(o.projMatrix);if(u&&e.S(c.zoom)>0){const t=e.aS(o.canonical,c),i=e.cN(t);_=e.a6.multiply(new Float32Array(16),c.globeMatrix,i),e.a6.multiply(_,c.projMatrix,_);}const p=e.a6.create();p[12]+=2*s/(e.f.devicePixelRatio*c.width),p[13]+=2*n/(e.f.devicePixelRatio*c.height),e.a6.multiply(_,p,_);const f=t.getOrCreateProgram("debug",{defines:d}),m=i.getTileByID(o.key);t.terrain&&t.terrain.setupElevationDraw(m,f);const g=Lt.disabled,v=Rt.disabled,x=t.colorModeForRenderPass(),y="$debug";l.activeTexture.set(h.TEXTURE0),t.emptyTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),u?m._makeGlobeTileDebugBuffers(t.context,c):m._makeDebugTileBoundsBuffers(t.context,c.projection);const b=m._tileDebugBuffer||t.debugBuffer,w=m._tileDebugIndexBuffer||t.debugIndexBuffer,T=m._tileDebugSegments||t.debugSegments;if(f.draw(t,h.LINE_STRIP,g,v,x,Ft.disabled,Pr(_,r),y,b,w,T,null,null,null,[m._globeTileDebugBorderBuffer]),a){const e=m.latestRawTileData,i=Math.floor((e&&e.byteLength||0)/1024);let r=o.canonical.toString();o.overscaledZ!==o.canonical.z&&(r+=` => ${o.overscaledZ}`),r+=` ${m.state}`,r+=` ${i}kb`,function(e,t){e.initDebugOverlayCanvas();const i=e.debugOverlayCanvas,o=e.context.gl,r=e.debugOverlayCanvas.getContext("2d");r.clearRect(0,0,i.width,i.height),r.shadowColor="white",r.shadowBlur=2,r.lineWidth=1.5,r.strokeStyle="white",r.textBaseline="top",r.font="bold 36px Open Sans, sans-serif",r.fillText(t,5,5),r.strokeText(t,5,5),e.debugOverlayTexture.update(i),e.debugOverlayTexture.bind(o.LINEAR,o.CLAMP_TO_EDGE);}(t,r);}const E=i.getTile(o).tileSize,S=512/Math.min(E,512)*(o.overscaledZ/c.zoom)*.5,C=m._tileDebugTextBuffer||t.debugBuffer,I=m._tileDebugTextIndexBuffer||t.quadTriangleIndexBuffer,D=m._tileDebugTextSegments||t.debugSegments;f.draw(t,h.TRIANGLES,g,v,Mt.alphaBlended,Ft.disabled,Pr(_,e.ax.transparent,S),y,C,I,D,null,null,null,[m._globeTileDebugTextBuffer]);}function Cs(e,t,i,o){Ds(e,0,t+i/2,e.transform.width,i,o);}function Is(e,t,i,o){Ds(e,t-i/2,0,i,e.transform.height,o);}function Ds(t,i,o,r,s,n){const a=t.context,l=a.gl;l.enable(l.SCISSOR_TEST),l.scissor(i*e.f.devicePixelRatio,o*e.f.devicePixelRatio,r*e.f.devicePixelRatio,s*e.f.devicePixelRatio),a.clear({color:n}),l.disable(l.SCISSOR_TEST);}const Ls=e.ay([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:As}=Ls;function Rs(e,t,i,o){e.emplaceBack(t,i,o);}class Ps{constructor(t){this.vertexArray=new e.az,this.indices=new e.aw,Rs(this.vertexArray,-1,-1,1),Rs(this.vertexArray,1,-1,1),Rs(this.vertexArray,-1,1,1),Rs(this.vertexArray,1,1,1),Rs(this.vertexArray,-1,-1,-1),Rs(this.vertexArray,1,-1,-1),Rs(this.vertexArray,-1,1,-1),Rs(this.vertexArray,1,1,-1),this.indices.emplaceBack(5,1,3),this.indices.emplaceBack(3,7,5),this.indices.emplaceBack(6,2,0),this.indices.emplaceBack(0,4,6),this.indices.emplaceBack(2,6,7),this.indices.emplaceBack(7,3,2),this.indices.emplaceBack(5,4,0),this.indices.emplaceBack(0,1,5),this.indices.emplaceBack(0,2,3),this.indices.emplaceBack(3,1,0),this.indices.emplaceBack(7,6,4),this.indices.emplaceBack(4,5,7),this.vertexBuffer=t.createVertexBuffer(this.vertexArray,As),this.indexBuffer=t.createIndexBuffer(this.indices),this.segment=e.aB.simpleSegment(0,0,36,12);}}function Ms(t,i,o,r,s,n){const a=t.context.gl,l=i.paint.get("sky-atmosphere-color"),c=i.paint.get("sky-atmosphere-halo-color"),h=i.paint.get("sky-atmosphere-sun-intensity"),u=((e,t,i,o,r)=>({u_matrix_3f:e,u_sun_direction:t,u_sun_intensity:i,u_color_tint_r:[o.r,o.g,o.b,o.a],u_color_tint_m:[r.r,r.g,r.b,r.a],u_luminance:5e-5}))(e.co.fromMat4(e.co.create(),r),s,h,l,c);a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+n,i.skyboxTexture,0),o.draw(t,a.TRIANGLES,Lt.disabled,Rt.disabled,Mt.unblended,Ft.frontCW,u,"skyboxCapture",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment);}const zs=e.ay([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class Os{constructor(t){const i=new e.cO;i.emplaceBack(-1,1,1,0,0),i.emplaceBack(1,1,1,1,0),i.emplaceBack(1,-1,1,1,1),i.emplaceBack(-1,-1,1,0,1);const o=new e.aw;o.emplaceBack(0,1,2),o.emplaceBack(2,3,0),this.vertexBuffer=t.createVertexBuffer(i,zs.members),this.indexBuffer=t.createIndexBuffer(o),this.segments=e.aB.simpleSegment(0,0,4,2);}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy();}}const Fs=e.ay([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_size_scale",components:1},{type:"Float32",name:"a_fade_opacity",components:1}]);class Bs{constructor(){this.starsCount=16e3,this.sizeMultiplier=.15,this.sizeRange=100,this.intensityRange=200;}}class ks{constructor(t){this.colorModeAlphaBlendedWriteRGB=new Mt([1,Pt,1,Pt],e.ax.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new Mt([1,0,1,0],e.ax.transparent,[!1,!1,!1,!0]),this.params=new Bs,this.updateNeeded=!0,t.tp.registerParameter(this.params,["Stars"],"starsCount",{min:100,max:16e3,step:1},(()=>{this.updateNeeded=!0;})),t.tp.registerParameter(this.params,["Stars"],"sizeMultiplier",{min:.01,max:2,step:.01}),t.tp.registerParameter(this.params,["Stars"],"sizeRange",{min:0,max:200,step:1},(()=>{this.updateNeeded=!0;})),t.tp.registerParameter(this.params,["Stars"],"intensityRange",{min:0,max:200,step:1},(()=>{this.updateNeeded=!0;}));}update(t){const i=t.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new Os(i);const t=this.params.sizeRange,o=this.params.intensityRange,r=function(t){const i=e.aA(30),o=[];for(let r=0;r{const i="globe"===s.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];e&&i.push("ALPHA_PASS");const u=t.getOrCreateProgram("globeAtmosphere",{defines:i}),_=((e,t,i,o,r,s,n,a,l,c,h,u)=>({u_frustum_tl:e,u_frustum_tr:t,u_frustum_br:i,u_frustum_bl:o,u_horizon:r,u_transition:s,u_fadeout_range:n,u_color:a,u_high_color:l,u_space_color:c,u_temporal_offset:h,u_horizon_angle:u}))(s.frustumCorners.TL,s.frustumCorners.TR,s.frustumCorners.BR,s.frustumCorners.BL,s.frustumCorners.horizon,a,d,l,c,h,p,g);t.uploadCommonUniforms(o,u);const f=this.atmosphereBuffer;f&&u.draw(t,r.TRIANGLES,n,Rt.disabled,e?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,Ft.backCW,_,e?"atmosphere_glow_alpha":"atmosphere_glow",f.vertexBuffer,f.indexBuffer,f.segments);};v(!1),v(!0);}drawStars(t,i){const o=e.aa(i.properties.get("star-intensity"),0,1);if(0===o)return;const r=t.context,s=r.gl,n=t.transform,a=t.getOrCreateProgram("stars"),l=e.bi.identity([]);e.bi.rotateX(l,l,-n._pitch),e.bi.rotateZ(l,l,-n.angle),e.bi.rotateX(l,l,e.bj(n._center.lat)),e.bi.rotateY(l,l,-e.bj(n._center.lng));const c=e.a6.fromQuat(new Float32Array(16),l),h=e.a6.multiply([],n.starsProjMatrix,c),u=e.co.fromMat4([],c),d=e.co.invert([],u),_=[0,1,0];e.N.transformMat3(_,_,d),e.N.scale(_,_,this.params.sizeMultiplier);const p=[1,0,0];e.N.transformMat3(p,p,d),e.N.scale(p,p,this.params.sizeMultiplier);const f=(m=_,g=p,v=o,{u_matrix:Float32Array.from(h),u_up:m,u_right:g,u_intensity_multiplier:v});var m,g,v;t.uploadCommonUniforms(r,a),this.starsVx&&this.starsIdx&&a.draw(t,s.TRIANGLES,Lt.disabled,Rt.disabled,this.colorModeAlphaBlendedWriteRGB,Ft.disabled,f,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments);}}function Ns(t,i){const o=[...t],r=i.cameraWorldSizeForFog/i.worldSize,s=e.a6.identity([]);return e.a6.scale(s,s,[r,r,1]),e.a6.multiply(o,s,o),e.a6.multiply(o,i.worldToFogMatrix,o),o}function Us(e,t,i,o){const r=i.material,s=o.context,{baseColorTexture:n,metallicRoughnessTexture:a}=r.pbrMetallicRoughness,{normalTexture:l,occlusionTexture:c,emissionTexture:h}=r;function u(t,i,o){if(t&&(e.push(i),s.activeTexture.set(s.gl.TEXTURE0+o),t.gfxTexture)){const{minFilter:e,magFilter:i,wrapS:o,wrapT:r}=t.sampler;t.gfxTexture.bindExtraParam(e,i,o,r);}}u(n,"HAS_TEXTURE_u_baseColorTexture",go.BaseColor),u(a,"HAS_TEXTURE_u_metallicRoughnessTexture",go.MetallicRoughness),u(l,"HAS_TEXTURE_u_normalTexture",go.Normal),u(c,"HAS_TEXTURE_u_occlusionTexture",go.Occlusion),u(h,"HAS_TEXTURE_u_emissionTexture",go.Emission),i.texcoordBuffer&&(e.push("HAS_ATTRIBUTE_a_uv_2f"),t.push(i.texcoordBuffer)),i.colorBuffer&&(e.push(12===i.colorBuffer.itemSize?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),t.push(i.colorBuffer)),i.normalBuffer&&(e.push("HAS_ATTRIBUTE_a_normal_3f"),t.push(i.normalBuffer)),i.pbrBuffer&&(e.push("HAS_ATTRIBUTE_a_pbr"),e.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),t.push(i.pbrBuffer)),"OPAQUE"!==r.alphaMode&&"MASK"!==r.alphaMode||e.push("UNPREMULT_TEXTURE_IN_SHADER"),r.defined||e.push("DIFFUSE_SHADED"),e.push("USE_STANDARD_DERIVATIVES");}function Gs(t,i,o,r,s,n){const a=o.paint.get("model-opacity"),l=i.context,c=new Lt(i.context.gl.LEQUAL,Lt.ReadWrite,i.depthRangeFor3D),h=i.transform,u=t.mesh,d=u.material,_=d.pbrMetallicRoughness,p=i.style.fog;let f;f="pixels"===i.transform.projection.zAxisUnit?[...t.nodeModelMatrix]:e.a6.multiply([],r.zScaleMatrix,t.nodeModelMatrix),e.a6.multiply(f,r.negCameraPosMatrix,f);const m=e.a6.invert([],f);e.a6.transpose(m,m);const g=o.paint.get("model-emissive-strength").constantOr(0),v=$r(new Float32Array(t.worldViewProjection),new Float32Array(f),new Float32Array(m),i,a,_.baseColorFactor,d.emissiveFactor,_.metallicFactor,_.roughnessFactor,d,g,o),x={defines:[]},y=[];Us(x.defines,y,u,i);const b=i.shadowRenderer;b&&(b.useNormalOffset=!1);let w=null;if(p){const e=Ns(t.nodeModelMatrix,i.transform);if(w=new Float32Array(e),"globe"!==h.projection.name){const t=u.aabb.min,i=u.aabb.max,[o,r]=p.getOpacityForBounds(e,t[0],t[1],i[0],i[1]);x.overrideFog=o>=me||r>=me;}}const T=vo(i,o.paint.get("model-cutoff-fade-range"));T.shouldRenderCutoff&&x.defines.push("RENDER_CUTOFF");const E=i.getOrCreateProgram("model",x);i.uploadCommonUniforms(l,E,null,w,T),"shadow"!==i.renderPass&&b&&b.setupShadowsFromMatrix(t.nodeModelMatrix,E),E.draw(i,l.gl.TRIANGLES,c,s,n,u.material.doubleSided?Ft.disabled:Ft.backCCW,v,o.id,u.vertexBuffer,u.indexBuffer,u.segments,o.paint,i.transform.zoom,void 0,y);}function js(t,i,o,r,s,n,a){let l;l="globe"===t.projection.name?e.cS(o,t):[...o],e.a6.multiply(l,l,i.matrix);const c=e.a6.multiply([],r,l);if(i.meshes)for(const t of i.meshes){if("BLEND"!==t.material.alphaMode){a.push({mesh:t,depth:0,modelIndex:s,worldViewProjection:c,nodeModelMatrix:l});continue}const i=e.N.transformMat4([],t.centroid,c);i[2]>0&&n.push({mesh:t,depth:i[2],modelIndex:s,worldViewProjection:c,nodeModelMatrix:l});}if(i.children)for(const e of i.children)js(t,e,o,r,s,n,a);}function Vs(e,t,i,o){const r=i.shadowRenderer;if(!r)return;const s=r.getShadowPassDepthMode(),n=r.getShadowPassColorMode(),a=r.calculateShadowPassMatrixFromMatrix(t),l=Kr(a);i.getOrCreateProgram("modelDepth",{defines:i._shadowMapDebug?[]:["DEPTH_TEXTURE"]}).draw(i,i.context.gl.TRIANGLES,s,Rt.disabled,n,Ft.backCCW,l,o.id,e.vertexBuffer,e.indexBuffer,e.segments,o.paint,i.transform.zoom,void 0,void 0);}function Zs(t,i,o){const r=i.updateZoomBasedPaintProperties(),s=function(t,i,o){let r,s,n,a=t.terrain?t.terrain.exaggeration():0;if(t.terrain&&a>0){const i=t.terrain,s=i.findDEMTileFor(o);s&&s.dem?r=e.cU.create(i,o,s):a=0;}if(0===a&&(i.terrainElevationMin=0,i.terrainElevationMax=0),a===i.validForExaggeration&&(0===a||r&&r._demTile&&r._demTile.tileID===i.validForDEMTile.id&&r._dem._timestamp===i.validForDEMTile.timestamp))return !1;for(const e in i.instancesPerModel){const t=i.instancesPerModel[e];for(let e=0;eh&&(h=e.max);}const u=e.aa(r.x,n,a)-r.x,d=e.aa(r.y,l,c)-r.y,_=e.bl(h,i.center.lat)-r.z;return i._zoomFromMercatorZ(Math.sqrt(u*u+d*d+_*_))}function qs(e,t,i,o,r,s,n){const a=e.context,l="shadow"===e.renderPass,c=e.shadowRenderer,h=l&&c?c.getShadowPassDepthMode():new Lt(a.gl.LEQUAL,Lt.ReadWrite,e.depthRangeFor3D),u=e.isTileAffectedByFog(s);if(i.meshes)for(const d of i.meshes){const _=["MODEL_POSITION_ON_GPU"],p=[];let f,m,g;o.instancedDataArray.length>20&&_.push("INSTANCED_ARRAYS");const v=vo(e,t.paint.get("model-cutoff-fade-range"));if(v.shouldRenderCutoff&&_.push("RENDER_CUTOFF"),l&&c)f=e.getOrCreateProgram("modelDepth",{defines:_}),m=Kr(n.shadowTileMatrix,n.shadowTileMatrix,Float32Array.from(i.matrix)),g=c.getShadowPassColorMode();else {Us(_,p,d,e),f=e.getOrCreateProgram("model",{defines:_,overrideFog:u});const o=d.material,l=o.pbrMetallicRoughness,h=t.paint.get("model-opacity"),x=t.paint.get("model-emissive-strength").constantOr(0);m=$r(s.expandedProjMatrix,Float32Array.from(i.matrix),new Float32Array(16),e,h,l.baseColorFactor,o.emissiveFactor,l.metallicFactor,l.roughnessFactor,o,x,t,r),c&&(n.shadowUniformsInitialized?f.setShadowUniformValues(a,c.getShadowUniformValues()):(c.setupShadows(s.toUnwrapped(),f,"model-tile",s.overscaledZ),n.shadowUniformsInitialized=!0)),g=v.shouldRenderCutoff||h<1||"OPAQUE"!==o.alphaMode?Mt.alphaBlended:Mt.unblended;}e.uploadCommonUniforms(a,f,s.toUnwrapped(),null,v);const x=d.material.doubleSided?Ft.disabled:Ft.backCCW;if(o.instancedDataArray.length>20)p.push(o.instancedDataBuffer),f.draw(e,a.gl.TRIANGLES,h,Rt.disabled,g,x,m,t.id,d.vertexBuffer,d.indexBuffer,d.segments,t.paint,e.transform.zoom,void 0,p,o.instancedDataArray.length);else {const i=l?"u_instance":"u_normal_matrix";for(let r=0;r30&&(i.buf.destroy(),this._storage.delete(t));}destroy(){for(const[e,t]of this._storage)t.buf.destroy(),this._storage.delete(e);}}class Js{registerParameter(e,t,i,o,r){}registerButton(e,t,i){}}const Qs={symbol:function(t,i,o,r,s){if("translucent"!==t.renderPass)return;const n=Rt.disabled,a=t.colorModeForRenderPass();o.layout.get("text-variable-anchor")&&function(t,i,o,r,s,n,a){const l=i.transform,c="map"===s,h="map"===n;for(const i of t){const t=r.getTile(i),s=t.getBucket(o);if(!s||!s.text||!s.text.segments.get().length)continue;const n=e.b5(s.textSizeData,l.zoom),u=zi(i,s.getProjection(),l),d=l.calculatePixelsToTileUnitsMatrix(t),_=fi(u,t.tileID.canonical,h,c,l,s.getProjection(),d),p=s.hasIconTextFit()&&s.hasIconData();if(n){const o=Math.pow(2,l.zoom-t.tileID.overscaledZ);os(s,c,h,a,e.cx,l,_,i,o,n,p);}}}(r,t,o,i,o.layout.get("text-rotation-alignment"),o.layout.get("text-pitch-alignment"),s);const l=0!==o.paint.get("icon-opacity").constantOr(1),c=0!==o.paint.get("text-opacity").constantOr(1);void 0!==o.layout.get("symbol-sort-key").constantOr(1)&&(l||c)?rs(t,i,o,r,n,a):(l&&rs(t,i,o,r,n,a,{onlyIcons:!0}),c&&rs(t,i,o,r,n,a,{onlyText:!0})),i.map.showCollisionBoxes&&(Qr(t,i,o,r,o.paint.get("text-translate"),o.paint.get("text-translate-anchor"),!0),Qr(t,i,o,r,o.paint.get("icon-translate"),o.paint.get("icon-translate-anchor"),!1));},circle:function(t,i,o,r){if("translucent"!==t.renderPass)return;const s=o.paint.get("circle-opacity"),n=o.paint.get("circle-stroke-width"),a=o.paint.get("circle-stroke-opacity"),l=void 0!==o.layout.get("circle-sort-key").constantOr(1),c=o.paint.get("circle-emissive-strength");if(0===s.constantOr(1)&&(0===n.constantOr(1)||0===a.constantOr(1)))return;const h=t.context,u=h.gl,d=t.transform,_=t.depthModeForSublayer(0,Lt.ReadOnly),p=Rt.disabled,f=t.colorModeForDrapableLayerRenderPass(c),m="globe"===d.projection.name,g=[e.a5(d.center.lng),e.ae(d.center.lat)],v=[];for(let s=0;se.sortKey-t.sortKey));const x={useDepthForOcclusion:d.depthOcclusionForSymbolsAndCircles};for(const e of v){const{programConfiguration:i,program:r,layoutVertexBuffer:s,globeExtVertexBuffer:n,indexBuffer:a,uniformValues:l,tile:c}=e.state,m=e.segments;t.terrain&&t.terrain.setupElevationDraw(c,r,x),t.uploadCommonUniforms(h,r,c.tileID.toUnwrapped()),r.draw(t,u.TRIANGLES,_,p,f,Ft.disabled,l,o.id,s,a,m,o.paint,d.zoom,i,[n]);}},heatmap:function(t,i,o,r){if(0!==o.paint.get("heatmap-opacity"))if("offscreen"===t.renderPass){const s=t.context,n=s.gl,a=Rt.disabled,l=new Mt([n.ONE,n.ONE,n.ONE,n.ONE],e.ax.transparent,[!0,!0,!0,!0]);!function(e,t,i,o){const r=e.gl,s=t.width*o,n=t.height*o;e.activeTexture.set(r.TEXTURE1),e.viewport.set([0,0,s,n]);let a=i.heatmapFbo;if(!a||a&&(a.width!==s||a.height!==n)){a&&a.destroy();const t=r.createTexture();r.bindTexture(r.TEXTURE_2D,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),a=i.heatmapFbo=e.createFramebuffer(s,n,!0,null),function(e,t,i,o,r,s){const n=e.gl;n.texImage2D(n.TEXTURE_2D,0,e.extRenderToTextureHalfFloat?n.RGBA16F:n.RGBA,r,s,0,n.RGBA,e.extRenderToTextureHalfFloat?n.HALF_FLOAT:n.UNSIGNED_BYTE,null),o.colorAttachment.set(i);}(e,0,t,a,s,n);}else r.bindTexture(r.TEXTURE_2D,a.colorAttachment.get()),e.bindFramebuffer.set(a.framebuffer);}(s,t,o,"globe"===t.transform.projection.name?.5:.25),s.clear({color:e.ax.transparent});const c=t.transform,h="globe"===c.projection.name,u=h?["PROJECTION_GLOBE_VIEW"]:[],d=h?Ft.frontCCW:Ft.disabled,_=[e.a5(c.center.lng),e.ae(c.center.lat)];for(let e=0;e({u_image:0,u_color_ramp:1,u_opacity:t.paint.get("heatmap-opacity")}))(0,i),i.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,i.paint,t.transform.zoom);}(t,o));},line:function(t,i,o,r){if("translucent"!==t.renderPass)return;const s=o.paint.get("line-opacity"),n=o.paint.get("line-width");if(0===s.constantOr(1)||0===n.constantOr(1))return;const a=o.paint.get("line-emissive-strength"),l=t.depthModeForSublayer(0,Lt.ReadOnly),c=t.colorModeForDrapableLayerRenderPass(a),h=t.terrain&&t.terrain.renderingToTexture?1:e.f.devicePixelRatio,u=o.paint.get("line-dasharray"),d=u.constantOr(1),_=o.layout.get("line-cap"),p=o.paint.get("line-pattern"),f=p.constantOr(1),m=o.paint.get("line-pattern").constantOr(1),g=1!==o.paint.get("line-opacity").constantOr(1);let v=!m&&g;const x=o.paint.get("line-gradient"),y=f?"linePattern":"line",b=t.context,w=b.gl,T=e.cA(o);t.terrain&&t.terrain.clipOrMaskOverlapStencilType()&&(v=!1);for(const s of r){const r=i.getTile(s);if(f&&!r.patternsLoaded())continue;const n=r.getBucket(o);if(!n)continue;t.prepareDrawTile();const a=n.programConfigurations.get(o.id),m=t.isTileAffectedByFog(s),g=t.getOrCreateProgram(y,{config:a,defines:T,overrideFog:m}),E=p.constantOr(null);if(E&&r.imageAtlas){const e=r.imageAtlas.patternPositions[E.toString()];e&&a.setConstantPatternPositions(e);}const S=u.constantOr(null),C=_.constantOr(null);if(!f&&S&&C&&r.lineAtlas){const e=r.lineAtlas.getDash(S,C);e&&a.setConstantPatternPositions(e);}let[I,D]=o.paint.get("line-trim-offset");if("round"===C||"square"===C){const e=1;I!==D&&(0===I&&(I-=e),1===D&&(D+=e));}const L=t.terrain?s.projMatrix:null,A=f?e.cB(t,r,o,L,h,[I,D]):e.cC(t,r,o,L,n.lineClipsArray.length,h,[I,D]);if(x){const r=n.gradients[o.id];let a=r.texture;if(o.gradientVersion!==r.version){let l=256;if(o.stepInterpolant){const o=i.getSource().maxzoom,r=s.canonical.z===o?Math.ceil(1<{g.draw(t,w.TRIANGLES,l,e,c,Ft.disabled,A,o.id,n.layoutVertexBuffer,n.indexBuffer,n.segments,o.paint,t.transform.zoom,a,[n.layoutVertexBuffer2]);};if(v){const e=t.stencilModeForClipping(s).ref;0===e&&t.terrain&&b.clear({stencil:0});const i={func:w.EQUAL,mask:255};A.u_alpha_discard_threshold=.8,R(new Rt(i,e,255,w.KEEP,w.KEEP,w.INVERT)),A.u_alpha_discard_threshold=0,R(new Rt(i,e,255,w.KEEP,w.KEEP,w.KEEP));}else R(t.stencilModeForClipping(s));}v&&(t.resetStencilClippingMasks(),t.terrain&&b.clear({stencil:0}));},fill:function(t,i,o,r){const s=o.paint.get("fill-color"),n=o.paint.get("fill-opacity");if(0===n.constantOr(1))return;const a=o.paint.get("fill-emissive-strength"),l=t.colorModeForDrapableLayerRenderPass(a),c=o.paint.get("fill-pattern"),h=t.opaquePassEnabledForLayer()&&!c.constantOr(1)&&1===s.constantOr(e.ax.transparent).a&&1===n.constantOr(0)?"opaque":"translucent";if(t.renderPass===h){const e=t.depthModeForSublayer(1,"opaque"===t.renderPass?Lt.ReadWrite:Lt.ReadOnly);ns(t,i,o,r,e,l,!1);}if("translucent"===t.renderPass&&o.paint.get("fill-antialias")){const e=t.depthModeForSublayer(o.getPaintProperty("fill-outline-color")?2:0,Lt.ReadOnly);ns(t,i,o,r,e,l,!0);}},"fill-extrusion":function(t,i,o,r){const s=o.paint.get("fill-extrusion-opacity"),n=t.context,a=n.gl,l=t.terrain,c=l&&l.renderingToTexture;if(0===s)return;const h=t.conflationActive&&t.layerUsedInConflation(o,i.getSource());if(h&&function(e,t,i,o){for(const r of o){const o=t.getTile(r).getBucket(i);o&&(o.updateReplacement(r,e.replacementSource),o.uploadCentroid(e.context));}}(t,i,o,r),l||h)for(const e of r){const r=i.getTile(e).getBucket(o);r&&cs(t.context,i,e,r,o,l,h);}if("shadow"===t.renderPass&&t.shadowRenderer){const n=t.shadowRenderer;if(l&&s<.65&&o._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof e.Z)return;const a=n.getShadowPassDepthMode(),c=n.getShadowPassColorMode();as(t,i,o,r,a,Rt.disabled,c,h);}else if("translucent"===t.renderPass){const u=!o.paint.get("fill-extrusion-pattern").constantOr(1),d=o.paint.get("fill-extrusion-color").constantOr(e.ax.white);if(!c&&0!==d.a){const e=new Lt(t.context.gl.LEQUAL,Lt.ReadWrite,t.depthRangeFor3D);1===s&&u?as(t,i,o,r,e,Rt.disabled,Mt.unblended,h):(as(t,i,o,r,e,Rt.disabled,Mt.disabled,h),as(t,i,o,r,e,t.stencilModeFor3D(),t.colorModeForRenderPass(),h),t.resetStencilClippingMasks());}if(t.style.enable3dLights()&&u&&(!l&&"globe"!==t.transform.projection.name||c)){const s=o.paint.get("fill-extrusion-opacity"),u=o.paint.get("fill-extrusion-ambient-occlusion-intensity"),d=o.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),_=o.paint.get("fill-extrusion-flood-light-intensity"),p=o.paint.get("fill-extrusion-flood-light-color").toArray01().slice(0,3),f=u>0&&d>0,m=_>0,g=(e,t,i)=>(1-i)*e+i*t,v=n=>{const l=t.depthModeForSublayer(1,Lt.ReadOnly,a.LEQUAL,!0),c=o.paint.get(n?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),f=g(.1,3,c),m=t._showOverdrawInspector;if(!m){const c=new Rt({func:a.ALWAYS,mask:255},255,255,a.KEEP,a.KEEP,a.REPLACE),m=new Mt([a.ONE,a.ONE,a.ONE,a.ONE],e.ax.transparent,[!1,!1,!1,!0],a.MIN);ls(t,i,o,r,l,c,m,Ft.disabled,n,"sdf",s,u,d,_,p,f,h,!1);}{const c=m?Rt.disabled:new Rt({func:a.EQUAL,mask:255},255,255,a.KEEP,a.DECR,a.DECR),g=m?t.colorModeForRenderPass():new Mt([a.ONE_MINUS_DST_ALPHA,a.DST_ALPHA,a.ONE,a.ONE],e.ax.transparent,[!0,!0,!0,!0]);ls(t,i,o,r,l,c,g,Ft.disabled,n,"color",s,u,d,_,p,f,h,!1);}};if(c){const c=(n,l,c)=>{const f=t.depthModeForSublayer(1,Lt.ReadOnly,a.LEQUAL,!1),m=o.paint.get(n?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),v=g(.1,3,m);{const c=new Mt([a.ONE,a.ONE,a.ONE,a.ONE],e.ax.transparent,[!1,!1,!1,!0]);ls(t,i,o,r,f,Rt.disabled,c,Ft.disabled,n,"clear",s,u,d,_,p,v,h,l);}{const c=new Rt({func:a.ALWAYS,mask:255},255,255,a.KEEP,a.KEEP,a.REPLACE),m=new Mt([a.ONE,a.ONE,a.ONE,a.ONE],e.ax.transparent,[!1,!1,!1,!0],a.MIN);ls(t,i,o,r,f,c,m,Ft.disabled,n,"sdf",s,u,d,_,p,v,h,l);}{const c=n?a.ZERO:a.ONE_MINUS_DST_ALPHA,m=new Rt({func:a.EQUAL,mask:255},255,255,a.KEEP,a.DECR,a.DECR),g=new Mt([c,a.DST_ALPHA,a.ONE_MINUS_DST_ALPHA,a.ZERO],e.ax.transparent,[!0,!0,!0,!0]);ls(t,i,o,r,f,m,g,Ft.disabled,n,"color",s,u,d,_,p,v,h,l);}{const m=new Mt([a.ONE,a.ONE,a.ONE,n?a.ZERO:a.ONE],e.ax.transparent,[!1,!1,!1,!0],n?a.FUNC_ADD:a.MAX);ls(t,i,o,r,f,Rt.disabled,m,Ft.disabled,n,"clear",s,u,d,_,p,v,h,l,c);}};if(f||m){let i;if(t.prepareDrawTile(),l){const t=l.drapeBufferSize[0],o=l.drapeBufferSize[1];i=l.framebufferCopyTexture,i&&(!i||i.size[0]===t&&i.size[1]===o)||(i&&i.destroy(),i=l.framebufferCopyTexture=new e.T(n,new e.h({width:t,height:o}),a.RGBA)),i.bind(a.LINEAR,a.CLAMP_TO_EDGE),a.copyTexImage2D(a.TEXTURE_2D,0,a.RGBA,0,0,t,o,0);}f&&c(!0,!1,i),m&&c(!1,!0,i);}}else f&&v(!0),m&&v(!1);}}},hillshade:function(e,t,i,o){if("offscreen"!==e.renderPass&&"translucent"!==e.renderPass)return;if(e.style.disableElevatedTerrain)return;const r=e.context,s=e.terrain&&e.terrain.renderingToTexture,[n,a]="translucent"!==e.renderPass||s?[{},o]:e.stencilConfigForOverlap(o);for(const o of a){const r=t.getTile(o);if(r.needsHillshadePrepare&&"offscreen"===e.renderPass)or(e,r,i);else if("translucent"===e.renderPass){const t=e.depthModeForSublayer(0,Lt.ReadOnly),a=i.paint.get("hillshade-emissive-strength"),l=e.colorModeForDrapableLayerRenderPass(a),c=s&&e.terrain?e.terrain.stencilModeForRTTOverlap(o):n[o.overscaledZ];tr(e,o,r,i,t,c,l);}}r.viewport.set([0,0,e.width,e.height]),e.resetStencilClippingMasks();},raster:function(t,i,o,r,s,n){if("translucent"!==t.renderPass)return;if(0===o.paint.get("raster-opacity"))return;const a="globe"===t.transform.projection.name,l=0!==o.paint.get("raster-elevation"),c=l&&a;if(t.renderElevatedRasterBackface&&!c)return;const h=t.context,u=h.gl,d=i.getSource(),_=function(t,i,o,r){const s=i.paint.get("raster-color"),n="raster-array"===t.type,a=[],l=i.paint.get("raster-resampling"),c=i.paint.get("raster-color-mix");let h=i.paint.get("raster-color-range");const u=[c[0],c[1],c[2],0],d=c[3];let _="nearest"===l?r.NEAREST:r.LINEAR;if(n&&(a.push("RASTER_ARRAY"),s||a.push("RASTER_COLOR"),"linear"===l&&a.push("RASTER_ARRAY_LINEAR"),_=r.NEAREST,!h&&t.rasterLayers)){const e=t.rasterLayers.find((({id:e})=>e===i.sourceLayer));e&&e.fields&&e.fields.range&&(h=e.fields.range);}if(h=h||[0,1],s){a.push("RASTER_COLOR"),o.activeTexture.set(r.TEXTURE2),i.updateColorRamp(h);let t=i.colorRampTexture;t||(t=i.colorRampTexture=new e.T(o,i.colorRamp,r.RGBA)),t.bind(r.LINEAR,r.CLAMP_TO_EDGE);}return {mix:u,range:h,offset:d,defines:a,resampling:_}}(d,o,h,u);if(d instanceof e.ap&&!r.length&&!a)return;const p=o.paint.get("raster-emissive-strength"),f=t.colorModeForDrapableLayerRenderPass(p),m=t.terrain&&t.terrain.renderingToTexture,g=!t.options.moving,v="nearest"===o.paint.get("raster-resampling")?u.NEAREST:u.LINEAR;if(d instanceof e.ap&&!r.length&&(d.onNorthPole||d.onSouthPole)){const e=l?t.stencilModeFor3D():Rt.disabled;return void fs(!!d.onNorthPole,null,t,i,o,p,_,Ft.disabled,e)}if(!r.length)return;const[x,y]=d instanceof e.ap||m?[{},r]:t.stencilConfigForOverlap(r),b=y[y.length-1].overscaledZ;c&&_.defines.push("PROJECTION_GLOBE_VIEW"),l&&_.defines.push("RENDER_CUTOFF");const w=(r,s,y)=>{for(const w of r){const r=w.toUnwrapped(),T=i.getTile(w);if(m&&(!T||!T.hasData()))continue;h.activeTexture.set(u.TEXTURE0);const E=gs(T,d,o,_);if(!E||!E.texture)continue;const{texture:S,mix:C,offset:I,tileSize:D,buffer:L}=E;let A,R;m?(A=Lt.disabled,R=w.projMatrix):l?(A=new Lt(u.LEQUAL,Lt.ReadWrite,t.depthRangeFor3D),R=a?Float32Array.from(t.transform.expandedFarZProjMatrix):t.transform.calculateProjMatrix(r,g)):(A=t.depthModeForSublayer(w.overscaledZ-b,1===o.paint.get("raster-opacity")?Lt.ReadWrite:Lt.ReadOnly,u.LESS),R=t.transform.calculateProjMatrix(r,g));const P=t.terrain&&m?t.terrain.stencilModeForRTTOverlap(w):x[w.overscaledZ],M=n?0:o.paint.get("raster-fade-duration");T.registerFadeDuration(M);const z=i.findLoadedParent(w,0),O=_r(T,z,i,t.transform,M);let F,B;t.terrain&&t.terrain.prepareDrawTile(),h.activeTexture.set(u.TEXTURE0),S.bind(v,u.CLAMP_TO_EDGE),h.activeTexture.set(u.TEXTURE1),z?(z.texture&&z.texture.bind(v,u.CLAMP_TO_EDGE),F=Math.pow(2,z.tileID.overscaledZ-T.tileID.overscaledZ),B=[T.tileID.canonical.x*F%1,T.tileID.canonical.y*F%1]):S.bind(v,u.CLAMP_TO_EDGE),S.useMipmap&&h.extTextureFilterAnisotropic&&t.transform.pitch>20&&u.texParameterf(u.TEXTURE_2D,h.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,h.extTextureFilterAnisotropicMax);const k=t.transform;let N;const U=l?ms(k):[0,0,0,0];let G,j,V,Z,H,W=0;if(c&&d instanceof e.ap&&d.coordinates.length>3)G=Float32Array.from(e.aT(e.ci(new e.bs(0,0,0)))),j=Float32Array.from(k.globeMatrix),V=Float32Array.from(e.ce(k)),Z=[e.a5(k.center.lng),e.ae(k.center.lat)],N=d.elevatedGlobePerspectiveTransform,H=d.elevatedGlobeGridMatrix||new Float32Array(9);else if(c){const t=e.cf(w.canonical);W=e.cg(t.getCenter().lat),G=Float32Array.from(e.aT(e.ci(w.canonical))),j=Float32Array.from(k.globeMatrix),V=Float32Array.from(e.ce(k)),Z=[e.a5(k.center.lng),e.ae(k.center.lat)],N=[0,0],H=Float32Array.from(e.ch(w.canonical,t,W,k.worldSize/k._pixelsPerMercatorPixel));}else N=d instanceof e.ap?d.perspectiveTransform:[0,0],G=new Float32Array(16),j=new Float32Array(9),V=new Float32Array(16),Z=[0,0],H=new Float32Array(9);const q=Br(R,G,j,V,H,B||[0,0],e.S(t.transform.zoom),Z,U,F||1,O,o,N,l?o.paint.get("raster-elevation"):0,2,C,I,_.range,D,L,p),$=t.isTileAffectedByFog(w),X=t.getOrCreateProgram("raster",{defines:_.defines,overrideFog:$});if(t.uploadCommonUniforms(h,X,r),d instanceof e.ap){const i=d.elevatedGlobeVertexBuffer,r=d.elevatedGlobeIndexBuffer;if(m||!a)d.boundsBuffer&&d.boundsSegments&&X.draw(t,u.TRIANGLES,A,Rt.disabled,f,Ft.disabled,q,o.id,d.boundsBuffer,t.quadTriangleIndexBuffer,d.boundsSegments);else if(i&&r){const n=k.zoom<=e.bG?d.elevatedGlobeSegments:d.getSegmentsForLongitude(k.center.lng);n&&X.draw(t,u.TRIANGLES,A,Rt.disabled,f,s,q,o.id,i,r,n);}}else if(c){A=new Lt(u.LEQUAL,Lt.ReadOnly,t.depthRangeFor3D);const e=t.globeSharedBuffers;if(e){const[i,r,n]=e.getGridBuffers(W,!1);X.draw(t,u.TRIANGLES,A,y||P,t.colorModeForRenderPass(),s,q,o.id,i,r,n);}}else {const{tileBoundsBuffer:e,tileBoundsIndexBuffer:i,tileBoundsSegments:r}=t.getTileBoundsBuffers(T);X.draw(t,u.TRIANGLES,A,P,f,Ft.disabled,q,o.id,e,i,r);}}if(!(d instanceof e.ap)&&c)for(const e of r){const r=e.canonical.y===(1<e.cG[t](r)));_.push(r);const p=r.canonical.x,f=r.canonical.y;for(const e of _){const n=i.getTile(a?e.wrapped():e);if(!n)continue;const c=n.rasterParticleState;if(!c)continue;const u=Ur([e.canonical.x+(1<e.tileID))),u&&(a.activeTexture.set(l.TEXTURE0),e.imageManager.bind(e.context,i.scope));for(const d of v){const v=e.isTileAffectedByFog(d),x=e.getOrCreateProgram(m,{overrideFog:v}),y=d.toUnwrapped(),b=o?d.projMatrix:e.transform.calculateProjMatrix(y);e.prepareDrawTile();const w=t?t.getTile(d):g?g[d.key]:new Gt(d,h,c.zoom,e),T=u?qr(b,n,s,e,u,i.scope,{tileID:d,tileSize:h}):Wr(b,n,s,r);e.uploadCommonUniforms(a,x,y);const{tileBoundsBuffer:E,tileBoundsIndexBuffer:S,tileBoundsSegments:C}=e.getTileBoundsBuffers(w);x.draw(e,l.TRIANGLES,p,_,f,Ft.disabled,T,i.id,E,S,C);}},sky:function(t,i,o){const r=t._atmosphere?e.S(t.transform.zoom):1,s=o.paint.get("sky-opacity")*r;if(0===s)return;const n=t.context,a=o.paint.get("sky-type"),l=new Lt(n.gl.LEQUAL,Lt.ReadOnly,[0,1]),c=t.frameCounter/1e3%1;"atmosphere"===a?"offscreen"===t.renderPass?o.needsSkyboxCapture(t)&&(function(t,i,o,r){const s=t.context,n=s.gl;let a=i.skyboxFbo;if(!a){a=i.skyboxFbo=s.createFramebuffer(32,32,!0,null),i.skyboxGeometry=new Ps(s),i.skyboxTexture=s.gl.createTexture(),n.bindTexture(n.TEXTURE_CUBE_MAP,i.skyboxTexture),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_MAG_FILTER,n.LINEAR);for(let e=0;e<6;++e)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,n.RGBA,32,32,0,n.RGBA,n.UNSIGNED_BYTE,null);}s.bindFramebuffer.set(a.framebuffer),s.viewport.set([0,0,32,32]);const l=i.getCenter(t,!0),c=t.getOrCreateProgram("skyboxCapture"),h=new Float64Array(16);e.a6.identity(h),e.a6.rotateY(h,h,.5*-Math.PI),Ms(t,i,c,h,l,0),e.a6.identity(h),e.a6.rotateY(h,h,.5*Math.PI),Ms(t,i,c,h,l,1),e.a6.identity(h),e.a6.rotateX(h,h,.5*-Math.PI),Ms(t,i,c,h,l,2),e.a6.identity(h),e.a6.rotateX(h,h,.5*Math.PI),Ms(t,i,c,h,l,3),e.a6.identity(h),Ms(t,i,c,h,l,4),e.a6.identity(h),e.a6.rotateY(h,h,Math.PI),Ms(t,i,c,h,l,5),s.viewport.set([0,0,t.width,t.height]);}(t,o),o.markSkyboxValid(t)):"sky"===t.renderPass&&function(e,t,i,o,r){const s=e.context,n=s.gl,a=e.transform,l=e.getOrCreateProgram("skybox");s.activeTexture.set(n.TEXTURE0),n.bindTexture(n.TEXTURE_CUBE_MAP,t.skyboxTexture);const c=((e,t,i,o,r)=>({u_matrix:e,u_sun_direction:t,u_cubemap:0,u_opacity:o,u_temporal_offset:r}))(a.skyboxMatrix,t.getCenter(e,!1),0,o,r);e.uploadCommonUniforms(s,l),l.draw(e,n.TRIANGLES,i,Rt.disabled,e.colorModeForRenderPass(),Ft.backCW,c,"skybox",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment);}(t,o,l,s,c):"gradient"===a&&"sky"===t.renderPass&&function(t,i,o,r,s){const n=t.context,a=n.gl,l=t.transform,c=t.getOrCreateProgram("skyboxGradient");i.skyboxGeometry||(i.skyboxGeometry=new Ps(n)),n.activeTexture.set(a.TEXTURE0);let h=i.colorRampTexture;h||(h=i.colorRampTexture=new e.T(n,i.colorRamp,a.RGBA)),h.bind(a.LINEAR,a.CLAMP_TO_EDGE);const u=((t,i,o,r,s)=>({u_matrix:t,u_color_ramp:0,u_center_direction:i,u_radius:e.bj(o),u_opacity:r,u_temporal_offset:s}))(l.skyboxMatrix,i.getCenter(t,!1),i.paint.get("sky-gradient-radius"),r,s);t.uploadCommonUniforms(n,c),c.draw(t,a.TRIANGLES,o,Rt.disabled,t.colorModeForRenderPass(),Ft.backCW,u,"skyboxGradient",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment);}(t,o,l,s,c);},debug:function(t,i,o,r,s,n){for(let a=0;a{a&&(a.useNormalOffset=!0,l||(a.enabled=!0));},h=i.getSource();if("light-beam"===t.renderPass&&"batched-model"!==h.type)return;if("vector"===h.type||"geojson"===h.type)return function(t,i,o,r){const s=t.transform;if("mercator"!==s.projection.name)return void e.w(`Drawing 3D models for ${s.projection.name} projection is not yet implemented`);const n=s.getFreeCameraOptions().position;if(!t.modelManager)return;const a=t.modelManager;o.modelManager=a;const l=t.shadowRenderer;if(!o._unevaluatedLayout._values.hasOwnProperty("model-id"))return;const c=o._unevaluatedLayout._values["model-id"],h={...o.layout.get("model-id").parameters};for(const u of r){const r=i.getTile(u).getBucket(o);if(!r||r.projection.name!==s.projection.name)continue;const d=Ws(u,s);h.zoom=d;const _=c.possiblyEvaluate(h);if(Zs(t,r,u),Hs.shadowUniformsInitialized=!1,Hs.useSingleShadowCascade=!!l&&0===l.getMaxCascadeForTile(u.toUnwrapped()),"shadow"===t.renderPass&&l){if(1===t.currentShadowCascade&&r.isInsideFirstShadowMapFrustum)continue;const i=s.calculatePosMatrix(u.toUnwrapped(),s.worldSize);if(Hs.tileMatrix.set(i),Hs.shadowTileMatrix=Float32Array.from(l.calculateShadowPassMatrixFromMatrix(i)),Hs.aabb.min.fill(0),Hs.aabb.max[0]=Hs.aabb.max[1]=e.V,Hs.aabb.max[2]=0,Xs(r,Hs,t,o.scope))continue}const p=1<0&&(e=_.evaluate(i.features[0].feature,{}));const s=a.getModel(e,o.scope);if(s&&s.uploaded)for(const e of s.nodes)qs(t,o,e,i,f,u,Hs);}}}(t,i,o,r),void c();if(!h.loaded())return;if("batched-model"===h.type)return function(t,i,o,r){o.resetLayerRenderingStats(t);const s=t.context,n=t.transform,a=t.style.fog,l=t.shadowRenderer;if("mercator"!==n.projection.name)return void e.w(`Drawing 3D landmark models for ${n.projection.name} projection is not yet implemented`);const c=t.transform.getFreeCameraOptions().position,h=e.N.scale([],[c.x,c.y,c.z],t.transform.worldSize);e.N.negate(h,h);const u=e.a6.identity([]),d=e.cR(n.center.lat,n.zoom),_=e.a6.fromScaling([],[1,1,1/d]);e.a6.translate(u,u,h);const p=o.paint.get("model-opacity"),f=new Lt(s.gl.LEQUAL,Lt.ReadWrite,t.depthRangeFor3D),m=new Lt(s.gl.LEQUAL,Lt.ReadOnly,t.depthRangeFor3D),g=new e.bS([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),v="shadow"===t.renderPass,x=v&&l?l.getCurrentCascadeFrustum():n.getFrustum(n.scaleZoom(n.worldSize)),y=o.getLayerRenderingStats(),b=function(c,h){for(const d of r){const r=i.getTile(d).getBucket(o);if(!r||!r.uploaded)continue;let b=!1;l&&(b=0===l.getMaxCascadeForTile(d.toUnwrapped()));const w=n.calculatePosMatrix(d.toUnwrapped(),n.worldSize),T=r.modelTraits;for(const i of r.getNodesInfo()){if(i.hiddenByReplacement)continue;if(!i.node.meshes)continue;const r=i.evaluatedScale,E=i.node;let S=0;if(t.terrain&&E.elevation&&(S=E.elevation*t.terrain.exaggeration()),r[0]<=1&&r[1]<=1&&r[2]<=1&&0===(()=>{const t=i.getLocalBounds();return g.min=[...t.min],g.max=[...t.max],g.min[2]+=S,g.max[2]+=S,e.N.transformMat4(g.min,g.min,w),e.N.transformMat4(g.max,g.max,w),g})().intersects(x))continue;const C="light-beam"===t.renderPass,I=[...w];e.a6.translate(I,I,[(E.anchor?E.anchor[0]:0)*(r[0]-1),(E.anchor?E.anchor[1]:0)*(r[1]-1),S]),e.N.exactEquals(r,e.cT)||e.a6.scale(I,I,r),e.a6.multiply(I,I,E.matrix);const D=e.a6.multiply([],_,I);e.a6.multiply(D,u,D);const L=e.a6.invert([],D);e.a6.transpose(L,L),e.a6.scale(L,L,$s);const A=e.a6.multiply([],n.expandedFarZProjMatrix,I),R=T&e.cV.HasMapboxMeshFeatures,P=R?0:i.evaluatedRMEA[0][2];for(let e=0;e=me||s>=me;}}const w=r.material;let T;w.occlusionTexture&&w.occlusionTexture.offsetScale&&(T=w.occlusionTexture.offsetScale,_.defines.push("OCCLUSION_TEXTURE_TRANSFORM")),!v&&l&&(l.useNormalOffset=!!r.normalBuffer);const S=t.getOrCreateProgram("model",_);!v&&l&&l.setupShadowsFromMatrix(I,S,l.useNormalOffset),t.uploadCommonUniforms(s,S,d.toUnwrapped(),x);const M=w.pbrMetallicRoughness;M.metallicFactor=.9,M.roughnessFactor=.5;const z=$r(new Float32Array(A),new Float32Array(D),new Float32Array(L),t,p,M.baseColorFactor,w.emissiveFactor,M.metallicFactor,M.roughnessFactor,w,P,o,[0,0,0],T);S.draw(t,s.gl.TRIANGLES,h&&!u?f:m,Rt.disabled,c?u||p<1||i.hasTranslucentParts?Mt.alphaBlended:Mt.unblended:Mt.disabled,Ft.backCCW,z,o.id,r.vertexBuffer,r.indexBuffer,r.segments,o.paint,t.transform.zoom,void 0,g);}}}};(((function(e,t,i,o){const r=e.terrain?e.terrain.exaggeration():0,s=e.transform.zoom;for(const n of o){const o=t.getTile(n).getBucket(i);o&&(e.conflationActive&&o.updateReplacement(n,e.replacementSource),o.evaluateScale(e,i),e.terrain&&r>0&&o.elevationUpdate(e.terrain,r,n,i.source),o.needsReEvaluation(e,s,i)&&o.evaluate(i));}})))(t,i,o,r),1===p?b(!0,!0):(b(!1,!0),b(!0,!1));}(t,i,o,r),void c();const u=h.getModels(),d=[],_=t.transform.getFreeCameraOptions().position,p=e.N.scale([],[_.x,_.y,_.z],t.transform.worldSize);e.N.negate(p,p);const f=[],m=[];let g=0;for(const i of u){const r=o.paint.get("model-rotation").constantOr(null),s=o.paint.get("model-scale").constantOr(null),n=o.paint.get("model-translation").constantOr(null);i.computeModelMatrix(t,r,s,n,!0,!0,!1);const a=e.a6.identity([]),l=e.cR(i.position.lat,t.transform.zoom),c=e.a6.fromScaling([],[1,1,1/l]);e.a6.translate(a,a,p),d.push({zScaleMatrix:c,negCameraPosMatrix:a});for(const e of i.nodes)js(t.transform,e,i.matrix,t.transform.expandedFarZProjMatrix,g,f,m);g++;}if(f.sort(((e,t)=>t.depth-e.depth)),"shadow"!==t.renderPass){if(1===s)for(const e of m)Gs(e,t,o,d[e.modelIndex],Rt.disabled,t.colorModeForRenderPass());else {for(const e of m)Gs(e,t,o,d[e.modelIndex],Rt.disabled,Mt.disabled);for(const e of m)Gs(e,t,o,d[e.modelIndex],t.stencilModeFor3D(),t.colorModeForRenderPass());t.resetStencilClippingMasks();}for(const e of f)Gs(e,t,o,d[e.modelIndex],Rt.disabled,t.colorModeForRenderPass());c();}else {for(const e of m)Vs(e.mesh,e.nodeModelMatrix,t,o);for(const e of f)Vs(e.mesh,e.nodeModelMatrix,t,o);c();}}},en={model:function(e,t,i){const o=e.scope,r=t.getSource();if(!r.loaded())return;if("vector"===r.type||"geojson"===r.type)return void(i.modelManager&&i.modelManager.upload(i,o));if("batched-model"===r.type)return;const s=r.getModels();for(const e of s)e.upload(i.context);},raster:function(e,t,i){const o=t.getSource();if(!(o instanceof ze&&o.loaded()))return;const r=e.sourceLayer||o.rasterLayerIds&&o.rasterLayerIds[0];if(!r)return;const s=e.paint.get("raster-array-band")||o.getInitialBand(r);if(null==s)return;const n=t.getIds().map((e=>t.getTileByID(e)));for(const e of n)e.updateNeeded(r,s)&&o.prepareTile(e,r,s);},"raster-particle":function(e,t,i){const o=t.getSource();if(!(o instanceof ze&&o.loaded()))return;const r=e.sourceLayer||o.rasterLayerIds&&o.rasterLayerIds[0];if(!r)return;const s=e.paint.get("raster-particle-array-band")||o.getInitialBand(r);if(null==s)return;const n=t.getIds().map((e=>t.getTileByID(e)));for(const e of n)e.updateNeeded(r,s)&&o.prepareTile(e,r,s);}};class tn{constructor(t,i,o,r){this.context=new Bt(t,i),this.transform=o,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.tp=r,this._debugParams={showTerrainProxyTiles:!1},r.registerParameter(this._debugParams,["Terrain"],"showTerrainProxyTiles",{},(()=>{this.style.map.triggerRepaint();})),this.setup(),this.numSublayers=Kt.maxUnderzooming+Kt.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.deferredRenderGpuTimeQueries=[],this.gpuTimers={},this.frameCounter=0,this._backgroundTiles={},this.conflationActive=!1,this.replacementSource=new e.cX,this.longestCutoffRange=0,this.minCutoffZoom=0,this._fogVisible=!1,this._cachedTileFogOpacities={},this._shadowRenderer=new wo(this),this._wireframeDebugCache=new Ys,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0;}updateTerrain(e,t){const i=!!e&&!!e.terrain&&this.transform.projection.supportsTerrain;if(!(i||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new gr(this,e));const o=this._terrain;this.transform.elevation=i?o:null,o.update(e,this.transform,t),this.transform.elevation&&!o.enabled&&(this.transform.elevation=null);}_updateFog(e){const t=e.fog;if(!t||"globe"===this.transform.projection.name||t.getOpacity(this.transform.pitch)<1||t.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[i,o]=t.getFovAdjustedRange(this.transform._fov);if(i>o)return void(this.transform.fogCullDistSq=null);const r=i+.78*(o-i);this.transform.fogCullDistSq=r*r;}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}get shadowRenderer(){return this._shadowRenderer&&this._shadowRenderer.enabled?this._shadowRenderer:null}get wireframeDebugCache(){return this._wireframeDebugCache}resize(t,i){if(this.width=t*e.f.devicePixelRatio,this.height=i*e.f.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style.order)this.style._mergedLayers[e].resize();}setup(){const t=this.context,i=new e.aN;i.emplaceBack(0,0),i.emplaceBack(e.V,0),i.emplaceBack(0,e.V),i.emplaceBack(e.V,e.V),this.tileExtentBuffer=t.createVertexBuffer(i,e.aP.members),this.tileExtentSegments=e.aB.simpleSegment(0,0,4,2);const o=new e.aN;o.emplaceBack(0,0),o.emplaceBack(e.V,0),o.emplaceBack(0,e.V),o.emplaceBack(e.V,e.V),this.debugBuffer=t.createVertexBuffer(o,e.aP.members),this.debugSegments=e.aB.simpleSegment(0,0,4,5);const r=new e.aN;r.emplaceBack(-1,-1),r.emplaceBack(1,-1),r.emplaceBack(-1,1),r.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(r,e.aP.members),this.viewportSegments=e.aB.simpleSegment(0,0,4,2);const s=new e.av;s.emplaceBack(0,0,0,0),s.emplaceBack(e.V,0,e.V,0),s.emplaceBack(0,e.V,0,e.V),s.emplaceBack(e.V,e.V,e.V,e.V),this.mercatorBoundsBuffer=t.createVertexBuffer(s,e.aR.members),this.mercatorBoundsSegments=e.aB.simpleSegment(0,0,4,2);const n=new e.aw;n.emplaceBack(0,1,2),n.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(n);const a=new e.aO;for(const e of [0,1,3,2,0])a.emplaceBack(e);this.debugIndexBuffer=t.createIndexBuffer(a),this.emptyTexture=new e.T(t,new e.h({width:1,height:1},Uint8Array.of(0,0,0,0)),t.gl.RGBA),this.identityMat=e.a6.create();const l=this.context.gl;this.stencilClearMode=new Rt({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.loadTimeStamps.push(performance.now());}getMercatorTileBoundsBuffers(){return {tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(e){return e._makeTileBoundsBuffers(this.context,this.transform.projection),e._tileBoundsBuffer?{tileBoundsBuffer:e._tileBoundsBuffer,tileBoundsIndexBuffer:e._tileBoundsIndexBuffer,tileBoundsSegments:e._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const e=this.context.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.getOrCreateProgram("clippingMask").draw(this,e.TRIANGLES,Lt.disabled,this.stencilClearMode,Mt.disabled,Ft.disabled,dr(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments);}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={});}_renderTileClippingMasks(e,t,i){if(!t||this.currentStencilSource===t.id||!e.isTileClipped()||!i||0===i.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let e=!1;for(const t of i)if(void 0===this._tileClippingMaskIDs[t.key]){e=!0;break}if(!e)return}this.currentStencilSource=t.id;const o=this.context,r=o.gl;this.nextStencilID+i.length>256&&this.clearStencil(),o.setColorMode(Mt.disabled),o.setDepthMode(Lt.disabled);const s=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const e of i){const i=t.getTile(e),o=this._tileClippingMaskIDs[e.key]=this.nextStencilID++,{tileBoundsBuffer:n,tileBoundsIndexBuffer:a,tileBoundsSegments:l}=this.getTileBoundsBuffers(i);s.draw(this,r.TRIANGLES,Lt.disabled,new Rt({func:r.ALWAYS,mask:0},o,255,r.KEEP,r.KEEP,r.REPLACE),Mt.disabled,Ft.disabled,dr(e.projMatrix),"$clipping",n,a,l);}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,t=this.context.gl;return new Rt({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(e);const t=this.context.gl;return new Rt({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}stencilConfigForOverlap(e){const t=this.context.gl,i=e.sort(((e,t)=>t.overscaledZ-e.overscaledZ)),o=i[i.length-1].overscaledZ,r=i[0].overscaledZ-o+1;if(r>1){this.currentStencilSource=void 0,this.nextStencilID+r>256&&this.clearStencil();const e={};for(let i=0;ithis.style&&this.style.enable3dLights()&&this.terrain&&this.terrain.renderingToTexture)()&&"translucent"===this.renderPass?new Mt([i.ONE,i.ONE_MINUS_SRC_ALPHA,i.CONSTANT_ALPHA,i.ONE_MINUS_SRC_ALPHA],new e.ax(0,0,0,void 0===t?0:t),[!0,!0,!0,!0]):this.colorModeForRenderPass()}depthModeForSublayer(e,t,i,o=!1){if(!this.opaquePassEnabledForLayer()&&!o)return Lt.disabled;const r=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new Lt(i||this.context.gl.LEQUAL,t,[r,r])}opaquePassEnabledForLayer(){return this.currentLayero[e])),n=this.style._mergedSourceCaches;this.imageManager=t.imageManager,this.modelManager=t.modelManager,this.symbolFadeChange=t.placement.symbolFadeChange(e.f.now()),this.imageManager.beginFrame();let a=0,l=!1;for(const e in n){const t=n[e];t.used&&(t.prepare(this.context),t.getSource().usedInConflation&&++a);}for(const e of s)e.isHidden(this.transform.zoom)||this.prepareLayer(e);const c={},h={},u={},d={},_={};for(const e in n){const t=n[e];c[e]=t.getVisibleCoordinates(),h[e]=c[e].slice().reverse(),u[e]=t.getVisibleCoordinates(!0).reverse(),d[e]=t.getShadowCasterCoordinates(),_[e]=t.sortCoordinatesByDistance(c[e]);}const p=e=>{const t=this.style.getLayerSourceCache(e);return t&&t.used?t.getSource():null};if(a){const e=[];for(const t of s)this.layerUsedInConflation(t,p(t))&&e.push(t);if(e&&e.length>1){const t=[];for(const i of e){const e=this.style.getLayerSourceCache(i);e&&e.used&&e.getSource().usedInConflation&&t.push({layer:i.fqid,cache:e});}this.replacementSource.setSources(t),l=!0;}}l||this.replacementSource.clear(),this.conflationActive=l,this.minCutoffZoom=0,this.longestCutoffRange=0;for(const e of s){const t=e.cutoffRange();if(this.longestCutoffRange=Math.max(t,this.longestCutoffRange),t>0){const t=p(e);t&&(this.minCutoffZoom=Math.max(t.minzoom,this.minCutoffZoom)),e.minzoom&&(this.minCutoffZoom=Math.max(e.minzoom,this.minCutoffZoom));}}this.opaquePassCutoff=1/0;for(let e=0;e{if(i.showOverdrawInspector)return e.ax.black;if(this.style.fog&&this.transform.projection.supportsFog&&!v){const t=this.style.fog.properties.get("color").toArray01();return new e.ax(...t)}if(this.style.fog&&this.transform.projection.supportsFog&&v){const t=this.style.fog.properties.get("space-color").toArray01();return new e.ax(...t)}return e.ax.transparent})();if(this.context.clear({color:x,depth:1}),this.clearStencil(),this._showOverdrawInspector=i.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&v&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=r.length-1;this.currentLayer>=0;this.currentLayer--){const e=s[this.currentLayer],i=t.getLayerSourceCache(e);if(e.isSky())continue;const o=i?(e.is3D()?_:h)[i.id]:void 0;this._renderTileClippingMasks(e,i,o),this.renderLayer(this,i,e,o);}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&v&&this._atmosphere.drawAtmosphereGlow(this,this.style.fog),this.renderPass="sky",(!this._atmosphere||e.S(this.transform.zoom)>0)&&("globe"===this.transform.projection.name||this.transform.isHorizonVisible()))for(this.currentLayer=0;this.currentLayer0&&e.hasShadowPass()&&0==--b&&(m.drawGroundShadows(),this.firstLightBeamLayer<=this.currentLayer)){const e=this.currentLayer;for(this.renderPass="light-beam",this.currentLayer=this.firstLightBeamLayer;this.currentLayer<=e;this.currentLayer++){const e=s[this.currentLayer];if(!e.hasLightBeamPass())continue;const i=t.getLayerSourceCache(e);this.renderLayer(this,i,e,i?h[i.id]:void 0);}this.currentLayer=e,this.renderPass="translucent";}++this.currentLayer;}}if(this.terrain&&this.terrain.postRender(),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){let i=null;s.forEach((e=>{const o=t.getLayerSourceCache(e);o&&!e.isHidden(this.transform.zoom)&&o.getVisibleCoordinates().length&&(!i||i.getSource().maxzoom0?t.pop():null}isPatternMissing(e,t){return null===e||void 0!==e&&!this.imageManager.getPattern(e.toString(),t)}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture}linearFloatFilteringSupported(){return null!=this.context.extTextureFloatLinear}currentGlobalDefines(e,t,i){const o=void 0===i?this.terrain&&this.terrain.renderingToTexture:i,r=this.terrain&&0===this.terrain.exaggeration(),s=[];return this.style&&this.style.enable3dLights()&&("globeRaster"===e||"terrainRaster"===e?(s.push("LIGHTING_3D_MODE"),s.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):o||s.push("LIGHTING_3D_MODE")),"shadow"===this.renderPass?this._shadowMapDebug||s.push("DEPTH_TEXTURE"):this.shadowRenderer&&(this.shadowRenderer.useNormalOffset?s.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"):s.push("RENDER_SHADOWS","DEPTH_TEXTURE")),this.terrainRenderModeElevated()&&(s.push("TERRAIN"),this.linearFloatFilteringSupported()&&s.push("TERRAIN_DEM_FLOAT_FORMAT"),r&&s.push("ZERO_EXAGGERATION")),"globe"===this.transform.projection.name&&s.push("GLOBE"),!this._fogVisible||o||void 0!==t&&!t||s.push("FOG","FOG_DITHERING"),o&&s.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&s.push("OVERDRAW_INSPECTOR"),s}getOrCreateProgram(e,t){this.cache=this.cache||{};const i=t&&t.defines||[],o=t&&t.config,r=t&&t.transformFeedback,s=this.currentGlobalDefines(e,t&&t.overrideFog,t&&t.overrideRtt).concat(i),n=br.cacheKey(Ko[e],e,s,o);return this.cache[n]||(this.cache[n]=new br(this.context,e,Ko[e],o,Yr[e],s,r)),this.cache[n]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.frontFace.setDefault(),this.context.cullFaceSide.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault();}setBaseState(){const e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD);}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new e.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA));}destroy(){this._terrain&&this._terrain.destroy(),this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this._wireframeDebugCache.destroy();}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile();}uploadCommonLightUniforms(t,i){if(this.style.enable3dLights()){const o=this.style.directionalLight,r=this.style.ambientLight;if(o&&r){const s=((t,i)=>{const o=t.properties.get("direction"),r=t.properties.get("color").toArray01(),s=t.properties.get("intensity"),n=i.properties.get("color").toArray01(),a=i.properties.get("intensity"),l=[o.x,o.y,o.z],c=e.cn(n,a),h=e.cn(r,s);return {u_lighting_ambient_color:c,u_lighting_directional_dir:l,u_lighting_directional_color:h,u_ground_radiance:vr(l,h,c)}})(o,r);i.setLightsUniformValues(t,s);}}}uploadCommonUniforms(t,i,o,r,s){if(this.uploadCommonLightUniforms(t,i),this.terrain&&this.terrain.renderingToTexture)return;const n=this.style.fog;if(n){const s=n.getOpacity(this.transform.pitch),a=((t,i,o,r,s,n,a,l,c,h,u,d)=>{const _=t.transform,p=i.properties.get("color").toArray01();p[3]=r;const f=t.frameCounter/1e3%1,[m,g]=i.properties.get("vertical-range");return {u_fog_matrix:o?_.calculateFogTileMatrix(o):d||t.identityMat,u_fog_range:i.getFovAdjustedRange(_._fov),u_fog_color:p,u_fog_horizon_blend:i.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(m,g),g],u_fog_temporal_offset:f,u_frustum_tl:s,u_frustum_tr:n,u_frustum_br:a,u_frustum_bl:l,u_globe_pos:c,u_globe_radius:h,u_viewport:u,u_globe_transition:e.S(_.zoom),u_is_globe:+("globe"===_.projection.name)}})(this,n,o,s,this.transform.frustumCorners.TL,this.transform.frustumCorners.TR,this.transform.frustumCorners.BR,this.transform.frustumCorners.BL,this.transform.globeCenterInViewSpace,this.transform.globeRadius,[this.transform.width*e.f.devicePixelRatio,this.transform.height*e.f.devicePixelRatio],r);i.setFogUniformValues(t,a);}s&&i.setCutoffUniformValues(t,s.uniformValues);}setTileLoadedFlag(e){this.tileLoaded=e;}saveCanvasCopy(){const e=this.canvasCopy();e&&(this.frameCopies.push(e),this.tileLoaded=!1);}canvasCopy(){const e=this.context.gl,t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.copyTexImage2D(e.TEXTURE_2D,0,e.RGBA,0,0,e.drawingBufferWidth,e.drawingBufferHeight,0),t}getCanvasCopiesAndTimestamps(){return {canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return !1;const e=this.style&&this.style.fog;return !!e&&0!==e.getOpacity(this.transform.pitch)}getBackgroundTiles(){const e=this._backgroundTiles,t=this._backgroundTiles={},i=this.transform.coveringTiles({tileSize:512});for(const o of i)t[o.key]=e[o.key]||new Gt(o,512,this.transform.tileZoom,this);return t}clearBackgroundTiles(){this._backgroundTiles={};}layerUsedInConflation(e,t){return !(!e.is3D()||e.minzoom&&e.minzoom>this.transform.zoom||"building"!==e.sourceLayer&&(!t||"batched-model"!==t.type))}isTileAffectedByFog(e){if(!this.style||!this.style.fog)return !1;if("globe"===this.transform.projection.name)return !0;let t=this._cachedTileFogOpacities[e.key];return t||(this._cachedTileFogOpacities[e.key]=t=this.style.fog.getOpacityForTile(e)),t[0]>=me||t[1]>=me}}function on(e,t){let i=!1,o=null;const r=()=>{o=null,i&&(e(),o=setTimeout(r,t),i=!1);};return ()=>(i=!0,o||r(),o)}class rn{constructor(t){this._hashName=t&&encodeURIComponent(t),e.aY(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=on(this._updateHashUnthrottled.bind(this),300);}addTo(e){return this._map=e,window.addEventListener("hashchange",this._onHashChange,!1),e.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(){const e=this._map;if(!e)return "";const t=sn(e);if(this._hashName){const e=this._hashName;let i=!1;const o=location.hash.slice(1).split("&").map((o=>{const r=o.split("=")[0];return r===e?(i=!0,`${r}=${t}`):o})).filter((e=>e));return i||o.push(`${e}=${t}`),`#${o.join("&")}`}return `#${t}`}_getCurrentHash(){const e=location.hash.replace("#","");if(this._hashName){let t;return e.split("&").map((e=>e.split("="))).forEach((e=>{e[0]===this._hashName&&(t=e);})),(t&&t[1]||"").split("/")}return e.split("/")}_onHashChange(){const e=this._map;if(!e)return !1;const t=this._getCurrentHash();if(t.length>=3&&!t.some((e=>isNaN(e)))){const i=e.dragRotate.isEnabled()&&e.touchZoomRotate.isEnabled()?+(t[3]||0):e.getBearing();return e.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:i,pitch:+(t[4]||0)}),!0}return !1}_updateHashUnthrottled(){history.replaceState(history.state,"",location.href.replace(/(#.+)?$/,this.getHashString()));}}function sn(e,t){const i=e.getCenter(),o=Math.round(100*e.getZoom())/100,r=Math.ceil((o*Math.LN2+Math.log(512/360/.5))/Math.LN10),s=Math.pow(10,r),n=Math.round(i.lng*s)/s,a=Math.round(i.lat*s)/s,l=e.getBearing(),c=e.getPitch();let h=t?`/${n}/${a}/${o}`:`${o}/${a}/${n}`;return (l||c)&&(h+="/"+Math.round(10*l)/10),c&&(h+=`/${Math.round(c)}`),h}const nn={linearity:.3,easing:e.c_(0,0,.3,1)},an=e.e({deceleration:2500,maxSpeed:1400},nn),ln=e.e({deceleration:20,maxSpeed:1400},nn),cn=e.e({deceleration:1e3,maxSpeed:360},nn),hn=e.e({deceleration:1e3,maxSpeed:90},nn);class un{constructor(e){this._map=e,this.clear();}clear(){this._inertiaBuffer=[];}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:e.f.now(),settings:t});}_drainInertiaBuffer(){const t=this._inertiaBuffer,i=e.f.now();for(;t.length>0&&i-t[0].time>160;)t.shift();}_onMoveEnd(t){if(this._map._prefersReducedMotion())return;if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={zoom:0,bearing:0,pitch:0,pan:new e.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)i.zoom+=e.zoomDelta||0,i.bearing+=e.bearingDelta||0,i.pitch+=e.pitchDelta||0,e.panDelta&&i.pan._add(e.panDelta),e.around&&(i.around=e.around),e.pinchAround&&(i.pinchAround=e.pinchAround);const o=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,r={};if(i.pan.mag()){const s=_n(i.pan.mag(),o,e.e({},an,t||{}));r.offset=i.pan.mult(s.amount/i.pan.mag()),r.center=this._map.transform.center,dn(r,s);}if(i.zoom){const e=_n(i.zoom,o,ln);r.zoom=this._map.transform.zoom+e.amount,dn(r,e);}if(i.bearing){const t=_n(i.bearing,o,cn);r.bearing=this._map.transform.bearing+e.aa(t.amount,-179,179),dn(r,t);}if(i.pitch){const e=_n(i.pitch,o,hn);r.pitch=this._map.transform.pitch+e.amount,dn(r,e);}if(r.zoom||r.bearing){const e=void 0===i.pinchAround?i.around:i.pinchAround;r.around=e?this._map.unproject(e):this._map.getCenter();}return this.clear(),r.noMoveStart=!0,r}}function dn(e,t){(!e.duration||e.durationi.unproject(e))),a=s.reduce(((e,t,i,o)=>e.add(t.div(o.length))),new e.P(0,0));super(t,{points:s,point:a,lngLats:n,lngLat:i.unproject(a),originalEvent:o}),this._defaultPrevented=!1;}}class mn extends e.b{preventDefault(){this._defaultPrevented=!0;}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i){super(e,{originalEvent:i}),this._defaultPrevented=!1;}}class gn{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance;}reset(){this._mousedownPos=void 0;}wheel(e){return this._firePreventable(new mn(e.type,this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new pn(e.type,this._map,e))}mouseup(e){this._map.fire(new pn(e.type,this._map,e));}preclick(t){const i=e.e({},t);i.type="preclick",this._map.fire(new pn(i.type,this._map,i));}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||(this.preclick(e),this._map.fire(new pn(e.type,this._map,e)));}dblclick(e){return this._firePreventable(new pn(e.type,this._map,e))}mouseover(e){this._map.fire(new pn(e.type,this._map,e));}mouseout(e){this._map.fire(new pn(e.type,this._map,e));}touchstart(e){return this._firePreventable(new fn(e.type,this._map,e))}touchmove(e){this._map.fire(new fn(e.type,this._map,e));}touchend(e){this._map.fire(new fn(e.type,this._map,e));}touchcancel(e){this._map.fire(new fn(e.type,this._map,e));}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return {}}isEnabled(){return !0}isActive(){return !1}enable(){}disable(){}}class vn{constructor(e){this._map=e;}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0;}mousemove(e){this._map.fire(new pn(e.type,this._map,e));}mousedown(){this._delayContextMenu=!0;}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new pn("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent);}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._map.fire(new pn(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault();}isEnabled(){return !0}isActive(){return !1}enable(){}disable(){}}class xn{constructor(e,t){this._map=e,this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=t.clickTolerance||1;}isEnabled(){return !!this._enabled}isActive(){return !!this._active}enable(){this.isEnabled()||(this._enabled=!0);}disable(){this.isEnabled()&&(this._enabled=!1);}mousedown(e,t){this.isEnabled()&&e.shiftKey&&0===e.button&&(h(),this._startPos=this._lastPos=t,this._active=!0);}mousemoveWindow(e,t){if(!this._active)return;const i=t,o=this._startPos,r=this._lastPos;if(!o||!r||r.equals(i)||!this._box&&i.dist(o){this._box&&(this._box.style.transform=`translate(${n}px,${l}px)`,this._box.style.width=a-n+"px",this._box.style.height=c-l+"px");}));}mouseupWindow(t,i){if(!this._active)return;const o=this._startPos,r=i;if(o&&0===t.button){if(this.reset(),_(),o.x!==r.x||o.y!==r.y)return this._map.fire(new e.b("boxzoomend",{originalEvent:t})),{cameraAnimation:e=>e.fitScreenCoordinates(o,r,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",t);}}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e));}blur(){this.reset();}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),u(),delete this._startPos,delete this._lastPos;}_fireEvent(t,i){return this._map.fire(new e.b(t,{originalEvent:i}))}}function yn(e,t){const i={};for(let o=0;othis.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=t.timeStamp),o.length===this.numTouches&&(this.centroid=function(t){const i=new e.P(0,0);for(const e of t)i._add(e);return i.div(t.length)}(i),this.touches=yn(o,i)));}touchmove(e,t,i){if(this.aborted||!this.centroid)return;const o=yn(i,t);for(const e in this.touches){const t=o[e];(!t||t.dist(this.touches[e])>30)&&(this.aborted=!0);}}touchend(e,t,i){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class wn{constructor(e){this.singleTap=new bn(e),this.numTaps=e.numTaps,this.reset();}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset();}touchstart(e,t,i){this.singleTap.touchstart(e,t,i);}touchmove(e,t,i){this.singleTap.touchmove(e,t,i);}touchend(e,t,i){const o=this.singleTap.touchend(e,t,i);if(o){const t=e.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(o)<30;if(t&&i||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=o,this.count===this.numTaps)return this.reset(),o}}}class Tn{constructor(){this._zoomIn=new wn({numTouches:1,numTaps:2}),this._zoomOut=new wn({numTouches:2,numTaps:1}),this.reset();}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset();}touchstart(e,t,i){this._zoomIn.touchstart(e,t,i),this._zoomOut.touchstart(e,t,i);}touchmove(e,t,i){this._zoomIn.touchmove(e,t,i),this._zoomOut.touchmove(e,t,i);}touchend(e,t,i){const o=this._zoomIn.touchend(e,t,i),r=this._zoomOut.touchend(e,t,i);return o?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()+1,around:t.unproject(o)},{originalEvent:e})}):r?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()-1,around:t.unproject(r)},{originalEvent:e})}):void 0}touchcancel(){this.reset();}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}const En={0:1,2:2};class Sn{constructor(e){this.reset(),this._clickTolerance=e.clickTolerance||1;}blur(){this.reset();}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0;}_correctButton(e,t){return !1}_move(e,t){return {}}mousedown(e,t){if(this._lastPoint)return;const i=m(e);this._correctButton(e,i)&&(this._lastPoint=t,this._eventButton=i);}mousemoveWindow(e,t){const i=this._lastPoint;if(i)if(e.preventDefault(),null!=this._eventButton&&function(e,t){const i=En[t];return void 0===e.buttons||(e.buttons&i)!==i}(e,this._eventButton))this.reset();else if(this._moved||!(t.dist(i)0&&(this._active=!0);const r=yn(o,i),s=new e.P(0,0),n=new e.P(0,0);let a=0;for(const e in r){const t=r[e],i=this._touches[e];i&&(s._add(t),n._add(t.sub(i)),a++,r[e]=t);}if(this._touches=r,a{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.removeAttribute("role");}),500);}}class An{constructor(){this.reset();}reset(){this._active=!1,this._firstTwoTouches=void 0;}_start(e){}_move(e,t,i){return {}}touchstart(e,t,i){this._firstTwoTouches||i.length<2||(this._firstTwoTouches=[i[0].identifier,i[1].identifier],this._start([t[0],t[1]]));}touchmove(e,t,i){const o=this._firstTwoTouches;if(!o)return;e.preventDefault();const[r,s]=o,n=Rn(i,t,r),a=Rn(i,t,s);if(!n||!a)return;const l=this._aroundCenter?null:n.add(a).div(2);return this._move([n,a],l,e)}touchend(e,t,i){if(!this._firstTwoTouches)return;const[o,r]=this._firstTwoTouches,s=Rn(i,t,o),n=Rn(i,t,r);s&&n||(this._active&&_(),this.reset());}touchcancel(){this.reset();}enable(e){this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}function Rn(e,t,i){for(let o=0;oMath.abs(e.x)}class Bn extends An{constructor(e){super(),this._map=e;}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0;}_start(e){this._lastPoints=e,Fn(e[0].sub(e[1]))&&(this._valid=!1);}_move(t,i,o){const r=this._lastPoints;if(!r)return;const s=t[0].sub(r[0]),n=t[1].sub(r[1]);return this._map._cooperativeGestures&&!e.c$()&&o.touches.length<3||(this._valid=this.gestureBeginsVertically(s,n,o.timeStamp),!this._valid)?void 0:(this._lastPoints=t,this._active=!0,{pitchDelta:(s.y+n.y)/2*-.5})}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;const o=e.mag()>=2,r=t.mag()>=2;if(!o&&!r)return;if(!o||!r)return null==this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const s=e.y>0==t.y>0;return Fn(e)&&Fn(t)&&s}}const kn={panStep:100,bearingStep:15,pitchStep:10};class Nn{constructor(){const e=kn;this._panStep=e.panStep,this._bearingStep=e.bearingStep,this._pitchStep=e.pitchStep,this._rotationDisabled=!1;}blur(){this.reset();}reset(){this._active=!1;}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,i=0,o=0,r=0,s=0;switch(e.keyCode){case 61:case 107:case 171:case 187:t=1;break;case 189:case 109:case 173:t=-1;break;case 37:e.shiftKey?i=-1:(e.preventDefault(),r=-1);break;case 39:e.shiftKey?i=1:(e.preventDefault(),r=1);break;case 38:e.shiftKey?o=1:(e.preventDefault(),s=-1);break;case 40:e.shiftKey?o=-1:(e.preventDefault(),s=1);break;default:return}return this._rotationDisabled&&(i=0,o=0),{cameraAnimation:n=>{const a=n.getZoom();n.easeTo({duration:300,easeId:"keyboardHandler",easing:Un,zoom:t?Math.round(a)+t*(e.shiftKey?2:1):a,bearing:n.getBearing()+i*this._bearingStep,pitch:n.getPitch()+o*this._pitchStep,offset:[-r*this._panStep,-s*this._panStep],center:n.getCenter()},{originalEvent:e});}}}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 Un(e){return e*(2-e)}const Gn=4.000244140625,jn=1/450;class Vn{constructor(t,i){this._map=t,this._el=t.getCanvasContainer(),this._handler=i,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=jn,e.aY(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this);}setZoomRate(e){this._defaultZoomRate=e;}setWheelZoomRate(e){this._wheelZoomRate=e;}isEnabled(){return !!this._enabled}isActive(){return this._active||void 0!==this._finishTimeout}isZooming(){return !!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around,this._map._cooperativeGestures&&this._addScrollZoomBlocker());}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()));}wheel(t){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(t.ctrlKey||t.metaKey||this.isZooming()||e.c$()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer));}let i=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const o=e.f.now(),r=o-(this._lastWheelEventTime||0);this._lastWheelEventTime=o,0!==i&&i%Gn==0?this._type="wheel":0!==i&&Math.abs(i)<4?this._type="trackpad":r>400?(this._type=null,this._lastValue=i,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(r*i)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,i+=this._lastValue)),t.shiftKey&&i&&(i/=4),this._type&&(this._lastWheelEvent=t,this._delta-=i,this._active||this._start(t)),t.preventDefault();}_onTimeout(e){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e);}_start(e){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 t=p(this._el,e);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:t,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame());}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const t=this._map.transform;"wheel"===this._type&&t.projection.wrap&&(t._center.lng>=180||t._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const i=()=>t._terrainEnabled()&&this._aroundCoord?t.computeZoomRelativeTo(this._aroundCoord):t.zoom;if(0!==this._delta){const e="wheel"===this._type&&Math.abs(this._delta)>Gn?this._wheelZoomRate:this._defaultZoomRate;let o=2/(1+Math.exp(-Math.abs(this._delta*e)));this._delta<0&&0!==o&&(o=1/o);const r=i(),s=Math.pow(2,r),n="number"==typeof this._targetZoom?t.zoomScale(this._targetZoom):s;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(n*o))),"wheel"===this._type&&(this._startZoom=r,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0;}const o="number"==typeof this._targetZoom?this._targetZoom:i(),r=this._startZoom,s=this._easing;let n,a=!1;if("wheel"===this._type&&r&&s){const t=Math.min((e.f.now()-this._lastWheelEventTime)/200,1),i=s(t);n=e.U(r,o,i),t<1?this._frameId||(this._frameId=!0):a=!0;}else n=o,a=!0;this._active=!0,a&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout;}),200));let l=n-i();return l*this._lastDelta<0&&(l=0),{noInertia:!0,needsRenderFrame:!a,zoomDelta:l,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let i=e.d0;if(this._prevEase){const t=this._prevEase,o=(e.f.now()-t.start)/t.duration,r=t.easing(o+.01)-t.easing(o),s=.27/Math.sqrt(r*r+1e-4)*.01,n=Math.sqrt(.0729-s*s);i=e.c_(s,n,.25,1);}return this._prevEase={start:e.f.now(),duration:t,easing:i},i}blur(){this.reset();}reset(){this._active=!1;}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=s("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`);}_showBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout((()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.removeAttribute("role");}),200);}}class Zn{constructor(e,t){this._clickZoom=e,this._tapZoom=t;}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 Hn{constructor(){this.reset();}reset(){this._active=!1;}blur(){this.reset();}dblclick(e,t){return e.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:i.getZoom()+(e.shiftKey?-1:1),around:i.unproject(t)},{originalEvent:e});}}}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class Wn{constructor(){this._tap=new wn({numTouches:1,numTaps:1}),this.reset();}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset();}touchstart(e,t,i){this._swipePoint||(this._tapTime&&e.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?i.length>0&&(this._swipePoint=t[0],this._swipeTouch=i[0].identifier):this._tap.touchstart(e,t,i));}touchmove(e,t,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const o=t[0],r=o.y-this._swipePoint.y;return this._swipePoint=o,e.preventDefault(),this._active=!0,{zoomDelta:r/128}}}else this._tap.touchmove(e,t,i);}touchend(e,t,i){this._tapTime?this._swipePoint&&0===i.length&&this.reset():this._tap.touchend(e,t,i)&&(this._tapTime=e.timeStamp);}touchcancel(){this.reset();}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class qn{constructor(e,t,i){this._el=e,this._mousePan=t,this._touchPan=i;}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("mapboxgl-touch-drag-pan");}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("mapboxgl-touch-drag-pan");}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class $n{constructor(e,t,i){this._pitchWithRotate=e.pitchWithRotate,this._mouseRotate=t,this._mousePitch=i;}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable();}disable(){this._mouseRotate.disable(),this._mousePitch.disable();}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class Xn{constructor(e,t,i,o){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=o,this._rotationDisabled=!1,this._enabled=!0;}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("mapboxgl-touch-zoom-rotate");}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("mapboxgl-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();}}const Kn=e=>e.zoom||e.drag||e.pitch||e.rotate;class Yn extends e.b{}class Jn{constructor(){this.constants=[1,1,.01],this.radius=0;}setup(t,i){const o=e.N.sub([],i,t);this.radius=e.N.length(o[2]<0?e.N.div([],o,this.constants):[o[0],o[1],0]);}projectRay(t){e.N.div(t,t,this.constants),e.N.normalize(t,t),e.N.mul(t,t,this.constants);const i=e.N.scale([],t,this.radius);if(i[2]>0){const t=e.N.scale([],[0,0,1],e.N.dot(i,[0,0,1])),o=e.N.scale([],e.N.normalize([],[i[0],i[1],0]),this.radius),r=e.N.add([],i,e.N.scale([],e.N.sub([],e.N.add([],o,t),i),2));i[0]=r[0],i[1]=r[1];}return i}}function Qn(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta}class ea{constructor(t,i){this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new un(t),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new Jn,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(i),e.aY(["handleEvent","handleWindowEvent"],this);const o=this._el;this._listeners=[[o,"touchstart",{passive:!0}],[o,"touchmove",{passive:!1}],[o,"touchend",void 0],[o,"touchcancel",void 0],[o,"mousedown",void 0],[o,"mousemove",void 0],[o,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[o,"mouseover",void 0],[o,"mouseout",void 0],[o,"dblclick",void 0],[o,"click",void 0],[o,"keydown",{capture:!1}],[o,"keyup",void 0],[o,"wheel",{passive:!1}],[o,"contextmenu",void 0],[window,"blur",void 0]];for(const[e,t,i]of this._listeners){const o=e===document?this.handleWindowEvent:this.handleEvent;e.addEventListener(t,o,i);}}destroy(){for(const[e,t,i]of this._listeners){const o=e===document?this.handleWindowEvent:this.handleEvent;e.removeEventListener(t,o,i);}}_addDefaultHandlers(e){const t=this._map,i=t.getCanvasContainer();this._add("mapEvent",new gn(t,e));const o=t.boxZoom=new xn(t,e);this._add("boxZoom",o);const r=new Tn,s=new Hn;t.doubleClickZoom=new Zn(s,r),this._add("tapZoom",r),this._add("clickZoom",s);const n=new Wn;this._add("tapDragZoom",n);const a=t.touchPitch=new Bn(t);this._add("touchPitch",a);const l=new In(e),c=new Dn(e);t.dragRotate=new $n(e,l,c),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",c,["mouseRotate"]);const h=new Cn(e),u=new Ln(t,e);t.dragPan=new qn(i,h,u),this._add("mousePan",h),this._add("touchPan",u,["touchZoom","touchRotate"]);const d=new On,_=new Mn;t.touchZoomRotate=new Xn(i,_,d,n),this._add("touchRotate",d,["touchPan","touchZoom"]),this._add("touchZoom",_,["touchPan","touchRotate"]),this._add("blockableMapEvent",new vn(t));const p=t.scrollZoom=new Vn(t,this);this._add("scrollZoom",p,["mousePan"]);const f=t.keyboard=new Nn;this._add("keyboard",f);for(const i of ["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])e.interactive&&e[i]&&t[i].enable(e[i]);}_add(e,t,i){this._handlers.push({handlerName:e,handler:t,allowed:i}),this._handlersById[e]=t;}stop(e){if(!this._updatingCamera){for(const{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[],this._originalZoom=void 0;}}isActive(){for(const{handler:e}of this._handlers)if(e.isActive())return !0;return !1}isZooming(){return !!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return !!this._eventsInProgress.rotate}isMoving(){return !!Kn(this._eventsInProgress)||this.isZooming()}_isDragging(){return !!this._eventsInProgress.drag}_blockedByActive(e,t,i){for(const o in e)if(o!==i&&(!t||t.indexOf(o)<0))return !0;return !1}handleWindowEvent(e){this.handleEvent(e,`${e.type}Window`);}_getMapTouches(e){const t=[];for(const i of e)this._el.contains(i.target)&&t.push(i);return t}handleEvent(e,t){this._updatingCamera=!0;const i="renderFrame"===e.type,o=i?void 0:e,r={needsRenderFrame:!1},s={},n={},a=e.touches?this._getMapTouches(e.touches):void 0,l=a?f(this._el,a):i?void 0:p(this._el,e);for(const{handlerName:i,handler:c,allowed:h}of this._handlers){if(!c.isEnabled())continue;let u;this._blockedByActive(n,h,i)?c.reset():c[t||e.type]&&(u=c[t||e.type](e,l,a),this.mergeHandlerResult(r,s,u,i,o),u&&u.needsRenderFrame&&this._triggerRenderFrame()),(u||c.isActive())&&(n[i]=c);}const c={};for(const e in this._previousActiveHandlers)n[e]||(c[e]=o);this._previousActiveHandlers=n,(Object.keys(c).length||Qn(r))&&(this._changes.push([r,s,c]),this._triggerRenderFrame()),(Object.keys(n).length||Qn(r))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:h}=r;h&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],h(this._map));}mergeHandlerResult(t,i,o,r,s){if(!o)return;e.e(t,o);const n={handlerName:r,originalEvent:o.originalEvent||s};void 0!==o.zoomDelta&&(i.zoom=n),void 0!==o.panDelta&&(i.drag=n),void 0!==o.pitchDelta&&(i.pitch=n),void 0!==o.bearingDelta&&(i.rotate=n);}_applyChanges(){const t={},i={},o={};for(const[r,s,n]of this._changes)r.panDelta&&(t.panDelta=(t.panDelta||new e.P(0,0))._add(r.panDelta)),r.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+r.zoomDelta),r.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+r.bearingDelta),r.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+r.pitchDelta),void 0!==r.around&&(t.around=r.around),void 0!==r.aroundCoord&&(t.aroundCoord=r.aroundCoord),void 0!==r.pinchAround&&(t.pinchAround=r.pinchAround),r.noInertia&&(t.noInertia=r.noInertia),e.e(i,s),e.e(o,n);this._updateMapTransform(t,i,o),this._changes=[];}_updateMapTransform(t,i,o){const r=this._map,s=r.transform,n=e=>[e.x,e.y,e.z];if((e=>{const t=this._eventsInProgress.drag;return t&&!this._handlersById[t.handlerName].isActive()})()&&!Qn(t)){const e=s.zoom;s.cameraElevationReference="sea",null!=this._originalZoom&&s._orthographicProjectionAtLowPitch&&"globe"!==s.projection.name&&0===s.pitch?(s.cameraElevationReference="ground",s.zoom=this._originalZoom):(s.recenterOnTerrain(),s.cameraElevationReference="ground"),e!==s.zoom&&this._map._update(!0);}if(s._isCameraConstrained&&r._stop(!0),!Qn(t))return void this._fireEvents(i,o,!0);let{panDelta:a,zoomDelta:l,bearingDelta:c,pitchDelta:h,around:u,aroundCoord:d,pinchAround:_}=t;s._isCameraConstrained&&(l>0&&(l=0),s._isCameraConstrained=!1),void 0!==_&&(u=_),(l||(e=>i[e]&&!this._eventsInProgress[e])("drag"))&&u&&(this._dragOrigin=n(s.pointCoordinate3D(u)),this._originalZoom=s.zoom,this._trackingEllipsoid.setup(s._camera.position,this._dragOrigin)),s.cameraElevationReference="sea",r._stop(!0),u=u||r.transform.centerPoint,c&&(s.bearing+=c),h&&(s.pitch+=h),s._updateCameraState();const p=[0,0,0];if(a)if("mercator"===s.projection.name){const e=this._trackingEllipsoid.projectRay(s.screenPointToMercatorRay(u).dir),t=this._trackingEllipsoid.projectRay(s.screenPointToMercatorRay(u.sub(a)).dir);p[0]=t[0]-e[0],p[1]=t[1]-e[1];}else {const t=s.pointCoordinate(u);if("globe"===s.projection.name){a=a.rotate(-s.angle);const i=s._pixelsPerMercatorPixel/s.worldSize;p[0]=-a.x*e.d1(e.au(t.y))*i,p[1]=-a.y*e.d1(s.center.lat)*i;}else {const e=s.pointCoordinate(u.sub(a));t&&e&&(p[0]=e.x-t.x,p[1]=e.y-t.y);}}const f=s.zoom,m=[0,0,0];if(l){const t=n(d||s.pointCoordinate3D(u)),i={dir:e.N.normalize([],e.N.sub([],t,s._camera.position))};if(i.dir[2]<0){const o=s.zoomDeltaToMovement(t,l);e.N.scale(m,i.dir,o);}}const g=e.N.add(p,p,m);s._translateCameraConstrained(g),l&&Math.abs(s.zoom-f)>1e-4&&s.recenterOnTerrain(),s.cameraElevationReference="ground",this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(i,o,!0);}_fireEvents(t,i,o){const r=Kn(this._eventsInProgress),s=Kn(t),n={};for(const e in t){const{originalEvent:i}=t[e];this._eventsInProgress[e]||(n[`${e}start`]=i),this._eventsInProgress[e]=t[e];}!r&&s&&this._fireEvent("movestart",s.originalEvent);for(const e in n)this._fireEvent(e,n[e]);s&&this._fireEvent("move",s.originalEvent);for(const e in t){const{originalEvent:i}=t[e];this._fireEvent(e,i);}const a={};let l;for(const e in this._eventsInProgress){const{handlerName:t,originalEvent:o}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],l=i[t]||o,a[`${e}end`]=l);}for(const e in a)this._fireEvent(e,a[e]);const c=Kn(this._eventsInProgress);if(o&&(r||s)&&!c){this._updatingCamera=!0;const t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=e=>0!==e&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new Yn("renderFrame",{timeStamp:e})),this._applyChanges();}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame());}}const ta="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class ia extends e.E{constructor(t,i){super(),this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=i.bearingSnap,this._respectPrefersReducedMotion=!1!==i.respectPrefersReducedMotion,e.aY(["_renderFrameCallback"],this);}getCenter(){return new e.bn(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}panBy(t,i,o){return t=e.P.convert(t).mult(-1),this.panTo(this.transform.center,e.e({offset:t},i),o)}panTo(t,i,o){return this.easeTo(e.e({center:t},i),o)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(t,i,o){return this.easeTo(e.e({zoom:t},i),o)}zoomIn(e,t){return this.zoomTo(this.getZoom()+1,e,t),this}zoomOut(e,t){return this.zoomTo(this.getZoom()-1,e,t),this}getBearing(){return this.transform.bearing}setBearing(e,t){return this.jumpTo({bearing:e},t),this}getPadding(){return this.transform.padding}setPadding(e,t){return this.jumpTo({padding:e},t),this}rotateTo(t,i,o){return this.easeTo(e.e({bearing:t},i),o)}resetNorth(t,i){return this.rotateTo(0,e.e({duration:1e3},t),i),this}resetNorthPitch(t,i){return this.easeTo(e.e({bearing:0,pitch:0,duration:1e3},t),i),this}snapToNorth(e,t){return Math.abs(this.getBearing())e.aspect?i/(2*Math.tan(.5*e.fovX)*e.aspect):o/(2*Math.tan(.5*e.fovY)*e.aspect)}_cameraForBoundsOnGlobe(t,i,o,r,s,n){const a=t.clone(),l=this._extendCameraOptions(n);a.bearing=r,a.pitch=s;const c=e.bn.convert(i),h=e.bn.convert(o),u=.5*(c.lat+h.lat),d=.5*(c.lng+h.lng),_=e.d2(u,d),p=e.N.normalize([],_),f=e.N.normalize([],e.N.cross([],p,[0,1,0])),m=e.N.cross([],f,p),g=[f[0],f[1],f[2],0,m[0],m[1],m[2],0,p[0],p[1],p[2],0,0,0,0,1],v=[_,e.d2(c.lat,c.lng),e.d2(h.lat,c.lng),e.d2(h.lat,h.lng),e.d2(c.lat,h.lng),e.d2(u,c.lng),e.d2(u,h.lng),e.d2(c.lat,d),e.d2(h.lat,d)];let x=e.bS.fromPoints(v.map((t=>[e.N.dot(f,t),e.N.dot(m,t),e.N.dot(p,t)])));const y=e.N.transformMat4([],x.center,g);0===e.N.squaredLength(y)&&e.N.set(y,0,0,1),e.N.normalize(y,y),e.N.scale(y,y,e.ab),a.center=e.d3(y);const b=a.getWorldToCameraMatrix(),w=e.a6.invert(new Float64Array(16),b);x=e.bS.applyTransform(x,e.a6.multiply([],b,g)),e.N.transformMat4(y,y,b);const T=.5*(x.max[2]-x.min[2]),E=this._minimumAABBFrustumDistance(a,x),S=e.N.scale([],[0,0,1],T),C=e.N.add(S,y,S),I=E+(0===a.pitch?0:e.N.distance(y,C)),D=a.globeCenterInViewSpace,L=e.N.sub([],y,[D[0],D[1],D[2]]);e.N.normalize(L,L),e.N.scale(L,L,I);const A=e.N.add([],y,L);e.N.transformMat4(A,A,w);const R=e.d4/e.ab,P=e.N.length(A),M=e.bl(Math.max(P*R-e.d4,Number.EPSILON),0),z=Math.min(a.zoomFromMercatorZAdjusted(M),l.maxZoom);return z>.5*(e.bG+e.bx)?(a.setProjection({name:"mercator"}),a.zoom=z,this._cameraForBounds(a,i,o,r,s,n)):{center:a.center,zoom:z,bearing:r,pitch:s}}queryTerrainElevation(t,i){const o=this.transform.elevation;return o?(i=e.e({},{exaggerated:!0},i),o.getAtPoint(e.L.fromLngLat(t),null,i.exaggerated)):null}_cameraForBounds(t,i,o,r,s,n){if("globe"===t.projection.name)return this._cameraForBoundsOnGlobe(t,i,o,r,s,n);const a=t.clone(),l=this._extendCameraOptions(n),c=a.padding;a.bearing=r,a.pitch=s;const h=e.bn.convert(i),u=e.bn.convert(o),d=new e.bn(h.lng,u.lat),_=new e.bn(u.lng,h.lat),p=a.project(h),f=a.project(u),m=this.queryTerrainElevation(h),g=this.queryTerrainElevation(u),v=this.queryTerrainElevation(d),x=this.queryTerrainElevation(_),y=[[p.x,p.y,Math.min(m||0,g||0,v||0,x||0)],[f.x,f.y,Math.max(m||0,g||0,v||0,x||0)]];let b=e.bS.fromPoints(y);const w=a.getWorldToCameraMatrix(),T=e.a6.invert(new Float64Array(16),w);b=e.bS.applyTransform(b,w);const E=e.N.sub([],b.max,b.min),S=c.left||0,C=c.right||0,I=c.bottom||0,D=c.top||0,{left:L,right:A,top:R,bottom:P}=l.padding,M=.5*(S+C),z=.5*(D+I),O=Math.min(a.scaleZoom(a.scale*Math.min((a.width-(S+C+L+A))/E[0],(a.height-(I+D+P+R))/E[1])),l.maxZoom),F=a.scale/a.zoomScale(O);b=new e.bS([b.min[0]-(L+M)*F,b.min[1]-(P+z)*F,b.min[2]],[b.max[0]+(A+M)*F,b.max[1]+(R+z)*F,b.max[2]]);const B=.5*E[2],k=this._minimumAABBFrustumDistance(a,b),N=[0,0,1,0];e.a7.transformMat4(N,N,w),e.a7.normalize(N,N);const U=e.N.scale([],N,k+B),G=e.N.add([],b.center,U),j=("number"==typeof l.offset.x&&"number"==typeof l.offset.y?new e.P(l.offset.x,l.offset.y):e.P.convert(l.offset)).rotate(-e.bj(r));b.center[0]-=j.x*F,b.center[1]+=j.y*F,e.N.transformMat4(b.center,b.center,T),e.N.transformMat4(G,G,T);const V=[b.center[0],b.center[1],G[2]*a.pixelsPerMeter];e.N.scale(V,V,1/a.worldSize);const Z=e.at(V[0]),H=e.au(V[1]),W=Math.min(a._zoomFromMercatorZ(V[2]),l.maxZoom),q=new e.bn(Z,H);return a.mercatorFromTransition&&W<.5*(e.bG+e.bx)?(a.setProjection({name:"globe"}),a.zoom=W,this._cameraForBounds(a,i,o,r,s,n)):{center:q,zoom:W,bearing:r,pitch:s}}fitBounds(e,t,i){const o=this.cameraForBounds(e,t);return this._fitInternal(o,t,i)}fitScreenCoordinates(t,i,o,r,s){const n=e.P.convert(t),a=e.P.convert(i),l=new e.P(Math.min(n.x,a.x),Math.min(n.y,a.y)),c=new e.P(Math.max(n.x,a.x),Math.max(n.y,a.y));if("mercator"===this.transform.projection.name&&this.transform.anyCornerOffEdge(n,a))return this;const h=this.transform.pointLocation3D(l),u=this.transform.pointLocation3D(c),d=this.transform.pointLocation3D(new e.P(l.x,c.y)),_=this.transform.pointLocation3D(new e.P(c.x,l.y)),p=[Math.min(h.lng,u.lng,d.lng,_.lng),Math.min(h.lat,u.lat,d.lat,_.lat)],f=[Math.max(h.lng,u.lng,d.lng,_.lng),Math.max(h.lat,u.lat,d.lat,_.lat)],m=r&&r.pitch?r.pitch:this.getPitch(),g=this._cameraForBounds(this.transform,p,f,o,m,r);return this._fitInternal(g,r,s)}_fitInternal(t,i,o){return t?(delete(i=e.e(t,i)).padding,i.linear?this.easeTo(i,o):this.flyTo(i,o)):this}jumpTo(t,i){this.stop();const o=t.preloadOnly?this.transform.clone():this.transform;let r=!1,s=!1,n=!1;return "zoom"in t&&o.zoom!==+t.zoom&&(r=!0,o.zoom=+t.zoom),void 0!==t.center&&(o.center=e.bn.convert(t.center)),"bearing"in t&&o.bearing!==+t.bearing&&(s=!0,o.bearing=+t.bearing),"pitch"in t&&o.pitch!==+t.pitch&&(n=!0,o.pitch=+t.pitch),null==t.padding||o.isPaddingEqual(t.padding)||(o.padding=t.padding),t.preloadOnly?(this._preloadTiles(o),this):(this.fire(new e.b("movestart",i)).fire(new e.b("move",i)),r&&this.fire(new e.b("zoomstart",i)).fire(new e.b("zoom",i)).fire(new e.b("zoomend",i)),s&&this.fire(new e.b("rotatestart",i)).fire(new e.b("rotate",i)).fire(new e.b("rotateend",i)),n&&this.fire(new e.b("pitchstart",i)).fire(new e.b("pitch",i)).fire(new e.b("pitchend",i)),this.fire(new e.b("moveend",i)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||e.w(ta),this.transform.getFreeCameraOptions()}setFreeCameraOptions(t,i){const o=this.transform;if(!o.projection.supportsFreeCamera)return e.w(ta),this;this.stop();const r=o.zoom,s=o.pitch,n=o.bearing;o.setFreeCameraOptions(t);const a=r!==o.zoom,l=s!==o.pitch,c=n!==o.bearing;return this.fire(new e.b("movestart",i)).fire(new e.b("move",i)),a&&this.fire(new e.b("zoomstart",i)).fire(new e.b("zoom",i)).fire(new e.b("zoomend",i)),c&&this.fire(new e.b("rotatestart",i)).fire(new e.b("rotate",i)).fire(new e.b("rotateend",i)),l&&this.fire(new e.b("pitchstart",i)).fire(new e.b("pitch",i)).fire(new e.b("pitchend",i)),this.fire(new e.b("moveend",i)),this}easeTo(t,i){this._stop(!1,t.easeId),(!1===(t=e.e({offset:[0,0],duration:500,easing:e.d0},t)).animate||this._prefersReducedMotion(t))&&(t.duration=0);const o=this.transform,r=this.getZoom(),s=this.getBearing(),n=this.getPitch(),a=this.getPadding(),l="zoom"in t?+t.zoom:r,c="bearing"in t?this._normalizeBearing(t.bearing,s):s,h="pitch"in t?+t.pitch:n,u="padding"in t?t.padding:o.padding,d=e.P.convert(t.offset);let _,p,f;if("globe"===o.projection.name){const i=e.L.fromLngLat(o.center),r=d.rotate(-o.angle);i.x+=r.x/o.worldSize,i.y+=r.y/o.worldSize;const s=i.toLngLat(),n=e.bn.convert(t.center||s);this._normalizeCenter(n),_=o.centerPoint.add(r),p=new e.P(i.x,i.y).mult(o.worldSize),f=new e.P(e.a5(n.lng),e.ae(n.lat)).mult(o.worldSize).sub(p);}else {_=o.centerPoint.add(d);const i=o.pointLocation(_),r=e.bn.convert(t.center||i);this._normalizeCenter(r),p=o.project(i),f=o.project(r).sub(p);}const m=o.zoomScale(l-r);let g,v;t.around&&(g=e.bn.convert(t.around),v=o.locationPoint(g));const x=this._zooming||l!==r,y=this._rotating||s!==c,b=this._pitching||h!==n,w=!o.isPaddingEqual(u),T=o=>T=>{if(x&&(o.zoom=e.U(r,l,T)),y&&(o.bearing=e.U(s,c,T)),b&&(o.pitch=e.U(n,h,T)),w&&(o.interpolatePadding(a,u,T),_=o.centerPoint.add(d)),g)o.setLocationAtPoint(g,v);else {const e=o.zoomScale(o.zoom-r),t=l>r?Math.min(2,m):Math.max(.5,m),i=Math.pow(t,1-T),s=o.unproject(p.add(f.mult(T*i)).mult(e));o.setLocationAtPoint(o.renderWorldCopies?s.wrap():s,_);}return t.preloadOnly||this._fireMoveEvents(i),o};if(t.preloadOnly){const e=this._emulate(T,t.duration,o);return this._preloadTiles(e),this}const E={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=x,this._rotating=y,this._pitching=b,this._easeId=t.easeId,this._prepareEase(i,t.noMoveStart,E),this._ease(T(o),(e=>{"sea"===o.cameraElevationReference&&o.recenterOnTerrain(),this._afterEase(i,e);}),t),this}_prepareEase(t,i,o={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&0===this.transform.pitch&&"globe"!==this.transform.projection.name&&(this.transform.cameraElevationReference="ground"),i||o.moving||this.fire(new e.b("movestart",t)),this._zooming&&!o.zooming&&this.fire(new e.b("zoomstart",t)),this._rotating&&!o.rotating&&this.fire(new e.b("rotatestart",t)),this._pitching&&!o.pitching&&this.fire(new e.b("pitchstart",t));}_fireMoveEvents(t){this.fire(new e.b("move",t)),this._zooming&&this.fire(new e.b("zoom",t)),this._rotating&&this.fire(new e.b("rotate",t)),this._pitching&&this.fire(new e.b("pitch",t));}_afterEase(t,i){if(this._easeId&&i&&this._easeId===i)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const o=this._zooming,r=this._rotating,s=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,o&&this.fire(new e.b("zoomend",t)),r&&this.fire(new e.b("rotateend",t)),s&&this.fire(new e.b("pitchend",t)),this.fire(new e.b("moveend",t));}flyTo(t,i){if(this._prefersReducedMotion(t)){const o=e.ac(t,["center","zoom","bearing","pitch","around"]);return this.jumpTo(o,i)}this.stop(),t=e.e({offset:[0,0],speed:1.2,curve:1.42,easing:e.d0},t);const o=this.transform,r=this.getZoom(),s=this.getBearing(),n=this.getPitch(),a="zoom"in t?e.aa(+t.zoom,o.minZoom,o.maxZoom):r,l="bearing"in t?this._normalizeBearing(t.bearing,s):s,c="pitch"in t?+t.pitch:n,h=o.zoomScale(a-r),u=e.P.convert(t.offset),d=o.centerPoint.add(u),_=o.pointLocation(d);let p=t.center;if(p&&t.padding){const e=this._cameraForBounds(this.transform,p,p,l,c,t);e&&(p=e.center);}p=e.bn.convert(p||_),this._normalizeCenter(p);const f=o.project(_),m=o.project(p).sub(f);let g=t.curve;const v=Math.max(o.width,o.height),x=v/h,y=m.mag();if("minZoom"in t){const i=e.aa(Math.min(t.minZoom,r,a),o.minZoom,o.maxZoom),s=v/o.zoomScale(i-r);g=Math.sqrt(s/y*2);}const b=g*g;function w(e){const t=(x*x-v*v+(e?-1:1)*b*b*y*y)/(2*(e?x:v)*b*y);return Math.log(Math.sqrt(t*t+1)-t)}function T(e){return (Math.exp(e)-Math.exp(-e))/2}function E(e){return (Math.exp(e)+Math.exp(-e))/2}const S=w(0);let C=function(e){return E(S)/E(S+g*e)},I=function(e){return v*((E(S)*(T(t=S+g*e)/E(t))-T(S))/b)/y;var t;},D=(w(1)-S)/g;if(Math.abs(y)<1e-6||!isFinite(D)){if(Math.abs(v-x)<1e-6)return this.easeTo(t,i);const e=xt.maxDuration&&(t.duration=0);const L=s!==l,A=c!==n,R=o=>h=>{const u=h*D,_=1/C(u);o.zoom=1===h?a:r+o.scaleZoom(_),L&&(o.bearing=e.U(s,l,h)),A&&(o.pitch=e.U(n,c,h));const g=1===h?p:o.unproject(f.add(m.mult(I(u))).mult(_));return o.setLocationAtPoint(o.renderWorldCopies?g.wrap():g,d),o._updateCameraOnTerrain(),t.preloadOnly||this._fireMoveEvents(i),o};if(t.preloadOnly){const e=this._emulate(R,t.duration,o);return this._preloadTiles(e),this}return this._zooming=!0,this._rotating=L,this._pitching=A,this._prepareEase(i,!1),this._ease(R(o),(()=>this._afterEase(i)),t),this}isEasing(){return !!this._easeFrameId}stop(){return this._stop()}_stop(e,t){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const e=this._onEaseEnd;this._onEaseEnd=void 0,e.call(this,t);}if(!e){const e=this.handlers;e&&e.stop(!1);}return this}_ease(t,i,o){!1===o.animate||0===o.duration?(t(1),i()):(this._easeStart=e.f.now(),this._easeOptions=o,this._onEaseFrame=t,this._onEaseEnd=i,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback));}_renderFrameCallback(){const t=Math.min((e.f.now()-this._easeStart)/this._easeOptions.duration,1),i=this._onEaseFrame;i&&i(this._easeOptions.easing(t)),t<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop();}_normalizeBearing(t,i){t=e.bh(t,-180,180);const o=Math.abs(t-i);return Math.abs(t-360-i)180?-360:i<-180?360:0;}_prefersReducedMotion(t){return this._respectPrefersReducedMotion&&e.f.prefersReducedMotion&&!(t&&t.essential)}_emulate(e,t,i){const o=Math.ceil(15*t/1e3),r=[],s=e(i.clone());for(let e=0;e<=o;e++){const t=s(e/o);r.push(t.clone());}return r}}class oa{constructor(t={}){this.options=t,e.aY(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this);}getDefaultPosition(){return "bottom-right"}onAdd(e){const t=this.options&&this.options.compact;return this._map=e,this._container=s("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=s("button","mapboxgl-ctrl-attrib-button",this._container),s("span","mapboxgl-ctrl-icon",this._compactButton).setAttribute("aria-hidden","true"),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=s("div","mapboxgl-ctrl-attrib-inner",this._container),t&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),void 0===t&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0,this._attribHTML=void 0;}_setElementTitle(e,t){const i=this._map._getUIString(`AttributionControl.${t}`);e.removeAttribute("title"),e.firstElementChild&&e.firstElementChild.setAttribute("title",i);}_toggleAttribution(){this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","false")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"));}_updateEditLink(){let t=this._editLink;t||(t=this._editLink=this._container.querySelector(".mapbox-improve-map"));const i=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||e.d5.ACCESS_TOKEN}];if(t){const o=i.reduce(((e,t,o)=>(t.value&&(e+=`${t.key}=${t.value}${oe.length-t.length)),e=e.filter(((t,i)=>{for(let o=i+1;o=0)return !1;return !0})),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=[...this.options.customAttribution,...e]:e.unshift(this.options.customAttribution));const i=e.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,e.length?(this._innerContainer.innerHTML=i,this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null);}_updateCompact(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact","mapboxgl-compact-show");}}class ra{constructor(){e.aY(["_updateLogo","_updateCompact"],this);}onAdd(e){this._map=e,this._container=s("div","mapboxgl-ctrl");const t=s("a","mapboxgl-ctrl-logo");return t.target="_blank",t.rel="noopener nofollow",t.href="https://www.mapbox.com/",t.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),t.setAttribute("rel","noopener nofollow"),this._container.appendChild(t),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact);}getDefaultPosition(){return "bottom-left"}_updateLogo(e){e&&"metadata"!==e.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none");}_logoRequired(){if(!this._map.style)return !0;const e=this._map.style._sourceCaches;if(0===Object.entries(e).length)return !0;for(const t in e){const i=e[t].getSource();if(i.hasOwnProperty("mapbox_logo")&&!i.mapbox_logo)return !1}return !0}_updateCompact(){const e=this._container.children;if(e.length){const t=e[0];this._map.getCanvasContainer().offsetWidth<250?t.classList.add("mapboxgl-compact"):t.classList.remove("mapboxgl-compact");}}}class sa{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1;}add(e){const t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){const t=this._currentlyRunning,i=t?this._queue.concat(t):this._queue;for(const t of i)if(t.id===e)return void(t.cancelled=!0)}run(e=0){const t=this._currentlyRunning=this._queue;this._queue=[];for(const i of t)if(!i.cancelled&&(i.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1;}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[];}}function na(t,i,o){if(t=new e.bn(t.lng,t.lat),i){const r=new e.bn(t.lng-360,t.lat),s=new e.bn(t.lng+360,t.lat),n=360*Math.ceil(Math.abs(t.lng-o.center.lng)/360),a=o.locationPoint(t).distSqr(i),l=i.x<0||i.y<0||i.x>o.width||i.y>o.height;o.locationPoint(r).distSqr(i)180;){const e=o.locationPoint(t);if(e.x>=0&&e.y>=0&&e.x<=o.width&&e.y<=o.height)break;t.lng>o.center.lng?t.lng-=360:t.lng+=360;}return t}const aa={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%)"};class la extends e.E{constructor(t,i){if(super(),(t instanceof HTMLElement||i)&&(t=e.e({element:t},i)),e.aY(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this),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._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",this._updateMoving=()=>this._update(!0),this._occludedOpacity=t&&t.occludedOpacity||.2,t&&t.element)this._element=t.element,this._offset=e.P.convert(t&&t.offset||[0,0]);else {this._defaultMarker=!0,this._element=s("div");const i=41,o=27,r=n("svg",{display:"block",height:i*this._scale+"px",width:o*this._scale+"px",viewBox:`0 0 ${o} ${i}`},this._element),a=n("radialGradient",{id:"shadowGradient"},n("defs",{},r));n("stop",{offset:"10%","stop-opacity":.4},a),n("stop",{offset:"100%","stop-opacity":.05},a),n("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},r),n("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},r),n("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},r),n("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},r),this._offset=e.P.convert(t&&t.offset||[0,-14]);}this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.hasAttribute("role")||this._element.setAttribute("role","img"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",(e=>{e.preventDefault();})),this._element.addEventListener("mousedown",(e=>{e.preventDefault();}));const o=this._element.classList;for(const e in aa)o.remove(`mapboxgl-marker-anchor-${e}`);o.add(`mapboxgl-marker-anchor-${this._anchor}`);const r=t&&t.className?t.className.trim().split(/\s+/):[];o.add(...r),this._popup=null;}addTo(e){return e===this._map||(this.remove(),this._map=e,e.getCanvasContainer().appendChild(this._element),e.on("move",this._updateMoving),e.on("moveend",this._update),e.on("remove",this._clearFadeTimer),e._addMarker(this),this.setDraggable(this._draggable),this._update(),e.on("click",this._onMapClick)),this}remove(){const e=this._map;return e&&(e.off("click",this._onMapClick),e.off("move",this._updateMoving),e.off("moveend",this._update),e.off("mousedown",this._addDragHandler),e.off("touchstart",this._addDragHandler),e.off("mouseup",this._onUp),e.off("touchend",this._onUp),e.off("mousemove",this._onMove),e.off("touchmove",this._onMove),e.off("remove",this._clearFadeTimer),e._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=e.bn.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeAttribute("role"),this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),e){if(!("offset"in e.options)){const t=38.1,i=13.5,o=Math.sqrt(Math.pow(i,2)/2);e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-t],"bottom-left":[o,-1*(t-i+o)],"bottom-right":[-o,-1*(t-i+o)],left:[i,-1*(t-i)],right:[-i,-1*(t-i)]}:this._offset;}this._popup=e,e._marker=this,this._lngLat&&this._popup.setLngLat(this._lngLat),this._element.setAttribute("role","button"),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress),this._element.setAttribute("aria-expanded","false");}return this}_onKeyPress(e){const t=e.code,i=e.charCode||e.keyCode;"Space"!==t&&"Enter"!==t&&32!==i&&13!==i||this.togglePopup();}_onMapClick(e){const t=e.originalEvent.target,i=this._element;this._popup&&(t===i||i.contains(t))&&this.togglePopup();}getPopup(){return this._popup}togglePopup(){const e=this._popup;return e?(e.isOpen()?(e.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(e.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const e=this._map,t=this._pos;if(!e||!t)return !1;const i=e.unproject(t),o=e.getFreeCameraOptions();if(!o.position)return !1;const r=o.position.toLngLat();return r.distanceTo(i)<.9*r.distanceTo(this._lngLat)}_evaluateOpacity(){const t=this._map;if(!t)return;const i=this._pos;if(!i||i.x<0||i.x>t.transform.width||i.y<0||i.y>t.transform.height)return void this._clearFadeTimer();const o=t.unproject(i);let r;t._showingGlobe()&&e.d6(t.transform,this._lngLat)?r=0:(r=1-t._queryFogOpacity(o),t.transform._terrainEnabled()&&t.getTerrain()&&this._behindTerrain()&&(r*=this._occludedOpacity)),this._element.style.opacity=`${r}`,this._element.style.pointerEvents=r>0?"auto":"none",this._popup&&this._popup._setOpacity(r),this._fadeTimer=null;}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null);}_updateDOM(){const e=this._pos;if(!e||!this._map)return;const t=this._offset.mult(this._scale);this._element.style.transform=`\n translate(${e.x}px,${e.y}px)\n ${aa[this._anchor]}\n ${this._calculateXYTransform()} ${this._calculateZTransform()}\n translate(${t.x}px,${t.y}px)\n `;}_calculateXYTransform(){const t=this._pos,i=this._map,o=this.getPitchAlignment();if(!i||!t||"map"!==o)return "";if(!i._showingGlobe()){const e=i.getPitch();return e?`rotateX(${e}deg)`:""}const r=e.bF(e.d7(i.transform,this._lngLat)),s=t.sub(e.d8(i.transform)),n=Math.abs(s.x)+Math.abs(s.y);if(0===n)return "";const a=r/n;return `rotateX(${-s.y*a}deg) rotateY(${s.x*a}deg)`}_calculateZTransform(){const t=this._pos,i=this._map;if(!i||!t)return "";let o=0;const r=this.getRotationAlignment();if("map"===r)if(i._showingGlobe()){const t=i.project(new e.bn(this._lngLat.lng,this._lngLat.lat+.001)),r=i.project(new e.bn(this._lngLat.lng,this._lngLat.lat-.001)).sub(t);o=e.bF(Math.atan2(r.y,r.x))-90;}else o=-i.getBearing();else if("horizon"===r){const r=e.O(4,6,i.getZoom()),s=e.d8(i.transform);s.y+=r*i.transform.height;const n=t.sub(s),a=e.bF(Math.atan2(n.y,n.x));o=(a>90?a-270:a+90)*(1-r);}return o+=this._rotation,o?`rotateZ(${o}deg)`:""}_update(e){cancelAnimationFrame(this._updateFrameId);const t=this._map;t&&(t.transform.renderWorldCopies&&(this._lngLat=na(this._lngLat,this._pos,t.transform)),this._pos=t.project(this._lngLat),!0===e?this._updateFrameId=requestAnimationFrame((()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM());})):this._pos=this._pos.round(),t._requestDomTask((()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(t._showingGlobe()||t.getTerrain()||t.getFog())&&!this._fadeTimer&&(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)));})));}getOffset(){return this._offset}setOffset(t){return this._offset=e.P.convert(t),this._update(),this}addClassName(e){return this._element.classList.add(e),this}removeClassName(e){return this._element.classList.remove(e),this}toggleClassName(e){return this._element.classList.toggle(e)}_onMove(t){const i=this._map;if(!i)return;const o=this._pointerdownPos,r=this._positionDelta;if(o&&r){if(!this._isDragging){const e=this._clickTolerance||i._clickTolerance;if(t.point.dist(o)=this._endTime)return this._end;const i=e.cc((t-this._startTime)/(this._endTime-this._startTime));return this._start*(1-i)+this._end*i}isEasing(e){return e>=this._startTime&&e<=this._endTime}jumpTo(e){this._startTime=-1/0,this._endTime=-1/0,this._start=e,this._end=e;}easeTo(e,t,i){this._start=this.getValue(t),this._end=e,this._startTime=t,this._endTime=t+i;}}const _a={"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":"Mapbox logo","Map.Title":"Map","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use ⌘ + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"},pa={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:85,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,performanceMetricsCollection:!0,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,antialias:!1,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,minTileCacheSize:null,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,transformRequest:null,accessToken:null,fadeDuration:300,respectPrefersReducedMotion:!0,crossSourceCollisions:!0,collectResourceTiming:!1,testMode:!1};class fa{constructor(){this.showOverdrawInspector=!1,this.showTileBoundaries=!1,this.showParseStatus=!1,this.continuousRedraw=!1,this.showTileAABBs=!1,this.showPadding=!1,this.showTerrainWireframe=!1,this.showLayers2DWireframe=!1,this.showLayers3DWireframe=!1;}}const ma={showCompass:!0,showZoom:!0,visualizePitch:!1};class ga{constructor(t,i,o=!1){this._clickTolerance=10,this.element=i,this.mouseRotate=new In({clickTolerance:t.dragRotate._mouseRotate._clickTolerance}),this.map=t,o&&(this.mousePitch=new Dn({clickTolerance:t.dragRotate._mousePitch._clickTolerance})),e.aY(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),i.addEventListener("mousedown",this.mousedown),i.addEventListener("touchstart",this.touchstart,{passive:!1}),i.addEventListener("touchmove",this.touchmove),i.addEventListener("touchend",this.touchend),i.addEventListener("touchcancel",this.reset);}down(e,t){this.mouseRotate.mousedown(e,t),this.mousePitch&&this.mousePitch.mousedown(e,t),h();}move(e,t){const i=this.map,o=this.mouseRotate.mousemoveWindow(e,t),r=o&&o.bearingDelta;if(r&&i.setBearing(i.getBearing()+r),this.mousePitch){const o=this.mousePitch.mousemoveWindow(e,t),r=o&&o.pitchDelta;r&&i.setPitch(i.getPitch()+r);}}off(){const e=this.element;e.removeEventListener("mousedown",this.mousedown),e.removeEventListener("touchstart",this.touchstart,{passive:!1}),e.removeEventListener("touchmove",this.touchmove),e.removeEventListener("touchend",this.touchend),e.removeEventListener("touchcancel",this.reset),this.offTemp();}offTemp(){u(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup);}mousedown(t){this.down(e.e({},t,{ctrlKey:!0,preventDefault:()=>t.preventDefault()}),p(this.element,t)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup);}mousemove(e){this.move(e,p(this.element,e));}mouseup(e){this.mouseRotate.mouseupWindow(e),this.mousePitch&&this.mousePitch.mouseupWindow(e),this.offTemp();}touchstart(e){1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=f(this.element,e.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>e.preventDefault()},this._startPos));}touchmove(e){1!==e.targetTouches.length?this.reset():(this._lastPos=f(this.element,e.targetTouches)[0],this.move({preventDefault:()=>e.preventDefault()},this._lastPos));}touchend(e){0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)t.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=t.minPitch&&null!=t.maxPitch&&t.minPitch>t.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=t.minPitch&&t.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=t.maxPitch&&t.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(t.antialias&&e.d9(window)&&(t.antialias=!1,e.w("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new mo(t.minZoom,t.maxZoom,t.minPitch,t.maxPitch,t.renderWorldCopies),t),this._repaint=!1,this._interactive=t.interactive,this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._failIfMajorPerformanceCaveat=t.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=t.preserveDrawingBuffer,this._antialias=t.antialias,this._trackResize=t.trackResize,this._bearingSnap=t.bearingSnap,this._refreshExpiredTiles=t.refreshExpiredTiles,this._fadeDuration=t.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=t.crossSourceCollisions,this._collectResourceTiming=t.collectResourceTiming,this._language=this._parseLanguage(t.language),this._worldview=t.worldview,this._renderTaskQueue=new sa,this._domRenderTaskQueue=new sa,this._controls=[],this._markers=[],this._popups=[],this._mapId=e.aC(),this._locale=e.e({},_a,t.locale),this._clickTolerance=t.clickTolerance,this._cooperativeGestures=t.cooperativeGestures,this._performanceMetricsCollection=t.performanceMetricsCollection,this._containerWidth=0,this._containerHeight=0,this._showParseStatus=!0,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new da(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._requestManager=new e.da(t.transformRequest,t.accessToken,t.testMode),this._silenceAuthErrors=!!t.testMode,this._contextCreateOptions=t.contextCreateOptions?{...t.contextCreateOptions}:{},"string"==typeof t.container){const e=document.getElementById(t.container);if(!e)throw new Error(`Container '${t.container.toString()}' not found.`);this._container=e;}else {if(!(t.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=t.container;}if(this._container.childNodes.length>0&&e.w("The map container element should be empty, otherwise the map's interactivity will be negatively impacted. If you want to display a message when WebGL is not supported, use the Mapbox GL Supported plugin instead."),t.maxBounds&&this.setMaxBounds(t.maxBounds),e.aY(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._debugParams=new fa,this._tp=t.devtools?new Js(this):new Js,this._tp.registerParameter(this._debugParams,["Debug"],"showOverdrawInspector",void 0,(()=>{this._update();})),this._tp.registerParameter(this._debugParams,["Debug"],"showTileBoundaries",void 0,(()=>{this._update();})),this._tp.registerParameter(this._debugParams,["Debug"],"showParseStatus",void 0,(()=>{this._update();})),this._tp.registerParameter(this._debugParams,["Debug"],"continuousRedraw",void 0,(e=>{this.repaint=e;})),this._tp.registerParameter(this._debugParams,["Debug"],"showTileAABBs",void 0,(e=>{this.showTileAABBs=e;})),this._tp.registerParameter(this._debugParams,["Debug"],"showPadding",void 0,(e=>{this.showPadding=e;})),this._tp.registerParameter(this._debugParams,["Debug","Wireframe"],"showTerrainWireframe",void 0,(()=>{this._update();})),this._tp.registerParameter(this._debugParams,["Debug","Wireframe"],"showLayers2DWireframe",void 0,(()=>{this._update();})),this._tp.registerParameter(this._debugParams,["Debug","Wireframe"],"showLayers3DWireframe",void 0,(()=>{this._update();})),this._setupPainter(),void 0===this.painter)throw new Error("Failed to initialize WebGL.");if(this.on("move",(()=>this._update(!1))),this.on("moveend",(()=>this._update(!1))),this.on("zoom",(()=>this._update(!0))),this._fullscreenchangeEvent="onfullscreenchange"in document?"fullscreenchange":"webkitfullscreenchange",window.addEventListener("online",this._onWindowOnline,!1),window.addEventListener("resize",this._onWindowResize,!1),window.addEventListener("orientationchange",this._onWindowResize,!1),window.addEventListener(this._fullscreenchangeEvent,this._onWindowResize,!1),window.addEventListener("visibilitychange",this._onVisibilityChange,!1),this.handlers=new ea(this,t),this._localFontFamily=t.localFontFamily,this._localIdeographFontFamily=t.localIdeographFontFamily,(t.style||!t.testMode)&&this.setStyle(t.style||e.d5.DEFAULT_STYLE,{localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),t.projection&&this.setProjection(t.projection),t.hash&&(this._hash=new rn("string"==typeof t.hash&&t.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){null==i.center&&null==i.zoom||(this.transform._unmodified=!1),this.jumpTo({center:t.center,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch});const o=t.bounds;o&&(this.resize(),this.fitBounds(o,e.e({},t.fitBoundsOptions,{duration:0})));}this.resize(),t.attributionControl&&this.addControl(new oa({customAttribution:t.customAttribution})),this._logoControl=new ra,this.addControl(this._logoControl,t.logoPosition),this.on("style.load",(()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet);})),this.on("data",(t=>{this._update("style"===t.dataType),this.fire(new e.b(`${t.dataType}data`,t));})),this.on("dataloading",(t=>{this.fire(new e.b(`${t.dataType}dataloading`,t));}));}_getMapId(){return this._mapId}addControl(t,i){if(void 0===i&&(i=t.getDefaultPosition?t.getDefaultPosition():"top-right"),!t||!t.onAdd)return this.fire(new e.a(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const o=t.onAdd(this);this._controls.push(t);const r=this._controlPositions[i];return -1!==i.indexOf("bottom")?r.insertBefore(o,r.firstChild):r.appendChild(o),this}removeControl(t){if(!t||!t.onRemove)return this.fire(new e.a(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const i=this._controls.indexOf(t);return i>-1&&this._controls.splice(i,1),t.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(t){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));const i=!this._moving;return i&&this.fire(new e.b("movestart",t)).fire(new e.b("move",t)),this.fire(new e.b("resize",t)),i&&this.fire(new e.b("moveend",t)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(t){return this.transform.setMaxBounds(e.ad.convert(t)),this._update()}setMinZoom(t){if((t=null==t?-2:t)>=-2&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t?this.setZoom(t):this.fire(new e.b("zoomstart")).fire(new e.b("zoom")).fire(new e.b("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(t){if((t=null==t?0:t)<0)throw new Error("minPitch must be greater than or equal to 0");if(t>=0&&t<=this.transform.maxPitch)return this.transform.minPitch=t,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(t>=this.transform.minPitch)return this.transform.maxPitch=t,this._update(),this.getPitch()>t?this.setPitch(t):this.fire(new e.b("pitchstart")).fire(new e.b("pitch")).fire(new e.b("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.renderWorldCopies=e,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(e){return "auto"===e?navigator.language:Array.isArray(e)?0===e.length?void 0:e.map((e=>"auto"===e?navigator.language:e)):e}setLanguage(e){const t=this._parseLanguage(e);if(!this.style||t===this._language)return this;this._language=t,this.style.reloadSources();for(const e of this._controls)e._setLanguage&&e._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(e){return this.style&&e!==this._worldview?(this._worldview=e,this.style.reloadSources(),this):this}getProjection(){return this.transform.mercatorFromTransition?{name:"globe",center:[0,0]}:this.transform.getProjection()}_showingGlobe(){return "globe"===this.transform.projection.name}setProjection(e){return this._lazyInitEmptyStyle(),e?"string"==typeof e&&(e={name:e}):e=null,this._useExplicitProjection=!!e,this._prioritizeAndUpdateProjection(e,this.style.projection)}_updateProjectionTransition(){if("globe"!==this.getProjection().name)return;const t=this.transform,i=t.projection.name;let o;"globe"===i&&t.zoom>=e.bx?(t.setMercatorFromTransition(),o=!0):"mercator"===i&&t.zoom=e.bx?this.transform.setMercatorFromTransition():this.transform.setProjection(t),this.style.applyProjectionUpdate(),i&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(t){return this.transform.locationPoint3D(e.bn.convert(t))}unproject(t){return this.transform.pointLocation3D(e.P.convert(t))}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}_isDragging(){return this.handlers&&this.handlers._isDragging()||!1}_createDelegatedListener(e,t,i){if("mouseenter"===e||"mouseover"===e){let o=!1;const r=r=>{const s=t.filter((e=>this.getLayer(e))),n=s.length?this.queryRenderedFeatures(r.point,{layers:s}):[];n.length?o||(o=!0,i.call(this,new pn(e,this,r.originalEvent,{features:n}))):o=!1;},s=()=>{o=!1;};return {layers:new Set(t),listener:i,delegates:{mousemove:r,mouseout:s}}}if("mouseleave"===e||"mouseout"===e){let o=!1;const r=r=>{const s=t.filter((e=>this.getLayer(e)));(s.length?this.queryRenderedFeatures(r.point,{layers:s}):[]).length?o=!0:o&&(o=!1,i.call(this,new pn(e,this,r.originalEvent)));},s=t=>{o&&(o=!1,i.call(this,new pn(e,this,t.originalEvent)));};return {layers:new Set(t),listener:i,delegates:{mousemove:r,mouseout:s}}}{const o=e=>{const o=t.filter((e=>this.getLayer(e))),r=o.length?this.queryRenderedFeatures(e.point,{layers:o}):[];r.length&&(e.features=r,i.call(this,e),delete e.features);};return {layers:new Set(t),listener:i,delegates:{[e]:o}}}}on(e,t,i){if(void 0===i)return super.on(e,t);if(Array.isArray(t)||(t=[t]),t)for(const e of t)if(!this._isValidId(e))return this;const o=this._createDelegatedListener(e,t,i);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(o);for(const e in o.delegates)this.on(e,o.delegates[e]);return this}once(e,t,i){if(void 0===i)return super.once(e,t);if(Array.isArray(t)||(t=[t]),t)for(const e of t)if(!this._isValidId(e))return this;const o=this._createDelegatedListener(e,t,i);for(const e in o.delegates)this.once(e,o.delegates[e]);return this}off(e,t,i){if(void 0===i)return super.off(e,t);t=new Set(Array.isArray(t)?t:[t]);for(const e of t)if(!this._isValidId(e))return this;const o=(e,t)=>{if(e.size!==t.size)return !1;for(const i of e)if(!t.has(i))return !1;return !0},r=this._delegatedListeners?this._delegatedListeners[e]:void 0;return r&&(e=>{for(let r=0;r{t?this.fire(new e.a(t)):o&&this._updateDiff(o,i);}));}else "object"==typeof t&&this._updateDiff(t,i);}_updateDiff(t,i){try{this.style.setState(t)&&this._update(!0);}catch(o){e.w(`Unable to perform style diff: ${o.message||o.error||o}. Rebuilding the style from scratch.`),this._updateStyle(t,i);}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(e.w("There is no style added to the map."),!1)}_isValidId(t){return null==t?(this.fire(new e.a(new Error("IDs can't be empty."))),!1):!e.c4(t)||(this.fire(new e.a(new Error(`IDs can't contain special symbols: "${t}".`))),!1)}addSource(e,t){return this._isValidId(e)?(this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)):this}isSourceLoaded(e){return !!this._isValidId(e)&&!!this.style&&this.style._isSourceCacheLoaded(e)}areTilesLoaded(){return this.style.areTilesLoaded()}addSourceType(e,t,i){this._lazyInitEmptyStyle(),this.style.addSourceType(e,t,i);}removeSource(e){return this._isValidId(e)?(this.style.removeSource(e),this._updateTerrain(),this._update(!0)):this}getSource(e){return this._isValidId(e)?this.style.getOwnSource(e):null}addImage(t,i,{pixelRatio:o=1,sdf:r=!1,stretchX:s,stretchY:n,content:a}={}){if(this._lazyInitEmptyStyle(),i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap){const{width:l,height:c,data:h}=e.f.getImageData(i);this.style.addImage(t,{data:new e.h({width:l,height:c},h),pixelRatio:o,stretchX:s,stretchY:n,content:a,sdf:r,version:0});}else if(void 0===i.width||void 0===i.height)this.fire(new e.a(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`")));else {const{width:l,height:c}=i,h=i;this.style.addImage(t,{data:new e.h({width:l,height:c},new Uint8Array(h.data)),pixelRatio:o,stretchX:s,stretchY:n,content:a,sdf:r,version:0,userImage:h}),h.onAdd&&h.onAdd(this,t);}}updateImage(t,i){this._lazyInitEmptyStyle();const o=this.style.getImage(t);if(!o)return void this.fire(new e.a(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const r=i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap?e.f.getImageData(i):i,{width:s,height:n}=r,a=r.data;if(void 0===s||void 0===n)return void this.fire(new e.a(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(s!==o.data.width||n!==o.data.height)return void this.fire(new e.a(new Error(`The width and height of the updated image (${s}, ${n})\n must be that same as the previous version of the image\n (${o.data.width}, ${o.data.height})`)));const l=!(i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap);o.data.replace(a,l),this.style.updateImage(t,o);}hasImage(t){return t?!!this.style&&!!this.style.getImage(t):(this.fire(new e.a(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e);}loadImage(t,i){e.d(this._requestManager.transformRequest(t,e.R.Image),((t,o)=>{i(t,o instanceof HTMLImageElement?e.f.getImageData(o):o);}));}listImages(){return this.style.listImages()}addModel(e,t){this._lazyInitEmptyStyle(),this.style.addModel(e,t);}hasModel(t){return t?this.style.hasModel(t):(this.fire(new e.a(new Error("Missing required model id"))),!1)}removeModel(e){this.style.removeModel(e);}listModels(){return this.style.listModels()}addLayer(e,t){return this._isValidId(e.id)?(this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)):this}getSlot(e){const t=this.getLayer(e);return t&&t.slot||null}setSlot(e,t){return this.style.setSlot(e,t),this.style.mergeLayers(),this._update(!0)}addImport(e,t){return this.style.addImport(e,t),this}updateImport(e,t){return "string"!=typeof t&&t.id!==e?(this.removeImport(e),this.addImport(t)):(this.style.updateImport(e,t),this._update(!0))}removeImport(e){return this.style.removeImport(e),this}moveImport(e,t){return this.style.moveImport(e,t),this._update(!0)}moveLayer(e,t){return this._isValidId(e)?(this.style.moveLayer(e,t),this._update(!0)):this}removeLayer(e){return this._isValidId(e)?(this.style.removeLayer(e),this._update(!0)):this}getLayer(e){return this._isValidId(e)?this.style.getOwnLayer(e):null}setLayerZoomRange(e,t,i){return this._isValidId(e)?(this.style.setLayerZoomRange(e,t,i),this._update(!0)):this}setFilter(e,t,i={}){return this._isValidId(e)?(this.style.setFilter(e,t,i),this._update(!0)):this}getFilter(e){return this._isValidId(e)?this.style.getFilter(e):null}setPaintProperty(e,t,i,o={}){return this._isValidId(e)?(this.style.setPaintProperty(e,t,i,o),this._update(!0)):this}getPaintProperty(e,t){return this._isValidId(e)?this.style.getPaintProperty(e,t):null}setLayoutProperty(e,t,i,o={}){return this._isValidId(e)?(this.style.setLayoutProperty(e,t,i,o),this._update(!0)):this}getLayoutProperty(e,t){return this._isValidId(e)?this.style.getLayoutProperty(e,t):null}getConfigProperty(e,t){return this.style.getConfigProperty(e,t)}setConfigProperty(e,t,i){return this.style.setConfigProperty(e,t,i),this._update(!0)}setLights(e){if(this._lazyInitEmptyStyle(),e&&1===e.length&&"flat"===e[0].type){const t=e[0];t.properties?this.style.setFlatLight(t.properties,t.id,{}):this.style.setFlatLight({},"flat");}else this.style.setLights(e),this.painter.terrain&&(this.painter.terrain.invalidateRenderCache=!0);return this._update(!0)}getLights(){const e=this.style.getLights()||[];return 0===e.length&&e.push({id:this.style.light.id,type:"flat",properties:this.style.getFlatLight()}),e}setLight(e,t={}){return console.log("The `map.setLight` function is deprecated, prefer using `map.setLights` with `flat` light type instead."),this.setLights([{id:"flat",type:"flat",properties:e}])}getLight(){return console.log("The `map.getLight` function is deprecated, prefer using `map.getLights` instead."),this.style.getFlatLight()}setTerrain(e){return this._lazyInitEmptyStyle(),!e&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(e),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(e){return this._lazyInitEmptyStyle(),this.style.setFog(e),this._update(!0)}getFog(){return this.style?this.style.getFog():null}setCamera(e){return this.style.setCamera(e),this._triggerCameraUpdate(e)}_triggerCameraUpdate(e){return this._update(this.transform.setOrthographicProjectionAtLowPitch("orthographic"===e["camera-projection"]))}getCamera(){return this.style.camera}_queryFogOpacity(t){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(e.bn.convert(t),this.transform):0}setFeatureState(e,t){return this._isValidId(e.source)?(this.style.setFeatureState(e,t),this._update()):this}removeFeatureState(e,t){return this._isValidId(e.source)?(this.style.removeFeatureState(e,t),this._update()):this}getFeatureState(e){return this._isValidId(e.source)?this.style.getFeatureState(e):null}_updateContainerDimensions(){if(!this._container)return;const e=this._container.getBoundingClientRect().width||400,t=this._container.getBoundingClientRect().height||300;let i,o,r,s=this._container;for(;s&&(!o||!r);){const e=window.getComputedStyle(s).transform;e&&"none"!==e&&(i=e.match(/matrix.*\((.+)\)/)[1].split(", "),i[0]&&"0"!==i[0]&&"1"!==i[0]&&(o=i[0]),i[3]&&"0"!==i[3]&&"1"!==i[3]&&(r=i[3])),s=s.parentElement;}this._containerWidth=o?Math.abs(e/o):e,this._containerHeight=r?Math.abs(t/r):t;}_detectMissingCSS(){"rgb(250, 128, 114)"!==window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&e.w("This page appears to be missing CSS declarations for Mapbox GL JS, which may cause the map to display incorrectly. Please ensure your page includes mapbox-gl.css, as described in https://www.mapbox.com/mapbox-gl-js/api/.");}_setupContainer(){const e=this._container;e.classList.add("mapboxgl-map"),(this._missingCSSCanary=s("div","mapboxgl-canary",e)).style.visibility="hidden",this._detectMissingCSS();const t=this._canvasContainer=s("div","mapboxgl-canvas-container",e);this._canvas=s("canvas","mapboxgl-canvas",t),this._interactive&&(t.classList.add("mapboxgl-interactive"),this._canvas.setAttribute("tabindex","0")),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const i=this._controlContainer=s("div","mapboxgl-control-container",e),o=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((e=>{o[e]=s("div",`mapboxgl-ctrl-${e}`,i);})),this._container.addEventListener("scroll",this._onMapScroll,!1);}_resizeCanvas(t,i){const o=e.f.devicePixelRatio||1;this._canvas.width=o*Math.ceil(t),this._canvas.height=o*Math.ceil(i),this._canvas.style.width=`${t}px`,this._canvas.style.height=`${i}px`;}_addMarker(e){this._markers.push(e);}_removeMarker(e){const t=this._markers.indexOf(e);-1!==t&&this._markers.splice(t,1);}_addPopup(e){this._popups.push(e);}_removePopup(e){const t=this._popups.indexOf(e);-1!==t&&this._popups.splice(t,1);}_setupPainter(){const t=e.e({},i.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),o=this._canvas.getContext("webgl2",t);o?(e.db(o,!0),this.painter=new tn(o,this._contextCreateOptions,this.transform,this._tp),this.on("data",(e=>{"source"===e.dataType&&this.painter.setTileLoadedFlag(!0);})),e.dc.testSupport(o)):this.fire(new e.a(new Error("Failed to initialize WebGL")));}_contextLost(t){t.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new e.b("webglcontextlost",{originalEvent:t}));}_contextRestored(t){this._setupPainter(),this.resize(),this._update(),this.fire(new e.b("webglcontextrestored",{originalEvent:t}));}_onMapScroll(e){if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}loaded(){return !this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(e){return this.style?(this._styleDirty=this._styleDirty||e,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e);}_requestDomTask(e){!this.loaded()||this.loaded()&&!this.isMoving()?e():this._domRenderTaskQueue.add(e);}_render(t){let i;this.fire(new e.b("renderstart"));const o=this.painter.context.extTimerQuery,r=e.f.now(),s=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(i=s.createQuery(),s.beginQuery(o.TIME_ELAPSED_EXT,i)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&(this._interactionRange[0]=Math.min(this._interactionRange[0],performance.now()),this._interactionRange[1]=Math.max(this._interactionRange[1],performance.now())),this._renderTaskQueue.run(t),this._domRenderTaskQueue.run(t),this._removed)return;this._updateProjectionTransition();const n=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const t=this.transform.zoom,i=this.transform.pitch,o=e.f.now(),r=new e.K(t,{now:o,fadeDuration:n,pitch:i,transition:this.style.transition});this.style.update(r);}this.style&&this.style.hasFogTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let a=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),a=this._updateAverageElevation(r),this.style.updateSources(this.transform),this._forceMarkerAndPopupUpdate()):a=this._updateAverageElevation(r),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,n,this._crossSourceCollisions),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries||this._debugParams.showTileBoundaries,showParseStatus:this.showParseStatus||this._debugParams.showParseStatus,wireframe:{terrain:this.showTerrainWireframe||this._debugParams.showTerrainWireframe,layers2D:this.showLayers2DWireframe||this._debugParams.showLayers2DWireframe,layers3D:this.showLayers3DWireframe||this._debugParams.showLayers3DWireframe},showOverdrawInspector:this._showOverdrawInspector||this._debugParams.showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,showTileAABBs:this.showTileAABBs||this._debugParams.showTileAABBs,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:n,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding||this._debugParams.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),gpuTimingDeferredRender:!!this.listens("gpu-timing-deferred-render"),speedIndexTiming:this.speedIndexTiming}),this.fire(new e.b("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new e.b("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),i){const t=e.f.now()-r;s.endQuery(o.TIME_ELAPSED_EXT),setTimeout((()=>{const o=s.getQueryParameter(i,s.QUERY_RESULT)/1e6;s.deleteQuery(i),this.fire(new e.b("gpu-timing-frame",{cpuTime:t,gpuTime:o}));}),50);}if(this.listens("gpu-timing-layer")){const t=this.painter.collectGpuTimers();setTimeout((()=>{const i=this.painter.queryGpuTimers(t);this.fire(new e.b("gpu-timing-layer",{layerTimes:i}));}),50);}if(this.listens("gpu-timing-deferred-render")){const t=this.painter.collectDeferredRenderGpuQueries();setTimeout((()=>{const i=this.painter.queryGpuTimeDeferredRender(t);this.fire(new e.b("gpu-timing-deferred-render",{gpuTime:i}));}),50);}const l=this._sourcesDirty||this._styleDirty||this._placementDirty||a;if(l||this._repaint)this.triggerRepaint();else {const t=!this.isMoving()&&this.loaded();if(t&&(a=this._updateAverageElevation(r,!0)),a)this.triggerRepaint();else if(this._triggerFrame(!1),t&&(this.fire(new e.b("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const t=this._calculateSpeedIndex();this.fire(new e.b("speedindexcompleted",{speedIndex:t})),this.speedIndexTiming=!1;}}!this._loaded||this._fullyLoaded||l||(this._fullyLoaded=!0,this._performanceMetricsCollection&&e.dd(this._requestManager._customAccessToken,{width:this.painter.width,height:this.painter.height,interactionRange:this._interactionRange,visibilityHidden:this._visibilityHidden,terrainEnabled:!!this.painter.style.getTerrain(),fogEnabled:!!this.painter.style.getFog(),projection:this.getProjection().name,zoom:this.transform.zoom,renderer:this.painter.context.renderer,vendor:this.painter.context.vendor}),this._authenticate());}_forceMarkerAndPopupUpdate(e){for(const t of this._markers)e&&!this.getRenderWorldCopies()&&(t._lngLat=t._lngLat.wrap()),t._update();for(const t of this._popups)!e||this.getRenderWorldCopies()||t._trackPointer||(t._lngLat=t._lngLat.wrap()),t._update();}_updateAverageElevation(e,t=!1){const i=e=>(this.transform.averageElevation=e,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&i(0);const o=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(o||(t||e-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(e)){const t=this.transform.averageElevation;let r=this.transform.sampleAverageElevation();this.transform.elevation&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(r)?r=0:this._averageElevationLastSampledAt=e;const s=Math.abs(t-r);if(s>1){if(this._isInitialLoad||o)return this._averageElevation.jumpTo(r),i(r);this._averageElevation.easeTo(r,e,300);}else if(s>1e-4)return this._averageElevation.jumpTo(r),i(r)}return !!this._averageElevation.isEasing(e)&&i(this._averageElevation.getValue(e))}_authenticate(){e.de(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(t=>{if(t&&(t.message===e.df||401===t.status)){const t=this.painter.context.gl;e.db(t,!1),this._logoControl instanceof ra&&this._logoControl._updateLogo(),t&&t.clear(t.DEPTH_BUFFER_BIT|t.COLOR_BUFFER_BIT|t.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new e.a(new Error("A valid Mapbox access token is required to use Mapbox GL JS. To create an account or a new access token, visit https://account.mapbox.com/")));}})),e.dg(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(()=>{}));}_updateTerrain(){const e=this._isDragging();this.painter.updateTerrain(this.style,e);}_calculateSpeedIndex(){const e=this.painter.canvasCopy(),t=this.painter.getCanvasCopiesAndTimestamps();t.timeStamps.push(performance.now());const i=this.painter.context.gl,o=i.createFramebuffer();function r(e){i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,e,0);const t=new Uint8Array(i.drawingBufferWidth*i.drawingBufferHeight*4);return i.readPixels(0,0,i.drawingBufferWidth,i.drawingBufferHeight,i.RGBA,i.UNSIGNED_BYTE,t),t}return i.bindFramebuffer(i.FRAMEBUFFER,o),this._canvasPixelComparison(r(e),t.canvasCopies.map(r),t.timeStamps)}_canvasPixelComparison(e,t,i){let o=i[1]-i[0];const r=e.length/4;for(let s=0;s{const t=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,t&&this._render(e);})));}_preloadTiles(t){const i=this.style?Object.values(this.style._sourceCaches):[];return e.b1(i,((e,i)=>e._preloadTiles(t,i)),(()=>{this.triggerRepaint();})),this}_onWindowOnline(){this._update();}_onWindowResize(e){this._trackResize&&this.resize({originalEvent:e})._update();}_onVisibilityChange(){"hidden"===document.visibilityState&&this._visibilityHidden++;}get showTileBoundaries(){return !!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._update());}get showParseStatus(){return !!this._showParseStatus}set showParseStatus(e){this._showParseStatus!==e&&(this._showParseStatus=e,this._update());}get showTerrainWireframe(){return !!this._showTerrainWireframe}set showTerrainWireframe(e){this._showTerrainWireframe!==e&&(this._showTerrainWireframe=e,this._update());}get showLayers2DWireframe(){return !!this._showLayers2DWireframe}set showLayers2DWireframe(e){this._showLayers2DWireframe!==e&&(this._showLayers2DWireframe=e,this._update());}get showLayers3DWireframe(){return !!this._showLayers3DWireframe}set showLayers3DWireframe(e){this._showLayers3DWireframe!==e&&(this._showLayers3DWireframe=e,this._update());}get speedIndexTiming(){return !!this._speedIndexTiming}set speedIndexTiming(e){this._speedIndexTiming!==e&&(this._speedIndexTiming=e,this._update());}get showPadding(){return !!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._update());}get showCollisionBoxes(){return !!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,e?this.style._generateCollisionBoxes():this._update());}get showOverdrawInspector(){return !!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._update());}get repaint(){return !!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this.triggerRepaint());}get vertices(){return !!this._vertices}set vertices(e){this._vertices=e,this._update();}get showTileAABBs(){return !!this._showTileAABBs}set showTileAABBs(e){this._showTileAABBs!==e&&(this._showTileAABBs=e,e&&this._update());}_setCacheLimits(t,i){e.dl(t,i);}get version(){return e.dk}},NavigationControl:class{constructor(t){this.options=e.e({},ma,t),this._container=s("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this.options.showZoom&&(e.aY(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",(e=>{this._map&&this._map.zoomIn({},{originalEvent:e});})),s("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",(e=>{this._map&&this._map.zoomOut({},{originalEvent:e});})),s("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(e.aY(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",(e=>{const t=this._map;t&&(this.options.visualizePitch?t.resetNorthPitch({},{originalEvent:e}):t.resetNorth({},{originalEvent:e}));})),this._compassIcon=s("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"));}_updateZoomButtons(){const e=this._map;if(!e)return;const t=e.getZoom(),i=t===e.getMaxZoom(),o=t===e.getMinZoom();this._zoomInButton.disabled=i,this._zoomOutButton.disabled=o,this._zoomInButton.setAttribute("aria-disabled",i.toString()),this._zoomOutButton.setAttribute("aria-disabled",o.toString());}_rotateCompassArrow(){const e=this._map;if(!e)return;const t=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(e.transform.pitch*(Math.PI/180)),.5)}) rotateX(${e.transform.pitch}deg) rotateZ(${e.transform.angle*(180/Math.PI)}deg)`:`rotate(${e.transform.angle*(180/Math.PI)}deg)`;e._requestDomTask((()=>{this._compassIcon&&(this._compassIcon.style.transform=t);}));}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),e.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&e.on("pitch",this._rotateCompassArrow),e.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new ga(e,this._compass,this.options.visualizePitch)),this._container}onRemove(){const e=this._map;e&&(this._container.remove(),this.options.showZoom&&e.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&e.off("pitch",this._rotateCompassArrow),e.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0);}_createButton(e,t){const i=s("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}_setButtonTitle(e,t){if(!this._map)return;const i=this._map._getUIString(`NavigationControl.${t}`);e.setAttribute("aria-label",i),e.firstElementChild&&e.firstElementChild.setAttribute("title",i);}},GeolocateControl:class extends e.E{constructor(t){super();const i=navigator.geolocation;this.options=e.e({geolocation:i},va,t),e.aY(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=on(this._updateMarkerRotation,20),this._numberOfWatches=0;}onAdd(e){return this._map=e,this._container=s("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){void 0!==this._geolocationWatchID&&(this.options.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,this._numberOfWatches=0,this._noTimeout=!1;}_checkGeolocationSupport(e){const t=(t=!!this.options.geolocation)=>{this._supportsGeolocation=t,e(t);};void 0!==this._supportsGeolocation?e(this._supportsGeolocation):void 0!==navigator.permissions?navigator.permissions.query({name:"geolocation"}).then((e=>t("denied"!==e.state))).catch((()=>t())):t();}_isOutOfMapMaxBounds(e){const t=this._map.getMaxBounds(),i=e.coords;return !!t&&(i.longitudet.getEast()||i.latitudet.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");}}_onSuccess(t){if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new e.b("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("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(t),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(t),this.options.showUserLocation&&this._userLocationDotMarker.removeClassName("mapboxgl-user-location-dot-stale"),this.fire(new e.b("geolocate",t)),this._finish();}}_updateCamera(t){const i=new e.bn(t.coords.longitude,t.coords.latitude),o=t.coords.accuracy,r=this._map.getBearing(),s=e.e({bearing:r},this.options.fitBoundsOptions);this._map.fitBounds(i.toBounds(o),s,{geolocateSource:!0});}_updateMarker(t){if(t){const i=new e.bn(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=t.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius();}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove();}_updateCircleRadius(){const t=this._map.transform,i=e.bl(1,t._center.lat)*t.worldSize,o=Math.ceil(2*this._accuracy*i);this._circleElement.style.width=`${o}px`,this._circleElement.style.height=`${o}px`;}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius();}_updateMarkerRotation(){this._userLocationDotMarker&&"number"==typeof this._heading?(this._userLocationDotMarker.setRotation(this._heading),this._userLocationDotMarker.addClassName("mapboxgl-user-location-show-heading")):(this._userLocationDotMarker.removeClassName("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0));}_onError(t){if(this._map){if(this.options.trackUserLocation)if(1===t.code){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e),void 0!==this._geolocationWatchID&&this._clearWatch();}else {if(3===t.code&&this._noTimeout)return;this._setErrorState();}"OFF"!==this._watchState&&this.options.showUserLocation&&this._userLocationDotMarker.addClassName("mapboxgl-user-location-dot-stale"),this.fire(new e.b("error",t)),this._finish();}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0;}_setupUI(t){if(void 0!==this._map){if(this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this._geolocateButton=s("button","mapboxgl-ctrl-geolocate",this._container),s("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!1===t){e.w("Geolocation support is not available so the GeolocateControl will be disabled.");const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t);}else {const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e);}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=s("div","mapboxgl-user-location"),this._dotElement.appendChild(s("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(s("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new la({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=s("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new la({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(t=>{t.geolocateSource||"ACTIVE_LOCK"!==this._watchState||t.originalEvent&&"resize"===t.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new e.b("trackuserlocationend")));}));}}_onDeviceOrientation(e){this._userLocationDotMarker&&(e.webkitCompassHeading?this._heading=e.webkitCompassHeading:!0===e.absolute&&(this._heading=-1*e.alpha),this._updateMarkerRotationThrottled());}trigger(){if(!this._setup)return e.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new e.b("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":this._numberOfWatches--,this._noTimeout=!1,this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this.fire(new e.b("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new e.b("trackuserlocationstart"));}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error");}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let e;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(e={maximumAge:6e5,timeout:0},this._noTimeout=!0):(e=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,e),this.options.showUserHeading&&this._addDeviceOrientationListener();}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return !0}_addDeviceOrientationListener(){const e=()=>{"ondeviceorientationabsolute"in window?window.addEventListener("deviceorientationabsolute",this._onDeviceOrientation):window.addEventListener("deviceorientation",this._onDeviceOrientation);};"undefined"!=typeof DeviceMotionEvent&&"function"==typeof DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((t=>{"granted"===t&&e();})).catch(console.error):e();}_clearWatch(){this.options.geolocation.clearWatch(this._geolocationWatchID),window.removeEventListener("deviceorientation",this._onDeviceOrientation),window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null);}},AttributionControl:oa,ScaleControl:class{constructor(t){this.options=e.e({},xa,t),this._isNumberFormatSupported=function(){try{return new Intl.NumberFormat("en",{style:"unit",unitDisplay:"short",unit:"meter"}),!0}catch(e){return !1}}(),e.aY(["_update","_setScale","setUnit"],this);}getDefaultPosition(){return "bottom-left"}_update(){const e=this.options.maxWidth||100,t=this._map,i=t._containerHeight/2,o=t._containerWidth/2-e/2,r=t.unproject([o,i]),s=t.unproject([o+e,i]),n=r.distanceTo(s);if("imperial"===this.options.unit){const t=3.2808*n;t>5280?this._setScale(e,t/5280,"mile"):this._setScale(e,t,"foot");}else "nautical"===this.options.unit?this._setScale(e,n/1852,"nautical-mile"):n>=1e3?this._setScale(e,n/1e3,"kilometer"):this._setScale(e,n,"meter");}_setScale(e,t,i){this._map._requestDomTask((()=>{const o=function(e){const t=Math.pow(10,`${Math.floor(e)}`.length-1);let i=e/t;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(e){const t=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*t)/t}(i),t*i}(t),r=o/t;this._container.innerHTML=this._isNumberFormatSupported&&"nautical-mile"!==i?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:i}).format(o):`${o} ${ya[i]}`,this._container.style.width=e*r+"px";}));}onAdd(e){return this._map=e,this._language=e.getLanguage(),this._container=s("div","mapboxgl-ctrl mapboxgl-ctrl-scale",e.getContainer()),this._container.dir="auto",this._map.on("move",this._update),this._update(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._update),this._map=void 0;}_setLanguage(e){this._language=e,this._update();}setUnit(e){this.options.unit=e,this._update();}},FullscreenControl:class{constructor(t){this._fullscreen=!1,t&&t.container&&(t.container instanceof HTMLElement?this._container=t.container:e.w("Full screen control 'container' must be a DOM element.")),e.aY(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in document&&(this._fullscreenchange="webkitfullscreenchange");}onAdd(t){return this._map=t,this._container||(this._container=this._map.getContainer()),this._controlContainer=s("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",e.w("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,document.removeEventListener(this._fullscreenchange,this._changeIcon);}_checkFullscreenSupport(){return !(!document.fullscreenEnabled&&!document.webkitFullscreenEnabled)}_setupUI(){const e=this._fullscreenButton=s("button","mapboxgl-ctrl-fullscreen",this._controlContainer);s("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),document.addEventListener(this._fullscreenchange,this._changeIcon);}_updateTitle(){const e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",e);}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(document.fullscreenElement||document.webkitFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle());}_onClickFullscreen(){this._isFullscreen()?document.exitFullscreen?document.exitFullscreen():document.webkitCancelFullScreen&&document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen();}},Popup:class extends e.E{constructor(t){super(),this.options=e.e(Object.create(ca),t),e.aY(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(t&&t.className?t.className.trim().split(/\s+/):[]);}addTo(t){return this._map&&this.remove(),this._map=t,this.options.closeOnClick&&t.on("preclick",this._onClose),this.options.closeOnMove&&t.on("move",this._onClose),t.on("remove",this.remove),this._update(),t._addPopup(this),this._focusFirstElement(),this._trackPointer?(t.on("mousemove",this._onMouseEvent),t.on("mouseup",this._onMouseEvent),t._canvasContainer.classList.add("mapboxgl-track-pointer")):t.on("move",this._update),this.fire(new e.b("open")),this}isOpen(){return !!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const t=this._map;return t&&(t.off("move",this._update),t.off("move",this._onClose),t.off("preclick",this._onClose),t.off("click",this._onClose),t.off("remove",this.remove),t.off("mousemove",this._onMouseEvent),t.off("mouseup",this._onMouseEvent),t.off("drag",this._onMouseEvent),t._canvasContainer&&t._canvasContainer.classList.remove("mapboxgl-track-pointer"),t._removePopup(this),this._map=void 0),this.fire(new e.b("close")),this}getLngLat(){return this._lngLat}setLngLat(t){this._lngLat=e.bn.convert(t),this._pos=null,this._trackPointer=!1,this._update();const i=this._map;return i&&(i.on("move",this._update),i.off("mousemove",this._onMouseEvent),i._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const e=this._map;return e&&(e.off("move",this._update),e.on("mousemove",this._onMouseEvent),e.on("drag",this._onMouseEvent),e._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(document.createTextNode(e))}setHTML(e){const t=document.createDocumentFragment(),i=document.createElement("body");let o;for(i.innerHTML=e;o=i.firstChild,o;)t.appendChild(o);return this.setDOMContent(t)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){let t=this._content;if(t)for(;t.hasChildNodes();)t.firstChild&&t.removeChild(t.firstChild);else t=this._content=s("div","mapboxgl-popup-content",this._container||void 0);if(t.appendChild(e),this.options.closeButton){const e=this._closeButton=s("button","mapboxgl-popup-close-button",t);e.type="button",e.setAttribute("aria-label","Close popup"),e.setAttribute("aria-hidden","true"),e.innerHTML="×",e.addEventListener("click",this._onClose);}return this._update(),this._focusFirstElement(),this}addClassName(e){return this._classList.add(e),this._updateClassList(),this}removeClassName(e){return this._classList.delete(e),this._updateClassList(),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){let t;return this._classList.delete(e)?t=!1:(this._classList.add(e),t=!0),this._updateClassList(),t}_onMouseEvent(e){this._update(e.point);}_getAnchor(e){if(this.options.anchor)return this.options.anchor;const t=this._map,i=this._container,o=this._pos;if(!t||!i||!o)return "bottom";const r=i.offsetWidth,s=i.offsetHeight,n=o.xt.transform.width-r/2;if(o.y+et.transform.height-s){if(n)return "bottom-left";if(a)return "bottom-right"}return n?"left":a?"right":"bottom"}_updateClassList(){const e=this._container;if(!e)return;const t=[...this._classList];t.push("mapboxgl-popup"),this._anchor&&t.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&t.push("mapboxgl-popup-track-pointer"),e.className=t.join(" ");}_update(t){const i=this._map,o=this._content;if(!i||!this._lngLat&&!this._trackPointer||!o)return;let r=this._container;if(r||(r=this._container=s("div","mapboxgl-popup",i.getContainer()),this._tip=s("div","mapboxgl-popup-tip",r),r.appendChild(o)),this.options.maxWidth&&r.style.maxWidth!==this.options.maxWidth&&(r.style.maxWidth=this.options.maxWidth),i.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=na(this._lngLat,this._pos,i.transform)),!this._trackPointer||t){const e=this._pos=this._trackPointer&&t?t:i.project(this._lngLat),o=ua(this.options.offset),r=this._anchor=this._getAnchor(o.y),s=ua(this.options.offset,r),n=e.add(s).round();i._requestDomTask((()=>{this._container&&r&&(this._container.style.transform=`${aa[r]} translate(${n.x}px,${n.y}px)`);}));}if(!this._marker&&i._showingGlobe()){const t=e.d6(i.transform,this._lngLat)?0:1;this._setOpacity(t);}this._updateClassList();}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(ha);e&&e.focus();}_onClose(){this.remove();}_setOpacity(e){this._container&&(this._container.style.opacity=`${e}`),this._content&&(this._content.style.pointerEvents=e?"auto":"none");}},Marker:la,Style:Mo,LngLat:e.bn,LngLatBounds:e.ad,Point:e.P,MercatorCoordinate:e.L,FreeCameraOptions:uo,Evented:e.E,config:e.d5,prewarm:e.dp,clearPrewarmedResources:e.dq,get accessToken(){return e.d5.ACCESS_TOKEN},set accessToken(t){e.d5.ACCESS_TOKEN=t;},get baseApiUrl(){return e.d5.API_URL},set baseApiUrl(t){e.d5.API_URL=t;},get workerCount(){return e.dr.workerCount},set workerCount(t){e.dr.workerCount=t;},get maxParallelImageRequests(){return e.d5.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(t){e.d5.MAX_PARALLEL_IMAGE_REQUESTS=t;},clearStorage(t){e.ds(t);},get workerUrl(){return e.dt.workerUrl},set workerUrl(t){e.dt.workerUrl=t;},get workerClass(){return e.dt.workerClass},set workerClass(t){e.dt.workerClass=t;},get workerParams(){return e.dt.workerParams},set workerParams(t){e.dt.workerParams=t;},get dracoUrl(){return e.du()},set dracoUrl(t){e.dv(t);},get meshoptUrl(){return e.dw()},set meshoptUrl(t){e.dx(t);},setNow:e.f.setNow,restoreNow:e.f.restoreNow};return ba})); // // Our custom intro provides a specialized "define()" function, called by the @@ -67,7 +75,7 @@ * Create mapbox control container * @param {string} className */ - function controlContainer$1(className) { + function controlContainer(className) { const container = document.createElement('div'); container.classList.add('mapboxgl-ctrl', 'mapboxgl-ctrl-group', className); return container; @@ -80,10 +88,11 @@ * @param {Node=} options.icon * @param {string=} options.textContent * @param {boolean=} options.disabled + * @param {boolean=} options.hidden * @param {string=} options.className * @param {() => void=} options.onClick */ - function controlButton$1(options = {}) { + function controlButton(options = {}) { const button = document.createElement('button'); button.type = 'button'; if (options.title) { @@ -98,6 +107,9 @@ if (options.disabled) { button.disabled = true; } + if (options.hidden) { + button.hidden = true; + } if (options.className) { button.classList.add(options.className); } @@ -114,11 +126,11 @@ * Create SVG element from string code * @param {string} string */ - function parseSVG$1(string) { + function parseSVG(string) { return /** @type SVGElement */ ((new DOMParser().parseFromString(string, 'image/svg+xml')).firstChild); } - const compass = parseSVG$1(` + const compass = parseSVG(` @@ -144,9 +156,9 @@ */ constructor(options = {}) { this.options = { ...options }; - this.container = controlContainer$1('mapbox-ctrl-compass'); + this.container = controlContainer('mapbox-ctrl-compass'); this.icon = icons$5.compass; - this.button = controlButton$1({ + this.button = controlButton({ title: 'Compass', icon: icons$5.compass, onClick: () => this.onControlButtonClick(), @@ -187,65 +199,6 @@ } } - /** - * Create mapbox control container - * @param {string} className - */ - function controlContainer(className) { - const container = document.createElement('div'); - container.classList.add('mapboxgl-ctrl', 'mapboxgl-ctrl-group', className); - return container; - } - - /** - * Create mapbox control button - * @param {Object} options - * @param {string=} options.title - * @param {Node=} options.icon - * @param {string=} options.textContent - * @param {boolean=} options.disabled - * @param {boolean=} options.hidden - * @param {string=} options.className - * @param {() => void=} options.onClick - */ - function controlButton(options = {}) { - const button = document.createElement('button'); - button.type = 'button'; - if (options.title) { - button.title = options.title; - } - if (options.icon) { - button.appendChild(options.icon); - } - if (options.textContent) { - button.textContent = options.textContent; - } - if (options.disabled) { - button.disabled = true; - } - if (options.hidden) { - button.hidden = true; - } - if (options.className) { - button.classList.add(options.className); - } - if (options.onClick) { - button.addEventListener('click', () => { - if (!options.onClick) return; - options.onClick(); - }); - } - return button; - } - - /** - * Create SVG element from string code - * @param {string} string - */ - function parseSVG(string) { - return /** @type SVGElement */ ((new DOMParser().parseFromString(string, 'image/svg+xml')).firstChild); - } - function createFileInput() { const node = document.createElement('input'); node.type = 'file'; @@ -3095,13 +3048,13 @@ const defaults = [ { - label: 'Streets', - styleName: 'Mapbox Streets', - styleUrl: 'mapbox://styles/mapbox/streets-v12', + label: 'Standard', + styleName: 'Mapbox Standard', + styleUrl: 'mapbox://styles/mapbox/standard', }, { label: 'Satellite', styleName: 'Mapbox Satellite Streets', - styleUrl: 'mapbox://sprites/mapbox/satellite-streets-v12', + styleUrl: 'mapbox://styles/mapbox/satellite-streets-v12', }, ]; @@ -3114,12 +3067,29 @@ } /** @param {string} name */ - findStyleByName(name) { + findStyle(name) { const style = this.options.styles.find((s) => s.styleName === name); if (!style) throw Error(`can't find style with name ${name}`); return style; } + getCurrentStyleName() { + if (!this.map) throw Error('map is undefined'); + /** @type {string} */ + let name; + /** @type {any} mapbox standard style doesn't return JSON Style object */ + const style = this.map.getStyle(); + if (Array.isArray(style.imports) && style.imports.length) { + // mapbox standard style + name = style.imports[0].data.name; + } else { + // classic style + name = style.name; + } + if (!name) throw Error('style must have name'); + return name; + } + expanded() { if (!this.map) throw Error('map is undefined'); /** @type HTMLButtonElement[] */ @@ -3145,9 +3115,8 @@ button.classList.remove('-active'); }); const styleNames = this.options.styles.map((style) => style.styleName); - const styleName = this.map.getStyle().name; - if (!styleName) throw Error('style must have name'); - const currentStyleIndex = styleNames.indexOf(styleName); + const currentStyleName = this.getCurrentStyleName(); + const currentStyleIndex = styleNames.indexOf(currentStyleName); if (currentStyleIndex !== -1) { const currentButton = buttons[currentStyleIndex]; currentButton.classList.add('-active'); @@ -3171,16 +3140,13 @@ select.addEventListener('change', () => { if (!this.map) throw Error('map is undefined'); - const style = this.findStyleByName(select.value); + const style = this.findStyle(select.value); this.map.setStyle(style.styleUrl); if (this.options.onChange) this.options.onChange(style); }); this.map.on('styledata', () => { - if (!this.map) throw Error('map is undefined'); - const styleName = this.map.getStyle().name; - if (!styleName) throw Error('style must have name'); - select.value = styleName; + select.value = this.getCurrentStyleName(); }); } @@ -3367,7 +3333,7 @@ const map = new mapboxgl.Map({ accessToken: 'pk.eyJ1Ijoia29yeXdrYSIsImEiOiJja2p1ajdlOWozMnF2MzBtajRvOTVzZDRpIn0.nnlX7TDuZ3zuGkZGr_oA3A', container: 'map', - style: 'mapbox://styles/mapbox/streets-v12', + style: 'mapbox://styles/mapbox/standard', zoom: 14, center: [30.5234, 50.4501], }); diff --git a/preview/preview.js b/preview/preview.js index 80ab441..45bd913 100644 --- a/preview/preview.js +++ b/preview/preview.js @@ -45,7 +45,7 @@ const polygon = { const map = new mapboxgl.Map({ accessToken: 'pk.eyJ1Ijoia29yeXdrYSIsImEiOiJja2p1ajdlOWozMnF2MzBtajRvOTVzZDRpIn0.nnlX7TDuZ3zuGkZGr_oA3A', container: 'map', - style: 'mapbox://styles/mapbox/streets-v12', + style: 'mapbox://styles/mapbox/standard', zoom: 14, center: [30.5234, 50.4501], });