diff --git a/crates/dbg-swc/.gitignore b/crates/dbg-swc/.gitignore index 37059aa248a3..64da15e98c1b 100644 --- a/crates/dbg-swc/.gitignore +++ b/crates/dbg-swc/.gitignore @@ -1,10 +1,13 @@ /*.output.js /input.js *.orig +input.new.js +input.orig.js *.txt /.input +/.compare # creduce creduce_bug* \ No newline at end of file diff --git a/crates/dbg-swc/src/minify/compare.rs b/crates/dbg-swc/src/minify/compare.rs index b3b13fb605ed..1a0e9ce2332c 100644 --- a/crates/dbg-swc/src/minify/compare.rs +++ b/crates/dbg-swc/src/minify/compare.rs @@ -1,14 +1,11 @@ -use std::{ - path::{Path, PathBuf}, - process::{Command, Stdio}, - sync::Arc, -}; +use std::{path::PathBuf, process::Command, sync::Arc}; -use anyhow::{bail, Context, Result}; +use anyhow::{Context, Result}; use clap::Args; use swc_common::SourceMap; use crate::util::{ + make_pretty, minifier::{get_esbuild_output, get_minified}, print_js, }; @@ -54,17 +51,3 @@ impl CompareCommand { Ok(()) } } - -fn make_pretty(f: &Path) -> Result<()> { - let mut c = Command::new("npx"); - c.stderr(Stdio::inherit()); - c.arg("js-beautify").arg("--replace").arg(f); - - let output = c.output().context("failed to run prettier")?; - - if !output.status.success() { - bail!("prettier failed"); - } - - Ok(()) -} diff --git a/crates/dbg-swc/src/minify/diff_options.rs b/crates/dbg-swc/src/minify/diff_options.rs new file mode 100644 index 000000000000..21b43c14ee16 --- /dev/null +++ b/crates/dbg-swc/src/minify/diff_options.rs @@ -0,0 +1,122 @@ +use std::{ + fs, + path::{Path, PathBuf}, + process::Command, + sync::Arc, +}; + +use anyhow::{Context, Result}; +use clap::Args; +use rayon::prelude::*; +use swc_common::{SourceMap, GLOBALS}; +use swc_ecma_minifier::option::{CompressOptions, MinifyOptions}; +use swc_ecma_transforms_base::fixer::fixer; +use swc_ecma_visit::VisitMutWith; +use tracing::info; + +use crate::util::{all_js_files, make_pretty, parse_js, print_js}; + +/// Useful for checking if the minifier is working correctly, even with the new +/// option. +#[derive(Debug, Args)] +pub struct DiffOptionCommand { + pub path: PathBuf, + + #[clap(long)] + pub open: bool, +} + +impl DiffOptionCommand { + pub fn run(self, cm: Arc) -> Result<()> { + let js_files = all_js_files(&self.path)?; + + let inputs = js_files + .into_iter() + .filter(|p| p.file_name() == Some("input.js".as_ref())) + .collect::>(); + + let files = GLOBALS.with(|globals| { + inputs + .into_par_iter() + .map(|f| GLOBALS.set(globals, || self.process_file(cm.clone(), &f))) + .collect::>>() + })?; + + for (orig_path, new_path) in files.into_iter().flatten() { + if self.open { + let mut c = Command::new("code"); + c.arg("--diff").arg("--wait"); + c.arg(&orig_path); + c.arg(&new_path); + c.output().context("failed to run vscode")?; + } + } + + Ok(()) + } + + fn process_file(&self, cm: Arc, f: &Path) -> Result> { + info!("Processing `{}`", f.display()); + + let fm = cm.load_file(f)?; + let m = parse_js(fm)?; + + let orig = { + let m = m.clone(); + let mut m = swc_ecma_minifier::optimize( + m.module, + cm.clone(), + Some(&m.comments), + None, + &MinifyOptions { + compress: Some(Default::default()), + mangle: None, + ..Default::default() + }, + &swc_ecma_minifier::option::ExtraOptions { + unresolved_mark: m.unresolved_mark, + top_level_mark: m.top_level_mark, + }, + ); + m.visit_mut_with(&mut fixer(None)); + print_js(cm.clone(), &m, false)? + }; + + let new = { + let mut m = swc_ecma_minifier::optimize( + m.module, + cm.clone(), + Some(&m.comments), + None, + &MinifyOptions { + compress: Some(CompressOptions { + conditionals: true, + ..Default::default() + }), + mangle: None, + ..Default::default() + }, + &swc_ecma_minifier::option::ExtraOptions { + unresolved_mark: m.unresolved_mark, + top_level_mark: m.top_level_mark, + }, + ); + m.visit_mut_with(&mut fixer(None)); + print_js(cm, &m, false)? + }; + + if orig == new { + fs::remove_file(f)?; + return Ok(None); + } + + let orig_path = f.with_extension("orig.js"); + fs::write(&orig_path, orig)?; + make_pretty(&orig_path)?; + let new_path = f.with_extension("new.js"); + fs::write(&new_path, new)?; + make_pretty(&new_path)?; + + Ok(Some((orig_path, new_path))) + } +} diff --git a/crates/dbg-swc/src/minify/mod.rs b/crates/dbg-swc/src/minify/mod.rs index 6da955ebdb53..c27861ce313c 100644 --- a/crates/dbg-swc/src/minify/mod.rs +++ b/crates/dbg-swc/src/minify/mod.rs @@ -4,9 +4,13 @@ use anyhow::Result; use clap::Subcommand; use swc_common::SourceMap; -use self::{compare::CompareCommand, ensure_size::EnsureSize, reduce::ReduceCommand}; +use self::{ + compare::CompareCommand, diff_options::DiffOptionCommand, ensure_size::EnsureSize, + reduce::ReduceCommand, +}; mod compare; +mod diff_options; mod ensure_size; mod reduce; @@ -15,6 +19,7 @@ mod reduce; pub enum MinifyCommand { Reduce(ReduceCommand), Compare(CompareCommand), + DiffOption(DiffOptionCommand), EnsureSize(EnsureSize), } @@ -24,6 +29,7 @@ impl MinifyCommand { MinifyCommand::Reduce(cmd) => cmd.run(cm), MinifyCommand::EnsureSize(cmd) => cmd.run(cm), MinifyCommand::Compare(cmd) => cmd.run(cm), + MinifyCommand::DiffOption(cmd) => cmd.run(cm), } } } diff --git a/crates/dbg-swc/src/util/mod.rs b/crates/dbg-swc/src/util/mod.rs index d29f85b1d760..6bb8fc694e1b 100644 --- a/crates/dbg-swc/src/util/mod.rs +++ b/crates/dbg-swc/src/util/mod.rs @@ -1,5 +1,6 @@ use std::{ path::{Path, PathBuf}, + process::{Command, Stdio}, sync::Arc, }; @@ -21,6 +22,20 @@ where op() } +pub fn make_pretty(f: &Path) -> Result<()> { + let mut c = Command::new("npx"); + c.stderr(Stdio::inherit()); + c.arg("js-beautify").arg("--replace").arg(f); + + let output = c.output().context("failed to run prettier")?; + + if !output.status.success() { + bail!("prettier failed"); + } + + Ok(()) +} + pub fn parse_js(fm: Arc) -> Result { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -80,7 +95,7 @@ pub fn print_js(cm: Arc, m: &Module, minify: bool) -> Result String::from_utf8(buf).context("swc emitted non-utf8 output") } -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct ModuleRecord { pub module: Module, pub comments: SingleThreadedComments, diff --git a/crates/swc/tests/fixture/issues-4xxx/4249/1/output/index.js b/crates/swc/tests/fixture/issues-4xxx/4249/1/output/index.js index 50406c0e8238..308583da53f4 100644 --- a/crates/swc/tests/fixture/issues-4xxx/4249/1/output/index.js +++ b/crates/swc/tests/fixture/issues-4xxx/4249/1/output/index.js @@ -1,5 +1,5 @@ foo({ bar: function(data, baz) { - !(!(baz ? data.quxA : data.quxB) && !(baz ? data.corgeA : data.corgeB) && (baz ? data.get("waldo") : data.waldo)) ? (baz ? data.quxA : data.quxB) || (baz ? data.get("waldo") : data.waldo) || (baz ? !data.corgeA : !data.corgeB) || pass() : pass(); + !(!(baz ? data.quxA : data.quxB) && !(baz ? data.corgeA : data.corgeB) && (baz ? data.get("waldo") : data.waldo)) && ((baz ? data.quxA : data.quxB) || (baz ? data.get("waldo") : data.waldo) || (baz ? !data.corgeA : !data.corgeB)) || pass(); } }); diff --git a/crates/swc/tests/tsc-references/parserindenter_es2015.2.minified.js b/crates/swc/tests/tsc-references/parserindenter_es2015.2.minified.js index 5b02ab1673a9..4382e8b8ded4 100644 --- a/crates/swc/tests/tsc-references/parserindenter_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/parserindenter_es2015.2.minified.js @@ -12,8 +12,7 @@ var Formatting; } GetIndentationEditsWorker(token, nextToken, node, sameLineIndent) { var result = new List_TextEditInfo(), indentationInfo = null; - if (this.AdjustStartOffsetIfNeeded(token, node), this.scriptBlockBeginLineNumber == token.lineNumber()) return result; - if (!sameLineIndent && this.IsMultiLineString(token)) return result; + if (this.AdjustStartOffsetIfNeeded(token, node), this.scriptBlockBeginLineNumber == token.lineNumber() || !sameLineIndent && this.IsMultiLineString(token)) return result; if (null == (indentationInfo = this.GetSpecialCaseIndentation(token, node))) { for(; !node.CanIndent() && null != node.Parent && token.Span.span.start() == node.Parent.AuthorNode.Details.StartOffset;)node = node.Parent; indentationInfo = node.CanIndent() && token.Span.span.start() == node.AuthorNode.Details.StartOffset ? node.GetEffectiveIndentation(this) : token.Token == AuthorTokenKind.atkIdentifier && null != nextToken && nextToken.Token == AuthorTokenKind.atkColon ? node.GetEffectiveChildrenIndentation(this) : this.ApplyIndentationDeltaFromParent(token, node); diff --git a/crates/swc/tests/tsc-references/parserindenter_es5.2.minified.js b/crates/swc/tests/tsc-references/parserindenter_es5.2.minified.js index 726d19e1ef4f..d202a95c2319 100644 --- a/crates/swc/tests/tsc-references/parserindenter_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/parserindenter_es5.2.minified.js @@ -17,8 +17,7 @@ import * as swcHelpers from "@swc/helpers"; return result; }, _proto.GetIndentationEditsWorker = function(token, nextToken, node, sameLineIndent) { var result = new List_TextEditInfo(), indentationInfo = null; - if (this.AdjustStartOffsetIfNeeded(token, node), this.scriptBlockBeginLineNumber == token.lineNumber()) return result; - if (!sameLineIndent && this.IsMultiLineString(token)) return result; + if (this.AdjustStartOffsetIfNeeded(token, node), this.scriptBlockBeginLineNumber == token.lineNumber() || !sameLineIndent && this.IsMultiLineString(token)) return result; if (null == (indentationInfo = this.GetSpecialCaseIndentation(token, node))) { for(; !node.CanIndent() && null != node.Parent && token.Span.span.start() == node.Parent.AuthorNode.Details.StartOffset;)node = node.Parent; indentationInfo = node.CanIndent() && token.Span.span.start() == node.AuthorNode.Details.StartOffset ? node.GetEffectiveIndentation(this) : token.Token == AuthorTokenKind.atkIdentifier && null != nextToken && nextToken.Token == AuthorTokenKind.atkColon ? node.GetEffectiveChildrenIndentation(this) : this.ApplyIndentationDeltaFromParent(token, node); diff --git a/crates/swc/tests/vercel/full-compact/react-autosuggest/1/output/index.js b/crates/swc/tests/vercel/full-compact/react-autosuggest/1/output/index.js index 7436fdbf0975..510bc3282c87 100644 --- a/crates/swc/tests/vercel/full-compact/react-autosuggest/1/output/index.js +++ b/crates/swc/tests/vercel/full-compact/react-autosuggest/1/output/index.js @@ -1 +1 @@ -"use strict";import*as e from"@swc/helpers";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var d=function(a){if(a&&a.__esModule)return a;if(null===a||"object"!==g(a)&&"function"!=typeof a)return{default:a};var b=f();if(b&&b.has(a))return b.get(a);var c={},h=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var d in a)if(Object.prototype.hasOwnProperty.call(a,d)){var e=h?Object.getOwnPropertyDescriptor(a,d):null;e&&(e.get||e.set)?Object.defineProperty(c,d,e):c[d]=a[d]}return c.default=a,b&&b.set(a,c),c}(require("react")),a=function(a){return a&&a.__esModule?a:{default:a}}(require("prop-types"));function f(){if("function"!=typeof WeakMap)return null;var a=new WeakMap;return f=function(){return a},a}function g(a){return(g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a})(a)}function h(){return(h=Object.assign||function(d){for(var a=1;a l.cons.eq_ignore_span(&r.cons), + ( + Some(Stmt::If(l @ IfStmt { alt: None, .. })), + Some(Stmt::If(r @ IfStmt { alt: None, .. })), + ) => l.cons.eq_ignore_span(&r.cons), _ => false, }); if !has_work { @@ -132,7 +135,7 @@ where match stmt.try_into_stmt() { Ok(stmt) => { match stmt { - Stmt::If(mut stmt) => { + Stmt::If(mut stmt @ IfStmt { alt: None, .. }) => { // match &mut cur { diff --git a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs index 23c6a55be96b..6dc15e0f00ef 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs @@ -1914,8 +1914,15 @@ where } } - #[cfg_attr(feature = "debug", tracing::instrument(skip_all))] fn visit_mut_fn_decl(&mut self, f: &mut FnDecl) { + #[cfg(feature = "debug")] + let _tracing = tracing::span!( + Level::ERROR, + "visit_mut_fn_decl", + id = tracing::field::display(&f.ident) + ) + .entered(); + self.functions .entry(f.ident.to_id()) .or_insert_with(|| FnMetadata::from(&f.function)); diff --git a/crates/swc_ecma_minifier/src/compress/pure/mod.rs b/crates/swc_ecma_minifier/src/compress/pure/mod.rs index bf8a889ac0dd..4f4321d7b6f0 100644 --- a/crates/swc_ecma_minifier/src/compress/pure/mod.rs +++ b/crates/swc_ecma_minifier/src/compress/pure/mod.rs @@ -385,6 +385,18 @@ impl VisitMut for Pure<'_> { self.visit_par(exprs); } + fn visit_mut_fn_decl(&mut self, n: &mut FnDecl) { + #[cfg(feature = "debug")] + let _tracing = tracing::span!( + Level::ERROR, + "visit_mut_fn_decl", + id = tracing::field::display(&n.ident) + ) + .entered(); + + n.visit_mut_children_with(self); + } + fn visit_mut_for_in_stmt(&mut self, n: &mut ForInStmt) { n.right.visit_mut_with(self); diff --git a/crates/swc_ecma_minifier/src/option/mod.rs b/crates/swc_ecma_minifier/src/option/mod.rs index 2c1e3ddec610..2deab01c04c6 100644 --- a/crates/swc_ecma_minifier/src/option/mod.rs +++ b/crates/swc_ecma_minifier/src/option/mod.rs @@ -139,7 +139,7 @@ pub struct CompressOptions { #[serde(alias = "computed_props")] pub computed_props: bool, - #[serde(default)] + #[serde(default = "true_by_default")] #[serde(alias = "conditionals")] pub conditionals: bool, diff --git a/crates/swc_ecma_minifier/src/option/terser.rs b/crates/swc_ecma_minifier/src/option/terser.rs index 47b2f6824a97..e49d0fb4ab5c 100644 --- a/crates/swc_ecma_minifier/src/option/terser.rs +++ b/crates/swc_ecma_minifier/src/option/terser.rs @@ -259,8 +259,7 @@ impl TerserCompressorOptions { collapse_vars: self.collapse_vars.unwrap_or(self.defaults), comparisons: self.comparisons.unwrap_or(self.defaults), computed_props: self.computed_props.unwrap_or(self.defaults), - // TODO: Use self.defaults - conditionals: self.conditionals.unwrap_or(false), + conditionals: self.conditionals.unwrap_or(self.defaults), dead_code: self.dead_code.unwrap_or(self.defaults), directives: self.directives.unwrap_or(self.defaults), drop_console: self.drop_console, diff --git a/crates/swc_ecma_minifier/tests/fixture/issues/2257/full/output.js b/crates/swc_ecma_minifier/tests/fixture/issues/2257/full/output.js index 84de421e35d2..5177ac9dc211 100644 --- a/crates/swc_ecma_minifier/tests/fixture/issues/2257/full/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/issues/2257/full/output.js @@ -953,7 +953,7 @@ return Object.keys(descriptor).forEach(function(key) { desc1[key] = descriptor[key]; }), desc1.enumerable = !!desc1.enumerable, desc1.configurable = !!desc1.configurable, ("value" in desc1 || desc1.initializer) && (desc1.writable = !0), desc1 = decorators.slice().reverse().reduce(function(desc, decorator) { - return decorator ? decorator(target, property, desc) || desc : desc; + return decorator && decorator(target, property, desc) || desc; }, desc1), context && void 0 !== desc1.initializer && (desc1.value = desc1.initializer ? desc1.initializer.call(context) : void 0, desc1.initializer = void 0), void 0 === desc1.initializer && (Object.defineProperty(target, property, desc1), desc1 = null), desc1; } function _arrayWithHoles(arr) { @@ -1045,10 +1045,7 @@ } function _asyncIterator(iterable) { var method; - if ("function" == typeof Symbol) { - if (Symbol.asyncIterator && null != (method = iterable[Symbol.asyncIterator])) return method.call(iterable); - if (Symbol.iterator && null != (method = iterable[Symbol.iterator])) return method.call(iterable); - } + if ("function" == typeof Symbol && (Symbol.asyncIterator && null != (method = iterable[Symbol.asyncIterator]) || Symbol.iterator && null != (method = iterable[Symbol.iterator]))) return method.call(iterable); throw new TypeError("Object is not async iterable"); } function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { @@ -1116,8 +1113,7 @@ } function construct(Parent1, args1, Class1) { return (construct = !function() { - if ("undefined" == typeof Reflect || !Reflect.construct) return !1; - if (Reflect.construct.sham) return !1; + if ("undefined" == typeof Reflect || !Reflect.construct || Reflect.construct.sham) return !1; if ("function" == typeof Proxy) return !0; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function() {})), !0; @@ -3495,7 +3491,7 @@ return function() { return new IteratorConstructor(this); }; - }, TO_STRING_TAG = NAME + " Iterator", INCORRECT_VALUES_NAME = !1, IterablePrototype = Iterable.prototype, nativeIterator = IterablePrototype[ITERATOR] || IterablePrototype["@@iterator"] || DEFAULT && IterablePrototype[DEFAULT], defaultIterator = !BUGGY_SAFARI_ITERATORS && nativeIterator || getIterationMethod(DEFAULT), anyNativeIterator = "Array" == NAME ? IterablePrototype.entries || nativeIterator : nativeIterator; + }, TO_STRING_TAG = NAME + " Iterator", INCORRECT_VALUES_NAME = !1, IterablePrototype = Iterable.prototype, nativeIterator = IterablePrototype[ITERATOR] || IterablePrototype["@@iterator"] || DEFAULT && IterablePrototype[DEFAULT], defaultIterator = !BUGGY_SAFARI_ITERATORS && nativeIterator || getIterationMethod(DEFAULT), anyNativeIterator = "Array" == NAME && IterablePrototype.entries || nativeIterator; if (anyNativeIterator && (CurrentIteratorPrototype = getPrototypeOf(anyNativeIterator.call(new Iterable()))) !== Object.prototype && CurrentIteratorPrototype.next && (IS_PURE || getPrototypeOf(CurrentIteratorPrototype) === IteratorPrototype || (setPrototypeOf ? setPrototypeOf(CurrentIteratorPrototype, IteratorPrototype) : isCallable(CurrentIteratorPrototype[ITERATOR]) || redefine(CurrentIteratorPrototype, ITERATOR, returnThis)), setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, !0, !0), IS_PURE && (Iterators[TO_STRING_TAG] = returnThis)), PROPER_FUNCTION_NAME && DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES && (!IS_PURE && CONFIGURABLE_FUNCTION_NAME ? createNonEnumerableProperty(IterablePrototype, "name", VALUES) : (INCORRECT_VALUES_NAME = !0, defaultIterator = function() { return nativeIterator.call(this); })), DEFAULT) { @@ -4452,9 +4448,7 @@ var isCallable = __webpack_require__(67106), isObject = __webpack_require__(39817); module.exports = function(input, pref) { var fn, val; - if ("string" === pref && isCallable(fn = input.toString) && !isObject(val = fn.call(input))) return val; - if (isCallable(fn = input.valueOf) && !isObject(val = fn.call(input))) return val; - if ("string" !== pref && isCallable(fn = input.toString) && !isObject(val = fn.call(input))) return val; + if ("string" === pref && isCallable(fn = input.toString) && !isObject(val = fn.call(input)) || isCallable(fn = input.valueOf) && !isObject(val = fn.call(input)) || "string" !== pref && isCallable(fn = input.toString) && !isObject(val = fn.call(input))) return val; throw TypeError("Can't convert object to primitive value"); }; }, @@ -4960,8 +4954,7 @@ buffer = data, byteOffset = toOffset(offset, BYTES); var $len = data.byteLength; if (void 0 === $length) { - if ($len % BYTES) throw RangeError(WRONG_LENGTH); - if ((byteLength = $len - byteOffset) < 0) throw RangeError(WRONG_LENGTH); + if ($len % BYTES || (byteLength = $len - byteOffset) < 0) throw RangeError(WRONG_LENGTH); } else if ((byteLength = toLength($length) * BYTES) + byteOffset > $len) throw RangeError(WRONG_LENGTH); length = byteLength / BYTES; } else if (isTypedArray(data)) return fromList(TypedArrayConstructor, data); @@ -6059,7 +6052,7 @@ s = "" === s ? t : s + repeat.call("0", 7 - t.length) + t; } return s; - }, FORCED = nativeToFixed && !0 || !fails(function() { + }, FORCED = !!nativeToFixed || !fails(function() { nativeToFixed.call({}); }); $({ @@ -6546,8 +6539,7 @@ "use strict"; var Internal, OwnPromiseCapability, PromiseWrapper, nativeThen, $ = __webpack_require__(35437), IS_PURE = __webpack_require__(80627), global = __webpack_require__(19514), getBuiltIn = __webpack_require__(44990), NativePromise = __webpack_require__(91591), redefine = __webpack_require__(78109), redefineAll = __webpack_require__(59855), setPrototypeOf = __webpack_require__(59057), setToStringTag = __webpack_require__(77875), setSpecies = __webpack_require__(53988), aCallable = __webpack_require__(74618), isCallable = __webpack_require__(67106), isObject = __webpack_require__(39817), anInstance = __webpack_require__(51819), inspectSource = __webpack_require__(71975), iterate = __webpack_require__(7261), checkCorrectnessOfIteration = __webpack_require__(34124), speciesConstructor = __webpack_require__(94850), task = __webpack_require__(46660).set, microtask = __webpack_require__(50277), promiseResolve = __webpack_require__(56540), hostReportErrors = __webpack_require__(85033), newPromiseCapabilityModule = __webpack_require__(11098), perform = __webpack_require__(68275), InternalStateModule = __webpack_require__(44670), isForced = __webpack_require__(23736), wellKnownSymbol = __webpack_require__(81019), IS_BROWSER = __webpack_require__(23573), IS_NODE = __webpack_require__(96590), V8_VERSION = __webpack_require__(50661), SPECIES = wellKnownSymbol("species"), PROMISE = "Promise", getInternalState = InternalStateModule.get, setInternalState = InternalStateModule.set, getInternalPromiseState = InternalStateModule.getterFor(PROMISE), NativePromisePrototype = NativePromise && NativePromise.prototype, PromiseConstructor = NativePromise, PromiseConstructorPrototype = NativePromisePrototype, TypeError = global.TypeError, document = global.document, process = global.process, newPromiseCapability = newPromiseCapabilityModule.f, newGenericPromiseCapability = newPromiseCapability, DISPATCH_EVENT = !!(document && document.createEvent && global.dispatchEvent), NATIVE_REJECTION_EVENT = isCallable(global.PromiseRejectionEvent), UNHANDLED_REJECTION = "unhandledrejection", SUBCLASSING = !1, FORCED = isForced(PROMISE, function() { var PROMISE_CONSTRUCTOR_SOURCE = inspectSource(PromiseConstructor), GLOBAL_CORE_JS_PROMISE = PROMISE_CONSTRUCTOR_SOURCE !== String(PromiseConstructor); - if (!GLOBAL_CORE_JS_PROMISE && 66 === V8_VERSION) return !0; - if (IS_PURE && !PromiseConstructorPrototype.finally) return !0; + if (!GLOBAL_CORE_JS_PROMISE && 66 === V8_VERSION || IS_PURE && !PromiseConstructorPrototype.finally) return !0; if (V8_VERSION >= 51 && /native code/.test(PROMISE_CONSTRUCTOR_SOURCE)) return !1; var promise = new PromiseConstructor(function(resolve) { resolve(1); @@ -7496,8 +7488,7 @@ } for(var results = [];;){ var result = regExpExec(rx, S); - if (null === result) break; - if (results.push(result), !global) break; + if (null === result || (results.push(result), !global)) break; "" === toString(result[0]) && (rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode)); } for(var accumulatedResult = "", nextSourcePosition = 0, i = 0; i < results.length; i++){ @@ -8585,12 +8576,10 @@ var EOF, $ = __webpack_require__(35437), DESCRIPTORS = __webpack_require__(87122), USE_NATIVE_URL = __webpack_require__(62902), global = __webpack_require__(19514), defineProperties = __webpack_require__(68381), redefine = __webpack_require__(78109), anInstance = __webpack_require__(51819), has = __webpack_require__(1521), assign = __webpack_require__(59038), arrayFrom = __webpack_require__(83581), codeAt = __webpack_require__(88668).codeAt, toASCII = __webpack_require__(41075), $toString = __webpack_require__(72729), setToStringTag = __webpack_require__(77875), URLSearchParamsModule = __webpack_require__(79085), InternalStateModule = __webpack_require__(44670), NativeURL = global.URL, URLSearchParams = URLSearchParamsModule.URLSearchParams, getInternalSearchParamsState = URLSearchParamsModule.getState, setInternalState = InternalStateModule.set, getInternalURLState = InternalStateModule.getterFor("URL"), floor = Math.floor, pow = Math.pow, INVALID_SCHEME = "Invalid scheme", INVALID_HOST = "Invalid host", INVALID_PORT = "Invalid port", ALPHA = /[A-Za-z]/, ALPHANUMERIC = /[\d+-.A-Za-z]/, DIGIT = /\d/, HEX_START = /^0x/i, OCT = /^[0-7]+$/, DEC = /^\d+$/, HEX = /^[\dA-Fa-f]+$/, FORBIDDEN_HOST_CODE_POINT = /[\0\t\n\r #%/:<>?@[\\\]^|]/, FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT = /[\0\t\n\r #/:<>?@[\\\]^|]/, LEADING_AND_TRAILING_C0_CONTROL_OR_SPACE = /^[\u0000-\u0020]+|[\u0000-\u0020]+$/g, TAB_AND_NEW_LINE = /[\t\n\r]/g, parseHost = function(url, input) { var result, codePoints, index; if ("[" == input.charAt(0)) { - if ("]" != input.charAt(input.length - 1)) return INVALID_HOST; - if (!(result = parseIPv6(input.slice(1, -1)))) return INVALID_HOST; + if ("]" != input.charAt(input.length - 1) || !(result = parseIPv6(input.slice(1, -1)))) return INVALID_HOST; url.host = result; } else if (isSpecial(url)) { - if (input = toASCII(input), FORBIDDEN_HOST_CODE_POINT.test(input)) return INVALID_HOST; - if (null === (result = parseIPv4(input))) return INVALID_HOST; + if (input = toASCII(input), FORBIDDEN_HOST_CODE_POINT.test(input) || null === (result = parseIPv4(input))) return INVALID_HOST; url.host = result; } else { if (FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT.test(input)) return INVALID_HOST; @@ -8640,8 +8629,7 @@ } for(value = length = 0; length < 4 && HEX.test(chr());)value = 16 * value + parseInt(chr(), 16), pointer++, length++; if ("." == chr()) { - if (0 == length) return; - if (pointer -= length, pieceIndex > 6) return; + if (0 == length || (pointer -= length, pieceIndex > 6)) return; for(numbersSeen = 0; chr();){ if (ipv4Piece = null, numbersSeen > 0) { if ("." != chr() || !(numbersSeen < 4)) return; @@ -9792,8 +9780,7 @@ if (path !== encodedPath) replaceHashPath(encodedPath); else { var a, b, location = getDOMLocation(), prevLocation = history.location; - if (!forceNextPop && (a = prevLocation, b = location, a.pathname === b.pathname && a.search === b.search && a.hash === b.hash)) return; - if (ignorePath === createPath(location)) return; + if (!forceNextPop && (a = prevLocation, b = location, a.pathname === b.pathname && a.search === b.search && a.hash === b.hash) || ignorePath === createPath(location)) return; ignorePath = null, handlePop(location); } } @@ -10405,8 +10392,7 @@ }; } }(options3), ret = Object.create(null); - if ("string" != typeof query) return ret; - if (!(query = query.trim().replace(/^[?#&]/, ""))) return ret; + if ("string" != typeof query || !(query = query.trim().replace(/^[?#&]/, ""))) return ret; for (const param of query.split("&")){ if ("" === param) continue; let [key, value] = splitOnFirst(options3.decode ? param.replace(/\+/g, " ") : param, "="); @@ -14549,8 +14535,7 @@ c = c.return; } for(c.sibling.return = c.return, c = c.sibling; 5 !== c.tag && 6 !== c.tag && 18 !== c.tag;){ - if (2 & c.flags) continue b; - if (null === c.child || 4 === c.tag) continue b; + if (2 & c.flags || null === c.child || 4 === c.tag) continue b; c.child.return = c, c = c.child; } if (!(2 & c.flags)) { diff --git a/crates/swc_ecma_minifier/tests/fixture/issues/4249/output.js b/crates/swc_ecma_minifier/tests/fixture/issues/4249/output.js index 50406c0e8238..308583da53f4 100644 --- a/crates/swc_ecma_minifier/tests/fixture/issues/4249/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/issues/4249/output.js @@ -1,5 +1,5 @@ foo({ bar: function(data, baz) { - !(!(baz ? data.quxA : data.quxB) && !(baz ? data.corgeA : data.corgeB) && (baz ? data.get("waldo") : data.waldo)) ? (baz ? data.quxA : data.quxB) || (baz ? data.get("waldo") : data.waldo) || (baz ? !data.corgeA : !data.corgeB) || pass() : pass(); + !(!(baz ? data.quxA : data.quxB) && !(baz ? data.corgeA : data.corgeB) && (baz ? data.get("waldo") : data.waldo)) && ((baz ? data.quxA : data.quxB) || (baz ? data.get("waldo") : data.waldo) || (baz ? !data.corgeA : !data.corgeB)) || pass(); } }); diff --git a/crates/swc_ecma_minifier/tests/fixture/issues/firebase-core/1/output.js b/crates/swc_ecma_minifier/tests/fixture/issues/firebase-core/1/output.js index 078a7dd8622a..09a966ccfb1e 100644 --- a/crates/swc_ecma_minifier/tests/fixture/issues/firebase-core/1/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/issues/firebase-core/1/output.js @@ -1243,7 +1243,7 @@ }, k.setRequestHeader = function(a, b) { this.v.append(a, b); }, k.getResponseHeader = function(a) { - return this.h ? this.h.get(a.toLowerCase()) || "" : ""; + return this.h && this.h.get(a.toLowerCase()) || ""; }, k.getAllResponseHeaders = function() { if (!this.h) return ""; const a = [], b = this.h.entries(); @@ -1368,7 +1368,7 @@ }), b6), "string" == typeof a ? null != c8 && encodeURIComponent(String(c8)) : R(a, b, c8)); } function Hd(a, b, c) { - return c && c.internalChannelParams ? c.internalChannelParams[a] || b : b; + return c && c.internalChannelParams && c.internalChannelParams[a] || b; } function Id(a) { this.za = 0, this.l = [], this.h = new Mb(), this.la = this.oa = this.F = this.W = this.g = this.sa = this.D = this.aa = this.o = this.P = this.s = null, this.Za = this.V = 0, this.Xa = Hd("failFast", !1, a), this.N = this.v = this.u = this.m = this.j = null, this.X = !0, this.I = this.ta = this.U = -1, this.Y = this.A = this.C = 0, this.Pa = Hd("baseRetryDelayMs", 5e3, a), this.$a = Hd("retryDelaySeedMs", 1e4, a), this.Ya = Hd("forwardChannelMaxRetries", 2, a), this.ra = Hd("forwardChannelRequestTimeoutMs", 2e4, a), this.qa = a && a.xmlHttpFactory || void 0, this.Ba = a && a.Yb || !1, this.K = void 0, this.H = a && a.supportsCrossDomainXhr || !1, this.J = "", this.i = new gd(a && a.concurrentRequestLimit), this.Ca = new ld(), this.ja = a && a.fastHandshake || !1, this.Ra = a && a.Wb || !1, a && a.Aa && this.h.Aa(), a && a.forceLongPolling && (this.X = !1), this.$ = !this.ja && this.X && a && a.detectBufferingProxy || !1, this.ka = void 0, this.O = 0, this.L = !1, this.B = null, this.Wa = !a || !1 !== a.Xb; diff --git a/crates/swc_ecma_minifier/tests/fixture/issues/firebase-firestore/1/output.js b/crates/swc_ecma_minifier/tests/fixture/issues/firebase-firestore/1/output.js index 0ca79d0e5657..c002a70cbab3 100644 --- a/crates/swc_ecma_minifier/tests/fixture/issues/firebase-firestore/1/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/issues/firebase-firestore/1/output.js @@ -215,10 +215,8 @@ X.T = -1; class it { constructor(t, e){ - if (this.seconds = t, this.nanoseconds = e, e < 0) throw new j(K.INVALID_ARGUMENT, "Timestamp nanoseconds out of range: " + e); - if (e >= 1e9) throw new j(K.INVALID_ARGUMENT, "Timestamp nanoseconds out of range: " + e); - if (t < -62135596800) throw new j(K.INVALID_ARGUMENT, "Timestamp seconds out of range: " + t); - if (t >= 253402300800) throw new j(K.INVALID_ARGUMENT, "Timestamp seconds out of range: " + t); + if (this.seconds = t, this.nanoseconds = e, e < 0 || e >= 1e9) throw new j(K.INVALID_ARGUMENT, "Timestamp nanoseconds out of range: " + e); + if (t < -62135596800 || t >= 253402300800) throw new j(K.INVALID_ARGUMENT, "Timestamp seconds out of range: " + t); } static now() { return it.fromMillis(Date.now()); @@ -880,8 +878,7 @@ } function zt(t, e) { var n, s; - if (t.limit !== e.limit) return !1; - if (t.orderBy.length !== e.orderBy.length) return !1; + if (t.limit !== e.limit || t.orderBy.length !== e.orderBy.length) return !1; for(let n5 = 0; n5 < t.orderBy.length; n5++)if (!ue(t.orderBy[n5], e.orderBy[n5])) return !1; if (t.filters.length !== e.filters.length) return !1; for(let i = 0; i < t.filters.length; i++)if (n = t.filters[i], s = e.filters[i], n.op !== s.op || !n.field.isEqual(s.field) || !Vt(n.value, s.value)) return !1; @@ -1036,8 +1033,7 @@ } function le(t, e) { if (null === t) return null === e; - if (null === e) return !1; - if (t.before !== e.before || t.position.length !== e.position.length) return !1; + if (null === e || t.before !== e.before || t.position.length !== e.position.length) return !1; for(let n = 0; n < t.position.length; n++)if (!Vt(t.position[n], e.position[n])) return !1; return !0; } @@ -1120,7 +1116,7 @@ }(t34, e15) && function(t, e) { for (const n of t.filters)if (!n.matches(e)) return !1; return !0; - }(t34, e15) && (t33 = t34, e14 = e15, (!t33.startAt || !!he(t33.startAt, Te(t33), e14)) && !(t33.endAt && he(t33.endAt, Te(t33), e14))); + }(t34, e15) && (t33 = t34, e14 = e15, !(t33.startAt && !he(t33.startAt, Te(t33), e14) || t33.endAt && he(t33.endAt, Te(t33), e14))); } function ve(t35) { return (e, n)=>{ @@ -1592,8 +1588,7 @@ return Math.pow(2, t) <= this.size + 1; } check() { - if (this.isRed() && this.left.isRed()) throw L(); - if (this.right.isRed()) throw L(); + if (this.isRed() && this.left.isRed() || this.right.isRed()) throw L(); const t = this.left.check(); if (t !== this.right.check()) throw L(); return t + (this.isRed() ? 0 : 1); @@ -1713,8 +1708,7 @@ }), e; } isEqual(t) { - if (!(t instanceof gn)) return !1; - if (this.size !== t.size) return !1; + if (!(t instanceof gn) || this.size !== t.size) return !1; const e = this.data.getIterator(), n = t.data.getIterator(); for(; e.hasNext();){ const t = e.getNext().key, s = n.getNext().key; @@ -4808,8 +4802,7 @@ return e ? this.copy(this.keyedMap.remove(t), this.sortedSet.remove(e)) : this; } isEqual(t) { - if (!(t instanceof $o)) return !1; - if (this.size !== t.size) return !1; + if (!(t instanceof $o) || this.size !== t.size) return !1; const e = this.sortedSet.getIterator(), n = t.sortedSet.getIterator(); for(; e.hasNext();){ const t = e.getNext().key, s = n.getNext().key; @@ -5182,7 +5175,7 @@ if (a.approximateByteSize() > 0) { var t212, e116, n42; const u = c.withResumeToken(a, s19).withSequenceNumber(t213.currentSequenceNumber); - i = i.insert(r, u), t212 = c, e116 = u, n42 = e, ((e116.resumeToken.approximateByteSize() > 0 || L(), 0 === t212.resumeToken.approximateByteSize()) ? 0 : e116.snapshotVersion.toMicroseconds() - t212.snapshotVersion.toMicroseconds() >= 3e8 ? 0 : !(n42.addedDocuments.size + n42.modifiedDocuments.size + n42.removedDocuments.size > 0)) || o4.push(n43.ze.updateTargetData(t213, u)); + i = i.insert(r, u), t212 = c, e116 = u, n42 = e, e116.resumeToken.approximateByteSize() > 0 || L(), (0 === t212.resumeToken.approximateByteSize() || e116.snapshotVersion.toMicroseconds() - t212.snapshotVersion.toMicroseconds() >= 3e8 || n42.addedDocuments.size + n42.modifiedDocuments.size + n42.removedDocuments.size > 0) && o4.push(n43.ze.updateTargetData(t213, u)); } }); let c2 = pn, r7; diff --git a/crates/swc_ecma_minifier/tests/fixture/issues/moment/1/output.js b/crates/swc_ecma_minifier/tests/fixture/issues/moment/1/output.js index 6461bae1cee4..3fb61edaa604 100644 --- a/crates/swc_ecma_minifier/tests/fixture/issues/moment/1/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/issues/moment/1/output.js @@ -424,7 +424,7 @@ 2000, 1 ]).day(i), this._minWeekdaysParse[i] = this.weekdaysMin(mom, "").toLocaleLowerCase(), this._shortWeekdaysParse[i] = this.weekdaysShort(mom, "").toLocaleLowerCase(), this._weekdaysParse[i] = this.weekdays(mom, "").toLocaleLowerCase(); - return strict ? "dddd" === format ? -1 !== (ii = indexOf.call(this._weekdaysParse, llc)) ? ii : null : "ddd" === format ? -1 !== (ii = indexOf.call(this._shortWeekdaysParse, llc)) ? ii : null : -1 !== (ii = indexOf.call(this._minWeekdaysParse, llc)) ? ii : null : "dddd" === format ? -1 !== (ii = indexOf.call(this._weekdaysParse, llc)) ? ii : -1 !== (ii = indexOf.call(this._shortWeekdaysParse, llc)) ? ii : -1 !== (ii = indexOf.call(this._minWeekdaysParse, llc)) ? ii : null : "ddd" === format ? -1 !== (ii = indexOf.call(this._shortWeekdaysParse, llc)) ? ii : -1 !== (ii = indexOf.call(this._weekdaysParse, llc)) ? ii : -1 !== (ii = indexOf.call(this._minWeekdaysParse, llc)) ? ii : null : -1 !== (ii = indexOf.call(this._minWeekdaysParse, llc)) ? ii : -1 !== (ii = indexOf.call(this._weekdaysParse, llc)) ? ii : -1 !== (ii = indexOf.call(this._shortWeekdaysParse, llc)) ? ii : null; + return strict ? "dddd" === format ? -1 !== (ii = indexOf.call(this._weekdaysParse, llc)) ? ii : null : "ddd" === format ? -1 !== (ii = indexOf.call(this._shortWeekdaysParse, llc)) ? ii : null : -1 !== (ii = indexOf.call(this._minWeekdaysParse, llc)) ? ii : null : "dddd" === format ? -1 !== (ii = indexOf.call(this._weekdaysParse, llc)) || -1 !== (ii = indexOf.call(this._shortWeekdaysParse, llc)) ? ii : -1 !== (ii = indexOf.call(this._minWeekdaysParse, llc)) ? ii : null : "ddd" === format ? -1 !== (ii = indexOf.call(this._shortWeekdaysParse, llc)) || -1 !== (ii = indexOf.call(this._weekdaysParse, llc)) ? ii : -1 !== (ii = indexOf.call(this._minWeekdaysParse, llc)) ? ii : null : -1 !== (ii = indexOf.call(this._minWeekdaysParse, llc)) || -1 !== (ii = indexOf.call(this._weekdaysParse, llc)) ? ii : -1 !== (ii = indexOf.call(this._shortWeekdaysParse, llc)) ? ii : null; } function computeWeekdaysParse() { function cmpLenRev(a, b) { @@ -1244,8 +1244,7 @@ return new Moment(this); }, proto.diff = function(input, units, asFloat) { var that, zoneDelta, output; - if (!this.isValid()) return NaN; - if (!(that = cloneWithOffset(input, this)).isValid()) return NaN; + if (!this.isValid() || !(that = cloneWithOffset(input, this)).isValid()) return NaN; switch(zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4, units = normalizeUnits(units)){ case "year": output = monthDiff(this, that) / 12; @@ -1448,24 +1447,15 @@ }; }, proto.eraName = function() { var i, l, val, eras = this.localeData().eras(); - for(i = 0, l = eras.length; i < l; ++i){ - if (val = this.clone().startOf("day").valueOf(), eras[i].since <= val && val <= eras[i].until) return eras[i].name; - if (eras[i].until <= val && val <= eras[i].since) return eras[i].name; - } + for(i = 0, l = eras.length; i < l; ++i)if (val = this.clone().startOf("day").valueOf(), eras[i].since <= val && val <= eras[i].until || eras[i].until <= val && val <= eras[i].since) return eras[i].name; return ""; }, proto.eraNarrow = function() { var i, l, val, eras = this.localeData().eras(); - for(i = 0, l = eras.length; i < l; ++i){ - if (val = this.clone().startOf("day").valueOf(), eras[i].since <= val && val <= eras[i].until) return eras[i].narrow; - if (eras[i].until <= val && val <= eras[i].since) return eras[i].narrow; - } + for(i = 0, l = eras.length; i < l; ++i)if (val = this.clone().startOf("day").valueOf(), eras[i].since <= val && val <= eras[i].until || eras[i].until <= val && val <= eras[i].since) return eras[i].narrow; return ""; }, proto.eraAbbr = function() { var i, l, val, eras = this.localeData().eras(); - for(i = 0, l = eras.length; i < l; ++i){ - if (val = this.clone().startOf("day").valueOf(), eras[i].since <= val && val <= eras[i].until) return eras[i].abbr; - if (eras[i].until <= val && val <= eras[i].since) return eras[i].abbr; - } + for(i = 0, l = eras.length; i < l; ++i)if (val = this.clone().startOf("day").valueOf(), eras[i].since <= val && val <= eras[i].until || eras[i].until <= val && val <= eras[i].since) return eras[i].abbr; return ""; }, proto.eraYear = function() { var i, l, dir, val, eras = this.localeData().eras(); @@ -1640,14 +1630,10 @@ }, proto$1.monthsParse = function(monthName, format, strict) { var i, mom, regex; if (this._monthsParseExact) return handleStrictParse.call(this, monthName, format, strict); - for(this._monthsParse || (this._monthsParse = [], this._longMonthsParse = [], this._shortMonthsParse = []), i = 0; i < 12; i++){ - if (mom = createUTC([ - 2000, - i - ]), strict && !this._longMonthsParse[i] && (this._longMonthsParse[i] = new RegExp("^" + this.months(mom, "").replace(".", "") + "$", "i"), this._shortMonthsParse[i] = new RegExp("^" + this.monthsShort(mom, "").replace(".", "") + "$", "i")), strict || this._monthsParse[i] || (regex = "^" + this.months(mom, "") + "|^" + this.monthsShort(mom, ""), this._monthsParse[i] = new RegExp(regex.replace(".", ""), "i")), strict && "MMMM" === format && this._longMonthsParse[i].test(monthName)) return i; - if (strict && "MMM" === format && this._shortMonthsParse[i].test(monthName)) return i; - if (!strict && this._monthsParse[i].test(monthName)) return i; - } + for(this._monthsParse || (this._monthsParse = [], this._longMonthsParse = [], this._shortMonthsParse = []), i = 0; i < 12; i++)if (mom = createUTC([ + 2000, + i + ]), strict && !this._longMonthsParse[i] && (this._longMonthsParse[i] = new RegExp("^" + this.months(mom, "").replace(".", "") + "$", "i"), this._shortMonthsParse[i] = new RegExp("^" + this.monthsShort(mom, "").replace(".", "") + "$", "i")), strict || this._monthsParse[i] || (regex = "^" + this.months(mom, "") + "|^" + this.monthsShort(mom, ""), this._monthsParse[i] = new RegExp(regex.replace(".", ""), "i")), strict && "MMMM" === format && this._longMonthsParse[i].test(monthName) || strict && "MMM" === format && this._shortMonthsParse[i].test(monthName) || !strict && this._monthsParse[i].test(monthName)) return i; }, proto$1.monthsRegex = function(isStrict) { return this._monthsParseExact ? (hasOwnProp(this, "_monthsRegex") || computeMonthsParse.call(this), isStrict) ? this._monthsStrictRegex : this._monthsRegex : (hasOwnProp(this, "_monthsRegex") || (this._monthsRegex = defaultMonthsRegex), this._monthsStrictRegex && isStrict ? this._monthsStrictRegex : this._monthsRegex); }, proto$1.monthsShortRegex = function(isStrict) { @@ -1668,15 +1654,10 @@ }, proto$1.weekdaysParse = function(weekdayName, format, strict) { var i, mom, regex; if (this._weekdaysParseExact) return handleStrictParse$1.call(this, weekdayName, format, strict); - for(this._weekdaysParse || (this._weekdaysParse = [], this._minWeekdaysParse = [], this._shortWeekdaysParse = [], this._fullWeekdaysParse = []), i = 0; i < 7; i++){ - if (mom = createUTC([ - 2000, - 1 - ]).day(i), strict && !this._fullWeekdaysParse[i] && (this._fullWeekdaysParse[i] = new RegExp("^" + this.weekdays(mom, "").replace(".", "\\.?") + "$", "i"), this._shortWeekdaysParse[i] = new RegExp("^" + this.weekdaysShort(mom, "").replace(".", "\\.?") + "$", "i"), this._minWeekdaysParse[i] = new RegExp("^" + this.weekdaysMin(mom, "").replace(".", "\\.?") + "$", "i")), this._weekdaysParse[i] || (regex = "^" + this.weekdays(mom, "") + "|^" + this.weekdaysShort(mom, "") + "|^" + this.weekdaysMin(mom, ""), this._weekdaysParse[i] = new RegExp(regex.replace(".", ""), "i")), strict && "dddd" === format && this._fullWeekdaysParse[i].test(weekdayName)) return i; - if (strict && "ddd" === format && this._shortWeekdaysParse[i].test(weekdayName)) return i; - if (strict && "dd" === format && this._minWeekdaysParse[i].test(weekdayName)) return i; - if (!strict && this._weekdaysParse[i].test(weekdayName)) return i; - } + for(this._weekdaysParse || (this._weekdaysParse = [], this._minWeekdaysParse = [], this._shortWeekdaysParse = [], this._fullWeekdaysParse = []), i = 0; i < 7; i++)if (mom = createUTC([ + 2000, + 1 + ]).day(i), strict && !this._fullWeekdaysParse[i] && (this._fullWeekdaysParse[i] = new RegExp("^" + this.weekdays(mom, "").replace(".", "\\.?") + "$", "i"), this._shortWeekdaysParse[i] = new RegExp("^" + this.weekdaysShort(mom, "").replace(".", "\\.?") + "$", "i"), this._minWeekdaysParse[i] = new RegExp("^" + this.weekdaysMin(mom, "").replace(".", "\\.?") + "$", "i")), this._weekdaysParse[i] || (regex = "^" + this.weekdays(mom, "") + "|^" + this.weekdaysShort(mom, "") + "|^" + this.weekdaysMin(mom, ""), this._weekdaysParse[i] = new RegExp(regex.replace(".", ""), "i")), strict && "dddd" === format && this._fullWeekdaysParse[i].test(weekdayName) || strict && "ddd" === format && this._shortWeekdaysParse[i].test(weekdayName) || strict && "dd" === format && this._minWeekdaysParse[i].test(weekdayName) || !strict && this._weekdaysParse[i].test(weekdayName)) return i; }, proto$1.weekdaysRegex = function(isStrict) { return this._weekdaysParseExact ? (hasOwnProp(this, "_weekdaysRegex") || computeWeekdaysParse.call(this), isStrict) ? this._weekdaysStrictRegex : this._weekdaysRegex : (hasOwnProp(this, "_weekdaysRegex") || (this._weekdaysRegex = defaultWeekdaysRegex), this._weekdaysStrictRegex && isStrict ? this._weekdaysStrictRegex : this._weekdaysRegex); }, proto$1.weekdaysShortRegex = function(isStrict) { diff --git a/crates/swc_ecma_minifier/tests/fixture/issues/quagga2/1.4.2/1/output.js b/crates/swc_ecma_minifier/tests/fixture/issues/quagga2/1.4.2/1/output.js index 09286bb312c7..6603126c45c0 100644 --- a/crates/swc_ecma_minifier/tests/fixture/issues/quagga2/1.4.2/1/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/issues/quagga2/1.4.2/1/output.js @@ -24,8 +24,7 @@ value: !0 }); }, __webpack_require__.t = function(value, mode) { - if (1 & mode && (value = __webpack_require__(value)), 8 & mode) return value; - if (4 & mode && "object" == typeof value && value && value.__esModule) return value; + if (1 & mode && (value = __webpack_require__(value)), 8 & mode || 4 & mode && "object" == typeof value && value && value.__esModule) return value; var ns = Object.create(null); if (__webpack_require__.r(ns), Object.defineProperty(ns, "default", { enumerable: !0, @@ -3089,8 +3088,7 @@ }, function(module, exports) { module.exports = function() { - if ("undefined" == typeof Reflect || !Reflect.construct) return !1; - if (Reflect.construct.sham) return !1; + if ("undefined" == typeof Reflect || !Reflect.construct || Reflect.construct.sham) return !1; if ("function" == typeof Proxy) return !0; try { return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})), !0; @@ -3367,8 +3365,7 @@ }(), barcode_reader = barcode_reader_BarcodeReader, code_128_reader = function(_BarcodeReader) { inherits_default()(Code128Reader, _BarcodeReader); var Derived, hasNativeReflectConstruct, _super = (Derived = Code128Reader, hasNativeReflectConstruct = function() { - if ("undefined" == typeof Reflect || !Reflect.construct) return !1; - if (Reflect.construct.sham) return !1; + if ("undefined" == typeof Reflect || !Reflect.construct || Reflect.construct.sham) return !1; if ("function" == typeof Proxy) return !0; try { return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})), !0; @@ -4416,7 +4413,7 @@ else done = !0; unshift && (codeset = codeset === this.CODE_A ? this.CODE_B : this.CODE_A); } - return null === code ? null : (code.end = this._nextUnset(this._row, code.end), this._verifyTrailingWhitespace(code)) ? (checksum -= multiplier * rawResult[rawResult.length - 1]) % 103 !== rawResult[rawResult.length - 1] ? null : result.length ? (removeLastCharacter && result.splice(result.length - 1, 1), { + return null === code ? null : (code.end = this._nextUnset(this._row, code.end), this._verifyTrailingWhitespace(code) && (checksum -= multiplier * rawResult[rawResult.length - 1]) % 103 === rawResult[rawResult.length - 1] && result.length) ? (removeLastCharacter && result.splice(result.length - 1, 1), { code: result.join(""), start: startInfo.start, end: code.end, @@ -4425,7 +4422,7 @@ decodedCodes: decodedCodes, endInfo: code, format: this.FORMAT - }) : null : null; + }) : null; } }, { @@ -4614,8 +4611,7 @@ ], ean_reader = function(_BarcodeReader) { inherits_default()(EANReader, _BarcodeReader); var Derived, hasNativeReflectConstruct, _super = (Derived = EANReader, hasNativeReflectConstruct = function() { - if ("undefined" == typeof Reflect || !Reflect.construct) return !1; - if (Reflect.construct.sham) return !1; + if ("undefined" == typeof Reflect || !Reflect.construct || Reflect.construct.sham) return !1; if ("function" == typeof Proxy) return !0; try { return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})), !0; @@ -4788,13 +4784,10 @@ start: startInfo.start, end: startInfo.end }; - if (decodedCodes.push(code), !(code = this._decodePayload(code, result, decodedCodes))) return null; - if (!(code = this._findEnd(code.end, !1))) return null; - if (decodedCodes.push(code), !this._checksum(result)) return null; + if (decodedCodes.push(code), !(code = this._decodePayload(code, result, decodedCodes)) || !(code = this._findEnd(code.end, !1)) || (decodedCodes.push(code), !this._checksum(result))) return null; if (this.supplements.length > 0) { var supplement = this._decodeExtensions(code.end); - if (!supplement) return null; - if (!supplement.decodedCodes) return null; + if (!supplement || !supplement.decodedCodes) return null; var lastCode = supplement.decodedCodes[supplement.decodedCodes.length - 1], endInfo = { start: lastCode.start + ((lastCode.end - lastCode.start) / 2 | 0), end: lastCode.end @@ -4867,8 +4860,7 @@ ]), code_39_reader = function(_BarcodeReader) { inherits_default()(Code39Reader, _BarcodeReader); var Derived, hasNativeReflectConstruct, _super = (Derived = Code39Reader, hasNativeReflectConstruct = function() { - if ("undefined" == typeof Reflect || !Reflect.construct) return !1; - if (Reflect.construct.sham) return !1; + if ("undefined" == typeof Reflect || !Reflect.construct || Reflect.construct.sham) return !1; if ("function" == typeof Proxy) return !0; try { return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})), !0; @@ -4978,8 +4970,7 @@ do { counters = this._toCounters(nextStart, counters); var pattern = this._toPattern(counters); - if (pattern < 0) return null; - if (null === (decodedChar = this._patternToChar(pattern))) return null; + if (pattern < 0 || null === (decodedChar = this._patternToChar(pattern))) return null; result.push(decodedChar), lastStart = nextStart, nextStart += array_helper.a.sum(counters), nextStart = this._nextSet(this._row, nextStart); }while ("*" !== decodedChar) return (result.pop(), result.length && this._verifyTrailingWhitespace(lastStart, nextStart, counters)) ? { @@ -4999,8 +4990,7 @@ }, code_39_vin_reader = function(_Code39Reader) { inherits_default()(Code39VINReader, _Code39Reader); var Derived, hasNativeReflectConstruct, _super = (Derived = Code39VINReader, hasNativeReflectConstruct = function() { - if ("undefined" == typeof Reflect || !Reflect.construct) return !1; - if (Reflect.construct.sham) return !1; + if ("undefined" == typeof Reflect || !Reflect.construct || Reflect.construct.sham) return !1; if ("function" == typeof Proxy) return !0; try { return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})), !0; @@ -5090,8 +5080,7 @@ ], codabar_reader = function(_BarcodeReader) { inherits_default()(NewCodabarReader, _BarcodeReader); var Derived, hasNativeReflectConstruct, _super = (Derived = NewCodabarReader, hasNativeReflectConstruct = function() { - if ("undefined" == typeof Reflect || !Reflect.construct) return !1; - if (Reflect.construct.sham) return !1; + if ("undefined" == typeof Reflect || !Reflect.construct || Reflect.construct.sham) return !1; if ("function" == typeof Proxy) return !0; try { return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})), !0; @@ -5262,9 +5251,7 @@ if (null === decodedChar) return null; if (result.push(decodedChar), nextStart += 8, result.length > 1 && this._isStartEnd(pattern)) break; }while (nextStart < this._counters.length) - if (result.length - 2 < 4 || !this._isStartEnd(pattern)) return null; - if (!this._verifyWhitespace(start.startCounter, nextStart - 8)) return null; - if (!this._validateResult(result, start.startCounter)) return null; + if (result.length - 2 < 4 || !this._isStartEnd(pattern) || !this._verifyWhitespace(start.startCounter, nextStart - 8) || !this._validateResult(result, start.startCounter)) return null; nextStart = nextStart > this._counters.length ? this._counters.length : nextStart; var end = start.start + this._sumCounters(start.startCounter, nextStart - 8); return { @@ -5281,8 +5268,7 @@ }(barcode_reader), upc_reader = function(_EANReader) { inherits_default()(UPCReader, _EANReader); var Derived, hasNativeReflectConstruct, _super = (Derived = UPCReader, hasNativeReflectConstruct = function() { - if ("undefined" == typeof Reflect || !Reflect.construct) return !1; - if (Reflect.construct.sham) return !1; + if ("undefined" == typeof Reflect || !Reflect.construct || Reflect.construct.sham) return !1; if ("function" == typeof Proxy) return !0; try { return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})), !0; @@ -5317,8 +5303,7 @@ }(ean_reader), ean_8_reader = function(_EANReader) { inherits_default()(EAN8Reader, _EANReader); var Derived, hasNativeReflectConstruct, _super = (Derived = EAN8Reader, hasNativeReflectConstruct = function() { - if ("undefined" == typeof Reflect || !Reflect.construct) return !1; - if (Reflect.construct.sham) return !1; + if ("undefined" == typeof Reflect || !Reflect.construct || Reflect.construct.sham) return !1; if ("function" == typeof Proxy) return !0; try { return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})), !0; @@ -5362,8 +5347,7 @@ }(ean_reader), ean_2_reader = function(_EANReader) { inherits_default()(EAN2Reader, _EANReader); var Derived, hasNativeReflectConstruct, _super = (Derived = EAN2Reader, hasNativeReflectConstruct = function() { - if ("undefined" == typeof Reflect || !Reflect.construct) return !1; - if (Reflect.construct.sham) return !1; + if ("undefined" == typeof Reflect || !Reflect.construct || Reflect.construct.sham) return !1; if ("function" == typeof Proxy) return !0; try { return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})), !0; @@ -5424,8 +5408,7 @@ ], ean_5_reader = function(_EANReader) { inherits_default()(EAN5Reader, _EANReader); var Derived, hasNativeReflectConstruct, _super = (Derived = EAN5Reader, hasNativeReflectConstruct = function() { - if ("undefined" == typeof Reflect || !Reflect.construct) return !1; - if (Reflect.construct.sham) return !1; + if ("undefined" == typeof Reflect || !Reflect.construct || Reflect.construct.sham) return !1; if ("function" == typeof Proxy) return !0; try { return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})), !0; @@ -5458,8 +5441,7 @@ if (!(code = this._decodeCode(offset))) return null; decodedCodes.push(code), result1.push(code.code % 10), code.code >= 10 && (codeFrequency1 |= 1 << 4 - i1), 4 !== i1 && (offset = this._nextSet(this._row, code.end), offset = this._nextUnset(this._row, offset)); } - if (5 !== result1.length) return null; - if (function(result) { + if (5 !== result1.length || function(result) { for(var length = result.length, sum = 0, i = length - 2; i >= 0; i -= 2)sum += result[i]; sum *= 3; for(var _i = length - 1; _i >= 0; _i -= 2)sum += result[_i]; @@ -5494,8 +5476,7 @@ var upc_e_reader = function(_EANReader) { inherits_default()(UPCEReader, _EANReader); var Derived, hasNativeReflectConstruct, _super = (Derived = UPCEReader, hasNativeReflectConstruct = function() { - if ("undefined" == typeof Reflect || !Reflect.construct) return !1; - if (Reflect.construct.sham) return !1; + if ("undefined" == typeof Reflect || !Reflect.construct || Reflect.construct.sham) return !1; if ("function" == typeof Proxy) return !0; try { return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})), !0; @@ -5635,8 +5616,7 @@ }(ean_reader), i2of5_reader = function(_BarcodeReader) { inherits_default()(I2of5Reader, _BarcodeReader); var Derived, hasNativeReflectConstruct, _super = (Derived = I2of5Reader, hasNativeReflectConstruct = function() { - if ("undefined" == typeof Reflect || !Reflect.construct) return !1; - if (Reflect.construct.sham) return !1; + if ("undefined" == typeof Reflect || !Reflect.construct || Reflect.construct.sham) return !1; if ("function" == typeof Proxy) return !0; try { return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})), !0; @@ -5880,7 +5860,7 @@ var endInfo = this._findEnd(); if (!endInfo) return null; var counters = this._fillCounters(startInfo.end, endInfo.start, !1); - return this._verifyCounterLength(counters) && this._decodePayload(counters, result, decodedCodes) ? result.length % 2 != 0 || result.length < 6 ? null : (decodedCodes.push(endInfo), { + return this._verifyCounterLength(counters) ? !this._decodePayload(counters, result, decodedCodes) || result.length % 2 != 0 || result.length < 6 ? null : (decodedCodes.push(endInfo), { code: result.join(""), start: startInfo.start, end: endInfo.end, @@ -5980,8 +5960,7 @@ }, 0), _2of5_reader = function(_BarcodeReader) { inherits_default()(TwoOfFiveReader, _BarcodeReader); var Derived, hasNativeReflectConstruct, _super = (Derived = TwoOfFiveReader, hasNativeReflectConstruct = function() { - if ("undefined" == typeof Reflect || !Reflect.construct) return !1; - if (Reflect.construct.sham) return !1; + if ("undefined" == typeof Reflect || !Reflect.construct || Reflect.construct.sham) return !1; if ("function" == typeof Proxy) return !0; try { return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})), !0; @@ -6112,14 +6091,14 @@ var decodedCodes = []; decodedCodes.push(startInfo); var result = []; - return this._decodePayload(counters, result, decodedCodes) ? result.length < 5 ? null : (decodedCodes.push(endInfo), { + return !this._decodePayload(counters, result, decodedCodes) || result.length < 5 ? null : (decodedCodes.push(endInfo), { code: result.join(""), start: startInfo.start, end: endInfo.end, startInfo: startInfo, decodedCodes: decodedCodes, format: this.FORMAT - }) : null; + }); } }, ]), TwoOfFiveReader; @@ -6177,8 +6156,7 @@ ]), code_93_reader = function(_BarcodeReader) { inherits_default()(Code93Reader, _BarcodeReader); var Derived, hasNativeReflectConstruct, _super = (Derived = Code93Reader, hasNativeReflectConstruct = function() { - if ("undefined" == typeof Reflect || !Reflect.construct) return !1; - if (Reflect.construct.sham) return !1; + if ("undefined" == typeof Reflect || !Reflect.construct || Reflect.construct.sham) return !1; if ("function" == typeof Proxy) return !0; try { return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})), !0; @@ -6331,8 +6309,7 @@ do { counters = this._toCounters(nextStart, counters); var pattern = this._toPattern(counters); - if (pattern < 0) return null; - if (null === (decodedChar = this._patternToChar(pattern))) return null; + if (pattern < 0 || null === (decodedChar = this._patternToChar(pattern))) return null; result.push(decodedChar), lastStart = nextStart, nextStart += array_helper.a.sum(counters), nextStart = this._nextSet(this._row, nextStart); }while ("*" !== decodedChar) return (result.pop(), result.length && this._verifyEnd(lastStart, nextStart) && this._verifyChecksums(result)) ? (result = result.slice(0, result.length - 2), null === (result = this._decodeExtended(result))) ? null : { @@ -6352,8 +6329,7 @@ }, code_32_reader = function(_Code39Reader) { inherits_default()(Code32Reader, _Code39Reader); var Derived, hasNativeReflectConstruct, _super = (Derived = Code32Reader, hasNativeReflectConstruct = function() { - if ("undefined" == typeof Reflect || !Reflect.construct) return !1; - if (Reflect.construct.sham) return !1; + if ("undefined" == typeof Reflect || !Reflect.construct || Reflect.construct.sham) return !1; if ("function" == typeof Proxy) return !0; try { return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})), !0; @@ -6398,8 +6374,7 @@ var result = get_default()(getPrototypeOf_default()(Code32Reader.prototype), "decode", this).call(this, row, start); if (!result) return null; var code = result.code; - if (!code) return null; - if (code = code.replace(code_32_reader_patterns.AEIO, ""), !this._checkChecksum(code)) return null; + if (!code || (code = code.replace(code_32_reader_patterns.AEIO, ""), !this._checkChecksum(code))) return null; var code32 = this._decodeCode32(code); return code32 ? (result.code = code32, result) : null; } @@ -6626,8 +6601,7 @@ }(), asyncToGenerator = __webpack_require__(20), asyncToGenerator_default = __webpack_require__.n(asyncToGenerator), regenerator = __webpack_require__(12), regenerator_default = __webpack_require__.n(regenerator), pick = __webpack_require__(85), pick_default = __webpack_require__.n(pick), wrapNativeSuper = __webpack_require__(86), wrapNativeSuper_default = __webpack_require__.n(wrapNativeSuper), Exception_Exception = function(_Error) { inherits_default()(Exception, _Error); var Derived, hasNativeReflectConstruct, _super = (Derived = Exception, hasNativeReflectConstruct = function() { - if ("undefined" == typeof Reflect || !Reflect.construct) return !1; - if (Reflect.construct.sham) return !1; + if ("undefined" == typeof Reflect || !Reflect.construct || Reflect.construct.sham) return !1; if ("function" == typeof Proxy) return !0; try { return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})), !0; diff --git a/crates/swc_ecma_minifier/tests/fixture/issues/react-autosuggest/1/output.js b/crates/swc_ecma_minifier/tests/fixture/issues/react-autosuggest/1/output.js index 50a1723ec30a..c6a4bedc0dd3 100644 --- a/crates/swc_ecma_minifier/tests/fixture/issues/react-autosuggest/1/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/issues/react-autosuggest/1/output.js @@ -96,8 +96,7 @@ var ItemsList = function(_Component) { var Derived, Constructor1, protoProps, staticProps, _super = (Derived = ItemsList1, function() { var self, call, result, Super = _getPrototypeOf(Derived); if (function() { - if ("undefined" == typeof Reflect || !Reflect.construct) return !1; - if (Reflect.construct.sham) return !1; + if ("undefined" == typeof Reflect || !Reflect.construct || Reflect.construct.sham) return !1; if ("function" == typeof Proxy) return !0; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function() {})), !0; diff --git a/crates/swc_ecma_minifier/tests/fixture/next/31077/static/chunks/1606726a.10299989c08cb523/output.js b/crates/swc_ecma_minifier/tests/fixture/next/31077/static/chunks/1606726a.10299989c08cb523/output.js index 478be45cf517..378f7dac881e 100644 --- a/crates/swc_ecma_minifier/tests/fixture/next/31077/static/chunks/1606726a.10299989c08cb523/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/next/31077/static/chunks/1606726a.10299989c08cb523/output.js @@ -57,8 +57,7 @@ if (1 != parent.nodeType || hasBlockDesc(node) || atomElements.test(node.nodeName) || "false" == node.contentEditable) return !1; off = domIndex(node) + (dir < 0 ? 0 : 1), node = parent; } else { - if (1 != node.nodeType) return !1; - if ("false" == (node = node.childNodes[off + (dir < 0 ? -1 : 0)]).contentEditable) return !1; + if (1 != node.nodeType || "false" == (node = node.childNodes[off + (dir < 0 ? -1 : 0)]).contentEditable) return !1; off = dir < 0 ? nodeSize(node) : 0; } } @@ -1265,8 +1264,7 @@ } function selectVertically(view, dir, mods) { var sel = view.state.selection; - if (sel instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.TextSelection && !sel.empty || mods.indexOf("s") > -1) return !1; - if (result1.mac && mods.indexOf("m") > -1) return !1; + if (sel instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.TextSelection && !sel.empty || mods.indexOf("s") > -1 || result1.mac && mods.indexOf("m") > -1) return !1; var $from = sel.$from, $to = sel.$to; if (!$from.parent.inlineContent || view.endOfTextblock(dir < 0 ? "up" : "down")) { var next = moveSelectionBlock(view.state, dir); @@ -1602,8 +1600,7 @@ }, DOMObserver.prototype.registerMutation = function(mut, added) { if (added.indexOf(mut.target) > -1) return null; var desc = this.view.docView.nearestDesc(mut.target); - if ("attributes" == mut.type && (desc == this.view.docView || "contenteditable" == mut.attributeName || "style" == mut.attributeName && !mut.oldValue && !mut.target.getAttribute("style"))) return null; - if (!desc || desc.ignoreMutation(mut)) return null; + if ("attributes" == mut.type && (desc == this.view.docView || "contenteditable" == mut.attributeName || "style" == mut.attributeName && !mut.oldValue && !mut.target.getAttribute("style")) || !desc || desc.ignoreMutation(mut)) return null; if ("childList" == mut.type) { for(var i = 0; i < mut.addedNodes.length; i++)added.push(mut.addedNodes[i]); if (desc.contentDOM && desc.contentDOM != desc.dom && !desc.contentDOM.contains(mut.target)) return { @@ -2652,8 +2649,7 @@ var pos, elt1 = (view10.root.elementFromPoint ? view10.root : doc).elementFromPoint(coords3.left, coords3.top + 1); if (!elt1 || !view10.dom.contains(1 != elt1.nodeType ? elt1.parentNode : elt1)) { var box = view10.dom.getBoundingClientRect(); - if (!inRect(coords3, box)) return null; - if (!(elt1 = elementFromPoint(view10.dom, coords3, box))) return null; + if (!inRect(coords3, box) || !(elt1 = elementFromPoint(view10.dom, coords3, box))) return null; } if (result1.safari) for(var p = elt1; node1 && p; p = parentNode(p))p.draggable && (node1 = offset1 = null); if (elt1 = (dom = elt1, coords1 = coords3, (parent = dom.parentNode) && /^li$/i.test(parent.nodeName) && coords1.left < dom.getBoundingClientRect().left ? parent : dom), node1) { diff --git a/crates/swc_ecma_minifier/tests/fixture/next/33265/static/chunks/d6e1aeb5-38a8d7ae57119c23/output.js b/crates/swc_ecma_minifier/tests/fixture/next/33265/static/chunks/d6e1aeb5-38a8d7ae57119c23/output.js index 782f107e6441..01395cc2edd7 100644 --- a/crates/swc_ecma_minifier/tests/fixture/next/33265/static/chunks/d6e1aeb5-38a8d7ae57119c23/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/next/33265/static/chunks/d6e1aeb5-38a8d7ae57119c23/output.js @@ -2872,7 +2872,7 @@ }, _proto.enableInterval_ = function() { this.updateInterval || (this.updateInterval = this.setInterval(this.update, 30)); }, _proto.disableInterval_ = function(e) { - this.player_.liveTracker && this.player_.liveTracker.isLive() && e && "ended" !== e.type || this.updateInterval && (this.clearInterval(this.updateInterval), this.updateInterval = null); + this.player_.liveTracker && this.player_.liveTracker.isLive() && e && "ended" !== e.type || !this.updateInterval || (this.clearInterval(this.updateInterval), this.updateInterval = null); }, _proto.createEl = function() { return _Slider.prototype.createEl.call(this, "div", { className: "vjs-progress-holder" @@ -6472,8 +6472,7 @@ return timeRangesList; }, isRangeDifferent = function(a, b) { if (a === b) return !1; - if (!a && b || !b && a) return !0; - if (a.length !== b.length) return !0; + if (!a && b || !b && a || a.length !== b.length) return !0; for(var i = 0; i < a.length; i++)if (a.start(i) !== b.start(i) || a.end(i) !== b.end(i)) return !0; return !1; }, lastBufferedEnd = function(a) { @@ -6900,8 +6899,7 @@ }, updateMaster$1 = function(master, newMedia, unchangedCheck) { void 0 === unchangedCheck && (unchangedCheck = isPlaylistUnchanged); var result = mergeOptions$2(master, {}), oldMedia = result.playlists[newMedia.id]; - if (!oldMedia) return null; - if (unchangedCheck(oldMedia, newMedia)) return null; + if (!oldMedia || unchangedCheck(oldMedia, newMedia)) return null; newMedia.segments = getAllSegments(newMedia); var mergedPlaylist = mergeOptions$2(oldMedia, newMedia); if (mergedPlaylist.preloadSegment && !newMedia.preloadSegment && delete mergedPlaylist.preloadSegment, oldMedia.segments) { @@ -7287,9 +7285,7 @@ return endRequestAndCallback(error, request, "", bytes); }); var type = (0, _videojs_vhs_utils_es_containers__WEBPACK_IMPORTED_MODULE_12__.Xm)(bytes); - return "ts" === type && bytes.length < 188 ? callbackOnCompleted(request, function() { - return endRequestAndCallback(error, request, "", bytes); - }) : !type && bytes.length < 376 ? callbackOnCompleted(request, function() { + return "ts" === type && bytes.length < 188 || !type && bytes.length < 376 ? callbackOnCompleted(request, function() { return endRequestAndCallback(error, request, "", bytes); }) : endRequestAndCallback(null, request, type, bytes); } @@ -7307,18 +7303,14 @@ }); return request1; }, EventTarget = videojs.EventTarget, mergeOptions = videojs.mergeOptions, dashPlaylistUnchanged = function(a, b) { - if (!isPlaylistUnchanged(a, b)) return !1; - if (a.sidx && b.sidx && (a.sidx.offset !== b.sidx.offset || a.sidx.length !== b.sidx.length)) return !1; - if (!a.sidx && b.sidx || a.sidx && !b.sidx) return !1; - if (a.segments && !b.segments || !a.segments && b.segments) return !1; + if (!isPlaylistUnchanged(a, b) || a.sidx && b.sidx && (a.sidx.offset !== b.sidx.offset || a.sidx.length !== b.sidx.length) || !a.sidx && b.sidx || a.sidx && !b.sidx || a.segments && !b.segments || !a.segments && b.segments) return !1; if (!a.segments && !b.segments) return !0; for(var i = 0; i < a.segments.length; i++){ var aSegment = a.segments[i], bSegment = b.segments[i]; if (aSegment.uri !== bSegment.uri) return !1; if (aSegment.byterange || bSegment.byterange) { var aByterange = aSegment.byterange, bByterange = bSegment.byterange; - if (aByterange && !bByterange || !aByterange && bByterange) return !1; - if (aByterange.offset !== bByterange.offset || aByterange.length !== bByterange.length) return !1; + if (aByterange && !bByterange || !aByterange && bByterange || aByterange.offset !== bByterange.offset || aByterange.length !== bByterange.length) return !1; } } return !0; @@ -8834,7 +8826,7 @@ return result; }, parseUserData: function(sei) { - return 181 !== sei.payload[0] ? null : (sei.payload[1] << 8 | sei.payload[2]) != 49 ? null : "GA94" !== String.fromCharCode(sei.payload[3], sei.payload[4], sei.payload[5], sei.payload[6]) ? null : 0x03 !== sei.payload[7] ? null : sei.payload.subarray(8, sei.payload.length - 1); + return 181 !== sei.payload[0] || (sei.payload[1] << 8 | sei.payload[2]) != 49 || "GA94" !== String.fromCharCode(sei.payload[3], sei.payload[4], sei.payload[5], sei.payload[6]) || 0x03 !== sei.payload[7] ? null : sei.payload.subarray(8, sei.payload.length - 1); }, parseCaptionPackets: function(pts, userData) { var i, count, offset, data, results = []; @@ -9989,8 +9981,7 @@ var chunk, packet, tempLength, frameSize = 0, byteIndex = 0; for(everything.length ? (tempLength = everything.length, (everything = new Uint8Array(bytes.byteLength + tempLength)).set(everything.subarray(0, tempLength)), everything.set(bytes, tempLength)) : everything = bytes; everything.length - byteIndex >= 3;){ if (73 === everything[byteIndex] && 68 === everything[byteIndex + 1] && 51 === everything[byteIndex + 2]) { - if (everything.length - byteIndex < 10) break; - if (frameSize = utils.parseId3TagSize(everything, byteIndex), byteIndex + frameSize > everything.length) break; + if (everything.length - byteIndex < 10 || (frameSize = utils.parseId3TagSize(everything, byteIndex), byteIndex + frameSize > everything.length)) break; chunk = { type: "timed-metadata", data: everything.subarray(byteIndex, byteIndex + frameSize) @@ -9998,8 +9989,7 @@ continue; } if ((0xff & everything[byteIndex]) == 0xff && (0xf0 & everything[byteIndex + 1]) == 0xf0) { - if (everything.length - byteIndex < 7) break; - if (frameSize = utils.parseAdtsSize(everything, byteIndex), byteIndex + frameSize > everything.length) break; + if (everything.length - byteIndex < 7 || (frameSize = utils.parseAdtsSize(everything, byteIndex), byteIndex + frameSize > everything.length)) break; packet = { type: "audio", data: everything.subarray(byteIndex, byteIndex + frameSize), @@ -10187,8 +10177,7 @@ info: {} }, timelineStartPts = 0; if (this.pendingTracks.length < this.numberOfTracks) { - if ("VideoSegmentStream" !== flushSource && "AudioSegmentStream" !== flushSource) return; - if (this.remuxTracks) return; + if ("VideoSegmentStream" !== flushSource && "AudioSegmentStream" !== flushSource || this.remuxTracks) return; if (0 === this.pendingTracks.length) { this.emittedTracks++, this.emittedTracks >= this.numberOfTracks && (this.trigger("done"), this.emittedTracks = 0); return; @@ -10420,8 +10409,7 @@ return (!videoTrackIds || 0 !== videoTrackIds.length) && (!timescales || "object" != typeof timescales || 0 !== Object.keys(timescales).length) && (trackId !== videoTrackIds[0] || timescale !== timescales[trackId]); }, this.parse = function(segment, videoTrackIds, timescales) { var parsedData; - if (!this.isInitialized()) return null; - if (!videoTrackIds || !timescales) return null; + if (!this.isInitialized() || !videoTrackIds || !timescales) return null; if (this.isNewInit(videoTrackIds, timescales)) timescale = timescales[trackId = videoTrackIds[0]]; else if (null === trackId || !timescale) return segmentCache.push(segment), null; for(; segmentCache.length > 0;){ @@ -10759,22 +10747,14 @@ var type = probe.aac.parseType(bytes, byteIndex); switch(type){ case "timed-metadata": - if (bytes.length - byteIndex < 10) { - endLoop = !0; - break; - } - if ((frameSize = probe.aac.parseId3TagSize(bytes, byteIndex)) > bytes.length) { + if (bytes.length - byteIndex < 10 || (frameSize = probe.aac.parseId3TagSize(bytes, byteIndex)) > bytes.length) { endLoop = !0; break; } null === timestamp && (packet = bytes.subarray(byteIndex, byteIndex + frameSize), timestamp = probe.aac.parseAacTimestamp(packet)), byteIndex += frameSize; break; case "audio": - if (bytes.length - byteIndex < 7) { - endLoop = !0; - break; - } - if ((frameSize = probe.aac.parseAdtsSize(bytes, byteIndex)) > bytes.length) { + if (bytes.length - byteIndex < 7 || (frameSize = probe.aac.parseAdtsSize(bytes, byteIndex)) > bytes.length) { endLoop = !0; break; } @@ -11030,10 +11010,10 @@ if (transmuxer.onmessage = function(event) { transmuxer.currentTransmux === options && ("data" === event.data.action && handleData_(event, transmuxedData, onData), "trackinfo" === event.data.action && onTrackInfo(event.data.trackInfo), "gopInfo" === event.data.action && handleGopInfo_(event, transmuxedData), "audioTimingInfo" === event.data.action && onAudioTimingInfo(event.data.audioTimingInfo), "videoTimingInfo" === event.data.action && onVideoTimingInfo(event.data.videoTimingInfo), "videoSegmentTimingInfo" === event.data.action && onVideoSegmentTimingInfo(event.data.videoSegmentTimingInfo), "audioSegmentTimingInfo" === event.data.action && onAudioSegmentTimingInfo(event.data.audioSegmentTimingInfo), "id3Frame" === event.data.action && onId3([ event.data.id3Frame - ], event.data.id3Frame.dispatchType), "caption" === event.data.action && onCaptions(event.data.caption), "endedtimeline" === event.data.action && (waitForEndedTimelineEvent = !1, onEndedTimeline()), "log" === event.data.action && onTransmuxerLog(event.data.log), "transmuxed" === event.data.type && (waitForEndedTimelineEvent || (transmuxer.onmessage = null, handleDone_({ + ], event.data.id3Frame.dispatchType), "caption" === event.data.action && onCaptions(event.data.caption), "endedtimeline" === event.data.action && (waitForEndedTimelineEvent = !1, onEndedTimeline()), "log" === event.data.action && onTransmuxerLog(event.data.log), "transmuxed" !== event.data.type || waitForEndedTimelineEvent || (transmuxer.onmessage = null, handleDone_({ transmuxedData: transmuxedData, callback: onDone - }), dequeue(transmuxer)))); + }), dequeue(transmuxer))); }, audioAppendStart && transmuxer.postMessage({ action: "setAudioAppendStart", appendStart: audioAppendStart @@ -11656,7 +11636,7 @@ return logFn1("could not choose a playlist with options", options), null; } }, lastBandwidthSelector = function() { - var pixelRatio = this.useDevicePixelRatio ? global_window__WEBPACK_IMPORTED_MODULE_0___default().devicePixelRatio || 1 : 1; + var pixelRatio = this.useDevicePixelRatio && global_window__WEBPACK_IMPORTED_MODULE_0___default().devicePixelRatio || 1; return simpleSelector(this.playlists.master, this.systemBandwidth, parseInt(safeGetComputedStyle(this.tech_.el(), "width"), 10) * pixelRatio, parseInt(safeGetComputedStyle(this.tech_.el(), "height"), 10) * pixelRatio, this.limitRenditionByPlayerDimensions, this.masterPlaylistController_); }, minRebufferMaxBandwidthSelector = function(settings) { var master = settings.master, currentTime = settings.currentTime, bandwidth = settings.bandwidth, duration = settings.duration, segmentDuration = settings.segmentDuration, timeUntilRebuffer = settings.timeUntilRebuffer, currentTimeline = settings.currentTimeline, syncController = settings.syncController, compatiblePlaylists = master.playlists.filter(function(playlist) { @@ -11798,8 +11778,7 @@ if (akeys.length !== bkeys.length) return !1; for(var i = 0; i < akeys.length; i++){ var key = akeys[i]; - if (key !== bkeys[i]) return !1; - if (a[key] !== b[key]) return !1; + if (key !== bkeys[i] || a[key] !== b[key]) return !1; } return !0; }, getSyncSegmentCandidate = function(currentTimeline, segments, targetTime) { @@ -12114,7 +12093,7 @@ }, _proto.timestampOffsetForSegment_ = function(options) { return timestampOffsetForSegment(options); }, _proto.earlyAbortWhenNeeded_ = function(stats) { - if (!this.vhs_.tech_.paused() && this.xhrOptions_.timeout && this.playlist_.attributes.BANDWIDTH && !(Date.now() - (stats.firstBytesReceivedAt || Date.now()) < 1000)) { + if (!(this.vhs_.tech_.paused() || !this.xhrOptions_.timeout || !this.playlist_.attributes.BANDWIDTH || Date.now() - (stats.firstBytesReceivedAt || Date.now()) < 1000)) { var buffered, currentTime, playbackRate, currentTime1 = this.currentTime_(), measuredBandwidth = stats.bandwidth, segmentDuration = this.pendingSegment_.duration, requestTimeRemaining = Playlist.estimateSegmentRequestTime(segmentDuration, measuredBandwidth, this.playlist_, stats.bytesReceived), timeUntilRebuffer$1 = (buffered = this.buffered_(), currentTime = currentTime1, void 0 === (playbackRate = this.vhs_.tech_.playbackRate()) && (playbackRate = 1), ((buffered.length ? buffered.end(buffered.length - 1) : 0) - currentTime) / playbackRate - 1); if (!(requestTimeRemaining <= timeUntilRebuffer$1)) { var switchCandidate = minRebufferMaxBandwidthSelector({ @@ -12138,10 +12117,10 @@ }, _proto.handleProgress_ = function(event, simpleSegment) { this.earlyAbortWhenNeeded_(simpleSegment.stats), this.checkForAbort_(simpleSegment.requestId) || this.trigger("progress"); }, _proto.handleTrackInfo_ = function(simpleSegment, trackInfo) { - this.earlyAbortWhenNeeded_(simpleSegment.stats), !this.checkForAbort_(simpleSegment.requestId) && (this.checkForIllegalMediaSwitch(trackInfo) || (trackInfo = trackInfo || {}, shallowEqual(this.currentMediaInfo_, trackInfo) || (this.appendInitSegment_ = { + this.earlyAbortWhenNeeded_(simpleSegment.stats), this.checkForAbort_(simpleSegment.requestId) || this.checkForIllegalMediaSwitch(trackInfo) || (trackInfo = trackInfo || {}, shallowEqual(this.currentMediaInfo_, trackInfo) || (this.appendInitSegment_ = { audio: !0, video: !0 - }, this.startingMediaInfo_ = trackInfo, this.currentMediaInfo_ = trackInfo, this.logger_("trackinfo update", trackInfo), this.trigger("trackinfo")), !this.checkForAbort_(simpleSegment.requestId) && (this.pendingSegment_.trackInfo = trackInfo, this.hasEnoughInfoToAppend_() && this.processCallQueue_()))); + }, this.startingMediaInfo_ = trackInfo, this.currentMediaInfo_ = trackInfo, this.logger_("trackinfo update", trackInfo), this.trigger("trackinfo")), !this.checkForAbort_(simpleSegment.requestId) && (this.pendingSegment_.trackInfo = trackInfo, this.hasEnoughInfoToAppend_() && this.processCallQueue_())); }, _proto.handleTimingInfo_ = function(simpleSegment, mediaType, timeType, time) { if (this.earlyAbortWhenNeeded_(simpleSegment.stats), !this.checkForAbort_(simpleSegment.requestId)) { var segmentInfo = this.pendingSegment_, timingInfoProperty = timingInfoPropertyForMedia(mediaType); @@ -12223,18 +12202,17 @@ }, _proto.getMediaInfo_ = function(segmentInfo) { return void 0 === segmentInfo && (segmentInfo = this.pendingSegment_), this.getCurrentMediaInfo_(segmentInfo) || this.startingMediaInfo_; }, _proto.hasEnoughInfoToAppend_ = function() { - if (!this.sourceUpdater_.ready()) return !1; - if (this.waitingOnRemove_ || this.quotaExceededErrorRetryTimeout_) return !1; + if (!this.sourceUpdater_.ready() || this.waitingOnRemove_ || this.quotaExceededErrorRetryTimeout_) return !1; var segmentInfo = this.pendingSegment_, trackInfo = this.getCurrentMediaInfo_(); if (!segmentInfo || !trackInfo) return !1; var hasAudio = trackInfo.hasAudio, hasVideo = trackInfo.hasVideo, isMuxed = trackInfo.isMuxed; - return (!hasVideo || !!segmentInfo.videoTimingInfo) && (!hasAudio || !!this.audioDisabled_ || !!isMuxed || !!segmentInfo.audioTimingInfo) && !shouldWaitForTimelineChange({ + return !(hasVideo && !segmentInfo.videoTimingInfo || hasAudio && !this.audioDisabled_ && !isMuxed && !segmentInfo.audioTimingInfo || shouldWaitForTimelineChange({ timelineChangeController: this.timelineChangeController_, currentTimeline: this.currentTimeline_, segmentTimeline: segmentInfo.timeline, loaderType: this.loaderType_, audioDisabled: this.audioDisabled_ - }); + })); }, _proto.handleData_ = function(simpleSegment, result) { if (this.earlyAbortWhenNeeded_(simpleSegment.stats), !this.checkForAbort_(simpleSegment.requestId)) { if (this.callQueue_.length || !this.hasEnoughInfoToAppend_()) { @@ -12595,7 +12573,7 @@ sourceUpdater.updating() || "closed" === sourceUpdater.mediaSource.readyState || (sourceUpdater.queue.shift(), queueEntry.action(sourceUpdater), queueEntry.doneFn && queueEntry.doneFn(), shiftQueue("audio", sourceUpdater), shiftQueue("video", sourceUpdater)); return; } - if ("mediaSource" !== type && !(!sourceUpdater.ready() || "closed" === sourceUpdater.mediaSource.readyState || _updating(type, sourceUpdater))) { + if (!("mediaSource" === type || !sourceUpdater.ready() || "closed" === sourceUpdater.mediaSource.readyState || _updating(type, sourceUpdater))) { if (queueEntry.type !== type) { if (null === (queueIndex = nextQueueIndexOfType(type, sourceUpdater.queue))) return; queueEntry = sourceUpdater.queue[queueIndex]; @@ -13639,10 +13617,7 @@ } } }, groupMatch1 = function groupMatch(list, media) { - for(var i = 0; i < list.length; i++){ - if (playlistMatch(media, list[i])) return !0; - if (list[i].playlists && groupMatch(list[i].playlists, media)) return !0; - } + for(var i = 0; i < list.length; i++)if (playlistMatch(media, list[i]) || list[i].playlists && groupMatch(list[i].playlists, media)) return !0; return !1; }, activeTrack1 = { AUDIO: function(type, settings) { @@ -13695,9 +13670,9 @@ } else groups.main ? variants = groups.main : 1 === groupKeys.length && (variants = groups[groupKeys[0]]); } - return void 0 === track ? variants : null !== track && variants ? variants.filter(function(props) { + return void 0 === track ? variants : null !== track && variants && variants.filter(function(props) { return props.id === track.id; - })[0] || null : null; + })[0] || null; }), mediaTypes[type].activeTrack = activeTrack1[type](type, settings4), mediaTypes[type].onGroupChanged = (type3 = type, settings1 = settings4, function() { var _settings$segmentLoad = settings1.segmentLoaders, segmentLoader = _settings$segmentLoad[type3], mainSegmentLoader = _settings$segmentLoad.main, mediaType = settings1.mediaTypes[type3], activeTrack = mediaType.activeTrack(), activeGroup = mediaType.getActiveGroup(), previousActiveLoader = mediaType.activePlaylistLoader, lastGroup = mediaType.lastGroup_; if ((!activeGroup || !lastGroup || activeGroup.id !== lastGroup.id) && (mediaType.lastGroup_ = activeGroup, mediaType.lastTrack_ = activeTrack, stopLoaders(segmentLoader, mediaType), activeGroup && !activeGroup.isMasterPlaylist)) { @@ -13970,8 +13945,7 @@ _this3.loadOnPlay_ && _this3.tech_.off("play", _this3.loadOnPlay_); var selectedMedia, updatedPlaylist = _this3.masterPlaylistLoader_.media(); if (!updatedPlaylist) { - if (_this3.excludeUnsupportedVariants_(), _this3.enableLowInitialPlaylist && (selectedMedia = _this3.selectInitialPlaylist()), selectedMedia || (selectedMedia = _this3.selectPlaylist()), !selectedMedia || !_this3.shouldSwitchToMedia_(selectedMedia)) return; - if (_this3.initialMedia_ = selectedMedia, _this3.switchMedia_(_this3.initialMedia_, "initial"), !("vhs-json" === _this3.sourceType_ && _this3.initialMedia_.segments)) return; + if (_this3.excludeUnsupportedVariants_(), _this3.enableLowInitialPlaylist && (selectedMedia = _this3.selectInitialPlaylist()), selectedMedia || (selectedMedia = _this3.selectPlaylist()), !selectedMedia || !_this3.shouldSwitchToMedia_(selectedMedia) || (_this3.initialMedia_ = selectedMedia, _this3.switchMedia_(_this3.initialMedia_, "initial"), !("vhs-json" === _this3.sourceType_ && _this3.initialMedia_.segments))) return; updatedPlaylist = _this3.initialMedia_; } _this3.handleUpdatedMediaPlaylist(updatedPlaylist); @@ -14263,18 +14237,12 @@ var expired = this.syncController_.getExpiredTime(media, this.duration()); if (null !== expired) { var master = this.masterPlaylistLoader_.master, mainSeekable = Vhs$1.Playlist.seekable(media, expired, Vhs$1.Playlist.liveEdgeDelay(master, media)); - if (0 !== mainSeekable.length) { - if (this.mediaTypes_.AUDIO.activePlaylistLoader) { - if (media = this.mediaTypes_.AUDIO.activePlaylistLoader.media(), null === (expired = this.syncController_.getExpiredTime(media, this.duration()))) return; - if (0 === (audioSeekable = Vhs$1.Playlist.seekable(media, expired, Vhs$1.Playlist.liveEdgeDelay(master, media))).length) return; - } - this.seekable_ && this.seekable_.length && (oldEnd = this.seekable_.end(0), oldStart = this.seekable_.start(0)), audioSeekable ? audioSeekable.start(0) > mainSeekable.end(0) || mainSeekable.start(0) > audioSeekable.end(0) ? this.seekable_ = mainSeekable : this.seekable_ = videojs.createTimeRanges([ - [ - audioSeekable.start(0) > mainSeekable.start(0) ? audioSeekable.start(0) : mainSeekable.start(0), - audioSeekable.end(0) < mainSeekable.end(0) ? audioSeekable.end(0) : mainSeekable.end(0), - ], - ]) : this.seekable_ = mainSeekable, this.seekable_ && this.seekable_.length && this.seekable_.end(0) === oldEnd && this.seekable_.start(0) === oldStart || (this.logger_("seekable updated [" + printableRange(this.seekable_) + "]"), this.tech_.trigger("seekablechanged")); - } + 0 !== mainSeekable.length && (!this.mediaTypes_.AUDIO.activePlaylistLoader || (media = this.mediaTypes_.AUDIO.activePlaylistLoader.media(), null !== (expired = this.syncController_.getExpiredTime(media, this.duration())) && 0 !== (audioSeekable = Vhs$1.Playlist.seekable(media, expired, Vhs$1.Playlist.liveEdgeDelay(master, media))).length)) && (this.seekable_ && this.seekable_.length && (oldEnd = this.seekable_.end(0), oldStart = this.seekable_.start(0)), audioSeekable ? audioSeekable.start(0) > mainSeekable.end(0) || mainSeekable.start(0) > audioSeekable.end(0) ? this.seekable_ = mainSeekable : this.seekable_ = videojs.createTimeRanges([ + [ + audioSeekable.start(0) > mainSeekable.start(0) ? audioSeekable.start(0) : mainSeekable.start(0), + audioSeekable.end(0) < mainSeekable.end(0) ? audioSeekable.end(0) : mainSeekable.end(0), + ], + ]) : this.seekable_ = mainSeekable, this.seekable_ && this.seekable_.length && this.seekable_.end(0) === oldEnd && this.seekable_.start(0) === oldStart || (this.logger_("seekable updated [" + printableRange(this.seekable_) + "]"), this.tech_.trigger("seekablechanged"))); } } } @@ -14692,7 +14660,7 @@ var average = -1, lastSystemBandwidth = -1; if (decay < 0 || decay > 1) throw new Error("Moving average bandwidth decay must be between 0 and 1."); return function() { - var pixelRatio = this.useDevicePixelRatio ? global_window__WEBPACK_IMPORTED_MODULE_0___default().devicePixelRatio || 1 : 1; + var pixelRatio = this.useDevicePixelRatio && global_window__WEBPACK_IMPORTED_MODULE_0___default().devicePixelRatio || 1; return average < 0 && (average = this.systemBandwidth, lastSystemBandwidth = this.systemBandwidth), this.systemBandwidth > 0 && this.systemBandwidth !== lastSystemBandwidth && (average = decay * this.systemBandwidth + (1 - decay) * average, lastSystemBandwidth = this.systemBandwidth), simpleSelector(this.playlists.master, average, parseInt(safeGetComputedStyle(this.tech_.el(), "width"), 10) * pixelRatio, parseInt(safeGetComputedStyle(this.tech_.el(), "height"), 10) * pixelRatio, this.limitRenditionByPlayerDimensions, this.masterPlaylistController_); }; }, diff --git a/crates/swc_ecma_minifier/tests/fixture/next/33265/static/chunks/pages/index-cb36c1bf7f830e3c/output.js b/crates/swc_ecma_minifier/tests/fixture/next/33265/static/chunks/pages/index-cb36c1bf7f830e3c/output.js index 63fc9a4b9aea..e55bb2d373d0 100644 --- a/crates/swc_ecma_minifier/tests/fixture/next/33265/static/chunks/pages/index-cb36c1bf7f830e3c/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/next/33265/static/chunks/pages/index-cb36c1bf7f830e3c/output.js @@ -643,7 +643,7 @@ offset: 4 }) || (0, byte_helpers.G3)(bytes, CONSTANTS.fmp4, { offset: 4 - })) || !!((0, byte_helpers.G3)(bytes, CONSTANTS.moof, { + }) || (0, byte_helpers.G3)(bytes, CONSTANTS.moof, { offset: 4 }) || (0, byte_helpers.G3)(bytes, CONSTANTS.moov, { offset: 4 @@ -1198,8 +1198,7 @@ } function needNamespaceDefine(node, isHTML, visibleNamespaces) { var prefix = node.prefix || "", uri = node.namespaceURI; - if (!uri) return !1; - if ("xml" === prefix && uri === NAMESPACE.XML || uri === NAMESPACE.XMLNS) return !1; + if (!uri || "xml" === prefix && uri === NAMESPACE.XML || uri === NAMESPACE.XMLNS) return !1; for(var i = visibleNamespaces.length; i--;){ var ns = visibleNamespaces[i]; if (ns.prefix === prefix) return ns.namespace !== uri; @@ -4065,9 +4064,7 @@ continue; } var m2 = t.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/); - if (!m2) continue; - if (!(node = createElement(m2[1], m2[3]))) continue; - if (!shouldAdd(current1, node)) continue; + if (!m2 || !(node = createElement(m2[1], m2[3])) || !shouldAdd(current1, node)) continue; if (m2[2]) { var classes = m2[2].split("."); classes.forEach(function(cl) { @@ -5190,8 +5187,7 @@ if ("string" == typeof value) return fromString(value, encodingOrOffset); if (ArrayBuffer.isView(value)) return fromArrayLike(value); if (null == value) throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value); - if (isInstance(value, ArrayBuffer) || value && isInstance(value.buffer, ArrayBuffer)) return fromArrayBuffer(value, encodingOrOffset, length); - if ("undefined" != typeof SharedArrayBuffer && (isInstance(value, SharedArrayBuffer) || value && isInstance(value.buffer, SharedArrayBuffer))) return fromArrayBuffer(value, encodingOrOffset, length); + if (isInstance(value, ArrayBuffer) || value && isInstance(value.buffer, ArrayBuffer) || "undefined" != typeof SharedArrayBuffer && (isInstance(value, SharedArrayBuffer) || value && isInstance(value.buffer, SharedArrayBuffer))) return fromArrayBuffer(value, encodingOrOffset, length); if ("number" == typeof value) throw new TypeError('The "value" argument must not be of type number. Received type number'); var valueOf = value.valueOf && value.valueOf(); if (null != valueOf && valueOf !== value) return Buffer.from(valueOf, encodingOrOffset, length); @@ -5263,9 +5259,7 @@ } function slowToString(encoding, start, end) { var loweredCase = !1; - if ((void 0 === start || start < 0) && (start = 0), start > this.length) return ""; - if ((void 0 === end || end > this.length) && (end = this.length), end <= 0) return ""; - if ((end >>>= 0) <= (start >>>= 0)) return ""; + if ((void 0 === start || start < 0) && (start = 0), start > this.length || ((void 0 === end || end > this.length) && (end = this.length), end <= 0 || (end >>>= 0) <= (start >>>= 0))) return ""; for(encoding || (encoding = "utf8");;)switch(encoding){ case "hex": return hexSlice(this, start, end); @@ -5422,8 +5416,7 @@ if (offset + ext > buf.length) throw new RangeError("Index out of range"); } function checkIEEE754(buf, value, offset, ext, max, min) { - if (offset + ext > buf.length) throw new RangeError("Index out of range"); - if (offset < 0) throw new RangeError("Index out of range"); + if (offset + ext > buf.length || offset < 0) throw new RangeError("Index out of range"); } function writeFloat(buf, value, offset, littleEndian, noAssert) { return value = +value, offset >>>= 0, noAssert || checkIEEE754(buf, value, offset, 4, 3.4028234663852886e38, -340282346638528860000000000000000000000), ieee754.write(buf, value, offset, littleEndian, 23, 4), offset + 4; @@ -5693,8 +5686,7 @@ return writeDouble(this, value, offset, !1, noAssert); }, Buffer.prototype.copy = function(target, targetStart, start, end) { if (!Buffer.isBuffer(target)) throw new TypeError("argument should be a Buffer"); - if (start || (start = 0), end || 0 === end || (end = this.length), targetStart >= target.length && (targetStart = target.length), targetStart || (targetStart = 0), end > 0 && end < start && (end = start), end === start) return 0; - if (0 === target.length || 0 === this.length) return 0; + if (start || (start = 0), end || 0 === end || (end = this.length), targetStart >= target.length && (targetStart = target.length), targetStart || (targetStart = 0), end > 0 && end < start && (end = start), end === start || 0 === target.length || 0 === this.length) return 0; if (targetStart < 0) throw new RangeError("targetStart out of bounds"); if (start < 0 || start >= this.length) throw new RangeError("Index out of range"); if (end < 0) throw new RangeError("sourceEnd out of bounds"); @@ -5729,11 +5721,7 @@ for(var codePoint, length = string.length, leadSurrogate = null, bytes = [], i = 0; i < length; ++i){ if ((codePoint = string.charCodeAt(i)) > 0xd7ff && codePoint < 0xe000) { if (!leadSurrogate) { - if (codePoint > 0xdbff) { - (units -= 3) > -1 && bytes.push(0xef, 0xbf, 0xbd); - continue; - } - if (i + 1 === length) { + if (codePoint > 0xdbff || i + 1 === length) { (units -= 3) > -1 && bytes.push(0xef, 0xbf, 0xbd); continue; } @@ -5830,8 +5818,7 @@ var setPrototypeOf = __webpack_require__(9611); function _construct(Parent1, args1, Class1) { return (_construct = !function() { - if ("undefined" == typeof Reflect || !Reflect.construct) return !1; - if (Reflect.construct.sham) return !1; + if ("undefined" == typeof Reflect || !Reflect.construct || Reflect.construct.sham) return !1; if ("function" == typeof Proxy) return !0; try { return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})), !0; diff --git a/crates/swc_ecma_minifier/tests/fixture/next/feedback-2/codemirror/output.js b/crates/swc_ecma_minifier/tests/fixture/next/feedback-2/codemirror/output.js index 3b9636ca6fc2..b9363b4f246d 100644 --- a/crates/swc_ecma_minifier/tests/fixture/next/feedback-2/codemirror/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/next/feedback-2/codemirror/output.js @@ -847,10 +847,7 @@ function lineIsHidden(doc, line) { var sps = sawCollapsedSpans && line.markedSpans; if (sps) { - for(var sp = void 0, i = 0; i < sps.length; ++i)if ((sp = sps[i]).marker.collapsed) { - if (null == sp.from) return !0; - if (!sp.marker.widgetNode && 0 == sp.from && sp.marker.inclusiveLeft && lineIsHiddenInner(doc, line, sp)) return !0; - } + for(var sp = void 0, i = 0; i < sps.length; ++i)if ((sp = sps[i]).marker.collapsed && (null == sp.from || !sp.marker.widgetNode && 0 == sp.from && sp.marker.inclusiveLeft && lineIsHiddenInner(doc, line, sp))) return !0; } } function lineIsHiddenInner(doc, line, span) { @@ -1553,8 +1550,7 @@ return coords; } function findViewIndex(cm, n) { - if (n >= cm.display.viewTo) return null; - if ((n -= cm.display.viewFrom) < 0) return null; + if (n >= cm.display.viewTo || (n -= cm.display.viewFrom) < 0) return null; for(var view = cm.display.view, i = 0; i < view.length; i++)if ((n -= view[i].size) < 0) return i; } function regChange(cm, from, to, lendiff) { @@ -3330,8 +3326,7 @@ lineInfo: function(line) { var n; if ("number" == typeof line) { - if (!isLine(this, line)) return null; - if (n = line, line = getLine(this, line), !line) return null; + if (!isLine(this, line) || (n = line, line = getLine(this, line), !line)) return null; } else if (null == (n = lineNo1(line))) return null; return { line: n, @@ -4152,7 +4147,7 @@ 16 == e.keyCode && (this.doc.sel.shift = !1), signalDOMEvent(this, e); } function onKeyPress(e) { - if ((!e.target || e.target == this.display.input.getField()) && !(eventInWidget(this.display, e) || signalDOMEvent(this, e)) && (!e.ctrlKey || e.altKey) && (!mac || !e.metaKey)) { + if (!(e.target && e.target != this.display.input.getField() || eventInWidget(this.display, e) || signalDOMEvent(this, e) || e.ctrlKey && !e.altKey || mac && e.metaKey)) { var cm, keyCode = e.keyCode, charCode = e.charCode; if (presto && keyCode == lastStoppedKey) { lastStoppedKey = null, e_preventDefault(e); @@ -4340,7 +4335,7 @@ return gutterEvent(cm, e, "gutterClick", !0); } function onContextMenu(cm, e) { - eventInWidget(cm.display, e) || contextMenuInGutter(cm, e) || !signalDOMEvent(cm, e, "contextmenu") && (captureRightClick || cm.display.input.onContextMenu(e)); + !(eventInWidget(cm.display, e) || contextMenuInGutter(cm, e) || signalDOMEvent(cm, e, "contextmenu")) && (captureRightClick || cm.display.input.onContextMenu(e)); } function contextMenuInGutter(cm, e) { return !!hasHandler(cm, "gutterContextMenu") && gutterEvent(cm, e, "gutterContextMenu", !1); @@ -4638,8 +4633,7 @@ return moveInStorageOrder ? new Pos(start.line, mv(ch, 1), "before") : new Pos(start.line, ch, "after"); }; partPos >= 0 && partPos < bidi.length; partPos += dir){ var part = bidi[partPos], moveInStorageOrder1 = dir > 0 == (1 != part.level), ch7 = moveInStorageOrder1 ? wrappedLineExtent.begin : mv(wrappedLineExtent.end, -1); - if (part.from <= ch7 && ch7 < part.to) return getRes(ch7, moveInStorageOrder1); - if (ch7 = moveInStorageOrder1 ? part.from : mv(part.to, -1), wrappedLineExtent.begin <= ch7 && ch7 < wrappedLineExtent.end) return getRes(ch7, moveInStorageOrder1); + if (part.from <= ch7 && ch7 < part.to || (ch7 = moveInStorageOrder1 ? part.from : mv(part.to, -1), wrappedLineExtent.begin <= ch7 && ch7 < wrappedLineExtent.end)) return getRes(ch7, moveInStorageOrder1); } }, res = searchInVisualLine(partPos2 + dir2, dir2, wrappedLineExtent2); if (res) return res; diff --git a/crates/swc_ecma_minifier/tests/fixture/next/feedback-util-promisify/chunks/pages/_app-72ad41192608e93a/output.js b/crates/swc_ecma_minifier/tests/fixture/next/feedback-util-promisify/chunks/pages/_app-72ad41192608e93a/output.js index d01175894aa8..fb14832740e2 100644 --- a/crates/swc_ecma_minifier/tests/fixture/next/feedback-util-promisify/chunks/pages/_app-72ad41192608e93a/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/next/feedback-util-promisify/chunks/pages/_app-72ad41192608e93a/output.js @@ -153,8 +153,7 @@ if ("string" == typeof e) return fromString(e, r); if (ArrayBuffer.isView(e)) return fromArrayLike(e); if (null == e) throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof e); - if (isInstance(e, ArrayBuffer) || e && isInstance(e.buffer, ArrayBuffer)) return fromArrayBuffer(e, r, t); - if ("undefined" != typeof SharedArrayBuffer && (isInstance(e, SharedArrayBuffer) || e && isInstance(e.buffer, SharedArrayBuffer))) return fromArrayBuffer(e, r, t); + if (isInstance(e, ArrayBuffer) || e && isInstance(e.buffer, ArrayBuffer) || "undefined" != typeof SharedArrayBuffer && (isInstance(e, SharedArrayBuffer) || e && isInstance(e.buffer, SharedArrayBuffer))) return fromArrayBuffer(e, r, t); if ("number" == typeof e) throw new TypeError('The "value" argument must not be of type number. Received type number'); var f = e.valueOf && e.valueOf(); if (null != f && f !== e) return Buffer.from(f, r, t); @@ -226,9 +225,7 @@ } function slowToString(e, r, t) { var f = !1; - if ((void 0 === r || r < 0) && (r = 0), r > this.length) return ""; - if ((void 0 === t || t > this.length) && (t = this.length), t <= 0) return ""; - if ((t >>>= 0) <= (r >>>= 0)) return ""; + if ((void 0 === r || r < 0) && (r = 0), r > this.length || ((void 0 === t || t > this.length) && (t = this.length), t <= 0 || (t >>>= 0) <= (r >>>= 0))) return ""; for(e || (e = "utf8");;)switch(e){ case "hex": return hexSlice(this, r, t); @@ -385,8 +382,7 @@ if (t + f > e.length) throw new RangeError("Index out of range"); } function checkIEEE754(e, r, t, f, n, i) { - if (t + f > e.length) throw new RangeError("Index out of range"); - if (t < 0) throw new RangeError("Index out of range"); + if (t + f > e.length || t < 0) throw new RangeError("Index out of range"); } function writeFloat(e, r, t, f, i) { return r = +r, t >>>= 0, i || checkIEEE754(e, r, t, 4, 34028234663852886e22, -340282346638528860000000000000000000000), n2.write(e, r, t, f, 23, 4), t + 4; @@ -656,8 +652,7 @@ return writeDouble(this, e, r, !1, t); }, Buffer.prototype.copy = function(e, r, t, f) { if (!Buffer.isBuffer(e)) throw new TypeError("argument should be a Buffer"); - if (t || (t = 0), f || 0 === f || (f = this.length), r >= e.length && (r = e.length), r || (r = 0), f > 0 && f < t && (f = t), f === t) return 0; - if (0 === e.length || 0 === this.length) return 0; + if (t || (t = 0), f || 0 === f || (f = this.length), r >= e.length && (r = e.length), r || (r = 0), f > 0 && f < t && (f = t), f === t || 0 === e.length || 0 === this.length) return 0; if (r < 0) throw new RangeError("targetStart out of bounds"); if (t < 0 || t >= this.length) throw new RangeError("Index out of range"); if (f < 0) throw new RangeError("sourceEnd out of bounds"); @@ -692,11 +687,7 @@ for(var t, f = e.length, n = null, i = [], o = 0; o < f; ++o){ if ((t = e.charCodeAt(o)) > 55295 && t < 57344) { if (!n) { - if (t > 56319) { - (r -= 3) > -1 && i.push(239, 191, 189); - continue; - } - if (o + 1 === f) { + if (t > 56319 || o + 1 === f) { (r -= 3) > -1 && i.push(239, 191, 189); continue; } @@ -901,8 +892,7 @@ 901: function(r10) { r10.exports = function(r, e, o) { if (r.filter) return r.filter(e, o); - if (null == r) throw new TypeError(); - if ("function" != typeof e) throw new TypeError(); + if (null == r || "function" != typeof e) throw new TypeError(); for(var n = [], i = 0; i < r.length; i++)if (t.call(r, i)) { var a = r[i]; e.call(o, a, i, r) && n.push(a); @@ -1706,15 +1696,11 @@ if ("function" != typeof Symbol || "function" != typeof Object.getOwnPropertySymbols) return !1; if ("symbol" == typeof Symbol.iterator) return !0; var r = {}, t = Symbol("test"), e = Object(t); - if ("string" == typeof t) return !1; - if ("[object Symbol]" !== Object.prototype.toString.call(t)) return !1; - if ("[object Symbol]" !== Object.prototype.toString.call(e)) return !1; + if ("string" == typeof t || "[object Symbol]" !== Object.prototype.toString.call(t) || "[object Symbol]" !== Object.prototype.toString.call(e)) return !1; for(t in r[t] = 42, r)return !1; - if ("function" == typeof Object.keys && 0 !== Object.keys(r).length) return !1; - if ("function" == typeof Object.getOwnPropertyNames && 0 !== Object.getOwnPropertyNames(r).length) return !1; + if ("function" == typeof Object.keys && 0 !== Object.keys(r).length || "function" == typeof Object.getOwnPropertyNames && 0 !== Object.getOwnPropertyNames(r).length) return !1; var n = Object.getOwnPropertySymbols(r); - if (1 !== n.length || n[0] !== t) return !1; - if (!Object.prototype.propertyIsEnumerable.call(r, t)) return !1; + if (1 !== n.length || n[0] !== t || !Object.prototype.propertyIsEnumerable.call(r, t)) return !1; if ("function" == typeof Object.getOwnPropertyDescriptor) { var i = Object.getOwnPropertyDescriptor(r, t); if (42 !== i.value || !0 !== i.enumerable) return !1; diff --git a/crates/swc_ecma_minifier/tests/fixture/next/react-ace/chunks/8a28b14e.d8fbda268ed281a1/output.js b/crates/swc_ecma_minifier/tests/fixture/next/react-ace/chunks/8a28b14e.d8fbda268ed281a1/output.js index 2e6fa35fab45..73eb745d0e18 100644 --- a/crates/swc_ecma_minifier/tests/fixture/next/react-ace/chunks/8a28b14e.d8fbda268ed281a1/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/next/react-ace/chunks/8a28b14e.d8fbda268ed281a1/output.js @@ -169,7 +169,7 @@ } if (!strictCSP) { var container = target; - target && target.getRootNode ? (container = target.getRootNode()) && container != target || (container = document) : container = document; + target && target.getRootNode && (container = target.getRootNode()) && container != target || (container = document); var doc = container.ownerDocument || container; if (id && exports.hasCssString(id, container)) return null; id && (cssText += "\n/*# sourceURL=ace/css/" + id + " */"); @@ -3395,15 +3395,13 @@ var stringBefore = token && /string|escape/.test(token.type), stringAfter = !rightToken || /string|escape/.test(rightToken.type); if (rightChar == quote) (pair = stringBefore !== stringAfter) && /string\.end/.test(rightToken.type) && (pair = !1); else { - if (stringBefore && !stringAfter) return null; - if (stringBefore && stringAfter) return null; + if (stringBefore && !stringAfter || stringBefore && stringAfter) return null; var wordRe = session.$mode.tokenRe; wordRe.lastIndex = 0; var isWordBefore = wordRe.test(leftChar); wordRe.lastIndex = 0; var isWordAfter = wordRe.test(leftChar); - if (isWordBefore || isWordAfter) return null; - if (rightChar && !/[\s;,.})\]\\]/.test(rightChar)) return null; + if (isWordBefore || isWordAfter || rightChar && !/[\s;,.})\]\\]/.test(rightChar)) return null; var charBefore = line[cursor.column - 2]; if (leftChar == quote && (charBefore == quote || wordRe.test(charBefore))) return null; pair = !0; @@ -5161,8 +5159,7 @@ for(var folds = foldLine.folds, i = 0; i < folds.length; i++){ var range = folds[i].range; if (range.contains(row, column)) { - if (1 == side && range.isEnd(row, column) && !range.isEmpty()) continue; - if (-1 == side && range.isStart(row, column) && !range.isEmpty()) continue; + if (1 == side && range.isEnd(row, column) && !range.isEmpty() || -1 == side && range.isStart(row, column) && !range.isEmpty()) continue; return folds[i]; } } @@ -6654,9 +6651,7 @@ for(var i = command.length; i--;)if (this.exec(command[i], editor, args)) return !0; return !1; } - if ("string" == typeof command && (command = this.commands[command]), !command) return !1; - if (editor && editor.$readOnly && !command.readOnly) return !1; - if (!1 != this.$checkCommandState && command.isAvailable && !command.isAvailable(editor)) return !1; + if ("string" == typeof command && (command = this.commands[command]), !command || editor && editor.$readOnly && !command.readOnly || !1 != this.$checkCommandState && command.isAvailable && !command.isAvailable(editor)) return !1; var e = { editor: editor, command: command, @@ -8472,8 +8467,7 @@ for(var first = (rows = this.$getSelectedRows(ranges[i])).first, last = rows.last; ++i < l;){ totalDiff && ranges[i].moveBy(totalDiff, 0); var subRows = this.$getSelectedRows(ranges[i]); - if (copy && subRows.first != last) break; - if (!copy && subRows.first > last + 1) break; + if (copy && subRows.first != last || !copy && subRows.first > last + 1) break; last = subRows.last; } for(i--, diff = this.session.$moveLines(first, last, copy ? 0 : dir), copy && -1 == dir && (rangeIndex = i + 1); rangeIndex <= i;)ranges[rangeIndex].moveBy(diff, 0), rangeIndex++; @@ -9262,8 +9256,7 @@ if (this.config = config, this.$updateCursorRow(), this.$lines.pageChanged(oldConfig, config)) return this.update(config); this.$lines.moveContainer(config); var lastRow = Math.min(config.lastRow + config.gutterOffset, this.session.getLength() - 1), oldLastRow = this.oldLastRow; - if (this.oldLastRow = lastRow, !oldConfig || oldLastRow < config.firstRow) return this.update(config); - if (lastRow < oldConfig.firstRow) return this.update(config); + if (this.oldLastRow = lastRow, !oldConfig || oldLastRow < config.firstRow || lastRow < oldConfig.firstRow) return this.update(config); if (oldConfig.firstRow < config.firstRow) for(var row = this.session.getFoldedRowCount(oldConfig.firstRow, config.firstRow - 1); row > 0; row--)this.$lines.shift(); if (oldLastRow > lastRow) for(var row = this.session.getFoldedRowCount(lastRow + 1, oldLastRow); row > 0; row--)this.$lines.pop(); config.firstRow < oldConfig.firstRow && this.$lines.unshift(this.$renderLines(config, config.firstRow, oldConfig.firstRow - 1)), lastRow > oldLastRow && this.$lines.push(this.$renderLines(config, oldLastRow + 1, lastRow)), this.updateLineHighlight(), this._signal("afterRender"), this.$updateGutterWidth(config); @@ -9484,10 +9477,7 @@ if (this.config = config, this.$lines.pageChanged(oldConfig, config)) return this.update(config); this.$lines.moveContainer(config); var lastRow = config.lastRow, oldLastRow = oldConfig ? oldConfig.lastRow : -1; - if (!oldConfig || oldLastRow < config.firstRow) return this.update(config); - if (lastRow < oldConfig.firstRow) return this.update(config); - if (!oldConfig || oldConfig.lastRow < config.firstRow) return this.update(config); - if (config.lastRow < oldConfig.firstRow) return this.update(config); + if (!oldConfig || oldLastRow < config.firstRow || lastRow < oldConfig.firstRow || !oldConfig || oldConfig.lastRow < config.firstRow || config.lastRow < oldConfig.firstRow) return this.update(config); if (oldConfig.firstRow < config.firstRow) for(var row = this.session.getFoldedRowCount(oldConfig.firstRow, config.firstRow - 1); row > 0; row--)this.$lines.shift(); if (oldConfig.lastRow > config.lastRow) for(var row = this.session.getFoldedRowCount(config.lastRow + 1, oldConfig.lastRow); row > 0; row--)this.$lines.pop(); config.firstRow < oldConfig.firstRow && this.$lines.unshift(this.$renderLinesFragment(config, config.firstRow, oldConfig.firstRow - 1)), config.lastRow > oldConfig.lastRow && this.$lines.push(this.$renderLinesFragment(config, oldConfig.lastRow + 1, config.lastRow)); @@ -10817,7 +10807,7 @@ margin: 0 10px;\ }, this.scrollBy = function(deltaX, deltaY) { deltaY && this.session.setScrollTop(this.session.getScrollTop() + deltaY), deltaX && this.session.setScrollLeft(this.session.getScrollLeft() + deltaX); }, this.isScrollableBy = function(deltaX, deltaY) { - return !!(deltaY < 0 && this.session.getScrollTop() >= 1 - this.scrollMargin.top) || !!(deltaY > 0 && this.session.getScrollTop() + this.$size.scrollerHeight - this.layerConfig.maxHeight < -1 + this.scrollMargin.bottom) || !!(deltaX < 0 && this.session.getScrollLeft() >= 1 - this.scrollMargin.left) || !!(deltaX > 0 && this.session.getScrollLeft() + this.$size.scrollerWidth - this.layerConfig.width < -1 + this.scrollMargin.right) || void 0; + if (deltaY < 0 && this.session.getScrollTop() >= 1 - this.scrollMargin.top || deltaY > 0 && this.session.getScrollTop() + this.$size.scrollerHeight - this.layerConfig.maxHeight < -1 + this.scrollMargin.bottom || deltaX < 0 && this.session.getScrollLeft() >= 1 - this.scrollMargin.left || deltaX > 0 && this.session.getScrollLeft() + this.$size.scrollerWidth - this.layerConfig.width < -1 + this.scrollMargin.right) return !0; }, this.pixelToScreenCoordinates = function(x, y) { if (this.$hasCssTransforms) { canvasPos = { @@ -12072,7 +12062,7 @@ background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZg (function() { this.getRowLength = function(row) { var h; - return (h = this.lineWidgets ? this.lineWidgets[row] && this.lineWidgets[row].rowCount || 0 : 0, this.$useWrapMode && this.$wrapData[row]) ? this.$wrapData[row].length + 1 + h : 1 + h; + return (h = this.lineWidgets && this.lineWidgets[row] && this.lineWidgets[row].rowCount || 0, this.$useWrapMode && this.$wrapData[row]) ? this.$wrapData[row].length + 1 + h : 1 + h; }, this.$getWidgetScreenLength = function() { var screenRows = 0; return this.lineWidgets.forEach(function(w) { diff --git a/crates/swc_ecma_minifier/tests/fixture/next/regression-1/framework-798bab57daac3897/output.js b/crates/swc_ecma_minifier/tests/fixture/next/regression-1/framework-798bab57daac3897/output.js index d80e5f9f11ee..e10674a5df1d 100644 --- a/crates/swc_ecma_minifier/tests/fixture/next/regression-1/framework-798bab57daac3897/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/next/regression-1/framework-798bab57daac3897/output.js @@ -3930,8 +3930,7 @@ a = a.return; } for(a.sibling.return = a.return, a = a.sibling; 5 !== a.tag && 6 !== a.tag && 18 !== a.tag;){ - if (2 & a.flags) continue a; - if (null === a.child || 4 === a.tag) continue a; + if (2 & a.flags || null === a.child || 4 === a.tag) continue a; a.child.return = a, a = a.child; } if (!(2 & a.flags)) return a.stateNode; diff --git a/crates/swc_ecma_minifier/tests/fixture/projects/next/archive-3/pages/dynamic/no-chunk-e2d9573b8d7df68a6cde/output.js b/crates/swc_ecma_minifier/tests/fixture/projects/next/archive-3/pages/dynamic/no-chunk-e2d9573b8d7df68a6cde/output.js index 42ad134dd069..5eea7240561a 100644 --- a/crates/swc_ecma_minifier/tests/fixture/projects/next/archive-3/pages/dynamic/no-chunk-e2d9573b8d7df68a6cde/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/projects/next/archive-3/pages/dynamic/no-chunk-e2d9573b8d7df68a6cde/output.js @@ -438,8 +438,7 @@ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4512), _Users_timneutkens_projects_next_js_node_modules_babel_runtime_helpers_esm_classCallCheck__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(8436), _Users_timneutkens_projects_next_js_node_modules_babel_runtime_helpers_esm_createClass__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(8370), _Users_timneutkens_projects_next_js_node_modules_babel_runtime_helpers_esm_assertThisInitialized__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(2911), _Users_timneutkens_projects_next_js_node_modules_babel_runtime_helpers_esm_inherits__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(3001), _Users_timneutkens_projects_next_js_node_modules_babel_runtime_helpers_esm_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7130), _Users_timneutkens_projects_next_js_node_modules_babel_runtime_helpers_esm_getPrototypeOf__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2374), _Users_timneutkens_projects_next_js_node_modules_babel_runtime_helpers_esm_defineProperty__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(9178), Welcome1 = function(_React$Component) { (0, _Users_timneutkens_projects_next_js_node_modules_babel_runtime_helpers_esm_inherits__WEBPACK_IMPORTED_MODULE_4__.Z)(Welcome, _React$Component); var Derived, hasNativeReflectConstruct, _super = (Derived = Welcome, hasNativeReflectConstruct = function() { - if ("undefined" == typeof Reflect || !Reflect.construct) return !1; - if (Reflect.construct.sham) return !1; + if ("undefined" == typeof Reflect || !Reflect.construct || Reflect.construct.sham) return !1; if ("function" == typeof Proxy) return !0; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function() {})), !0; diff --git a/crates/swc_ecma_minifier/tests/full/feedback-mapbox/2c796e83-0724e2af5f19128a/output.js b/crates/swc_ecma_minifier/tests/full/feedback-mapbox/2c796e83-0724e2af5f19128a/output.js index 0bb0a564aa9d..790bf22f409e 100644 --- a/crates/swc_ecma_minifier/tests/full/feedback-mapbox/2c796e83-0724e2af5f19128a/output.js +++ b/crates/swc_ecma_minifier/tests/full/feedback-mapbox/2c796e83-0724e2af5f19128a/output.js @@ -1,11 +1,11 @@ -(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[634],{6158:function(b,c,a){var d=a(3454);!function(c,a){b.exports=a()}(this,function(){"use strict";var c,e,b;function a(g,a){if(c){if(e){var f="self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; ("+c+")(sharedChunk); ("+e+")(sharedChunk); self.onerror = null;",d={};c(d),b=a(d),"undefined"!=typeof window&&window&&window.URL&&window.URL.createObjectURL&&(b.workerUrl=window.URL.createObjectURL(new Blob([f],{type:"text/javascript"})))}else e=a}else c=a}return a(["exports"],function(a){var bq="2.7.0",eG=H;function H(a,c,d,b){this.cx=3*a,this.bx=3*(d-a)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*c,this.by=3*(b-c)-this.cy,this.ay=1-this.cy-this.by,this.p1x=a,this.p1y=b,this.p2x=d,this.p2y=b}H.prototype.sampleCurveX=function(a){return((this.ax*a+this.bx)*a+this.cx)*a},H.prototype.sampleCurveY=function(a){return((this.ay*a+this.by)*a+this.cy)*a},H.prototype.sampleCurveDerivativeX=function(a){return(3*this.ax*a+2*this.bx)*a+this.cx},H.prototype.solveCurveX=function(c,e){var b,d,a,f,g;for(void 0===e&&(e=1e-6),a=c,g=0;g<8;g++){if(Math.abs(f=this.sampleCurveX(a)-c)Math.abs(h))break;a-=f/h}if((a=c)<(b=0))return b;if(a>(d=1))return d;for(;bf?b=a:d=a,a=.5*(d-b)+b;return a},H.prototype.solve=function(a,b){return this.sampleCurveY(this.solveCurveX(a,b))};var aF=aG;function aG(a,b){this.x=a,this.y=b}aG.prototype={clone:function(){return new aG(this.x,this.y)},add:function(a){return this.clone()._add(a)},sub:function(a){return this.clone()._sub(a)},multByPoint:function(a){return this.clone()._multByPoint(a)},divByPoint:function(a){return this.clone()._divByPoint(a)},mult:function(a){return this.clone()._mult(a)},div:function(a){return this.clone()._div(a)},rotate:function(a){return this.clone()._rotate(a)},rotateAround:function(a,b){return this.clone()._rotateAround(a,b)},matMult:function(a){return this.clone()._matMult(a)},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(a){return this.x===a.x&&this.y===a.y},dist:function(a){return Math.sqrt(this.distSqr(a))},distSqr:function(a){var b=a.x-this.x,c=a.y-this.y;return b*b+c*c},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(a){return Math.atan2(this.y-a.y,this.x-a.x)},angleWith:function(a){return this.angleWithSep(a.x,a.y)},angleWithSep:function(a,b){return Math.atan2(this.x*b-this.y*a,this.x*a+this.y*b)},_matMult:function(a){var b=a[2]*this.x+a[3]*this.y;return this.x=a[0]*this.x+a[1]*this.y,this.y=b,this},_add:function(a){return this.x+=a.x,this.y+=a.y,this},_sub:function(a){return this.x-=a.x,this.y-=a.y,this},_mult:function(a){return this.x*=a,this.y*=a,this},_div:function(a){return this.x/=a,this.y/=a,this},_multByPoint:function(a){return this.x*=a.x,this.y*=a.y,this},_divByPoint:function(a){return this.x/=a.x,this.y/=a.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var a=this.y;return this.y=this.x,this.x=-a,this},_rotate:function(a){var b=Math.cos(a),c=Math.sin(a),d=c*this.x+b*this.y;return this.x=b*this.x-c*this.y,this.y=d,this},_rotateAround:function(b,a){var c=Math.cos(b),d=Math.sin(b),e=a.y+d*(this.x-a.x)+c*(this.y-a.y);return this.x=a.x+c*(this.x-a.x)-d*(this.y-a.y),this.y=e,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},aG.convert=function(a){return a instanceof aG?a:Array.isArray(a)?new aG(a[0],a[1]):a};var s="undefined"!=typeof self?self:{},I="undefined"!=typeof Float32Array?Float32Array:Array;function aH(){var a=new I(9);return I!=Float32Array&&(a[1]=0,a[2]=0,a[3]=0,a[5]=0,a[6]=0,a[7]=0),a[0]=1,a[4]=1,a[8]=1,a}function aI(a){return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=1,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a}function aJ(a,b,c){var h=b[0],i=b[1],j=b[2],k=b[3],l=b[4],m=b[5],n=b[6],o=b[7],p=b[8],q=b[9],r=b[10],s=b[11],t=b[12],u=b[13],v=b[14],w=b[15],d=c[0],e=c[1],f=c[2],g=c[3];return a[0]=d*h+e*l+f*p+g*t,a[1]=d*i+e*m+f*q+g*u,a[2]=d*j+e*n+f*r+g*v,a[3]=d*k+e*o+f*s+g*w,a[4]=(d=c[4])*h+(e=c[5])*l+(f=c[6])*p+(g=c[7])*t,a[5]=d*i+e*m+f*q+g*u,a[6]=d*j+e*n+f*r+g*v,a[7]=d*k+e*o+f*s+g*w,a[8]=(d=c[8])*h+(e=c[9])*l+(f=c[10])*p+(g=c[11])*t,a[9]=d*i+e*m+f*q+g*u,a[10]=d*j+e*n+f*r+g*v,a[11]=d*k+e*o+f*s+g*w,a[12]=(d=c[12])*h+(e=c[13])*l+(f=c[14])*p+(g=c[15])*t,a[13]=d*i+e*m+f*q+g*u,a[14]=d*j+e*n+f*r+g*v,a[15]=d*k+e*o+f*s+g*w,a}function br(b,a,f){var r,g,h,i,j,k,l,m,n,o,p,q,c=f[0],d=f[1],e=f[2];return a===b?(b[12]=a[0]*c+a[4]*d+a[8]*e+a[12],b[13]=a[1]*c+a[5]*d+a[9]*e+a[13],b[14]=a[2]*c+a[6]*d+a[10]*e+a[14],b[15]=a[3]*c+a[7]*d+a[11]*e+a[15]):(g=a[1],h=a[2],i=a[3],j=a[4],k=a[5],l=a[6],m=a[7],n=a[8],o=a[9],p=a[10],q=a[11],b[0]=r=a[0],b[1]=g,b[2]=h,b[3]=i,b[4]=j,b[5]=k,b[6]=l,b[7]=m,b[8]=n,b[9]=o,b[10]=p,b[11]=q,b[12]=r*c+j*d+n*e+a[12],b[13]=g*c+k*d+o*e+a[13],b[14]=h*c+l*d+p*e+a[14],b[15]=i*c+m*d+q*e+a[15]),b}function bs(a,b,f){var c=f[0],d=f[1],e=f[2];return a[0]=b[0]*c,a[1]=b[1]*c,a[2]=b[2]*c,a[3]=b[3]*c,a[4]=b[4]*d,a[5]=b[5]*d,a[6]=b[6]*d,a[7]=b[7]*d,a[8]=b[8]*e,a[9]=b[9]*e,a[10]=b[10]*e,a[11]=b[11]*e,a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15],a}function bt(a,b,e){var c=Math.sin(e),d=Math.cos(e),f=b[4],g=b[5],h=b[6],i=b[7],j=b[8],k=b[9],l=b[10],m=b[11];return b!==a&&(a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]),a[4]=f*d+j*c,a[5]=g*d+k*c,a[6]=h*d+l*c,a[7]=i*d+m*c,a[8]=j*d-f*c,a[9]=k*d-g*c,a[10]=l*d-h*c,a[11]=m*d-i*c,a}function bu(a,b,e){var c=Math.sin(e),d=Math.cos(e),f=b[0],g=b[1],h=b[2],i=b[3],j=b[8],k=b[9],l=b[10],m=b[11];return b!==a&&(a[4]=b[4],a[5]=b[5],a[6]=b[6],a[7]=b[7],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]),a[0]=f*d-j*c,a[1]=g*d-k*c,a[2]=h*d-l*c,a[3]=i*d-m*c,a[8]=f*c+j*d,a[9]=g*c+k*d,a[10]=h*c+l*d,a[11]=i*c+m*d,a}Math.hypot||(Math.hypot=function(){for(var b=0,a=arguments.length;a--;)b+=arguments[a]*arguments[a];return Math.sqrt(b)});var bv=aJ;function aK(){var a=new I(3);return I!=Float32Array&&(a[0]=0,a[1]=0,a[2]=0),a}function eH(b){var a=new I(3);return a[0]=b[0],a[1]=b[1],a[2]=b[2],a}function aL(a){return Math.hypot(a[0],a[1],a[2])}function Q(b,c,d){var a=new I(3);return a[0]=b,a[1]=c,a[2]=d,a}function bw(a,b,c){return a[0]=b[0]+c[0],a[1]=b[1]+c[1],a[2]=b[2]+c[2],a}function aM(a,b,c){return a[0]=b[0]-c[0],a[1]=b[1]-c[1],a[2]=b[2]-c[2],a}function aN(a,b,c){return a[0]=b[0]*c[0],a[1]=b[1]*c[1],a[2]=b[2]*c[2],a}function eI(a,b,c){return a[0]=Math.max(b[0],c[0]),a[1]=Math.max(b[1],c[1]),a[2]=Math.max(b[2],c[2]),a}function bx(a,b,c){return a[0]=b[0]*c,a[1]=b[1]*c,a[2]=b[2]*c,a}function by(a,b,c,d){return a[0]=b[0]+c[0]*d,a[1]=b[1]+c[1]*d,a[2]=b[2]+c[2]*d,a}function bz(c,a){var d=a[0],e=a[1],f=a[2],b=d*d+e*e+f*f;return b>0&&(b=1/Math.sqrt(b)),c[0]=a[0]*b,c[1]=a[1]*b,c[2]=a[2]*b,c}function bA(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]}function bB(a,b,c){var d=b[0],e=b[1],f=b[2],g=c[0],h=c[1],i=c[2];return a[0]=e*i-f*h,a[1]=f*g-d*i,a[2]=d*h-e*g,a}function bC(b,g,a){var c=g[0],d=g[1],e=g[2],f=a[3]*c+a[7]*d+a[11]*e+a[15];return b[0]=(a[0]*c+a[4]*d+a[8]*e+a[12])/(f=f||1),b[1]=(a[1]*c+a[5]*d+a[9]*e+a[13])/f,b[2]=(a[2]*c+a[6]*d+a[10]*e+a[14])/f,b}function bD(a,h,b){var c=b[0],d=b[1],e=b[2],i=h[0],j=h[1],k=h[2],l=d*k-e*j,f=e*i-c*k,g=c*j-d*i,p=d*g-e*f,n=e*l-c*g,o=c*f-d*l,m=2*b[3];return f*=m,g*=m,n*=2,o*=2,a[0]=i+(l*=m)+(p*=2),a[1]=j+f+n,a[2]=k+g+o,a}var J,bE=aM;function bF(b,c,a){var d=c[0],e=c[1],f=c[2],g=c[3];return b[0]=a[0]*d+a[4]*e+a[8]*f+a[12]*g,b[1]=a[1]*d+a[5]*e+a[9]*f+a[13]*g,b[2]=a[2]*d+a[6]*e+a[10]*f+a[14]*g,b[3]=a[3]*d+a[7]*e+a[11]*f+a[15]*g,b}function aO(){var a=new I(4);return I!=Float32Array&&(a[0]=0,a[1]=0,a[2]=0),a[3]=1,a}function bG(a){return a[0]=0,a[1]=0,a[2]=0,a[3]=1,a}function bH(a,b,e){e*=.5;var f=b[0],g=b[1],h=b[2],i=b[3],c=Math.sin(e),d=Math.cos(e);return a[0]=f*d+i*c,a[1]=g*d+h*c,a[2]=h*d-g*c,a[3]=i*d-f*c,a}function eJ(a,b){return a[0]===b[0]&&a[1]===b[1]}aK(),J=new I(4),I!=Float32Array&&(J[0]=0,J[1]=0,J[2]=0,J[3]=0),aK(),Q(1,0,0),Q(0,1,0),aO(),aO(),aH(),ls=new I(2),I!=Float32Array&&(ls[0]=0,ls[1]=0);const aP=Math.PI/180,eK=180/Math.PI;function bI(a){return a*aP}function bJ(a){return a*eK}const eL=[[0,0],[1,0],[1,1],[0,1],];function bK(a){if(a<=0)return 0;if(a>=1)return 1;const b=a*a,c=b*a;return 4*(a<.5?c:3*(a-b)+c-.75)}function aQ(a,b,c,d){const e=new eG(a,b,c,d);return function(a){return e.solve(a)}}const bL=aQ(.25,.1,.25,1);function bM(a,b,c){return Math.min(c,Math.max(b,a))}function bN(b,c,a){return(a=bM((a-b)/(c-b),0,1))*a*(3-2*a)}function bO(e,a,c){const b=c-a,d=((e-a)%b+b)%b+a;return d===a?c:d}function bP(a,c,b){if(!a.length)return b(null,[]);let d=a.length;const e=new Array(a.length);let f=null;a.forEach((a,g)=>{c(a,(a,c)=>{a&&(f=a),e[g]=c,0== --d&&b(f,e)})})}function bQ(a){const b=[];for(const c in a)b.push(a[c]);return b}function bR(a,...d){for(const b of d)for(const c in b)a[c]=b[c];return a}let eM=1;function bS(){return eM++}function eN(){return function b(a){return a?(a^16*Math.random()>>a/4).toString(16):([1e7]+ -[1e3]+ -4e3+ -8e3+ -1e11).replace(/[018]/g,b)}()}function bT(a){return a<=1?1:Math.pow(2,Math.ceil(Math.log(a)/Math.LN2))}function eO(a){return!!a&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(a)}function bU(a,b){a.forEach(a=>{b[a]&&(b[a]=b[a].bind(b))})}function bV(a,b){return -1!==a.indexOf(b,a.length-b.length)}function eP(a,d,e){const c={};for(const b in a)c[b]=d.call(e||this,a[b],b,a);return c}function bW(a,d,e){const c={};for(const b in a)d.call(e||this,a[b],b,a)&&(c[b]=a[b]);return c}function bX(a){return Array.isArray(a)?a.map(bX):"object"==typeof a&&a?eP(a,bX):a}const eQ={};function bY(a){eQ[a]||("undefined"!=typeof console&&console.warn(a),eQ[a]=!0)}function eR(a,b,c){return(c.y-a.y)*(b.x-a.x)>(b.y-a.y)*(c.x-a.x)}function eS(a){let e=0;for(let b,c,d=0,f=a.length,g=f-1;d@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(f,c,d,e)=>{const b=d||e;return a[c]=!b||b.toLowerCase(),""}),a["max-age"]){const b=parseInt(a["max-age"],10);isNaN(b)?delete a["max-age"]:a["max-age"]=b}return a}let eU,af,eV,eW=null;function eX(b){if(null==eW){const a=b.navigator?b.navigator.userAgent:null;eW=!!b.safari||!(!a||!(/\b(iPad|iPhone|iPod)\b/.test(a)||a.match("Safari")&&!a.match("Chrome")))}return eW}function eY(b){try{const a=s[b];return a.setItem("_mapbox_test_",1),a.removeItem("_mapbox_test_"),!0}catch(c){return!1}}const b$={now:()=>void 0!==eV?eV:s.performance.now(),setNow(a){eV=a},restoreNow(){eV=void 0},frame(a){const b=s.requestAnimationFrame(a);return{cancel:()=>s.cancelAnimationFrame(b)}},getImageData(a,b=0){const c=s.document.createElement("canvas"),d=c.getContext("2d");if(!d)throw new Error("failed to create canvas 2d context");return c.width=a.width,c.height=a.height,d.drawImage(a,0,0,a.width,a.height),d.getImageData(-b,-b,a.width+2*b,a.height+2*b)},resolveURL:a=>(eU||(eU=s.document.createElement("a")),eU.href=a,eU.href),get devicePixelRatio(){return s.devicePixelRatio},get prefersReducedMotion(){return!!s.matchMedia&&(null==af&&(af=s.matchMedia("(prefers-reduced-motion: reduce)")),af.matches)}};let R;const b_={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(null==R){const aR=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{R=null!=d.env.API_URL_REGEX?new RegExp(d.env.API_URL_REGEX):aR}catch(eZ){R=aR}}return R},get EVENTS_URL(){return this.API_URL?0===this.API_URL.indexOf("https://api.mapbox.cn")?"https://events.mapbox.cn/events/v2":0===this.API_URL.indexOf("https://api.mapbox.com")?"https://events.mapbox.com/events/v2":null: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,MAX_PARALLEL_IMAGE_REQUESTS:16},b0={supported:!1,testSupport:function(a){!e_&&ag&&(e0?e1(a):e$=a)}};let e$,ag,e_=!1,e0=!1;function e1(a){const b=a.createTexture();a.bindTexture(a.TEXTURE_2D,b);try{if(a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,ag),a.isContextLost())return;b0.supported=!0}catch(c){}a.deleteTexture(b),e_=!0}s.document&&((ag=s.document.createElement("img")).onload=function(){e$&&e1(e$),e$=null,e0=!0},ag.onerror=function(){e_=!0,e$=null},ag.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const b1="NO_ACCESS_TOKEN";function b2(a){return 0===a.indexOf("mapbox:")}function e2(a){return b_.API_URL_REGEX.test(a)}const e3=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function e4(b){const a=b.match(e3);if(!a)throw new Error("Unable to parse URL object");return{protocol:a[1],authority:a[2],path:a[3]||"/",params:a[4]?a[4].split("&"):[]}}function e5(a){const b=a.params.length?`?${a.params.join("&")}`:"";return`${a.protocol}://${a.authority}${a.path}${b}`}function e6(b){if(!b)return null;const a=b.split(".");if(!a||3!==a.length)return null;try{return JSON.parse(decodeURIComponent(s.atob(a[1]).split("").map(a=>"%"+("00"+a.charCodeAt(0).toString(16)).slice(-2)).join("")))}catch(c){return null}}class e7{constructor(a){this.type=a,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(c){const a=e6(b_.ACCESS_TOKEN);let b="";return b=a&&a.u?s.btoa(encodeURIComponent(a.u).replace(/%([0-9A-F]{2})/g,(b,a)=>String.fromCharCode(Number("0x"+a)))):b_.ACCESS_TOKEN||"",c?`mapbox.eventData.${c}:${b}`:`mapbox.eventData:${b}`}fetchEventData(){const c=eY("localStorage"),d=this.getStorageKey(),e=this.getStorageKey("uuid");if(c)try{const a=s.localStorage.getItem(d);a&&(this.eventData=JSON.parse(a));const b=s.localStorage.getItem(e);b&&(this.anonId=b)}catch(f){bY("Unable to read from LocalStorage")}}saveEventData(){const a=eY("localStorage"),b=this.getStorageKey(),c=this.getStorageKey("uuid");if(a)try{s.localStorage.setItem(c,this.anonId),Object.keys(this.eventData).length>=1&&s.localStorage.setItem(b,JSON.stringify(this.eventData))}catch(d){bY("Unable to write to LocalStorage")}}processRequests(a){}postEvent(d,a,h,e){if(!b_.EVENTS_URL)return;const b=e4(b_.EVENTS_URL);b.params.push(`access_token=${e||b_.ACCESS_TOKEN||""}`);const c={event:this.type,created:new Date(d).toISOString(),sdkIdentifier:"mapbox-gl-js",sdkVersion:bq,skuId:"01",userId:this.anonId},f=a?bR(c,a):c,g={url:e5(b),headers:{"Content-Type":"text/plain"},body:JSON.stringify([f])};this.pendingRequest=fj(g,a=>{this.pendingRequest=null,h(a),this.saveEventData(),this.processRequests(e)})}queueRequest(a,b){this.queue.push(a),this.processRequests(b)}}const aS=new class extends e7{constructor(a){super("appUserTurnstile"),this._customAccessToken=a}postTurnstileEvent(a,b){b_.EVENTS_URL&&b_.ACCESS_TOKEN&&Array.isArray(a)&&a.some(a=>b2(a)||e2(a))&&this.queueRequest(Date.now(),b)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const c=e6(b_.ACCESS_TOKEN),f=c?c.u:b_.ACCESS_TOKEN;let a=f!==this.eventData.tokenU;eO(this.anonId)||(this.anonId=eN(),a=!0);const b=this.queue.shift();if(this.eventData.lastSuccess){const g=new Date(this.eventData.lastSuccess),h=new Date(b),d=(b-this.eventData.lastSuccess)/864e5;a=a||d>=1||d< -1||g.getDate()!==h.getDate()}else a=!0;if(!a)return this.processRequests();this.postEvent(b,{"enabled.telemetry":!1},a=>{a||(this.eventData.lastSuccess=b,this.eventData.tokenU=f)},e)}},b3=aS.postTurnstileEvent.bind(aS),aT=new class extends e7{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(b,c,a,d){this.skuToken=c,this.errorCb=d,b_.EVENTS_URL&&(a||b_.ACCESS_TOKEN?this.queueRequest({id:b,timestamp:Date.now()},a):this.errorCb(new Error(b1)))}processRequests(b){if(this.pendingRequest||0===this.queue.length)return;const{id:a,timestamp:c}=this.queue.shift();a&&this.success[a]||(this.anonId||this.fetchEventData(),eO(this.anonId)||(this.anonId=eN()),this.postEvent(c,{skuToken:this.skuToken},b=>{b?this.errorCb(b):a&&(this.success[a]=!0)},b))}},b4=aT.postMapLoadEvent.bind(aT),aU=new class extends e7{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(e,b,f,c){if(!b_.API_URL||!b_.SESSION_PATH)return;const a=e4(b_.API_URL+b_.SESSION_PATH);a.params.push(`sku=${b||""}`),a.params.push(`access_token=${c||b_.ACCESS_TOKEN||""}`);const d={url:e5(a),headers:{"Content-Type":"text/plain"}};this.pendingRequest=fk(d,a=>{this.pendingRequest=null,f(a),this.saveEventData(),this.processRequests(c)})}getSessionAPI(b,c,a,d){this.skuToken=c,this.errorCb=d,b_.SESSION_PATH&&b_.API_URL&&(a||b_.ACCESS_TOKEN?this.queueRequest({id:b,timestamp:Date.now()},a):this.errorCb(new Error(b1)))}processRequests(b){if(this.pendingRequest||0===this.queue.length)return;const{id:a,timestamp:c}=this.queue.shift();a&&this.success[a]||this.getSession(c,this.skuToken,b=>{b?this.errorCb(b):a&&(this.success[a]=!0)},b)}},b5=aU.getSessionAPI.bind(aU),e8=new Set,e9="mapbox-tiles";let fa,fb,fc=500,fd=50;function fe(){s.caches&&!fa&&(fa=s.caches.open(e9))}function ff(a){const b=a.indexOf("?");return b<0?a:a.slice(0,b)}let fg=1/0;const aV={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};"function"==typeof Object.freeze&&Object.freeze(aV);class fh extends Error{constructor(a,b,c){401===b&&e2(c)&&(a+=": you may have provided an invalid Mapbox access token. See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes"),super(a),this.status=b,this.url=c}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const b6=bZ()?()=>self.worker&&self.worker.referrer:()=>("blob:"===s.location.protocol?s.parent:s).location.href,b7=function(a,b){var c;if(!(/^file:/.test(c=a.url)||/^file:/.test(b6())&&!/^\w+:/.test(c))){if(s.fetch&&s.Request&&s.AbortController&&s.Request.prototype.hasOwnProperty("signal"))return function(a,g){var c;const e=new s.AbortController,b=new s.Request(a.url,{method:a.method||"GET",body:a.body,credentials:a.credentials,headers:a.headers,referrer:b6(),signal:e.signal});let h=!1,i=!1;const f=(c=b.url).indexOf("sku=")>0&&e2(c);"json"===a.type&&b.headers.set("Accept","application/json");const d=(c,d,e)=>{if(i)return;if(c&&"SecurityError"!==c.message&&bY(c),d&&e)return j(d);const h=Date.now();s.fetch(b).then(b=>{if(b.ok){const c=f?b.clone():null;return j(b,c,h)}return g(new fh(b.statusText,b.status,a.url))}).catch(a=>{20!==a.code&&g(new Error(a.message))})},j=(c,d,e)=>{("arrayBuffer"===a.type?c.arrayBuffer():"json"===a.type?c.json():c.text()).then(a=>{i||(d&&e&&function(e,a,c){if(fe(),!fa)return;const d={status:a.status,statusText:a.statusText,headers:new s.Headers};a.headers.forEach((a,b)=>d.headers.set(b,a));const b=eT(a.headers.get("Cache-Control")||"");b["no-store"]||(b["max-age"]&&d.headers.set("Expires",new Date(c+1e3*b["max-age"]).toUTCString()),new Date(d.headers.get("Expires")).getTime()-c<42e4||function(a,b){if(void 0===fb)try{new Response(new ReadableStream),fb=!0}catch(c){fb=!1}fb?b(a.body):a.blob().then(b)}(a,a=>{const b=new s.Response(a,d);fe(),fa&&fa.then(a=>a.put(ff(e.url),b)).catch(a=>bY(a.message))}))}(b,d,e),h=!0,g(null,a,c.headers.get("Cache-Control"),c.headers.get("Expires")))}).catch(a=>{i||g(new Error(a.message))})};return f?function(b,a){if(fe(),!fa)return a(null);const c=ff(b.url);fa.then(b=>{b.match(c).then(d=>{const e=function(a){if(!a)return!1;const b=new Date(a.headers.get("Expires")||0),c=eT(a.headers.get("Cache-Control")||"");return b>Date.now()&&!c["no-cache"]}(d);b.delete(c),e&&b.put(c,d.clone()),a(null,d,e)}).catch(a)}).catch(a)}(b,d):d(null,null),{cancel(){i=!0,h||e.abort()}}}(a,b);if(bZ()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",a,b,void 0,!0)}return function(b,d){const a=new s.XMLHttpRequest;for(const c in a.open(b.method||"GET",b.url,!0),"arrayBuffer"===b.type&&(a.responseType="arraybuffer"),b.headers)a.setRequestHeader(c,b.headers[c]);return"json"===b.type&&(a.responseType="text",a.setRequestHeader("Accept","application/json")),a.withCredentials="include"===b.credentials,a.onerror=()=>{d(new Error(a.statusText))},a.onload=()=>{if((a.status>=200&&a.status<300||0===a.status)&&null!==a.response){let c=a.response;if("json"===b.type)try{c=JSON.parse(a.response)}catch(e){return d(e)}d(null,c,a.getResponseHeader("Cache-Control"),a.getResponseHeader("Expires"))}else d(new fh(a.statusText,a.status,b.url))},a.send(b.body),{cancel:()=>a.abort()}}(a,b)},fi=function(a,b){return b7(bR(a,{type:"arrayBuffer"}),b)},fj=function(a,b){return b7(bR(a,{method:"POST"}),b)},fk=function(a,b){return b7(bR(a,{method:"GET"}),b)};function fl(b){const a=s.document.createElement("a");return a.href=b,a.protocol===s.document.location.protocol&&a.host===s.document.location.host}const fm="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let b8,b9;b8=[],b9=0;const ca=function(a,c){if(b0.supported&&(a.headers||(a.headers={}),a.headers.accept="image/webp,*/*"),b9>=b_.MAX_PARALLEL_IMAGE_REQUESTS){const b={requestParameters:a,callback:c,cancelled:!1,cancel(){this.cancelled=!0}};return b8.push(b),b}b9++;let d=!1;const e=()=>{if(!d)for(d=!0,b9--;b8.length&&b9{e(),b?c(b):a&&(s.createImageBitmap?function(a,c){const b=new s.Blob([new Uint8Array(a)],{type:"image/png"});s.createImageBitmap(b).then(a=>{c(null,a)}).catch(a=>{c(new Error(`Could not load image because of ${a.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(a,(a,b)=>c(a,b,d,f)):function(b,e){const a=new s.Image,c=s.URL;a.onload=()=>{e(null,a),c.revokeObjectURL(a.src),a.onload=null,s.requestAnimationFrame(()=>{a.src=fm})},a.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 d=new s.Blob([new Uint8Array(b)],{type:"image/png"});a.src=b.byteLength?c.createObjectURL(d):fm}(a,(a,b)=>c(a,b,d,f)))});return{cancel(){f.cancel(),e()}}};function fn(a,c,b){b[a]&& -1!==b[a].indexOf(c)||(b[a]=b[a]||[],b[a].push(c))}function fo(b,d,a){if(a&&a[b]){const c=a[b].indexOf(d);-1!==c&&a[b].splice(c,1)}}class aW{constructor(a,b={}){bR(this,b),this.type=a}}class cb extends aW{constructor(a,b={}){super("error",bR({error:a},b))}}class S{on(a,b){return this._listeners=this._listeners||{},fn(a,b,this._listeners),this}off(a,b){return fo(a,b,this._listeners),fo(a,b,this._oneTimeListeners),this}once(b,a){return a?(this._oneTimeListeners=this._oneTimeListeners||{},fn(b,a,this._oneTimeListeners),this):new Promise(a=>this.once(b,a))}fire(a,e){"string"==typeof a&&(a=new aW(a,e||{}));const b=a.type;if(this.listens(b)){a.target=this;const f=this._listeners&&this._listeners[b]?this._listeners[b].slice():[];for(const g of f)g.call(this,a);const h=this._oneTimeListeners&&this._oneTimeListeners[b]?this._oneTimeListeners[b].slice():[];for(const c of h)fo(b,c,this._oneTimeListeners),c.call(this,a);const d=this._eventedParent;d&&(bR(a,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),d.fire(a))}else a instanceof cb&&console.error(a.error);return this}listens(a){return!!(this._listeners&&this._listeners[a]&&this._listeners[a].length>0||this._oneTimeListeners&&this._oneTimeListeners[a]&&this._oneTimeListeners[a].length>0||this._eventedParent&&this._eventedParent.listens(a))}setEventedParent(a,b){return this._eventedParent=a,this._eventedParentData=b,this}}var b=JSON.parse('{"$version":8,"$root":{"version":{"required":true,"type":"enum","values":[8]},"name":{"type":"string"},"metadata":{"type":"*"},"center":{"type":"array","value":"number"},"zoom":{"type":"number"},"bearing":{"type":"number","default":0,"period":360,"units":"degrees"},"pitch":{"type":"number","default":0,"units":"degrees"},"light":{"type":"light"},"terrain":{"type":"terrain"},"fog":{"type":"fog"},"sources":{"required":true,"type":"sources"},"sprite":{"type":"string"},"glyphs":{"type":"string"},"transition":{"type":"transition"},"projection":{"type":"projection"},"layers":{"required":true,"type":"array","value":"layer"}},"sources":{"*":{"type":"source"}},"source":["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],"source_vector":{"type":{"required":true,"type":"enum","values":{"vector":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"attribution":{"type":"string"},"promoteId":{"type":"promoteId"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster":{"type":{"required":true,"type":"enum","values":{"raster":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"attribution":{"type":"string"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_dem":{"type":{"required":true,"type":"enum","values":{"raster-dem":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"attribution":{"type":"string"},"encoding":{"type":"enum","values":{"terrarium":{},"mapbox":{}},"default":"mapbox"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_geojson":{"type":{"required":true,"type":"enum","values":{"geojson":{}}},"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":{}}},"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":{}}},"url":{"required":true,"type":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"layer":{"id":{"type":"string","required":true},"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"raster":{},"hillshade":{},"background":{},"sky":{}},"required":true},"metadata":{"type":"*"},"source":{"type":"string"},"source-layer":{"type":"string"},"minzoom":{"type":"number","minimum":0,"maximum":24},"maxzoom":{"type":"number","minimum":0,"maximum":24},"filter":{"type":"filter"},"layout":{"type":"layout"},"paint":{"type":"paint"}},"layout":["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background","layout_sky"],"layout_background":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_sky":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_circle":{"circle-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_heatmap":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill-extrusion":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_line":{"line-cap":{"type":"enum","values":{"butt":{},"round":{},"square":{}},"default":"butt","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-join":{"type":"enum","values":{"bevel":{},"round":{},"miter":{}},"default":"miter","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"requires":[{"line-join":"miter"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-round-limit":{"type":"number","default":1.05,"requires":[{"line-join":"round"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_symbol":{"symbol-placement":{"type":"enum","values":{"point":{},"line":{},"line-center":{}},"default":"point","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-spacing":{"type":"number","default":250,"minimum":1,"units":"pixels","requires":[{"symbol-placement":"line"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","values":{"auto":{},"viewport-y":{},"source":{}},"default":"auto","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-optional":{"type":"boolean","default":false,"requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-size":{"type":"number","default":1,"minimum":0,"units":"factor of the original icon size","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{"type":"enum","values":{"none":{},"width":{},"height":{},"both":{}},"default":"none","requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{"type":"array","value":"number","length":4,"default":[0,0,0,0],"units":"pixels","requires":["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-image":{"type":"resolvedImage","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-keep-upright":{"type":"boolean","default":false,"requires":["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-offset":{"type":"array","value":"number","length":2,"default":[0,0],"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-field":{"type":"formatted","default":"","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-font":{"type":"array","value":"string","default":["Open Sans Regular","Arial Unicode MS Regular"],"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size":{"type":"number","default":16,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{"type":"number","default":10,"minimum":0,"units":"ems","requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-justify":{"type":"enum","values":{"auto":{},"left":{},"center":{},"right":{}},"default":"center","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{"type":"number","units":"ems","default":0,"requires":["text-field"],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["zoom","feature"]}},"text-variable-anchor":{"type":"array","value":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["text-field",{"!":"text-variable-anchor"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{"type":"number","default":45,"units":"degrees","requires":["text-field",{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":{},"vertical":{}},"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-keep-upright":{"type":"boolean","default":true,"requires":["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-transform":{"type":"enum","values":{"none":{},"uppercase":{},"lowercase":{}},"default":"none","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-offset":{"type":"array","value":"number","units":"ems","length":2,"default":[0,0],"requires":["text-field",{"!":"text-radial-offset"}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-optional":{"type":"boolean","default":false,"requires":["text-field","icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_raster":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_hillshade":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"filter":{"type":"array","value":"*"},"filter_symbol":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature","pitch","distance-from-center"]}},"filter_fill":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_line":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_circle":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_fill-extrusion":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_heatmap":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_operator":{"type":"enum","values":{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},"in":{},"!in":{},"all":{},"any":{},"none":{},"has":{},"!has":{},"within":{}}},"geometry_type":{"type":"enum","values":{"Point":{},"LineString":{},"Polygon":{}}},"function":{"expression":{"type":"expression"},"stops":{"type":"array","value":"function_stop"},"base":{"type":"number","default":1,"minimum":0},"property":{"type":"string","default":"$zoom"},"type":{"type":"enum","values":{"identity":{},"exponential":{},"interval":{},"categorical":{}},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":{},"lab":{},"hcl":{}},"default":"rgb"},"default":{"type":"*","required":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"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"horizon-blend":{"type":"number","property-type":"data-constant","default":0.1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":{},"viewport":{}},"property-type":"data-constant","transition":false,"expression":{"interpolated":false,"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":{},"equalEarth":{},"equirectangular":{},"lambertConformalConic":{},"mercator":{},"naturalEarth":{},"winkelTripel":{}},"default":"mercator","required":true},"center":{"type":"array","length":2,"value":"number","property-type":"data-constant","transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]},"parallels":{"type":"array","length":2,"value":"number","property-type":"data-constant","transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]}},"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_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"interpolated":false,"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"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","transition":true,"requires":[{"!":"fill-pattern"},{"fill-antialias":true}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"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,"requires":[{"!":"fill-extrusion-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-extrusion-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"requires":["fill-extrusion-height"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"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"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"line-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["line-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"transition":true,"units":"line widths","requires":[{"!":"line-pattern"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{"type":"color","transition":false,"requires":[{"!":"line-pattern"},{"source":"geojson","has":{"lineMetrics":true}}],"expression":{"interpolated":true,"parameters":["line-progress"]},"property-type":"color-ramp"}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["circle-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"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"]},"property-type":"data-driven"}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"transition":false,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"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"],"transition":false,"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,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["icon-image","icon-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","transition":true,"overridable":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["text-field","text-translate"],"expression":{"interpolated":false,"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-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"units":"degrees","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":{},"nearest":{}},"default":"linear","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"transition":false,"units":"milliseconds","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"transition":false,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"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"]},"property-type":"data-constant"},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_background":{"background-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"background-pattern"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"cross-faded"},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":{},"atmosphere":{}},"default":"atmosphere","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"requires":[{"sky-type":"atmosphere"}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun-intensity":{"type":"number","requires":[{"sky-type":"atmosphere"}],"default":10,"minimum":0,"maximum":100,"transition":false,"property-type":"data-constant"},"sky-gradient-center":{"type":"array","requires":[{"sky-type":"gradient"}],"value":"number","default":[0,0],"length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient-radius":{"type":"number","requires":[{"sky-type":"gradient"}],"default":90,"minimum":0,"maximum":180,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"transition":false,"requires":[{"sky-type":"gradient"}],"expression":{"interpolated":true,"parameters":["sky-radial-progress"]},"property-type":"color-ramp"},"sky-atmosphere-halo-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-atmosphere-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"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"}},"transition":{"duration":{"type":"number","default":300,"minimum":0,"units":"milliseconds"},"delay":{"type":"number","default":0,"minimum":0,"units":"milliseconds"}},"property-type":{"data-driven":{"type":"property-type"},"cross-faded":{"type":"property-type"},"cross-faded-data-driven":{"type":"property-type"},"color-ramp":{"type":"property-type"},"data-constant":{"type":"property-type"},"constant":{"type":"property-type"}},"promoteId":{"*":{"type":"string"}}}');class cc{constructor(b,a,d,c){this.message=(b?`${b}: `:"")+d,c&&(this.identifier=c),null!=a&&a.__line__&&(this.line=a.__line__)}}function cd(a){const b=a.value;return b?[new cc(a.key,b,"constants have been deprecated as of v8"),]:[]}function ce(a,...d){for(const b of d)for(const c in b)a[c]=b[c];return a}function fp(a){return a instanceof Number||a instanceof String||a instanceof Boolean?a.valueOf():a}function fq(a){if(Array.isArray(a))return a.map(fq);if(a instanceof Object&&!(a instanceof Number||a instanceof String||a instanceof Boolean)){const b={};for(const c in a)b[c]=fq(a[c]);return b}return fp(a)}class fr extends Error{constructor(b,a){super(a),this.message=a,this.key=b}}class fs{constructor(a,b=[]){for(const[c,d]of(this.parent=a,this.bindings={},b))this.bindings[c]=d}concat(a){return new fs(this,a)}get(a){if(this.bindings[a])return this.bindings[a];if(this.parent)return this.parent.get(a);throw new Error(`${a} not found in scope.`)}has(a){return!!this.bindings[a]|| !!this.parent&&this.parent.has(a)}}const cf={kind:"null"},f={kind:"number"},i={kind:"string"},h={kind:"boolean"},y={kind:"color"},K={kind:"object"},l={kind:"value"},cg={kind:"collator"},ch={kind:"formatted"},ci={kind:"resolvedImage"};function z(a,b){return{kind:"array",itemType:a,N:b}}function ft(a){if("array"===a.kind){const b=ft(a.itemType);return"number"==typeof a.N?`array<${b}, ${a.N}>`:"value"===a.itemType.kind?"array":`array<${b}>`}return a.kind}const fu=[cf,f,i,h,y,ch,K,z(l),ci];function fv(b,a){if("error"===a.kind)return null;if("array"===b.kind){if("array"===a.kind&&(0===a.N&&"value"===a.itemType.kind||!fv(b.itemType,a.itemType))&&("number"!=typeof b.N||b.N===a.N))return null}else{if(b.kind===a.kind)return null;if("value"===b.kind){for(const c of fu)if(!fv(c,a))return null}}return`Expected ${ft(b)} but found ${ft(a)} instead.`}function fw(b,a){return a.some(a=>a.kind===b.kind)}function fx(b,a){return a.some(a=>"null"===a?null===b:"array"===a?Array.isArray(b):"object"===a?b&&!Array.isArray(b)&&"object"==typeof b:a===typeof b)}function ah(b){var a={exports:{}};return b(a,a.exports),a.exports}var fy=ah(function(b,a){var c={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 d(a){return(a=Math.round(a))<0?0:a>255?255:a}function e(a){return d("%"===a[a.length-1]?parseFloat(a)/100*255:parseInt(a))}function f(a){var b;return(b="%"===a[a.length-1]?parseFloat(a)/100:parseFloat(a))<0?0:b>1?1:b}function g(b,c,a){return a<0?a+=1:a>1&&(a-=1),6*a<1?b+(c-b)*a*6:2*a<1?c:3*a<2?b+(c-b)*(2/3-a)*6:b}try{a.parseCSSColor=function(q){var a,b=q.replace(/ /g,"").toLowerCase();if(b in c)return c[b].slice();if("#"===b[0])return 4===b.length?(a=parseInt(b.substr(1),16))>=0&&a<=4095?[(3840&a)>>4|(3840&a)>>8,240&a|(240&a)>>4,15&a|(15&a)<<4,1,]:null:7===b.length&&(a=parseInt(b.substr(1),16))>=0&&a<=16777215?[(16711680&a)>>16,(65280&a)>>8,255&a,1,]:null;var j=b.indexOf("("),p=b.indexOf(")");if(-1!==j&&p+1===b.length){var r=b.substr(0,j),h=b.substr(j+1,p-(j+1)).split(","),k=1;switch(r){case"rgba":if(4!==h.length)break;k=f(h.pop());case"rgb":return 3!==h.length?null:[e(h[0]),e(h[1]),e(h[2]),k,];case"hsla":if(4!==h.length)break;k=f(h.pop());case"hsl":if(3!==h.length)break;var m=(parseFloat(h[0])%360+360)%360/360,n=f(h[1]),i=f(h[2]),l=i<=.5?i*(n+1):i+n-i*n,o=2*i-l;return[d(255*g(o,l,m+1/3)),d(255*g(o,l,m)),d(255*g(o,l,m-1/3)),k,]}}return null}}catch(h){}});class m{constructor(a,b,c,d=1){this.r=a,this.g=b,this.b=c,this.a=d}static parse(b){if(!b)return;if(b instanceof m)return b;if("string"!=typeof b)return;const a=fy.parseCSSColor(b);return a?new m(a[0]/255*a[3],a[1]/255*a[3],a[2]/255*a[3],a[3]):void 0}toString(){const[a,b,c,d]=this.toArray();return`rgba(${Math.round(a)},${Math.round(b)},${Math.round(c)},${d})`}toArray(){const{r:b,g:c,b:d,a:a}=this;return 0===a?[0,0,0,0]:[255*b/a,255*c/a,255*d/a,a,]}}m.black=new m(0,0,0,1),m.white=new m(1,1,1,1),m.transparent=new m(0,0,0,0),m.red=new m(1,0,0,1),m.blue=new m(0,0,1,1);class fz{constructor(b,a,c){this.sensitivity=b?a?"variant":"case":a?"accent":"base",this.locale=c,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(a,b){return this.collator.compare(a,b)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class fA{constructor(a,b,c,d,e){this.text=a.normalize?a.normalize():a,this.image=b,this.scale=c,this.fontStack=d,this.textColor=e}}class fB{constructor(a){this.sections=a}static fromString(a){return new fB([new fA(a,null,null,null,null),])}isEmpty(){return 0===this.sections.length||!this.sections.some(a=>0!==a.text.length||a.image&&0!==a.image.name.length)}static factory(a){return a instanceof fB?a:fB.fromString(a)}toString(){return 0===this.sections.length?"":this.sections.map(a=>a.text).join("")}serialize(){const b=["format"];for(const a of this.sections){if(a.image){b.push(["image",a.image.name]);continue}b.push(a.text);const c={};a.fontStack&&(c["text-font"]=["literal",a.fontStack.split(","),]),a.scale&&(c["font-scale"]=a.scale),a.textColor&&(c["text-color"]=["rgba"].concat(a.textColor.toArray())),b.push(c)}return b}}class cj{constructor(a){this.name=a.name,this.available=a.available}toString(){return this.name}static fromString(a){return a?new cj({name:a,available:!1}):null}serialize(){return["image",this.name]}}function fC(b,c,d,a){return"number"==typeof b&&b>=0&&b<=255&&"number"==typeof c&&c>=0&&c<=255&&"number"==typeof d&&d>=0&&d<=255?void 0===a||"number"==typeof a&&a>=0&&a<=1?null:`Invalid rgba value [${[b,c,d,a].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof a?[b,c,d,a]:[b,c,d]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function fD(a){if(null===a)return!0;if("string"==typeof a)return!0;if("boolean"==typeof a)return!0;if("number"==typeof a)return!0;if(a instanceof m)return!0;if(a instanceof fz)return!0;if(a instanceof fB)return!0;if(a instanceof cj)return!0;if(Array.isArray(a)){for(const b of a)if(!fD(b))return!1;return!0}if("object"==typeof a){for(const c in a)if(!fD(a[c]))return!1;return!0}return!1}function fE(a){if(null===a)return cf;if("string"==typeof a)return i;if("boolean"==typeof a)return h;if("number"==typeof a)return f;if(a instanceof m)return y;if(a instanceof fz)return cg;if(a instanceof fB)return ch;if(a instanceof cj)return ci;if(Array.isArray(a)){const d=a.length;let b;for(const e of a){const c=fE(e);if(b){if(b===c)continue;b=l;break}b=c}return z(b||l,d)}return K}function fF(a){const b=typeof a;return null===a?"":"string"===b||"number"===b||"boolean"===b?String(a):a instanceof m||a instanceof fB||a instanceof cj?a.toString():JSON.stringify(a)}class ck{constructor(a,b){this.type=a,this.value=b}static parse(b,d){if(2!==b.length)return d.error(`'literal' expression requires exactly one argument, but found ${b.length-1} instead.`);if(!fD(b[1]))return d.error("invalid value");const e=b[1];let c=fE(e);const a=d.expectedType;return"array"===c.kind&&0===c.N&&a&&"array"===a.kind&&("number"!=typeof a.N||0===a.N)&&(c=a),new ck(c,e)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof m?["rgba"].concat(this.value.toArray()):this.value instanceof fB?this.value.serialize():this.value}}class fG{constructor(a){this.name="ExpressionEvaluationError",this.message=a}toJSON(){return this.message}}const fH={string:i,number:f,boolean:h,object:K};class L{constructor(a,b){this.type=a,this.args=b}static parse(a,c){if(a.length<2)return c.error("Expected at least one argument.");let e,b=1;const g=a[0];if("array"===g){let f,h;if(a.length>2){const d=a[1];if("string"!=typeof d||!(d in fH)||"object"===d)return c.error('The item type argument of "array" must be one of string, number, boolean',1);f=fH[d],b++}else f=l;if(a.length>3){if(null!==a[2]&&("number"!=typeof a[2]||a[2]<0||a[2]!==Math.floor(a[2])))return c.error('The length argument to "array" must be a positive integer literal',2);h=a[2],b++}e=z(f,h)}else e=fH[g];const i=[];for(;ba.outputDefined())}serialize(){const a=this.type,c=[a.kind];if("array"===a.kind){const b=a.itemType;if("string"===b.kind||"number"===b.kind||"boolean"===b.kind){c.push(b.kind);const d=a.N;("number"==typeof d||this.args.length>1)&&c.push(d)}}return c.concat(this.args.map(a=>a.serialize()))}}class cl{constructor(a){this.type=ch,this.sections=a}static parse(c,b){if(c.length<2)return b.error("Expected at least one argument.");const m=c[1];if(!Array.isArray(m)&&"object"==typeof m)return b.error("First argument must be an image or text section.");const d=[];let h=!1;for(let e=1;e<=c.length-1;++e){const a=c[e];if(h&&"object"==typeof a&&!Array.isArray(a)){h=!1;let n=null;if(a["font-scale"]&&!(n=b.parse(a["font-scale"],1,f)))return null;let o=null;if(a["text-font"]&&!(o=b.parse(a["text-font"],1,z(i))))return null;let p=null;if(a["text-color"]&&!(p=b.parse(a["text-color"],1,y)))return null;const j=d[d.length-1];j.scale=n,j.font=o,j.textColor=p}else{const k=b.parse(c[e],1,l);if(!k)return null;const g=k.type.kind;if("string"!==g&&"value"!==g&&"null"!==g&&"resolvedImage"!==g)return b.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");h=!0,d.push({content:k,scale:null,font:null,textColor:null})}}return new cl(d)}evaluate(a){return new fB(this.sections.map(b=>{const c=b.content.evaluate(a);return fE(c)===ci?new fA("",c,null,null,null):new fA(fF(c),null,b.scale?b.scale.evaluate(a):null,b.font?b.font.evaluate(a).join(","):null,b.textColor?b.textColor.evaluate(a):null)}))}eachChild(b){for(const a of this.sections)b(a.content),a.scale&&b(a.scale),a.font&&b(a.font),a.textColor&&b(a.textColor)}outputDefined(){return!1}serialize(){const c=["format"];for(const a of this.sections){c.push(a.content.serialize());const b={};a.scale&&(b["font-scale"]=a.scale.serialize()),a.font&&(b["text-font"]=a.font.serialize()),a.textColor&&(b["text-color"]=a.textColor.serialize()),c.push(b)}return c}}class cm{constructor(a){this.type=ci,this.input=a}static parse(b,a){if(2!==b.length)return a.error("Expected two arguments.");const c=a.parse(b[1],1,i);return c?new cm(c):a.error("No image name provided.")}evaluate(a){const c=this.input.evaluate(a),b=cj.fromString(c);return b&&a.availableImages&&(b.available=a.availableImages.indexOf(c)> -1),b}eachChild(a){a(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const fI={"to-boolean":h,"to-color":y,"to-number":f,"to-string":i};class T{constructor(a,b){this.type=a,this.args=b}static parse(a,c){if(a.length<2)return c.error("Expected at least one argument.");const d=a[0];if(("to-boolean"===d||"to-string"===d)&&2!==a.length)return c.error("Expected one argument.");const g=fI[d],e=[];for(let b=1;b4?`Invalid rbga value ${JSON.stringify(a)}: expected an array containing either three or four numeric values.`:fC(a[0],a[1],a[2],a[3])))return new m(a[0]/255,a[1]/255,a[2]/255,a[3])}throw new fG(c||`Could not parse color from value '${"string"==typeof a?a:String(JSON.stringify(a))}'`)}if("number"===this.type.kind){let d=null;for(const h of this.args){if(null===(d=h.evaluate(b)))return 0;const f=Number(d);if(!isNaN(f))return f}throw new fG(`Could not convert ${JSON.stringify(d)} to number.`)}return"formatted"===this.type.kind?fB.fromString(fF(this.args[0].evaluate(b))):"resolvedImage"===this.type.kind?cj.fromString(fF(this.args[0].evaluate(b))):fF(this.args[0].evaluate(b))}eachChild(a){this.args.forEach(a)}outputDefined(){return this.args.every(a=>a.outputDefined())}serialize(){if("formatted"===this.type.kind)return new cl([{content:this.args[0],scale:null,font:null,textColor:null},]).serialize();if("resolvedImage"===this.type.kind)return new cm(this.args[0]).serialize();const a=[`to-${this.type.kind}`];return this.eachChild(b=>{a.push(b.serialize())}),a}}const fJ=["Unknown","Point","LineString","Polygon",];class fK{constructor(){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}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?fJ[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||{}}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const a=this.featureDistanceData.center,b=this.featureDistanceData.scale,{x:c,y:d}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(c*b-a[0])+this.featureDistanceData.bearing[1]*(d*b-a[1])}return 0}parseColor(a){let b=this._parseColorCache[a];return b||(b=this._parseColorCache[a]=m.parse(a)),b}}class aX{constructor(a,b,c,d){this.name=a,this.type=b,this._evaluate=c,this.args=d}evaluate(a){return this._evaluate(a,this.args)}eachChild(a){this.args.forEach(a)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(a=>a.serialize()))}static parse(f,c){const j=f[0],b=aX.definitions[j];if(!b)return c.error(`Unknown expression "${j}". If you wanted a literal array, use ["literal", [...]].`,0);const q=Array.isArray(b)?b[0]:b.type,m=Array.isArray(b)?[[b[1],b[2]]]:b.overloads,h=m.filter(([a])=>!Array.isArray(a)||a.length===f.length-1);let e=null;for(const[a,r]of h){e=new f1(c.registry,c.path,null,c.scope);const d=[];let n=!1;for(let i=1;i{var a;return a=b,Array.isArray(a)?`(${a.map(ft).join(", ")})`:`(${ft(a.type)}...)`}).join(" | "),k=[];for(let l=1;l=b[2]||a[1]<=b[1]||a[3]>=b[3])}function fN(a,c){const d=(180+a[0])/360,e=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+a[1]*Math.PI/360)))/360,b=Math.pow(2,c.z);return[Math.round(d*b*8192),Math.round(e*b*8192),]}function fO(a,b,c){const d=a[0]-b[0],e=a[1]-b[1],f=a[0]-c[0],g=a[1]-c[1];return d*g-f*e==0&&d*f<=0&&e*g<=0}function fP(h,i){var d,b,e;let f=!1;for(let g=0,j=i.length;g(d=h)[1]!=(e=c[a+1])[1]>d[1]&&d[0]<(e[0]-b[0])*(d[1]-b[1])/(e[1]-b[1])+b[0]&&(f=!f)}}return f}function fQ(c,b){for(let a=0;a0&&h<0||g<0&&h>0}function fS(i,j,k){var a,b,c,d,g,h;for(const f of k)for(let e=0;eb[2]){const d=.5*c;let e=a[0]-b[0]>d?-c:b[0]-a[0]>d?c:0;0===e&&(e=a[0]-b[2]>d?-c:b[2]-a[0]>d?c:0),a[0]+=e}fL(f,a)}function fY(f,g,h,a){const i=8192*Math.pow(2,a.z),b=[8192*a.x,8192*a.y],c=[];for(const j of f)for(const d of j){const e=[d.x+b[0],d.y+b[1]];fX(e,g,h,i),c.push(e)}return c}function fZ(j,a,k,c){var b;const e=8192*Math.pow(2,c.z),f=[8192*c.x,8192*c.y],d=[];for(const l of j){const g=[];for(const h of l){const i=[h.x+f[0],h.y+f[1]];fL(a,i),g.push(i)}d.push(g)}if(a[2]-a[0]<=e/2)for(const m of((b=a)[0]=b[1]=1/0,b[2]=b[3]=-1/0,d))for(const n of m)fX(n,a,k,e);return d}class co{constructor(a,b){this.type=h,this.geojson=a,this.geometries=b}static parse(b,d){if(2!==b.length)return d.error(`'within' expression requires exactly one argument, but found ${b.length-1} instead.`);if(fD(b[1])){const a=b[1];if("FeatureCollection"===a.type)for(let c=0;c{b&&!f$(a)&&(b=!1)}),b}function f_(a){if(a instanceof aX&&"feature-state"===a.name)return!1;let b=!0;return a.eachChild(a=>{b&&!f_(a)&&(b=!1)}),b}function f0(a,b){if(a instanceof aX&&b.indexOf(a.name)>=0)return!1;let c=!0;return a.eachChild(a=>{c&&!f0(a,b)&&(c=!1)}),c}class cp{constructor(b,a){this.type=a.type,this.name=b,this.boundExpression=a}static parse(c,b){if(2!==c.length||"string"!=typeof c[1])return b.error("'var' expression requires exactly one string literal argument.");const a=c[1];return b.scope.has(a)?new cp(a,b.scope.get(a)):b.error(`Unknown variable "${a}". Make sure "${a}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(a){return this.boundExpression.evaluate(a)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class f1{constructor(b,a=[],c,d=new fs,e=[]){this.registry=b,this.path=a,this.key=a.map(a=>`[${a}]`).join(""),this.scope=d,this.errors=e,this.expectedType=c}parse(a,b,d,e,c={}){return b?this.concat(b,d,e)._parse(a,c):this._parse(a,c)}_parse(a,f){function g(a,b,c){return"assert"===c?new L(b,[a]):"coerce"===c?new T(b,[a]):a}if(null!==a&&"string"!=typeof a&&"boolean"!=typeof a&&"number"!=typeof a||(a=["literal",a]),Array.isArray(a)){if(0===a.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const d=a[0];if("string"!=typeof d)return this.error(`Expression name must be a string, but found ${typeof d} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const h=this.registry[d];if(h){let b=h.parse(a,this);if(!b)return null;if(this.expectedType){const c=this.expectedType,e=b.type;if("string"!==c.kind&&"number"!==c.kind&&"boolean"!==c.kind&&"object"!==c.kind&&"array"!==c.kind||"value"!==e.kind){if("color"!==c.kind&&"formatted"!==c.kind&&"resolvedImage"!==c.kind||"value"!==e.kind&&"string"!==e.kind){if(this.checkSubtype(c,e))return null}else b=g(b,c,f.typeAnnotation||"coerce")}else b=g(b,c,f.typeAnnotation||"assert")}if(!(b instanceof ck)&&"resolvedImage"!==b.type.kind&&f2(b)){const i=new fK;try{b=new ck(b.type,b.evaluate(i))}catch(j){return this.error(j.message),null}}return b}return this.error(`Unknown expression "${d}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===a?"'undefined' value invalid. Use null instead.":"object"==typeof a?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof a} instead.`)}concat(a,c,b){const d="number"==typeof a?this.path.concat(a):this.path,e=b?this.scope.concat(b):this.scope;return new f1(this.registry,d,c||null,e,this.errors)}error(a,...b){const c=`${this.key}${b.map(a=>`[${a}]`).join("")}`;this.errors.push(new fr(c,a))}checkSubtype(b,c){const a=fv(b,c);return a&&this.error(a),a}}function f2(a){if(a instanceof cp)return f2(a.boundExpression);if(a instanceof aX&&"error"===a.name)return!1;if(a instanceof cn)return!1;if(a instanceof co)return!1;const c=a instanceof T||a instanceof L;let b=!0;return a.eachChild(a=>{b=c?b&&f2(a):b&&a instanceof ck}),!!b&&f$(a)&&f0(a,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center",])}function f3(b,c){const g=b.length-1;let d,h,e=0,f=g,a=0;for(;e<=f;)if(d=b[a=Math.floor((e+f)/2)],h=b[a+1],d<=c){if(a===g||cc))throw new fG("Input is not a number.");f=a-1}return 0}class cq{constructor(a,b,c){for(const[d,e]of(this.type=a,this.input=b,this.labels=[],this.outputs=[],c))this.labels.push(d),this.outputs.push(e)}static parse(b,a){if(b.length-1<4)return a.error(`Expected at least 4 arguments, but found only ${b.length-1}.`);if((b.length-1)%2!=0)return a.error("Expected an even number of arguments.");const i=a.parse(b[1],1,f);if(!i)return null;const d=[];let e=null;a.expectedType&&"value"!==a.expectedType.kind&&(e=a.expectedType);for(let c=1;c=g)return a.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',j);const h=a.parse(k,l,e);if(!h)return null;e=e||h.type,d.push([g,h])}return new cq(e,i,d)}evaluate(a){const b=this.labels,c=this.outputs;if(1===b.length)return c[0].evaluate(a);const d=this.input.evaluate(a);if(d<=b[0])return c[0].evaluate(a);const e=b.length;return d>=b[e-1]?c[e-1].evaluate(a):c[f3(b,d)].evaluate(a)}eachChild(a){for(const b of(a(this.input),this.outputs))a(b)}outputDefined(){return this.outputs.every(a=>a.outputDefined())}serialize(){const b=["step",this.input.serialize()];for(let a=0;a0&&b.push(this.labels[a]),b.push(this.outputs[a].serialize());return b}}function aY(b,c,a){return b*(1-a)+c*a}var f4=Object.freeze({__proto__:null,number:aY,color:function(a,b,c){return new m(aY(a.r,b.r,c),aY(a.g,b.g,c),aY(a.b,b.b,c),aY(a.a,b.a,c))},array:function(a,b,c){return a.map((a,d)=>aY(a,b[d],c))}});const f5=4/29,aZ=6/29,f6=3*aZ*aZ,f7=Math.PI/180,f8=180/Math.PI;function f9(a){return a>.008856451679035631?Math.pow(a,1/3):a/f6+f5}function ga(a){return a>aZ?a*a*a:f6*(a-f5)}function gb(a){return 255*(a<=.0031308?12.92*a:1.055*Math.pow(a,1/2.4)-.055)}function gc(a){return(a/=255)<=.04045?a/12.92:Math.pow((a+.055)/1.055,2.4)}function cr(a){const b=gc(a.r),c=gc(a.g),d=gc(a.b),f=f9((.4124564*b+.3575761*c+.1804375*d)/.95047),e=f9((.2126729*b+.7151522*c+.072175*d)/1);return{l:116*e-16,a:500*(f-e),b:200*(e-f9((.0193339*b+.119192*c+.9503041*d)/1.08883)),alpha:a.a}}function cs(b){let a=(b.l+16)/116,c=isNaN(b.a)?a:a+b.a/500,d=isNaN(b.b)?a:a-b.b/200;return a=1*ga(a),c=.95047*ga(c),d=1.08883*ga(d),new m(gb(3.2404542*c-1.5371385*a-.4985314*d),gb(-0.969266*c+1.8760108*a+.041556*d),gb(.0556434*c-.2040259*a+1.0572252*d),b.alpha)}const ct={forward:cr,reverse:cs,interpolate:function(a,b,c){return{l:aY(a.l,b.l,c),a:aY(a.a,b.a,c),b:aY(a.b,b.b,c),alpha:aY(a.alpha,b.alpha,c)}}},cu={forward:function(d){const{l:e,a:a,b:b}=cr(d),c=Math.atan2(b,a)*f8;return{h:c<0?c+360:c,c:Math.sqrt(a*a+b*b),l:e,alpha:d.a}},reverse:function(a){const b=a.h*f7,c=a.c;return cs({l:a.l,a:Math.cos(b)*c,b:Math.sin(b)*c,alpha:a.alpha})},interpolate:function(a,b,c){return{h:function(b,c,d){const a=c-b;return b+d*(a>180||a< -180?a-360*Math.round(a/360):a)}(a.h,b.h,c),c:aY(a.c,b.c,c),l:aY(a.l,b.l,c),alpha:aY(a.alpha,b.alpha,c)}}};var gd=Object.freeze({__proto__:null,lab:ct,hcl:cu});class ai{constructor(a,b,c,d,e){for(const[f,g]of(this.type=a,this.operator=b,this.interpolation=c,this.input=d,this.labels=[],this.outputs=[],e))this.labels.push(f),this.outputs.push(g)}static interpolationFactor(a,d,e,f){let b=0;if("exponential"===a.name)b=ge(d,a.base,e,f);else if("linear"===a.name)b=ge(d,1,e,f);else if("cubic-bezier"===a.name){const c=a.controlPoints;b=new eG(c[0],c[1],c[2],c[3]).solve(ge(d,1,e,f))}return b}static parse(g,a){let[h,b,i,...j]=g;if(!Array.isArray(b)||0===b.length)return a.error("Expected an interpolation type expression.",1);if("linear"===b[0])b={name:"linear"};else if("exponential"===b[0]){const n=b[1];if("number"!=typeof n)return a.error("Exponential interpolation requires a numeric base.",1,1);b={name:"exponential",base:n}}else{if("cubic-bezier"!==b[0])return a.error(`Unknown interpolation type ${String(b[0])}`,1,0);{const k=b.slice(1);if(4!==k.length||k.some(a=>"number"!=typeof a||a<0||a>1))return a.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);b={name:"cubic-bezier",controlPoints:k}}}if(g.length-1<4)return a.error(`Expected at least 4 arguments, but found only ${g.length-1}.`);if((g.length-1)%2!=0)return a.error("Expected an even number of arguments.");if(!(i=a.parse(i,2,f)))return null;const e=[];let c=null;"interpolate-hcl"===h||"interpolate-lab"===h?c=y:a.expectedType&&"value"!==a.expectedType.kind&&(c=a.expectedType);for(let d=0;d=l)return a.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',o);const m=a.parse(p,q,c);if(!m)return null;c=c||m.type,e.push([l,m])}return"number"===c.kind||"color"===c.kind||"array"===c.kind&&"number"===c.itemType.kind&&"number"==typeof c.N?new ai(c,h,b,i,e):a.error(`Type ${ft(c)} is not interpolatable.`)}evaluate(b){const a=this.labels,c=this.outputs;if(1===a.length)return c[0].evaluate(b);const d=this.input.evaluate(b);if(d<=a[0])return c[0].evaluate(b);const i=a.length;if(d>=a[i-1])return c[i-1].evaluate(b);const e=f3(a,d),f=ai.interpolationFactor(this.interpolation,d,a[e],a[e+1]),g=c[e].evaluate(b),h=c[e+1].evaluate(b);return"interpolate"===this.operator?f4[this.type.kind.toLowerCase()](g,h,f):"interpolate-hcl"===this.operator?cu.reverse(cu.interpolate(cu.forward(g),cu.forward(h),f)):ct.reverse(ct.interpolate(ct.forward(g),ct.forward(h),f))}eachChild(a){for(const b of(a(this.input),this.outputs))a(b)}outputDefined(){return this.outputs.every(a=>a.outputDefined())}serialize(){let b;b="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 c=[this.operator,b,this.input.serialize(),];for(let a=0;afv(b,a.type));return new cv(h?l:a,c)}evaluate(d){let b,a=null,c=0;for(const e of this.args){if(c++,(a=e.evaluate(d))&&a instanceof cj&&!a.available&&(b||(b=a),a=null,c===this.args.length))return b;if(null!==a)break}return a}eachChild(a){this.args.forEach(a)}outputDefined(){return this.args.every(a=>a.outputDefined())}serialize(){const a=["coalesce"];return this.eachChild(b=>{a.push(b.serialize())}),a}}class cw{constructor(b,a){this.type=a.type,this.bindings=[].concat(b),this.result=a}evaluate(a){return this.result.evaluate(a)}eachChild(a){for(const b of this.bindings)a(b[1]);a(this.result)}static parse(a,c){if(a.length<4)return c.error(`Expected at least 3 arguments, but found ${a.length-1} instead.`);const e=[];for(let b=1;b=b.length)throw new fG(`Array index out of bounds: ${a} > ${b.length-1}.`);if(a!==Math.floor(a))throw new fG(`Array index must be an integer, but found ${a} instead.`);return b[a]}eachChild(a){a(this.index),a(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize(),]}}class cy{constructor(a,b){this.type=h,this.needle=a,this.haystack=b}static parse(a,b){if(3!==a.length)return b.error(`Expected 2 arguments, but found ${a.length-1} instead.`);const c=b.parse(a[1],1,l),d=b.parse(a[2],2,l);return c&&d?fw(c.type,[h,i,f,cf,l])?new cy(c,d):b.error(`Expected first argument to be of type boolean, string, number or null, but found ${ft(c.type)} instead`):null}evaluate(c){const b=this.needle.evaluate(c),a=this.haystack.evaluate(c);if(!a)return!1;if(!fx(b,["boolean","string","number","null",]))throw new fG(`Expected first argument to be of type boolean, string, number or null, but found ${ft(fE(b))} instead.`);if(!fx(a,["string","array"]))throw new fG(`Expected second argument to be of type array or string, but found ${ft(fE(a))} instead.`);return a.indexOf(b)>=0}eachChild(a){a(this.needle),a(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize(),]}}class cz{constructor(a,b,c){this.type=f,this.needle=a,this.haystack=b,this.fromIndex=c}static parse(a,b){if(a.length<=2||a.length>=5)return b.error(`Expected 3 or 4 arguments, but found ${a.length-1} instead.`);const c=b.parse(a[1],1,l),d=b.parse(a[2],2,l);if(!c||!d)return null;if(!fw(c.type,[h,i,f,cf,l]))return b.error(`Expected first argument to be of type boolean, string, number or null, but found ${ft(c.type)} instead`);if(4===a.length){const e=b.parse(a[3],3,f);return e?new cz(c,d,e):null}return new cz(c,d)}evaluate(c){const a=this.needle.evaluate(c),b=this.haystack.evaluate(c);if(!fx(a,["boolean","string","number","null",]))throw new fG(`Expected first argument to be of type boolean, string, number or null, but found ${ft(fE(a))} instead.`);if(!fx(b,["string","array"]))throw new fG(`Expected second argument to be of type array or string, but found ${ft(fE(b))} instead.`);if(this.fromIndex){const d=this.fromIndex.evaluate(c);return b.indexOf(a,d)}return b.indexOf(a)}eachChild(a){a(this.needle),a(this.haystack),this.fromIndex&&a(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&& void 0!==this.fromIndex){const a=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),a,]}return["index-of",this.needle.serialize(),this.haystack.serialize(),]}}class cA{constructor(a,b,c,d,e,f){this.inputType=a,this.type=b,this.input=c,this.cases=d,this.outputs=e,this.otherwise=f}static parse(b,c){if(b.length<5)return c.error(`Expected at least 4 arguments, but found only ${b.length-1}.`);if(b.length%2!=1)return c.error("Expected an even number of arguments.");let g,d;c.expectedType&&"value"!==c.expectedType.kind&&(d=c.expectedType);const j={},k=[];for(let e=2;eNumber.MAX_SAFE_INTEGER)return f.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof a&&Math.floor(a)!==a)return f.error("Numeric branch labels must be integer values.");if(g){if(f.checkSubtype(g,fE(a)))return null}else g=fE(a);if(void 0!==j[String(a)])return f.error("Branch labels must be unique.");j[String(a)]=k.length}const m=c.parse(o,e,d);if(!m)return null;d=d||m.type,k.push(m)}const i=c.parse(b[1],1,l);if(!i)return null;const n=c.parse(b[b.length-1],b.length-1,d);return n?"value"!==i.type.kind&&c.concat(1).checkSubtype(g,i.type)?null:new cA(g,d,i,j,k,n):null}evaluate(a){const b=this.input.evaluate(a);return(fE(b)===this.inputType&&this.outputs[this.cases[b]]||this.otherwise).evaluate(a)}eachChild(a){a(this.input),this.outputs.forEach(a),a(this.otherwise)}outputDefined(){return this.outputs.every(a=>a.outputDefined())&&this.otherwise.outputDefined()}serialize(){const b=["match",this.input.serialize()],h=Object.keys(this.cases).sort(),c=[],e={};for(const a of h){const f=e[this.cases[a]];void 0===f?(e[this.cases[a]]=c.length,c.push([this.cases[a],[a]])):c[f][1].push(a)}const g=a=>"number"===this.inputType.kind?Number(a):a;for(const[i,d]of c)b.push(1===d.length?g(d[0]):d.map(g)),b.push(this.outputs[i].serialize());return b.push(this.otherwise.serialize()),b}}class cB{constructor(a,b,c){this.type=a,this.branches=b,this.otherwise=c}static parse(a,b){if(a.length<4)return b.error(`Expected at least 3 arguments, but found only ${a.length-1}.`);if(a.length%2!=0)return b.error("Expected an odd number of arguments.");let c;b.expectedType&&"value"!==b.expectedType.kind&&(c=b.expectedType);const f=[];for(let d=1;da.outputDefined())&&this.otherwise.outputDefined()}serialize(){const a=["case"];return this.eachChild(b=>{a.push(b.serialize())}),a}}class cC{constructor(a,b,c,d){this.type=a,this.input=b,this.beginIndex=c,this.endIndex=d}static parse(a,c){if(a.length<=2||a.length>=5)return c.error(`Expected 3 or 4 arguments, but found ${a.length-1} instead.`);const b=c.parse(a[1],1,l),d=c.parse(a[2],2,f);if(!b||!d)return null;if(!fw(b.type,[z(l),i,l]))return c.error(`Expected first argument to be of type array or string, but found ${ft(b.type)} instead`);if(4===a.length){const e=c.parse(a[3],3,f);return e?new cC(b.type,b,d,e):null}return new cC(b.type,b,d)}evaluate(b){const a=this.input.evaluate(b),c=this.beginIndex.evaluate(b);if(!fx(a,["string","array"]))throw new fG(`Expected first argument to be of type array or string, but found ${ft(fE(a))} instead.`);if(this.endIndex){const d=this.endIndex.evaluate(b);return a.slice(c,d)}return a.slice(c)}eachChild(a){a(this.input),a(this.beginIndex),this.endIndex&&a(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&& void 0!==this.endIndex){const a=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),a,]}return["slice",this.input.serialize(),this.beginIndex.serialize(),]}}function gf(b,a){return"=="===b||"!="===b?"boolean"===a.kind||"string"===a.kind||"number"===a.kind||"null"===a.kind||"value"===a.kind:"string"===a.kind||"number"===a.kind||"value"===a.kind}function cD(d,a,b,c){return 0===c.compare(a,b)}function A(a,b,c){const d="=="!==a&&"!="!==a;return class e{constructor(a,b,c){this.type=h,this.lhs=a,this.rhs=b,this.collator=c,this.hasUntypedArgument="value"===a.type.kind||"value"===b.type.kind}static parse(f,c){if(3!==f.length&&4!==f.length)return c.error("Expected two or three arguments.");const g=f[0];let a=c.parse(f[1],1,l);if(!a)return null;if(!gf(g,a.type))return c.concat(1).error(`"${g}" comparisons are not supported for type '${ft(a.type)}'.`);let b=c.parse(f[2],2,l);if(!b)return null;if(!gf(g,b.type))return c.concat(2).error(`"${g}" comparisons are not supported for type '${ft(b.type)}'.`);if(a.type.kind!==b.type.kind&&"value"!==a.type.kind&&"value"!==b.type.kind)return c.error(`Cannot compare types '${ft(a.type)}' and '${ft(b.type)}'.`);d&&("value"===a.type.kind&&"value"!==b.type.kind?a=new L(b.type,[a]):"value"!==a.type.kind&&"value"===b.type.kind&&(b=new L(a.type,[b])));let h=null;if(4===f.length){if("string"!==a.type.kind&&"string"!==b.type.kind&&"value"!==a.type.kind&&"value"!==b.type.kind)return c.error("Cannot use collator to compare non-string types.");if(!(h=c.parse(f[3],3,cg)))return null}return new e(a,b,h)}evaluate(e){const f=this.lhs.evaluate(e),g=this.rhs.evaluate(e);if(d&&this.hasUntypedArgument){const h=fE(f),i=fE(g);if(h.kind!==i.kind||"string"!==h.kind&&"number"!==h.kind)throw new fG(`Expected arguments for "${a}" to be (string, string) or (number, number), but found (${h.kind}, ${i.kind}) instead.`)}if(this.collator&&!d&&this.hasUntypedArgument){const j=fE(f),k=fE(g);if("string"!==j.kind||"string"!==k.kind)return b(e,f,g)}return this.collator?c(e,f,g,this.collator.evaluate(e)):b(e,f,g)}eachChild(a){a(this.lhs),a(this.rhs),this.collator&&a(this.collator)}outputDefined(){return!0}serialize(){const b=[a];return this.eachChild(a=>{b.push(a.serialize())}),b}}}const cE=A("==",function(c,a,b){return a===b},cD),cF=A("!=",function(c,a,b){return a!==b},function(d,a,b,c){return!cD(0,a,b,c)}),cG=A("<",function(c,a,b){return ac.compare(a,b)}),cH=A(">",function(c,a,b){return a>b},function(d,a,b,c){return c.compare(a,b)>0}),cI=A("<=",function(c,a,b){return a<=b},function(d,a,b,c){return 0>=c.compare(a,b)}),cJ=A(">=",function(c,a,b){return a>=b},function(d,a,b,c){return c.compare(a,b)>=0});class cK{constructor(a,b,c,d,e){this.type=i,this.number=a,this.locale=b,this.currency=c,this.minFractionDigits=d,this.maxFractionDigits=e}static parse(c,b){if(3!==c.length)return b.error("Expected two arguments.");const d=b.parse(c[1],1,f);if(!d)return null;const a=c[2];if("object"!=typeof a||Array.isArray(a))return b.error("NumberFormat options argument must be an object.");let e=null;if(a.locale&&!(e=b.parse(a.locale,1,i)))return null;let g=null;if(a.currency&&!(g=b.parse(a.currency,1,i)))return null;let h=null;if(a["min-fraction-digits"]&&!(h=b.parse(a["min-fraction-digits"],1,f)))return null;let j=null;return!a["max-fraction-digits"]||(j=b.parse(a["max-fraction-digits"],1,f))?new cK(d,e,g,h,j):null}evaluate(a){return new Intl.NumberFormat(this.locale?this.locale.evaluate(a):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(a):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(a):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(a):void 0}).format(this.number.evaluate(a))}eachChild(a){a(this.number),this.locale&&a(this.locale),this.currency&&a(this.currency),this.minFractionDigits&&a(this.minFractionDigits),this.maxFractionDigits&&a(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const a={};return this.locale&&(a.locale=this.locale.serialize()),this.currency&&(a.currency=this.currency.serialize()),this.minFractionDigits&&(a["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(a["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),a,]}}class cL{constructor(a){this.type=f,this.input=a}static parse(b,c){if(2!==b.length)return c.error(`Expected 1 argument, but found ${b.length-1} instead.`);const a=c.parse(b[1],1);return a?"array"!==a.type.kind&&"string"!==a.type.kind&&"value"!==a.type.kind?c.error(`Expected argument of type string or array, but found ${ft(a.type)} instead.`):new cL(a):null}evaluate(b){const a=this.input.evaluate(b);if("string"==typeof a)return a.length;if(Array.isArray(a))return a.length;throw new fG(`Expected value to be of type string or array, but found ${ft(fE(a))} instead.`)}eachChild(a){a(this.input)}outputDefined(){return!1}serialize(){const a=["length"];return this.eachChild(b=>{a.push(b.serialize())}),a}}const U={"==":cE,"!=":cF,">":cH,"<":cG,">=":cJ,"<=":cI,array:L,at:cx,boolean:L,case:cB,coalesce:cv,collator:cn,format:cl,image:cm,in:cy,"index-of":cz,interpolate:ai,"interpolate-hcl":ai,"interpolate-lab":ai,length:cL,let:cw,literal:ck,match:cA,number:L,"number-format":cK,object:L,slice:cC,step:cq,string:L,"to-boolean":T,"to-color":T,"to-number":T,"to-string":T,var:cp,within:co};function a$(b,[c,d,e,f]){c=c.evaluate(b),d=d.evaluate(b),e=e.evaluate(b);const a=f?f.evaluate(b):1,g=fC(c,d,e,a);if(g)throw new fG(g);return new m(c/255*a,d/255*a,e/255*a,a)}function gg(b,c){const a=c[b];return void 0===a?null:a}function x(a){return{type:a}}function gh(a){return{result:"success",value:a}}function gi(a){return{result:"error",value:a}}function gj(a){return"data-driven"===a["property-type"]||"cross-faded-data-driven"===a["property-type"]}function gk(a){return!!a.expression&&a.expression.parameters.indexOf("zoom")> -1}function gl(a){return!!a.expression&&a.expression.interpolated}function gm(a){return a instanceof Number?"number":a instanceof String?"string":a instanceof Boolean?"boolean":Array.isArray(a)?"array":null===a?"null":typeof a}function gn(a){return"object"==typeof a&&null!==a&&!Array.isArray(a)}function go(a){return a}function gp(a,e){const r="color"===e.type,g=a.stops&&"object"==typeof a.stops[0][0],s=g||!(g|| void 0!==a.property),b=a.type||(gl(e)?"exponential":"interval");if(r&&((a=ce({},a)).stops&&(a.stops=a.stops.map(a=>[a[0],m.parse(a[1]),])),a.default=m.parse(a.default?a.default:e.default)),a.colorSpace&&"rgb"!==a.colorSpace&&!gd[a.colorSpace])throw new Error(`Unknown color space: ${a.colorSpace}`);let f,j,t;if("exponential"===b)f=gt;else if("interval"===b)f=gs;else if("categorical"===b){for(const k of(f=gr,j=Object.create(null),a.stops))j[k[0]]=k[1];t=typeof a.stops[0][0]}else{if("identity"!==b)throw new Error(`Unknown function type "${b}"`);f=gu}if(g){const c={},l=[];for(let h=0;ha[0]),evaluate:({zoom:b},c)=>gt({stops:n,base:a.base},e,b).evaluate(b,c)}}if(s){const q="exponential"===b?{name:"exponential",base:void 0!==a.base?a.base:1}:null;return{kind:"camera",interpolationType:q,interpolationFactor:ai.interpolationFactor.bind(void 0,q),zoomStops:a.stops.map(a=>a[0]),evaluate:({zoom:b})=>f(a,e,b,j,t)}}return{kind:"source",evaluate(d,b){const c=b&&b.properties?b.properties[a.property]:void 0;return void 0===c?gq(a.default,e.default):f(a,e,c,j,t)}}}function gq(a,b,c){return void 0!==a?a:void 0!==b?b:void 0!==c?c:void 0}function gr(b,c,a,d,e){return gq(typeof a===e?d[a]:void 0,b.default,c.default)}function gs(a,d,b){if("number"!==gm(b))return gq(a.default,d.default);const c=a.stops.length;if(1===c)return a.stops[0][1];if(b<=a.stops[0][0])return a.stops[0][1];if(b>=a.stops[c-1][0])return a.stops[c-1][1];const e=f3(a.stops.map(a=>a[0]),b);return a.stops[e][1]}function gt(a,e,b){const h=void 0!==a.base?a.base:1;if("number"!==gm(b))return gq(a.default,e.default);const d=a.stops.length;if(1===d)return a.stops[0][1];if(b<=a.stops[0][0])return a.stops[0][1];if(b>=a.stops[d-1][0])return a.stops[d-1][1];const c=f3(a.stops.map(a=>a[0]),b),i=function(e,a,c,f){const b=f-c,d=e-c;return 0===b?0:1===a?d/b:(Math.pow(a,d)-1)/(Math.pow(a,b)-1)}(b,h,a.stops[c][0],a.stops[c+1][0]),f=a.stops[c][1],j=a.stops[c+1][1];let g=f4[e.type]||go;if(a.colorSpace&&"rgb"!==a.colorSpace){const k=gd[a.colorSpace];g=(a,b)=>k.reverse(k.interpolate(k.forward(a),k.forward(b),i))}return"function"==typeof f.evaluate?{evaluate(...a){const b=f.evaluate.apply(void 0,a),c=j.evaluate.apply(void 0,a);if(void 0!==b&& void 0!==c)return g(b,c,i)}}:g(f,j,i)}function gu(c,b,a){return"color"===b.type?a=m.parse(a):"formatted"===b.type?a=fB.fromString(a.toString()):"resolvedImage"===b.type?a=cj.fromString(a.toString()):gm(a)===b.type||"enum"===b.type&&b.values[a]||(a=void 0),gq(a,c.default,b.default)}aX.register(U,{error:[{kind:"error"},[i],(a,[b])=>{throw new fG(b.evaluate(a))},],typeof:[i,[l],(a,[b])=>ft(fE(b.evaluate(a))),],"to-rgba":[z(f,4),[y],(a,[b])=>b.evaluate(a).toArray(),],rgb:[y,[f,f,f],a$],rgba:[y,[f,f,f,f],a$],has:{type:h,overloads:[[[i],(a,[d])=>{var b,c;return b=d.evaluate(a),c=a.properties(),b in c},],[[i,K],(a,[b,c])=>b.evaluate(a) in c.evaluate(a),],]},get:{type:l,overloads:[[[i],(a,[b])=>gg(b.evaluate(a),a.properties()),],[[i,K],(a,[b,c])=>gg(b.evaluate(a),c.evaluate(a)),],]},"feature-state":[l,[i],(a,[b])=>gg(b.evaluate(a),a.featureState||{}),],properties:[K,[],a=>a.properties()],"geometry-type":[i,[],a=>a.geometryType()],id:[l,[],a=>a.id()],zoom:[f,[],a=>a.globals.zoom],pitch:[f,[],a=>a.globals.pitch||0],"distance-from-center":[f,[],a=>a.distanceFromCenter(),],"heatmap-density":[f,[],a=>a.globals.heatmapDensity||0,],"line-progress":[f,[],a=>a.globals.lineProgress||0,],"sky-radial-progress":[f,[],a=>a.globals.skyRadialProgress||0,],accumulated:[l,[],a=>void 0===a.globals.accumulated?null:a.globals.accumulated,],"+":[f,x(f),(b,c)=>{let a=0;for(const d of c)a+=d.evaluate(b);return a},],"*":[f,x(f),(b,c)=>{let a=1;for(const d of c)a*=d.evaluate(b);return a},],"-":{type:f,overloads:[[[f,f],(a,[b,c])=>b.evaluate(a)-c.evaluate(a),],[[f],(a,[b])=>-b.evaluate(a)],]},"/":[f,[f,f],(a,[b,c])=>b.evaluate(a)/c.evaluate(a),],"%":[f,[f,f],(a,[b,c])=>b.evaluate(a)%c.evaluate(a),],ln2:[f,[],()=>Math.LN2],pi:[f,[],()=>Math.PI],e:[f,[],()=>Math.E],"^":[f,[f,f],(a,[b,c])=>Math.pow(b.evaluate(a),c.evaluate(a)),],sqrt:[f,[f],(a,[b])=>Math.sqrt(b.evaluate(a)),],log10:[f,[f],(a,[b])=>Math.log(b.evaluate(a))/Math.LN10,],ln:[f,[f],(a,[b])=>Math.log(b.evaluate(a))],log2:[f,[f],(a,[b])=>Math.log(b.evaluate(a))/Math.LN2,],sin:[f,[f],(a,[b])=>Math.sin(b.evaluate(a)),],cos:[f,[f],(a,[b])=>Math.cos(b.evaluate(a)),],tan:[f,[f],(a,[b])=>Math.tan(b.evaluate(a)),],asin:[f,[f],(a,[b])=>Math.asin(b.evaluate(a)),],acos:[f,[f],(a,[b])=>Math.acos(b.evaluate(a)),],atan:[f,[f],(a,[b])=>Math.atan(b.evaluate(a)),],min:[f,x(f),(b,a)=>Math.min(...a.map(a=>a.evaluate(b))),],max:[f,x(f),(b,a)=>Math.max(...a.map(a=>a.evaluate(b))),],abs:[f,[f],(a,[b])=>Math.abs(b.evaluate(a)),],round:[f,[f],(b,[c])=>{const a=c.evaluate(b);return a<0?-Math.round(-a):Math.round(a)},],floor:[f,[f],(a,[b])=>Math.floor(b.evaluate(a)),],ceil:[f,[f],(a,[b])=>Math.ceil(b.evaluate(a)),],"filter-==":[h,[i,l],(a,[b,c])=>a.properties()[b.value]===c.value,],"filter-id-==":[h,[l],(a,[b])=>a.id()===b.value,],"filter-type-==":[h,[i],(a,[b])=>a.geometryType()===b.value,],"filter-<":[h,[i,l],(c,[d,e])=>{const a=c.properties()[d.value],b=e.value;return typeof a==typeof b&&a{const a=c.id(),b=d.value;return typeof a==typeof b&&a":[h,[i,l],(c,[d,e])=>{const a=c.properties()[d.value],b=e.value;return typeof a==typeof b&&a>b},],"filter-id->":[h,[l],(c,[d])=>{const a=c.id(),b=d.value;return typeof a==typeof b&&a>b},],"filter-<=":[h,[i,l],(c,[d,e])=>{const a=c.properties()[d.value],b=e.value;return typeof a==typeof b&&a<=b},],"filter-id-<=":[h,[l],(c,[d])=>{const a=c.id(),b=d.value;return typeof a==typeof b&&a<=b},],"filter->=":[h,[i,l],(c,[d,e])=>{const a=c.properties()[d.value],b=e.value;return typeof a==typeof b&&a>=b},],"filter-id->=":[h,[l],(c,[d])=>{const a=c.id(),b=d.value;return typeof a==typeof b&&a>=b},],"filter-has":[h,[l],(a,[b])=>b.value in a.properties(),],"filter-has-id":[h,[],a=>null!==a.id()&& void 0!==a.id(),],"filter-type-in":[h,[z(i)],(a,[b])=>b.value.indexOf(a.geometryType())>=0,],"filter-id-in":[h,[z(l)],(a,[b])=>b.value.indexOf(a.id())>=0,],"filter-in-small":[h,[i,z(l)],(a,[b,c])=>c.value.indexOf(a.properties()[b.value])>=0,],"filter-in-large":[h,[i,z(l)],(b,[c,a])=>(function(d,e,b,c){for(;b<=c;){const a=b+c>>1;if(e[a]===d)return!0;e[a]>d?c=a-1:b=a+1}return!1})(b.properties()[c.value],a.value,0,a.value.length-1),],all:{type:h,overloads:[[[h,h],(a,[b,c])=>b.evaluate(a)&&c.evaluate(a),],[x(h),(a,b)=>{for(const c of b)if(!c.evaluate(a))return!1;return!0},],]},any:{type:h,overloads:[[[h,h],(a,[b,c])=>b.evaluate(a)||c.evaluate(a),],[x(h),(a,b)=>{for(const c of b)if(c.evaluate(a))return!0;return!1},],]},"!":[h,[h],(a,[b])=>!b.evaluate(a)],"is-supported-script":[h,[i],(a,[c])=>{const b=a.globals&&a.globals.isSupportedScript;return!b||b(c.evaluate(a))},],upcase:[i,[i],(a,[b])=>b.evaluate(a).toUpperCase(),],downcase:[i,[i],(a,[b])=>b.evaluate(a).toLowerCase(),],concat:[i,x(l),(b,a)=>a.map(a=>fF(a.evaluate(b))).join(""),],"resolved-locale":[i,[cg],(a,[b])=>b.evaluate(a).resolvedLocale(),]});class cM{constructor(c,b){var a;this.expression=c,this._warningHistory={},this._evaluator=new fK,this._defaultValue=b?"color"===(a=b).type&&gn(a.default)?new m(0,0,0,0):"color"===a.type?m.parse(a.default)||null:void 0===a.default?null:a.default:null,this._enumValues=b&&"enum"===b.type?b.values:null}evaluateWithoutErrorHandling(a,b,c,d,e,f,g,h){return this._evaluator.globals=a,this._evaluator.feature=b,this._evaluator.featureState=c,this._evaluator.canonical=d,this._evaluator.availableImages=e||null,this._evaluator.formattedSection=f,this._evaluator.featureTileCoord=g||null,this._evaluator.featureDistanceData=h||null,this.expression.evaluate(this._evaluator)}evaluate(c,d,e,f,g,h,i,j){this._evaluator.globals=c,this._evaluator.feature=d||null,this._evaluator.featureState=e||null,this._evaluator.canonical=f,this._evaluator.availableImages=g||null,this._evaluator.formattedSection=h||null,this._evaluator.featureTileCoord=i||null,this._evaluator.featureDistanceData=j||null;try{const a=this.expression.evaluate(this._evaluator);if(null==a||"number"==typeof a&&a!=a)return this._defaultValue;if(this._enumValues&&!(a in this._enumValues))throw new fG(`Expected value to be one of ${Object.keys(this._enumValues).map(a=>JSON.stringify(a)).join(", ")}, but found ${JSON.stringify(a)} instead.`);return a}catch(b){return this._warningHistory[b.message]||(this._warningHistory[b.message]=!0,"undefined"!=typeof console&&console.warn(b.message)),this._defaultValue}}}function gv(a){return Array.isArray(a)&&a.length>0&&"string"==typeof a[0]&&a[0]in U}function cN(d,a){const b=new f1(U,[],a?function(a){const b={color:y,string:i,number:f,enum:i,boolean:h,formatted:ch,resolvedImage:ci};return"array"===a.type?z(b[a.value]||l,a.length):b[a.type]}(a):void 0),c=b.parse(d,void 0,void 0,void 0,a&&"string"===a.type?{typeAnnotation:"coerce"}:void 0);return c?gh(new cM(c,a)):gi(b.errors)}class cO{constructor(a,b){this.kind=a,this._styleExpression=b,this.isStateDependent="constant"!==a&&!f_(b.expression)}evaluateWithoutErrorHandling(a,b,c,d,e,f){return this._styleExpression.evaluateWithoutErrorHandling(a,b,c,d,e,f)}evaluate(a,b,c,d,e,f){return this._styleExpression.evaluate(a,b,c,d,e,f)}}class cP{constructor(a,b,c,d){this.kind=a,this.zoomStops=c,this._styleExpression=b,this.isStateDependent="camera"!==a&&!f_(b.expression),this.interpolationType=d}evaluateWithoutErrorHandling(a,b,c,d,e,f){return this._styleExpression.evaluateWithoutErrorHandling(a,b,c,d,e,f)}evaluate(a,b,c,d,e,f){return this._styleExpression.evaluate(a,b,c,d,e,f)}interpolationFactor(a,b,c){return this.interpolationType?ai.interpolationFactor(this.interpolationType,a,b,c):0}}function gw(b,c){if("error"===(b=cN(b,c)).result)return b;const d=b.value.expression,e=f$(d);if(!e&&!gj(c))return gi([new fr("","data expressions not supported"),]);const f=f0(d,["zoom","pitch","distance-from-center",]);if(!f&&!gk(c))return gi([new fr("","zoom expressions not supported"),]);const a=gx(d);return a||f?a instanceof fr?gi([a]):a instanceof ai&&!gl(c)?gi([new fr("",'"interpolate" expressions cannot be used with this property'),]):gh(a?new cP(e?"camera":"composite",b.value,a.labels,a instanceof ai?a.interpolation:void 0):new cO(e?"constant":"source",b.value)):gi([new fr("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'),])}class cQ{constructor(a,b){this._parameters=a,this._specification=b,ce(this,gp(this._parameters,this._specification))}static deserialize(a){return new cQ(a._parameters,a._specification)}static serialize(a){return{_parameters:a._parameters,_specification:a._specification}}}function gx(a){let b=null;if(a instanceof cw)b=gx(a.result);else if(a instanceof cv){for(const c of a.args)if(b=gx(c))break}else(a instanceof cq||a instanceof ai)&&a.input instanceof aX&&"zoom"===a.input.name&&(b=a);return b instanceof fr||a.eachChild(c=>{const a=gx(c);a instanceof fr?b=a:!b&&a?b=new fr("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):b&&a&&b!==a&&(b=new fr("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),b}function cR(c){const d=c.key,a=c.value,b=c.valueSpec||{},f=c.objectElementValidators||{},l=c.style,m=c.styleSpec;let g=[];const k=gm(a);if("object"!==k)return[new cc(d,a,`object expected, ${k} found`),];for(const e in a){const j=e.split(".")[0],n=b[j]||b["*"];let h;if(f[j])h=f[j];else if(b[j])h=gR;else if(f["*"])h=f["*"];else{if(!b["*"]){g.push(new cc(d,a[e],`unknown property "${e}"`));continue}h=gR}g=g.concat(h({key:(d?`${d}.`:d)+e,value:a[e],valueSpec:n,style:l,styleSpec:m,object:a,objectKey:e},a))}for(const i in b)f[i]||b[i].required&& void 0===b[i].default&& void 0===a[i]&&g.push(new cc(d,a,`missing required property "${i}"`));return g}function cS(c){const b=c.value,a=c.valueSpec,i=c.style,h=c.styleSpec,e=c.key,j=c.arrayElementValidator||gR;if("array"!==gm(b))return[new cc(e,b,`array expected, ${gm(b)} found`),];if(a.length&&b.length!==a.length)return[new cc(e,b,`array length ${a.length} expected, length ${b.length} found`),];if(a["min-length"]&&b.lengthg)return[new cc(e,a,`${a} is greater than the maximum value ${g}`),]}return[]}function cU(a){function f(c){let d=[];const a=c.value,b=c.key;if("array"!==gm(a))return[new cc(b,a,`array expected, ${gm(a)} found`),];if(2!==a.length)return[new cc(b,a,`array length 2 expected, length ${a.length} found`),];if(e){if("object"!==gm(a[0]))return[new cc(b,a,`object expected, ${gm(a[0])} found`),];if(void 0===a[0].zoom)return[new cc(b,a,"object stop key must have zoom"),];if(void 0===a[0].value)return[new cc(b,a,"object stop key must have value"),];if(k&&k>fp(a[0].zoom))return[new cc(b,a[0].zoom,"stop zoom values must appear in ascending order"),];fp(a[0].zoom)!==k&&(k=fp(a[0].zoom),j=void 0,l={}),d=d.concat(cR({key:`${b}[0]`,value:a[0],valueSpec:{zoom:{}},style:c.style,styleSpec:c.styleSpec,objectElementValidators:{zoom:cT,value:g}}))}else d=d.concat(g({key:`${b}[0]`,value:a[0],valueSpec:{},style:c.style,styleSpec:c.styleSpec},a));return gv(fq(a[1]))?d.concat([new cc(`${b}[1]`,a[1],"expressions are not allowed in function stops."),]):d.concat(gR({key:`${b}[1]`,value:a[1],valueSpec:h,style:c.style,styleSpec:c.styleSpec}))}function g(a,g){const b=gm(a.value),d=fp(a.value),e=null!==a.value?a.value:g;if(i){if(b!==i)return[new cc(a.key,e,`${b} stop domain type must match previous stop domain type ${i}`),]}else i=b;if("number"!==b&&"string"!==b&&"boolean"!==b)return[new cc(a.key,e,"stop domain value must be a number, string, or boolean"),];if("number"!==b&&"categorical"!==c){let f=`number expected, ${b} found`;return gj(h)&& void 0===c&&(f+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new cc(a.key,e,f)]}return"categorical"!==c||"number"!==b||isFinite(d)&&Math.floor(d)===d?"categorical"!==c&&"number"===b&& void 0!==j&&d=8&&(d||gj(a.valueSpec)?d&&!gk(a.valueSpec)&&b.push(new cc(a.key,a.value,"zoom functions not supported")):b.push(new cc(a.key,a.value,"property functions not supported"))),("categorical"===c||e)&& void 0===a.value.property&&b.push(new cc(a.key,a.value,'"property" property is required')),b}function gy(a){const c=("property"===a.expressionContext?gw:cN)(fq(a.value),a.valueSpec);if("error"===c.result)return c.value.map(b=>new cc(`${a.key}${b.key}`,a.value,b.message));const b=c.value.expression||c.value._styleExpression.expression;if("property"===a.expressionContext&&"text-font"===a.propertyKey&&!b.outputDefined())return[new cc(a.key,a.value,`Invalid data expression for "${a.propertyKey}". Output values must be contained as literals within the expression.`),];if("property"===a.expressionContext&&"layout"===a.propertyType&&!f_(b))return[new cc(a.key,a.value,'"feature-state" data expressions are not supported with layout properties.'),];if("filter"===a.expressionContext)return gz(b,a);if(a.expressionContext&&0===a.expressionContext.indexOf("cluster")){if(!f0(b,["zoom","feature-state"]))return[new cc(a.key,a.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.'),];if("cluster-initial"===a.expressionContext&&!f$(b))return[new cc(a.key,a.value,"Feature data expressions are not supported with initial expression part of cluster properties."),]}return[]}function gz(b,a){const c=new Set(["zoom","feature-state","pitch","distance-from-center",]);for(const d of a.valueSpec.expression.parameters)c.delete(d);if(0===c.size)return[];const e=[];return b instanceof aX&&c.has(b.name)?[new cc(a.key,a.value,`["${b.name}"] expression is not supported in a filter for a ${a.object.type} layer with id: ${a.object.id}`),]:(b.eachChild(b=>{e.push(...gz(b,a))}),e)}function cV(c){const e=c.key,a=c.value,b=c.valueSpec,d=[];return Array.isArray(b.values)?-1===b.values.indexOf(fp(a))&&d.push(new cc(e,a,`expected one of [${b.values.join(", ")}], ${JSON.stringify(a)} found`)):-1===Object.keys(b.values).indexOf(fp(a))&&d.push(new cc(e,a,`expected one of [${Object.keys(b.values).join(", ")}], ${JSON.stringify(a)} found`)),d}function gA(a){if(!0===a|| !1===a)return!0;if(!Array.isArray(a)||0===a.length)return!1;switch(a[0]){case"has":return a.length>=2&&"$id"!==a[1]&&"$type"!==a[1];case"in":return a.length>=3&&("string"!=typeof a[1]||Array.isArray(a[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==a.length||Array.isArray(a[1])||Array.isArray(a[2]);case"any":case"all":for(const b of a.slice(1))if(!gA(b)&&"boolean"!=typeof b)return!1;return!0;default:return!0}}function gB(a,k="fill"){if(null==a)return{filter:()=>!0,needGeometry:!1,needFeature:!1};gA(a)||(a=gI(a));const c=a;let d=!0;try{d=function(a){if(!gE(a))return a;let b=fq(a);return gD(b),b=gC(b)}(c)}catch(l){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate. +(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[634],{6158:function(b,c,a){var d=a(3454);!function(c,a){b.exports=a()}(this,function(){"use strict";var c,e,b;function a(g,a){if(c){if(e){var f="self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; ("+c+")(sharedChunk); ("+e+")(sharedChunk); self.onerror = null;",d={};c(d),b=a(d),"undefined"!=typeof window&&window&&window.URL&&window.URL.createObjectURL&&(b.workerUrl=window.URL.createObjectURL(new Blob([f],{type:"text/javascript"})))}else e=a}else c=a}return a(["exports"],function(a){var bq="2.7.0",eG=H;function H(a,c,d,b){this.cx=3*a,this.bx=3*(d-a)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*c,this.by=3*(b-c)-this.cy,this.ay=1-this.cy-this.by,this.p1x=a,this.p1y=b,this.p2x=d,this.p2y=b}H.prototype.sampleCurveX=function(a){return((this.ax*a+this.bx)*a+this.cx)*a},H.prototype.sampleCurveY=function(a){return((this.ay*a+this.by)*a+this.cy)*a},H.prototype.sampleCurveDerivativeX=function(a){return(3*this.ax*a+2*this.bx)*a+this.cx},H.prototype.solveCurveX=function(c,e){var b,d,a,f,g;for(void 0===e&&(e=1e-6),a=c,g=0;g<8;g++){if(Math.abs(f=this.sampleCurveX(a)-c)Math.abs(h))break;a-=f/h}if((a=c)<(b=0))return b;if(a>(d=1))return d;for(;bf?b=a:d=a,a=.5*(d-b)+b;return a},H.prototype.solve=function(a,b){return this.sampleCurveY(this.solveCurveX(a,b))};var aF=aG;function aG(a,b){this.x=a,this.y=b}aG.prototype={clone:function(){return new aG(this.x,this.y)},add:function(a){return this.clone()._add(a)},sub:function(a){return this.clone()._sub(a)},multByPoint:function(a){return this.clone()._multByPoint(a)},divByPoint:function(a){return this.clone()._divByPoint(a)},mult:function(a){return this.clone()._mult(a)},div:function(a){return this.clone()._div(a)},rotate:function(a){return this.clone()._rotate(a)},rotateAround:function(a,b){return this.clone()._rotateAround(a,b)},matMult:function(a){return this.clone()._matMult(a)},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(a){return this.x===a.x&&this.y===a.y},dist:function(a){return Math.sqrt(this.distSqr(a))},distSqr:function(a){var b=a.x-this.x,c=a.y-this.y;return b*b+c*c},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(a){return Math.atan2(this.y-a.y,this.x-a.x)},angleWith:function(a){return this.angleWithSep(a.x,a.y)},angleWithSep:function(a,b){return Math.atan2(this.x*b-this.y*a,this.x*a+this.y*b)},_matMult:function(a){var b=a[2]*this.x+a[3]*this.y;return this.x=a[0]*this.x+a[1]*this.y,this.y=b,this},_add:function(a){return this.x+=a.x,this.y+=a.y,this},_sub:function(a){return this.x-=a.x,this.y-=a.y,this},_mult:function(a){return this.x*=a,this.y*=a,this},_div:function(a){return this.x/=a,this.y/=a,this},_multByPoint:function(a){return this.x*=a.x,this.y*=a.y,this},_divByPoint:function(a){return this.x/=a.x,this.y/=a.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var a=this.y;return this.y=this.x,this.x=-a,this},_rotate:function(a){var b=Math.cos(a),c=Math.sin(a),d=c*this.x+b*this.y;return this.x=b*this.x-c*this.y,this.y=d,this},_rotateAround:function(b,a){var c=Math.cos(b),d=Math.sin(b),e=a.y+d*(this.x-a.x)+c*(this.y-a.y);return this.x=a.x+c*(this.x-a.x)-d*(this.y-a.y),this.y=e,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},aG.convert=function(a){return a instanceof aG?a:Array.isArray(a)?new aG(a[0],a[1]):a};var s="undefined"!=typeof self?self:{},I="undefined"!=typeof Float32Array?Float32Array:Array;function aH(){var a=new I(9);return I!=Float32Array&&(a[1]=0,a[2]=0,a[3]=0,a[5]=0,a[6]=0,a[7]=0),a[0]=1,a[4]=1,a[8]=1,a}function aI(a){return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=1,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a}function aJ(a,b,c){var h=b[0],i=b[1],j=b[2],k=b[3],l=b[4],m=b[5],n=b[6],o=b[7],p=b[8],q=b[9],r=b[10],s=b[11],t=b[12],u=b[13],v=b[14],w=b[15],d=c[0],e=c[1],f=c[2],g=c[3];return a[0]=d*h+e*l+f*p+g*t,a[1]=d*i+e*m+f*q+g*u,a[2]=d*j+e*n+f*r+g*v,a[3]=d*k+e*o+f*s+g*w,a[4]=(d=c[4])*h+(e=c[5])*l+(f=c[6])*p+(g=c[7])*t,a[5]=d*i+e*m+f*q+g*u,a[6]=d*j+e*n+f*r+g*v,a[7]=d*k+e*o+f*s+g*w,a[8]=(d=c[8])*h+(e=c[9])*l+(f=c[10])*p+(g=c[11])*t,a[9]=d*i+e*m+f*q+g*u,a[10]=d*j+e*n+f*r+g*v,a[11]=d*k+e*o+f*s+g*w,a[12]=(d=c[12])*h+(e=c[13])*l+(f=c[14])*p+(g=c[15])*t,a[13]=d*i+e*m+f*q+g*u,a[14]=d*j+e*n+f*r+g*v,a[15]=d*k+e*o+f*s+g*w,a}function br(b,a,f){var r,g,h,i,j,k,l,m,n,o,p,q,c=f[0],d=f[1],e=f[2];return a===b?(b[12]=a[0]*c+a[4]*d+a[8]*e+a[12],b[13]=a[1]*c+a[5]*d+a[9]*e+a[13],b[14]=a[2]*c+a[6]*d+a[10]*e+a[14],b[15]=a[3]*c+a[7]*d+a[11]*e+a[15]):(g=a[1],h=a[2],i=a[3],j=a[4],k=a[5],l=a[6],m=a[7],n=a[8],o=a[9],p=a[10],q=a[11],b[0]=r=a[0],b[1]=g,b[2]=h,b[3]=i,b[4]=j,b[5]=k,b[6]=l,b[7]=m,b[8]=n,b[9]=o,b[10]=p,b[11]=q,b[12]=r*c+j*d+n*e+a[12],b[13]=g*c+k*d+o*e+a[13],b[14]=h*c+l*d+p*e+a[14],b[15]=i*c+m*d+q*e+a[15]),b}function bs(a,b,f){var c=f[0],d=f[1],e=f[2];return a[0]=b[0]*c,a[1]=b[1]*c,a[2]=b[2]*c,a[3]=b[3]*c,a[4]=b[4]*d,a[5]=b[5]*d,a[6]=b[6]*d,a[7]=b[7]*d,a[8]=b[8]*e,a[9]=b[9]*e,a[10]=b[10]*e,a[11]=b[11]*e,a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15],a}function bt(a,b,e){var c=Math.sin(e),d=Math.cos(e),f=b[4],g=b[5],h=b[6],i=b[7],j=b[8],k=b[9],l=b[10],m=b[11];return b!==a&&(a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]),a[4]=f*d+j*c,a[5]=g*d+k*c,a[6]=h*d+l*c,a[7]=i*d+m*c,a[8]=j*d-f*c,a[9]=k*d-g*c,a[10]=l*d-h*c,a[11]=m*d-i*c,a}function bu(a,b,e){var c=Math.sin(e),d=Math.cos(e),f=b[0],g=b[1],h=b[2],i=b[3],j=b[8],k=b[9],l=b[10],m=b[11];return b!==a&&(a[4]=b[4],a[5]=b[5],a[6]=b[6],a[7]=b[7],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]),a[0]=f*d-j*c,a[1]=g*d-k*c,a[2]=h*d-l*c,a[3]=i*d-m*c,a[8]=f*c+j*d,a[9]=g*c+k*d,a[10]=h*c+l*d,a[11]=i*c+m*d,a}Math.hypot||(Math.hypot=function(){for(var b=0,a=arguments.length;a--;)b+=arguments[a]*arguments[a];return Math.sqrt(b)});var bv=aJ;function aK(){var a=new I(3);return I!=Float32Array&&(a[0]=0,a[1]=0,a[2]=0),a}function eH(b){var a=new I(3);return a[0]=b[0],a[1]=b[1],a[2]=b[2],a}function aL(a){return Math.hypot(a[0],a[1],a[2])}function Q(b,c,d){var a=new I(3);return a[0]=b,a[1]=c,a[2]=d,a}function bw(a,b,c){return a[0]=b[0]+c[0],a[1]=b[1]+c[1],a[2]=b[2]+c[2],a}function aM(a,b,c){return a[0]=b[0]-c[0],a[1]=b[1]-c[1],a[2]=b[2]-c[2],a}function aN(a,b,c){return a[0]=b[0]*c[0],a[1]=b[1]*c[1],a[2]=b[2]*c[2],a}function eI(a,b,c){return a[0]=Math.max(b[0],c[0]),a[1]=Math.max(b[1],c[1]),a[2]=Math.max(b[2],c[2]),a}function bx(a,b,c){return a[0]=b[0]*c,a[1]=b[1]*c,a[2]=b[2]*c,a}function by(a,b,c,d){return a[0]=b[0]+c[0]*d,a[1]=b[1]+c[1]*d,a[2]=b[2]+c[2]*d,a}function bz(c,a){var d=a[0],e=a[1],f=a[2],b=d*d+e*e+f*f;return b>0&&(b=1/Math.sqrt(b)),c[0]=a[0]*b,c[1]=a[1]*b,c[2]=a[2]*b,c}function bA(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]}function bB(a,b,c){var d=b[0],e=b[1],f=b[2],g=c[0],h=c[1],i=c[2];return a[0]=e*i-f*h,a[1]=f*g-d*i,a[2]=d*h-e*g,a}function bC(b,g,a){var c=g[0],d=g[1],e=g[2],f=a[3]*c+a[7]*d+a[11]*e+a[15];return b[0]=(a[0]*c+a[4]*d+a[8]*e+a[12])/(f=f||1),b[1]=(a[1]*c+a[5]*d+a[9]*e+a[13])/f,b[2]=(a[2]*c+a[6]*d+a[10]*e+a[14])/f,b}function bD(a,h,b){var c=b[0],d=b[1],e=b[2],i=h[0],j=h[1],k=h[2],l=d*k-e*j,f=e*i-c*k,g=c*j-d*i,p=d*g-e*f,n=e*l-c*g,o=c*f-d*l,m=2*b[3];return f*=m,g*=m,n*=2,o*=2,a[0]=i+(l*=m)+(p*=2),a[1]=j+f+n,a[2]=k+g+o,a}var J,bE=aM;function bF(b,c,a){var d=c[0],e=c[1],f=c[2],g=c[3];return b[0]=a[0]*d+a[4]*e+a[8]*f+a[12]*g,b[1]=a[1]*d+a[5]*e+a[9]*f+a[13]*g,b[2]=a[2]*d+a[6]*e+a[10]*f+a[14]*g,b[3]=a[3]*d+a[7]*e+a[11]*f+a[15]*g,b}function aO(){var a=new I(4);return I!=Float32Array&&(a[0]=0,a[1]=0,a[2]=0),a[3]=1,a}function bG(a){return a[0]=0,a[1]=0,a[2]=0,a[3]=1,a}function bH(a,b,e){e*=.5;var f=b[0],g=b[1],h=b[2],i=b[3],c=Math.sin(e),d=Math.cos(e);return a[0]=f*d+i*c,a[1]=g*d+h*c,a[2]=h*d-g*c,a[3]=i*d-f*c,a}function eJ(a,b){return a[0]===b[0]&&a[1]===b[1]}aK(),J=new I(4),I!=Float32Array&&(J[0]=0,J[1]=0,J[2]=0,J[3]=0),aK(),Q(1,0,0),Q(0,1,0),aO(),aO(),aH(),lr=new I(2),I!=Float32Array&&(lr[0]=0,lr[1]=0);const aP=Math.PI/180,eK=180/Math.PI;function bI(a){return a*aP}function bJ(a){return a*eK}const eL=[[0,0],[1,0],[1,1],[0,1],];function bK(a){if(a<=0)return 0;if(a>=1)return 1;const b=a*a,c=b*a;return 4*(a<.5?c:3*(a-b)+c-.75)}function aQ(a,b,c,d){const e=new eG(a,b,c,d);return function(a){return e.solve(a)}}const bL=aQ(.25,.1,.25,1);function bM(a,b,c){return Math.min(c,Math.max(b,a))}function bN(b,c,a){return(a=bM((a-b)/(c-b),0,1))*a*(3-2*a)}function bO(e,a,c){const b=c-a,d=((e-a)%b+b)%b+a;return d===a?c:d}function bP(a,c,b){if(!a.length)return b(null,[]);let d=a.length;const e=new Array(a.length);let f=null;a.forEach((a,g)=>{c(a,(a,c)=>{a&&(f=a),e[g]=c,0== --d&&b(f,e)})})}function bQ(a){const b=[];for(const c in a)b.push(a[c]);return b}function bR(a,...d){for(const b of d)for(const c in b)a[c]=b[c];return a}let eM=1;function bS(){return eM++}function eN(){return function b(a){return a?(a^16*Math.random()>>a/4).toString(16):([1e7]+ -[1e3]+ -4e3+ -8e3+ -1e11).replace(/[018]/g,b)}()}function bT(a){return a<=1?1:Math.pow(2,Math.ceil(Math.log(a)/Math.LN2))}function eO(a){return!!a&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(a)}function bU(a,b){a.forEach(a=>{b[a]&&(b[a]=b[a].bind(b))})}function bV(a,b){return -1!==a.indexOf(b,a.length-b.length)}function eP(a,d,e){const c={};for(const b in a)c[b]=d.call(e||this,a[b],b,a);return c}function bW(a,d,e){const c={};for(const b in a)d.call(e||this,a[b],b,a)&&(c[b]=a[b]);return c}function bX(a){return Array.isArray(a)?a.map(bX):"object"==typeof a&&a?eP(a,bX):a}const eQ={};function bY(a){eQ[a]||("undefined"!=typeof console&&console.warn(a),eQ[a]=!0)}function eR(a,b,c){return(c.y-a.y)*(b.x-a.x)>(b.y-a.y)*(c.x-a.x)}function eS(a){let e=0;for(let b,c,d=0,f=a.length,g=f-1;d@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(f,c,d,e)=>{const b=d||e;return a[c]=!b||b.toLowerCase(),""}),a["max-age"]){const b=parseInt(a["max-age"],10);isNaN(b)?delete a["max-age"]:a["max-age"]=b}return a}let eU,af,eV,eW=null;function eX(b){if(null==eW){const a=b.navigator?b.navigator.userAgent:null;eW=!!b.safari||!(!a||!(/\b(iPad|iPhone|iPod)\b/.test(a)||a.match("Safari")&&!a.match("Chrome")))}return eW}function eY(b){try{const a=s[b];return a.setItem("_mapbox_test_",1),a.removeItem("_mapbox_test_"),!0}catch(c){return!1}}const b$={now:()=>void 0!==eV?eV:s.performance.now(),setNow(a){eV=a},restoreNow(){eV=void 0},frame(a){const b=s.requestAnimationFrame(a);return{cancel:()=>s.cancelAnimationFrame(b)}},getImageData(a,b=0){const c=s.document.createElement("canvas"),d=c.getContext("2d");if(!d)throw new Error("failed to create canvas 2d context");return c.width=a.width,c.height=a.height,d.drawImage(a,0,0,a.width,a.height),d.getImageData(-b,-b,a.width+2*b,a.height+2*b)},resolveURL:a=>(eU||(eU=s.document.createElement("a")),eU.href=a,eU.href),get devicePixelRatio(){return s.devicePixelRatio},get prefersReducedMotion(){return!!s.matchMedia&&(null==af&&(af=s.matchMedia("(prefers-reduced-motion: reduce)")),af.matches)}};let R;const b_={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(null==R){const aR=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{R=null!=d.env.API_URL_REGEX?new RegExp(d.env.API_URL_REGEX):aR}catch(eZ){R=aR}}return R},get EVENTS_URL(){return this.API_URL?0===this.API_URL.indexOf("https://api.mapbox.cn")?"https://events.mapbox.cn/events/v2":0===this.API_URL.indexOf("https://api.mapbox.com")?"https://events.mapbox.com/events/v2":null: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,MAX_PARALLEL_IMAGE_REQUESTS:16},b0={supported:!1,testSupport:function(a){!e_&&ag&&(e0?e1(a):e$=a)}};let e$,ag,e_=!1,e0=!1;function e1(a){const b=a.createTexture();a.bindTexture(a.TEXTURE_2D,b);try{if(a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,ag),a.isContextLost())return;b0.supported=!0}catch(c){}a.deleteTexture(b),e_=!0}s.document&&((ag=s.document.createElement("img")).onload=function(){e$&&e1(e$),e$=null,e0=!0},ag.onerror=function(){e_=!0,e$=null},ag.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const b1="NO_ACCESS_TOKEN";function b2(a){return 0===a.indexOf("mapbox:")}function e2(a){return b_.API_URL_REGEX.test(a)}const e3=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function e4(b){const a=b.match(e3);if(!a)throw new Error("Unable to parse URL object");return{protocol:a[1],authority:a[2],path:a[3]||"/",params:a[4]?a[4].split("&"):[]}}function e5(a){const b=a.params.length?`?${a.params.join("&")}`:"";return`${a.protocol}://${a.authority}${a.path}${b}`}function e6(b){if(!b)return null;const a=b.split(".");if(!a||3!==a.length)return null;try{return JSON.parse(decodeURIComponent(s.atob(a[1]).split("").map(a=>"%"+("00"+a.charCodeAt(0).toString(16)).slice(-2)).join("")))}catch(c){return null}}class e7{constructor(a){this.type=a,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(c){const a=e6(b_.ACCESS_TOKEN);let b="";return b=a&&a.u?s.btoa(encodeURIComponent(a.u).replace(/%([0-9A-F]{2})/g,(b,a)=>String.fromCharCode(Number("0x"+a)))):b_.ACCESS_TOKEN||"",c?`mapbox.eventData.${c}:${b}`:`mapbox.eventData:${b}`}fetchEventData(){const c=eY("localStorage"),d=this.getStorageKey(),e=this.getStorageKey("uuid");if(c)try{const a=s.localStorage.getItem(d);a&&(this.eventData=JSON.parse(a));const b=s.localStorage.getItem(e);b&&(this.anonId=b)}catch(f){bY("Unable to read from LocalStorage")}}saveEventData(){const a=eY("localStorage"),b=this.getStorageKey(),c=this.getStorageKey("uuid");if(a)try{s.localStorage.setItem(c,this.anonId),Object.keys(this.eventData).length>=1&&s.localStorage.setItem(b,JSON.stringify(this.eventData))}catch(d){bY("Unable to write to LocalStorage")}}processRequests(a){}postEvent(d,a,h,e){if(!b_.EVENTS_URL)return;const b=e4(b_.EVENTS_URL);b.params.push(`access_token=${e||b_.ACCESS_TOKEN||""}`);const c={event:this.type,created:new Date(d).toISOString(),sdkIdentifier:"mapbox-gl-js",sdkVersion:bq,skuId:"01",userId:this.anonId},f=a?bR(c,a):c,g={url:e5(b),headers:{"Content-Type":"text/plain"},body:JSON.stringify([f])};this.pendingRequest=fj(g,a=>{this.pendingRequest=null,h(a),this.saveEventData(),this.processRequests(e)})}queueRequest(a,b){this.queue.push(a),this.processRequests(b)}}const aS=new class extends e7{constructor(a){super("appUserTurnstile"),this._customAccessToken=a}postTurnstileEvent(a,b){b_.EVENTS_URL&&b_.ACCESS_TOKEN&&Array.isArray(a)&&a.some(a=>b2(a)||e2(a))&&this.queueRequest(Date.now(),b)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const c=e6(b_.ACCESS_TOKEN),f=c?c.u:b_.ACCESS_TOKEN;let a=f!==this.eventData.tokenU;eO(this.anonId)||(this.anonId=eN(),a=!0);const b=this.queue.shift();if(this.eventData.lastSuccess){const g=new Date(this.eventData.lastSuccess),h=new Date(b),d=(b-this.eventData.lastSuccess)/864e5;a=a||d>=1||d< -1||g.getDate()!==h.getDate()}else a=!0;if(!a)return this.processRequests();this.postEvent(b,{"enabled.telemetry":!1},a=>{a||(this.eventData.lastSuccess=b,this.eventData.tokenU=f)},e)}},b3=aS.postTurnstileEvent.bind(aS),aT=new class extends e7{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(b,c,a,d){this.skuToken=c,this.errorCb=d,b_.EVENTS_URL&&(a||b_.ACCESS_TOKEN?this.queueRequest({id:b,timestamp:Date.now()},a):this.errorCb(new Error(b1)))}processRequests(b){if(this.pendingRequest||0===this.queue.length)return;const{id:a,timestamp:c}=this.queue.shift();a&&this.success[a]||(this.anonId||this.fetchEventData(),eO(this.anonId)||(this.anonId=eN()),this.postEvent(c,{skuToken:this.skuToken},b=>{b?this.errorCb(b):a&&(this.success[a]=!0)},b))}},b4=aT.postMapLoadEvent.bind(aT),aU=new class extends e7{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(e,b,f,c){if(!b_.API_URL||!b_.SESSION_PATH)return;const a=e4(b_.API_URL+b_.SESSION_PATH);a.params.push(`sku=${b||""}`),a.params.push(`access_token=${c||b_.ACCESS_TOKEN||""}`);const d={url:e5(a),headers:{"Content-Type":"text/plain"}};this.pendingRequest=fk(d,a=>{this.pendingRequest=null,f(a),this.saveEventData(),this.processRequests(c)})}getSessionAPI(b,c,a,d){this.skuToken=c,this.errorCb=d,b_.SESSION_PATH&&b_.API_URL&&(a||b_.ACCESS_TOKEN?this.queueRequest({id:b,timestamp:Date.now()},a):this.errorCb(new Error(b1)))}processRequests(b){if(this.pendingRequest||0===this.queue.length)return;const{id:a,timestamp:c}=this.queue.shift();a&&this.success[a]||this.getSession(c,this.skuToken,b=>{b?this.errorCb(b):a&&(this.success[a]=!0)},b)}},b5=aU.getSessionAPI.bind(aU),e8=new Set,e9="mapbox-tiles";let fa,fb,fc=500,fd=50;function fe(){s.caches&&!fa&&(fa=s.caches.open(e9))}function ff(a){const b=a.indexOf("?");return b<0?a:a.slice(0,b)}let fg=1/0;const aV={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};"function"==typeof Object.freeze&&Object.freeze(aV);class fh extends Error{constructor(a,b,c){401===b&&e2(c)&&(a+=": you may have provided an invalid Mapbox access token. See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes"),super(a),this.status=b,this.url=c}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const b6=bZ()?()=>self.worker&&self.worker.referrer:()=>("blob:"===s.location.protocol?s.parent:s).location.href,b7=function(a,b){var c;if(!(/^file:/.test(c=a.url)||/^file:/.test(b6())&&!/^\w+:/.test(c))){if(s.fetch&&s.Request&&s.AbortController&&s.Request.prototype.hasOwnProperty("signal"))return function(a,g){var c;const e=new s.AbortController,b=new s.Request(a.url,{method:a.method||"GET",body:a.body,credentials:a.credentials,headers:a.headers,referrer:b6(),signal:e.signal});let h=!1,i=!1;const f=(c=b.url).indexOf("sku=")>0&&e2(c);"json"===a.type&&b.headers.set("Accept","application/json");const d=(c,d,e)=>{if(i)return;if(c&&"SecurityError"!==c.message&&bY(c),d&&e)return j(d);const h=Date.now();s.fetch(b).then(b=>{if(b.ok){const c=f?b.clone():null;return j(b,c,h)}return g(new fh(b.statusText,b.status,a.url))}).catch(a=>{20!==a.code&&g(new Error(a.message))})},j=(c,d,e)=>{("arrayBuffer"===a.type?c.arrayBuffer():"json"===a.type?c.json():c.text()).then(a=>{i||(d&&e&&function(e,a,c){if(fe(),!fa)return;const d={status:a.status,statusText:a.statusText,headers:new s.Headers};a.headers.forEach((a,b)=>d.headers.set(b,a));const b=eT(a.headers.get("Cache-Control")||"");b["no-store"]||(b["max-age"]&&d.headers.set("Expires",new Date(c+1e3*b["max-age"]).toUTCString()),new Date(d.headers.get("Expires")).getTime()-c<42e4||function(a,b){if(void 0===fb)try{new Response(new ReadableStream),fb=!0}catch(c){fb=!1}fb?b(a.body):a.blob().then(b)}(a,a=>{const b=new s.Response(a,d);fe(),fa&&fa.then(a=>a.put(ff(e.url),b)).catch(a=>bY(a.message))}))}(b,d,e),h=!0,g(null,a,c.headers.get("Cache-Control"),c.headers.get("Expires")))}).catch(a=>{i||g(new Error(a.message))})};return f?function(b,a){if(fe(),!fa)return a(null);const c=ff(b.url);fa.then(b=>{b.match(c).then(d=>{const e=function(a){if(!a)return!1;const b=new Date(a.headers.get("Expires")||0),c=eT(a.headers.get("Cache-Control")||"");return b>Date.now()&&!c["no-cache"]}(d);b.delete(c),e&&b.put(c,d.clone()),a(null,d,e)}).catch(a)}).catch(a)}(b,d):d(null,null),{cancel(){i=!0,h||e.abort()}}}(a,b);if(bZ()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",a,b,void 0,!0)}return function(b,d){const a=new s.XMLHttpRequest;for(const c in a.open(b.method||"GET",b.url,!0),"arrayBuffer"===b.type&&(a.responseType="arraybuffer"),b.headers)a.setRequestHeader(c,b.headers[c]);return"json"===b.type&&(a.responseType="text",a.setRequestHeader("Accept","application/json")),a.withCredentials="include"===b.credentials,a.onerror=()=>{d(new Error(a.statusText))},a.onload=()=>{if((a.status>=200&&a.status<300||0===a.status)&&null!==a.response){let c=a.response;if("json"===b.type)try{c=JSON.parse(a.response)}catch(e){return d(e)}d(null,c,a.getResponseHeader("Cache-Control"),a.getResponseHeader("Expires"))}else d(new fh(a.statusText,a.status,b.url))},a.send(b.body),{cancel:()=>a.abort()}}(a,b)},fi=function(a,b){return b7(bR(a,{type:"arrayBuffer"}),b)},fj=function(a,b){return b7(bR(a,{method:"POST"}),b)},fk=function(a,b){return b7(bR(a,{method:"GET"}),b)};function fl(b){const a=s.document.createElement("a");return a.href=b,a.protocol===s.document.location.protocol&&a.host===s.document.location.host}const fm="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let b8,b9;b8=[],b9=0;const ca=function(a,c){if(b0.supported&&(a.headers||(a.headers={}),a.headers.accept="image/webp,*/*"),b9>=b_.MAX_PARALLEL_IMAGE_REQUESTS){const b={requestParameters:a,callback:c,cancelled:!1,cancel(){this.cancelled=!0}};return b8.push(b),b}b9++;let d=!1;const e=()=>{if(!d)for(d=!0,b9--;b8.length&&b9{e(),b?c(b):a&&(s.createImageBitmap?function(a,c){const b=new s.Blob([new Uint8Array(a)],{type:"image/png"});s.createImageBitmap(b).then(a=>{c(null,a)}).catch(a=>{c(new Error(`Could not load image because of ${a.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(a,(a,b)=>c(a,b,d,f)):function(b,e){const a=new s.Image,c=s.URL;a.onload=()=>{e(null,a),c.revokeObjectURL(a.src),a.onload=null,s.requestAnimationFrame(()=>{a.src=fm})},a.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 d=new s.Blob([new Uint8Array(b)],{type:"image/png"});a.src=b.byteLength?c.createObjectURL(d):fm}(a,(a,b)=>c(a,b,d,f)))});return{cancel(){f.cancel(),e()}}};function fn(a,c,b){b[a]&& -1!==b[a].indexOf(c)||(b[a]=b[a]||[],b[a].push(c))}function fo(b,d,a){if(a&&a[b]){const c=a[b].indexOf(d);-1!==c&&a[b].splice(c,1)}}class aW{constructor(a,b={}){bR(this,b),this.type=a}}class cb extends aW{constructor(a,b={}){super("error",bR({error:a},b))}}class S{on(a,b){return this._listeners=this._listeners||{},fn(a,b,this._listeners),this}off(a,b){return fo(a,b,this._listeners),fo(a,b,this._oneTimeListeners),this}once(b,a){return a?(this._oneTimeListeners=this._oneTimeListeners||{},fn(b,a,this._oneTimeListeners),this):new Promise(a=>this.once(b,a))}fire(a,e){"string"==typeof a&&(a=new aW(a,e||{}));const b=a.type;if(this.listens(b)){a.target=this;const f=this._listeners&&this._listeners[b]?this._listeners[b].slice():[];for(const g of f)g.call(this,a);const h=this._oneTimeListeners&&this._oneTimeListeners[b]?this._oneTimeListeners[b].slice():[];for(const c of h)fo(b,c,this._oneTimeListeners),c.call(this,a);const d=this._eventedParent;d&&(bR(a,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),d.fire(a))}else a instanceof cb&&console.error(a.error);return this}listens(a){return!!(this._listeners&&this._listeners[a]&&this._listeners[a].length>0||this._oneTimeListeners&&this._oneTimeListeners[a]&&this._oneTimeListeners[a].length>0||this._eventedParent&&this._eventedParent.listens(a))}setEventedParent(a,b){return this._eventedParent=a,this._eventedParentData=b,this}}var b=JSON.parse('{"$version":8,"$root":{"version":{"required":true,"type":"enum","values":[8]},"name":{"type":"string"},"metadata":{"type":"*"},"center":{"type":"array","value":"number"},"zoom":{"type":"number"},"bearing":{"type":"number","default":0,"period":360,"units":"degrees"},"pitch":{"type":"number","default":0,"units":"degrees"},"light":{"type":"light"},"terrain":{"type":"terrain"},"fog":{"type":"fog"},"sources":{"required":true,"type":"sources"},"sprite":{"type":"string"},"glyphs":{"type":"string"},"transition":{"type":"transition"},"projection":{"type":"projection"},"layers":{"required":true,"type":"array","value":"layer"}},"sources":{"*":{"type":"source"}},"source":["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],"source_vector":{"type":{"required":true,"type":"enum","values":{"vector":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"attribution":{"type":"string"},"promoteId":{"type":"promoteId"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster":{"type":{"required":true,"type":"enum","values":{"raster":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"attribution":{"type":"string"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_dem":{"type":{"required":true,"type":"enum","values":{"raster-dem":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"attribution":{"type":"string"},"encoding":{"type":"enum","values":{"terrarium":{},"mapbox":{}},"default":"mapbox"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_geojson":{"type":{"required":true,"type":"enum","values":{"geojson":{}}},"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":{}}},"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":{}}},"url":{"required":true,"type":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"layer":{"id":{"type":"string","required":true},"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"raster":{},"hillshade":{},"background":{},"sky":{}},"required":true},"metadata":{"type":"*"},"source":{"type":"string"},"source-layer":{"type":"string"},"minzoom":{"type":"number","minimum":0,"maximum":24},"maxzoom":{"type":"number","minimum":0,"maximum":24},"filter":{"type":"filter"},"layout":{"type":"layout"},"paint":{"type":"paint"}},"layout":["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background","layout_sky"],"layout_background":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_sky":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_circle":{"circle-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_heatmap":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill-extrusion":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_line":{"line-cap":{"type":"enum","values":{"butt":{},"round":{},"square":{}},"default":"butt","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-join":{"type":"enum","values":{"bevel":{},"round":{},"miter":{}},"default":"miter","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"requires":[{"line-join":"miter"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-round-limit":{"type":"number","default":1.05,"requires":[{"line-join":"round"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_symbol":{"symbol-placement":{"type":"enum","values":{"point":{},"line":{},"line-center":{}},"default":"point","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-spacing":{"type":"number","default":250,"minimum":1,"units":"pixels","requires":[{"symbol-placement":"line"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","values":{"auto":{},"viewport-y":{},"source":{}},"default":"auto","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-optional":{"type":"boolean","default":false,"requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-size":{"type":"number","default":1,"minimum":0,"units":"factor of the original icon size","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{"type":"enum","values":{"none":{},"width":{},"height":{},"both":{}},"default":"none","requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{"type":"array","value":"number","length":4,"default":[0,0,0,0],"units":"pixels","requires":["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-image":{"type":"resolvedImage","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-keep-upright":{"type":"boolean","default":false,"requires":["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-offset":{"type":"array","value":"number","length":2,"default":[0,0],"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-field":{"type":"formatted","default":"","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-font":{"type":"array","value":"string","default":["Open Sans Regular","Arial Unicode MS Regular"],"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size":{"type":"number","default":16,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{"type":"number","default":10,"minimum":0,"units":"ems","requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-justify":{"type":"enum","values":{"auto":{},"left":{},"center":{},"right":{}},"default":"center","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{"type":"number","units":"ems","default":0,"requires":["text-field"],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["zoom","feature"]}},"text-variable-anchor":{"type":"array","value":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["text-field",{"!":"text-variable-anchor"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{"type":"number","default":45,"units":"degrees","requires":["text-field",{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":{},"vertical":{}},"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-keep-upright":{"type":"boolean","default":true,"requires":["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-transform":{"type":"enum","values":{"none":{},"uppercase":{},"lowercase":{}},"default":"none","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-offset":{"type":"array","value":"number","units":"ems","length":2,"default":[0,0],"requires":["text-field",{"!":"text-radial-offset"}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-optional":{"type":"boolean","default":false,"requires":["text-field","icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_raster":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_hillshade":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"filter":{"type":"array","value":"*"},"filter_symbol":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature","pitch","distance-from-center"]}},"filter_fill":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_line":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_circle":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_fill-extrusion":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_heatmap":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_operator":{"type":"enum","values":{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},"in":{},"!in":{},"all":{},"any":{},"none":{},"has":{},"!has":{},"within":{}}},"geometry_type":{"type":"enum","values":{"Point":{},"LineString":{},"Polygon":{}}},"function":{"expression":{"type":"expression"},"stops":{"type":"array","value":"function_stop"},"base":{"type":"number","default":1,"minimum":0},"property":{"type":"string","default":"$zoom"},"type":{"type":"enum","values":{"identity":{},"exponential":{},"interval":{},"categorical":{}},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":{},"lab":{},"hcl":{}},"default":"rgb"},"default":{"type":"*","required":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"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"horizon-blend":{"type":"number","property-type":"data-constant","default":0.1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":{},"viewport":{}},"property-type":"data-constant","transition":false,"expression":{"interpolated":false,"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":{},"equalEarth":{},"equirectangular":{},"lambertConformalConic":{},"mercator":{},"naturalEarth":{},"winkelTripel":{}},"default":"mercator","required":true},"center":{"type":"array","length":2,"value":"number","property-type":"data-constant","transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]},"parallels":{"type":"array","length":2,"value":"number","property-type":"data-constant","transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]}},"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_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"interpolated":false,"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"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","transition":true,"requires":[{"!":"fill-pattern"},{"fill-antialias":true}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"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,"requires":[{"!":"fill-extrusion-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-extrusion-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"requires":["fill-extrusion-height"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"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"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"line-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["line-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"transition":true,"units":"line widths","requires":[{"!":"line-pattern"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{"type":"color","transition":false,"requires":[{"!":"line-pattern"},{"source":"geojson","has":{"lineMetrics":true}}],"expression":{"interpolated":true,"parameters":["line-progress"]},"property-type":"color-ramp"}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["circle-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"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"]},"property-type":"data-driven"}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"transition":false,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"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"],"transition":false,"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,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["icon-image","icon-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","transition":true,"overridable":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["text-field","text-translate"],"expression":{"interpolated":false,"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-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"units":"degrees","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":{},"nearest":{}},"default":"linear","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"transition":false,"units":"milliseconds","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"transition":false,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"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"]},"property-type":"data-constant"},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_background":{"background-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"background-pattern"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"cross-faded"},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":{},"atmosphere":{}},"default":"atmosphere","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"requires":[{"sky-type":"atmosphere"}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun-intensity":{"type":"number","requires":[{"sky-type":"atmosphere"}],"default":10,"minimum":0,"maximum":100,"transition":false,"property-type":"data-constant"},"sky-gradient-center":{"type":"array","requires":[{"sky-type":"gradient"}],"value":"number","default":[0,0],"length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient-radius":{"type":"number","requires":[{"sky-type":"gradient"}],"default":90,"minimum":0,"maximum":180,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"transition":false,"requires":[{"sky-type":"gradient"}],"expression":{"interpolated":true,"parameters":["sky-radial-progress"]},"property-type":"color-ramp"},"sky-atmosphere-halo-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-atmosphere-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"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"}},"transition":{"duration":{"type":"number","default":300,"minimum":0,"units":"milliseconds"},"delay":{"type":"number","default":0,"minimum":0,"units":"milliseconds"}},"property-type":{"data-driven":{"type":"property-type"},"cross-faded":{"type":"property-type"},"cross-faded-data-driven":{"type":"property-type"},"color-ramp":{"type":"property-type"},"data-constant":{"type":"property-type"},"constant":{"type":"property-type"}},"promoteId":{"*":{"type":"string"}}}');class cc{constructor(b,a,d,c){this.message=(b?`${b}: `:"")+d,c&&(this.identifier=c),null!=a&&a.__line__&&(this.line=a.__line__)}}function cd(a){const b=a.value;return b?[new cc(a.key,b,"constants have been deprecated as of v8"),]:[]}function ce(a,...d){for(const b of d)for(const c in b)a[c]=b[c];return a}function fp(a){return a instanceof Number||a instanceof String||a instanceof Boolean?a.valueOf():a}function fq(a){if(Array.isArray(a))return a.map(fq);if(a instanceof Object&&!(a instanceof Number||a instanceof String||a instanceof Boolean)){const b={};for(const c in a)b[c]=fq(a[c]);return b}return fp(a)}class fr extends Error{constructor(b,a){super(a),this.message=a,this.key=b}}class fs{constructor(a,b=[]){for(const[c,d]of(this.parent=a,this.bindings={},b))this.bindings[c]=d}concat(a){return new fs(this,a)}get(a){if(this.bindings[a])return this.bindings[a];if(this.parent)return this.parent.get(a);throw new Error(`${a} not found in scope.`)}has(a){return!!this.bindings[a]|| !!this.parent&&this.parent.has(a)}}const cf={kind:"null"},f={kind:"number"},i={kind:"string"},h={kind:"boolean"},y={kind:"color"},K={kind:"object"},l={kind:"value"},cg={kind:"collator"},ch={kind:"formatted"},ci={kind:"resolvedImage"};function z(a,b){return{kind:"array",itemType:a,N:b}}function ft(a){if("array"===a.kind){const b=ft(a.itemType);return"number"==typeof a.N?`array<${b}, ${a.N}>`:"value"===a.itemType.kind?"array":`array<${b}>`}return a.kind}const fu=[cf,f,i,h,y,ch,K,z(l),ci];function fv(b,a){if("error"===a.kind)return null;if("array"===b.kind){if("array"===a.kind&&(0===a.N&&"value"===a.itemType.kind||!fv(b.itemType,a.itemType))&&("number"!=typeof b.N||b.N===a.N))return null}else{if(b.kind===a.kind)return null;if("value"===b.kind){for(const c of fu)if(!fv(c,a))return null}}return`Expected ${ft(b)} but found ${ft(a)} instead.`}function fw(b,a){return a.some(a=>a.kind===b.kind)}function fx(b,a){return a.some(a=>"null"===a?null===b:"array"===a?Array.isArray(b):"object"===a?b&&!Array.isArray(b)&&"object"==typeof b:a===typeof b)}function ah(b){var a={exports:{}};return b(a,a.exports),a.exports}var fy=ah(function(b,a){var c={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 d(a){return(a=Math.round(a))<0?0:a>255?255:a}function e(a){return d("%"===a[a.length-1]?parseFloat(a)/100*255:parseInt(a))}function f(a){var b;return(b="%"===a[a.length-1]?parseFloat(a)/100:parseFloat(a))<0?0:b>1?1:b}function g(b,c,a){return a<0?a+=1:a>1&&(a-=1),6*a<1?b+(c-b)*a*6:2*a<1?c:3*a<2?b+(c-b)*(2/3-a)*6:b}try{a.parseCSSColor=function(q){var a,b=q.replace(/ /g,"").toLowerCase();if(b in c)return c[b].slice();if("#"===b[0])return 4===b.length?(a=parseInt(b.substr(1),16))>=0&&a<=4095?[(3840&a)>>4|(3840&a)>>8,240&a|(240&a)>>4,15&a|(15&a)<<4,1,]:null:7===b.length&&(a=parseInt(b.substr(1),16))>=0&&a<=16777215?[(16711680&a)>>16,(65280&a)>>8,255&a,1,]:null;var j=b.indexOf("("),p=b.indexOf(")");if(-1!==j&&p+1===b.length){var r=b.substr(0,j),h=b.substr(j+1,p-(j+1)).split(","),k=1;switch(r){case"rgba":if(4!==h.length)break;k=f(h.pop());case"rgb":return 3!==h.length?null:[e(h[0]),e(h[1]),e(h[2]),k,];case"hsla":if(4!==h.length)break;k=f(h.pop());case"hsl":if(3!==h.length)break;var m=(parseFloat(h[0])%360+360)%360/360,n=f(h[1]),i=f(h[2]),l=i<=.5?i*(n+1):i+n-i*n,o=2*i-l;return[d(255*g(o,l,m+1/3)),d(255*g(o,l,m)),d(255*g(o,l,m-1/3)),k,]}}return null}}catch(h){}});class m{constructor(a,b,c,d=1){this.r=a,this.g=b,this.b=c,this.a=d}static parse(b){if(!b)return;if(b instanceof m)return b;if("string"!=typeof b)return;const a=fy.parseCSSColor(b);return a?new m(a[0]/255*a[3],a[1]/255*a[3],a[2]/255*a[3],a[3]):void 0}toString(){const[a,b,c,d]=this.toArray();return`rgba(${Math.round(a)},${Math.round(b)},${Math.round(c)},${d})`}toArray(){const{r:b,g:c,b:d,a:a}=this;return 0===a?[0,0,0,0]:[255*b/a,255*c/a,255*d/a,a,]}}m.black=new m(0,0,0,1),m.white=new m(1,1,1,1),m.transparent=new m(0,0,0,0),m.red=new m(1,0,0,1),m.blue=new m(0,0,1,1);class fz{constructor(b,a,c){this.sensitivity=b?a?"variant":"case":a?"accent":"base",this.locale=c,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(a,b){return this.collator.compare(a,b)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class fA{constructor(a,b,c,d,e){this.text=a.normalize?a.normalize():a,this.image=b,this.scale=c,this.fontStack=d,this.textColor=e}}class fB{constructor(a){this.sections=a}static fromString(a){return new fB([new fA(a,null,null,null,null),])}isEmpty(){return 0===this.sections.length||!this.sections.some(a=>0!==a.text.length||a.image&&0!==a.image.name.length)}static factory(a){return a instanceof fB?a:fB.fromString(a)}toString(){return 0===this.sections.length?"":this.sections.map(a=>a.text).join("")}serialize(){const b=["format"];for(const a of this.sections){if(a.image){b.push(["image",a.image.name]);continue}b.push(a.text);const c={};a.fontStack&&(c["text-font"]=["literal",a.fontStack.split(","),]),a.scale&&(c["font-scale"]=a.scale),a.textColor&&(c["text-color"]=["rgba"].concat(a.textColor.toArray())),b.push(c)}return b}}class cj{constructor(a){this.name=a.name,this.available=a.available}toString(){return this.name}static fromString(a){return a?new cj({name:a,available:!1}):null}serialize(){return["image",this.name]}}function fC(b,c,d,a){return"number"==typeof b&&b>=0&&b<=255&&"number"==typeof c&&c>=0&&c<=255&&"number"==typeof d&&d>=0&&d<=255?void 0===a||"number"==typeof a&&a>=0&&a<=1?null:`Invalid rgba value [${[b,c,d,a].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof a?[b,c,d,a]:[b,c,d]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function fD(a){if(null===a||"string"==typeof a||"boolean"==typeof a||"number"==typeof a||a instanceof m||a instanceof fz||a instanceof fB||a instanceof cj)return!0;if(Array.isArray(a)){for(const b of a)if(!fD(b))return!1;return!0}if("object"==typeof a){for(const c in a)if(!fD(a[c]))return!1;return!0}return!1}function fE(a){if(null===a)return cf;if("string"==typeof a)return i;if("boolean"==typeof a)return h;if("number"==typeof a)return f;if(a instanceof m)return y;if(a instanceof fz)return cg;if(a instanceof fB)return ch;if(a instanceof cj)return ci;if(Array.isArray(a)){const d=a.length;let b;for(const e of a){const c=fE(e);if(b){if(b===c)continue;b=l;break}b=c}return z(b||l,d)}return K}function fF(a){const b=typeof a;return null===a?"":"string"===b||"number"===b||"boolean"===b?String(a):a instanceof m||a instanceof fB||a instanceof cj?a.toString():JSON.stringify(a)}class ck{constructor(a,b){this.type=a,this.value=b}static parse(b,d){if(2!==b.length)return d.error(`'literal' expression requires exactly one argument, but found ${b.length-1} instead.`);if(!fD(b[1]))return d.error("invalid value");const e=b[1];let c=fE(e);const a=d.expectedType;return"array"===c.kind&&0===c.N&&a&&"array"===a.kind&&("number"!=typeof a.N||0===a.N)&&(c=a),new ck(c,e)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof m?["rgba"].concat(this.value.toArray()):this.value instanceof fB?this.value.serialize():this.value}}class fG{constructor(a){this.name="ExpressionEvaluationError",this.message=a}toJSON(){return this.message}}const fH={string:i,number:f,boolean:h,object:K};class L{constructor(a,b){this.type=a,this.args=b}static parse(a,c){if(a.length<2)return c.error("Expected at least one argument.");let e,b=1;const g=a[0];if("array"===g){let f,h;if(a.length>2){const d=a[1];if("string"!=typeof d||!(d in fH)||"object"===d)return c.error('The item type argument of "array" must be one of string, number, boolean',1);f=fH[d],b++}else f=l;if(a.length>3){if(null!==a[2]&&("number"!=typeof a[2]||a[2]<0||a[2]!==Math.floor(a[2])))return c.error('The length argument to "array" must be a positive integer literal',2);h=a[2],b++}e=z(f,h)}else e=fH[g];const i=[];for(;ba.outputDefined())}serialize(){const a=this.type,c=[a.kind];if("array"===a.kind){const b=a.itemType;if("string"===b.kind||"number"===b.kind||"boolean"===b.kind){c.push(b.kind);const d=a.N;("number"==typeof d||this.args.length>1)&&c.push(d)}}return c.concat(this.args.map(a=>a.serialize()))}}class cl{constructor(a){this.type=ch,this.sections=a}static parse(c,b){if(c.length<2)return b.error("Expected at least one argument.");const m=c[1];if(!Array.isArray(m)&&"object"==typeof m)return b.error("First argument must be an image or text section.");const d=[];let h=!1;for(let e=1;e<=c.length-1;++e){const a=c[e];if(h&&"object"==typeof a&&!Array.isArray(a)){h=!1;let n=null;if(a["font-scale"]&&!(n=b.parse(a["font-scale"],1,f)))return null;let o=null;if(a["text-font"]&&!(o=b.parse(a["text-font"],1,z(i))))return null;let p=null;if(a["text-color"]&&!(p=b.parse(a["text-color"],1,y)))return null;const j=d[d.length-1];j.scale=n,j.font=o,j.textColor=p}else{const k=b.parse(c[e],1,l);if(!k)return null;const g=k.type.kind;if("string"!==g&&"value"!==g&&"null"!==g&&"resolvedImage"!==g)return b.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");h=!0,d.push({content:k,scale:null,font:null,textColor:null})}}return new cl(d)}evaluate(a){return new fB(this.sections.map(b=>{const c=b.content.evaluate(a);return fE(c)===ci?new fA("",c,null,null,null):new fA(fF(c),null,b.scale?b.scale.evaluate(a):null,b.font?b.font.evaluate(a).join(","):null,b.textColor?b.textColor.evaluate(a):null)}))}eachChild(b){for(const a of this.sections)b(a.content),a.scale&&b(a.scale),a.font&&b(a.font),a.textColor&&b(a.textColor)}outputDefined(){return!1}serialize(){const c=["format"];for(const a of this.sections){c.push(a.content.serialize());const b={};a.scale&&(b["font-scale"]=a.scale.serialize()),a.font&&(b["text-font"]=a.font.serialize()),a.textColor&&(b["text-color"]=a.textColor.serialize()),c.push(b)}return c}}class cm{constructor(a){this.type=ci,this.input=a}static parse(b,a){if(2!==b.length)return a.error("Expected two arguments.");const c=a.parse(b[1],1,i);return c?new cm(c):a.error("No image name provided.")}evaluate(a){const c=this.input.evaluate(a),b=cj.fromString(c);return b&&a.availableImages&&(b.available=a.availableImages.indexOf(c)> -1),b}eachChild(a){a(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const fI={"to-boolean":h,"to-color":y,"to-number":f,"to-string":i};class T{constructor(a,b){this.type=a,this.args=b}static parse(a,c){if(a.length<2)return c.error("Expected at least one argument.");const d=a[0];if(("to-boolean"===d||"to-string"===d)&&2!==a.length)return c.error("Expected one argument.");const g=fI[d],e=[];for(let b=1;b4?`Invalid rbga value ${JSON.stringify(a)}: expected an array containing either three or four numeric values.`:fC(a[0],a[1],a[2],a[3])))return new m(a[0]/255,a[1]/255,a[2]/255,a[3])}throw new fG(c||`Could not parse color from value '${"string"==typeof a?a:String(JSON.stringify(a))}'`)}if("number"===this.type.kind){let d=null;for(const h of this.args){if(null===(d=h.evaluate(b)))return 0;const f=Number(d);if(!isNaN(f))return f}throw new fG(`Could not convert ${JSON.stringify(d)} to number.`)}return"formatted"===this.type.kind?fB.fromString(fF(this.args[0].evaluate(b))):"resolvedImage"===this.type.kind?cj.fromString(fF(this.args[0].evaluate(b))):fF(this.args[0].evaluate(b))}eachChild(a){this.args.forEach(a)}outputDefined(){return this.args.every(a=>a.outputDefined())}serialize(){if("formatted"===this.type.kind)return new cl([{content:this.args[0],scale:null,font:null,textColor:null},]).serialize();if("resolvedImage"===this.type.kind)return new cm(this.args[0]).serialize();const a=[`to-${this.type.kind}`];return this.eachChild(b=>{a.push(b.serialize())}),a}}const fJ=["Unknown","Point","LineString","Polygon",];class fK{constructor(){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}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?fJ[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||{}}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const a=this.featureDistanceData.center,b=this.featureDistanceData.scale,{x:c,y:d}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(c*b-a[0])+this.featureDistanceData.bearing[1]*(d*b-a[1])}return 0}parseColor(a){let b=this._parseColorCache[a];return b||(b=this._parseColorCache[a]=m.parse(a)),b}}class aX{constructor(a,b,c,d){this.name=a,this.type=b,this._evaluate=c,this.args=d}evaluate(a){return this._evaluate(a,this.args)}eachChild(a){this.args.forEach(a)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(a=>a.serialize()))}static parse(f,c){const j=f[0],b=aX.definitions[j];if(!b)return c.error(`Unknown expression "${j}". If you wanted a literal array, use ["literal", [...]].`,0);const q=Array.isArray(b)?b[0]:b.type,m=Array.isArray(b)?[[b[1],b[2]]]:b.overloads,h=m.filter(([a])=>!Array.isArray(a)||a.length===f.length-1);let e=null;for(const[a,r]of h){e=new f1(c.registry,c.path,null,c.scope);const d=[];let n=!1;for(let i=1;i{var a;return a=b,Array.isArray(a)?`(${a.map(ft).join(", ")})`:`(${ft(a.type)}...)`}).join(" | "),k=[];for(let l=1;l=b[2]||a[1]<=b[1]||a[3]>=b[3])}function fN(a,c){const d=(180+a[0])/360,e=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+a[1]*Math.PI/360)))/360,b=Math.pow(2,c.z);return[Math.round(d*b*8192),Math.round(e*b*8192),]}function fO(a,b,c){const d=a[0]-b[0],e=a[1]-b[1],f=a[0]-c[0],g=a[1]-c[1];return d*g-f*e==0&&d*f<=0&&e*g<=0}function fP(h,i){var d,b,e;let f=!1;for(let g=0,j=i.length;g(d=h)[1]!=(e=c[a+1])[1]>d[1]&&d[0]<(e[0]-b[0])*(d[1]-b[1])/(e[1]-b[1])+b[0]&&(f=!f)}}return f}function fQ(c,b){for(let a=0;a0&&h<0||g<0&&h>0}function fS(i,j,k){var a,b,c,d,g,h;for(const f of k)for(let e=0;eb[2]){const d=.5*c;let e=a[0]-b[0]>d?-c:b[0]-a[0]>d?c:0;0===e&&(e=a[0]-b[2]>d?-c:b[2]-a[0]>d?c:0),a[0]+=e}fL(f,a)}function fY(f,g,h,a){const i=8192*Math.pow(2,a.z),b=[8192*a.x,8192*a.y],c=[];for(const j of f)for(const d of j){const e=[d.x+b[0],d.y+b[1]];fX(e,g,h,i),c.push(e)}return c}function fZ(j,a,k,c){var b;const e=8192*Math.pow(2,c.z),f=[8192*c.x,8192*c.y],d=[];for(const l of j){const g=[];for(const h of l){const i=[h.x+f[0],h.y+f[1]];fL(a,i),g.push(i)}d.push(g)}if(a[2]-a[0]<=e/2)for(const m of((b=a)[0]=b[1]=1/0,b[2]=b[3]=-1/0,d))for(const n of m)fX(n,a,k,e);return d}class co{constructor(a,b){this.type=h,this.geojson=a,this.geometries=b}static parse(b,d){if(2!==b.length)return d.error(`'within' expression requires exactly one argument, but found ${b.length-1} instead.`);if(fD(b[1])){const a=b[1];if("FeatureCollection"===a.type)for(let c=0;c{b&&!f$(a)&&(b=!1)}),b}function f_(a){if(a instanceof aX&&"feature-state"===a.name)return!1;let b=!0;return a.eachChild(a=>{b&&!f_(a)&&(b=!1)}),b}function f0(a,b){if(a instanceof aX&&b.indexOf(a.name)>=0)return!1;let c=!0;return a.eachChild(a=>{c&&!f0(a,b)&&(c=!1)}),c}class cp{constructor(b,a){this.type=a.type,this.name=b,this.boundExpression=a}static parse(c,b){if(2!==c.length||"string"!=typeof c[1])return b.error("'var' expression requires exactly one string literal argument.");const a=c[1];return b.scope.has(a)?new cp(a,b.scope.get(a)):b.error(`Unknown variable "${a}". Make sure "${a}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(a){return this.boundExpression.evaluate(a)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class f1{constructor(b,a=[],c,d=new fs,e=[]){this.registry=b,this.path=a,this.key=a.map(a=>`[${a}]`).join(""),this.scope=d,this.errors=e,this.expectedType=c}parse(a,b,d,e,c={}){return b?this.concat(b,d,e)._parse(a,c):this._parse(a,c)}_parse(a,f){function g(a,b,c){return"assert"===c?new L(b,[a]):"coerce"===c?new T(b,[a]):a}if(null!==a&&"string"!=typeof a&&"boolean"!=typeof a&&"number"!=typeof a||(a=["literal",a]),Array.isArray(a)){if(0===a.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const d=a[0];if("string"!=typeof d)return this.error(`Expression name must be a string, but found ${typeof d} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const h=this.registry[d];if(h){let b=h.parse(a,this);if(!b)return null;if(this.expectedType){const c=this.expectedType,e=b.type;if("string"!==c.kind&&"number"!==c.kind&&"boolean"!==c.kind&&"object"!==c.kind&&"array"!==c.kind||"value"!==e.kind){if("color"!==c.kind&&"formatted"!==c.kind&&"resolvedImage"!==c.kind||"value"!==e.kind&&"string"!==e.kind){if(this.checkSubtype(c,e))return null}else b=g(b,c,f.typeAnnotation||"coerce")}else b=g(b,c,f.typeAnnotation||"assert")}if(!(b instanceof ck)&&"resolvedImage"!==b.type.kind&&f2(b)){const i=new fK;try{b=new ck(b.type,b.evaluate(i))}catch(j){return this.error(j.message),null}}return b}return this.error(`Unknown expression "${d}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===a?"'undefined' value invalid. Use null instead.":"object"==typeof a?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof a} instead.`)}concat(a,c,b){const d="number"==typeof a?this.path.concat(a):this.path,e=b?this.scope.concat(b):this.scope;return new f1(this.registry,d,c||null,e,this.errors)}error(a,...b){const c=`${this.key}${b.map(a=>`[${a}]`).join("")}`;this.errors.push(new fr(c,a))}checkSubtype(b,c){const a=fv(b,c);return a&&this.error(a),a}}function f2(a){if(a instanceof cp)return f2(a.boundExpression);if(a instanceof aX&&"error"===a.name||a instanceof cn||a instanceof co)return!1;const c=a instanceof T||a instanceof L;let b=!0;return a.eachChild(a=>{b=c?b&&f2(a):b&&a instanceof ck}),!!b&&f$(a)&&f0(a,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center",])}function f3(b,c){const g=b.length-1;let d,h,e=0,f=g,a=0;for(;e<=f;)if(d=b[a=Math.floor((e+f)/2)],h=b[a+1],d<=c){if(a===g||cc))throw new fG("Input is not a number.");f=a-1}return 0}class cq{constructor(a,b,c){for(const[d,e]of(this.type=a,this.input=b,this.labels=[],this.outputs=[],c))this.labels.push(d),this.outputs.push(e)}static parse(b,a){if(b.length-1<4)return a.error(`Expected at least 4 arguments, but found only ${b.length-1}.`);if((b.length-1)%2!=0)return a.error("Expected an even number of arguments.");const i=a.parse(b[1],1,f);if(!i)return null;const d=[];let e=null;a.expectedType&&"value"!==a.expectedType.kind&&(e=a.expectedType);for(let c=1;c=g)return a.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',j);const h=a.parse(k,l,e);if(!h)return null;e=e||h.type,d.push([g,h])}return new cq(e,i,d)}evaluate(a){const b=this.labels,c=this.outputs;if(1===b.length)return c[0].evaluate(a);const d=this.input.evaluate(a);if(d<=b[0])return c[0].evaluate(a);const e=b.length;return d>=b[e-1]?c[e-1].evaluate(a):c[f3(b,d)].evaluate(a)}eachChild(a){for(const b of(a(this.input),this.outputs))a(b)}outputDefined(){return this.outputs.every(a=>a.outputDefined())}serialize(){const b=["step",this.input.serialize()];for(let a=0;a0&&b.push(this.labels[a]),b.push(this.outputs[a].serialize());return b}}function aY(b,c,a){return b*(1-a)+c*a}var f4=Object.freeze({__proto__:null,number:aY,color:function(a,b,c){return new m(aY(a.r,b.r,c),aY(a.g,b.g,c),aY(a.b,b.b,c),aY(a.a,b.a,c))},array:function(a,b,c){return a.map((a,d)=>aY(a,b[d],c))}});const f5=4/29,aZ=6/29,f6=3*aZ*aZ,f7=Math.PI/180,f8=180/Math.PI;function f9(a){return a>.008856451679035631?Math.pow(a,1/3):a/f6+f5}function ga(a){return a>aZ?a*a*a:f6*(a-f5)}function gb(a){return 255*(a<=.0031308?12.92*a:1.055*Math.pow(a,1/2.4)-.055)}function gc(a){return(a/=255)<=.04045?a/12.92:Math.pow((a+.055)/1.055,2.4)}function cr(a){const b=gc(a.r),c=gc(a.g),d=gc(a.b),f=f9((.4124564*b+.3575761*c+.1804375*d)/.95047),e=f9((.2126729*b+.7151522*c+.072175*d)/1);return{l:116*e-16,a:500*(f-e),b:200*(e-f9((.0193339*b+.119192*c+.9503041*d)/1.08883)),alpha:a.a}}function cs(b){let a=(b.l+16)/116,c=isNaN(b.a)?a:a+b.a/500,d=isNaN(b.b)?a:a-b.b/200;return a=1*ga(a),c=.95047*ga(c),d=1.08883*ga(d),new m(gb(3.2404542*c-1.5371385*a-.4985314*d),gb(-0.969266*c+1.8760108*a+.041556*d),gb(.0556434*c-.2040259*a+1.0572252*d),b.alpha)}const ct={forward:cr,reverse:cs,interpolate:function(a,b,c){return{l:aY(a.l,b.l,c),a:aY(a.a,b.a,c),b:aY(a.b,b.b,c),alpha:aY(a.alpha,b.alpha,c)}}},cu={forward:function(d){const{l:e,a:a,b:b}=cr(d),c=Math.atan2(b,a)*f8;return{h:c<0?c+360:c,c:Math.sqrt(a*a+b*b),l:e,alpha:d.a}},reverse:function(a){const b=a.h*f7,c=a.c;return cs({l:a.l,a:Math.cos(b)*c,b:Math.sin(b)*c,alpha:a.alpha})},interpolate:function(a,b,c){return{h:function(b,c,d){const a=c-b;return b+d*(a>180||a< -180?a-360*Math.round(a/360):a)}(a.h,b.h,c),c:aY(a.c,b.c,c),l:aY(a.l,b.l,c),alpha:aY(a.alpha,b.alpha,c)}}};var gd=Object.freeze({__proto__:null,lab:ct,hcl:cu});class ai{constructor(a,b,c,d,e){for(const[f,g]of(this.type=a,this.operator=b,this.interpolation=c,this.input=d,this.labels=[],this.outputs=[],e))this.labels.push(f),this.outputs.push(g)}static interpolationFactor(a,d,e,f){let b=0;if("exponential"===a.name)b=ge(d,a.base,e,f);else if("linear"===a.name)b=ge(d,1,e,f);else if("cubic-bezier"===a.name){const c=a.controlPoints;b=new eG(c[0],c[1],c[2],c[3]).solve(ge(d,1,e,f))}return b}static parse(g,a){let[h,b,i,...j]=g;if(!Array.isArray(b)||0===b.length)return a.error("Expected an interpolation type expression.",1);if("linear"===b[0])b={name:"linear"};else if("exponential"===b[0]){const n=b[1];if("number"!=typeof n)return a.error("Exponential interpolation requires a numeric base.",1,1);b={name:"exponential",base:n}}else{if("cubic-bezier"!==b[0])return a.error(`Unknown interpolation type ${String(b[0])}`,1,0);{const k=b.slice(1);if(4!==k.length||k.some(a=>"number"!=typeof a||a<0||a>1))return a.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);b={name:"cubic-bezier",controlPoints:k}}}if(g.length-1<4)return a.error(`Expected at least 4 arguments, but found only ${g.length-1}.`);if((g.length-1)%2!=0)return a.error("Expected an even number of arguments.");if(!(i=a.parse(i,2,f)))return null;const e=[];let c=null;"interpolate-hcl"===h||"interpolate-lab"===h?c=y:a.expectedType&&"value"!==a.expectedType.kind&&(c=a.expectedType);for(let d=0;d=l)return a.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',o);const m=a.parse(p,q,c);if(!m)return null;c=c||m.type,e.push([l,m])}return"number"===c.kind||"color"===c.kind||"array"===c.kind&&"number"===c.itemType.kind&&"number"==typeof c.N?new ai(c,h,b,i,e):a.error(`Type ${ft(c)} is not interpolatable.`)}evaluate(b){const a=this.labels,c=this.outputs;if(1===a.length)return c[0].evaluate(b);const d=this.input.evaluate(b);if(d<=a[0])return c[0].evaluate(b);const i=a.length;if(d>=a[i-1])return c[i-1].evaluate(b);const e=f3(a,d),f=ai.interpolationFactor(this.interpolation,d,a[e],a[e+1]),g=c[e].evaluate(b),h=c[e+1].evaluate(b);return"interpolate"===this.operator?f4[this.type.kind.toLowerCase()](g,h,f):"interpolate-hcl"===this.operator?cu.reverse(cu.interpolate(cu.forward(g),cu.forward(h),f)):ct.reverse(ct.interpolate(ct.forward(g),ct.forward(h),f))}eachChild(a){for(const b of(a(this.input),this.outputs))a(b)}outputDefined(){return this.outputs.every(a=>a.outputDefined())}serialize(){let b;b="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 c=[this.operator,b,this.input.serialize(),];for(let a=0;afv(b,a.type));return new cv(h?l:a,c)}evaluate(d){let b,a=null,c=0;for(const e of this.args){if(c++,(a=e.evaluate(d))&&a instanceof cj&&!a.available&&(b||(b=a),a=null,c===this.args.length))return b;if(null!==a)break}return a}eachChild(a){this.args.forEach(a)}outputDefined(){return this.args.every(a=>a.outputDefined())}serialize(){const a=["coalesce"];return this.eachChild(b=>{a.push(b.serialize())}),a}}class cw{constructor(b,a){this.type=a.type,this.bindings=[].concat(b),this.result=a}evaluate(a){return this.result.evaluate(a)}eachChild(a){for(const b of this.bindings)a(b[1]);a(this.result)}static parse(a,c){if(a.length<4)return c.error(`Expected at least 3 arguments, but found ${a.length-1} instead.`);const e=[];for(let b=1;b=b.length)throw new fG(`Array index out of bounds: ${a} > ${b.length-1}.`);if(a!==Math.floor(a))throw new fG(`Array index must be an integer, but found ${a} instead.`);return b[a]}eachChild(a){a(this.index),a(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize(),]}}class cy{constructor(a,b){this.type=h,this.needle=a,this.haystack=b}static parse(a,b){if(3!==a.length)return b.error(`Expected 2 arguments, but found ${a.length-1} instead.`);const c=b.parse(a[1],1,l),d=b.parse(a[2],2,l);return c&&d?fw(c.type,[h,i,f,cf,l])?new cy(c,d):b.error(`Expected first argument to be of type boolean, string, number or null, but found ${ft(c.type)} instead`):null}evaluate(c){const b=this.needle.evaluate(c),a=this.haystack.evaluate(c);if(!a)return!1;if(!fx(b,["boolean","string","number","null",]))throw new fG(`Expected first argument to be of type boolean, string, number or null, but found ${ft(fE(b))} instead.`);if(!fx(a,["string","array"]))throw new fG(`Expected second argument to be of type array or string, but found ${ft(fE(a))} instead.`);return a.indexOf(b)>=0}eachChild(a){a(this.needle),a(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize(),]}}class cz{constructor(a,b,c){this.type=f,this.needle=a,this.haystack=b,this.fromIndex=c}static parse(a,b){if(a.length<=2||a.length>=5)return b.error(`Expected 3 or 4 arguments, but found ${a.length-1} instead.`);const c=b.parse(a[1],1,l),d=b.parse(a[2],2,l);if(!c||!d)return null;if(!fw(c.type,[h,i,f,cf,l]))return b.error(`Expected first argument to be of type boolean, string, number or null, but found ${ft(c.type)} instead`);if(4===a.length){const e=b.parse(a[3],3,f);return e?new cz(c,d,e):null}return new cz(c,d)}evaluate(c){const a=this.needle.evaluate(c),b=this.haystack.evaluate(c);if(!fx(a,["boolean","string","number","null",]))throw new fG(`Expected first argument to be of type boolean, string, number or null, but found ${ft(fE(a))} instead.`);if(!fx(b,["string","array"]))throw new fG(`Expected second argument to be of type array or string, but found ${ft(fE(b))} instead.`);if(this.fromIndex){const d=this.fromIndex.evaluate(c);return b.indexOf(a,d)}return b.indexOf(a)}eachChild(a){a(this.needle),a(this.haystack),this.fromIndex&&a(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&& void 0!==this.fromIndex){const a=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),a,]}return["index-of",this.needle.serialize(),this.haystack.serialize(),]}}class cA{constructor(a,b,c,d,e,f){this.inputType=a,this.type=b,this.input=c,this.cases=d,this.outputs=e,this.otherwise=f}static parse(b,c){if(b.length<5)return c.error(`Expected at least 4 arguments, but found only ${b.length-1}.`);if(b.length%2!=1)return c.error("Expected an even number of arguments.");let g,d;c.expectedType&&"value"!==c.expectedType.kind&&(d=c.expectedType);const j={},k=[];for(let e=2;eNumber.MAX_SAFE_INTEGER)return f.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof a&&Math.floor(a)!==a)return f.error("Numeric branch labels must be integer values.");if(g){if(f.checkSubtype(g,fE(a)))return null}else g=fE(a);if(void 0!==j[String(a)])return f.error("Branch labels must be unique.");j[String(a)]=k.length}const m=c.parse(o,e,d);if(!m)return null;d=d||m.type,k.push(m)}const i=c.parse(b[1],1,l);if(!i)return null;const n=c.parse(b[b.length-1],b.length-1,d);return n?"value"!==i.type.kind&&c.concat(1).checkSubtype(g,i.type)?null:new cA(g,d,i,j,k,n):null}evaluate(a){const b=this.input.evaluate(a);return(fE(b)===this.inputType&&this.outputs[this.cases[b]]||this.otherwise).evaluate(a)}eachChild(a){a(this.input),this.outputs.forEach(a),a(this.otherwise)}outputDefined(){return this.outputs.every(a=>a.outputDefined())&&this.otherwise.outputDefined()}serialize(){const b=["match",this.input.serialize()],h=Object.keys(this.cases).sort(),c=[],e={};for(const a of h){const f=e[this.cases[a]];void 0===f?(e[this.cases[a]]=c.length,c.push([this.cases[a],[a]])):c[f][1].push(a)}const g=a=>"number"===this.inputType.kind?Number(a):a;for(const[i,d]of c)b.push(1===d.length?g(d[0]):d.map(g)),b.push(this.outputs[i].serialize());return b.push(this.otherwise.serialize()),b}}class cB{constructor(a,b,c){this.type=a,this.branches=b,this.otherwise=c}static parse(a,b){if(a.length<4)return b.error(`Expected at least 3 arguments, but found only ${a.length-1}.`);if(a.length%2!=0)return b.error("Expected an odd number of arguments.");let c;b.expectedType&&"value"!==b.expectedType.kind&&(c=b.expectedType);const f=[];for(let d=1;da.outputDefined())&&this.otherwise.outputDefined()}serialize(){const a=["case"];return this.eachChild(b=>{a.push(b.serialize())}),a}}class cC{constructor(a,b,c,d){this.type=a,this.input=b,this.beginIndex=c,this.endIndex=d}static parse(a,c){if(a.length<=2||a.length>=5)return c.error(`Expected 3 or 4 arguments, but found ${a.length-1} instead.`);const b=c.parse(a[1],1,l),d=c.parse(a[2],2,f);if(!b||!d)return null;if(!fw(b.type,[z(l),i,l]))return c.error(`Expected first argument to be of type array or string, but found ${ft(b.type)} instead`);if(4===a.length){const e=c.parse(a[3],3,f);return e?new cC(b.type,b,d,e):null}return new cC(b.type,b,d)}evaluate(b){const a=this.input.evaluate(b),c=this.beginIndex.evaluate(b);if(!fx(a,["string","array"]))throw new fG(`Expected first argument to be of type array or string, but found ${ft(fE(a))} instead.`);if(this.endIndex){const d=this.endIndex.evaluate(b);return a.slice(c,d)}return a.slice(c)}eachChild(a){a(this.input),a(this.beginIndex),this.endIndex&&a(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&& void 0!==this.endIndex){const a=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),a,]}return["slice",this.input.serialize(),this.beginIndex.serialize(),]}}function gf(b,a){return"=="===b||"!="===b?"boolean"===a.kind||"string"===a.kind||"number"===a.kind||"null"===a.kind||"value"===a.kind:"string"===a.kind||"number"===a.kind||"value"===a.kind}function cD(d,a,b,c){return 0===c.compare(a,b)}function A(a,b,c){const d="=="!==a&&"!="!==a;return class e{constructor(a,b,c){this.type=h,this.lhs=a,this.rhs=b,this.collator=c,this.hasUntypedArgument="value"===a.type.kind||"value"===b.type.kind}static parse(f,c){if(3!==f.length&&4!==f.length)return c.error("Expected two or three arguments.");const g=f[0];let a=c.parse(f[1],1,l);if(!a)return null;if(!gf(g,a.type))return c.concat(1).error(`"${g}" comparisons are not supported for type '${ft(a.type)}'.`);let b=c.parse(f[2],2,l);if(!b)return null;if(!gf(g,b.type))return c.concat(2).error(`"${g}" comparisons are not supported for type '${ft(b.type)}'.`);if(a.type.kind!==b.type.kind&&"value"!==a.type.kind&&"value"!==b.type.kind)return c.error(`Cannot compare types '${ft(a.type)}' and '${ft(b.type)}'.`);d&&("value"===a.type.kind&&"value"!==b.type.kind?a=new L(b.type,[a]):"value"!==a.type.kind&&"value"===b.type.kind&&(b=new L(a.type,[b])));let h=null;if(4===f.length){if("string"!==a.type.kind&&"string"!==b.type.kind&&"value"!==a.type.kind&&"value"!==b.type.kind)return c.error("Cannot use collator to compare non-string types.");if(!(h=c.parse(f[3],3,cg)))return null}return new e(a,b,h)}evaluate(e){const f=this.lhs.evaluate(e),g=this.rhs.evaluate(e);if(d&&this.hasUntypedArgument){const h=fE(f),i=fE(g);if(h.kind!==i.kind||"string"!==h.kind&&"number"!==h.kind)throw new fG(`Expected arguments for "${a}" to be (string, string) or (number, number), but found (${h.kind}, ${i.kind}) instead.`)}if(this.collator&&!d&&this.hasUntypedArgument){const j=fE(f),k=fE(g);if("string"!==j.kind||"string"!==k.kind)return b(e,f,g)}return this.collator?c(e,f,g,this.collator.evaluate(e)):b(e,f,g)}eachChild(a){a(this.lhs),a(this.rhs),this.collator&&a(this.collator)}outputDefined(){return!0}serialize(){const b=[a];return this.eachChild(a=>{b.push(a.serialize())}),b}}}const cE=A("==",function(c,a,b){return a===b},cD),cF=A("!=",function(c,a,b){return a!==b},function(d,a,b,c){return!cD(0,a,b,c)}),cG=A("<",function(c,a,b){return ac.compare(a,b)}),cH=A(">",function(c,a,b){return a>b},function(d,a,b,c){return c.compare(a,b)>0}),cI=A("<=",function(c,a,b){return a<=b},function(d,a,b,c){return 0>=c.compare(a,b)}),cJ=A(">=",function(c,a,b){return a>=b},function(d,a,b,c){return c.compare(a,b)>=0});class cK{constructor(a,b,c,d,e){this.type=i,this.number=a,this.locale=b,this.currency=c,this.minFractionDigits=d,this.maxFractionDigits=e}static parse(c,b){if(3!==c.length)return b.error("Expected two arguments.");const d=b.parse(c[1],1,f);if(!d)return null;const a=c[2];if("object"!=typeof a||Array.isArray(a))return b.error("NumberFormat options argument must be an object.");let e=null;if(a.locale&&!(e=b.parse(a.locale,1,i)))return null;let g=null;if(a.currency&&!(g=b.parse(a.currency,1,i)))return null;let h=null;if(a["min-fraction-digits"]&&!(h=b.parse(a["min-fraction-digits"],1,f)))return null;let j=null;return!a["max-fraction-digits"]||(j=b.parse(a["max-fraction-digits"],1,f))?new cK(d,e,g,h,j):null}evaluate(a){return new Intl.NumberFormat(this.locale?this.locale.evaluate(a):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(a):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(a):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(a):void 0}).format(this.number.evaluate(a))}eachChild(a){a(this.number),this.locale&&a(this.locale),this.currency&&a(this.currency),this.minFractionDigits&&a(this.minFractionDigits),this.maxFractionDigits&&a(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const a={};return this.locale&&(a.locale=this.locale.serialize()),this.currency&&(a.currency=this.currency.serialize()),this.minFractionDigits&&(a["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(a["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),a,]}}class cL{constructor(a){this.type=f,this.input=a}static parse(b,c){if(2!==b.length)return c.error(`Expected 1 argument, but found ${b.length-1} instead.`);const a=c.parse(b[1],1);return a?"array"!==a.type.kind&&"string"!==a.type.kind&&"value"!==a.type.kind?c.error(`Expected argument of type string or array, but found ${ft(a.type)} instead.`):new cL(a):null}evaluate(b){const a=this.input.evaluate(b);if("string"==typeof a||Array.isArray(a))return a.length;throw new fG(`Expected value to be of type string or array, but found ${ft(fE(a))} instead.`)}eachChild(a){a(this.input)}outputDefined(){return!1}serialize(){const a=["length"];return this.eachChild(b=>{a.push(b.serialize())}),a}}const U={"==":cE,"!=":cF,">":cH,"<":cG,">=":cJ,"<=":cI,array:L,at:cx,boolean:L,case:cB,coalesce:cv,collator:cn,format:cl,image:cm,in:cy,"index-of":cz,interpolate:ai,"interpolate-hcl":ai,"interpolate-lab":ai,length:cL,let:cw,literal:ck,match:cA,number:L,"number-format":cK,object:L,slice:cC,step:cq,string:L,"to-boolean":T,"to-color":T,"to-number":T,"to-string":T,var:cp,within:co};function a$(b,[c,d,e,f]){c=c.evaluate(b),d=d.evaluate(b),e=e.evaluate(b);const a=f?f.evaluate(b):1,g=fC(c,d,e,a);if(g)throw new fG(g);return new m(c/255*a,d/255*a,e/255*a,a)}function gg(b,c){const a=c[b];return void 0===a?null:a}function x(a){return{type:a}}function gh(a){return{result:"success",value:a}}function gi(a){return{result:"error",value:a}}function gj(a){return"data-driven"===a["property-type"]||"cross-faded-data-driven"===a["property-type"]}function gk(a){return!!a.expression&&a.expression.parameters.indexOf("zoom")> -1}function gl(a){return!!a.expression&&a.expression.interpolated}function gm(a){return a instanceof Number?"number":a instanceof String?"string":a instanceof Boolean?"boolean":Array.isArray(a)?"array":null===a?"null":typeof a}function gn(a){return"object"==typeof a&&null!==a&&!Array.isArray(a)}function go(a){return a}function gp(a,e){const r="color"===e.type,g=a.stops&&"object"==typeof a.stops[0][0],s=g||!(g|| void 0!==a.property),b=a.type||(gl(e)?"exponential":"interval");if(r&&((a=ce({},a)).stops&&(a.stops=a.stops.map(a=>[a[0],m.parse(a[1]),])),a.default=m.parse(a.default?a.default:e.default)),a.colorSpace&&"rgb"!==a.colorSpace&&!gd[a.colorSpace])throw new Error(`Unknown color space: ${a.colorSpace}`);let f,j,t;if("exponential"===b)f=gt;else if("interval"===b)f=gs;else if("categorical"===b){for(const k of(f=gr,j=Object.create(null),a.stops))j[k[0]]=k[1];t=typeof a.stops[0][0]}else{if("identity"!==b)throw new Error(`Unknown function type "${b}"`);f=gu}if(g){const c={},l=[];for(let h=0;ha[0]),evaluate:({zoom:b},c)=>gt({stops:n,base:a.base},e,b).evaluate(b,c)}}if(s){const q="exponential"===b?{name:"exponential",base:void 0!==a.base?a.base:1}:null;return{kind:"camera",interpolationType:q,interpolationFactor:ai.interpolationFactor.bind(void 0,q),zoomStops:a.stops.map(a=>a[0]),evaluate:({zoom:b})=>f(a,e,b,j,t)}}return{kind:"source",evaluate(d,b){const c=b&&b.properties?b.properties[a.property]:void 0;return void 0===c?gq(a.default,e.default):f(a,e,c,j,t)}}}function gq(a,b,c){return void 0!==a?a:void 0!==b?b:void 0!==c?c:void 0}function gr(b,c,a,d,e){return gq(typeof a===e?d[a]:void 0,b.default,c.default)}function gs(a,d,b){if("number"!==gm(b))return gq(a.default,d.default);const c=a.stops.length;if(1===c||b<=a.stops[0][0])return a.stops[0][1];if(b>=a.stops[c-1][0])return a.stops[c-1][1];const e=f3(a.stops.map(a=>a[0]),b);return a.stops[e][1]}function gt(a,e,b){const h=void 0!==a.base?a.base:1;if("number"!==gm(b))return gq(a.default,e.default);const d=a.stops.length;if(1===d||b<=a.stops[0][0])return a.stops[0][1];if(b>=a.stops[d-1][0])return a.stops[d-1][1];const c=f3(a.stops.map(a=>a[0]),b),i=function(e,a,c,f){const b=f-c,d=e-c;return 0===b?0:1===a?d/b:(Math.pow(a,d)-1)/(Math.pow(a,b)-1)}(b,h,a.stops[c][0],a.stops[c+1][0]),f=a.stops[c][1],j=a.stops[c+1][1];let g=f4[e.type]||go;if(a.colorSpace&&"rgb"!==a.colorSpace){const k=gd[a.colorSpace];g=(a,b)=>k.reverse(k.interpolate(k.forward(a),k.forward(b),i))}return"function"==typeof f.evaluate?{evaluate(...a){const b=f.evaluate.apply(void 0,a),c=j.evaluate.apply(void 0,a);if(void 0!==b&& void 0!==c)return g(b,c,i)}}:g(f,j,i)}function gu(c,b,a){return"color"===b.type?a=m.parse(a):"formatted"===b.type?a=fB.fromString(a.toString()):"resolvedImage"===b.type?a=cj.fromString(a.toString()):gm(a)===b.type||"enum"===b.type&&b.values[a]||(a=void 0),gq(a,c.default,b.default)}aX.register(U,{error:[{kind:"error"},[i],(a,[b])=>{throw new fG(b.evaluate(a))},],typeof:[i,[l],(a,[b])=>ft(fE(b.evaluate(a))),],"to-rgba":[z(f,4),[y],(a,[b])=>b.evaluate(a).toArray(),],rgb:[y,[f,f,f],a$],rgba:[y,[f,f,f,f],a$],has:{type:h,overloads:[[[i],(a,[d])=>{var b,c;return b=d.evaluate(a),c=a.properties(),b in c},],[[i,K],(a,[b,c])=>b.evaluate(a) in c.evaluate(a),],]},get:{type:l,overloads:[[[i],(a,[b])=>gg(b.evaluate(a),a.properties()),],[[i,K],(a,[b,c])=>gg(b.evaluate(a),c.evaluate(a)),],]},"feature-state":[l,[i],(a,[b])=>gg(b.evaluate(a),a.featureState||{}),],properties:[K,[],a=>a.properties()],"geometry-type":[i,[],a=>a.geometryType()],id:[l,[],a=>a.id()],zoom:[f,[],a=>a.globals.zoom],pitch:[f,[],a=>a.globals.pitch||0],"distance-from-center":[f,[],a=>a.distanceFromCenter(),],"heatmap-density":[f,[],a=>a.globals.heatmapDensity||0,],"line-progress":[f,[],a=>a.globals.lineProgress||0,],"sky-radial-progress":[f,[],a=>a.globals.skyRadialProgress||0,],accumulated:[l,[],a=>void 0===a.globals.accumulated?null:a.globals.accumulated,],"+":[f,x(f),(b,c)=>{let a=0;for(const d of c)a+=d.evaluate(b);return a},],"*":[f,x(f),(b,c)=>{let a=1;for(const d of c)a*=d.evaluate(b);return a},],"-":{type:f,overloads:[[[f,f],(a,[b,c])=>b.evaluate(a)-c.evaluate(a),],[[f],(a,[b])=>-b.evaluate(a)],]},"/":[f,[f,f],(a,[b,c])=>b.evaluate(a)/c.evaluate(a),],"%":[f,[f,f],(a,[b,c])=>b.evaluate(a)%c.evaluate(a),],ln2:[f,[],()=>Math.LN2],pi:[f,[],()=>Math.PI],e:[f,[],()=>Math.E],"^":[f,[f,f],(a,[b,c])=>Math.pow(b.evaluate(a),c.evaluate(a)),],sqrt:[f,[f],(a,[b])=>Math.sqrt(b.evaluate(a)),],log10:[f,[f],(a,[b])=>Math.log(b.evaluate(a))/Math.LN10,],ln:[f,[f],(a,[b])=>Math.log(b.evaluate(a))],log2:[f,[f],(a,[b])=>Math.log(b.evaluate(a))/Math.LN2,],sin:[f,[f],(a,[b])=>Math.sin(b.evaluate(a)),],cos:[f,[f],(a,[b])=>Math.cos(b.evaluate(a)),],tan:[f,[f],(a,[b])=>Math.tan(b.evaluate(a)),],asin:[f,[f],(a,[b])=>Math.asin(b.evaluate(a)),],acos:[f,[f],(a,[b])=>Math.acos(b.evaluate(a)),],atan:[f,[f],(a,[b])=>Math.atan(b.evaluate(a)),],min:[f,x(f),(b,a)=>Math.min(...a.map(a=>a.evaluate(b))),],max:[f,x(f),(b,a)=>Math.max(...a.map(a=>a.evaluate(b))),],abs:[f,[f],(a,[b])=>Math.abs(b.evaluate(a)),],round:[f,[f],(b,[c])=>{const a=c.evaluate(b);return a<0?-Math.round(-a):Math.round(a)},],floor:[f,[f],(a,[b])=>Math.floor(b.evaluate(a)),],ceil:[f,[f],(a,[b])=>Math.ceil(b.evaluate(a)),],"filter-==":[h,[i,l],(a,[b,c])=>a.properties()[b.value]===c.value,],"filter-id-==":[h,[l],(a,[b])=>a.id()===b.value,],"filter-type-==":[h,[i],(a,[b])=>a.geometryType()===b.value,],"filter-<":[h,[i,l],(c,[d,e])=>{const a=c.properties()[d.value],b=e.value;return typeof a==typeof b&&a{const a=c.id(),b=d.value;return typeof a==typeof b&&a":[h,[i,l],(c,[d,e])=>{const a=c.properties()[d.value],b=e.value;return typeof a==typeof b&&a>b},],"filter-id->":[h,[l],(c,[d])=>{const a=c.id(),b=d.value;return typeof a==typeof b&&a>b},],"filter-<=":[h,[i,l],(c,[d,e])=>{const a=c.properties()[d.value],b=e.value;return typeof a==typeof b&&a<=b},],"filter-id-<=":[h,[l],(c,[d])=>{const a=c.id(),b=d.value;return typeof a==typeof b&&a<=b},],"filter->=":[h,[i,l],(c,[d,e])=>{const a=c.properties()[d.value],b=e.value;return typeof a==typeof b&&a>=b},],"filter-id->=":[h,[l],(c,[d])=>{const a=c.id(),b=d.value;return typeof a==typeof b&&a>=b},],"filter-has":[h,[l],(a,[b])=>b.value in a.properties(),],"filter-has-id":[h,[],a=>null!==a.id()&& void 0!==a.id(),],"filter-type-in":[h,[z(i)],(a,[b])=>b.value.indexOf(a.geometryType())>=0,],"filter-id-in":[h,[z(l)],(a,[b])=>b.value.indexOf(a.id())>=0,],"filter-in-small":[h,[i,z(l)],(a,[b,c])=>c.value.indexOf(a.properties()[b.value])>=0,],"filter-in-large":[h,[i,z(l)],(b,[c,a])=>(function(d,e,b,c){for(;b<=c;){const a=b+c>>1;if(e[a]===d)return!0;e[a]>d?c=a-1:b=a+1}return!1})(b.properties()[c.value],a.value,0,a.value.length-1),],all:{type:h,overloads:[[[h,h],(a,[b,c])=>b.evaluate(a)&&c.evaluate(a),],[x(h),(a,b)=>{for(const c of b)if(!c.evaluate(a))return!1;return!0},],]},any:{type:h,overloads:[[[h,h],(a,[b,c])=>b.evaluate(a)||c.evaluate(a),],[x(h),(a,b)=>{for(const c of b)if(c.evaluate(a))return!0;return!1},],]},"!":[h,[h],(a,[b])=>!b.evaluate(a)],"is-supported-script":[h,[i],(a,[c])=>{const b=a.globals&&a.globals.isSupportedScript;return!b||b(c.evaluate(a))},],upcase:[i,[i],(a,[b])=>b.evaluate(a).toUpperCase(),],downcase:[i,[i],(a,[b])=>b.evaluate(a).toLowerCase(),],concat:[i,x(l),(b,a)=>a.map(a=>fF(a.evaluate(b))).join(""),],"resolved-locale":[i,[cg],(a,[b])=>b.evaluate(a).resolvedLocale(),]});class cM{constructor(c,b){var a;this.expression=c,this._warningHistory={},this._evaluator=new fK,this._defaultValue=b?"color"===(a=b).type&&gn(a.default)?new m(0,0,0,0):"color"===a.type?m.parse(a.default)||null:void 0===a.default?null:a.default:null,this._enumValues=b&&"enum"===b.type?b.values:null}evaluateWithoutErrorHandling(a,b,c,d,e,f,g,h){return this._evaluator.globals=a,this._evaluator.feature=b,this._evaluator.featureState=c,this._evaluator.canonical=d,this._evaluator.availableImages=e||null,this._evaluator.formattedSection=f,this._evaluator.featureTileCoord=g||null,this._evaluator.featureDistanceData=h||null,this.expression.evaluate(this._evaluator)}evaluate(c,d,e,f,g,h,i,j){this._evaluator.globals=c,this._evaluator.feature=d||null,this._evaluator.featureState=e||null,this._evaluator.canonical=f,this._evaluator.availableImages=g||null,this._evaluator.formattedSection=h||null,this._evaluator.featureTileCoord=i||null,this._evaluator.featureDistanceData=j||null;try{const a=this.expression.evaluate(this._evaluator);if(null==a||"number"==typeof a&&a!=a)return this._defaultValue;if(this._enumValues&&!(a in this._enumValues))throw new fG(`Expected value to be one of ${Object.keys(this._enumValues).map(a=>JSON.stringify(a)).join(", ")}, but found ${JSON.stringify(a)} instead.`);return a}catch(b){return this._warningHistory[b.message]||(this._warningHistory[b.message]=!0,"undefined"!=typeof console&&console.warn(b.message)),this._defaultValue}}}function gv(a){return Array.isArray(a)&&a.length>0&&"string"==typeof a[0]&&a[0]in U}function cN(d,a){const b=new f1(U,[],a?function(a){const b={color:y,string:i,number:f,enum:i,boolean:h,formatted:ch,resolvedImage:ci};return"array"===a.type?z(b[a.value]||l,a.length):b[a.type]}(a):void 0),c=b.parse(d,void 0,void 0,void 0,a&&"string"===a.type?{typeAnnotation:"coerce"}:void 0);return c?gh(new cM(c,a)):gi(b.errors)}class cO{constructor(a,b){this.kind=a,this._styleExpression=b,this.isStateDependent="constant"!==a&&!f_(b.expression)}evaluateWithoutErrorHandling(a,b,c,d,e,f){return this._styleExpression.evaluateWithoutErrorHandling(a,b,c,d,e,f)}evaluate(a,b,c,d,e,f){return this._styleExpression.evaluate(a,b,c,d,e,f)}}class cP{constructor(a,b,c,d){this.kind=a,this.zoomStops=c,this._styleExpression=b,this.isStateDependent="camera"!==a&&!f_(b.expression),this.interpolationType=d}evaluateWithoutErrorHandling(a,b,c,d,e,f){return this._styleExpression.evaluateWithoutErrorHandling(a,b,c,d,e,f)}evaluate(a,b,c,d,e,f){return this._styleExpression.evaluate(a,b,c,d,e,f)}interpolationFactor(a,b,c){return this.interpolationType?ai.interpolationFactor(this.interpolationType,a,b,c):0}}function gw(b,c){if("error"===(b=cN(b,c)).result)return b;const d=b.value.expression,e=f$(d);if(!e&&!gj(c))return gi([new fr("","data expressions not supported"),]);const f=f0(d,["zoom","pitch","distance-from-center",]);if(!f&&!gk(c))return gi([new fr("","zoom expressions not supported"),]);const a=gx(d);return a||f?a instanceof fr?gi([a]):a instanceof ai&&!gl(c)?gi([new fr("",'"interpolate" expressions cannot be used with this property'),]):gh(a?new cP(e?"camera":"composite",b.value,a.labels,a instanceof ai?a.interpolation:void 0):new cO(e?"constant":"source",b.value)):gi([new fr("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'),])}class cQ{constructor(a,b){this._parameters=a,this._specification=b,ce(this,gp(this._parameters,this._specification))}static deserialize(a){return new cQ(a._parameters,a._specification)}static serialize(a){return{_parameters:a._parameters,_specification:a._specification}}}function gx(a){let b=null;if(a instanceof cw)b=gx(a.result);else if(a instanceof cv){for(const c of a.args)if(b=gx(c))break}else(a instanceof cq||a instanceof ai)&&a.input instanceof aX&&"zoom"===a.input.name&&(b=a);return b instanceof fr||a.eachChild(c=>{const a=gx(c);a instanceof fr?b=a:!b&&a?b=new fr("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):b&&a&&b!==a&&(b=new fr("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),b}function cR(c){const d=c.key,a=c.value,b=c.valueSpec||{},f=c.objectElementValidators||{},l=c.style,m=c.styleSpec;let g=[];const k=gm(a);if("object"!==k)return[new cc(d,a,`object expected, ${k} found`),];for(const e in a){const j=e.split(".")[0],n=b[j]||b["*"];let h;if(f[j])h=f[j];else if(b[j])h=gR;else if(f["*"])h=f["*"];else{if(!b["*"]){g.push(new cc(d,a[e],`unknown property "${e}"`));continue}h=gR}g=g.concat(h({key:(d?`${d}.`:d)+e,value:a[e],valueSpec:n,style:l,styleSpec:m,object:a,objectKey:e},a))}for(const i in b)f[i]||b[i].required&& void 0===b[i].default&& void 0===a[i]&&g.push(new cc(d,a,`missing required property "${i}"`));return g}function cS(c){const b=c.value,a=c.valueSpec,i=c.style,h=c.styleSpec,e=c.key,j=c.arrayElementValidator||gR;if("array"!==gm(b))return[new cc(e,b,`array expected, ${gm(b)} found`),];if(a.length&&b.length!==a.length)return[new cc(e,b,`array length ${a.length} expected, length ${b.length} found`),];if(a["min-length"]&&b.lengthg)return[new cc(e,a,`${a} is greater than the maximum value ${g}`),]}return[]}function cU(a){function f(c){let d=[];const a=c.value,b=c.key;if("array"!==gm(a))return[new cc(b,a,`array expected, ${gm(a)} found`),];if(2!==a.length)return[new cc(b,a,`array length 2 expected, length ${a.length} found`),];if(e){if("object"!==gm(a[0]))return[new cc(b,a,`object expected, ${gm(a[0])} found`),];if(void 0===a[0].zoom)return[new cc(b,a,"object stop key must have zoom"),];if(void 0===a[0].value)return[new cc(b,a,"object stop key must have value"),];if(k&&k>fp(a[0].zoom))return[new cc(b,a[0].zoom,"stop zoom values must appear in ascending order"),];fp(a[0].zoom)!==k&&(k=fp(a[0].zoom),j=void 0,l={}),d=d.concat(cR({key:`${b}[0]`,value:a[0],valueSpec:{zoom:{}},style:c.style,styleSpec:c.styleSpec,objectElementValidators:{zoom:cT,value:g}}))}else d=d.concat(g({key:`${b}[0]`,value:a[0],valueSpec:{},style:c.style,styleSpec:c.styleSpec},a));return gv(fq(a[1]))?d.concat([new cc(`${b}[1]`,a[1],"expressions are not allowed in function stops."),]):d.concat(gR({key:`${b}[1]`,value:a[1],valueSpec:h,style:c.style,styleSpec:c.styleSpec}))}function g(a,g){const b=gm(a.value),d=fp(a.value),e=null!==a.value?a.value:g;if(i){if(b!==i)return[new cc(a.key,e,`${b} stop domain type must match previous stop domain type ${i}`),]}else i=b;if("number"!==b&&"string"!==b&&"boolean"!==b)return[new cc(a.key,e,"stop domain value must be a number, string, or boolean"),];if("number"!==b&&"categorical"!==c){let f=`number expected, ${b} found`;return gj(h)&& void 0===c&&(f+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new cc(a.key,e,f)]}return"categorical"!==c||"number"!==b||isFinite(d)&&Math.floor(d)===d?"categorical"!==c&&"number"===b&& void 0!==j&&d=8&&(d||gj(a.valueSpec)?d&&!gk(a.valueSpec)&&b.push(new cc(a.key,a.value,"zoom functions not supported")):b.push(new cc(a.key,a.value,"property functions not supported"))),("categorical"===c||e)&& void 0===a.value.property&&b.push(new cc(a.key,a.value,'"property" property is required')),b}function gy(a){const c=("property"===a.expressionContext?gw:cN)(fq(a.value),a.valueSpec);if("error"===c.result)return c.value.map(b=>new cc(`${a.key}${b.key}`,a.value,b.message));const b=c.value.expression||c.value._styleExpression.expression;if("property"===a.expressionContext&&"text-font"===a.propertyKey&&!b.outputDefined())return[new cc(a.key,a.value,`Invalid data expression for "${a.propertyKey}". Output values must be contained as literals within the expression.`),];if("property"===a.expressionContext&&"layout"===a.propertyType&&!f_(b))return[new cc(a.key,a.value,'"feature-state" data expressions are not supported with layout properties.'),];if("filter"===a.expressionContext)return gz(b,a);if(a.expressionContext&&0===a.expressionContext.indexOf("cluster")){if(!f0(b,["zoom","feature-state"]))return[new cc(a.key,a.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.'),];if("cluster-initial"===a.expressionContext&&!f$(b))return[new cc(a.key,a.value,"Feature data expressions are not supported with initial expression part of cluster properties."),]}return[]}function gz(b,a){const c=new Set(["zoom","feature-state","pitch","distance-from-center",]);for(const d of a.valueSpec.expression.parameters)c.delete(d);if(0===c.size)return[];const e=[];return b instanceof aX&&c.has(b.name)?[new cc(a.key,a.value,`["${b.name}"] expression is not supported in a filter for a ${a.object.type} layer with id: ${a.object.id}`),]:(b.eachChild(b=>{e.push(...gz(b,a))}),e)}function cV(c){const e=c.key,a=c.value,b=c.valueSpec,d=[];return Array.isArray(b.values)?-1===b.values.indexOf(fp(a))&&d.push(new cc(e,a,`expected one of [${b.values.join(", ")}], ${JSON.stringify(a)} found`)):-1===Object.keys(b.values).indexOf(fp(a))&&d.push(new cc(e,a,`expected one of [${Object.keys(b.values).join(", ")}], ${JSON.stringify(a)} found`)),d}function gA(a){if(!0===a|| !1===a)return!0;if(!Array.isArray(a)||0===a.length)return!1;switch(a[0]){case"has":return a.length>=2&&"$id"!==a[1]&&"$type"!==a[1];case"in":return a.length>=3&&("string"!=typeof a[1]||Array.isArray(a[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==a.length||Array.isArray(a[1])||Array.isArray(a[2]);case"any":case"all":for(const b of a.slice(1))if(!gA(b)&&"boolean"!=typeof b)return!1;return!0;default:return!0}}function gB(a,k="fill"){if(null==a)return{filter:()=>!0,needGeometry:!1,needFeature:!1};gA(a)||(a=gI(a));const c=a;let d=!0;try{d=function(a){if(!gE(a))return a;let b=fq(a);return gD(b),b=gC(b)}(c)}catch(l){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate. This is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md and paste the contents of this message in the report. Thank you! Filter Expression: ${JSON.stringify(c,null,2)} `)}const f=b[`filter_${k}`],g=cN(d,f);let h=null;if("error"===g.result)throw new Error(g.value.map(a=>`${a.key}: ${a.message}`).join(", "));h=(a,b,c)=>g.value.evaluate(a,b,{},c);let i=null,j=null;if(d!==c){const e=cN(c,f);if("error"===e.result)throw new Error(e.value.map(a=>`${a.key}: ${a.message}`).join(", "));i=(a,b,c,d,f)=>e.value.evaluate(a,b,{},c,void 0,void 0,d,f),j=!f$(e.value.expression)}return{filter:h,dynamicFilter:i||void 0,needGeometry:gH(d),needFeature:!!j}}function gC(a){if(!Array.isArray(a))return a;const b=function(a){if(gF.has(a[0])){for(let b=1;bgC(a))}function gD(a){let b=!1;const c=[];if("case"===a[0]){for(let d=1;d",">=","<","<=","to-boolean",]);function gG(a,b){return ab?1:0}function gH(a){if(!Array.isArray(a))return!1;if("within"===a[0])return!0;for(let b=1;b"===b||"<="===b||">="===b?gJ(a[1],a[2],b):"any"===b?(c=a.slice(1),["any"].concat(c.map(gI))):"all"===b?["all"].concat(a.slice(1).map(gI)):"none"===b?["all"].concat(a.slice(1).map(gI).map(gM)):"in"===b?gK(a[1],a.slice(2)):"!in"===b?gM(gK(a[1],a.slice(2))):"has"===b?gL(a[1]):"!has"===b?gM(gL(a[1])):"within"!==b||a}function gJ(c,a,b){switch(c){case"$type":return[`filter-type-${b}`,a];case"$id":return[`filter-id-${b}`,a];default:return[`filter-${b}`,c,a]}}function gK(b,a){if(0===a.length)return!1;switch(b){case"$type":return["filter-type-in",["literal",a]];case"$id":return["filter-id-in",["literal",a]];default:return a.length>200&&!a.some(b=>typeof b!=typeof a[0])?["filter-in-large",b,["literal",a.sort(gG)],]:["filter-in-small",b,["literal",a],]}}function gL(a){switch(a){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",a]}}function gM(a){return["!",a]}function a_(a){if(gA(fq(a.value))){const b=fq(a.layerType);return gy(ce({},a,{expressionContext:"filter",valueSpec:a.styleSpec[`filter_${b||"fill"}`]}))}return gN(a)}function gN(e){const a=e.value,c=e.key;if("array"!==gm(a))return[new cc(c,a,`array expected, ${gm(a)} found`),];const h=e.styleSpec;let d,b=[];if(a.length<1)return[new cc(c,a,"filter array must have at least 1 element"),];switch(b=b.concat(cV({key:`${c}[0]`,value:a[0],valueSpec:h.filter_operator,style:e.style,styleSpec:e.styleSpec})),fp(a[0])){case"<":case"<=":case">":case">=":a.length>=2&&"$type"===fp(a[1])&&b.push(new cc(c,a,`"$type" cannot be use with operator "${a[0]}"`));case"==":case"!=":3!==a.length&&b.push(new cc(c,a,`filter array for operator "${a[0]}" must have 3 elements`));case"in":case"!in":a.length>=2&&"string"!==(d=gm(a[1]))&&b.push(new cc(`${c}[1]`,a[1],`string expected, ${d} found`));for(let f=2;f{d in a&&b.push(new cc(c,a[d],`"${d}" is prohibited for ref layers`))}),g.layers.forEach(a=>{fp(a.id)===m&&(j=a)}),j?j.ref?b.push(new cc(c,a.ref,"ref cannot reference another ref layer")):e=fp(j.type):b.push(new cc(c,a.ref,`ref layer "${m}" not found`))}else if("background"!==e&&"sky"!==e){if(a.source){const h=g.sources&&g.sources[a.source],f=h&&fp(h.type);h?"vector"===f&&"raster"===e?b.push(new cc(c,a.source,`layer "${a.id}" requires a raster source`)):"raster"===f&&"raster"!==e?b.push(new cc(c,a.source,`layer "${a.id}" requires a vector source`)):"vector"!==f||a["source-layer"]?"raster-dem"===f&&"hillshade"!==e?b.push(new cc(c,a.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"===e&&a.paint&&a.paint["line-gradient"]&&("geojson"!==f||!h.lineMetrics)&&b.push(new cc(c,a,`layer "${a.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):b.push(new cc(c,a,`layer "${a.id}" must specify a "source-layer"`)):b.push(new cc(c,a.source,`source "${a.source}" not found`))}else b.push(new cc(c,a,'missing required property "source"'))}return b=b.concat(cR({key:c,value:a,valueSpec:l.layer,style:d.style,styleSpec:d.styleSpec,objectElementValidators:{"*":()=>[],type:()=>gR({key:`${c}.type`,value:a.type,valueSpec:l.layer.type,style:d.style,styleSpec:d.styleSpec,object:a,objectKey:"type"}),filter:a=>a_(ce({layerType:e},a)),layout:b=>cR({layer:a,key:b.key,value:b.value,style:b.style,styleSpec:b.styleSpec,objectElementValidators:{"*":a=>cX(ce({layerType:e},a))}}),paint:b=>cR({layer:a,key:b.key,value:b.value,style:b.style,styleSpec:b.styleSpec,objectElementValidators:{"*":a=>cW(ce({layerType:e},a))}})}}))}function cY(a){const b=a.value,d=a.key,c=gm(b);return"string"!==c?[new cc(d,b,`string expected, ${c} found`)]:[]}const gP={promoteId:function({key:b,value:a}){if("string"===gm(a))return cY({key:b,value:a});{const c=[];for(const d in a)c.push(...cY({key:`${b}.${d}`,value:a[d]}));return c}}};function a1(d){const a=d.value,b=d.key,c=d.styleSpec,e=d.style;if(!a.type)return[new cc(b,a,'"type" is required')];const i=fp(a.type);let f;switch(i){case"vector":case"raster":case"raster-dem":return cR({key:b,value:a,valueSpec:c[`source_${i.replace("-","_")}`],style:d.style,styleSpec:c,objectElementValidators:gP});case"geojson":if(f=cR({key:b,value:a,valueSpec:c.source_geojson,style:e,styleSpec:c,objectElementValidators:gP}),a.cluster)for(const g in a.clusterProperties){const[h,j]=a.clusterProperties[g],k="string"==typeof h?[h,["accumulated"],["get",g],]:h;f.push(...gy({key:`${b}.${g}.map`,value:j,expressionContext:"cluster-map"})),f.push(...gy({key:`${b}.${g}.reduce`,value:k,expressionContext:"cluster-reduce"}))}return f;case"video":return cR({key:b,value:a,valueSpec:c.source_video,style:e,styleSpec:c});case"image":return cR({key:b,value:a,valueSpec:c.source_image,style:e,styleSpec:c});case"canvas":return[new cc(b,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas"),];default:return cV({key:`${b}.type`,value:a.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image",]},style:e,styleSpec:c})}}function a2(f){const b=f.value,d=f.styleSpec,e=d.light,h=f.style;let c=[];const i=gm(b);if(void 0===b)return c;if("object"!==i)return c.concat([new cc("light",b,`object expected, ${i} found`),]);for(const a in b){const g=a.match(/^(.*)-transition$/);c=c.concat(g&&e[g[1]]&&e[g[1]].transition?gR({key:a,value:b[a],valueSpec:d.transition,style:h,styleSpec:d}):e[a]?gR({key:a,value:b[a],valueSpec:e[a],style:h,styleSpec:d}):[new cc(a,b[a],`unknown property "${a}"`),])}return c}function a3(d){const a=d.value,h=d.key,e=d.style,f=d.styleSpec,g=f.terrain;let c=[];const k=gm(a);if(void 0===a)return c;if("object"!==k)return c.concat([new cc("terrain",a,`object expected, ${k} found`),]);for(const b in a){const i=b.match(/^(.*)-transition$/);c=c.concat(i&&g[i[1]]&&g[i[1]].transition?gR({key:b,value:a[b],valueSpec:f.transition,style:e,styleSpec:f}):g[b]?gR({key:b,value:a[b],valueSpec:g[b],style:e,styleSpec:f}):[new cc(b,a[b],`unknown property "${b}"`),])}if(a.source){const j=e.sources&&e.sources[a.source],l=j&&fp(j.type);j?"raster-dem"!==l&&c.push(new cc(h,a.source,`terrain cannot be used with a source of type ${l}, it only be used with a "raster-dem" source type`)):c.push(new cc(h,a.source,`source "${a.source}" not found`))}else c.push(new cc(h,a,'terrain is missing required property "source"'));return c}function a4(f){const b=f.value,h=f.style,d=f.styleSpec,e=d.fog;let c=[];const i=gm(b);if(void 0===b)return c;if("object"!==i)return c.concat([new cc("fog",b,`object expected, ${i} found`),]);for(const a in b){const g=a.match(/^(.*)-transition$/);c=c.concat(g&&e[g[1]]&&e[g[1]].transition?gR({key:a,value:b[a],valueSpec:d.transition,style:h,styleSpec:d}):e[a]?gR({key:a,value:b[a],valueSpec:e[a],style:h,styleSpec:d}):[new cc(a,b[a],`unknown property "${a}"`),])}return c}const gQ={"*":()=>[],array:cS,boolean:function(a){const b=a.value,d=a.key,c=gm(b);return"boolean"!==c?[new cc(d,b,`boolean expected, ${c} found`),]:[]},number:cT,color:function(b){const c=b.key,a=b.value,d=gm(a);return"string"!==d?[new cc(c,a,`color expected, ${d} found`),]:null===fy.parseCSSColor(a)?[new cc(c,a,`color expected, "${a}" found`),]:[]},constants:cd,enum:cV,filter:a_,function:cU,layer:a0,object:cR,source:a1,light:a2,terrain:a3,fog:a4,string:cY,formatted:function(a){return 0===cY(a).length?[]:gy(a)},resolvedImage:function(a){return 0===cY(a).length?[]:gy(a)},projection:function(c){const b=c.value,f=c.styleSpec,g=f.projection,h=c.style;let a=[];const d=gm(b);if("object"===d)for(const e in b)a=a.concat(gR({key:e,value:b[e],valueSpec:g[e],style:h,styleSpec:f}));else"string"!==d&&(a=a.concat([new cc("projection",b,`object or string expected, ${d} found`),]));return a}};function gR(b){const c=b.value,a=b.valueSpec,d=b.styleSpec;return a.expression&&gn(fp(c))?cU(b):a.expression&&gv(fq(c))?gy(b):a.type&&gQ[a.type]?gQ[a.type](b):cR(ce({},b,{valueSpec:a.type?d[a.type]:a}))}function gS(c){const a=c.value,d=c.key,b=cY(c);return b.length||(-1===a.indexOf("{fontstack}")&&b.push(new cc(d,a,'"glyphs" url must include a "{fontstack}" token')),-1===a.indexOf("{range}")&&b.push(new cc(d,a,'"glyphs" url must include a "{range}" token'))),b}function t(a,d=b){let c=[];return c=c.concat(gR({key:"",value:a,valueSpec:d.$root,styleSpec:d,style:a,objectElementValidators:{glyphs:gS,"*":()=>[]}})),a.constants&&(c=c.concat(cd({key:"constants",value:a.constants,style:a,styleSpec:d}))),gT(c)}function gT(a){return[].concat(a).sort((a,b)=>a.line-b.line)}function v(a){return function(...b){return gT(a.apply(this,b))}}t.source=v(a1),t.light=v(a2),t.terrain=v(a3),t.fog=v(a4),t.layer=v(a0),t.filter=v(a_),t.paintProperty=v(cW),t.layoutProperty=v(cX);const M=t,cZ=M.light,c$=M.fog,gU=M.paintProperty,gV=M.layoutProperty;function c_(c,a){let b=!1;if(a&&a.length)for(const d of a)c.fire(new cb(new Error(d.message))),b=!0;return b}var aj=u;function u(b,c,d){var e=this.cells=[];if(b instanceof ArrayBuffer){this.arrayBuffer=b;var a=new Int32Array(this.arrayBuffer);b=a[0],this.d=(c=a[1])+2*(d=a[2]);for(var f=0;f=a[b+0]&&k>=a[b+1])?(d[c]=!0,m.push(n[c])):d[c]=!1}}},u.prototype._forEachCell=function(d,e,f,g,h,i,j,c){for(var k=this._convertToCellCoord(d),l=this._convertToCellCoord(e),m=this._convertToCellCoord(f),n=this._convertToCellCoord(g),a=k;a<=m;a++)for(var b=l;b<=n;b++){var o=this.d*b+a;if((!c||c(this._convertFromCellCoord(a),this._convertFromCellCoord(b),this._convertFromCellCoord(a+1),this._convertFromCellCoord(b+1)))&&h.call(this,d,e,f,g,o,i,j,c))return}},u.prototype._convertFromCellCoord=function(a){return(a-this.padding)/this.scale},u.prototype._convertToCellCoord=function(a){return Math.max(0,Math.min(this.d-1,Math.floor(a*this.scale)+this.padding))},u.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var c=this.cells,f=3+this.cells.length+1+1,g=0,e=0;e=0)continue;const i=a[e];d[e]=gY[c].shallow.indexOf(e)>=0?i:g_(i,b)}a instanceof Error&&(d.message=a.message)}if(d.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==c&&(d.$name=c),d}throw new Error("can't serialize object of type "+typeof a)}function g0(a){if(null==a||"boolean"==typeof a||"number"==typeof a||"string"==typeof a||a instanceof Boolean||a instanceof Number||a instanceof String||a instanceof Date||a instanceof RegExp||gZ(a)||g$(a)||ArrayBuffer.isView(a)||a instanceof gW)return a;if(Array.isArray(a))return a.map(g0);if("object"==typeof a){const d=a.$name||"Object",{klass:b}=gY[d];if(!b)throw new Error(`can't deserialize unregistered class ${d}`);if(b.deserialize)return b.deserialize(a);const e=Object.create(b.prototype);for(const c of Object.keys(a)){if("$name"===c)continue;const f=a[c];e[c]=gY[d].shallow.indexOf(c)>=0?f:g0(f)}return e}throw new Error("can't deserialize object of type "+typeof a)}class c0{constructor(){this.first=!0}update(b,c){const a=Math.floor(b);return this.first?(this.first=!1,this.lastIntegerZoom=a,this.lastIntegerZoomTime=0,this.lastZoom=b,this.lastFloorZoom=a,!0):(this.lastFloorZoom>a?(this.lastIntegerZoom=a+1,this.lastIntegerZoomTime=c):this.lastFloorZooma>=1536&&a<=1791,g2=a=>a>=1872&&a<=1919,g3=a=>a>=2208&&a<=2303,g4=a=>a>=11904&&a<=12031,g5=a=>a>=12032&&a<=12255,g6=a=>a>=12272&&a<=12287,g7=a=>a>=12288&&a<=12351,g8=a=>a>=12352&&a<=12447,g9=a=>a>=12448&&a<=12543,ha=a=>a>=12544&&a<=12591,hb=a=>a>=12704&&a<=12735,hc=a=>a>=12736&&a<=12783,hd=a=>a>=12784&&a<=12799,he=a=>a>=12800&&a<=13055,hf=a=>a>=13056&&a<=13311,hg=a=>a>=13312&&a<=19903,hh=a=>a>=19968&&a<=40959,hi=a=>a>=40960&&a<=42127,hj=a=>a>=42128&&a<=42191,hk=a=>a>=44032&&a<=55215,hl=a=>a>=63744&&a<=64255,hm=a=>a>=64336&&a<=65023,hn=a=>a>=65040&&a<=65055,ho=a=>a>=65072&&a<=65103,hp=a=>a>=65104&&a<=65135,hq=a=>a>=65136&&a<=65279,hr=a=>a>=65280&&a<=65519;function hs(a){for(const b of a)if(hv(b.charCodeAt(0)))return!0;return!1}function ht(a){for(const b of a)if(!hu(b.charCodeAt(0)))return!1;return!0}function hu(a){return!(g1(a)||g2(a)||g3(a)||hm(a)||hq(a))}function hv(a){var b,c,d,e,f,g,h,i;return!(746!==a&&747!==a&&(a<4352||!(hb(a)||ha(a)||ho(a)&&!(a>=65097&&a<=65103)||hl(a)||hf(a)||g4(a)||hc(a)||!(!g7(a)||a>=12296&&a<=12305||a>=12308&&a<=12319||12336===a)||hg(a)||hh(a)||he(a)||(b=a)>=12592&&b<=12687||(c=a)>=43360&&c<=43391||(d=a)>=55216&&d<=55295||(e=a)>=4352&&e<=4607||hk(a)||g8(a)||g6(a)||(f=a)>=12688&&f<=12703||g5(a)||hd(a)||g9(a)&&12540!==a||!(!hr(a)||65288===a||65289===a||65293===a||a>=65306&&a<=65310||65339===a||65341===a||65343===a||a>=65371&&a<=65503||65507===a||a>=65512&&a<=65519)||!(!hp(a)||a>=65112&&a<=65118||a>=65123&&a<=65126)||(g=a)>=5120&&g<=5759||(h=a)>=6320&&h<=6399||hn(a)||(i=a)>=19904&&i<=19967||hi(a)||hj(a))))}function hw(b){var a,c,d,e,f,g,h,i,j,k,l,m,n;return!(hv(b)||(c=a=b)>=128&&c<=255&&(167===a||169===a||174===a||177===a||188===a||189===a||190===a||215===a||247===a)||(d=a)>=8192&&d<=8303&&(8214===a||8224===a||8225===a||8240===a||8241===a||8251===a||8252===a||8258===a||8263===a||8264===a||8265===a||8273===a)||(e=a)>=8448&&e<=8527||(f=a)>=8528&&f<=8591||(g=a)>=8960&&g<=9215&&(a>=8960&&a<=8967||a>=8972&&a<=8991||a>=8996&&a<=9e3||9003===a||a>=9085&&a<=9114||a>=9150&&a<=9165||9167===a||a>=9169&&a<=9179||a>=9186&&a<=9215)||(h=a)>=9216&&h<=9279&&9251!==a||(i=a)>=9280&&i<=9311||(j=a)>=9312&&j<=9471||(k=a)>=9632&&k<=9727||(l=a)>=9728&&l<=9983&&!(a>=9754&&a<=9759)||(m=a)>=11008&&m<=11263&&(a>=11026&&a<=11055||a>=11088&&a<=11097||a>=11192&&a<=11243)||g7(a)||g9(a)||(n=a)>=57344&&n<=63743||ho(a)||hp(a)||hr(a)||8734===a||8756===a||8757===a||a>=9984&&a<=10087||a>=10102&&a<=10131||65532===a||65533===a)}function hx(a){return a>=1424&&a<=2303||hm(a)||hq(a)}function hy(a,c){var b;return!(!c&&hx(a)||a>=2304&&a<=3583||a>=3840&&a<=4255||(b=a)>=6016&&b<=6143)}function hz(a){for(const b of a)if(hx(b.charCodeAt(0)))return!0;return!1}const hA="deferred",hB="loading",hC="loaded";let hD=null,hE="unavailable",hF=null;const c1=function(a){a&&"string"==typeof a&&a.indexOf("NetworkError")> -1&&(hE="error"),hD&&hD(a)};function hG(){c2.fire(new aW("pluginStateChange",{pluginStatus:hE,pluginURL:hF}))}const c2=new S,c3=function(){return hE},hH=function(){if(hE!==hA||!hF)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");hE=hB,hG(),hF&&fi({url:hF},a=>{a?c1(a):(hE=hC,hG())})},c4={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>hE===hC||null!=c4.applyArabicShaping,isLoading:()=>hE===hB,setState(a){hE=a.pluginStatus,hF=a.pluginURL},isParsed:()=>null!=c4.applyArabicShaping&&null!=c4.processBidirectionalText&&null!=c4.processStyledBidirectionalText,getPluginURL:()=>hF};class c5{constructor(b,a){this.zoom=b,a?(this.now=a.now,this.fadeDuration=a.fadeDuration,this.zoomHistory=a.zoomHistory,this.transition=a.transition,this.pitch=a.pitch):(this.now=0,this.fadeDuration=0,this.zoomHistory=new c0,this.transition={},this.pitch=0)}isSupportedScript(a){return function(a,b){for(const c of a)if(!hy(c.charCodeAt(0),b))return!1;return!0}(a,c4.isLoaded())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const a=this.zoom,b=a-Math.floor(a),c=this.crossFadingFactor();return a>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:b+(1-b)*c}:{fromScale:.5,toScale:1,t:1-(1-c)*b}}}class hI{constructor(a,b){this.property=a,this.value=b,this.expression=function(a,b){if(gn(a))return new cQ(a,b);if(gv(a)){const c=gw(a,b);if("error"===c.result)throw new Error(c.value.map(a=>`${a.key}: ${a.message}`).join(", "));return c.value}{let d=a;return"string"==typeof a&&"color"===b.type&&(d=m.parse(a)),{kind:"constant",evaluate:()=>d}}}(void 0===b?a.specification.default:b,a.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(a,b,c){return this.property.possiblyEvaluate(this,a,b,c)}}class hJ{constructor(a){this.property=a,this.value=new hI(a,void 0)}transitioned(a,b){return new hK(this.property,this.value,b,bR({},a.transition,this.transition),a.now)}untransitioned(){return new hK(this.property,this.value,null,{},0)}}class c6{constructor(a){this._properties=a,this._values=Object.create(a.defaultTransitionablePropertyValues)}getValue(a){return bX(this._values[a].value.value)}setValue(a,b){this._values.hasOwnProperty(a)||(this._values[a]=new hJ(this._values[a].property)),this._values[a].value=new hI(this._values[a].property,null===b?void 0:bX(b))}getTransition(a){return bX(this._values[a].transition)}setTransition(a,b){this._values.hasOwnProperty(a)||(this._values[a]=new hJ(this._values[a].property)),this._values[a].transition=bX(b)||void 0}serialize(){const b={};for(const a of Object.keys(this._values)){const c=this.getValue(a);void 0!==c&&(b[a]=c);const d=this.getTransition(a);void 0!==d&&(b[`${a}-transition`]=d)}return b}transitioned(c,d){const b=new hL(this._properties);for(const a of Object.keys(this._values))b._values[a]=this._values[a].transitioned(c,d._values[a]);return b}untransitioned(){const a=new hL(this._properties);for(const b of Object.keys(this._values))a._values[b]=this._values[b].untransitioned();return a}}class hK{constructor(c,d,e,a,b){const f=a.delay||0,g=a.duration||0;b=b||0,this.property=c,this.value=d,this.begin=b+f,this.end=this.begin+g,c.specification.transition&&(a.delay||a.duration)&&(this.prior=e)}possiblyEvaluate(a,c,d){const e=a.now||0,b=this.value.possiblyEvaluate(a,c,d),f=this.prior;if(f){if(e>this.end)return this.prior=null,b;if(this.value.isDataDriven())return this.prior=null,b;if(ed.zoomHistory.lastIntegerZoom?{from:a,to:b,other:c}:{from:c,to:b,other:a}}interpolate(a){return a}}class a5{constructor(a){this.specification=a}possiblyEvaluate(b,a,d,e){if(void 0!==b.value){if("constant"===b.expression.kind){const c=b.expression.evaluate(a,null,{},d,e);return this._calculate(c,c,c,a)}return this._calculate(b.expression.evaluate(new c5(Math.floor(a.zoom-1),a)),b.expression.evaluate(new c5(Math.floor(a.zoom),a)),b.expression.evaluate(new c5(Math.floor(a.zoom+1),a)),a)}}_calculate(c,a,d,b){return b.zoom>b.zoomHistory.lastIntegerZoom?{from:c,to:a}:{from:d,to:a}}interpolate(a){return a}}class V{constructor(a){this.specification=a}possiblyEvaluate(a,b,c,d){return!!a.expression.evaluate(b,null,{},c,d)}interpolate(){return!1}}class n{constructor(b){for(const a in this.properties=b,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[],b){const c=b[a];c.specification.overridable&&this.overridableProperties.push(a);const d=this.defaultPropertyValues[a]=new hI(c,void 0),e=this.defaultTransitionablePropertyValues[a]=new hJ(c);this.defaultTransitioningPropertyValues[a]=e.untransitioned(),this.defaultPossiblyEvaluatedValues[a]=d.possiblyEvaluate({})}}}function hO(a,b){return 256*(a=bM(Math.floor(a),0,255))+bM(Math.floor(b),0,255)}c("DataDrivenProperty",g),c("DataConstantProperty",e),c("CrossFadedDataDrivenProperty",N),c("CrossFadedProperty",a5),c("ColorRampProperty",V);const hP={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class O{constructor(a,b){this._structArray=a,this._pos1=b*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class k{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(a,b){return a._trim(),b&&(a.isTransferred=!0,b.push(a.arrayBuffer)),{length:a.length,arrayBuffer:a.arrayBuffer}}static deserialize(b){const a=Object.create(this.prototype);return a.arrayBuffer=b.arrayBuffer,a.length=b.length,a.capacity=b.arrayBuffer.byteLength/a.bytesPerElement,a._refreshViews(),a}_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(a){this.reserve(a),this.length=a}reserve(a){if(a>this.capacity){this.capacity=Math.max(a,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const b=this.uint8;this._refreshViews(),b&&this.uint8.set(b)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function j(b,a=1){let c=0,d=0;return{members:b.map(b=>{const e=hP[b.type].BYTES_PER_ELEMENT,g=c=hQ(c,Math.max(a,e)),f=b.components||1;return d=Math.max(d,e),c+=e*f,{name:b.name,type:b.type,components:f,offset:g}}),size:hQ(c,Math.max(d,a)),alignment:a}}function hQ(b,a){return Math.ceil(b/a)*a}class al extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(b,c){const a=this.length;return this.resize(a+1),this.emplace(a,b,c)}emplace(a,c,d){const b=2*a;return this.int16[b+0]=c,this.int16[b+1]=d,a}}al.prototype.bytesPerElement=4,c("StructArrayLayout2i4",al);class am extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(b,c,d,e){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e)}emplace(b,c,d,e,f){const a=4*b;return this.int16[a+0]=c,this.int16[a+1]=d,this.int16[a+2]=e,this.int16[a+3]=f,b}}am.prototype.bytesPerElement=8,c("StructArrayLayout4i8",am);class a6 extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(b,c,d,e,f,g,h){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e,f,g,h)}emplace(a,d,e,f,g,h,i,j){const c=6*a,b=12*a,k=3*a;return this.int16[c+0]=d,this.int16[c+1]=e,this.uint8[b+4]=f,this.uint8[b+5]=g,this.uint8[b+6]=h,this.uint8[b+7]=i,this.float32[k+2]=j,a}}a6.prototype.bytesPerElement=12,c("StructArrayLayout2i4ub1f12",a6);class an extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(b,c,d){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d)}emplace(b,c,d,e){const a=3*b;return this.float32[a+0]=c,this.float32[a+1]=d,this.float32[a+2]=e,b}}an.prototype.bytesPerElement=12,c("StructArrayLayout3f12",an);class w extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(b,c,d,e,f,g,h,i,j,k){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e,f,g,h,i,j,k)}emplace(b,c,d,e,f,g,h,i,j,k,l){const a=10*b;return this.uint16[a+0]=c,this.uint16[a+1]=d,this.uint16[a+2]=e,this.uint16[a+3]=f,this.uint16[a+4]=g,this.uint16[a+5]=h,this.uint16[a+6]=i,this.uint16[a+7]=j,this.uint16[a+8]=k,this.uint16[a+9]=l,b}}w.prototype.bytesPerElement=20,c("StructArrayLayout10ui20",w);class W extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(b,c,d,e,f,g,h,i){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e,f,g,h,i)}emplace(b,c,d,e,f,g,h,i,j){const a=8*b;return this.uint16[a+0]=c,this.uint16[a+1]=d,this.uint16[a+2]=e,this.uint16[a+3]=f,this.uint16[a+4]=g,this.uint16[a+5]=h,this.uint16[a+6]=i,this.uint16[a+7]=j,b}}W.prototype.bytesPerElement=16,c("StructArrayLayout8ui16",W);class a7 extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q)}emplace(b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r){const a=16*b;return this.int16[a+0]=c,this.int16[a+1]=d,this.int16[a+2]=e,this.int16[a+3]=f,this.uint16[a+4]=g,this.uint16[a+5]=h,this.uint16[a+6]=i,this.uint16[a+7]=j,this.int16[a+8]=k,this.int16[a+9]=l,this.int16[a+10]=m,this.int16[a+11]=n,this.int16[a+12]=o,this.int16[a+13]=p,this.int16[a+14]=q,this.int16[a+15]=r,b}}a7.prototype.bytesPerElement=32,c("StructArrayLayout4i4ui4i4i32",a7);class a8 extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(b){const a=this.length;return this.resize(a+1),this.emplace(a,b)}emplace(a,b){return this.uint32[1*a+0]=b,a}}a8.prototype.bytesPerElement=4,c("StructArrayLayout1ul4",a8);class ao extends k{_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(b,c,d,e,f,g,h,i,j,k,l,m,n){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e,f,g,h,i,j,k,l,m,n)}emplace(c,d,e,f,g,h,i,j,k,l,m,n,o,p){const a=20*c,b=10*c;return this.int16[a+0]=d,this.int16[a+1]=e,this.int16[a+2]=f,this.int16[a+3]=g,this.int16[a+4]=h,this.float32[b+3]=i,this.float32[b+4]=j,this.float32[b+5]=k,this.float32[b+6]=l,this.int16[a+14]=m,this.uint32[b+8]=n,this.uint16[a+18]=o,this.uint16[a+19]=p,c}}ao.prototype.bytesPerElement=40,c("StructArrayLayout5i4f1i1ul2ui40",ao);class a9 extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(b,c,d,e,f,g,h){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e,f,g,h)}emplace(b,c,d,e,f,g,h,i){const a=8*b;return this.int16[a+0]=c,this.int16[a+1]=d,this.int16[a+2]=e,this.int16[a+4]=f,this.int16[a+5]=g,this.int16[a+6]=h,this.int16[a+7]=i,b}}a9.prototype.bytesPerElement=16,c("StructArrayLayout3i2i2i16",a9);class ap extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(b,c,d,e,f){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e,f)}emplace(a,d,e,f,g,h){const b=4*a,c=8*a;return this.float32[b+0]=d,this.float32[b+1]=e,this.float32[b+2]=f,this.int16[c+6]=g,this.int16[c+7]=h,a}}ap.prototype.bytesPerElement=16,c("StructArrayLayout2f1f2i16",ap);class ba extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(b,c,d,e){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e)}emplace(a,d,e,f,g){const b=12*a,c=3*a;return this.uint8[b+0]=d,this.uint8[b+1]=e,this.float32[c+1]=f,this.float32[c+2]=g,a}}ba.prototype.bytesPerElement=12,c("StructArrayLayout2ub2f12",ba);class aq extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(b,c,d){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d)}emplace(b,c,d,e){const a=3*b;return this.uint16[a+0]=c,this.uint16[a+1]=d,this.uint16[a+2]=e,b}}aq.prototype.bytesPerElement=6,c("StructArrayLayout3ui6",aq);class ar extends k{_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(b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v)}emplace(c,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y){const a=30*c,b=15*c,d=60*c;return this.int16[a+0]=e,this.int16[a+1]=f,this.int16[a+2]=g,this.float32[b+2]=h,this.float32[b+3]=i,this.uint16[a+8]=j,this.uint16[a+9]=k,this.uint32[b+5]=l,this.uint32[b+6]=m,this.uint32[b+7]=n,this.uint16[a+16]=o,this.uint16[a+17]=p,this.uint16[a+18]=q,this.float32[b+10]=r,this.float32[b+11]=s,this.uint8[d+48]=t,this.uint8[d+49]=u,this.uint8[d+50]=v,this.uint32[b+13]=w,this.int16[a+28]=x,this.uint8[d+58]=y,c}}ar.prototype.bytesPerElement=60,c("StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60",ar);class as extends k{_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(b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E)}emplace(c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G){const a=38*c,b=19*c;return this.int16[a+0]=d,this.int16[a+1]=e,this.int16[a+2]=f,this.float32[b+2]=g,this.float32[b+3]=h,this.int16[a+8]=i,this.int16[a+9]=j,this.int16[a+10]=k,this.int16[a+11]=l,this.int16[a+12]=m,this.int16[a+13]=n,this.uint16[a+14]=o,this.uint16[a+15]=p,this.uint16[a+16]=q,this.uint16[a+17]=r,this.uint16[a+18]=s,this.uint16[a+19]=t,this.uint16[a+20]=u,this.uint16[a+21]=v,this.uint16[a+22]=w,this.uint16[a+23]=x,this.uint16[a+24]=y,this.uint16[a+25]=z,this.uint16[a+26]=A,this.uint16[a+27]=B,this.uint16[a+28]=C,this.uint32[b+15]=D,this.float32[b+16]=E,this.float32[b+17]=F,this.float32[b+18]=G,c}}as.prototype.bytesPerElement=76,c("StructArrayLayout3i2f6i15ui1ul3f76",as);class X extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(b){const a=this.length;return this.resize(a+1),this.emplace(a,b)}emplace(a,b){return this.float32[1*a+0]=b,a}}X.prototype.bytesPerElement=4,c("StructArrayLayout1f4",X);class at extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(b,c,d){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d)}emplace(b,c,d,e){const a=3*b;return this.int16[a+0]=c,this.int16[a+1]=d,this.int16[a+2]=e,b}}at.prototype.bytesPerElement=6,c("StructArrayLayout3i6",at);class bb extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(b,c,d,e,f,g,h){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e,f,g,h)}emplace(b,c,d,e,f,g,h,i){const a=7*b;return this.float32[a+0]=c,this.float32[a+1]=d,this.float32[a+2]=e,this.float32[a+3]=f,this.float32[a+4]=g,this.float32[a+5]=h,this.float32[a+6]=i,b}}bb.prototype.bytesPerElement=28,c("StructArrayLayout7f28",bb);class au extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(b,c,d,e){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e)}emplace(a,c,d,e,f){const b=6*a;return this.uint32[3*a+0]=c,this.uint16[b+2]=d,this.uint16[b+3]=e,this.uint16[b+4]=f,a}}au.prototype.bytesPerElement=12,c("StructArrayLayout1ul3ui12",au);class Y extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(b,c){const a=this.length;return this.resize(a+1),this.emplace(a,b,c)}emplace(a,c,d){const b=2*a;return this.uint16[b+0]=c,this.uint16[b+1]=d,a}}Y.prototype.bytesPerElement=4,c("StructArrayLayout2ui4",Y);class av extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(b){const a=this.length;return this.resize(a+1),this.emplace(a,b)}emplace(a,b){return this.uint16[1*a+0]=b,a}}av.prototype.bytesPerElement=2,c("StructArrayLayout1ui2",av);class Z extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(b,c){const a=this.length;return this.resize(a+1),this.emplace(a,b,c)}emplace(a,c,d){const b=2*a;return this.float32[b+0]=c,this.float32[b+1]=d,a}}Z.prototype.bytesPerElement=8,c("StructArrayLayout2f8",Z);class aw extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(b,c,d,e){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e)}emplace(b,c,d,e,f){const a=4*b;return this.float32[a+0]=c,this.float32[a+1]=d,this.float32[a+2]=e,this.float32[a+3]=f,b}}aw.prototype.bytesPerElement=16,c("StructArrayLayout4f16",aw);class c7 extends O{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]}}c7.prototype.size=40;class c8 extends ao{get(a){return new c7(this,a)}}c("CollisionBoxArray",c8);class c9 extends O{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(a){this._structArray.uint8[this._pos1+49]=a}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(a){this._structArray.uint8[this._pos1+50]=a}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(a){this._structArray.uint32[this._pos4+13]=a}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(a){this._structArray.uint8[this._pos1+58]=a}}c9.prototype.size=60;class da extends ar{get(a){return new c9(this,a)}}c("PlacedSymbolArray",da);class db extends O{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 rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+11]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+13]}get key(){return this._structArray.uint16[this._pos2+14]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+17]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+19]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+21]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+22]}get featureIndex(){return this._structArray.uint16[this._pos2+23]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+25]}get numIconVertices(){return this._structArray.uint16[this._pos2+26]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+27]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+28]}get crossTileID(){return this._structArray.uint32[this._pos4+15]}set crossTileID(a){this._structArray.uint32[this._pos4+15]=a}get textOffset0(){return this._structArray.float32[this._pos4+16]}get textOffset1(){return this._structArray.float32[this._pos4+17]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+18]}}db.prototype.size=76;class dc extends as{get(a){return new db(this,a)}}c("SymbolInstanceArray",dc);class dd extends X{getoffsetX(a){return this.float32[1*a+0]}}c("GlyphOffsetArray",dd);class de extends at{getx(a){return this.int16[3*a+0]}gety(a){return this.int16[3*a+1]}gettileUnitDistanceFromAnchor(a){return this.int16[3*a+2]}}c("SymbolLineVertexArray",de);class df extends O{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]}}df.prototype.size=12;class dg extends au{get(a){return new df(this,a)}}c("FeatureIndexArray",dg);class dh extends O{get a_centroid_pos0(){return this._structArray.uint16[this._pos2+0]}get a_centroid_pos1(){return this._structArray.uint16[this._pos2+1]}}dh.prototype.size=4;class di extends Y{get(a){return new dh(this,a)}}c("FillExtrusionCentroidArray",di);const hR=j([{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},]),hS=j([{name:"a_dash_to",components:4,type:"Uint16"},{name:"a_dash_from",components:4,type:"Uint16"},]);var bc=ah(function(a){a.exports=function(c,j){var g,h,a,i,e,f,b,d;for(h=c.length-(g=3&c.length),a=j,e=3432918353,f=461845907,d=0;d>>16)*e&65535)<<16)&4294967295)<<15|b>>>17))*f+(((b>>>16)*f&65535)<<16)&4294967295)<<13|a>>>19))+((5*(a>>>16)&65535)<<16)&4294967295))+((58964+(i>>>16)&65535)<<16);switch(b=0,g){case 3:b^=(255&c.charCodeAt(d+2))<<16;case 2:b^=(255&c.charCodeAt(d+1))<<8;case 1:a^=b=(65535&(b=(b=(65535&(b^=255&c.charCodeAt(d)))*e+(((b>>>16)*e&65535)<<16)&4294967295)<<15|b>>>17))*f+(((b>>>16)*f&65535)<<16)&4294967295}return a^=c.length,a=2246822507*(65535&(a^=a>>>16))+((2246822507*(a>>>16)&65535)<<16)&4294967295,a=3266489909*(65535&(a^=a>>>13))+((3266489909*(a>>>16)&65535)<<16)&4294967295,(a^=a>>>16)>>>0}}),dj=ah(function(a){a.exports=function(b,f){for(var d,e=b.length,a=f^e,c=0;e>=4;)d=1540483477*(65535&(d=255&b.charCodeAt(c)|(255&b.charCodeAt(++c))<<8|(255&b.charCodeAt(++c))<<16|(255&b.charCodeAt(++c))<<24))+((1540483477*(d>>>16)&65535)<<16),a=1540483477*(65535&a)+((1540483477*(a>>>16)&65535)<<16)^(d=1540483477*(65535&(d^=d>>>24))+((1540483477*(d>>>16)&65535)<<16)),e-=4,++c;switch(e){case 3:a^=(255&b.charCodeAt(c+2))<<16;case 2:a^=(255&b.charCodeAt(c+1))<<8;case 1:a=1540483477*(65535&(a^=255&b.charCodeAt(c)))+((1540483477*(a>>>16)&65535)<<16)}return a=1540483477*(65535&(a^=a>>>13))+((1540483477*(a>>>16)&65535)<<16),(a^=a>>>15)>>>0}}),bd=bc;bd.murmur3=bc,bd.murmur2=dj;class dk{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(a,b,c,d){this.ids.push(hT(a)),this.positions.push(b,c,d)}getPositions(f){const d=hT(f);let a=0,b=this.ids.length-1;for(;a>1;this.ids[c]>=d?b=c:a=c+1}const e=[];for(;this.ids[a]===d;)e.push({index:this.positions[3*a],start:this.positions[3*a+1],end:this.positions[3*a+2]}),a++;return e}static serialize(c,d){const a=new Float64Array(c.ids),b=new Uint32Array(c.positions);return hU(a,b,0,a.length-1),d&&d.push(a.buffer,b.buffer),{ids:a,positions:b}}static deserialize(b){const a=new dk;return a.ids=b.ids,a.positions=b.positions,a.indexed=!0,a}}function hT(b){const a=+b;return!isNaN(a)&&Number.MIN_SAFE_INTEGER<=a&&a<=Number.MAX_SAFE_INTEGER?a:bd(String(b))}function hU(c,f,d,e){for(;d>1];let b=d-1,a=e+1;for(;;){do b++;while(c[b]g)if(b>=a)break;hV(c,b,a),hV(f,3*b,3*a),hV(f,3*b+1,3*a+1),hV(f,3*b+2,3*a+2)}a-d`u_${a}`),this.type=c}setUniform(a,c,b){a.set(b.constantOr(this.value))}getBinding(a,b,c){return"color"===this.type?new dn(a,b):new dl(a,b)}}class dq{constructor(b,a){this.uniformNames=a.map(a=>`u_${a}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(a,b){this.pixelRatioFrom=b.pixelRatio,this.pixelRatioTo=a.pixelRatio,this.patternFrom=b.tl.concat(b.br),this.patternTo=a.tl.concat(a.br)}setUniform(c,d,e,a){const b="u_pattern_to"===a||"u_dash_to"===a?this.patternTo:"u_pattern_from"===a||"u_dash_from"===a?this.patternFrom:"u_pixel_ratio_to"===a?this.pixelRatioTo:"u_pixel_ratio_from"===a?this.pixelRatioFrom:null;b&&c.set(b)}getBinding(b,c,a){return"u_pattern_from"===a||"u_pattern_to"===a||"u_dash_from"===a||"u_dash_to"===a?new dm(b,c):new dl(b,c)}}class dr{constructor(a,b,c,d){this.expression=a,this.type=c,this.maxValue=0,this.paintVertexAttributes=b.map(a=>({name:`a_${a}`,type:"Float32",components:"color"===c?2:1,offset:0})),this.paintVertexArray=new d}populatePaintArray(a,b,h,c,d,e){const f=this.paintVertexArray.length,g=this.expression.evaluate(new c5(0),b,{},d,c,e);this.paintVertexArray.resize(a),this._setPaintValue(f,a,g)}updatePaintArray(a,b,c,d,e){const f=this.expression.evaluate({zoom:0},c,d,void 0,e);this._setPaintValue(a,b,f)}_setPaintValue(d,e,a){if("color"===this.type){const f=hZ(a);for(let b=d;b`u_${a}_t`),this.type=c,this.useIntegerZoom=d,this.zoom=e,this.maxValue=0,this.paintVertexAttributes=a.map(a=>({name:`a_${a}`,type:"Float32",components:"color"===c?4:2,offset:0})),this.paintVertexArray=new f}populatePaintArray(a,b,i,c,d,e){const f=this.expression.evaluate(new c5(this.zoom),b,{},d,c,e),g=this.expression.evaluate(new c5(this.zoom+1),b,{},d,c,e),h=this.paintVertexArray.length;this.paintVertexArray.resize(a),this._setPaintValue(h,a,f,g)}updatePaintArray(d,e,a,b,c){const f=this.expression.evaluate({zoom:this.zoom},a,b,void 0,c),g=this.expression.evaluate({zoom:this.zoom+1},a,b,void 0,c);this._setPaintValue(d,e,f,g)}_setPaintValue(e,f,a,b){if("color"===this.type){const g=hZ(a),h=hZ(b);for(let c=e;c!0){this.binders={},this._buffers=[];const g=[];for(const a in e.paint._values){if(!n(a))continue;const c=e.paint.get(a);if(!(c instanceof hM&&gj(c.property.specification)))continue;const f=h_(a,e.type),b=c.value,d=c.property.specification.type,j=c.property.useIntegerZoom,k=c.property.specification["property-type"],h="cross-faded"===k||"cross-faded-data-driven"===k,l="line-dasharray"===String(a)&&"constant"!==e.layout.get("line-cap").value.kind;if("constant"!==b.kind||l){if("source"===b.kind||l||h){const m=h2(a,d,"source");this.binders[a]=h?new dt(b,f,d,j,i,m,e.id):new dr(b,f,d,m),g.push(`/a_${a}`)}else{const o=h2(a,d,"composite");this.binders[a]=new ds(b,f,d,j,i,o),g.push(`/z_${a}`)}}else this.binders[a]=h?new dq(b.value,f):new dp(b.value,f,d),g.push(`/u_${a}`)}this.cacheKey=g.sort().join("")}getMaxValue(b){const a=this.binders[b];return a instanceof dr||a instanceof ds?a.maxValue:0}populatePaintArrays(b,c,d,e,f,g){for(const h in this.binders){const a=this.binders[h];(a instanceof dr||a instanceof ds||a instanceof dt)&&a.populatePaintArray(b,c,d,e,f,g)}}setConstantPatternPositions(b,c){for(const d in this.binders){const a=this.binders[d];a instanceof dq&&a.setConstantPatternPositions(b,c)}}updatePaintArrays(c,g,h,i,j,k){let d=!1;for(const e in c){const l=g.getPositions(e);for(const b of l){const m=h.feature(b.index);for(const f in this.binders){const a=this.binders[f];if((a instanceof dr||a instanceof ds||a instanceof dt)&& !0===a.expression.isStateDependent){const n=i.paint.get(f);a.expression=n.value,a.updatePaintArray(b.start,b.end,m,c[e],j,k),d=!0}}}}return d}defines(){const b=[];for(const c in this.binders){const a=this.binders[c];(a instanceof dp||a instanceof dq)&&b.push(...a.uniformNames.map(a=>`#define HAS_UNIFORM_${a}`))}return b}getBinderAttributes(){const c=[];for(const d in this.binders){const a=this.binders[d];if(a instanceof dr||a instanceof ds||a instanceof dt)for(let b=0;b!0){for(const a of(this.programConfigurations={},b))this.programConfigurations[a.id]=new du(a,c,d);this.needsUpload=!1,this._featureMap=new dk,this._bufferOffset=0}populatePaintArrays(a,b,c,d,e,f,g){for(const h in this.programConfigurations)this.programConfigurations[h].populatePaintArrays(a,b,d,e,f,g);void 0!==b.id&&this._featureMap.add(b.id,c,this._bufferOffset,a),this._bufferOffset=a,this.needsUpload=!0}updatePaintArrays(b,c,d,e,f){for(const a of d)this.needsUpload=this.programConfigurations[a.id].updatePaintArrays(b,this._featureMap,c,a,e,f)||this.needsUpload}get(a){return this.programConfigurations[a]}upload(a){if(this.needsUpload){for(const b in this.programConfigurations)this.programConfigurations[b].upload(a);this.needsUpload=!1}}destroy(){for(const a in this.programConfigurations)this.programConfigurations[a].destroy()}}const h$={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from",],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from",],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from",],"line-dasharray":["dash_to","dash_from"]};function h_(a,b){return h$[a]||[a.replace(`${b}-`,"").replace(/-/g,"_"),]}const h0={"line-pattern":{source:w,composite:w},"fill-pattern":{source:w,composite:w},"fill-extrusion-pattern":{source:w,composite:w},"line-dasharray":{source:W,composite:W}},h1={color:{source:Z,composite:aw},number:{source:X,composite:Z}};function h2(c,d,a){const b=h0[c];return b&&b[a]||h1[d][a]}c("ConstantBinder",dp),c("CrossFadedConstantBinder",dq),c("SourceExpressionBinder",dr),c("CrossFadedCompositeBinder",dt),c("CompositeExpressionBinder",ds),c("ProgramConfiguration",du,{omit:["_buffers"]}),c("ProgramConfigurationSet",dv);const h3="-transition";class be extends S{constructor(a,b){if(super(),this.id=a.id,this.type=a.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,"custom"!==a.type&&(this.metadata=a.metadata,this.minzoom=a.minzoom,this.maxzoom=a.maxzoom,"background"!==a.type&&"sky"!==a.type&&(this.source=a.source,this.sourceLayer=a["source-layer"],this.filter=a.filter),b.layout&&(this._unevaluatedLayout=new class{constructor(a){this._properties=a,this._values=Object.create(a.defaultPropertyValues)}getValue(a){return bX(this._values[a].value)}setValue(a,b){this._values[a]=new hI(this._values[a].property,null===b?void 0:bX(b))}serialize(){const a={};for(const b of Object.keys(this._values)){const c=this.getValue(b);void 0!==c&&(a[b]=c)}return a}possiblyEvaluate(c,d,e){const a=new hN(this._properties);for(const b of Object.keys(this._values))a._values[b]=this._values[b].possiblyEvaluate(c,d,e);return a}}(b.layout)),b.paint)){for(const c in this._transitionablePaint=new c6(b.paint),a.paint)this.setPaintProperty(c,a.paint[c],{validate:!1});for(const d in a.layout)this.setLayoutProperty(d,a.layout[d],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new hN(b.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(a){return"visibility"===a?this.visibility:this._unevaluatedLayout.getValue(a)}setLayoutProperty(a,b,c={}){null!=b&&this._validate(gV,`layers.${this.id}.layout.${a}`,a,b,c)||("visibility"!==a?this._unevaluatedLayout.setValue(a,b):this.visibility=b)}getPaintProperty(a){return bV(a,h3)?this._transitionablePaint.getTransition(a.slice(0,-h3.length)):this._transitionablePaint.getValue(a)}setPaintProperty(a,b,e={}){if(null!=b&&this._validate(gU,`layers.${this.id}.paint.${a}`,a,b,e))return!1;if(bV(a,h3))return this._transitionablePaint.setTransition(a.slice(0,-h3.length),b||void 0),!1;{const c=this._transitionablePaint._values[a],f="cross-faded-data-driven"===c.property.specification["property-type"],g=c.value.isDataDriven(),h=c.value;this._transitionablePaint.setValue(a,b),this._handleSpecialPaintPropertyUpdate(a);const d=this._transitionablePaint._values[a].value;return d.isDataDriven()||g||f||this._handleOverridablePaintPropertyUpdate(a,h,d)}}_handleSpecialPaintPropertyUpdate(a){}getProgramIds(){return null}getProgramConfiguration(a){return null}_handleOverridablePaintPropertyUpdate(a,b,c){return!1}isHidden(a){return!!(this.minzoom&&a=this.maxzoom)||"none"===this.visibility}updateTransitions(a){this._transitioningPaint=this._transitionablePaint.transitioned(a,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(a,b){a.getCrossfadeParameters&&(this._crossfadeParameters=a.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(a,void 0,b)),this.paint=this._transitioningPaint.possiblyEvaluate(a,void 0,b)}serialize(){const a={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(a.layout=a.layout||{},a.layout.visibility=this.visibility),bW(a,(a,b)=>!(void 0===a||"layout"===b&&!Object.keys(a).length||"paint"===b&&!Object.keys(a).length))}_validate(c,d,e,f,a={}){return(!a|| !1!==a.validate)&&c_(this,c.call(M,{key:d,layerType:this.type,objectKey:e,value:f,styleSpec:b,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const b in this.paint._values){const a=this.paint.get(b);if(a instanceof hM&&gj(a.property.specification)&&("source"===a.value.kind||"composite"===a.value.kind)&&a.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=gB(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const dw=j([{name:"a_pos",components:2,type:"Int16"},],4),{members:h4}=dw;class ay{constructor(a=[]){this.segments=a}prepareSegment(b,d,e,c){let a=this.segments[this.segments.length-1];return b>ay.MAX_VERTEX_ARRAY_LENGTH&&bY(`Max vertices per segment is ${ay.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${b}`),(!a||a.vertexLength+b>ay.MAX_VERTEX_ARRAY_LENGTH||a.sortKey!==c)&&(a={vertexOffset:d.length,primitiveOffset:e.length,vertexLength:0,primitiveLength:0},void 0!==c&&(a.sortKey=c),this.segments.push(a)),a}get(){return this.segments}destroy(){for(const a of this.segments)for(const b in a.vaos)a.vaos[b].destroy()}static simpleSegment(a,b,c,d){return new ay([{vertexOffset:a,primitiveOffset:b,vertexLength:c,primitiveLength:d,vaos:{},sortKey:0},])}}ay.MAX_VERTEX_ARRAY_LENGTH=65535,c("SegmentVector",ay);class dx{constructor(a,b){a&&(b?this.setSouthWest(a).setNorthEast(b):4===a.length?this.setSouthWest([a[0],a[1],]).setNorthEast([a[2],a[3]]):this.setSouthWest(a[0]).setNorthEast(a[1]))}setNorthEast(a){return this._ne=a instanceof dy?new dy(a.lng,a.lat):dy.convert(a),this}setSouthWest(a){return this._sw=a instanceof dy?new dy(a.lng,a.lat):dy.convert(a),this}extend(a){const d=this._sw,e=this._ne;let b,c;if(a instanceof dy)b=a,c=a;else{if(!(a instanceof dx))return Array.isArray(a)?4===a.length||a.every(Array.isArray)?this.extend(dx.convert(a)):this.extend(dy.convert(a)):this;if(b=a._sw,c=a._ne,!b||!c)return this}return d||e?(d.lng=Math.min(b.lng,d.lng),d.lat=Math.min(b.lat,d.lat),e.lng=Math.max(c.lng,e.lng),e.lat=Math.max(c.lat,e.lat)):(this._sw=new dy(b.lng,b.lat),this._ne=new dy(c.lng,c.lat)),this}getCenter(){return new dy((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 dy(this.getWest(),this.getNorth())}getSouthEast(){return new dy(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(d){const{lng:a,lat:b}=dy.convert(d);let c=this._sw.lng<=a&&a<=this._ne.lng;return this._sw.lng>this._ne.lng&&(c=this._sw.lng>=a&&a>=this._ne.lng),this._sw.lat<=b&&b<=this._ne.lat&&c}static convert(a){return!a||a instanceof dx?a:new dx(a)}}class dy{constructor(a,b){if(isNaN(a)||isNaN(b))throw new Error(`Invalid LngLat object: (${a}, ${b})`);if(this.lng=+a,this.lat=+b,this.lat>90||this.lat< -90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new dy(bO(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(b){const a=Math.PI/180,c=this.lat*a,d=b.lat*a,e=Math.sin(c)*Math.sin(d)+Math.cos(c)*Math.cos(d)*Math.cos((b.lng-this.lng)*a);return 6371008.8*Math.acos(Math.min(e,1))}toBounds(c=0){const a=360*c/40075017,b=a/Math.cos(Math.PI/180*this.lat);return new dx(new dy(this.lng-b,this.lat-a),new dy(this.lng+b,this.lat+a))}static convert(a){if(a instanceof dy)return a;if(Array.isArray(a)&&(2===a.length||3===a.length))return new dy(Number(a[0]),Number(a[1]));if(!Array.isArray(a)&&"object"==typeof a&&null!==a)return new dy(Number("lng"in a?a.lng:a.lon),Number(a.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 [, ]")}}const h5=2*Math.PI*6371008.8;function h6(a){return h5*Math.cos(a*Math.PI/180)}function dz(a){return(180+a)/360}function dA(a){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+a*Math.PI/360)))/360}function dB(a,b){return a/h6(b)}function h7(a){return 360*a-180}function dC(a){return 360/Math.PI*Math.atan(Math.exp((180-360*a)*Math.PI/180))-90}function h8(a,b){return a*h6(dC(b))}class dD{constructor(a,b,c=0){this.x=+a,this.y=+b,this.z=+c}static fromLngLat(b,c=0){const a=dy.convert(b);return new dD(dz(a.lng),dA(a.lat),dB(c,a.lat))}toLngLat(){return new dy(h7(this.x),dC(this.y))}toAltitude(){return h8(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/h5*(1/Math.cos(dC(this.y)*Math.PI/180))}}function h9(c,i,j,k,l,d,b,e,f){const g=(i+k)/2,h=(j+l)/2,a=new aF(g,h);e(a),function(e,f,a,b,g,h){const c=a-g,d=b-h;return Math.abs((b-f)*c-(a-e)*d)/Math.hypot(c,d)}(a.x,a.y,d.x,d.y,b.x,b.y)>=f?(h9(c,i,j,g,h,d,a,e,f),h9(c,g,h,k,l,a,b,e,f)):c.push(b)}function ia(i,d,j){const b=[];let e,f,c;for(const a of i){const{x:g,y:h}=a;d(a),c?h9(b,e,f,g,h,c,a,d,j):b.push(a),e=g,f=h,c=a}return b}function ib(a,d){const b=Math.round(a.x*d),c=Math.round(a.y*d);return a.x=bM(b,-16384,16383),a.y=bM(c,-16384,16383),(ba.x+1||ca.y+1)&&bY("Geometry exceeds allowed extent, reduce your vector tile buffer size"),a}function ic(d,g,e){const a=d.loadGeometry(),f=d.extent,j=8192/f;if(g&&e&&e.projection.isReprojectedInTileSpace){const m=1<{const c=h7((g.x+a.x/f)/m),d=dC((g.y+a.y/f)/m),b=q.project(c,d);a.x=(b.x*n-o)*f,a.y=(b.y*n-p)*f};for(let b=0;b=f||c.y<0||c.y>=f||(h(c),i.push(c));a[b]=i}}for(const k of a)for(const l of k)ib(l,j);return a}function id(a,b){return{type:a.type,id:a.id,properties:a.properties,geometry:b?ic(a):[]}}function ie(a,b,c,d,e){a.emplaceBack(2*b+(d+1)/2,2*c+(e+1)/2)}class bf{constructor(a){this.zoom=a.zoom,this.overscaling=a.overscaling,this.layers=a.layers,this.layerIds=this.layers.map(a=>a.id),this.index=a.index,this.hasPattern=!1,this.layoutVertexArray=new al,this.indexArray=new aq,this.segments=new ay,this.programConfigurations=new dv(a.layers,a.zoom),this.stateDependentLayerIds=this.layers.filter(a=>a.isStateDependent()).map(a=>a.id)}populate(g,h,a,m){const i=this.layers[0],d=[];let b=null;for(const{feature:c,id:n,index:o,sourceLayerIndex:p}of("circle"===i.type&&(b=i.layout.get("circle-sort-key")),g)){const j=this.layers[0]._featureFilter.needGeometry,e=id(c,j);if(!this.layers[0]._featureFilter.filter(new c5(this.zoom),e,a))continue;const q=b?b.evaluate(e,{},a):void 0,r={id:n,properties:c.properties,type:c.type,sourceLayerIndex:p,index:o,geometry:j?e.geometry:ic(c,a,m),patterns:{},sortKey:q};d.push(r)}for(const k of(b&&d.sort((a,b)=>a.sortKey-b.sortKey),d)){const{geometry:l,index:f,sourceLayerIndex:s}=k,t=g[f].feature;this.addFeature(k,l,f,h.availableImages,a),h.featureIndex.insert(t,l,f,s,this.index)}}update(a,b,c,d){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(a,b,this.stateDependentLayers,c,d)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(a){this.uploaded||(this.layoutVertexBuffer=a.createVertexBuffer(this.layoutVertexArray,h4),this.indexBuffer=a.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(a),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,g,h,i,j){for(const k of g)for(const f of k){const a=f.x,b=f.y;if(a<0||a>=8192||b<0||b>=8192)continue;const d=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),c=d.vertexLength;ie(this.layoutVertexArray,a,b,-1,-1),ie(this.layoutVertexArray,a,b,1,-1),ie(this.layoutVertexArray,a,b,1,1),ie(this.layoutVertexArray,a,b,-1,1),this.indexArray.emplaceBack(c,c+1,c+2),this.indexArray.emplaceBack(c,c+3,c+2),d.vertexLength+=4,d.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,h,{},i,j)}}function dE(a,b){for(let c=0;c1){if(ij(a,b))return!0;for(let c=0;c1?b:b.sub(a)._mult(d)._add(a))}function io(h,c){let b,a,d,e=!1;for(let f=0;fc.y!=d.y>c.y&&c.x<(d.x-a.x)*(c.y-a.y)/(d.y-a.y)+a.x&&(e=!e)}return e}function ip(b,c){let d=!1;for(let e=0,g=b.length-1;ec.y!=f.y>c.y&&c.x<(f.x-a.x)*(c.y-a.y)/(f.y-a.y)+a.x&&(d=!d)}return d}function dF(a,d,e,f,g){for(const b of a)if(d<=b.x&&e<=b.y&&f>=b.x&&g>=b.y)return!0;const h=[new aF(d,e),new aF(d,g),new aF(f,g),new aF(f,e),];if(a.length>2){for(const i of h)if(ip(a,i))return!0}for(let c=0;ce.x&&b.x>e.x||a.ye.y&&b.y>e.y)return!1;const f=eR(a,b,c[0]);return f!==eR(a,b,c[1])||f!==eR(a,b,c[2])||f!==eR(a,b,c[3])}function ir(a,b,d){const c=b.paint.get(a).value;return"constant"===c.kind?c.value:d.programConfigurations.get(b.id).getMaxValue(a)}function is(a){return Math.sqrt(a[0]*a[0]+a[1]*a[1])}function it(a,b,f,g,h){if(!b[0]&&!b[1])return a;const d=aF.convert(b)._mult(h);"viewport"===f&&d._rotate(-g);const e=[];for(let c=0;c{var a,b,c;const h=bF([],j,d),i=1/h[3]/e*g;return a=h,b=h,c=[i,i,f?1/h[3]:i,i],a[0]=b[0]*c[0],a[1]=b[1]*c[1],a[2]=b[2]*c[2],a[3]=b[3]*c[3],a}),c=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5],].map(a=>{const c=bz([],bB([],bE([],b[a[0]],b[a[1]]),bE([],b[a[2]],b[a[1]]))),d=-bA(c,b[a[1]]);return c.concat(d)});return new dH(b,c)}}class B{constructor(a,b){this.min=a,this.max=b,this.center=bx([],bw([],this.min,this.max),.5)}quadrant(d){const b=[d%2==0,d<2],e=eH(this.min),c=eH(this.max);for(let a=0;a=0;if(0===e)return 0;e!==c.length&&(j=!1)}if(j)return 2;for(let a=0;a<3;a++){let g=Number.MAX_VALUE,h=-Number.MAX_VALUE;for(let i=0;ithis.max[a]-this.min[a])return 0}return 1}}function iw(b,l,c,g,h,a,i,m,d){if(a&&b.queryGeometry.isAboveHorizon)return!1;for(const n of(a&&(d*=b.pixelToTileUnitsFactor),l))for(const f of n){const e=f.add(m),j=h&&c.elevation?c.elevation.exaggeration()*h.getElevationAt(e.x,e.y,!0):0,o=a?e:ix(e,j,g),p=a?b.tilespaceRays.map(a=>iA(a,j)):b.queryGeometry.screenGeometry,k=bF([],[f.x,f.y,j,1],g);if(!i&&a?d*=k[3]/c.cameraToCenterDistance:i&&!a&&(d*=c.cameraToCenterDistance/k[3]),ig(p,o,d))return!0}return!1}function ix(b,c,d){const a=bF([],[b.x,b.y,c,1],d);return new aF(a[0]/a[3],a[1]/a[3])}const iy=Q(0,0,0),iz=Q(0,0,1);function iA(b,c){const a=aK();return iy[2]=c,b.intersectsPlane(iy,iz,a),new aF(a[0],a[1])}class dI extends bf{}function iB(b,{width:c,height:d},e,a){if(a){if(a instanceof Uint8ClampedArray)a=new Uint8Array(a.buffer);else if(a.length!==c*d*e)throw new RangeError("mismatched image size")}else a=new Uint8Array(c*d*e);return b.width=c,b.height=d,b.data=a,b}function iC(a,{width:b,height:c},d){if(b===a.width&&c===a.height)return;const e=iB({},{width:b,height:c},d);iD(a,e,{x:0,y:0},{x:0,y:0},{width:Math.min(a.width,b),height:Math.min(a.height,c)},d),a.width=b,a.height=c,a.data=e.data}function iD(c,b,d,e,a,h){if(0===a.width||0===a.height)return b;if(a.width>c.width||a.height>c.height||d.x>c.width-a.width||d.y>c.height-a.height)throw new RangeError("out of range source coordinates for image copy");if(a.width>b.width||a.height>b.height||e.x>b.width-a.width||e.y>b.height-a.height)throw new RangeError("out of range destination coordinates for image copy");const i=c.data,j=b.data;for(let f=0;f{o[a.evaluationKey]=e;const b=a.expression.evaluate(o);l.data[c+d+0]=Math.floor(255*b.r/b.a),l.data[c+d+1]=Math.floor(255*b.g/b.a),l.data[c+d+2]=Math.floor(255*b.b/b.a),l.data[c+d+3]=Math.floor(255*b.a)};if(a.clips)for(let c=0,h=0;c80*a){d=g=b[0],e=h=b[1];for(var l=a;lg&&(g=i),j>h&&(h=j);k=0!==(k=Math.max(g-d,h-e))?1/k:0}return iJ(c,m,a,d,e,k),m}function iH(c,e,f,d,g){var a,b;if(g===i3(c,e,f,d)>0)for(a=e;a=e;a-=d)b=i0(a,c[a],c[a+1],b);return b&&iW(b,b.next)&&(i1(b),b=b.next),b}function iI(c,b){if(!c)return c;b||(b=c);var d,a=c;do if(d=!1,a.steiner|| !iW(a,a.next)&&0!==iV(a.prev,a,a.next))a=a.next;else{if(i1(a),(a=b=a.prev)===a.next)break;d=!0}while(d||a!==b)return b}function iJ(a,b,c,e,f,d,h){if(a){!h&&d&&function(b,c,d,e){var a=b;do null===a.z&&(a.z=iR(a.x,a.y,c,d,e)),a.prevZ=a.prev,a.nextZ=a.next,a=a.next;while(a!==b)a.prevZ.nextZ=null,a.prevZ=null,function(g){var h,b,a,c,d,i,e,f,j=1;do{for(b=g,g=null,d=null,i=0;b;){for(i++,a=b,e=0,h=0;h0||f>0&&a;)0!==e&&(0===f||!a||b.z<=a.z)?(c=b,b=b.nextZ,e--):(c=a,a=a.nextZ,f--),d?d.nextZ=c:g=c,c.prevZ=d,d=c;b=a}d.nextZ=null,j*=2}while(i>1)}(a)}(a,e,f,d);for(var i,g,j=a;a.prev!==a.next;)if(i=a.prev,g=a.next,d?iL(a,e,f,d):iK(a))b.push(i.i/c),b.push(a.i/c),b.push(g.i/c),i1(a),a=g.next,j=g.next;else if((a=g)===j){h?1===h?iJ(a=iM(iI(a),b,c),b,c,e,f,d,2):2===h&&iN(a,b,c,e,f,d):iJ(iI(a),b,c,e,f,d,1);break}}}function iK(b){var c=b.prev,d=b,e=b.next;if(iV(c,d,e)>=0)return!1;for(var a=b.next.next;a!==b.prev;){if(iT(c.x,c.y,d.x,d.y,e.x,e.y,a.x,a.y)&&iV(a.prev,a,a.next)>=0)return!1;a=a.next}return!0}function iL(f,g,h,i){var d=f.prev,e=f,a=f.next;if(iV(d,e,a)>=0)return!1;for(var l=d.x>e.x?d.x>a.x?d.x:a.x:e.x>a.x?e.x:a.x,m=d.y>e.y?d.y>a.y?d.y:a.y:e.y>a.y?e.y:a.y,j=iR(d.x=j&&c&&c.z<=k;){if(b!==f.prev&&b!==f.next&&iT(d.x,d.y,e.x,e.y,a.x,a.y,b.x,b.y)&&iV(b.prev,b,b.next)>=0)return!1;if(b=b.prevZ,c!==f.prev&&c!==f.next&&iT(d.x,d.y,e.x,e.y,a.x,a.y,c.x,c.y)&&iV(c.prev,c,c.next)>=0)return!1;c=c.nextZ}for(;b&&b.z>=j;){if(b!==f.prev&&b!==f.next&&iT(d.x,d.y,e.x,e.y,a.x,a.y,b.x,b.y)&&iV(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;c&&c.z<=k;){if(c!==f.prev&&c!==f.next&&iT(d.x,d.y,e.x,e.y,a.x,a.y,c.x,c.y)&&iV(c.prev,c,c.next)>=0)return!1;c=c.nextZ}return!0}function iM(d,e,f){var a=d;do{var c=a.prev,b=a.next.next;!iW(c,b)&&iX(c,a,a.next,b)&&i$(c,b)&&i$(b,c)&&(e.push(c.i/f),e.push(a.i/f),e.push(b.i/f),i1(a),i1(a.next),a=d=b),a=a.next}while(a!==d)return iI(a)}function iN(d,e,f,g,h,i){var a=d;do{for(var b=a.next.next;b!==a.prev;){if(a.i!==b.i&&iU(a,b)){var c=i_(a,b);return a=iI(a,a.next),c=iI(c,c.next),iJ(a,e,f,g,h,i),void iJ(c,e,f,g,h,i)}b=b.next}a=a.next}while(a!==d)}function iO(a,b){return a.x-b.x}function iP(c,b){var a=function(h,k){var b,a=k,d=h.x,c=h.y,e=-1/0;do{if(c<=a.y&&c>=a.next.y&&a.next.y!==a.y){var f=a.x+(c-a.y)*(a.next.x-a.x)/(a.next.y-a.y);if(f<=d&&f>e){if(e=f,f===d){if(c===a.y)return a;if(c===a.next.y)return a.next}b=a.x=a.x&&a.x>=l&&d!==a.x&&iT(cb.x||a.x===b.x&&iQ(b,a)))&&(b=a,j=g)),a=a.next;while(a!==m)return b}(c,b);if(!a)return b;var d=i_(a,c),e=iI(a,a.next);return iI(d,d.next),b===a?e:b}function iQ(a,b){return 0>iV(a.prev,a,b.prev)&&0>iV(b.next,a,a.next)}function iR(a,b,d,e,c){return(a=1431655765&((a=858993459&((a=252645135&((a=16711935&((a=32767*(a-d)*c)|a<<8))|a<<4))|a<<2))|a<<1))|(b=1431655765&((b=858993459&((b=252645135&((b=16711935&((b=32767*(b-e)*c)|b<<8))|b<<4))|b<<2))|b<<1))<<1}function iS(c){var a=c,b=c;do(a.x=0&&(c-a)*(f-b)-(e-a)*(d-b)>=0&&(e-a)*(h-b)-(g-a)*(f-b)>=0}function iU(a,b){return a.next.i!==b.i&&a.prev.i!==b.i&&!function(b,c){var a=b;do{if(a.i!==b.i&&a.next.i!==b.i&&a.i!==c.i&&a.next.i!==c.i&&iX(a,a.next,b,c))return!0;a=a.next}while(a!==b)return!1}(a,b)&&(i$(a,b)&&i$(b,a)&&function(b,e){var a=b,c=!1,f=(b.x+e.x)/2,d=(b.y+e.y)/2;do a.y>d!=a.next.y>d&&a.next.y!==a.y&&f<(a.next.x-a.x)*(d-a.y)/(a.next.y-a.y)+a.x&&(c=!c),a=a.next;while(a!==b)return c}(a,b)&&(iV(a.prev,a,b.prev)||iV(a,b.prev,b))||iW(a,b)&&iV(a.prev,a,a.next)>0&&iV(b.prev,b,b.next)>0)}function iV(b,a,c){return(a.y-b.y)*(c.x-a.x)-(a.x-b.x)*(c.y-a.y)}function iW(a,b){return a.x===b.x&&a.y===b.y}function iX(a,b,c,d){var e=iZ(iV(a,b,c)),f=iZ(iV(a,b,d)),g=iZ(iV(c,d,a)),h=iZ(iV(c,d,b));return e!==f&&g!==h||!(0!==e||!iY(a,c,b))||!(0!==f||!iY(a,d,b))||!(0!==g||!iY(c,a,d))||!(0!==h||!iY(c,b,d))}function iY(a,b,c){return b.x<=Math.max(a.x,c.x)&&b.x>=Math.min(a.x,c.x)&&b.y<=Math.max(a.y,c.y)&&b.y>=Math.min(a.y,c.y)}function iZ(a){return a>0?1:a<0?-1:0}function i$(a,b){return 0>iV(a.prev,a,a.next)?iV(a,b,a.next)>=0&&iV(a,a.prev,b)>=0:0>iV(a,b,a.prev)||0>iV(a,a.next,b)}function i_(a,b){var d=new i2(a.i,a.x,a.y),c=new i2(b.i,b.x,b.y),e=a.next,f=b.prev;return a.next=b,b.prev=a,d.next=e,e.prev=d,c.next=d,d.prev=c,f.next=c,c.prev=f,c}function i0(c,d,e,b){var a=new i2(c,d,e);return b?(a.next=b.next,a.prev=b,b.next.prev=a,b.next=a):(a.prev=a,a.next=a),a}function i1(a){a.next.prev=a.prev,a.prev.next=a.next,a.prevZ&&(a.prevZ.nextZ=a.nextZ),a.nextZ&&(a.nextZ.prevZ=a.prevZ)}function i2(a,b,c){this.i=a,this.x=b,this.y=c,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function i3(b,g,d,e){for(var f=0,a=g,c=d-e;ab;){if(d-b>600){var f=d-b+1,k=e-b+1,l=Math.log(f),i=.5*Math.exp(2*l/3),m=.5*Math.sqrt(l*i*(f-i)/f)*(k-f/2<0?-1:1);i5(a,e,Math.max(b,Math.floor(e-k*i/f+m)),Math.min(d,Math.floor(e+(f-k)*i/f+m)),g)}var j=a[e],h=b,c=d;for(i6(a,b,e),g(a[d],j)>0&&i6(a,b,d);hg(a[h],j);)h++;for(;g(a[c],j)>0;)c--}0===g(a[b],j)?i6(a,b,c):i6(a,++c,d),c<=e&&(b=c+1),e<=c&&(d=c-1)}}function i6(a,b,c){var d=a[b];a[b]=a[c],a[c]=d}function i7(a,b){return ab?1:0}function i8(c,f){const i=c.length;if(i<=1)return[c];const a=[];let d,h;for(let e=0;e1)for(let b=0;b0&&c.holes.push(g+=b[a-1].length)}return c},dM.default=az;class dN{constructor(a){this.zoom=a.zoom,this.overscaling=a.overscaling,this.layers=a.layers,this.layerIds=this.layers.map(a=>a.id),this.index=a.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new al,this.indexArray=new aq,this.indexArray2=new Y,this.programConfigurations=new dv(a.layers,a.zoom),this.segments=new ay,this.segments2=new ay,this.stateDependentLayerIds=this.layers.filter(a=>a.isStateDependent()).map(a=>a.id)}populate(i,a,b,l){this.hasPattern=ja("fill",this.layers,a);const d=this.layers[0].layout.get("fill-sort-key"),e=[];for(const{feature:c,id:m,index:n,sourceLayerIndex:o}of i){const j=this.layers[0]._featureFilter.needGeometry,f=id(c,j);if(!this.layers[0]._featureFilter.filter(new c5(this.zoom),f,b))continue;const p=d?d.evaluate(f,{},b,a.availableImages):void 0,q={id:m,properties:c.properties,type:c.type,sourceLayerIndex:o,index:n,geometry:j?f.geometry:ic(c,b,l),patterns:{},sortKey:p};e.push(q)}for(const g of(d&&e.sort((a,b)=>a.sortKey-b.sortKey),e)){const{geometry:k,index:h,sourceLayerIndex:r}=g;if(this.hasPattern){const s=jb("fill",this.layers,g,this.zoom,a);this.patternFeatures.push(s)}else this.addFeature(g,k,h,b,{},a.availableImages);a.featureIndex.insert(i[h].feature,k,h,r,this.index)}}update(a,b,c,d){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(a,b,this.stateDependentLayers,c,d)}addFeatures(e,b,c,d){for(const a of this.patternFeatures)this.addFeature(a,a.geometry,a.index,b,c,d)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(a){this.uploaded||(this.layoutVertexBuffer=a.createVertexBuffer(this.layoutVertexArray,iG),this.indexBuffer=a.createIndexBuffer(this.indexArray),this.indexBuffer2=a.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(a),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(m,n,o,p,q,r=[]){for(const g of i8(n,500)){let h=0;for(const s of g)h+=s.length;const i=this.segments.prepareSegment(h,this.layoutVertexArray,this.indexArray),j=i.vertexLength,c=[],l=[];for(const a of g){if(0===a.length)continue;a!==g[0]&&l.push(c.length/2);const k=this.segments2.prepareSegment(a.length,this.layoutVertexArray,this.indexArray2),f=k.vertexLength;this.layoutVertexArray.emplaceBack(a[0].x,a[0].y),this.indexArray2.emplaceBack(f+a.length-1,f),c.push(a[0].x),c.push(a[0].y);for(let b=1;b>3}if(d--,1===c||2===c)f+=b.readSVarint(),g+=b.readSVarint(),1===c&&(a&&e.push(a),a=[]),a.push(new aF(f,g));else{if(7!==c)throw new Error("unknown command "+c);a&&a.push(a[0].clone())}}return a&&e.push(a),e},$.prototype.bbox=function(){var a=this._pbf;a.pos=this._geometry;for(var k=a.readVarint()+a.pos,b=1,e=0,c=0,d=0,f=1/0,g=-1/0,h=1/0,i=-1/0;a.pos>3}if(e--,1===b||2===b)(c+=a.readSVarint())g&&(g=c),(d+=a.readSVarint())i&&(i=d);else if(7!==b)throw new Error("unknown command "+b)}return[f,h,g,i]},$.prototype.toGeoJSON=function(h,i,j){var a,c,k=this.extent*Math.pow(2,j),l=this.extent*h,m=this.extent*i,b=this.loadGeometry(),d=$.types[this.type];function e(b){for(var a=0;a>3;c=1===b?a.readString():2===b?a.readFloat():3===b?a.readDouble():4===b?a.readVarint64():5===b?a.readVarint():6===b?a.readSVarint():7===b?a.readBoolean():null}return c}(c))}function ji(c,d,a){if(3===c){var b=new dR(a,a.readVarint()+a.pos);b.length&&(d[b.name]=b)}}dS.prototype.feature=function(a){if(a<0||a>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[a];var b=this._pbf.readVarint()+this._pbf.pos;return new dQ(this._pbf,b,this.extent,this._keys,this._values)};var _={VectorTile:function(a,b){this.layers=a.readFields(ji,{},b)},VectorTileFeature:dQ,VectorTileLayer:dR};const jj=_.VectorTileFeature.types;function jk(a,b,c,d,e,f,g,h){a.emplaceBack((b<<1)+g,(c<<1)+f,(Math.floor(8192*d)<<1)+e,Math.round(h))}class dT{constructor(){this.acc=new aF(0,0),this.polyCount=[]}startRing(a){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new aF(a.x,a.y),this.max=new aF(a.x,a.y))}append(a,c){this.currentPolyCount.edges++,this.acc._add(a);let b=!!this.borders;const d=this.min,e=this.max;a.xe.x&&(e.x=a.x,b=!0),a.ye.y&&(e.y=a.y,b=!0),((0===a.x||8192===a.x)&&a.x===c.x)!=((0===a.y||8192===a.y)&&a.y===c.y)&&this.processBorderOverlap(a,c),b&&this.checkBorderIntersection(a,c)}checkBorderIntersection(b,a){a.x<0!=b.x<0&&this.addBorderIntersection(0,aY(a.y,b.y,(0-a.x)/(b.x-a.x))),a.x>8192!=b.x>8192&&this.addBorderIntersection(1,aY(a.y,b.y,(8192-a.x)/(b.x-a.x))),a.y<0!=b.y<0&&this.addBorderIntersection(2,aY(a.x,b.x,(0-a.y)/(b.y-a.y))),a.y>8192!=b.y>8192&&this.addBorderIntersection(3,aY(a.x,b.x,(8192-a.y)/(b.y-a.y)))}addBorderIntersection(c,a){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 b=this.borders[c];ab[1]&&(b[1]=a)}processBorderOverlap(a,b){if(a.x===b.x){if(a.y===b.y)return;const c=0===a.x?0:1;this.addBorderIntersection(c,b.y),this.addBorderIntersection(c,a.y)}else{const d=0===a.y?2:3;this.addBorderIntersection(d,b.x),this.addBorderIntersection(d,a.x)}}centroid(){const a=this.polyCount.reduce((a,b)=>a+b.edges,0);return 0!==a?this.acc.div(a)._round():new aF(0,0)}span(){return new aF(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce((a,b)=>a+ +(b[0]!==Number.MAX_VALUE),0)}}class dU{constructor(a){this.zoom=a.zoom,this.overscaling=a.overscaling,this.layers=a.layers,this.layerIds=this.layers.map(a=>a.id),this.index=a.index,this.hasPattern=!1,this.layoutVertexArray=new am,this.centroidVertexArray=new di,this.indexArray=new aq,this.programConfigurations=new dv(a.layers,a.zoom),this.segments=new ay,this.stateDependentLayerIds=this.layers.filter(a=>a.isStateDependent()).map(a=>a.id),this.enableTerrain=a.enableTerrain}populate(i,b,c,j){for(const{feature:a,id:k,index:e,sourceLayerIndex:f}of(this.features=[],this.hasPattern=ja("fill-extrusion",this.layers,b),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDone=[!1,!1,!1,!1],this.tileToMeter=function(a){const b=Math.exp(Math.PI*(1-a.y/(1<a.x<=0)||l.every(a=>a.x>=8192)||l.every(a=>a.y<=0)||l.every(a=>a.y>=8192))continue;for(let u=0;u=1){const d=g[i-1];if(!jl(c,d)){a&&a.append(c,d),b.vertexLength+4>ay.MAX_VERTEX_ARRAY_LENGTH&&(b=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const n=c.sub(d)._perp(),o=n.x/(Math.abs(n.x)+Math.abs(n.y)),p=n.y>0?1:0,z=d.dist(c);f+z>32768&&(f=0),jk(this.layoutVertexArray,c.x,c.y,o,p,0,0,f),jk(this.layoutVertexArray,c.x,c.y,o,p,0,1,f),f+=z,jk(this.layoutVertexArray,d.x,d.y,o,p,0,0,f),jk(this.layoutVertexArray,d.x,d.y,o,p,0,1,f);const h=b.vertexLength;this.indexArray.emplaceBack(h,h+2,h+1),this.indexArray.emplaceBack(h+1,h+2,h+3),b.vertexLength+=4,b.primitiveLength+=2}}}}if(b.vertexLength+m>ay.MAX_VERTEX_ARRAY_LENGTH&&(b=this.segments.prepareSegment(m,this.layoutVertexArray,this.indexArray)),"Polygon"!==jj[y.type])continue;const q=[],A=[],v=b.vertexLength;for(let w=0;w0){if(a.borders){a.vertexArrayOffset=this.centroidVertexArray.length;const G=a.borders,H=this.featuresOnBorder.push(a)-1;for(let t=0;t<4;t++)G[t][0]!==Number.MAX_VALUE&&this.borders[t].push(H)}this.encodeCentroid(a.borders?void 0:a.centroid(),a)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,y,C,E,F,D)}sortBorders(){for(let a=0;a<4;a++)this.borders[a].sort((b,c)=>this.featuresOnBorder[b].borders[a][0]-this.featuresOnBorder[c].borders[a][0])}encodeCentroid(b,e,f=!0){let c,a;if(b){if(0!==b.y){const h=e.span()._mult(this.tileToMeter);c=(Math.max(b.x,1)<<3)+Math.min(7,Math.round(h.x/10)),a=(Math.max(b.y,1)<<3)+Math.min(7,Math.round(h.y/10))}else c=Math.ceil(7*(b.x+450)),a=0}else c=0,a=+f;let g=f?this.centroidVertexArray.length:e.vertexArrayOffset;for(const d of e.polyCount){f&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*d.edges+d.top);for(let i=0;i<2*d.edges;i++)this.centroidVertexArray.emplace(g++,0,a),this.centroidVertexArray.emplace(g++,c,a);for(let j=0;j8192)||a.y===b.y&&(a.y<0||a.y>8192)}c("FillExtrusionBucket",dU,{omit:["layers","features"]}),c("PartMetadata",dT);var jm={paint:new n({"fill-extrusion-opacity":new e(b["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new g(b["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new e(b["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new e(b["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new N(b["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new g(b["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new g(b["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new e(b["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})};function jn(a,b){return a.x*b.x+a.y*b.y}function jo(i,a){if(1===i.length){let b=0;const c=a[b++];let d;for(;!d||c.equals(d);)if(!(d=a[b++]))return 1/0;for(;ba.id),this.index=a.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(a=>{this.gradients[a.id]={}}),this.layoutVertexArray=new a6,this.layoutVertexArray2=new an,this.indexArray=new aq,this.programConfigurations=new dv(a.layers,a.zoom),this.segments=new ay,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(a=>a.isStateDependent()).map(a=>a.id)}populate(j,a,b,m){this.hasPattern=ja("line",this.layers,a);const e=this.layers[0].layout.get("line-sort-key"),f=[];for(const{feature:c,id:n,index:o,sourceLayerIndex:p}of j){const k=this.layers[0]._featureFilter.needGeometry,g=id(c,k);if(!this.layers[0]._featureFilter.filter(new c5(this.zoom),g,b))continue;const q=e?e.evaluate(g,{},b):void 0,r={id:n,properties:c.properties,type:c.type,sourceLayerIndex:p,index:o,geometry:k?g.geometry:ic(c,b,m),patterns:{},sortKey:q};f.push(r)}e&&f.sort((a,b)=>a.sortKey-b.sortKey);const{lineAtlas:h,featureIndex:s}=a,t=this.addConstantDashes(h);for(const d of f){const{geometry:l,index:i,sourceLayerIndex:u}=d;if(t&&this.addFeatureDashes(d,h),this.hasPattern){const v=jb("line",this.layers,d,this.zoom,a);this.patternFeatures.push(v)}else this.addFeature(d,l,i,b,h.positions,a.availableImages);s.insert(j[i].feature,l,i,u,this.index)}}addConstantDashes(b){let d=!1;for(const e of this.layers){const f=e.paint.get("line-dasharray").value,g=e.layout.get("line-cap").value;if("constant"!==f.kind||"constant"!==g.kind)d=!0;else{const c=g.value,a=f.value;if(!a)continue;b.addDash(a.from,c),b.addDash(a.to,c),a.other&&b.addDash(a.other,c)}}return d}addFeatureDashes(a,b){const c=this.zoom;for(const m of this.layers){const d=m.paint.get("line-dasharray").value,e=m.layout.get("line-cap").value;if("constant"===d.kind&&"constant"===e.kind)continue;let g,h,i,j,k,l;if("constant"===d.kind){const f=d.value;if(!f)continue;g=f.other||f.to,h=f.to,i=f.from}else g=d.evaluate({zoom:c-1},a),h=d.evaluate({zoom:c},a),i=d.evaluate({zoom:c+1},a);"constant"===e.kind?j=k=l=e.value:(j=e.evaluate({zoom:c-1},a),k=e.evaluate({zoom:c},a),l=e.evaluate({zoom:c+1},a)),b.addDash(g,j),b.addDash(h,k),b.addDash(i,l);const n=b.getKey(g,j),o=b.getKey(h,k),p=b.getKey(i,l);a.patterns[m.id]={min:n,mid:o,max:p}}}update(a,b,c,d){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(a,b,this.stateDependentLayers,c,d)}addFeatures(e,b,c,d){for(const a of this.patternFeatures)this.addFeature(a,a.geometry,a.index,b,c,d)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(a){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=a.createVertexBuffer(this.layoutVertexArray2,js)),this.layoutVertexBuffer=a.createVertexBuffer(this.layoutVertexArray,jr),this.indexBuffer=a.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(a),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(a){if(a.properties&&a.properties.hasOwnProperty("mapbox_clip_start")&&a.properties.hasOwnProperty("mapbox_clip_end"))return{start:+a.properties.mapbox_clip_start,end:+a.properties.mapbox_clip_end}}addFeature(a,c,d,e,f,g){const b=this.layers[0].layout,h=b.get("line-join").evaluate(a,{}),i=b.get("line-cap").evaluate(a,{}),j=b.get("line-miter-limit"),k=b.get("line-round-limit");for(const l of(this.lineClips=this.lineFeatureClips(a),c))this.addLine(l,a,h,i,j,k);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,a,d,f,g,e)}addLine(g,K,A,L,v,M){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let q=0;q=2&&g[i-1].equals(g[i-2]);)i--;let l=0;for(;l0;if(B&&m>l){const C=a.dist(h);if(C>2*s){const w=a.sub(a.sub(h)._mult(s/C)._round());this.updateDistance(h,w),this.addCurrentVertex(w,d,0,0,c),h=w}}const D=h&&j;let e=D?A:r?"butt":L;if(D&&"round"===e&&(kv&&(e="bevel"),"bevel"===e&&(k>2&&(e="flipbevel"),k100)f=b.mult(-1);else{const O=k*d.add(b).mag()/d.sub(b).mag();f._perp()._mult(O*(p?-1:1))}this.addCurrentVertex(a,f,0,0,c),this.addCurrentVertex(a,f.mult(-1),0,0,c)}else if("bevel"===e||"fakeround"===e){const E=-Math.sqrt(k*k-1),F=p?E:0,G=p?0:E;if(h&&this.addCurrentVertex(a,d,F,G,c),"fakeround"===e){const H=Math.round(180*N/Math.PI/20);for(let x=1;x2*s){const z=a.add(j.sub(a)._mult(s/J)._round());this.updateDistance(a,z),this.addCurrentVertex(z,b,0,0,c),a=z}}}}addCurrentVertex(d,a,b,c,e,f=!1){const g=a.y*c-a.x,h=-a.y-a.x*c;this.addHalfVertex(d,a.x+a.y*b,a.y-a.x*b,f,!1,b,e),this.addHalfVertex(d,g,h,f,!0,-c,e)}addHalfVertex({x:e,y:f},g,h,i,b,c,d){this.layoutVertexArray.emplaceBack((e<<1)+(i?1:0),(f<<1)+(b?1:0),Math.round(63*g)+128,Math.round(63*h)+128,1+(0===c?0:c<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineSoFar);const a=d.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,a),d.primitiveLength++),b?this.e2=a:this.e1=a}updateScaledDistance(){if(this.lineClips){const a=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=a*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(a,b){this.distance+=a.dist(b),this.updateScaledDistance()}}c("LineBucket",dX,{omit:["layers","patternFeatures"]});const dY=new n({"line-cap":new g(b.layout_line["line-cap"]),"line-join":new g(b.layout_line["line-join"]),"line-miter-limit":new e(b.layout_line["line-miter-limit"]),"line-round-limit":new e(b.layout_line["line-round-limit"]),"line-sort-key":new g(b.layout_line["line-sort-key"])});var dZ={paint:new n({"line-opacity":new g(b.paint_line["line-opacity"]),"line-color":new g(b.paint_line["line-color"]),"line-translate":new e(b.paint_line["line-translate"]),"line-translate-anchor":new e(b.paint_line["line-translate-anchor"]),"line-width":new g(b.paint_line["line-width"]),"line-gap-width":new g(b.paint_line["line-gap-width"]),"line-offset":new g(b.paint_line["line-offset"]),"line-blur":new g(b.paint_line["line-blur"]),"line-dasharray":new N(b.paint_line["line-dasharray"]),"line-pattern":new N(b.paint_line["line-pattern"]),"line-gradient":new V(b.paint_line["line-gradient"])}),layout:dY};const d$=new class extends g{possiblyEvaluate(b,a){return a=new c5(Math.floor(a.zoom),{now:a.now,fadeDuration:a.fadeDuration,zoomHistory:a.zoomHistory,transition:a.transition}),super.possiblyEvaluate(b,a)}evaluate(b,a,c,d){return a=bR({},a,{zoom:Math.floor(a.zoom)}),super.evaluate(b,a,c,d)}}(dZ.paint.properties["line-width"].specification);function jv(a,b){return b>0?b+2*a:a}d$.useIntegerZoom=!0;const jw=j([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"},{name:"a_z_tile_anchor",components:4,type:"Int16"},],4),jx=j([{name:"a_projected_pos",components:3,type:"Float32"},],4);j([{name:"a_fade_opacity",components:1,type:"Uint32"},],4);const jy=j([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},]),jz=j([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},]);j([{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 jA=j([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"},],4),d_=j([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"},],4);function d0(e,i){const{expression:a}=i;if("constant"===a.kind)return{kind:"constant",layoutSize:a.evaluate(new c5(e+1))};if("source"===a.kind)return{kind:"source"};{const{zoomStops:b,interpolationType:h}=a;let c=0;for(;c{a.text=function(a,c,d){const b=c.layout.get("text-transform").evaluate(d,{});return"uppercase"===b?a=a.toLocaleUpperCase():"lowercase"===b&&(a=a.toLocaleLowerCase()),c4.applyArabicShaping&&(a=c4.applyArabicShaping(a)),a}(a.text,b,c)}),a}const jC={"!":"\uFE15","#":"\uFF03",$:"\uFF04","%":"\uFF05","&":"\uFF06","(":"\uFE35",")":"\uFE36","*":"\uFF0A","+":"\uFF0B",",":"\uFE10","-":"\uFE32",".":"\u30FB","/":"\uFF0F",":":"\uFE13",";":"\uFE14","<":"\uFE3F","=":"\uFF1D",">":"\uFE40","?":"\uFE16","@":"\uFF20","[":"\uFE47","\\":"\uFF3C","]":"\uFE48","^":"\uFF3E",_:"\uFE33","`":"\uFF40","{":"\uFE37","|":"\u2015","}":"\uFE38","~":"\uFF5E","\xa2":"\uFFE0","\xa3":"\uFFE1","\xa5":"\uFFE5","\xa6":"\uFFE4","\xac":"\uFFE2","\xaf":"\uFFE3","\u2013":"\uFE32","\u2014":"\uFE31","\u2018":"\uFE43","\u2019":"\uFE44","\u201C":"\uFE41","\u201D":"\uFE42","\u2026":"\uFE19","\u2027":"\u30FB","\u20A9":"\uFFE6","\u3001":"\uFE11","\u3002":"\uFE12","\u3008":"\uFE3F","\u3009":"\uFE40","\u300A":"\uFE3D","\u300B":"\uFE3E","\u300C":"\uFE41","\u300D":"\uFE42","\u300E":"\uFE43","\u300F":"\uFE44","\u3010":"\uFE3B","\u3011":"\uFE3C","\u3014":"\uFE39","\u3015":"\uFE3A","\u3016":"\uFE17","\u3017":"\uFE18","\uFF01":"\uFE15","\uFF08":"\uFE35","\uFF09":"\uFE36","\uFF0C":"\uFE10","\uFF0D":"\uFE32","\uFF0E":"\u30FB","\uFF1A":"\uFE13","\uFF1B":"\uFE14","\uFF1C":"\uFE3F","\uFF1E":"\uFE40","\uFF1F":"\uFE16","\uFF3B":"\uFE47","\uFF3D":"\uFE48","\uFF3F":"\uFE33","\uFF5B":"\uFE37","\uFF5C":"\u2015","\uFF5D":"\uFE38","\uFF5F":"\uFE35","\uFF60":"\uFE36","\uFF61":"\uFE12","\uFF62":"\uFE41","\uFF63":"\uFE42"};function jD(a){return"\uFE36"===a||"\uFE48"===a||"\uFE38"===a||"\uFE44"===a||"\uFE42"===a||"\uFE3E"===a||"\uFE3C"===a||"\uFE3A"===a||"\uFE18"===a||"\uFE40"===a||"\uFE10"===a||"\uFE13"===a||"\uFE14"===a||"\uFF40"===a||"\uFFE3"===a||"\uFE11"===a||"\uFE12"===a}function jE(a){return"\uFE35"===a||"\uFE47"===a||"\uFE37"===a||"\uFE43"===a||"\uFE41"===a||"\uFE3D"===a||"\uFE3B"===a||"\uFE39"===a||"\uFE17"===a||"\uFE3F"===a}var jF=function(g,h,j,e,k){var a,c,l=8*k-e-1,m=(1<>1,b=-7,d=j?k-1:0,i=j?-1:1,f=g[h+d];for(d+=i,a=f&(1<< -b)-1,f>>=-b,b+=l;b>0;a=256*a+g[h+d],d+=i,b-=8);for(c=a&(1<< -b)-1,a>>=-b,b+=e;b>0;c=256*c+g[h+d],d+=i,b-=8);if(0===a)a=1-n;else{if(a===m)return c?NaN:1/0*(f?-1:1);c+=Math.pow(2,e),a-=n}return(f?-1:1)*c*Math.pow(2,a-e)},jG=function(j,b,k,m,c,n){var a,d,e,h=8*n-c-1,i=(1<>1,o=23===c?5960464477539062e-23:0,g=m?0:n-1,l=m?1:-1,p=b<0||0===b&&1/b<0?1:0;for(isNaN(b=Math.abs(b))||b===1/0?(d=isNaN(b)?1:0,a=i):(a=Math.floor(Math.log(b)/Math.LN2),b*(e=Math.pow(2,-a))<1&&(a--,e*=2),(b+=a+f>=1?o/e:o*Math.pow(2,1-f))*e>=2&&(a++,e/=2),a+f>=i?(d=0,a=i):a+f>=1?(d=(b*e-1)*Math.pow(2,c),a+=f):(d=b*Math.pow(2,f-1)*Math.pow(2,c),a=0));c>=8;j[k+g]=255&d,g+=l,d/=256,c-=8);for(a=a<0;j[k+g]=255&a,g+=l,a/=256,h-=8);j[k+g-l]|=128*p},d2=P;function P(a){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(a)?a:new Uint8Array(a||0),this.pos=0,this.type=0,this.length=this.buf.length}P.Varint=0,P.Fixed64=1,P.Bytes=2,P.Fixed32=5;var jH="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function jI(a){return a.type===P.Bytes?a.readVarint()+a.pos:a.pos+1}function jJ(a,b,c){return c?4294967296*b+(a>>>0):4294967296*(b>>>0)+(a>>>0)}function jK(e,a,b){var d=a<=16383?1:a<=2097151?2:a<=268435455?3:Math.floor(Math.log(a)/(7*Math.LN2));b.realloc(d);for(var c=b.pos-1;c>=e;c--)b.buf[c+d]=b.buf[c]}function jL(b,c){for(var a=0;a>>8,a[c+2]=b>>>16,a[c+3]=b>>>24}function jW(a,b){return(a[b]|a[b+1]<<8|a[b+2]<<16)+(a[b+3]<<24)}function jX(b,a,c){a.glyphs=[],1===b&&c.readMessage(jY,a)}function jY(a,b,c){if(3===a){const{id:f,bitmap:g,width:d,height:e,left:h,top:i,advance:j}=c.readMessage(jZ,{});b.glyphs.push({id:f,bitmap:new dJ({width:d+6,height:e+6},g),metrics:{width:d,height:e,left:h,top:i,advance:j}})}else 4===a?b.ascender=c.readSVarint():5===a&&(b.descender=c.readSVarint())}function jZ(a,b,c){1===a?b.id=c.readVarint():2===a?b.bitmap=c.readBytes():3===a?b.width=c.readVarint():4===a?b.height=c.readVarint():5===a?b.left=c.readSVarint():6===a?b.top=c.readSVarint():7===a&&(b.advance=c.readVarint())}function d3(g){let h=0,i=0;for(const j of g)h+=j.w*j.h,i=Math.max(i,j.w);g.sort((a,b)=>b.h-a.h);const c=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(h/.95)),i),h:1/0},];let e=0,f=0;for(const a of g)for(let d=c.length-1;d>=0;d--){const b=c[d];if(!(a.w>b.w||a.h>b.h)){if(a.x=b.x,a.y=b.y,f=Math.max(f,a.y+a.h),e=Math.max(e,a.x+a.w),a.w===b.w&&a.h===b.h){const k=c.pop();d>3,f=this.pos;this.type=7&b,d(e,c,this),this.pos===f&&this.skip(b)}return c},readMessage:function(a,b){return this.readFields(a,b,this.readVarint()+this.pos)},readFixed32:function(){var a=jU(this.buf,this.pos);return this.pos+=4,a},readSFixed32:function(){var a=jW(this.buf,this.pos);return this.pos+=4,a},readFixed64:function(){var a=jU(this.buf,this.pos)+4294967296*jU(this.buf,this.pos+4);return this.pos+=8,a},readSFixed64:function(){var a=jU(this.buf,this.pos)+4294967296*jW(this.buf,this.pos+4);return this.pos+=8,a},readFloat:function(){var a=jF(this.buf,this.pos,!0,23,4);return this.pos+=4,a},readDouble:function(){var a=jF(this.buf,this.pos,!0,52,8);return this.pos+=8,a},readVarint:function(d){var a,b,c=this.buf;return a=127&(b=c[this.pos++]),b<128?a:(a|=(127&(b=c[this.pos++]))<<7,b<128?a:(a|=(127&(b=c[this.pos++]))<<14,b<128?a:(a|=(127&(b=c[this.pos++]))<<21,b<128?a:function(d,e,c){var a,b,f=c.buf;if(a=(112&(b=f[c.pos++]))>>4,b<128)return jJ(d,a,e);if(a|=(127&(b=f[c.pos++]))<<3,b<128)return jJ(d,a,e);if(a|=(127&(b=f[c.pos++]))<<10,b<128)return jJ(d,a,e);if(a|=(127&(b=f[c.pos++]))<<17,b<128)return jJ(d,a,e);if(a|=(127&(b=f[c.pos++]))<<24,b<128)return jJ(d,a,e);if(a|=(1&(b=f[c.pos++]))<<31,b<128)return jJ(d,a,e);throw new Error("Expected varint not more than 10 bytes")}(a|=(15&(b=c[this.pos]))<<28,d,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var a=this.readVarint();return a%2==1?-((a+1)/2):a/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var c,d,e,a=this.readVarint()+this.pos,b=this.pos;return this.pos=a,a-b>=12&&jH?(c=this.buf,d=b,e=a,jH.decode(c.subarray(d,e))):function(d,k,j){for(var h="",b=k;b239?4:c>223?3:c>191?2:1;if(b+e>j)break;1===e?c<128&&(a=c):2===e?128==(192&(f=d[b+1]))&&(a=(31&c)<<6|63&f)<=127&&(a=null):3===e?(g=d[b+2],128==(192&(f=d[b+1]))&&128==(192&g)&&((a=(15&c)<<12|(63&f)<<6|63&g)<=2047||a>=55296&&a<=57343)&&(a=null)):4===e&&(g=d[b+2],i=d[b+3],128==(192&(f=d[b+1]))&&128==(192&g)&&128==(192&i)&&((a=(15&c)<<18|(63&f)<<12|(63&g)<<6|63&i)<=65535||a>=1114112)&&(a=null)),null===a?(a=65533,e=1):a>65535&&(a-=65536,h+=String.fromCharCode(a>>>10&1023|55296),a=56320|1023&a),h+=String.fromCharCode(a),b+=e}return h}(this.buf,b,a)},readBytes:function(){var a=this.readVarint()+this.pos,b=this.buf.subarray(this.pos,a);return this.pos=a,b},readPackedVarint:function(a,b){if(this.type!==P.Bytes)return a.push(this.readVarint(b));var c=jI(this);for(a=a||[];this.pos127;);else if(a===P.Bytes)this.pos=this.readVarint()+this.pos;else if(a===P.Fixed32)this.pos+=4;else{if(a!==P.Fixed64)throw new Error("Unimplemented type: "+a);this.pos+=8}},writeTag:function(a,b){this.writeVarint(a<<3|b)},realloc:function(c){for(var a=this.length||16;a268435455||a<0?function(e,h){var f,g,d,c,a,b,i;if(e>=0?(f=e%4294967296|0,g=e/4294967296|0):(g=~(-e/4294967296),4294967295^(f=~(-e%4294967296))?f=f+1|0:(f=0,g=g+1|0)),e>=18446744073709552e3||e< -18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");h.realloc(10),d=f,(c=h).buf[c.pos++]=127&d|128,d>>>=7,c.buf[c.pos++]=127&d|128,d>>>=7,c.buf[c.pos++]=127&d|128,d>>>=7,c.buf[c.pos++]=127&d|128,c.buf[c.pos]=127&(d>>>=7),a=g,b=h,i=(7&a)<<4,b.buf[b.pos++]|=i|((a>>>=3)?128:0),a&&(b.buf[b.pos++]=127&a|((a>>>=7)?128:0),a&&(b.buf[b.pos++]=127&a|((a>>>=7)?128:0),a&&(b.buf[b.pos++]=127&a|((a>>>=7)?128:0),a&&(b.buf[b.pos++]=127&a|((a>>>=7)?128:0),a&&(b.buf[b.pos++]=127&a)))))}(a,this):(this.realloc(4),this.buf[this.pos++]=127&a|(a>127?128:0),a<=127||(this.buf[this.pos++]=127&(a>>>=7)|(a>127?128:0),a<=127||(this.buf[this.pos++]=127&(a>>>=7)|(a>127?128:0),a<=127||(this.buf[this.pos++]=a>>>7&127))))},writeSVarint:function(a){this.writeVarint(a<0?-(2*a)-1:2*a)},writeBoolean:function(a){this.writeVarint(Boolean(a))},writeString:function(a){a=String(a),this.realloc(4*a.length),this.pos++;var c=this.pos;this.pos=function(c,f,b){for(var a,d,e=0;e55295&&a<57344){if(!d){a>56319||e+1===f.length?(c[b++]=239,c[b++]=191,c[b++]=189):d=a;continue}if(a<56320){c[b++]=239,c[b++]=191,c[b++]=189,d=a;continue}a=d-55296<<10|a-56320|65536,d=null}else d&&(c[b++]=239,c[b++]=191,c[b++]=189,d=null);a<128?c[b++]=a:(a<2048?c[b++]=a>>6|192:(a<65536?c[b++]=a>>12|224:(c[b++]=a>>18|240,c[b++]=a>>12&63|128),c[b++]=a>>6&63|128),c[b++]=63&a|128)}return b}(this.buf,a,this.pos);var b=this.pos-c;b>=128&&jK(c,b,this),this.pos=c-1,this.writeVarint(b),this.pos+=b},writeFloat:function(a){this.realloc(4),jG(this.buf,a,this.pos,!0,23,4),this.pos+=4},writeDouble:function(a){this.realloc(8),jG(this.buf,a,this.pos,!0,52,8),this.pos+=8},writeBytes:function(c){var a=c.length;this.writeVarint(a),this.realloc(a);for(var b=0;b=128&&jK(b,a,this),this.pos=b-1,this.writeVarint(a),this.pos+=a},writeMessage:function(a,b,c){this.writeTag(a,P.Bytes),this.writeRawMessage(b,c)},writePackedVarint:function(b,a){a.length&&this.writeMessage(b,jL,a)},writePackedSVarint:function(b,a){a.length&&this.writeMessage(b,jM,a)},writePackedBoolean:function(b,a){a.length&&this.writeMessage(b,jP,a)},writePackedFloat:function(b,a){a.length&&this.writeMessage(b,jN,a)},writePackedDouble:function(b,a){a.length&&this.writeMessage(b,jO,a)},writePackedFixed32:function(b,a){a.length&&this.writeMessage(b,jQ,a)},writePackedSFixed32:function(b,a){a.length&&this.writeMessage(b,jR,a)},writePackedFixed64:function(b,a){a.length&&this.writeMessage(b,jS,a)},writePackedSFixed64:function(b,a){a.length&&this.writeMessage(b,jT,a)},writeBytesField:function(a,b){this.writeTag(a,P.Bytes),this.writeBytes(b)},writeFixed32Field:function(a,b){this.writeTag(a,P.Fixed32),this.writeFixed32(b)},writeSFixed32Field:function(a,b){this.writeTag(a,P.Fixed32),this.writeSFixed32(b)},writeFixed64Field:function(a,b){this.writeTag(a,P.Fixed64),this.writeFixed64(b)},writeSFixed64Field:function(a,b){this.writeTag(a,P.Fixed64),this.writeSFixed64(b)},writeVarintField:function(a,b){this.writeTag(a,P.Varint),this.writeVarint(b)},writeSVarintField:function(a,b){this.writeTag(a,P.Varint),this.writeSVarint(b)},writeStringField:function(a,b){this.writeTag(a,P.Bytes),this.writeString(b)},writeFloatField:function(a,b){this.writeTag(a,P.Fixed32),this.writeFloat(b)},writeDoubleField:function(a,b){this.writeTag(a,P.Fixed64),this.writeDouble(b)},writeBooleanField:function(a,b){this.writeVarintField(a,Boolean(b))}};class bj{constructor(a,{pixelRatio:b,version:c,stretchX:d,stretchY:e,content:f}){this.paddedRect=a,this.pixelRatio=b,this.stretchX=d,this.stretchY=e,this.content=f,this.version=c}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1,]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1,]}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio,]}}class d4{constructor(g,h){const i={},j={};this.haveRenderCallbacks=[];const k=[];this.addImages(g,i,k),this.addImages(h,j,k);const{w:q,h:r}=d3(k),b=new bg({width:q||1,height:r||1});for(const l in g){const m=g[l],n=i[l].paddedRect;bg.copy(m.data,b,{x:0,y:0},{x:n.x+1,y:n.y+1},m.data)}for(const o in h){const a=h[o],p=j[o].paddedRect,c=p.x+1,d=p.y+1,e=a.data.width,f=a.data.height;bg.copy(a.data,b,{x:0,y:0},{x:c,y:d},a.data),bg.copy(a.data,b,{x:0,y:f-1},{x:c,y:d-1},{width:e,height:1}),bg.copy(a.data,b,{x:0,y:0},{x:c,y:d+f},{width:e,height:1}),bg.copy(a.data,b,{x:e-1,y:0},{x:c-1,y:d},{width:1,height:f}),bg.copy(a.data,b,{x:0,y:0},{x:c+e,y:d},{width:1,height:f})}this.image=b,this.iconPositions=i,this.patternPositions=j}addImages(c,e,f){for(const b in c){const a=c[b],d={x:0,y:0,w:a.data.width+2,h:a.data.height+2};f.push(d),e[b]=new bj(d,a),a.hasRenderCallback&&this.haveRenderCallbacks.push(b)}}patchUpdatedImages(a,c){for(const b in a.dispatchRenderCallbacks(this.haveRenderCallbacks),a.updatedImages)this.patchUpdatedImage(this.iconPositions[b],a.getImage(b),c),this.patchUpdatedImage(this.patternPositions[b],a.getImage(b),c)}patchUpdatedImage(a,b,c){if(!a||!b)return;if(a.version===b.version)return;a.version=b.version;const[d,e]=a.tl;c.update(b.data,void 0,{x:d,y:e})}}c("ImagePosition",bj),c("ImageAtlas",d4);const d5={horizontal:1,vertical:2,horizontalOnly:3};class j${constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(b,c){const a=new j$;return a.scale=b||1,a.fontStack=c,a}static forImage(b){const a=new j$;return a.imageName=b,a}}class j_{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(d,e){const a=new j_;for(let b=0;b=0&&b>=a&&j1[this.text.charCodeAt(b)];b--)d--;this.text=this.text.substring(a,d),this.sectionIndex=this.sectionIndex.slice(a,d)}substring(b,c){const a=new j_;return a.text=this.text.substring(b,c),a.sectionIndex=this.sectionIndex.slice(b,c),a.sections=this.sections,a}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((a,b)=>Math.max(a,this.sections[b].scale),0)}addTextSection(a,c){this.text+=a.text,this.sections.push(j$.forText(a.scale,a.fontStack||c));const d=this.sections.length-1;for(let b=0;b=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function j0(u,c,v,d,w,i,x,y,z,e,f,j,m,k,l,A){const a=j_.fromFeature(u,w);let b;j===d5.vertical&&a.verticalizePunctuation(m);const{processBidirectionalText:n,processStyledBidirectionalText:o}=c4;if(n&&1===a.sections.length){b=[];const B=n(a.toString(),j8(a,e,i,c,d,k,l));for(const p of B){const g=new j_;g.text=p,g.sections=a.sections;for(let q=0;q0&&D>k&&(k=D)}else{const E=U[e.fontStack];if(!E)continue;E[c]&&(u=E[c]);const l=H[e.fontStack];if(!l)continue;const P=l.glyphs[c];if(!P)continue;if(d=P.metrics,B=8203!==c?24:0,i){const F=void 0!==l.ascender?Math.abs(l.ascender):0,Q=void 0!==l.descender?Math.abs(l.descender):0,R=(F+Q)*a;M=0;let f=0;for(let c=0;c -j/2;){if(--a<0)return!1;c-=b[a].dist(k),k=b[a]}c+=b[a].dist(b[a+1]),a++;const f=[];let g=0;for(;cl;)g-=f.shift().angleDelta;if(g>m)return!1;a++,c+=h.dist(i)}return!0}function kd(b){let c=0;for(let a=0;aj){const k=(j-e)/f,q=aY(c.x,d.x,k),r=aY(c.y,d.y,k),l=new d7(q,r,0,d.angleTo(c),b);return!i||kc(a,l,p,i,m)?l:void 0}e+=f}}function kh(b,a,k,f,l,g,c,h,d){const m=ke(f,g,c),i=kf(f,l),e=i*c,j=0===b[0].x||b[0].x===d||0===b[0].y||b[0].y===d;return a-e=0&&m=0&&n=0&&b+r<=v){const o=new d7(m,n,0,w,c);o._round(),i&&!kc(a,o,j,i,p)||f.push(o)}}e+=l}return u||f.length||q||(f=ki(a,e/2,d,i,p,j,q,!0,k)),f}function d8(k,c,d,e,f){const l=[];for(let i=0;i=e&&b.x>=e||(a.x>=e?a=new aF(e,a.y+(e-a.x)/(b.x-a.x)*(b.y-a.y))._round():b.x>=e&&(b=new aF(e,a.y+(e-a.x)/(b.x-a.x)*(b.y-a.y))._round()),a.y>=f&&b.y>=f||(a.y>=f?a=new aF(a.x+(f-a.y)/(b.y-a.y)*(b.x-a.x),f)._round():b.y>=f&&(b=new aF(a.x+(f-a.y)/(b.y-a.y)*(b.x-a.x),f)._round()),g&&a.equals(g[g.length-1])||(g=[a],l.push(g)),g.push(b)))))}}return l}function kj(f,a,b,g,h,c,i,j,k){for(let d=a;d -1)f[++c]=a,b[c]=j,b[c+1]=1e20}for(let e=0,k=0;e{let a=this.entries[b];a||(a=this.entries[b]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let d=a.glyphs[c];if(void 0!==d)return void f(null,{stack:b,id:c,glyph:d});if(d=this._tinySDF(a,b,c))return a.glyphs[c]=d,void f(null,{stack:b,id:c,glyph:d});const e=Math.floor(c/256);if(256*e>65535)return void f(new Error("glyphs > 65535 not supported"));if(a.ranges[e])return void f(null,{stack:b,id:c,glyph:d});let g=a.requests[e];g||(g=a.requests[e]=[],aA.loadGlyphRange(b,e,this.url,this.requestManager,(d,b)=>{if(b){for(const c in a.ascender=b.ascender,a.descender=b.descender,b.glyphs)this._doesCharSupportLocalGlyph(+c)||(a.glyphs[+c]=b.glyphs[+c]);a.ranges[e]=!0}for(const f of g)f(d,b);delete a.requests[e]})),g.push((a,d)=>{a?f(a):d&&f(null,{stack:b,id:c,glyph:d.glyphs[c]||null})})},(d,f)=>{if(d)e(d);else if(f){const b={};for(const{stack:a,id:g,glyph:c}of f)void 0===b[a]&&(b[a]={}),void 0===b[a].glyphs&&(b[a].glyphs={}),b[a].glyphs[g]=c&&{id:c.id,bitmap:c.bitmap.clone(),metrics:c.metrics},b[a].ascender=this.entries[a].ascender,b[a].descender=this.entries[a].descender;e(null,b)}})}_doesCharSupportLocalGlyph(a){return this.localGlyphMode!==d9.none&&(this.localGlyphMode===d9.all?!!this.localFontFamily:!!this.localFontFamily&&(hh(a)||hk(a)||g8(a)||g9(a))||g7(a))}_tinySDF(e,d,a){const f=this.localFontFamily;if(!f||!this._doesCharSupportLocalGlyph(a))return;let b=e.tinySDF;if(!b){let c="400";/bold/i.test(d)?c="900":/medium/i.test(d)?c="500":/light/i.test(d)&&(c="200"),(b=e.tinySDF=new aA.TinySDF({fontFamily:f,fontWeight:c,fontSize:48,buffer:6,radius:16})).fontWeight=c}if(this.localGlyphs[b.fontWeight][a])return this.localGlyphs[b.fontWeight][a];const g=String.fromCharCode(a),{data:h,width:i,height:j,glyphWidth:k,glyphHeight:l,glyphLeft:m,glyphTop:n,glyphAdvance:o}=b.draw(g);return this.localGlyphs[b.fontWeight][a]={id:a,bitmap:new dJ({width:i,height:j},h),metrics:{width:k/2,height:l/2,left:m/2,top:n/2-27,advance:o/2,localGlyph:!0}}}}function kl(c,D,E,o){const h=[],b=c.image,F=b.pixelRatio,i=b.paddedRect.w-2,j=b.paddedRect.h-2,G=c.right-c.left,H=c.bottom-c.top,d=b.stretchX||[[0,i]],e=b.stretchY||[[0,j]],p=(b,a)=>b+a[1]-a[0],k=d.reduce(p,0),l=e.reduce(p,0),q=i-k,r=j-l;let s=0,t=k,u=0,v=l,x=0,y=q,z=0,A=r;if(b.content&&o){const a=b.content;s=km(d,0,a[0]),u=km(e,0,a[1]),t=km(d,a[0],a[2]),v=km(e,a[1],a[3]),x=a[0]-s,z=a[1]-u,y=a[2]-a[0]-t,A=a[3]-a[1]-v}const w=(a,d,e,f)=>{const i=(a.stretch-s)/t*G+c.left,J=a.fixed-x-y*a.stretch/k,j=(d.stretch-u)/v*H+c.top,K=d.fixed-z-A*d.stretch/l,m=(e.stretch-s)/t*G+c.left,L=e.fixed-x-y*e.stretch/k,n=(f.stretch-u)/v*H+c.top,M=f.fixed-z-A*f.stretch/l,o=new aF(i,j),p=new aF(m,j),q=new aF(m,n),r=new aF(i,n),N=new aF(J/F,K/F),O=new aF(L/F,M/F),h=D*Math.PI/180;if(h){const w=Math.sin(h),B=Math.cos(h),g=[B,-w,w,B];o._matMult(g),p._matMult(g),r._matMult(g),q._matMult(g)}const C=a.stretch+a.fixed,I=d.stretch+d.fixed;return{tl:o,tr:p,bl:r,br:q,tex:{x:b.paddedRect.x+1+C,y:b.paddedRect.y+1+I,w:e.stretch+e.fixed-C,h:f.stretch+f.fixed-I},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:N,pixelOffsetBR:O,minFontScaleX:y/F/G,minFontScaleY:A/F/H,isSDF:E}};if(o&&(b.stretchX||b.stretchY)){const m=kn(d,q,k),n=kn(e,r,l);for(let f=0;f{if(b)g(b);else if(c){var d;const e={},a=(d=c,new d2(d).readFields(jX,{}));for(const f of a.glyphs)e[f.id]=f;g(null,{glyphs:e,ascender:a.ascender,descender:a.descender})}})},aA.TinySDF=class{constructor({fontSize:c=24,buffer:d=3,radius:e=8,cutoff:f=.25,fontFamily:g="sans-serif",fontWeight:h="normal",fontStyle:i="normal"}){this.buffer=d,this.cutoff=f,this.radius=e;const a=this.size=c+4*d,j=this._createCanvas(a),b=this.ctx=j.getContext("2d",{willReadFrequently:!0});b.font=`${i} ${h} ${c}px ${g}`,b.textBaseline="alphabetic",b.textAlign="left",b.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(b){const a=document.createElement("canvas");return a.width=a.height=b,a}draw(p){const{width:u,actualBoundingBoxAscent:q,actualBoundingBoxDescent:v,actualBoundingBoxLeft:w,actualBoundingBoxRight:x}=this.ctx.measureText(p),r=Math.floor(q),b=Math.min(this.size-this.buffer,Math.ceil(x-w)),c=Math.min(this.size-this.buffer,Math.ceil(q)+Math.ceil(v)),d=b+2*this.buffer,m=c+2*this.buffer,i=d*m,s=new Uint8ClampedArray(i),t={data:s,width:d,height:m,glyphWidth:b,glyphHeight:c,glyphTop:r,glyphLeft:0,glyphAdvance:u};if(0===b||0===c)return t;const{ctx:n,buffer:a,gridInner:f,gridOuter:g}=this;n.clearRect(a,a,b,c),n.fillText(p,a,a+r+1);const y=n.getImageData(a,a,b,c);g.fill(1e20,0,i),f.fill(0,0,i);for(let j=0;j0?e*e:0,f[l]=e<0?e*e:0}}kj(g,0,0,d,m,d,this.f,this.v,this.z),kj(f,a,a,b,c,d,this.f,this.v,this.z);for(let h=0;hb?1:0}){if(this.data=b,this.length=this.data.length,this.compare=c,this.length>0)for(let a=(this.length>>1)-1;a>=0;a--)this._down(a)}push(a){this.data.push(a),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const a=this.data[0],b=this.data.pop();return this.length--,this.length>0&&(this.data[0]=b,this._down(0)),a}peek(){return this.data[0]}_up(a){const{data:b,compare:f}=this,c=b[a];for(;a>0;){const d=a-1>>1,e=b[d];if(f(c,e)>=0)break;b[a]=e,a=d}b[a]=c}_down(a){const{data:b,compare:f}=this,h=this.length>>1,g=b[a];for(;af(b[e],d)&&(c=e,d=b[e]),f(d,g)>=0)break;b[a]=d,a=c}b[a]=g}}function kq(e,r=1,p=!1){let h=1/0,i=1/0,j=-1/0,k=-1/0;const q=e[0];for(let f=0;fj)&&(j=c.x),(!f||c.y>k)&&(k=c.y)}const l=Math.min(j-h,k-i);let a=l/2;const d=new kp([],kr);if(0===l)return new aF(h,i);for(let m=h;mg.d||!g.d)&&(g=b,p&&console.log("found best %d after %d probes",Math.round(1e4*b.d)/1e4,o)),b.max-g.d<=r||(a=b.h/2,d.push(new ks(b.p.x-a,b.p.y-a,a,e)),d.push(new ks(b.p.x+a,b.p.y-a,a,e)),d.push(new ks(b.p.x-a,b.p.y+a,a,e)),d.push(new ks(b.p.x+a,b.p.y+a,a,e)),o+=4)}return p&&(console.log(`num probes: ${o}`),console.log(`best distance: ${g.d}`)),g.p}function kr(a,b){return b.max-a.max}function ks(a,b,c,d){this.p=new aF(a,b),this.h=c,this.d=function(b,i){let d=!1,e=1/0;for(let f=0;fb.y!=c.y>b.y&&b.x<(c.x-a.x)*(b.y-a.y)/(c.y-a.y)+a.x&&(d=!d),e=Math.min(e,im(b,a,c))}}return(d?1:-1)*Math.sqrt(e)}(this.p,d),this.max=this.d+this.h*Math.SQRT2}const kt=Number.POSITIVE_INFINITY,ku=Math.sqrt(2);function ea(b,a){return a[1]!==kt?function(e,a,b){let c=0,d=0;switch(a=Math.abs(a),b=Math.abs(b),e){case"top-right":case"top-left":case"top":d=b-7;break;case"bottom-right":case"bottom-left":case"bottom":d=7-b}switch(e){case"top-right":case"bottom-right":case"right":c=-a;break;case"top-left":case"bottom-left":case"left":c=a}return[c,d]}(b,a[0],a[1]):function(e,a){let b=0,c=0;a<0&&(a=0);const d=a/ku;switch(e){case"top-right":case"top-left":c=d-7;break;case"bottom-right":case"bottom-left":c=7-d;break;case"bottom":c=7-a;break;case"top":c=a-7}switch(e){case"top-right":case"bottom-right":b=-d;break;case"top-left":case"bottom-left":b=d;break;case"left":b=a;break;case"right":b=-a}return[b,c]}(b,a[0])}function kv(a,w,x,y,n,M,N,b,o,O){a.createArrays(),a.tilePixelRatio=8192/(512*a.overscaling),a.compareText={},a.iconsNeedLinear=!1;const d=a.layers[0].layout,g=a.layers[0]._unevaluatedLayout._values,e={};if("composite"===a.textSizeData.kind){const{minZoom:P,maxZoom:Q}=a.textSizeData;e.compositeTextSizes=[g["text-size"].possiblyEvaluate(new c5(P),b),g["text-size"].possiblyEvaluate(new c5(Q),b),]}if("composite"===a.iconSizeData.kind){const{minZoom:R,maxZoom:S}=a.iconSizeData;e.compositeIconSizes=[g["icon-size"].possiblyEvaluate(new c5(R),b),g["icon-size"].possiblyEvaluate(new c5(S),b),]}e.layoutTextSize=g["text-size"].possiblyEvaluate(new c5(o+1),b),e.layoutIconSize=g["icon-size"].possiblyEvaluate(new c5(o+1),b),e.textMaxSize=g["text-size"].possiblyEvaluate(new c5(18),b);const z="map"===d.get("text-rotation-alignment")&&"point"!==d.get("symbol-placement"),T=d.get("text-size");for(const c of a.features){const A=d.get("text-font").evaluate(c,{},b).join(","),B=T.evaluate(c,{},b),p=e.layoutTextSize.evaluate(c,{},b),f=(e.layoutIconSize.evaluate(c,{},b),{horizontal:{},vertical:void 0}),k=c.text;let q,l=[0,0];if(k){const C=k.toString(),U=24*d.get("text-letter-spacing").evaluate(c,{},b),D=24*d.get("text-line-height").evaluate(c,{},b),E=ht(C)?U:0,r=d.get("text-anchor").evaluate(c,{},b),s=d.get("text-variable-anchor");if(!s){const F=d.get("text-radial-offset").evaluate(c,{},b);l=F?ea(r,[24*F,kt]):d.get("text-offset").evaluate(c,{},b).map(a=>24*a)}let h=z?"center":d.get("text-justify").evaluate(c,{},b);const i=d.get("symbol-placement"),V="point"===i,G="point"===i?24*d.get("text-max-width").evaluate(c,{},b):0,H=b=>{a.allowVerticalPlacement&&hs(C)&&(f.vertical=j0(k,w,x,n,A,G,D,r,b,E,l,d5.vertical,!0,i,p,B))};if(!z&&s){const I="auto"===h?s.map(a=>eb(a)):[h];let J=!1;for(let t=0;t=0||!hs(C)){const K=j0(k,w,x,n,A,G,D,r,h,E,l,d5.horizontal,!1,i,p,B);K&&(f.horizontal[h]=K)}H("point"===i?"left":h)}}let L=!1;if(c.icon&&c.icon.name){const j=y[c.icon.name];j&&(q=ka(n[c.icon.name],d.get("icon-offset").evaluate(c,{},b),d.get("icon-anchor").evaluate(c,{},b)),L=j.sdf,void 0===a.sdfIcons?a.sdfIcons=j.sdf:a.sdfIcons!==j.sdf&&bY("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(j.pixelRatio!==a.pixelRatio||0!==d.get("icon-rotate").constantOr(1))&&(a.iconsNeedLinear=!0))}const v=kz(f.horizontal)||f.vertical;a.iconsInText||(a.iconsInText=!!v&&v.iconsInText),(v||q)&&kw(a,c,f,q,y,e,p,0,l,L,N,b,O)}M&&a.generateCollisionDebugBuffers(o,a.collisionBoxArray)}function eb(a){switch(a){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function kw(c,b,e,f,F,A,n,G,H,I,J,d,K){let i=A.textMaxSize.evaluate(b,{},d);void 0===i&&(i=n);const a=c.layers[0].layout,o=a.get("icon-offset").evaluate(b,{},d),g=kz(e.horizontal)||e.vertical,p=n/24,q=c.tilePixelRatio*i/24,r=c.tilePixelRatio*a.get("symbol-spacing"),L=a.get("text-padding")*c.tilePixelRatio,M=a.get("icon-padding")*c.tilePixelRatio,s=a.get("text-max-angle")*aP,N="map"===a.get("text-rotation-alignment")&&"point"!==a.get("symbol-placement"),O="map"===a.get("icon-rotation-alignment")&&"point"!==a.get("symbol-placement"),t=a.get("symbol-placement"),B=r/2,j=a.get("icon-text-fit");let C;f&&"none"!==j&&(c.allowVerticalPlacement&&e.vertical&&(C=kb(f,e.vertical,j,a.get("icon-text-fit-padding"),o,p)),g&&(f=kb(f,g,j,a.get("icon-text-fit-padding"),o,p)));const h=(g,a,h)=>{if(a.x<0||a.x>=8192||a.y<0||a.y>=8192)return;const{x:i,y:j,z:k}=K.projectTilePoint(a.x,a.y,h),l=new d7(i,j,k,0,void 0);!function(a,d,e,aa,h,z,H,j,f,r,m,s,t,I,u,v,ac,J,K,L,b,w,M,x,c){const k=a.addToLineVertexArray(d,aa);let l,n,o,y,N,O,P,Q=0,R=0,S=0,T=0,A=-1,B=-1;const g={};let U=bd(""),C=0,D=0;if(void 0===f._unevaluatedLayout.getValue("text-radial-offset")?[C,D]=f.layout.get("text-offset").evaluate(b,{},c).map(a=>24*a):(C=24*f.layout.get("text-radial-offset").evaluate(b,{},c),D=kt),a.allowVerticalPlacement&&h.vertical){const V=h.vertical;if(u)O=kB(V),j&&(P=kB(j));else{const W=f.layout.get("text-rotate").evaluate(b,{},c)+90;o=kA(r,e,d,m,s,t,V,I,W,v),j&&(y=kA(r,e,d,m,s,t,j,J,W))}}if(z){const E=f.layout.get("icon-rotate").evaluate(b,{},c),X="none"!==f.layout.get("icon-text-fit"),Y=kl(z,E,M,X),F=j?kl(j,E,M,X):void 0;n=kA(r,e,d,m,s,t,z,J,E),Q=4*Y.length;const Z=a.iconSizeData;let p=null;"source"===Z.kind?(p=[128*f.layout.get("icon-size").evaluate(b,{},c),])[0]>kx&&bY(`${a.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`):"composite"===Z.kind&&((p=[128*w.compositeIconSizes[0].evaluate(b,{},c),128*w.compositeIconSizes[1].evaluate(b,{},c),])[0]>kx||p[1]>kx)&&bY(`${a.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`),a.addSymbols(a.icon,Y,p,L,K,b,!1,e,d,k.lineStartIndex,k.lineLength,-1,x,c),A=a.icon.placedSymbolArray.length-1,F&&(R=4*F.length,a.addSymbols(a.icon,F,p,L,K,b,d5.vertical,e,d,k.lineStartIndex,k.lineLength,-1,x,c),B=a.icon.placedSymbolArray.length-1)}for(const $ in h.horizontal){const q=h.horizontal[$];l||(U=bd(q.text),u?N=kB(q):l=kA(r,e,d,m,s,t,q,I,f.layout.get("text-rotate").evaluate(b,{},c),v));const _=1===q.positionedLines.length;if(S+=ky(a,e,d,q,H,f,u,b,v,k,h.vertical?d5.horizontal:d5.horizontalOnly,_?Object.keys(h.horizontal):[$],g,A,w,x,c),_)break}h.vertical&&(T+=ky(a,e,d,h.vertical,H,f,u,b,v,k,d5.vertical,["vertical"],g,B,w,x,c));let i=-1;const G=(a,b)=>a?Math.max(a,b):b;i=G(N,i),i=G(O,i),i=G(P,i);const ab=i> -1?1:0;a.glyphOffsetArray.length>=aB.MAX_GLYPHS&&bY("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==b.sortKey&&a.addToSortKeyRanges(a.symbolInstances.length,b.sortKey),a.symbolInstances.emplaceBack(e.x,e.y,e.z,d.x,d.y,g.right>=0?g.right:-1,g.center>=0?g.center:-1,g.left>=0?g.left:-1,g.vertical>=0?g.vertical:-1,A,B,U,void 0!==l?l:a.collisionBoxArray.length,void 0!==l?l+1:a.collisionBoxArray.length,void 0!==o?o:a.collisionBoxArray.length,void 0!==o?o+1:a.collisionBoxArray.length,void 0!==n?n:a.collisionBoxArray.length,void 0!==n?n+1:a.collisionBoxArray.length,y||a.collisionBoxArray.length,y?y+1:a.collisionBoxArray.length,m,S,T,Q,R,ab,0,C,D,i)}(c,a,l,g,e,f,F,C,c.layers[0],c.collisionBoxArray,b.index,b.sourceLayerIndex,c.index,L,N,H,0,M,O,o,b,A,I,J,d)};if("line"===t)for(const u of d8(b.geometry,0,0,8192,8192)){const D=kh(u,r,s,e.vertical||g,f,24,q,c.overscaling,8192);for(const v of D){const w=g;w&&kC(c,w.text,B,v)||h(u,v,d)}}else if("line-center"===t){for(const k of b.geometry)if(k.length>1){const x=kg(k,s,e.vertical||g,f,24,q);x&&h(k,x,d)}}else if("Polygon"===b.type)for(const y of i8(b.geometry,0)){const z=kq(y,16);h(y[0],new d7(z.x,z.y,0,0,void 0),d)}else if("LineString"===b.type)for(const l of b.geometry)h(l,new d7(l[0].x,l[0].y,0,0,void 0),d);else if("Point"===b.type)for(const E of b.geometry)for(const m of E)h([m],new d7(m.x,m.y,0,0,void 0),d)}const kx=32640;function ky(a,l,m,n,o,e,f,b,g,h,p,q,r,s,i,t,c){const j=function(Z,c,g,M,l,N,O,B){const s=[];if(0===c.positionedLines.length)return s;const h=M.layout.get("text-rotate").evaluate(N,{})*Math.PI/180,m=function(c){const a=c[0],b=c[1],d=a*b;return d>0?[a,-b]:d<0?[-a,b]:0===a?[b,a]:[b,-a]}(g);let C=Math.abs(c.top-c.bottom);for(const P of c.positionedLines)C-=P.lineOffset;const D=c.positionedLines.length,Q=C/D;let t=c.top-g[1];for(let n=0;nkx&&bY(`${a.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`):"composite"===k.kind&&((d=[128*i.compositeTextSizes[0].evaluate(b,{},c),128*i.compositeTextSizes[1].evaluate(b,{},c),])[0]>kx||d[1]>kx)&&bY(`${a.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`),a.addSymbols(a.text,j,d,g,f,b,p,l,m,h.lineStartIndex,h.lineLength,s,t,c),q))r[u]=a.text.placedSymbolArray.length-1;return 4*j.length}function kz(a){for(const b in a)return a[b];return null}function kA(o,m,p,r,s,t,a,u,q,n){let b=a.top,c=a.bottom,d=a.left,e=a.right;const f=a.collisionPadding;if(f&&(d-=f[0],b-=f[1],e+=f[2],c+=f[3]),q){const g=new aF(d,b),h=new aF(e,b),i=new aF(d,c),j=new aF(e,c),l=q*aP;let k=new aF(0,0);n&&(k=new aF(n[0],n[1])),g._rotateAround(l,k),h._rotateAround(l,k),i._rotateAround(l,k),j._rotateAround(l,k),d=Math.min(g.x,h.x,i.x,j.x),e=Math.max(g.x,h.x,i.x,j.x),b=Math.min(g.y,h.y,i.y,j.y),c=Math.max(g.y,h.y,i.y,j.y)}return o.emplaceBack(m.x,m.y,m.z,p.x,p.y,d,b,e,c,u,r,s,t),o.length-1}function kB(a){a.collisionPadding&&(a.top-=a.collisionPadding[1],a.bottom+=a.collisionPadding[3]);const b=a.bottom-a.top;return b>0?Math.max(10,b):null}function kC(f,a,g,d){const b=f.compareText;if(a in b){const e=b[a];for(let c=e.length-1;c>=0;c--)if(d.dist(e[c])a.id),this.index=a.index,this.pixelRatio=a.pixelRatio,this.sourceLayerIndex=a.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=aI([]),this.placementViewportMatrix=aI([]);const d=this.layers[0]._unevaluatedLayout._values;this.textSizeData=d0(this.zoom,d["text-size"]),this.iconSizeData=d0(this.zoom,d["icon-size"]);const b=this.layers[0].layout,e=b.get("symbol-sort-key"),c=b.get("symbol-z-order");this.canOverlap=b.get("text-allow-overlap")||b.get("icon-allow-overlap")||b.get("text-ignore-placement")||b.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==c&& void 0!==e.constantOr(1),this.sortFeaturesByY=("viewport-y"===c||"auto"===c&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=b.get("text-writing-mode").map(a=>d5[a]),this.stateDependentLayerIds=this.layers.filter(a=>a.isStateDependent()).map(a=>a.id),this.sourceID=a.sourceID}createArrays(){this.text=new ec(new dv(this.layers,this.zoom,a=>/^text/.test(a))),this.icon=new ec(new dv(this.layers,this.zoom,a=>/^icon/.test(a))),this.glyphOffsetArray=new dd,this.lineVertexArray=new de,this.symbolInstances=new dc}calculateGlyphDependencies(b,c,g,e,f){for(let a=0;a0)&&("constant"!==k.value.kind||k.value.value.length>0),o="constant"!==l.value.kind||!!l.value.value||Object.keys(l.parameters).length>0,x=b.get("symbol-sort-key");if(this.features=[],!n&&!o)return;const p=j.iconDependencies,q=j.glyphDependencies,r=j.availableImages,y=new c5(this.zoom);for(const{feature:h,id:z,index:A,sourceLayerIndex:B}of v){const s=d._featureFilter.needGeometry,a=id(h,s);if(!d._featureFilter.filter(y,a,c))continue;let e,f;if(s||(a.geometry=ic(h,c,w)),n){const C=d.getValueAndResolveTokens("text-field",a,c,r),t=fB.factory(C);kG(t)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===c3()||this.hasRTLText&&c4.isParsed())&&(e=jB(t,d,a))}if(o){const m=d.getValueAndResolveTokens("icon-image",a,c,r);f=m instanceof cj?m:cj.fromString(m)}if(!e&&!f)continue;const D=this.sortFeaturesByKey?x.evaluate(a,{},c):void 0;if(this.features.push({id:z,text:e,icon:f,index:A,sourceLayerIndex:B,geometry:a.geometry,properties:h.properties,type:kD[h.type],sortKey:D}),f&&(p[f.name]=!0),e){const E=k.evaluate(a,{},c).join(","),F="map"===b.get("text-rotation-alignment")&&"point"!==b.get("symbol-placement");for(const i of(this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(d5.vertical)>=0,e.sections))if(i.image)p[i.image.name]=!0;else{const G=hs(e.toString()),u=i.fontStack||E,H=q[u]=q[u]||{};this.calculateGlyphDependencies(i.text,H,F,this.allowVerticalPlacement,G)}}}"line"===b.get("symbol-placement")&&(this.features=function(k){const d={},c={},g=[];let l=0;function m(a){g.push(k[a]),l++}function n(b,d,e){const a=c[b];return delete c[b],c[d]=a,g[a].geometry[0].pop(),g[a].geometry[0]=g[a].geometry[0].concat(e[0]),a}function o(c,b,e){const a=d[b];return delete d[b],d[c]=a,g[a].geometry[0].shift(),g[a].geometry[0]=e[0].concat(g[a].geometry[0]),a}function i(c,a,d){const b=d?a[0][a[0].length-1]:a[0][0];return`${c}:${b.x}:${b.y}`}for(let e=0;ea.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((a,b)=>a.sortKey-b.sortKey)}update(a,b,c,d){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(a,b,this.layers,c,d),this.icon.programConfigurations.updatePaintArrays(a,b,this.layers,c,d))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(a){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(a),this.iconCollisionBox.upload(a)),this.text.upload(a,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(a,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(d,a){const h=this.lineVertexArray.length;if(void 0!==d.segment){let i=d.dist(a[d.segment+1]),j=d.dist(a[d.segment]);const e={};for(let b=d.segment+1;b=0;c--)e[c]={x:a[c].x,y:a[c].y,tileUnitDistanceFromAnchor:j},c>0&&(j+=a[c-1].dist(a[c]));for(let f=0;f=0?a.rightJustifiedTextSymbolIndex:a.centerJustifiedTextSymbolIndex>=0?a.centerJustifiedTextSymbolIndex:a.leftJustifiedTextSymbolIndex>=0?a.leftJustifiedTextSymbolIndex:a.verticalPlacedTextSymbolIndex>=0?a.verticalPlacedTextSymbolIndex:c),e=bh(this.textSizeData,b,d)/24;return this.tilePixelRatio*e}getSymbolInstanceIconSize(a,e,b){const c=this.icon.placedSymbolArray.get(b),d=bh(this.iconSizeData,a,c);return this.tilePixelRatio*d}_commitDebugCollisionVertexUpdate(b,c,a){b.emplaceBack(c,-a,-a),b.emplaceBack(c,a,-a),b.emplaceBack(c,a,a),b.emplaceBack(c,-a,a)}_updateTextDebugCollisionBoxes(b,c,d,e,f,g){for(let a=e;a0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(b,d){const c=b.placedSymbolArray.get(d),e=c.vertexStartIndex+4*c.numGlyphs;for(let a=c.vertexStartIndex;ag[a]-g[b]||h[b]-h[a]),c}addToSortKeyRanges(a,c){const b=this.sortKeyRanges[this.sortKeyRanges.length-1];b&&b.sortKey===c?b.symbolInstanceEnd=a+1:this.sortKeyRanges.push({sortKey:c,symbolInstanceStart:a,symbolInstanceEnd:a+1})}sortFeatures(b){if(this.sortFeaturesByY&&this.sortedAngle!==b&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){for(const c of(this.symbolInstanceIndexes=this.getSortedSymbolIndexes(b),this.sortedAngle=b,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[],this.symbolInstanceIndexes)){const a=this.symbolInstances.get(c);this.featureSortOrder.push(a.featureIndex),[a.rightJustifiedTextSymbolIndex,a.centerJustifiedTextSymbolIndex,a.leftJustifiedTextSymbolIndex,].forEach((a,b,c)=>{a>=0&&c.indexOf(a)===b&&this.addIndicesForPlacedSymbol(this.text,a)}),a.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,a.verticalPlacedTextSymbolIndex),a.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,a.placedIconSymbolIndex),a.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,a.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}c("SymbolBucket",aB,{omit:["layers","collisionBoxArray","features","compareText",]}),aB.MAX_GLYPHS=65535,aB.addDynamicAttributes=bk;const ee=new n({"symbol-placement":new e(b.layout_symbol["symbol-placement"]),"symbol-spacing":new e(b.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new e(b.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new g(b.layout_symbol["symbol-sort-key"]),"symbol-z-order":new e(b.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new e(b.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new e(b.layout_symbol["icon-ignore-placement"]),"icon-optional":new e(b.layout_symbol["icon-optional"]),"icon-rotation-alignment":new e(b.layout_symbol["icon-rotation-alignment"]),"icon-size":new g(b.layout_symbol["icon-size"]),"icon-text-fit":new e(b.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new e(b.layout_symbol["icon-text-fit-padding"]),"icon-image":new g(b.layout_symbol["icon-image"]),"icon-rotate":new g(b.layout_symbol["icon-rotate"]),"icon-padding":new e(b.layout_symbol["icon-padding"]),"icon-keep-upright":new e(b.layout_symbol["icon-keep-upright"]),"icon-offset":new g(b.layout_symbol["icon-offset"]),"icon-anchor":new g(b.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new e(b.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new e(b.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new e(b.layout_symbol["text-rotation-alignment"]),"text-field":new g(b.layout_symbol["text-field"]),"text-font":new g(b.layout_symbol["text-font"]),"text-size":new g(b.layout_symbol["text-size"]),"text-max-width":new g(b.layout_symbol["text-max-width"]),"text-line-height":new g(b.layout_symbol["text-line-height"]),"text-letter-spacing":new g(b.layout_symbol["text-letter-spacing"]),"text-justify":new g(b.layout_symbol["text-justify"]),"text-radial-offset":new g(b.layout_symbol["text-radial-offset"]),"text-variable-anchor":new e(b.layout_symbol["text-variable-anchor"]),"text-anchor":new g(b.layout_symbol["text-anchor"]),"text-max-angle":new e(b.layout_symbol["text-max-angle"]),"text-writing-mode":new e(b.layout_symbol["text-writing-mode"]),"text-rotate":new g(b.layout_symbol["text-rotate"]),"text-padding":new e(b.layout_symbol["text-padding"]),"text-keep-upright":new e(b.layout_symbol["text-keep-upright"]),"text-transform":new g(b.layout_symbol["text-transform"]),"text-offset":new g(b.layout_symbol["text-offset"]),"text-allow-overlap":new e(b.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new e(b.layout_symbol["text-ignore-placement"]),"text-optional":new e(b.layout_symbol["text-optional"])});var kH={paint:new n({"icon-opacity":new g(b.paint_symbol["icon-opacity"]),"icon-color":new g(b.paint_symbol["icon-color"]),"icon-halo-color":new g(b.paint_symbol["icon-halo-color"]),"icon-halo-width":new g(b.paint_symbol["icon-halo-width"]),"icon-halo-blur":new g(b.paint_symbol["icon-halo-blur"]),"icon-translate":new e(b.paint_symbol["icon-translate"]),"icon-translate-anchor":new e(b.paint_symbol["icon-translate-anchor"]),"text-opacity":new g(b.paint_symbol["text-opacity"]),"text-color":new g(b.paint_symbol["text-color"],{runtimeType:y,getOverride:a=>a.textColor,hasOverride:a=>!!a.textColor}),"text-halo-color":new g(b.paint_symbol["text-halo-color"]),"text-halo-width":new g(b.paint_symbol["text-halo-width"]),"text-halo-blur":new g(b.paint_symbol["text-halo-blur"]),"text-translate":new e(b.paint_symbol["text-translate"]),"text-translate-anchor":new e(b.paint_symbol["text-translate-anchor"])}),layout:ee};class ef{constructor(a){this.type=a.property.overrides?a.property.overrides.runtimeType:cf,this.defaultValue=a}evaluate(a){if(a.formattedSection){const b=this.defaultValue.property.overrides;if(b&&b.hasOverride(a.formattedSection))return b.getOverride(a.formattedSection)}return a.feature&&a.featureState?this.defaultValue.evaluate(a.feature,a.featureState):this.defaultValue.property.specification.default}eachChild(a){this.defaultValue.isConstant()||a(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}c("FormatSectionOverride",ef,{omit:["defaultValue"]});class eg extends be{constructor(a){super(a,kH)}recalculate(d,e){super.recalculate(d,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 b=this.layout.get("text-writing-mode");if(b){const a=[];for(const c of b)0>a.indexOf(c)&&a.push(c);this.layout._values["text-writing-mode"]=a}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(b,c,e,f){var g;const a=this.layout.get(b).evaluate(c,{},e,f),d=this._unevaluatedLayout._values[b];return d.isDataDriven()||gv(d.value)||!a?a:(g=c.properties,a.replace(/{([^{}]+)}/g,(b,a)=>a in g?String(g[a]):""))}createBucket(a){return new aB(a)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const b of kH.paint.overridableProperties){if(!eg.hasPaintOverride(this.layout,b))continue;const a=this.paint.get(b),e=new ef(a),c=new cM(e,a.property.specification);let d=null;d="constant"===a.value.kind||"source"===a.value.kind?new cO("source",c):new cP("composite",c,a.value.zoomStops,a.value._interpolationType),this.paint._values[b]=new hM(a.property,d,a.parameters)}}_handleOverridablePaintPropertyUpdate(a,b,c){return!(!this.layout||b.isDataDriven()||c.isDataDriven())&&eg.hasPaintOverride(this.layout,a)}static hasPaintOverride(c,d){const a=c.get("text-field"),h=kH.paint.properties[d];let e=!1;const f=a=>{for(const b of a)if(h.overrides&&h.overrides.hasOverride(b))return void(e=!0)};if("constant"===a.value.kind&&a.value.value instanceof fB)f(a.value.value.sections);else if("source"===a.value.kind){const g=a=>{e||(a instanceof ck&&fE(a.value)===ch?f(a.value.sections):a instanceof cl?f(a.sections):a.eachChild(g))},b=a.value;b._styleExpression&&g(b._styleExpression.expression)}return e}getProgramConfiguration(a){return new du(this,a)}}var kI={paint:new n({"background-color":new e(b.paint_background["background-color"]),"background-pattern":new a5(b.paint_background["background-pattern"]),"background-opacity":new e(b.paint_background["background-opacity"])})},kJ={paint:new n({"raster-opacity":new e(b.paint_raster["raster-opacity"]),"raster-hue-rotate":new e(b.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new e(b.paint_raster["raster-brightness-min"]),"raster-brightness-max":new e(b.paint_raster["raster-brightness-max"]),"raster-saturation":new e(b.paint_raster["raster-saturation"]),"raster-contrast":new e(b.paint_raster["raster-contrast"]),"raster-resampling":new e(b.paint_raster["raster-resampling"]),"raster-fade-duration":new e(b.paint_raster["raster-fade-duration"])})};class kK extends be{constructor(a){super(a,{}),this.implementation=a}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){}serialize(){}onAdd(a){this.implementation.onAdd&&this.implementation.onAdd(a,a.painter.context.gl)}onRemove(a){this.implementation.onRemove&&this.implementation.onRemove(a,a.painter.context.gl)}}var kL={paint:new n({"sky-type":new e(b.paint_sky["sky-type"]),"sky-atmosphere-sun":new e(b.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new e(b.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new e(b.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new e(b.paint_sky["sky-gradient-radius"]),"sky-gradient":new V(b.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new e(b.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new e(b.paint_sky["sky-atmosphere-color"]),"sky-opacity":new e(b.paint_sky["sky-opacity"])})};function kM(l,m,n){var a,b,f,h,i,j,k,c,d;const g=Q(0,0,1),e=bG(aO());return a=e,b=e,f=n?-(l*aP)+Math.PI:l*aP,f*=.5,h=b[0],i=b[1],j=b[2],k=b[3],c=Math.sin(f),d=Math.cos(f),a[0]=h*d-j*c,a[1]=i*d+k*c,a[2]=j*d+h*c,a[3]=k*d-i*c,bH(e,e,-(m*aP)),bD(g,g,e),bz(g,g)}const kN={circle:class extends be{constructor(a){super(a,iv)}createBucket(a){return new bf(a)}queryRadius(b){const a=b;return ir("circle-radius",this,a)+ir("circle-stroke-width",this,a)+is(this.paint.get("circle-translate"))}queryIntersectsFeature(a,b,c,e,j,d,f,g){const h=iu(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),d.angle,a.pixelToTileUnitsFactor),i=this.paint.get("circle-radius").evaluate(b,c)+this.paint.get("circle-stroke-width").evaluate(b,c);return iw(a,e,d,f,g,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),h,i)}getProgramIds(){return["circle"]}getProgramConfiguration(a){return new du(this,a)}},heatmap:class extends be{createBucket(a){return new dI(a)}constructor(a){super(a,iE),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(a){"heatmap-color"===a&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=dK({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(a){return ir("heatmap-radius",this,a)}queryIntersectsFeature(a,b,c,d,i,e,f,g){const h=this.paint.get("heatmap-radius").evaluate(b,c);return iw(a,d,e,f,g,!0,!0,new aF(0,0),h)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(a){return new du(this,a)}},hillshade:class extends be{constructor(a){super(a,iF)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare",]}getProgramConfiguration(a){return new du(this,a)}},fill:class extends be{constructor(a){super(a,jc)}getProgramIds(){const a=this.paint.get("fill-pattern"),b=a&&a.constantOr(1),c=[b?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&c.push(b&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),c}getProgramConfiguration(a){return new du(this,a)}recalculate(b,c){super.recalculate(b,c);const a=this.paint._values["fill-outline-color"];"constant"===a.value.kind&& void 0===a.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(a){return new dN(a)}queryRadius(){return is(this.paint.get("fill-translate"))}queryIntersectsFeature(a,d,e,b,f,c){return!a.queryGeometry.isAboveHorizon&&ih(it(a.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),c.angle,a.pixelToTileUnitsFactor),b)}isTileClipped(){return!0}},"fill-extrusion":class extends be{constructor(a){super(a,jm)}createBucket(a){return new dU(a)}queryRadius(){return is(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion",]}getProgramConfiguration(a){return new du(this,a)}queryIntersectsFeature(c,k,l,v,C,a,w,m,x){var d,e,f,g,h,i,n,o,p;const y=iu(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),a.angle,c.pixelToTileUnitsFactor),z=this.paint.get("fill-extrusion-height").evaluate(k,l),A=this.paint.get("fill-extrusion-base").evaluate(k,l),b=[0,0],q=m&&a.elevation,B=a.elevation?a.elevation.exaggeration():1;if(q){const r=c.tile.getBucket(this).centroidVertexArray,s=x+1;if(s=3){for(let d=0;d1&&(b=i[++j]);const n=Math.abs(a-b.left),o=Math.abs(a-b.right),e=Math.min(n,o);let g;const h=d/c*(f+1);if(b.isDash){const k=f-Math.abs(h);g=Math.sqrt(e*e+k*k)}else g=f-Math.sqrt(e*e+h*h);this.image.data[m+a]=Math.max(0,Math.min(255,g+128))}}}addRegularDash(a,k){for(let b=a.length-1;b>=0;--b){const e=a[b],f=a[b+1];e.zeroLength?a.splice(b,1):f&&f.isDash===e.isDash&&(f.left=e.left,a.splice(b,1))}const g=a[0],h=a[a.length-1];g.isDash===h.isDash&&(g.left=h.left-this.width,h.right=g.right+this.width);const l=this.width*this.nextRow;let i=0,d=a[i];for(let c=0;c1&&(d=a[++i]);const m=Math.abs(c-d.left),n=Math.abs(c-d.right),j=Math.min(m,n);this.image.data[l+c]=Math.max(0,Math.min(255,(d.isDash?j:-j)+k+128))}}addDash(a,e){const f=this.getKey(a,e);if(this.positions[f])return this.positions[f];const h="round"===e,c=h?7:0,i=2*c+1;if(this.nextRow+i>this.height)return bY("LineAtlas out of space"),null;0===a.length&&a.push(1);let d=0;for(let b=0;b0;a--)c+=(e&(b=1<this.canonical.z?new bn(a,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new bn(a,this.wrap,a,this.canonical.x>>b,this.canonical.y>>b)}calculateScaledKey(a,b=!0){if(this.overscaledZ===a&&b)return this.key;if(a>this.canonical.z)return kV(this.wrap*+b,a,this.canonical.z,this.canonical.x,this.canonical.y);{const c=this.canonical.z-a;return kV(this.wrap*+b,a,a,this.canonical.x>>c,this.canonical.y>>c)}}isChildOf(a){if(a.wrap!==this.wrap)return!1;const b=this.canonical.z-a.canonical.z;return 0===a.overscaledZ||a.overscaledZ>b&&a.canonical.y===this.canonical.y>>b}children(d){if(this.overscaledZ>=d)return[new bn(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y),];const a=this.canonical.z+1,b=2*this.canonical.x,c=2*this.canonical.y;return[new bn(a,this.wrap,a,b,c),new bn(a,this.wrap,a,b+1,c),new bn(a,this.wrap,a,b,c+1),new bn(a,this.wrap,a,b+1,c+1),]}isLessThan(a){return this.wrapa.wrap)&&(this.overscaledZa.overscaledZ)&&(this.canonical.xa.canonical.x)&&this.canonical.yMath.abs(i[a])){if(d[a]h[a])return null}else{const j=1/i[a];let b=(g[a]-d[a])*j,c=(h[a]-d[a])*j;if(b>c){const k=b;b=c,c=k}if(b>e&&(e=b),cf)return null}return e}function k$(b,c,d,y,z,A,B,C,D,e,a){const f=y-b,g=z-c,h=A-d,i=B-b,j=C-c,k=D-d,q=a[1]*k-a[2]*j,r=a[2]*i-a[0]*k,s=a[0]*j-a[1]*i,t=f*q+g*r+h*s;if(1e-15>Math.abs(t))return null;const l=1/t,m=e[0]-b,n=e[1]-c,o=e[2]-d,p=(m*q+n*r+o*s)*l;if(p<0||p>1)return null;const u=n*h-o*g,v=o*f-m*h,w=m*g-n*f,x=(a[0]*u+a[1]*v+a[2]*w)*l;return x<0||p+x>1?null:(i*u+j*v+k*w)*l}function k_(d,e,j,b,c,k,l,f,g){const a=1<{const e=f?1:0,g=(c+1)*a-e,h=d*a,i=(d+1)*a-e;b[0]=c*a,b[1]=h,b[2]=g,b[3]=i};let c=new kY(b);const a=[];for(let g=0;g=1;b/=2){const d=f[f.length-1];c=new kY(b);for(let h=0;h0;){const{idx:u,t:B,nodex:g,nodey:h,depth:j}=t.pop();if(this.leaves[u]){k_(g,h,j,o,p,q,r,a,b);const k=1<=x[2])return B}continue}let l=0;for(let c=0;c=s[i[m]]&&(i.splice(m,0,c),y=!0);y||(i[l]=c),l++}}for(let z=0;z=this.dim+1||b< -1||b>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(b+1)*this.stride+(a+1)}_unpackMapbox(a,b,c){return(256*a*256+256*b+c)/10-1e4}_unpackTerrarium(a,b,c){return 256*a+b+c/256-32768}static pack(d,e){const b=[0,0,0,0],c=bo.getUnpackVector(e);let a=Math.floor((d+c[3])/c[2]);return b[2]=a%256,a=Math.floor(a/256),b[1]=a%256,a=Math.floor(a/256),b[0]=a,b}getPixels(){return new bg({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(i,a,b){if(this.dim!==i.dim)throw new Error("dem dimension mismatch");let e=a*this.dim,f=a*this.dim+this.dim,g=b*this.dim,h=b*this.dim+this.dim;switch(a){case -1:e=f-1;break;case 1:f=e+1}switch(b){case -1:g=h-1;break;case 1:h=g+1}const j=-a*this.dim,k=-b*this.dim;for(let c=g;c{"source"===a.dataType&&"metadata"===a.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===a.dataType&&"content"===a.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))}),a.on("error",()=>{this._sourceErrored=!0}),this._source=a,this._tiles={},this._cache=new class{constructor(a,b){this.max=a,this.onRemove=b,this.reset()}reset(){for(const b in this.data)for(const a of this.data[b])a.timeout&&clearTimeout(a.timeout),this.onRemove(a.value);return this.data={},this.order=[],this}add(e,f,b){const a=e.wrapped().key;void 0===this.data[a]&&(this.data[a]=[]);const c={value:f,timeout:void 0};if(void 0!==b&&(c.timeout=setTimeout(()=>{this.remove(e,c)},b)),this.data[a].push(c),this.order.push(a),this.order.length>this.max){const d=this._getAndRemoveByKey(this.order[0]);d&&this.onRemove(d)}return this}has(a){return a.wrapped().key in this.data}getAndRemove(a){return this.has(a)?this._getAndRemoveByKey(a.wrapped().key):null}_getAndRemoveByKey(a){const b=this.data[a].shift();return b.timeout&&clearTimeout(b.timeout),0===this.data[a].length&&delete this.data[a],this.order.splice(this.order.indexOf(a),1),b.value}getByKey(b){const a=this.data[b];return a?a[0].value:null}get(a){return this.has(a)?this.data[a.wrapped().key][0].value:null}remove(c,d){if(!this.has(c))return this;const a=c.wrapped().key,e=void 0===d?0:this.data[a].indexOf(d),b=this.data[a][e];return this.data[a].splice(e,1),b.timeout&&clearTimeout(b.timeout),0===this.data[a].length&&delete this.data[a],this.onRemove(b.value),this.order.splice(this.order.indexOf(a),1),this}setMaxSize(b){for(this.max=b;this.order.length>this.max;){const a=this._getAndRemoveByKey(this.order[0]);a&&this.onRemove(a)}return this}filter(d){const a=[];for(const e in this.data)for(const b of this.data[e])d(b.value)||a.push(b);for(const c of a)this.remove(c.value.tileID,c)}}(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=null,this._maxTileCacheSize=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new class{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(a,g,c){const b=String(g);if(this.stateChanges[a]=this.stateChanges[a]||{},this.stateChanges[a][b]=this.stateChanges[a][b]||{},bR(this.stateChanges[a][b],c),null===this.deletedStates[a])for(const d in this.deletedStates[a]={},this.state[a])d!==b&&(this.deletedStates[a][d]=null);else if(this.deletedStates[a]&&null===this.deletedStates[a][b])for(const e in this.deletedStates[a][b]={},this.state[a][b])c[e]||(this.deletedStates[a][b][e]=null);else for(const f in c)this.deletedStates[a]&&this.deletedStates[a][b]&&null===this.deletedStates[a][b][f]&&delete this.deletedStates[a][b][f]}removeFeatureState(a,d,c){if(null===this.deletedStates[a])return;const b=String(d);if(this.deletedStates[a]=this.deletedStates[a]||{},c&& void 0!==d)null!==this.deletedStates[a][b]&&(this.deletedStates[a][b]=this.deletedStates[a][b]||{},this.deletedStates[a][b][c]=null);else if(void 0!==d){if(this.stateChanges[a]&&this.stateChanges[a][b])for(c in this.deletedStates[a][b]={},this.stateChanges[a][b])this.deletedStates[a][b][c]=null;else this.deletedStates[a][b]=null}else this.deletedStates[a]=null}getState(a,b){const c=String(b),d=bR({},(this.state[a]||{})[c],(this.stateChanges[a]||{})[c]);if(null===this.deletedStates[a])return{};if(this.deletedStates[a]){const e=this.deletedStates[a][b];if(null===e)return{};for(const f in e)delete d[f]}return d}initializeTileState(a,b){a.setFeatureState(this.state,b)}coalesceChanges(g,j){const c={};for(const b in this.stateChanges){this.state[b]=this.state[b]||{};const h={};for(const d in this.stateChanges[b])this.state[b][d]||(this.state[b][d]={}),bR(this.state[b][d],this.stateChanges[b][d]),h[d]=this.state[b][d];c[b]=h}for(const a in this.deletedStates){this.state[a]=this.state[a]||{};const f={};if(null===this.deletedStates[a])for(const i in this.state[a])f[i]={},this.state[a][i]={};else for(const e in this.deletedStates[a]){if(null===this.deletedStates[a][e])this.state[a][e]={};else for(const k of Object.keys(this.deletedStates[a][e]))delete this.state[a][e][k];f[e]=this.state[a][e]}c[a]=c[a]||{},bR(c[a],f)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(c).length)for(const l in g)g[l].setFeatureState(c,j)}}}onAdd(a){this.map=a,this._minTileCacheSize=a?a._minTileCacheSize:null,this._maxTileCacheSize=a?a._maxTileCacheSize:null}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const b in this._tiles){const a=this._tiles[b];if("loaded"!==a.state&&"errored"!==a.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const a=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,a&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(a,b){return a.isSymbolTile=this._onlySymbols,this._source.loadTile(a,b)}_unloadTile(a){if(this._source.unloadTile)return this._source.unloadTile(a,()=>{})}_abortTile(a){if(this._source.abortTile)return this._source.abortTile(a,()=>{})}serialize(){return this._source.serialize()}prepare(b){for(const c in this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null),this._tiles){const a=this._tiles[c];a.upload(b),a.prepare(this.map.style.imageManager)}}getIds(){return bQ(this._tiles).map(a=>a.tileID).sort(k3).map(a=>a.key)}getRenderableIds(b){const a=[];for(const c in this._tiles)this._isIdRenderable(+c,b)&&a.push(this._tiles[c]);return b?a.sort((e,f)=>{const a=e.tileID,b=f.tileID,c=new aF(a.canonical.x,a.canonical.y)._rotate(this.transform.angle),d=new aF(b.canonical.x,b.canonical.y)._rotate(this.transform.angle);return a.overscaledZ-b.overscaledZ||d.y-c.y||d.x-c.x}).map(a=>a.tileID.key):a.map(a=>a.tileID).sort(k3).map(a=>a.key)}hasRenderableParent(b){const a=this.findLoadedParent(b,0);return!!a&&this._isIdRenderable(a.tileID.key)}_isIdRenderable(a,b){return this._tiles[a]&&this._tiles[a].hasData()&&!this._coveredTiles[a]&&(b||!this._tiles[a].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else for(const a in this._cache.reset(),this._tiles)"errored"!==this._tiles[a].state&&this._reloadTile(+a,"reloading")}_reloadTile(b,c){const a=this._tiles[b];a&&("loading"!==a.state&&(a.state=c),this._loadTile(a,this._tileLoaded.bind(this,a,b,c)))}_tileLoaded(a,d,e,b){if(b){if(a.state="errored",404!==b.status)this._source.fire(new cb(b,{tile:a}));else if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const c=this.map.painter.terrain;this.update(this.transform,c.getScaledDemTileSize(),!0),c.resetTileLookupCache(this.id)}else this.update(this.transform)}else a.timeAdded=b$.now(),"expired"===e&&(a.refreshedUponExpiration=!0),this._setTileReloadTimer(d,a),"raster-dem"===this._source.type&&a.dem&&this._backfillDEM(a),this._state.initializeTileState(a,this.map?this.map.painter:null),this._source.fire(new aW("data",{dataType:"source",tile:a,coord:a.tileID,sourceCacheId:this.id}))}_backfillDEM(a){const c=this.getRenderableIds();for(let b=0;b1||(Math.abs(b)>1&&(1===Math.abs(b+d)?b+=d:1===Math.abs(b-d)&&(b-=d)),c.dem&&a.dem&&(a.dem.backfillBorder(c.dem,b,e),a.neighboringTiles&&a.neighboringTiles[f]&&(a.neighboringTiles[f].backfilled=!0)))}}getTile(a){return this.getTileByID(a.key)}getTileByID(a){return this._tiles[a]}_retainLoadedChildren(h,d,i,e){for(const f in this._tiles){let a=this._tiles[f];if(e[f]||!a.hasData()||a.tileID.overscaledZ<=d||a.tileID.overscaledZ>i)continue;let b=a.tileID;for(;a&&a.tileID.overscaledZ>d+1;){const g=a.tileID.scaledTo(a.tileID.overscaledZ-1);(a=this._tiles[g.key])&&a.hasData()&&(b=g)}let c=b;for(;c.overscaledZ>d;)if(h[(c=c.scaledTo(c.overscaledZ-1)).key]){e[b.key]=b;break}}}findLoadedParent(a,d){if(a.key in this._loadedParentTiles){const b=this._loadedParentTiles[a.key];return b&&b.tileID.overscaledZ>=d?b:null}for(let c=a.overscaledZ-1;c>=d;c--){const f=a.scaledTo(c),e=this._getLoadedTile(f);if(e)return e}}_getLoadedTile(a){const b=this._tiles[a.key];return b&&b.hasData()?b:this._cache.getByKey(this._source.reparseOverscaled?a.wrapped().key:a.canonical.key)}updateCacheSize(b,a){a=a||this._source.tileSize;const e=Math.ceil(b.width/a)+1,f=Math.ceil(b.height/a)+1,c=Math.floor(e*f*5),d="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,c):c,g="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,d):d;this._cache.setMaxSize(g)}handleWrapJump(b){const c=Math.round((b-(void 0===this._prevLng?b:this._prevLng))/360);if(this._prevLng=b,c){const d={};for(const g in this._tiles){const a=this._tiles[g];a.tileID=a.tileID.unwrapTo(a.tileID.wrap+c),d[a.tileID.key]=a}for(const e in this._tiles=d,this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const f in this._tiles)this._setTileReloadTimer(+f,this._tiles[f])}}update(e,n,o){if(this.transform=e,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!o)return;let a;this.updateCacheSize(e,n),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?a=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(a=>new bn(a.canonical.z,a.wrap,a.canonical.z,a.canonical.x,a.canonical.y)):(a=e.coveringTiles({tileSize:n||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&&(a=a.filter(a=>this._source.hasTile(a)))):a=[];const b=this._updateRetainedTiles(a);if(k4(this._source.type)&&0!==a.length){const h={},p={},s=Object.keys(b);for(const i of s){const j=b[i],k=this._tiles[i];if(!k||k.fadeEndTime&&k.fadeEndTime<=b$.now())continue;const f=this.findLoadedParent(j,Math.max(j.overscaledZ-aD.maxOverzooming,this._source.minzoom));f&&(this._addTile(f.tileID),h[f.tileID.key]=f.tileID),p[i]=j}const t=a[a.length-1].overscaledZ;for(const l in this._tiles){const m=this._tiles[l];if(b[l]||!m.hasData())continue;let c=m.tileID;for(;c.overscaledZ>t;){c=c.scaledTo(c.overscaledZ-1);const q=this._tiles[c.key];if(q&&q.hasData()&&p[c.key]){b[l]=m.tileID;break}}}for(const g in h)b[g]||(this._coveredTiles[g]=!0,b[g]=h[g])}for(const u in b)this._tiles[u].clearFadeHold();const v=function(c,d){const a=[];for(const b in c)b in d||a.push(b);return a}(this._tiles,b);for(const r of v){const d=this._tiles[r];d.hasSymbolBuckets&&!d.holdingForFade()?d.setHoldDuration(this.map._fadeDuration):d.hasSymbolBuckets&&!d.symbolFadeFinished()||this._removeTile(+r)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const a in this._tiles)this._tiles[a].holdingForFade()&&this._removeTile(+a)}_updateRetainedTiles(e){const a={};if(0===e.length)return a;const j={},k=e.reduce((a,b)=>Math.min(a,b.overscaledZ),1/0),l=e[0].overscaledZ,p=Math.max(l-aD.maxOverzooming,this._source.minzoom),q=Math.max(l+aD.maxUnderzooming,this._source.minzoom),m={};for(const f of e){const r=this._addTile(f);a[f.key]=f,r.hasData()||k=this._source.maxzoom){const h=c.children(this._source.maxzoom)[0],n=this.getTile(h);if(n&&n.hasData()){a[h.key]=h;continue}}else{const g=c.children(this._source.maxzoom);if(a[g[0].key]&&a[g[1].key]&&a[g[2].key]&&a[g[3].key])continue}let o=b.wasRequested();for(let i=c.overscaledZ-1;i>=p;--i){const d=c.scaledTo(i);if(j[d.key])break;if(j[d.key]=!0,(b=this.getTile(d))||!o||(b=this._addTile(d)),b&&(a[d.key]=d,o=b.wasRequested(),b.hasData()))break}}return a}_updateLoadedParentTileCache(){for(const e in this._loadedParentTiles={},this._tiles){const c=[];let b,a=this._tiles[e].tileID;for(;a.overscaledZ>0;){if(a.key in this._loadedParentTiles){b=this._loadedParentTiles[a.key];break}c.push(a.key);const d=a.scaledTo(a.overscaledZ-1);if(b=this._getLoadedTile(d))break;a=d}for(const f of c)this._loadedParentTiles[f]=b}}_addTile(b){let a=this._tiles[b.key];if(a)return a;(a=this._cache.getAndRemove(b))&&(this._setTileReloadTimer(b.key,a),a.tileID=b,this._state.initializeTileState(a,this.map?this.map.painter:null),this._cacheTimers[b.key]&&(clearTimeout(this._cacheTimers[b.key]),delete this._cacheTimers[b.key],this._setTileReloadTimer(b.key,a)));const c=Boolean(a);if(!c){const d=this.map?this.map.painter:null,e="raster"===this._source.type||"raster-dem"===this._source.type;a=new eq(b,this._source.tileSize*b.overscaleFactor(),this.transform.tileZoom,d,e),this._loadTile(a,this._tileLoaded.bind(this,a,b.key,a.state))}return a?(a.uses++,this._tiles[b.key]=a,c||this._source.fire(new aW("dataloading",{tile:a,coord:a.tileID,dataType:"source"})),a):null}_setTileReloadTimer(a,c){a in this._timers&&(clearTimeout(this._timers[a]),delete this._timers[a]);const b=c.getExpiryTimeout();b&&(this._timers[a]=setTimeout(()=>{this._reloadTile(a,"expired"),delete this._timers[a]},b))}_removeTile(b){const a=this._tiles[b];a&&(a.uses--,delete this._tiles[b],this._timers[b]&&(clearTimeout(this._timers[b]),delete this._timers[b]),a.uses>0||(a.hasData()&&"reloading"!==a.state?this._cache.add(a.tileID,a,a.getExpiryTimeout()):(a.aborted=!0,this._abortTile(a),this._unloadTile(a))))}clearTiles(){for(const a in this._shouldReloadOnResume=!1,this._paused=!1,this._tiles)this._removeTile(+a);this._source._clear&&this._source._clear(),this._cache.reset()}tilesIn(e,f,g){const a=[],c=this.transform;if(!c)return a;for(const h in this._tiles){const b=this._tiles[h];if(g&&b.clearQueryDebugViz(),b.holdingForFade())continue;const d=e.containsTile(b,c,f);d&&a.push(d)}return a}getVisibleCoordinates(c){const a=this.getRenderableIds(c).map(a=>this._tiles[a].tileID);for(const b of a)b.projMatrix=this.transform.calculateProjMatrix(b.toUnwrapped());return a}hasTransition(){if(this._source.hasTransition())return!0;if(k4(this._source.type))for(const b in this._tiles){const a=this._tiles[b];if(void 0!==a.fadeEndTime&&a.fadeEndTime>=b$.now())return!0}return!1}setFeatureState(a,b,c){this._state.updateState(a=a||"_geojsonTileLayer",b,c)}removeFeatureState(a,b,c){this._state.removeFeatureState(a=a||"_geojsonTileLayer",b,c)}getFeatureState(a,b){return this._state.getState(a=a||"_geojsonTileLayer",b)}setDependencies(b,c,d){const a=this._tiles[b];a&&a.setDependencies(c,d)}reloadTilesForDependencies(b,c){for(const a in this._tiles)this._tiles[a].hasDependency(b,c)&&this._reloadTile(+a,"reloading");this._cache.filter(a=>!a.hasDependency(b,c))}_preloadTiles(a,f){const b=new Map,g=Array.isArray(a)?a:[a],c=this.map.painter.terrain,h=this.usedForTerrain&&c?c.getScaledDemTileSize():this._source.tileSize;for(const d of g){const i=d.coveringTiles({tileSize:h,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 i)b.set(e.key,e);this.usedForTerrain&&d.updateElevation(!1)}const j=Array.from(b.values()),k="raster"===this._source.type||"raster-dem"===this._source.type;bP(j,(a,c)=>{const b=new eq(a,this._source.tileSize*a.overscaleFactor(),this.transform.tileZoom,this.map.painter,k);this._loadTile(b,a=>{"raster-dem"===this._source.type&&b.dem&&this._backfillDEM(b),c(a,b)})},f)}}function k3(a,b){const c=Math.abs(2*a.wrap)- +(a.wrap<0),d=Math.abs(2*b.wrap)- +(b.wrap<0);return a.overscaledZ-b.overscaledZ||d-c||b.canonical.y-a.canonical.y||b.canonical.x-a.canonical.x}function k4(a){return"raster"===a||"image"===a||"video"===a}aD.maxOverzooming=10,aD.maxUnderzooming=3;class k5{constructor(a,b,c){this._demTile=a,this._dem=this._demTile.dem,this._scale=b,this._offset=c}static create(f,b,g){const a=g||f.findDEMTileFor(b);if(!a||!a.dem)return;const e=a.dem,c=a.tileID,d=1<=0&&a[3]>=0&&l.insert(k,a[0],a[1],a[2],a[3])}}loadVTLayers(){if(!this.vtLayers)for(const a in this.vtLayers=new _.VectorTile(new d2(this.rawTileData)).layers,this.sourceLayerCoder=new kW(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={},this.vtLayers)this.vtFeatures[a]=[];return this.vtLayers}query(c,j,k,l){this.loadVTLayers();const d=c.params||{},m=gB(d.filter),n=c.tileResult,g=c.transform,a=n.bufferedTilespaceBounds,b=this.grid.query(a.min.x,a.min.y,a.max.x,a.max.y,(a,b,c,d)=>dF(n.bufferedTilespaceGeometry,a,b,c,d));b.sort(k7);let o=null;g.elevation&&b.length>0&&(o=k5.create(g.elevation,this.tileID));const h={};let i;for(let e=0;e(q||(q=ic(a,this.tileID.canonical,c.tileTransform)),b.queryIntersectsFeature(n,a,d,q,this.z,c.transform,c.pixelPosMatrix,o,e)))}return h}loadMatchingFeature(l,t,g,e,m,u,v,n,o){const{featureIndex:p,bucketIndex:w,sourceLayerIndex:x,layoutVertexArrayOffset:y}=t,h=this.bucketLayerIDs[w];if(e&&!function(b,c){for(let a=0;a=0)return!0;return!1}(e,h))return;const q=this.sourceLayerCoder.decode(x),a=this.vtLayers[q].feature(p);if(g.needGeometry){const z=id(a,!0);if(!g.filter(new c5(this.tileID.overscaledZ),z,this.tileID.canonical))return}else if(!g.filter(new c5(this.tileID.overscaledZ),a))return;const i=this.getId(a,q);for(let j=0;je.indexOf(b))continue;const c=u[b];if(!c)continue;let f={};void 0!==i&&n&&(f=n.getState(c.sourceLayer||"_geojsonTileLayer",i));const d=bR({},v[b]);d.paint=k6(d.paint,c.paint,a,f,m),d.layout=k6(d.layout,c.layout,a,f,m);const r=!o||o(a,c,f,y);if(!r)continue;const s=new kX(a,this.z,this.x,this.y,i);s.layer=d;let k=l[b];void 0===k&&(k=l[b]=[]),k.push({featureIndex:p,feature:s,intersectionZ:r})}}lookupSymbolFeatures(b,c,d,e,f,g,h,i){const a={};this.loadVTLayers();const j=gB(f);for(const k of b)this.loadMatchingFeature(a,{bucketIndex:d,sourceLayerIndex:e,featureIndex:k,layoutVertexArrayOffset:0},j,g,h,i,c);return a}loadFeature(e){const{featureIndex:a,sourceLayerIndex:f}=e;this.loadVTLayers();const c=this.sourceLayerCoder.decode(f),b=this.vtFeatures[c];if(b[a])return b[a];const d=this.vtLayers[c].feature(a);return b[a]=d,d}hasLayer(a){for(const b of this.bucketLayerIDs)for(const c of b)if(a===c)return!0;return!1}getId(b,c){let a=b.id;return this.promoteId&&"boolean"==typeof(a=b.properties["string"==typeof this.promoteId?this.promoteId:this.promoteId[c]])&&(a=Number(a)),a}}function k6(a,b,c,d,e){return eP(a,(g,f)=>{const a=b instanceof hN?b.get(f):null;return a&&a.evaluate?a.evaluate(c,d,e):a})}function k7(a,b){return b-a}c("FeatureIndex",el,{omit:["rawTileData","sourceLayerCoder"]});var em=j([{name:"a_pos",type:"Int16",components:2},]);const aa=new Uint16Array(8184);for(let ab=0;ab<2046;ab++){let aE=ab+2,D=0,E=0,F=0,G=0,ac=0,ad=0;for(1&aE?F=G=ac=32:D=E=ad=32;(aE>>=1)>1;){const en=D+F>>1,eo=E+G>>1;1&aE?(F=D,G=E,D=ac,E=ad):(D=F,E=G,F=ac,G=ad),ac=en,ad=eo}const ae=4*ab;aa[ae+0]=D,aa[ae+1]=E,aa[ae+2]=F,aa[ae+3]=G}const k8=new Uint16Array(2178),k9=new Uint8Array(1089),la=new Uint16Array(1089);function lb(a){return 0===a?-0.03125:32===a?.03125:0}var ep=j([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2},]);const lc={type:2,extent:8192,loadGeometry:()=>[[new aF(0,0),new aF(8193,0),new aF(8193,8193),new aF(0,8193),new aF(0,0),],]};class eq{constructor(b,c,d,a,e){this.tileID=b,this.uid=bS(),this.uses=0,this.tileSize=c,this.tileZoom=d,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=e,this.expiredRequestCount=0,this.state="loading",a&&a.transform&&(this.projection=a.transform.projection)}registerFadeDuration(b){const a=b+this.timeAdded;ae.getLayer(a)).filter(Boolean);if(0!==c.length)for(const f of(a.layers=c,a.stateDependentLayerIds&&(a.stateDependentLayers=a.stateDependentLayerIds.map(a=>c.filter(b=>b.id===a)[0])),c))b[f.id]=a}return b}(a.buckets,b.style),this.hasSymbolBuckets=!1,this.buckets){const c=this.buckets[g];if(c instanceof aB){if(this.hasSymbolBuckets=!0,!f)break;c.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const h in this.buckets){const d=this.buckets[h];if(d instanceof aB&&d.hasRTLText){this.hasRTLText=!0,c4.isLoading()||c4.isLoaded()||"deferred"!==c3()||hH();break}}for(const e in this.queryPadding=0,this.buckets){const i=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,b.style.getLayer(e).queryRadius(i))}a.imageAtlas&&(this.imageAtlas=a.imageAtlas),a.glyphAtlasImage&&(this.glyphAtlasImage=a.glyphAtlasImage),a.lineAtlas&&(this.lineAtlas=a.lineAtlas)}else this.collisionBoxArray=new c8}unloadVectorData(){if(this.hasData()){for(const a in this.buckets)this.buckets[a].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._tileDebugIndexBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this.globeGridBuffer&&(this.globeGridBuffer.destroy(),this.globeGridBuffer=null),this.globePoleBuffer&&(this.globePoleBuffer.destroy(),this.globePoleBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(a){return this.buckets[a.id]}upload(a){for(const d in this.buckets){const c=this.buckets[d];c.uploadPending()&&c.upload(a)}const b=a.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new eh(a,this.imageAtlas.image,b.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new eh(a,this.glyphAtlasImage,b.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new eh(a,this.lineAtlas.image,b.ALPHA),this.lineAtlas.uploaded=!0)}prepare(a){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(a,this.imageAtlasTexture)}queryRenderedFeatures(a,b,c,d,e,f,g,h){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:d,pixelPosMatrix:g,transform:f,params:e,tileTransform:this.tileTransform},a,b,c):{}}querySourceFeatures(m,a){const b=this.latestFeatureIndex;if(!b||!b.rawTileData)return;const g=b.loadVTLayers(),h=a?a.sourceLayer:"",d=g._geojsonTileLayer||g[h];if(!d)return;const e=gB(a&&a.filter),{z:i,x:j,y:k}=this.tileID.canonical,n={z:i,x:j,y:k};for(let f=0;fe)a=!1;else if(c){if(this.expirationTime=0;f--){const g=4*f,h=aa[g+0],i=aa[g+1],j=aa[g+2],k=aa[g+3],l=h+j>>1,m=i+k>>1,r=l+m-i,s=m+h-l,t=33*i+h,u=33*k+j,a=33*m+l,y=Math.hypot((k8[2*t+0]+k8[2*u+0])/2-k8[2*a+0],(k8[2*t+1]+k8[2*u+1])/2-k8[2*a+1])>=16;if(k9[a]=k9[a]||(y?1:0),f<1022){const z=(i+s>>1)*33+(h+r>>1),A=(k+s>>1)*33+(j+r>>1);k9[a]=k9[a]||k9[z]||k9[A]}}const B=new am,C=new aq;let D=0;function E(b,c){const a=33*c+b;return 0===la[a]&&(B.emplaceBack(k8[2*a+0],k8[2*a+1],8192*b/32,8192*c/32),la[a]=++D),la[a]-1}function v(a,b,e,f,c,d){const g=a+e>>1,h=b+f>>1;if(Math.abs(a-c)+Math.abs(b-d)>1&&k9[33*h+g])v(c,d,a,b,g,h),v(e,f,c,d,g,h);else{const i=E(a,b),j=E(e,f),k=E(c,d);C.emplaceBack(i,j,k)}}return v(0,0,32,32,32,0),v(32,32,0,0,0,32),{vertices:B,indices:C}}(this.tileID.canonical,e);a=g.vertices,b=g.indices}else{for(const{x:i,y:j}of(a=new am,b=new aq,h))a.emplaceBack(i,j,0,0);const d=dM(a.int16,void 0,4);for(let c=0;c{const a=65*d+b;c.emplaceBack(a+1,a,a+65),c.emplaceBack(a+65,a+65+1,a+1)};for(let a=0;a<64;a++)for(let b=0;b<64;b++)d(b,a);return c}getWirefameBuffer(b){if(!this.wireframeSegments){const a=this._createWireframeGrid();this.wireframeIndexBuffer=b.createIndexBuffer(a),this.wireframeSegments=ay.simpleSegment(0,0,4096,a.length)}return[this.wireframeIndexBuffer,this.wireframeSegments,]}_createWireframeGrid(){const c=new Y,d=(b,d)=>{const a=65*d+b;c.emplaceBack(a,a+1),c.emplaceBack(a,a+65),c.emplaceBack(a,a+65+1)};for(let a=0;a<64;a++)for(let b=0;b<64;b++)d(b,a);return c}}function ew(a,b){if(!b.isReprojectedInTileSpace)return{scale:1<m&&(n(i,a,e,f,c,d),n(a,j,c,d,g,h))}n(c,d,h,j,i,j),n(d,e,i,j,i,k),n(e,f,i,k,h,k),n(f,c,h,k,h,j),o-=m,p-=m,q+=m,r+=m;const l=1/Math.max(q-o,r-p);return{scale:l,x:o*l,y:p*l,x2:q*l,y2:r*l,projection:b}}class ex{constructor(c){const d={},e=[];for(const f in c){const g=c[f],q=d[f]={};for(const h in g.glyphs){const a=g.glyphs[+h];if(!a||0===a.bitmap.width||0===a.bitmap.height)continue;const i=a.metrics.localGlyph?2:1,j={x:0,y:0,w:a.bitmap.width+2*i,h:a.bitmap.height+2*i};e.push(j),q[h]=j}}const{w:r,h:s}=d3(e),k=new dJ({width:r||1,height:s||1});for(const l in c){const m=c[l];for(const n in m.glyphs){const b=m.glyphs[+n];if(!b||0===b.bitmap.width||0===b.bitmap.height)continue;const o=d[l][n],p=b.metrics.localGlyph?2:1;dJ.copy(b.bitmap,k,{x:0,y:0},{x:o.x+p,y:o.y+p},b.bitmap)}}this.image=k,this.positions=d}}c("GlyphAtlas",ex);class ll{constructor(a){this.tileID=new bn(a.tileID.overscaledZ,a.tileID.wrap,a.tileID.canonical.z,a.tileID.canonical.x,a.tileID.canonical.y),this.tileZoom=a.tileZoom,this.uid=a.uid,this.zoom=a.zoom,this.canonical=a.tileID.canonical,this.pixelRatio=a.pixelRatio,this.tileSize=a.tileSize,this.source=a.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=a.showCollisionBoxes,this.collectResourceTiming=!!a.collectResourceTiming,this.returnDependencies=!!a.returnDependencies,this.promoteId=a.promoteId,this.enableTerrain=!!a.enableTerrain,this.isSymbolTile=a.isSymbolTile,this.tileTransform=ew(a.tileID.canonical,a.projection),this.projection=a.projection}parse(h,v,i,j,E){this.status="parsing",this.data=h,this.collisionBoxArray=new c8;const w=new kW(Object.keys(h.layers).sort()),c=new el(this.tileID,this.promoteId);c.bucketLayerIDs=[];const x={},m=new bl(256,256),d={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:m,availableImages:i},k=v.familiesBySource[this.source];for(const b in k){const e=h.layers[b];if(!e)continue;let n=!1,o=!1;for(const y of k[b])"symbol"===y[0].type?n=!0:o=!0;if(!0===this.isSymbolTile&&!n)continue;if(!1===this.isSymbolTile&&!o)continue;1===e.version&&bY(`Vector tile source "${this.source}" layer "${b}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const p=w.encode(b),q=[];for(let f=0;f=a.maxzoom||"none"!==a.visibility&&(lm(g,this.zoom,i),(x[a.id]=a.createBucket({index:c.bucketLayerIDs.length,layers:g,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:p,sourceID:this.source,enableTerrain:this.enableTerrain,availableImages:i})).populate(q,d,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(g.map(a=>a.id)))}}let F,A,B,C;m.trim();const l={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},s=eP(d.glyphDependencies,a=>Object.keys(a).map(Number));Object.keys(s).length?j.send("getGlyphs",{uid:this.uid,stacks:s},(a,b)=>{F||(F=a,A=b,D.call(this))},void 0,!1,l):A={};const t=Object.keys(d.iconDependencies);t.length?j.send("getImages",{icons:t,source:this.source,tileID:this.tileID,type:"icons"},(a,b)=>{F||(F=a,B=b,D.call(this))},void 0,!1,l):B={};const u=Object.keys(d.patternDependencies);function D(){if(F)return E(F);if(A&&B&&C){const b=new ex(A),e=new d4(B,C);for(const f in x){const a=x[f];a instanceof aB?(lm(a.layers,this.zoom,i),kv(a,A,b.positions,B,e.iconPositions,this.showCollisionBoxes,i,this.tileID.canonical,this.tileZoom,this.projection),a.projection=this.projection.name):a.hasPattern&&(a instanceof dX||a instanceof dN||a instanceof dU)&&(lm(a.layers,this.zoom,i),a.addFeatures(d,this.tileID.canonical,e.patternPositions,i))}this.status="done",E(null,{buckets:bQ(x).filter(a=>!a.isEmpty()),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:b.image,lineAtlas:m,imageAtlas:e,glyphMap:this.returnDependencies?A:null,iconMap:this.returnDependencies?B:null,glyphPositions:this.returnDependencies?b.positions:null})}}u.length?j.send("getImages",{icons:u,source:this.source,tileID:this.tileID,type:"patterns"},(a,b)=>{F||(F=a,C=b,D.call(this))},void 0,!1,l):C={},D.call(this)}}function lm(a,b,c){const d=new c5(b);for(const e of a)e.recalculate(d,c)}class ey{constructor(a){this.entries={},this.scheduler=a}request(b,d,e,c){const a=this.entries[b]=this.entries[b]||{callbacks:[]};if(a.result){const[f,g]=a.result;return this.scheduler?this.scheduler.add(()=>{c(f,g)},d):c(f,g),()=>{}}return a.callbacks.push(c),a.cancel||(a.cancel=e((c,e)=>{for(const f of(a.result=[c,e],a.callbacks))this.scheduler?this.scheduler.add(()=>{f(c,e)},d):f(c,e);setTimeout(()=>delete this.entries[b],3e3)})),()=>{a.result||(a.callbacks=a.callbacks.filter(a=>a!==c),a.callbacks.length||(a.cancel(),delete this.entries[b]))}}}function ez(a,c,d){const b=JSON.stringify(a.request);return a.data&&(this.deduped.entries[b]={result:[null,a.data]}),this.deduped.request(b,{type:"parseTile",isSymbolTile:a.isSymbolTile,zoom:a.tileZoom},b=>{const c=fi(a.request,(c,a,e,f)=>{c?b(c):a&&b(null,{vectorTile:d?void 0:new _.VectorTile(new d2(a)),rawData:a,cacheControl:e,expires:f})});return()=>{c.cancel(),b()}},c)}const ln=aI(new Float64Array(16));class lo{constructor(a,b){this._tr=a,this._worldSize=b}createInversionMatrix(){return ln}createTileMatrix(e){let a,f,g;const c=e.canonical,b=aI(new Float64Array(16)),h=this._tr.projection;if(h.isReprojectedInTileSpace){const d=ew(c,h);a=1,f=d.x+e.wrap*d.scale,g=d.y,bs(b,b,[a/d.scale,a/d.scale,this._tr.pixelsPerMeter/this._worldSize,])}else a=this._worldSize/this._tr.zoomScale(c.z),f=(c.x+Math.pow(2,c.z)*e.wrap)*a,g=c.y*a;return br(b,b,[f,g,0]),bs(b,b,[a/8192,a/8192,1]),b}pointCoordinate(a,b,c){const d=this._tr.horizonLineFromTop(!1),e=new aF(a,Math.max(d,b));return this._tr.rayIntersectionCoordinate(this._tr.pointRayIntersection(e,c))}upVector(){return[0,0,1]}upVectorScale(){return 1}}var eA={name:"albers",range:[4,7],center:[-96,37.5],parallels:[29.5,45.5],zAxisUnit:"meters",conic:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],initializeConstants(){if(this.constants&&eJ(this.parallels,this.constants.parallels))return;const a=Math.sin(this.parallels[0]*aP),b=(a+Math.sin(this.parallels[1]*aP))/2,c=1+a*(2*b-a),d=Math.sqrt(c)/b;this.constants={n:b,c:c,r0:d,parallels:this.parallels}},project(d,e){this.initializeConstants();const b=(d-this.center[0])*aP,{n:a,c:f,r0:g}=this.constants,c=Math.sqrt(f-2*a*Math.sin(e*aP))/a;return{x:c*Math.sin(b*a),y:c*Math.cos(b*a)-g,z:0}},unproject(c,f){this.initializeConstants();const{n:a,c:g,r0:h}=this.constants,b=h+f;let d=Math.atan2(c,Math.abs(b))*Math.sign(b);b*a<0&&(d-=Math.PI*Math.sign(c)*Math.sign(b));const e=this.center[0]*aP*a;d=bO(d,-Math.PI-e,Math.PI-e);const i=d/a*eK+this.center[0],j=Math.asin(bM((g-(c*c+b*b)*a*a)/(2*a),-1,1)),k=bM(j*eK,-85.051129,85.051129);return new dy(i,k)},projectTilePoint:(a,b)=>({x:a,y:b,z:0}),locationPoint:(a,b)=>a._coordinatePoint(a.locationCoordinate(b),!1),pixelsPerMeter:(a,b)=>dB(1,a)*b,farthestPixelDistance(a){return lf(a,this.pixelsPerMeter(a.center.lat,a.worldSize))},createTileTransform:(a,b)=>new lo(a,b)};const lp=Math.sqrt(3)/2;var eB={name:"equalEarth",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(c,d){d=d/180*Math.PI,c=c/180*Math.PI;const b=Math.asin(lp*Math.sin(d)),a=b*b,e=a*a*a;return{x:.5*(c*Math.cos(b)/(lp*(1.340264+ -0.24331799999999998*a+e*(.0062510000000000005+.034164*a)))/Math.PI+.5),y:1-.5*(b*(1.340264+ -0.081106*a+e*(893e-6+.003796*a))/Math.PI+1),z:0}},unproject(d,e){d=(2*d-.5)*Math.PI;let b=e=(2*(1-e)-1)*Math.PI,a=b*b,c=a*a*a;for(let f,g,h,i=0;i<12&&(g=b*(1.340264+ -0.081106*a+c*(893e-6+.003796*a))-e,h=1.340264+ -0.24331799999999998*a+c*(.0062510000000000005+.034164*a),f=g/h,b=bM(b-f,-Math.PI/3,Math.PI/3),a=b*b,c=a*a*a,!(1e-12>Math.abs(f)));++i);const j=bM(180*(lp*d*(1.340264+ -0.24331799999999998*a+c*(.0062510000000000005+.034164*a))/Math.cos(b))/Math.PI,-180,180),k=bM(180*Math.asin(Math.sin(b)/lp)/Math.PI,-85.051129,85.051129);return new dy(j,k)},projectTilePoint:(a,b)=>({x:a,y:b,z:0}),locationPoint:(a,b)=>a._coordinatePoint(a.locationCoordinate(b),!1),pixelsPerMeter:(a,b)=>dB(1,a)*b,farthestPixelDistance(a){return lf(a,this.pixelsPerMeter(a.center.lat,a.worldSize))},createTileTransform:(a,b)=>new lo(a,b)},eC={name:"equirectangular",supportsWorldCopies:!0,center:[0,0],range:[3.5,7],zAxisUnit:"meters",wrap:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project:(a,b)=>({x:.5+a/360,y:.5-b/360,z:0}),unproject(a,b){const c=bM(360*(.5-b),-85.051129,85.051129);return new dy(360*(a-.5),c)},projectTilePoint:(a,b)=>({x:a,y:b,z:0}),locationPoint:(a,b)=>a._coordinatePoint(a.locationCoordinate(b),!1),pixelsPerMeter:(a,b)=>dB(1,a)*b,farthestPixelDistance(a){return lf(a,this.pixelsPerMeter(a.center.lat,a.worldSize))},createTileTransform:(a,b)=>new lo(a,b)};const lq=Math.PI/2;function lr(a){return Math.tan((lq+a)/2)}var ls,eD={name:"lambertConformalConic",range:[3.5,7],zAxisUnit:"meters",center:[0,30],parallels:[30,30],conic:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],initializeConstants(){if(this.constants&&eJ(this.parallels,this.constants.parallels))return;const a=this.parallels[0]*aP,b=this.parallels[1]*aP,d=Math.cos(a),c=a===b?Math.sin(a):Math.log(d/Math.cos(b))/Math.log(lr(b)/lr(a)),e=d*Math.pow(lr(a),c)/c;this.constants={n:c,f:e,parallels:this.parallels}},project(b,a){this.initializeConstants(),a*=aP,b=(b-this.center[0])*aP;const{n:c,f:d}=this.constants;d>0?a< -lq+1e-6&&(a=-lq+1e-6):a>lq-1e-6&&(a=lq-1e-6);const e=d/Math.pow(lr(a),c);return{x:.5*(e*Math.sin(c*b)/Math.PI+.5),y:1-.5*((d-e*Math.cos(c*b))/Math.PI+.5),z:0}},unproject(a,d){this.initializeConstants(),a=(2*a-.5)*Math.PI,d=(2*(1-d)-.5)*Math.PI;const{n:c,f:e}=this.constants,b=e-d,f=Math.sign(b),h=Math.sign(c)*Math.sqrt(a*a+b*b);let g=Math.atan2(a,Math.abs(b))*f;b*c<0&&(g-=Math.PI*Math.sign(a)*f);const i=bM(g/c*eK+this.center[0],-180,180),j=bM((2*Math.atan(Math.pow(e/h,1/c))-lq)*eK,-85.051129,85.051129);return new dy(i,j)},projectTilePoint:(a,b)=>({x:a,y:b,z:0}),locationPoint:(a,b)=>a._coordinatePoint(a.locationCoordinate(b),!1),pixelsPerMeter:(a,b)=>dB(1,a)*b,farthestPixelDistance(a){return lf(a,this.pixelsPerMeter(a.center.lat,a.worldSize))},createTileTransform:(a,b)=>new lo(a,b)},eE={name:"mercator",wrap:!0,requiresDraping:!1,supportsWorldCopies:!0,supportsTerrain:!0,supportsFog:!0,supportsFreeCamera:!0,zAxisUnit:"meters",center:[0,0],project:(a,b)=>({x:dz(a),y:dA(b),z:0}),unproject(a,b){const c=h7(a),d=dC(b);return new dy(c,d)},projectTilePoint:(a,b)=>({x:a,y:b,z:0}),locationPoint:(a,b)=>a._coordinatePoint(a.locationCoordinate(b),!1),pixelsPerMeter:(a,b)=>dB(1,a)*b,farthestPixelDistance(a){return lf(a,this.pixelsPerMeter(a.center.lat,a.worldSize))},createTileTransform:(a,b)=>new lo(a,b)};const lt=85.051129*aP;var eF={name:"naturalEarth",center:[0,0],range:[3.5,7],isReprojectedInTileSpace:!0,zAxisUnit:"meters",unsupportedLayers:["custom"],project(d,c){const a=(c*=aP)*c,b=a*a;return{x:.5*((d*=aP)*(.8707-.131979*a+b*(b*(.003971*a-.001529*b)-.013791))/Math.PI+.5),y:1-.5*(c*(1.007226+a*(.015085+b*(.028874*a-.044475-.005916*b)))/Math.PI+1),z:0}},unproject(d,e){d=(2*d-.5)*Math.PI;let b=e=(2*(1-e)-1)*Math.PI,g=25,f=0,a=b*b;do{a=b*b;const c=a*a;f=(b*(1.007226+a*(.015085+c*(.028874*a-.044475-.005916*c)))-e)/(1.007226+a*(.045255+c*(.259866*a-.311325-.06507600000000001*c))),b=bM(b-f,-lt,lt)}while(Math.abs(f)>1e-6&& --g>0)a=b*b;const h=bM(d/(.8707+a*(a*(a*a*a*(.003971-.001529*a)-.013791)-.131979))*eK,-180,180);return new dy(h,b*eK)},projectTilePoint:(a,b)=>({x:a,y:b,z:0}),locationPoint:(a,b)=>a._coordinatePoint(a.locationCoordinate(b),!1),pixelsPerMeter:(a,b)=>dB(1,a)*b,farthestPixelDistance(a){return lf(a,this.pixelsPerMeter(a.center.lat,a.worldSize))},createTileTransform:(a,b)=>new lo(a,b)};const lu=85.051129*aP,lv={albers:eA,equalEarth:eB,equirectangular:eC,lambertConformalConic:eD,mercator:eE,naturalEarth:eF,winkelTripel:{name:"winkelTripel",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(a,b){b*=aP,a*=aP;const c=Math.cos(b),d=Math.acos(c*Math.cos(a/2)),e=Math.sin(d)/d;return{x:.5*((.5*(a*(2/Math.PI)+2*c*Math.sin(a/2)/e)||0)/Math.PI+.5),y:1-.5*((.5*(b+Math.sin(b)/e)||0)/Math.PI+1),z:0}},unproject(j,k){let b=j=(2*j-.5)*Math.PI,c=k=(2*(1-k)-1)*Math.PI,z=25,l=0,m=0;do{const a=Math.cos(c),d=Math.sin(c),o=2*d*a,p=d*d,n=a*a,e=Math.cos(b/2),f=Math.sin(b/2),q=2*e*f,r=f*f,h=1-n*e*e,i=h?1/h:0,g=h?Math.acos(a*e)*Math.sqrt(1/h):0,s=.5*(2*g*a*f+2*b/Math.PI)-j,t=.5*(g*d+c)-k,u=.5*i*(n*r+g*a*e*p)+1/Math.PI,v=i*(q*o/4-g*d*f),w=.125*i*(o*f-g*d*n*q),x=.5*i*(p*e+g*r*a)+.5,y=v*w-x*u;l=(t*v-s*x)/y,m=(s*w-t*u)/y,b=bM(b-l,-Math.PI,Math.PI),c=bM(c-m,-lu,lu)}while((Math.abs(l)>1e-6||Math.abs(m)>1e-6)&& --z>0)return new dy(b*eK,c*eK)},projectTilePoint:(a,b)=>({x:a,y:b,z:0}),locationPoint:(a,b)=>a._coordinatePoint(a.locationCoordinate(b),!1),pixelsPerMeter:(a,b)=>dB(1,a)*b,farthestPixelDistance(a){return lf(a,this.pixelsPerMeter(a.center.lat,a.worldSize))},createTileTransform:(a,b)=>new lo(a,b)}};a.ARRAY_TYPE=I,a.AUTH_ERR_MSG=b1,a.Aabb=B,a.Actor=class{constructor(a,b,c){this.target=a,this.parent=b,this.mapId=c,this.callbacks={},this.cancelCallbacks={},bU(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=bZ()?a:s,this.scheduler=new class{constructor(){this.tasks={},this.taskQueue=[],bU(["process"],this),this.invoker=new class{constructor(a){this._callback=a,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(){delete this._channel,this._callback=()=>{}}}(this.process),this.nextId=0}add(b,c){const a=this.nextId++,d=function({type:b,isSymbolTile:c,zoom:a}){return a=a||0,"message"===b?0:"maybePrepare"!==b||c?"parseTile"!==b||c?"parseTile"===b&&c?300-a:"maybePrepare"===b&&c?400-a:500:200-a:100-a}(c);return 0===d?(bZ(),b(),{cancel(){}}):(this.tasks[a]={fn:b,metadata:c,priority:d,id:a},this.taskQueue.push(a),this.invoker.trigger(),{cancel:()=>{delete this.tasks[a]}})}process(){bZ();{if(this.taskQueue=this.taskQueue.filter(a=>!!this.tasks[a]),!this.taskQueue.length)return;const a=this.pick();if(null===a)return;const b=this.tasks[a];if(delete this.tasks[a],this.taskQueue.length&&this.invoker.trigger(),!b)return;b.fn()}}pick(){let a=null,c=1/0;for(let b=0;b{a&&delete this.callbacks[b],this.target.postMessage({id:b,type:"",targetMapId:f,sourceMapId:this.mapId})}}}receive(e){const a=e.data,b=a.id;if(b&&(!a.targetMapId||this.mapId===a.targetMapId)){if(""===a.type){const c=this.cancelCallbacks[b];delete this.cancelCallbacks[b],c&&c.cancel()}else if(a.mustQueue||bZ()){const d=this.callbacks[b];this.cancelCallbacks[b]=this.scheduler.add(()=>this.processTask(b,a),d&&d.metadata||{type:"message"})}else this.processTask(b,a)}}processTask(e,a){if(""===a.type){const b=this.callbacks[e];delete this.callbacks[e],b&&(a.error?b(g0(a.error)):b(null,g0(a.data)))}else{const g=eX(this.globalScope)?void 0:[],c=a.hasCallback?(a,b)=>{delete this.cancelCallbacks[e],this.target.postMessage({id:e,type:"",sourceMapId:this.mapId,error:a?g_(a):null,data:g_(b,g)},g)}:a=>{},d=g0(a.data);if(this.parent[a.type])this.parent[a.type](a.sourceMapId,d,c);else if(this.parent.getWorkerSource){const f=a.type.split(".");this.parent.getWorkerSource(a.sourceMapId,f[0],d.source)[f[1]](d,c)}else c(new Error(`Could not find function ${a.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},a.CanonicalTileID=bm,a.Color=m,a.ColorMode=r,a.CullFaceMode=o,a.DEMData=bo,a.DataConstantProperty=e,a.DedupedRequest=ey,a.DepthMode=C,a.EXTENT=8192,a.Elevation=class{getAtPointOrZero(a,b=0){return this.getAtPoint(a,b)||0}getAtPoint(a,e,o=!0){null==e&&(e=null);const i=this._source();if(!i)return e;if(a.y<0||a.y>1)return e;const g=i.getSource().maxzoom,j=1<{const e=this.getAtTileOffset(a,c.x,c.y),d=b.upVector(a.canonical,c.x,c.y);return bx(d,d,e*b.upVectorScale(a.canonical)),d}}getForTilePoints(a,b,e,c){const d=k5.create(this,a,c);return!!d&&(b.forEach(a=>{a[2]=this.exaggeration()*d.getElevationAt(a[0],a[1],e)}),!0)}getMinMaxForTile(a){const c=this.findDEMTileFor(a);if(!c||!c.dem)return null;const d=c.dem.tree,e=c.tileID,h=1<Math.abs(e))return!1;const d=((b[0]-this.pos[0])*a[0]+(b[1]-this.pos[1])*a[1]+(b[2]-this.pos[2])*a[2])/e;return c[0]=this.pos[0]+this.dir[0]*d,c[1]=this.pos[1]+this.dir[1]*d,c[2]=this.pos[2]+this.dir[2]*d,!0}closestPointOnSphere(i,b,a){var j,k,n,o,p,q,r,s;if(j=this.pos,k=i,n=j[0],o=j[1],p=j[2],q=k[0],r=k[1],s=k[2],Math.abs(n-q)<=1e-6*Math.max(1,Math.abs(n),Math.abs(q))&&Math.abs(o-r)<=1e-6*Math.max(1,Math.abs(o),Math.abs(r))&&Math.abs(p-s)<=1e-6*Math.max(1,Math.abs(p),Math.abs(s))||0===b)return a[0]=a[1]=a[2]=0,!1;const[f,g,h]=this.dir,c=this.pos[0]-i[0],d=this.pos[1]-i[1],e=this.pos[2]-i[2],w=f*f+g*g+h*h,l=2*(c*f+d*g+e*h),x=l*l-4*w*(c*c+d*d+e*e-b*b);if(x<0){const t=Math.max(-l/2,0),y=c+f*t,z=d+g*t,A=e+h*t,u=Math.hypot(y,z,A);return a[0]=y*b/u,a[1]=z*b/u,a[2]=A*b/u,!1}{const m=(-l-Math.sqrt(x))/(2*w);if(m<0){const v=Math.hypot(c,d,e);return a[0]=c*b/v,a[1]=d*b/v,a[2]=e*b/v,!1}return a[0]=c+f*m,a[1]=d+g*m,a[2]=e+h*m,!0}}},a.RequestManager=class{constructor(a,b,c){this._transformRequestFn=a,this._customAccessToken=b,this._silenceAuthErrors=!!c,this._createSkuToken()}_createSkuToken(){const a=function(){let a="";for(let b=0;b<10;b++)a+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1","01",a].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=a.token,this._skuTokenExpiresAt=a.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(a,b){return this._transformRequestFn&&this._transformRequestFn(a,b)||{url:a}}normalizeStyleURL(a,c){if(!b2(a))return a;const b=e4(a);return b.path=`/styles/v1${b.path}`,this._makeAPIURL(b,this._customAccessToken||c)}normalizeGlyphsURL(a,c){if(!b2(a))return a;const b=e4(a);return b.path=`/fonts/v1${b.path}`,this._makeAPIURL(b,this._customAccessToken||c)}normalizeSourceURL(b,c){if(!b2(b))return b;const a=e4(b);return a.path=`/v4/${a.authority}.json`,a.params.push("secure"),this._makeAPIURL(a,this._customAccessToken||c)}normalizeSpriteURL(b,c,d,e){const a=e4(b);return b2(b)?(a.path=`/styles/v1${a.path}/sprite${c}${d}`,this._makeAPIURL(a,this._customAccessToken||e)):(a.path+=`${c}${d}`,e5(a))}normalizeTileURL(b,e,c){if(this._isSkuTokenExpired()&&this._createSkuToken(),b&&!b2(b))return b;const a=e4(b);a.path=a.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${e||c&&"raster"!==a.authority&&512===c?"@2x":""}${b0.supported?".webp":"$1"}`),"raster"===a.authority?a.path=`/${b_.RASTER_URL_PREFIX}${a.path}`:(a.path=a.path.replace(/^.+\/v4\//,"/"),a.path=`/${b_.TILE_URL_VERSION}${a.path}`);const d=this._customAccessToken||function(b){for(const c of b){const a=c.match(/^access_token=(.*)$/);if(a)return a[1]}return null}(a.params)||b_.ACCESS_TOKEN;return b_.REQUIRE_ACCESS_TOKEN&&d&&this._skuToken&&a.params.push(`sku=${this._skuToken}`),this._makeAPIURL(a,d)}canonicalizeTileURL(d,e){const a=e4(d);if(!a.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!a.path.match(/\.[\w]+$/))return d;let b="mapbox://";a.path.match(/^\/raster\/v1\//)?b+=`raster/${a.path.replace(`/${b_.RASTER_URL_PREFIX}/`,"")}`:b+=`tiles/${a.path.replace(`/${b_.TILE_URL_VERSION}/`,"")}`;let c=a.params;return e&&(c=c.filter(a=>!a.match(/^access_token=/))),c.length&&(b+=`?${c.join("&")}`),b}canonicalizeTileset(d,c){const e=!!c&&b2(c),a=[];for(const b of d.tiles||[])e2(b)?a.push(this.canonicalizeTileURL(b,e)):a.push(b);return a}_makeAPIURL(a,b){const d="See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes",c=e4(b_.API_URL);if(a.protocol=c.protocol,a.authority=c.authority,"http"===a.protocol){const e=a.params.indexOf("secure");e>=0&&a.params.splice(e,1)}if("/"!==c.path&&(a.path=`${c.path}${a.path}`),!b_.REQUIRE_ACCESS_TOKEN)return e5(a);if(b=b||b_.ACCESS_TOKEN,!this._silenceAuthErrors){if(!b)throw new Error(`An API access token is required to use Mapbox GL. ${d}`);if("s"===b[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${d}`)}return a.params=a.params.filter(a=>-1===a.indexOf("access_token")),a.params.push(`access_token=${b||""}`),e5(a)}},a.ResourceType=aV,a.SegmentVector=ay,a.SourceCache=aD,a.StencilMode=aC,a.StructArrayLayout1ui2=av,a.StructArrayLayout2f1f2i16=ap,a.StructArrayLayout2i4=al,a.StructArrayLayout2ui4=Y,a.StructArrayLayout3f12=an,a.StructArrayLayout3ui6=aq,a.StructArrayLayout4i8=am,a.Texture=eh,a.Tile=eq,a.Transitionable=c6,a.Uniform1f=dl,a.Uniform1i=class extends ax{constructor(a,b){super(a,b),this.current=0}set(a){this.current!==a&&(this.current=a,this.gl.uniform1i(this.location,a))}},a.Uniform2f=class extends ax{constructor(a,b){super(a,b),this.current=[0,0]}set(a){a[0]===this.current[0]&&a[1]===this.current[1]||(this.current=a,this.gl.uniform2f(this.location,a[0],a[1]))}},a.Uniform3f=class extends ax{constructor(a,b){super(a,b),this.current=[0,0,0]}set(a){a[0]===this.current[0]&&a[1]===this.current[1]&&a[2]===this.current[2]||(this.current=a,this.gl.uniform3f(this.location,a[0],a[1],a[2]))}},a.Uniform4f=dm,a.UniformColor=dn,a.UniformMatrix2f=class extends ax{constructor(a,b){super(a,b),this.current=hY}set(b){for(let a=0;a<4;a++)if(b[a]!==this.current[a]){this.current=b,this.gl.uniformMatrix2fv(this.location,!1,b);break}}},a.UniformMatrix3f=class extends ax{constructor(a,b){super(a,b),this.current=hX}set(b){for(let a=0;a<9;a++)if(b[a]!==this.current[a]){this.current=b,this.gl.uniformMatrix3fv(this.location,!1,b);break}}},a.UniformMatrix4f=class extends ax{constructor(a,b){super(a,b),this.current=hW}set(a){if(a[12]!==this.current[12]||a[0]!==this.current[0])return this.current=a,void this.gl.uniformMatrix4fv(this.location,!1,a);for(let b=1;b<16;b++)if(a[b]!==this.current[b]){this.current=a,this.gl.uniformMatrix4fv(this.location,!1,a);break}}},a.UnwrappedTileID=ej,a.ValidationError=cc,a.VectorTileWorkerSource=class extends S{constructor(a,b,c,d,e){super(),this.actor=a,this.layerIndex=b,this.availableImages=c,this.loadVectorData=e||ez,this.loading={},this.loaded={},this.deduped=new ey(a.scheduler),this.isSpriteLoaded=d,this.scheduler=a.scheduler}loadTile(a,e){const c=a.uid,b=a&&a.request,f=b&&b.collectResourceTiming,d=this.loading[c]=new ll(a);d.abort=this.loadVectorData(a,(h,g)=>{const i=!this.loading[c];if(delete this.loading[c],i||h||!g)return d.status="done",i||(this.loaded[c]=d),e(h);const k=g.rawData,j={};g.expires&&(j.expires=g.expires),g.cacheControl&&(j.cacheControl=g.cacheControl),d.vectorTile=g.vectorTile||new _.VectorTile(new d2(k));const l=()=>{d.parse(d.vectorTile,this.layerIndex,this.availableImages,this.actor,(a,c)=>{if(a||!c)return e(a);const d={};if(f){const g=ei(b);g.length>0&&(d.resourceTiming=JSON.parse(JSON.stringify(g)))}e(null,bR({rawTileData:k.slice(0)},c,j,d))})};this.isSpriteLoaded?l():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(l,{type:"parseTile",isSymbolTile:a.isSymbolTile,zoom:a.tileZoom}):l()}),this.loaded=this.loaded||{},this.loaded[c]=d})}reloadTile(b,f){const c=this.loaded,e=b.uid,g=this;if(c&&c[e]){const a=c[e];a.showCollisionBoxes=b.showCollisionBoxes,a.enableTerrain=!!b.enableTerrain,a.projection=b.projection;const d=(c,d)=>{const b=a.reloadCallback;b&&(delete a.reloadCallback,a.parse(a.vectorTile,g.layerIndex,this.availableImages,g.actor,b)),f(c,d)};"parsing"===a.status?a.reloadCallback=d:"done"===a.status&&(a.vectorTile?a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.actor,d):d())}}abortTile(c,d){const b=c.uid,a=this.loading[b];a&&(a.abort&&a.abort(),delete this.loading[b]),d()}removeTile(c,d){const a=this.loaded,b=c.uid;a&&a[b]&&delete a[b],d()}},a.WritingMode=d5,a.ZoomHistory=c0,a.add=bw,a.addDynamicAttributes=bk,a.adjoint=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=b[4],h=b[5],i=b[6],j=b[7],k=b[8];return a[0]=g*k-h*j,a[1]=e*j-d*k,a[2]=d*h-e*g,a[3]=h*i-f*k,a[4]=c*k-e*i,a[5]=e*f-c*h,a[6]=f*j-g*i,a[7]=d*i-c*j,a[8]=c*g-d*f,a},a.asyncAll=bP,a.bezier=aQ,a.bindAll=bU,a.boundsAttributes=ep,a.bufferConvexPolygon=function(a,g){const e=[];for(let b=0;bfd&&(a.getActor().send("enforceCacheSizeLimit",fc),fg=0)},a.calculateGlobeMatrix=eu,a.calculateGlobeMercatorMatrix=function(a){const c=a.worldSize,f=bM(a.center.lat,-85.051129,85.051129),d=new aF(dz(a.center.lng)*c,dA(f)*c),g=dB(1,a.center.lat)*c,h=a.pixelsPerMeter,e=c/(g/a.pixelsPerMeter),b=aI(new Float64Array(16));return br(b,b,[d.x,d.y,0]),bs(b,b,[e,e,h]),b},a.clamp=bM,a.clearTileCache=function(a){const b=s.caches.delete(e9);a&&b.catch(a).then(()=>a())},a.clipLine=d8,a.clone=function(b){var a=new I(16);return a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a[4]=b[4],a[5]=b[5],a[6]=b[6],a[7]=b[7],a[8]=b[8],a[9]=b[9],a[10]=b[10],a[11]=b[11],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15],a},a.clone$1=bX,a.collisionCircleLayout=d_,a.config=b_,a.conjugate=function(a,b){return a[0]=-b[0],a[1]=-b[1],a[2]=-b[2],a[3]=b[3],a},a.create=function(){var a=new I(16);return I!=Float32Array&&(a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[11]=0,a[12]=0,a[13]=0,a[14]=0),a[0]=1,a[5]=1,a[10]=1,a[15]=1,a},a.create$1=aH,a.createExpression=cN,a.createLayout=j,a.createStyleLayer=function(a){return"custom"===a.type?new kK(a):new kN[a.type](a)},a.cross=bB,a.degToRad=bI,a.div=function(a,b,c){return a[0]=b[0]/c[0],a[1]=b[1]/c[1],a[2]=b[2]/c[2],a},a.dot=bA,a.ease=bL,a.easeCubicInOut=bK,a.emitValidationErrors=c_,a.endsWith=bV,a.enforceCacheSizeLimit=function(a){fe(),fa&&fa.then(b=>{b.keys().then(d=>{for(let c=0;cb&&(e+=(c[a]-b)*(c[a]-b)),d[a]Math.abs(a.parallels[0]+a.parallels[1])){let c=function(b){const a=Math.max(.01,Math.cos(b*aP)),c=1/(2*Math.max(Math.PI*a,1/a));return{wrap:!0,supportsWorldCopies:!0,unsupportedLayers:["custom",],project(b,d){const e=b*aP*a,f=Math.sin(d*aP)/a;return{x:e*c+.5,y:-f*c+.5,z:0}},unproject(b,d){const e=-(d-.5)/c,f=bM((b-.5)/c*eK/a,-180,180),g=Math.asin(bM(e*a,-1,1)),h=bM(g*eK,-85.051129,85.051129);return new dy(f,h)}}}(a.parallels[0]);if("lambertConformalConic"===a.name){const{project:d,unproject:e}=lv.mercator;c={wrap:!0,supportsWorldCopies:!0,project:d,unproject:e}}return bR({},b,a,c)}return bR({},b,a)}(a,b):a},a.getRTLTextPluginStatus=c3,a.getReferrer=b6,a.getTilePoint=function(a,{x:b,y:c},d=0){return new aF(((b-d)*a.scale-a.x)*8192,(c*a.scale-a.y)*8192)},a.getTileVec3=function(a,b,c=0){return Q(((b.x-c)*a.scale-a.x)*8192,(b.y*a.scale-a.y)*8192,h8(b.z,b.y))},a.getVideo=function(c,e){const a=s.document.createElement("video");a.muted=!0,a.onloadstart=function(){e(null,a)};for(let b=0;b0&&(a=1/Math.sqrt(a)),b[0]=d*a,b[1]=e*a,b[2]=f*a,b[3]=g*a,b},a.number=aY,a.ortho=function(a,b,c,d,e,f,g){var h=1/(b-c),i=1/(d-e),j=1/(f-g);return a[0]=-2*h,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=-2*i,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=2*j,a[11]=0,a[12]=(b+c)*h,a[13]=(e+d)*i,a[14]=(g+f)*j,a[15]=1,a},a.pbf=d2,a.perspective=function(a,f,g,c,b){var d,e=1/Math.tan(f/2);return a[0]=e/g,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=e,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[11]=-1,a[12]=0,a[13]=0,a[15]=0,null!=b&&b!==1/0?(a[10]=(b+c)*(d=1/(c-b)),a[14]=2*b*c*d):(a[10]=-1,a[14]=-2*c),a},a.pick=function(c,d){const e={};for(let a=0;athis._layers[a.id]),e=g[0];if("none"===e.visibility)continue;const h=e.source||"";let c=this.familiesBySource[h];c||(c=this.familiesBySource[h]={});const i=e.sourceLayer||"_geojsonTileLayer";let f=c[i];f||(f=c[i]=[]),f.push(g)}}}const{ImageBitmap:n}=a.window;class o{loadTile(d,e){const{uid:f,encoding:g,rawImageData:b,padding:c,buildQuadTree:h}=d,i=n&&b instanceof n?this.getImageData(b,c):b;e(null,new a.DEMData(f,i,g,c<1,h))}getImageData(b,c){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(b.width,b.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d")),this.offscreenCanvas.width=b.width,this.offscreenCanvas.height=b.height,this.offscreenCanvasContext.drawImage(b,0,0,b.width,b.height);const d=this.offscreenCanvasContext.getImageData(-c,-c,b.width+2*c,b.height+2*c);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),new a.RGBAImage({width:d.width,height:d.height},d.data)}}var f,p=function e(b,c){var a,d=b&&b.type;if("FeatureCollection"===d)for(a=0;a=Math.abs(d)?b-f+d:d-f+b,b=f}b+g>=0!= !!i&&a.reverse()}const s=a.vectorTile.VectorTileFeature.prototype.toGeoJSON;class t{constructor(b){this._feature=b,this.extent=a.EXTENT,this.type=b.type,this.properties=b.tags,"id"in b&&!isNaN(b.id)&&(this.id=parseInt(b.id,10))}loadGeometry(){if(1===this._feature.type){const b=[];for(const c of this._feature.geometry)b.push([new a.pointGeometry(c[0],c[1]),]);return b}{const d=[];for(const g of this._feature.geometry){const e=[];for(const f of g)e.push(new a.pointGeometry(f[0],f[1]));d.push(e)}return d}}toGeoJSON(a,b,c){return s.call(this,a,b,c)}}class u{constructor(b){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=a.EXTENT,this.length=b.length,this._features=b}feature(a){return new t(this._features[a])}}var g=a.vectorTile.VectorTileFeature,h=i;function i(a,b){this.options=b||{},this.features=a,this.length=a.length}function b(a,b){this.id="number"==typeof a.id?a.id:void 0,this.type=a.type,this.rawGeometry=1===a.type?[a.geometry]:a.geometry,this.properties=a.tags,this.extent=b||4096}i.prototype.feature=function(a){return new b(this.features[a],this.options.extent)},b.prototype.loadGeometry=function(){var e=this.rawGeometry;this.geometry=[];for(var c=0;c>31}function A(f,a){for(var g=f.loadGeometry(),d=f.type,h=0,i=0,n=g.length,e=0;e>1;D(c,d,g,a,b,f%2),C(c,d,e,a,g-1,f+1),C(c,d,e,g+1,b,f+1)}function D(g,a,e,b,d,h){for(;d>b;){if(d-b>600){const f=d-b+1,l=e-b+1,m=Math.log(f),j=.5*Math.exp(2*m/3),n=.5*Math.sqrt(m*j*(f-j)/f)*(l-f/2<0?-1:1);D(g,a,e,Math.max(b,Math.floor(e-l*j/f+n)),Math.min(d,Math.floor(e+(f-l)*j/f+n)),h)}const k=a[2*e+h];let i=b,c=d;for(E(g,a,b,e),a[2*d+h]>k&&E(g,a,b,d);ik;)c--}a[2*b+h]===k?E(g,a,b,c):E(g,a,++c,d),c<=e&&(b=c+1),e<=c&&(d=c-1)}}function E(d,c,a,b){F(d,a,b),F(c,2*a,2*b),F(c,2*a+1,2*b+1)}function F(a,b,c){const d=a[b];a[b]=a[c],a[c]=d}function G(c,d,e,f){const a=c-e,b=d-f;return a*a+b*b}c.fromVectorTileJs=j,c.fromGeojsonVt=function(d,b){b=b||{};var c={};for(var a in d)c[a]=new h(d[a].features,b),c[a].name=a,c[a].version=b.version,c[a].extent=b.extent;return j({layers:c})},c.GeoJSONWrapper=h;class H{constructor(b,f=a=>a[0],g=a=>a[1],e=64,h=Float64Array){this.nodeSize=e,this.points=b;const i=b.length<65536?Uint16Array:Uint32Array,c=this.ids=new i(b.length),d=this.coords=new h(2*b.length);for(let a=0;a=j&&b<=l&&c>=k&&c<=m&&n.push(i[d]);continue}const e=Math.floor((h+g)/2);b=f[2*e],c=f[2*e+1],b>=j&&b<=l&&c>=k&&c<=m&&n.push(i[e]);const p=(o+1)%2;(0===o?j<=b:k<=c)&&(a.push(h),a.push(e-1),a.push(p)),(0===o?l>=b:m>=c)&&(a.push(e+1),a.push(g),a.push(p))}return n}(this.ids,this.coords,a,b,c,d,this.nodeSize)}within(a,b,c){return function(j,e,f,g,b,q){const a=[0,j.length-1,0],k=[],o=b*b;for(;a.length;){const l=a.pop(),h=a.pop(),i=a.pop();if(h-i<=q){for(let c=i;c<=h;c++)G(e[2*c],e[2*c+1],f,g)<=o&&k.push(j[c]);continue}const d=Math.floor((i+h)/2),m=e[2*d],n=e[2*d+1];G(m,n,f,g)<=o&&k.push(j[d]);const p=(l+1)%2;(0===l?f-b<=m:g-b<=n)&&(a.push(i),a.push(d-1),a.push(p)),(0===l?f+b>=m:g+b>=n)&&(a.push(d+1),a.push(h),a.push(p))}return k}(this.ids,this.coords,a,b,c,this.nodeSize)}}const I=Math.fround||(f=new Float32Array(1),a=>(f[0]=+a,f[0]));class J{constructor(a){this.options=R(Object.create({minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:a=>a}),a),this.trees=new Array(this.options.maxZoom+1)}load(b){const{log:c,minZoom:i,maxZoom:f,nodeSize:g}=this.options;c&&console.time("total time");const h=`prepare ${b.length} points`;c&&console.time(h),this.points=b;let a=[];for(let d=0;d=i;e--){const j=+Date.now();a=this._cluster(a,e),this.trees[e]=new H(a,S,T,g,Float32Array),c&&console.log("z%d: %d clusters in %dms",e,a.length,+Date.now()-j)}return c&&console.timeEnd("total time"),this}getClusters(a,d){let b=((a[0]+180)%360+360)%360-180;const e=Math.max(-90,Math.min(90,a[1]));let c=180===a[2]?180:((a[2]+180)%360+360)%360-180;const f=Math.max(-90,Math.min(90,a[3]));if(a[2]-a[0]>=360)b=-180,c=180;else if(b>c){const j=this.getClusters([b,e,180,f],d),k=this.getClusters([-180,e,c,f],d);return j.concat(k)}const h=this.trees[this._limitZoom(d)],l=h.range(O(b),P(f),O(c),P(e)),i=[];for(const m of l){const g=h.points[m];i.push(g.numPoints?M(g):this.points[g.index])}return i}getChildren(c){const h=this._getOriginId(c),g=this._getOriginZoom(c),d="No cluster with the specified id.",a=this.trees[g];if(!a)throw new Error(d);const e=a.points[h];if(!e)throw new Error(d);const i=this.options.radius/(this.options.extent*Math.pow(2,g-1)),j=a.within(e.x,e.y,i),f=[];for(const k of j){const b=a.points[k];b.parentId===c&&f.push(b.numPoints?M(b):this.points[b.index])}if(0===f.length)throw new Error(d);return f}getLeaves(d,a,b){const c=[];return this._appendLeaves(c,d,a=a||10,b=b||0,0),c}getTile(i,d,e){const b=this.trees[this._limitZoom(i)],a=Math.pow(2,i),{extent:j,radius:k}=this.options,c=k/j,g=(e-c)/a,h=(e+1+c)/a,f={features:[]};return this._addTileFeatures(b.range((d-c)/a,g,(d+1+c)/a,h),b.points,d,e,a,f),0===d&&this._addTileFeatures(b.range(1-c/a,g,1,h),b.points,a,e,a,f),d===a-1&&this._addTileFeatures(b.range(0,g,c/a,h),b.points,-1,e,a,f),f.features.length?f:null}getClusterExpansionZoom(a){let b=this._getOriginZoom(a)-1;for(;b<=this.options.maxZoom;){const c=this.getChildren(a);if(b++,1!==c.length)break;a=c[0].properties.cluster_id}return b}_appendLeaves(c,g,e,d,a){const h=this.getChildren(g);for(const f of h){const b=f.properties;if(b&&b.cluster?a+b.point_count<=d?a+=b.point_count:a=this._appendLeaves(c,b.cluster_id,e,d,a):ab&&(c+=o.numPoints||1)}if(c>e&&c>=u){let p=a.x*e,q=a.y*e,i=j&&e>1?this._map(a,!0):null;const l=(g<<5)+(b+1)+this.points.length;for(const x of k){const d=h.points[x];if(d.zoom<=b)continue;d.zoom=b;const r=d.numPoints||1;p+=d.x*r,q+=d.y*r,d.parentId=l,j&&(i||(i=this._map(a,!0)),j(i,this._map(d)))}a.parentId=l,f.push(K(p/c,q/c,l,c,i))}else if(f.push(a),c>1)for(const y of k){const m=h.points[y];m.zoom<=b||(m.zoom=b,f.push(m))}}return f}_getOriginId(a){return a-this.points.length>>5}_getOriginZoom(a){return(a-this.points.length)%32}_map(a,c){if(a.numPoints)return c?R({},a.properties):a.properties;const d=this.points[a.index].properties,b=this.options.map(d);return c&&b===d?R({},b):b}}function K(a,b,c,d,e){return{x:I(a),y:I(b),zoom:1/0,id:c,parentId:-1,numPoints:d,properties:e}}function L(a,b){const[c,d]=a.geometry.coordinates;return{x:I(O(c)),y:I(P(d)),zoom:1/0,index:b,parentId:-1}}function M(a){return{type:"Feature",id:a.id,properties:N(a),geometry:{type:"Point",coordinates:[360*(a.x-.5),Q(a.y),]}}}function N(b){const a=b.numPoints,c=a>=1e4?`${Math.round(a/1e3)}k`:a>=1e3?Math.round(a/100)/10+"k":a;return R(R({},b.properties),{cluster:!0,cluster_id:b.id,point_count:a,point_count_abbreviated:c})}function O(a){return a/360+.5}function P(c){const b=Math.sin(c*Math.PI/180),a=.5-.25*Math.log((1+b)/(1-b))/Math.PI;return a<0?0:a>1?1:a}function Q(a){return 360*Math.atan(Math.exp((180-360*a)*Math.PI/180))/Math.PI-90}function R(a,b){for(const c in b)a[c]=b[c];return a}function S(a){return a.x}function T(a){return a.y}function U(a,b,c,g){for(var d,f=g,k=c-b>>1,i=c-b,l=a[b],m=a[b+1],n=a[c],o=a[c+1],e=b+3;ef)d=e,f=h;else if(h===f){var j=Math.abs(e-k);jg&&(d-b>3&&U(a,b,d,g),a[d+2]=f,c-d>3&&U(a,d,c,g))}function V(f,g,c,d,h,i){var a=h-c,b=i-d;if(0!==a||0!==b){var e=((f-c)*a+(g-d)*b)/(a*a+b*b);e>1?(c=h,d=i):e>0&&(c+=a*e,d+=b*e)}return(a=f-c)*a+(b=g-d)*b}function W(a,c,d,e){var b={id:void 0===a?null:a,type:c,geometry:d,tags:e,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(d){var b=d.geometry,c=d.type;if("Point"===c||"MultiPoint"===c||"LineString"===c)X(d,b);else if("Polygon"===c||"MultiLineString"===c)for(var a=0;a0&&(h+=k?(f*d-c*g)/2:Math.sqrt(Math.pow(c-f,2)+Math.pow(d-g,2))),f=c,g=d}var i=a.length-3;a[2]=1,U(a,0,i,j),a[i+2]=1,a.size=Math.abs(h),a.start=0,a.end=a.size}function _(b,d,e,f){for(var a=0;a1?1:a}function ac(j,m,e,d,f,n,o,p){if(d/=m,n>=(e/=m)&&o=d)return null;for(var i=[],k=0;k=e&&r=d)){var b=[];if("Point"===a||"MultiPoint"===a)ad(h,b,e,d,f);else if("LineString"===a)ae(h,b,e,d,f,!1,p.lineMetrics);else if("MultiLineString"===a)ag(h,b,e,d,f,!1);else if("Polygon"===a)ag(h,b,e,d,f,!0);else if("MultiPolygon"===a)for(var g=0;g=e&&d<=f&&(c.push(b[a]),c.push(b[a+1]),c.push(b[a+2]))}}function ae(b,u,e,f,o,v,m){for(var n,g,a=af(b),p=0===o?ai:aj,q=b.start,h=0;he&&(g=p(a,c,d,j,k,e),m&&(a.start=q+n*g)):l>f?r=e&&(g=p(a,c,d,j,k,e),t=!0),r>f&&l<=f&&(g=p(a,c,d,j,k,f),t=!0),!v&&t&&(m&&(a.end=q+n*g),u.push(a),a=af(b)),m&&(q+=n)}var i=b.length-3;c=b[i],d=b[i+1],s=b[i+2],(l=0===o?c:d)>=e&&l<=f&&ah(a,c,d,s),i=a.length-3,v&&i>=3&&(a[i]!==a[0]||a[i+1]!==a[1])&&ah(a,a[0],a[1],a[2]),a.length&&u.push(a)}function af(b){var a=[];return a.size=b.size,a.start=b.start,a.end=b.end,a}function ag(b,c,d,e,f,g){for(var a=0;aa.maxX&&(a.maxX=h),i>a.maxY&&(a.maxY=i)}return a}function ap(f,d,h,m){var b=d.geometry,c=d.type,e=[];if("Point"===c||"MultiPoint"===c)for(var a=0;a0&&a.size<(f?g:b))e.numPoints+=a.length/3;else{for(var d=[],c=0;cg)&&(e.numSimplified++,d.push(a[c]),d.push(a[c+1])),e.numPoints++;f&&function(b,f){for(var e=0,a=0,c=b.length,d=c-2;a0===f)for(a=0,c=b.length;a24)throw new Error("maxZoom should be in the 0-24 range");if(a.promoteId&&a.generateId)throw new Error("promoteId and generateId cannot be used together.");var d,e,b,c,f,g,h=function(a,d){var c=[];if("FeatureCollection"===a.type)for(var b=0;b1&&console.time("creation"),a=this.tiles[u]=ao(g,c,d,b,e),this.tileCoords.push({z:c,x:d,y:b}),j)){j>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",c,d,b,a.numFeatures,a.numPoints,a.numSimplified),console.timeEnd("creation"));var v="z"+c;this.stats[v]=(this.stats[v]||0)+1,this.total++}if(a.source=g,m){if(c===e.maxZoom||c===m)continue;var w=1<1&&console.time("clipping");var n,o,p,q,k,l,i=.5*e.buffer/e.extent,r=.5-i,s=.5+i,t=1+i;n=o=p=q=null,k=ac(g,h,d-i,d+s,0,a.minX,a.maxX,e),l=ac(g,h,d+r,d+t,0,a.minX,a.maxX,e),g=null,k&&(n=ac(k,h,b-i,b+s,1,a.minY,a.maxY,e),o=ac(k,h,b+r,b+t,1,a.minY,a.maxY,e),k=null),l&&(p=ac(l,h,b-i,b+s,1,a.minY,a.maxY,e),q=ac(l,h,b+r,b+t,1,a.minY,a.maxY,e),l=null),j>1&&console.timeEnd("clipping"),f.push(n||[],c+1,2*d,2*b),f.push(o||[],c+1,2*d,2*b+1),f.push(p||[],c+1,2*d+1,2*b),f.push(q||[],c+1,2*d+1,2*b+1)}}},d.prototype.getTile=function(a,b,g){var k=this.options,l=k.extent,h=k.debug;if(a<0||a>24)return null;var j=1<1&&console.log("drilling down to z%d-%d-%d",a,b,g);for(var c,d=a,e=b,f=g;!c&&d>0;)d--,e=Math.floor(e/2),f=Math.floor(f/2),c=this.tiles[ar(d,e,f)];return c&&c.source?(h>1&&console.log("found parent tile z%d-%d-%d",d,e,f),h>1&&console.time("drilling down"),this.splitTile(c.source,d,e,f,a,b,g),h>1&&console.timeEnd("drilling down"),this.tiles[i]?am(this.tiles[i],l):null):null};class as extends a.VectorTileWorkerSource{constructor(b,d,e,f,a){super(b,d,e,f,function(g,b){const d=g.tileID.canonical;if(!this._geoJSONIndex)return b(null,null);const e=this._geoJSONIndex.getTile(d.z,d.x,d.y);if(!e)return b(null,null);const f=new u(e.features);let a=c(f);0===a.byteOffset&&a.byteLength===a.buffer.byteLength||(a=new Uint8Array(a)),b(null,{vectorTile:f,rawData:a.buffer})}),a&&(this.loadGeoJSON=a)}loadData(b,e){const c=b&&b.request,f=c&&c.collectResourceTiming;this.loadGeoJSON(b,(i,g)=>{if(i||!g)return e(i);if("object"!=typeof g)return e(new Error(`Input data given to '${b.source}' is not a valid GeoJSON object.`));{p(g,!0);try{var j,k;if(b.filter){const l=a.createExpression(b.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===l.result)throw new Error(l.value.map(a=>`${a.key}: ${a.message}`).join(", "));const n=g.features.filter(a=>l.value.evaluate({zoom:0},a));g={type:"FeatureCollection",features:n}}this._geoJSONIndex=b.cluster?new J(function({superclusterOptions:b,clusterProperties:d}){if(!d||!b)return b;const f={},g={},l={accumulated:null,zoom:0},m={properties:null},h=Object.keys(d);for(const c of h){const[e,i]=d[c],j=a.createExpression(i),k=a.createExpression("string"==typeof e?[e,["accumulated",],["get",c,],]:e);f[c]=j.value,g[c]=k.value}return b.map=c=>{m.properties=c;const a={};for(const b of h)a[b]=f[b].evaluate(l,m);return a},b.reduce=(b,c)=>{for(const a of(m.properties=c,h))l.accumulated=b[a],b[a]=g[a].evaluate(l,m)},b}(b)).load(g.features):(j=g,k=b.geojsonVtOptions,new d(j,k))}catch(o){return e(o)}this.loaded={};const h={};if(f){const m=a.getPerformanceMeasurement(c);m&&(h.resourceTiming={},h.resourceTiming[b.source]=JSON.parse(JSON.stringify(m)))}e(null,h)}})}reloadTile(a,b){const c=this.loaded;return c&&c[a.uid]?super.reloadTile(a,b):this.loadTile(a,b)}loadGeoJSON(b,c){if(b.request)a.getJSON(b.request,c);else{if("string"!=typeof b.data)return c(new Error(`Input data given to '${b.source}' is not a valid GeoJSON object.`));try{return c(null,JSON.parse(b.data))}catch(d){return c(new Error(`Input data given to '${b.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(b,a){try{a(null,this._geoJSONIndex.getClusterExpansionZoom(b.clusterId))}catch(c){a(c)}}getClusterChildren(b,a){try{a(null,this._geoJSONIndex.getChildren(b.clusterId))}catch(c){a(c)}}getClusterLeaves(a,b){try{b(null,this._geoJSONIndex.getLeaves(a.clusterId,a.limit,a.offset))}catch(c){b(c)}}}class e{constructor(b){this.self=b,this.actor=new a.Actor(b,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=a.getProjection({name:"mercator"}),this.workerSourceTypes={vector:a.VectorTileWorkerSource,geojson:as},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(a,b)=>{if(this.workerSourceTypes[a])throw new Error(`Worker source with name "${a}" already registered.`);this.workerSourceTypes[a]=b},this.self.registerRTLTextPlugin=b=>{if(a.plugin.isParsed())throw new Error("RTL text plugin already registered.");a.plugin.applyArabicShaping=b.applyArabicShaping,a.plugin.processBidirectionalText=b.processBidirectionalText,a.plugin.processStyledBidirectionalText=b.processStyledBidirectionalText}}clearCaches(a,c,b){delete this.layerIndexes[a],delete this.availableImages[a],delete this.workerSources[a],delete this.demWorkerSources[a],b()}checkIfReady(b,c,a){a()}setReferrer(b,a){this.referrer=a}spriteLoaded(c,e){for(const f in this.isSpriteLoaded[c]=e,this.workerSources[c]){const b=this.workerSources[c][f];for(const d in b)b[d]instanceof a.VectorTileWorkerSource&&(b[d].isSpriteLoaded=e,b[d].fire(new a.Event("isSpriteLoaded")))}}setImages(a,b,d){for(const e in this.availableImages[a]=b,this.workerSources[a]){const c=this.workerSources[a][e];for(const f in c)c[f].availableImages=b}d()}enableTerrain(c,a,b){this.terrain=a,b()}setProjection(b,c){this.projections[b]=a.getProjection(c)}setLayers(a,b,c){this.getLayerIndex(a).replace(b),c()}updateLayers(b,a,c){this.getLayerIndex(b).update(a.layers,a.removedIds),c()}loadTile(c,b,e){const d=this.enableTerrain?a.extend({enableTerrain:this.terrain},b):b;d.projection=this.projections[c]||this.defaultProjection,this.getWorkerSource(c,b.type,b.source).loadTile(d,e)}loadDEMTile(c,b,d){const e=this.enableTerrain?a.extend({buildQuadTree:this.terrain},b):b;this.getDEMWorkerSource(c,b.source).loadTile(e,d)}reloadTile(c,b,e){const d=this.enableTerrain?a.extend({enableTerrain:this.terrain},b):b;d.projection=this.projections[c]||this.defaultProjection,this.getWorkerSource(c,b.type,b.source).reloadTile(d,e)}abortTile(b,a,c){this.getWorkerSource(b,a.type,a.source).abortTile(a,c)}removeTile(b,a,c){this.getWorkerSource(b,a.type,a.source).removeTile(a,c)}removeSource(b,a,c){if(!this.workerSources[b]||!this.workerSources[b][a.type]||!this.workerSources[b][a.type][a.source])return;const d=this.workerSources[b][a.type][a.source];delete this.workerSources[b][a.type][a.source],void 0!==d.removeSource?d.removeSource(a,c):c()}loadWorkerSource(d,b,a){try{this.self.importScripts(b.url),a()}catch(c){a(c.toString())}}syncRTLPluginState(g,e,c){try{a.plugin.setState(e);const b=a.plugin.getPluginURL();if(a.plugin.isLoaded()&&!a.plugin.isParsed()&&null!=b){this.self.importScripts(b);const d=a.plugin.isParsed();c(d?void 0:new Error(`RTL Text Plugin failed to import scripts from ${b}`),d)}}catch(f){c(f.toString())}}getAvailableImages(b){let a=this.availableImages[b];return a||(a=[]),a}getLayerIndex(b){let a=this.layerIndexes[b];return a||(a=this.layerIndexes[b]=new m),a}getWorkerSource(a,b,c){return this.workerSources[a]||(this.workerSources[a]={}),this.workerSources[a][b]||(this.workerSources[a][b]={}),this.workerSources[a][b][c]||(this.workerSources[a][b][c]=new this.workerSourceTypes[b]({send:(b,c,d,g,e,f)=>{this.actor.send(b,c,d,a,e,f)},scheduler:this.actor.scheduler},this.getLayerIndex(a),this.getAvailableImages(a),this.isSpriteLoaded[a])),this.workerSources[a][b][c]}getDEMWorkerSource(a,b){return this.demWorkerSources[a]||(this.demWorkerSources[a]={}),this.demWorkerSources[a][b]||(this.demWorkerSources[a][b]=new o),this.demWorkerSources[a][b]}enforceCacheSizeLimit(c,b){a.enforceCacheSizeLimit(b)}getWorkerPerformanceMetrics(b,c,a){a(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new e(self)),e}),a(["./shared"],function(a){var l=m;function m(c){var b,a;return b=c,"undefined"!=typeof window&&"undefined"!=typeof document&& !!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 a,b,d=new Blob([""],{type:"text/javascript"}),c=URL.createObjectURL(d);try{b=new Worker(c),a=!0}catch(e){a=!1}return b&&b.terminate(),URL.revokeObjectURL(c),a}()&&"Uint8ClampedArray"in window&& !!ArrayBuffer.isView&& !!function(){var a=document.createElement("canvas");a.width=a.height=1;var b=a.getContext("2d");if(!b)return!1;var c=b.getImageData(0,0,1,1);return c&&c.width===a.width}()&&(void 0===B[a=b&&b.failIfMajorPerformanceCaveat]&&(B[a]=function(f){var e,c,d,b,a=(e=f,c=document.createElement("canvas"),(d=Object.create(m.webGLContextAttributes)).failIfMajorPerformanceCaveat=e,c.getContext("webgl",d)||c.getContext("experimental-webgl",d));if(!a)return!1;try{b=a.createShader(a.VERTEX_SHADER)}catch(g){return!1}return!(!b||a.isContextLost())&&(a.shaderSource(b,"void main() {}"),a.compileShader(b),!0===a.getShaderParameter(b,a.COMPILE_STATUS))}(a)),!!B[a]&&!document.documentMode)}var B={};function C(b,c){var d=c[0],e=c[1],f=c[2],g=c[3],a=d*g-f*e;return a?(b[0]=g*(a=1/a),b[1]=-e*a,b[2]=-f*a,b[3]=d*a,b):null}function D(a,b){if(Array.isArray(a)){if(!Array.isArray(b)||a.length!==b.length)return!1;for(let c=0;c{a.window.removeEventListener("click",G,!0)},0)},b.mousePos=function(a,b){const c=a.getBoundingClientRect();return H(a,c,b)},b.touchPos=function(b,c){const e=b.getBoundingClientRect(),d=[];for(let a=0;a=0?0:b.button};class J extends a.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new a.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(a){if(this.loaded!==a&&(this.loaded=a,a)){for(const{ids:b,callback:c}of this.requestors)this._notify(b,c);this.requestors=[]}}getImage(a){return this.images[a]}addImage(a,b){this._validate(a,b)&&(this.images[a]=b)}_validate(d,b){let c=!0;return this._validateStretch(b.stretchX,b.data&&b.data.width)||(this.fire(new a.ErrorEvent(new Error(`Image "${d}" has invalid "stretchX" value`))),c=!1),this._validateStretch(b.stretchY,b.data&&b.data.height)||(this.fire(new a.ErrorEvent(new Error(`Image "${d}" has invalid "stretchY" value`))),c=!1),this._validateContent(b.content,b)||(this.fire(new a.ErrorEvent(new Error(`Image "${d}" has invalid "content" value`))),c=!1),c}_validateStretch(b,d){if(!b)return!0;let c=0;for(const a of b){if(a[0]{this.ready=!0})}broadcast(c,d,b){a.asyncAll(this.actors,(a,b)=>{a.send(c,d,b)},b=b||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(a=>{a.remove()}),this.actors=[],this.workerPool.release(this.id)}}function V(b,c,d){return c*(a.EXTENT/(b.tileSize*Math.pow(2,d-b.tileID.overscaledZ)))}n.Actor=a.Actor;class W{constructor(b,c,d){this.context=b;const a=b.gl;this.buffer=a.createBuffer(),this.dynamicDraw=Boolean(d),this.context.unbindVAO(),b.bindElementBuffer.set(this.buffer),a.bufferData(a.ELEMENT_ARRAY_BUFFER,c.arrayBuffer,this.dynamicDraw?a.DYNAMIC_DRAW:a.STATIC_DRAW),this.dynamicDraw||delete c.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(b){const a=this.context.gl;this.context.unbindVAO(),this.bind(),a.bufferSubData(a.ELEMENT_ARRAY_BUFFER,0,b.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const X={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Y{constructor(c,b,d,e){this.length=b.length,this.attributes=d,this.itemSize=b.bytesPerElement,this.dynamicDraw=e,this.context=c;const a=c.gl;this.buffer=a.createBuffer(),c.bindVertexBuffer.set(this.buffer),a.bufferData(a.ARRAY_BUFFER,b.arrayBuffer,this.dynamicDraw?a.DYNAMIC_DRAW:a.STATIC_DRAW),this.dynamicDraw||delete b.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(b){const a=this.context.gl;this.bind(),a.bufferSubData(a.ARRAY_BUFFER,0,b.arrayBuffer)}enableAttributes(c,d){for(let a=0;ad.pointCoordinate3D(a)),this.cameraGeometry=this.bufferedCameraGeometry(0)}static createFromScreenPoints(b,c){let d,e;if(b instanceof a.pointGeometry||"number"==typeof b[0]){const h=a.pointGeometry.convert(b);d=[a.pointGeometry.convert(b)],e=c.isPointAboveHorizon(h)}else{const f=a.pointGeometry.convert(b[0]),g=a.pointGeometry.convert(b[1]);d=[f,g],e=a.polygonizeBounds(f,g).every(a=>c.isPointAboveHorizon(a))}return new _(d,c.getCameraPoint(),e,c)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(b){return a.polygonizeBounds(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],b)}bufferedCameraGeometry(e){const d=this.screenBounds[0],b=1===this.screenBounds.length?this.screenBounds[0].add(new a.pointGeometry(1,1)):this.screenBounds[1],c=a.polygonizeBounds(d,b,0,!1);return this.cameraPoint.y>b.y&&(this.cameraPoint.x>d.x&&this.cameraPoint.x=b.x?c[2]=this.cameraPoint:this.cameraPoint.x<=d.x&&(c[3]=this.cameraPoint)),a.bufferConvexPolygon(c,e)}containsTile(c,d,h){var b;const f=c.queryPadding+1,i=c.tileID.wrap,e=h?this._bufferedCameraMercator(f,d).map(b=>a.getTilePoint(c.tileTransform,b,i)):this._bufferedScreenMercator(f,d).map(b=>a.getTilePoint(c.tileTransform,b,i)),g=this.screenGeometryMercator.map(b=>a.getTileVec3(c.tileTransform,b,i)),j=g.map(b=>new a.pointGeometry(b[0],b[1])),k=d.getFreeCameraOptions().position||new a.MercatorCoordinate(0,0,0),n=a.getTileVec3(c.tileTransform,k,i),l=g.map(c=>{const b=a.sub(c,c,n);return a.normalize(b,b),new a.Ray(n,b)}),m=V(c,1,d.zoom);if(a.polygonIntersectsBox(e,0,0,a.EXTENT,a.EXTENT))return{queryGeometry:this,tilespaceGeometry:j,tilespaceRays:l,bufferedTilespaceGeometry:e,bufferedTilespaceBounds:((b=a.getBounds(e)).min.x=a.clamp(b.min.x,0,a.EXTENT),b.min.y=a.clamp(b.min.y,0,a.EXTENT),b.max.x=a.clamp(b.max.x,0,a.EXTENT),b.max.y=a.clamp(b.max.y,0,a.EXTENT),b),tile:c,tileID:c.tileID,pixelToTileUnitsFactor:m}}_bufferedScreenMercator(b,d){const a=aa(b);if(this._screenRaycastCache[a])return this._screenRaycastCache[a];{const c=this.bufferedScreenGeometry(b).map(a=>d.pointCoordinate3D(a));return this._screenRaycastCache[a]=c,c}}_bufferedCameraMercator(b,d){const a=aa(b);if(this._cameraRaycastCache[a])return this._cameraRaycastCache[a];{const c=this.bufferedCameraGeometry(b).map(a=>d.pointCoordinate3D(a));return this._cameraRaycastCache[a]=c,c}}}function aa(a){return 100*a|0}function ab(b,c,e){const d=function(g,f){if(g)return e(g);if(f){const d=a.pick(a.extend(f,b),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding",]);f.vector_layers&&(d.vectorLayers=f.vector_layers,d.vectorLayerIds=d.vectorLayers.map(a=>a.id)),d.tiles=c.canonicalizeTileset(d,b.url),e(null,d)}};return b.url?a.getJSON(c.transformRequest(c.normalizeSourceURL(b.url),a.ResourceType.Source),d):a.exported.frame(()=>d(null,b))}class ac{constructor(b,c,d){this.bounds=a.LngLatBounds.convert(this.validateBounds(b)),this.minzoom=c||0,this.maxzoom=d||24}validateBounds(a){return Array.isArray(a)&&4===a.length?[Math.max(-180,a[0]),Math.max(-90,a[1]),Math.min(180,a[2]),Math.min(90,a[3]),]:[-180,-90,180,90]}contains(b){const c=Math.pow(2,b.z),d=Math.floor(a.mercatorXfromLng(this.bounds.getWest())*c),e=Math.floor(a.mercatorYfromLat(this.bounds.getNorth())*c),f=Math.ceil(a.mercatorXfromLng(this.bounds.getEast())*c),g=Math.ceil(a.mercatorYfromLat(this.bounds.getSouth())*c);return b.x>=d&&b.x=e&&b.y{this._tileJSONRequest=null,this._loaded=!0,c?this.fire(new a.ErrorEvent(c)):b&&(a.extend(this,b),b.bounds&&(this.tileBounds=new ac(b.bounds,this.minzoom,this.maxzoom)),a.postTurnstileEvent(b.tiles),this.fire(new a.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new a.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}onAdd(a){this.map=a,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return a.extend({},this._options)}hasTile(a){return!this.tileBounds||this.tileBounds.contains(a.canonical)}loadTile(b,e){const c=a.exported.devicePixelRatio>=2,d=this.map._requestManager.normalizeTileURL(b.tileID.canonical.url(this.tiles,this.scheme),c,this.tileSize);b.request=a.getImage(this.map._requestManager.transformRequest(d,a.ResourceType.Tile),(g,f,h,i)=>{if(delete b.request,b.aborted)b.state="unloaded",e(null);else if(g)b.state="errored",e(g);else if(f){this.map._refreshExpiredTiles&&b.setExpiryData({cacheControl:h,expires:i});const c=this.map.painter.context,d=c.gl;b.texture=this.map.painter.getTileTexture(f.width),b.texture?b.texture.update(f,{useMipmap:!0}):(b.texture=new a.Texture(c,f,d.RGBA,{useMipmap:!0}),b.texture.bind(d.LINEAR,d.CLAMP_TO_EDGE),c.extTextureFilterAnisotropic&&d.texParameterf(d.TEXTURE_2D,c.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,c.extTextureFilterAnisotropicMax)),b.state="loaded",a.cacheEntryPossiblyAdded(this.dispatcher),e(null)}})}abortTile(a,b){a.request&&(a.request.cancel(),delete a.request),b()}unloadTile(a,b){a.texture&&this.map.painter.saveTileTexture(a.texture),b()}hasTransition(){return!1}}let ad;function ae(e,f,g,h,i,j,k,l){const b=[e,g,i,f,h,j,1,1,1],c=[k,l,1],d=a.adjoint([],b),[m,n,o]=a.transformMat3(c,c,a.transpose(d,d));return a.multiply(b,[m,0,0,0,n,0,0,0,o],b)}class s extends a.Evented{constructor(b,a,c,d){super(),this.id=b,this.dispatcher=c,this.coordinates=a.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(d),this.options=a}load(b,c){this._loaded=!1,this.fire(new a.Event("dataloading",{dataType:"source"})),this.url=this.options.url,a.getImage(this.map._requestManager.transformRequest(this.url,a.ResourceType.Image),(d,e)=>{this._loaded=!0,d?this.fire(new a.ErrorEvent(d)):e&&(this.image=a.exported.getImageData(e),this.width=this.image.width,this.height=this.image.height,b&&(this.coordinates=b),c&&c(),this._finishLoading())})}loaded(){return this._loaded}updateImage(a){return this.image&&a.url&&(this.options.url=a.url,this.load(a.coordinates,()=>{this.texture=null})),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new a.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(a){this.map=a,this.load()}setCoordinates(b){this.coordinates=b,delete this._boundsArray;const c=b.map(a.MercatorCoordinate.fromLngLat);return this.tileID=function(i){let b=1/0,c=1/0,d=-1/0,e=-1/0;for(const f of i)b=Math.min(b,f.x),c=Math.min(c,f.y),d=Math.max(d,f.x),e=Math.max(e,f.y);const g=Math.max(0,Math.floor(-Math.log(Math.max(d-b,e-c))/Math.LN2)),h=Math.pow(2,g);return new a.CanonicalTileID(g,Math.floor((b+d)/2*h),Math.floor((c+e)/2*h))}(c),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new a.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){delete this._boundsArray}_makeBoundsArray(){const f=a.tileTransform(this.tileID,this.map.transform.projection),[b,c,d,e]=this.coordinates.map(b=>{const c=f.projection.project(b[0],b[1]);return a.getTilePoint(f,c)._round()});return this.perspectiveTransform=function(c,d,f,g,h,i,j,k,l,m){const e=ae(0,0,c,0,0,d,c,d),b=ae(f,g,h,i,j,k,l,m);return a.multiply(b,a.adjoint(e,e),b),[b[6]/b[8]*c/a.EXTENT,b[7]/b[8]*d/a.EXTENT,]}(this.width,this.height,b.x,b.y,c.x,c.y,e.x,e.y,d.x,d.y),this._boundsArray=new a.StructArrayLayout4i8,this._boundsArray.emplaceBack(b.x,b.y,0,0),this._boundsArray.emplaceBack(c.x,c.y,a.EXTENT,0),this._boundsArray.emplaceBack(e.x,e.y,0,a.EXTENT),this._boundsArray.emplaceBack(d.x,d.y,a.EXTENT,a.EXTENT),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const b=this.map.painter.context,c=b.gl;for(const e in this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=b.createVertexBuffer(this._boundsArray,a.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=a.SegmentVector.simpleSegment(0,0,4,2)),this.texture||(this.texture=new a.Texture(b,this.image,c.RGBA),this.texture.bind(c.LINEAR,c.CLAMP_TO_EDGE)),this.tiles){const d=this.tiles[e];"loaded"!==d.state&&(d.state="loaded",d.texture=this.texture)}}loadTile(a,b){this.tileID&&this.tileID.equals(a.tileID.canonical)?(this.tiles[String(a.tileID.wrap)]=a,a.buckets={},b(null)):(a.state="errored",b(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const af={vector:class extends a.Evented{constructor(c,b,d,e){if(super(),this.id=c,this.dispatcher=d,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,a.extend(this,a.pick(b,["url","scheme","tileSize","promoteId",])),this._options=a.extend({type:"vector"},b),this._collectResourceTiming=b.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(e),this._tileWorkers={},this._deduped=new a.DedupedRequest}load(){this._loaded=!1,this.fire(new a.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=ab(this._options,this.map._requestManager,(c,b)=>{this._tileJSONRequest=null,this._loaded=!0,c?this.fire(new a.ErrorEvent(c)):b&&(a.extend(this,b),b.bounds&&(this.tileBounds=new ac(b.bounds,this.minzoom,this.maxzoom)),a.postTurnstileEvent(b.tiles,this.map._requestManager._customAccessToken),this.fire(new a.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new a.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}hasTile(a){return!this.tileBounds||this.tileBounds.contains(a.canonical)}onAdd(a){this.map=a,this.load()}setSourceProperty(a){this._tileJSONRequest&&this._tileJSONRequest.cancel(),a();const b=this.map.style._getSourceCaches(this.id);for(const c of b)c.clearTiles();this.load()}setTiles(a){return this.setSourceProperty(()=>{this._options.tiles=a}),this}setUrl(a){return this.setSourceProperty(()=>{this.url=a,this._options.url=a}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return a.extend({},this._options)}loadTile(b,e){const d=this.map._requestManager.normalizeTileURL(b.tileID.canonical.url(this.tiles,this.scheme)),c={request:this.map._requestManager.transformRequest(d,a.ResourceType.Tile),data:void 0,uid:b.uid,tileID:b.tileID,tileZoom:b.tileZoom,zoom:b.tileID.overscaledZ,tileSize:this.tileSize*b.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:a.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:b.isSymbolTile};if(c.request.collectResourceTiming=this._collectResourceTiming,b.actor&&"expired"!==b.state)"loading"===b.state?b.reloadCallback=e:b.request=b.actor.send("reloadTile",c,g.bind(this));else if(b.actor=this._tileWorkers[d]=this._tileWorkers[d]||this.dispatcher.getActor(),this.dispatcher.ready)b.request=b.actor.send("loadTile",c,g.bind(this),void 0,!0);else{const f=a.loadVectorTile.call({deduped:this._deduped},c,(d,a)=>{d||!a?g.call(this,d):(c.data={cacheControl:a.cacheControl,expires:a.expires,rawData:a.rawData.slice(0)},b.actor&&b.actor.send("loadTile",c,g.bind(this),void 0,!0))},!0);b.request={cancel:f}}function g(d,c){return delete b.request,b.aborted?e(null):d&&404!==d.status?e(d):(c&&c.resourceTiming&&(b.resourceTiming=c.resourceTiming),this.map._refreshExpiredTiles&&c&&b.setExpiryData(c),b.loadVectorData(c,this.map.painter),a.cacheEntryPossiblyAdded(this.dispatcher),e(null),void(b.reloadCallback&&(this.loadTile(b,b.reloadCallback),b.reloadCallback=null)))}}abortTile(a){a.request&&(a.request.cancel(),delete a.request),a.actor&&a.actor.send("abortTile",{uid:a.uid,type:this.type,source:this.id})}unloadTile(a){a.unloadVectorData(),a.actor&&a.actor.send("removeTile",{uid:a.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}},raster:r,"raster-dem":class extends r{constructor(c,b,d,e){super(c,b,d,e),this.type="raster-dem",this.maxzoom=22,this._options=a.extend({type:"raster-dem"},b),this.encoding=b.encoding||"mapbox"}loadTile(b,d){const c=this.map._requestManager.normalizeTileURL(b.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function e(a,c){a&&(b.state="errored",d(a)),c&&(b.dem=c,b.dem.onDeserialize(),b.needsHillshadePrepare=!0,b.needsDEMTextureUpload=!0,b.state="loaded",d(null))}b.request=a.getImage(this.map._requestManager.transformRequest(c,a.ResourceType.Tile),(function(g,c,h,i){if(delete b.request,b.aborted)b.state="unloaded",d(null);else if(g)b.state="errored",d(g);else if(c){this.map._refreshExpiredTiles&&b.setExpiryData({cacheControl:h,expires:i});const j=a.window.ImageBitmap&&c instanceof a.window.ImageBitmap&&(null==ad&&(ad=a.window.OffscreenCanvas&&new a.window.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof a.window.createImageBitmap),ad),f=1-(c.width-a.prevPowerOfTwo(c.width))/2;f<1||b.neighboringTiles||(b.neighboringTiles=this._getNeighboringTiles(b.tileID));const k=j?c:a.exported.getImageData(c,f),l={uid:b.uid,coord:b.tileID,source:this.id,rawImageData:k,encoding:this.encoding,padding:f};b.actor&&"expired"!==b.state||(b.actor=this.dispatcher.getActor(),b.actor.send("loadDEMTile",l,e.bind(this),void 0,!0))}}).bind(this))}_getNeighboringTiles(c){const b=c.canonical,e=Math.pow(2,b.z),f=(b.x-1+e)%e,g=0===b.x?c.wrap-1:c.wrap,h=(b.x+1+e)%e,i=b.x+1===e?c.wrap+1:c.wrap,d={};return d[new a.OverscaledTileID(c.overscaledZ,g,b.z,f,b.y).key]={backfilled:!1},d[new a.OverscaledTileID(c.overscaledZ,i,b.z,h,b.y).key]={backfilled:!1},b.y>0&&(d[new a.OverscaledTileID(c.overscaledZ,g,b.z,f,b.y-1).key]={backfilled:!1},d[new a.OverscaledTileID(c.overscaledZ,c.wrap,b.z,b.x,b.y-1).key]={backfilled:!1},d[new a.OverscaledTileID(c.overscaledZ,i,b.z,h,b.y-1).key]={backfilled:!1}),b.y+1{if(this._loaded=!0,this._pendingLoad=null,c)this.fire(new a.ErrorEvent(c));else{const d={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&b&&b.resourceTiming&&b.resourceTiming[this.id]&&(d.resourceTiming=b.resourceTiming[this.id]),this.fire(new a.Event("data",d)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)})}loaded(){return this._loaded}loadTile(b,d){const c=b.actor?"reloadTile":"loadTile";b.actor=this.actor,b.request=this.actor.send(c,{type:this.type,uid:b.uid,tileID:b.tileID,tileZoom:b.tileZoom,zoom:b.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:a.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},(a,e)=>(delete b.request,b.unloadVectorData(),b.aborted?d(null):a?d(a):(b.loadVectorData(e,this.map.painter,"reloadTile"===c),d(null))),void 0,"loadTile"===c)}abortTile(a){a.request&&(a.request.cancel(),delete a.request),a.aborted=!0}unloadTile(a){a.unloadVectorData(),this.actor.send("removeTile",{uid:a.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return a.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends s{constructor(b,a,c,d){super(b,a,c,d),this.roundZoom=!0,this.type="video",this.options=a}load(){this._loaded=!1;const b=this.options;for(const c of(this.urls=[],b.urls))this.urls.push(this.map._requestManager.transformRequest(c,a.ResourceType.Source).url);a.getVideo(this.urls,(b,c)=>{this._loaded=!0,b?this.fire(new a.ErrorEvent(b)):c&&(this.video=c,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(c){if(this.video){const b=this.video.seekable;cb.end(0)?this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${b.start(0)} and ${b.end(0)}-second mark.`))):this.video.currentTime=c}}getVideo(){return this.video}onAdd(a){this.map||(this.map=a,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 c=this.map.painter.context,b=c.gl;for(const e in this.texture?this.video.paused||(this.texture.bind(b.LINEAR,b.CLAMP_TO_EDGE),b.texSubImage2D(b.TEXTURE_2D,0,0,0,b.RGBA,b.UNSIGNED_BYTE,this.video)):(this.texture=new a.Texture(c,this.video,b.RGBA),this.texture.bind(b.LINEAR,b.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=c.createVertexBuffer(this._boundsArray,a.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=a.SegmentVector.simpleSegment(0,0,4,2)),this.tiles){const d=this.tiles[e];"loaded"!==d.state&&(d.state="loaded",d.texture=this.texture)}}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:s,canvas:class extends s{constructor(c,b,d,e){super(c,b,d,e),b.coordinates?Array.isArray(b.coordinates)&&4===b.coordinates.length&&!b.coordinates.some(a=>!Array.isArray(a)||2!==a.length||a.some(a=>"number"!=typeof a))||this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${c}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${c}`,null,'missing required property "coordinates"'))),b.animate&&"boolean"!=typeof b.animate&&this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${c}`,null,'optional "animate" property must be a boolean value'))),b.canvas?"string"==typeof b.canvas||b.canvas instanceof a.window.HTMLCanvasElement||this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${c}`,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 a.ErrorEvent(new a.ValidationError(`sources.${c}`,null,'missing required property "canvas"'))),this.options=b,this.animate=void 0===b.animate||b.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof a.window.HTMLCanvasElement?this.options.canvas:a.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new a.ErrorEvent(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(a){this.map=a,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let b=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,b=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,b=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const c=this.map.painter.context,e=c.gl;for(const f in this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=c.createVertexBuffer(this._boundsArray,a.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=a.SegmentVector.simpleSegment(0,0,4,2)),this.texture?(b||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new a.Texture(c,this.canvas,e.RGBA,{premultiply:!0}),this.tiles){const d=this.tiles[f];"loaded"!==d.state&&(d.state="loaded",d.texture=this.texture)}}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const a of[this.canvas.width,this.canvas.height,])if(isNaN(a)||a<=0)return!0;return!1}}},ag=function(c,d,e,f){const b=new af[d.type](c,d,e,f);if(b.id!==c)throw new Error(`Expected Source id to be ${c} instead of ${b.id}`);return a.bindAll(["load","abort","unload","serialize","prepare",],b),b};function ah(c,d){const b=a.identity([]);return a.scale(b,b,[.5*c.width,-(.5*c.height),1,]),a.translate(b,b,[1,-1,0]),a.multiply$1(b,b,c.calculateProjMatrix(d.toUnwrapped()))}function ai(b,g,h,i,j,k,l,d=!1){const e=b.tilesIn(i,l,d);e.sort(ak);const f=[];for(const a of e)f.push({wrappedTileID:a.tile.tileID.wrapped().key,queryResults:a.tile.queryRenderedFeatures(g,h,b._state,a,j,k,ah(b.transform,a.tile.tileID),d)});const c=function(j){const b={},d={};for(const e of j){const f=e.queryResults,g=e.wrappedTileID,h=d[g]=d[g]||{};for(const a in f){const k=f[a],i=h[a]=h[a]||{},l=b[a]=b[a]||[];for(const c of k)i[c.featureIndex]||(i[c.featureIndex]=!0,l.push(c))}}return b}(f);for(const m in c)c[m].forEach(c=>{const a=c.feature,d=b.getFeatureState(a.layer["source-layer"],a.id);a.source=a.layer.source,a.layer["source-layer"]&&(a.sourceLayer=a.layer["source-layer"]),a.state=d});return c}function aj(g,h){const b=g.getRenderableIds().map(a=>g.getTileByID(a)),c=[],d={};for(let a=0;a{a.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[am]}numActive(){return Object.keys(this.active).length}}let an;function ao(){return an||(an=new e),an}function ap(c,e){const d={};for(const b in c)"ref"!==b&&(d[b]=c[b]);return a.refProperties.forEach(a=>{a in e&&(d[a]=e[a])}),d}function aq(a){a=a.slice();const d=Object.create(null);for(let c=0;c0?(e-g)/h:0;return this.points[f].mult(1-i).add(this.points[b].mult(i))}}class az{constructor(a,b,c){const e=this.boxCells=[],f=this.circleCells=[];this.xCellCount=Math.ceil(a/c),this.yCellCount=Math.ceil(b/c);for(let d=0;dthis.width||i<0||g>this.height)return!d&&[];const a=[];if(f<=0&&g<=0&&this.width<=h&&this.height<=i){if(d)return!0;for(let b=0;b0:a}_queryCircle(b,c,a,d,j){const f=b-a,g=b+a,h=c-a,i=c+a;if(g<0||f>this.width||i<0||h>this.height)return!d&&[];const e=[];return this._forEachCell(f,h,g,i,this._queryCellCircle,e,{hitTest:d,circle:{x:b,y:c,radius:a},seenUids:{box:{},circle:{}}},j),d?e.length>0:e}query(a,b,c,d,e){return this._query(a,b,c,d,!1,e)}hitTest(a,b,c,d,e){return this._query(a,b,c,d,!0,e)}hitTestCircle(a,b,c,d){return this._queryCircle(a,b,c,!0,d)}_queryCell(l,m,n,o,p,g,k,h){const i=k.seenUids,q=this.boxCells[p];if(null!==q){const a=this.bboxes;for(const e of q)if(!i.box[e]){i.box[e]=!0;const b=4*e;if(l<=a[b+2]&&m<=a[b+3]&&n>=a[b+0]&&o>=a[b+1]&&(!h||h(this.boxKeys[e]))){if(k.hitTest)return g.push(!0),!0;g.push({key:this.boxKeys[e],x1:a[b],y1:a[b+1],x2:a[b+2],y2:a[b+3]})}}}const r=this.circleCells[p];if(null!==r){const c=this.circles;for(const f of r)if(!i.circle[f]){i.circle[f]=!0;const d=3*f;if(this._circleAndRectCollide(c[d],c[d+1],c[d+2],l,m,n,o)&&(!h||h(this.circleKeys[f]))){if(k.hitTest)return g.push(!0),!0;{const s=c[d],t=c[d+1],j=c[d+2];g.push({key:this.circleKeys[f],x1:s-j,y1:t-j,x2:s+j,y2:t+j})}}}}}_queryCellCircle(o,p,q,r,j,k,l,b){const a=l.circle,c=l.seenUids,m=this.boxCells[j];if(null!==m){const d=this.bboxes;for(const e of m)if(!c.box[e]){c.box[e]=!0;const f=4*e;if(this._circleAndRectCollide(a.x,a.y,a.radius,d[f+0],d[f+1],d[f+2],d[f+3])&&(!b||b(this.boxKeys[e])))return k.push(!0),!0}}const n=this.circleCells[j];if(null!==n){const h=this.circles;for(const g of n)if(!c.circle[g]){c.circle[g]=!0;const i=3*g;if(this._circlesCollide(h[i],h[i+1],h[i+2],a.x,a.y,a.radius)&&(!b||b(this.circleKeys[g])))return k.push(!0),!0}}}_forEachCell(c,d,e,f,g,h,i,j){const k=this._convertToXCellCoord(c),l=this._convertToYCellCoord(d),m=this._convertToXCellCoord(e),n=this._convertToYCellCoord(f);for(let a=k;a<=m;a++)for(let b=l;b<=n;b++)if(g.call(this,c,d,e,f,this.xCellCount*b+a,h,i,j))return}_convertToXCellCoord(a){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(a*this.xScale)))}_convertToYCellCoord(a){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(a*this.yScale)))}_circlesCollide(d,e,f,g,h,i){const a=g-d,b=h-e,c=f+i;return c*c>a*a+b*b}_circleAndRectCollide(j,k,a,f,g,l,m){const b=(l-f)/2,d=Math.abs(j-(f+b));if(d>b+a)return!1;const c=(m-g)/2,e=Math.abs(k-(g+c));if(e>c+a)return!1;if(d<=b||e<=c)return!0;const h=d-b,i=e-c;return h*h+i*i<=a*a}}const aA=Math.tan(85*Math.PI/180);function aB(e,f,g,h,c,i){let b=a.create();if(g){if("globe"===c.projection.name)b=a.calculateGlobeMatrix(c,c.worldSize/c._projectionScaler,[0,0]),a.multiply$1(b,b,a.globeDenormalizeECEF(a.globeTileBounds(f)));else{const d=C([],i);b[0]=d[0],b[1]=d[1],b[4]=d[2],b[5]=d[3]}h||a.rotateZ(b,b,c.angle)}else a.multiply$1(b,c.labelPlaneMatrix,e);return b}function aC(g,j,h,i,f,b){if(h){if("globe"===f.projection.name){const c=aB(g,j,h,i,f,b);return a.invert(c,c),a.multiply$1(c,g,c),c}{const d=a.clone(g),e=a.identity([]);return e[0]=b[0],e[1]=b[1],e[4]=b[2],e[5]=b[3],a.multiply$1(d,d,e),i||a.rotateZ(d,d,-f.angle),d}}return f.glCoordMatrix}function aD(d,e,f=0){const b=[d.x,d.y,f,1];f?a.transformMat4$1(b,b,e):aP(b,b,e);const c=b[3];return{point:new a.pointGeometry(b[0]/c,b[1]/c),signedDistanceFromCamera:c}}function aE(a,b){return Math.min(.5+a/b*.5,1.5)}function aF(a,b){const c=a[0]/a[3],d=a[1]/a[3];return c>= -b[0]&&c<=b[0]&&d>= -b[1]&&d<=b[1]}function aG(c,m,e,i,n,x,y,z,o,p){const q=e.transform,A=i?c.textSizeData:c.iconSizeData,G=a.evaluateSizeForZoom(A,e.transform.zoom),H=[256/e.width*2+1,256/e.height*2+1,],d=i?c.text.dynamicLayoutVertexArray:c.icon.dynamicLayoutVertexArray;d.clear();const B=c.lineVertexArray,r=i?c.text.placedSymbolArray:c.icon.placedSymbolArray,C=e.transform.width/e.transform.height;let f=!1;for(let g=0;gMath.abs(c.x-b.x)*e?{useVertical:!0}:d.writingMode===a.WritingMode.vertical?b.yaA}(b,c,e)?1===d.flipState?{needsFlipping:!0}:null:b.x>c.x?{needsFlipping:!0}:null}function aJ(b,E,c,v,m,n,w,o,d,F,p,e,q,x,r,i,j){const f=E/24,s=b.lineOffsetX*f,t=b.lineOffsetY*f;let g;if(b.numGlyphs>1){const G=b.glyphStartIndex+b.numGlyphs,H=b.lineStartIndex,I=b.lineStartIndex+b.lineLength,h=aH(f,o,s,t,c,p,e,b,d,n,q,r,!1,i,j);if(!h)return{notEnoughRoom:!0};const J=aD(h.first.point,w).point,K=aD(h.last.point,w).point;if(v&&!c){const k=aI(b,J,K,x);if(b.flipState=k&&k.needsFlipping?1:2,k)return k}g=[h.first];for(let u=b.glyphStartIndex+1;u0?B.point:aL(e,A,y,1,m,void 0,i,j.canonical),x);if(b.flipState=l&&l.needsFlipping?1:2,l)return l}const C=aM(f*o.getoffsetX(b.glyphStartIndex),s,t,c,p,e,b.segment,b.lineStartIndex,b.lineStartIndex+b.lineLength,d,n,q,r,!1,!1,i,j);if(!C)return{notEnoughRoom:!0};g=[C]}for(const D of g)a.addDynamicAttributes(F,D.point,D.angle);return{}}function aK(c,g,e,h,f){const b=h.projectTilePoint(c.x,c.y,g);if(!f)return aD(b,e,b.z);const d=f(c);return aD(new a.pointGeometry(b.x+d[0],b.y+d[1]),e,b.z+d[2])}function aL(a,d,b,e,f,g,h,i){const j=aK(a.add(a.sub(d)._unit()),i,f,h,g).point,c=b.sub(j);return b.add(c._mult(e/c.mag()))}function aM(p,q,r,s,t,D,u,k,E,f,F,j,v,w,G,H,I){const x=s?p-q:p+q;let h=x>0?1:-1,l=0;s&&(h*=-1,l=Math.PI),h<0&&(l+=Math.PI);let b=h>0?k+u:k+u+1,c=t,e=t,m=0,i=0;const y=Math.abs(x),n=[],g=[];let d=D;const J=()=>{const c=b-h;return 0===m?D:new a.pointGeometry(f.getx(c),f.gety(c))},z=()=>aL(J(),d,e,y-m+1,F,v,H,I.canonical);for(;m+i<=y;){if((b+=h)=E)return null;if(e=c,n.push(c),w&&g.push(d||J()),void 0===(c=j[b])){d=new a.pointGeometry(f.getx(b),f.gety(b));const A=aK(d,I.canonical,F,H,v);c=A.signedDistanceFromCamera>0?j[b]=A.point:z()}else d=null;m+=i,i=e.dist(c)}G&&v&&(d=d||new a.pointGeometry(f.getx(b),f.gety(b)),j[b]=c=void 0===j[b]?c:z(),i=e.dist(c));const B=(y-m)/i,C=c.sub(e),o=C.mult(B)._add(e);r&&o._add(C._unit()._perp()._mult(r*h));const K=l+Math.atan2(c.y-e.y,c.x-e.x);return n.push(o),w&&(d=d||new a.pointGeometry(f.getx(b),f.gety(b)),g.push(function(c,d,b){const e=1-b;return new a.pointGeometry(c.x*e+d.x*b,c.y*e+d.y*b)}(g.length>0?g[g.length-1]:d,d,B))),{point:o,angle:K,path:n,tilePath:g}}const aN=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,]);function aO(d,a){for(let b=0;ba.sortKey-b.sortKey));this._currentPartIndex[0,0,0],I=new a.pointGeometry(f.tileAnchorX,f.tileAnchorY),r=this.transform.projection.projectTilePoint(f.tileAnchorX,f.tileAnchorY,l.canonical),s=H(I),g=[r.x+s[0],r.y+s[1],r.z+s[2]],t=this.projectAndGetPerspectiveRatio(V,g[0],g[1],g[2],l),{perspectiveRatio:u}=t,v=(q?D/u:D*u)/a.ONE_EM,_=aD(new a.pointGeometry(g[0],g[1]),E,g[2]).point,w=t.signedDistanceFromCamera>0?aH(v,U,f.lineOffsetX*v,f.lineOffsetY*v,!1,_,I,f,T,E,{},k&&!q?H:null,q&&!!k,this.transform.projection,l):null;let m=!1,x=!1,y=!0;if(w&&!t.aboveHorizon){const c=.5*Y*u+Z,h=new a.pointGeometry(-100,-100),i=new a.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),n=new ay,J=w.first,K=w.last;let b=[];for(let z=J.path.length-1;z>=1;z--)b.push(J.path[z]);for(let A=1;A{const c=H(aaD(a,W));b=L.some(a=>a.signedDistanceFromCamera<=0)?[]:L.map(a=>a.point)}let M=[];if(b.length>0){const d=b[0].clone(),e=b[0].clone();for(let j=1;j=h.x&&e.x<=i.x&&d.y>=h.y&&e.y<=i.y?[b]:e.xi.x||e.yi.y?[]:a.clipLine([b],h.x,h.y,i.x,i.y)}for(const ab of M){n.reset(ab,.25*c);let B=0;B=n.length<=.5*c?1:Math.ceil(n.paddedLength/aa)+1;for(let C=0;C0){a.transformMat4$1(b,b,d);let i=!1;this.fogState&&g&&(i=function(d,e,f,g,h,b){const i=b.calculateFogTileMatrix(h),c=[e,f,g];return a.transformMat4(c,c,i),Q(d,c,b.pitch,b._fov)}(this.fogState,e,f,c||0,g.toUnwrapped(),this.transform)>.9),h=b[2]>b[3]||i}else aP(b,b,d);return{point:new a.pointGeometry((b[0]/b[3]+1)/2*this.transform.width+100,(-b[1]/b[3]+1)/2*this.transform.height+100),perspectiveRatio:Math.min(.5+this.transform.cameraToCenterDistance/b[3]*.5,1.5),signedDistanceFromCamera:b[3],aboveHorizon:h}}isOffscreen(a,b,c,d){return c<100||a>=this.screenRightBoundary||d<100||b>this.screenBottomBoundary}isInsideGrid(a,b,c,d){return c>=0&&a=0&&ba.collisionGroupID===b}}return this.collisionGroups[a]}}(e),this.collisionCircleArrays={},this.prevPlacement=b,b&&(b.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(h,d,b,q){const c=b.getBucket(d),i=b.latestFeatureIndex;if(!c||!i||d.id!==c.layerIds[0])return;const e=c.layers[0].layout,r=b.collisionBoxArray,s=Math.pow(2,this.transform.zoom-b.tileID.overscaledZ),t=b.tileSize/a.EXTENT,j=b.tileID.toUnwrapped(),f=this.transform.calculateProjMatrix(j),g="map"===e.get("text-pitch-alignment"),k="map"===e.get("text-rotation-alignment");d.compileFilter();const l=d.dynamicFilter(),u=d.dynamicFilterNeedsFeature(),m=this.transform.calculatePixelsToTileUnitsMatrix(b),v=aB(f,b.tileID.canonical,g,k,this.transform,m);let n=null;if(g){const w=aC(f,b.tileID.canonical,g,k,this.transform,m);n=a.multiply$1([],this.transform.labelPlaneMatrix,w)}let o=null;l&&b.latestFeatureIndex&&(o={unwrappedTileID:j,dynamicFilter:l,dynamicFilterNeedsFeature:u,featureIndex:b.latestFeatureIndex}),this.retainedQueryData[c.bucketInstanceId]=new aU(c.bucketInstanceId,i,c.sourceLayerIndex,c.index,b.tileID);const p={bucket:c,layout:e,posMatrix:f,textLabelPlaneMatrix:v,labelToScreenMatrix:n,clippingData:o,scale:s,textPixelRatio:t,holdingForFade:b.holdingForFade(),collisionBoxArray:r,partiallyEvaluatedTextSize:a.evaluateSizeForZoom(c.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:a.evaluateSizeForZoom(c.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(c.sourceID)};if(q)for(const x of c.sortKeyRanges){const{sortKey:y,symbolInstanceStart:z,symbolInstanceEnd:A}=x;h.push({sortKey:y,symbolInstanceStart:z,symbolInstanceEnd:A,parameters:p})}else h.push({symbolInstanceStart:0,symbolInstanceEnd:c.symbolInstances.length,parameters:p})}attemptAnchorPlacement(d,s,g,h,e,i,j,k,l,m,n,a,t,c,f,o,v,u){const p=[a.textOffset0,a.textOffset1],b=aV(d,g,h,p,e),q=this.collisionIndex.placeCollisionBox(e,s,aW(b.x,b.y,i,j,this.transform.angle),n,k,l,m.predicate);if((!o||0!==this.collisionIndex.placeCollisionBox(c.getSymbolInstanceIconSize(u,this.transform.zoom,t),o,aW(b.x,b.y,i,j,this.transform.angle),n,k,l,m.predicate).box.length)&&q.box.length>0){let r;return this.prevPlacement&&this.prevPlacement.variableOffsets[a.crossTileID]&&this.prevPlacement.placements[a.crossTileID]&&this.prevPlacement.placements[a.crossTileID].text&&(r=this.prevPlacement.variableOffsets[a.crossTileID].anchor),this.variableOffsets[a.crossTileID]={textOffset:p,width:g,height:h,anchor:d,textScale:e,prevAnchor:r},this.markUsedJustification(c,d,a,f),c.allowVerticalPlacement&&(this.markUsedOrientation(c,f,a),this.placedOrientations[a.crossTileID]=f),{shift:b,placedGlyphBoxes:q}}}placeLayerBucketPart(e,t,i,o){const{bucket:b,layout:c,posMatrix:p,textLabelPlaneMatrix:u,labelToScreenMatrix:v,clippingData:w,textPixelRatio:x,holdingForFade:y,collisionBoxArray:f,partiallyEvaluatedTextSize:z,partiallyEvaluatedIconSize:A,collisionGroup:B}=e.parameters,q=c.get("text-optional"),r=c.get("icon-optional"),j=c.get("text-allow-overlap"),k=c.get("icon-allow-overlap"),C="map"===c.get("text-rotation-alignment"),D="map"===c.get("text-pitch-alignment"),E="none"!==c.get("icon-text-fit"),s="viewport-y"===c.get("symbol-z-order"),F=j&&(k||!b.hasIconData()||r),G=k&&(j||!b.hasTextData()||q);!b.collisionArrays&&f&&b.deserializeCollisionBoxes(f),i&&o&&b.updateCollisionDebugBuffers(this.transform.zoom,f);const l=(d,ac,f)=>{if(w){const $={zoom:this.transform.zoom,pitch:this.transform.pitch};let N=null;if(w.dynamicFilterNeedsFeature){const O=this.retainedQueryData[b.bucketInstanceId];N=w.featureIndex.loadFeature({featureIndex:d.featureIndex,bucketIndex:O.bucketIndex,sourceLayerIndex:O.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,w.dynamicFilter)($,N,this.retainedQueryData[b.bucketInstanceId].tileID.canonical,new a.pointGeometry(d.tileAnchorX,d.tileAnchorY),this.transform.calculateDistanceTileData(w.unwrappedTileID)))return this.placements[d.crossTileID]=new aS(!1,!1,!1,!0),void(t[d.crossTileID]=!0)}if(t[d.crossTileID])return;if(y)return void(this.placements[d.crossTileID]=new aS(!1,!1,!1));let e=!1,l=!1,n=!0,ad=null,h={box:null,offscreen:null},s={box:null,offscreen:null},m=null,g=null,H=null,J=0,K=0,P=0;f.textFeatureIndex?J=f.textFeatureIndex:d.useRuntimeCollisionCircles&&(J=d.featureIndex),f.verticalTextFeatureIndex&&(K=f.verticalTextFeatureIndex);const _=a=>{a.tileID=this.retainedQueryData[b.bucketInstanceId].tileID,(this.transform.elevation||a.elevation)&&(a.elevation=this.transform.elevation?this.transform.elevation.getAtTileOffset(this.retainedQueryData[b.bucketInstanceId].tileID,a.tileAnchorX,a.tileAnchorY):0)},Q=f.textBox;if(Q){_(Q);const R=f=>{let c=a.WritingMode.horizontal;if(b.allowVerticalPlacement&&!f&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[d.crossTileID];e&&(this.placedOrientations[d.crossTileID]=e,c=e,this.markUsedOrientation(b,c,d))}return c},S=(c,e)=>{if(b.allowVerticalPlacement&&d.numVerticalGlyphVertices>0&&f.verticalTextBox){for(const g of b.writingModes)if(g===a.WritingMode.vertical?s=h=e():h=c(),h&&h.box&&h.box.length)break}else h=c()};if(c.get("text-variable-anchor")){let L=c.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[d.crossTileID]){const T=this.prevPlacement.variableOffsets[d.crossTileID];L.indexOf(T.anchor)>0&&(L=L.filter(a=>a!==T.anchor)).unshift(T.anchor)}const ae=(a,l,m)=>{const g=b.getSymbolInstanceTextSize(z,d,this.transform.zoom,ac),n=(a.x2-a.x1)*g+2*a.padding,o=(a.y2-a.y1)*g+2*a.padding,h=E&&!k?l:null;h&&_(h);let c={box:[],offscreen:!1};const q=j?2*L.length:L.length;for(let f=0;f=L.length,d,ac,b,m,h,z,A);if(i&&(c=i.placedGlyphBoxes)&&c.box&&c.box.length){e=!0,ad=i.shift;break}}return c};S(()=>ae(Q,f.iconBox,a.WritingMode.horizontal),()=>{const c=f.verticalTextBox;return c&&_(c),b.allowVerticalPlacement&&!(h&&h.box&&h.box.length)&&d.numVerticalGlyphVertices>0&&c?ae(c,f.verticalIconBox,a.WritingMode.vertical):{box:null,offscreen:null}}),h&&(e=h.box,n=h.offscreen);const aa=R(h&&h.box);if(!e&&this.prevPlacement){const M=this.prevPlacement.variableOffsets[d.crossTileID];M&&(this.variableOffsets[d.crossTileID]=M,this.markUsedJustification(b,M.anchor,d,aa))}}else{const af=(f,e)=>{const g=b.getSymbolInstanceTextSize(z,d,this.transform.zoom,ac),c=this.collisionIndex.placeCollisionBox(g,f,new a.pointGeometry(0,0),j,x,p,B.predicate);return c&&c.box&&c.box.length&&(this.markUsedOrientation(b,e,d),this.placedOrientations[d.crossTileID]=e),c};S(()=>af(Q,a.WritingMode.horizontal),()=>{const c=f.verticalTextBox;return b.allowVerticalPlacement&&d.numVerticalGlyphVertices>0&&c?(_(c),af(c,a.WritingMode.vertical)):{box:null,offscreen:null}}),R(h&&h.box&&h.box.length)}}if(e=(m=h)&&m.box&&m.box.length>0,n=m&&m.offscreen,d.useRuntimeCollisionCircles){const U=b.text.placedSymbolArray.get(d.centerJustifiedTextSymbolIndex>=0?d.centerJustifiedTextSymbolIndex:d.verticalPlacedTextSymbolIndex),V=a.evaluateSizeForFeature(b.textSizeData,z,U),ab=c.get("text-padding");g=this.collisionIndex.placeCollisionCircles(j,U,b.lineVertexArray,b.glyphOffsetArray,V,p,u,v,i,D,B.predicate,d.collisionCircleDiameter*V/a.ONE_EM,ab,this.retainedQueryData[b.bucketInstanceId].tileID),e=j||g.circles.length>0&&!g.collisionDetected,n=n&&g.offscreen}if(f.iconFeatureIndex&&(P=f.iconFeatureIndex),f.iconBox){const W=c=>{_(c);const d=E&&ad?aW(ad.x,ad.y,C,D,this.transform.angle):new a.pointGeometry(0,0),e=b.getSymbolInstanceIconSize(A,this.transform.zoom,ac);return this.collisionIndex.placeCollisionBox(e,c,d,k,x,p,B.predicate)};l=s&&s.box&&s.box.length&&f.verticalIconBox?(H=W(f.verticalIconBox)).box.length>0:(H=W(f.iconBox)).box.length>0,n=n&&H.offscreen}const X=q||0===d.numHorizontalGlyphVertices&&0===d.numVerticalGlyphVertices,Y=r||0===d.numIconVertices;if(X||Y?Y?X||(l=l&&e):e=l&&e:l=e=l&&e,e&&m&&m.box&&this.collisionIndex.insertCollisionBox(m.box,c.get("text-ignore-placement"),b.bucketInstanceId,s&&s.box&&K?K:J,B.ID),l&&H&&this.collisionIndex.insertCollisionBox(H.box,c.get("icon-ignore-placement"),b.bucketInstanceId,P,B.ID),g&&(e&&this.collisionIndex.insertCollisionCircles(g.circles,c.get("text-ignore-placement"),b.bucketInstanceId,J,B.ID),i)){const Z=b.bucketInstanceId;let o=this.collisionCircleArrays[Z];void 0===o&&(o=this.collisionCircleArrays[Z]=new aT);for(let I=0;I=0;--g){const h=m[g];l(b.symbolInstances.get(h),h,b.collisionArrays[h])}}else for(let d=e.symbolInstanceStart;d=0&&(e.text.placedSymbolArray.get(d).crossTileID=c>=0&&d!==c?0:b.crossTileID)}markUsedOrientation(d,b,c){const e=b===a.WritingMode.horizontal||b===a.WritingMode.horizontalOnly?b:0,f=b===a.WritingMode.vertical?b:0,g=[c.leftJustifiedTextSymbolIndex,c.centerJustifiedTextSymbolIndex,c.rightJustifiedTextSymbolIndex,];for(const h of g)d.text.placedSymbolArray.get(h).placedOrientation=e;c.verticalPlacedTextSymbolIndex&&(d.text.placedSymbolArray.get(c.verticalPlacedTextSymbolIndex).placedOrientation=f)}commit(f){this.commitTime=f,this.zoomAtLastRecencyCheck=this.transform.zoom;const a=this.prevPlacement;let c=!1;this.prevZoomAdjustment=a?a.zoomAdjustment(this.transform.zoom):0;const i=a?a.symbolFadeChange(f):1,j=a?a.opacities:{},m=a?a.variableOffsets:{},n=a?a.placedOrientations:{};for(const g in this.placements){const b=this.placements[g],h=j[g];h?(this.opacities[g]=new aR(h,i,b.text,b.icon,null,b.clipped),c=c||b.text!==h.text.placed||b.icon!==h.icon.placed):(this.opacities[g]=new aR(null,i,b.text,b.icon,b.skipFade,b.clipped),c=c||b.text||b.icon)}for(const k in j){const l=j[k];if(!this.opacities[k]){const o=new aR(l,i,!1,!1);o.isHidden()||(this.opacities[k]=o,c=c||l.text.placed||l.icon.placed)}}for(const d in m)this.variableOffsets[d]||!this.opacities[d]||this.opacities[d].isHidden()||(this.variableOffsets[d]=m[d]);for(const e in n)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=n[e]);c?this.lastPlacementChangeTime=f:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=a?a.lastPlacementChangeTime:f)}updateLayerOpacities(c,d){const e={};for(const a of d){const b=a.getBucket(c);b&&a.latestFeatureIndex&&c.id===b.layerIds[0]&&this.updateBucketOpacities(b,e,a.collisionBoxArray)}}updateBucketOpacities(b,s,t){b.hasTextData()&&b.text.opacityVertexArray.clear(),b.hasIconData()&&b.icon.opacityVertexArray.clear(),b.hasIconCollisionBoxData()&&b.iconCollisionBox.collisionVertexArray.clear(),b.hasTextCollisionBoxData()&&b.textCollisionBox.collisionVertexArray.clear();const f=b.layers[0].layout,F=!!b.layers[0].dynamicFilter(),G=new aR(null,0,!1,!1,!0),u=f.get("text-allow-overlap"),v=f.get("icon-allow-overlap"),H=f.get("text-variable-anchor"),I="map"===f.get("text-rotation-alignment"),J="map"===f.get("text-pitch-alignment"),l="none"!==f.get("icon-text-fit"),K=new aR(null,0,u&&(v||!b.hasIconData()||f.get("icon-optional")),v&&(u||!b.hasTextData()||f.get("text-optional")),!0);!b.collisionArrays&&t&&(b.hasIconCollisionBoxData()||b.hasTextCollisionBoxData())&&b.deserializeCollisionBoxes(t);const m=(b,c,d)=>{for(let a=0;a0||y>0,A=c.numIconVertices>0,o=this.placedOrientations[c.crossTileID],p=o===a.WritingMode.vertical,j=o===a.WritingMode.horizontal||o===a.WritingMode.horizontalOnly;if(!z&&!A||d.isHidden()||w++,z){const B=aY(d.text);m(b.text,x,p?0:B),m(b.text,y,j?0:B);const L=d.text.isHidden();[c.rightJustifiedTextSymbolIndex,c.centerJustifiedTextSymbolIndex,c.leftJustifiedTextSymbolIndex,].forEach(a=>{a>=0&&(b.text.placedSymbolArray.get(a).hidden=L||p?1:0)}),c.verticalPlacedTextSymbolIndex>=0&&(b.text.placedSymbolArray.get(c.verticalPlacedTextSymbolIndex).hidden=L||j?1:0);const C=this.variableOffsets[c.crossTileID];C&&this.markUsedJustification(b,C.anchor,c,o);const q=this.placedOrientations[c.crossTileID];q&&(this.markUsedJustification(b,"left",c,q),this.markUsedOrientation(b,q,c))}if(A){const D=aY(d.icon);c.placedIconSymbolIndex>=0&&(m(b.icon,c.numIconVertices,p?0:D),b.icon.placedSymbolArray.get(c.placedIconSymbolIndex).hidden=d.icon.isHidden()),c.verticalPlacedIconSymbolIndex>=0&&(m(b.icon,c.numVerticalIconVertices,j?0:D),b.icon.placedSymbolArray.get(c.verticalPlacedIconSymbolIndex).hidden=d.icon.isHidden())}if(b.hasIconCollisionBoxData()||b.hasTextCollisionBoxData()){const g=b.collisionArrays[n];if(g){let e=new a.pointGeometry(0,0),k=!0;if(g.textBox||g.verticalTextBox){if(H){const h=this.variableOffsets[i];h?(e=aV(h.anchor,h.width,h.height,h.textOffset,h.textScale),I&&e._rotate(J?this.transform.angle:-this.transform.angle)):k=!1}F&&(k=!d.clipped),g.textBox&&aX(b.textCollisionBox.collisionVertexArray,d.text.placed,!k||p,e.x,e.y),g.verticalTextBox&&aX(b.textCollisionBox.collisionVertexArray,d.text.placed,!k||j,e.x,e.y)}const E=k&&Boolean(!j&&g.verticalIconBox);g.iconBox&&aX(b.iconCollisionBox.collisionVertexArray,d.icon.placed,E,l?e.x:0,l?e.y:0),g.verticalIconBox&&aX(b.iconCollisionBox.collisionVertexArray,d.icon.placed,!E,l?e.x:0,l?e.y:0)}}}if(b.fullyClipped=0===w,b.sortFeatures(this.transform.angle),this.retainedQueryData[b.bucketInstanceId]&&(this.retainedQueryData[b.bucketInstanceId].featureSortOrder=b.featureSortOrder),b.hasTextData()&&b.text.opacityVertexBuffer&&b.text.opacityVertexBuffer.updateData(b.text.opacityVertexArray),b.hasIconData()&&b.icon.opacityVertexBuffer&&b.icon.opacityVertexBuffer.updateData(b.icon.opacityVertexArray),b.hasIconCollisionBoxData()&&b.iconCollisionBox.collisionVertexBuffer&&b.iconCollisionBox.collisionVertexBuffer.updateData(b.iconCollisionBox.collisionVertexArray),b.hasTextCollisionBoxData()&&b.textCollisionBox.collisionVertexBuffer&&b.textCollisionBox.collisionVertexBuffer.updateData(b.textCollisionBox.collisionVertexArray),b.bucketInstanceId in this.collisionCircleArrays){const r=this.collisionCircleArrays[b.bucketInstanceId];b.placementInvProjMatrix=r.invProjMatrix,b.placementViewportMatrix=r.viewportMatrix,b.collisionCircleArray=r.circles,delete this.collisionCircleArrays[b.bucketInstanceId]}}symbolFadeChange(a){return 0===this.fadeDuration?1:(a-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(a){return Math.max(0,(this.transform.zoom-a)/1.5)}hasTransitions(a){return this.stale||a-this.lastPlacementChangeTimeb}setStale(){this.stale=!0}}(b,f,g,h,i),this._currentPlacementIndex=c.length-1,this._forceFullPlacement=d,this._showCollisionBoxes=e,this._done=!1}isDone(){return this._done}continuePlacement(d,e,f){const h=a.exported.now(),g=()=>{const b=a.exported.now()-h;return!this._forceFullPlacement&&b>2};for(;this._currentPlacementIndex>=0;){const b=e[d[this._currentPlacementIndex]],c=this.placement.collisionIndex.transform.zoom;if("symbol"===b.type&&(!b.minzoom||b.minzoom<=c)&&(!b.maxzoom||b.maxzoom>c)){if(this._inProgressLayer||(this._inProgressLayer=new aZ(b)),this._inProgressLayer.continuePlacement(f[b.source],this.placement,this._showCollisionBoxes,b,g))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(a){return this.placement.commit(a),this.placement}}const a_=512/a.EXTENT/2;class a0{constructor(d,e,f){this.tileID=d,this.indexedSymbolInstances={},this.bucketInstanceId=f;for(let a=0;aa.overscaledZ)for(const l in f){const i=f[l];i.tileID.isChildOf(a)&&i.findMatches(b.symbolInstances,a,d)}else{const j=f[a.scaledTo(Number(e)).key];j&&j.findMatches(b.symbolInstances,a,d)}}for(let g=0;g{c[a]=!0}),this.layerIndexes)c[a]||delete this.layerIndexes[a]}}const a3=(c,b)=>a.emitValidationErrors(c,b&&b.filter(a=>"source.canvas"!==a.identifier)),a4=a.pick(i,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection",]),a5=a.pick(i,["setCenter","setZoom","setBearing","setPitch",]),a6=function(){const c={},f=a.spec.$version;for(const b in a.spec.$root){const d=a.spec.$root[b];if(d.required){let e=null;null!=(e="version"===b?f:"array"===d.type?[]:{})&&(c[b]=e)}}return c}(),a7={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class c extends a.Evented{constructor(d,b={}){super(),this.map=d,this.dispatcher=new n(ao(),this),this.imageManager=new J,this.imageManager.setEventedParent(this),this.glyphManager=new a.GlyphManager(d._requestManager,b.localFontFamily?a.LocalGlyphMode.all:b.localIdeographFontFamily?a.LocalGlyphMode.ideographs:a.LocalGlyphMode.none,b.localFontFamily||b.localIdeographFontFamily),this.lineAtlas=new a.LineAtlas(256,512),this.crossTileSymbolIndex=new a2,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this.zoomHistory=new a.ZoomHistory,this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",a.getReferrer());const e=this;this._rtlTextPluginCallback=c.registerForPluginStateChange(b=>{e.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:b.pluginStatus,pluginURL:b.pluginURL},(f,b)=>{if(a.triggerPluginCompletionEvent(f),b&&b.every(a=>a))for(const g in e._sourceCaches){const c=e._sourceCaches[g],d=c.getSource().type;"vector"!==d&&"geojson"!==d||c.reload()}})}),this.on("data",a=>{if("source"!==a.dataType||"metadata"!==a.sourceDataType)return;const b=this.getSource(a.sourceId);if(b&&b.vectorLayerIds)for(const d in this._layers){const c=this._layers[d];c.source===b.id&&this._validateLayer(c)}})}loadURL(b,c={}){this.fire(new a.Event("dataloading",{dataType:"style"}));const e="boolean"==typeof c.validate?c.validate:!a.isMapboxURL(b);b=this.map._requestManager.normalizeStyleURL(b,c.accessToken);const d=this.map._requestManager.transformRequest(b,a.ResourceType.Style);this._request=a.getJSON(d,(b,c)=>{this._request=null,b?this.fire(new a.ErrorEvent(b)):c&&this._load(c,e)})}loadJSON(b,c={}){this.fire(new a.Event("dataloading",{dataType:"style"})),this._request=a.exported.frame(()=>{this._request=null,this._load(b,!1!==c.validate)})}loadEmpty(){this.fire(new a.Event("dataloading",{dataType:"style"})),this._load(a6,!1)}_updateLayerCount(a,c){const b=c?1:-1;a.is3D()&&(this._num3DLayers+=b),"circle"===a.type&&(this._numCircleLayers+=b),"symbol"===a.type&&(this._numSymbolLayers+=b)}_load(c,f){if(f&&a3(this,a.validateStyle(c)))return;for(const d in this._loaded=!0,this.stylesheet=c,this.updateProjection(),c.sources)this.addSource(d,c.sources[d],{validate:!1});this._changed=!1,c.sprite?this._loadSprite(c.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(c.glyphs);const e=aq(this.stylesheet.layers);for(let b of(this._order=e.map(a=>a.id),this._layers={},this._serializedLayers={},e))(b=a.createStyleLayer(b)).setEventedParent(this,{layer:{id:b.id}}),this._layers[b.id]=b,this._serializedLayers[b.id]=b.serialize(),this._updateLayerCount(b,!0);this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new M(this.stylesheet.light),this.stylesheet.terrain&&!this.terrainSetForDrapingOnly()&&this._createTerrain(this.stylesheet.terrain,1),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this._updateDrapeFirstLayers(),this.fire(new a.Event("data",{dataType:"style"})),this.fire(new a.Event("style.load"))}terrainSetForDrapingOnly(){return this.terrain&&0===this.terrain.drapeRenderMode}setProjection(a){a?this.stylesheet.projection=a:delete this.stylesheet.projection,this.updateProjection()}updateProjection(){const b=this.map.transform.projection,c=this.map.transform.setProjection(this.map._runtimeProjection||(this.stylesheet?this.stylesheet.projection:void 0)),a=this.map.transform.projection;if(this._loaded&&(a.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null)),this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),c){if(a.isReprojectedInTileSpace||b.isReprojectedInTileSpace)for(const d in this.map.painter.clearBackgroundTiles(),this._sourceCaches)this._sourceCaches[d].clearTiles();else this._forceSymbolLayerUpdate();this.map._update(!0)}}_loadSprite(b){this._spriteRequest=function(c,b,e){let f,g,h;const d=a.exported.devicePixelRatio>1?"@2x":"";let i=a.getJSON(b.transformRequest(b.normalizeSpriteURL(c,d,".json"),a.ResourceType.SpriteJSON),(a,b)=>{i=null,h||(h=a,f=b,k())}),j=a.getImage(b.transformRequest(b.normalizeSpriteURL(c,d,".png"),a.ResourceType.SpriteImage),(a,b)=>{j=null,h||(h=a,g=b,k())});function k(){if(h)e(h);else if(f&&g){const k=a.exported.getImageData(g),b={};for(const c in f){const{width:d,height:i,x:l,y:m,sdf:n,pixelRatio:o,stretchX:p,stretchY:q,content:r}=f[c],j=new a.RGBAImage({width:d,height:i});a.RGBAImage.copy(k,j,{x:l,y:m},{x:0,y:0},{width:d,height:i}),b[c]={data:j,pixelRatio:o,sdf:n,stretchX:p,stretchY:q,content:r}}e(null,b)}}return{cancel(){i&&(i.cancel(),i=null),j&&(j.cancel(),j=null)}}}(b,this.map._requestManager,(c,b)=>{if(this._spriteRequest=null,c)this.fire(new a.ErrorEvent(c));else if(b)for(const d in b)this.imageManager.addImage(d,b[d]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new a.Event("data",{dataType:"style"}))})}_validateLayer(c){const b=this.getSource(c.source);if(!b)return;const d=c.sourceLayer;d&&("geojson"===b.type||b.vectorLayerIds&& -1===b.vectorLayerIds.indexOf(d))&&this.fire(new a.ErrorEvent(new Error(`Source layer "${d}" does not exist on source "${b.id}" as specified by style layer "${c.id}"`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(const a in this._sourceCaches)if(!this._sourceCaches[a].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(c){const a=[];for(const d of c){const b=this._layers[d];"custom"!==b.type&&a.push(b.serialize())}return a}hasTransitions(){if(this.light&&this.light.hasTransition())return!0;if(this.fog&&this.fog.hasTransition())return!0;for(const a in this._sourceCaches)if(this._sourceCaches[a].hasTransition())return!0;for(const b in this._layers)if(this._layers[b].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(a){return!!this.terrain&&a7[a.type]}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}update(b){if(!this._loaded)return;const p=this._changed;if(this._changed){const g=Object.keys(this._updatedLayers),h=Object.keys(this._removedLayers);for(const d in(g.length||h.length)&&this._updateWorkerLayers(g,h),this._updatedSources){const i=this._updatedSources[d];"reload"===i?this._reloadSource(d):"clear"===i&&this._clearSource(d)}for(const q in this._updateTilesForChangedImages(),this._updatedPaintProps)this._layers[q].updateTransitions(b);this.light.updateTransitions(b),this.fog&&this.fog.updateTransitions(b),this._resetUpdates()}const e={};for(const j in this._sourceCaches){const k=this._sourceCaches[j];e[j]=k.used,k.used=!1}for(const r of this._order){const c=this._layers[r];if(c.recalculate(b,this._availableImages),!c.isHidden(b.zoom)){const l=this._getLayerSourceCache(c);l&&(l.used=!0)}const m=this.map.painter;if(m){const n=c.getProgramIds();if(!n)continue;const s=c.getProgramConfiguration(b.zoom);for(const t of n)m.useProgram(t,s)}}for(const o in e){const f=this._sourceCaches[o];e[o]!==f.used&&f.getSource().fire(new a.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:f.getSource().id}))}this.light.recalculate(b),this.terrain&&this.terrain.recalculate(b),this.fog&&this.fog.recalculate(b),this.z=b.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),p&&this.fire(new a.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const a=Object.keys(this._changedImages);if(a.length){for(const b in this._sourceCaches)this._sourceCaches[b].reloadTilesForDependencies(["icons","patterns"],a);this._changedImages={}}}_updateWorkerLayers(a,b){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(a),removedIds:b})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(b){if(this._checkLoaded(),a3(this,a.validateStyle(b)))return!1;(b=a.clone$1(b)).layers=aq(b.layers);const c=(function(c,a){if(!c)return[{command:i.setStyle,args:[a]},];let b=[];try{if(!D(c.version,a.version))return[{command:i.setStyle,args:[a]},];D(c.center,a.center)||b.push({command:i.setCenter,args:[a.center]}),D(c.zoom,a.zoom)||b.push({command:i.setZoom,args:[a.zoom]}),D(c.bearing,a.bearing)||b.push({command:i.setBearing,args:[a.bearing]}),D(c.pitch,a.pitch)||b.push({command:i.setPitch,args:[a.pitch]}),D(c.sprite,a.sprite)||b.push({command:i.setSprite,args:[a.sprite]}),D(c.glyphs,a.glyphs)||b.push({command:i.setGlyphs,args:[a.glyphs]}),D(c.transition,a.transition)||b.push({command:i.setTransition,args:[a.transition]}),D(c.light,a.light)||b.push({command:i.setLight,args:[a.light]}),D(c.fog,a.fog)||b.push({command:i.setFog,args:[a.fog]}),D(c.projection,a.projection)||b.push({command:i.setProjection,args:[a.projection]});const e={},f=[];!function(c,b,d,e){let a;for(a in b=b||{},c=c||{})c.hasOwnProperty(a)&&(b.hasOwnProperty(a)||as(a,d,e));for(a in b)b.hasOwnProperty(a)&&(c.hasOwnProperty(a)?D(c[a],b[a])||("geojson"===c[a].type&&"geojson"===b[a].type&&au(c,b,a)?d.push({command:i.setGeoJSONSourceData,args:[a,b[a].data,]}):at(a,b,d,e)):ar(a,b,d))}(c.sources,a.sources,f,e);const g=[];c.layers&&c.layers.forEach(a=>{e[a.source]?b.push({command:i.removeLayer,args:[a.id]}):g.push(a)});let d=c.terrain;d&&e[d.source]&&(b.push({command:i.setTerrain,args:[void 0]}),d=void 0),b=b.concat(f),D(d,a.terrain)||b.push({command:i.setTerrain,args:[a.terrain]}),function(m,k,f){k=k||[];const n=(m=m||[]).map(aw),j=k.map(aw),p=m.reduce(ax,{}),o=k.reduce(ax,{}),g=n.slice(),q=Object.create(null);let e,h,b,d,c,l,a;for(e=0,h=0;e!(a.command in a5));if(0===c.length)return!1;const d=c.filter(a=>!(a.command in a4));if(d.length>0)throw new Error(`Unimplemented: ${d.map(a=>a.command).join(", ")}.`);return c.forEach(a=>{"setTransition"!==a.command&&this[a.command].apply(this,a.args)}),this.stylesheet=b,this.updateProjection(),!0}addImage(b,c){if(this.getImage(b))return this.fire(new a.ErrorEvent(new Error("An image with this name already exists.")));this.imageManager.addImage(b,c),this._afterImageUpdated(b)}updateImage(a,b){this.imageManager.updateImage(a,b)}getImage(a){return this.imageManager.getImage(a)}removeImage(b){if(!this.getImage(b))return this.fire(new a.ErrorEvent(new Error("No image with this name exists.")));this.imageManager.removeImage(b),this._afterImageUpdated(b)}_afterImageUpdated(b){this._availableImages=this.imageManager.listImages(),this._changedImages[b]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new a.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(c,b,f={}){if(this._checkLoaded(),void 0!==this.getSource(c))throw new Error("There is already a source with this ID");if(!b.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(b).join(", ")}.`);if(["vector","raster","geojson","video","image",].indexOf(b.type)>=0&&this._validate(a.validateStyle.source,`sources.${c}`,b,null,f))return;this.map&&this.map._collectResourceTiming&&(b.collectResourceTiming=!0);const d=ag(c,b,this.dispatcher,this);d.setEventedParent(this,()=>({isSourceLoaded:this.loaded(),source:d.serialize(),sourceId:c}));const e=b=>{const f=(b?"symbol:":"other:")+c,e=this._sourceCaches[f]=new a.SourceCache(f,d,b);(b?this._symbolSourceCaches:this._otherSourceCaches)[c]=e,e.style=this,e.onAdd(this.map)};e(!1),"vector"!==b.type&&"geojson"!==b.type||e(!0),d.onAdd&&d.onAdd(this.map),this._changed=!0}removeSource(b){this._checkLoaded();const d=this.getSource(b);if(void 0===d)throw new Error("There is no source with this ID");for(const e in this._layers)if(this._layers[e].source===b)return this.fire(new a.ErrorEvent(new Error(`Source "${b}" cannot be removed while layer "${e}" is using it.`)));if(this.terrain&&this.terrain.get().source===b)return this.fire(new a.ErrorEvent(new Error(`Source "${b}" cannot be removed while terrain is using it.`)));const f=this._getSourceCaches(b);for(const c of f)delete this._sourceCaches[c.id],delete this._updatedSources[c.id],c.fire(new a.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:c.getSource().id})),c.setEventedParent(null),c.clearTiles();delete this._otherSourceCaches[b],delete this._symbolSourceCaches[b],d.setEventedParent(null),d.onRemove&&d.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(a,b){this._checkLoaded(),this.getSource(a).setData(b),this._changed=!0}getSource(b){const a=this._getSourceCache(b);return a&&a.getSource()}addLayer(c,e,h={}){this._checkLoaded();const d=c.id;if(this.getLayer(d))return void this.fire(new a.ErrorEvent(new Error(`Layer with id "${d}" already exists on this map`)));let b;if("custom"===c.type){if(a3(this,a.validateCustomStyleLayer(c)))return;b=a.createStyleLayer(c)}else{if("object"==typeof c.source&&(this.addSource(d,c.source),c=a.clone$1(c),c=a.extend(c,{source:d})),this._validate(a.validateStyle.layer,`layers.${d}`,c,{arrayIndex:-1},h))return;b=a.createStyleLayer(c),this._validateLayer(b),b.setEventedParent(this,{layer:{id:d}}),this._serializedLayers[b.id]=b.serialize(),this._updateLayerCount(b,!0)}const f=e?this._order.indexOf(e):this._order.length;if(e&& -1===f)return void this.fire(new a.ErrorEvent(new Error(`Layer with id "${e}" does not exist on this map.`)));this._order.splice(f,0,d),this._layerOrderChanged=!0,this._layers[d]=b;const g=this._getLayerSourceCache(b);if(this._removedLayers[d]&&b.source&&g&&"custom"!==b.type){const i=this._removedLayers[d];delete this._removedLayers[d],i.type!==b.type?this._updatedSources[b.source]="clear":(this._updatedSources[b.source]="reload",g.pause())}this._updateLayer(b),b.onAdd&&b.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(b,c){if(this._checkLoaded(),this._changed=!0,!this._layers[b])return void this.fire(new a.ErrorEvent(new Error(`The layer '${b}' does not exist in the map's style and cannot be moved.`)));if(b===c)return;const e=this._order.indexOf(b);this._order.splice(e,1);const d=c?this._order.indexOf(c):this._order.length;c&& -1===d?this.fire(new a.ErrorEvent(new Error(`Layer with id "${c}" does not exist on this map.`))):(this._order.splice(d,0,b),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(b){this._checkLoaded();const c=this._layers[b];if(!c)return void this.fire(new a.ErrorEvent(new Error(`The layer '${b}' does not exist in the map's style and cannot be removed.`)));c.setEventedParent(null),this._updateLayerCount(c,!1);const d=this._order.indexOf(b);this._order.splice(d,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[b]=c,delete this._layers[b],delete this._serializedLayers[b],delete this._updatedLayers[b],delete this._updatedPaintProps[b],c.onRemove&&c.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(a){return this._layers[a]}hasLayer(a){return a in this._layers}hasLayerType(a){for(const b in this._layers)if(this._layers[b].type===a)return!0;return!1}setLayerZoomRange(e,c,d){this._checkLoaded();const b=this.getLayer(e);b?b.minzoom===c&&b.maxzoom===d||(null!=c&&(b.minzoom=c),null!=d&&(b.maxzoom=d),this._updateLayer(b)):this.fire(new a.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(d,c,e={}){this._checkLoaded();const b=this.getLayer(d);if(b){if(!D(b.filter,c))return null==c?(b.filter=void 0,void this._updateLayer(b)):void(this._validate(a.validateStyle.filter,`layers.${b.id}.filter`,c,{layerType:b.type},e)||(b.filter=a.clone$1(c),this._updateLayer(b)))}else this.fire(new a.ErrorEvent(new Error(`The layer '${d}' does not exist in the map's style and cannot be filtered.`)))}getFilter(b){return a.clone$1(this.getLayer(b).filter)}setLayoutProperty(c,d,e,f={}){this._checkLoaded();const b=this.getLayer(c);b?D(b.getLayoutProperty(d),e)||(b.setLayoutProperty(d,e,f),this._updateLayer(b)):this.fire(new a.ErrorEvent(new Error(`The layer '${c}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(b,d){const c=this.getLayer(b);if(c)return c.getLayoutProperty(d);this.fire(new a.ErrorEvent(new Error(`The layer '${b}' does not exist in the map's style.`)))}setPaintProperty(c,d,e,f={}){this._checkLoaded();const b=this.getLayer(c);b?D(b.getPaintProperty(d),e)||(b.setPaintProperty(d,e,f)&&this._updateLayer(b),this._changed=!0,this._updatedPaintProps[c]=!0):this.fire(new a.ErrorEvent(new Error(`The layer '${c}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(a,b){return this.getLayer(a).getPaintProperty(b)}setFeatureState(b,g){this._checkLoaded();const c=b.source,d=b.sourceLayer,e=this.getSource(c);if(void 0===e)return void this.fire(new a.ErrorEvent(new Error(`The source '${c}' does not exist in the map's style.`)));const f=e.type;if("geojson"===f&&d)return void this.fire(new a.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===f&&!d)return void this.fire(new a.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===b.id&&this.fire(new a.ErrorEvent(new Error("The feature id parameter must be provided.")));const h=this._getSourceCaches(c);for(const i of h)i.setFeatureState(d,b.id,g)}removeFeatureState(b,d){this._checkLoaded();const c=b.source,e=this.getSource(c);if(void 0===e)return void this.fire(new a.ErrorEvent(new Error(`The source '${c}' does not exist in the map's style.`)));const f=e.type,g="vector"===f?b.sourceLayer:void 0;if("vector"===f&&!g)return void this.fire(new a.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));if(d&&"string"!=typeof b.id&&"number"!=typeof b.id)return void this.fire(new a.ErrorEvent(new Error("A feature id is required to remove its specific state property.")));const h=this._getSourceCaches(c);for(const i of h)i.removeFeatureState(g,b.id,d)}getFeatureState(b){this._checkLoaded();const c=b.source,d=b.sourceLayer,e=this.getSource(c);if(void 0!==e){if("vector"!==e.type||d)return void 0===b.id&&this.fire(new a.ErrorEvent(new Error("The feature id parameter must be provided."))),this._getSourceCaches(c)[0].getFeatureState(d,b.id);this.fire(new a.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new a.ErrorEvent(new Error(`The source '${c}' does not exist in the map's style.`)))}getTransition(){return a.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const b={};for(const d in this._sourceCaches){const c=this._sourceCaches[d].getSource();b[c.id]||(b[c.id]=c.serialize())}return a.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,terrain:this.stylesheet.terrain,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:b,layers:this._serializeLayers(this._order)},a=>void 0!==a)}_updateLayer(a){this._updatedLayers[a.id]=!0;const b=this._getLayerSourceCache(a);a.source&&!this._updatedSources[a.source]&&b&&"raster"!==b.getSource().type&&(this._updatedSources[a.source]="reload",b.pause()),this._changed=!0,a.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(g){var h,i;const j={},a=[];for(let b=this._order.length-1;b>=0;b--){const d=this._order[b];if(h=d,"fill-extrusion"===this._layers[h].type)for(const o of(j[d]=b,g)){const k=o[d];if(k)for(const p of k)a.push(p)}}a.sort((a,b)=>b.intersectionZ-a.intersectionZ);const e=[];for(let c=this._order.length-1;c>=0;c--){const l=this._order[c];if(i=l,"fill-extrusion"===this._layers[i].type)for(let f=a.length-1;f>=0;f--){const m=a[f].feature;if(j[m.layer.id]{const a=this.getLayer(b);return a&&a.is3D()}):this.has3DLayers(),h=_.createFromScreenPoints(j,d);for(const i in this._sourceCaches){const l=this._sourceCaches[i].getSource().id;b.layers&&!e[l]||c.push(ai(this._sourceCaches[i],this._layers,this._serializedLayers,h,b,d,k,!!this.map._showQueryGeometry))}return this.placement&&c.push(function(i,j,r,k,c,l,m){const a={},f=l.queryRenderedSymbols(k),d=[];for(const n of Object.keys(f).map(Number))d.push(m[n]);for(const b of(d.sort(ak),d)){const g=b.featureIndex.lookupSymbolFeatures(f[b.bucketInstanceId],j,b.bucketIndex,b.sourceLayerIndex,c.filter,c.layers,c.availableImages,i);for(const e in g){const o=a[e]=a[e]||[],h=g[e];for(const p of(h.sort((c,d)=>{const a=b.featureSortOrder;if(a){const e=a.indexOf(c.featureIndex);return a.indexOf(d.featureIndex)-e}return d.featureIndex-c.featureIndex}),h))o.push(p)}}for(const q in a)a[q].forEach(b=>{const a=b.feature,c=r(i[q]).getFeatureState(a.layer["source-layer"],a.id);a.source=a.layer.source,a.layer["source-layer"]&&(a.sourceLayer=a.layer["source-layer"]),a.state=c});return a}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),h.screenGeometry,b,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(c)}querySourceFeatures(d,b){b&&b.filter&&this._validate(a.validateStyle.filter,"querySourceFeatures.filter",b.filter,null,b);const e=this._getSourceCaches(d);let c=[];for(const f of e)c=c.concat(aj(f,b));return c}addSourceType(a,b,d){return c.getSourceType(a)?d(new Error(`A source type called "${a}" already exists.`)):(c.setSourceType(a,b),b.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:a,url:b.workerSourceURL},d):d(null,null))}getLight(){return this.light.getLight()}setLight(b,e={}){this._checkLoaded();const f=this.light.getLight();let c=!1;for(const d in b)if(!D(b[d],f[d])){c=!0;break}if(!c)return;const g={now:a.exported.now(),transition:a.extend({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(b,e),this.light.updateTransitions(g)}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}setTerrain(b,c=1){if(this._checkLoaded(),!b)return delete this.terrain,delete this.stylesheet.terrain,this.dispatcher.broadcast("enableTerrain",!1),this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);if(1===c){if("object"==typeof b.source){const e="terrain-dem-src";this.addSource(e,b.source),b=a.clone$1(b),b=a.extend(b,{source:e})}if(this._validate(a.validateStyle.terrain,"terrain",b))return}if(!this.terrain||this.terrain&&c!==this.terrain.drapeRenderMode)this._createTerrain(b,c);else{const d=this.terrain,g=d.get();for(const f in b)if(!D(b[f],g[f])){d.set(b),this.stylesheet.terrain=b;const h={now:a.exported.now(),transition:a.extend({duration:0},this.stylesheet.transition)};d.updateTransitions(h);break}}this._updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(b){const c=this.fog=new U(b,this.map.transform);this.stylesheet.fog=b;const d={now:a.exported.now(),transition:a.extend({duration:0},this.stylesheet.transition)};c.updateTransitions(d)}_updateMarkersOpacity(){0!==this.map._markers.length&&this.map._requestDomTask(()=>{for(const a of this.map._markers)a._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(b){if(this._checkLoaded(),!b)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const c=this.fog,e=c.get();for(const d in b)if(!D(b[d],e[d])){c.set(b),this.stylesheet.fog=b;const f={now:a.exported.now(),transition:a.extend({duration:0},this.stylesheet.transition)};c.updateTransitions(f);break}}else this._createFog(b);this._markersNeedUpdate=!0}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const a=this._order.filter(a=>this.isLayerDraped(this._layers[a])),b=this._order.filter(a=>!this.isLayerDraped(this._layers[a]));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...a),this._drapedFirstOrder.push(...b)}_createTerrain(b,c){const d=this.terrain=new P(b,c);this.stylesheet.terrain=b,this.dispatcher.broadcast("enableTerrain",!0),this._force3DLayerUpdate();const e={now:a.exported.now(),transition:a.extend({duration:0},this.stylesheet.transition)};d.updateTransitions(e)}_force3DLayerUpdate(){for(const b in this._layers){const a=this._layers[b];"fill-extrusion"===a.type&&this._updateLayer(a)}}_forceSymbolLayerUpdate(){for(const b in this._layers){const a=this._layers[b];"symbol"===a.type&&this._updateLayer(a)}}_validate(c,d,e,f,b={}){return(!b|| !1!==b.validate)&&a3(this,c.call(a.validateStyle,a.extend({key:d,style:this.serialize(),value:e,styleSpec:a.spec},f)))}_remove(){for(const c in this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),a.evented.off("pluginStateChange",this._rtlTextPluginCallback),this._layers)this._layers[c].setEventedParent(null);for(const b in this._sourceCaches)this._sourceCaches[b].clearTiles(),this._sourceCaches[b].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(a){const b=this._getSourceCaches(a);for(const c of b)c.clearTiles()}_reloadSource(b){const c=this._getSourceCaches(b);for(const a of c)a.resume(),a.reload()}_updateSources(a){for(const b in this._sourceCaches)this._sourceCaches[b].update(a)}_generateCollisionBoxes(){for(const b in this._sourceCaches){const a=this._sourceCaches[b];a.resume(),a.reload()}}_updatePlacement(c,k,h,l,e=!1){let f=!1,i=!1;const d={};for(const m of this._order){const b=this._layers[m];if("symbol"!==b.type)continue;if(!d[b.source]){const j=this._getLayerSourceCache(b);if(!j)continue;d[b.source]=j.getRenderableIds(!0).map(a=>j.getTileByID(a)).sort((a,b)=>b.tileID.overscaledZ-a.tileID.overscaledZ||(a.tileID.isLessThan(b.tileID)?-1:1))}const n=this.crossTileSymbolIndex.addLayer(b,d[b.source],c.center.lng,c.projection);f=f||n}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),e=e||this._layerOrderChanged||0===h,this._layerOrderChanged&&this.fire(new a.Event("neworder")),(e||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(a.exported.now(),c.zoom))&&(this.pauseablePlacement=new a$(c,this._order,e,k,h,l,this.placement,this.fog&&c.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,d),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(a.exported.now()),i=!0),f&&this.pauseablePlacement.placement.setStale()),i||f)for(const o of this._order){const g=this._layers[o];"symbol"===g.type&&this.placement.updateLayerOpacities(g,d[g.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(a.exported.now())}_releaseSymbolFadeTiles(){for(const a in this._sourceCaches)this._sourceCaches[a].releaseSymbolFadeTiles()}getImages(d,a,c){this.imageManager.getImages(a.icons,c),this._updateTilesForChangedImages();const b=b=>{b&&b.setDependencies(a.tileID.key,a.type,a.icons)};b(this._otherSourceCaches[a.source]),b(this._symbolSourceCaches[a.source])}getGlyphs(c,a,b){this.glyphManager.getGlyphs(a.stacks,b)}getResource(d,b,c){return a.makeRequest(b,c)}_getSourceCache(a){return this._otherSourceCaches[a]}_getLayerSourceCache(a){return"symbol"===a.type?this._symbolSourceCaches[a.source]:this._otherSourceCaches[a.source]}_getSourceCaches(a){const b=[];return this._otherSourceCaches[a]&&b.push(this._otherSourceCaches[a]),this._symbolSourceCaches[a]&&b.push(this._symbolSourceCaches[a]),b}has3DLayers(){return this._num3DLayers>0}hasSymbolLayers(){return this._numSymbolLayers>0}hasCircleLayers(){return this._numCircleLayers>0}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}destroy(){this._clearWorkerCaches(),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}c.getSourceType=function(a){return af[a]},c.setSourceType=function(a,b){af[a]=b},c.registerForPluginStateChange=a.registerForPluginStateChange;var t="\n#define EPSILON 0.0000001\n#define PI 3.141592653589793\n#define EXTENT 8192.0\n#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;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);}\n#endif",j="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;}";let u={},v={};u=bb("","\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\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nuniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;\n#else\nuniform sampler2D u_dem;uniform 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*texture2D(u_dem,pos).a;\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));\n#ifdef TERRAIN_DEM_NEAREST_FILTER\nreturn u_exaggeration*tl;\n#endif\nfloat 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*texture2D(u_dem_prev,pos).a;\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) {float nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}\n#else\nfloat elevation(vec2 apos) {return currentElevation(apos);}\n#endif\nfloat unpack_depth(vec4 rgba_depth)\n{const vec4 bit_shift=vec4(1.0/(256.0*256.0*256.0),1.0/(256.0*256.0),1.0/256.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=texture2D(u_dem,pos).a;float tr=texture2D(u_dem,pos+vec2(off.x,0.0)).a;float bl=texture2D(u_dem,pos+vec2(0.0,off.y)).a;float br=texture2D(u_dem,pos+off).a;\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;vec4 bounds=vec4(d,vec2(1.0)-d);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",!0),v=bb("#ifdef FOG\nuniform float u_fog_temporal_offset;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=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;}vec3 fog_dither(vec3 color) {vec2 dither_seed=gl_FragCoord.xy+u_fog_temporal_offset;return dither(color,dither_seed);}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}\n#endif","#ifdef FOG\nuniform mat4 u_fog_matrix;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",!0);const a8=bb("\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;}\n#ifdef TERRAIN\nhighp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(256.0*256.0*256.0,256.0*256.0,256.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/256.0,1.0/256.0,1.0/256.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}\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;}vec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {\n#if defined(PROJECTION_GLOBE_VIEW) && !defined(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) {\n#if defined(PROJECTION_GLOBE_VIEW) && !defined(PROJECTED_POS_ON_VIEWPORT)\nreturn mix(globe,mercator,t);\n#else\nreturn globe;\n#endif\n}\n#ifdef PROJECTION_GLOBE_VIEW\nmat3 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;}const vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);//Normalized device coordinate that is not rendered."),a9=t;var ba={background:bb("uniform vec4 u_color;uniform float u_opacity;void main() {vec4 out_color=u_color;\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\n}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),backgroundPattern:bb("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_mix);\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\n}","uniform mat4 u_matrix;uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),circle:bb("varying 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\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);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 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}","#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;attribute float a_scale;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);\n#ifdef PROJECTION_GLOBE_VIEW\nvec2 scaled_extrude=extrude*a_scale;vec3 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=scaled_extrude.x*surface_vectors[0]+scaled_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);vec4 world_center=vec4(pos,1);\n#else \nmat3 surface_vectors=mat3(1.0);float height=circle_elevation(circle_center);vec4 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\n#if defined(SCALE_WITH_MAP) && defined(PROJECTION_GLOBE_VIEW)\nview_scale*=a_scale;\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();\n#ifdef PITCH_WITH_MAP\nfloat cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);vec4 occlusion_world_center=vec4(circle_center,cantilevered_height,1);vec4 occlusion_projected_center=u_matrix*occlusion_world_center;\n#else\nvec4 occlusion_world_center=world_center;vec4 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:bb("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:bb("uniform 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\ngl_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\n}","uniform 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;attribute float a_scale;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);\n#ifdef PROJECTION_GLOBE_VIEW\nextrude*=a_scale;vec3 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;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#else\nvec3 pos=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:bb("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\n}","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:bb("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));}","attribute 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:bb("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:bb("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);}","attribute 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:bb("#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\nvec4 out_color=color;\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\n}","attribute 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:bb("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\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 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\n}","attribute 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:bb("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=mix(color1,color2,u_fade);\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\n}","uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillPattern:bb("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_fade);\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\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillExtrusion:bb("varying vec4 v_color;void main() {vec4 color=v_color;\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\n}","uniform 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;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 vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;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));base=max(0.0,base);height=max(0.0,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\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==0.0 ?-5.0 : base);vec3 pos=vec3(pos_nx.xy,h);\n#else\nvec3 pos=vec3(pos_nx.xy,t > 0.0 ? height : base);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_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*(pos.z+lift));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);float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;float directional=clamp(dot(normal,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.rgb+=clamp(color.rgb*directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity;\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),fillExtrusionPattern:bb("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_fade);out_color=out_color*v_lighting;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform 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_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;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_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;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\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==0.0 ?-5.0 : base);vec3 p=vec3(pos_nx.xy,h);\n#else\nvec3 p=vec3(pos_nx.xy,z);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_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_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;\n#ifdef FOG\nv_fog_pos=fog_position(p);\n#endif\n}"),hillshadePrepare:bb("#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 texture2D(u_image,coord).a/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);float f=getElevation(v_pos+vec2(epsilon.x,0));float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float h=getElevation(v_pos+vec2(0,epsilon.y));float i=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+f+f+i)-(a+d+d+g),(g+h+h+i)-(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);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","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:bb("uniform 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;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 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\n}","uniform 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:bb("uniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;\n#ifdef RENDER_LINE_DASH\nuniform sampler2D u_dash_image;uniform float u_mix;uniform vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;varying highp vec2 v_uv;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash_from\n#pragma mapbox: define lowp vec4 dash_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash_from\n#pragma mapbox: initialize lowp vec4 dash_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);\n#ifdef RENDER_LINE_DASH\nfloat sdfdist_a=texture2D(u_dash_image,v_tex_a).a;float sdfdist_b=texture2D(u_dash_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfwidth=min(dash_from.z*u_scale.y,dash_to.z*u_scale.z);float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/sdfwidth;alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);\n#endif\n#ifdef RENDER_LINE_GRADIENT\nvec4 out_color=texture2D(u_gradient_image,v_uv);\n#else\nvec4 out_color=color;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef RENDER_LINE_ALPHA_DISCARD\nif (alpha < u_alpha_discard_threshold) {discard;}\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define EXTRUDE_SCALE 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;\n#ifdef RENDER_LINE_GRADIENT\nattribute vec3 a_packed;\n#else\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;\n#ifdef RENDER_LINE_DASH\nuniform vec2 u_texsize;uniform mediump vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform float u_image_height;varying highp vec2 v_uv;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash_from\n#pragma mapbox: define lowp vec4 dash_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash_from\n#pragma mapbox: initialize lowp vec4 dash_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;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#ifdef RENDER_LINE_GRADIENT\nfloat a_uv_x=a_packed[0];float a_split_index=a_packed[1];float a_linesofar=a_packed[2];highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);\n#endif\n#ifdef RENDER_LINE_DASH\nfloat tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;float scaleA=dash_from.z==0.0 ? 0.0 : tileZoomRatio/(dash_from.z*fromScale);float scaleB=dash_to.z==0.0 ? 0.0 : tileZoomRatio/(dash_to.z*toScale);float heightA=dash_from.y;float heightB=dash_to.y;v_tex_a=vec2(a_linesofar*scaleA/floorwidth,(-normal.y*heightA+dash_from.x+0.5)/u_texsize.y);v_tex_b=vec2(a_linesofar*scaleB/floorwidth,(-normal.y*heightB+dash_to.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:bb("uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;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_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\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_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;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:bb("uniform 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;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(\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 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\n}","uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {float w=1.0+dot(a_texture_pos,u_perspective_transform);gl_Position=u_matrix*vec4(a_pos*w,0,w);v_pos0=a_texture_pos/8192.0;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),symbolIcon:bb("uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_z_tile_anchor;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;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;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_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_minFontScale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}float anchorZ=a_z_tile_anchor.x;vec2 tileAnchor=a_z_tile_anchor.yz;vec3 h=elevationVector(tileAnchor)*elevation(tileAnchor);vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tileAnchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(vec3(a_pos,anchorZ)+h,mercator_pos,u_zoom_transition);vec4 projectedPoint=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\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 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),anchorZ,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec3 proj_pos=mix_globe_mercator(vec3(a_projected_pos.xy,anchorZ),mercator_pos,u_zoom_transition);\n#ifdef PROJECTED_POS_ON_VIEWPORT\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,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_minFontScale,fontScale)+a_pxoffset/16.0);\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\nfloat occlusion_fade=occlusionFade(projectedPoint);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projectedPoint.w <=0.0 || occlusion_fade==0.0));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\nv_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;v_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change))*projection_transition_fade;}"),symbolSDF:bb("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying 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\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\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;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_z_tile_anchor;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_tile_id;uniform float u_zoom_transition;varying 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\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_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[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}float anchorZ=a_z_tile_anchor.x;vec2 tileAnchor=a_z_tile_anchor.yz;vec3 h=elevationVector(tileAnchor)*elevation(tileAnchor);vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tileAnchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(vec3(a_pos,anchorZ)+h,mercator_pos,u_zoom_transition);vec4 projectedPoint=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\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 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),anchorZ,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec3 proj_pos=mix_globe_mercator(vec3(a_projected_pos.xy,anchorZ),mercator_pos,u_zoom_transition);\n#ifdef PROJECTED_POS_ON_VIEWPORT\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,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 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\nfloat occlusion_fade=occlusionFade(projectedPoint);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projectedPoint.w <=0.0 || occlusion_fade==0.0));float gamma_scale=gl_Position.w;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));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade);}"),symbolTextAndIcon:bb("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying 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\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\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;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_z_tile_anchor;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;varying 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\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_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[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}float anchorZ=a_z_tile_anchor.x;vec2 tileAnchor=a_z_tile_anchor.yz;vec3 h=elevationVector(tileAnchor)*elevation(tileAnchor);vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tileAnchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(vec3(a_pos,anchorZ)+h,mercator_pos,u_zoom_transition);vec4 projectedPoint=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),anchorZ,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec3 proj_pos=mix_globe_mercator(vec3(a_projected_pos.xy,anchorZ),mercator_pos,u_zoom_transition);\n#ifdef PROJECTED_POS_ON_VIEWPORT\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,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);\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\nfloat occlusion_fade=occlusionFade(projectedPoint);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projectedPoint.w <=0.0 || occlusion_fade==0.0));float gamma_scale=gl_Position.w;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\nv_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade,is_sdf);}"),terrainRaster:bb("uniform sampler2D u_image0;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\nvoid main() {vec4 color=texture2D(u_image0,v_pos0);\n#ifdef FOG\ncolor=fog_dither(fog_apply_from_vert(color,v_fog_opacity));\n#endif\ngl_FragColor=color;\n#ifdef TERRAIN_WIREFRAME\ngl_FragColor=vec4(1.0,0.0,0.0,0.8);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_skirt_height;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\nconst float skirtOffset=24575.0;const float wireframeOffset=0.00015;void main() {v_pos0=a_texture_pos/8192.0;float skirt=float(a_pos.x >=skirtOffset);float elevation=elevation(a_texture_pos)-skirt*u_skirt_height;\n#ifdef TERRAIN_WIREFRAME\nelevation+=u_skirt_height*u_skirt_height*wireframeOffset;\n#endif\nvec2 decodedPos=a_pos-vec2(skirt*skirtOffset,0.0);gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);\n#ifdef FOG\nv_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));\n#endif\n}"),terrainDepth:bb("#ifdef GL_ES\nprecision highp float;\n#endif\nvarying float v_depth;void main() {gl_FragColor=pack_depth(v_depth);}","uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying float v_depth;void main() {float elevation=elevation(a_texture_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}"),skybox:bb("\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}",j),skyboxGradient:bb("varying 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}",j),skyboxCapture:bb("\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:bb("uniform sampler2D u_image0;varying vec2 v_pos0;void main() {gl_FragColor=texture2D(u_image0,v_pos0);\n#ifdef TERRAIN_WIREFRAME\ngl_FragColor=vec4(1.0,0.0,0.0,0.8);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_proj_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;attribute vec3 a_globe_pos;attribute vec2 a_merc_pos;attribute vec2 a_uv;varying vec2 v_pos0;const float wireframeOffset=1e3;void main() {v_pos0=a_uv;vec2 uv=a_uv*EXTENT;vec4 up_vector=vec4(elevationVector(uv),1.0);float height=elevation(uv);\n#ifdef TERRAIN_WIREFRAME\nheight+=wireframeOffset;\n#endif\nvec4 globe=u_globe_matrix*vec4(a_globe_pos+up_vector.xyz*height,1.0);vec4 mercator=vec4(0.0);if (u_zoom_transition > 0.0) {mercator=vec4(a_merc_pos,height,1.0);mercator.xy-=u_merc_center;mercator.x=wrap(mercator.x,-0.5,0.5);mercator=u_merc_matrix*mercator;}vec3 position=mix(globe.xyz,mercator.xyz,u_zoom_transition);gl_Position=u_proj_matrix*vec4(position,1.0);}"),globeAtmosphere:bb("uniform vec2 u_center;uniform float u_radius;uniform vec2 u_screen_size;uniform float u_opacity;uniform highp float u_fadeout_range;uniform vec3 u_start_color;uniform vec3 u_end_color;uniform float u_pixel_ratio;void main() {highp vec2 fragCoord=gl_FragCoord.xy/u_pixel_ratio;fragCoord.y=u_screen_size.y-fragCoord.y;float distFromCenter=length(fragCoord-u_center);float normDistFromCenter=length(fragCoord-u_center)/u_radius;if (normDistFromCenter < 1.0)\ndiscard;float t=clamp(1.0-sqrt(normDistFromCenter-1.0)/u_fadeout_range,0.0,1.0);vec3 color=mix(u_start_color,u_end_color,1.0-t);gl_FragColor=vec4(color*t*u_opacity,u_opacity);}","attribute vec3 a_pos;void main() {gl_Position=vec4(a_pos,1.0);}")};function bb(c,b,h){const e=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,d=/uniform (highp |mediump |lowp )?([\w]+) ([\w]+)([\s]*)([\w]*)/g,i=b.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),f=c.match(d),g=b.match(d),j=t.match(d);let a=g?g.concat(f):f;h||(u.staticUniforms&&(a=u.staticUniforms.concat(a)),v.staticUniforms&&(a=v.staticUniforms.concat(a))),a&&(a=a.concat(j));const k={};return{fragmentSource:c=c.replace(e,(e,d,b,c,a)=>(k[a]=!0,"define"===d?` +Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(l[1])} }\`.`),];const k=[];return"symbol"===b.layerType&&("text-field"===c&&e&&!e.glyphs&&k.push(new cc(d,a,'use of "text-field" requires a style "glyphs" property')),"text-font"===c&&gn(fq(a))&&"identity"===fp(a.type)&&k.push(new cc(d,a,'"text-font" does not support identity functions'))),k.concat(gR({key:b.key,value:a,valueSpec:h,style:e,styleSpec:f,expressionContext:"property",propertyType:i,propertyKey:c}))}function cW(a){return gO(a,"paint")}function cX(a){return gO(a,"layout")}function a0(d){let b=[];const a=d.value,c=d.key,g=d.style,l=d.styleSpec;a.type||a.ref||b.push(new cc(c,a,'either "type" or "ref" is required'));let e=fp(a.type);const m=fp(a.ref);if(a.id){const n=fp(a.id);for(let i=0;i{d in a&&b.push(new cc(c,a[d],`"${d}" is prohibited for ref layers`))}),g.layers.forEach(a=>{fp(a.id)===m&&(j=a)}),j?j.ref?b.push(new cc(c,a.ref,"ref cannot reference another ref layer")):e=fp(j.type):b.push(new cc(c,a.ref,`ref layer "${m}" not found`))}else if("background"!==e&&"sky"!==e){if(a.source){const h=g.sources&&g.sources[a.source],f=h&&fp(h.type);h?"vector"===f&&"raster"===e?b.push(new cc(c,a.source,`layer "${a.id}" requires a raster source`)):"raster"===f&&"raster"!==e?b.push(new cc(c,a.source,`layer "${a.id}" requires a vector source`)):"vector"!==f||a["source-layer"]?"raster-dem"===f&&"hillshade"!==e?b.push(new cc(c,a.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"===e&&a.paint&&a.paint["line-gradient"]&&("geojson"!==f||!h.lineMetrics)&&b.push(new cc(c,a,`layer "${a.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):b.push(new cc(c,a,`layer "${a.id}" must specify a "source-layer"`)):b.push(new cc(c,a.source,`source "${a.source}" not found`))}else b.push(new cc(c,a,'missing required property "source"'))}return b=b.concat(cR({key:c,value:a,valueSpec:l.layer,style:d.style,styleSpec:d.styleSpec,objectElementValidators:{"*":()=>[],type:()=>gR({key:`${c}.type`,value:a.type,valueSpec:l.layer.type,style:d.style,styleSpec:d.styleSpec,object:a,objectKey:"type"}),filter:a=>a_(ce({layerType:e},a)),layout:b=>cR({layer:a,key:b.key,value:b.value,style:b.style,styleSpec:b.styleSpec,objectElementValidators:{"*":a=>cX(ce({layerType:e},a))}}),paint:b=>cR({layer:a,key:b.key,value:b.value,style:b.style,styleSpec:b.styleSpec,objectElementValidators:{"*":a=>cW(ce({layerType:e},a))}})}}))}function cY(a){const b=a.value,d=a.key,c=gm(b);return"string"!==c?[new cc(d,b,`string expected, ${c} found`)]:[]}const gP={promoteId:function({key:b,value:a}){if("string"===gm(a))return cY({key:b,value:a});{const c=[];for(const d in a)c.push(...cY({key:`${b}.${d}`,value:a[d]}));return c}}};function a1(d){const a=d.value,b=d.key,c=d.styleSpec,e=d.style;if(!a.type)return[new cc(b,a,'"type" is required')];const i=fp(a.type);let f;switch(i){case"vector":case"raster":case"raster-dem":return cR({key:b,value:a,valueSpec:c[`source_${i.replace("-","_")}`],style:d.style,styleSpec:c,objectElementValidators:gP});case"geojson":if(f=cR({key:b,value:a,valueSpec:c.source_geojson,style:e,styleSpec:c,objectElementValidators:gP}),a.cluster)for(const g in a.clusterProperties){const[h,j]=a.clusterProperties[g],k="string"==typeof h?[h,["accumulated"],["get",g],]:h;f.push(...gy({key:`${b}.${g}.map`,value:j,expressionContext:"cluster-map"})),f.push(...gy({key:`${b}.${g}.reduce`,value:k,expressionContext:"cluster-reduce"}))}return f;case"video":return cR({key:b,value:a,valueSpec:c.source_video,style:e,styleSpec:c});case"image":return cR({key:b,value:a,valueSpec:c.source_image,style:e,styleSpec:c});case"canvas":return[new cc(b,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas"),];default:return cV({key:`${b}.type`,value:a.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image",]},style:e,styleSpec:c})}}function a2(f){const b=f.value,d=f.styleSpec,e=d.light,h=f.style;let c=[];const i=gm(b);if(void 0===b)return c;if("object"!==i)return c.concat([new cc("light",b,`object expected, ${i} found`),]);for(const a in b){const g=a.match(/^(.*)-transition$/);c=c.concat(g&&e[g[1]]&&e[g[1]].transition?gR({key:a,value:b[a],valueSpec:d.transition,style:h,styleSpec:d}):e[a]?gR({key:a,value:b[a],valueSpec:e[a],style:h,styleSpec:d}):[new cc(a,b[a],`unknown property "${a}"`),])}return c}function a3(d){const a=d.value,h=d.key,e=d.style,f=d.styleSpec,g=f.terrain;let c=[];const k=gm(a);if(void 0===a)return c;if("object"!==k)return c.concat([new cc("terrain",a,`object expected, ${k} found`),]);for(const b in a){const i=b.match(/^(.*)-transition$/);c=c.concat(i&&g[i[1]]&&g[i[1]].transition?gR({key:b,value:a[b],valueSpec:f.transition,style:e,styleSpec:f}):g[b]?gR({key:b,value:a[b],valueSpec:g[b],style:e,styleSpec:f}):[new cc(b,a[b],`unknown property "${b}"`),])}if(a.source){const j=e.sources&&e.sources[a.source],l=j&&fp(j.type);j?"raster-dem"!==l&&c.push(new cc(h,a.source,`terrain cannot be used with a source of type ${l}, it only be used with a "raster-dem" source type`)):c.push(new cc(h,a.source,`source "${a.source}" not found`))}else c.push(new cc(h,a,'terrain is missing required property "source"'));return c}function a4(f){const b=f.value,h=f.style,d=f.styleSpec,e=d.fog;let c=[];const i=gm(b);if(void 0===b)return c;if("object"!==i)return c.concat([new cc("fog",b,`object expected, ${i} found`),]);for(const a in b){const g=a.match(/^(.*)-transition$/);c=c.concat(g&&e[g[1]]&&e[g[1]].transition?gR({key:a,value:b[a],valueSpec:d.transition,style:h,styleSpec:d}):e[a]?gR({key:a,value:b[a],valueSpec:e[a],style:h,styleSpec:d}):[new cc(a,b[a],`unknown property "${a}"`),])}return c}const gQ={"*":()=>[],array:cS,boolean:function(a){const b=a.value,d=a.key,c=gm(b);return"boolean"!==c?[new cc(d,b,`boolean expected, ${c} found`),]:[]},number:cT,color:function(b){const c=b.key,a=b.value,d=gm(a);return"string"!==d?[new cc(c,a,`color expected, ${d} found`),]:null===fy.parseCSSColor(a)?[new cc(c,a,`color expected, "${a}" found`),]:[]},constants:cd,enum:cV,filter:a_,function:cU,layer:a0,object:cR,source:a1,light:a2,terrain:a3,fog:a4,string:cY,formatted:function(a){return 0===cY(a).length?[]:gy(a)},resolvedImage:function(a){return 0===cY(a).length?[]:gy(a)},projection:function(c){const b=c.value,f=c.styleSpec,g=f.projection,h=c.style;let a=[];const d=gm(b);if("object"===d)for(const e in b)a=a.concat(gR({key:e,value:b[e],valueSpec:g[e],style:h,styleSpec:f}));else"string"!==d&&(a=a.concat([new cc("projection",b,`object or string expected, ${d} found`),]));return a}};function gR(b){const c=b.value,a=b.valueSpec,d=b.styleSpec;return a.expression&&gn(fp(c))?cU(b):a.expression&&gv(fq(c))?gy(b):a.type&&gQ[a.type]?gQ[a.type](b):cR(ce({},b,{valueSpec:a.type?d[a.type]:a}))}function gS(c){const a=c.value,d=c.key,b=cY(c);return b.length||(-1===a.indexOf("{fontstack}")&&b.push(new cc(d,a,'"glyphs" url must include a "{fontstack}" token')),-1===a.indexOf("{range}")&&b.push(new cc(d,a,'"glyphs" url must include a "{range}" token'))),b}function t(a,d=b){let c=[];return c=c.concat(gR({key:"",value:a,valueSpec:d.$root,styleSpec:d,style:a,objectElementValidators:{glyphs:gS,"*":()=>[]}})),a.constants&&(c=c.concat(cd({key:"constants",value:a.constants,style:a,styleSpec:d}))),gT(c)}function gT(a){return[].concat(a).sort((a,b)=>a.line-b.line)}function v(a){return function(...b){return gT(a.apply(this,b))}}t.source=v(a1),t.light=v(a2),t.terrain=v(a3),t.fog=v(a4),t.layer=v(a0),t.filter=v(a_),t.paintProperty=v(cW),t.layoutProperty=v(cX);const M=t,cZ=M.light,c$=M.fog,gU=M.paintProperty,gV=M.layoutProperty;function c_(c,a){let b=!1;if(a&&a.length)for(const d of a)c.fire(new cb(new Error(d.message))),b=!0;return b}var aj=u;function u(b,c,d){var e=this.cells=[];if(b instanceof ArrayBuffer){this.arrayBuffer=b;var a=new Int32Array(this.arrayBuffer);b=a[0],this.d=(c=a[1])+2*(d=a[2]);for(var f=0;f=a[b+0]&&k>=a[b+1])?(d[c]=!0,m.push(n[c])):d[c]=!1}}},u.prototype._forEachCell=function(d,e,f,g,h,i,j,c){for(var k=this._convertToCellCoord(d),l=this._convertToCellCoord(e),m=this._convertToCellCoord(f),n=this._convertToCellCoord(g),a=k;a<=m;a++)for(var b=l;b<=n;b++){var o=this.d*b+a;if((!c||c(this._convertFromCellCoord(a),this._convertFromCellCoord(b),this._convertFromCellCoord(a+1),this._convertFromCellCoord(b+1)))&&h.call(this,d,e,f,g,o,i,j,c))return}},u.prototype._convertFromCellCoord=function(a){return(a-this.padding)/this.scale},u.prototype._convertToCellCoord=function(a){return Math.max(0,Math.min(this.d-1,Math.floor(a*this.scale)+this.padding))},u.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var c=this.cells,f=3+this.cells.length+1+1,g=0,e=0;e=0)continue;const i=a[e];d[e]=gY[c].shallow.indexOf(e)>=0?i:g_(i,b)}a instanceof Error&&(d.message=a.message)}if(d.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==c&&(d.$name=c),d}throw new Error("can't serialize object of type "+typeof a)}function g0(a){if(null==a||"boolean"==typeof a||"number"==typeof a||"string"==typeof a||a instanceof Boolean||a instanceof Number||a instanceof String||a instanceof Date||a instanceof RegExp||gZ(a)||g$(a)||ArrayBuffer.isView(a)||a instanceof gW)return a;if(Array.isArray(a))return a.map(g0);if("object"==typeof a){const d=a.$name||"Object",{klass:b}=gY[d];if(!b)throw new Error(`can't deserialize unregistered class ${d}`);if(b.deserialize)return b.deserialize(a);const e=Object.create(b.prototype);for(const c of Object.keys(a)){if("$name"===c)continue;const f=a[c];e[c]=gY[d].shallow.indexOf(c)>=0?f:g0(f)}return e}throw new Error("can't deserialize object of type "+typeof a)}class c0{constructor(){this.first=!0}update(b,c){const a=Math.floor(b);return this.first?(this.first=!1,this.lastIntegerZoom=a,this.lastIntegerZoomTime=0,this.lastZoom=b,this.lastFloorZoom=a,!0):(this.lastFloorZoom>a?(this.lastIntegerZoom=a+1,this.lastIntegerZoomTime=c):this.lastFloorZooma>=1536&&a<=1791,g2=a=>a>=1872&&a<=1919,g3=a=>a>=2208&&a<=2303,g4=a=>a>=11904&&a<=12031,g5=a=>a>=12032&&a<=12255,g6=a=>a>=12272&&a<=12287,g7=a=>a>=12288&&a<=12351,g8=a=>a>=12352&&a<=12447,g9=a=>a>=12448&&a<=12543,ha=a=>a>=12544&&a<=12591,hb=a=>a>=12704&&a<=12735,hc=a=>a>=12736&&a<=12783,hd=a=>a>=12784&&a<=12799,he=a=>a>=12800&&a<=13055,hf=a=>a>=13056&&a<=13311,hg=a=>a>=13312&&a<=19903,hh=a=>a>=19968&&a<=40959,hi=a=>a>=40960&&a<=42127,hj=a=>a>=42128&&a<=42191,hk=a=>a>=44032&&a<=55215,hl=a=>a>=63744&&a<=64255,hm=a=>a>=64336&&a<=65023,hn=a=>a>=65040&&a<=65055,ho=a=>a>=65072&&a<=65103,hp=a=>a>=65104&&a<=65135,hq=a=>a>=65136&&a<=65279,hr=a=>a>=65280&&a<=65519;function hs(a){for(const b of a)if(hv(b.charCodeAt(0)))return!0;return!1}function ht(a){for(const b of a)if(!hu(b.charCodeAt(0)))return!1;return!0}function hu(a){return!(g1(a)||g2(a)||g3(a)||hm(a)||hq(a))}function hv(a){var b,c,d,e,f,g,h,i;return!(746!==a&&747!==a&&(a<4352||!(hb(a)||ha(a)||ho(a)&&!(a>=65097&&a<=65103)||hl(a)||hf(a)||g4(a)||hc(a)||!(!g7(a)||a>=12296&&a<=12305||a>=12308&&a<=12319||12336===a)||hg(a)||hh(a)||he(a)||(b=a)>=12592&&b<=12687||(c=a)>=43360&&c<=43391||(d=a)>=55216&&d<=55295||(e=a)>=4352&&e<=4607||hk(a)||g8(a)||g6(a)||(f=a)>=12688&&f<=12703||g5(a)||hd(a)||g9(a)&&12540!==a||!(!hr(a)||65288===a||65289===a||65293===a||a>=65306&&a<=65310||65339===a||65341===a||65343===a||a>=65371&&a<=65503||65507===a||a>=65512&&a<=65519)||!(!hp(a)||a>=65112&&a<=65118||a>=65123&&a<=65126)||(g=a)>=5120&&g<=5759||(h=a)>=6320&&h<=6399||hn(a)||(i=a)>=19904&&i<=19967||hi(a)||hj(a))))}function hw(b){var a,c,d,e,f,g,h,i,j,k,l,m,n;return!(hv(b)||(c=a=b)>=128&&c<=255&&(167===a||169===a||174===a||177===a||188===a||189===a||190===a||215===a||247===a)||(d=a)>=8192&&d<=8303&&(8214===a||8224===a||8225===a||8240===a||8241===a||8251===a||8252===a||8258===a||8263===a||8264===a||8265===a||8273===a)||(e=a)>=8448&&e<=8527||(f=a)>=8528&&f<=8591||(g=a)>=8960&&g<=9215&&(a>=8960&&a<=8967||a>=8972&&a<=8991||a>=8996&&a<=9e3||9003===a||a>=9085&&a<=9114||a>=9150&&a<=9165||9167===a||a>=9169&&a<=9179||a>=9186&&a<=9215)||(h=a)>=9216&&h<=9279&&9251!==a||(i=a)>=9280&&i<=9311||(j=a)>=9312&&j<=9471||(k=a)>=9632&&k<=9727||(l=a)>=9728&&l<=9983&&!(a>=9754&&a<=9759)||(m=a)>=11008&&m<=11263&&(a>=11026&&a<=11055||a>=11088&&a<=11097||a>=11192&&a<=11243)||g7(a)||g9(a)||(n=a)>=57344&&n<=63743||ho(a)||hp(a)||hr(a)||8734===a||8756===a||8757===a||a>=9984&&a<=10087||a>=10102&&a<=10131||65532===a||65533===a)}function hx(a){return a>=1424&&a<=2303||hm(a)||hq(a)}function hy(a,c){var b;return!(!c&&hx(a)||a>=2304&&a<=3583||a>=3840&&a<=4255||(b=a)>=6016&&b<=6143)}function hz(a){for(const b of a)if(hx(b.charCodeAt(0)))return!0;return!1}const hA="deferred",hB="loading",hC="loaded";let hD=null,hE="unavailable",hF=null;const c1=function(a){a&&"string"==typeof a&&a.indexOf("NetworkError")> -1&&(hE="error"),hD&&hD(a)};function hG(){c2.fire(new aW("pluginStateChange",{pluginStatus:hE,pluginURL:hF}))}const c2=new S,c3=function(){return hE},hH=function(){if(hE!==hA||!hF)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");hE=hB,hG(),hF&&fi({url:hF},a=>{a?c1(a):(hE=hC,hG())})},c4={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>hE===hC||null!=c4.applyArabicShaping,isLoading:()=>hE===hB,setState(a){hE=a.pluginStatus,hF=a.pluginURL},isParsed:()=>null!=c4.applyArabicShaping&&null!=c4.processBidirectionalText&&null!=c4.processStyledBidirectionalText,getPluginURL:()=>hF};class c5{constructor(b,a){this.zoom=b,a?(this.now=a.now,this.fadeDuration=a.fadeDuration,this.zoomHistory=a.zoomHistory,this.transition=a.transition,this.pitch=a.pitch):(this.now=0,this.fadeDuration=0,this.zoomHistory=new c0,this.transition={},this.pitch=0)}isSupportedScript(a){return function(a,b){for(const c of a)if(!hy(c.charCodeAt(0),b))return!1;return!0}(a,c4.isLoaded())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const a=this.zoom,b=a-Math.floor(a),c=this.crossFadingFactor();return a>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:b+(1-b)*c}:{fromScale:.5,toScale:1,t:1-(1-c)*b}}}class hI{constructor(a,b){this.property=a,this.value=b,this.expression=function(a,b){if(gn(a))return new cQ(a,b);if(gv(a)){const c=gw(a,b);if("error"===c.result)throw new Error(c.value.map(a=>`${a.key}: ${a.message}`).join(", "));return c.value}{let d=a;return"string"==typeof a&&"color"===b.type&&(d=m.parse(a)),{kind:"constant",evaluate:()=>d}}}(void 0===b?a.specification.default:b,a.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(a,b,c){return this.property.possiblyEvaluate(this,a,b,c)}}class hJ{constructor(a){this.property=a,this.value=new hI(a,void 0)}transitioned(a,b){return new hK(this.property,this.value,b,bR({},a.transition,this.transition),a.now)}untransitioned(){return new hK(this.property,this.value,null,{},0)}}class c6{constructor(a){this._properties=a,this._values=Object.create(a.defaultTransitionablePropertyValues)}getValue(a){return bX(this._values[a].value.value)}setValue(a,b){this._values.hasOwnProperty(a)||(this._values[a]=new hJ(this._values[a].property)),this._values[a].value=new hI(this._values[a].property,null===b?void 0:bX(b))}getTransition(a){return bX(this._values[a].transition)}setTransition(a,b){this._values.hasOwnProperty(a)||(this._values[a]=new hJ(this._values[a].property)),this._values[a].transition=bX(b)||void 0}serialize(){const b={};for(const a of Object.keys(this._values)){const c=this.getValue(a);void 0!==c&&(b[a]=c);const d=this.getTransition(a);void 0!==d&&(b[`${a}-transition`]=d)}return b}transitioned(c,d){const b=new hL(this._properties);for(const a of Object.keys(this._values))b._values[a]=this._values[a].transitioned(c,d._values[a]);return b}untransitioned(){const a=new hL(this._properties);for(const b of Object.keys(this._values))a._values[b]=this._values[b].untransitioned();return a}}class hK{constructor(c,d,e,a,b){const f=a.delay||0,g=a.duration||0;b=b||0,this.property=c,this.value=d,this.begin=b+f,this.end=this.begin+g,c.specification.transition&&(a.delay||a.duration)&&(this.prior=e)}possiblyEvaluate(a,b,c){const d=a.now||0,e=this.value.possiblyEvaluate(a,b,c),f=this.prior;if(f){if(d>this.end||this.value.isDataDriven())return this.prior=null,e;if(dd.zoomHistory.lastIntegerZoom?{from:a,to:b,other:c}:{from:c,to:b,other:a}}interpolate(a){return a}}class a5{constructor(a){this.specification=a}possiblyEvaluate(b,a,d,e){if(void 0!==b.value){if("constant"===b.expression.kind){const c=b.expression.evaluate(a,null,{},d,e);return this._calculate(c,c,c,a)}return this._calculate(b.expression.evaluate(new c5(Math.floor(a.zoom-1),a)),b.expression.evaluate(new c5(Math.floor(a.zoom),a)),b.expression.evaluate(new c5(Math.floor(a.zoom+1),a)),a)}}_calculate(c,a,d,b){return b.zoom>b.zoomHistory.lastIntegerZoom?{from:c,to:a}:{from:d,to:a}}interpolate(a){return a}}class V{constructor(a){this.specification=a}possiblyEvaluate(a,b,c,d){return!!a.expression.evaluate(b,null,{},c,d)}interpolate(){return!1}}class n{constructor(b){for(const a in this.properties=b,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[],b){const c=b[a];c.specification.overridable&&this.overridableProperties.push(a);const d=this.defaultPropertyValues[a]=new hI(c,void 0),e=this.defaultTransitionablePropertyValues[a]=new hJ(c);this.defaultTransitioningPropertyValues[a]=e.untransitioned(),this.defaultPossiblyEvaluatedValues[a]=d.possiblyEvaluate({})}}}function hO(a,b){return 256*(a=bM(Math.floor(a),0,255))+bM(Math.floor(b),0,255)}c("DataDrivenProperty",g),c("DataConstantProperty",e),c("CrossFadedDataDrivenProperty",N),c("CrossFadedProperty",a5),c("ColorRampProperty",V);const hP={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class O{constructor(a,b){this._structArray=a,this._pos1=b*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class k{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(a,b){return a._trim(),b&&(a.isTransferred=!0,b.push(a.arrayBuffer)),{length:a.length,arrayBuffer:a.arrayBuffer}}static deserialize(b){const a=Object.create(this.prototype);return a.arrayBuffer=b.arrayBuffer,a.length=b.length,a.capacity=b.arrayBuffer.byteLength/a.bytesPerElement,a._refreshViews(),a}_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(a){this.reserve(a),this.length=a}reserve(a){if(a>this.capacity){this.capacity=Math.max(a,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const b=this.uint8;this._refreshViews(),b&&this.uint8.set(b)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function j(b,a=1){let c=0,d=0;return{members:b.map(b=>{const e=hP[b.type].BYTES_PER_ELEMENT,g=c=hQ(c,Math.max(a,e)),f=b.components||1;return d=Math.max(d,e),c+=e*f,{name:b.name,type:b.type,components:f,offset:g}}),size:hQ(c,Math.max(d,a)),alignment:a}}function hQ(b,a){return Math.ceil(b/a)*a}class al extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(b,c){const a=this.length;return this.resize(a+1),this.emplace(a,b,c)}emplace(a,c,d){const b=2*a;return this.int16[b+0]=c,this.int16[b+1]=d,a}}al.prototype.bytesPerElement=4,c("StructArrayLayout2i4",al);class am extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(b,c,d,e){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e)}emplace(b,c,d,e,f){const a=4*b;return this.int16[a+0]=c,this.int16[a+1]=d,this.int16[a+2]=e,this.int16[a+3]=f,b}}am.prototype.bytesPerElement=8,c("StructArrayLayout4i8",am);class a6 extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(b,c,d,e,f,g,h){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e,f,g,h)}emplace(a,d,e,f,g,h,i,j){const c=6*a,b=12*a,k=3*a;return this.int16[c+0]=d,this.int16[c+1]=e,this.uint8[b+4]=f,this.uint8[b+5]=g,this.uint8[b+6]=h,this.uint8[b+7]=i,this.float32[k+2]=j,a}}a6.prototype.bytesPerElement=12,c("StructArrayLayout2i4ub1f12",a6);class an extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(b,c,d){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d)}emplace(b,c,d,e){const a=3*b;return this.float32[a+0]=c,this.float32[a+1]=d,this.float32[a+2]=e,b}}an.prototype.bytesPerElement=12,c("StructArrayLayout3f12",an);class w extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(b,c,d,e,f,g,h,i,j,k){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e,f,g,h,i,j,k)}emplace(b,c,d,e,f,g,h,i,j,k,l){const a=10*b;return this.uint16[a+0]=c,this.uint16[a+1]=d,this.uint16[a+2]=e,this.uint16[a+3]=f,this.uint16[a+4]=g,this.uint16[a+5]=h,this.uint16[a+6]=i,this.uint16[a+7]=j,this.uint16[a+8]=k,this.uint16[a+9]=l,b}}w.prototype.bytesPerElement=20,c("StructArrayLayout10ui20",w);class W extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(b,c,d,e,f,g,h,i){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e,f,g,h,i)}emplace(b,c,d,e,f,g,h,i,j){const a=8*b;return this.uint16[a+0]=c,this.uint16[a+1]=d,this.uint16[a+2]=e,this.uint16[a+3]=f,this.uint16[a+4]=g,this.uint16[a+5]=h,this.uint16[a+6]=i,this.uint16[a+7]=j,b}}W.prototype.bytesPerElement=16,c("StructArrayLayout8ui16",W);class a7 extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q)}emplace(b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r){const a=16*b;return this.int16[a+0]=c,this.int16[a+1]=d,this.int16[a+2]=e,this.int16[a+3]=f,this.uint16[a+4]=g,this.uint16[a+5]=h,this.uint16[a+6]=i,this.uint16[a+7]=j,this.int16[a+8]=k,this.int16[a+9]=l,this.int16[a+10]=m,this.int16[a+11]=n,this.int16[a+12]=o,this.int16[a+13]=p,this.int16[a+14]=q,this.int16[a+15]=r,b}}a7.prototype.bytesPerElement=32,c("StructArrayLayout4i4ui4i4i32",a7);class a8 extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(b){const a=this.length;return this.resize(a+1),this.emplace(a,b)}emplace(a,b){return this.uint32[1*a+0]=b,a}}a8.prototype.bytesPerElement=4,c("StructArrayLayout1ul4",a8);class ao extends k{_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(b,c,d,e,f,g,h,i,j,k,l,m,n){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e,f,g,h,i,j,k,l,m,n)}emplace(c,d,e,f,g,h,i,j,k,l,m,n,o,p){const a=20*c,b=10*c;return this.int16[a+0]=d,this.int16[a+1]=e,this.int16[a+2]=f,this.int16[a+3]=g,this.int16[a+4]=h,this.float32[b+3]=i,this.float32[b+4]=j,this.float32[b+5]=k,this.float32[b+6]=l,this.int16[a+14]=m,this.uint32[b+8]=n,this.uint16[a+18]=o,this.uint16[a+19]=p,c}}ao.prototype.bytesPerElement=40,c("StructArrayLayout5i4f1i1ul2ui40",ao);class a9 extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(b,c,d,e,f,g,h){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e,f,g,h)}emplace(b,c,d,e,f,g,h,i){const a=8*b;return this.int16[a+0]=c,this.int16[a+1]=d,this.int16[a+2]=e,this.int16[a+4]=f,this.int16[a+5]=g,this.int16[a+6]=h,this.int16[a+7]=i,b}}a9.prototype.bytesPerElement=16,c("StructArrayLayout3i2i2i16",a9);class ap extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(b,c,d,e,f){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e,f)}emplace(a,d,e,f,g,h){const b=4*a,c=8*a;return this.float32[b+0]=d,this.float32[b+1]=e,this.float32[b+2]=f,this.int16[c+6]=g,this.int16[c+7]=h,a}}ap.prototype.bytesPerElement=16,c("StructArrayLayout2f1f2i16",ap);class ba extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(b,c,d,e){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e)}emplace(a,d,e,f,g){const b=12*a,c=3*a;return this.uint8[b+0]=d,this.uint8[b+1]=e,this.float32[c+1]=f,this.float32[c+2]=g,a}}ba.prototype.bytesPerElement=12,c("StructArrayLayout2ub2f12",ba);class aq extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(b,c,d){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d)}emplace(b,c,d,e){const a=3*b;return this.uint16[a+0]=c,this.uint16[a+1]=d,this.uint16[a+2]=e,b}}aq.prototype.bytesPerElement=6,c("StructArrayLayout3ui6",aq);class ar extends k{_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(b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v)}emplace(c,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y){const a=30*c,b=15*c,d=60*c;return this.int16[a+0]=e,this.int16[a+1]=f,this.int16[a+2]=g,this.float32[b+2]=h,this.float32[b+3]=i,this.uint16[a+8]=j,this.uint16[a+9]=k,this.uint32[b+5]=l,this.uint32[b+6]=m,this.uint32[b+7]=n,this.uint16[a+16]=o,this.uint16[a+17]=p,this.uint16[a+18]=q,this.float32[b+10]=r,this.float32[b+11]=s,this.uint8[d+48]=t,this.uint8[d+49]=u,this.uint8[d+50]=v,this.uint32[b+13]=w,this.int16[a+28]=x,this.uint8[d+58]=y,c}}ar.prototype.bytesPerElement=60,c("StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60",ar);class as extends k{_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(b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E)}emplace(c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G){const a=38*c,b=19*c;return this.int16[a+0]=d,this.int16[a+1]=e,this.int16[a+2]=f,this.float32[b+2]=g,this.float32[b+3]=h,this.int16[a+8]=i,this.int16[a+9]=j,this.int16[a+10]=k,this.int16[a+11]=l,this.int16[a+12]=m,this.int16[a+13]=n,this.uint16[a+14]=o,this.uint16[a+15]=p,this.uint16[a+16]=q,this.uint16[a+17]=r,this.uint16[a+18]=s,this.uint16[a+19]=t,this.uint16[a+20]=u,this.uint16[a+21]=v,this.uint16[a+22]=w,this.uint16[a+23]=x,this.uint16[a+24]=y,this.uint16[a+25]=z,this.uint16[a+26]=A,this.uint16[a+27]=B,this.uint16[a+28]=C,this.uint32[b+15]=D,this.float32[b+16]=E,this.float32[b+17]=F,this.float32[b+18]=G,c}}as.prototype.bytesPerElement=76,c("StructArrayLayout3i2f6i15ui1ul3f76",as);class X extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(b){const a=this.length;return this.resize(a+1),this.emplace(a,b)}emplace(a,b){return this.float32[1*a+0]=b,a}}X.prototype.bytesPerElement=4,c("StructArrayLayout1f4",X);class at extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(b,c,d){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d)}emplace(b,c,d,e){const a=3*b;return this.int16[a+0]=c,this.int16[a+1]=d,this.int16[a+2]=e,b}}at.prototype.bytesPerElement=6,c("StructArrayLayout3i6",at);class bb extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(b,c,d,e,f,g,h){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e,f,g,h)}emplace(b,c,d,e,f,g,h,i){const a=7*b;return this.float32[a+0]=c,this.float32[a+1]=d,this.float32[a+2]=e,this.float32[a+3]=f,this.float32[a+4]=g,this.float32[a+5]=h,this.float32[a+6]=i,b}}bb.prototype.bytesPerElement=28,c("StructArrayLayout7f28",bb);class au extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(b,c,d,e){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e)}emplace(a,c,d,e,f){const b=6*a;return this.uint32[3*a+0]=c,this.uint16[b+2]=d,this.uint16[b+3]=e,this.uint16[b+4]=f,a}}au.prototype.bytesPerElement=12,c("StructArrayLayout1ul3ui12",au);class Y extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(b,c){const a=this.length;return this.resize(a+1),this.emplace(a,b,c)}emplace(a,c,d){const b=2*a;return this.uint16[b+0]=c,this.uint16[b+1]=d,a}}Y.prototype.bytesPerElement=4,c("StructArrayLayout2ui4",Y);class av extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(b){const a=this.length;return this.resize(a+1),this.emplace(a,b)}emplace(a,b){return this.uint16[1*a+0]=b,a}}av.prototype.bytesPerElement=2,c("StructArrayLayout1ui2",av);class Z extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(b,c){const a=this.length;return this.resize(a+1),this.emplace(a,b,c)}emplace(a,c,d){const b=2*a;return this.float32[b+0]=c,this.float32[b+1]=d,a}}Z.prototype.bytesPerElement=8,c("StructArrayLayout2f8",Z);class aw extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(b,c,d,e){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e)}emplace(b,c,d,e,f){const a=4*b;return this.float32[a+0]=c,this.float32[a+1]=d,this.float32[a+2]=e,this.float32[a+3]=f,b}}aw.prototype.bytesPerElement=16,c("StructArrayLayout4f16",aw);class c7 extends O{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]}}c7.prototype.size=40;class c8 extends ao{get(a){return new c7(this,a)}}c("CollisionBoxArray",c8);class c9 extends O{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(a){this._structArray.uint8[this._pos1+49]=a}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(a){this._structArray.uint8[this._pos1+50]=a}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(a){this._structArray.uint32[this._pos4+13]=a}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(a){this._structArray.uint8[this._pos1+58]=a}}c9.prototype.size=60;class da extends ar{get(a){return new c9(this,a)}}c("PlacedSymbolArray",da);class db extends O{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 rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+11]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+13]}get key(){return this._structArray.uint16[this._pos2+14]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+17]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+19]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+21]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+22]}get featureIndex(){return this._structArray.uint16[this._pos2+23]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+25]}get numIconVertices(){return this._structArray.uint16[this._pos2+26]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+27]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+28]}get crossTileID(){return this._structArray.uint32[this._pos4+15]}set crossTileID(a){this._structArray.uint32[this._pos4+15]=a}get textOffset0(){return this._structArray.float32[this._pos4+16]}get textOffset1(){return this._structArray.float32[this._pos4+17]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+18]}}db.prototype.size=76;class dc extends as{get(a){return new db(this,a)}}c("SymbolInstanceArray",dc);class dd extends X{getoffsetX(a){return this.float32[1*a+0]}}c("GlyphOffsetArray",dd);class de extends at{getx(a){return this.int16[3*a+0]}gety(a){return this.int16[3*a+1]}gettileUnitDistanceFromAnchor(a){return this.int16[3*a+2]}}c("SymbolLineVertexArray",de);class df extends O{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]}}df.prototype.size=12;class dg extends au{get(a){return new df(this,a)}}c("FeatureIndexArray",dg);class dh extends O{get a_centroid_pos0(){return this._structArray.uint16[this._pos2+0]}get a_centroid_pos1(){return this._structArray.uint16[this._pos2+1]}}dh.prototype.size=4;class di extends Y{get(a){return new dh(this,a)}}c("FillExtrusionCentroidArray",di);const hR=j([{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},]),hS=j([{name:"a_dash_to",components:4,type:"Uint16"},{name:"a_dash_from",components:4,type:"Uint16"},]);var bc=ah(function(a){a.exports=function(c,j){var g,h,a,i,e,f,b,d;for(h=c.length-(g=3&c.length),a=j,e=3432918353,f=461845907,d=0;d>>16)*e&65535)<<16)&4294967295)<<15|b>>>17))*f+(((b>>>16)*f&65535)<<16)&4294967295)<<13|a>>>19))+((5*(a>>>16)&65535)<<16)&4294967295))+((58964+(i>>>16)&65535)<<16);switch(b=0,g){case 3:b^=(255&c.charCodeAt(d+2))<<16;case 2:b^=(255&c.charCodeAt(d+1))<<8;case 1:a^=b=(65535&(b=(b=(65535&(b^=255&c.charCodeAt(d)))*e+(((b>>>16)*e&65535)<<16)&4294967295)<<15|b>>>17))*f+(((b>>>16)*f&65535)<<16)&4294967295}return a^=c.length,a=2246822507*(65535&(a^=a>>>16))+((2246822507*(a>>>16)&65535)<<16)&4294967295,a=3266489909*(65535&(a^=a>>>13))+((3266489909*(a>>>16)&65535)<<16)&4294967295,(a^=a>>>16)>>>0}}),dj=ah(function(a){a.exports=function(b,f){for(var d,e=b.length,a=f^e,c=0;e>=4;)d=1540483477*(65535&(d=255&b.charCodeAt(c)|(255&b.charCodeAt(++c))<<8|(255&b.charCodeAt(++c))<<16|(255&b.charCodeAt(++c))<<24))+((1540483477*(d>>>16)&65535)<<16),a=1540483477*(65535&a)+((1540483477*(a>>>16)&65535)<<16)^(d=1540483477*(65535&(d^=d>>>24))+((1540483477*(d>>>16)&65535)<<16)),e-=4,++c;switch(e){case 3:a^=(255&b.charCodeAt(c+2))<<16;case 2:a^=(255&b.charCodeAt(c+1))<<8;case 1:a=1540483477*(65535&(a^=255&b.charCodeAt(c)))+((1540483477*(a>>>16)&65535)<<16)}return a=1540483477*(65535&(a^=a>>>13))+((1540483477*(a>>>16)&65535)<<16),(a^=a>>>15)>>>0}}),bd=bc;bd.murmur3=bc,bd.murmur2=dj;class dk{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(a,b,c,d){this.ids.push(hT(a)),this.positions.push(b,c,d)}getPositions(f){const d=hT(f);let a=0,b=this.ids.length-1;for(;a>1;this.ids[c]>=d?b=c:a=c+1}const e=[];for(;this.ids[a]===d;)e.push({index:this.positions[3*a],start:this.positions[3*a+1],end:this.positions[3*a+2]}),a++;return e}static serialize(c,d){const a=new Float64Array(c.ids),b=new Uint32Array(c.positions);return hU(a,b,0,a.length-1),d&&d.push(a.buffer,b.buffer),{ids:a,positions:b}}static deserialize(b){const a=new dk;return a.ids=b.ids,a.positions=b.positions,a.indexed=!0,a}}function hT(b){const a=+b;return!isNaN(a)&&Number.MIN_SAFE_INTEGER<=a&&a<=Number.MAX_SAFE_INTEGER?a:bd(String(b))}function hU(c,f,d,e){for(;d>1];let b=d-1,a=e+1;for(;;){do b++;while(c[b]g)if(b>=a)break;hV(c,b,a),hV(f,3*b,3*a),hV(f,3*b+1,3*a+1),hV(f,3*b+2,3*a+2)}a-d`u_${a}`),this.type=c}setUniform(a,c,b){a.set(b.constantOr(this.value))}getBinding(a,b,c){return"color"===this.type?new dn(a,b):new dl(a,b)}}class dq{constructor(b,a){this.uniformNames=a.map(a=>`u_${a}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(a,b){this.pixelRatioFrom=b.pixelRatio,this.pixelRatioTo=a.pixelRatio,this.patternFrom=b.tl.concat(b.br),this.patternTo=a.tl.concat(a.br)}setUniform(c,d,e,a){const b="u_pattern_to"===a||"u_dash_to"===a?this.patternTo:"u_pattern_from"===a||"u_dash_from"===a?this.patternFrom:"u_pixel_ratio_to"===a?this.pixelRatioTo:"u_pixel_ratio_from"===a?this.pixelRatioFrom:null;b&&c.set(b)}getBinding(b,c,a){return"u_pattern_from"===a||"u_pattern_to"===a||"u_dash_from"===a||"u_dash_to"===a?new dm(b,c):new dl(b,c)}}class dr{constructor(a,b,c,d){this.expression=a,this.type=c,this.maxValue=0,this.paintVertexAttributes=b.map(a=>({name:`a_${a}`,type:"Float32",components:"color"===c?2:1,offset:0})),this.paintVertexArray=new d}populatePaintArray(a,b,h,c,d,e){const f=this.paintVertexArray.length,g=this.expression.evaluate(new c5(0),b,{},d,c,e);this.paintVertexArray.resize(a),this._setPaintValue(f,a,g)}updatePaintArray(a,b,c,d,e){const f=this.expression.evaluate({zoom:0},c,d,void 0,e);this._setPaintValue(a,b,f)}_setPaintValue(d,e,a){if("color"===this.type){const f=hZ(a);for(let b=d;b`u_${a}_t`),this.type=c,this.useIntegerZoom=d,this.zoom=e,this.maxValue=0,this.paintVertexAttributes=a.map(a=>({name:`a_${a}`,type:"Float32",components:"color"===c?4:2,offset:0})),this.paintVertexArray=new f}populatePaintArray(a,b,i,c,d,e){const f=this.expression.evaluate(new c5(this.zoom),b,{},d,c,e),g=this.expression.evaluate(new c5(this.zoom+1),b,{},d,c,e),h=this.paintVertexArray.length;this.paintVertexArray.resize(a),this._setPaintValue(h,a,f,g)}updatePaintArray(d,e,a,b,c){const f=this.expression.evaluate({zoom:this.zoom},a,b,void 0,c),g=this.expression.evaluate({zoom:this.zoom+1},a,b,void 0,c);this._setPaintValue(d,e,f,g)}_setPaintValue(e,f,a,b){if("color"===this.type){const g=hZ(a),h=hZ(b);for(let c=e;c!0){this.binders={},this._buffers=[];const g=[];for(const a in e.paint._values){if(!n(a))continue;const c=e.paint.get(a);if(!(c instanceof hM&&gj(c.property.specification)))continue;const f=h_(a,e.type),b=c.value,d=c.property.specification.type,j=c.property.useIntegerZoom,k=c.property.specification["property-type"],h="cross-faded"===k||"cross-faded-data-driven"===k,l="line-dasharray"===String(a)&&"constant"!==e.layout.get("line-cap").value.kind;if("constant"!==b.kind||l){if("source"===b.kind||l||h){const m=h2(a,d,"source");this.binders[a]=h?new dt(b,f,d,j,i,m,e.id):new dr(b,f,d,m),g.push(`/a_${a}`)}else{const o=h2(a,d,"composite");this.binders[a]=new ds(b,f,d,j,i,o),g.push(`/z_${a}`)}}else this.binders[a]=h?new dq(b.value,f):new dp(b.value,f,d),g.push(`/u_${a}`)}this.cacheKey=g.sort().join("")}getMaxValue(b){const a=this.binders[b];return a instanceof dr||a instanceof ds?a.maxValue:0}populatePaintArrays(b,c,d,e,f,g){for(const h in this.binders){const a=this.binders[h];(a instanceof dr||a instanceof ds||a instanceof dt)&&a.populatePaintArray(b,c,d,e,f,g)}}setConstantPatternPositions(b,c){for(const d in this.binders){const a=this.binders[d];a instanceof dq&&a.setConstantPatternPositions(b,c)}}updatePaintArrays(c,g,h,i,j,k){let d=!1;for(const e in c){const l=g.getPositions(e);for(const b of l){const m=h.feature(b.index);for(const f in this.binders){const a=this.binders[f];if((a instanceof dr||a instanceof ds||a instanceof dt)&& !0===a.expression.isStateDependent){const n=i.paint.get(f);a.expression=n.value,a.updatePaintArray(b.start,b.end,m,c[e],j,k),d=!0}}}}return d}defines(){const b=[];for(const c in this.binders){const a=this.binders[c];(a instanceof dp||a instanceof dq)&&b.push(...a.uniformNames.map(a=>`#define HAS_UNIFORM_${a}`))}return b}getBinderAttributes(){const c=[];for(const d in this.binders){const a=this.binders[d];if(a instanceof dr||a instanceof ds||a instanceof dt)for(let b=0;b!0){for(const a of(this.programConfigurations={},b))this.programConfigurations[a.id]=new du(a,c,d);this.needsUpload=!1,this._featureMap=new dk,this._bufferOffset=0}populatePaintArrays(a,b,c,d,e,f,g){for(const h in this.programConfigurations)this.programConfigurations[h].populatePaintArrays(a,b,d,e,f,g);void 0!==b.id&&this._featureMap.add(b.id,c,this._bufferOffset,a),this._bufferOffset=a,this.needsUpload=!0}updatePaintArrays(b,c,d,e,f){for(const a of d)this.needsUpload=this.programConfigurations[a.id].updatePaintArrays(b,this._featureMap,c,a,e,f)||this.needsUpload}get(a){return this.programConfigurations[a]}upload(a){if(this.needsUpload){for(const b in this.programConfigurations)this.programConfigurations[b].upload(a);this.needsUpload=!1}}destroy(){for(const a in this.programConfigurations)this.programConfigurations[a].destroy()}}const h$={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from",],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from",],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from",],"line-dasharray":["dash_to","dash_from"]};function h_(a,b){return h$[a]||[a.replace(`${b}-`,"").replace(/-/g,"_"),]}const h0={"line-pattern":{source:w,composite:w},"fill-pattern":{source:w,composite:w},"fill-extrusion-pattern":{source:w,composite:w},"line-dasharray":{source:W,composite:W}},h1={color:{source:Z,composite:aw},number:{source:X,composite:Z}};function h2(c,d,a){const b=h0[c];return b&&b[a]||h1[d][a]}c("ConstantBinder",dp),c("CrossFadedConstantBinder",dq),c("SourceExpressionBinder",dr),c("CrossFadedCompositeBinder",dt),c("CompositeExpressionBinder",ds),c("ProgramConfiguration",du,{omit:["_buffers"]}),c("ProgramConfigurationSet",dv);const h3="-transition";class be extends S{constructor(a,b){if(super(),this.id=a.id,this.type=a.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,"custom"!==a.type&&(this.metadata=a.metadata,this.minzoom=a.minzoom,this.maxzoom=a.maxzoom,"background"!==a.type&&"sky"!==a.type&&(this.source=a.source,this.sourceLayer=a["source-layer"],this.filter=a.filter),b.layout&&(this._unevaluatedLayout=new class{constructor(a){this._properties=a,this._values=Object.create(a.defaultPropertyValues)}getValue(a){return bX(this._values[a].value)}setValue(a,b){this._values[a]=new hI(this._values[a].property,null===b?void 0:bX(b))}serialize(){const a={};for(const b of Object.keys(this._values)){const c=this.getValue(b);void 0!==c&&(a[b]=c)}return a}possiblyEvaluate(c,d,e){const a=new hN(this._properties);for(const b of Object.keys(this._values))a._values[b]=this._values[b].possiblyEvaluate(c,d,e);return a}}(b.layout)),b.paint)){for(const c in this._transitionablePaint=new c6(b.paint),a.paint)this.setPaintProperty(c,a.paint[c],{validate:!1});for(const d in a.layout)this.setLayoutProperty(d,a.layout[d],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new hN(b.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(a){return"visibility"===a?this.visibility:this._unevaluatedLayout.getValue(a)}setLayoutProperty(a,b,c={}){null!=b&&this._validate(gV,`layers.${this.id}.layout.${a}`,a,b,c)||("visibility"!==a?this._unevaluatedLayout.setValue(a,b):this.visibility=b)}getPaintProperty(a){return bV(a,h3)?this._transitionablePaint.getTransition(a.slice(0,-h3.length)):this._transitionablePaint.getValue(a)}setPaintProperty(a,b,e={}){if(null!=b&&this._validate(gU,`layers.${this.id}.paint.${a}`,a,b,e))return!1;if(bV(a,h3))return this._transitionablePaint.setTransition(a.slice(0,-h3.length),b||void 0),!1;{const c=this._transitionablePaint._values[a],f="cross-faded-data-driven"===c.property.specification["property-type"],g=c.value.isDataDriven(),h=c.value;this._transitionablePaint.setValue(a,b),this._handleSpecialPaintPropertyUpdate(a);const d=this._transitionablePaint._values[a].value;return d.isDataDriven()||g||f||this._handleOverridablePaintPropertyUpdate(a,h,d)}}_handleSpecialPaintPropertyUpdate(a){}getProgramIds(){return null}getProgramConfiguration(a){return null}_handleOverridablePaintPropertyUpdate(a,b,c){return!1}isHidden(a){return!!(this.minzoom&&a=this.maxzoom)||"none"===this.visibility}updateTransitions(a){this._transitioningPaint=this._transitionablePaint.transitioned(a,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(a,b){a.getCrossfadeParameters&&(this._crossfadeParameters=a.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(a,void 0,b)),this.paint=this._transitioningPaint.possiblyEvaluate(a,void 0,b)}serialize(){const a={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(a.layout=a.layout||{},a.layout.visibility=this.visibility),bW(a,(a,b)=>!(void 0===a||"layout"===b&&!Object.keys(a).length||"paint"===b&&!Object.keys(a).length))}_validate(c,d,e,f,a={}){return(!a|| !1!==a.validate)&&c_(this,c.call(M,{key:d,layerType:this.type,objectKey:e,value:f,styleSpec:b,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const b in this.paint._values){const a=this.paint.get(b);if(a instanceof hM&&gj(a.property.specification)&&("source"===a.value.kind||"composite"===a.value.kind)&&a.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=gB(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const dw=j([{name:"a_pos",components:2,type:"Int16"},],4),{members:h4}=dw;class ay{constructor(a=[]){this.segments=a}prepareSegment(b,d,e,c){let a=this.segments[this.segments.length-1];return b>ay.MAX_VERTEX_ARRAY_LENGTH&&bY(`Max vertices per segment is ${ay.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${b}`),(!a||a.vertexLength+b>ay.MAX_VERTEX_ARRAY_LENGTH||a.sortKey!==c)&&(a={vertexOffset:d.length,primitiveOffset:e.length,vertexLength:0,primitiveLength:0},void 0!==c&&(a.sortKey=c),this.segments.push(a)),a}get(){return this.segments}destroy(){for(const a of this.segments)for(const b in a.vaos)a.vaos[b].destroy()}static simpleSegment(a,b,c,d){return new ay([{vertexOffset:a,primitiveOffset:b,vertexLength:c,primitiveLength:d,vaos:{},sortKey:0},])}}ay.MAX_VERTEX_ARRAY_LENGTH=65535,c("SegmentVector",ay);class dx{constructor(a,b){a&&(b?this.setSouthWest(a).setNorthEast(b):4===a.length?this.setSouthWest([a[0],a[1],]).setNorthEast([a[2],a[3]]):this.setSouthWest(a[0]).setNorthEast(a[1]))}setNorthEast(a){return this._ne=a instanceof dy?new dy(a.lng,a.lat):dy.convert(a),this}setSouthWest(a){return this._sw=a instanceof dy?new dy(a.lng,a.lat):dy.convert(a),this}extend(a){const d=this._sw,e=this._ne;let b,c;if(a instanceof dy)b=a,c=a;else{if(!(a instanceof dx))return Array.isArray(a)?4===a.length||a.every(Array.isArray)?this.extend(dx.convert(a)):this.extend(dy.convert(a)):this;if(b=a._sw,c=a._ne,!b||!c)return this}return d||e?(d.lng=Math.min(b.lng,d.lng),d.lat=Math.min(b.lat,d.lat),e.lng=Math.max(c.lng,e.lng),e.lat=Math.max(c.lat,e.lat)):(this._sw=new dy(b.lng,b.lat),this._ne=new dy(c.lng,c.lat)),this}getCenter(){return new dy((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 dy(this.getWest(),this.getNorth())}getSouthEast(){return new dy(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(d){const{lng:a,lat:b}=dy.convert(d);let c=this._sw.lng<=a&&a<=this._ne.lng;return this._sw.lng>this._ne.lng&&(c=this._sw.lng>=a&&a>=this._ne.lng),this._sw.lat<=b&&b<=this._ne.lat&&c}static convert(a){return!a||a instanceof dx?a:new dx(a)}}class dy{constructor(a,b){if(isNaN(a)||isNaN(b))throw new Error(`Invalid LngLat object: (${a}, ${b})`);if(this.lng=+a,this.lat=+b,this.lat>90||this.lat< -90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new dy(bO(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(b){const a=Math.PI/180,c=this.lat*a,d=b.lat*a,e=Math.sin(c)*Math.sin(d)+Math.cos(c)*Math.cos(d)*Math.cos((b.lng-this.lng)*a);return 6371008.8*Math.acos(Math.min(e,1))}toBounds(c=0){const a=360*c/40075017,b=a/Math.cos(Math.PI/180*this.lat);return new dx(new dy(this.lng-b,this.lat-a),new dy(this.lng+b,this.lat+a))}static convert(a){if(a instanceof dy)return a;if(Array.isArray(a)&&(2===a.length||3===a.length))return new dy(Number(a[0]),Number(a[1]));if(!Array.isArray(a)&&"object"==typeof a&&null!==a)return new dy(Number("lng"in a?a.lng:a.lon),Number(a.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 [, ]")}}const h5=2*Math.PI*6371008.8;function h6(a){return h5*Math.cos(a*Math.PI/180)}function dz(a){return(180+a)/360}function dA(a){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+a*Math.PI/360)))/360}function dB(a,b){return a/h6(b)}function h7(a){return 360*a-180}function dC(a){return 360/Math.PI*Math.atan(Math.exp((180-360*a)*Math.PI/180))-90}function h8(a,b){return a*h6(dC(b))}class dD{constructor(a,b,c=0){this.x=+a,this.y=+b,this.z=+c}static fromLngLat(b,c=0){const a=dy.convert(b);return new dD(dz(a.lng),dA(a.lat),dB(c,a.lat))}toLngLat(){return new dy(h7(this.x),dC(this.y))}toAltitude(){return h8(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/h5*(1/Math.cos(dC(this.y)*Math.PI/180))}}function h9(c,i,j,k,l,d,b,e,f){const g=(i+k)/2,h=(j+l)/2,a=new aF(g,h);e(a),function(e,f,a,b,g,h){const c=a-g,d=b-h;return Math.abs((b-f)*c-(a-e)*d)/Math.hypot(c,d)}(a.x,a.y,d.x,d.y,b.x,b.y)>=f?(h9(c,i,j,g,h,d,a,e,f),h9(c,g,h,k,l,a,b,e,f)):c.push(b)}function ia(i,d,j){const b=[];let e,f,c;for(const a of i){const{x:g,y:h}=a;d(a),c?h9(b,e,f,g,h,c,a,d,j):b.push(a),e=g,f=h,c=a}return b}function ib(a,d){const b=Math.round(a.x*d),c=Math.round(a.y*d);return a.x=bM(b,-16384,16383),a.y=bM(c,-16384,16383),(ba.x+1||ca.y+1)&&bY("Geometry exceeds allowed extent, reduce your vector tile buffer size"),a}function ic(d,g,e){const a=d.loadGeometry(),f=d.extent,j=8192/f;if(g&&e&&e.projection.isReprojectedInTileSpace){const m=1<{const c=h7((g.x+a.x/f)/m),d=dC((g.y+a.y/f)/m),b=q.project(c,d);a.x=(b.x*n-o)*f,a.y=(b.y*n-p)*f};for(let b=0;b=f||c.y<0||c.y>=f||(h(c),i.push(c));a[b]=i}}for(const k of a)for(const l of k)ib(l,j);return a}function id(a,b){return{type:a.type,id:a.id,properties:a.properties,geometry:b?ic(a):[]}}function ie(a,b,c,d,e){a.emplaceBack(2*b+(d+1)/2,2*c+(e+1)/2)}class bf{constructor(a){this.zoom=a.zoom,this.overscaling=a.overscaling,this.layers=a.layers,this.layerIds=this.layers.map(a=>a.id),this.index=a.index,this.hasPattern=!1,this.layoutVertexArray=new al,this.indexArray=new aq,this.segments=new ay,this.programConfigurations=new dv(a.layers,a.zoom),this.stateDependentLayerIds=this.layers.filter(a=>a.isStateDependent()).map(a=>a.id)}populate(g,h,a,m){const i=this.layers[0],d=[];let b=null;for(const{feature:c,id:n,index:o,sourceLayerIndex:p}of("circle"===i.type&&(b=i.layout.get("circle-sort-key")),g)){const j=this.layers[0]._featureFilter.needGeometry,e=id(c,j);if(!this.layers[0]._featureFilter.filter(new c5(this.zoom),e,a))continue;const q=b?b.evaluate(e,{},a):void 0,r={id:n,properties:c.properties,type:c.type,sourceLayerIndex:p,index:o,geometry:j?e.geometry:ic(c,a,m),patterns:{},sortKey:q};d.push(r)}for(const k of(b&&d.sort((a,b)=>a.sortKey-b.sortKey),d)){const{geometry:l,index:f,sourceLayerIndex:s}=k,t=g[f].feature;this.addFeature(k,l,f,h.availableImages,a),h.featureIndex.insert(t,l,f,s,this.index)}}update(a,b,c,d){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(a,b,this.stateDependentLayers,c,d)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(a){this.uploaded||(this.layoutVertexBuffer=a.createVertexBuffer(this.layoutVertexArray,h4),this.indexBuffer=a.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(a),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,g,h,i,j){for(const k of g)for(const f of k){const a=f.x,b=f.y;if(a<0||a>=8192||b<0||b>=8192)continue;const d=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),c=d.vertexLength;ie(this.layoutVertexArray,a,b,-1,-1),ie(this.layoutVertexArray,a,b,1,-1),ie(this.layoutVertexArray,a,b,1,1),ie(this.layoutVertexArray,a,b,-1,1),this.indexArray.emplaceBack(c,c+1,c+2),this.indexArray.emplaceBack(c,c+3,c+2),d.vertexLength+=4,d.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,h,{},i,j)}}function dE(a,b){for(let c=0;c1){if(ij(a,b))return!0;for(let c=0;c1?b:b.sub(a)._mult(d)._add(a))}function io(h,c){let b,a,d,e=!1;for(let f=0;fc.y!=d.y>c.y&&c.x<(d.x-a.x)*(c.y-a.y)/(d.y-a.y)+a.x&&(e=!e)}return e}function ip(b,c){let d=!1;for(let e=0,g=b.length-1;ec.y!=f.y>c.y&&c.x<(f.x-a.x)*(c.y-a.y)/(f.y-a.y)+a.x&&(d=!d)}return d}function dF(a,d,e,f,g){for(const b of a)if(d<=b.x&&e<=b.y&&f>=b.x&&g>=b.y)return!0;const h=[new aF(d,e),new aF(d,g),new aF(f,g),new aF(f,e),];if(a.length>2){for(const i of h)if(ip(a,i))return!0}for(let c=0;ce.x&&b.x>e.x||a.ye.y&&b.y>e.y)return!1;const f=eR(a,b,c[0]);return f!==eR(a,b,c[1])||f!==eR(a,b,c[2])||f!==eR(a,b,c[3])}function ir(a,b,d){const c=b.paint.get(a).value;return"constant"===c.kind?c.value:d.programConfigurations.get(b.id).getMaxValue(a)}function is(a){return Math.sqrt(a[0]*a[0]+a[1]*a[1])}function it(a,b,f,g,h){if(!b[0]&&!b[1])return a;const d=aF.convert(b)._mult(h);"viewport"===f&&d._rotate(-g);const e=[];for(let c=0;c{var a,b,c;const h=bF([],j,d),i=1/h[3]/e*g;return a=h,b=h,c=[i,i,f?1/h[3]:i,i],a[0]=b[0]*c[0],a[1]=b[1]*c[1],a[2]=b[2]*c[2],a[3]=b[3]*c[3],a}),c=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5],].map(a=>{const c=bz([],bB([],bE([],b[a[0]],b[a[1]]),bE([],b[a[2]],b[a[1]]))),d=-bA(c,b[a[1]]);return c.concat(d)});return new dH(b,c)}}class B{constructor(a,b){this.min=a,this.max=b,this.center=bx([],bw([],this.min,this.max),.5)}quadrant(d){const b=[d%2==0,d<2],e=eH(this.min),c=eH(this.max);for(let a=0;a=0;if(0===e)return 0;e!==c.length&&(j=!1)}if(j)return 2;for(let a=0;a<3;a++){let g=Number.MAX_VALUE,h=-Number.MAX_VALUE;for(let i=0;ithis.max[a]-this.min[a])return 0}return 1}}function iw(b,l,c,g,h,a,i,m,d){if(a&&b.queryGeometry.isAboveHorizon)return!1;for(const n of(a&&(d*=b.pixelToTileUnitsFactor),l))for(const f of n){const e=f.add(m),j=h&&c.elevation?c.elevation.exaggeration()*h.getElevationAt(e.x,e.y,!0):0,o=a?e:ix(e,j,g),p=a?b.tilespaceRays.map(a=>iA(a,j)):b.queryGeometry.screenGeometry,k=bF([],[f.x,f.y,j,1],g);if(!i&&a?d*=k[3]/c.cameraToCenterDistance:i&&!a&&(d*=c.cameraToCenterDistance/k[3]),ig(p,o,d))return!0}return!1}function ix(b,c,d){const a=bF([],[b.x,b.y,c,1],d);return new aF(a[0]/a[3],a[1]/a[3])}const iy=Q(0,0,0),iz=Q(0,0,1);function iA(b,c){const a=aK();return iy[2]=c,b.intersectsPlane(iy,iz,a),new aF(a[0],a[1])}class dI extends bf{}function iB(b,{width:c,height:d},e,a){if(a){if(a instanceof Uint8ClampedArray)a=new Uint8Array(a.buffer);else if(a.length!==c*d*e)throw new RangeError("mismatched image size")}else a=new Uint8Array(c*d*e);return b.width=c,b.height=d,b.data=a,b}function iC(a,{width:b,height:c},d){if(b===a.width&&c===a.height)return;const e=iB({},{width:b,height:c},d);iD(a,e,{x:0,y:0},{x:0,y:0},{width:Math.min(a.width,b),height:Math.min(a.height,c)},d),a.width=b,a.height=c,a.data=e.data}function iD(c,b,d,e,a,h){if(0===a.width||0===a.height)return b;if(a.width>c.width||a.height>c.height||d.x>c.width-a.width||d.y>c.height-a.height)throw new RangeError("out of range source coordinates for image copy");if(a.width>b.width||a.height>b.height||e.x>b.width-a.width||e.y>b.height-a.height)throw new RangeError("out of range destination coordinates for image copy");const i=c.data,j=b.data;for(let f=0;f{o[a.evaluationKey]=e;const b=a.expression.evaluate(o);l.data[c+d+0]=Math.floor(255*b.r/b.a),l.data[c+d+1]=Math.floor(255*b.g/b.a),l.data[c+d+2]=Math.floor(255*b.b/b.a),l.data[c+d+3]=Math.floor(255*b.a)};if(a.clips)for(let c=0,h=0;c80*a){d=g=b[0],e=h=b[1];for(var l=a;lg&&(g=i),j>h&&(h=j);k=0!==(k=Math.max(g-d,h-e))?1/k:0}return iJ(c,m,a,d,e,k),m}function iH(c,e,f,d,g){var a,b;if(g===i3(c,e,f,d)>0)for(a=e;a=e;a-=d)b=i0(a,c[a],c[a+1],b);return b&&iW(b,b.next)&&(i1(b),b=b.next),b}function iI(c,b){if(!c)return c;b||(b=c);var d,a=c;do if(d=!1,a.steiner|| !iW(a,a.next)&&0!==iV(a.prev,a,a.next))a=a.next;else{if(i1(a),(a=b=a.prev)===a.next)break;d=!0}while(d||a!==b)return b}function iJ(a,b,c,e,f,d,h){if(a){!h&&d&&function(b,c,d,e){var a=b;do null===a.z&&(a.z=iR(a.x,a.y,c,d,e)),a.prevZ=a.prev,a.nextZ=a.next,a=a.next;while(a!==b)a.prevZ.nextZ=null,a.prevZ=null,function(g){var h,b,a,c,d,i,e,f,j=1;do{for(b=g,g=null,d=null,i=0;b;){for(i++,a=b,e=0,h=0;h0||f>0&&a;)0!==e&&(0===f||!a||b.z<=a.z)?(c=b,b=b.nextZ,e--):(c=a,a=a.nextZ,f--),d?d.nextZ=c:g=c,c.prevZ=d,d=c;b=a}d.nextZ=null,j*=2}while(i>1)}(a)}(a,e,f,d);for(var i,g,j=a;a.prev!==a.next;)if(i=a.prev,g=a.next,d?iL(a,e,f,d):iK(a))b.push(i.i/c),b.push(a.i/c),b.push(g.i/c),i1(a),a=g.next,j=g.next;else if((a=g)===j){h?1===h?iJ(a=iM(iI(a),b,c),b,c,e,f,d,2):2===h&&iN(a,b,c,e,f,d):iJ(iI(a),b,c,e,f,d,1);break}}}function iK(b){var c=b.prev,d=b,e=b.next;if(iV(c,d,e)>=0)return!1;for(var a=b.next.next;a!==b.prev;){if(iT(c.x,c.y,d.x,d.y,e.x,e.y,a.x,a.y)&&iV(a.prev,a,a.next)>=0)return!1;a=a.next}return!0}function iL(f,g,h,i){var d=f.prev,e=f,a=f.next;if(iV(d,e,a)>=0)return!1;for(var l=d.x>e.x?d.x>a.x?d.x:a.x:e.x>a.x?e.x:a.x,m=d.y>e.y?d.y>a.y?d.y:a.y:e.y>a.y?e.y:a.y,j=iR(d.x=j&&c&&c.z<=k;){if(b!==f.prev&&b!==f.next&&iT(d.x,d.y,e.x,e.y,a.x,a.y,b.x,b.y)&&iV(b.prev,b,b.next)>=0||(b=b.prevZ,c!==f.prev&&c!==f.next&&iT(d.x,d.y,e.x,e.y,a.x,a.y,c.x,c.y)&&iV(c.prev,c,c.next)>=0))return!1;c=c.nextZ}for(;b&&b.z>=j;){if(b!==f.prev&&b!==f.next&&iT(d.x,d.y,e.x,e.y,a.x,a.y,b.x,b.y)&&iV(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;c&&c.z<=k;){if(c!==f.prev&&c!==f.next&&iT(d.x,d.y,e.x,e.y,a.x,a.y,c.x,c.y)&&iV(c.prev,c,c.next)>=0)return!1;c=c.nextZ}return!0}function iM(d,e,f){var a=d;do{var c=a.prev,b=a.next.next;!iW(c,b)&&iX(c,a,a.next,b)&&i$(c,b)&&i$(b,c)&&(e.push(c.i/f),e.push(a.i/f),e.push(b.i/f),i1(a),i1(a.next),a=d=b),a=a.next}while(a!==d)return iI(a)}function iN(d,e,f,g,h,i){var a=d;do{for(var b=a.next.next;b!==a.prev;){if(a.i!==b.i&&iU(a,b)){var c=i_(a,b);return a=iI(a,a.next),c=iI(c,c.next),iJ(a,e,f,g,h,i),void iJ(c,e,f,g,h,i)}b=b.next}a=a.next}while(a!==d)}function iO(a,b){return a.x-b.x}function iP(c,b){var a=function(h,k){var b,a=k,d=h.x,c=h.y,e=-1/0;do{if(c<=a.y&&c>=a.next.y&&a.next.y!==a.y){var f=a.x+(c-a.y)*(a.next.x-a.x)/(a.next.y-a.y);if(f<=d&&f>e){if(e=f,f===d){if(c===a.y)return a;if(c===a.next.y)return a.next}b=a.x=a.x&&a.x>=l&&d!==a.x&&iT(cb.x||a.x===b.x&&iQ(b,a)))&&(b=a,j=g)),a=a.next;while(a!==m)return b}(c,b);if(!a)return b;var d=i_(a,c),e=iI(a,a.next);return iI(d,d.next),b===a?e:b}function iQ(a,b){return 0>iV(a.prev,a,b.prev)&&0>iV(b.next,a,a.next)}function iR(a,b,d,e,c){return(a=1431655765&((a=858993459&((a=252645135&((a=16711935&((a=32767*(a-d)*c)|a<<8))|a<<4))|a<<2))|a<<1))|(b=1431655765&((b=858993459&((b=252645135&((b=16711935&((b=32767*(b-e)*c)|b<<8))|b<<4))|b<<2))|b<<1))<<1}function iS(c){var a=c,b=c;do(a.x=0&&(c-a)*(f-b)-(e-a)*(d-b)>=0&&(e-a)*(h-b)-(g-a)*(f-b)>=0}function iU(a,b){return a.next.i!==b.i&&a.prev.i!==b.i&&!function(b,c){var a=b;do{if(a.i!==b.i&&a.next.i!==b.i&&a.i!==c.i&&a.next.i!==c.i&&iX(a,a.next,b,c))return!0;a=a.next}while(a!==b)return!1}(a,b)&&(i$(a,b)&&i$(b,a)&&function(b,e){var a=b,c=!1,f=(b.x+e.x)/2,d=(b.y+e.y)/2;do a.y>d!=a.next.y>d&&a.next.y!==a.y&&f<(a.next.x-a.x)*(d-a.y)/(a.next.y-a.y)+a.x&&(c=!c),a=a.next;while(a!==b)return c}(a,b)&&(iV(a.prev,a,b.prev)||iV(a,b.prev,b))||iW(a,b)&&iV(a.prev,a,a.next)>0&&iV(b.prev,b,b.next)>0)}function iV(b,a,c){return(a.y-b.y)*(c.x-a.x)-(a.x-b.x)*(c.y-a.y)}function iW(a,b){return a.x===b.x&&a.y===b.y}function iX(a,b,c,d){var e=iZ(iV(a,b,c)),f=iZ(iV(a,b,d)),g=iZ(iV(c,d,a)),h=iZ(iV(c,d,b));return e!==f&&g!==h||!(0!==e||!iY(a,c,b))||!(0!==f||!iY(a,d,b))||!(0!==g||!iY(c,a,d))||!(0!==h||!iY(c,b,d))}function iY(a,b,c){return b.x<=Math.max(a.x,c.x)&&b.x>=Math.min(a.x,c.x)&&b.y<=Math.max(a.y,c.y)&&b.y>=Math.min(a.y,c.y)}function iZ(a){return a>0?1:a<0?-1:0}function i$(a,b){return 0>iV(a.prev,a,a.next)?iV(a,b,a.next)>=0&&iV(a,a.prev,b)>=0:0>iV(a,b,a.prev)||0>iV(a,a.next,b)}function i_(a,b){var d=new i2(a.i,a.x,a.y),c=new i2(b.i,b.x,b.y),e=a.next,f=b.prev;return a.next=b,b.prev=a,d.next=e,e.prev=d,c.next=d,d.prev=c,f.next=c,c.prev=f,c}function i0(c,d,e,b){var a=new i2(c,d,e);return b?(a.next=b.next,a.prev=b,b.next.prev=a,b.next=a):(a.prev=a,a.next=a),a}function i1(a){a.next.prev=a.prev,a.prev.next=a.next,a.prevZ&&(a.prevZ.nextZ=a.nextZ),a.nextZ&&(a.nextZ.prevZ=a.prevZ)}function i2(a,b,c){this.i=a,this.x=b,this.y=c,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function i3(b,g,d,e){for(var f=0,a=g,c=d-e;ab;){if(d-b>600){var f=d-b+1,k=e-b+1,l=Math.log(f),i=.5*Math.exp(2*l/3),m=.5*Math.sqrt(l*i*(f-i)/f)*(k-f/2<0?-1:1);i5(a,e,Math.max(b,Math.floor(e-k*i/f+m)),Math.min(d,Math.floor(e+(f-k)*i/f+m)),g)}var j=a[e],h=b,c=d;for(i6(a,b,e),g(a[d],j)>0&&i6(a,b,d);hg(a[h],j);)h++;for(;g(a[c],j)>0;)c--}0===g(a[b],j)?i6(a,b,c):i6(a,++c,d),c<=e&&(b=c+1),e<=c&&(d=c-1)}}function i6(a,b,c){var d=a[b];a[b]=a[c],a[c]=d}function i7(a,b){return ab?1:0}function i8(c,f){const i=c.length;if(i<=1)return[c];const a=[];let d,h;for(let e=0;e1)for(let b=0;b0&&c.holes.push(g+=b[a-1].length)}return c},dM.default=az;class dN{constructor(a){this.zoom=a.zoom,this.overscaling=a.overscaling,this.layers=a.layers,this.layerIds=this.layers.map(a=>a.id),this.index=a.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new al,this.indexArray=new aq,this.indexArray2=new Y,this.programConfigurations=new dv(a.layers,a.zoom),this.segments=new ay,this.segments2=new ay,this.stateDependentLayerIds=this.layers.filter(a=>a.isStateDependent()).map(a=>a.id)}populate(i,a,b,l){this.hasPattern=ja("fill",this.layers,a);const d=this.layers[0].layout.get("fill-sort-key"),e=[];for(const{feature:c,id:m,index:n,sourceLayerIndex:o}of i){const j=this.layers[0]._featureFilter.needGeometry,f=id(c,j);if(!this.layers[0]._featureFilter.filter(new c5(this.zoom),f,b))continue;const p=d?d.evaluate(f,{},b,a.availableImages):void 0,q={id:m,properties:c.properties,type:c.type,sourceLayerIndex:o,index:n,geometry:j?f.geometry:ic(c,b,l),patterns:{},sortKey:p};e.push(q)}for(const g of(d&&e.sort((a,b)=>a.sortKey-b.sortKey),e)){const{geometry:k,index:h,sourceLayerIndex:r}=g;if(this.hasPattern){const s=jb("fill",this.layers,g,this.zoom,a);this.patternFeatures.push(s)}else this.addFeature(g,k,h,b,{},a.availableImages);a.featureIndex.insert(i[h].feature,k,h,r,this.index)}}update(a,b,c,d){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(a,b,this.stateDependentLayers,c,d)}addFeatures(e,b,c,d){for(const a of this.patternFeatures)this.addFeature(a,a.geometry,a.index,b,c,d)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(a){this.uploaded||(this.layoutVertexBuffer=a.createVertexBuffer(this.layoutVertexArray,iG),this.indexBuffer=a.createIndexBuffer(this.indexArray),this.indexBuffer2=a.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(a),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(m,n,o,p,q,r=[]){for(const g of i8(n,500)){let h=0;for(const s of g)h+=s.length;const i=this.segments.prepareSegment(h,this.layoutVertexArray,this.indexArray),j=i.vertexLength,c=[],l=[];for(const a of g){if(0===a.length)continue;a!==g[0]&&l.push(c.length/2);const k=this.segments2.prepareSegment(a.length,this.layoutVertexArray,this.indexArray2),f=k.vertexLength;this.layoutVertexArray.emplaceBack(a[0].x,a[0].y),this.indexArray2.emplaceBack(f+a.length-1,f),c.push(a[0].x),c.push(a[0].y);for(let b=1;b>3}if(d--,1===c||2===c)f+=b.readSVarint(),g+=b.readSVarint(),1===c&&(a&&e.push(a),a=[]),a.push(new aF(f,g));else{if(7!==c)throw new Error("unknown command "+c);a&&a.push(a[0].clone())}}return a&&e.push(a),e},$.prototype.bbox=function(){var a=this._pbf;a.pos=this._geometry;for(var k=a.readVarint()+a.pos,b=1,e=0,c=0,d=0,f=1/0,g=-1/0,h=1/0,i=-1/0;a.pos>3}if(e--,1===b||2===b)(c+=a.readSVarint())g&&(g=c),(d+=a.readSVarint())i&&(i=d);else if(7!==b)throw new Error("unknown command "+b)}return[f,h,g,i]},$.prototype.toGeoJSON=function(h,i,j){var a,c,k=this.extent*Math.pow(2,j),l=this.extent*h,m=this.extent*i,b=this.loadGeometry(),d=$.types[this.type];function e(b){for(var a=0;a>3;c=1===b?a.readString():2===b?a.readFloat():3===b?a.readDouble():4===b?a.readVarint64():5===b?a.readVarint():6===b?a.readSVarint():7===b?a.readBoolean():null}return c}(c))}function ji(c,d,a){if(3===c){var b=new dR(a,a.readVarint()+a.pos);b.length&&(d[b.name]=b)}}dS.prototype.feature=function(a){if(a<0||a>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[a];var b=this._pbf.readVarint()+this._pbf.pos;return new dQ(this._pbf,b,this.extent,this._keys,this._values)};var _={VectorTile:function(a,b){this.layers=a.readFields(ji,{},b)},VectorTileFeature:dQ,VectorTileLayer:dR};const jj=_.VectorTileFeature.types;function jk(a,b,c,d,e,f,g,h){a.emplaceBack((b<<1)+g,(c<<1)+f,(Math.floor(8192*d)<<1)+e,Math.round(h))}class dT{constructor(){this.acc=new aF(0,0),this.polyCount=[]}startRing(a){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new aF(a.x,a.y),this.max=new aF(a.x,a.y))}append(a,c){this.currentPolyCount.edges++,this.acc._add(a);let b=!!this.borders;const d=this.min,e=this.max;a.xe.x&&(e.x=a.x,b=!0),a.ye.y&&(e.y=a.y,b=!0),((0===a.x||8192===a.x)&&a.x===c.x)!=((0===a.y||8192===a.y)&&a.y===c.y)&&this.processBorderOverlap(a,c),b&&this.checkBorderIntersection(a,c)}checkBorderIntersection(b,a){a.x<0!=b.x<0&&this.addBorderIntersection(0,aY(a.y,b.y,(0-a.x)/(b.x-a.x))),a.x>8192!=b.x>8192&&this.addBorderIntersection(1,aY(a.y,b.y,(8192-a.x)/(b.x-a.x))),a.y<0!=b.y<0&&this.addBorderIntersection(2,aY(a.x,b.x,(0-a.y)/(b.y-a.y))),a.y>8192!=b.y>8192&&this.addBorderIntersection(3,aY(a.x,b.x,(8192-a.y)/(b.y-a.y)))}addBorderIntersection(c,a){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 b=this.borders[c];ab[1]&&(b[1]=a)}processBorderOverlap(a,b){if(a.x===b.x){if(a.y===b.y)return;const c=0===a.x?0:1;this.addBorderIntersection(c,b.y),this.addBorderIntersection(c,a.y)}else{const d=0===a.y?2:3;this.addBorderIntersection(d,b.x),this.addBorderIntersection(d,a.x)}}centroid(){const a=this.polyCount.reduce((a,b)=>a+b.edges,0);return 0!==a?this.acc.div(a)._round():new aF(0,0)}span(){return new aF(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce((a,b)=>a+ +(b[0]!==Number.MAX_VALUE),0)}}class dU{constructor(a){this.zoom=a.zoom,this.overscaling=a.overscaling,this.layers=a.layers,this.layerIds=this.layers.map(a=>a.id),this.index=a.index,this.hasPattern=!1,this.layoutVertexArray=new am,this.centroidVertexArray=new di,this.indexArray=new aq,this.programConfigurations=new dv(a.layers,a.zoom),this.segments=new ay,this.stateDependentLayerIds=this.layers.filter(a=>a.isStateDependent()).map(a=>a.id),this.enableTerrain=a.enableTerrain}populate(i,b,c,j){for(const{feature:a,id:k,index:e,sourceLayerIndex:f}of(this.features=[],this.hasPattern=ja("fill-extrusion",this.layers,b),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDone=[!1,!1,!1,!1],this.tileToMeter=function(a){const b=Math.exp(Math.PI*(1-a.y/(1<a.x<=0)||l.every(a=>a.x>=8192)||l.every(a=>a.y<=0)||l.every(a=>a.y>=8192))continue;for(let u=0;u=1){const d=g[i-1];if(!jl(c,d)){a&&a.append(c,d),b.vertexLength+4>ay.MAX_VERTEX_ARRAY_LENGTH&&(b=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const n=c.sub(d)._perp(),o=n.x/(Math.abs(n.x)+Math.abs(n.y)),p=n.y>0?1:0,z=d.dist(c);f+z>32768&&(f=0),jk(this.layoutVertexArray,c.x,c.y,o,p,0,0,f),jk(this.layoutVertexArray,c.x,c.y,o,p,0,1,f),f+=z,jk(this.layoutVertexArray,d.x,d.y,o,p,0,0,f),jk(this.layoutVertexArray,d.x,d.y,o,p,0,1,f);const h=b.vertexLength;this.indexArray.emplaceBack(h,h+2,h+1),this.indexArray.emplaceBack(h+1,h+2,h+3),b.vertexLength+=4,b.primitiveLength+=2}}}}if(b.vertexLength+m>ay.MAX_VERTEX_ARRAY_LENGTH&&(b=this.segments.prepareSegment(m,this.layoutVertexArray,this.indexArray)),"Polygon"!==jj[y.type])continue;const q=[],A=[],v=b.vertexLength;for(let w=0;w0){if(a.borders){a.vertexArrayOffset=this.centroidVertexArray.length;const G=a.borders,H=this.featuresOnBorder.push(a)-1;for(let t=0;t<4;t++)G[t][0]!==Number.MAX_VALUE&&this.borders[t].push(H)}this.encodeCentroid(a.borders?void 0:a.centroid(),a)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,y,C,E,F,D)}sortBorders(){for(let a=0;a<4;a++)this.borders[a].sort((b,c)=>this.featuresOnBorder[b].borders[a][0]-this.featuresOnBorder[c].borders[a][0])}encodeCentroid(b,e,f=!0){let c,a;if(b){if(0!==b.y){const h=e.span()._mult(this.tileToMeter);c=(Math.max(b.x,1)<<3)+Math.min(7,Math.round(h.x/10)),a=(Math.max(b.y,1)<<3)+Math.min(7,Math.round(h.y/10))}else c=Math.ceil(7*(b.x+450)),a=0}else c=0,a=+f;let g=f?this.centroidVertexArray.length:e.vertexArrayOffset;for(const d of e.polyCount){f&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*d.edges+d.top);for(let i=0;i<2*d.edges;i++)this.centroidVertexArray.emplace(g++,0,a),this.centroidVertexArray.emplace(g++,c,a);for(let j=0;j8192)||a.y===b.y&&(a.y<0||a.y>8192)}c("FillExtrusionBucket",dU,{omit:["layers","features"]}),c("PartMetadata",dT);var jm={paint:new n({"fill-extrusion-opacity":new e(b["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new g(b["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new e(b["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new e(b["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new N(b["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new g(b["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new g(b["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new e(b["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})};function jn(a,b){return a.x*b.x+a.y*b.y}function jo(i,a){if(1===i.length){let b=0;const c=a[b++];let d;for(;!d||c.equals(d);)if(!(d=a[b++]))return 1/0;for(;ba.id),this.index=a.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(a=>{this.gradients[a.id]={}}),this.layoutVertexArray=new a6,this.layoutVertexArray2=new an,this.indexArray=new aq,this.programConfigurations=new dv(a.layers,a.zoom),this.segments=new ay,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(a=>a.isStateDependent()).map(a=>a.id)}populate(j,a,b,m){this.hasPattern=ja("line",this.layers,a);const e=this.layers[0].layout.get("line-sort-key"),f=[];for(const{feature:c,id:n,index:o,sourceLayerIndex:p}of j){const k=this.layers[0]._featureFilter.needGeometry,g=id(c,k);if(!this.layers[0]._featureFilter.filter(new c5(this.zoom),g,b))continue;const q=e?e.evaluate(g,{},b):void 0,r={id:n,properties:c.properties,type:c.type,sourceLayerIndex:p,index:o,geometry:k?g.geometry:ic(c,b,m),patterns:{},sortKey:q};f.push(r)}e&&f.sort((a,b)=>a.sortKey-b.sortKey);const{lineAtlas:h,featureIndex:s}=a,t=this.addConstantDashes(h);for(const d of f){const{geometry:l,index:i,sourceLayerIndex:u}=d;if(t&&this.addFeatureDashes(d,h),this.hasPattern){const v=jb("line",this.layers,d,this.zoom,a);this.patternFeatures.push(v)}else this.addFeature(d,l,i,b,h.positions,a.availableImages);s.insert(j[i].feature,l,i,u,this.index)}}addConstantDashes(b){let d=!1;for(const e of this.layers){const f=e.paint.get("line-dasharray").value,g=e.layout.get("line-cap").value;if("constant"!==f.kind||"constant"!==g.kind)d=!0;else{const c=g.value,a=f.value;if(!a)continue;b.addDash(a.from,c),b.addDash(a.to,c),a.other&&b.addDash(a.other,c)}}return d}addFeatureDashes(a,b){const c=this.zoom;for(const m of this.layers){const d=m.paint.get("line-dasharray").value,e=m.layout.get("line-cap").value;if("constant"===d.kind&&"constant"===e.kind)continue;let g,h,i,j,k,l;if("constant"===d.kind){const f=d.value;if(!f)continue;g=f.other||f.to,h=f.to,i=f.from}else g=d.evaluate({zoom:c-1},a),h=d.evaluate({zoom:c},a),i=d.evaluate({zoom:c+1},a);"constant"===e.kind?j=k=l=e.value:(j=e.evaluate({zoom:c-1},a),k=e.evaluate({zoom:c},a),l=e.evaluate({zoom:c+1},a)),b.addDash(g,j),b.addDash(h,k),b.addDash(i,l);const n=b.getKey(g,j),o=b.getKey(h,k),p=b.getKey(i,l);a.patterns[m.id]={min:n,mid:o,max:p}}}update(a,b,c,d){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(a,b,this.stateDependentLayers,c,d)}addFeatures(e,b,c,d){for(const a of this.patternFeatures)this.addFeature(a,a.geometry,a.index,b,c,d)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(a){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=a.createVertexBuffer(this.layoutVertexArray2,js)),this.layoutVertexBuffer=a.createVertexBuffer(this.layoutVertexArray,jr),this.indexBuffer=a.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(a),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(a){if(a.properties&&a.properties.hasOwnProperty("mapbox_clip_start")&&a.properties.hasOwnProperty("mapbox_clip_end"))return{start:+a.properties.mapbox_clip_start,end:+a.properties.mapbox_clip_end}}addFeature(a,c,d,e,f,g){const b=this.layers[0].layout,h=b.get("line-join").evaluate(a,{}),i=b.get("line-cap").evaluate(a,{}),j=b.get("line-miter-limit"),k=b.get("line-round-limit");for(const l of(this.lineClips=this.lineFeatureClips(a),c))this.addLine(l,a,h,i,j,k);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,a,d,f,g,e)}addLine(g,K,A,L,v,M){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let q=0;q=2&&g[i-1].equals(g[i-2]);)i--;let l=0;for(;l0;if(B&&m>l){const C=a.dist(h);if(C>2*s){const w=a.sub(a.sub(h)._mult(s/C)._round());this.updateDistance(h,w),this.addCurrentVertex(w,d,0,0,c),h=w}}const D=h&&j;let e=D?A:r?"butt":L;if(D&&"round"===e&&(kv&&(e="bevel"),"bevel"===e&&(k>2&&(e="flipbevel"),k100)f=b.mult(-1);else{const O=k*d.add(b).mag()/d.sub(b).mag();f._perp()._mult(O*(p?-1:1))}this.addCurrentVertex(a,f,0,0,c),this.addCurrentVertex(a,f.mult(-1),0,0,c)}else if("bevel"===e||"fakeround"===e){const E=-Math.sqrt(k*k-1),F=p?E:0,G=p?0:E;if(h&&this.addCurrentVertex(a,d,F,G,c),"fakeround"===e){const H=Math.round(180*N/Math.PI/20);for(let x=1;x2*s){const z=a.add(j.sub(a)._mult(s/J)._round());this.updateDistance(a,z),this.addCurrentVertex(z,b,0,0,c),a=z}}}}addCurrentVertex(d,a,b,c,e,f=!1){const g=a.y*c-a.x,h=-a.y-a.x*c;this.addHalfVertex(d,a.x+a.y*b,a.y-a.x*b,f,!1,b,e),this.addHalfVertex(d,g,h,f,!0,-c,e)}addHalfVertex({x:e,y:f},g,h,i,b,c,d){this.layoutVertexArray.emplaceBack((e<<1)+(i?1:0),(f<<1)+(b?1:0),Math.round(63*g)+128,Math.round(63*h)+128,1+(0===c?0:c<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineSoFar);const a=d.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,a),d.primitiveLength++),b?this.e2=a:this.e1=a}updateScaledDistance(){if(this.lineClips){const a=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=a*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(a,b){this.distance+=a.dist(b),this.updateScaledDistance()}}c("LineBucket",dX,{omit:["layers","patternFeatures"]});const dY=new n({"line-cap":new g(b.layout_line["line-cap"]),"line-join":new g(b.layout_line["line-join"]),"line-miter-limit":new e(b.layout_line["line-miter-limit"]),"line-round-limit":new e(b.layout_line["line-round-limit"]),"line-sort-key":new g(b.layout_line["line-sort-key"])});var dZ={paint:new n({"line-opacity":new g(b.paint_line["line-opacity"]),"line-color":new g(b.paint_line["line-color"]),"line-translate":new e(b.paint_line["line-translate"]),"line-translate-anchor":new e(b.paint_line["line-translate-anchor"]),"line-width":new g(b.paint_line["line-width"]),"line-gap-width":new g(b.paint_line["line-gap-width"]),"line-offset":new g(b.paint_line["line-offset"]),"line-blur":new g(b.paint_line["line-blur"]),"line-dasharray":new N(b.paint_line["line-dasharray"]),"line-pattern":new N(b.paint_line["line-pattern"]),"line-gradient":new V(b.paint_line["line-gradient"])}),layout:dY};const d$=new class extends g{possiblyEvaluate(b,a){return a=new c5(Math.floor(a.zoom),{now:a.now,fadeDuration:a.fadeDuration,zoomHistory:a.zoomHistory,transition:a.transition}),super.possiblyEvaluate(b,a)}evaluate(b,a,c,d){return a=bR({},a,{zoom:Math.floor(a.zoom)}),super.evaluate(b,a,c,d)}}(dZ.paint.properties["line-width"].specification);function jv(a,b){return b>0?b+2*a:a}d$.useIntegerZoom=!0;const jw=j([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"},{name:"a_z_tile_anchor",components:4,type:"Int16"},],4),jx=j([{name:"a_projected_pos",components:3,type:"Float32"},],4);j([{name:"a_fade_opacity",components:1,type:"Uint32"},],4);const jy=j([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},]),jz=j([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},]);j([{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 jA=j([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"},],4),d_=j([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"},],4);function d0(e,i){const{expression:a}=i;if("constant"===a.kind)return{kind:"constant",layoutSize:a.evaluate(new c5(e+1))};if("source"===a.kind)return{kind:"source"};{const{zoomStops:b,interpolationType:h}=a;let c=0;for(;c{a.text=function(a,c,d){const b=c.layout.get("text-transform").evaluate(d,{});return"uppercase"===b?a=a.toLocaleUpperCase():"lowercase"===b&&(a=a.toLocaleLowerCase()),c4.applyArabicShaping&&(a=c4.applyArabicShaping(a)),a}(a.text,b,c)}),a}const jC={"!":"\uFE15","#":"\uFF03",$:"\uFF04","%":"\uFF05","&":"\uFF06","(":"\uFE35",")":"\uFE36","*":"\uFF0A","+":"\uFF0B",",":"\uFE10","-":"\uFE32",".":"\u30FB","/":"\uFF0F",":":"\uFE13",";":"\uFE14","<":"\uFE3F","=":"\uFF1D",">":"\uFE40","?":"\uFE16","@":"\uFF20","[":"\uFE47","\\":"\uFF3C","]":"\uFE48","^":"\uFF3E",_:"\uFE33","`":"\uFF40","{":"\uFE37","|":"\u2015","}":"\uFE38","~":"\uFF5E","\xa2":"\uFFE0","\xa3":"\uFFE1","\xa5":"\uFFE5","\xa6":"\uFFE4","\xac":"\uFFE2","\xaf":"\uFFE3","\u2013":"\uFE32","\u2014":"\uFE31","\u2018":"\uFE43","\u2019":"\uFE44","\u201C":"\uFE41","\u201D":"\uFE42","\u2026":"\uFE19","\u2027":"\u30FB","\u20A9":"\uFFE6","\u3001":"\uFE11","\u3002":"\uFE12","\u3008":"\uFE3F","\u3009":"\uFE40","\u300A":"\uFE3D","\u300B":"\uFE3E","\u300C":"\uFE41","\u300D":"\uFE42","\u300E":"\uFE43","\u300F":"\uFE44","\u3010":"\uFE3B","\u3011":"\uFE3C","\u3014":"\uFE39","\u3015":"\uFE3A","\u3016":"\uFE17","\u3017":"\uFE18","\uFF01":"\uFE15","\uFF08":"\uFE35","\uFF09":"\uFE36","\uFF0C":"\uFE10","\uFF0D":"\uFE32","\uFF0E":"\u30FB","\uFF1A":"\uFE13","\uFF1B":"\uFE14","\uFF1C":"\uFE3F","\uFF1E":"\uFE40","\uFF1F":"\uFE16","\uFF3B":"\uFE47","\uFF3D":"\uFE48","\uFF3F":"\uFE33","\uFF5B":"\uFE37","\uFF5C":"\u2015","\uFF5D":"\uFE38","\uFF5F":"\uFE35","\uFF60":"\uFE36","\uFF61":"\uFE12","\uFF62":"\uFE41","\uFF63":"\uFE42"};function jD(a){return"\uFE36"===a||"\uFE48"===a||"\uFE38"===a||"\uFE44"===a||"\uFE42"===a||"\uFE3E"===a||"\uFE3C"===a||"\uFE3A"===a||"\uFE18"===a||"\uFE40"===a||"\uFE10"===a||"\uFE13"===a||"\uFE14"===a||"\uFF40"===a||"\uFFE3"===a||"\uFE11"===a||"\uFE12"===a}function jE(a){return"\uFE35"===a||"\uFE47"===a||"\uFE37"===a||"\uFE43"===a||"\uFE41"===a||"\uFE3D"===a||"\uFE3B"===a||"\uFE39"===a||"\uFE17"===a||"\uFE3F"===a}var jF=function(g,h,j,e,k){var a,c,l=8*k-e-1,m=(1<>1,b=-7,d=j?k-1:0,i=j?-1:1,f=g[h+d];for(d+=i,a=f&(1<< -b)-1,f>>=-b,b+=l;b>0;a=256*a+g[h+d],d+=i,b-=8);for(c=a&(1<< -b)-1,a>>=-b,b+=e;b>0;c=256*c+g[h+d],d+=i,b-=8);if(0===a)a=1-n;else{if(a===m)return c?NaN:1/0*(f?-1:1);c+=Math.pow(2,e),a-=n}return(f?-1:1)*c*Math.pow(2,a-e)},jG=function(j,b,k,m,c,n){var a,d,e,h=8*n-c-1,i=(1<>1,o=23===c?5960464477539062e-23:0,g=m?0:n-1,l=m?1:-1,p=b<0||0===b&&1/b<0?1:0;for(isNaN(b=Math.abs(b))||b===1/0?(d=isNaN(b)?1:0,a=i):(a=Math.floor(Math.log(b)/Math.LN2),b*(e=Math.pow(2,-a))<1&&(a--,e*=2),(b+=a+f>=1?o/e:o*Math.pow(2,1-f))*e>=2&&(a++,e/=2),a+f>=i?(d=0,a=i):a+f>=1?(d=(b*e-1)*Math.pow(2,c),a+=f):(d=b*Math.pow(2,f-1)*Math.pow(2,c),a=0));c>=8;j[k+g]=255&d,g+=l,d/=256,c-=8);for(a=a<0;j[k+g]=255&a,g+=l,a/=256,h-=8);j[k+g-l]|=128*p},d2=P;function P(a){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(a)?a:new Uint8Array(a||0),this.pos=0,this.type=0,this.length=this.buf.length}P.Varint=0,P.Fixed64=1,P.Bytes=2,P.Fixed32=5;var jH="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function jI(a){return a.type===P.Bytes?a.readVarint()+a.pos:a.pos+1}function jJ(e,a,b){var d=a<=16383?1:a<=2097151?2:a<=268435455?3:Math.floor(Math.log(a)/(7*Math.LN2));b.realloc(d);for(var c=b.pos-1;c>=e;c--)b.buf[c+d]=b.buf[c]}function jK(b,c){for(var a=0;a>>8,a[c+2]=b>>>16,a[c+3]=b>>>24}function jV(a,b){return(a[b]|a[b+1]<<8|a[b+2]<<16)+(a[b+3]<<24)}function jW(b,a,c){a.glyphs=[],1===b&&c.readMessage(jX,a)}function jX(a,b,c){if(3===a){const{id:f,bitmap:g,width:d,height:e,left:h,top:i,advance:j}=c.readMessage(jY,{});b.glyphs.push({id:f,bitmap:new dJ({width:d+6,height:e+6},g),metrics:{width:d,height:e,left:h,top:i,advance:j}})}else 4===a?b.ascender=c.readSVarint():5===a&&(b.descender=c.readSVarint())}function jY(a,b,c){1===a?b.id=c.readVarint():2===a?b.bitmap=c.readBytes():3===a?b.width=c.readVarint():4===a?b.height=c.readVarint():5===a?b.left=c.readSVarint():6===a?b.top=c.readSVarint():7===a&&(b.advance=c.readVarint())}function d3(g){let h=0,i=0;for(const j of g)h+=j.w*j.h,i=Math.max(i,j.w);g.sort((a,b)=>b.h-a.h);const c=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(h/.95)),i),h:1/0},];let e=0,f=0;for(const a of g)for(let d=c.length-1;d>=0;d--){const b=c[d];if(!(a.w>b.w||a.h>b.h)){if(a.x=b.x,a.y=b.y,f=Math.max(f,a.y+a.h),e=Math.max(e,a.x+a.w),a.w===b.w&&a.h===b.h){const k=c.pop();d>3,f=this.pos;this.type=7&b,d(e,c,this),this.pos===f&&this.skip(b)}return c},readMessage:function(a,b){return this.readFields(a,b,this.readVarint()+this.pos)},readFixed32:function(){var a=jT(this.buf,this.pos);return this.pos+=4,a},readSFixed32:function(){var a=jV(this.buf,this.pos);return this.pos+=4,a},readFixed64:function(){var a=jT(this.buf,this.pos)+4294967296*jT(this.buf,this.pos+4);return this.pos+=8,a},readSFixed64:function(){var a=jT(this.buf,this.pos)+4294967296*jV(this.buf,this.pos+4);return this.pos+=8,a},readFloat:function(){var a=jF(this.buf,this.pos,!0,23,4);return this.pos+=4,a},readDouble:function(){var a=jF(this.buf,this.pos,!0,52,8);return this.pos+=8,a},readVarint:function(d){var a,b,c=this.buf;return a=127&(b=c[this.pos++]),b<128?a:(a|=(127&(b=c[this.pos++]))<<7,b<128?a:(a|=(127&(b=c[this.pos++]))<<14,b<128?a:(a|=(127&(b=c[this.pos++]))<<21,b<128?a:function(g,h,b){var e,f,c,a,d=b.buf;if(c=(112&(a=d[b.pos++]))>>4,a<128||(c|=(127&(a=d[b.pos++]))<<3,a<128)||(c|=(127&(a=d[b.pos++]))<<10,a<128)||(c|=(127&(a=d[b.pos++]))<<17,a<128)||(c|=(127&(a=d[b.pos++]))<<24,a<128)||(c|=(1&(a=d[b.pos++]))<<31,a<128))return e=g,f=c,h?4294967296*f+(e>>>0):4294967296*(f>>>0)+(e>>>0);throw new Error("Expected varint not more than 10 bytes")}(a|=(15&(b=c[this.pos]))<<28,d,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var a=this.readVarint();return a%2==1?-((a+1)/2):a/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var c,d,e,a=this.readVarint()+this.pos,b=this.pos;return this.pos=a,a-b>=12&&jH?(c=this.buf,d=b,e=a,jH.decode(c.subarray(d,e))):function(d,k,j){for(var h="",b=k;b239?4:c>223?3:c>191?2:1;if(b+e>j)break;1===e?c<128&&(a=c):2===e?128==(192&(f=d[b+1]))&&(a=(31&c)<<6|63&f)<=127&&(a=null):3===e?(g=d[b+2],128==(192&(f=d[b+1]))&&128==(192&g)&&((a=(15&c)<<12|(63&f)<<6|63&g)<=2047||a>=55296&&a<=57343)&&(a=null)):4===e&&(g=d[b+2],i=d[b+3],128==(192&(f=d[b+1]))&&128==(192&g)&&128==(192&i)&&((a=(15&c)<<18|(63&f)<<12|(63&g)<<6|63&i)<=65535||a>=1114112)&&(a=null)),null===a?(a=65533,e=1):a>65535&&(a-=65536,h+=String.fromCharCode(a>>>10&1023|55296),a=56320|1023&a),h+=String.fromCharCode(a),b+=e}return h}(this.buf,b,a)},readBytes:function(){var a=this.readVarint()+this.pos,b=this.buf.subarray(this.pos,a);return this.pos=a,b},readPackedVarint:function(a,b){if(this.type!==P.Bytes)return a.push(this.readVarint(b));var c=jI(this);for(a=a||[];this.pos127;);else if(a===P.Bytes)this.pos=this.readVarint()+this.pos;else if(a===P.Fixed32)this.pos+=4;else{if(a!==P.Fixed64)throw new Error("Unimplemented type: "+a);this.pos+=8}},writeTag:function(a,b){this.writeVarint(a<<3|b)},realloc:function(c){for(var a=this.length||16;a268435455||a<0?function(e,h){var f,g,d,c,a,b,i;if(e>=0?(f=e%4294967296|0,g=e/4294967296|0):(g=~(-e/4294967296),4294967295^(f=~(-e%4294967296))?f=f+1|0:(f=0,g=g+1|0)),e>=18446744073709552e3||e< -18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");h.realloc(10),d=f,(c=h).buf[c.pos++]=127&d|128,d>>>=7,c.buf[c.pos++]=127&d|128,d>>>=7,c.buf[c.pos++]=127&d|128,d>>>=7,c.buf[c.pos++]=127&d|128,c.buf[c.pos]=127&(d>>>=7),a=g,b=h,i=(7&a)<<4,b.buf[b.pos++]|=i|((a>>>=3)?128:0),a&&(b.buf[b.pos++]=127&a|((a>>>=7)?128:0),a&&(b.buf[b.pos++]=127&a|((a>>>=7)?128:0),a&&(b.buf[b.pos++]=127&a|((a>>>=7)?128:0),a&&(b.buf[b.pos++]=127&a|((a>>>=7)?128:0),a&&(b.buf[b.pos++]=127&a)))))}(a,this):(this.realloc(4),this.buf[this.pos++]=127&a|(a>127?128:0),a<=127||(this.buf[this.pos++]=127&(a>>>=7)|(a>127?128:0),a<=127||(this.buf[this.pos++]=127&(a>>>=7)|(a>127?128:0),a<=127||(this.buf[this.pos++]=a>>>7&127))))},writeSVarint:function(a){this.writeVarint(a<0?-(2*a)-1:2*a)},writeBoolean:function(a){this.writeVarint(Boolean(a))},writeString:function(a){a=String(a),this.realloc(4*a.length),this.pos++;var c=this.pos;this.pos=function(c,f,b){for(var a,d,e=0;e55295&&a<57344){if(!d){a>56319||e+1===f.length?(c[b++]=239,c[b++]=191,c[b++]=189):d=a;continue}if(a<56320){c[b++]=239,c[b++]=191,c[b++]=189,d=a;continue}a=d-55296<<10|a-56320|65536,d=null}else d&&(c[b++]=239,c[b++]=191,c[b++]=189,d=null);a<128?c[b++]=a:(a<2048?c[b++]=a>>6|192:(a<65536?c[b++]=a>>12|224:(c[b++]=a>>18|240,c[b++]=a>>12&63|128),c[b++]=a>>6&63|128),c[b++]=63&a|128)}return b}(this.buf,a,this.pos);var b=this.pos-c;b>=128&&jJ(c,b,this),this.pos=c-1,this.writeVarint(b),this.pos+=b},writeFloat:function(a){this.realloc(4),jG(this.buf,a,this.pos,!0,23,4),this.pos+=4},writeDouble:function(a){this.realloc(8),jG(this.buf,a,this.pos,!0,52,8),this.pos+=8},writeBytes:function(c){var a=c.length;this.writeVarint(a),this.realloc(a);for(var b=0;b=128&&jJ(b,a,this),this.pos=b-1,this.writeVarint(a),this.pos+=a},writeMessage:function(a,b,c){this.writeTag(a,P.Bytes),this.writeRawMessage(b,c)},writePackedVarint:function(b,a){a.length&&this.writeMessage(b,jK,a)},writePackedSVarint:function(b,a){a.length&&this.writeMessage(b,jL,a)},writePackedBoolean:function(b,a){a.length&&this.writeMessage(b,jO,a)},writePackedFloat:function(b,a){a.length&&this.writeMessage(b,jM,a)},writePackedDouble:function(b,a){a.length&&this.writeMessage(b,jN,a)},writePackedFixed32:function(b,a){a.length&&this.writeMessage(b,jP,a)},writePackedSFixed32:function(b,a){a.length&&this.writeMessage(b,jQ,a)},writePackedFixed64:function(b,a){a.length&&this.writeMessage(b,jR,a)},writePackedSFixed64:function(b,a){a.length&&this.writeMessage(b,jS,a)},writeBytesField:function(a,b){this.writeTag(a,P.Bytes),this.writeBytes(b)},writeFixed32Field:function(a,b){this.writeTag(a,P.Fixed32),this.writeFixed32(b)},writeSFixed32Field:function(a,b){this.writeTag(a,P.Fixed32),this.writeSFixed32(b)},writeFixed64Field:function(a,b){this.writeTag(a,P.Fixed64),this.writeFixed64(b)},writeSFixed64Field:function(a,b){this.writeTag(a,P.Fixed64),this.writeSFixed64(b)},writeVarintField:function(a,b){this.writeTag(a,P.Varint),this.writeVarint(b)},writeSVarintField:function(a,b){this.writeTag(a,P.Varint),this.writeSVarint(b)},writeStringField:function(a,b){this.writeTag(a,P.Bytes),this.writeString(b)},writeFloatField:function(a,b){this.writeTag(a,P.Fixed32),this.writeFloat(b)},writeDoubleField:function(a,b){this.writeTag(a,P.Fixed64),this.writeDouble(b)},writeBooleanField:function(a,b){this.writeVarintField(a,Boolean(b))}};class bj{constructor(a,{pixelRatio:b,version:c,stretchX:d,stretchY:e,content:f}){this.paddedRect=a,this.pixelRatio=b,this.stretchX=d,this.stretchY=e,this.content=f,this.version=c}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1,]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1,]}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio,]}}class d4{constructor(g,h){const i={},j={};this.haveRenderCallbacks=[];const k=[];this.addImages(g,i,k),this.addImages(h,j,k);const{w:q,h:r}=d3(k),b=new bg({width:q||1,height:r||1});for(const l in g){const m=g[l],n=i[l].paddedRect;bg.copy(m.data,b,{x:0,y:0},{x:n.x+1,y:n.y+1},m.data)}for(const o in h){const a=h[o],p=j[o].paddedRect,c=p.x+1,d=p.y+1,e=a.data.width,f=a.data.height;bg.copy(a.data,b,{x:0,y:0},{x:c,y:d},a.data),bg.copy(a.data,b,{x:0,y:f-1},{x:c,y:d-1},{width:e,height:1}),bg.copy(a.data,b,{x:0,y:0},{x:c,y:d+f},{width:e,height:1}),bg.copy(a.data,b,{x:e-1,y:0},{x:c-1,y:d},{width:1,height:f}),bg.copy(a.data,b,{x:0,y:0},{x:c+e,y:d},{width:1,height:f})}this.image=b,this.iconPositions=i,this.patternPositions=j}addImages(c,e,f){for(const b in c){const a=c[b],d={x:0,y:0,w:a.data.width+2,h:a.data.height+2};f.push(d),e[b]=new bj(d,a),a.hasRenderCallback&&this.haveRenderCallbacks.push(b)}}patchUpdatedImages(a,c){for(const b in a.dispatchRenderCallbacks(this.haveRenderCallbacks),a.updatedImages)this.patchUpdatedImage(this.iconPositions[b],a.getImage(b),c),this.patchUpdatedImage(this.patternPositions[b],a.getImage(b),c)}patchUpdatedImage(a,b,c){if(!a||!b||a.version===b.version)return;a.version=b.version;const[d,e]=a.tl;c.update(b.data,void 0,{x:d,y:e})}}c("ImagePosition",bj),c("ImageAtlas",d4);const d5={horizontal:1,vertical:2,horizontalOnly:3};class jZ{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(b,c){const a=new jZ;return a.scale=b||1,a.fontStack=c,a}static forImage(b){const a=new jZ;return a.imageName=b,a}}class j${constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(d,e){const a=new j$;for(let b=0;b=0&&b>=a&&j0[this.text.charCodeAt(b)];b--)d--;this.text=this.text.substring(a,d),this.sectionIndex=this.sectionIndex.slice(a,d)}substring(b,c){const a=new j$;return a.text=this.text.substring(b,c),a.sectionIndex=this.sectionIndex.slice(b,c),a.sections=this.sections,a}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((a,b)=>Math.max(a,this.sections[b].scale),0)}addTextSection(a,c){this.text+=a.text,this.sections.push(jZ.forText(a.scale,a.fontStack||c));const d=this.sections.length-1;for(let b=0;b=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function j_(u,c,v,d,w,i,x,y,z,e,f,j,m,k,l,A){const a=j$.fromFeature(u,w);let b;j===d5.vertical&&a.verticalizePunctuation(m);const{processBidirectionalText:n,processStyledBidirectionalText:o}=c4;if(n&&1===a.sections.length){b=[];const B=n(a.toString(),j7(a,e,i,c,d,k,l));for(const p of B){const g=new j$;g.text=p,g.sections=a.sections;for(let q=0;q0&&D>k&&(k=D)}else{const E=U[e.fontStack];if(!E)continue;E[c]&&(u=E[c]);const l=H[e.fontStack];if(!l)continue;const P=l.glyphs[c];if(!P)continue;if(d=P.metrics,B=8203!==c?24:0,i){const F=void 0!==l.ascender?Math.abs(l.ascender):0,Q=void 0!==l.descender?Math.abs(l.descender):0,R=(F+Q)*a;M=0;let f=0;for(let c=0;c -j/2;){if(--a<0)return!1;c-=b[a].dist(k),k=b[a]}c+=b[a].dist(b[a+1]),a++;const f=[];let g=0;for(;cl;)g-=f.shift().angleDelta;if(g>m)return!1;a++,c+=h.dist(i)}return!0}function kc(b){let c=0;for(let a=0;aj){const k=(j-e)/f,q=aY(c.x,d.x,k),r=aY(c.y,d.y,k),l=new d7(q,r,0,d.angleTo(c),b);return!i||kb(a,l,p,i,m)?l:void 0}e+=f}}function kg(b,a,k,f,l,g,c,h,d){const m=kd(f,g,c),i=ke(f,l),e=i*c,j=0===b[0].x||b[0].x===d||0===b[0].y||b[0].y===d;return a-e=0&&m=0&&n=0&&b+r<=v){const o=new d7(m,n,0,w,c);o._round(),i&&!kb(a,o,j,i,p)||f.push(o)}}e+=l}return u||f.length||q||(f=kh(a,e/2,d,i,p,j,q,!0,k)),f}function d8(k,c,d,e,f){const l=[];for(let i=0;i=e&&b.x>=e||(a.x>=e?a=new aF(e,a.y+(e-a.x)/(b.x-a.x)*(b.y-a.y))._round():b.x>=e&&(b=new aF(e,a.y+(e-a.x)/(b.x-a.x)*(b.y-a.y))._round()),a.y>=f&&b.y>=f||(a.y>=f?a=new aF(a.x+(f-a.y)/(b.y-a.y)*(b.x-a.x),f)._round():b.y>=f&&(b=new aF(a.x+(f-a.y)/(b.y-a.y)*(b.x-a.x),f)._round()),g&&a.equals(g[g.length-1])||(g=[a],l.push(g)),g.push(b)))))}}return l}function ki(f,a,b,g,h,c,i,j,k){for(let d=a;d -1)f[++c]=a,b[c]=j,b[c+1]=1e20}for(let e=0,k=0;e{let a=this.entries[b];a||(a=this.entries[b]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let d=a.glyphs[c];if(void 0!==d)return void f(null,{stack:b,id:c,glyph:d});if(d=this._tinySDF(a,b,c))return a.glyphs[c]=d,void f(null,{stack:b,id:c,glyph:d});const e=Math.floor(c/256);if(256*e>65535)return void f(new Error("glyphs > 65535 not supported"));if(a.ranges[e])return void f(null,{stack:b,id:c,glyph:d});let g=a.requests[e];g||(g=a.requests[e]=[],aA.loadGlyphRange(b,e,this.url,this.requestManager,(d,b)=>{if(b){for(const c in a.ascender=b.ascender,a.descender=b.descender,b.glyphs)this._doesCharSupportLocalGlyph(+c)||(a.glyphs[+c]=b.glyphs[+c]);a.ranges[e]=!0}for(const f of g)f(d,b);delete a.requests[e]})),g.push((a,d)=>{a?f(a):d&&f(null,{stack:b,id:c,glyph:d.glyphs[c]||null})})},(d,f)=>{if(d)e(d);else if(f){const b={};for(const{stack:a,id:g,glyph:c}of f)void 0===b[a]&&(b[a]={}),void 0===b[a].glyphs&&(b[a].glyphs={}),b[a].glyphs[g]=c&&{id:c.id,bitmap:c.bitmap.clone(),metrics:c.metrics},b[a].ascender=this.entries[a].ascender,b[a].descender=this.entries[a].descender;e(null,b)}})}_doesCharSupportLocalGlyph(a){return this.localGlyphMode!==d9.none&&(this.localGlyphMode===d9.all?!!this.localFontFamily:!!this.localFontFamily&&(hh(a)||hk(a)||g8(a)||g9(a))||g7(a))}_tinySDF(e,d,a){const f=this.localFontFamily;if(!f||!this._doesCharSupportLocalGlyph(a))return;let b=e.tinySDF;if(!b){let c="400";/bold/i.test(d)?c="900":/medium/i.test(d)?c="500":/light/i.test(d)&&(c="200"),(b=e.tinySDF=new aA.TinySDF({fontFamily:f,fontWeight:c,fontSize:48,buffer:6,radius:16})).fontWeight=c}if(this.localGlyphs[b.fontWeight][a])return this.localGlyphs[b.fontWeight][a];const g=String.fromCharCode(a),{data:h,width:i,height:j,glyphWidth:k,glyphHeight:l,glyphLeft:m,glyphTop:n,glyphAdvance:o}=b.draw(g);return this.localGlyphs[b.fontWeight][a]={id:a,bitmap:new dJ({width:i,height:j},h),metrics:{width:k/2,height:l/2,left:m/2,top:n/2-27,advance:o/2,localGlyph:!0}}}}function kk(c,D,E,o){const h=[],b=c.image,F=b.pixelRatio,i=b.paddedRect.w-2,j=b.paddedRect.h-2,G=c.right-c.left,H=c.bottom-c.top,d=b.stretchX||[[0,i]],e=b.stretchY||[[0,j]],p=(b,a)=>b+a[1]-a[0],k=d.reduce(p,0),l=e.reduce(p,0),q=i-k,r=j-l;let s=0,t=k,u=0,v=l,x=0,y=q,z=0,A=r;if(b.content&&o){const a=b.content;s=kl(d,0,a[0]),u=kl(e,0,a[1]),t=kl(d,a[0],a[2]),v=kl(e,a[1],a[3]),x=a[0]-s,z=a[1]-u,y=a[2]-a[0]-t,A=a[3]-a[1]-v}const w=(a,d,e,f)=>{const i=(a.stretch-s)/t*G+c.left,J=a.fixed-x-y*a.stretch/k,j=(d.stretch-u)/v*H+c.top,K=d.fixed-z-A*d.stretch/l,m=(e.stretch-s)/t*G+c.left,L=e.fixed-x-y*e.stretch/k,n=(f.stretch-u)/v*H+c.top,M=f.fixed-z-A*f.stretch/l,o=new aF(i,j),p=new aF(m,j),q=new aF(m,n),r=new aF(i,n),N=new aF(J/F,K/F),O=new aF(L/F,M/F),h=D*Math.PI/180;if(h){const w=Math.sin(h),B=Math.cos(h),g=[B,-w,w,B];o._matMult(g),p._matMult(g),r._matMult(g),q._matMult(g)}const C=a.stretch+a.fixed,I=d.stretch+d.fixed;return{tl:o,tr:p,bl:r,br:q,tex:{x:b.paddedRect.x+1+C,y:b.paddedRect.y+1+I,w:e.stretch+e.fixed-C,h:f.stretch+f.fixed-I},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:N,pixelOffsetBR:O,minFontScaleX:y/F/G,minFontScaleY:A/F/H,isSDF:E}};if(o&&(b.stretchX||b.stretchY)){const m=km(d,q,k),n=km(e,r,l);for(let f=0;f{if(b)g(b);else if(c){var d;const e={},a=(d=c,new d2(d).readFields(jW,{}));for(const f of a.glyphs)e[f.id]=f;g(null,{glyphs:e,ascender:a.ascender,descender:a.descender})}})},aA.TinySDF=class{constructor({fontSize:c=24,buffer:d=3,radius:e=8,cutoff:f=.25,fontFamily:g="sans-serif",fontWeight:h="normal",fontStyle:i="normal"}){this.buffer=d,this.cutoff=f,this.radius=e;const a=this.size=c+4*d,j=this._createCanvas(a),b=this.ctx=j.getContext("2d",{willReadFrequently:!0});b.font=`${i} ${h} ${c}px ${g}`,b.textBaseline="alphabetic",b.textAlign="left",b.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(b){const a=document.createElement("canvas");return a.width=a.height=b,a}draw(p){const{width:u,actualBoundingBoxAscent:q,actualBoundingBoxDescent:v,actualBoundingBoxLeft:w,actualBoundingBoxRight:x}=this.ctx.measureText(p),r=Math.floor(q),b=Math.min(this.size-this.buffer,Math.ceil(x-w)),c=Math.min(this.size-this.buffer,Math.ceil(q)+Math.ceil(v)),d=b+2*this.buffer,m=c+2*this.buffer,i=d*m,s=new Uint8ClampedArray(i),t={data:s,width:d,height:m,glyphWidth:b,glyphHeight:c,glyphTop:r,glyphLeft:0,glyphAdvance:u};if(0===b||0===c)return t;const{ctx:n,buffer:a,gridInner:f,gridOuter:g}=this;n.clearRect(a,a,b,c),n.fillText(p,a,a+r+1);const y=n.getImageData(a,a,b,c);g.fill(1e20,0,i),f.fill(0,0,i);for(let j=0;j0?e*e:0,f[l]=e<0?e*e:0}}ki(g,0,0,d,m,d,this.f,this.v,this.z),ki(f,a,a,b,c,d,this.f,this.v,this.z);for(let h=0;hb?1:0}){if(this.data=b,this.length=this.data.length,this.compare=c,this.length>0)for(let a=(this.length>>1)-1;a>=0;a--)this._down(a)}push(a){this.data.push(a),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const a=this.data[0],b=this.data.pop();return this.length--,this.length>0&&(this.data[0]=b,this._down(0)),a}peek(){return this.data[0]}_up(a){const{data:b,compare:f}=this,c=b[a];for(;a>0;){const d=a-1>>1,e=b[d];if(f(c,e)>=0)break;b[a]=e,a=d}b[a]=c}_down(a){const{data:b,compare:f}=this,h=this.length>>1,g=b[a];for(;af(b[e],d)&&(c=e,d=b[e]),f(d,g)>=0)break;b[a]=d,a=c}b[a]=g}}function kp(e,r=1,p=!1){let h=1/0,i=1/0,j=-1/0,k=-1/0;const q=e[0];for(let f=0;fj)&&(j=c.x),(!f||c.y>k)&&(k=c.y)}const l=Math.min(j-h,k-i);let a=l/2;const d=new ko([],kq);if(0===l)return new aF(h,i);for(let m=h;mg.d||!g.d)&&(g=b,p&&console.log("found best %d after %d probes",Math.round(1e4*b.d)/1e4,o)),b.max-g.d<=r||(a=b.h/2,d.push(new kr(b.p.x-a,b.p.y-a,a,e)),d.push(new kr(b.p.x+a,b.p.y-a,a,e)),d.push(new kr(b.p.x-a,b.p.y+a,a,e)),d.push(new kr(b.p.x+a,b.p.y+a,a,e)),o+=4)}return p&&(console.log(`num probes: ${o}`),console.log(`best distance: ${g.d}`)),g.p}function kq(a,b){return b.max-a.max}function kr(a,b,c,d){this.p=new aF(a,b),this.h=c,this.d=function(b,i){let d=!1,e=1/0;for(let f=0;fb.y!=c.y>b.y&&b.x<(c.x-a.x)*(b.y-a.y)/(c.y-a.y)+a.x&&(d=!d),e=Math.min(e,im(b,a,c))}}return(d?1:-1)*Math.sqrt(e)}(this.p,d),this.max=this.d+this.h*Math.SQRT2}const ks=Number.POSITIVE_INFINITY,kt=Math.sqrt(2);function ea(b,a){return a[1]!==ks?function(e,a,b){let c=0,d=0;switch(a=Math.abs(a),b=Math.abs(b),e){case"top-right":case"top-left":case"top":d=b-7;break;case"bottom-right":case"bottom-left":case"bottom":d=7-b}switch(e){case"top-right":case"bottom-right":case"right":c=-a;break;case"top-left":case"bottom-left":case"left":c=a}return[c,d]}(b,a[0],a[1]):function(e,a){let b=0,c=0;a<0&&(a=0);const d=a/kt;switch(e){case"top-right":case"top-left":c=d-7;break;case"bottom-right":case"bottom-left":c=7-d;break;case"bottom":c=7-a;break;case"top":c=a-7}switch(e){case"top-right":case"bottom-right":b=-d;break;case"top-left":case"bottom-left":b=d;break;case"left":b=a;break;case"right":b=-a}return[b,c]}(b,a[0])}function ku(a,w,x,y,n,M,N,b,o,O){a.createArrays(),a.tilePixelRatio=8192/(512*a.overscaling),a.compareText={},a.iconsNeedLinear=!1;const d=a.layers[0].layout,g=a.layers[0]._unevaluatedLayout._values,e={};if("composite"===a.textSizeData.kind){const{minZoom:P,maxZoom:Q}=a.textSizeData;e.compositeTextSizes=[g["text-size"].possiblyEvaluate(new c5(P),b),g["text-size"].possiblyEvaluate(new c5(Q),b),]}if("composite"===a.iconSizeData.kind){const{minZoom:R,maxZoom:S}=a.iconSizeData;e.compositeIconSizes=[g["icon-size"].possiblyEvaluate(new c5(R),b),g["icon-size"].possiblyEvaluate(new c5(S),b),]}e.layoutTextSize=g["text-size"].possiblyEvaluate(new c5(o+1),b),e.layoutIconSize=g["icon-size"].possiblyEvaluate(new c5(o+1),b),e.textMaxSize=g["text-size"].possiblyEvaluate(new c5(18),b);const z="map"===d.get("text-rotation-alignment")&&"point"!==d.get("symbol-placement"),T=d.get("text-size");for(const c of a.features){const A=d.get("text-font").evaluate(c,{},b).join(","),B=T.evaluate(c,{},b),p=e.layoutTextSize.evaluate(c,{},b),f=(e.layoutIconSize.evaluate(c,{},b),{horizontal:{},vertical:void 0}),k=c.text;let q,l=[0,0];if(k){const C=k.toString(),U=24*d.get("text-letter-spacing").evaluate(c,{},b),D=24*d.get("text-line-height").evaluate(c,{},b),E=ht(C)?U:0,r=d.get("text-anchor").evaluate(c,{},b),s=d.get("text-variable-anchor");if(!s){const F=d.get("text-radial-offset").evaluate(c,{},b);l=F?ea(r,[24*F,ks]):d.get("text-offset").evaluate(c,{},b).map(a=>24*a)}let h=z?"center":d.get("text-justify").evaluate(c,{},b);const i=d.get("symbol-placement"),V="point"===i,G="point"===i?24*d.get("text-max-width").evaluate(c,{},b):0,H=b=>{a.allowVerticalPlacement&&hs(C)&&(f.vertical=j_(k,w,x,n,A,G,D,r,b,E,l,d5.vertical,!0,i,p,B))};if(!z&&s){const I="auto"===h?s.map(a=>eb(a)):[h];let J=!1;for(let t=0;t=0||!hs(C)){const K=j_(k,w,x,n,A,G,D,r,h,E,l,d5.horizontal,!1,i,p,B);K&&(f.horizontal[h]=K)}H("point"===i?"left":h)}}let L=!1;if(c.icon&&c.icon.name){const j=y[c.icon.name];j&&(q=j9(n[c.icon.name],d.get("icon-offset").evaluate(c,{},b),d.get("icon-anchor").evaluate(c,{},b)),L=j.sdf,void 0===a.sdfIcons?a.sdfIcons=j.sdf:a.sdfIcons!==j.sdf&&bY("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(j.pixelRatio!==a.pixelRatio||0!==d.get("icon-rotate").constantOr(1))&&(a.iconsNeedLinear=!0))}const v=ky(f.horizontal)||f.vertical;a.iconsInText||(a.iconsInText=!!v&&v.iconsInText),(v||q)&&kv(a,c,f,q,y,e,p,0,l,L,N,b,O)}M&&a.generateCollisionDebugBuffers(o,a.collisionBoxArray)}function eb(a){switch(a){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function kv(c,b,e,f,F,A,n,G,H,I,J,d,K){let i=A.textMaxSize.evaluate(b,{},d);void 0===i&&(i=n);const a=c.layers[0].layout,o=a.get("icon-offset").evaluate(b,{},d),g=ky(e.horizontal)||e.vertical,p=n/24,q=c.tilePixelRatio*i/24,r=c.tilePixelRatio*a.get("symbol-spacing"),L=a.get("text-padding")*c.tilePixelRatio,M=a.get("icon-padding")*c.tilePixelRatio,s=a.get("text-max-angle")*aP,N="map"===a.get("text-rotation-alignment")&&"point"!==a.get("symbol-placement"),O="map"===a.get("icon-rotation-alignment")&&"point"!==a.get("symbol-placement"),t=a.get("symbol-placement"),B=r/2,j=a.get("icon-text-fit");let C;f&&"none"!==j&&(c.allowVerticalPlacement&&e.vertical&&(C=ka(f,e.vertical,j,a.get("icon-text-fit-padding"),o,p)),g&&(f=ka(f,g,j,a.get("icon-text-fit-padding"),o,p)));const h=(g,a,h)=>{if(a.x<0||a.x>=8192||a.y<0||a.y>=8192)return;const{x:i,y:j,z:k}=K.projectTilePoint(a.x,a.y,h),l=new d7(i,j,k,0,void 0);!function(a,d,e,aa,h,z,H,j,f,r,m,s,t,I,u,v,ac,J,K,L,b,w,M,x,c){const k=a.addToLineVertexArray(d,aa);let l,n,o,y,N,O,P,Q=0,R=0,S=0,T=0,A=-1,B=-1;const g={};let U=bd(""),C=0,D=0;if(void 0===f._unevaluatedLayout.getValue("text-radial-offset")?[C,D]=f.layout.get("text-offset").evaluate(b,{},c).map(a=>24*a):(C=24*f.layout.get("text-radial-offset").evaluate(b,{},c),D=ks),a.allowVerticalPlacement&&h.vertical){const V=h.vertical;if(u)O=kA(V),j&&(P=kA(j));else{const W=f.layout.get("text-rotate").evaluate(b,{},c)+90;o=kz(r,e,d,m,s,t,V,I,W,v),j&&(y=kz(r,e,d,m,s,t,j,J,W))}}if(z){const E=f.layout.get("icon-rotate").evaluate(b,{},c),X="none"!==f.layout.get("icon-text-fit"),Y=kk(z,E,M,X),F=j?kk(j,E,M,X):void 0;n=kz(r,e,d,m,s,t,z,J,E),Q=4*Y.length;const Z=a.iconSizeData;let p=null;"source"===Z.kind?(p=[128*f.layout.get("icon-size").evaluate(b,{},c),])[0]>kw&&bY(`${a.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`):"composite"===Z.kind&&((p=[128*w.compositeIconSizes[0].evaluate(b,{},c),128*w.compositeIconSizes[1].evaluate(b,{},c),])[0]>kw||p[1]>kw)&&bY(`${a.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`),a.addSymbols(a.icon,Y,p,L,K,b,!1,e,d,k.lineStartIndex,k.lineLength,-1,x,c),A=a.icon.placedSymbolArray.length-1,F&&(R=4*F.length,a.addSymbols(a.icon,F,p,L,K,b,d5.vertical,e,d,k.lineStartIndex,k.lineLength,-1,x,c),B=a.icon.placedSymbolArray.length-1)}for(const $ in h.horizontal){const q=h.horizontal[$];l||(U=bd(q.text),u?N=kA(q):l=kz(r,e,d,m,s,t,q,I,f.layout.get("text-rotate").evaluate(b,{},c),v));const _=1===q.positionedLines.length;if(S+=kx(a,e,d,q,H,f,u,b,v,k,h.vertical?d5.horizontal:d5.horizontalOnly,_?Object.keys(h.horizontal):[$],g,A,w,x,c),_)break}h.vertical&&(T+=kx(a,e,d,h.vertical,H,f,u,b,v,k,d5.vertical,["vertical"],g,B,w,x,c));let i=-1;const G=(a,b)=>a?Math.max(a,b):b;i=G(N,i),i=G(O,i),i=G(P,i);const ab=i> -1?1:0;a.glyphOffsetArray.length>=aB.MAX_GLYPHS&&bY("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==b.sortKey&&a.addToSortKeyRanges(a.symbolInstances.length,b.sortKey),a.symbolInstances.emplaceBack(e.x,e.y,e.z,d.x,d.y,g.right>=0?g.right:-1,g.center>=0?g.center:-1,g.left>=0?g.left:-1,g.vertical>=0?g.vertical:-1,A,B,U,void 0!==l?l:a.collisionBoxArray.length,void 0!==l?l+1:a.collisionBoxArray.length,void 0!==o?o:a.collisionBoxArray.length,void 0!==o?o+1:a.collisionBoxArray.length,void 0!==n?n:a.collisionBoxArray.length,void 0!==n?n+1:a.collisionBoxArray.length,y||a.collisionBoxArray.length,y?y+1:a.collisionBoxArray.length,m,S,T,Q,R,ab,0,C,D,i)}(c,a,l,g,e,f,F,C,c.layers[0],c.collisionBoxArray,b.index,b.sourceLayerIndex,c.index,L,N,H,0,M,O,o,b,A,I,J,d)};if("line"===t)for(const u of d8(b.geometry,0,0,8192,8192)){const D=kg(u,r,s,e.vertical||g,f,24,q,c.overscaling,8192);for(const v of D){const w=g;w&&kB(c,w.text,B,v)||h(u,v,d)}}else if("line-center"===t){for(const k of b.geometry)if(k.length>1){const x=kf(k,s,e.vertical||g,f,24,q);x&&h(k,x,d)}}else if("Polygon"===b.type)for(const y of i8(b.geometry,0)){const z=kp(y,16);h(y[0],new d7(z.x,z.y,0,0,void 0),d)}else if("LineString"===b.type)for(const l of b.geometry)h(l,new d7(l[0].x,l[0].y,0,0,void 0),d);else if("Point"===b.type)for(const E of b.geometry)for(const m of E)h([m],new d7(m.x,m.y,0,0,void 0),d)}const kw=32640;function kx(a,l,m,n,o,e,f,b,g,h,p,q,r,s,i,t,c){const j=function(Z,c,g,M,l,N,O,B){const s=[];if(0===c.positionedLines.length)return s;const h=M.layout.get("text-rotate").evaluate(N,{})*Math.PI/180,m=function(c){const a=c[0],b=c[1],d=a*b;return d>0?[a,-b]:d<0?[-a,b]:0===a?[b,a]:[b,-a]}(g);let C=Math.abs(c.top-c.bottom);for(const P of c.positionedLines)C-=P.lineOffset;const D=c.positionedLines.length,Q=C/D;let t=c.top-g[1];for(let n=0;nkw&&bY(`${a.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`):"composite"===k.kind&&((d=[128*i.compositeTextSizes[0].evaluate(b,{},c),128*i.compositeTextSizes[1].evaluate(b,{},c),])[0]>kw||d[1]>kw)&&bY(`${a.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`),a.addSymbols(a.text,j,d,g,f,b,p,l,m,h.lineStartIndex,h.lineLength,s,t,c),q))r[u]=a.text.placedSymbolArray.length-1;return 4*j.length}function ky(a){for(const b in a)return a[b];return null}function kz(o,m,p,r,s,t,a,u,q,n){let b=a.top,c=a.bottom,d=a.left,e=a.right;const f=a.collisionPadding;if(f&&(d-=f[0],b-=f[1],e+=f[2],c+=f[3]),q){const g=new aF(d,b),h=new aF(e,b),i=new aF(d,c),j=new aF(e,c),l=q*aP;let k=new aF(0,0);n&&(k=new aF(n[0],n[1])),g._rotateAround(l,k),h._rotateAround(l,k),i._rotateAround(l,k),j._rotateAround(l,k),d=Math.min(g.x,h.x,i.x,j.x),e=Math.max(g.x,h.x,i.x,j.x),b=Math.min(g.y,h.y,i.y,j.y),c=Math.max(g.y,h.y,i.y,j.y)}return o.emplaceBack(m.x,m.y,m.z,p.x,p.y,d,b,e,c,u,r,s,t),o.length-1}function kA(a){a.collisionPadding&&(a.top-=a.collisionPadding[1],a.bottom+=a.collisionPadding[3]);const b=a.bottom-a.top;return b>0?Math.max(10,b):null}function kB(f,a,g,d){const b=f.compareText;if(a in b){const e=b[a];for(let c=e.length-1;c>=0;c--)if(d.dist(e[c])a.id),this.index=a.index,this.pixelRatio=a.pixelRatio,this.sourceLayerIndex=a.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=aI([]),this.placementViewportMatrix=aI([]);const d=this.layers[0]._unevaluatedLayout._values;this.textSizeData=d0(this.zoom,d["text-size"]),this.iconSizeData=d0(this.zoom,d["icon-size"]);const b=this.layers[0].layout,e=b.get("symbol-sort-key"),c=b.get("symbol-z-order");this.canOverlap=b.get("text-allow-overlap")||b.get("icon-allow-overlap")||b.get("text-ignore-placement")||b.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==c&& void 0!==e.constantOr(1),this.sortFeaturesByY=("viewport-y"===c||"auto"===c&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=b.get("text-writing-mode").map(a=>d5[a]),this.stateDependentLayerIds=this.layers.filter(a=>a.isStateDependent()).map(a=>a.id),this.sourceID=a.sourceID}createArrays(){this.text=new ec(new dv(this.layers,this.zoom,a=>/^text/.test(a))),this.icon=new ec(new dv(this.layers,this.zoom,a=>/^icon/.test(a))),this.glyphOffsetArray=new dd,this.lineVertexArray=new de,this.symbolInstances=new dc}calculateGlyphDependencies(b,c,g,e,f){for(let a=0;a0)&&("constant"!==k.value.kind||k.value.value.length>0),o="constant"!==l.value.kind||!!l.value.value||Object.keys(l.parameters).length>0,x=b.get("symbol-sort-key");if(this.features=[],!n&&!o)return;const p=j.iconDependencies,q=j.glyphDependencies,r=j.availableImages,y=new c5(this.zoom);for(const{feature:h,id:z,index:A,sourceLayerIndex:B}of v){const s=d._featureFilter.needGeometry,a=id(h,s);if(!d._featureFilter.filter(y,a,c))continue;let e,f;if(s||(a.geometry=ic(h,c,w)),n){const C=d.getValueAndResolveTokens("text-field",a,c,r),t=fB.factory(C);kF(t)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===c3()||this.hasRTLText&&c4.isParsed())&&(e=jB(t,d,a))}if(o){const m=d.getValueAndResolveTokens("icon-image",a,c,r);f=m instanceof cj?m:cj.fromString(m)}if(!e&&!f)continue;const D=this.sortFeaturesByKey?x.evaluate(a,{},c):void 0;if(this.features.push({id:z,text:e,icon:f,index:A,sourceLayerIndex:B,geometry:a.geometry,properties:h.properties,type:kC[h.type],sortKey:D}),f&&(p[f.name]=!0),e){const E=k.evaluate(a,{},c).join(","),F="map"===b.get("text-rotation-alignment")&&"point"!==b.get("symbol-placement");for(const i of(this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(d5.vertical)>=0,e.sections))if(i.image)p[i.image.name]=!0;else{const G=hs(e.toString()),u=i.fontStack||E,H=q[u]=q[u]||{};this.calculateGlyphDependencies(i.text,H,F,this.allowVerticalPlacement,G)}}}"line"===b.get("symbol-placement")&&(this.features=function(k){const d={},c={},g=[];let l=0;function m(a){g.push(k[a]),l++}function n(b,d,e){const a=c[b];return delete c[b],c[d]=a,g[a].geometry[0].pop(),g[a].geometry[0]=g[a].geometry[0].concat(e[0]),a}function o(c,b,e){const a=d[b];return delete d[b],d[c]=a,g[a].geometry[0].shift(),g[a].geometry[0]=e[0].concat(g[a].geometry[0]),a}function i(c,a,d){const b=d?a[0][a[0].length-1]:a[0][0];return`${c}:${b.x}:${b.y}`}for(let e=0;ea.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((a,b)=>a.sortKey-b.sortKey)}update(a,b,c,d){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(a,b,this.layers,c,d),this.icon.programConfigurations.updatePaintArrays(a,b,this.layers,c,d))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(a){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(a),this.iconCollisionBox.upload(a)),this.text.upload(a,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(a,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(d,a){const h=this.lineVertexArray.length;if(void 0!==d.segment){let i=d.dist(a[d.segment+1]),j=d.dist(a[d.segment]);const e={};for(let b=d.segment+1;b=0;c--)e[c]={x:a[c].x,y:a[c].y,tileUnitDistanceFromAnchor:j},c>0&&(j+=a[c-1].dist(a[c]));for(let f=0;f=0?a.rightJustifiedTextSymbolIndex:a.centerJustifiedTextSymbolIndex>=0?a.centerJustifiedTextSymbolIndex:a.leftJustifiedTextSymbolIndex>=0?a.leftJustifiedTextSymbolIndex:a.verticalPlacedTextSymbolIndex>=0?a.verticalPlacedTextSymbolIndex:c),e=bh(this.textSizeData,b,d)/24;return this.tilePixelRatio*e}getSymbolInstanceIconSize(a,e,b){const c=this.icon.placedSymbolArray.get(b),d=bh(this.iconSizeData,a,c);return this.tilePixelRatio*d}_commitDebugCollisionVertexUpdate(b,c,a){b.emplaceBack(c,-a,-a),b.emplaceBack(c,a,-a),b.emplaceBack(c,a,a),b.emplaceBack(c,-a,a)}_updateTextDebugCollisionBoxes(b,c,d,e,f,g){for(let a=e;a0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(b,d){const c=b.placedSymbolArray.get(d),e=c.vertexStartIndex+4*c.numGlyphs;for(let a=c.vertexStartIndex;ag[a]-g[b]||h[b]-h[a]),c}addToSortKeyRanges(a,c){const b=this.sortKeyRanges[this.sortKeyRanges.length-1];b&&b.sortKey===c?b.symbolInstanceEnd=a+1:this.sortKeyRanges.push({sortKey:c,symbolInstanceStart:a,symbolInstanceEnd:a+1})}sortFeatures(b){if(this.sortFeaturesByY&&this.sortedAngle!==b&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){for(const c of(this.symbolInstanceIndexes=this.getSortedSymbolIndexes(b),this.sortedAngle=b,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[],this.symbolInstanceIndexes)){const a=this.symbolInstances.get(c);this.featureSortOrder.push(a.featureIndex),[a.rightJustifiedTextSymbolIndex,a.centerJustifiedTextSymbolIndex,a.leftJustifiedTextSymbolIndex,].forEach((a,b,c)=>{a>=0&&c.indexOf(a)===b&&this.addIndicesForPlacedSymbol(this.text,a)}),a.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,a.verticalPlacedTextSymbolIndex),a.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,a.placedIconSymbolIndex),a.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,a.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}c("SymbolBucket",aB,{omit:["layers","collisionBoxArray","features","compareText",]}),aB.MAX_GLYPHS=65535,aB.addDynamicAttributes=bk;const ee=new n({"symbol-placement":new e(b.layout_symbol["symbol-placement"]),"symbol-spacing":new e(b.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new e(b.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new g(b.layout_symbol["symbol-sort-key"]),"symbol-z-order":new e(b.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new e(b.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new e(b.layout_symbol["icon-ignore-placement"]),"icon-optional":new e(b.layout_symbol["icon-optional"]),"icon-rotation-alignment":new e(b.layout_symbol["icon-rotation-alignment"]),"icon-size":new g(b.layout_symbol["icon-size"]),"icon-text-fit":new e(b.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new e(b.layout_symbol["icon-text-fit-padding"]),"icon-image":new g(b.layout_symbol["icon-image"]),"icon-rotate":new g(b.layout_symbol["icon-rotate"]),"icon-padding":new e(b.layout_symbol["icon-padding"]),"icon-keep-upright":new e(b.layout_symbol["icon-keep-upright"]),"icon-offset":new g(b.layout_symbol["icon-offset"]),"icon-anchor":new g(b.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new e(b.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new e(b.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new e(b.layout_symbol["text-rotation-alignment"]),"text-field":new g(b.layout_symbol["text-field"]),"text-font":new g(b.layout_symbol["text-font"]),"text-size":new g(b.layout_symbol["text-size"]),"text-max-width":new g(b.layout_symbol["text-max-width"]),"text-line-height":new g(b.layout_symbol["text-line-height"]),"text-letter-spacing":new g(b.layout_symbol["text-letter-spacing"]),"text-justify":new g(b.layout_symbol["text-justify"]),"text-radial-offset":new g(b.layout_symbol["text-radial-offset"]),"text-variable-anchor":new e(b.layout_symbol["text-variable-anchor"]),"text-anchor":new g(b.layout_symbol["text-anchor"]),"text-max-angle":new e(b.layout_symbol["text-max-angle"]),"text-writing-mode":new e(b.layout_symbol["text-writing-mode"]),"text-rotate":new g(b.layout_symbol["text-rotate"]),"text-padding":new e(b.layout_symbol["text-padding"]),"text-keep-upright":new e(b.layout_symbol["text-keep-upright"]),"text-transform":new g(b.layout_symbol["text-transform"]),"text-offset":new g(b.layout_symbol["text-offset"]),"text-allow-overlap":new e(b.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new e(b.layout_symbol["text-ignore-placement"]),"text-optional":new e(b.layout_symbol["text-optional"])});var kG={paint:new n({"icon-opacity":new g(b.paint_symbol["icon-opacity"]),"icon-color":new g(b.paint_symbol["icon-color"]),"icon-halo-color":new g(b.paint_symbol["icon-halo-color"]),"icon-halo-width":new g(b.paint_symbol["icon-halo-width"]),"icon-halo-blur":new g(b.paint_symbol["icon-halo-blur"]),"icon-translate":new e(b.paint_symbol["icon-translate"]),"icon-translate-anchor":new e(b.paint_symbol["icon-translate-anchor"]),"text-opacity":new g(b.paint_symbol["text-opacity"]),"text-color":new g(b.paint_symbol["text-color"],{runtimeType:y,getOverride:a=>a.textColor,hasOverride:a=>!!a.textColor}),"text-halo-color":new g(b.paint_symbol["text-halo-color"]),"text-halo-width":new g(b.paint_symbol["text-halo-width"]),"text-halo-blur":new g(b.paint_symbol["text-halo-blur"]),"text-translate":new e(b.paint_symbol["text-translate"]),"text-translate-anchor":new e(b.paint_symbol["text-translate-anchor"])}),layout:ee};class ef{constructor(a){this.type=a.property.overrides?a.property.overrides.runtimeType:cf,this.defaultValue=a}evaluate(a){if(a.formattedSection){const b=this.defaultValue.property.overrides;if(b&&b.hasOverride(a.formattedSection))return b.getOverride(a.formattedSection)}return a.feature&&a.featureState?this.defaultValue.evaluate(a.feature,a.featureState):this.defaultValue.property.specification.default}eachChild(a){this.defaultValue.isConstant()||a(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}c("FormatSectionOverride",ef,{omit:["defaultValue"]});class eg extends be{constructor(a){super(a,kG)}recalculate(d,e){super.recalculate(d,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 b=this.layout.get("text-writing-mode");if(b){const a=[];for(const c of b)0>a.indexOf(c)&&a.push(c);this.layout._values["text-writing-mode"]=a}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(b,c,e,f){var g;const a=this.layout.get(b).evaluate(c,{},e,f),d=this._unevaluatedLayout._values[b];return d.isDataDriven()||gv(d.value)||!a?a:(g=c.properties,a.replace(/{([^{}]+)}/g,(b,a)=>a in g?String(g[a]):""))}createBucket(a){return new aB(a)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const b of kG.paint.overridableProperties){if(!eg.hasPaintOverride(this.layout,b))continue;const a=this.paint.get(b),e=new ef(a),c=new cM(e,a.property.specification);let d=null;d="constant"===a.value.kind||"source"===a.value.kind?new cO("source",c):new cP("composite",c,a.value.zoomStops,a.value._interpolationType),this.paint._values[b]=new hM(a.property,d,a.parameters)}}_handleOverridablePaintPropertyUpdate(a,b,c){return!(!this.layout||b.isDataDriven()||c.isDataDriven())&&eg.hasPaintOverride(this.layout,a)}static hasPaintOverride(c,d){const a=c.get("text-field"),h=kG.paint.properties[d];let e=!1;const f=a=>{for(const b of a)if(h.overrides&&h.overrides.hasOverride(b))return void(e=!0)};if("constant"===a.value.kind&&a.value.value instanceof fB)f(a.value.value.sections);else if("source"===a.value.kind){const g=a=>{e||(a instanceof ck&&fE(a.value)===ch?f(a.value.sections):a instanceof cl?f(a.sections):a.eachChild(g))},b=a.value;b._styleExpression&&g(b._styleExpression.expression)}return e}getProgramConfiguration(a){return new du(this,a)}}var kH={paint:new n({"background-color":new e(b.paint_background["background-color"]),"background-pattern":new a5(b.paint_background["background-pattern"]),"background-opacity":new e(b.paint_background["background-opacity"])})},kI={paint:new n({"raster-opacity":new e(b.paint_raster["raster-opacity"]),"raster-hue-rotate":new e(b.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new e(b.paint_raster["raster-brightness-min"]),"raster-brightness-max":new e(b.paint_raster["raster-brightness-max"]),"raster-saturation":new e(b.paint_raster["raster-saturation"]),"raster-contrast":new e(b.paint_raster["raster-contrast"]),"raster-resampling":new e(b.paint_raster["raster-resampling"]),"raster-fade-duration":new e(b.paint_raster["raster-fade-duration"])})};class kJ extends be{constructor(a){super(a,{}),this.implementation=a}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){}serialize(){}onAdd(a){this.implementation.onAdd&&this.implementation.onAdd(a,a.painter.context.gl)}onRemove(a){this.implementation.onRemove&&this.implementation.onRemove(a,a.painter.context.gl)}}var kK={paint:new n({"sky-type":new e(b.paint_sky["sky-type"]),"sky-atmosphere-sun":new e(b.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new e(b.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new e(b.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new e(b.paint_sky["sky-gradient-radius"]),"sky-gradient":new V(b.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new e(b.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new e(b.paint_sky["sky-atmosphere-color"]),"sky-opacity":new e(b.paint_sky["sky-opacity"])})};function kL(l,m,n){var a,b,f,h,i,j,k,c,d;const g=Q(0,0,1),e=bG(aO());return a=e,b=e,f=n?-(l*aP)+Math.PI:l*aP,f*=.5,h=b[0],i=b[1],j=b[2],k=b[3],c=Math.sin(f),d=Math.cos(f),a[0]=h*d-j*c,a[1]=i*d+k*c,a[2]=j*d+h*c,a[3]=k*d-i*c,bH(e,e,-(m*aP)),bD(g,g,e),bz(g,g)}const kM={circle:class extends be{constructor(a){super(a,iv)}createBucket(a){return new bf(a)}queryRadius(b){const a=b;return ir("circle-radius",this,a)+ir("circle-stroke-width",this,a)+is(this.paint.get("circle-translate"))}queryIntersectsFeature(a,b,c,e,j,d,f,g){const h=iu(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),d.angle,a.pixelToTileUnitsFactor),i=this.paint.get("circle-radius").evaluate(b,c)+this.paint.get("circle-stroke-width").evaluate(b,c);return iw(a,e,d,f,g,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),h,i)}getProgramIds(){return["circle"]}getProgramConfiguration(a){return new du(this,a)}},heatmap:class extends be{createBucket(a){return new dI(a)}constructor(a){super(a,iE),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(a){"heatmap-color"===a&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=dK({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(a){return ir("heatmap-radius",this,a)}queryIntersectsFeature(a,b,c,d,i,e,f,g){const h=this.paint.get("heatmap-radius").evaluate(b,c);return iw(a,d,e,f,g,!0,!0,new aF(0,0),h)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(a){return new du(this,a)}},hillshade:class extends be{constructor(a){super(a,iF)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare",]}getProgramConfiguration(a){return new du(this,a)}},fill:class extends be{constructor(a){super(a,jc)}getProgramIds(){const a=this.paint.get("fill-pattern"),b=a&&a.constantOr(1),c=[b?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&c.push(b&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),c}getProgramConfiguration(a){return new du(this,a)}recalculate(b,c){super.recalculate(b,c);const a=this.paint._values["fill-outline-color"];"constant"===a.value.kind&& void 0===a.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(a){return new dN(a)}queryRadius(){return is(this.paint.get("fill-translate"))}queryIntersectsFeature(a,d,e,b,f,c){return!a.queryGeometry.isAboveHorizon&&ih(it(a.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),c.angle,a.pixelToTileUnitsFactor),b)}isTileClipped(){return!0}},"fill-extrusion":class extends be{constructor(a){super(a,jm)}createBucket(a){return new dU(a)}queryRadius(){return is(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion",]}getProgramConfiguration(a){return new du(this,a)}queryIntersectsFeature(c,k,l,v,C,a,w,m,x){var d,e,f,g,h,i,n,o,p;const y=iu(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),a.angle,c.pixelToTileUnitsFactor),z=this.paint.get("fill-extrusion-height").evaluate(k,l),A=this.paint.get("fill-extrusion-base").evaluate(k,l),b=[0,0],q=m&&a.elevation,B=a.elevation?a.elevation.exaggeration():1;if(q){const r=c.tile.getBucket(this).centroidVertexArray,s=x+1;if(s=3){for(let d=0;d1&&(b=i[++j]);const n=Math.abs(a-b.left),o=Math.abs(a-b.right),e=Math.min(n,o);let g;const h=d/c*(f+1);if(b.isDash){const k=f-Math.abs(h);g=Math.sqrt(e*e+k*k)}else g=f-Math.sqrt(e*e+h*h);this.image.data[m+a]=Math.max(0,Math.min(255,g+128))}}}addRegularDash(a,k){for(let b=a.length-1;b>=0;--b){const e=a[b],f=a[b+1];e.zeroLength?a.splice(b,1):f&&f.isDash===e.isDash&&(f.left=e.left,a.splice(b,1))}const g=a[0],h=a[a.length-1];g.isDash===h.isDash&&(g.left=h.left-this.width,h.right=g.right+this.width);const l=this.width*this.nextRow;let i=0,d=a[i];for(let c=0;c1&&(d=a[++i]);const m=Math.abs(c-d.left),n=Math.abs(c-d.right),j=Math.min(m,n);this.image.data[l+c]=Math.max(0,Math.min(255,(d.isDash?j:-j)+k+128))}}addDash(a,e){const f=this.getKey(a,e);if(this.positions[f])return this.positions[f];const h="round"===e,c=h?7:0,i=2*c+1;if(this.nextRow+i>this.height)return bY("LineAtlas out of space"),null;0===a.length&&a.push(1);let d=0;for(let b=0;b0;a--)c+=(e&(b=1<this.canonical.z?new bn(a,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new bn(a,this.wrap,a,this.canonical.x>>b,this.canonical.y>>b)}calculateScaledKey(a,b=!0){if(this.overscaledZ===a&&b)return this.key;if(a>this.canonical.z)return kU(this.wrap*+b,a,this.canonical.z,this.canonical.x,this.canonical.y);{const c=this.canonical.z-a;return kU(this.wrap*+b,a,a,this.canonical.x>>c,this.canonical.y>>c)}}isChildOf(a){if(a.wrap!==this.wrap)return!1;const b=this.canonical.z-a.canonical.z;return 0===a.overscaledZ||a.overscaledZ>b&&a.canonical.y===this.canonical.y>>b}children(d){if(this.overscaledZ>=d)return[new bn(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y),];const a=this.canonical.z+1,b=2*this.canonical.x,c=2*this.canonical.y;return[new bn(a,this.wrap,a,b,c),new bn(a,this.wrap,a,b+1,c),new bn(a,this.wrap,a,b,c+1),new bn(a,this.wrap,a,b+1,c+1),]}isLessThan(a){return this.wrapa.wrap)&&(this.overscaledZa.overscaledZ)&&(this.canonical.xa.canonical.x)&&this.canonical.yMath.abs(i[a])){if(d[a]h[a])return null}else{const j=1/i[a];let b=(g[a]-d[a])*j,c=(h[a]-d[a])*j;if(b>c){const k=b;b=c,c=k}if(b>e&&(e=b),cf)return null}return e}function kZ(b,c,d,y,z,A,B,C,D,e,a){const f=y-b,g=z-c,h=A-d,i=B-b,j=C-c,k=D-d,q=a[1]*k-a[2]*j,r=a[2]*i-a[0]*k,s=a[0]*j-a[1]*i,t=f*q+g*r+h*s;if(1e-15>Math.abs(t))return null;const l=1/t,m=e[0]-b,n=e[1]-c,o=e[2]-d,p=(m*q+n*r+o*s)*l;if(p<0||p>1)return null;const u=n*h-o*g,v=o*f-m*h,w=m*g-n*f,x=(a[0]*u+a[1]*v+a[2]*w)*l;return x<0||p+x>1?null:(i*u+j*v+k*w)*l}function k$(d,e,j,b,c,k,l,f,g){const a=1<{const e=f?1:0,g=(c+1)*a-e,h=d*a,i=(d+1)*a-e;b[0]=c*a,b[1]=h,b[2]=g,b[3]=i};let c=new kX(b);const a=[];for(let g=0;g=1;b/=2){const d=f[f.length-1];c=new kX(b);for(let h=0;h0;){const{idx:u,t:B,nodex:g,nodey:h,depth:j}=t.pop();if(this.leaves[u]){k$(g,h,j,o,p,q,r,a,b);const k=1<=x[2])return B}continue}let l=0;for(let c=0;c=s[i[m]]&&(i.splice(m,0,c),y=!0);y||(i[l]=c),l++}}for(let z=0;z=this.dim+1||b< -1||b>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(b+1)*this.stride+(a+1)}_unpackMapbox(a,b,c){return(256*a*256+256*b+c)/10-1e4}_unpackTerrarium(a,b,c){return 256*a+b+c/256-32768}static pack(d,e){const b=[0,0,0,0],c=bo.getUnpackVector(e);let a=Math.floor((d+c[3])/c[2]);return b[2]=a%256,a=Math.floor(a/256),b[1]=a%256,a=Math.floor(a/256),b[0]=a,b}getPixels(){return new bg({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(i,a,b){if(this.dim!==i.dim)throw new Error("dem dimension mismatch");let e=a*this.dim,f=a*this.dim+this.dim,g=b*this.dim,h=b*this.dim+this.dim;switch(a){case -1:e=f-1;break;case 1:f=e+1}switch(b){case -1:g=h-1;break;case 1:h=g+1}const j=-a*this.dim,k=-b*this.dim;for(let c=g;c{"source"===a.dataType&&"metadata"===a.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===a.dataType&&"content"===a.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))}),a.on("error",()=>{this._sourceErrored=!0}),this._source=a,this._tiles={},this._cache=new class{constructor(a,b){this.max=a,this.onRemove=b,this.reset()}reset(){for(const b in this.data)for(const a of this.data[b])a.timeout&&clearTimeout(a.timeout),this.onRemove(a.value);return this.data={},this.order=[],this}add(e,f,b){const a=e.wrapped().key;void 0===this.data[a]&&(this.data[a]=[]);const c={value:f,timeout:void 0};if(void 0!==b&&(c.timeout=setTimeout(()=>{this.remove(e,c)},b)),this.data[a].push(c),this.order.push(a),this.order.length>this.max){const d=this._getAndRemoveByKey(this.order[0]);d&&this.onRemove(d)}return this}has(a){return a.wrapped().key in this.data}getAndRemove(a){return this.has(a)?this._getAndRemoveByKey(a.wrapped().key):null}_getAndRemoveByKey(a){const b=this.data[a].shift();return b.timeout&&clearTimeout(b.timeout),0===this.data[a].length&&delete this.data[a],this.order.splice(this.order.indexOf(a),1),b.value}getByKey(b){const a=this.data[b];return a?a[0].value:null}get(a){return this.has(a)?this.data[a.wrapped().key][0].value:null}remove(c,d){if(!this.has(c))return this;const a=c.wrapped().key,e=void 0===d?0:this.data[a].indexOf(d),b=this.data[a][e];return this.data[a].splice(e,1),b.timeout&&clearTimeout(b.timeout),0===this.data[a].length&&delete this.data[a],this.onRemove(b.value),this.order.splice(this.order.indexOf(a),1),this}setMaxSize(b){for(this.max=b;this.order.length>this.max;){const a=this._getAndRemoveByKey(this.order[0]);a&&this.onRemove(a)}return this}filter(d){const a=[];for(const e in this.data)for(const b of this.data[e])d(b.value)||a.push(b);for(const c of a)this.remove(c.value.tileID,c)}}(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=null,this._maxTileCacheSize=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new class{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(a,g,c){const b=String(g);if(this.stateChanges[a]=this.stateChanges[a]||{},this.stateChanges[a][b]=this.stateChanges[a][b]||{},bR(this.stateChanges[a][b],c),null===this.deletedStates[a])for(const d in this.deletedStates[a]={},this.state[a])d!==b&&(this.deletedStates[a][d]=null);else if(this.deletedStates[a]&&null===this.deletedStates[a][b])for(const e in this.deletedStates[a][b]={},this.state[a][b])c[e]||(this.deletedStates[a][b][e]=null);else for(const f in c)this.deletedStates[a]&&this.deletedStates[a][b]&&null===this.deletedStates[a][b][f]&&delete this.deletedStates[a][b][f]}removeFeatureState(a,d,c){if(null===this.deletedStates[a])return;const b=String(d);if(this.deletedStates[a]=this.deletedStates[a]||{},c&& void 0!==d)null!==this.deletedStates[a][b]&&(this.deletedStates[a][b]=this.deletedStates[a][b]||{},this.deletedStates[a][b][c]=null);else if(void 0!==d){if(this.stateChanges[a]&&this.stateChanges[a][b])for(c in this.deletedStates[a][b]={},this.stateChanges[a][b])this.deletedStates[a][b][c]=null;else this.deletedStates[a][b]=null}else this.deletedStates[a]=null}getState(a,b){const c=String(b),d=bR({},(this.state[a]||{})[c],(this.stateChanges[a]||{})[c]);if(null===this.deletedStates[a])return{};if(this.deletedStates[a]){const e=this.deletedStates[a][b];if(null===e)return{};for(const f in e)delete d[f]}return d}initializeTileState(a,b){a.setFeatureState(this.state,b)}coalesceChanges(g,j){const c={};for(const b in this.stateChanges){this.state[b]=this.state[b]||{};const h={};for(const d in this.stateChanges[b])this.state[b][d]||(this.state[b][d]={}),bR(this.state[b][d],this.stateChanges[b][d]),h[d]=this.state[b][d];c[b]=h}for(const a in this.deletedStates){this.state[a]=this.state[a]||{};const f={};if(null===this.deletedStates[a])for(const i in this.state[a])f[i]={},this.state[a][i]={};else for(const e in this.deletedStates[a]){if(null===this.deletedStates[a][e])this.state[a][e]={};else for(const k of Object.keys(this.deletedStates[a][e]))delete this.state[a][e][k];f[e]=this.state[a][e]}c[a]=c[a]||{},bR(c[a],f)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(c).length)for(const l in g)g[l].setFeatureState(c,j)}}}onAdd(a){this.map=a,this._minTileCacheSize=a?a._minTileCacheSize:null,this._maxTileCacheSize=a?a._maxTileCacheSize:null}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const b in this._tiles){const a=this._tiles[b];if("loaded"!==a.state&&"errored"!==a.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const a=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,a&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(a,b){return a.isSymbolTile=this._onlySymbols,this._source.loadTile(a,b)}_unloadTile(a){if(this._source.unloadTile)return this._source.unloadTile(a,()=>{})}_abortTile(a){if(this._source.abortTile)return this._source.abortTile(a,()=>{})}serialize(){return this._source.serialize()}prepare(b){for(const c in this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null),this._tiles){const a=this._tiles[c];a.upload(b),a.prepare(this.map.style.imageManager)}}getIds(){return bQ(this._tiles).map(a=>a.tileID).sort(k2).map(a=>a.key)}getRenderableIds(b){const a=[];for(const c in this._tiles)this._isIdRenderable(+c,b)&&a.push(this._tiles[c]);return b?a.sort((e,f)=>{const a=e.tileID,b=f.tileID,c=new aF(a.canonical.x,a.canonical.y)._rotate(this.transform.angle),d=new aF(b.canonical.x,b.canonical.y)._rotate(this.transform.angle);return a.overscaledZ-b.overscaledZ||d.y-c.y||d.x-c.x}).map(a=>a.tileID.key):a.map(a=>a.tileID).sort(k2).map(a=>a.key)}hasRenderableParent(b){const a=this.findLoadedParent(b,0);return!!a&&this._isIdRenderable(a.tileID.key)}_isIdRenderable(a,b){return this._tiles[a]&&this._tiles[a].hasData()&&!this._coveredTiles[a]&&(b||!this._tiles[a].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else for(const a in this._cache.reset(),this._tiles)"errored"!==this._tiles[a].state&&this._reloadTile(+a,"reloading")}_reloadTile(b,c){const a=this._tiles[b];a&&("loading"!==a.state&&(a.state=c),this._loadTile(a,this._tileLoaded.bind(this,a,b,c)))}_tileLoaded(a,d,e,b){if(b){if(a.state="errored",404!==b.status)this._source.fire(new cb(b,{tile:a}));else if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const c=this.map.painter.terrain;this.update(this.transform,c.getScaledDemTileSize(),!0),c.resetTileLookupCache(this.id)}else this.update(this.transform)}else a.timeAdded=b$.now(),"expired"===e&&(a.refreshedUponExpiration=!0),this._setTileReloadTimer(d,a),"raster-dem"===this._source.type&&a.dem&&this._backfillDEM(a),this._state.initializeTileState(a,this.map?this.map.painter:null),this._source.fire(new aW("data",{dataType:"source",tile:a,coord:a.tileID,sourceCacheId:this.id}))}_backfillDEM(a){const c=this.getRenderableIds();for(let b=0;b1||(Math.abs(b)>1&&(1===Math.abs(b+d)?b+=d:1===Math.abs(b-d)&&(b-=d)),c.dem&&a.dem&&(a.dem.backfillBorder(c.dem,b,e),a.neighboringTiles&&a.neighboringTiles[f]&&(a.neighboringTiles[f].backfilled=!0)))}}getTile(a){return this.getTileByID(a.key)}getTileByID(a){return this._tiles[a]}_retainLoadedChildren(h,d,i,e){for(const f in this._tiles){let a=this._tiles[f];if(e[f]||!a.hasData()||a.tileID.overscaledZ<=d||a.tileID.overscaledZ>i)continue;let b=a.tileID;for(;a&&a.tileID.overscaledZ>d+1;){const g=a.tileID.scaledTo(a.tileID.overscaledZ-1);(a=this._tiles[g.key])&&a.hasData()&&(b=g)}let c=b;for(;c.overscaledZ>d;)if(h[(c=c.scaledTo(c.overscaledZ-1)).key]){e[b.key]=b;break}}}findLoadedParent(a,d){if(a.key in this._loadedParentTiles){const b=this._loadedParentTiles[a.key];return b&&b.tileID.overscaledZ>=d?b:null}for(let c=a.overscaledZ-1;c>=d;c--){const f=a.scaledTo(c),e=this._getLoadedTile(f);if(e)return e}}_getLoadedTile(a){const b=this._tiles[a.key];return b&&b.hasData()?b:this._cache.getByKey(this._source.reparseOverscaled?a.wrapped().key:a.canonical.key)}updateCacheSize(b,a){a=a||this._source.tileSize;const e=Math.ceil(b.width/a)+1,f=Math.ceil(b.height/a)+1,c=Math.floor(e*f*5),d="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,c):c,g="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,d):d;this._cache.setMaxSize(g)}handleWrapJump(b){const c=Math.round((b-(void 0===this._prevLng?b:this._prevLng))/360);if(this._prevLng=b,c){const d={};for(const g in this._tiles){const a=this._tiles[g];a.tileID=a.tileID.unwrapTo(a.tileID.wrap+c),d[a.tileID.key]=a}for(const e in this._tiles=d,this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const f in this._tiles)this._setTileReloadTimer(+f,this._tiles[f])}}update(e,n,o){if(this.transform=e,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!o)return;let a;this.updateCacheSize(e,n),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?a=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(a=>new bn(a.canonical.z,a.wrap,a.canonical.z,a.canonical.x,a.canonical.y)):(a=e.coveringTiles({tileSize:n||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&&(a=a.filter(a=>this._source.hasTile(a)))):a=[];const b=this._updateRetainedTiles(a);if(k3(this._source.type)&&0!==a.length){const h={},p={},s=Object.keys(b);for(const i of s){const j=b[i],k=this._tiles[i];if(!k||k.fadeEndTime&&k.fadeEndTime<=b$.now())continue;const f=this.findLoadedParent(j,Math.max(j.overscaledZ-aD.maxOverzooming,this._source.minzoom));f&&(this._addTile(f.tileID),h[f.tileID.key]=f.tileID),p[i]=j}const t=a[a.length-1].overscaledZ;for(const l in this._tiles){const m=this._tiles[l];if(b[l]||!m.hasData())continue;let c=m.tileID;for(;c.overscaledZ>t;){c=c.scaledTo(c.overscaledZ-1);const q=this._tiles[c.key];if(q&&q.hasData()&&p[c.key]){b[l]=m.tileID;break}}}for(const g in h)b[g]||(this._coveredTiles[g]=!0,b[g]=h[g])}for(const u in b)this._tiles[u].clearFadeHold();const v=function(c,d){const a=[];for(const b in c)b in d||a.push(b);return a}(this._tiles,b);for(const r of v){const d=this._tiles[r];d.hasSymbolBuckets&&!d.holdingForFade()?d.setHoldDuration(this.map._fadeDuration):d.hasSymbolBuckets&&!d.symbolFadeFinished()||this._removeTile(+r)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const a in this._tiles)this._tiles[a].holdingForFade()&&this._removeTile(+a)}_updateRetainedTiles(e){const a={};if(0===e.length)return a;const j={},k=e.reduce((a,b)=>Math.min(a,b.overscaledZ),1/0),l=e[0].overscaledZ,p=Math.max(l-aD.maxOverzooming,this._source.minzoom),q=Math.max(l+aD.maxUnderzooming,this._source.minzoom),m={};for(const f of e){const r=this._addTile(f);a[f.key]=f,r.hasData()||k=this._source.maxzoom){const h=c.children(this._source.maxzoom)[0],n=this.getTile(h);if(n&&n.hasData()){a[h.key]=h;continue}}else{const g=c.children(this._source.maxzoom);if(a[g[0].key]&&a[g[1].key]&&a[g[2].key]&&a[g[3].key])continue}let o=b.wasRequested();for(let i=c.overscaledZ-1;i>=p;--i){const d=c.scaledTo(i);if(j[d.key]||(j[d.key]=!0,(b=this.getTile(d))||!o||(b=this._addTile(d)),b&&(a[d.key]=d,o=b.wasRequested(),b.hasData())))break}}return a}_updateLoadedParentTileCache(){for(const e in this._loadedParentTiles={},this._tiles){const c=[];let b,a=this._tiles[e].tileID;for(;a.overscaledZ>0;){if(a.key in this._loadedParentTiles){b=this._loadedParentTiles[a.key];break}c.push(a.key);const d=a.scaledTo(a.overscaledZ-1);if(b=this._getLoadedTile(d))break;a=d}for(const f of c)this._loadedParentTiles[f]=b}}_addTile(b){let a=this._tiles[b.key];if(a)return a;(a=this._cache.getAndRemove(b))&&(this._setTileReloadTimer(b.key,a),a.tileID=b,this._state.initializeTileState(a,this.map?this.map.painter:null),this._cacheTimers[b.key]&&(clearTimeout(this._cacheTimers[b.key]),delete this._cacheTimers[b.key],this._setTileReloadTimer(b.key,a)));const c=Boolean(a);if(!c){const d=this.map?this.map.painter:null,e="raster"===this._source.type||"raster-dem"===this._source.type;a=new eq(b,this._source.tileSize*b.overscaleFactor(),this.transform.tileZoom,d,e),this._loadTile(a,this._tileLoaded.bind(this,a,b.key,a.state))}return a?(a.uses++,this._tiles[b.key]=a,c||this._source.fire(new aW("dataloading",{tile:a,coord:a.tileID,dataType:"source"})),a):null}_setTileReloadTimer(a,c){a in this._timers&&(clearTimeout(this._timers[a]),delete this._timers[a]);const b=c.getExpiryTimeout();b&&(this._timers[a]=setTimeout(()=>{this._reloadTile(a,"expired"),delete this._timers[a]},b))}_removeTile(b){const a=this._tiles[b];a&&(a.uses--,delete this._tiles[b],this._timers[b]&&(clearTimeout(this._timers[b]),delete this._timers[b]),a.uses>0||(a.hasData()&&"reloading"!==a.state?this._cache.add(a.tileID,a,a.getExpiryTimeout()):(a.aborted=!0,this._abortTile(a),this._unloadTile(a))))}clearTiles(){for(const a in this._shouldReloadOnResume=!1,this._paused=!1,this._tiles)this._removeTile(+a);this._source._clear&&this._source._clear(),this._cache.reset()}tilesIn(e,f,g){const a=[],c=this.transform;if(!c)return a;for(const h in this._tiles){const b=this._tiles[h];if(g&&b.clearQueryDebugViz(),b.holdingForFade())continue;const d=e.containsTile(b,c,f);d&&a.push(d)}return a}getVisibleCoordinates(c){const a=this.getRenderableIds(c).map(a=>this._tiles[a].tileID);for(const b of a)b.projMatrix=this.transform.calculateProjMatrix(b.toUnwrapped());return a}hasTransition(){if(this._source.hasTransition())return!0;if(k3(this._source.type))for(const b in this._tiles){const a=this._tiles[b];if(void 0!==a.fadeEndTime&&a.fadeEndTime>=b$.now())return!0}return!1}setFeatureState(a,b,c){this._state.updateState(a=a||"_geojsonTileLayer",b,c)}removeFeatureState(a,b,c){this._state.removeFeatureState(a=a||"_geojsonTileLayer",b,c)}getFeatureState(a,b){return this._state.getState(a=a||"_geojsonTileLayer",b)}setDependencies(b,c,d){const a=this._tiles[b];a&&a.setDependencies(c,d)}reloadTilesForDependencies(b,c){for(const a in this._tiles)this._tiles[a].hasDependency(b,c)&&this._reloadTile(+a,"reloading");this._cache.filter(a=>!a.hasDependency(b,c))}_preloadTiles(a,f){const b=new Map,g=Array.isArray(a)?a:[a],c=this.map.painter.terrain,h=this.usedForTerrain&&c?c.getScaledDemTileSize():this._source.tileSize;for(const d of g){const i=d.coveringTiles({tileSize:h,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 i)b.set(e.key,e);this.usedForTerrain&&d.updateElevation(!1)}const j=Array.from(b.values()),k="raster"===this._source.type||"raster-dem"===this._source.type;bP(j,(a,c)=>{const b=new eq(a,this._source.tileSize*a.overscaleFactor(),this.transform.tileZoom,this.map.painter,k);this._loadTile(b,a=>{"raster-dem"===this._source.type&&b.dem&&this._backfillDEM(b),c(a,b)})},f)}}function k2(a,b){const c=Math.abs(2*a.wrap)- +(a.wrap<0),d=Math.abs(2*b.wrap)- +(b.wrap<0);return a.overscaledZ-b.overscaledZ||d-c||b.canonical.y-a.canonical.y||b.canonical.x-a.canonical.x}function k3(a){return"raster"===a||"image"===a||"video"===a}aD.maxOverzooming=10,aD.maxUnderzooming=3;class k4{constructor(a,b,c){this._demTile=a,this._dem=this._demTile.dem,this._scale=b,this._offset=c}static create(f,b,g){const a=g||f.findDEMTileFor(b);if(!a||!a.dem)return;const e=a.dem,c=a.tileID,d=1<=0&&a[3]>=0&&l.insert(k,a[0],a[1],a[2],a[3])}}loadVTLayers(){if(!this.vtLayers)for(const a in this.vtLayers=new _.VectorTile(new d2(this.rawTileData)).layers,this.sourceLayerCoder=new kV(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={},this.vtLayers)this.vtFeatures[a]=[];return this.vtLayers}query(c,j,k,l){this.loadVTLayers();const d=c.params||{},m=gB(d.filter),n=c.tileResult,g=c.transform,a=n.bufferedTilespaceBounds,b=this.grid.query(a.min.x,a.min.y,a.max.x,a.max.y,(a,b,c,d)=>dF(n.bufferedTilespaceGeometry,a,b,c,d));b.sort(k6);let o=null;g.elevation&&b.length>0&&(o=k4.create(g.elevation,this.tileID));const h={};let i;for(let e=0;e(q||(q=ic(a,this.tileID.canonical,c.tileTransform)),b.queryIntersectsFeature(n,a,d,q,this.z,c.transform,c.pixelPosMatrix,o,e)))}return h}loadMatchingFeature(l,t,g,e,m,u,v,n,o){const{featureIndex:p,bucketIndex:w,sourceLayerIndex:x,layoutVertexArrayOffset:y}=t,h=this.bucketLayerIDs[w];if(e&&!function(b,c){for(let a=0;a=0)return!0;return!1}(e,h))return;const q=this.sourceLayerCoder.decode(x),a=this.vtLayers[q].feature(p);if(g.needGeometry){const z=id(a,!0);if(!g.filter(new c5(this.tileID.overscaledZ),z,this.tileID.canonical))return}else if(!g.filter(new c5(this.tileID.overscaledZ),a))return;const i=this.getId(a,q);for(let j=0;je.indexOf(b))continue;const c=u[b];if(!c)continue;let f={};void 0!==i&&n&&(f=n.getState(c.sourceLayer||"_geojsonTileLayer",i));const d=bR({},v[b]);d.paint=k5(d.paint,c.paint,a,f,m),d.layout=k5(d.layout,c.layout,a,f,m);const r=!o||o(a,c,f,y);if(!r)continue;const s=new kW(a,this.z,this.x,this.y,i);s.layer=d;let k=l[b];void 0===k&&(k=l[b]=[]),k.push({featureIndex:p,feature:s,intersectionZ:r})}}lookupSymbolFeatures(b,c,d,e,f,g,h,i){const a={};this.loadVTLayers();const j=gB(f);for(const k of b)this.loadMatchingFeature(a,{bucketIndex:d,sourceLayerIndex:e,featureIndex:k,layoutVertexArrayOffset:0},j,g,h,i,c);return a}loadFeature(e){const{featureIndex:a,sourceLayerIndex:f}=e;this.loadVTLayers();const c=this.sourceLayerCoder.decode(f),b=this.vtFeatures[c];if(b[a])return b[a];const d=this.vtLayers[c].feature(a);return b[a]=d,d}hasLayer(a){for(const b of this.bucketLayerIDs)for(const c of b)if(a===c)return!0;return!1}getId(b,c){let a=b.id;return this.promoteId&&"boolean"==typeof(a=b.properties["string"==typeof this.promoteId?this.promoteId:this.promoteId[c]])&&(a=Number(a)),a}}function k5(a,b,c,d,e){return eP(a,(g,f)=>{const a=b instanceof hN?b.get(f):null;return a&&a.evaluate?a.evaluate(c,d,e):a})}function k6(a,b){return b-a}c("FeatureIndex",el,{omit:["rawTileData","sourceLayerCoder"]});var em=j([{name:"a_pos",type:"Int16",components:2},]);const aa=new Uint16Array(8184);for(let ab=0;ab<2046;ab++){let aE=ab+2,D=0,E=0,F=0,G=0,ac=0,ad=0;for(1&aE?F=G=ac=32:D=E=ad=32;(aE>>=1)>1;){const en=D+F>>1,eo=E+G>>1;1&aE?(F=D,G=E,D=ac,E=ad):(D=F,E=G,F=ac,G=ad),ac=en,ad=eo}const ae=4*ab;aa[ae+0]=D,aa[ae+1]=E,aa[ae+2]=F,aa[ae+3]=G}const k7=new Uint16Array(2178),k8=new Uint8Array(1089),k9=new Uint16Array(1089);function la(a){return 0===a?-0.03125:32===a?.03125:0}var ep=j([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2},]);const lb={type:2,extent:8192,loadGeometry:()=>[[new aF(0,0),new aF(8193,0),new aF(8193,8193),new aF(0,8193),new aF(0,0),],]};class eq{constructor(b,c,d,a,e){this.tileID=b,this.uid=bS(),this.uses=0,this.tileSize=c,this.tileZoom=d,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=e,this.expiredRequestCount=0,this.state="loading",a&&a.transform&&(this.projection=a.transform.projection)}registerFadeDuration(b){const a=b+this.timeAdded;ae.getLayer(a)).filter(Boolean);if(0!==c.length)for(const f of(a.layers=c,a.stateDependentLayerIds&&(a.stateDependentLayers=a.stateDependentLayerIds.map(a=>c.filter(b=>b.id===a)[0])),c))b[f.id]=a}return b}(a.buckets,b.style),this.hasSymbolBuckets=!1,this.buckets){const c=this.buckets[g];if(c instanceof aB){if(this.hasSymbolBuckets=!0,!f)break;c.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const h in this.buckets){const d=this.buckets[h];if(d instanceof aB&&d.hasRTLText){this.hasRTLText=!0,c4.isLoading()||c4.isLoaded()||"deferred"!==c3()||hH();break}}for(const e in this.queryPadding=0,this.buckets){const i=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,b.style.getLayer(e).queryRadius(i))}a.imageAtlas&&(this.imageAtlas=a.imageAtlas),a.glyphAtlasImage&&(this.glyphAtlasImage=a.glyphAtlasImage),a.lineAtlas&&(this.lineAtlas=a.lineAtlas)}else this.collisionBoxArray=new c8}unloadVectorData(){if(this.hasData()){for(const a in this.buckets)this.buckets[a].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._tileDebugIndexBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this.globeGridBuffer&&(this.globeGridBuffer.destroy(),this.globeGridBuffer=null),this.globePoleBuffer&&(this.globePoleBuffer.destroy(),this.globePoleBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(a){return this.buckets[a.id]}upload(a){for(const d in this.buckets){const c=this.buckets[d];c.uploadPending()&&c.upload(a)}const b=a.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new eh(a,this.imageAtlas.image,b.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new eh(a,this.glyphAtlasImage,b.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new eh(a,this.lineAtlas.image,b.ALPHA),this.lineAtlas.uploaded=!0)}prepare(a){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(a,this.imageAtlasTexture)}queryRenderedFeatures(a,b,c,d,e,f,g,h){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:d,pixelPosMatrix:g,transform:f,params:e,tileTransform:this.tileTransform},a,b,c):{}}querySourceFeatures(m,a){const b=this.latestFeatureIndex;if(!b||!b.rawTileData)return;const g=b.loadVTLayers(),h=a?a.sourceLayer:"",d=g._geojsonTileLayer||g[h];if(!d)return;const e=gB(a&&a.filter),{z:i,x:j,y:k}=this.tileID.canonical,n={z:i,x:j,y:k};for(let f=0;fe)a=!1;else if(c){if(this.expirationTime=0;f--){const g=4*f,h=aa[g+0],i=aa[g+1],j=aa[g+2],k=aa[g+3],l=h+j>>1,m=i+k>>1,r=l+m-i,s=m+h-l,t=33*i+h,u=33*k+j,a=33*m+l,y=Math.hypot((k7[2*t+0]+k7[2*u+0])/2-k7[2*a+0],(k7[2*t+1]+k7[2*u+1])/2-k7[2*a+1])>=16;if(k8[a]=k8[a]||(y?1:0),f<1022){const z=(i+s>>1)*33+(h+r>>1),A=(k+s>>1)*33+(j+r>>1);k8[a]=k8[a]||k8[z]||k8[A]}}const B=new am,C=new aq;let D=0;function E(b,c){const a=33*c+b;return 0===k9[a]&&(B.emplaceBack(k7[2*a+0],k7[2*a+1],8192*b/32,8192*c/32),k9[a]=++D),k9[a]-1}function v(a,b,e,f,c,d){const g=a+e>>1,h=b+f>>1;if(Math.abs(a-c)+Math.abs(b-d)>1&&k8[33*h+g])v(c,d,a,b,g,h),v(e,f,c,d,g,h);else{const i=E(a,b),j=E(e,f),k=E(c,d);C.emplaceBack(i,j,k)}}return v(0,0,32,32,32,0),v(32,32,0,0,0,32),{vertices:B,indices:C}}(this.tileID.canonical,e);a=g.vertices,b=g.indices}else{for(const{x:i,y:j}of(a=new am,b=new aq,h))a.emplaceBack(i,j,0,0);const d=dM(a.int16,void 0,4);for(let c=0;c{const a=65*d+b;c.emplaceBack(a+1,a,a+65),c.emplaceBack(a+65,a+65+1,a+1)};for(let a=0;a<64;a++)for(let b=0;b<64;b++)d(b,a);return c}getWirefameBuffer(b){if(!this.wireframeSegments){const a=this._createWireframeGrid();this.wireframeIndexBuffer=b.createIndexBuffer(a),this.wireframeSegments=ay.simpleSegment(0,0,4096,a.length)}return[this.wireframeIndexBuffer,this.wireframeSegments,]}_createWireframeGrid(){const c=new Y,d=(b,d)=>{const a=65*d+b;c.emplaceBack(a,a+1),c.emplaceBack(a,a+65),c.emplaceBack(a,a+65+1)};for(let a=0;a<64;a++)for(let b=0;b<64;b++)d(b,a);return c}}function ew(a,b){if(!b.isReprojectedInTileSpace)return{scale:1<m&&(n(i,a,e,f,c,d),n(a,j,c,d,g,h))}n(c,d,h,j,i,j),n(d,e,i,j,i,k),n(e,f,i,k,h,k),n(f,c,h,k,h,j),o-=m,p-=m,q+=m,r+=m;const l=1/Math.max(q-o,r-p);return{scale:l,x:o*l,y:p*l,x2:q*l,y2:r*l,projection:b}}class ex{constructor(c){const d={},e=[];for(const f in c){const g=c[f],q=d[f]={};for(const h in g.glyphs){const a=g.glyphs[+h];if(!a||0===a.bitmap.width||0===a.bitmap.height)continue;const i=a.metrics.localGlyph?2:1,j={x:0,y:0,w:a.bitmap.width+2*i,h:a.bitmap.height+2*i};e.push(j),q[h]=j}}const{w:r,h:s}=d3(e),k=new dJ({width:r||1,height:s||1});for(const l in c){const m=c[l];for(const n in m.glyphs){const b=m.glyphs[+n];if(!b||0===b.bitmap.width||0===b.bitmap.height)continue;const o=d[l][n],p=b.metrics.localGlyph?2:1;dJ.copy(b.bitmap,k,{x:0,y:0},{x:o.x+p,y:o.y+p},b.bitmap)}}this.image=k,this.positions=d}}c("GlyphAtlas",ex);class lk{constructor(a){this.tileID=new bn(a.tileID.overscaledZ,a.tileID.wrap,a.tileID.canonical.z,a.tileID.canonical.x,a.tileID.canonical.y),this.tileZoom=a.tileZoom,this.uid=a.uid,this.zoom=a.zoom,this.canonical=a.tileID.canonical,this.pixelRatio=a.pixelRatio,this.tileSize=a.tileSize,this.source=a.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=a.showCollisionBoxes,this.collectResourceTiming=!!a.collectResourceTiming,this.returnDependencies=!!a.returnDependencies,this.promoteId=a.promoteId,this.enableTerrain=!!a.enableTerrain,this.isSymbolTile=a.isSymbolTile,this.tileTransform=ew(a.tileID.canonical,a.projection),this.projection=a.projection}parse(h,v,i,j,E){this.status="parsing",this.data=h,this.collisionBoxArray=new c8;const w=new kV(Object.keys(h.layers).sort()),c=new el(this.tileID,this.promoteId);c.bucketLayerIDs=[];const x={},m=new bl(256,256),d={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:m,availableImages:i},k=v.familiesBySource[this.source];for(const b in k){const e=h.layers[b];if(!e)continue;let n=!1,o=!1;for(const y of k[b])"symbol"===y[0].type?n=!0:o=!0;if(!0===this.isSymbolTile&&!n|| !1===this.isSymbolTile&&!o)continue;1===e.version&&bY(`Vector tile source "${this.source}" layer "${b}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const p=w.encode(b),q=[];for(let f=0;f=a.maxzoom||"none"!==a.visibility&&(ll(g,this.zoom,i),(x[a.id]=a.createBucket({index:c.bucketLayerIDs.length,layers:g,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:p,sourceID:this.source,enableTerrain:this.enableTerrain,availableImages:i})).populate(q,d,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(g.map(a=>a.id)))}}let F,A,B,C;m.trim();const l={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},s=eP(d.glyphDependencies,a=>Object.keys(a).map(Number));Object.keys(s).length?j.send("getGlyphs",{uid:this.uid,stacks:s},(a,b)=>{F||(F=a,A=b,D.call(this))},void 0,!1,l):A={};const t=Object.keys(d.iconDependencies);t.length?j.send("getImages",{icons:t,source:this.source,tileID:this.tileID,type:"icons"},(a,b)=>{F||(F=a,B=b,D.call(this))},void 0,!1,l):B={};const u=Object.keys(d.patternDependencies);function D(){if(F)return E(F);if(A&&B&&C){const b=new ex(A),e=new d4(B,C);for(const f in x){const a=x[f];a instanceof aB?(ll(a.layers,this.zoom,i),ku(a,A,b.positions,B,e.iconPositions,this.showCollisionBoxes,i,this.tileID.canonical,this.tileZoom,this.projection),a.projection=this.projection.name):a.hasPattern&&(a instanceof dX||a instanceof dN||a instanceof dU)&&(ll(a.layers,this.zoom,i),a.addFeatures(d,this.tileID.canonical,e.patternPositions,i))}this.status="done",E(null,{buckets:bQ(x).filter(a=>!a.isEmpty()),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:b.image,lineAtlas:m,imageAtlas:e,glyphMap:this.returnDependencies?A:null,iconMap:this.returnDependencies?B:null,glyphPositions:this.returnDependencies?b.positions:null})}}u.length?j.send("getImages",{icons:u,source:this.source,tileID:this.tileID,type:"patterns"},(a,b)=>{F||(F=a,C=b,D.call(this))},void 0,!1,l):C={},D.call(this)}}function ll(a,b,c){const d=new c5(b);for(const e of a)e.recalculate(d,c)}class ey{constructor(a){this.entries={},this.scheduler=a}request(b,d,e,c){const a=this.entries[b]=this.entries[b]||{callbacks:[]};if(a.result){const[f,g]=a.result;return this.scheduler?this.scheduler.add(()=>{c(f,g)},d):c(f,g),()=>{}}return a.callbacks.push(c),a.cancel||(a.cancel=e((c,e)=>{for(const f of(a.result=[c,e],a.callbacks))this.scheduler?this.scheduler.add(()=>{f(c,e)},d):f(c,e);setTimeout(()=>delete this.entries[b],3e3)})),()=>{a.result||(a.callbacks=a.callbacks.filter(a=>a!==c),a.callbacks.length||(a.cancel(),delete this.entries[b]))}}}function ez(a,c,d){const b=JSON.stringify(a.request);return a.data&&(this.deduped.entries[b]={result:[null,a.data]}),this.deduped.request(b,{type:"parseTile",isSymbolTile:a.isSymbolTile,zoom:a.tileZoom},b=>{const c=fi(a.request,(c,a,e,f)=>{c?b(c):a&&b(null,{vectorTile:d?void 0:new _.VectorTile(new d2(a)),rawData:a,cacheControl:e,expires:f})});return()=>{c.cancel(),b()}},c)}const lm=aI(new Float64Array(16));class ln{constructor(a,b){this._tr=a,this._worldSize=b}createInversionMatrix(){return lm}createTileMatrix(e){let a,f,g;const c=e.canonical,b=aI(new Float64Array(16)),h=this._tr.projection;if(h.isReprojectedInTileSpace){const d=ew(c,h);a=1,f=d.x+e.wrap*d.scale,g=d.y,bs(b,b,[a/d.scale,a/d.scale,this._tr.pixelsPerMeter/this._worldSize,])}else a=this._worldSize/this._tr.zoomScale(c.z),f=(c.x+Math.pow(2,c.z)*e.wrap)*a,g=c.y*a;return br(b,b,[f,g,0]),bs(b,b,[a/8192,a/8192,1]),b}pointCoordinate(a,b,c){const d=this._tr.horizonLineFromTop(!1),e=new aF(a,Math.max(d,b));return this._tr.rayIntersectionCoordinate(this._tr.pointRayIntersection(e,c))}upVector(){return[0,0,1]}upVectorScale(){return 1}}var eA={name:"albers",range:[4,7],center:[-96,37.5],parallels:[29.5,45.5],zAxisUnit:"meters",conic:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],initializeConstants(){if(this.constants&&eJ(this.parallels,this.constants.parallels))return;const a=Math.sin(this.parallels[0]*aP),b=(a+Math.sin(this.parallels[1]*aP))/2,c=1+a*(2*b-a),d=Math.sqrt(c)/b;this.constants={n:b,c:c,r0:d,parallels:this.parallels}},project(d,e){this.initializeConstants();const b=(d-this.center[0])*aP,{n:a,c:f,r0:g}=this.constants,c=Math.sqrt(f-2*a*Math.sin(e*aP))/a;return{x:c*Math.sin(b*a),y:c*Math.cos(b*a)-g,z:0}},unproject(c,f){this.initializeConstants();const{n:a,c:g,r0:h}=this.constants,b=h+f;let d=Math.atan2(c,Math.abs(b))*Math.sign(b);b*a<0&&(d-=Math.PI*Math.sign(c)*Math.sign(b));const e=this.center[0]*aP*a;d=bO(d,-Math.PI-e,Math.PI-e);const i=d/a*eK+this.center[0],j=Math.asin(bM((g-(c*c+b*b)*a*a)/(2*a),-1,1)),k=bM(j*eK,-85.051129,85.051129);return new dy(i,k)},projectTilePoint:(a,b)=>({x:a,y:b,z:0}),locationPoint:(a,b)=>a._coordinatePoint(a.locationCoordinate(b),!1),pixelsPerMeter:(a,b)=>dB(1,a)*b,farthestPixelDistance(a){return le(a,this.pixelsPerMeter(a.center.lat,a.worldSize))},createTileTransform:(a,b)=>new ln(a,b)};const lo=Math.sqrt(3)/2;var eB={name:"equalEarth",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(c,d){d=d/180*Math.PI,c=c/180*Math.PI;const b=Math.asin(lo*Math.sin(d)),a=b*b,e=a*a*a;return{x:.5*(c*Math.cos(b)/(lo*(1.340264+ -0.24331799999999998*a+e*(.0062510000000000005+.034164*a)))/Math.PI+.5),y:1-.5*(b*(1.340264+ -0.081106*a+e*(893e-6+.003796*a))/Math.PI+1),z:0}},unproject(d,e){d=(2*d-.5)*Math.PI;let b=e=(2*(1-e)-1)*Math.PI,a=b*b,c=a*a*a;for(let f,g,h,i=0;i<12&&(g=b*(1.340264+ -0.081106*a+c*(893e-6+.003796*a))-e,h=1.340264+ -0.24331799999999998*a+c*(.0062510000000000005+.034164*a),f=g/h,b=bM(b-f,-Math.PI/3,Math.PI/3),a=b*b,c=a*a*a,!(1e-12>Math.abs(f)));++i);const j=bM(180*(lo*d*(1.340264+ -0.24331799999999998*a+c*(.0062510000000000005+.034164*a))/Math.cos(b))/Math.PI,-180,180),k=bM(180*Math.asin(Math.sin(b)/lo)/Math.PI,-85.051129,85.051129);return new dy(j,k)},projectTilePoint:(a,b)=>({x:a,y:b,z:0}),locationPoint:(a,b)=>a._coordinatePoint(a.locationCoordinate(b),!1),pixelsPerMeter:(a,b)=>dB(1,a)*b,farthestPixelDistance(a){return le(a,this.pixelsPerMeter(a.center.lat,a.worldSize))},createTileTransform:(a,b)=>new ln(a,b)},eC={name:"equirectangular",supportsWorldCopies:!0,center:[0,0],range:[3.5,7],zAxisUnit:"meters",wrap:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project:(a,b)=>({x:.5+a/360,y:.5-b/360,z:0}),unproject(a,b){const c=bM(360*(.5-b),-85.051129,85.051129);return new dy(360*(a-.5),c)},projectTilePoint:(a,b)=>({x:a,y:b,z:0}),locationPoint:(a,b)=>a._coordinatePoint(a.locationCoordinate(b),!1),pixelsPerMeter:(a,b)=>dB(1,a)*b,farthestPixelDistance(a){return le(a,this.pixelsPerMeter(a.center.lat,a.worldSize))},createTileTransform:(a,b)=>new ln(a,b)};const lp=Math.PI/2;function lq(a){return Math.tan((lp+a)/2)}var lr,eD={name:"lambertConformalConic",range:[3.5,7],zAxisUnit:"meters",center:[0,30],parallels:[30,30],conic:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],initializeConstants(){if(this.constants&&eJ(this.parallels,this.constants.parallels))return;const a=this.parallels[0]*aP,b=this.parallels[1]*aP,d=Math.cos(a),c=a===b?Math.sin(a):Math.log(d/Math.cos(b))/Math.log(lq(b)/lq(a)),e=d*Math.pow(lq(a),c)/c;this.constants={n:c,f:e,parallels:this.parallels}},project(b,a){this.initializeConstants(),a*=aP,b=(b-this.center[0])*aP;const{n:c,f:d}=this.constants;d>0?a< -lp+1e-6&&(a=-lp+1e-6):a>lp-1e-6&&(a=lp-1e-6);const e=d/Math.pow(lq(a),c);return{x:.5*(e*Math.sin(c*b)/Math.PI+.5),y:1-.5*((d-e*Math.cos(c*b))/Math.PI+.5),z:0}},unproject(a,d){this.initializeConstants(),a=(2*a-.5)*Math.PI,d=(2*(1-d)-.5)*Math.PI;const{n:c,f:e}=this.constants,b=e-d,f=Math.sign(b),h=Math.sign(c)*Math.sqrt(a*a+b*b);let g=Math.atan2(a,Math.abs(b))*f;b*c<0&&(g-=Math.PI*Math.sign(a)*f);const i=bM(g/c*eK+this.center[0],-180,180),j=bM((2*Math.atan(Math.pow(e/h,1/c))-lp)*eK,-85.051129,85.051129);return new dy(i,j)},projectTilePoint:(a,b)=>({x:a,y:b,z:0}),locationPoint:(a,b)=>a._coordinatePoint(a.locationCoordinate(b),!1),pixelsPerMeter:(a,b)=>dB(1,a)*b,farthestPixelDistance(a){return le(a,this.pixelsPerMeter(a.center.lat,a.worldSize))},createTileTransform:(a,b)=>new ln(a,b)},eE={name:"mercator",wrap:!0,requiresDraping:!1,supportsWorldCopies:!0,supportsTerrain:!0,supportsFog:!0,supportsFreeCamera:!0,zAxisUnit:"meters",center:[0,0],project:(a,b)=>({x:dz(a),y:dA(b),z:0}),unproject(a,b){const c=h7(a),d=dC(b);return new dy(c,d)},projectTilePoint:(a,b)=>({x:a,y:b,z:0}),locationPoint:(a,b)=>a._coordinatePoint(a.locationCoordinate(b),!1),pixelsPerMeter:(a,b)=>dB(1,a)*b,farthestPixelDistance(a){return le(a,this.pixelsPerMeter(a.center.lat,a.worldSize))},createTileTransform:(a,b)=>new ln(a,b)};const ls=85.051129*aP;var eF={name:"naturalEarth",center:[0,0],range:[3.5,7],isReprojectedInTileSpace:!0,zAxisUnit:"meters",unsupportedLayers:["custom"],project(d,c){const a=(c*=aP)*c,b=a*a;return{x:.5*((d*=aP)*(.8707-.131979*a+b*(b*(.003971*a-.001529*b)-.013791))/Math.PI+.5),y:1-.5*(c*(1.007226+a*(.015085+b*(.028874*a-.044475-.005916*b)))/Math.PI+1),z:0}},unproject(d,e){d=(2*d-.5)*Math.PI;let b=e=(2*(1-e)-1)*Math.PI,g=25,f=0,a=b*b;do{a=b*b;const c=a*a;f=(b*(1.007226+a*(.015085+c*(.028874*a-.044475-.005916*c)))-e)/(1.007226+a*(.045255+c*(.259866*a-.311325-.06507600000000001*c))),b=bM(b-f,-ls,ls)}while(Math.abs(f)>1e-6&& --g>0)a=b*b;const h=bM(d/(.8707+a*(a*(a*a*a*(.003971-.001529*a)-.013791)-.131979))*eK,-180,180);return new dy(h,b*eK)},projectTilePoint:(a,b)=>({x:a,y:b,z:0}),locationPoint:(a,b)=>a._coordinatePoint(a.locationCoordinate(b),!1),pixelsPerMeter:(a,b)=>dB(1,a)*b,farthestPixelDistance(a){return le(a,this.pixelsPerMeter(a.center.lat,a.worldSize))},createTileTransform:(a,b)=>new ln(a,b)};const lt=85.051129*aP,lu={albers:eA,equalEarth:eB,equirectangular:eC,lambertConformalConic:eD,mercator:eE,naturalEarth:eF,winkelTripel:{name:"winkelTripel",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(a,b){b*=aP,a*=aP;const c=Math.cos(b),d=Math.acos(c*Math.cos(a/2)),e=Math.sin(d)/d;return{x:.5*((.5*(a*(2/Math.PI)+2*c*Math.sin(a/2)/e)||0)/Math.PI+.5),y:1-.5*((.5*(b+Math.sin(b)/e)||0)/Math.PI+1),z:0}},unproject(j,k){let b=j=(2*j-.5)*Math.PI,c=k=(2*(1-k)-1)*Math.PI,z=25,l=0,m=0;do{const a=Math.cos(c),d=Math.sin(c),o=2*d*a,p=d*d,n=a*a,e=Math.cos(b/2),f=Math.sin(b/2),q=2*e*f,r=f*f,h=1-n*e*e,i=h?1/h:0,g=h?Math.acos(a*e)*Math.sqrt(1/h):0,s=.5*(2*g*a*f+2*b/Math.PI)-j,t=.5*(g*d+c)-k,u=.5*i*(n*r+g*a*e*p)+1/Math.PI,v=i*(q*o/4-g*d*f),w=.125*i*(o*f-g*d*n*q),x=.5*i*(p*e+g*r*a)+.5,y=v*w-x*u;l=(t*v-s*x)/y,m=(s*w-t*u)/y,b=bM(b-l,-Math.PI,Math.PI),c=bM(c-m,-lt,lt)}while((Math.abs(l)>1e-6||Math.abs(m)>1e-6)&& --z>0)return new dy(b*eK,c*eK)},projectTilePoint:(a,b)=>({x:a,y:b,z:0}),locationPoint:(a,b)=>a._coordinatePoint(a.locationCoordinate(b),!1),pixelsPerMeter:(a,b)=>dB(1,a)*b,farthestPixelDistance(a){return le(a,this.pixelsPerMeter(a.center.lat,a.worldSize))},createTileTransform:(a,b)=>new ln(a,b)}};a.ARRAY_TYPE=I,a.AUTH_ERR_MSG=b1,a.Aabb=B,a.Actor=class{constructor(a,b,c){this.target=a,this.parent=b,this.mapId=c,this.callbacks={},this.cancelCallbacks={},bU(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=bZ()?a:s,this.scheduler=new class{constructor(){this.tasks={},this.taskQueue=[],bU(["process"],this),this.invoker=new class{constructor(a){this._callback=a,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(){delete this._channel,this._callback=()=>{}}}(this.process),this.nextId=0}add(b,c){const a=this.nextId++,d=function({type:b,isSymbolTile:c,zoom:a}){return a=a||0,"message"===b?0:"maybePrepare"!==b||c?"parseTile"!==b||c?"parseTile"===b&&c?300-a:"maybePrepare"===b&&c?400-a:500:200-a:100-a}(c);return 0===d?(bZ(),b(),{cancel(){}}):(this.tasks[a]={fn:b,metadata:c,priority:d,id:a},this.taskQueue.push(a),this.invoker.trigger(),{cancel:()=>{delete this.tasks[a]}})}process(){bZ();{if(this.taskQueue=this.taskQueue.filter(a=>!!this.tasks[a]),!this.taskQueue.length)return;const a=this.pick();if(null===a)return;const b=this.tasks[a];if(delete this.tasks[a],this.taskQueue.length&&this.invoker.trigger(),!b)return;b.fn()}}pick(){let a=null,c=1/0;for(let b=0;b{a&&delete this.callbacks[b],this.target.postMessage({id:b,type:"",targetMapId:f,sourceMapId:this.mapId})}}}receive(e){const a=e.data,b=a.id;if(b&&(!a.targetMapId||this.mapId===a.targetMapId)){if(""===a.type){const c=this.cancelCallbacks[b];delete this.cancelCallbacks[b],c&&c.cancel()}else if(a.mustQueue||bZ()){const d=this.callbacks[b];this.cancelCallbacks[b]=this.scheduler.add(()=>this.processTask(b,a),d&&d.metadata||{type:"message"})}else this.processTask(b,a)}}processTask(e,a){if(""===a.type){const b=this.callbacks[e];delete this.callbacks[e],b&&(a.error?b(g0(a.error)):b(null,g0(a.data)))}else{const g=eX(this.globalScope)?void 0:[],c=a.hasCallback?(a,b)=>{delete this.cancelCallbacks[e],this.target.postMessage({id:e,type:"",sourceMapId:this.mapId,error:a?g_(a):null,data:g_(b,g)},g)}:a=>{},d=g0(a.data);if(this.parent[a.type])this.parent[a.type](a.sourceMapId,d,c);else if(this.parent.getWorkerSource){const f=a.type.split(".");this.parent.getWorkerSource(a.sourceMapId,f[0],d.source)[f[1]](d,c)}else c(new Error(`Could not find function ${a.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},a.CanonicalTileID=bm,a.Color=m,a.ColorMode=r,a.CullFaceMode=o,a.DEMData=bo,a.DataConstantProperty=e,a.DedupedRequest=ey,a.DepthMode=C,a.EXTENT=8192,a.Elevation=class{getAtPointOrZero(a,b=0){return this.getAtPoint(a,b)||0}getAtPoint(a,f,o=!0){null==f&&(f=null);const i=this._source();if(!i||a.y<0||a.y>1)return f;const g=i.getSource().maxzoom,j=1<{const e=this.getAtTileOffset(a,c.x,c.y),d=b.upVector(a.canonical,c.x,c.y);return bx(d,d,e*b.upVectorScale(a.canonical)),d}}getForTilePoints(a,b,e,c){const d=k4.create(this,a,c);return!!d&&(b.forEach(a=>{a[2]=this.exaggeration()*d.getElevationAt(a[0],a[1],e)}),!0)}getMinMaxForTile(a){const c=this.findDEMTileFor(a);if(!c||!c.dem)return null;const d=c.dem.tree,e=c.tileID,h=1<Math.abs(e))return!1;const d=((b[0]-this.pos[0])*a[0]+(b[1]-this.pos[1])*a[1]+(b[2]-this.pos[2])*a[2])/e;return c[0]=this.pos[0]+this.dir[0]*d,c[1]=this.pos[1]+this.dir[1]*d,c[2]=this.pos[2]+this.dir[2]*d,!0}closestPointOnSphere(i,b,a){var j,k,n,o,p,q,r,s;if(j=this.pos,k=i,n=j[0],o=j[1],p=j[2],q=k[0],r=k[1],s=k[2],Math.abs(n-q)<=1e-6*Math.max(1,Math.abs(n),Math.abs(q))&&Math.abs(o-r)<=1e-6*Math.max(1,Math.abs(o),Math.abs(r))&&Math.abs(p-s)<=1e-6*Math.max(1,Math.abs(p),Math.abs(s))||0===b)return a[0]=a[1]=a[2]=0,!1;const[f,g,h]=this.dir,c=this.pos[0]-i[0],d=this.pos[1]-i[1],e=this.pos[2]-i[2],w=f*f+g*g+h*h,l=2*(c*f+d*g+e*h),x=l*l-4*w*(c*c+d*d+e*e-b*b);if(x<0){const t=Math.max(-l/2,0),y=c+f*t,z=d+g*t,A=e+h*t,u=Math.hypot(y,z,A);return a[0]=y*b/u,a[1]=z*b/u,a[2]=A*b/u,!1}{const m=(-l-Math.sqrt(x))/(2*w);if(m<0){const v=Math.hypot(c,d,e);return a[0]=c*b/v,a[1]=d*b/v,a[2]=e*b/v,!1}return a[0]=c+f*m,a[1]=d+g*m,a[2]=e+h*m,!0}}},a.RequestManager=class{constructor(a,b,c){this._transformRequestFn=a,this._customAccessToken=b,this._silenceAuthErrors=!!c,this._createSkuToken()}_createSkuToken(){const a=function(){let a="";for(let b=0;b<10;b++)a+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1","01",a].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=a.token,this._skuTokenExpiresAt=a.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(a,b){return this._transformRequestFn&&this._transformRequestFn(a,b)||{url:a}}normalizeStyleURL(a,c){if(!b2(a))return a;const b=e4(a);return b.path=`/styles/v1${b.path}`,this._makeAPIURL(b,this._customAccessToken||c)}normalizeGlyphsURL(a,c){if(!b2(a))return a;const b=e4(a);return b.path=`/fonts/v1${b.path}`,this._makeAPIURL(b,this._customAccessToken||c)}normalizeSourceURL(b,c){if(!b2(b))return b;const a=e4(b);return a.path=`/v4/${a.authority}.json`,a.params.push("secure"),this._makeAPIURL(a,this._customAccessToken||c)}normalizeSpriteURL(b,c,d,e){const a=e4(b);return b2(b)?(a.path=`/styles/v1${a.path}/sprite${c}${d}`,this._makeAPIURL(a,this._customAccessToken||e)):(a.path+=`${c}${d}`,e5(a))}normalizeTileURL(b,e,c){if(this._isSkuTokenExpired()&&this._createSkuToken(),b&&!b2(b))return b;const a=e4(b);a.path=a.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${e||c&&"raster"!==a.authority&&512===c?"@2x":""}${b0.supported?".webp":"$1"}`),"raster"===a.authority?a.path=`/${b_.RASTER_URL_PREFIX}${a.path}`:(a.path=a.path.replace(/^.+\/v4\//,"/"),a.path=`/${b_.TILE_URL_VERSION}${a.path}`);const d=this._customAccessToken||function(b){for(const c of b){const a=c.match(/^access_token=(.*)$/);if(a)return a[1]}return null}(a.params)||b_.ACCESS_TOKEN;return b_.REQUIRE_ACCESS_TOKEN&&d&&this._skuToken&&a.params.push(`sku=${this._skuToken}`),this._makeAPIURL(a,d)}canonicalizeTileURL(d,e){const a=e4(d);if(!a.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!a.path.match(/\.[\w]+$/))return d;let b="mapbox://";a.path.match(/^\/raster\/v1\//)?b+=`raster/${a.path.replace(`/${b_.RASTER_URL_PREFIX}/`,"")}`:b+=`tiles/${a.path.replace(`/${b_.TILE_URL_VERSION}/`,"")}`;let c=a.params;return e&&(c=c.filter(a=>!a.match(/^access_token=/))),c.length&&(b+=`?${c.join("&")}`),b}canonicalizeTileset(d,c){const e=!!c&&b2(c),a=[];for(const b of d.tiles||[])e2(b)?a.push(this.canonicalizeTileURL(b,e)):a.push(b);return a}_makeAPIURL(a,b){const d="See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes",c=e4(b_.API_URL);if(a.protocol=c.protocol,a.authority=c.authority,"http"===a.protocol){const e=a.params.indexOf("secure");e>=0&&a.params.splice(e,1)}if("/"!==c.path&&(a.path=`${c.path}${a.path}`),!b_.REQUIRE_ACCESS_TOKEN)return e5(a);if(b=b||b_.ACCESS_TOKEN,!this._silenceAuthErrors){if(!b)throw new Error(`An API access token is required to use Mapbox GL. ${d}`);if("s"===b[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${d}`)}return a.params=a.params.filter(a=>-1===a.indexOf("access_token")),a.params.push(`access_token=${b||""}`),e5(a)}},a.ResourceType=aV,a.SegmentVector=ay,a.SourceCache=aD,a.StencilMode=aC,a.StructArrayLayout1ui2=av,a.StructArrayLayout2f1f2i16=ap,a.StructArrayLayout2i4=al,a.StructArrayLayout2ui4=Y,a.StructArrayLayout3f12=an,a.StructArrayLayout3ui6=aq,a.StructArrayLayout4i8=am,a.Texture=eh,a.Tile=eq,a.Transitionable=c6,a.Uniform1f=dl,a.Uniform1i=class extends ax{constructor(a,b){super(a,b),this.current=0}set(a){this.current!==a&&(this.current=a,this.gl.uniform1i(this.location,a))}},a.Uniform2f=class extends ax{constructor(a,b){super(a,b),this.current=[0,0]}set(a){a[0]===this.current[0]&&a[1]===this.current[1]||(this.current=a,this.gl.uniform2f(this.location,a[0],a[1]))}},a.Uniform3f=class extends ax{constructor(a,b){super(a,b),this.current=[0,0,0]}set(a){a[0]===this.current[0]&&a[1]===this.current[1]&&a[2]===this.current[2]||(this.current=a,this.gl.uniform3f(this.location,a[0],a[1],a[2]))}},a.Uniform4f=dm,a.UniformColor=dn,a.UniformMatrix2f=class extends ax{constructor(a,b){super(a,b),this.current=hY}set(b){for(let a=0;a<4;a++)if(b[a]!==this.current[a]){this.current=b,this.gl.uniformMatrix2fv(this.location,!1,b);break}}},a.UniformMatrix3f=class extends ax{constructor(a,b){super(a,b),this.current=hX}set(b){for(let a=0;a<9;a++)if(b[a]!==this.current[a]){this.current=b,this.gl.uniformMatrix3fv(this.location,!1,b);break}}},a.UniformMatrix4f=class extends ax{constructor(a,b){super(a,b),this.current=hW}set(a){if(a[12]!==this.current[12]||a[0]!==this.current[0])return this.current=a,void this.gl.uniformMatrix4fv(this.location,!1,a);for(let b=1;b<16;b++)if(a[b]!==this.current[b]){this.current=a,this.gl.uniformMatrix4fv(this.location,!1,a);break}}},a.UnwrappedTileID=ej,a.ValidationError=cc,a.VectorTileWorkerSource=class extends S{constructor(a,b,c,d,e){super(),this.actor=a,this.layerIndex=b,this.availableImages=c,this.loadVectorData=e||ez,this.loading={},this.loaded={},this.deduped=new ey(a.scheduler),this.isSpriteLoaded=d,this.scheduler=a.scheduler}loadTile(a,e){const c=a.uid,b=a&&a.request,f=b&&b.collectResourceTiming,d=this.loading[c]=new lk(a);d.abort=this.loadVectorData(a,(h,g)=>{const i=!this.loading[c];if(delete this.loading[c],i||h||!g)return d.status="done",i||(this.loaded[c]=d),e(h);const k=g.rawData,j={};g.expires&&(j.expires=g.expires),g.cacheControl&&(j.cacheControl=g.cacheControl),d.vectorTile=g.vectorTile||new _.VectorTile(new d2(k));const l=()=>{d.parse(d.vectorTile,this.layerIndex,this.availableImages,this.actor,(a,c)=>{if(a||!c)return e(a);const d={};if(f){const g=ei(b);g.length>0&&(d.resourceTiming=JSON.parse(JSON.stringify(g)))}e(null,bR({rawTileData:k.slice(0)},c,j,d))})};this.isSpriteLoaded?l():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(l,{type:"parseTile",isSymbolTile:a.isSymbolTile,zoom:a.tileZoom}):l()}),this.loaded=this.loaded||{},this.loaded[c]=d})}reloadTile(b,f){const c=this.loaded,e=b.uid,g=this;if(c&&c[e]){const a=c[e];a.showCollisionBoxes=b.showCollisionBoxes,a.enableTerrain=!!b.enableTerrain,a.projection=b.projection;const d=(c,d)=>{const b=a.reloadCallback;b&&(delete a.reloadCallback,a.parse(a.vectorTile,g.layerIndex,this.availableImages,g.actor,b)),f(c,d)};"parsing"===a.status?a.reloadCallback=d:"done"===a.status&&(a.vectorTile?a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.actor,d):d())}}abortTile(c,d){const b=c.uid,a=this.loading[b];a&&(a.abort&&a.abort(),delete this.loading[b]),d()}removeTile(c,d){const a=this.loaded,b=c.uid;a&&a[b]&&delete a[b],d()}},a.WritingMode=d5,a.ZoomHistory=c0,a.add=bw,a.addDynamicAttributes=bk,a.adjoint=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=b[4],h=b[5],i=b[6],j=b[7],k=b[8];return a[0]=g*k-h*j,a[1]=e*j-d*k,a[2]=d*h-e*g,a[3]=h*i-f*k,a[4]=c*k-e*i,a[5]=e*f-c*h,a[6]=f*j-g*i,a[7]=d*i-c*j,a[8]=c*g-d*f,a},a.asyncAll=bP,a.bezier=aQ,a.bindAll=bU,a.boundsAttributes=ep,a.bufferConvexPolygon=function(a,g){const e=[];for(let b=0;bfd&&(a.getActor().send("enforceCacheSizeLimit",fc),fg=0)},a.calculateGlobeMatrix=eu,a.calculateGlobeMercatorMatrix=function(a){const c=a.worldSize,f=bM(a.center.lat,-85.051129,85.051129),d=new aF(dz(a.center.lng)*c,dA(f)*c),g=dB(1,a.center.lat)*c,h=a.pixelsPerMeter,e=c/(g/a.pixelsPerMeter),b=aI(new Float64Array(16));return br(b,b,[d.x,d.y,0]),bs(b,b,[e,e,h]),b},a.clamp=bM,a.clearTileCache=function(a){const b=s.caches.delete(e9);a&&b.catch(a).then(()=>a())},a.clipLine=d8,a.clone=function(b){var a=new I(16);return a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a[4]=b[4],a[5]=b[5],a[6]=b[6],a[7]=b[7],a[8]=b[8],a[9]=b[9],a[10]=b[10],a[11]=b[11],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15],a},a.clone$1=bX,a.collisionCircleLayout=d_,a.config=b_,a.conjugate=function(a,b){return a[0]=-b[0],a[1]=-b[1],a[2]=-b[2],a[3]=b[3],a},a.create=function(){var a=new I(16);return I!=Float32Array&&(a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[11]=0,a[12]=0,a[13]=0,a[14]=0),a[0]=1,a[5]=1,a[10]=1,a[15]=1,a},a.create$1=aH,a.createExpression=cN,a.createLayout=j,a.createStyleLayer=function(a){return"custom"===a.type?new kJ(a):new kM[a.type](a)},a.cross=bB,a.degToRad=bI,a.div=function(a,b,c){return a[0]=b[0]/c[0],a[1]=b[1]/c[1],a[2]=b[2]/c[2],a},a.dot=bA,a.ease=bL,a.easeCubicInOut=bK,a.emitValidationErrors=c_,a.endsWith=bV,a.enforceCacheSizeLimit=function(a){fe(),fa&&fa.then(b=>{b.keys().then(d=>{for(let c=0;cb&&(e+=(c[a]-b)*(c[a]-b)),d[a]Math.abs(a.parallels[0]+a.parallels[1])){let c=function(b){const a=Math.max(.01,Math.cos(b*aP)),c=1/(2*Math.max(Math.PI*a,1/a));return{wrap:!0,supportsWorldCopies:!0,unsupportedLayers:["custom",],project(b,d){const e=b*aP*a,f=Math.sin(d*aP)/a;return{x:e*c+.5,y:-f*c+.5,z:0}},unproject(b,d){const e=-(d-.5)/c,f=bM((b-.5)/c*eK/a,-180,180),g=Math.asin(bM(e*a,-1,1)),h=bM(g*eK,-85.051129,85.051129);return new dy(f,h)}}}(a.parallels[0]);if("lambertConformalConic"===a.name){const{project:d,unproject:e}=lu.mercator;c={wrap:!0,supportsWorldCopies:!0,project:d,unproject:e}}return bR({},b,a,c)}return bR({},b,a)}(a,b):a},a.getRTLTextPluginStatus=c3,a.getReferrer=b6,a.getTilePoint=function(a,{x:b,y:c},d=0){return new aF(((b-d)*a.scale-a.x)*8192,(c*a.scale-a.y)*8192)},a.getTileVec3=function(a,b,c=0){return Q(((b.x-c)*a.scale-a.x)*8192,(b.y*a.scale-a.y)*8192,h8(b.z,b.y))},a.getVideo=function(c,e){const a=s.document.createElement("video");a.muted=!0,a.onloadstart=function(){e(null,a)};for(let b=0;b0&&(a=1/Math.sqrt(a)),b[0]=d*a,b[1]=e*a,b[2]=f*a,b[3]=g*a,b},a.number=aY,a.ortho=function(a,b,c,d,e,f,g){var h=1/(b-c),i=1/(d-e),j=1/(f-g);return a[0]=-2*h,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=-2*i,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=2*j,a[11]=0,a[12]=(b+c)*h,a[13]=(e+d)*i,a[14]=(g+f)*j,a[15]=1,a},a.pbf=d2,a.perspective=function(a,f,g,c,b){var d,e=1/Math.tan(f/2);return a[0]=e/g,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=e,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[11]=-1,a[12]=0,a[13]=0,a[15]=0,null!=b&&b!==1/0?(a[10]=(b+c)*(d=1/(c-b)),a[14]=2*b*c*d):(a[10]=-1,a[14]=-2*c),a},a.pick=function(c,d){const e={};for(let a=0;athis._layers[a.id]),e=g[0];if("none"===e.visibility)continue;const h=e.source||"";let c=this.familiesBySource[h];c||(c=this.familiesBySource[h]={});const i=e.sourceLayer||"_geojsonTileLayer";let f=c[i];f||(f=c[i]=[]),f.push(g)}}}const{ImageBitmap:n}=a.window;class o{loadTile(d,e){const{uid:f,encoding:g,rawImageData:b,padding:c,buildQuadTree:h}=d,i=n&&b instanceof n?this.getImageData(b,c):b;e(null,new a.DEMData(f,i,g,c<1,h))}getImageData(b,c){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(b.width,b.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d")),this.offscreenCanvas.width=b.width,this.offscreenCanvas.height=b.height,this.offscreenCanvasContext.drawImage(b,0,0,b.width,b.height);const d=this.offscreenCanvasContext.getImageData(-c,-c,b.width+2*c,b.height+2*c);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),new a.RGBAImage({width:d.width,height:d.height},d.data)}}var f,p=function e(b,c){var a,d=b&&b.type;if("FeatureCollection"===d)for(a=0;a=Math.abs(d)?b-f+d:d-f+b,b=f}b+g>=0!= !!i&&a.reverse()}const s=a.vectorTile.VectorTileFeature.prototype.toGeoJSON;class t{constructor(b){this._feature=b,this.extent=a.EXTENT,this.type=b.type,this.properties=b.tags,"id"in b&&!isNaN(b.id)&&(this.id=parseInt(b.id,10))}loadGeometry(){if(1===this._feature.type){const b=[];for(const c of this._feature.geometry)b.push([new a.pointGeometry(c[0],c[1]),]);return b}{const d=[];for(const g of this._feature.geometry){const e=[];for(const f of g)e.push(new a.pointGeometry(f[0],f[1]));d.push(e)}return d}}toGeoJSON(a,b,c){return s.call(this,a,b,c)}}class u{constructor(b){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=a.EXTENT,this.length=b.length,this._features=b}feature(a){return new t(this._features[a])}}var g=a.vectorTile.VectorTileFeature,h=i;function i(a,b){this.options=b||{},this.features=a,this.length=a.length}function b(a,b){this.id="number"==typeof a.id?a.id:void 0,this.type=a.type,this.rawGeometry=1===a.type?[a.geometry]:a.geometry,this.properties=a.tags,this.extent=b||4096}i.prototype.feature=function(a){return new b(this.features[a],this.options.extent)},b.prototype.loadGeometry=function(){var e=this.rawGeometry;this.geometry=[];for(var c=0;c>31}function A(f,a){for(var g=f.loadGeometry(),d=f.type,h=0,i=0,n=g.length,e=0;e>1;D(c,d,g,a,b,f%2),C(c,d,e,a,g-1,f+1),C(c,d,e,g+1,b,f+1)}function D(g,a,e,b,d,h){for(;d>b;){if(d-b>600){const f=d-b+1,l=e-b+1,m=Math.log(f),j=.5*Math.exp(2*m/3),n=.5*Math.sqrt(m*j*(f-j)/f)*(l-f/2<0?-1:1);D(g,a,e,Math.max(b,Math.floor(e-l*j/f+n)),Math.min(d,Math.floor(e+(f-l)*j/f+n)),h)}const k=a[2*e+h];let i=b,c=d;for(E(g,a,b,e),a[2*d+h]>k&&E(g,a,b,d);ik;)c--}a[2*b+h]===k?E(g,a,b,c):E(g,a,++c,d),c<=e&&(b=c+1),e<=c&&(d=c-1)}}function E(d,c,a,b){F(d,a,b),F(c,2*a,2*b),F(c,2*a+1,2*b+1)}function F(a,b,c){const d=a[b];a[b]=a[c],a[c]=d}function G(c,d,e,f){const a=c-e,b=d-f;return a*a+b*b}c.fromVectorTileJs=j,c.fromGeojsonVt=function(d,b){b=b||{};var c={};for(var a in d)c[a]=new h(d[a].features,b),c[a].name=a,c[a].version=b.version,c[a].extent=b.extent;return j({layers:c})},c.GeoJSONWrapper=h;class H{constructor(b,f=a=>a[0],g=a=>a[1],e=64,h=Float64Array){this.nodeSize=e,this.points=b;const i=b.length<65536?Uint16Array:Uint32Array,c=this.ids=new i(b.length),d=this.coords=new h(2*b.length);for(let a=0;a=j&&b<=l&&c>=k&&c<=m&&n.push(i[d]);continue}const e=Math.floor((h+g)/2);b=f[2*e],c=f[2*e+1],b>=j&&b<=l&&c>=k&&c<=m&&n.push(i[e]);const p=(o+1)%2;(0===o?j<=b:k<=c)&&(a.push(h),a.push(e-1),a.push(p)),(0===o?l>=b:m>=c)&&(a.push(e+1),a.push(g),a.push(p))}return n}(this.ids,this.coords,a,b,c,d,this.nodeSize)}within(a,b,c){return function(j,e,f,g,b,q){const a=[0,j.length-1,0],k=[],o=b*b;for(;a.length;){const l=a.pop(),h=a.pop(),i=a.pop();if(h-i<=q){for(let c=i;c<=h;c++)G(e[2*c],e[2*c+1],f,g)<=o&&k.push(j[c]);continue}const d=Math.floor((i+h)/2),m=e[2*d],n=e[2*d+1];G(m,n,f,g)<=o&&k.push(j[d]);const p=(l+1)%2;(0===l?f-b<=m:g-b<=n)&&(a.push(i),a.push(d-1),a.push(p)),(0===l?f+b>=m:g+b>=n)&&(a.push(d+1),a.push(h),a.push(p))}return k}(this.ids,this.coords,a,b,c,this.nodeSize)}}const I=Math.fround||(f=new Float32Array(1),a=>(f[0]=+a,f[0]));class J{constructor(a){this.options=R(Object.create({minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:a=>a}),a),this.trees=new Array(this.options.maxZoom+1)}load(b){const{log:c,minZoom:i,maxZoom:f,nodeSize:g}=this.options;c&&console.time("total time");const h=`prepare ${b.length} points`;c&&console.time(h),this.points=b;let a=[];for(let d=0;d=i;e--){const j=+Date.now();a=this._cluster(a,e),this.trees[e]=new H(a,S,T,g,Float32Array),c&&console.log("z%d: %d clusters in %dms",e,a.length,+Date.now()-j)}return c&&console.timeEnd("total time"),this}getClusters(a,d){let b=((a[0]+180)%360+360)%360-180;const e=Math.max(-90,Math.min(90,a[1]));let c=180===a[2]?180:((a[2]+180)%360+360)%360-180;const f=Math.max(-90,Math.min(90,a[3]));if(a[2]-a[0]>=360)b=-180,c=180;else if(b>c){const j=this.getClusters([b,e,180,f],d),k=this.getClusters([-180,e,c,f],d);return j.concat(k)}const h=this.trees[this._limitZoom(d)],l=h.range(O(b),P(f),O(c),P(e)),i=[];for(const m of l){const g=h.points[m];i.push(g.numPoints?M(g):this.points[g.index])}return i}getChildren(c){const h=this._getOriginId(c),g=this._getOriginZoom(c),d="No cluster with the specified id.",a=this.trees[g];if(!a)throw new Error(d);const e=a.points[h];if(!e)throw new Error(d);const i=this.options.radius/(this.options.extent*Math.pow(2,g-1)),j=a.within(e.x,e.y,i),f=[];for(const k of j){const b=a.points[k];b.parentId===c&&f.push(b.numPoints?M(b):this.points[b.index])}if(0===f.length)throw new Error(d);return f}getLeaves(d,a,b){const c=[];return this._appendLeaves(c,d,a=a||10,b=b||0,0),c}getTile(i,d,e){const b=this.trees[this._limitZoom(i)],a=Math.pow(2,i),{extent:j,radius:k}=this.options,c=k/j,g=(e-c)/a,h=(e+1+c)/a,f={features:[]};return this._addTileFeatures(b.range((d-c)/a,g,(d+1+c)/a,h),b.points,d,e,a,f),0===d&&this._addTileFeatures(b.range(1-c/a,g,1,h),b.points,a,e,a,f),d===a-1&&this._addTileFeatures(b.range(0,g,c/a,h),b.points,-1,e,a,f),f.features.length?f:null}getClusterExpansionZoom(a){let b=this._getOriginZoom(a)-1;for(;b<=this.options.maxZoom;){const c=this.getChildren(a);if(b++,1!==c.length)break;a=c[0].properties.cluster_id}return b}_appendLeaves(c,g,e,d,a){const h=this.getChildren(g);for(const f of h){const b=f.properties;if(b&&b.cluster?a+b.point_count<=d?a+=b.point_count:a=this._appendLeaves(c,b.cluster_id,e,d,a):ab&&(c+=o.numPoints||1)}if(c>e&&c>=u){let p=a.x*e,q=a.y*e,i=j&&e>1?this._map(a,!0):null;const l=(g<<5)+(b+1)+this.points.length;for(const x of k){const d=h.points[x];if(d.zoom<=b)continue;d.zoom=b;const r=d.numPoints||1;p+=d.x*r,q+=d.y*r,d.parentId=l,j&&(i||(i=this._map(a,!0)),j(i,this._map(d)))}a.parentId=l,f.push(K(p/c,q/c,l,c,i))}else if(f.push(a),c>1)for(const y of k){const m=h.points[y];m.zoom<=b||(m.zoom=b,f.push(m))}}return f}_getOriginId(a){return a-this.points.length>>5}_getOriginZoom(a){return(a-this.points.length)%32}_map(a,c){if(a.numPoints)return c?R({},a.properties):a.properties;const d=this.points[a.index].properties,b=this.options.map(d);return c&&b===d?R({},b):b}}function K(a,b,c,d,e){return{x:I(a),y:I(b),zoom:1/0,id:c,parentId:-1,numPoints:d,properties:e}}function L(a,b){const[c,d]=a.geometry.coordinates;return{x:I(O(c)),y:I(P(d)),zoom:1/0,index:b,parentId:-1}}function M(a){return{type:"Feature",id:a.id,properties:N(a),geometry:{type:"Point",coordinates:[360*(a.x-.5),Q(a.y),]}}}function N(b){const a=b.numPoints,c=a>=1e4?`${Math.round(a/1e3)}k`:a>=1e3?Math.round(a/100)/10+"k":a;return R(R({},b.properties),{cluster:!0,cluster_id:b.id,point_count:a,point_count_abbreviated:c})}function O(a){return a/360+.5}function P(c){const b=Math.sin(c*Math.PI/180),a=.5-.25*Math.log((1+b)/(1-b))/Math.PI;return a<0?0:a>1?1:a}function Q(a){return 360*Math.atan(Math.exp((180-360*a)*Math.PI/180))/Math.PI-90}function R(a,b){for(const c in b)a[c]=b[c];return a}function S(a){return a.x}function T(a){return a.y}function U(a,b,c,g){for(var d,f=g,k=c-b>>1,i=c-b,l=a[b],m=a[b+1],n=a[c],o=a[c+1],e=b+3;ef)d=e,f=h;else if(h===f){var j=Math.abs(e-k);jg&&(d-b>3&&U(a,b,d,g),a[d+2]=f,c-d>3&&U(a,d,c,g))}function V(f,g,c,d,h,i){var a=h-c,b=i-d;if(0!==a||0!==b){var e=((f-c)*a+(g-d)*b)/(a*a+b*b);e>1?(c=h,d=i):e>0&&(c+=a*e,d+=b*e)}return(a=f-c)*a+(b=g-d)*b}function W(a,c,d,e){var b={id:void 0===a?null:a,type:c,geometry:d,tags:e,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(d){var b=d.geometry,c=d.type;if("Point"===c||"MultiPoint"===c||"LineString"===c)X(d,b);else if("Polygon"===c||"MultiLineString"===c)for(var a=0;a0&&(h+=k?(f*d-c*g)/2:Math.sqrt(Math.pow(c-f,2)+Math.pow(d-g,2))),f=c,g=d}var i=a.length-3;a[2]=1,U(a,0,i,j),a[i+2]=1,a.size=Math.abs(h),a.start=0,a.end=a.size}function _(b,d,e,f){for(var a=0;a1?1:a}function ac(j,m,e,d,f,n,o,p){if(d/=m,n>=(e/=m)&&o=d)return null;for(var i=[],k=0;k=e&&r=d)){var b=[];if("Point"===a||"MultiPoint"===a)ad(h,b,e,d,f);else if("LineString"===a)ae(h,b,e,d,f,!1,p.lineMetrics);else if("MultiLineString"===a)ag(h,b,e,d,f,!1);else if("Polygon"===a)ag(h,b,e,d,f,!0);else if("MultiPolygon"===a)for(var g=0;g=e&&d<=f&&(c.push(b[a]),c.push(b[a+1]),c.push(b[a+2]))}}function ae(b,u,e,f,o,v,m){for(var n,g,a=af(b),p=0===o?ai:aj,q=b.start,h=0;he&&(g=p(a,c,d,j,k,e),m&&(a.start=q+n*g)):l>f?r=e&&(g=p(a,c,d,j,k,e),t=!0),r>f&&l<=f&&(g=p(a,c,d,j,k,f),t=!0),!v&&t&&(m&&(a.end=q+n*g),u.push(a),a=af(b)),m&&(q+=n)}var i=b.length-3;c=b[i],d=b[i+1],s=b[i+2],(l=0===o?c:d)>=e&&l<=f&&ah(a,c,d,s),i=a.length-3,v&&i>=3&&(a[i]!==a[0]||a[i+1]!==a[1])&&ah(a,a[0],a[1],a[2]),a.length&&u.push(a)}function af(b){var a=[];return a.size=b.size,a.start=b.start,a.end=b.end,a}function ag(b,c,d,e,f,g){for(var a=0;aa.maxX&&(a.maxX=h),i>a.maxY&&(a.maxY=i)}return a}function ap(f,d,h,m){var b=d.geometry,c=d.type,e=[];if("Point"===c||"MultiPoint"===c)for(var a=0;a0&&a.size<(f?g:b))e.numPoints+=a.length/3;else{for(var d=[],c=0;cg)&&(e.numSimplified++,d.push(a[c]),d.push(a[c+1])),e.numPoints++;f&&function(b,f){for(var e=0,a=0,c=b.length,d=c-2;a0===f)for(a=0,c=b.length;a24)throw new Error("maxZoom should be in the 0-24 range");if(a.promoteId&&a.generateId)throw new Error("promoteId and generateId cannot be used together.");var d,e,b,c,f,g,h=function(a,d){var c=[];if("FeatureCollection"===a.type)for(var b=0;b1&&console.time("creation"),a=this.tiles[u]=ao(g,c,d,b,e),this.tileCoords.push({z:c,x:d,y:b}),j)){j>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",c,d,b,a.numFeatures,a.numPoints,a.numSimplified),console.timeEnd("creation"));var v="z"+c;this.stats[v]=(this.stats[v]||0)+1,this.total++}if(a.source=g,m){if(c===e.maxZoom||c===m)continue;var w=1<1&&console.time("clipping");var n,o,p,q,k,l,i=.5*e.buffer/e.extent,r=.5-i,s=.5+i,t=1+i;n=o=p=q=null,k=ac(g,h,d-i,d+s,0,a.minX,a.maxX,e),l=ac(g,h,d+r,d+t,0,a.minX,a.maxX,e),g=null,k&&(n=ac(k,h,b-i,b+s,1,a.minY,a.maxY,e),o=ac(k,h,b+r,b+t,1,a.minY,a.maxY,e),k=null),l&&(p=ac(l,h,b-i,b+s,1,a.minY,a.maxY,e),q=ac(l,h,b+r,b+t,1,a.minY,a.maxY,e),l=null),j>1&&console.timeEnd("clipping"),f.push(n||[],c+1,2*d,2*b),f.push(o||[],c+1,2*d,2*b+1),f.push(p||[],c+1,2*d+1,2*b),f.push(q||[],c+1,2*d+1,2*b+1)}}},d.prototype.getTile=function(a,b,g){var k=this.options,l=k.extent,h=k.debug;if(a<0||a>24)return null;var j=1<1&&console.log("drilling down to z%d-%d-%d",a,b,g);for(var c,d=a,e=b,f=g;!c&&d>0;)d--,e=Math.floor(e/2),f=Math.floor(f/2),c=this.tiles[ar(d,e,f)];return c&&c.source?(h>1&&console.log("found parent tile z%d-%d-%d",d,e,f),h>1&&console.time("drilling down"),this.splitTile(c.source,d,e,f,a,b,g),h>1&&console.timeEnd("drilling down"),this.tiles[i]?am(this.tiles[i],l):null):null};class as extends a.VectorTileWorkerSource{constructor(b,d,e,f,a){super(b,d,e,f,function(g,b){const d=g.tileID.canonical;if(!this._geoJSONIndex)return b(null,null);const e=this._geoJSONIndex.getTile(d.z,d.x,d.y);if(!e)return b(null,null);const f=new u(e.features);let a=c(f);0===a.byteOffset&&a.byteLength===a.buffer.byteLength||(a=new Uint8Array(a)),b(null,{vectorTile:f,rawData:a.buffer})}),a&&(this.loadGeoJSON=a)}loadData(b,e){const c=b&&b.request,f=c&&c.collectResourceTiming;this.loadGeoJSON(b,(i,g)=>{if(i||!g)return e(i);if("object"!=typeof g)return e(new Error(`Input data given to '${b.source}' is not a valid GeoJSON object.`));{p(g,!0);try{var j,k;if(b.filter){const l=a.createExpression(b.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===l.result)throw new Error(l.value.map(a=>`${a.key}: ${a.message}`).join(", "));const n=g.features.filter(a=>l.value.evaluate({zoom:0},a));g={type:"FeatureCollection",features:n}}this._geoJSONIndex=b.cluster?new J(function({superclusterOptions:b,clusterProperties:d}){if(!d||!b)return b;const f={},g={},l={accumulated:null,zoom:0},m={properties:null},h=Object.keys(d);for(const c of h){const[e,i]=d[c],j=a.createExpression(i),k=a.createExpression("string"==typeof e?[e,["accumulated",],["get",c,],]:e);f[c]=j.value,g[c]=k.value}return b.map=c=>{m.properties=c;const a={};for(const b of h)a[b]=f[b].evaluate(l,m);return a},b.reduce=(b,c)=>{for(const a of(m.properties=c,h))l.accumulated=b[a],b[a]=g[a].evaluate(l,m)},b}(b)).load(g.features):(j=g,k=b.geojsonVtOptions,new d(j,k))}catch(o){return e(o)}this.loaded={};const h={};if(f){const m=a.getPerformanceMeasurement(c);m&&(h.resourceTiming={},h.resourceTiming[b.source]=JSON.parse(JSON.stringify(m)))}e(null,h)}})}reloadTile(a,b){const c=this.loaded;return c&&c[a.uid]?super.reloadTile(a,b):this.loadTile(a,b)}loadGeoJSON(b,c){if(b.request)a.getJSON(b.request,c);else{if("string"!=typeof b.data)return c(new Error(`Input data given to '${b.source}' is not a valid GeoJSON object.`));try{return c(null,JSON.parse(b.data))}catch(d){return c(new Error(`Input data given to '${b.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(b,a){try{a(null,this._geoJSONIndex.getClusterExpansionZoom(b.clusterId))}catch(c){a(c)}}getClusterChildren(b,a){try{a(null,this._geoJSONIndex.getChildren(b.clusterId))}catch(c){a(c)}}getClusterLeaves(a,b){try{b(null,this._geoJSONIndex.getLeaves(a.clusterId,a.limit,a.offset))}catch(c){b(c)}}}class e{constructor(b){this.self=b,this.actor=new a.Actor(b,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=a.getProjection({name:"mercator"}),this.workerSourceTypes={vector:a.VectorTileWorkerSource,geojson:as},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(a,b)=>{if(this.workerSourceTypes[a])throw new Error(`Worker source with name "${a}" already registered.`);this.workerSourceTypes[a]=b},this.self.registerRTLTextPlugin=b=>{if(a.plugin.isParsed())throw new Error("RTL text plugin already registered.");a.plugin.applyArabicShaping=b.applyArabicShaping,a.plugin.processBidirectionalText=b.processBidirectionalText,a.plugin.processStyledBidirectionalText=b.processStyledBidirectionalText}}clearCaches(a,c,b){delete this.layerIndexes[a],delete this.availableImages[a],delete this.workerSources[a],delete this.demWorkerSources[a],b()}checkIfReady(b,c,a){a()}setReferrer(b,a){this.referrer=a}spriteLoaded(c,e){for(const f in this.isSpriteLoaded[c]=e,this.workerSources[c]){const b=this.workerSources[c][f];for(const d in b)b[d]instanceof a.VectorTileWorkerSource&&(b[d].isSpriteLoaded=e,b[d].fire(new a.Event("isSpriteLoaded")))}}setImages(a,b,d){for(const e in this.availableImages[a]=b,this.workerSources[a]){const c=this.workerSources[a][e];for(const f in c)c[f].availableImages=b}d()}enableTerrain(c,a,b){this.terrain=a,b()}setProjection(b,c){this.projections[b]=a.getProjection(c)}setLayers(a,b,c){this.getLayerIndex(a).replace(b),c()}updateLayers(b,a,c){this.getLayerIndex(b).update(a.layers,a.removedIds),c()}loadTile(c,b,e){const d=this.enableTerrain?a.extend({enableTerrain:this.terrain},b):b;d.projection=this.projections[c]||this.defaultProjection,this.getWorkerSource(c,b.type,b.source).loadTile(d,e)}loadDEMTile(c,b,d){const e=this.enableTerrain?a.extend({buildQuadTree:this.terrain},b):b;this.getDEMWorkerSource(c,b.source).loadTile(e,d)}reloadTile(c,b,e){const d=this.enableTerrain?a.extend({enableTerrain:this.terrain},b):b;d.projection=this.projections[c]||this.defaultProjection,this.getWorkerSource(c,b.type,b.source).reloadTile(d,e)}abortTile(b,a,c){this.getWorkerSource(b,a.type,a.source).abortTile(a,c)}removeTile(b,a,c){this.getWorkerSource(b,a.type,a.source).removeTile(a,c)}removeSource(b,a,c){if(!this.workerSources[b]||!this.workerSources[b][a.type]||!this.workerSources[b][a.type][a.source])return;const d=this.workerSources[b][a.type][a.source];delete this.workerSources[b][a.type][a.source],void 0!==d.removeSource?d.removeSource(a,c):c()}loadWorkerSource(d,b,a){try{this.self.importScripts(b.url),a()}catch(c){a(c.toString())}}syncRTLPluginState(g,e,c){try{a.plugin.setState(e);const b=a.plugin.getPluginURL();if(a.plugin.isLoaded()&&!a.plugin.isParsed()&&null!=b){this.self.importScripts(b);const d=a.plugin.isParsed();c(d?void 0:new Error(`RTL Text Plugin failed to import scripts from ${b}`),d)}}catch(f){c(f.toString())}}getAvailableImages(b){let a=this.availableImages[b];return a||(a=[]),a}getLayerIndex(b){let a=this.layerIndexes[b];return a||(a=this.layerIndexes[b]=new m),a}getWorkerSource(a,b,c){return this.workerSources[a]||(this.workerSources[a]={}),this.workerSources[a][b]||(this.workerSources[a][b]={}),this.workerSources[a][b][c]||(this.workerSources[a][b][c]=new this.workerSourceTypes[b]({send:(b,c,d,g,e,f)=>{this.actor.send(b,c,d,a,e,f)},scheduler:this.actor.scheduler},this.getLayerIndex(a),this.getAvailableImages(a),this.isSpriteLoaded[a])),this.workerSources[a][b][c]}getDEMWorkerSource(a,b){return this.demWorkerSources[a]||(this.demWorkerSources[a]={}),this.demWorkerSources[a][b]||(this.demWorkerSources[a][b]=new o),this.demWorkerSources[a][b]}enforceCacheSizeLimit(c,b){a.enforceCacheSizeLimit(b)}getWorkerPerformanceMetrics(b,c,a){a(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new e(self)),e}),a(["./shared"],function(a){var l=m;function m(c){var b,a;return b=c,"undefined"!=typeof window&&"undefined"!=typeof document&& !!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 a,b,d=new Blob([""],{type:"text/javascript"}),c=URL.createObjectURL(d);try{b=new Worker(c),a=!0}catch(e){a=!1}return b&&b.terminate(),URL.revokeObjectURL(c),a}()&&"Uint8ClampedArray"in window&& !!ArrayBuffer.isView&& !!function(){var a=document.createElement("canvas");a.width=a.height=1;var b=a.getContext("2d");if(!b)return!1;var c=b.getImageData(0,0,1,1);return c&&c.width===a.width}()&&(void 0===B[a=b&&b.failIfMajorPerformanceCaveat]&&(B[a]=function(f){var e,c,d,b,a=(e=f,c=document.createElement("canvas"),(d=Object.create(m.webGLContextAttributes)).failIfMajorPerformanceCaveat=e,c.getContext("webgl",d)||c.getContext("experimental-webgl",d));if(!a)return!1;try{b=a.createShader(a.VERTEX_SHADER)}catch(g){return!1}return!(!b||a.isContextLost())&&(a.shaderSource(b,"void main() {}"),a.compileShader(b),!0===a.getShaderParameter(b,a.COMPILE_STATUS))}(a)),!!B[a]&&!document.documentMode)}var B={};function C(b,c){var d=c[0],e=c[1],f=c[2],g=c[3],a=d*g-f*e;return a?(b[0]=g*(a=1/a),b[1]=-e*a,b[2]=-f*a,b[3]=d*a,b):null}function D(a,b){if(Array.isArray(a)){if(!Array.isArray(b)||a.length!==b.length)return!1;for(let c=0;c{a.window.removeEventListener("click",G,!0)},0)},b.mousePos=function(a,b){const c=a.getBoundingClientRect();return H(a,c,b)},b.touchPos=function(b,c){const e=b.getBoundingClientRect(),d=[];for(let a=0;a=0?0:b.button};class J extends a.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new a.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(a){if(this.loaded!==a&&(this.loaded=a,a)){for(const{ids:b,callback:c}of this.requestors)this._notify(b,c);this.requestors=[]}}getImage(a){return this.images[a]}addImage(a,b){this._validate(a,b)&&(this.images[a]=b)}_validate(d,b){let c=!0;return this._validateStretch(b.stretchX,b.data&&b.data.width)||(this.fire(new a.ErrorEvent(new Error(`Image "${d}" has invalid "stretchX" value`))),c=!1),this._validateStretch(b.stretchY,b.data&&b.data.height)||(this.fire(new a.ErrorEvent(new Error(`Image "${d}" has invalid "stretchY" value`))),c=!1),this._validateContent(b.content,b)||(this.fire(new a.ErrorEvent(new Error(`Image "${d}" has invalid "content" value`))),c=!1),c}_validateStretch(b,d){if(!b)return!0;let c=0;for(const a of b){if(a[0]{this.ready=!0})}broadcast(c,d,b){a.asyncAll(this.actors,(a,b)=>{a.send(c,d,b)},b=b||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(a=>{a.remove()}),this.actors=[],this.workerPool.release(this.id)}}function V(b,c,d){return c*(a.EXTENT/(b.tileSize*Math.pow(2,d-b.tileID.overscaledZ)))}n.Actor=a.Actor;class W{constructor(b,c,d){this.context=b;const a=b.gl;this.buffer=a.createBuffer(),this.dynamicDraw=Boolean(d),this.context.unbindVAO(),b.bindElementBuffer.set(this.buffer),a.bufferData(a.ELEMENT_ARRAY_BUFFER,c.arrayBuffer,this.dynamicDraw?a.DYNAMIC_DRAW:a.STATIC_DRAW),this.dynamicDraw||delete c.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(b){const a=this.context.gl;this.context.unbindVAO(),this.bind(),a.bufferSubData(a.ELEMENT_ARRAY_BUFFER,0,b.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const X={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Y{constructor(c,b,d,e){this.length=b.length,this.attributes=d,this.itemSize=b.bytesPerElement,this.dynamicDraw=e,this.context=c;const a=c.gl;this.buffer=a.createBuffer(),c.bindVertexBuffer.set(this.buffer),a.bufferData(a.ARRAY_BUFFER,b.arrayBuffer,this.dynamicDraw?a.DYNAMIC_DRAW:a.STATIC_DRAW),this.dynamicDraw||delete b.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(b){const a=this.context.gl;this.bind(),a.bufferSubData(a.ARRAY_BUFFER,0,b.arrayBuffer)}enableAttributes(c,d){for(let a=0;ad.pointCoordinate3D(a)),this.cameraGeometry=this.bufferedCameraGeometry(0)}static createFromScreenPoints(b,c){let d,e;if(b instanceof a.pointGeometry||"number"==typeof b[0]){const h=a.pointGeometry.convert(b);d=[a.pointGeometry.convert(b)],e=c.isPointAboveHorizon(h)}else{const f=a.pointGeometry.convert(b[0]),g=a.pointGeometry.convert(b[1]);d=[f,g],e=a.polygonizeBounds(f,g).every(a=>c.isPointAboveHorizon(a))}return new _(d,c.getCameraPoint(),e,c)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(b){return a.polygonizeBounds(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],b)}bufferedCameraGeometry(e){const d=this.screenBounds[0],b=1===this.screenBounds.length?this.screenBounds[0].add(new a.pointGeometry(1,1)):this.screenBounds[1],c=a.polygonizeBounds(d,b,0,!1);return this.cameraPoint.y>b.y&&(this.cameraPoint.x>d.x&&this.cameraPoint.x=b.x?c[2]=this.cameraPoint:this.cameraPoint.x<=d.x&&(c[3]=this.cameraPoint)),a.bufferConvexPolygon(c,e)}containsTile(c,d,h){var b;const f=c.queryPadding+1,i=c.tileID.wrap,e=h?this._bufferedCameraMercator(f,d).map(b=>a.getTilePoint(c.tileTransform,b,i)):this._bufferedScreenMercator(f,d).map(b=>a.getTilePoint(c.tileTransform,b,i)),g=this.screenGeometryMercator.map(b=>a.getTileVec3(c.tileTransform,b,i)),j=g.map(b=>new a.pointGeometry(b[0],b[1])),k=d.getFreeCameraOptions().position||new a.MercatorCoordinate(0,0,0),n=a.getTileVec3(c.tileTransform,k,i),l=g.map(c=>{const b=a.sub(c,c,n);return a.normalize(b,b),new a.Ray(n,b)}),m=V(c,1,d.zoom);if(a.polygonIntersectsBox(e,0,0,a.EXTENT,a.EXTENT))return{queryGeometry:this,tilespaceGeometry:j,tilespaceRays:l,bufferedTilespaceGeometry:e,bufferedTilespaceBounds:((b=a.getBounds(e)).min.x=a.clamp(b.min.x,0,a.EXTENT),b.min.y=a.clamp(b.min.y,0,a.EXTENT),b.max.x=a.clamp(b.max.x,0,a.EXTENT),b.max.y=a.clamp(b.max.y,0,a.EXTENT),b),tile:c,tileID:c.tileID,pixelToTileUnitsFactor:m}}_bufferedScreenMercator(b,d){const a=aa(b);if(this._screenRaycastCache[a])return this._screenRaycastCache[a];{const c=this.bufferedScreenGeometry(b).map(a=>d.pointCoordinate3D(a));return this._screenRaycastCache[a]=c,c}}_bufferedCameraMercator(b,d){const a=aa(b);if(this._cameraRaycastCache[a])return this._cameraRaycastCache[a];{const c=this.bufferedCameraGeometry(b).map(a=>d.pointCoordinate3D(a));return this._cameraRaycastCache[a]=c,c}}}function aa(a){return 100*a|0}function ab(b,c,e){const d=function(g,f){if(g)return e(g);if(f){const d=a.pick(a.extend(f,b),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding",]);f.vector_layers&&(d.vectorLayers=f.vector_layers,d.vectorLayerIds=d.vectorLayers.map(a=>a.id)),d.tiles=c.canonicalizeTileset(d,b.url),e(null,d)}};return b.url?a.getJSON(c.transformRequest(c.normalizeSourceURL(b.url),a.ResourceType.Source),d):a.exported.frame(()=>d(null,b))}class ac{constructor(b,c,d){this.bounds=a.LngLatBounds.convert(this.validateBounds(b)),this.minzoom=c||0,this.maxzoom=d||24}validateBounds(a){return Array.isArray(a)&&4===a.length?[Math.max(-180,a[0]),Math.max(-90,a[1]),Math.min(180,a[2]),Math.min(90,a[3]),]:[-180,-90,180,90]}contains(b){const c=Math.pow(2,b.z),d=Math.floor(a.mercatorXfromLng(this.bounds.getWest())*c),e=Math.floor(a.mercatorYfromLat(this.bounds.getNorth())*c),f=Math.ceil(a.mercatorXfromLng(this.bounds.getEast())*c),g=Math.ceil(a.mercatorYfromLat(this.bounds.getSouth())*c);return b.x>=d&&b.x=e&&b.y{this._tileJSONRequest=null,this._loaded=!0,c?this.fire(new a.ErrorEvent(c)):b&&(a.extend(this,b),b.bounds&&(this.tileBounds=new ac(b.bounds,this.minzoom,this.maxzoom)),a.postTurnstileEvent(b.tiles),this.fire(new a.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new a.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}onAdd(a){this.map=a,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return a.extend({},this._options)}hasTile(a){return!this.tileBounds||this.tileBounds.contains(a.canonical)}loadTile(b,e){const c=a.exported.devicePixelRatio>=2,d=this.map._requestManager.normalizeTileURL(b.tileID.canonical.url(this.tiles,this.scheme),c,this.tileSize);b.request=a.getImage(this.map._requestManager.transformRequest(d,a.ResourceType.Tile),(g,f,h,i)=>{if(delete b.request,b.aborted)b.state="unloaded",e(null);else if(g)b.state="errored",e(g);else if(f){this.map._refreshExpiredTiles&&b.setExpiryData({cacheControl:h,expires:i});const c=this.map.painter.context,d=c.gl;b.texture=this.map.painter.getTileTexture(f.width),b.texture?b.texture.update(f,{useMipmap:!0}):(b.texture=new a.Texture(c,f,d.RGBA,{useMipmap:!0}),b.texture.bind(d.LINEAR,d.CLAMP_TO_EDGE),c.extTextureFilterAnisotropic&&d.texParameterf(d.TEXTURE_2D,c.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,c.extTextureFilterAnisotropicMax)),b.state="loaded",a.cacheEntryPossiblyAdded(this.dispatcher),e(null)}})}abortTile(a,b){a.request&&(a.request.cancel(),delete a.request),b()}unloadTile(a,b){a.texture&&this.map.painter.saveTileTexture(a.texture),b()}hasTransition(){return!1}}let ad;function ae(e,f,g,h,i,j,k,l){const b=[e,g,i,f,h,j,1,1,1],c=[k,l,1],d=a.adjoint([],b),[m,n,o]=a.transformMat3(c,c,a.transpose(d,d));return a.multiply(b,[m,0,0,0,n,0,0,0,o],b)}class s extends a.Evented{constructor(b,a,c,d){super(),this.id=b,this.dispatcher=c,this.coordinates=a.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(d),this.options=a}load(b,c){this._loaded=!1,this.fire(new a.Event("dataloading",{dataType:"source"})),this.url=this.options.url,a.getImage(this.map._requestManager.transformRequest(this.url,a.ResourceType.Image),(d,e)=>{this._loaded=!0,d?this.fire(new a.ErrorEvent(d)):e&&(this.image=a.exported.getImageData(e),this.width=this.image.width,this.height=this.image.height,b&&(this.coordinates=b),c&&c(),this._finishLoading())})}loaded(){return this._loaded}updateImage(a){return this.image&&a.url&&(this.options.url=a.url,this.load(a.coordinates,()=>{this.texture=null})),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new a.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(a){this.map=a,this.load()}setCoordinates(b){this.coordinates=b,delete this._boundsArray;const c=b.map(a.MercatorCoordinate.fromLngLat);return this.tileID=function(i){let b=1/0,c=1/0,d=-1/0,e=-1/0;for(const f of i)b=Math.min(b,f.x),c=Math.min(c,f.y),d=Math.max(d,f.x),e=Math.max(e,f.y);const g=Math.max(0,Math.floor(-Math.log(Math.max(d-b,e-c))/Math.LN2)),h=Math.pow(2,g);return new a.CanonicalTileID(g,Math.floor((b+d)/2*h),Math.floor((c+e)/2*h))}(c),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new a.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){delete this._boundsArray}_makeBoundsArray(){const f=a.tileTransform(this.tileID,this.map.transform.projection),[b,c,d,e]=this.coordinates.map(b=>{const c=f.projection.project(b[0],b[1]);return a.getTilePoint(f,c)._round()});return this.perspectiveTransform=function(c,d,f,g,h,i,j,k,l,m){const e=ae(0,0,c,0,0,d,c,d),b=ae(f,g,h,i,j,k,l,m);return a.multiply(b,a.adjoint(e,e),b),[b[6]/b[8]*c/a.EXTENT,b[7]/b[8]*d/a.EXTENT,]}(this.width,this.height,b.x,b.y,c.x,c.y,e.x,e.y,d.x,d.y),this._boundsArray=new a.StructArrayLayout4i8,this._boundsArray.emplaceBack(b.x,b.y,0,0),this._boundsArray.emplaceBack(c.x,c.y,a.EXTENT,0),this._boundsArray.emplaceBack(e.x,e.y,0,a.EXTENT),this._boundsArray.emplaceBack(d.x,d.y,a.EXTENT,a.EXTENT),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const b=this.map.painter.context,c=b.gl;for(const e in this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=b.createVertexBuffer(this._boundsArray,a.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=a.SegmentVector.simpleSegment(0,0,4,2)),this.texture||(this.texture=new a.Texture(b,this.image,c.RGBA),this.texture.bind(c.LINEAR,c.CLAMP_TO_EDGE)),this.tiles){const d=this.tiles[e];"loaded"!==d.state&&(d.state="loaded",d.texture=this.texture)}}loadTile(a,b){this.tileID&&this.tileID.equals(a.tileID.canonical)?(this.tiles[String(a.tileID.wrap)]=a,a.buckets={},b(null)):(a.state="errored",b(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const af={vector:class extends a.Evented{constructor(c,b,d,e){if(super(),this.id=c,this.dispatcher=d,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,a.extend(this,a.pick(b,["url","scheme","tileSize","promoteId",])),this._options=a.extend({type:"vector"},b),this._collectResourceTiming=b.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(e),this._tileWorkers={},this._deduped=new a.DedupedRequest}load(){this._loaded=!1,this.fire(new a.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=ab(this._options,this.map._requestManager,(c,b)=>{this._tileJSONRequest=null,this._loaded=!0,c?this.fire(new a.ErrorEvent(c)):b&&(a.extend(this,b),b.bounds&&(this.tileBounds=new ac(b.bounds,this.minzoom,this.maxzoom)),a.postTurnstileEvent(b.tiles,this.map._requestManager._customAccessToken),this.fire(new a.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new a.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}hasTile(a){return!this.tileBounds||this.tileBounds.contains(a.canonical)}onAdd(a){this.map=a,this.load()}setSourceProperty(a){this._tileJSONRequest&&this._tileJSONRequest.cancel(),a();const b=this.map.style._getSourceCaches(this.id);for(const c of b)c.clearTiles();this.load()}setTiles(a){return this.setSourceProperty(()=>{this._options.tiles=a}),this}setUrl(a){return this.setSourceProperty(()=>{this.url=a,this._options.url=a}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return a.extend({},this._options)}loadTile(b,e){const d=this.map._requestManager.normalizeTileURL(b.tileID.canonical.url(this.tiles,this.scheme)),c={request:this.map._requestManager.transformRequest(d,a.ResourceType.Tile),data:void 0,uid:b.uid,tileID:b.tileID,tileZoom:b.tileZoom,zoom:b.tileID.overscaledZ,tileSize:this.tileSize*b.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:a.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:b.isSymbolTile};if(c.request.collectResourceTiming=this._collectResourceTiming,b.actor&&"expired"!==b.state)"loading"===b.state?b.reloadCallback=e:b.request=b.actor.send("reloadTile",c,g.bind(this));else if(b.actor=this._tileWorkers[d]=this._tileWorkers[d]||this.dispatcher.getActor(),this.dispatcher.ready)b.request=b.actor.send("loadTile",c,g.bind(this),void 0,!0);else{const f=a.loadVectorTile.call({deduped:this._deduped},c,(d,a)=>{d||!a?g.call(this,d):(c.data={cacheControl:a.cacheControl,expires:a.expires,rawData:a.rawData.slice(0)},b.actor&&b.actor.send("loadTile",c,g.bind(this),void 0,!0))},!0);b.request={cancel:f}}function g(d,c){return delete b.request,b.aborted?e(null):d&&404!==d.status?e(d):(c&&c.resourceTiming&&(b.resourceTiming=c.resourceTiming),this.map._refreshExpiredTiles&&c&&b.setExpiryData(c),b.loadVectorData(c,this.map.painter),a.cacheEntryPossiblyAdded(this.dispatcher),e(null),void(b.reloadCallback&&(this.loadTile(b,b.reloadCallback),b.reloadCallback=null)))}}abortTile(a){a.request&&(a.request.cancel(),delete a.request),a.actor&&a.actor.send("abortTile",{uid:a.uid,type:this.type,source:this.id})}unloadTile(a){a.unloadVectorData(),a.actor&&a.actor.send("removeTile",{uid:a.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}},raster:r,"raster-dem":class extends r{constructor(c,b,d,e){super(c,b,d,e),this.type="raster-dem",this.maxzoom=22,this._options=a.extend({type:"raster-dem"},b),this.encoding=b.encoding||"mapbox"}loadTile(b,d){const c=this.map._requestManager.normalizeTileURL(b.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function e(a,c){a&&(b.state="errored",d(a)),c&&(b.dem=c,b.dem.onDeserialize(),b.needsHillshadePrepare=!0,b.needsDEMTextureUpload=!0,b.state="loaded",d(null))}b.request=a.getImage(this.map._requestManager.transformRequest(c,a.ResourceType.Tile),(function(g,c,h,i){if(delete b.request,b.aborted)b.state="unloaded",d(null);else if(g)b.state="errored",d(g);else if(c){this.map._refreshExpiredTiles&&b.setExpiryData({cacheControl:h,expires:i});const j=a.window.ImageBitmap&&c instanceof a.window.ImageBitmap&&(null==ad&&(ad=a.window.OffscreenCanvas&&new a.window.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof a.window.createImageBitmap),ad),f=1-(c.width-a.prevPowerOfTwo(c.width))/2;f<1||b.neighboringTiles||(b.neighboringTiles=this._getNeighboringTiles(b.tileID));const k=j?c:a.exported.getImageData(c,f),l={uid:b.uid,coord:b.tileID,source:this.id,rawImageData:k,encoding:this.encoding,padding:f};b.actor&&"expired"!==b.state||(b.actor=this.dispatcher.getActor(),b.actor.send("loadDEMTile",l,e.bind(this),void 0,!0))}}).bind(this))}_getNeighboringTiles(c){const b=c.canonical,e=Math.pow(2,b.z),f=(b.x-1+e)%e,g=0===b.x?c.wrap-1:c.wrap,h=(b.x+1+e)%e,i=b.x+1===e?c.wrap+1:c.wrap,d={};return d[new a.OverscaledTileID(c.overscaledZ,g,b.z,f,b.y).key]={backfilled:!1},d[new a.OverscaledTileID(c.overscaledZ,i,b.z,h,b.y).key]={backfilled:!1},b.y>0&&(d[new a.OverscaledTileID(c.overscaledZ,g,b.z,f,b.y-1).key]={backfilled:!1},d[new a.OverscaledTileID(c.overscaledZ,c.wrap,b.z,b.x,b.y-1).key]={backfilled:!1},d[new a.OverscaledTileID(c.overscaledZ,i,b.z,h,b.y-1).key]={backfilled:!1}),b.y+1{if(this._loaded=!0,this._pendingLoad=null,c)this.fire(new a.ErrorEvent(c));else{const d={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&b&&b.resourceTiming&&b.resourceTiming[this.id]&&(d.resourceTiming=b.resourceTiming[this.id]),this.fire(new a.Event("data",d)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)})}loaded(){return this._loaded}loadTile(b,d){const c=b.actor?"reloadTile":"loadTile";b.actor=this.actor,b.request=this.actor.send(c,{type:this.type,uid:b.uid,tileID:b.tileID,tileZoom:b.tileZoom,zoom:b.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:a.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},(a,e)=>(delete b.request,b.unloadVectorData(),b.aborted?d(null):a?d(a):(b.loadVectorData(e,this.map.painter,"reloadTile"===c),d(null))),void 0,"loadTile"===c)}abortTile(a){a.request&&(a.request.cancel(),delete a.request),a.aborted=!0}unloadTile(a){a.unloadVectorData(),this.actor.send("removeTile",{uid:a.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return a.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends s{constructor(b,a,c,d){super(b,a,c,d),this.roundZoom=!0,this.type="video",this.options=a}load(){this._loaded=!1;const b=this.options;for(const c of(this.urls=[],b.urls))this.urls.push(this.map._requestManager.transformRequest(c,a.ResourceType.Source).url);a.getVideo(this.urls,(b,c)=>{this._loaded=!0,b?this.fire(new a.ErrorEvent(b)):c&&(this.video=c,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(c){if(this.video){const b=this.video.seekable;cb.end(0)?this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${b.start(0)} and ${b.end(0)}-second mark.`))):this.video.currentTime=c}}getVideo(){return this.video}onAdd(a){this.map||(this.map=a,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 c=this.map.painter.context,b=c.gl;for(const e in this.texture?this.video.paused||(this.texture.bind(b.LINEAR,b.CLAMP_TO_EDGE),b.texSubImage2D(b.TEXTURE_2D,0,0,0,b.RGBA,b.UNSIGNED_BYTE,this.video)):(this.texture=new a.Texture(c,this.video,b.RGBA),this.texture.bind(b.LINEAR,b.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=c.createVertexBuffer(this._boundsArray,a.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=a.SegmentVector.simpleSegment(0,0,4,2)),this.tiles){const d=this.tiles[e];"loaded"!==d.state&&(d.state="loaded",d.texture=this.texture)}}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:s,canvas:class extends s{constructor(c,b,d,e){super(c,b,d,e),b.coordinates?Array.isArray(b.coordinates)&&4===b.coordinates.length&&!b.coordinates.some(a=>!Array.isArray(a)||2!==a.length||a.some(a=>"number"!=typeof a))||this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${c}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${c}`,null,'missing required property "coordinates"'))),b.animate&&"boolean"!=typeof b.animate&&this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${c}`,null,'optional "animate" property must be a boolean value'))),b.canvas?"string"==typeof b.canvas||b.canvas instanceof a.window.HTMLCanvasElement||this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${c}`,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 a.ErrorEvent(new a.ValidationError(`sources.${c}`,null,'missing required property "canvas"'))),this.options=b,this.animate=void 0===b.animate||b.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof a.window.HTMLCanvasElement?this.options.canvas:a.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new a.ErrorEvent(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(a){this.map=a,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let b=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,b=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,b=!0),this._hasInvalidDimensions()||0===Object.keys(this.tiles).length)return;const c=this.map.painter.context,e=c.gl;for(const f in this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=c.createVertexBuffer(this._boundsArray,a.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=a.SegmentVector.simpleSegment(0,0,4,2)),this.texture?(b||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new a.Texture(c,this.canvas,e.RGBA,{premultiply:!0}),this.tiles){const d=this.tiles[f];"loaded"!==d.state&&(d.state="loaded",d.texture=this.texture)}}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const a of[this.canvas.width,this.canvas.height,])if(isNaN(a)||a<=0)return!0;return!1}}},ag=function(c,d,e,f){const b=new af[d.type](c,d,e,f);if(b.id!==c)throw new Error(`Expected Source id to be ${c} instead of ${b.id}`);return a.bindAll(["load","abort","unload","serialize","prepare",],b),b};function ah(c,d){const b=a.identity([]);return a.scale(b,b,[.5*c.width,-(.5*c.height),1,]),a.translate(b,b,[1,-1,0]),a.multiply$1(b,b,c.calculateProjMatrix(d.toUnwrapped()))}function ai(b,g,h,i,j,k,l,d=!1){const e=b.tilesIn(i,l,d);e.sort(ak);const f=[];for(const a of e)f.push({wrappedTileID:a.tile.tileID.wrapped().key,queryResults:a.tile.queryRenderedFeatures(g,h,b._state,a,j,k,ah(b.transform,a.tile.tileID),d)});const c=function(j){const b={},d={};for(const e of j){const f=e.queryResults,g=e.wrappedTileID,h=d[g]=d[g]||{};for(const a in f){const k=f[a],i=h[a]=h[a]||{},l=b[a]=b[a]||[];for(const c of k)i[c.featureIndex]||(i[c.featureIndex]=!0,l.push(c))}}return b}(f);for(const m in c)c[m].forEach(c=>{const a=c.feature,d=b.getFeatureState(a.layer["source-layer"],a.id);a.source=a.layer.source,a.layer["source-layer"]&&(a.sourceLayer=a.layer["source-layer"]),a.state=d});return c}function aj(g,h){const b=g.getRenderableIds().map(a=>g.getTileByID(a)),c=[],d={};for(let a=0;a{a.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[am]}numActive(){return Object.keys(this.active).length}}let an;function ao(){return an||(an=new e),an}function ap(c,e){const d={};for(const b in c)"ref"!==b&&(d[b]=c[b]);return a.refProperties.forEach(a=>{a in e&&(d[a]=e[a])}),d}function aq(a){a=a.slice();const d=Object.create(null);for(let c=0;c0?(e-g)/h:0;return this.points[f].mult(1-i).add(this.points[b].mult(i))}}class az{constructor(a,b,c){const e=this.boxCells=[],f=this.circleCells=[];this.xCellCount=Math.ceil(a/c),this.yCellCount=Math.ceil(b/c);for(let d=0;dthis.width||i<0||g>this.height)return!d&&[];const a=[];if(f<=0&&g<=0&&this.width<=h&&this.height<=i){if(d)return!0;for(let b=0;b0:a}_queryCircle(b,c,a,d,j){const f=b-a,g=b+a,h=c-a,i=c+a;if(g<0||f>this.width||i<0||h>this.height)return!d&&[];const e=[];return this._forEachCell(f,h,g,i,this._queryCellCircle,e,{hitTest:d,circle:{x:b,y:c,radius:a},seenUids:{box:{},circle:{}}},j),d?e.length>0:e}query(a,b,c,d,e){return this._query(a,b,c,d,!1,e)}hitTest(a,b,c,d,e){return this._query(a,b,c,d,!0,e)}hitTestCircle(a,b,c,d){return this._queryCircle(a,b,c,!0,d)}_queryCell(l,m,n,o,p,g,k,h){const i=k.seenUids,q=this.boxCells[p];if(null!==q){const a=this.bboxes;for(const e of q)if(!i.box[e]){i.box[e]=!0;const b=4*e;if(l<=a[b+2]&&m<=a[b+3]&&n>=a[b+0]&&o>=a[b+1]&&(!h||h(this.boxKeys[e]))){if(k.hitTest)return g.push(!0),!0;g.push({key:this.boxKeys[e],x1:a[b],y1:a[b+1],x2:a[b+2],y2:a[b+3]})}}}const r=this.circleCells[p];if(null!==r){const c=this.circles;for(const f of r)if(!i.circle[f]){i.circle[f]=!0;const d=3*f;if(this._circleAndRectCollide(c[d],c[d+1],c[d+2],l,m,n,o)&&(!h||h(this.circleKeys[f]))){if(k.hitTest)return g.push(!0),!0;{const s=c[d],t=c[d+1],j=c[d+2];g.push({key:this.circleKeys[f],x1:s-j,y1:t-j,x2:s+j,y2:t+j})}}}}}_queryCellCircle(o,p,q,r,j,k,l,b){const a=l.circle,c=l.seenUids,m=this.boxCells[j];if(null!==m){const d=this.bboxes;for(const e of m)if(!c.box[e]){c.box[e]=!0;const f=4*e;if(this._circleAndRectCollide(a.x,a.y,a.radius,d[f+0],d[f+1],d[f+2],d[f+3])&&(!b||b(this.boxKeys[e])))return k.push(!0),!0}}const n=this.circleCells[j];if(null!==n){const h=this.circles;for(const g of n)if(!c.circle[g]){c.circle[g]=!0;const i=3*g;if(this._circlesCollide(h[i],h[i+1],h[i+2],a.x,a.y,a.radius)&&(!b||b(this.circleKeys[g])))return k.push(!0),!0}}}_forEachCell(c,d,e,f,g,h,i,j){const k=this._convertToXCellCoord(c),l=this._convertToYCellCoord(d),m=this._convertToXCellCoord(e),n=this._convertToYCellCoord(f);for(let a=k;a<=m;a++)for(let b=l;b<=n;b++)if(g.call(this,c,d,e,f,this.xCellCount*b+a,h,i,j))return}_convertToXCellCoord(a){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(a*this.xScale)))}_convertToYCellCoord(a){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(a*this.yScale)))}_circlesCollide(d,e,f,g,h,i){const a=g-d,b=h-e,c=f+i;return c*c>a*a+b*b}_circleAndRectCollide(j,k,a,f,g,l,m){const b=(l-f)/2,d=Math.abs(j-(f+b));if(d>b+a)return!1;const c=(m-g)/2,e=Math.abs(k-(g+c));if(e>c+a)return!1;if(d<=b||e<=c)return!0;const h=d-b,i=e-c;return h*h+i*i<=a*a}}const aA=Math.tan(85*Math.PI/180);function aB(e,f,g,h,c,i){let b=a.create();if(g){if("globe"===c.projection.name)b=a.calculateGlobeMatrix(c,c.worldSize/c._projectionScaler,[0,0]),a.multiply$1(b,b,a.globeDenormalizeECEF(a.globeTileBounds(f)));else{const d=C([],i);b[0]=d[0],b[1]=d[1],b[4]=d[2],b[5]=d[3]}h||a.rotateZ(b,b,c.angle)}else a.multiply$1(b,c.labelPlaneMatrix,e);return b}function aC(g,j,h,i,f,b){if(h){if("globe"===f.projection.name){const c=aB(g,j,h,i,f,b);return a.invert(c,c),a.multiply$1(c,g,c),c}{const d=a.clone(g),e=a.identity([]);return e[0]=b[0],e[1]=b[1],e[4]=b[2],e[5]=b[3],a.multiply$1(d,d,e),i||a.rotateZ(d,d,-f.angle),d}}return f.glCoordMatrix}function aD(d,e,f=0){const b=[d.x,d.y,f,1];f?a.transformMat4$1(b,b,e):aP(b,b,e);const c=b[3];return{point:new a.pointGeometry(b[0]/c,b[1]/c),signedDistanceFromCamera:c}}function aE(a,b){return Math.min(.5+a/b*.5,1.5)}function aF(a,b){const c=a[0]/a[3],d=a[1]/a[3];return c>= -b[0]&&c<=b[0]&&d>= -b[1]&&d<=b[1]}function aG(c,m,e,i,n,x,y,z,o,p){const q=e.transform,A=i?c.textSizeData:c.iconSizeData,G=a.evaluateSizeForZoom(A,e.transform.zoom),H=[256/e.width*2+1,256/e.height*2+1,],d=i?c.text.dynamicLayoutVertexArray:c.icon.dynamicLayoutVertexArray;d.clear();const B=c.lineVertexArray,r=i?c.text.placedSymbolArray:c.icon.placedSymbolArray,C=e.transform.width/e.transform.height;let f=!1;for(let g=0;gMath.abs(c.x-b.x)*e?{useVertical:!0}:d.writingMode===a.WritingMode.vertical?b.yaA}(b,c,e)?1===d.flipState?{needsFlipping:!0}:null:b.x>c.x?{needsFlipping:!0}:null}function aJ(b,E,c,v,m,n,w,o,d,F,p,e,q,x,r,i,j){const f=E/24,s=b.lineOffsetX*f,t=b.lineOffsetY*f;let g;if(b.numGlyphs>1){const G=b.glyphStartIndex+b.numGlyphs,H=b.lineStartIndex,I=b.lineStartIndex+b.lineLength,h=aH(f,o,s,t,c,p,e,b,d,n,q,r,!1,i,j);if(!h)return{notEnoughRoom:!0};const J=aD(h.first.point,w).point,K=aD(h.last.point,w).point;if(v&&!c){const k=aI(b,J,K,x);if(b.flipState=k&&k.needsFlipping?1:2,k)return k}g=[h.first];for(let u=b.glyphStartIndex+1;u0?B.point:aL(e,A,y,1,m,void 0,i,j.canonical),x);if(b.flipState=l&&l.needsFlipping?1:2,l)return l}const C=aM(f*o.getoffsetX(b.glyphStartIndex),s,t,c,p,e,b.segment,b.lineStartIndex,b.lineStartIndex+b.lineLength,d,n,q,r,!1,!1,i,j);if(!C)return{notEnoughRoom:!0};g=[C]}for(const D of g)a.addDynamicAttributes(F,D.point,D.angle);return{}}function aK(c,g,e,h,f){const b=h.projectTilePoint(c.x,c.y,g);if(!f)return aD(b,e,b.z);const d=f(c);return aD(new a.pointGeometry(b.x+d[0],b.y+d[1]),e,b.z+d[2])}function aL(a,d,b,e,f,g,h,i){const j=aK(a.add(a.sub(d)._unit()),i,f,h,g).point,c=b.sub(j);return b.add(c._mult(e/c.mag()))}function aM(p,q,r,s,t,D,u,k,E,f,F,j,v,w,G,H,I){const x=s?p-q:p+q;let h=x>0?1:-1,l=0;s&&(h*=-1,l=Math.PI),h<0&&(l+=Math.PI);let b=h>0?k+u:k+u+1,c=t,e=t,m=0,i=0;const y=Math.abs(x),n=[],g=[];let d=D;const J=()=>{const c=b-h;return 0===m?D:new a.pointGeometry(f.getx(c),f.gety(c))},z=()=>aL(J(),d,e,y-m+1,F,v,H,I.canonical);for(;m+i<=y;){if((b+=h)=E)return null;if(e=c,n.push(c),w&&g.push(d||J()),void 0===(c=j[b])){d=new a.pointGeometry(f.getx(b),f.gety(b));const A=aK(d,I.canonical,F,H,v);c=A.signedDistanceFromCamera>0?j[b]=A.point:z()}else d=null;m+=i,i=e.dist(c)}G&&v&&(d=d||new a.pointGeometry(f.getx(b),f.gety(b)),j[b]=c=void 0===j[b]?c:z(),i=e.dist(c));const B=(y-m)/i,C=c.sub(e),o=C.mult(B)._add(e);r&&o._add(C._unit()._perp()._mult(r*h));const K=l+Math.atan2(c.y-e.y,c.x-e.x);return n.push(o),w&&(d=d||new a.pointGeometry(f.getx(b),f.gety(b)),g.push(function(c,d,b){const e=1-b;return new a.pointGeometry(c.x*e+d.x*b,c.y*e+d.y*b)}(g.length>0?g[g.length-1]:d,d,B))),{point:o,angle:K,path:n,tilePath:g}}const aN=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,]);function aO(d,a){for(let b=0;ba.sortKey-b.sortKey));this._currentPartIndex[0,0,0],I=new a.pointGeometry(f.tileAnchorX,f.tileAnchorY),r=this.transform.projection.projectTilePoint(f.tileAnchorX,f.tileAnchorY,l.canonical),s=H(I),g=[r.x+s[0],r.y+s[1],r.z+s[2]],t=this.projectAndGetPerspectiveRatio(V,g[0],g[1],g[2],l),{perspectiveRatio:u}=t,v=(q?D/u:D*u)/a.ONE_EM,_=aD(new a.pointGeometry(g[0],g[1]),E,g[2]).point,w=t.signedDistanceFromCamera>0?aH(v,U,f.lineOffsetX*v,f.lineOffsetY*v,!1,_,I,f,T,E,{},k&&!q?H:null,q&&!!k,this.transform.projection,l):null;let m=!1,x=!1,y=!0;if(w&&!t.aboveHorizon){const c=.5*Y*u+Z,h=new a.pointGeometry(-100,-100),i=new a.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),n=new ay,J=w.first,K=w.last;let b=[];for(let z=J.path.length-1;z>=1;z--)b.push(J.path[z]);for(let A=1;A{const c=H(aaD(a,W));b=L.some(a=>a.signedDistanceFromCamera<=0)?[]:L.map(a=>a.point)}let M=[];if(b.length>0){const d=b[0].clone(),e=b[0].clone();for(let j=1;j=h.x&&e.x<=i.x&&d.y>=h.y&&e.y<=i.y?[b]:e.xi.x||e.yi.y?[]:a.clipLine([b],h.x,h.y,i.x,i.y)}for(const ab of M){n.reset(ab,.25*c);let B=0;B=n.length<=.5*c?1:Math.ceil(n.paddedLength/aa)+1;for(let C=0;C0){a.transformMat4$1(b,b,d);let i=!1;this.fogState&&g&&(i=function(d,e,f,g,h,b){const i=b.calculateFogTileMatrix(h),c=[e,f,g];return a.transformMat4(c,c,i),Q(d,c,b.pitch,b._fov)}(this.fogState,e,f,c||0,g.toUnwrapped(),this.transform)>.9),h=b[2]>b[3]||i}else aP(b,b,d);return{point:new a.pointGeometry((b[0]/b[3]+1)/2*this.transform.width+100,(-b[1]/b[3]+1)/2*this.transform.height+100),perspectiveRatio:Math.min(.5+this.transform.cameraToCenterDistance/b[3]*.5,1.5),signedDistanceFromCamera:b[3],aboveHorizon:h}}isOffscreen(a,b,c,d){return c<100||a>=this.screenRightBoundary||d<100||b>this.screenBottomBoundary}isInsideGrid(a,b,c,d){return c>=0&&a=0&&ba.collisionGroupID===b}}return this.collisionGroups[a]}}(e),this.collisionCircleArrays={},this.prevPlacement=b,b&&(b.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(h,d,b,q){const c=b.getBucket(d),i=b.latestFeatureIndex;if(!c||!i||d.id!==c.layerIds[0])return;const e=c.layers[0].layout,r=b.collisionBoxArray,s=Math.pow(2,this.transform.zoom-b.tileID.overscaledZ),t=b.tileSize/a.EXTENT,j=b.tileID.toUnwrapped(),f=this.transform.calculateProjMatrix(j),g="map"===e.get("text-pitch-alignment"),k="map"===e.get("text-rotation-alignment");d.compileFilter();const l=d.dynamicFilter(),u=d.dynamicFilterNeedsFeature(),m=this.transform.calculatePixelsToTileUnitsMatrix(b),v=aB(f,b.tileID.canonical,g,k,this.transform,m);let n=null;if(g){const w=aC(f,b.tileID.canonical,g,k,this.transform,m);n=a.multiply$1([],this.transform.labelPlaneMatrix,w)}let o=null;l&&b.latestFeatureIndex&&(o={unwrappedTileID:j,dynamicFilter:l,dynamicFilterNeedsFeature:u,featureIndex:b.latestFeatureIndex}),this.retainedQueryData[c.bucketInstanceId]=new aU(c.bucketInstanceId,i,c.sourceLayerIndex,c.index,b.tileID);const p={bucket:c,layout:e,posMatrix:f,textLabelPlaneMatrix:v,labelToScreenMatrix:n,clippingData:o,scale:s,textPixelRatio:t,holdingForFade:b.holdingForFade(),collisionBoxArray:r,partiallyEvaluatedTextSize:a.evaluateSizeForZoom(c.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:a.evaluateSizeForZoom(c.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(c.sourceID)};if(q)for(const x of c.sortKeyRanges){const{sortKey:y,symbolInstanceStart:z,symbolInstanceEnd:A}=x;h.push({sortKey:y,symbolInstanceStart:z,symbolInstanceEnd:A,parameters:p})}else h.push({symbolInstanceStart:0,symbolInstanceEnd:c.symbolInstances.length,parameters:p})}attemptAnchorPlacement(d,s,g,h,e,i,j,k,l,m,n,a,t,c,f,o,v,u){const p=[a.textOffset0,a.textOffset1],b=aV(d,g,h,p,e),q=this.collisionIndex.placeCollisionBox(e,s,aW(b.x,b.y,i,j,this.transform.angle),n,k,l,m.predicate);if((!o||0!==this.collisionIndex.placeCollisionBox(c.getSymbolInstanceIconSize(u,this.transform.zoom,t),o,aW(b.x,b.y,i,j,this.transform.angle),n,k,l,m.predicate).box.length)&&q.box.length>0){let r;return this.prevPlacement&&this.prevPlacement.variableOffsets[a.crossTileID]&&this.prevPlacement.placements[a.crossTileID]&&this.prevPlacement.placements[a.crossTileID].text&&(r=this.prevPlacement.variableOffsets[a.crossTileID].anchor),this.variableOffsets[a.crossTileID]={textOffset:p,width:g,height:h,anchor:d,textScale:e,prevAnchor:r},this.markUsedJustification(c,d,a,f),c.allowVerticalPlacement&&(this.markUsedOrientation(c,f,a),this.placedOrientations[a.crossTileID]=f),{shift:b,placedGlyphBoxes:q}}}placeLayerBucketPart(e,t,i,o){const{bucket:b,layout:c,posMatrix:p,textLabelPlaneMatrix:u,labelToScreenMatrix:v,clippingData:w,textPixelRatio:x,holdingForFade:y,collisionBoxArray:f,partiallyEvaluatedTextSize:z,partiallyEvaluatedIconSize:A,collisionGroup:B}=e.parameters,q=c.get("text-optional"),r=c.get("icon-optional"),j=c.get("text-allow-overlap"),k=c.get("icon-allow-overlap"),C="map"===c.get("text-rotation-alignment"),D="map"===c.get("text-pitch-alignment"),E="none"!==c.get("icon-text-fit"),s="viewport-y"===c.get("symbol-z-order"),F=j&&(k||!b.hasIconData()||r),G=k&&(j||!b.hasTextData()||q);!b.collisionArrays&&f&&b.deserializeCollisionBoxes(f),i&&o&&b.updateCollisionDebugBuffers(this.transform.zoom,f);const l=(d,ac,f)=>{if(w){const $={zoom:this.transform.zoom,pitch:this.transform.pitch};let N=null;if(w.dynamicFilterNeedsFeature){const O=this.retainedQueryData[b.bucketInstanceId];N=w.featureIndex.loadFeature({featureIndex:d.featureIndex,bucketIndex:O.bucketIndex,sourceLayerIndex:O.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,w.dynamicFilter)($,N,this.retainedQueryData[b.bucketInstanceId].tileID.canonical,new a.pointGeometry(d.tileAnchorX,d.tileAnchorY),this.transform.calculateDistanceTileData(w.unwrappedTileID)))return this.placements[d.crossTileID]=new aS(!1,!1,!1,!0),void(t[d.crossTileID]=!0)}if(t[d.crossTileID])return;if(y)return void(this.placements[d.crossTileID]=new aS(!1,!1,!1));let e=!1,l=!1,n=!0,ad=null,h={box:null,offscreen:null},s={box:null,offscreen:null},m=null,g=null,H=null,J=0,K=0,P=0;f.textFeatureIndex?J=f.textFeatureIndex:d.useRuntimeCollisionCircles&&(J=d.featureIndex),f.verticalTextFeatureIndex&&(K=f.verticalTextFeatureIndex);const _=a=>{a.tileID=this.retainedQueryData[b.bucketInstanceId].tileID,(this.transform.elevation||a.elevation)&&(a.elevation=this.transform.elevation?this.transform.elevation.getAtTileOffset(this.retainedQueryData[b.bucketInstanceId].tileID,a.tileAnchorX,a.tileAnchorY):0)},Q=f.textBox;if(Q){_(Q);const R=f=>{let c=a.WritingMode.horizontal;if(b.allowVerticalPlacement&&!f&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[d.crossTileID];e&&(this.placedOrientations[d.crossTileID]=e,c=e,this.markUsedOrientation(b,c,d))}return c},S=(c,e)=>{if(b.allowVerticalPlacement&&d.numVerticalGlyphVertices>0&&f.verticalTextBox){for(const g of b.writingModes)if(g===a.WritingMode.vertical?s=h=e():h=c(),h&&h.box&&h.box.length)break}else h=c()};if(c.get("text-variable-anchor")){let L=c.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[d.crossTileID]){const T=this.prevPlacement.variableOffsets[d.crossTileID];L.indexOf(T.anchor)>0&&(L=L.filter(a=>a!==T.anchor)).unshift(T.anchor)}const ae=(a,l,m)=>{const g=b.getSymbolInstanceTextSize(z,d,this.transform.zoom,ac),n=(a.x2-a.x1)*g+2*a.padding,o=(a.y2-a.y1)*g+2*a.padding,h=E&&!k?l:null;h&&_(h);let c={box:[],offscreen:!1};const q=j?2*L.length:L.length;for(let f=0;f=L.length,d,ac,b,m,h,z,A);if(i&&(c=i.placedGlyphBoxes)&&c.box&&c.box.length){e=!0,ad=i.shift;break}}return c};S(()=>ae(Q,f.iconBox,a.WritingMode.horizontal),()=>{const c=f.verticalTextBox;return c&&_(c),b.allowVerticalPlacement&&!(h&&h.box&&h.box.length)&&d.numVerticalGlyphVertices>0&&c?ae(c,f.verticalIconBox,a.WritingMode.vertical):{box:null,offscreen:null}}),h&&(e=h.box,n=h.offscreen);const aa=R(h&&h.box);if(!e&&this.prevPlacement){const M=this.prevPlacement.variableOffsets[d.crossTileID];M&&(this.variableOffsets[d.crossTileID]=M,this.markUsedJustification(b,M.anchor,d,aa))}}else{const af=(f,e)=>{const g=b.getSymbolInstanceTextSize(z,d,this.transform.zoom,ac),c=this.collisionIndex.placeCollisionBox(g,f,new a.pointGeometry(0,0),j,x,p,B.predicate);return c&&c.box&&c.box.length&&(this.markUsedOrientation(b,e,d),this.placedOrientations[d.crossTileID]=e),c};S(()=>af(Q,a.WritingMode.horizontal),()=>{const c=f.verticalTextBox;return b.allowVerticalPlacement&&d.numVerticalGlyphVertices>0&&c?(_(c),af(c,a.WritingMode.vertical)):{box:null,offscreen:null}}),R(h&&h.box&&h.box.length)}}if(e=(m=h)&&m.box&&m.box.length>0,n=m&&m.offscreen,d.useRuntimeCollisionCircles){const U=b.text.placedSymbolArray.get(d.centerJustifiedTextSymbolIndex>=0?d.centerJustifiedTextSymbolIndex:d.verticalPlacedTextSymbolIndex),V=a.evaluateSizeForFeature(b.textSizeData,z,U),ab=c.get("text-padding");g=this.collisionIndex.placeCollisionCircles(j,U,b.lineVertexArray,b.glyphOffsetArray,V,p,u,v,i,D,B.predicate,d.collisionCircleDiameter*V/a.ONE_EM,ab,this.retainedQueryData[b.bucketInstanceId].tileID),e=j||g.circles.length>0&&!g.collisionDetected,n=n&&g.offscreen}if(f.iconFeatureIndex&&(P=f.iconFeatureIndex),f.iconBox){const W=c=>{_(c);const d=E&&ad?aW(ad.x,ad.y,C,D,this.transform.angle):new a.pointGeometry(0,0),e=b.getSymbolInstanceIconSize(A,this.transform.zoom,ac);return this.collisionIndex.placeCollisionBox(e,c,d,k,x,p,B.predicate)};l=s&&s.box&&s.box.length&&f.verticalIconBox?(H=W(f.verticalIconBox)).box.length>0:(H=W(f.iconBox)).box.length>0,n=n&&H.offscreen}const X=q||0===d.numHorizontalGlyphVertices&&0===d.numVerticalGlyphVertices,Y=r||0===d.numIconVertices;if(X||Y?Y?X||(l=l&&e):e=l&&e:l=e=l&&e,e&&m&&m.box&&this.collisionIndex.insertCollisionBox(m.box,c.get("text-ignore-placement"),b.bucketInstanceId,s&&s.box&&K?K:J,B.ID),l&&H&&this.collisionIndex.insertCollisionBox(H.box,c.get("icon-ignore-placement"),b.bucketInstanceId,P,B.ID),g&&(e&&this.collisionIndex.insertCollisionCircles(g.circles,c.get("text-ignore-placement"),b.bucketInstanceId,J,B.ID),i)){const Z=b.bucketInstanceId;let o=this.collisionCircleArrays[Z];void 0===o&&(o=this.collisionCircleArrays[Z]=new aT);for(let I=0;I=0;--g){const h=m[g];l(b.symbolInstances.get(h),h,b.collisionArrays[h])}}else for(let d=e.symbolInstanceStart;d=0&&(e.text.placedSymbolArray.get(d).crossTileID=c>=0&&d!==c?0:b.crossTileID)}markUsedOrientation(d,b,c){const e=b===a.WritingMode.horizontal||b===a.WritingMode.horizontalOnly?b:0,f=b===a.WritingMode.vertical?b:0,g=[c.leftJustifiedTextSymbolIndex,c.centerJustifiedTextSymbolIndex,c.rightJustifiedTextSymbolIndex,];for(const h of g)d.text.placedSymbolArray.get(h).placedOrientation=e;c.verticalPlacedTextSymbolIndex&&(d.text.placedSymbolArray.get(c.verticalPlacedTextSymbolIndex).placedOrientation=f)}commit(f){this.commitTime=f,this.zoomAtLastRecencyCheck=this.transform.zoom;const a=this.prevPlacement;let c=!1;this.prevZoomAdjustment=a?a.zoomAdjustment(this.transform.zoom):0;const i=a?a.symbolFadeChange(f):1,j=a?a.opacities:{},m=a?a.variableOffsets:{},n=a?a.placedOrientations:{};for(const g in this.placements){const b=this.placements[g],h=j[g];h?(this.opacities[g]=new aR(h,i,b.text,b.icon,null,b.clipped),c=c||b.text!==h.text.placed||b.icon!==h.icon.placed):(this.opacities[g]=new aR(null,i,b.text,b.icon,b.skipFade,b.clipped),c=c||b.text||b.icon)}for(const k in j){const l=j[k];if(!this.opacities[k]){const o=new aR(l,i,!1,!1);o.isHidden()||(this.opacities[k]=o,c=c||l.text.placed||l.icon.placed)}}for(const d in m)this.variableOffsets[d]||!this.opacities[d]||this.opacities[d].isHidden()||(this.variableOffsets[d]=m[d]);for(const e in n)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=n[e]);c?this.lastPlacementChangeTime=f:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=a?a.lastPlacementChangeTime:f)}updateLayerOpacities(c,d){const e={};for(const a of d){const b=a.getBucket(c);b&&a.latestFeatureIndex&&c.id===b.layerIds[0]&&this.updateBucketOpacities(b,e,a.collisionBoxArray)}}updateBucketOpacities(b,s,t){b.hasTextData()&&b.text.opacityVertexArray.clear(),b.hasIconData()&&b.icon.opacityVertexArray.clear(),b.hasIconCollisionBoxData()&&b.iconCollisionBox.collisionVertexArray.clear(),b.hasTextCollisionBoxData()&&b.textCollisionBox.collisionVertexArray.clear();const f=b.layers[0].layout,F=!!b.layers[0].dynamicFilter(),G=new aR(null,0,!1,!1,!0),u=f.get("text-allow-overlap"),v=f.get("icon-allow-overlap"),H=f.get("text-variable-anchor"),I="map"===f.get("text-rotation-alignment"),J="map"===f.get("text-pitch-alignment"),l="none"!==f.get("icon-text-fit"),K=new aR(null,0,u&&(v||!b.hasIconData()||f.get("icon-optional")),v&&(u||!b.hasTextData()||f.get("text-optional")),!0);!b.collisionArrays&&t&&(b.hasIconCollisionBoxData()||b.hasTextCollisionBoxData())&&b.deserializeCollisionBoxes(t);const m=(b,c,d)=>{for(let a=0;a0||y>0,A=c.numIconVertices>0,o=this.placedOrientations[c.crossTileID],p=o===a.WritingMode.vertical,j=o===a.WritingMode.horizontal||o===a.WritingMode.horizontalOnly;if(!z&&!A||d.isHidden()||w++,z){const B=aY(d.text);m(b.text,x,p?0:B),m(b.text,y,j?0:B);const L=d.text.isHidden();[c.rightJustifiedTextSymbolIndex,c.centerJustifiedTextSymbolIndex,c.leftJustifiedTextSymbolIndex,].forEach(a=>{a>=0&&(b.text.placedSymbolArray.get(a).hidden=L||p?1:0)}),c.verticalPlacedTextSymbolIndex>=0&&(b.text.placedSymbolArray.get(c.verticalPlacedTextSymbolIndex).hidden=L||j?1:0);const C=this.variableOffsets[c.crossTileID];C&&this.markUsedJustification(b,C.anchor,c,o);const q=this.placedOrientations[c.crossTileID];q&&(this.markUsedJustification(b,"left",c,q),this.markUsedOrientation(b,q,c))}if(A){const D=aY(d.icon);c.placedIconSymbolIndex>=0&&(m(b.icon,c.numIconVertices,p?0:D),b.icon.placedSymbolArray.get(c.placedIconSymbolIndex).hidden=d.icon.isHidden()),c.verticalPlacedIconSymbolIndex>=0&&(m(b.icon,c.numVerticalIconVertices,j?0:D),b.icon.placedSymbolArray.get(c.verticalPlacedIconSymbolIndex).hidden=d.icon.isHidden())}if(b.hasIconCollisionBoxData()||b.hasTextCollisionBoxData()){const g=b.collisionArrays[n];if(g){let e=new a.pointGeometry(0,0),k=!0;if(g.textBox||g.verticalTextBox){if(H){const h=this.variableOffsets[i];h?(e=aV(h.anchor,h.width,h.height,h.textOffset,h.textScale),I&&e._rotate(J?this.transform.angle:-this.transform.angle)):k=!1}F&&(k=!d.clipped),g.textBox&&aX(b.textCollisionBox.collisionVertexArray,d.text.placed,!k||p,e.x,e.y),g.verticalTextBox&&aX(b.textCollisionBox.collisionVertexArray,d.text.placed,!k||j,e.x,e.y)}const E=k&&Boolean(!j&&g.verticalIconBox);g.iconBox&&aX(b.iconCollisionBox.collisionVertexArray,d.icon.placed,E,l?e.x:0,l?e.y:0),g.verticalIconBox&&aX(b.iconCollisionBox.collisionVertexArray,d.icon.placed,!E,l?e.x:0,l?e.y:0)}}}if(b.fullyClipped=0===w,b.sortFeatures(this.transform.angle),this.retainedQueryData[b.bucketInstanceId]&&(this.retainedQueryData[b.bucketInstanceId].featureSortOrder=b.featureSortOrder),b.hasTextData()&&b.text.opacityVertexBuffer&&b.text.opacityVertexBuffer.updateData(b.text.opacityVertexArray),b.hasIconData()&&b.icon.opacityVertexBuffer&&b.icon.opacityVertexBuffer.updateData(b.icon.opacityVertexArray),b.hasIconCollisionBoxData()&&b.iconCollisionBox.collisionVertexBuffer&&b.iconCollisionBox.collisionVertexBuffer.updateData(b.iconCollisionBox.collisionVertexArray),b.hasTextCollisionBoxData()&&b.textCollisionBox.collisionVertexBuffer&&b.textCollisionBox.collisionVertexBuffer.updateData(b.textCollisionBox.collisionVertexArray),b.bucketInstanceId in this.collisionCircleArrays){const r=this.collisionCircleArrays[b.bucketInstanceId];b.placementInvProjMatrix=r.invProjMatrix,b.placementViewportMatrix=r.viewportMatrix,b.collisionCircleArray=r.circles,delete this.collisionCircleArrays[b.bucketInstanceId]}}symbolFadeChange(a){return 0===this.fadeDuration?1:(a-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(a){return Math.max(0,(this.transform.zoom-a)/1.5)}hasTransitions(a){return this.stale||a-this.lastPlacementChangeTimeb}setStale(){this.stale=!0}}(b,f,g,h,i),this._currentPlacementIndex=c.length-1,this._forceFullPlacement=d,this._showCollisionBoxes=e,this._done=!1}isDone(){return this._done}continuePlacement(d,e,f){const h=a.exported.now(),g=()=>{const b=a.exported.now()-h;return!this._forceFullPlacement&&b>2};for(;this._currentPlacementIndex>=0;){const b=e[d[this._currentPlacementIndex]],c=this.placement.collisionIndex.transform.zoom;if("symbol"===b.type&&(!b.minzoom||b.minzoom<=c)&&(!b.maxzoom||b.maxzoom>c)){if(this._inProgressLayer||(this._inProgressLayer=new aZ(b)),this._inProgressLayer.continuePlacement(f[b.source],this.placement,this._showCollisionBoxes,b,g))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(a){return this.placement.commit(a),this.placement}}const a_=512/a.EXTENT/2;class a0{constructor(d,e,f){this.tileID=d,this.indexedSymbolInstances={},this.bucketInstanceId=f;for(let a=0;aa.overscaledZ)for(const l in f){const i=f[l];i.tileID.isChildOf(a)&&i.findMatches(b.symbolInstances,a,d)}else{const j=f[a.scaledTo(Number(e)).key];j&&j.findMatches(b.symbolInstances,a,d)}}for(let g=0;g{c[a]=!0}),this.layerIndexes)c[a]||delete this.layerIndexes[a]}}const a3=(c,b)=>a.emitValidationErrors(c,b&&b.filter(a=>"source.canvas"!==a.identifier)),a4=a.pick(i,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection",]),a5=a.pick(i,["setCenter","setZoom","setBearing","setPitch",]),a6=function(){const c={},f=a.spec.$version;for(const b in a.spec.$root){const d=a.spec.$root[b];if(d.required){let e=null;null!=(e="version"===b?f:"array"===d.type?[]:{})&&(c[b]=e)}}return c}(),a7={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class c extends a.Evented{constructor(d,b={}){super(),this.map=d,this.dispatcher=new n(ao(),this),this.imageManager=new J,this.imageManager.setEventedParent(this),this.glyphManager=new a.GlyphManager(d._requestManager,b.localFontFamily?a.LocalGlyphMode.all:b.localIdeographFontFamily?a.LocalGlyphMode.ideographs:a.LocalGlyphMode.none,b.localFontFamily||b.localIdeographFontFamily),this.lineAtlas=new a.LineAtlas(256,512),this.crossTileSymbolIndex=new a2,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this.zoomHistory=new a.ZoomHistory,this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",a.getReferrer());const e=this;this._rtlTextPluginCallback=c.registerForPluginStateChange(b=>{e.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:b.pluginStatus,pluginURL:b.pluginURL},(f,b)=>{if(a.triggerPluginCompletionEvent(f),b&&b.every(a=>a))for(const g in e._sourceCaches){const c=e._sourceCaches[g],d=c.getSource().type;"vector"!==d&&"geojson"!==d||c.reload()}})}),this.on("data",a=>{if("source"!==a.dataType||"metadata"!==a.sourceDataType)return;const b=this.getSource(a.sourceId);if(b&&b.vectorLayerIds)for(const d in this._layers){const c=this._layers[d];c.source===b.id&&this._validateLayer(c)}})}loadURL(b,c={}){this.fire(new a.Event("dataloading",{dataType:"style"}));const e="boolean"==typeof c.validate?c.validate:!a.isMapboxURL(b);b=this.map._requestManager.normalizeStyleURL(b,c.accessToken);const d=this.map._requestManager.transformRequest(b,a.ResourceType.Style);this._request=a.getJSON(d,(b,c)=>{this._request=null,b?this.fire(new a.ErrorEvent(b)):c&&this._load(c,e)})}loadJSON(b,c={}){this.fire(new a.Event("dataloading",{dataType:"style"})),this._request=a.exported.frame(()=>{this._request=null,this._load(b,!1!==c.validate)})}loadEmpty(){this.fire(new a.Event("dataloading",{dataType:"style"})),this._load(a6,!1)}_updateLayerCount(a,c){const b=c?1:-1;a.is3D()&&(this._num3DLayers+=b),"circle"===a.type&&(this._numCircleLayers+=b),"symbol"===a.type&&(this._numSymbolLayers+=b)}_load(c,f){if(f&&a3(this,a.validateStyle(c)))return;for(const d in this._loaded=!0,this.stylesheet=c,this.updateProjection(),c.sources)this.addSource(d,c.sources[d],{validate:!1});this._changed=!1,c.sprite?this._loadSprite(c.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(c.glyphs);const e=aq(this.stylesheet.layers);for(let b of(this._order=e.map(a=>a.id),this._layers={},this._serializedLayers={},e))(b=a.createStyleLayer(b)).setEventedParent(this,{layer:{id:b.id}}),this._layers[b.id]=b,this._serializedLayers[b.id]=b.serialize(),this._updateLayerCount(b,!0);this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new M(this.stylesheet.light),this.stylesheet.terrain&&!this.terrainSetForDrapingOnly()&&this._createTerrain(this.stylesheet.terrain,1),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this._updateDrapeFirstLayers(),this.fire(new a.Event("data",{dataType:"style"})),this.fire(new a.Event("style.load"))}terrainSetForDrapingOnly(){return this.terrain&&0===this.terrain.drapeRenderMode}setProjection(a){a?this.stylesheet.projection=a:delete this.stylesheet.projection,this.updateProjection()}updateProjection(){const b=this.map.transform.projection,c=this.map.transform.setProjection(this.map._runtimeProjection||(this.stylesheet?this.stylesheet.projection:void 0)),a=this.map.transform.projection;if(this._loaded&&(a.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null)),this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),c){if(a.isReprojectedInTileSpace||b.isReprojectedInTileSpace)for(const d in this.map.painter.clearBackgroundTiles(),this._sourceCaches)this._sourceCaches[d].clearTiles();else this._forceSymbolLayerUpdate();this.map._update(!0)}}_loadSprite(b){this._spriteRequest=function(c,b,e){let f,g,h;const d=a.exported.devicePixelRatio>1?"@2x":"";let i=a.getJSON(b.transformRequest(b.normalizeSpriteURL(c,d,".json"),a.ResourceType.SpriteJSON),(a,b)=>{i=null,h||(h=a,f=b,k())}),j=a.getImage(b.transformRequest(b.normalizeSpriteURL(c,d,".png"),a.ResourceType.SpriteImage),(a,b)=>{j=null,h||(h=a,g=b,k())});function k(){if(h)e(h);else if(f&&g){const k=a.exported.getImageData(g),b={};for(const c in f){const{width:d,height:i,x:l,y:m,sdf:n,pixelRatio:o,stretchX:p,stretchY:q,content:r}=f[c],j=new a.RGBAImage({width:d,height:i});a.RGBAImage.copy(k,j,{x:l,y:m},{x:0,y:0},{width:d,height:i}),b[c]={data:j,pixelRatio:o,sdf:n,stretchX:p,stretchY:q,content:r}}e(null,b)}}return{cancel(){i&&(i.cancel(),i=null),j&&(j.cancel(),j=null)}}}(b,this.map._requestManager,(c,b)=>{if(this._spriteRequest=null,c)this.fire(new a.ErrorEvent(c));else if(b)for(const d in b)this.imageManager.addImage(d,b[d]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new a.Event("data",{dataType:"style"}))})}_validateLayer(c){const b=this.getSource(c.source);if(!b)return;const d=c.sourceLayer;d&&("geojson"===b.type||b.vectorLayerIds&& -1===b.vectorLayerIds.indexOf(d))&&this.fire(new a.ErrorEvent(new Error(`Source layer "${d}" does not exist on source "${b.id}" as specified by style layer "${c.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const a in this._sourceCaches)if(!this._sourceCaches[a].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(c){const a=[];for(const d of c){const b=this._layers[d];"custom"!==b.type&&a.push(b.serialize())}return a}hasTransitions(){if(this.light&&this.light.hasTransition()||this.fog&&this.fog.hasTransition())return!0;for(const a in this._sourceCaches)if(this._sourceCaches[a].hasTransition())return!0;for(const b in this._layers)if(this._layers[b].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(a){return!!this.terrain&&a7[a.type]}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}update(b){if(!this._loaded)return;const p=this._changed;if(this._changed){const g=Object.keys(this._updatedLayers),h=Object.keys(this._removedLayers);for(const d in(g.length||h.length)&&this._updateWorkerLayers(g,h),this._updatedSources){const i=this._updatedSources[d];"reload"===i?this._reloadSource(d):"clear"===i&&this._clearSource(d)}for(const q in this._updateTilesForChangedImages(),this._updatedPaintProps)this._layers[q].updateTransitions(b);this.light.updateTransitions(b),this.fog&&this.fog.updateTransitions(b),this._resetUpdates()}const e={};for(const j in this._sourceCaches){const k=this._sourceCaches[j];e[j]=k.used,k.used=!1}for(const r of this._order){const c=this._layers[r];if(c.recalculate(b,this._availableImages),!c.isHidden(b.zoom)){const l=this._getLayerSourceCache(c);l&&(l.used=!0)}const m=this.map.painter;if(m){const n=c.getProgramIds();if(!n)continue;const s=c.getProgramConfiguration(b.zoom);for(const t of n)m.useProgram(t,s)}}for(const o in e){const f=this._sourceCaches[o];e[o]!==f.used&&f.getSource().fire(new a.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:f.getSource().id}))}this.light.recalculate(b),this.terrain&&this.terrain.recalculate(b),this.fog&&this.fog.recalculate(b),this.z=b.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),p&&this.fire(new a.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const a=Object.keys(this._changedImages);if(a.length){for(const b in this._sourceCaches)this._sourceCaches[b].reloadTilesForDependencies(["icons","patterns"],a);this._changedImages={}}}_updateWorkerLayers(a,b){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(a),removedIds:b})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(b){if(this._checkLoaded(),a3(this,a.validateStyle(b)))return!1;(b=a.clone$1(b)).layers=aq(b.layers);const c=(function(c,a){if(!c)return[{command:i.setStyle,args:[a]},];let b=[];try{if(!D(c.version,a.version))return[{command:i.setStyle,args:[a]},];D(c.center,a.center)||b.push({command:i.setCenter,args:[a.center]}),D(c.zoom,a.zoom)||b.push({command:i.setZoom,args:[a.zoom]}),D(c.bearing,a.bearing)||b.push({command:i.setBearing,args:[a.bearing]}),D(c.pitch,a.pitch)||b.push({command:i.setPitch,args:[a.pitch]}),D(c.sprite,a.sprite)||b.push({command:i.setSprite,args:[a.sprite]}),D(c.glyphs,a.glyphs)||b.push({command:i.setGlyphs,args:[a.glyphs]}),D(c.transition,a.transition)||b.push({command:i.setTransition,args:[a.transition]}),D(c.light,a.light)||b.push({command:i.setLight,args:[a.light]}),D(c.fog,a.fog)||b.push({command:i.setFog,args:[a.fog]}),D(c.projection,a.projection)||b.push({command:i.setProjection,args:[a.projection]});const e={},f=[];!function(c,b,d,e){let a;for(a in b=b||{},c=c||{})c.hasOwnProperty(a)&&(b.hasOwnProperty(a)||as(a,d,e));for(a in b)b.hasOwnProperty(a)&&(c.hasOwnProperty(a)?D(c[a],b[a])||("geojson"===c[a].type&&"geojson"===b[a].type&&au(c,b,a)?d.push({command:i.setGeoJSONSourceData,args:[a,b[a].data,]}):at(a,b,d,e)):ar(a,b,d))}(c.sources,a.sources,f,e);const g=[];c.layers&&c.layers.forEach(a=>{e[a.source]?b.push({command:i.removeLayer,args:[a.id]}):g.push(a)});let d=c.terrain;d&&e[d.source]&&(b.push({command:i.setTerrain,args:[void 0]}),d=void 0),b=b.concat(f),D(d,a.terrain)||b.push({command:i.setTerrain,args:[a.terrain]}),function(m,k,f){k=k||[];const n=(m=m||[]).map(aw),j=k.map(aw),p=m.reduce(ax,{}),o=k.reduce(ax,{}),g=n.slice(),q=Object.create(null);let e,h,b,d,c,l,a;for(e=0,h=0;e!(a.command in a5));if(0===c.length)return!1;const d=c.filter(a=>!(a.command in a4));if(d.length>0)throw new Error(`Unimplemented: ${d.map(a=>a.command).join(", ")}.`);return c.forEach(a=>{"setTransition"!==a.command&&this[a.command].apply(this,a.args)}),this.stylesheet=b,this.updateProjection(),!0}addImage(b,c){if(this.getImage(b))return this.fire(new a.ErrorEvent(new Error("An image with this name already exists.")));this.imageManager.addImage(b,c),this._afterImageUpdated(b)}updateImage(a,b){this.imageManager.updateImage(a,b)}getImage(a){return this.imageManager.getImage(a)}removeImage(b){if(!this.getImage(b))return this.fire(new a.ErrorEvent(new Error("No image with this name exists.")));this.imageManager.removeImage(b),this._afterImageUpdated(b)}_afterImageUpdated(b){this._availableImages=this.imageManager.listImages(),this._changedImages[b]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new a.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(c,b,f={}){if(this._checkLoaded(),void 0!==this.getSource(c))throw new Error("There is already a source with this ID");if(!b.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(b).join(", ")}.`);if(["vector","raster","geojson","video","image",].indexOf(b.type)>=0&&this._validate(a.validateStyle.source,`sources.${c}`,b,null,f))return;this.map&&this.map._collectResourceTiming&&(b.collectResourceTiming=!0);const d=ag(c,b,this.dispatcher,this);d.setEventedParent(this,()=>({isSourceLoaded:this.loaded(),source:d.serialize(),sourceId:c}));const e=b=>{const f=(b?"symbol:":"other:")+c,e=this._sourceCaches[f]=new a.SourceCache(f,d,b);(b?this._symbolSourceCaches:this._otherSourceCaches)[c]=e,e.style=this,e.onAdd(this.map)};e(!1),"vector"!==b.type&&"geojson"!==b.type||e(!0),d.onAdd&&d.onAdd(this.map),this._changed=!0}removeSource(b){this._checkLoaded();const d=this.getSource(b);if(void 0===d)throw new Error("There is no source with this ID");for(const e in this._layers)if(this._layers[e].source===b)return this.fire(new a.ErrorEvent(new Error(`Source "${b}" cannot be removed while layer "${e}" is using it.`)));if(this.terrain&&this.terrain.get().source===b)return this.fire(new a.ErrorEvent(new Error(`Source "${b}" cannot be removed while terrain is using it.`)));const f=this._getSourceCaches(b);for(const c of f)delete this._sourceCaches[c.id],delete this._updatedSources[c.id],c.fire(new a.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:c.getSource().id})),c.setEventedParent(null),c.clearTiles();delete this._otherSourceCaches[b],delete this._symbolSourceCaches[b],d.setEventedParent(null),d.onRemove&&d.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(a,b){this._checkLoaded(),this.getSource(a).setData(b),this._changed=!0}getSource(b){const a=this._getSourceCache(b);return a&&a.getSource()}addLayer(c,e,h={}){this._checkLoaded();const d=c.id;if(this.getLayer(d))return void this.fire(new a.ErrorEvent(new Error(`Layer with id "${d}" already exists on this map`)));let b;if("custom"===c.type){if(a3(this,a.validateCustomStyleLayer(c)))return;b=a.createStyleLayer(c)}else{if("object"==typeof c.source&&(this.addSource(d,c.source),c=a.clone$1(c),c=a.extend(c,{source:d})),this._validate(a.validateStyle.layer,`layers.${d}`,c,{arrayIndex:-1},h))return;b=a.createStyleLayer(c),this._validateLayer(b),b.setEventedParent(this,{layer:{id:d}}),this._serializedLayers[b.id]=b.serialize(),this._updateLayerCount(b,!0)}const f=e?this._order.indexOf(e):this._order.length;if(e&& -1===f)return void this.fire(new a.ErrorEvent(new Error(`Layer with id "${e}" does not exist on this map.`)));this._order.splice(f,0,d),this._layerOrderChanged=!0,this._layers[d]=b;const g=this._getLayerSourceCache(b);if(this._removedLayers[d]&&b.source&&g&&"custom"!==b.type){const i=this._removedLayers[d];delete this._removedLayers[d],i.type!==b.type?this._updatedSources[b.source]="clear":(this._updatedSources[b.source]="reload",g.pause())}this._updateLayer(b),b.onAdd&&b.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(b,c){if(this._checkLoaded(),this._changed=!0,!this._layers[b])return void this.fire(new a.ErrorEvent(new Error(`The layer '${b}' does not exist in the map's style and cannot be moved.`)));if(b===c)return;const e=this._order.indexOf(b);this._order.splice(e,1);const d=c?this._order.indexOf(c):this._order.length;c&& -1===d?this.fire(new a.ErrorEvent(new Error(`Layer with id "${c}" does not exist on this map.`))):(this._order.splice(d,0,b),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(b){this._checkLoaded();const c=this._layers[b];if(!c)return void this.fire(new a.ErrorEvent(new Error(`The layer '${b}' does not exist in the map's style and cannot be removed.`)));c.setEventedParent(null),this._updateLayerCount(c,!1);const d=this._order.indexOf(b);this._order.splice(d,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[b]=c,delete this._layers[b],delete this._serializedLayers[b],delete this._updatedLayers[b],delete this._updatedPaintProps[b],c.onRemove&&c.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(a){return this._layers[a]}hasLayer(a){return a in this._layers}hasLayerType(a){for(const b in this._layers)if(this._layers[b].type===a)return!0;return!1}setLayerZoomRange(e,c,d){this._checkLoaded();const b=this.getLayer(e);b?b.minzoom===c&&b.maxzoom===d||(null!=c&&(b.minzoom=c),null!=d&&(b.maxzoom=d),this._updateLayer(b)):this.fire(new a.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(d,c,e={}){this._checkLoaded();const b=this.getLayer(d);if(b){if(!D(b.filter,c))return null==c?(b.filter=void 0,void this._updateLayer(b)):void(this._validate(a.validateStyle.filter,`layers.${b.id}.filter`,c,{layerType:b.type},e)||(b.filter=a.clone$1(c),this._updateLayer(b)))}else this.fire(new a.ErrorEvent(new Error(`The layer '${d}' does not exist in the map's style and cannot be filtered.`)))}getFilter(b){return a.clone$1(this.getLayer(b).filter)}setLayoutProperty(c,d,e,f={}){this._checkLoaded();const b=this.getLayer(c);b?D(b.getLayoutProperty(d),e)||(b.setLayoutProperty(d,e,f),this._updateLayer(b)):this.fire(new a.ErrorEvent(new Error(`The layer '${c}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(b,d){const c=this.getLayer(b);if(c)return c.getLayoutProperty(d);this.fire(new a.ErrorEvent(new Error(`The layer '${b}' does not exist in the map's style.`)))}setPaintProperty(c,d,e,f={}){this._checkLoaded();const b=this.getLayer(c);b?D(b.getPaintProperty(d),e)||(b.setPaintProperty(d,e,f)&&this._updateLayer(b),this._changed=!0,this._updatedPaintProps[c]=!0):this.fire(new a.ErrorEvent(new Error(`The layer '${c}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(a,b){return this.getLayer(a).getPaintProperty(b)}setFeatureState(b,g){this._checkLoaded();const c=b.source,d=b.sourceLayer,e=this.getSource(c);if(void 0===e)return void this.fire(new a.ErrorEvent(new Error(`The source '${c}' does not exist in the map's style.`)));const f=e.type;if("geojson"===f&&d)return void this.fire(new a.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===f&&!d)return void this.fire(new a.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===b.id&&this.fire(new a.ErrorEvent(new Error("The feature id parameter must be provided.")));const h=this._getSourceCaches(c);for(const i of h)i.setFeatureState(d,b.id,g)}removeFeatureState(b,d){this._checkLoaded();const c=b.source,e=this.getSource(c);if(void 0===e)return void this.fire(new a.ErrorEvent(new Error(`The source '${c}' does not exist in the map's style.`)));const f=e.type,g="vector"===f?b.sourceLayer:void 0;if("vector"===f&&!g)return void this.fire(new a.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));if(d&&"string"!=typeof b.id&&"number"!=typeof b.id)return void this.fire(new a.ErrorEvent(new Error("A feature id is required to remove its specific state property.")));const h=this._getSourceCaches(c);for(const i of h)i.removeFeatureState(g,b.id,d)}getFeatureState(b){this._checkLoaded();const c=b.source,d=b.sourceLayer,e=this.getSource(c);if(void 0!==e){if("vector"!==e.type||d)return void 0===b.id&&this.fire(new a.ErrorEvent(new Error("The feature id parameter must be provided."))),this._getSourceCaches(c)[0].getFeatureState(d,b.id);this.fire(new a.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new a.ErrorEvent(new Error(`The source '${c}' does not exist in the map's style.`)))}getTransition(){return a.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const b={};for(const d in this._sourceCaches){const c=this._sourceCaches[d].getSource();b[c.id]||(b[c.id]=c.serialize())}return a.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,terrain:this.stylesheet.terrain,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:b,layers:this._serializeLayers(this._order)},a=>void 0!==a)}_updateLayer(a){this._updatedLayers[a.id]=!0;const b=this._getLayerSourceCache(a);a.source&&!this._updatedSources[a.source]&&b&&"raster"!==b.getSource().type&&(this._updatedSources[a.source]="reload",b.pause()),this._changed=!0,a.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(g){var h,i;const j={},a=[];for(let b=this._order.length-1;b>=0;b--){const d=this._order[b];if(h=d,"fill-extrusion"===this._layers[h].type)for(const o of(j[d]=b,g)){const k=o[d];if(k)for(const p of k)a.push(p)}}a.sort((a,b)=>b.intersectionZ-a.intersectionZ);const e=[];for(let c=this._order.length-1;c>=0;c--){const l=this._order[c];if(i=l,"fill-extrusion"===this._layers[i].type)for(let f=a.length-1;f>=0;f--){const m=a[f].feature;if(j[m.layer.id]{const a=this.getLayer(b);return a&&a.is3D()}):this.has3DLayers(),h=_.createFromScreenPoints(j,d);for(const i in this._sourceCaches){const l=this._sourceCaches[i].getSource().id;b.layers&&!e[l]||c.push(ai(this._sourceCaches[i],this._layers,this._serializedLayers,h,b,d,k,!!this.map._showQueryGeometry))}return this.placement&&c.push(function(i,j,r,k,c,l,m){const a={},f=l.queryRenderedSymbols(k),d=[];for(const n of Object.keys(f).map(Number))d.push(m[n]);for(const b of(d.sort(ak),d)){const g=b.featureIndex.lookupSymbolFeatures(f[b.bucketInstanceId],j,b.bucketIndex,b.sourceLayerIndex,c.filter,c.layers,c.availableImages,i);for(const e in g){const o=a[e]=a[e]||[],h=g[e];for(const p of(h.sort((c,d)=>{const a=b.featureSortOrder;if(a){const e=a.indexOf(c.featureIndex);return a.indexOf(d.featureIndex)-e}return d.featureIndex-c.featureIndex}),h))o.push(p)}}for(const q in a)a[q].forEach(b=>{const a=b.feature,c=r(i[q]).getFeatureState(a.layer["source-layer"],a.id);a.source=a.layer.source,a.layer["source-layer"]&&(a.sourceLayer=a.layer["source-layer"]),a.state=c});return a}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),h.screenGeometry,b,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(c)}querySourceFeatures(d,b){b&&b.filter&&this._validate(a.validateStyle.filter,"querySourceFeatures.filter",b.filter,null,b);const e=this._getSourceCaches(d);let c=[];for(const f of e)c=c.concat(aj(f,b));return c}addSourceType(a,b,d){return c.getSourceType(a)?d(new Error(`A source type called "${a}" already exists.`)):(c.setSourceType(a,b),b.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:a,url:b.workerSourceURL},d):d(null,null))}getLight(){return this.light.getLight()}setLight(b,e={}){this._checkLoaded();const f=this.light.getLight();let c=!1;for(const d in b)if(!D(b[d],f[d])){c=!0;break}if(!c)return;const g={now:a.exported.now(),transition:a.extend({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(b,e),this.light.updateTransitions(g)}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}setTerrain(b,c=1){if(this._checkLoaded(),!b)return delete this.terrain,delete this.stylesheet.terrain,this.dispatcher.broadcast("enableTerrain",!1),this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);if(1===c){if("object"==typeof b.source){const e="terrain-dem-src";this.addSource(e,b.source),b=a.clone$1(b),b=a.extend(b,{source:e})}if(this._validate(a.validateStyle.terrain,"terrain",b))return}if(!this.terrain||this.terrain&&c!==this.terrain.drapeRenderMode)this._createTerrain(b,c);else{const d=this.terrain,g=d.get();for(const f in b)if(!D(b[f],g[f])){d.set(b),this.stylesheet.terrain=b;const h={now:a.exported.now(),transition:a.extend({duration:0},this.stylesheet.transition)};d.updateTransitions(h);break}}this._updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(b){const c=this.fog=new U(b,this.map.transform);this.stylesheet.fog=b;const d={now:a.exported.now(),transition:a.extend({duration:0},this.stylesheet.transition)};c.updateTransitions(d)}_updateMarkersOpacity(){0!==this.map._markers.length&&this.map._requestDomTask(()=>{for(const a of this.map._markers)a._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(b){if(this._checkLoaded(),!b)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const c=this.fog,e=c.get();for(const d in b)if(!D(b[d],e[d])){c.set(b),this.stylesheet.fog=b;const f={now:a.exported.now(),transition:a.extend({duration:0},this.stylesheet.transition)};c.updateTransitions(f);break}}else this._createFog(b);this._markersNeedUpdate=!0}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const a=this._order.filter(a=>this.isLayerDraped(this._layers[a])),b=this._order.filter(a=>!this.isLayerDraped(this._layers[a]));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...a),this._drapedFirstOrder.push(...b)}_createTerrain(b,c){const d=this.terrain=new P(b,c);this.stylesheet.terrain=b,this.dispatcher.broadcast("enableTerrain",!0),this._force3DLayerUpdate();const e={now:a.exported.now(),transition:a.extend({duration:0},this.stylesheet.transition)};d.updateTransitions(e)}_force3DLayerUpdate(){for(const b in this._layers){const a=this._layers[b];"fill-extrusion"===a.type&&this._updateLayer(a)}}_forceSymbolLayerUpdate(){for(const b in this._layers){const a=this._layers[b];"symbol"===a.type&&this._updateLayer(a)}}_validate(c,d,e,f,b={}){return(!b|| !1!==b.validate)&&a3(this,c.call(a.validateStyle,a.extend({key:d,style:this.serialize(),value:e,styleSpec:a.spec},f)))}_remove(){for(const c in this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),a.evented.off("pluginStateChange",this._rtlTextPluginCallback),this._layers)this._layers[c].setEventedParent(null);for(const b in this._sourceCaches)this._sourceCaches[b].clearTiles(),this._sourceCaches[b].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(a){const b=this._getSourceCaches(a);for(const c of b)c.clearTiles()}_reloadSource(b){const c=this._getSourceCaches(b);for(const a of c)a.resume(),a.reload()}_updateSources(a){for(const b in this._sourceCaches)this._sourceCaches[b].update(a)}_generateCollisionBoxes(){for(const b in this._sourceCaches){const a=this._sourceCaches[b];a.resume(),a.reload()}}_updatePlacement(c,k,h,l,e=!1){let f=!1,i=!1;const d={};for(const m of this._order){const b=this._layers[m];if("symbol"!==b.type)continue;if(!d[b.source]){const j=this._getLayerSourceCache(b);if(!j)continue;d[b.source]=j.getRenderableIds(!0).map(a=>j.getTileByID(a)).sort((a,b)=>b.tileID.overscaledZ-a.tileID.overscaledZ||(a.tileID.isLessThan(b.tileID)?-1:1))}const n=this.crossTileSymbolIndex.addLayer(b,d[b.source],c.center.lng,c.projection);f=f||n}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),e=e||this._layerOrderChanged||0===h,this._layerOrderChanged&&this.fire(new a.Event("neworder")),(e||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(a.exported.now(),c.zoom))&&(this.pauseablePlacement=new a$(c,this._order,e,k,h,l,this.placement,this.fog&&c.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,d),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(a.exported.now()),i=!0),f&&this.pauseablePlacement.placement.setStale()),i||f)for(const o of this._order){const g=this._layers[o];"symbol"===g.type&&this.placement.updateLayerOpacities(g,d[g.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(a.exported.now())}_releaseSymbolFadeTiles(){for(const a in this._sourceCaches)this._sourceCaches[a].releaseSymbolFadeTiles()}getImages(d,a,c){this.imageManager.getImages(a.icons,c),this._updateTilesForChangedImages();const b=b=>{b&&b.setDependencies(a.tileID.key,a.type,a.icons)};b(this._otherSourceCaches[a.source]),b(this._symbolSourceCaches[a.source])}getGlyphs(c,a,b){this.glyphManager.getGlyphs(a.stacks,b)}getResource(d,b,c){return a.makeRequest(b,c)}_getSourceCache(a){return this._otherSourceCaches[a]}_getLayerSourceCache(a){return"symbol"===a.type?this._symbolSourceCaches[a.source]:this._otherSourceCaches[a.source]}_getSourceCaches(a){const b=[];return this._otherSourceCaches[a]&&b.push(this._otherSourceCaches[a]),this._symbolSourceCaches[a]&&b.push(this._symbolSourceCaches[a]),b}has3DLayers(){return this._num3DLayers>0}hasSymbolLayers(){return this._numSymbolLayers>0}hasCircleLayers(){return this._numCircleLayers>0}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}destroy(){this._clearWorkerCaches(),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}c.getSourceType=function(a){return af[a]},c.setSourceType=function(a,b){af[a]=b},c.registerForPluginStateChange=a.registerForPluginStateChange;var t="\n#define EPSILON 0.0000001\n#define PI 3.141592653589793\n#define EXTENT 8192.0\n#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;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);}\n#endif",j="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;}";let u={},v={};u=bb("","\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\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nuniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;\n#else\nuniform sampler2D u_dem;uniform 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*texture2D(u_dem,pos).a;\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));\n#ifdef TERRAIN_DEM_NEAREST_FILTER\nreturn u_exaggeration*tl;\n#endif\nfloat 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*texture2D(u_dem_prev,pos).a;\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) {float nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}\n#else\nfloat elevation(vec2 apos) {return currentElevation(apos);}\n#endif\nfloat unpack_depth(vec4 rgba_depth)\n{const vec4 bit_shift=vec4(1.0/(256.0*256.0*256.0),1.0/(256.0*256.0),1.0/256.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=texture2D(u_dem,pos).a;float tr=texture2D(u_dem,pos+vec2(off.x,0.0)).a;float bl=texture2D(u_dem,pos+vec2(0.0,off.y)).a;float br=texture2D(u_dem,pos+off).a;\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;vec4 bounds=vec4(d,vec2(1.0)-d);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",!0),v=bb("#ifdef FOG\nuniform float u_fog_temporal_offset;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=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;}vec3 fog_dither(vec3 color) {vec2 dither_seed=gl_FragCoord.xy+u_fog_temporal_offset;return dither(color,dither_seed);}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}\n#endif","#ifdef FOG\nuniform mat4 u_fog_matrix;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",!0);const a8=bb("\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;}\n#ifdef TERRAIN\nhighp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(256.0*256.0*256.0,256.0*256.0,256.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/256.0,1.0/256.0,1.0/256.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}\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;}vec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {\n#if defined(PROJECTION_GLOBE_VIEW) && !defined(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) {\n#if defined(PROJECTION_GLOBE_VIEW) && !defined(PROJECTED_POS_ON_VIEWPORT)\nreturn mix(globe,mercator,t);\n#else\nreturn globe;\n#endif\n}\n#ifdef PROJECTION_GLOBE_VIEW\nmat3 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;}const vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);//Normalized device coordinate that is not rendered."),a9=t;var ba={background:bb("uniform vec4 u_color;uniform float u_opacity;void main() {vec4 out_color=u_color;\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\n}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),backgroundPattern:bb("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_mix);\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\n}","uniform mat4 u_matrix;uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),circle:bb("varying 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\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);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 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}","#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;attribute float a_scale;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);\n#ifdef PROJECTION_GLOBE_VIEW\nvec2 scaled_extrude=extrude*a_scale;vec3 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=scaled_extrude.x*surface_vectors[0]+scaled_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);vec4 world_center=vec4(pos,1);\n#else \nmat3 surface_vectors=mat3(1.0);float height=circle_elevation(circle_center);vec4 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\n#if defined(SCALE_WITH_MAP) && defined(PROJECTION_GLOBE_VIEW)\nview_scale*=a_scale;\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();\n#ifdef PITCH_WITH_MAP\nfloat cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);vec4 occlusion_world_center=vec4(circle_center,cantilevered_height,1);vec4 occlusion_projected_center=u_matrix*occlusion_world_center;\n#else\nvec4 occlusion_world_center=world_center;vec4 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:bb("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:bb("uniform 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\ngl_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\n}","uniform 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;attribute float a_scale;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);\n#ifdef PROJECTION_GLOBE_VIEW\nextrude*=a_scale;vec3 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;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#else\nvec3 pos=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:bb("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\n}","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:bb("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));}","attribute 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:bb("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:bb("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);}","attribute 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:bb("#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\nvec4 out_color=color;\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\n}","attribute 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:bb("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\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 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\n}","attribute 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:bb("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=mix(color1,color2,u_fade);\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\n}","uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillPattern:bb("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_fade);\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\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillExtrusion:bb("varying vec4 v_color;void main() {vec4 color=v_color;\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\n}","uniform 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;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 vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;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));base=max(0.0,base);height=max(0.0,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\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==0.0 ?-5.0 : base);vec3 pos=vec3(pos_nx.xy,h);\n#else\nvec3 pos=vec3(pos_nx.xy,t > 0.0 ? height : base);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_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*(pos.z+lift));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);float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;float directional=clamp(dot(normal,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.rgb+=clamp(color.rgb*directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity;\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),fillExtrusionPattern:bb("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_fade);out_color=out_color*v_lighting;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform 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_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;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_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;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\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==0.0 ?-5.0 : base);vec3 p=vec3(pos_nx.xy,h);\n#else\nvec3 p=vec3(pos_nx.xy,z);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_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_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;\n#ifdef FOG\nv_fog_pos=fog_position(p);\n#endif\n}"),hillshadePrepare:bb("#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 texture2D(u_image,coord).a/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);float f=getElevation(v_pos+vec2(epsilon.x,0));float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float h=getElevation(v_pos+vec2(0,epsilon.y));float i=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+f+f+i)-(a+d+d+g),(g+h+h+i)-(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);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","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:bb("uniform 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;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 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\n}","uniform 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:bb("uniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;\n#ifdef RENDER_LINE_DASH\nuniform sampler2D u_dash_image;uniform float u_mix;uniform vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;varying highp vec2 v_uv;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash_from\n#pragma mapbox: define lowp vec4 dash_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash_from\n#pragma mapbox: initialize lowp vec4 dash_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);\n#ifdef RENDER_LINE_DASH\nfloat sdfdist_a=texture2D(u_dash_image,v_tex_a).a;float sdfdist_b=texture2D(u_dash_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfwidth=min(dash_from.z*u_scale.y,dash_to.z*u_scale.z);float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/sdfwidth;alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);\n#endif\n#ifdef RENDER_LINE_GRADIENT\nvec4 out_color=texture2D(u_gradient_image,v_uv);\n#else\nvec4 out_color=color;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef RENDER_LINE_ALPHA_DISCARD\nif (alpha < u_alpha_discard_threshold) {discard;}\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define EXTRUDE_SCALE 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;\n#ifdef RENDER_LINE_GRADIENT\nattribute vec3 a_packed;\n#else\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;\n#ifdef RENDER_LINE_DASH\nuniform vec2 u_texsize;uniform mediump vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform float u_image_height;varying highp vec2 v_uv;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash_from\n#pragma mapbox: define lowp vec4 dash_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash_from\n#pragma mapbox: initialize lowp vec4 dash_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;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#ifdef RENDER_LINE_GRADIENT\nfloat a_uv_x=a_packed[0];float a_split_index=a_packed[1];float a_linesofar=a_packed[2];highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);\n#endif\n#ifdef RENDER_LINE_DASH\nfloat tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;float scaleA=dash_from.z==0.0 ? 0.0 : tileZoomRatio/(dash_from.z*fromScale);float scaleB=dash_to.z==0.0 ? 0.0 : tileZoomRatio/(dash_to.z*toScale);float heightA=dash_from.y;float heightB=dash_to.y;v_tex_a=vec2(a_linesofar*scaleA/floorwidth,(-normal.y*heightA+dash_from.x+0.5)/u_texsize.y);v_tex_b=vec2(a_linesofar*scaleB/floorwidth,(-normal.y*heightB+dash_to.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:bb("uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;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_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\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_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;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:bb("uniform 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;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(\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 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\n}","uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {float w=1.0+dot(a_texture_pos,u_perspective_transform);gl_Position=u_matrix*vec4(a_pos*w,0,w);v_pos0=a_texture_pos/8192.0;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),symbolIcon:bb("uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_z_tile_anchor;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;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;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_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_minFontScale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}float anchorZ=a_z_tile_anchor.x;vec2 tileAnchor=a_z_tile_anchor.yz;vec3 h=elevationVector(tileAnchor)*elevation(tileAnchor);vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tileAnchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(vec3(a_pos,anchorZ)+h,mercator_pos,u_zoom_transition);vec4 projectedPoint=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\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 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),anchorZ,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec3 proj_pos=mix_globe_mercator(vec3(a_projected_pos.xy,anchorZ),mercator_pos,u_zoom_transition);\n#ifdef PROJECTED_POS_ON_VIEWPORT\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,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_minFontScale,fontScale)+a_pxoffset/16.0);\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\nfloat occlusion_fade=occlusionFade(projectedPoint);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projectedPoint.w <=0.0 || occlusion_fade==0.0));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\nv_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;v_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change))*projection_transition_fade;}"),symbolSDF:bb("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying 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\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\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;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_z_tile_anchor;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_tile_id;uniform float u_zoom_transition;varying 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\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_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[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}float anchorZ=a_z_tile_anchor.x;vec2 tileAnchor=a_z_tile_anchor.yz;vec3 h=elevationVector(tileAnchor)*elevation(tileAnchor);vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tileAnchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(vec3(a_pos,anchorZ)+h,mercator_pos,u_zoom_transition);vec4 projectedPoint=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\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 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),anchorZ,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec3 proj_pos=mix_globe_mercator(vec3(a_projected_pos.xy,anchorZ),mercator_pos,u_zoom_transition);\n#ifdef PROJECTED_POS_ON_VIEWPORT\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,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 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\nfloat occlusion_fade=occlusionFade(projectedPoint);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projectedPoint.w <=0.0 || occlusion_fade==0.0));float gamma_scale=gl_Position.w;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));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade);}"),symbolTextAndIcon:bb("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying 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\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\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;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_z_tile_anchor;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;varying 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\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_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[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}float anchorZ=a_z_tile_anchor.x;vec2 tileAnchor=a_z_tile_anchor.yz;vec3 h=elevationVector(tileAnchor)*elevation(tileAnchor);vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tileAnchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(vec3(a_pos,anchorZ)+h,mercator_pos,u_zoom_transition);vec4 projectedPoint=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),anchorZ,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec3 proj_pos=mix_globe_mercator(vec3(a_projected_pos.xy,anchorZ),mercator_pos,u_zoom_transition);\n#ifdef PROJECTED_POS_ON_VIEWPORT\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,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);\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\nfloat occlusion_fade=occlusionFade(projectedPoint);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projectedPoint.w <=0.0 || occlusion_fade==0.0));float gamma_scale=gl_Position.w;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\nv_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade,is_sdf);}"),terrainRaster:bb("uniform sampler2D u_image0;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\nvoid main() {vec4 color=texture2D(u_image0,v_pos0);\n#ifdef FOG\ncolor=fog_dither(fog_apply_from_vert(color,v_fog_opacity));\n#endif\ngl_FragColor=color;\n#ifdef TERRAIN_WIREFRAME\ngl_FragColor=vec4(1.0,0.0,0.0,0.8);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_skirt_height;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\nconst float skirtOffset=24575.0;const float wireframeOffset=0.00015;void main() {v_pos0=a_texture_pos/8192.0;float skirt=float(a_pos.x >=skirtOffset);float elevation=elevation(a_texture_pos)-skirt*u_skirt_height;\n#ifdef TERRAIN_WIREFRAME\nelevation+=u_skirt_height*u_skirt_height*wireframeOffset;\n#endif\nvec2 decodedPos=a_pos-vec2(skirt*skirtOffset,0.0);gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);\n#ifdef FOG\nv_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));\n#endif\n}"),terrainDepth:bb("#ifdef GL_ES\nprecision highp float;\n#endif\nvarying float v_depth;void main() {gl_FragColor=pack_depth(v_depth);}","uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying float v_depth;void main() {float elevation=elevation(a_texture_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}"),skybox:bb("\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}",j),skyboxGradient:bb("varying 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}",j),skyboxCapture:bb("\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:bb("uniform sampler2D u_image0;varying vec2 v_pos0;void main() {gl_FragColor=texture2D(u_image0,v_pos0);\n#ifdef TERRAIN_WIREFRAME\ngl_FragColor=vec4(1.0,0.0,0.0,0.8);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_proj_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;attribute vec3 a_globe_pos;attribute vec2 a_merc_pos;attribute vec2 a_uv;varying vec2 v_pos0;const float wireframeOffset=1e3;void main() {v_pos0=a_uv;vec2 uv=a_uv*EXTENT;vec4 up_vector=vec4(elevationVector(uv),1.0);float height=elevation(uv);\n#ifdef TERRAIN_WIREFRAME\nheight+=wireframeOffset;\n#endif\nvec4 globe=u_globe_matrix*vec4(a_globe_pos+up_vector.xyz*height,1.0);vec4 mercator=vec4(0.0);if (u_zoom_transition > 0.0) {mercator=vec4(a_merc_pos,height,1.0);mercator.xy-=u_merc_center;mercator.x=wrap(mercator.x,-0.5,0.5);mercator=u_merc_matrix*mercator;}vec3 position=mix(globe.xyz,mercator.xyz,u_zoom_transition);gl_Position=u_proj_matrix*vec4(position,1.0);}"),globeAtmosphere:bb("uniform vec2 u_center;uniform float u_radius;uniform vec2 u_screen_size;uniform float u_opacity;uniform highp float u_fadeout_range;uniform vec3 u_start_color;uniform vec3 u_end_color;uniform float u_pixel_ratio;void main() {highp vec2 fragCoord=gl_FragCoord.xy/u_pixel_ratio;fragCoord.y=u_screen_size.y-fragCoord.y;float distFromCenter=length(fragCoord-u_center);float normDistFromCenter=length(fragCoord-u_center)/u_radius;if (normDistFromCenter < 1.0)\ndiscard;float t=clamp(1.0-sqrt(normDistFromCenter-1.0)/u_fadeout_range,0.0,1.0);vec3 color=mix(u_start_color,u_end_color,1.0-t);gl_FragColor=vec4(color*t*u_opacity,u_opacity);}","attribute vec3 a_pos;void main() {gl_Position=vec4(a_pos,1.0);}")};function bb(c,b,h){const e=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,d=/uniform (highp |mediump |lowp )?([\w]+) ([\w]+)([\s]*)([\w]*)/g,i=b.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),f=c.match(d),g=b.match(d),j=t.match(d);let a=g?g.concat(f):f;h||(u.staticUniforms&&(a=u.staticUniforms.concat(a)),v.staticUniforms&&(a=v.staticUniforms.concat(a))),a&&(a=a.concat(j));const k={};return{fragmentSource:c=c.replace(e,(e,d,b,c,a)=>(k[a]=!0,"define"===d?` #ifndef HAS_UNIFORM_u_${a} varying ${b} ${c} ${a}; #else @@ -57,4 +57,4 @@ uniform ${b} ${c} u_${a}; `}),staticAttributes:i,staticUniforms:a}}class bc{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(f,h,i,b,a,j,c,d){this.context=f;let g=this.boundPaintVertexBuffers.length!==b.length;for(let e=0;!g&&e{const g=b.paint.get("hillshade-shadow-color"),h=b.paint.get("hillshade-highlight-color"),i=b.paint.get("hillshade-accent-color");let e=b.paint.get("hillshade-illumination-direction")*(Math.PI/180);"viewport"===b.paint.get("hillshade-illumination-anchor")&&(e-=c.transform.angle);const j=!c.options.moving;return{u_matrix:f||c.transform.calculateProjMatrix(d.tileID.toUnwrapped(),j),u_image:0,u_latrange:function(e,b){const c=Math.pow(2,b.canonical.z),d=b.canonical.y;return[new a.MercatorCoordinate(0,d/c).toLngLat().lat,new a.MercatorCoordinate(0,(d+1)/c).toLngLat().lat,]}(0,d.tileID),u_light:[b.paint.get("hillshade-exaggeration"),e,],u_shadow:g,u_highlight:h,u_accent:i}})(b,f,g,b.terrain?e.projMatrix:null);b.prepareDrawProgram(c,i,e.toUnwrapped());const{tileBoundsBuffer:n,tileBoundsIndexBuffer:o,tileBoundsSegments:p}=b.getTileBoundsBuffers(f);i.draw(c,d.TRIANGLES,j,k,l,a.CullFaceMode.disabled,m,g.id,n,o,p)}function be(d,b,e){if(!b.needsDEMTextureUpload)return;const c=d.context,g=c.gl;c.pixelStoreUnpackPremultiplyAlpha.set(!1),b.demTexture=b.demTexture||d.getTileTexture(e.stride);const f=e.getPixels();b.demTexture?b.demTexture.update(f,{premultiply:!1}):b.demTexture=new a.Texture(c,f,g.RGBA,{premultiply:!1}),b.needsDEMTextureUpload=!1}function bf(f,b,j,k,l,m){const c=f.context,d=c.gl;if(!b.dem)return;const g=b.dem;if(c.activeTexture.set(d.TEXTURE1),be(f,b,g),!b.demTexture)return;b.demTexture.bind(d.NEAREST,d.CLAMP_TO_EDGE);const e=g.dim;c.activeTexture.set(d.TEXTURE0);let h=b.fbo;if(!h){const i=new a.Texture(c,{width:e,height:e,data:null},d.RGBA);i.bind(d.LINEAR,d.CLAMP_TO_EDGE),(h=b.fbo=c.createFramebuffer(e,e,!0)).colorAttachment.set(i.texture)}c.bindFramebuffer.set(h.framebuffer),c.viewport.set([0,0,e,e]);const{tileBoundsBuffer:n,tileBoundsIndexBuffer:o,tileBoundsSegments:p}=f.getMercatorTileBoundsBuffers();f.useProgram("hillshadePrepare").draw(c,d.TRIANGLES,k,l,m,a.CullFaceMode.disabled,((e,c)=>{const d=c.stride,b=a.create();return a.ortho(b,0,a.EXTENT,-a.EXTENT,0,0,1),a.translate(b,b,[0,-a.EXTENT,0]),{u_matrix:b,u_image:1,u_dimension:[d,d],u_zoom:e.overscaledZ,u_unpack:c.unpackVector}})(b.tileID,g),j.id,n,o,p),b.needsHillshadePrepare=!1}const k=(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_image0:new a.Uniform1i(b,c.u_image0),u_skirt_height:new a.Uniform1f(b,c.u_skirt_height)}),bg=(a,b)=>({u_matrix:a,u_image0:0,u_skirt_height:b}),bh=(a,b,c,d,e)=>({u_proj_matrix:Float32Array.from(a),u_globe_matrix:b,u_merc_matrix:c,u_zoom_transition:d,u_merc_center:e,u_image0:0});function bi(a,b){return null!=a&&null!=b&&!(!a.hasData()||!b.hasData())&&null!=a.demTexture&&null!=b.demTexture&&a.tileID.key!==b.tileID.key}const bj=new class{constructor(){this.operations={}}newMorphing(a,d,b,e,f){if(a in this.operations){const c=this.operations[a];c.to.tileID.key!==b.tileID.key&&(c.queued=b)}else this.operations[a]={startTime:e,phase:0,duration:f,from:d,to:b,queued:null}}getMorphValuesForProxy(b){if(!(b in this.operations))return null;const a=this.operations[b];return{from:a.from,to:a.to,phase:a.phase}}update(b){for(const c in this.operations){const a=this.operations[c];for(a.phase=(b-a.startTime)/a.duration;a.phase>=1||!this._validOp(a);)if(!this._nextOp(a,b)){delete this.operations[c];break}}}_nextOp(a,b){return!!a.queued&&(a.from=a.to,a.to=a.queued,a.queued=null,a.phase=0,a.startTime=b,!0)}_validOp(a){return a.from.hasData()&&a.to.hasData()}},bk={0:null,1:"TERRAIN_VERTEX_MORPHING",2:"TERRAIN_WIREFRAME"};function bl(a,c){const b=1<({u_matrix:a});function bn(b,c,k,l,d){if(d>0){const e=a.exported.now(),f=(e-b.timeAdded)/d,m=c?(e-c.timeAdded)/d:-1,g=k.getSource(),h=l.coveringZoomLevel({tileSize:g.tileSize,roundZoom:g.roundZoom}),i=!c||Math.abs(c.tileID.overscaledZ-h)>Math.abs(b.tileID.overscaledZ-h),j=i&&b.refreshedUponExpiration?1:a.clamp(i?f:1-m,0,1);return b.refreshedUponExpiration&&f>=1&&(b.refreshedUponExpiration=!1),c?{opacity:1,mix:1-j}:{opacity:j,mix:0}}return{opacity:1,mix:0}}class bo extends a.SourceCache{constructor(a){const c={type:"raster-dem",maxzoom:a.transform.maxZoom},d=new n(ao(),null),b=ag("mock-dem",c,d,a.style);super("mock-dem",b,!1),b.setEventedParent(this),this._sourceLoaded=!0}_loadTile(a,b){a.state="loaded",b(null)}}class bp extends a.SourceCache{constructor(a){const b=ag("proxy",{type:"geojson",maxzoom:a.transform.maxZoom},new n(ao(),null),a.style);super("proxy",b,!1),b.setEventedParent(this),this.map=this.getSource().map=a,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(c,e,f){if(c.freezeTileCoverage)return;this.transform=c;const d=c.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((d,b)=>{if(d[b.key]="",!this._tiles[b.key]){const e=new a.Tile(b,this._source.tileSize*b.overscaleFactor(),c.tileZoom);e.state="loaded",this._tiles[b.key]=e}return d},{});for(const b in this._tiles)b in d||(this.freeFBO(b),this._tiles[b].unloadVectorData(),delete this._tiles[b])}freeFBO(a){const b=this.proxyCachedFBO[a];if(void 0!==b){const c=Object.values(b);this.renderCachePool.push(...c),delete this.proxyCachedFBO[a]}}deallocRenderCache(){this.renderCache.forEach(a=>a.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class bq extends a.OverscaledTileID{constructor(a,b,c){super(a.overscaledZ,a.wrap,a.canonical.z,a.canonical.x,a.canonical.y),this.proxyTileKey=b,this.projMatrix=c}}class br extends a.Elevation{constructor(c,d){super(),this.painter=c,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[e,g,h]=function(o){const e=new a.StructArrayLayout4i8,i=new a.StructArrayLayout3ui6;e.reserve(17161),i.reserve(33800);const b=a.EXTENT/128,f=a.EXTENT+b/2,j=f+b;for(let c=-b;cf||c<0||c>f?24575:0,k=a.clamp(Math.round(d),0,a.EXTENT),l=a.clamp(Math.round(c),0,a.EXTENT);e.emplaceBack(k+m,l,k,l)}const n=(b,c)=>{const a=131*c+b;i.emplaceBack(a+1,a,a+131),i.emplaceBack(a+131,a+131+1,a+1)};for(let g=1;g<129;g++)for(let h=1;h<129;h++)n(h,g);return[0,129].forEach(b=>{for(let a=0;a<130;a++)n(a,b),n(b,a)}),[e,i,32768]}(),f=c.context;this.gridBuffer=f.createVertexBuffer(e,a.boundsAttributes.members),this.gridIndexBuffer=f.createIndexBuffer(g),this.gridSegments=a.SegmentVector.simpleSegment(0,0,e.length,g.length),this.gridNoSkirtSegments=a.SegmentVector.simpleSegment(0,0,e.length,h),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new bp(d.map),this.orthoMatrix=a.create(),a.ortho(this.orthoMatrix,0,a.EXTENT,0,a.EXTENT,0,1);const b=f.gl;this._overlapStencilMode=new a.StencilMode({func:b.GEQUAL,mask:255},0,255,b.KEEP,b.KEEP,b.REPLACE),this._previousZoom=c.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=d,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new bo(d.map)}set style(a){a.on("data",this._onStyleDataEvent.bind(this)),a.on("neworder",this._checkRenderCacheEfficiency.bind(this)),this._style=a,this._checkRenderCacheEfficiency()}update(b,c,f){if(b&&b.terrain){this._style!==b&&(this.style=b),this.enabled=!0;const d=b.terrain.properties;this.sourceCache=0===b.terrain.drapeRenderMode?this._mockSourceCache:b._getSourceCache(d.get("source")),this._exaggeration=d.get("exaggeration");const e=()=>{this.sourceCache.used&&a.warnOnce(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source. This leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const b=this.getScaledDemTileSize();this.sourceCache.update(c,b,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,e(),this._initializing=!0),e(),c.updateElevation(!f),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(c),this._emptyDEMTextureDirty=!0}else this._disable()}resetTileLookupCache(a){this._findCoveringTileCache[a]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_checkRenderCacheEfficiency(){const b=this.renderCacheEfficiency(this._style);this._style.map._optimizeForTerrain||100!==b.efficiency&&a.warnOnce(`Terrain render cache efficiency is not optimal (${b.efficiency}%) and performance may be affected negatively, consider placing all background, fill and line layers before layer - with id '${b.firstUndrapedLayer}' or create a map using optimizeForTerrain: true option.`)}_onStyleDataEvent(a){a.coord&&"source"===a.dataType?this._clearRenderCacheForTile(a.sourceCacheId,a.coord):"style"===a.dataType&&(this._invalidateRenderCache=!0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const a in this._style._sourceCaches)this._style._sourceCaches[a].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach(a=>a.fb.destroy()),this.pool=[],this._depthFBO&&(this._depthFBO.destroy(),delete this._depthFBO,delete this._depthTexture)}_source(){return this.enabled?this.sourceCache:null}exaggeration(){return this._exaggeration}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const a=2*this.proxySourceCache.getSource().tileSize;return[a,a]}set useVertexMorphing(a){this._useVertexMorphing=a}updateTileBinding(h){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const i=this.proxySourceCache,d=this.painter.transform;this._initializing&&(this._initializing=0===d._centerAltitude&& -1===this.getAtPointOrZero(a.MercatorCoordinate.fromLngLat(d.center),-1),this._emptyDEMTextureDirty=!this._initializing);const c=this.proxyCoords=i.getIds().map(b=>{const a=i.getTileByID(b).tileID;return a.projMatrix=d.calculateProjMatrix(a.toUnwrapped()),a});(function(d,b){const c=b.transform.pointCoordinate(b.transform.getCameraPoint()),e=new a.pointGeometry(c.x,c.y);d.sort((b,c)=>{if(c.overscaledZ-b.overscaledZ)return c.overscaledZ-b.overscaledZ;const f=new a.pointGeometry(b.canonical.x+(1<{this.proxyToSource[a.key]={}}),this.terrainTileForTile={};const k=this._style._sourceCaches;for(const e in k){const b=k[e];if(!b.used)continue;if(b!==this.sourceCache&&this.resetTileLookupCache(b.id),this._setupProxiedCoordsForOrtho(b,h[e],j),b.usedForTerrain)continue;const m=h[e];b.getSource().reparseOverscaled&&this._assignTerrainTiles(m)}this.proxiedCoords[i.id]=c.map(a=>new bq(a,a.key,this.orthoMatrix)),this._assignTerrainTiles(c),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(j),this.renderingToTexture=!1,this._updateTimestamp=a.exported.now();const l={};for(const n of(this._visibleDemTiles=[],this.proxyCoords)){const f=this.terrainTileForTile[n.key];if(!f)continue;const g=f.tileID.key;g in l||(this._visibleDemTiles.push(f),l[g]=g)}}_assignTerrainTiles(a){this._initializing||a.forEach(a=>{if(this.terrainTileForTile[a.key])return;const b=this._findTileCoveringTileID(a,this.sourceCache);b&&(this.terrainTileForTile[a.key]=b)})}_prepareDEMTextures(){const b=this.painter.context,d=b.gl;for(const e in this.terrainTileForTile){const a=this.terrainTileForTile[e],c=a.dem;c&&(!a.demTexture||a.needsDEMTextureUpload)&&(b.activeTexture.set(d.TEXTURE1),be(this.painter,a,c))}}_prepareDemTileUniforms(f,a,d,g){if(!a||null==a.demTexture)return!1;const b=f.tileID.canonical,c=Math.pow(2,a.tileID.canonical.z-b.z),e=g||"";return d[`u_dem_tl${e}`]=[b.x*c%1,b.y*c%1,],d[`u_dem_scale${e}`]=c,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const b=this.painter.context,c=b.gl;if(!this._emptyDepthBufferTexture){const d={width:1,height:1,data:new Uint8Array([255,255,255,255,])};this._emptyDepthBufferTexture=new a.Texture(b,d,c.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let a=0;const b=this._visibleDemTiles.reduce((b,c)=>{if(!c.dem)return b;const d=c.dem.tree.minimums[0];return d>0&&a++,b+d},0);return a?b/a:0}_updateEmptyDEMTexture(){const c=this.painter.context,d=c.gl;c.activeTexture.set(d.TEXTURE2);const f=this._getLoadedAreaMinimum(),e={width:1,height:1,data:new Uint8Array(a.DEMData.pack(f,this.sourceCache.getSource().encoding))};this._emptyDEMTextureDirty=!1;let b=this._emptyDEMTexture;return b?b.update(e,{premultiply:!1}):b=this._emptyDEMTexture=new a.Texture(c,e,d.RGBA,{premultiply:!1}),b}setupElevationDraw(g,p,d){var n;const f=this.painter.context,b=f.gl,c=(n=this.sourceCache.getSource().encoding,{u_dem:2,u_dem_prev:4,u_dem_unpack:a.DEMData.getUnpackVector(n),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,u_tile_tl_up:[0,0,1],u_tile_tr_up:[0,0,1],u_tile_br_up:[0,0,1],u_tile_bl_up:[0,0,1],u_tile_up_scale:1});c.u_dem_size=this.sourceCache.getSource().tileSize,c.u_exaggeration=this.exaggeration();const j=this.painter.transform,h=j.projection.createTileTransform(j,j.worldSize),i=g.tileID.canonical;c.u_tile_tl_up=h.upVector(i,0,0),c.u_tile_tr_up=h.upVector(i,a.EXTENT,0),c.u_tile_br_up=h.upVector(i,a.EXTENT,a.EXTENT),c.u_tile_bl_up=h.upVector(i,0,a.EXTENT),c.u_tile_up_scale=h.upVectorScale(i);let e=null,k=null,o=1;if(d&&d.morphing&&this._useVertexMorphing){const l=d.morphing.srcDemTile,m=d.morphing.dstDemTile;o=d.morphing.phase,l&&m&&(this._prepareDemTileUniforms(g,l,c,"_prev")&&(k=l),this._prepareDemTileUniforms(g,m,c)&&(e=m))}if(k&&e?(f.activeTexture.set(b.TEXTURE2),e.demTexture.bind(b.NEAREST,b.CLAMP_TO_EDGE,b.NEAREST),f.activeTexture.set(b.TEXTURE4),k.demTexture.bind(b.NEAREST,b.CLAMP_TO_EDGE,b.NEAREST),c.u_dem_lerp=o):(e=this.terrainTileForTile[g.tileID.key],f.activeTexture.set(b.TEXTURE2),(this._prepareDemTileUniforms(g,e,c)?e.demTexture:this.emptyDEMTexture).bind(b.NEAREST,b.CLAMP_TO_EDGE)),f.activeTexture.set(b.TEXTURE3),d&&d.useDepthForOcclusion?(this._depthTexture.bind(b.NEAREST,b.CLAMP_TO_EDGE),c.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height,]):(this.emptyDepthBufferTexture.bind(b.NEAREST,b.CLAMP_TO_EDGE),c.u_depth_size_inv=[1,1]),d&&d.useMeterToDem&&e){const q=(1<{if(l===c)return;const a=[];d&&a.push(bk[g]),a.push(bk[c]),a.push("PROJECTION_GLOBE_VIEW"),k=b.useProgram("globeRaster",null,a),l=c},n=b.colorModeForRenderPass(),o=new a.DepthMode(f.LEQUAL,a.DepthMode.ReadWrite,b.depthRangeFor3D);bj.update(d);const c=b.transform,p=a.calculateGlobeMatrix(c,c.worldSize),q=a.calculateGlobeMercatorMatrix(c),r=[a.mercatorXfromLng(c.center.lng),a.mercatorYfromLat(c.center.lat),],s=b.globeSharedBuffers;(g?[!1,!0]:[!1]).forEach(u=>{l=-1;const x=u?f.LINES:f.TRIANGLES;for(const g of j){const v=i.getTile(g),y=Math.pow(2,g.canonical.z),[D,E]=a.globeBuffersForTileMesh(b,v,g,y),z=a.StencilMode.disabled,A=h.prevTerrainTileForTile[g.key],B=h.terrainTileForTile[g.key];bi(A,B)&&bj.newMorphing(g.key,A,B,d,250),e.activeTexture.set(f.TEXTURE0),v.texture.bind(f.LINEAR,f.CLAMP_TO_EDGE);const t=bj.getMorphValuesForProxy(g.key),F=t?1:0,C={};t&&a.extend$1(C,{morphing:{srcDemTile:t.from,dstDemTile:t.to,phase:a.easeCubicInOut(t.phase)}});const G=a.globeMatrixForTile(g.canonical,p),H=bh(c.projMatrix,G,q,a.globeToMercatorTransition(c.zoom),r);if(m(F,u),h.setupElevationDraw(v,k,C),b.prepareDrawProgram(e,k,g.toUnwrapped()),s){const[I,J]=u?s.getWirefameBuffer(b.context):[s.gridIndexBuffer,s.gridSegments,];k.draw(e,x,o,z,n,a.CullFaceMode.backCCW,H,"globe_raster",D,I,J)}if(!u){const K=[0===g.canonical.y?a.globePoleMatrixForTile(g.canonical,!1,c):null,g.canonical.y===y-1?a.globePoleMatrixForTile(g.canonical,!0,c):null,];for(const w of K){if(!w)continue;const L=bh(c.projMatrix,w,w,0,r);s&&k.draw(e,x,o,z,n,a.CullFaceMode.disabled,L,"globe_pole_raster",E,s.poleIndexBuffer,s.poleSegments)}}}})}(b,c,e,f,d);else{const g=b.context,h=g.gl;let k,l;const i=b.options.showTerrainWireframe?2:0,m=(a,d)=>{if(l===a)return;const c=[bk[a]];d&&c.push(bk[i]),k=b.useProgram("terrainRaster",null,c),l=a},n=b.colorModeForRenderPass(),o=new a.DepthMode(h.LEQUAL,a.DepthMode.ReadWrite,b.depthRangeFor3D);bj.update(d);const j=b.transform,p=6*Math.pow(1.5,22-j.zoom)*c.exaggeration();(i?[!1,!0]:[!1]).forEach(r=>{l=-1;const w=r?h.LINES:h.TRIANGLES,[x,y]=r?c.getWirefameBuffer():[c.gridIndexBuffer,c.gridSegments,];for(const i of f){const s=e.getTile(i),z=a.StencilMode.disabled,t=c.prevTerrainTileForTile[i.key],u=c.terrainTileForTile[i.key];bi(t,u)&&bj.newMorphing(i.key,t,u,d,250),g.activeTexture.set(h.TEXTURE0),s.texture.bind(h.LINEAR,h.CLAMP_TO_EDGE,h.LINEAR_MIPMAP_NEAREST);const q=bj.getMorphValuesForProxy(i.key),A=q?1:0;let v;q&&(v={morphing:{srcDemTile:q.from,dstDemTile:q.to,phase:a.easeCubicInOut(q.phase)}});const B=bg(i.projMatrix,bl(i.canonical,j.renderWorldCopies)?p/10:p);m(A,r),c.setupElevationDraw(s,k,v),b.prepareDrawProgram(g,k,i.toUnwrapped()),k.draw(g,w,o,z,n,a.CullFaceMode.backCCW,B,"terrain_raster",c.gridBuffer,x,y)}})}}(c,this,this.proxySourceCache,b,this._updateTimestamp),this.renderingToTexture=!0,b.splice(0,b.length))}renderBatch(p){if(0===this._drapedRenderBatches.length)return p+1;this.renderingToTexture=!0;const c=this.painter,e=this.painter.context,f=this.proxySourceCache,s=this.proxiedCoords[f.id],k=this._drapedRenderBatches.shift(),h=[],t=c.style.order;let i=0;for(const g of s){const l=f.getTileByID(g.proxyTileKey),m=f.proxyCachedFBO[g.key]?f.proxyCachedFBO[g.key][p]:void 0,b=void 0!==m?f.renderCache[m]:this.pool[i++],q=void 0!==m;if(l.texture=b.tex,q&&!b.dirty){h.push(l.tileID);continue}let r;e.bindFramebuffer.set(b.fb.framebuffer),this.renderedToTile=!1,b.dirty&&(e.clear({color:a.Color.transparent,stencil:0}),b.dirty=!1);for(let n=k.start;n<=k.end;++n){const j=c.style._layers[t[n]];if(j.isHidden(c.transform.zoom))continue;const d=c.style._getLayerSourceCache(j),o=d?this.proxyToSource[g.key][d.id]:[g];if(!o)continue;const u=o;e.viewport.set([0,0,b.fb.width,b.fb.height,]),r!==(d?d.id:null)&&(this._setupStencil(b,o,j,d),r=d?d.id:null),c.renderLayer(c,d,j,u)}this.renderedToTile?(b.dirty=!0,h.push(l.tileID)):q|| --i,5===i&&(i=0,this.renderToBackBuffer(h))}return this.renderToBackBuffer(h),this.renderingToTexture=!1,e.bindFramebuffer.set(null),e.viewport.set([0,0,c.width,c.height]),k.end+1}postRender(){}renderCacheEfficiency(a){const e=a.order.length;if(0===e)return{efficiency:100};let f,g=0,b=0,c=!1;for(let d=0;da.dem).forEach(b=>{a=Math.min(a,b.dem.tree.minimums[0])}),0===a?a:(a-30)*this._exaggeration}raycast(d,e,f){if(!this._visibleDemTiles)return null;const b=this._visibleDemTiles.filter(a=>a.dem).map(b=>{const c=b.tileID,a=Math.pow(2,c.overscaledZ),{x:g,y:h}=c.canonical,i=g/a,j=(g+1)/a,k=h/a,l=(h+1)/a;return{minx:i,miny:k,maxx:j,maxy:l,t:b.dem.tree.raycastRoot(i,k,j,l,d,e,f),tile:b}});for(const a of(b.sort((a,b)=>(null!==a.t?a.t:Number.MAX_VALUE)-(null!==b.t?b.t:Number.MAX_VALUE)),b)){if(null==a.t)break;const c=a.tile.dem.tree.raycast(a.minx,a.miny,a.maxx,a.maxy,d,e,f);if(null!=c)return c}return null}_createFBO(){const b=this.painter.context,c=b.gl,d=this.drapeBufferSize;b.activeTexture.set(c.TEXTURE0);const f=new a.Texture(b,{width:d[0],height:d[1],data:null},c.RGBA);f.bind(c.LINEAR,c.CLAMP_TO_EDGE);const e=b.createFramebuffer(d[0],d[1],!1);return e.colorAttachment.set(f.texture),e.depthAttachment=new Z(b,e.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=b.createRenderbuffer(b.gl.DEPTH_STENCIL,d[0],d[1]),this._stencilRef=0,e.depthAttachment.set(this._sharedDepthStencil),b.clear({stencil:0})):e.depthAttachment.set(this._sharedDepthStencil),b.extTextureFilterAnisotropic&&!b.extTextureFilterAnisotropicForceOff&&c.texParameterf(c.TEXTURE_2D,b.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,b.extTextureFilterAnisotropicMax),{fb:e,tex:f,dirty:!1}}_initFBOPool(){for(;this.pool.length{const a=this._style._layers[c],d=a.isHidden(this.painter.transform.zoom),b=a.getCrossfadeParameters(),e=!!b&&1!==b.t,f=a.hasTransition();return"custom"!==a.type&&!d&&(e||f)})}_clearRasterFadeFromRenderCache(){let e=!1;for(const h in this._style._sourceCaches)if(this._style._sourceCaches[h]._source instanceof r){e=!0;break}if(e)for(let c=0;ca.renderCachePool.length){const i=Object.values(a.proxyCachedFBO);a.proxyCachedFBO={};for(let e=0;e=0;g--){const b=f[g];if(a.getTileByID(b.key),void 0!==a.proxyCachedFBO[b.key]){const j=p[b.key],k=this.proxyToSource[b.key];let d=0;for(const l in k){const m=k[l],n=j[l];if(!n||n.length!==m.length||m.some((a,b)=>a!==n[b]||t[l]&&t[l].hasOwnProperty(a.key))){d=-1;break}++d}for(const r in a.proxyCachedFBO[b.key])a.renderCache[a.proxyCachedFBO[b.key][r]].dirty=d<0||d!==Object.values(j).length}}const o=[...this._drapedRenderBatches];for(const s of(o.sort((a,b)=>b.end-b.start-(a.end-a.start)),o))for(const h of f){if(a.proxyCachedFBO[h.key])continue;let c=a.renderCachePool.pop();void 0===c&&a.renderCache.length<50&&(c=a.renderCache.length,a.renderCache.push(this._createFBO())),void 0!==c&&(a.proxyCachedFBO[h.key]={},a.proxyCachedFBO[h.key][s.start]=c,a.renderCache[c].dirty=!0)}this._tilesDirty={}}_setupStencil(g,a,c,d){if(!d||!this._sourceTilesOverlap[d.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const e=this.painter.context,f=e.gl;if(a.length<=1)return void(this._overlapStencilType=!1);let b;if(c.isTileClipped())b=a.length,this._overlapStencilMode.test={func:f.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(a[0].overscaledZ>a[a.length-1].overscaledZ))return void(this._overlapStencilType=!1);b=1,this._overlapStencilMode.test={func:f.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+b>255&&(e.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=b,this._overlapStencilMode.ref=this._stencilRef,c.isTileClipped()&&this._renderTileClippingMasks(a,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return"Clip"===this._overlapStencilType||"Mask"===this._overlapStencilType}stencilModeForRTTOverlap(b){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[b.key]),this._overlapStencilMode):a.StencilMode.disabled}_renderTileClippingMasks(f,g){const b=this.painter,d=this.painter.context,c=d.gl;b._tileClippingMaskIDs={},d.setColorMode(a.ColorMode.disabled),d.setDepthMode(a.DepthMode.disabled);const h=b.useProgram("clippingMask");for(const e of f){const i=b._tileClippingMaskIDs[e.key]=--g;h.draw(d,c.TRIANGLES,a.DepthMode.disabled,new a.StencilMode({func:c.ALWAYS,mask:0},i,255,c.KEEP,c.KEEP,c.REPLACE),a.ColorMode.disabled,a.CullFaceMode.disabled,bm(e.projMatrix),"$clipping",b.tileExtentBuffer,b.quadTriangleIndexBuffer,b.tileExtentSegments)}}pointCoordinate(e){const d=this.painter.transform;if(e.x<0||e.x>d.width||e.y<0||e.y>d.height)return null;const b=[e.x,e.y,1,1];a.transformMat4$1(b,b,d.pixelMatrixInverse),a.scale$1(b,b,1/b[3]),b[0]/=d.worldSize,b[1]/=d.worldSize;const g=d._camera.position,i=a.mercatorZfromAltitude(1,d.center.lat),c=[g[0],g[1],g[2]/i,0],f=a.subtract([],b.slice(0,3),c);a.normalize(f,f);const h=this.raycast(c,f,this._exaggeration);return null!==h&&h?(a.scaleAndAdd(c,c,f,h),c[3]=c[2],c[2]*=i,c):null}drawDepth(){const e=this.painter,b=e.context,i=this.proxySourceCache,c=Math.ceil(e.width),d=Math.ceil(e.height);if(this._depthFBO&&(this._depthFBO.width!==c||this._depthFBO.height!==d)&&(this._depthFBO.destroy(),delete this._depthFBO,delete this._depthTexture),!this._depthFBO){const f=b.gl,g=b.createFramebuffer(c,d,!0);b.activeTexture.set(f.TEXTURE0);const h=new a.Texture(b,{width:c,height:d,data:null},f.RGBA);h.bind(f.NEAREST,f.CLAMP_TO_EDGE),g.colorAttachment.set(h.texture);const j=b.createRenderbuffer(b.gl.DEPTH_COMPONENT16,c,d);g.depthAttachment.set(j),this._depthFBO=g,this._depthTexture=h}b.bindFramebuffer.set(this._depthFBO.framebuffer),b.viewport.set([0,0,c,d]),function(b,c,h,i){if("globe"===b.transform.projection.name)return;const d=b.context,e=d.gl;d.clear({depth:1});const f=b.useProgram("terrainDepth"),j=new a.DepthMode(e.LESS,a.DepthMode.ReadWrite,b.depthRangeFor3D);for(const g of i){const k=h.getTile(g),l=bg(g.projMatrix,0);c.setupElevationDraw(k,f),f.draw(d,e.TRIANGLES,j,a.StencilMode.disabled,a.ColorMode.unblended,a.CullFaceMode.backCCW,l,"terrain_depth",c.gridBuffer,c.gridIndexBuffer,c.gridNoSkirtSegments)}}(e,this,i,this.proxyCoords)}_setupProxiedCoordsForOrtho(a,f,c){if(a.getSource() instanceof s)return this._setupProxiedCoordsForImageSource(a,f,c);this._findCoveringTileCache[a.id]=this._findCoveringTileCache[a.id]||{};const k=this.proxiedCoords[a.id]=[],l=this.proxyCoords;for(let g=0;g(a.min.x=Math.min(a.min.x,b.x-o.x),a.min.y=Math.min(a.min.y,b.y-o.y),a.max.x=Math.max(a.max.x,b.x-o.x),a.max.y=Math.max(a.max.y,b.y-o.y),a),{min:new a.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE),max:new a.pointGeometry(-Number.MAX_VALUE,-Number.MAX_VALUE)}),n=(b,c)=>{const d=b.wrap+b.canonical.x/(1<g+p.max.x||e+fh+p.max.y};for(let f=0;fa.key===c.tileID.key);if(j)return j}if(c.tileID.key!==b.key){const d=b.canonical.z-c.tileID.canonical.z;let f,g,h;e=a.create();const k=c.tileID.wrap-b.wrap<0?(g=(f=a.EXTENT>>d)*((c.tileID.canonical.x<=g){const h=c.canonical.z-g;d.getSource().reparseOverscaled?(e=Math.max(c.canonical.z+2,d.transform.tileZoom),f=new a.OverscaledTileID(e,c.wrap,g,c.canonical.x>>h,c.canonical.y>>h)):0!==h&&(e=g,f=new a.OverscaledTileID(e,c.wrap,g,c.canonical.x>>h,c.canonical.y>>h))}f.key!==c.key&&(m.push(f.key),b=d.getTile(f))}const n=a=>{m.forEach(b=>{l[b]=a}),m.length=0};for(e-=1;e>=o&&(!b||!b.hasData());e--){b&&n(b.tileID.key);const j=f.calculateScaledKey(e);if((b=d.getTileByID(j))&&b.hasData())break;const k=l[j];if(null===k)break;void 0===k?m.push(j):b=d.getTileByID(k)}return n(b?b.tileID.key:null),b&&b.hasData()?b:null}findDEMTileFor(a){return this.enabled?this._findTileCoveringTileID(a,this.sourceCache):null}prepareDrawTile(a){this.renderedToTile=!0}_clearRenderCacheForTile(b,c){let a=this._tilesDirty[b];a||(a=this._tilesDirty[b]={}),a[c.key]=!0}getWirefameBuffer(){if(!this.wireframeSegments){const b=function(g){let f,e,b;const c=new a.StructArrayLayout2ui4,d=131;for(e=1;e<129;e++){for(f=1;f<129;f++)b=e*d+f,c.emplaceBack(b,b+1),c.emplaceBack(b,b+d),c.emplaceBack(b+1,b+d),128===e&&c.emplaceBack(b+d,b+d+1);c.emplaceBack(b+1,b+1+d)}return c}();this.wireframeIndexBuffer=this.painter.context.createIndexBuffer(b),this.wireframeSegments=a.SegmentVector.simpleSegment(0,0,this.gridBuffer.length,b.length)}return[this.wireframeIndexBuffer,this.wireframeSegments,]}}function bs(b){const c=[];for(let a=0;am.indexOf(t)&&m.push(t);let n=e?e.defines():[];n=n.concat(r.map(a=>`#define ${a}`));const D=n.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",a9,a8.fragmentSource,v.fragmentSource,k.fragmentSource).join("\n"),E=n.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",a9,a8.vertexSource,v.vertexSource,u.vertexSource,k.vertexSource).join("\n"),o=d.createShader(d.FRAGMENT_SHADER);if(d.isContextLost())return void(this.failedToCreate=!0);d.shaderSource(o,D),d.compileShader(o),d.attachShader(this.program,o);const p=d.createShader(d.VERTEX_SHADER);if(d.isContextLost())return void(this.failedToCreate=!0);d.shaderSource(p,E),d.compileShader(p),d.attachShader(this.program,p),this.attributes={};const i={};this.numAttributes=l.length;for(let f=0;f>16,g>>16],u_pixel_coord_lower:[65535&f,65535&g]}}const bv=(h,f,i,j)=>{const b=f.style.light,c=b.properties.get("position"),d=[c.x,c.y,c.z],g=a.create$1();"viewport"===b.properties.get("anchor")&&(a.fromRotation(g,-f.transform.angle),a.transformMat3(d,d,g));const e=b.properties.get("color");return{u_matrix:h,u_lightpos:d,u_lightintensity:b.properties.get("intensity"),u_lightcolor:[e.r,e.g,e.b],u_vertical_gradient:+i,u_opacity:j}},bw=(d,b,e,f,g,h,c)=>a.extend(bv(d,b,e,f),bu(h,b,c),{u_height_factor:-Math.pow(2,g.overscaledZ)/c.tileSize/8}),bx=a=>({u_matrix:a}),by=(b,c,d,e)=>a.extend(bx(b),bu(d,c,e)),bz=(a,b)=>({u_matrix:a,u_world:b}),bA=(b,c,d,e,f)=>a.extend(by(b,c,d,e),{u_world:f}),bB=(d,g,e,c)=>{const b=d.transform;let f;return f="map"===c.paint.get("circle-pitch-alignment")?b.calculatePixelsToTileUnitsMatrix(e):new Float32Array([b.pixelsToGLUnits[0],0,0,b.pixelsToGLUnits[1],]),{u_camera_to_center_distance:b.cameraToCenterDistance,u_matrix:d.translatePosMatrix(g.projMatrix,e,c.paint.get("circle-translate"),c.paint.get("circle-translate-anchor")),u_device_pixel_ratio:a.exported.devicePixelRatio,u_extrude_scale:f}},bC=b=>{const a=[];return"map"===b.paint.get("circle-pitch-alignment")&&a.push("PITCH_WITH_MAP"),"map"===b.paint.get("circle-pitch-scale")&&a.push("SCALE_WITH_MAP"),a},bD=(d,b,e)=>{const c=a.EXTENT/e.tileSize;return{u_matrix:d,u_camera_to_center_distance:b.cameraToCenterDistance,u_extrude_scale:[b.pixelsToGLUnits[0]/c,b.pixelsToGLUnits[1]/c,]}},bE=(a,b,c=1)=>({u_matrix:a,u_color:b,u_overlay:0,u_overlay_scale:c}),bF=(a,b,c,d)=>({u_matrix:a,u_extrude_scale:V(b,1,c),u_intensity:d}),bG=(d,b,g,e,h,i)=>{const f=d.transform,j=f.calculatePixelsToTileUnitsMatrix(b),c={u_matrix:bJ(d,b,g,h),u_pixels_to_tile_units:j,u_device_pixel_ratio:a.exported.devicePixelRatio,u_units_to_pixels:[1/f.pixelsToGLUnits[0],1/f.pixelsToGLUnits[1],],u_dash_image:0,u_gradient_image:1,u_image_height:i,u_texsize:[0,0],u_scale:[0,0,0],u_mix:0,u_alpha_discard_threshold:0};if(bK(g)){const k=bI(b,d.transform);c.u_texsize=b.lineAtlasTexture.size,c.u_scale=[k,e.fromScale,e.toScale,],c.u_mix=e.t}return c},bH=(e,b,f,d,g)=>{const c=e.transform,h=bI(b,c);return{u_matrix:bJ(e,b,f,g),u_texsize:b.imageAtlasTexture.size,u_pixels_to_tile_units:c.calculatePixelsToTileUnitsMatrix(b),u_device_pixel_ratio:a.exported.devicePixelRatio,u_image:0,u_scale:[h,d.fromScale,d.toScale],u_fade:d.t,u_units_to_pixels:[1/c.pixelsToGLUnits[0],1/c.pixelsToGLUnits[1],],u_alpha_discard_threshold:0}};function bI(a,b){return 1/V(a,1,b.tileZoom)}function bJ(c,a,b,d){return c.translatePosMatrix(d||a.tileID.projMatrix,a,b.paint.get("line-translate"),b.paint.get("line-translate-anchor"))}function bK(b){const a=b.paint.get("line-dasharray").value;return a.value||"constant"!==a.kind}const bL=(e,f,g,d,a,h)=>{var b,c;return{u_matrix:e,u_tl_parent:f,u_scale_parent:g,u_fade_t:d.mix,u_opacity:d.opacity*a.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:a.paint.get("raster-brightness-min"),u_brightness_high:a.paint.get("raster-brightness-max"),u_saturation_factor:(c=a.paint.get("raster-saturation"))>0?1-1/(1.001-c):-c,u_contrast_factor:(b=a.paint.get("raster-contrast"))>0?1/(1-b):1+b,u_spin_weights:bM(a.paint.get("raster-hue-rotate")),u_perspective_transform:h}};function bM(a){a*=Math.PI/180;const c=Math.sin(a),b=Math.cos(a);return[(2*b+1)/3,(-Math.sqrt(3)*c-b+1)/3,(Math.sqrt(3)*c-b+1)/3,]}const bN=(a,b,e,f,d,g,h,i,j,k,l,m,n,o)=>{const c=d.transform;return{u_is_size_zoom_constant:+("constant"===a||"source"===a),u_is_size_feature_constant:+("constant"===a||"camera"===a),u_size_t:b?b.uSizeT:0,u_size:b?b.uSize:0,u_camera_to_center_distance:c.cameraToCenterDistance,u_pitch:c.pitch/360*2*Math.PI,u_rotate_symbol:+e,u_aspect_ratio:c.width/c.height,u_fade_change:d.options.fadeDuration?d.symbolFadeChange:1,u_matrix:g,u_label_plane_matrix:h,u_coord_matrix:i,u_is_text:+j,u_pitch_with_map:+f,u_texsize:k,u_tile_id:l,u_zoom_transition:m,u_inv_rot_matrix:n,u_merc_center:o,u_texture:0}},bO=(d,e,f,c,b,g,h,i,j,k,l,m,n,o,p)=>{const{cameraToCenterDistance:q,_pitch:r}=b.transform;return a.extend(bN(d,e,f,c,b,g,h,i,j,k,m,n,o,p),{u_gamma_scale:c?q*Math.cos(b.terrain?0:r):1,u_device_pixel_ratio:a.exported.devicePixelRatio,u_is_halo:+l})},bP=(b,c,d,e,f,g,h,i,j,k,l,m,n,o)=>a.extend(bO(b,c,d,e,f,g,h,i,!0,j,!0,l,m,n,o),{u_texsize_icon:k,u_texture_icon:1}),bQ=(a,b,c)=>({u_matrix:a,u_opacity:b,u_color:c}),bR=(b,c,d,e,f,g)=>a.extend(function(f,c,b,a){const d=b.imageManager.getPattern(f.from.toString()),e=b.imageManager.getPattern(f.to.toString()),{width:k,height:l}=b.imageManager.getPixelSize(),g=Math.pow(2,a.tileID.overscaledZ),h=a.tileSize*Math.pow(2,b.transform.tileZoom)/g,i=h*(a.tileID.canonical.x+a.tileID.wrap*g),j=h*a.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:d.tl,u_pattern_br_a:d.br,u_pattern_tl_b:e.tl,u_pattern_br_b:e.br,u_texsize:[k,l],u_mix:c.t,u_pattern_size_a:d.displaySize,u_pattern_size_b:e.displaySize,u_scale_a:c.fromScale,u_scale_b:c.toScale,u_tile_units_to_pixels:1/V(a,1,b.transform.tileZoom),u_pixel_coord_upper:[i>>16,j>>16,],u_pixel_coord_lower:[65535&i,65535&j,]}}(e,g,d,f),{u_matrix:b,u_opacity:c}),bS={fillExtrusion:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_lightpos:new a.Uniform3f(b,c.u_lightpos),u_lightintensity:new a.Uniform1f(b,c.u_lightintensity),u_lightcolor:new a.Uniform3f(b,c.u_lightcolor),u_vertical_gradient:new a.Uniform1f(b,c.u_vertical_gradient),u_opacity:new a.Uniform1f(b,c.u_opacity)}),fillExtrusionPattern:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_lightpos:new a.Uniform3f(b,c.u_lightpos),u_lightintensity:new a.Uniform1f(b,c.u_lightintensity),u_lightcolor:new a.Uniform3f(b,c.u_lightcolor),u_vertical_gradient:new a.Uniform1f(b,c.u_vertical_gradient),u_height_factor:new a.Uniform1f(b,c.u_height_factor),u_image:new a.Uniform1i(b,c.u_image),u_texsize:new a.Uniform2f(b,c.u_texsize),u_pixel_coord_upper:new a.Uniform2f(b,c.u_pixel_coord_upper),u_pixel_coord_lower:new a.Uniform2f(b,c.u_pixel_coord_lower),u_scale:new a.Uniform3f(b,c.u_scale),u_fade:new a.Uniform1f(b,c.u_fade),u_opacity:new a.Uniform1f(b,c.u_opacity)}),fill:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix)}),fillPattern:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_image:new a.Uniform1i(b,c.u_image),u_texsize:new a.Uniform2f(b,c.u_texsize),u_pixel_coord_upper:new a.Uniform2f(b,c.u_pixel_coord_upper),u_pixel_coord_lower:new a.Uniform2f(b,c.u_pixel_coord_lower),u_scale:new a.Uniform3f(b,c.u_scale),u_fade:new a.Uniform1f(b,c.u_fade)}),fillOutline:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_world:new a.Uniform2f(b,c.u_world)}),fillOutlinePattern:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_world:new a.Uniform2f(b,c.u_world),u_image:new a.Uniform1i(b,c.u_image),u_texsize:new a.Uniform2f(b,c.u_texsize),u_pixel_coord_upper:new a.Uniform2f(b,c.u_pixel_coord_upper),u_pixel_coord_lower:new a.Uniform2f(b,c.u_pixel_coord_lower),u_scale:new a.Uniform3f(b,c.u_scale),u_fade:new a.Uniform1f(b,c.u_fade)}),circle:(b,c)=>({u_camera_to_center_distance:new a.Uniform1f(b,c.u_camera_to_center_distance),u_extrude_scale:new a.UniformMatrix2f(b,c.u_extrude_scale),u_device_pixel_ratio:new a.Uniform1f(b,c.u_device_pixel_ratio),u_matrix:new a.UniformMatrix4f(b,c.u_matrix)}),collisionBox:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_camera_to_center_distance:new a.Uniform1f(b,c.u_camera_to_center_distance),u_extrude_scale:new a.Uniform2f(b,c.u_extrude_scale)}),collisionCircle:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_inv_matrix:new a.UniformMatrix4f(b,c.u_inv_matrix),u_camera_to_center_distance:new a.Uniform1f(b,c.u_camera_to_center_distance),u_viewport_size:new a.Uniform2f(b,c.u_viewport_size)}),debug:(b,c)=>({u_color:new a.UniformColor(b,c.u_color),u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_overlay:new a.Uniform1i(b,c.u_overlay),u_overlay_scale:new a.Uniform1f(b,c.u_overlay_scale)}),clippingMask:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix)}),heatmap:(b,c)=>({u_extrude_scale:new a.Uniform1f(b,c.u_extrude_scale),u_intensity:new a.Uniform1f(b,c.u_intensity),u_matrix:new a.UniformMatrix4f(b,c.u_matrix)}),heatmapTexture:(b,c)=>({u_image:new a.Uniform1i(b,c.u_image),u_color_ramp:new a.Uniform1i(b,c.u_color_ramp),u_opacity:new a.Uniform1f(b,c.u_opacity)}),hillshade:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_image:new a.Uniform1i(b,c.u_image),u_latrange:new a.Uniform2f(b,c.u_latrange),u_light:new a.Uniform2f(b,c.u_light),u_shadow:new a.UniformColor(b,c.u_shadow),u_highlight:new a.UniformColor(b,c.u_highlight),u_accent:new a.UniformColor(b,c.u_accent)}),hillshadePrepare:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_image:new a.Uniform1i(b,c.u_image),u_dimension:new a.Uniform2f(b,c.u_dimension),u_zoom:new a.Uniform1f(b,c.u_zoom),u_unpack:new a.Uniform4f(b,c.u_unpack)}),line:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_pixels_to_tile_units:new a.UniformMatrix2f(b,c.u_pixels_to_tile_units),u_device_pixel_ratio:new a.Uniform1f(b,c.u_device_pixel_ratio),u_units_to_pixels:new a.Uniform2f(b,c.u_units_to_pixels),u_dash_image:new a.Uniform1i(b,c.u_dash_image),u_gradient_image:new a.Uniform1i(b,c.u_gradient_image),u_image_height:new a.Uniform1f(b,c.u_image_height),u_texsize:new a.Uniform2f(b,c.u_texsize),u_scale:new a.Uniform3f(b,c.u_scale),u_mix:new a.Uniform1f(b,c.u_mix),u_alpha_discard_threshold:new a.Uniform1f(b,c.u_alpha_discard_threshold)}),linePattern:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_texsize:new a.Uniform2f(b,c.u_texsize),u_pixels_to_tile_units:new a.UniformMatrix2f(b,c.u_pixels_to_tile_units),u_device_pixel_ratio:new a.Uniform1f(b,c.u_device_pixel_ratio),u_image:new a.Uniform1i(b,c.u_image),u_units_to_pixels:new a.Uniform2f(b,c.u_units_to_pixels),u_scale:new a.Uniform3f(b,c.u_scale),u_fade:new a.Uniform1f(b,c.u_fade),u_alpha_discard_threshold:new a.Uniform1f(b,c.u_alpha_discard_threshold)}),raster:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_tl_parent:new a.Uniform2f(b,c.u_tl_parent),u_scale_parent:new a.Uniform1f(b,c.u_scale_parent),u_fade_t:new a.Uniform1f(b,c.u_fade_t),u_opacity:new a.Uniform1f(b,c.u_opacity),u_image0:new a.Uniform1i(b,c.u_image0),u_image1:new a.Uniform1i(b,c.u_image1),u_brightness_low:new a.Uniform1f(b,c.u_brightness_low),u_brightness_high:new a.Uniform1f(b,c.u_brightness_high),u_saturation_factor:new a.Uniform1f(b,c.u_saturation_factor),u_contrast_factor:new a.Uniform1f(b,c.u_contrast_factor),u_spin_weights:new a.Uniform3f(b,c.u_spin_weights),u_perspective_transform:new a.Uniform2f(b,c.u_perspective_transform)}),symbolIcon:(b,c)=>({u_is_size_zoom_constant:new a.Uniform1i(b,c.u_is_size_zoom_constant),u_is_size_feature_constant:new a.Uniform1i(b,c.u_is_size_feature_constant),u_size_t:new a.Uniform1f(b,c.u_size_t),u_size:new a.Uniform1f(b,c.u_size),u_camera_to_center_distance:new a.Uniform1f(b,c.u_camera_to_center_distance),u_pitch:new a.Uniform1f(b,c.u_pitch),u_rotate_symbol:new a.Uniform1i(b,c.u_rotate_symbol),u_aspect_ratio:new a.Uniform1f(b,c.u_aspect_ratio),u_fade_change:new a.Uniform1f(b,c.u_fade_change),u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_label_plane_matrix:new a.UniformMatrix4f(b,c.u_label_plane_matrix),u_coord_matrix:new a.UniformMatrix4f(b,c.u_coord_matrix),u_is_text:new a.Uniform1i(b,c.u_is_text),u_pitch_with_map:new a.Uniform1i(b,c.u_pitch_with_map),u_texsize:new a.Uniform2f(b,c.u_texsize),u_tile_id:new a.Uniform3f(b,c.u_tile_id),u_zoom_transition:new a.Uniform1f(b,c.u_zoom_transition),u_inv_rot_matrix:new a.UniformMatrix4f(b,c.u_inv_rot_matrix),u_merc_center:new a.Uniform2f(b,c.u_merc_center),u_texture:new a.Uniform1i(b,c.u_texture)}),symbolSDF:(b,c)=>({u_is_size_zoom_constant:new a.Uniform1i(b,c.u_is_size_zoom_constant),u_is_size_feature_constant:new a.Uniform1i(b,c.u_is_size_feature_constant),u_size_t:new a.Uniform1f(b,c.u_size_t),u_size:new a.Uniform1f(b,c.u_size),u_camera_to_center_distance:new a.Uniform1f(b,c.u_camera_to_center_distance),u_pitch:new a.Uniform1f(b,c.u_pitch),u_rotate_symbol:new a.Uniform1i(b,c.u_rotate_symbol),u_aspect_ratio:new a.Uniform1f(b,c.u_aspect_ratio),u_fade_change:new a.Uniform1f(b,c.u_fade_change),u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_label_plane_matrix:new a.UniformMatrix4f(b,c.u_label_plane_matrix),u_coord_matrix:new a.UniformMatrix4f(b,c.u_coord_matrix),u_is_text:new a.Uniform1i(b,c.u_is_text),u_pitch_with_map:new a.Uniform1i(b,c.u_pitch_with_map),u_texsize:new a.Uniform2f(b,c.u_texsize),u_texture:new a.Uniform1i(b,c.u_texture),u_gamma_scale:new a.Uniform1f(b,c.u_gamma_scale),u_device_pixel_ratio:new a.Uniform1f(b,c.u_device_pixel_ratio),u_tile_id:new a.Uniform3f(b,c.u_tile_id),u_zoom_transition:new a.Uniform1f(b,c.u_zoom_transition),u_inv_rot_matrix:new a.UniformMatrix4f(b,c.u_inv_rot_matrix),u_merc_center:new a.Uniform2f(b,c.u_merc_center),u_is_halo:new a.Uniform1i(b,c.u_is_halo)}),symbolTextAndIcon:(b,c)=>({u_is_size_zoom_constant:new a.Uniform1i(b,c.u_is_size_zoom_constant),u_is_size_feature_constant:new a.Uniform1i(b,c.u_is_size_feature_constant),u_size_t:new a.Uniform1f(b,c.u_size_t),u_size:new a.Uniform1f(b,c.u_size),u_camera_to_center_distance:new a.Uniform1f(b,c.u_camera_to_center_distance),u_pitch:new a.Uniform1f(b,c.u_pitch),u_rotate_symbol:new a.Uniform1i(b,c.u_rotate_symbol),u_aspect_ratio:new a.Uniform1f(b,c.u_aspect_ratio),u_fade_change:new a.Uniform1f(b,c.u_fade_change),u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_label_plane_matrix:new a.UniformMatrix4f(b,c.u_label_plane_matrix),u_coord_matrix:new a.UniformMatrix4f(b,c.u_coord_matrix),u_is_text:new a.Uniform1i(b,c.u_is_text),u_pitch_with_map:new a.Uniform1i(b,c.u_pitch_with_map),u_texsize:new a.Uniform2f(b,c.u_texsize),u_texsize_icon:new a.Uniform2f(b,c.u_texsize_icon),u_texture:new a.Uniform1i(b,c.u_texture),u_texture_icon:new a.Uniform1i(b,c.u_texture_icon),u_gamma_scale:new a.Uniform1f(b,c.u_gamma_scale),u_device_pixel_ratio:new a.Uniform1f(b,c.u_device_pixel_ratio),u_is_halo:new a.Uniform1i(b,c.u_is_halo)}),background:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_opacity:new a.Uniform1f(b,c.u_opacity),u_color:new a.UniformColor(b,c.u_color)}),backgroundPattern:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_opacity:new a.Uniform1f(b,c.u_opacity),u_image:new a.Uniform1i(b,c.u_image),u_pattern_tl_a:new a.Uniform2f(b,c.u_pattern_tl_a),u_pattern_br_a:new a.Uniform2f(b,c.u_pattern_br_a),u_pattern_tl_b:new a.Uniform2f(b,c.u_pattern_tl_b),u_pattern_br_b:new a.Uniform2f(b,c.u_pattern_br_b),u_texsize:new a.Uniform2f(b,c.u_texsize),u_mix:new a.Uniform1f(b,c.u_mix),u_pattern_size_a:new a.Uniform2f(b,c.u_pattern_size_a),u_pattern_size_b:new a.Uniform2f(b,c.u_pattern_size_b),u_scale_a:new a.Uniform1f(b,c.u_scale_a),u_scale_b:new a.Uniform1f(b,c.u_scale_b),u_pixel_coord_upper:new a.Uniform2f(b,c.u_pixel_coord_upper),u_pixel_coord_lower:new a.Uniform2f(b,c.u_pixel_coord_lower),u_tile_units_to_pixels:new a.Uniform1f(b,c.u_tile_units_to_pixels)}),terrainRaster:k,terrainDepth:k,skybox:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_sun_direction:new a.Uniform3f(b,c.u_sun_direction),u_cubemap:new a.Uniform1i(b,c.u_cubemap),u_opacity:new a.Uniform1f(b,c.u_opacity),u_temporal_offset:new a.Uniform1f(b,c.u_temporal_offset)}),skyboxGradient:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_color_ramp:new a.Uniform1i(b,c.u_color_ramp),u_center_direction:new a.Uniform3f(b,c.u_center_direction),u_radius:new a.Uniform1f(b,c.u_radius),u_opacity:new a.Uniform1f(b,c.u_opacity),u_temporal_offset:new a.Uniform1f(b,c.u_temporal_offset)}),skyboxCapture:(b,c)=>({u_matrix_3f:new a.UniformMatrix3f(b,c.u_matrix_3f),u_sun_direction:new a.Uniform3f(b,c.u_sun_direction),u_sun_intensity:new a.Uniform1f(b,c.u_sun_intensity),u_color_tint_r:new a.Uniform4f(b,c.u_color_tint_r),u_color_tint_m:new a.Uniform4f(b,c.u_color_tint_m),u_luminance:new a.Uniform1f(b,c.u_luminance)}),globeRaster:(b,c)=>({u_proj_matrix:new a.UniformMatrix4f(b,c.u_proj_matrix),u_globe_matrix:new a.UniformMatrix4f(b,c.u_globe_matrix),u_merc_matrix:new a.UniformMatrix4f(b,c.u_merc_matrix),u_zoom_transition:new a.Uniform1f(b,c.u_zoom_transition),u_merc_center:new a.Uniform2f(b,c.u_merc_center),u_image0:new a.Uniform1i(b,c.u_image0)}),globeAtmosphere:(b,c)=>({u_center:new a.Uniform2f(b,c.u_center),u_radius:new a.Uniform1f(b,c.u_radius),u_screen_size:new a.Uniform2f(b,c.u_screen_size),u_pixel_ratio:new a.Uniform1f(b,c.u_pixel_ratio),u_opacity:new a.Uniform1f(b,c.u_opacity),u_fadeout_range:new a.Uniform1f(b,c.u_fadeout_range),u_start_color:new a.Uniform3f(b,c.u_start_color),u_end_color:new a.Uniform3f(b,c.u_end_color)})};let bT;function bU(b,H,s,A,t,I,B){var u;const f=b.context,C=f.gl,D=b.useProgram("collisionBox"),j=[];let g=0,E=0;for(let v=0;v0){const l=a.create(),J=x;a.mul(l,d.placementInvProjMatrix,b.transform.glCoordMatrix),a.mul(l,l,d.placementViewportMatrix),j.push({circleArray:y,circleOffset:E,transform:J,invTransform:l}),g+=y.length/4,E=g}e&&(b.terrain&&b.terrain.setupElevationDraw(k,D),D.draw(f,C.LINES,a.DepthMode.disabled,a.StencilMode.disabled,b.colorModeForRenderPass(),a.CullFaceMode.disabled,bD(x,b.transform,k),s.id,e.layoutVertexBuffer,e.indexBuffer,e.segments,null,b.transform.zoom,null,e.collisionVertexBuffer,e.collisionVertexBufferExt))}if(!B||!j.length)return;const K=b.useProgram("collisionCircle"),c=new a.StructArrayLayout2f1f2i16;c.resize(4*g),c._trim();let m=0;for(const h of j)for(let z=0;z[0,0,0];e.clear();for(let j=0;j=0&&(r[b.associatedIconIndex]={shiftedAnchor:x,angle:y})}else aO(b.numGlyphs,e)}if(p){d.clear();const A=c.icon.placedSymbolArray;for(let f=0;f[0,0,0];aG(d,g.projMatrix,b,i,C,W,j,ad,am,g)}const D=b.translatePosMatrix(g.projMatrix,e,J,K),E=n||i&&Q||al?bV:C,F=b.translatePosMatrix(W,e,J,K,!0),an=o&&0!==h.paint.get(i?"text-halo-width":"icon-halo-width").constantOr(1);let Y;const G=N.createInversionMatrix(g.toUnwrapped());Y=o?d.iconsInText?bP(m.kind,y,u,j,b,D,E,F,p,T,z,x,G,v):bO(m.kind,y,u,j,b,D,E,F,i,p,!0,z,x,G,v):bN(m.kind,y,u,j,b,D,E,F,i,p,z,x,G,v);const Z={program:ag,buffers:l,uniformValues:Y,atlasTexture:A,atlasTextureIcon:U,atlasInterpolation:B,atlasInterpolationIcon:S,isSDF:o,hasHalo:an,tile:e,labelPlaneMatrixInv:aj};if(ae&&d.canOverlap){O=!0;const ao=l.segments.get();for(const $ of ao)r.push({segments:new a.SegmentVector([$]),sortKey:$.sortKey,state:Z})}else r.push({segments:l.segments,sortKey:0,state:Z})}for(const H of(O&&r.sort((a,b)=>a.sortKey-b.sortKey),r)){const c=H.state;if(b.terrain&&b.terrain.setupElevationDraw(c.tile,c.program,{useDepthForOcclusion:!w,labelPlaneMatrixInv:c.labelPlaneMatrixInv}),t.activeTexture.set(k.TEXTURE0),c.atlasTexture.bind(c.atlasInterpolation,k.CLAMP_TO_EDGE),c.atlasTextureIcon&&(t.activeTexture.set(k.TEXTURE1),c.atlasTextureIcon&&c.atlasTextureIcon.bind(c.atlasInterpolationIcon,k.CLAMP_TO_EDGE)),c.isSDF){const I=c.uniformValues;c.hasHalo&&(I.u_is_halo=1,b$(c.buffers,H.segments,h,b,c.program,P,L,M,I)),I.u_is_halo=0}b$(c.buffers,H.segments,h,b,c.program,P,L,M,c.uniformValues)}}function b$(b,f,c,d,g,h,i,j,k){const e=d.context;g.draw(e,e.gl.TRIANGLES,h,i,j,a.CullFaceMode.disabled,k,c.id,b.layoutVertexBuffer,b.indexBuffer,f,c.paint,d.transform.zoom,b.programConfigurations.get(c.id),b.dynamicLayoutVertexBuffer,b.opacityVertexBuffer)}function b_(b,y,c,z,A,B,s){const e=b.context.gl,l=c.paint.get("fill-pattern"),g=l&&l.constantOr(1),m=c.getCrossfadeParameters();let n,i,o,p,q;for(const h of(s?(i=g&&!c.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",n=e.LINES):(i=g?"fillPattern":"fill",n=e.TRIANGLES),z)){const d=y.getTile(h);if(g&&!d.patternsLoaded())continue;const f=d.getBucket(c);if(!f)continue;b.prepareDrawTile(h);const j=f.programConfigurations.get(c.id),t=b.useProgram(i,j);g&&(b.context.activeTexture.set(e.TEXTURE0),d.imageAtlasTexture.bind(e.LINEAR,e.CLAMP_TO_EDGE),j.updatePaintBuffers(m));const r=l.constantOr(null);if(r&&d.imageAtlas){const u=d.imageAtlas,v=u.patternPositions[r.to.toString()],w=u.patternPositions[r.from.toString()];v&&w&&j.setConstantPatternPositions(v,w)}const k=b.translatePosMatrix(h.projMatrix,d,c.paint.get("fill-translate"),c.paint.get("fill-translate-anchor"));if(s){p=f.indexBuffer2,q=f.segments2;const x=b.terrain&&b.terrain.renderingToTexture?b.terrain.drapeBufferSize:[e.drawingBufferWidth,e.drawingBufferHeight,];o="fillOutlinePattern"===i&&g?bA(k,b,m,d,x):bz(k,x)}else p=f.indexBuffer,q=f.segments,o=g?by(k,b,m,d):bx(k);b.prepareDrawProgram(b.context,t,h.toUnwrapped()),t.draw(b.context,n,A,b.stencilModeForClipping(h),B,a.CullFaceMode.disabled,o,c.id,f.layoutVertexBuffer,p,q,c.paint,b.transform.zoom,j)}}function b0(b,m,c,x,y,z,A){const f=b.context,h=f.gl,n=c.paint.get("fill-extrusion-pattern"),k=n.constantOr(1),o=c.getCrossfadeParameters(),p=c.paint.get("fill-extrusion-opacity");for(const g of x){const e=m.getTile(g),d=e.getBucket(c);if(!d)continue;const i=d.programConfigurations.get(c.id),j=b.useProgram(k?"fillExtrusionPattern":"fillExtrusion",i);if(b.terrain){const q=b.terrain;if(!d.enableTerrain)continue;if(q.setupElevationDraw(e,j,{useMeterToDem:!0}),b1(f,m,g,d,c,q),!d.centroidVertexBuffer){const r=j.attributes.a_centroid_pos;void 0!==r&&h.vertexAttrib2f(r,0,0)}}k&&(b.context.activeTexture.set(h.TEXTURE0),e.imageAtlasTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),i.updatePaintBuffers(o));const l=n.constantOr(null);if(l&&e.imageAtlas){const s=e.imageAtlas,t=s.patternPositions[l.to.toString()],u=s.patternPositions[l.from.toString()];t&&u&&i.setConstantPatternPositions(t,u)}const v=b.translatePosMatrix(g.projMatrix,e,c.paint.get("fill-extrusion-translate"),c.paint.get("fill-extrusion-translate-anchor")),w=c.paint.get("fill-extrusion-vertical-gradient"),B=k?bw(v,b,w,p,g,o,e):bv(v,b,w,p);b.prepareDrawProgram(f,j,g.toUnwrapped()),j.draw(f,f.gl.TRIANGLES,y,z,A,a.CullFaceMode.backCCW,B,c.id,d.layoutVertexBuffer,d.indexBuffer,d.segments,c.paint,b.transform.zoom,i,b.terrain?d.centroidVertexBuffer:null)}}function b1(w,D,p,c,E,q){const x=[b=>{let c=b.canonical.x-1,d=b.wrap;return c<0&&(c=(1<{let c=b.canonical.x+1,d=b.wrap;return c===1<new a.OverscaledTileID(b.overscaledZ,b.wrap,b.canonical.z,b.canonical.x,(0===b.canonical.y?1<new a.OverscaledTileID(b.overscaledZ,b.wrap,b.canonical.z,b.canonical.x,b.canonical.y===(1<{const b=D.getSource().maxzoom,c=b=>{const a=D.getTileByID(b);if(a&&a.hasData())return a.getBucket(E)};let d,e,f;return(a.overscaledZ===a.canonical.z||a.overscaledZ>=b)&&(d=c(a.key)),a.overscaledZ>=b&&(e=c(a.calculateScaledKey(a.overscaledZ+1))),a.overscaledZ>b&&(f=c(a.calculateScaledKey(a.overscaledZ-1))),d||e||f},F=[0,0,0],G=(b,c)=>(F[0]=Math.min(b.min.y,c.min.y),F[1]=Math.max(b.max.y,c.max.y),F[2]=a.EXTENT-c.min.x>b.max.x?c.min.x-a.EXTENT:b.max.x,F),H=(b,c)=>(F[0]=Math.min(b.min.x,c.min.x),F[1]=Math.max(b.max.x,c.max.x),F[2]=a.EXTENT-c.min.y>b.max.y?c.min.y-a.EXTENT:b.max.y,F),z=[(a,b)=>G(a,b),(a,b)=>G(b,a),(a,b)=>H(a,b),(a,b)=>H(b,a),],j=new a.pointGeometry(0,0);let r,s,A;const B=(e,f,b,c,d)=>{const g=[[c?b:e,c?e:b,0],[c?b:f,c?f:b,0],],i=d<0?a.EXTENT+d:d,h=[c?i:(e+f)/2,c?(e+f)/2:i,0,];return 0===b&&d<0||0!==b&&d>0?q.getForTilePoints(A,[h],!0,s):g.push(h),q.getForTilePoints(p,g,!0,r),Math.max(g[0][2],g[1][2],h[2])/q.exaggeration()};for(let d=0;d<4;d++){const k=c.borders[d];if(0===k.length&&(c.borderDone[d]=!0),c.borderDone[d])continue;const t=A=x[d](p),b=y(t);if(!b||!b.enableTerrain)continue;if(!(s=q.findDEMTileFor(t))||!s.dem)continue;if(!r){const l=q.findDEMTileFor(p);if(!l||!l.dem)return;r=l}const f=(d<2?1:5)-d,h=b.borders[f];let g=0;for(let m=0;mu[0]+3);)b.borderDone[f]||b.encodeCentroid(void 0,e,!1),g++;if(e&&gu[1]-3)&&(n++,++g!==h.length);)e=b.featuresOnBorder[h[g]];if(e=b.featuresOnBorder[h[v]],i.intersectsCount()>1||e.intersectsCount()>1||1!==n){1!==n&&(g=v),c.encodeCentroid(void 0,i,!1),b.borderDone[f]||b.encodeCentroid(void 0,e,!1);continue}const o=z[d](i,e),C=d%2?a.EXTENT-1:0;j.x=B(o[0],Math.min(a.EXTENT-1,o[1]),C,d<2,o[2]),j.y=0,c.encodeCentroid(j,i,!1),b.borderDone[f]||b.encodeCentroid(j,e,!1)}else c.encodeCentroid(void 0,i,!1)}c.borderDone[d]=c.needsCentroidUpdate=!0,b.borderDone[f]||(b.borderDone[f]=b.needsCentroidUpdate=!0)}(c.needsCentroidUpdate|| !c.centroidVertexBuffer&&0!==c.centroidVertexArray.length)&&c.uploadCentroid(w)}const b2=new a.Color(1,0,0,1),b3=new a.Color(0,1,0,1),b4=new a.Color(0,0,1,1),b5=new a.Color(1,0,1,1),b6=new a.Color(0,1,1,1);function b7(a,c,b,d){b9(a,0,c+b/2,a.transform.width,b,d)}function b8(a,c,b,d){b9(a,c-b/2,0,b,a.transform.height,d)}function b9(d,e,f,g,h,i){const c=d.context,b=c.gl;b.enable(b.SCISSOR_TEST),b.scissor(e*a.exported.devicePixelRatio,f*a.exported.devicePixelRatio,g*a.exported.devicePixelRatio,h*a.exported.devicePixelRatio),c.clear({color:i}),b.disable(b.SCISSOR_TEST)}function ca(b,h,c){const f=b.context,e=f.gl,i=c.projMatrix,g=b.useProgram("debug"),d=h.getTileByID(c.key);b.terrain&&b.terrain.setupElevationDraw(d,g);const j=a.DepthMode.disabled,k=a.StencilMode.disabled,o=b.colorModeForRenderPass(),l="$debug";f.activeTexture.set(e.TEXTURE0),b.emptyTexture.bind(e.LINEAR,e.CLAMP_TO_EDGE),d._makeDebugTileBoundsBuffers(b.context,b.transform.projection);const p=d._tileDebugBuffer||b.debugBuffer,q=d._tileDebugIndexBuffer||b.debugIndexBuffer,r=d._tileDebugSegments||b.debugSegments;g.draw(f,e.LINE_STRIP,j,k,o,a.CullFaceMode.disabled,bE(i,a.Color.red),l,p,q,r);const m=d.latestRawTileData,s=Math.floor((m&&m.byteLength||0)/1024),t=h.getTile(c).tileSize,u=512/Math.min(t,512)*(c.overscaledZ/b.transform.zoom)*.5;let n=c.canonical.toString();c.overscaledZ!==c.canonical.z&&(n+=` => ${c.overscaledZ}`),function(b,d){b.initDebugOverlayCanvas();const c=b.debugOverlayCanvas,e=b.context.gl,a=b.debugOverlayCanvas.getContext("2d");a.clearRect(0,0,c.width,c.height),a.shadowColor="white",a.shadowBlur=2,a.lineWidth=1.5,a.strokeStyle="white",a.textBaseline="top",a.font="bold 36px Open Sans, sans-serif",a.fillText(d,5,5),a.strokeText(d,5,5),b.debugOverlayTexture.update(c),b.debugOverlayTexture.bind(e.LINEAR,e.CLAMP_TO_EDGE)}(b,`${n} ${s}kb`),g.draw(f,e.TRIANGLES,j,k,a.ColorMode.alphaBlended,a.CullFaceMode.disabled,bE(i,a.Color.transparent,u),l,b.debugBuffer,b.quadTriangleIndexBuffer,b.debugSegments)}const w=a.createLayout([{name:"a_pos_3f",components:3,type:"Float32"},]),{members:cb}=w;function cc(a,b,c,d){a.emplaceBack(b,c,d)}class cd{constructor(b){this.vertexArray=new a.StructArrayLayout3f12,this.indices=new a.StructArrayLayout3ui6,cc(this.vertexArray,-1,-1,1),cc(this.vertexArray,1,-1,1),cc(this.vertexArray,-1,1,1),cc(this.vertexArray,1,1,1),cc(this.vertexArray,-1,-1,-1),cc(this.vertexArray,1,-1,-1),cc(this.vertexArray,-1,1,-1),cc(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=b.createVertexBuffer(this.vertexArray,cb),this.indexBuffer=b.createIndexBuffer(this.indices),this.segment=a.SegmentVector.simpleSegment(0,0,36,12)}}function ce(f,b,j,k,l,m){var g,h,i,c,d;const e=f.gl,n=b.paint.get("sky-atmosphere-color"),o=b.paint.get("sky-atmosphere-halo-color"),p=b.paint.get("sky-atmosphere-sun-intensity"),q=(g=a.fromMat4([],k),h=l,i=p,c=n,d=o,{u_matrix_3f:g,u_sun_direction:h,u_sun_intensity:i,u_color_tint_r:[c.r,c.g,c.b,c.a],u_color_tint_m:[d.r,d.g,d.b,d.a],u_luminance:5e-5});e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+m,b.skyboxTexture,0),j.draw(f,e.TRIANGLES,a.DepthMode.disabled,a.StencilMode.disabled,a.ColorMode.unblended,a.CullFaceMode.frontCW,q,"skyboxCapture",b.skyboxGeometry.vertexBuffer,b.skyboxGeometry.indexBuffer,b.skyboxGeometry.segment)}const cf={symbol:function(c,d,b,e,h){if("translucent"!==c.renderPass)return;const f=a.StencilMode.disabled,g=c.colorModeForRenderPass();b.layout.get("text-variable-anchor")&&function(k,e,g,l,m,n,o){const b=e.transform,h="map"===m,i="map"===n,p=b.projection.createTileTransform(b,b.worldSize);for(const f of k){const d=l.getTile(f),c=d.getBucket(g);if(!c||c.projection!==b.projection.name||!c.text||!c.text.segments.get().length)continue;const j=a.evaluateSizeForZoom(c.textSizeData,b.zoom),q=e.transform.calculatePixelsToTileUnitsMatrix(d),r=aB(f.projMatrix,d.tileID.canonical,i,h,e.transform,q),s="none"!==g.layout.get("icon-text-fit")&&c.hasIconData();if(j){const t=Math.pow(2,b.zoom-d.tileID.overscaledZ);bX(c,h,i,o,a.symbolSize,b,r,f,t,j,s,p)}}}(e,c,b,d,b.layout.get("text-rotation-alignment"),b.layout.get("text-pitch-alignment"),h),0!==b.paint.get("icon-opacity").constantOr(1)&&bZ(c,d,b,e,!1,b.paint.get("icon-translate"),b.paint.get("icon-translate-anchor"),b.layout.get("icon-rotation-alignment"),b.layout.get("icon-pitch-alignment"),b.layout.get("icon-keep-upright"),f,g),0!==b.paint.get("text-opacity").constantOr(1)&&bZ(c,d,b,e,!0,b.paint.get("text-translate"),b.paint.get("text-translate-anchor"),b.layout.get("text-rotation-alignment"),b.layout.get("text-pitch-alignment"),b.layout.get("text-keep-upright"),f,g),d.map.showCollisionBoxes&&(bU(c,d,b,e,b.paint.get("text-translate"),b.paint.get("text-translate-anchor"),!0),bU(c,d,b,e,b.paint.get("icon-translate"),b.paint.get("icon-translate-anchor"),!1))},circle:function(b,r,c,j){if("translucent"!==b.renderPass)return;const s=c.paint.get("circle-opacity"),t=c.paint.get("circle-stroke-width"),u=c.paint.get("circle-stroke-opacity"),k=void 0!==c.layout.get("circle-sort-key").constantOr(1);if(0===s.constantOr(1)&&(0===t.constantOr(1)||0===u.constantOr(1)))return;const f=b.context,v=f.gl,w=b.depthModeForSublayer(0,a.DepthMode.ReadOnly),x=a.StencilMode.disabled,y=b.colorModeForRenderPass(),e=[];for(let g=0;ga.sortKey-b.sortKey);const B={useDepthForOcclusion:"globe"!==b.transform.projection.name};for(const p of e){const{programConfiguration:C,program:i,layoutVertexBuffer:D,indexBuffer:E,uniformValues:F,tile:q}=p.state,G=p.segments;b.terrain&&b.terrain.setupElevationDraw(q,i,B),b.prepareDrawProgram(f,i,q.tileID.toUnwrapped()),i.draw(f,v.TRIANGLES,w,x,y,a.CullFaceMode.disabled,F,c.id,D,E,G,c.paint,b.transform.zoom,C)}},heatmap:function(b,k,c,l){if(0!==c.paint.get("heatmap-opacity")){if("offscreen"===b.renderPass){const d=b.context,g=d.gl,n=a.StencilMode.disabled,o=new a.ColorMode([g.ONE,g.ONE],a.Color.transparent,[!0,!0,!0,!0]);(function(b,c,e){const a=b.gl;b.activeTexture.set(a.TEXTURE1),b.viewport.set([0,0,c.width/4,c.height/4,]);let d=e.heatmapFbo;if(d)a.bindTexture(a.TEXTURE_2D,d.colorAttachment.get()),b.bindFramebuffer.set(d.framebuffer);else{const f=a.createTexture();a.bindTexture(a.TEXTURE_2D,f),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR),d=e.heatmapFbo=b.createFramebuffer(c.width/4,c.height/4,!1),function(b,c,d,e){const a=b.gl;a.texImage2D(a.TEXTURE_2D,0,a.RGBA,c.width/4,c.height/4,0,a.RGBA,b.extRenderToTextureHalfFloat?b.extTextureHalfFloat.HALF_FLOAT_OES:a.UNSIGNED_BYTE,null),e.colorAttachment.set(d)}(b,c,f,d)}})(d,b,c),d.clear({color:a.Color.transparent});for(let h=0;h{const b=[];bK(a)&&b.push("RENDER_LINE_DASH"),a.paint.get("line-gradient")&&b.push("RENDER_LINE_GRADIENT");const c=a.paint.get("line-pattern").constantOr(1),d=1!==a.paint.get("line-opacity").constantOr(1);return!c&&d&&b.push("RENDER_LINE_ALPHA_DISCARD"),b})(c);let m=v.includes("RENDER_LINE_ALPHA_DISCARD");for(const h of(b.terrain&&b.terrain.clipOrMaskOverlapStencilType()&&(m=!1),H)){const f=s.getTile(h);if(j&&!f.patternsLoaded())continue;const i=f.getBucket(c);if(!i)continue;b.prepareDrawTile(h);const k=i.programConfigurations.get(c.id),O=b.useProgram(N,k,v),n=u.constantOr(null);if(n&&f.imageAtlas){const w=f.imageAtlas,x=w.patternPositions[n.to.toString()],y=w.patternPositions[n.from.toString()];x&&y&&k.setConstantPatternPositions(x,y)}const o=t.constantOr(null),p=L.constantOr(null);if(!j&&o&&p&&f.lineAtlas){const z=f.lineAtlas,A=z.getDash(o.to,p),B=z.getDash(o.from,p);A&&B&&k.setConstantPatternPositions(A,B)}const C=b.terrain?h.projMatrix:null,D=j?bH(b,f,c,l,C):bG(b,f,c,l,C,i.lineClipsArray.length);if(M){const e=i.gradients[c.id];let E=e.texture;if(c.gradientVersion!==e.version){let F=256;if(c.stepInterpolant){const P=s.getSource().maxzoom,Q=h.canonical.z===P?Math.ceil(1<{O.draw(g,d.TRIANGLES,R,e,S,a.CullFaceMode.disabled,D,c.id,i.layoutVertexBuffer,i.indexBuffer,i.segments,c.paint,b.transform.zoom,k,i.layoutVertexBuffer2)};if(m){const r=b.stencilModeForClipping(h).ref;0===r&&b.terrain&&g.clear({stencil:0});const G={func:d.EQUAL,mask:255};D.u_alpha_discard_threshold=.8,q(new a.StencilMode(G,r,255,d.KEEP,d.KEEP,d.INVERT)),D.u_alpha_discard_threshold=0,q(new a.StencilMode(G,r,255,d.KEEP,d.KEEP,d.KEEP))}else q(b.stencilModeForClipping(h))}m&&(b.resetStencilClippingMasks(),b.terrain&&g.clear({stencil:0}))},fill:function(b,d,c,e){const h=c.paint.get("fill-color"),f=c.paint.get("fill-opacity");if(0===f.constantOr(1))return;const g=b.colorModeForRenderPass(),i=c.paint.get("fill-pattern"),j=b.opaquePassEnabledForLayer()&&!i.constantOr(1)&&1===h.constantOr(a.Color.transparent).a&&1===f.constantOr(0)?"opaque":"translucent";if(b.renderPass===j){const k=b.depthModeForSublayer(1,"opaque"===b.renderPass?a.DepthMode.ReadWrite:a.DepthMode.ReadOnly);b_(b,d,c,e,k,g,!1)}if("translucent"===b.renderPass&&c.paint.get("fill-antialias")){const l=b.depthModeForSublayer(c.getPaintProperty("fill-outline-color")?2:0,a.DepthMode.ReadOnly);b_(b,d,c,e,l,g,!0)}},"fill-extrusion":function(b,d,c,e){const g=c.paint.get("fill-extrusion-opacity");if(0!==g&&"translucent"===b.renderPass){const f=new a.DepthMode(b.context.gl.LEQUAL,a.DepthMode.ReadWrite,b.depthRangeFor3D);if(1!==g||c.paint.get("fill-extrusion-pattern").constantOr(1))b0(b,d,c,e,f,a.StencilMode.disabled,a.ColorMode.disabled),b0(b,d,c,e,f,b.stencilModeFor3D(),b.colorModeForRenderPass()),b.resetStencilClippingMasks();else{const h=b.colorModeForRenderPass();b0(b,d,c,e,f,a.StencilMode.disabled,h)}}},hillshade:function(b,j,e,f){if("offscreen"!==b.renderPass&&"translucent"!==b.renderPass)return;const k=b.context,g=b.depthModeForSublayer(0,a.DepthMode.ReadOnly),h=b.colorModeForRenderPass(),i=b.terrain&&b.terrain.renderingToTexture,[l,m]="translucent"!==b.renderPass||i?[{},f]:b.stencilConfigForOverlap(f);for(const c of m){const d=j.getTile(c);if(d.needsHillshadePrepare&&"offscreen"===b.renderPass)bf(b,d,e,g,a.StencilMode.disabled,h);else if("translucent"===b.renderPass){const n=i&&b.terrain?b.terrain.stencilModeForRTTOverlap(c):l[c.overscaledZ];bd(b,c,d,e,g,n,h)}}k.viewport.set([0,0,b.width,b.height]),b.resetStencilClippingMasks()},raster:function(b,j,f,m,H,x){if("translucent"!==b.renderPass)return;if(0===f.paint.get("raster-opacity"))return;if(!m.length)return;const g=b.context,c=g.gl,h=j.getSource(),n=b.useProgram("raster"),q=b.colorModeForRenderPass(),i=b.terrain&&b.terrain.renderingToTexture,[y,o]=h instanceof s||i?[{},m]:b.stencilConfigForOverlap(m),z=o[o.length-1].overscaledZ,A=!b.options.moving;for(const e of o){const r=i?a.DepthMode.disabled:b.depthModeForSublayer(e.overscaledZ-z,1===f.paint.get("raster-opacity")?a.DepthMode.ReadWrite:a.DepthMode.ReadOnly,c.LESS),t=e.toUnwrapped(),d=j.getTile(e);if(i&&(!d||!d.hasData()))continue;const B=i?e.projMatrix:b.transform.calculateProjMatrix(t,A),C=b.terrain&&i?b.terrain.stencilModeForRTTOverlap(e):y[e.overscaledZ],u=x?0:f.paint.get("raster-fade-duration");d.registerFadeDuration(u);const k=j.findLoadedParent(e,0),D=bn(d,k,j,b.transform,u);let l,v;b.terrain&&b.terrain.prepareDrawTile(e);const p="nearest"===f.paint.get("raster-resampling")?c.NEAREST:c.LINEAR;g.activeTexture.set(c.TEXTURE0),d.texture.bind(p,c.CLAMP_TO_EDGE),g.activeTexture.set(c.TEXTURE1),k?(k.texture.bind(p,c.CLAMP_TO_EDGE),l=Math.pow(2,k.tileID.overscaledZ-d.tileID.overscaledZ),v=[d.tileID.canonical.x*l%1,d.tileID.canonical.y*l%1,]):d.texture.bind(p,c.CLAMP_TO_EDGE);const w=bL(B,v||[0,0],l||1,D,f,h instanceof s?h.perspectiveTransform:[0,0]);if(b.prepareDrawProgram(g,n,t),h instanceof s)n.draw(g,c.TRIANGLES,r,a.StencilMode.disabled,q,a.CullFaceMode.disabled,w,f.id,h.boundsBuffer,b.quadTriangleIndexBuffer,h.boundsSegments);else{const{tileBoundsBuffer:E,tileBoundsIndexBuffer:F,tileBoundsSegments:G}=b.getTileBoundsBuffers(d);n.draw(g,c.TRIANGLES,r,C,q,a.CullFaceMode.disabled,w,f.id,E,F,G)}}b.resetStencilClippingMasks()},background:function(b,j,e,k){const l=e.paint.get("background-color"),f=e.paint.get("background-opacity");if(0===f)return;const g=b.context,m=g.gl,n=b.transform,o=n.tileSize,d=e.paint.get("background-pattern");if(b.isPatternMissing(d))return;const p=!d&&1===l.a&&1===f&&b.opaquePassEnabledForLayer()?"opaque":"translucent";if(b.renderPass!==p)return;const t=a.StencilMode.disabled,u=b.depthModeForSublayer(0,"opaque"===p?a.DepthMode.ReadWrite:a.DepthMode.ReadOnly),v=b.colorModeForRenderPass(),q=b.useProgram(d?"backgroundPattern":"background");let h,i=k;i||(h=b.getBackgroundTiles(),i=Object.values(h).map(a=>a.tileID)),d&&(g.activeTexture.set(m.TEXTURE0),b.imageManager.bind(b.context));const w=e.getCrossfadeParameters();for(const c of i){const r=c.toUnwrapped(),s=k?c.projMatrix:b.transform.calculateProjMatrix(r);b.prepareDrawTile(c);const x=j?j.getTile(c):h?h[c.key]:new a.Tile(c,o,n.zoom,b),y=d?bR(s,f,b,d,{tileID:c,tileSize:o},w):bQ(s,f,l);b.prepareDrawProgram(g,q,r);const{tileBoundsBuffer:z,tileBoundsIndexBuffer:A,tileBoundsSegments:B}=b.getTileBoundsBuffers(x);q.draw(g,m.TRIANGLES,u,t,v,a.CullFaceMode.disabled,y,e.id,z,A,B)}},sky:function(b,k,c){const d=b.transform,i="mercator"===d.projection.name||"globe"===d.projection.name?1:a.smoothstep(7,8,d.zoom),e=c.paint.get("sky-opacity")*i;if(0===e)return;const j=b.context,f=c.paint.get("sky-type"),g=new a.DepthMode(j.gl.LEQUAL,a.DepthMode.ReadOnly,[0,1]),h=b.frameCounter/1e3%1;"atmosphere"===f?"offscreen"===b.renderPass?c.needsSkyboxCapture(b)&&(function(h,e,k,l){const d=h.context,b=d.gl;let i=e.skyboxFbo;if(!i){i=e.skyboxFbo=d.createFramebuffer(32,32,!1),e.skyboxGeometry=new cd(d),e.skyboxTexture=d.gl.createTexture(),b.bindTexture(b.TEXTURE_CUBE_MAP,e.skyboxTexture),b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE),b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE),b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MIN_FILTER,b.LINEAR),b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MAG_FILTER,b.LINEAR);for(let j=0;j<6;++j)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,b.RGBA,32,32,0,b.RGBA,b.UNSIGNED_BYTE,null)}d.bindFramebuffer.set(i.framebuffer),d.viewport.set([0,0,32,32,]);const f=e.getCenter(h,!0),g=h.useProgram("skyboxCapture"),c=new Float64Array(16);a.identity(c),a.rotateY(c,c,-(.5*Math.PI)),ce(d,e,g,c,f,0),a.identity(c),a.rotateY(c,c,.5*Math.PI),ce(d,e,g,c,f,1),a.identity(c),a.rotateX(c,c,-(.5*Math.PI)),ce(d,e,g,c,f,2),a.identity(c),a.rotateX(c,c,.5*Math.PI),ce(d,e,g,c,f,3),a.identity(c),ce(d,e,g,c,f,4),a.identity(c),a.rotateY(c,c,Math.PI),ce(d,e,g,c,f,5),d.viewport.set([0,0,h.width,h.height,])}(b,c),c.markSkyboxValid(b)):"sky"===b.renderPass&&function(b,c,i,j,k){var f,g;const d=b.context,e=d.gl,l=b.transform,h=b.useProgram("skybox");d.activeTexture.set(e.TEXTURE0),e.bindTexture(e.TEXTURE_CUBE_MAP,c.skyboxTexture);const m=(f=l.skyboxMatrix,g=c.getCenter(b,!1),{u_matrix:f,u_sun_direction:g,u_cubemap:0,u_opacity:j,u_temporal_offset:k});b.prepareDrawProgram(d,h),h.draw(d,e.TRIANGLES,i,a.StencilMode.disabled,b.colorModeForRenderPass(),a.CullFaceMode.backCW,m,"skybox",c.skyboxGeometry.vertexBuffer,c.skyboxGeometry.indexBuffer,c.skyboxGeometry.segment)}(b,c,g,e,h):"gradient"===f&&"sky"===b.renderPass&&function(c,b,m,n,o){var g,h,i,j,k;const d=c.context,e=d.gl,p=c.transform,l=c.useProgram("skyboxGradient");b.skyboxGeometry||(b.skyboxGeometry=new cd(d)),d.activeTexture.set(e.TEXTURE0);let f=b.colorRampTexture;f||(f=b.colorRampTexture=new a.Texture(d,b.colorRamp,e.RGBA)),f.bind(e.LINEAR,e.CLAMP_TO_EDGE);const q=(g=p.skyboxMatrix,h=b.getCenter(c,!1),i=b.paint.get("sky-gradient-radius"),j=n,k=o,{u_matrix:g,u_color_ramp:0,u_center_direction:h,u_radius:a.degToRad(i),u_opacity:j,u_temporal_offset:k});c.prepareDrawProgram(d,l),l.draw(d,e.TRIANGLES,m,a.StencilMode.disabled,c.colorModeForRenderPass(),a.CullFaceMode.backCW,q,"skyboxGradient",b.skyboxGeometry.vertexBuffer,b.skyboxGeometry.indexBuffer,b.skyboxGeometry.segment)}(b,c,g,e,h)},debug:function(c,d,b){for(let a=0;aa.getOpacity(this.transform.pitch)||.03>a.properties.get("horizon-blend"))return void(this.transform.fogCullDistSq=null);const[b,c]=a.getFovAdjustedRange(this.transform._fov);if(b>c)return void(this.transform.fogCullDistSq=null);const d=b+.78*(c-b);this.transform.fogCullDistSq=d*d}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}resize(b,c){if(this.width=b*a.exported.devicePixelRatio,this.height=c*a.exported.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height,]),this.style)for(const d of this.style.order)this.style._layers[d].resize()}setup(){const b=this.context,c=new a.StructArrayLayout2i4;c.emplaceBack(0,0),c.emplaceBack(a.EXTENT,0),c.emplaceBack(0,a.EXTENT),c.emplaceBack(a.EXTENT,a.EXTENT),this.tileExtentBuffer=b.createVertexBuffer(c,a.posAttributes.members),this.tileExtentSegments=a.SegmentVector.simpleSegment(0,0,4,2);const d=new a.StructArrayLayout2i4;d.emplaceBack(0,0),d.emplaceBack(a.EXTENT,0),d.emplaceBack(0,a.EXTENT),d.emplaceBack(a.EXTENT,a.EXTENT),this.debugBuffer=b.createVertexBuffer(d,a.posAttributes.members),this.debugSegments=a.SegmentVector.simpleSegment(0,0,4,5);const e=new a.StructArrayLayout2i4;e.emplaceBack(-1,-1),e.emplaceBack(1,-1),e.emplaceBack(-1,1),e.emplaceBack(1,1),this.viewportBuffer=b.createVertexBuffer(e,a.posAttributes.members),this.viewportSegments=a.SegmentVector.simpleSegment(0,0,4,2);const f=new a.StructArrayLayout4i8;f.emplaceBack(0,0,0,0),f.emplaceBack(a.EXTENT,0,a.EXTENT,0),f.emplaceBack(0,a.EXTENT,0,a.EXTENT),f.emplaceBack(a.EXTENT,a.EXTENT,a.EXTENT,a.EXTENT),this.mercatorBoundsBuffer=b.createVertexBuffer(f,a.boundsAttributes.members),this.mercatorBoundsSegments=a.SegmentVector.simpleSegment(0,0,4,2);const h=new a.StructArrayLayout3ui6;h.emplaceBack(0,1,2),h.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=b.createIndexBuffer(h);const i=new a.StructArrayLayout1ui2;for(const j of[0,1,3,2,0])i.emplaceBack(j);this.debugIndexBuffer=b.createIndexBuffer(i),this.emptyTexture=new a.Texture(b,{width:1,height:1,data:new Uint8Array([0,0,0,0])},b.gl.RGBA),this.identityMat=a.create();const g=this.context.gl;this.stencilClearMode=new a.StencilMode({func:g.ALWAYS,mask:0},0,255,g.ZERO,g.ZERO,g.ZERO),this.loadTimeStamps.push(a.window.performance.now())}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(a){return a._makeTileBoundsBuffers(this.context,this.transform.projection),a._tileBoundsBuffer?{tileBoundsBuffer:a._tileBoundsBuffer,tileBoundsIndexBuffer:a._tileBoundsIndexBuffer,tileBoundsSegments:a._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const b=this.context,c=b.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.useProgram("clippingMask").draw(b,c.TRIANGLES,a.DepthMode.disabled,this.stencilClearMode,a.ColorMode.disabled,a.CullFaceMode.disabled,bm(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(h,d,b){if(!d||this.currentStencilSource===d.id||!h.isTileClipped()||!b||0===b.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let g=!1;for(const i of b)if(void 0===this._tileClippingMaskIDs[i.key]){g=!0;break}if(!g)return}this.currentStencilSource=d.id;const e=this.context,c=e.gl;this.nextStencilID+b.length>256&&this.clearStencil(),e.setColorMode(a.ColorMode.disabled),e.setDepthMode(a.DepthMode.disabled);const j=this.useProgram("clippingMask");for(const f of(this._tileClippingMaskIDs={},b)){const k=d.getTile(f),l=this._tileClippingMaskIDs[f.key]=this.nextStencilID++,{tileBoundsBuffer:m,tileBoundsIndexBuffer:n,tileBoundsSegments:o}=this.getTileBoundsBuffers(k);j.draw(e,c.TRIANGLES,a.DepthMode.disabled,new a.StencilMode({func:c.ALWAYS,mask:0},l,255,c.KEEP,c.KEEP,c.REPLACE),a.ColorMode.disabled,a.CullFaceMode.disabled,bm(f.projMatrix),"$clipping",m,n,o)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const c=this.nextStencilID++,b=this.context.gl;return new a.StencilMode({func:b.NOTEQUAL,mask:255},c,255,b.KEEP,b.KEEP,b.REPLACE)}stencilModeForClipping(c){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(c);const b=this.context.gl;return new a.StencilMode({func:b.EQUAL,mask:255},this._tileClippingMaskIDs[c.key],0,b.KEEP,b.KEEP,b.REPLACE)}stencilConfigForOverlap(h){const c=this.context.gl,b=h.sort((a,b)=>b.overscaledZ-a.overscaledZ),f=b[b.length-1].overscaledZ,d=b[0].overscaledZ-f+1;if(d>1){this.currentStencilSource=void 0,this.nextStencilID+d>256&&this.clearStencil();const g={};for(let e=0;e=0;this.currentLayer--){const k=this.style._layers[c[this.currentLayer]],l=b._getLayerSourceCache(k);if(k.isSky())continue;const x=l?g[l.id]:void 0;this._renderTileClippingMasks(k,l,x),this.renderLayer(this,l,k,x)}if(this.renderPass="sky",(a.globeToMercatorTransition(this.transform.zoom)>0||"globe"!==this.transform.projection.name)&&this.transform.isHorizonVisible())for(this.currentLayer=0;this.currentLayer{const a=b._getLayerSourceCache(c);a&&!c.isHidden(this.transform.zoom)&&(!t||t.getSource().maxzoom0?a.pop():null}isPatternMissing(a){if(!a)return!1;if(!a.from||!a.to)return!0;const b=this.imageManager.getPattern(a.from.toString()),c=this.imageManager.getPattern(a.to.toString());return!b||!c}currentGlobalDefines(){const b=this.terrain&&this.terrain.renderingToTexture,c=this.style&&this.style.fog,a=[];return this.terrain&&!this.terrain.renderingToTexture&&a.push("TERRAIN"),c&&!b&&0!==c.getOpacity(this.transform.pitch)&&a.push("FOG"),b&&a.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&a.push("OVERDRAW_INSPECTOR"),a}useProgram(a,c,e){this.cache=this.cache||{};const d=this.currentGlobalDefines().concat(e||[]),b=bt.cacheKey(a,d,c);return this.cache[b]||(this.cache[b]=new bt(this.context,a,ba[a],c,bS[a],d)),this.cache[b]}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 a=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height,]),this.context.blendEquation.set(a.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=a.window.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new a.Texture(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this._terrain&&this._terrain.destroy(),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}prepareDrawTile(a){this.terrain&&this.terrain.prepareDrawTile(a)}prepareDrawProgram(c,d,e){if(this.terrain&&this.terrain.renderingToTexture)return;const a=this.style.fog;if(a){const b=a.getOpacity(this.transform.pitch);0!==b&&d.setFogUniformValues(c,((b,c,d,e)=>{const a=c.properties.get("color"),f=b.frameCounter/1e3%1,g=[a.r/a.a,a.g/a.a,a.b/a.a,e,];return{u_fog_matrix:d?b.transform.calculateFogTileMatrix(d):b.identityMat,u_fog_range:c.getFovAdjustedRange(b.transform._fov),u_fog_color:g,u_fog_horizon_blend:c.properties.get("horizon-blend"),u_fog_temporal_offset:f}})(this,a,e,b))}}setTileLoadedFlag(a){this.tileLoaded=a}saveCanvasCopy(){this.frameCopies.push(this.canvasCopy()),this.tileLoaded=!1}canvasCopy(){const a=this.context.gl,b=a.createTexture();return a.bindTexture(a.TEXTURE_2D,b),a.copyTexImage2D(a.TEXTURE_2D,0,a.RGBA,0,0,a.drawingBufferWidth,a.drawingBufferHeight,0),b}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const a=this.style&&this.style.fog;return!!a&&0!==a.getOpacity(this.transform.pitch)}getBackgroundTiles(){const d=this._backgroundTiles,c=this._backgroundTiles={},e=this.transform.coveringTiles({tileSize:512});for(const b of e)c[b.key]=d[b.key]||new a.Tile(b,512,this.transform.tileZoom,this);return c}clearBackgroundTiles(){this._backgroundTiles={}}}class ch{constructor(a=0,b=0,c=0,d=0){if(isNaN(a)||a<0||isNaN(b)||b<0||isNaN(c)||c<0||isNaN(d)||d<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=a,this.bottom=b,this.left=c,this.right=d}interpolate(b,c,d){return null!=c.top&&null!=b.top&&(this.top=a.number(b.top,c.top,d)),null!=c.bottom&&null!=b.bottom&&(this.bottom=a.number(b.bottom,c.bottom,d)),null!=c.left&&null!=b.left&&(this.left=a.number(b.left,c.left,d)),null!=c.right&&null!=b.right&&(this.right=a.number(b.right,c.right,d)),this}getCenter(b,c){const d=a.clamp((this.left+b-this.right)/2,0,b),e=a.clamp((this.top+c-this.bottom)/2,0,c);return new a.pointGeometry(d,e)}equals(a){return this.top===a.top&&this.bottom===a.bottom&&this.left===a.left&&this.right===a.right}clone(){return new ch(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function ci(b,c){const d=a.getColumn(b,3);a.fromQuat(b,c),a.setColumn(b,3,d)}function cj(c,b){a.setColumn(c,3,[b[0],b[1],b[2],1])}function ck(c,d){const b=a.identity$1([]);return a.rotateZ$1(b,b,-d),a.rotateX$1(b,b,-c),b}function cl(b,c){const f=[b[0],b[1],0],d=[c[0],c[1],0];if(a.length(f)>=1e-15){const g=a.normalize([],f);a.scale$2(d,g,a.dot(d,g)),c[0]=d[0],c[1]=d[1]}const e=a.cross([],c,b);if(1e-15>a.len(e))return null;const h=Math.atan2(-e[1],e[0]);return ck(Math.atan2(Math.sqrt(b[0]*b[0]+b[1]*b[1]),-b[2]),h)}class x{constructor(a,b){this.position=a,this.orientation=b}get position(){return this._position}set position(b){this._position=this._renderWorldCopies?function(b){if(!b)return;const c=Array.isArray(b)?new a.MercatorCoordinate(b[0],b[1],b[2]):b;return c.x=a.wrap(c.x,0,1),c}(b):b}lookAtPoint(e,b){if(this.orientation=null,!this.position)return;const f=this._elevation?this._elevation.getAtPointOrZero(a.MercatorCoordinate.fromLngLat(e)):0,c=this.position,d=a.MercatorCoordinate.fromLngLat(e,f),g=[d.x-c.x,d.y-c.y,d.z-c.z];b||(b=[0,0,1]),b[2]=Math.abs(b[2]),this.orientation=cl(g,b)}setPitchBearing(b,c){this.orientation=ck(a.degToRad(b),a.degToRad(-c))}}class cm{constructor(b,c){this._transform=a.identity([]),this._orientation=a.identity$1([]),c&&(this._orientation=c,ci(this._transform,this._orientation)),b&&cj(this._transform,b)}get mercatorPosition(){const b=this.position;return new a.MercatorCoordinate(b[0],b[1],b[2])}get position(){const b=a.getColumn(this._transform,3);return[b[0],b[1],b[2]]}set position(a){cj(this._transform,a)}get orientation(){return this._orientation}set orientation(a){this._orientation=a,ci(this._transform,this._orientation)}getPitchBearing(){const a=this.forward(),b=this.right();return{bearing:Math.atan2(-b[1],b[0]),pitch:Math.atan2(Math.sqrt(a[0]*a[0]+a[1]*a[1]),-a[2])}}setPitchBearing(a,b){this._orientation=ck(a,b),ci(this._transform,this._orientation)}forward(){const b=a.getColumn(this._transform,2);return[-b[0],-b[1],-b[2]]}up(){const b=a.getColumn(this._transform,1);return[-b[0],-b[1],-b[2]]}right(){const b=a.getColumn(this._transform,0);return[b[0],b[1],b[2]]}getCameraToWorld(c,d){const b=new Float64Array(16);return a.invert(b,this.getWorldToCamera(c,d)),b}getWorldToCameraPosition(e,f,c){const d=this.position;a.scale$2(d,d,-e);const b=new Float64Array(16);return a.fromScaling(b,[c,c,c]),a.translate(b,b,d),b[10]*=f,b}getWorldToCamera(f,c){const b=new Float64Array(16),e=new Float64Array(4),d=this.position;return a.conjugate(e,this._orientation),a.scale$2(d,d,-f),a.fromQuat(b,e),a.translate(b,b,d),b[1]*=-1,b[5]*=-1,b[9]*=-1,b[13]*=-1,b[8]*=c,b[9]*=c,b[10]*=c,b[11]*=c,b}getCameraToClipPerspective(c,d,e,f){const b=new Float64Array(16);return a.perspective(b,c,d,e,f),b}getDistanceToElevation(b){const c=0===b?0:a.mercatorZfromAltitude(b,this.position[1]),d=this.forward();return(c-this.position[2])/d[2]}clone(){return new cm([...this.position],[...this.orientation])}}function cn(b,e){const f=cp(b),c=function(c,y,d,h,v){const l=new a.LngLat(d.lng-180*cq,d.lat),m=new a.LngLat(d.lng+180*cq,d.lat),n=c.project(l.lng,l.lat),o=c.project(m.lng,m.lat),e=-Math.atan2(o.y-n.y,o.x-n.x),i=a.MercatorCoordinate.fromLngLat(d);i.y=a.clamp(i.y,-0.999975,.999975);const f=i.toLngLat(),g=c.project(f.lng,f.lat),p=a.MercatorCoordinate.fromLngLat(f);p.x+=cq;const q=p.toLngLat(),r=c.project(q.lng,q.lat),w=cs(r.x-g.x,r.y-g.y,e),s=a.MercatorCoordinate.fromLngLat(f);s.y+=cq;const t=s.toLngLat(),u=c.project(t.lng,t.lat),j=cs(u.x-g.x,u.y-g.y,e),x=Math.abs(w.x)/Math.abs(j.y),k=a.identity([]);a.rotateZ(k,k,-e*(1-(v?0:h)));const b=a.identity([]);return a.scale(b,b,[1,1-(1-x)*h,1]),b[4]=-j.x/j.y*h,a.rotateZ(b,b,e),a.multiply$1(b,k,b),b}(b.projection,0,b.center,f,e),d=co(b);return a.scale(c,c,[d,d,1]),c}function co(b){const c=b.projection,d=cp(b),e=cr(c,b.center),f=cr(c,a.LngLat.convert(c.center));return Math.pow(2,e*d+(1-d)*f)}function cp(b){const c=b.projection.range;if(!c)return 0;const e=Math.max(b.width,b.height),d=Math.log(e/1024)/Math.LN2;return a.smoothstep(c[0]+d,c[1]+d,b.zoom)}const cq=1/4e4;function cr(d,c){const b=a.clamp(c.lat,-a.MAX_MERCATOR_LATITUDE,a.MAX_MERCATOR_LATITUDE),e=new a.LngLat(c.lng-180*cq,b),f=new a.LngLat(c.lng+180*cq,b),g=d.project(e.lng,b),h=d.project(f.lng,b),i=a.MercatorCoordinate.fromLngLat(e),j=a.MercatorCoordinate.fromLngLat(f),k=h.x-g.x,l=h.y-g.y,m=j.x-i.x,n=j.y-i.y;return Math.log(Math.sqrt((m*m+n*n)/(k*k+l*l)))/Math.LN2}function cs(a,b,c){const d=Math.cos(c),e=Math.sin(c);return{x:a*d-b*e,y:a*e+b*d}}class ct{constructor(e,f,b,c,d){this.tileSize=512,this._renderWorldCopies=void 0===d||d,this._minZoom=e||0,this._maxZoom=f||22,this._minPitch=null==b?0:b,this._maxPitch=null==c?60:c,this.setProjection(),this.setMaxBounds(),this.width=0,this.height=0,this._center=new a.LngLat(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 ch,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._distanceTileDataCache={},this._camera=new cm,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._projectionScaler=1,this._horizonShift=.1}clone(){const a=new ct(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return a.setProjection(this.getProjection()),a._elevation=this._elevation,a._centerAltitude=this._centerAltitude,a.tileSize=this.tileSize,a.setMaxBounds(this.getMaxBounds()),a.width=this.width,a.height=this.height,a.cameraElevationReference=this.cameraElevationReference,a._center=this._center,a._setZoom(this.zoom),a._cameraZoom=this._cameraZoom,a.angle=this.angle,a._fov=this._fov,a._pitch=this._pitch,a._nearZ=this._nearZ,a._farZ=this._farZ,a._averageElevation=this._averageElevation,a._unmodified=this._unmodified,a._edgeInsets=this._edgeInsets.clone(),a._camera=this._camera.clone(),a._calcMatrices(),a.freezeTileCoverage=this.freezeTileCoverage,a}get elevation(){return this._elevation}set elevation(a){this._elevation!==a&&(this._elevation=a,a?this._updateCenterElevation()&&this._updateCameraOnTerrain():(this._cameraZoom=null,this._centerAltitude=0),this._calcMatrices())}updateElevation(a){this._terrainEnabled()&&null==this._cameraZoom&&this._updateCenterElevation()&&this._updateCameraOnTerrain(),a&&this._constrainCameraAltitude(),this._calcMatrices()}getProjection(){return a.pick(this.projection,["name","center","parallels",])}setProjection(b){null==b&&(b={name:"mercator"}),this.projectionOptions=b;const c=this.projection?this.getProjection():void 0;return this.projection=a.getProjection(b),!D(c,this.getProjection())&&(this._calcMatrices(),!0)}get minZoom(){return this._minZoom}set minZoom(a){this._minZoom!==a&&(this._minZoom=a,this.zoom=Math.max(this.zoom,a))}get maxZoom(){return this._maxZoom}set maxZoom(a){this._maxZoom!==a&&(this._maxZoom=a,this.zoom=Math.min(this.zoom,a))}get minPitch(){return this._minPitch}set minPitch(a){this._minPitch!==a&&(this._minPitch=a,this.pitch=Math.max(this.pitch,a))}get maxPitch(){return this._maxPitch}set maxPitch(a){this._maxPitch!==a&&(this._maxPitch=a,this.pitch=Math.min(this.pitch,a))}get renderWorldCopies(){return this._renderWorldCopies&& !0===this.projection.supportsWorldCopies}set renderWorldCopies(a){void 0===a?a=!0:null===a&&(a=!1),this._renderWorldCopies=a}get worldSize(){return this.tileSize*this.scale}get cameraWorldSize(){const a=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(a))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.cameraWorldSize)}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new a.pointGeometry(this.width,this.height)}get bearing(){return a.wrap(this.rotation,-180,180)}set bearing(a){this.rotation=a}get rotation(){return-this.angle/Math.PI*180}set rotation(m){var b,c,d,g,h,i,j,k,e,f;const l=-m*Math.PI/180;this.angle!==l&&(this._unmodified=!1,this.angle=l,this._calcMatrices(),this.rotationMatrix=(b=new a.ARRAY_TYPE(4),a.ARRAY_TYPE!=Float32Array&&(b[1]=0,b[2]=0),b[0]=1,b[3]=1,b),c=this.rotationMatrix,d=this.rotationMatrix,g=this.angle,h=d[0],i=d[1],j=d[2],k=d[3],e=Math.sin(g),f=Math.cos(g),c[0]=h*f+j*e,c[1]=i*f+k*e,c[2]=-(h*e)+j*f,c[3]=-(i*e)+k*f)}get pitch(){return this._pitch/Math.PI*180}set pitch(c){const b=a.clamp(c,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==b&&(this._unmodified=!1,this._pitch=b,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(a){a=Math.max(.01,Math.min(60,a)),this._fov!==a&&(this._unmodified=!1,this._fov=a/180*Math.PI,this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(a){this._averageElevation=a,this._calcFogMatrices()}get zoom(){return this._zoom}set zoom(b){const a=Math.min(Math.max(b,this.minZoom),this.maxZoom);this._zoom!==a&&(this._unmodified=!1,this._setZoom(a),this._terrainEnabled()&&this._updateCameraOnTerrain(),this._constrain(),this._calcMatrices())}_setZoom(a){this._zoom=a,this.scale=this.zoomScale(a),this.tileZoom=Math.floor(a),this.zoomFraction=a-this.tileZoom}_updateCenterElevation(){if(!this._elevation)return!1;const a=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center),-1);return -1===a?(this._cameraZoom=null,!1):(this._centerAltitude=a,!0)}_updateCameraOnTerrain(){this._cameraZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize)}sampleAverageElevation(){if(!this._elevation)return 0;const i=this._elevation,d=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8],],f=this.horizonLineFromTop();let g=0,e=0;for(let b=0;bc.maxzoom&&(d=c.maxzoom);const r=this.locationCoordinate(this.center),e=1<{const d=1/4e4,g=new a.MercatorCoordinate(b.x+d,b.y,b.z),h=new a.MercatorCoordinate(b.x,b.y+d,b.z),i=b.toLngLat(),j=g.toLngLat(),k=h.toLngLat(),c=this.locationCoordinate(i),e=this.locationCoordinate(j),f=this.locationCoordinate(k),l=Math.hypot(e.x-c.x,e.y-c.y),m=Math.hypot(f.x-c.x,f.y-c.y);return Math.sqrt(l*m)*O/d},j=b=>{const c=F,d=N;return{aabb:a.tileAABB(this,e,0,0,0,b,d,c,this.projection),zoom:0,x:0,y:0,minZ:d,maxZ:c,wrap:b,fullyVisible:!1}},f=[];let h=[];const k=d,v=c.reparseOverscaled?A:d,G=a=>a*a,Q=G((u-this._centerAltitude)*E),H=b=>{if(!this._elevation||!b.tileID||!C)return;const c=this._elevation.getMinMaxForTile(b.tileID),a=b.aabb;c?(a.min[2]=c.min,a.max[2]=c.max,a.center[2]=(a.min[2]+a.max[2])/2):(b.shouldSplit=I(b),b.shouldSplit||(a.min[2]=a.max[2]=a.center[2]=this._centerAltitude))},I=b=>{if(b.zoom.85?1:h}const i=d*d+e*e+c;return i{if(b*G(.707)0;){const b=f.pop(),l=b.x,m=b.y;let n=b.fullyVisible;if(!n){const w=b.aabb.intersects(D);if(0===w)continue;n=2===w}if(b.zoom!==k&&I(b))for(let g=0;g<4;g++){const o=(l<<1)+g%2,p=(m<<1)+(g>>1),q={aabb:C?b.aabb.quadrant(g):a.tileAABB(this,e,b.zoom+1,o,p,b.wrap,b.minZ,b.maxZ,this.projection),zoom:b.zoom+1,x:o,y:p,wrap:b.wrap,fullyVisible:n,tileID:void 0,shouldSplit:void 0,minZ:b.minZ,maxZ:b.maxZ};B&&(q.tileID=new a.OverscaledTileID(b.zoom+1===k?v:b.zoom+1,b.wrap,b.zoom+1,o,p),H(q)),f.push(q)}else{const x=b.zoom===k?v:b.zoom;if(c.minzoom&&c.minzoom>x)continue;const y=s[0]-(.5+l+(b.wrap<{const e=[0,0,0,1],f=[a.EXTENT,a.EXTENT,0,1],i=this.calculateFogTileMatrix(d.tileID.toUnwrapped());a.transformMat4$1(e,e,i),a.transformMat4$1(f,f,i);const g=a.getAABBPointSquareDist(e,f);if(0===g)return!0;let j=!1;const k=this._elevation;if(k&&g>R&&0!==S){const m=this.calculateProjMatrix(d.tileID.toUnwrapped());let b;c.isTerrainDEM||(b=k.getMinMaxForTile(d.tileID)),b||(b={min:N,max:F});const l=a.furthestTileCorner(this.rotation),h=[l[0]*a.EXTENT,l[1]*a.EXTENT,b.max,];a.transformMat4(h,h,m),j=(1-h[1])*this.height*.5a.distanceSq-b.distanceSq).map(a=>a.tileID)}resize(a,b){this.width=a,this.height=b,this.pixelsToGLUnits=[2/a,-2/b],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(a){return Math.pow(2,a)}scaleZoom(a){return Math.log(a)/Math.LN2}project(b){const d=a.clamp(b.lat,-a.MAX_MERCATOR_LATITUDE,a.MAX_MERCATOR_LATITUDE),c=this.projection.project(b.lng,d);return new a.pointGeometry(c.x*this.worldSize,c.y*this.worldSize)}unproject(a){return this.projection.unproject(a.x/this.worldSize,a.y/this.worldSize)}get point(){return this.project(this.center)}setLocationAtPoint(e,f){const b=this.pointCoordinate(f),c=this.pointCoordinate(this.centerPoint),d=this.locationCoordinate(e);this.setLocation(new a.MercatorCoordinate(d.x-(b.x-c.x),d.y-(b.y-c.y)))}setLocation(a){this.center=this.coordinateLocation(a),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(a){return this.projection.locationPoint(this,a)}locationPoint3D(a){return this._coordinatePoint(this.locationCoordinate(a),!0)}pointLocation(a){return this.coordinateLocation(this.pointCoordinate(a))}pointLocation3D(a){return this.coordinateLocation(this.pointCoordinate3D(a))}locationCoordinate(b,c){const e=c?a.mercatorZfromAltitude(c,b.lat):void 0,d=this.projection.project(b.lng,b.lat);return new a.MercatorCoordinate(d.x,d.y,e)}coordinateLocation(a){return this.projection.unproject(a.x,a.y)}pointRayIntersection(d,f){const h=null!=f?f:this._centerAltitude,b=[d.x,d.y,0,1],c=[d.x,d.y,1,1];a.transformMat4$1(b,b,this.pixelMatrixInverse),a.transformMat4$1(c,c,this.pixelMatrixInverse);const i=c[3];a.scale$1(b,b,1/b[3]),a.scale$1(c,c,1/i);const e=b[2],g=c[2];return{p0:b,p1:c,t:e===g?0:(h-e)/(g-e)}}screenPointToMercatorRay(d){const b=[d.x,d.y,0,1],c=[d.x,d.y,1,1];return a.transformMat4$1(b,b,this.pixelMatrixInverse),a.transformMat4$1(c,c,this.pixelMatrixInverse),a.scale$1(b,b,1/b[3]),a.scale$1(c,c,1/c[3]),b[2]=a.mercatorZfromAltitude(b[2],this._center.lat)*this.worldSize,c[2]=a.mercatorZfromAltitude(c[2],this._center.lat)*this.worldSize,a.scale$1(b,b,1/this.worldSize),a.scale$1(c,c,1/this.worldSize),new a.Ray([b[0],b[1],b[2]],a.normalize([],a.sub([],c,b)))}rayIntersectionCoordinate(e){const{p0:b,p1:c,t:d}=e,f=a.mercatorZfromAltitude(b[2],this._center.lat),g=a.mercatorZfromAltitude(c[2],this._center.lat);return new a.MercatorCoordinate(a.number(b[0],c[0],d)/this.worldSize,a.number(b[1],c[1],d)/this.worldSize,a.number(f,g,d))}pointCoordinate(a,b=this._centerAltitude){return this.projection.createTileTransform(this,this.worldSize).pointCoordinate(a.x,a.y,b)}pointCoordinate3D(c){if(!this.elevation)return this.pointCoordinate(c);const i=this.elevation;let b=this.elevation.pointCoordinate(c);if(b)return new a.MercatorCoordinate(b[0],b[1],b[2]);let f=0,d=this.horizonLineFromTop();if(c.y>d)return this.pointCoordinate(c);const j=.02*d,e=c.clone();for(let g=0;g<10&&d-f>j;g++){e.y=a.number(f,d,.66);const h=i.pointCoordinate(e);h?(d=e.y,b=h):f=e.y}return b?new a.MercatorCoordinate(b[0],b[1],b[2]):this.pointCoordinate(c)}isPointAboveHorizon(a){if(this.elevation)return!this.elevation.pointCoordinate(a);{const b=this.horizonLineFromTop();return a.y0?new a.pointGeometry(b[0]/b[3],b[1]/b[3]):new a.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE)}_getBounds(j,k){var f,l,g,m,h,n,i,o;const p=new a.pointGeometry(this._edgeInsets.left,this._edgeInsets.top),q=new a.pointGeometry(this.width-this._edgeInsets.right,this._edgeInsets.top),r=new a.pointGeometry(this.width-this._edgeInsets.right,this.height-this._edgeInsets.bottom),s=new a.pointGeometry(this._edgeInsets.left,this.height-this._edgeInsets.bottom);let b=this.pointCoordinate(p,j),c=this.pointCoordinate(q,j);const d=this.pointCoordinate(r,k),e=this.pointCoordinate(s,k);return b.y>1&&c.y>=0?b=new a.MercatorCoordinate((1-e.y)/(f=e,((l=b).y-f.y)/(l.x-f.x))+e.x,1):b.y<0&&c.y<=1&&(b=new a.MercatorCoordinate(-e.y/(g=e,((m=b).y-g.y)/(m.x-g.x))+e.x,0)),c.y>1&&b.y>=0?c=new a.MercatorCoordinate((1-d.y)/(h=d,((n=c).y-h.y)/(n.x-h.x))+d.x,1):c.y<0&&b.y<=1&&(c=new a.MercatorCoordinate(-d.y/(i=d,((o=c).y-i.y)/(o.x-i.x))+d.x,0)),new a.LngLatBounds().extend(this.coordinateLocation(b)).extend(this.coordinateLocation(c)).extend(this.coordinateLocation(e)).extend(this.coordinateLocation(d))}_getBounds3D(){const a=this.elevation;if(!a.visibleDemTiles.length)return this._getBounds(0,0);const b=a.visibleDemTiles.reduce((a,b)=>{if(b.dem){const c=b.dem.tree;a.min=Math.min(a.min,c.minimums[0]),a.max=Math.max(a.max,c.maximums[0])}return a},{min:Number.MAX_VALUE,max:0});return this._getBounds(b.min*a.exaggeration(),b.max*a.exaggeration())}getBounds(){return this._terrainEnabled()?this._getBounds3D():this._getBounds(0,0)}horizonLineFromTop(b=!0){const c=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))+this.centerOffset.y,a=this.height/2-c*(1-this._horizonShift);return b?Math.max(0,a):a}getMaxBounds(){return this.maxBounds}setMaxBounds(b){this.maxBounds=b,this.minLat=-a.MAX_MERCATOR_LATITUDE,this.maxLat=a.MAX_MERCATOR_LATITUDE,this.minLng=-180,this.maxLng=180,b&&(this.minLat=b.getSouth(),this.maxLat=b.getNorth(),this.minLng=b.getWest(),this.maxLng=b.getEast(),this.maxLngi&&(g=i-l),i-he&&(b=e-k),e-d.5?j-1:j,k>.5?k-1:k,0,]),this.alignedProjMatrix=l,b=a.create(),a.scale(b,b,[this.width/2,-this.height/2,1,]),a.translate(b,b,[1,-1,0]),this.labelPlaneMatrix=b,b=a.create(),a.scale(b,b,[1,-1,1]),a.translate(b,b,[-1,-1,0]),a.scale(b,b,[2/this.width,2/this.height,1,]),this.glCoordMatrix=b,this.pixelMatrix=a.multiply$1(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),this._calcFogMatrices(),this._distanceTileDataCache={},b=a.invert(new Float64Array(16),this.pixelMatrix),!b)throw new Error("failed to invert matrix");this.pixelMatrixInverse=b,this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const e=this.cameraWorldSize,f=this.cameraPixelsPerMeter,b=this._camera.position,g=1/this.height,d=[e,e,f];a.scale$2(d,d,g),a.scale$2(b,b,-1),a.multiply$2(b,b,d);const c=a.create();a.translate(c,c,b),a.scale(c,c,d),this.mercatorFogMatrix=c,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(e,f,g)}_computeCameraPosition(a){const e=(a=a||this.pixelsPerMeter)/this.pixelsPerMeter,b=this._camera.forward(),d=this.point,c=this._mercatorZfromZoom(this._cameraZoom?this._cameraZoom:this._zoom)*e-a/this.worldSize*this._centerAltitude;return[d.x/this.worldSize-b[0]*c,d.y/this.worldSize-b[1]*c,a/this.worldSize*this._centerAltitude-b[2]*c,]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(b){const e=this._maxCameraBoundsDistance()*Math.cos(this._pitch),c=b[2];let d=1;c>0&&(d=Math.min((e-this._camera.position[2])/c,1)),this._camera.position=a.scaleAndAdd([],this._camera.position,b,d),this._updateStateFromCamera()}_updateStateFromCamera(){const b=this._camera.position,e=this._camera.forward(),{pitch:c,bearing:f}=this._camera.getPitchBearing(),g=a.mercatorZfromAltitude(this._centerAltitude,this.center.lat)*this._projectionScaler,h=this._mercatorZfromZoom(this._maxZoom)*Math.cos(a.degToRad(this._maxPitch)),d=Math.max((b[2]-g)/Math.cos(c),h),i=this._zoomFromMercatorZ(d);a.scaleAndAdd(b,b,e,d),this._pitch=a.clamp(c,a.degToRad(this.minPitch),a.degToRad(this.maxPitch)),this.angle=a.wrap(f,-Math.PI,Math.PI),this._setZoom(a.clamp(i,this._minZoom,this._maxZoom)),this._terrainEnabled()&&this._updateCameraOnTerrain(),this._center=this.coordinateLocation(new a.MercatorCoordinate(b[0],b[1],b[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(a){return Math.pow(2,a)*this.tileSize}_mercatorZfromZoom(a){return this.cameraToCenterDistance/this._worldSizeFromZoom(a)}_minimumHeightOverTerrain(){const a=Math.min((null!=this._cameraZoom?this._cameraZoom:this._zoom)+2,this._maxZoom);return this._mercatorZfromZoom(a)}_zoomFromMercatorZ(a){return this.scaleZoom(this.cameraToCenterDistance/(a*this.tileSize))}_terrainEnabled(){return!(!this._elevation|| !this.projection.supportsTerrain&&(a.warnOnce("Terrain is not yet supported with alternate projections. Use mercator to enable terrain."),1))}anyCornerOffEdge(b,c){const f=Math.min(b.x,c.x),g=Math.max(b.x,c.x),e=Math.min(b.y,c.y),h=Math.max(b.y,c.y);if(el||d.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+a.radToDeg(this.fovAboveCenter)>88||this.anyCornerOffEdge(new a.pointGeometry(0,0),new a.pointGeometry(this.width,this.height))}zoomDeltaToMovement(c,d){const b=a.length(a.sub([],this._camera.position,c)),e=this._zoomFromMercatorZ(b)+d;return b-this._mercatorZfromZoom(e)}getCameraPoint(){const b=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new a.pointGeometry(0,b))}}function cu(a,b){let c=!1,d=null;const e=()=>{d=null,c&&(a(),d=setTimeout(e,b),c=!1)};return()=>(c=!0,d||e(),d)}const d={linearity:.3,easing:a.bezier(0,0,.3,1)},cv=a.extend({deceleration:2500,maxSpeed:1400},d),cw=a.extend({deceleration:20,maxSpeed:1400},d),cx=a.extend({deceleration:1e3,maxSpeed:360},d),cy=a.extend({deceleration:1e3,maxSpeed:90},d);function cz(a,b){(!a.duration||a.durationf.unproject(a)),g=d.reduce((a,b,d,c)=>a.add(b.div(c.length)),new a.pointGeometry(0,0));super(e,{points:d,point:g,lngLats:i,lngLat:f.unproject(g),originalEvent:c}),this._defaultPrevented=!1}}class cD extends a.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(a,c,b){super(a,{originalEvent:b}),this._defaultPrevented=!1}}class cE{constructor(a,b){this._map=a,this._clickTolerance=b.clickTolerance}reset(){delete this._mousedownPos}wheel(a){return this._firePreventable(new cD(a.type,this._map,a))}mousedown(a,b){return this._mousedownPos=b,this._firePreventable(new cB(a.type,this._map,a))}mouseup(a){this._map.fire(new cB(a.type,this._map,a))}preclick(c){const b=a.extend({},c);b.type="preclick",this._map.fire(new cB(b.type,this._map,b))}click(a,b){this._mousedownPos&&this._mousedownPos.dist(b)>=this._clickTolerance||(this.preclick(a),this._map.fire(new cB(a.type,this._map,a)))}dblclick(a){return this._firePreventable(new cB(a.type,this._map,a))}mouseover(a){this._map.fire(new cB(a.type,this._map,a))}mouseout(a){this._map.fire(new cB(a.type,this._map,a))}touchstart(a){return this._firePreventable(new cC(a.type,this._map,a))}touchmove(a){this._map.fire(new cC(a.type,this._map,a))}touchend(a){this._map.fire(new cC(a.type,this._map,a))}touchcancel(a){this._map.fire(new cC(a.type,this._map,a))}_firePreventable(a){if(this._map.fire(a),a.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class cF{constructor(a){this._map=a}reset(){this._delayContextMenu=!1,delete this._contextMenuEvent}mousemove(a){this._map.fire(new cB(a.type,this._map,a))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new cB("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(a){this._delayContextMenu?this._contextMenuEvent=a:this._map.fire(new cB(a.type,this._map,a)),this._map.listens("contextmenu")&&a.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class cG{constructor(a,b){this._map=a,this._el=a.getCanvasContainer(),this._container=a.getContainer(),this._clickTolerance=b.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(a,c){this.isEnabled()&&a.shiftKey&&0===a.button&&(b.disableDrag(),this._startPos=this._lastPos=c,this._active=!0)}mousemoveWindow(d,e){if(!this._active)return;const a=e;if(this._lastPos.equals(a)|| !this._box&&a.dist(this._startPos){this._box&&(this._box.style.transform=`translate(${f}px,${h}px)`,this._box.style.width=g-f+"px",this._box.style.height=i-h+"px")})}mouseupWindow(c,f){if(!this._active)return;if(0!==c.button)return;const d=this._startPos,e=f;if(this.reset(),b.suppressClick(),d.x!==e.x||d.y!==e.y)return this._map.fire(new a.Event("boxzoomend",{originalEvent:c})),{cameraAnimation:a=>a.fitScreenCoordinates(d,e,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",c)}keydown(a){this._active&&27===a.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",a))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),b.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(b,c){return this._map.fire(new a.Event(b,{originalEvent:c}))}}function cH(b,d){const c={};for(let a=0;athis.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=d.timeStamp),b.length===this.numTouches&&(this.centroid=function(b){const c=new a.pointGeometry(0,0);for(const d of b)c._add(d);return c.div(b.length)}(c),this.touches=cH(b,c)))}touchmove(g,c,d){if(this.aborted||!this.centroid)return;const e=cH(d,c);for(const a in this.touches){const f=this.touches[a],b=e[a];(!b||b.dist(f)>30)&&(this.aborted=!0)}}touchend(b,d,c){if((!this.centroid||b.timeStamp-this.startTime>500)&&(this.aborted=!0),0===c.length){const a=!this.aborted&&this.centroid;if(this.reset(),a)return a}}}(b),this.numTaps=b.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(a,b,c){this.singleTap.touchstart(a,b,c)}touchmove(a,b,c){this.singleTap.touchmove(a,b,c)}touchend(b,c,d){const a=this.singleTap.touchend(b,c,d);if(a){const e=b.timeStamp-this.lastTime<500,f=!this.lastTap||30>this.lastTap.dist(a);if(e&&f||this.reset(),this.count++,this.lastTime=b.timeStamp,this.lastTap=a,this.count===this.numTaps)return this.reset(),a}}}class cJ{constructor(){this._zoomIn=new cI({numTouches:1,numTaps:2}),this._zoomOut=new cI({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(a,b,c){this._zoomIn.touchstart(a,b,c),this._zoomOut.touchstart(a,b,c)}touchmove(a,b,c){this._zoomIn.touchmove(a,b,c),this._zoomOut.touchmove(a,b,c)}touchend(a,b,c){const d=this._zoomIn.touchend(a,b,c),e=this._zoomOut.touchend(a,b,c);return d?(this._active=!0,a.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:b=>b.easeTo({duration:300,zoom:b.getZoom()+1,around:b.unproject(d)},{originalEvent:a})}):e?(this._active=!0,a.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:b=>b.easeTo({duration:300,zoom:b.getZoom()-1,around:b.unproject(e)},{originalEvent:a})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const cK={0:1,2:2};class f{constructor(a){this.reset(),this._clickTolerance=a.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,delete this._lastPoint,delete this._eventButton}_correctButton(a,b){return!1}_move(a,b){return{}}mousedown(a,d){if(this._lastPoint)return;const c=b.mouseButton(a);this._correctButton(a,c)&&(this._lastPoint=d,this._eventButton=c)}mousemoveWindow(c,a){const b=this._lastPoint;if(b){if(c.preventDefault(),function(a,c){const b=cK[c];return void 0===a.buttons||(a.buttons&b)!==b}(c,this._eventButton))this.reset();else if(this._moved||!(a.dist(b)0&&(this._active=!0);const b=cH(g,k),h=new a.pointGeometry(0,0),d=new a.pointGeometry(0,0);let c=0;for(const e in b){const f=b[e],i=this._touches[e];i&&(h._add(f),d._add(f.sub(i)),c++,b[e]=f)}if(this._touches=b,c{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show")},500)}}class g{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}_start(a){}_move(a,b,c){return{}}touchstart(c,b,a){this._firstTwoTouches||a.length<2||(this._firstTwoTouches=[a[0].identifier,a[1].identifier,],this._start([b[0],b[1]]))}touchmove(c,d,e){if(!this._firstTwoTouches)return;c.preventDefault();const[f,g]=this._firstTwoTouches,a=cP(e,d,f),b=cP(e,d,g);if(!a||!b)return;const h=this._aroundCenter?null:a.add(b).div(2);return this._move([a,b],h,c)}touchend(h,a,c){if(!this._firstTwoTouches)return;const[d,e]=this._firstTwoTouches,f=cP(c,a,d),g=cP(c,a,e);f&&g||(this._active&&b.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(a){this._enabled=!0,this._aroundCenter=!!a&&"center"===a.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function cP(b,c,d){for(let a=0;aMath.abs(cQ(this._distance,this._startDistance))))return this._active=!0,{zoomDelta:cQ(this._distance,c),pinchAround:b}}}function cS(a,b){return 180*a.angleWith(b)/Math.PI}class cT extends g{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(a){this._startVector=this._vector=a[0].sub(a[1]),this._minDiameter=a[0].dist(a[1])}_move(a,b){const c=this._vector;if(this._vector=a[0].sub(a[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:cS(this._vector,c),pinchAround:b}}_isBelowThreshold(a){this._minDiameter=Math.min(this._minDiameter,a.mag());const b=25/(Math.PI*this._minDiameter)*360,c=cS(a,this._startVector);return Math.abs(c)Math.abs(a.x)}class cV extends g{constructor(a){super(),this._map=a}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}_start(a){this._lastPoints=a,cU(a[0].sub(a[1]))&&(this._valid=!1)}_move(a,e,b){const c=a[0].sub(this._lastPoints[0]),d=a[1].sub(this._lastPoints[1]);if(!(this._map._cooperativeGestures&&b.touches.length<3)&&(this._valid=this.gestureBeginsVertically(c,d,b.timeStamp),this._valid))return this._lastPoints=a,this._active=!0,{pitchDelta:-((c.y+d.y)/2*.5)}}gestureBeginsVertically(a,b,c){if(void 0!==this._valid)return this._valid;const d=a.mag()>=2,e=b.mag()>=2;if(!d&&!e)return;if(!d||!e)return void 0===this._firstMove&&(this._firstMove=c),c-this._firstMove<100&&void 0;const f=a.y>0==b.y>0;return cU(a)&&cU(b)&&f}}class cW{constructor(){const a={panStep:100,bearingStep:15,pitchStep:10};this._panStep=a.panStep,this._bearingStep=a.bearingStep,this._pitchStep=a.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(a){if(a.altKey||a.ctrlKey||a.metaKey)return;let d=0,b=0,c=0,e=0,f=0;switch(a.keyCode){case 61:case 107:case 171:case 187:d=1;break;case 189:case 109:case 173:d=-1;break;case 37:a.shiftKey?b=-1:(a.preventDefault(),e=-1);break;case 39:a.shiftKey?b=1:(a.preventDefault(),e=1);break;case 38:a.shiftKey?c=1:(a.preventDefault(),f=-1);break;case 40:a.shiftKey?c=-1:(a.preventDefault(),f=1);break;default:return}return this._rotationDisabled&&(b=0,c=0),{cameraAnimation:g=>{const h=g.getZoom();g.easeTo({duration:300,easeId:"keyboardHandler",easing:cX,zoom:d?Math.round(h)+d*(a.shiftKey?2:1):h,bearing:g.getBearing()+b*this._bearingStep,pitch:g.getPitch()+c*this._pitchStep,offset:[-e*this._panStep,-f*this._panStep,],center:g.getCenter()},{originalEvent:a})}}}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 cX(a){return a*(2-a)}const cY=4.000244140625;class cZ{constructor(b,c){this._map=b,this._el=b.getCanvasContainer(),this._handler=c,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,a.bindAll(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert","_isFullscreen",],this)}setZoomRate(a){this._defaultZoomRate=a}setWheelZoomRate(a){this._wheelZoomRate=a}isEnabled(){return!!this._enabled}isActive(){return!!this._active|| void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(a){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!a&&"center"===a.around,this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(b){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(b.ctrlKey||b.metaKey||this.isZooming()||this._isFullscreen()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let c=b.deltaMode===a.window.WheelEvent.DOM_DELTA_LINE?40*b.deltaY:b.deltaY;const d=a.exported.now(),e=d-(this._lastWheelEventTime||0);this._lastWheelEventTime=d,0!==c&&c%cY==0?this._type="wheel":0!==c&&4>Math.abs(c)?this._type="trackpad":e>400?(this._type=null,this._lastValue=c,this._timeout=setTimeout(this._onTimeout,40,b)):this._type||(this._type=200>Math.abs(e*c)?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,c+=this._lastValue)),b.shiftKey&&c&&(c/=4),this._type&&(this._lastWheelEvent=b,this._delta-=c,this._active||this._start(b)),b.preventDefault()}_onTimeout(a){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(a)}_start(a){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 c=b.mousePos(this._el,a);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:c,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 b=this._map.transform,c=()=>b._terrainEnabled()&&this._aroundCoord?b.computeZoomRelativeTo(this._aroundCoord):b.zoom;if(0!==this._delta){const k="wheel"===this._type&&Math.abs(this._delta)>cY?this._wheelZoomRate:this._defaultZoomRate;let d=2/(1+Math.exp(-Math.abs(this._delta*k)));this._delta<0&&0!==d&&(d=1/d);const l=c(),m=Math.pow(2,l),n="number"==typeof this._targetZoom?b.zoomScale(this._targetZoom):m;this._targetZoom=Math.min(b.maxZoom,Math.max(b.minZoom,b.scaleZoom(n*d))),"wheel"===this._type&&(this._startZoom=c(),this._easing=this._smoothOutEasing(200)),this._delta=0}const g="number"==typeof this._targetZoom?this._targetZoom:c(),h=this._startZoom,i=this._easing;let f,e=!1;if("wheel"===this._type&&h&&i){const j=Math.min((a.exported.now()-this._lastWheelEventTime)/200,1),o=i(j);f=a.number(h,g,o),j<1?this._frameId||(this._frameId=!0):e=!0}else f=g,e=!0;return this._active=!0,e&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!e,zoomDelta:f-c(),around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(g){let c=a.ease;if(this._prevEase){const b=this._prevEase,e=(a.exported.now()-b.start)/b.duration,f=b.easing(e+.01)-b.easing(e),d=.27/Math.sqrt(f*f+1e-4)*.01,h=Math.sqrt(.0729-d*d);c=a.bezier(d,h,.25,1)}return this._prevEase={start:a.exported.now(),duration:g,easing:c},c}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=b.create("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(a.window.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`)}_isFullscreen(){return!!a.window.document.fullscreenElement}_showBlockerAlert(){"hidden"===this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="visible"),this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show")},200)}}class c${constructor(a,b){this._clickZoom=a,this._tapZoom=b}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 c_{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(a,b){return a.preventDefault(),{cameraAnimation(c){c.easeTo({duration:300,zoom:c.getZoom()+(a.shiftKey?-1:1),around:c.unproject(b)},{originalEvent:a})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class c0{constructor(){this._tap=new cI({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,this._tap.reset()}touchstart(b,c,a){this._swipePoint||(this._tapTime&&b.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?a.length>0&&(this._swipePoint=c[0],this._swipeTouch=a[0].identifier):this._tap.touchstart(b,c,a))}touchmove(a,b,c){if(this._tapTime){if(this._swipePoint){if(c[0].identifier!==this._swipeTouch)return;const d=b[0],e=d.y-this._swipePoint.y;return this._swipePoint=d,a.preventDefault(),this._active=!0,{zoomDelta:e/128}}}else this._tap.touchmove(a,b,c)}touchend(a,c,b){this._tapTime?this._swipePoint&&0===b.length&&this.reset():this._tap.touchend(a,c,b)&&(this._tapTime=a.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class c1{constructor(a,b,c){this._el=a,this._mousePan=b,this._touchPan=c}enable(a){this._inertiaOptions=a||{},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 c2{constructor(a,b,c){this._pitchWithRotate=a.pitchWithRotate,this._mouseRotate=b,this._mousePitch=c}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 c3{constructor(a,b,c,d){this._el=a,this._touchZoom=b,this._touchRotate=c,this._tapDragZoom=d,this._rotationDisabled=!1,this._enabled=!0}enable(a){this._touchZoom.enable(a),this._rotationDisabled||this._touchRotate.enable(a),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 c4=a=>a.zoom||a.drag||a.pitch||a.rotate;class c5 extends a.Event{}function c6(a){return a.panDelta&&a.panDelta.mag()||a.zoomDelta||a.bearingDelta||a.pitchDelta}const c7="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class c8 extends a.Evented{constructor(b,c){super(),this._moving=!1,this._zooming=!1,this.transform=b,this._bearingSnap=c.bearingSnap,a.bindAll(["_renderFrameCallback"],this)}getCenter(){return new a.LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(a,b){return this.jumpTo({center:a},b)}panBy(b,c,d){return b=a.pointGeometry.convert(b).mult(-1),this.panTo(this.transform.center,a.extend({offset:b},c),d)}panTo(b,c,d){return this.easeTo(a.extend({center:b},c),d)}getZoom(){return this.transform.zoom}setZoom(a,b){return this.jumpTo({zoom:a},b),this}zoomTo(b,c,d){return this.easeTo(a.extend({zoom:b},c),d)}zoomIn(a,b){return this.zoomTo(this.getZoom()+1,a,b),this}zoomOut(a,b){return this.zoomTo(this.getZoom()-1,a,b),this}getBearing(){return this.transform.bearing}setBearing(a,b){return this.jumpTo({bearing:a},b),this}getPadding(){return this.transform.padding}setPadding(a,b){return this.jumpTo({padding:a},b),this}rotateTo(b,c,d){return this.easeTo(a.extend({bearing:b},c),d)}resetNorth(b,c){return this.rotateTo(0,a.extend({duration:1e3},b),c),this}resetNorthPitch(b,c){return this.easeTo(a.extend({bearing:0,pitch:0,duration:1e3},b),c),this}snapToNorth(a,b){return Math.abs(this.getBearing())i=>{if(t&&(c.zoom=a.number(d,g,i)),u&&(c.bearing=a.number(e,n,i)),v&&(c.pitch=a.number(f,o,i)),w&&(c.interpolatePadding(z,p,i),h=c.centerPoint.add(q)),k)c.setLocationAtPoint(k,s);else{const l=c.zoomScale(c.zoom-d),x=g>d?Math.min(2,B):Math.max(.5,B),y=Math.pow(x,1-i),j=c.unproject(r.add(A.mult(i*y)).mult(l));c.setLocationAtPoint(c.renderWorldCopies?j.wrap():j,h)}return b.preloadOnly||this._fireMoveEvents(m),c};if(b.preloadOnly){const x=this._emulate(l,b.duration,c);return this._preloadTiles(x),this}const y={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=t,this._rotating=u,this._pitching=v,this._padding=w,this._easeId=b.easeId,this._prepareEase(m,b.noMoveStart,y),this._ease(l(c),a=>{c.recenterOnTerrain(),this._afterEase(m,a)},b),this}_prepareEase(b,d,c={}){this._moving=!0,this.transform.cameraElevationReference="sea",d||c.moving||this.fire(new a.Event("movestart",b)),this._zooming&&!c.zooming&&this.fire(new a.Event("zoomstart",b)),this._rotating&&!c.rotating&&this.fire(new a.Event("rotatestart",b)),this._pitching&&!c.pitching&&this.fire(new a.Event("pitchstart",b))}_fireMoveEvents(b){this.fire(new a.Event("move",b)),this._zooming&&this.fire(new a.Event("zoom",b)),this._rotating&&this.fire(new a.Event("rotate",b)),this._pitching&&this.fire(new a.Event("pitch",b))}_afterEase(b,c){if(this._easeId&&c&&this._easeId===c)return;delete this._easeId,this.transform.cameraElevationReference="ground";const d=this._zooming,e=this._rotating,f=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,d&&this.fire(new a.Event("zoomend",b)),e&&this.fire(new a.Event("rotateend",b)),f&&this.fire(new a.Event("pitchend",b)),this.fire(new a.Event("moveend",b))}flyTo(b,g){if(!b.essential&&a.exported.prefersReducedMotion){const r=a.pick(b,["center","zoom","bearing","pitch","around",]);return this.jumpTo(r,g)}this.stop(),b=a.extend({offset:[0,0],speed:1.2,curve:1.42,easing:a.ease},b);const c=this.transform,f=this.getZoom(),h=this.getBearing(),k=this.getPitch(),J=this.getPadding(),l="zoom"in b?a.clamp(+b.zoom,c.minZoom,c.maxZoom):f,s="bearing"in b?this._normalizeBearing(b.bearing,h):h,t="pitch"in b?+b.pitch:k,u="padding"in b?b.padding:c.padding,v=c.zoomScale(l-f),w=a.pointGeometry.convert(b.offset);let x=c.centerPoint.add(w);const m=c.pointLocation(x),n=a.LngLat.convert(b.center||m);this._normalizeCenter(n);const y=c.project(m),z=c.project(n).sub(y);let d=b.curve;const e=Math.max(c.width,c.height),i=e/v,o=z.mag();if("minZoom"in b){const A=a.clamp(Math.min(b.minZoom,f,l),c.minZoom,c.maxZoom),B=e/c.zoomScale(A-f);d=Math.sqrt(B/o*2)}const K=d*d;function p(b){const a=(i*i-e*e+(b?-1:1)*K*K*o*o)/(2*(b?i:e)*K*o);return Math.log(Math.sqrt(a*a+1)-a)}function L(a){return(Math.exp(a)-Math.exp(-a))/2}function M(a){return(Math.exp(a)+Math.exp(-a))/2}const C=p(0);let D=function(a){return M(C)/M(C+d*a)},E=function(b){var a;return e*((M(C)*(L(a=C+d*b)/M(a))-L(C))/K)/o},j=(p(1)-C)/d;if(1e-6>Math.abs(o)||!isFinite(j)){if(1e-6>Math.abs(e-i))return this.easeTo(b,g);const N=ib.maxDuration&&(b.duration=0);const F=h!==s,G=t!==k,H=!c.isPaddingEqual(u),q=c=>d=>{const e=d*j,i=1/D(e);c.zoom=1===d?l:f+c.scaleZoom(i),F&&(c.bearing=a.number(h,s,d)),G&&(c.pitch=a.number(k,t,d)),H&&(c.interpolatePadding(J,u,d),x=c.centerPoint.add(w));const m=1===d?n:c.unproject(y.add(z.mult(E(e))).mult(i));return c.setLocationAtPoint(c.renderWorldCopies?m.wrap():m,x),c._updateCenterElevation(),b.preloadOnly||this._fireMoveEvents(g),c};if(b.preloadOnly){const I=this._emulate(q,b.duration,c);return this._preloadTiles(I),this}return this._zooming=!0,this._rotating=F,this._pitching=G,this._padding=H,this._prepareEase(g,!1),this._ease(q(c),()=>this._afterEase(g),b),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(b,c){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const d=this._onEaseEnd;delete this._onEaseEnd,d.call(this,c)}if(!b){const a=this.handlers;a&&a.stop(!1)}return this}_ease(c,d,b){!1===b.animate||0===b.duration?(c(1),d()):(this._easeStart=a.exported.now(),this._easeOptions=b,this._onEaseFrame=c,this._onEaseEnd=d,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const b=Math.min((a.exported.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(b)),b<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(b,c){b=a.wrap(b,-180,180);const d=Math.abs(b-c);return Math.abs(b-360-c)180?-360:c< -180?360:0}_emulate(d,e,f){const b=Math.ceil(15*e/1e3),c=[],g=d(f.clone());for(let a=0;a<=b;a++){const h=g(a/b);c.push(h.clone())}return c}}class y{constructor(b={}){this.options=b,a.bindAll(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact",],this)}getDefaultPosition(){return"bottom-right"}onAdd(c){const a=this.options&&this.options.compact;return this._map=c,this._container=b.create("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=b.create("button","mapboxgl-ctrl-attrib-button",this._container),b.create("span","mapboxgl-ctrl-icon",this._compactButton).setAttribute("aria-hidden",!0),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=b.create("div","mapboxgl-ctrl-attrib-inner",this._container),this._innerContainer.setAttribute("role","list"),a&&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===a&&(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(a,c){const b=this._map._getUIString(`AttributionControl.${c}`);a.setAttribute("aria-label",b),a.removeAttribute("title"),a.firstElementChild&&a.firstElementChild.setAttribute("title",b)}_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 b=this._editLink;b||(b=this._editLink=this._container.querySelector(".mapbox-improve-map"));const c=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||a.config.ACCESS_TOKEN},];if(b){const d=c.reduce((b,a,d)=>(a.value&&(b+=`${a.key}=${a.value}${da.indexOf(b.attribution)&&a.push(b.attribution)}}a.sort((a,b)=>a.length-b.length),a=a.filter((c,d)=>{for(let b=d+1;b=0)return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?a=[...this.options.customAttribution,...a,]:a.unshift(this.options.customAttribution));const c=a.join(" | ");c!==this._attribHTML&&(this._attribHTML=c,a.length?(this._innerContainer.innerHTML=c,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 c9{constructor(){a.bindAll(["_updateLogo"],this),a.bindAll(["_updateCompact"],this)}onAdd(c){this._map=c,this._container=b.create("div","mapboxgl-ctrl");const a=b.create("a","mapboxgl-ctrl-logo");return a.target="_blank",a.rel="noopener nofollow",a.href="https://www.mapbox.com/",a.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),a.setAttribute("rel","noopener nofollow"),this._container.appendChild(a),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(a){a&&"metadata"!==a.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const a=this._map.style._sourceCaches;if(0===Object.entries(a).length)return!0;for(const c in a){const b=a[c].getSource();if(b.hasOwnProperty("mapbox_logo")&&!b.mapbox_logo)return!1}return!0}_updateCompact(){const a=this._container.children;if(a.length){const b=a[0];this._map.getCanvasContainer().offsetWidth<250?b.classList.add("mapboxgl-compact"):b.classList.remove("mapboxgl-compact")}}}class da{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(b){const a=++this._id;return this._queue.push({callback:b,id:a,cancelled:!1}),a}remove(c){const a=this._currentlyRunning,d=a?this._queue.concat(a):this._queue;for(const b of d)if(b.id===c)return void(b.cancelled=!0)}run(b=0){const c=this._currentlyRunning=this._queue;for(const a of(this._queue=[],c))if(!a.cancelled&&(a.callback(b),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function db(b,d,c){if(b=new a.LngLat(b.lng,b.lat),d){const f=new a.LngLat(b.lng-360,b.lat),g=new a.LngLat(b.lng+360,b.lat),h=360*Math.ceil(Math.abs(b.lng-c.center.lng)/360),i=c.locationPoint(b).distSqr(d),j=d.x<0||d.y<0||d.x>c.width||d.y>c.height;c.locationPoint(f).distSqr(d)180;){const e=c.locationPoint(b);if(e.x>=0&&e.y>=0&&e.x<=c.width&&e.y<=c.height)break;b.lng>c.center.lng?b.lng-=360:b.lng+=360}return b}const dc={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 z extends a.Evented{constructor(c,e){if(super(),(c instanceof a.window.HTMLElement||e)&&(c=a.extend({element:c},e)),a.bindAll(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer",],this),this._anchor=c&&c.anchor||"center",this._color=c&&c.color||"#3FB1CE",this._scale=c&&c.scale||1,this._draggable=c&&c.draggable||!1,this._clickTolerance=c&&c.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=c&&c.rotation||0,this._rotationAlignment=c&&c.rotationAlignment||"auto",this._pitchAlignment=c&&c.pitchAlignment&&"auto"!==c.pitchAlignment?c.pitchAlignment:this._rotationAlignment,this._updateMoving=()=>this._update(!0),c&&c.element)this._element=c.element,this._offset=a.pointGeometry.convert(c&&c.offset||[0,0]);else{this._defaultMarker=!0,this._element=b.create("div");const f=41,g=27,d=b.createSVG("svg",{display:"block",height:f*this._scale+"px",width:g*this._scale+"px",viewBox:`0 0 ${g} ${f}`},this._element),h=b.createSVG("radialGradient",{id:"shadowGradient"},b.createSVG("defs",{},d));b.createSVG("stop",{offset:"10%","stop-opacity":.4},h),b.createSVG("stop",{offset:"100%","stop-opacity":.05},h),b.createSVG("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},d),b.createSVG("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"},d),b.createSVG("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"},d),b.createSVG("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},d),this._offset=a.pointGeometry.convert(c&&c.offset||[0,-14])}this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",a=>{a.preventDefault()}),this._element.addEventListener("mousedown",a=>{a.preventDefault()});const i=this._element.classList;for(const j in dc)i.remove(`mapboxgl-marker-anchor-${j}`);i.add(`mapboxgl-marker-anchor-${this._anchor}`),this._popup=null}addTo(a){return a===this._map||(this.remove(),this._map=a,a.getCanvasContainer().appendChild(this._element),a.on("move",this._updateMoving),a.on("moveend",this._update),a.on("remove",this._clearFadeTimer),a._addMarker(this),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick)),this}remove(){return this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._updateMoving),this._map.off("moveend",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),this._map.off("remove",this._clearFadeTimer),this._map._removeMarker(this),delete this._map),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(b){return this._lngLat=a.LngLat.convert(b),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(c){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")),c){if(!("offset"in c.options)){const b=38.1,a=13.5,d=Math.sqrt(Math.pow(a,2)/2);c.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-b],"bottom-left":[d,-1*(b-a+d),],"bottom-right":[-d,-1*(b-a+d),],left:[a,-1*(b-a)],right:[-a,-1*(b-a)]}:this._offset}this._popup=c,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(a){const b=a.code,c=a.charCode||a.keyCode;"Space"!==b&&"Enter"!==b&&32!==c&&13!==c||this.togglePopup()}_onMapClick(c){const a=c.originalEvent.target,b=this._element;this._popup&&(a===b||b.contains(a))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const a=this._popup;return a&&(a.isOpen()?(a.remove(),this._element.setAttribute("aria-expanded","false")):(a.addTo(this._map),this._element.setAttribute("aria-expanded","true"))),this}_evaluateOpacity(){const a=this._pos?this._pos.sub(this._transformedOffset()):null;if(!this._withinScreenBounds(a))return void this._clearFadeTimer();const b=this._map.unproject(a);let c=!1;if(this._map.transform._terrainEnabled()&&this._map.getTerrain()){const d=this._map.getFreeCameraOptions();if(d.position){const e=d.position.toLngLat();c=e.distanceTo(b)<.9*e.distanceTo(this._lngLat)}}const f=(1-this._map._queryFogOpacity(b))*(c?.2:1);this._element.style.opacity=`${f}`,this._popup&&this._popup._setOpacity(`${f}`),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_withinScreenBounds(a){const b=this._map.transform;return!!a&&a.x>=0&&a.x=0&&a.y{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),this._map._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(this._map.getTerrain()||this._map.getFog())&&!this._fadeTimer&&(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))}))}_transformedOffset(){if(!this._defaultMarker)return this._offset;const b=this._map.transform,a=this._offset.mult(this._scale);return"map"===this._rotationAlignment&&a._rotate(b.angle),"map"===this._pitchAlignment&&(a.y*=Math.cos(b._pitch)),a}getOffset(){return this._offset}setOffset(b){return this._offset=a.pointGeometry.convert(b),this._update(),this}_onMove(b){if(!this._isDragging){const c=this._clickTolerance||this._map._clickTolerance;this._isDragging=b.point.dist(this._pointerdownPos)>=c}this._isDragging&&(this._pos=b.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new a.Event("dragstart"))),this.fire(new a.Event("drag")))}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),"active"===this._state&&this.fire(new a.Event("dragend")),this._state="inactive"}_addDragHandler(a){this._element.contains(a.originalEvent.target)&&(a.preventDefault(),this._positionDelta=a.point.sub(this._pos).add(this._transformedOffset()),this._pointerdownPos=a.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))}setDraggable(a){return this._draggable=!!a,this._map&&(a?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(a){return this._rotation=a||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(a){return this._rotationAlignment=a||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(a){return this._pitchAlignment=a&&"auto"!==a?a:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}}const{HTMLImageElement:dd,HTMLElement:de,ImageBitmap:df}=a.window;function dg(a){a.parentNode&&a.parentNode.removeChild(a)}class dh{constructor(c,b,d=!1){this._clickTolerance=10,this.element=b,this.mouseRotate=new cM({clickTolerance:c.dragRotate._mouseRotate._clickTolerance}),this.map=c,d&&(this.mousePitch=new cN({clickTolerance:c.dragRotate._mousePitch._clickTolerance})),a.bindAll(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset",],this),b.addEventListener("mousedown",this.mousedown),b.addEventListener("touchstart",this.touchstart,{passive:!1}),b.addEventListener("touchmove",this.touchmove),b.addEventListener("touchend",this.touchend),b.addEventListener("touchcancel",this.reset)}down(a,c){this.mouseRotate.mousedown(a,c),this.mousePitch&&this.mousePitch.mousedown(a,c),b.disableDrag()}move(d,e){const a=this.map,b=this.mouseRotate.mousemoveWindow(d,e);if(b&&b.bearingDelta&&a.setBearing(a.getBearing()+b.bearingDelta),this.mousePitch){const c=this.mousePitch.mousemoveWindow(d,e);c&&c.pitchDelta&&a.setPitch(a.getPitch()+c.pitchDelta)}}off(){const a=this.element;a.removeEventListener("mousedown",this.mousedown),a.removeEventListener("touchstart",this.touchstart,{passive:!1}),a.removeEventListener("touchmove",this.touchmove),a.removeEventListener("touchend",this.touchend),a.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){b.enableDrag(),a.window.removeEventListener("mousemove",this.mousemove),a.window.removeEventListener("mouseup",this.mouseup)}mousedown(c){this.down(a.extend({},c,{ctrlKey:!0,preventDefault:()=>c.preventDefault()}),b.mousePos(this.element,c)),a.window.addEventListener("mousemove",this.mousemove),a.window.addEventListener("mouseup",this.mouseup)}mousemove(a){this.move(a,b.mousePos(this.element,a))}mouseup(a){this.mouseRotate.mouseupWindow(a),this.mousePitch&&this.mousePitch.mouseupWindow(a),this.offTemp()}touchstart(a){1!==a.targetTouches.length?this.reset():(this._startPos=this._lastPos=b.touchPos(this.element,a.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>a.preventDefault()},this._startPos))}touchmove(a){1!==a.targetTouches.length?this.reset():(this._lastPos=b.touchPos(this.element,a.targetTouches)[0],this.move({preventDefault:()=>a.preventDefault()},this._lastPos))}touchend(a){0===a.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)5280?dm(d,c,f/5280,a._getUIString("ScaleControl.Miles"),a):dm(d,c,f,a._getUIString("ScaleControl.Feet"),a)}else b&&"nautical"===b.unit?dm(d,c,e/1852,a._getUIString("ScaleControl.NauticalMiles"),a):e>=1e3?dm(d,c,e/1e3,a._getUIString("ScaleControl.Kilometers"),a):dm(d,c,e,a._getUIString("ScaleControl.Meters"),a)}function dm(d,e,a,f,b){const c=function(b){const c=Math.pow(10,`${Math.floor(b)}`.length-1);let a=b/c;return a=a>=10?10:a>=5?5:a>=3?3:a>=2?2:a>=1?1:function(a){const b=Math.pow(10,Math.ceil(-Math.log(a)/Math.LN10));return Math.round(a*b)/b}(a),c*a}(a),g=c/a;b._requestDomTask(()=>{d.style.width=e*g+"px",d.innerHTML=`${c} ${f}`})}const A={version:a.version,supported:l,setRTLTextPlugin:a.setRTLTextPlugin,getRTLTextPluginStatus:a.getRTLTextPluginStatus,Map:class extends c8{constructor(c){if(null!=(c=a.extend({},{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,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,optimizeForTerrain:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,transformRequest:null,accessToken:null,fadeDuration:300,crossSourceCollisions:!0},c)).minZoom&&null!=c.maxZoom&&c.minZoom>c.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=c.minPitch&&null!=c.maxPitch&&c.minPitch>c.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=c.minPitch&&c.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=c.maxPitch&&c.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(super(new ct(c.minZoom,c.maxZoom,c.minPitch,c.maxPitch,c.renderWorldCopies),c),this._interactive=c.interactive,this._minTileCacheSize=c.minTileCacheSize,this._maxTileCacheSize=c.maxTileCacheSize,this._failIfMajorPerformanceCaveat=c.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=c.preserveDrawingBuffer,this._antialias=c.antialias,this._trackResize=c.trackResize,this._bearingSnap=c.bearingSnap,this._refreshExpiredTiles=c.refreshExpiredTiles,this._fadeDuration=c.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=c.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=c.collectResourceTiming,this._optimizeForTerrain=c.optimizeForTerrain,this._renderTaskQueue=new da,this._domRenderTaskQueue=new da,this._controls=[],this._markers=[],this._mapId=a.uniqueId(),this._locale=a.extend({},{"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","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use \u2318 + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"},c.locale),this._clickTolerance=c.clickTolerance,this._cooperativeGestures=c.cooperativeGestures,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevation=new class{constructor(a){this.jumpTo(a)}getValue(b){if(b<=this._startTime)return this._start;if(b>=this._endTime)return this._end;const c=a.easeCubicInOut((b-this._startTime)/(this._endTime-this._startTime));return this._start*(1-c)+this._end*c}isEasing(a){return a>=this._startTime&&a<=this._endTime}jumpTo(a){this._startTime=-1/0,this._endTime=-1/0,this._start=a,this._end=a}easeTo(b,a,c){this._start=this.getValue(a),this._end=b,this._startTime=a,this._endTime=a+c}}(0),this._requestManager=new a.RequestManager(c.transformRequest,c.accessToken,c.testMode),this._silenceAuthErrors=!!c.testMode,"string"==typeof c.container){if(this._container=a.window.document.getElementById(c.container),!this._container)throw new Error(`Container '${c.container}' not found.`)}else{if(!(c.container instanceof de))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=c.container}if(this._container.childNodes.length>0&&a.warnOnce("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."),c.maxBounds&&this.setMaxBounds(c.maxBounds),a.bindAll(["_onWindowOnline","_onWindowResize","_onMapScroll","_contextLost","_contextRestored",],this),this._setupContainer(),this._setupPainter(),void 0===this.painter)throw new Error("Failed to initialize WebGL.");this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),void 0!==a.window&&(a.window.addEventListener("online",this._onWindowOnline,!1),a.window.addEventListener("resize",this._onWindowResize,!1),a.window.addEventListener("orientationchange",this._onWindowResize,!1),a.window.addEventListener("webkitfullscreenchange",this._onWindowResize,!1)),this.handlers=new class{constructor(c,d){this._map=c,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new class{constructor(a){this._map=a,this.clear()}clear(){this._inertiaBuffer=[]}record(b){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:a.exported.now(),settings:b})}_drainInertiaBuffer(){const b=this._inertiaBuffer,c=a.exported.now();for(;b.length>0&&c-b[0].time>160;)b.shift()}_onMoveEnd(k){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const b={zoom:0,bearing:0,pitch:0,pan:new a.pointGeometry(0,0),pinchAround:void 0,around:void 0};for(const{settings:d}of this._inertiaBuffer)b.zoom+=d.zoomDelta||0,b.bearing+=d.bearingDelta||0,b.pitch+=d.pitchDelta||0,d.panDelta&&b.pan._add(d.panDelta),d.around&&(b.around=d.around),d.pinchAround&&(b.pinchAround=d.pinchAround);const e=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,c={};if(b.pan.mag()){const f=cA(b.pan.mag(),e,a.extend({},cv,k||{}));c.offset=b.pan.mult(f.amount/b.pan.mag()),c.center=this._map.transform.center,cz(c,f)}if(b.zoom){const g=cA(b.zoom,e,cw);c.zoom=this._map.transform.zoom+g.amount,cz(c,g)}if(b.bearing){const h=cA(b.bearing,e,cx);c.bearing=this._map.transform.bearing+a.clamp(h.amount,-179,179),cz(c,h)}if(b.pitch){const i=cA(b.pitch,e,cy);c.pitch=this._map.transform.pitch+i.amount,cz(c,i)}if(c.zoom||c.bearing){const j=void 0===b.pinchAround?b.around:b.pinchAround;c.around=j?this._map.unproject(j):this._map.getCenter()}return this.clear(),a.extend(c,{noMoveStart:!0})}}(c),this._bearingSnap=d.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new class{constructor(){this.constants=[1,1,.01],this.radius=0}setup(c,d){const b=a.sub([],d,c);this.radius=a.length(b[2]<0?a.div([],b,this.constants):[b[0],b[1],0])}projectRay(c){a.div(c,c,this.constants),a.normalize(c,c),a.mul$1(c,c,this.constants);const b=a.scale$2([],c,this.radius);if(b[2]>0){const e=a.scale$2([],[0,0,1],a.dot(b,[0,0,1])),f=a.scale$2([],a.normalize([],[b[0],b[1],0]),this.radius),d=a.add([],b,a.scale$2([],a.sub([],a.add([],f,e),b),2));b[0]=d[0],b[1]=d[1]}return b}},this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(d),a.bindAll(["handleEvent","handleWindowEvent"],this);const b=this._el;for(const[e,f,g]of(this._listeners=[[b,"touchstart",{passive:!0},],[b,"touchmove",{passive:!1},],[b,"touchend",void 0],[b,"touchcancel",void 0],[b,"mousedown",void 0],[b,"mousemove",void 0],[b,"mouseup",void 0],[a.window.document,"mousemove",{capture:!0},],[a.window.document,"mouseup",void 0],[b,"mouseover",void 0],[b,"mouseout",void 0],[b,"dblclick",void 0],[b,"click",void 0],[b,"keydown",{capture:!1},],[b,"keyup",void 0],[b,"wheel",{passive:!1},],[b,"contextmenu",void 0],[a.window,"blur",void 0],],this._listeners))e.addEventListener(f,e===a.window.document?this.handleWindowEvent:this.handleEvent,g)}destroy(){for(const[b,c,d]of this._listeners)b.removeEventListener(c,b===a.window.document?this.handleWindowEvent:this.handleEvent,d)}_addDefaultHandlers(b){const a=this._map,d=a.getCanvasContainer();this._add("mapEvent",new cE(a,b));const n=a.boxZoom=new cG(a,b);this._add("boxZoom",n);const e=new cJ,f=new c_;a.doubleClickZoom=new c$(f,e),this._add("tapZoom",e),this._add("clickZoom",f);const g=new c0;this._add("tapDragZoom",g);const o=a.touchPitch=new cV(a);this._add("touchPitch",o);const h=new cM(b),i=new cN(b);a.dragRotate=new c2(b,h,i),this._add("mouseRotate",h,["mousePitch"]),this._add("mousePitch",i,["mouseRotate"]);const j=new cL(b),k=new cO(a,b);a.dragPan=new c1(d,j,k),this._add("mousePan",j),this._add("touchPan",k,["touchZoom","touchRotate",]);const l=new cT,m=new cR;a.touchZoomRotate=new c3(d,m,l,g),this._add("touchRotate",l,["touchPan","touchZoom",]),this._add("touchZoom",m,["touchPan","touchRotate",]),this._add("blockableMapEvent",new cF(a));const p=a.scrollZoom=new cZ(a,this);this._add("scrollZoom",p,["mousePan"]);const q=a.keyboard=new cW;for(const c of(this._add("keyboard",q),["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard",]))b.interactive&&b[c]&&a[c].enable(b[c])}_add(a,b,c){this._handlers.push({handlerName:a,handler:b,allowed:c}),this._handlersById[a]=b}stop(a){if(!this._updatingCamera){for(const{handler:b}of this._handlers)b.reset();this._inertia.clear(),this._fireEvents({},{},a),this._changes=[]}}isActive(){for(const{handler:a}of this._handlers)if(a.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return Boolean(c4(this._eventsInProgress))||this.isZooming()}_blockedByActive(c,a,d){for(const b in c)if(b!==d&&(!a||0>a.indexOf(b)))return!0;return!1}handleWindowEvent(a){this.handleEvent(a,`${a.type}Window`)}_getMapTouches(c){const a=[];for(const b of c)this._el.contains(b.target)&&a.push(b);return a}handleEvent(a,j){this._updatingCamera=!0;const k="renderFrame"===a.type,l=k?void 0:a,d={needsRenderFrame:!1},m={},e={},g=a.touches?this._getMapTouches(a.touches):void 0,p=g?b.touchPos(this._el,g):k?void 0:b.mousePos(this._el,a);for(const{handlerName:h,handler:c,allowed:q}of this._handlers){if(!c.isEnabled())continue;let f;this._blockedByActive(e,q,h)?c.reset():c[j||a.type]&&(f=c[j||a.type](a,p,g),this.mergeHandlerResult(d,m,f,h,l),f&&f.needsRenderFrame&&this._triggerRenderFrame()),(f||c.isActive())&&(e[h]=c)}const i={};for(const n in this._previousActiveHandlers)e[n]||(i[n]=l);this._previousActiveHandlers=e,(Object.keys(i).length||c6(d))&&(this._changes.push([d,m,i]),this._triggerRenderFrame()),(Object.keys(e).length||c6(d))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:o}=d;o&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],o(this._map))}mergeHandlerResult(e,c,b,f,g){if(!b)return;a.extend(e,b);const d={handlerName:f,originalEvent:b.originalEvent||g};void 0!==b.zoomDelta&&(c.zoom=d),void 0!==b.panDelta&&(c.drag=d),void 0!==b.pitchDelta&&(c.pitch=d),void 0!==b.bearingDelta&&(c.rotate=d)}_applyChanges(){const c={},d={},e={};for(const[b,f,g]of this._changes)b.panDelta&&(c.panDelta=(c.panDelta||new a.pointGeometry(0,0))._add(b.panDelta)),b.zoomDelta&&(c.zoomDelta=(c.zoomDelta||0)+b.zoomDelta),b.bearingDelta&&(c.bearingDelta=(c.bearingDelta||0)+b.bearingDelta),b.pitchDelta&&(c.pitchDelta=(c.pitchDelta||0)+b.pitchDelta),void 0!==b.around&&(c.around=b.around),void 0!==b.aroundCoord&&(c.aroundCoord=b.aroundCoord),void 0!==b.pinchAround&&(c.pinchAround=b.pinchAround),b.noInertia&&(c.noInertia=b.noInertia),a.extend(d,f),a.extend(e,g);this._updateMapTransform(c,d,e),this._changes=[]}_updateMapTransform(d,f,k){const g=this._map,b=g.transform,l=a=>[a.x,a.y,a.z];if((b=>{const a=this._eventsInProgress.drag;return a&&!this._handlersById[a.handlerName].isActive()})()&&!c6(d)){const t=b.zoom;b.cameraElevationReference="sea",b.recenterOnTerrain(),b.cameraElevationReference="ground",t!==b.zoom&&this._map._update(!0)}if(!c6(d))return this._fireEvents(f,k,!0);let{panDelta:m,zoomDelta:h,bearingDelta:n,pitchDelta:o,around:c,aroundCoord:u,pinchAround:p}=d;void 0!==p&&(c=p),f.drag&&!this._eventsInProgress.drag&&c&&(this._dragOrigin=l(b.pointCoordinate3D(c)),this._trackingEllipsoid.setup(b._camera.position,this._dragOrigin)),b.cameraElevationReference="sea",g._stop(!0),c=c||g.transform.centerPoint,n&&(b.bearing+=n),o&&(b.pitch+=o),b._updateCameraState();const e=[0,0,0];if(m){const i=b.pointCoordinate(c),j=b.pointCoordinate(c.sub(m));i&&j&&(e[0]=j.x-i.x,e[1]=j.y-i.y)}const v=b.zoom,q=[0,0,0];if(h){const r=l(u||b.pointCoordinate3D(c)),s={dir:a.normalize([],a.sub([],r,b._camera.position))};if(s.dir[2]<0){const w=b.zoomDeltaToMovement(r,h);a.scale$2(q,s.dir,w)}}const x=a.add(e,e,q);b._translateCameraConstrained(x),h&&Math.abs(b.zoom-v)>1e-4&&b.recenterOnTerrain(),b.cameraElevationReference="ground",this._map._update(),d.noInertia||this._inertia.record(d),this._fireEvents(f,k,!0)}_fireEvents(b,p,q){const j=c4(this._eventsInProgress),c=c4(b),g={};for(const d in b){const{originalEvent:r}=b[d];this._eventsInProgress[d]||(g[`${d}start`]=r),this._eventsInProgress[d]=b[d]}for(const k in!j&&c&&this._fireEvent("movestart",c.originalEvent),g)this._fireEvent(k,g[k]);for(const l in c&&this._fireEvent("move",c.originalEvent),b){const{originalEvent:s}=b[l];this._fireEvent(l,s)}const h={};let e;for(const i in this._eventsInProgress){const{handlerName:m,originalEvent:t}=this._eventsInProgress[i];this._handlersById[m].isActive()||(delete this._eventsInProgress[i],e=p[m]||t,h[`${i}end`]=e)}for(const n in h)this._fireEvent(n,h[n]);const u=c4(this._eventsInProgress);if(q&&(j||c)&&!u){this._updatingCamera=!0;const f=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),o=a=>0!==a&& -this._bearingSnap{delete this._frameId,this.handleEvent(new c5("renderFrame",{timeStamp:a})),this._applyChanges()})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}(this,c),this._localFontFamily=c.localFontFamily,this._localIdeographFontFamily=c.localIdeographFontFamily,c.style&&this.setStyle(c.style,{localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),c.projection&&this.setProjection(c.projection),this._hash=c.hash&&new class{constructor(b){this._hashName=b&&encodeURIComponent(b),a.bindAll(["_getCurrentHash","_onHashChange","_updateHash",],this),this._updateHash=cu(this._updateHashUnthrottled.bind(this),300)}addTo(b){return this._map=b,a.window.addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return a.window.removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),delete this._map,this}getHashString(k){const f=this._map.getCenter(),d=Math.round(100*this._map.getZoom())/100,c=Math.pow(10,Math.ceil((d*Math.LN2+Math.log(512/360/.5))/Math.LN10)),g=Math.round(f.lng*c)/c,h=Math.round(f.lat*c)/c,i=this._map.getBearing(),e=this._map.getPitch();let b="";if(b+=k?`/${g}/${h}/${d}`:`${d}/${h}/${g}`,(i||e)&&(b+="/"+Math.round(10*i)/10),e&&(b+=`/${Math.round(e)}`),this._hashName){const l=this._hashName;let m=!1;const j=a.window.location.hash.slice(1).split("&").map(a=>{const c=a.split("=")[0];return c===l?(m=!0,`${c}=${b}`):a}).filter(a=>a);return m||j.push(`${l}=${b}`),`#${j.join("&")}`}return`#${b}`}_getCurrentHash(){const b=a.window.location.hash.replace("#","");if(this._hashName){let c;return b.split("&").map(a=>a.split("=")).forEach(a=>{a[0]===this._hashName&&(c=a)}),(c&&c[1]||"").split("/")}return b.split("/")}_onHashChange(){const a=this._getCurrentHash();if(a.length>=3&&!a.some(a=>isNaN(a))){const b=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(a[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+a[2],+a[1]],zoom:+a[0],bearing:b,pitch:+(a[4]||0)}),!0}return!1}_updateHashUnthrottled(){const b=a.window.location.href.replace(/(#.+)?$/,this.getHashString());a.window.history.replaceState(a.window.history.state,null,b)}}("string"==typeof c.hash&&c.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:c.center,zoom:c.zoom,bearing:c.bearing,pitch:c.pitch}),c.bounds&&(this.resize(),this.fitBounds(c.bounds,a.extend({},c.fitBoundsOptions,{duration:0})))),this.resize(),c.attributionControl&&this.addControl(new y({customAttribution:c.customAttribution})),this._logoControl=new c9,this.addControl(this._logoControl,c.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",b=>{this._update("style"===b.dataType),this.fire(new a.Event(`${b.dataType}data`,b))}),this.on("dataloading",b=>{this.fire(new a.Event(`${b.dataType}dataloading`,b))})}_getMapId(){return this._mapId}addControl(b,c){if(void 0===c&&(c=b.getDefaultPosition?b.getDefaultPosition():"top-right"),!b||!b.onAdd)return this.fire(new a.ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const e=b.onAdd(this);this._controls.push(b);const d=this._controlPositions[c];return -1!==c.indexOf("bottom")?d.insertBefore(e,d.firstChild):d.appendChild(e),this}removeControl(b){if(!b||!b.onRemove)return this.fire(new a.ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const c=this._controls.indexOf(b);return c> -1&&this._controls.splice(c,1),b.onRemove(this),this}hasControl(a){return this._controls.indexOf(a)> -1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(b){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 c=!this._moving;return c&&this.fire(new a.Event("movestart",b)).fire(new a.Event("move",b)),this.fire(new a.Event("resize",b)),c&&this.fire(new a.Event("moveend",b)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(b){return this.transform.setMaxBounds(a.LngLatBounds.convert(b)),this._update()}setMinZoom(b){if((b=null==b?-2:b)>= -2&&b<=this.transform.maxZoom)return this.transform.minZoom=b,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=b,this._update(),this.getZoom()>b?this.setZoom(b):this.fire(new a.Event("zoomstart")).fire(new a.Event("zoom")).fire(new a.Event("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(b){if((b=null==b?0:b)<0)throw new Error("minPitch must be greater than or equal to 0");if(b>=0&&b<=this.transform.maxPitch)return this.transform.minPitch=b,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(b>=this.transform.minPitch)return this.transform.maxPitch=b,this._update(),this.getPitch()>b?this.setPitch(b):this.fire(new a.Event("pitchstart")).fire(new a.Event("pitch")).fire(new a.Event("pitchend")),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(a){return this.transform.renderWorldCopies=a,this._update()}getProjection(){return this.transform.getProjection()}setProjection(a){return this._lazyInitEmptyStyle(),"string"==typeof a&&(a={name:a}),this._runtimeProjection=a,this.style.updateProjection(),this._transitionFromGlobe=!1,this}project(b){return this.transform.locationPoint3D(a.LngLat.convert(b))}unproject(b){return this.transform.pointLocation3D(a.pointGeometry.convert(b))}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()}_createDelegatedListener(a,b,c){if("mouseenter"===a||"mouseover"===a){let h=!1;const d=d=>{const e=b.filter(a=>this.getLayer(a)),f=e.length?this.queryRenderedFeatures(d.point,{layers:e}):[];f.length?h||(h=!0,c.call(this,new cB(a,this,d.originalEvent,{features:f}))):h=!1},e=()=>{h=!1};return{layers:new Set(b),listener:c,delegates:{mousemove:d,mouseout:e}}}if("mouseleave"===a||"mouseout"===a){let i=!1;const f=d=>{const e=b.filter(a=>this.getLayer(a));(e.length?this.queryRenderedFeatures(d.point,{layers:e}):[]).length?i=!0:i&&(i=!1,c.call(this,new cB(a,this,d.originalEvent)))},g=b=>{i&&(i=!1,c.call(this,new cB(a,this,b.originalEvent)))};return{layers:new Set(b),listener:c,delegates:{mousemove:f,mouseout:g}}}return{layers:new Set(b),listener:c,delegates:{[a]:a=>{const d=b.filter(a=>this.getLayer(a)),e=d.length?this.queryRenderedFeatures(a.point,{layers:d}):[];e.length&&(a.features=e,c.call(this,a),delete a.features)}}}}on(a,b,d){if(void 0===d)return super.on(a,b);Array.isArray(b)||(b=[b]);const c=this._createDelegatedListener(a,b,d);for(const e in this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[a]=this._delegatedListeners[a]||[],this._delegatedListeners[a].push(c),c.delegates)this.on(e,c.delegates[e]);return this}once(b,a,c){if(void 0===c)return super.once(b,a);Array.isArray(a)||(a=[a]);const d=this._createDelegatedListener(b,a,c);for(const e in d.delegates)this.once(e,d.delegates[e]);return this}off(b,a,d){if(void 0===d)return super.off(b,a);a=new Set(Array.isArray(a)?a:[a]);const e=(a,b)=>{if(a.size!==b.size)return!1;for(const c of a)if(!b.has(c))return!1;return!0},c=this._delegatedListeners?this._delegatedListeners[b]:void 0;return c&&(f=>{for(let b=0;b{b?this.fire(new a.ErrorEvent(b)):d&&this._updateDiff(d,c)})}else"object"==typeof b&&this._updateDiff(b,c)}_updateDiff(c,d){try{this.style.setState(c)&&this._update(!0)}catch(b){a.warnOnce(`Unable to perform style diff: ${b.message||b.error||b}. Rebuilding the style from scratch.`),this._updateStyle(c,d)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():a.warnOnce("There is no style added to the map.")}addSource(a,b){return this._lazyInitEmptyStyle(),this.style.addSource(a,b),this._update(!0)}isSourceLoaded(b){const c=this.style&&this.style._getSourceCaches(b);if(0!==c.length)return c.every(a=>a.loaded());this.fire(new a.ErrorEvent(new Error(`There is no source with ID '${b}'`)))}areTilesLoaded(){const a=this.style&&this.style._sourceCaches;for(const d in a){const b=a[d]._tiles;for(const e in b){const c=b[e];if("loaded"!==c.state&&"errored"!==c.state)return!1}}return!0}addSourceType(a,b,c){return this._lazyInitEmptyStyle(),this.style.addSourceType(a,b,c)}removeSource(a){return this.style.removeSource(a),this._updateTerrain(),this._update(!0)}getSource(a){return this.style.getSource(a)}addImage(c,b,{pixelRatio:e=1,sdf:f=!1,stretchX:g,stretchY:h,content:i}={}){if(this._lazyInitEmptyStyle(),b instanceof dd||df&&b instanceof df){const{width:j,height:k,data:l}=a.exported.getImageData(b);this.style.addImage(c,{data:new a.RGBAImage({width:j,height:k},l),pixelRatio:e,stretchX:g,stretchY:h,content:i,sdf:f,version:0})}else{if(void 0===b.width|| void 0===b.height)return this.fire(new a.ErrorEvent(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:m,height:n,data:o}=b,d=b;this.style.addImage(c,{data:new a.RGBAImage({width:m,height:n},new Uint8Array(o)),pixelRatio:e,stretchX:g,stretchY:h,content:i,sdf:f,version:0,userImage:d}),d.onAdd&&d.onAdd(this,c)}}}updateImage(d,b){const c=this.style.getImage(d);if(!c)return this.fire(new a.ErrorEvent(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const g=b instanceof dd||df&&b instanceof df?a.exported.getImageData(b):b,{width:e,height:f,data:h}=g;return void 0===e|| void 0===f?this.fire(new a.ErrorEvent(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`"))):e!==c.data.width||f!==c.data.height?this.fire(new a.ErrorEvent(new Error("The width and height of the updated image must be that same as the previous version of the image"))):(c.data.replace(h,!(b instanceof dd||df&&b instanceof df)),void this.style.updateImage(d,c))}hasImage(b){return b?!!this.style.getImage(b):(this.fire(new a.ErrorEvent(new Error("Missing required image id"))),!1)}removeImage(a){this.style.removeImage(a)}loadImage(b,c){a.getImage(this._requestManager.transformRequest(b,a.ResourceType.Image),(d,b)=>{c(d,b instanceof dd?a.exported.getImageData(b):b)})}listImages(){return this.style.listImages()}addLayer(a,b){return this._lazyInitEmptyStyle(),this.style.addLayer(a,b),this._update(!0)}moveLayer(a,b){return this.style.moveLayer(a,b),this._update(!0)}removeLayer(a){return this.style.removeLayer(a),this._update(!0)}getLayer(a){return this.style.getLayer(a)}setLayerZoomRange(a,b,c){return this.style.setLayerZoomRange(a,b,c),this._update(!0)}setFilter(a,b,c={}){return this.style.setFilter(a,b,c),this._update(!0)}getFilter(a){return this.style.getFilter(a)}setPaintProperty(a,b,c,d={}){return this.style.setPaintProperty(a,b,c,d),this._update(!0)}getPaintProperty(a,b){return this.style.getPaintProperty(a,b)}setLayoutProperty(a,b,c,d={}){return this.style.setLayoutProperty(a,b,c,d),this._update(!0)}getLayoutProperty(a,b){return this.style.getLayoutProperty(a,b)}setLight(a,b={}){return this._lazyInitEmptyStyle(),this.style.setLight(a,b),this._update(!0)}getLight(){return this.style.getLight()}setTerrain(a){return this._lazyInitEmptyStyle(),!a&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(a),this._averageElevationLastSampledAt=-1/0,this._update(!0)}_updateProjection(){"globe"===this.transform.projection.name&&this.transform.zoom>=a.GLOBE_ZOOM_THRESHOLD_MAX&&!this._transitionFromGlobe&&(this.setProjection({name:"mercator"}),this._transitionFromGlobe=!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(a){return this._lazyInitEmptyStyle(),this.style.setFog(a),this._update(!0)}getFog(){return this.style?this.style.getFog():null}_queryFogOpacity(b){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(a.LngLat.convert(b),this.transform):0}setFeatureState(a,b){return this.style.setFeatureState(a,b),this._update()}removeFeatureState(a,b){return this.style.removeFeatureState(a,b),this._update()}getFeatureState(a){return this.style.getFeatureState(a)}_updateContainerDimensions(){if(!this._container)return;const d=this._container.getBoundingClientRect().width||400,e=this._container.getBoundingClientRect().height||300;let b,c=this._container;for(;c&&!b;){const f=a.window.getComputedStyle(c).transform;f&&"none"!==f&&(b=f.match(/matrix.*\((.+)\)/)[1].split(", ")),c=c.parentElement}b?(this._containerWidth=b[0]&&"0"!==b[0]?Math.abs(d/b[0]):d,this._containerHeight=b[3]&&"0"!==b[3]?Math.abs(e/b[3]):e):(this._containerWidth=d,this._containerHeight=e)}_detectMissingCSS(){"rgb(250, 128, 114)"!==a.window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&a.warnOnce("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 a=this._container;a.classList.add("mapboxgl-map"),(this._missingCSSCanary=b.create("div","mapboxgl-canary",a)).style.visibility="hidden",this._detectMissingCSS();const c=this._canvasContainer=b.create("div","mapboxgl-canvas-container",a);this._interactive&&c.classList.add("mapboxgl-interactive"),this._canvas=b.create("canvas","mapboxgl-canvas",c),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex","0"),this._canvas.setAttribute("aria-label","Map"),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const d=this._controlContainer=b.create("div","mapboxgl-control-container",a),e=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right",].forEach(a=>{e[a]=b.create("div",`mapboxgl-ctrl-${a}`,d)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(b,c){const d=a.exported.devicePixelRatio||1;this._canvas.width=d*Math.ceil(b),this._canvas.height=d*Math.ceil(c),this._canvas.style.width=`${b}px`,this._canvas.style.height=`${c}px`}_addMarker(a){this._markers.push(a)}_removeMarker(b){const a=this._markers.indexOf(b);-1!==a&&this._markers.splice(a,1)}_setupPainter(){const c=a.extend({},l.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),b=this._canvas.getContext("webgl",c)||this._canvas.getContext("experimental-webgl",c);b?(a.storeAuthState(b,!0),this.painter=new cg(b,this.transform),this.on("data",a=>{"source"===a.dataType&&this.painter.setTileLoadedFlag(!0)}),a.exported$1.testSupport(b)):this.fire(new a.ErrorEvent(new Error("Failed to initialize WebGL")))}_contextLost(b){b.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new a.Event("webglcontextlost",{originalEvent:b}))}_contextRestored(b){this._setupPainter(),this.resize(),this._update(),this.fire(new a.Event("webglcontextrestored",{originalEvent:b}))}_onMapScroll(a){if(a.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(a){return this.style&&(this._styleDirty=this._styleDirty||a,this._sourcesDirty=!0,this.triggerRepaint()),this}_requestRenderFrame(a){return this._update(),this._renderTaskQueue.add(a)}_cancelRenderFrame(a){this._renderTaskQueue.remove(a)}_requestDomTask(a){!this.loaded()||this.loaded()&&!this.isMoving()?a():this._domRenderTaskQueue.add(a)}_render(h){let c;const b=this.painter.context.extTimerQuery,d=a.exported.now();this.listens("gpu-timing-frame")&&(c=b.createQueryEXT(),b.beginQueryEXT(b.TIME_ELAPSED_EXT,c));let e=this._updateAverageElevation(d);if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(h),this._domRenderTaskQueue.run(h),this._removed)return;this._updateProjection();let i=!1;const f=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const j=this.transform.zoom,o=this.transform.pitch,k=a.exported.now();this.style.zoomHistory.update(j,k);const l=new a.EvaluationParameters(j,{now:k,fadeDuration:f,pitch:o,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),g=l.crossFadingFactor();1===g&&g===this._crossFadingFactor||(i=!0,this._crossFadingFactor=g),this.style.update(l)}if(this.style&&this.style.fog&&this.style.fog.hasTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0),this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),this.style._updateSources(this.transform),this._forceMarkerUpdate()),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,f,this._crossSourceCollisions),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showTerrainWireframe:this.showTerrainWireframe,showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:f,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),speedIndexTiming:this.speedIndexTiming}),this.fire(new a.Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new a.Event("load"))),this.style&&(this.style.hasTransitions()||i)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),this.listens("gpu-timing-frame")){const q=a.exported.now()-d;b.endQueryEXT(b.TIME_ELAPSED_EXT,c),setTimeout(()=>{const d=b.getQueryObjectEXT(c,b.QUERY_RESULT_EXT)/1e6;b.deleteQueryEXT(c),this.fire(new a.Event("gpu-timing-frame",{cpuTime:q,gpuTime:d}))},50)}if(this.listens("gpu-timing-layer")){const r=this.painter.collectGpuTimers();setTimeout(()=>{const b=this.painter.queryGpuTimers(r);this.fire(new a.Event("gpu-timing-layer",{layerTimes:b}))},50)}const m=this._sourcesDirty||this._styleDirty||this._placementDirty||e;if(m||this._repaint)this.triggerRepaint();else{const n=!this.isMoving()&&this.loaded();if(n&&(e=this._updateAverageElevation(d,!0)),e)this.triggerRepaint();else if(this._triggerFrame(!1),n&&(this.fire(new a.Event("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const p=this._calculateSpeedIndex();this.fire(new a.Event("speedindexcompleted",{speedIndex:p})),this.speedIndexTiming=!1}}return!this._loaded||this._fullyLoaded||m||(this._fullyLoaded=!0,this._authenticate()),this}_forceMarkerUpdate(){for(const a of this._markers)a._update()}_updateAverageElevation(b,e=!1){const c=a=>(this.transform.averageElevation=a,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&c(0);if((e||b-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(b)){const f=this.transform.averageElevation;let a=this.transform.sampleAverageElevation();isNaN(a)?a=0:this._averageElevationLastSampledAt=b;const d=Math.abs(f-a);if(d>1){if(this._isInitialLoad)return this._averageElevation.jumpTo(a),c(a);this._averageElevation.easeTo(a,b,300)}else if(d>1e-4)return this._averageElevation.jumpTo(a),c(a)}return!!this._averageElevation.isEasing(b)&&c(this._averageElevation.getValue(b))}_authenticate(){a.getMapSessionAPI(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,c=>{if(c&&(c.message===a.AUTH_ERR_MSG||401===c.status)){const b=this.painter.context.gl;a.storeAuthState(b,!1),this._logoControl instanceof c9&&this._logoControl._updateLogo(),b&&b.clear(b.DEPTH_BUFFER_BIT|b.COLOR_BUFFER_BIT|b.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new a.ErrorEvent(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/")))}}),a.postMapLoadEvent(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_updateTerrain(){this.painter.updateTerrain(this.style,this.isMoving()||this.isRotating()||this.isZooming())}_calculateSpeedIndex(){const d=this.painter.canvasCopy(),a=this.painter.getCanvasCopiesAndTimestamps();a.timeStamps.push(performance.now());const b=this.painter.context.gl,e=b.createFramebuffer();function c(c){b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,c,0);const a=new Uint8Array(b.drawingBufferWidth*b.drawingBufferHeight*4);return b.readPixels(0,0,b.drawingBufferWidth,b.drawingBufferHeight,b.RGBA,b.UNSIGNED_BYTE,a),a}return b.bindFramebuffer(b.FRAMEBUFFER,e),this._canvasPixelComparison(c(d),a.canvasCopies.map(c),a.timeStamps)}_canvasPixelComparison(b,f,e){let g=e[1]-e[0];const i=b.length/4;for(let c=0;c{const b=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,b&&this._render(a)}))}_preloadTiles(c){const b=this.style&&Object.values(this.style._sourceCaches)||[];return a.asyncAll(b,(a,b)=>a._preloadTiles(c,b),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(a){this._trackResize&&this.resize({originalEvent:a})._update()}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(a){this._showTileBoundaries!==a&&(this._showTileBoundaries=a,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(a){this._showTerrainWireframe!==a&&(this._showTerrainWireframe=a,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(a){this._speedIndexTiming!==a&&(this._speedIndexTiming=a,this._update())}get showPadding(){return!!this._showPadding}set showPadding(a){this._showPadding!==a&&(this._showPadding=a,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(a){this._showCollisionBoxes!==a&&(this._showCollisionBoxes=a,a?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(a){this._showOverdrawInspector!==a&&(this._showOverdrawInspector=a,this._update())}get repaint(){return!!this._repaint}set repaint(a){this._repaint!==a&&(this._repaint=a,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(a){this._vertices=a,this._update()}_setCacheLimits(b,c){a.setCacheLimits(b,c)}get version(){return a.version}},NavigationControl:class{constructor(c){this.options=a.extend({},{showCompass:!0,showZoom:!0,visualizePitch:!1},c),this._container=b.create("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",a=>a.preventDefault()),this.options.showZoom&&(a.bindAll(["_setButtonTitle","_updateZoomButtons",],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",a=>this._map.zoomIn({},{originalEvent:a})),b.create("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden",!0),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",a=>this._map.zoomOut({},{originalEvent:a})),b.create("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden",!0)),this.options.showCompass&&(a.bindAll(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",a=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:a}):this._map.resetNorth({},{originalEvent:a})}),this._compassIcon=b.create("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden",!0))}_updateZoomButtons(){const a=this._map.getZoom(),b=a===this._map.getMaxZoom(),c=a===this._map.getMinZoom();this._zoomInButton.disabled=b,this._zoomOutButton.disabled=c,this._zoomInButton.setAttribute("aria-disabled",b.toString()),this._zoomOutButton.setAttribute("aria-disabled",c.toString())}_rotateCompassArrow(){const a=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitch*(Math.PI/180)),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${this._map.transform.angle*(180/Math.PI)}deg)`:`rotate(${this._map.transform.angle*(180/Math.PI)}deg)`;this._map._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=a)})}onAdd(a){return this._map=a,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new dh(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){this._container.remove(),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(c,d){const a=b.create("button",c,this._container);return a.type="button",a.addEventListener("click",d),a}_setButtonTitle(a,c){const b=this._map._getUIString(`NavigationControl.${c}`);a.setAttribute("aria-label",b),a.firstElementChild&&a.firstElementChild.setAttribute("title",b)}},GeolocateControl:class extends a.Evented{constructor(b){super(),this.options=a.extend({},{positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,showUserHeading:!1},b),a.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation",],this),this._onDeviceOrientationListener=this._onDeviceOrientation.bind(this),this._updateMarkerRotationThrottled=cu(this._updateMarkerRotation,20)}onAdd(d){var c;return this._map=d,this._container=b.create("div","mapboxgl-ctrl mapboxgl-ctrl-group"),c=this._setupUI,void 0!==di?c(di):void 0!==a.window.navigator.permissions?a.window.navigator.permissions.query({name:"geolocation"}).then(a=>{c(di="denied"!==a.state)}):c(di=!!a.window.navigator.geolocation),this._container}onRemove(){void 0!==this._geolocationWatchID&&(a.window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,dj=0,dk=!1}_isOutOfMapMaxBounds(c){const a=this._map.getMaxBounds(),b=c.coords;return a&&(b.longitudea.getEast()||b.latitudea.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(b){if(this._map){if(this._isOutOfMapMaxBounds(b))return this._setErrorState(),this.fire(new a.Event("outofmaxbounds",b)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=b,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(b),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(b),this.options.showUserLocation&&this._dotElement.classList.remove("mapboxgl-user-location-dot-stale"),this.fire(new a.Event("geolocate",b)),this._finish()}}_updateCamera(b){const c=new a.LngLat(b.coords.longitude,b.coords.latitude),d=b.coords.accuracy,e=this._map.getBearing(),f=a.extend({bearing:e},this.options.fitBoundsOptions);this._map.fitBounds(c.toBounds(d),f,{geolocateSource:!0})}_updateMarker(b){if(b){const c=new a.LngLat(b.coords.longitude,b.coords.latitude);this._accuracyCircleMarker.setLngLat(c).addTo(this._map),this._userLocationDotMarker.setLngLat(c).addTo(this._map),this._accuracy=b.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const a=this._map._containerHeight/2,c=this._map.unproject([0,a]),d=this._map.unproject([100,a]),e=c.distanceTo(d)/100,b=Math.ceil(2*this._accuracy/e);this._circleElement.style.width=`${b}px`,this._circleElement.style.height=`${b}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&"number"==typeof this._heading?(this._userLocationDotMarker.setRotation(this._heading),this._dotElement.classList.add("mapboxgl-user-location-show-heading")):(this._dotElement.classList.remove("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0))}_onError(b){if(this._map){if(this.options.trackUserLocation){if(1===b.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 c=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",c),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",c),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===b.code&&dk)return;this._setErrorState()}}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("mapboxgl-user-location-dot-stale"),this.fire(new a.Event("error",b)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(e){if(this._container.addEventListener("contextmenu",a=>a.preventDefault()),this._geolocateButton=b.create("button","mapboxgl-ctrl-geolocate",this._container),b.create("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden",!0),this._geolocateButton.type="button",!1===e){a.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");const c=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",c),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",c)}else{const d=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",d),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",d)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=b.create("div","mapboxgl-user-location"),this._dotElement.appendChild(b.create("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(b.create("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new z({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=b.create("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new z({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",b=>{b.geolocateSource||"ACTIVE_LOCK"!==this._watchState||b.originalEvent&&"resize"===b.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new a.Event("trackuserlocationend")))})}_onDeviceOrientation(a){this._userLocationDotMarker&&(a.webkitCompassHeading?this._heading=a.webkitCompassHeading:!0===a.absolute&&(this._heading=-1*a.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return a.warnOnce("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 a.Event("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":dj--,dk=!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 a.Event("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 a.Event("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 b;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),++dj>1?(b={maximumAge:6e5,timeout:0},dk=!0):(b=this.options.positionOptions,dk=!1),this._geolocationWatchID=a.window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,b),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else a.window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const b=()=>{a.window.addEventListener("ondeviceorientationabsolute"in a.window?"deviceorientationabsolute":"deviceorientation",this._onDeviceOrientationListener)};void 0!==a.window.DeviceMotionEvent&&"function"==typeof a.window.DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then(a=>{"granted"===a&&b()}).catch(console.error):b()}_clearWatch(){a.window.navigator.geolocation.clearWatch(this._geolocationWatchID),a.window.removeEventListener("deviceorientation",this._onDeviceOrientationListener),a.window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientationListener),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:y,ScaleControl:class{constructor(b){this.options=a.extend({},{maxWidth:100,unit:"metric"},b),a.bindAll(["_onMove","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_onMove(){dl(this._map,this._container,this.options)}onAdd(a){return this._map=a,this._container=b.create("div","mapboxgl-ctrl mapboxgl-ctrl-scale",a.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._onMove),this._map=void 0}setUnit(a){this.options.unit=a,dl(this._map,this._container,this.options)}},FullscreenControl:class{constructor(b){this._fullscreen=!1,b&&b.container&&(b.container instanceof a.window.HTMLElement?this._container=b.container:a.warnOnce("Full screen control 'container' must be a DOM element.")),a.bindAll(["_onClickFullscreen","_changeIcon",],this),"onfullscreenchange"in a.window.document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in a.window.document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(c){return this._map=c,this._container||(this._container=this._map.getContainer()),this._controlContainer=b.create("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",a.warnOnce("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,a.window.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!a.window.document.fullscreenEnabled&&!a.window.document.webkitFullscreenEnabled)}_setupUI(){const c=this._fullscreenButton=b.create("button","mapboxgl-ctrl-fullscreen",this._controlContainer);b.create("span","mapboxgl-ctrl-icon",c).setAttribute("aria-hidden",!0),c.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),a.window.document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const a=this._getTitle();this._fullscreenButton.setAttribute("aria-label",a),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",a)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(a.window.document.fullscreenElement||a.window.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()?a.window.document.exitFullscreen?a.window.document.exitFullscreen():a.window.document.webkitCancelFullScreen&&a.window.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class extends a.Evented{constructor(b){super(),this.options=a.extend(Object.create({closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"}),b),a.bindAll(["_update","_onClose","remove","_onMouseMove","_onMouseUp","_onDrag",],this),this._classList=new Set(b&&b.className?b.className.trim().split(/\s+/):[])}addTo(b){return this._map&&this.remove(),this._map=b,this.options.closeOnClick&&this._map.on("preclick",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._map._canvasContainer.classList.add("mapboxgl-track-pointer")):this._map.on("move",this._update),this.fire(new a.Event("open")),this}isOpen(){return!!this._map}remove(){return this._content&&this._content.remove(),this._container&&(this._container.remove(),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),delete this._map),this.fire(new a.Event("close")),this}getLngLat(){return this._lngLat}setLngLat(b){return this._lngLat=a.LngLat.convert(b),this._pos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._map._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._map._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(b){return this.setDOMContent(a.window.document.createTextNode(b))}setHTML(e){const b=a.window.document.createDocumentFragment(),c=a.window.document.createElement("body");let d;for(c.innerHTML=e;d=c.firstChild;)b.appendChild(d);return this.setDOMContent(b)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(a){return this.options.maxWidth=a,this._update(),this}setDOMContent(a){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=b.create("div","mapboxgl-popup-content",this._container);return this._content.appendChild(a),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(a){return this._classList.add(a),this._container&&this._updateClassList(),this}removeClassName(a){return this._classList.delete(a),this._container&&this._updateClassList(),this}setOffset(a){return this.options.offset=a,this._update(),this}toggleClassName(b){let a;return this._classList.delete(b)?a=!1:(this._classList.add(b),a=!0),this._container&&this._updateClassList(),a}_createCloseButton(){this.options.closeButton&&(this._closeButton=b.create("button","mapboxgl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.setAttribute("aria-label","Close popup"),this._closeButton.setAttribute("aria-hidden","true"),this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_onMouseUp(a){this._update(a.point)}_onMouseMove(a){this._update(a.point)}_onDrag(a){this._update(a.point)}_getAnchor(e){if(this.options.anchor)return this.options.anchor;const b=this._pos,c=this._container.offsetWidth,d=this._container.offsetHeight;let a;return a=b.y+e.bottom.ythis._map.transform.height-d?["bottom"]:[],b.xthis._map.transform.width-c/2&&a.push("right"),0===a.length?"bottom":a.join("-")}_updateClassList(){const a=[...this._classList];a.push("mapboxgl-popup"),this._anchor&&a.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&a.push("mapboxgl-popup-track-pointer"),this._container.className=a.join(" ")}_update(c){if(this._map&&(this._lngLat||this._trackPointer)&&this._content){if(this._container||(this._container=b.create("div","mapboxgl-popup",this._map.getContainer()),this._tip=b.create("div","mapboxgl-popup-tip",this._container),this._container.appendChild(this._content)),this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._map.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=db(this._lngLat,this._pos,this._map.transform)),!this._trackPointer||c){const e=this._pos=this._trackPointer&&c?c:this._map.project(this._lngLat),d=function(b){if(b||(b=new a.pointGeometry(0,0)),"number"==typeof b){const d=Math.round(Math.sqrt(.5*Math.pow(b,2)));return{center:new a.pointGeometry(0,0),top:new a.pointGeometry(0,b),"top-left":new a.pointGeometry(d,d),"top-right":new a.pointGeometry(-d,d),bottom:new a.pointGeometry(0,-b),"bottom-left":new a.pointGeometry(d,-d),"bottom-right":new a.pointGeometry(-d,-d),left:new a.pointGeometry(b,0),right:new a.pointGeometry(-b,0)}}if(b instanceof a.pointGeometry||Array.isArray(b)){const c=a.pointGeometry.convert(b);return{center:c,top:c,"top-left":c,"top-right":c,bottom:c,"bottom-left":c,"bottom-right":c,left:c,right:c}}return{center:a.pointGeometry.convert(b.center||[0,0,]),top:a.pointGeometry.convert(b.top||[0,0]),"top-left":a.pointGeometry.convert(b["top-left"]||[0,0]),"top-right":a.pointGeometry.convert(b["top-right"]||[0,0]),bottom:a.pointGeometry.convert(b.bottom||[0,0,]),"bottom-left":a.pointGeometry.convert(b["bottom-left"]||[0,0]),"bottom-right":a.pointGeometry.convert(b["bottom-right"]||[0,0]),left:a.pointGeometry.convert(b.left||[0,0]),right:a.pointGeometry.convert(b.right||[0,0,])}}(this.options.offset),f=this._anchor=this._getAnchor(d),g=e.add(d[f]).round();this._map._requestDomTask(()=>{this._container&&f&&(this._container.style.transform=`${dc[f]} translate(${g.x}px,${g.y}px)`)})}this._updateClassList()}}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const a=this._container.querySelector("a[href], [tabindex]:not([tabindex='-1']), [contenteditable]:not([contenteditable='false']), button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])");a&&a.focus()}_onClose(){this.remove()}_setOpacity(a){this._content&&(this._content.style.opacity=a),this._tip&&(this._tip.style.opacity=a)}},Marker:z,Style:c,LngLat:a.LngLat,LngLatBounds:a.LngLatBounds,Point:a.pointGeometry,MercatorCoordinate:a.MercatorCoordinate,FreeCameraOptions:x,Evented:a.Evented,config:a.config,prewarm:function(){ao().acquire(am)},clearPrewarmedResources:function(){const a=an;a&&(a.isPreloaded()&&1===a.numActive()?(a.release(am),an=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 a.config.ACCESS_TOKEN},set accessToken(t){a.config.ACCESS_TOKEN=t},get baseApiUrl(){return a.config.API_URL},set baseApiUrl(t){a.config.API_URL=t},get workerCount(){return e.workerCount},set workerCount(e){e.workerCount=e},get maxParallelImageRequests(){return a.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(t){a.config.MAX_PARALLEL_IMAGE_REQUESTS=t},clearStorage(b){a.clearTileCache(b)},workerUrl:"",workerClass:null,setNow:a.exported.setNow,restoreNow:a.exported.restoreNow};return A}),b})}},]) + with id '${b.firstUndrapedLayer}' or create a map using optimizeForTerrain: true option.`)}_onStyleDataEvent(a){a.coord&&"source"===a.dataType?this._clearRenderCacheForTile(a.sourceCacheId,a.coord):"style"===a.dataType&&(this._invalidateRenderCache=!0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const a in this._style._sourceCaches)this._style._sourceCaches[a].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach(a=>a.fb.destroy()),this.pool=[],this._depthFBO&&(this._depthFBO.destroy(),delete this._depthFBO,delete this._depthTexture)}_source(){return this.enabled?this.sourceCache:null}exaggeration(){return this._exaggeration}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const a=2*this.proxySourceCache.getSource().tileSize;return[a,a]}set useVertexMorphing(a){this._useVertexMorphing=a}updateTileBinding(h){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const i=this.proxySourceCache,d=this.painter.transform;this._initializing&&(this._initializing=0===d._centerAltitude&& -1===this.getAtPointOrZero(a.MercatorCoordinate.fromLngLat(d.center),-1),this._emptyDEMTextureDirty=!this._initializing);const c=this.proxyCoords=i.getIds().map(b=>{const a=i.getTileByID(b).tileID;return a.projMatrix=d.calculateProjMatrix(a.toUnwrapped()),a});(function(d,b){const c=b.transform.pointCoordinate(b.transform.getCameraPoint()),e=new a.pointGeometry(c.x,c.y);d.sort((b,c)=>{if(c.overscaledZ-b.overscaledZ)return c.overscaledZ-b.overscaledZ;const f=new a.pointGeometry(b.canonical.x+(1<{this.proxyToSource[a.key]={}}),this.terrainTileForTile={};const k=this._style._sourceCaches;for(const e in k){const b=k[e];if(!b.used||(b!==this.sourceCache&&this.resetTileLookupCache(b.id),this._setupProxiedCoordsForOrtho(b,h[e],j),b.usedForTerrain))continue;const m=h[e];b.getSource().reparseOverscaled&&this._assignTerrainTiles(m)}this.proxiedCoords[i.id]=c.map(a=>new bq(a,a.key,this.orthoMatrix)),this._assignTerrainTiles(c),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(j),this.renderingToTexture=!1,this._updateTimestamp=a.exported.now();const l={};for(const n of(this._visibleDemTiles=[],this.proxyCoords)){const f=this.terrainTileForTile[n.key];if(!f)continue;const g=f.tileID.key;g in l||(this._visibleDemTiles.push(f),l[g]=g)}}_assignTerrainTiles(a){this._initializing||a.forEach(a=>{if(this.terrainTileForTile[a.key])return;const b=this._findTileCoveringTileID(a,this.sourceCache);b&&(this.terrainTileForTile[a.key]=b)})}_prepareDEMTextures(){const b=this.painter.context,d=b.gl;for(const e in this.terrainTileForTile){const a=this.terrainTileForTile[e],c=a.dem;c&&(!a.demTexture||a.needsDEMTextureUpload)&&(b.activeTexture.set(d.TEXTURE1),be(this.painter,a,c))}}_prepareDemTileUniforms(f,a,d,g){if(!a||null==a.demTexture)return!1;const b=f.tileID.canonical,c=Math.pow(2,a.tileID.canonical.z-b.z),e=g||"";return d[`u_dem_tl${e}`]=[b.x*c%1,b.y*c%1,],d[`u_dem_scale${e}`]=c,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const b=this.painter.context,c=b.gl;if(!this._emptyDepthBufferTexture){const d={width:1,height:1,data:new Uint8Array([255,255,255,255,])};this._emptyDepthBufferTexture=new a.Texture(b,d,c.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let a=0;const b=this._visibleDemTiles.reduce((b,c)=>{if(!c.dem)return b;const d=c.dem.tree.minimums[0];return d>0&&a++,b+d},0);return a?b/a:0}_updateEmptyDEMTexture(){const c=this.painter.context,d=c.gl;c.activeTexture.set(d.TEXTURE2);const f=this._getLoadedAreaMinimum(),e={width:1,height:1,data:new Uint8Array(a.DEMData.pack(f,this.sourceCache.getSource().encoding))};this._emptyDEMTextureDirty=!1;let b=this._emptyDEMTexture;return b?b.update(e,{premultiply:!1}):b=this._emptyDEMTexture=new a.Texture(c,e,d.RGBA,{premultiply:!1}),b}setupElevationDraw(g,p,d){var n;const f=this.painter.context,b=f.gl,c=(n=this.sourceCache.getSource().encoding,{u_dem:2,u_dem_prev:4,u_dem_unpack:a.DEMData.getUnpackVector(n),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,u_tile_tl_up:[0,0,1],u_tile_tr_up:[0,0,1],u_tile_br_up:[0,0,1],u_tile_bl_up:[0,0,1],u_tile_up_scale:1});c.u_dem_size=this.sourceCache.getSource().tileSize,c.u_exaggeration=this.exaggeration();const j=this.painter.transform,h=j.projection.createTileTransform(j,j.worldSize),i=g.tileID.canonical;c.u_tile_tl_up=h.upVector(i,0,0),c.u_tile_tr_up=h.upVector(i,a.EXTENT,0),c.u_tile_br_up=h.upVector(i,a.EXTENT,a.EXTENT),c.u_tile_bl_up=h.upVector(i,0,a.EXTENT),c.u_tile_up_scale=h.upVectorScale(i);let e=null,k=null,o=1;if(d&&d.morphing&&this._useVertexMorphing){const l=d.morphing.srcDemTile,m=d.morphing.dstDemTile;o=d.morphing.phase,l&&m&&(this._prepareDemTileUniforms(g,l,c,"_prev")&&(k=l),this._prepareDemTileUniforms(g,m,c)&&(e=m))}if(k&&e?(f.activeTexture.set(b.TEXTURE2),e.demTexture.bind(b.NEAREST,b.CLAMP_TO_EDGE,b.NEAREST),f.activeTexture.set(b.TEXTURE4),k.demTexture.bind(b.NEAREST,b.CLAMP_TO_EDGE,b.NEAREST),c.u_dem_lerp=o):(e=this.terrainTileForTile[g.tileID.key],f.activeTexture.set(b.TEXTURE2),(this._prepareDemTileUniforms(g,e,c)?e.demTexture:this.emptyDEMTexture).bind(b.NEAREST,b.CLAMP_TO_EDGE)),f.activeTexture.set(b.TEXTURE3),d&&d.useDepthForOcclusion?(this._depthTexture.bind(b.NEAREST,b.CLAMP_TO_EDGE),c.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height,]):(this.emptyDepthBufferTexture.bind(b.NEAREST,b.CLAMP_TO_EDGE),c.u_depth_size_inv=[1,1]),d&&d.useMeterToDem&&e){const q=(1<{if(l===c)return;const a=[];d&&a.push(bk[g]),a.push(bk[c]),a.push("PROJECTION_GLOBE_VIEW"),k=b.useProgram("globeRaster",null,a),l=c},n=b.colorModeForRenderPass(),o=new a.DepthMode(f.LEQUAL,a.DepthMode.ReadWrite,b.depthRangeFor3D);bj.update(d);const c=b.transform,p=a.calculateGlobeMatrix(c,c.worldSize),q=a.calculateGlobeMercatorMatrix(c),r=[a.mercatorXfromLng(c.center.lng),a.mercatorYfromLat(c.center.lat),],s=b.globeSharedBuffers;(g?[!1,!0]:[!1]).forEach(u=>{l=-1;const x=u?f.LINES:f.TRIANGLES;for(const g of j){const v=i.getTile(g),y=Math.pow(2,g.canonical.z),[D,E]=a.globeBuffersForTileMesh(b,v,g,y),z=a.StencilMode.disabled,A=h.prevTerrainTileForTile[g.key],B=h.terrainTileForTile[g.key];bi(A,B)&&bj.newMorphing(g.key,A,B,d,250),e.activeTexture.set(f.TEXTURE0),v.texture.bind(f.LINEAR,f.CLAMP_TO_EDGE);const t=bj.getMorphValuesForProxy(g.key),F=t?1:0,C={};t&&a.extend$1(C,{morphing:{srcDemTile:t.from,dstDemTile:t.to,phase:a.easeCubicInOut(t.phase)}});const G=a.globeMatrixForTile(g.canonical,p),H=bh(c.projMatrix,G,q,a.globeToMercatorTransition(c.zoom),r);if(m(F,u),h.setupElevationDraw(v,k,C),b.prepareDrawProgram(e,k,g.toUnwrapped()),s){const[I,J]=u?s.getWirefameBuffer(b.context):[s.gridIndexBuffer,s.gridSegments,];k.draw(e,x,o,z,n,a.CullFaceMode.backCCW,H,"globe_raster",D,I,J)}if(!u){const K=[0===g.canonical.y?a.globePoleMatrixForTile(g.canonical,!1,c):null,g.canonical.y===y-1?a.globePoleMatrixForTile(g.canonical,!0,c):null,];for(const w of K){if(!w)continue;const L=bh(c.projMatrix,w,w,0,r);s&&k.draw(e,x,o,z,n,a.CullFaceMode.disabled,L,"globe_pole_raster",E,s.poleIndexBuffer,s.poleSegments)}}}})}(b,c,e,f,d);else{const g=b.context,h=g.gl;let k,l;const i=b.options.showTerrainWireframe?2:0,m=(a,d)=>{if(l===a)return;const c=[bk[a]];d&&c.push(bk[i]),k=b.useProgram("terrainRaster",null,c),l=a},n=b.colorModeForRenderPass(),o=new a.DepthMode(h.LEQUAL,a.DepthMode.ReadWrite,b.depthRangeFor3D);bj.update(d);const j=b.transform,p=6*Math.pow(1.5,22-j.zoom)*c.exaggeration();(i?[!1,!0]:[!1]).forEach(r=>{l=-1;const w=r?h.LINES:h.TRIANGLES,[x,y]=r?c.getWirefameBuffer():[c.gridIndexBuffer,c.gridSegments,];for(const i of f){const s=e.getTile(i),z=a.StencilMode.disabled,t=c.prevTerrainTileForTile[i.key],u=c.terrainTileForTile[i.key];bi(t,u)&&bj.newMorphing(i.key,t,u,d,250),g.activeTexture.set(h.TEXTURE0),s.texture.bind(h.LINEAR,h.CLAMP_TO_EDGE,h.LINEAR_MIPMAP_NEAREST);const q=bj.getMorphValuesForProxy(i.key),A=q?1:0;let v;q&&(v={morphing:{srcDemTile:q.from,dstDemTile:q.to,phase:a.easeCubicInOut(q.phase)}});const B=bg(i.projMatrix,bl(i.canonical,j.renderWorldCopies)?p/10:p);m(A,r),c.setupElevationDraw(s,k,v),b.prepareDrawProgram(g,k,i.toUnwrapped()),k.draw(g,w,o,z,n,a.CullFaceMode.backCCW,B,"terrain_raster",c.gridBuffer,x,y)}})}}(c,this,this.proxySourceCache,b,this._updateTimestamp),this.renderingToTexture=!0,b.splice(0,b.length))}renderBatch(p){if(0===this._drapedRenderBatches.length)return p+1;this.renderingToTexture=!0;const c=this.painter,e=this.painter.context,f=this.proxySourceCache,s=this.proxiedCoords[f.id],k=this._drapedRenderBatches.shift(),h=[],t=c.style.order;let i=0;for(const g of s){const l=f.getTileByID(g.proxyTileKey),m=f.proxyCachedFBO[g.key]?f.proxyCachedFBO[g.key][p]:void 0,b=void 0!==m?f.renderCache[m]:this.pool[i++],q=void 0!==m;if(l.texture=b.tex,q&&!b.dirty){h.push(l.tileID);continue}let r;e.bindFramebuffer.set(b.fb.framebuffer),this.renderedToTile=!1,b.dirty&&(e.clear({color:a.Color.transparent,stencil:0}),b.dirty=!1);for(let n=k.start;n<=k.end;++n){const j=c.style._layers[t[n]];if(j.isHidden(c.transform.zoom))continue;const d=c.style._getLayerSourceCache(j),o=d?this.proxyToSource[g.key][d.id]:[g];if(!o)continue;const u=o;e.viewport.set([0,0,b.fb.width,b.fb.height,]),r!==(d?d.id:null)&&(this._setupStencil(b,o,j,d),r=d?d.id:null),c.renderLayer(c,d,j,u)}this.renderedToTile?(b.dirty=!0,h.push(l.tileID)):q|| --i,5===i&&(i=0,this.renderToBackBuffer(h))}return this.renderToBackBuffer(h),this.renderingToTexture=!1,e.bindFramebuffer.set(null),e.viewport.set([0,0,c.width,c.height]),k.end+1}postRender(){}renderCacheEfficiency(a){const e=a.order.length;if(0===e)return{efficiency:100};let f,g=0,b=0,c=!1;for(let d=0;da.dem).forEach(b=>{a=Math.min(a,b.dem.tree.minimums[0])}),0===a?a:(a-30)*this._exaggeration}raycast(d,e,f){if(!this._visibleDemTiles)return null;const b=this._visibleDemTiles.filter(a=>a.dem).map(b=>{const c=b.tileID,a=Math.pow(2,c.overscaledZ),{x:g,y:h}=c.canonical,i=g/a,j=(g+1)/a,k=h/a,l=(h+1)/a;return{minx:i,miny:k,maxx:j,maxy:l,t:b.dem.tree.raycastRoot(i,k,j,l,d,e,f),tile:b}});for(const a of(b.sort((a,b)=>(null!==a.t?a.t:Number.MAX_VALUE)-(null!==b.t?b.t:Number.MAX_VALUE)),b)){if(null==a.t)break;const c=a.tile.dem.tree.raycast(a.minx,a.miny,a.maxx,a.maxy,d,e,f);if(null!=c)return c}return null}_createFBO(){const b=this.painter.context,c=b.gl,d=this.drapeBufferSize;b.activeTexture.set(c.TEXTURE0);const f=new a.Texture(b,{width:d[0],height:d[1],data:null},c.RGBA);f.bind(c.LINEAR,c.CLAMP_TO_EDGE);const e=b.createFramebuffer(d[0],d[1],!1);return e.colorAttachment.set(f.texture),e.depthAttachment=new Z(b,e.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=b.createRenderbuffer(b.gl.DEPTH_STENCIL,d[0],d[1]),this._stencilRef=0,e.depthAttachment.set(this._sharedDepthStencil),b.clear({stencil:0})):e.depthAttachment.set(this._sharedDepthStencil),b.extTextureFilterAnisotropic&&!b.extTextureFilterAnisotropicForceOff&&c.texParameterf(c.TEXTURE_2D,b.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,b.extTextureFilterAnisotropicMax),{fb:e,tex:f,dirty:!1}}_initFBOPool(){for(;this.pool.length{const a=this._style._layers[c],d=a.isHidden(this.painter.transform.zoom),b=a.getCrossfadeParameters(),e=!!b&&1!==b.t,f=a.hasTransition();return"custom"!==a.type&&!d&&(e||f)})}_clearRasterFadeFromRenderCache(){let e=!1;for(const h in this._style._sourceCaches)if(this._style._sourceCaches[h]._source instanceof r){e=!0;break}if(e)for(let c=0;ca.renderCachePool.length){const i=Object.values(a.proxyCachedFBO);a.proxyCachedFBO={};for(let e=0;e=0;g--){const b=f[g];if(a.getTileByID(b.key),void 0!==a.proxyCachedFBO[b.key]){const j=p[b.key],k=this.proxyToSource[b.key];let d=0;for(const l in k){const m=k[l],n=j[l];if(!n||n.length!==m.length||m.some((a,b)=>a!==n[b]||t[l]&&t[l].hasOwnProperty(a.key))){d=-1;break}++d}for(const r in a.proxyCachedFBO[b.key])a.renderCache[a.proxyCachedFBO[b.key][r]].dirty=d<0||d!==Object.values(j).length}}const o=[...this._drapedRenderBatches];for(const s of(o.sort((a,b)=>b.end-b.start-(a.end-a.start)),o))for(const h of f){if(a.proxyCachedFBO[h.key])continue;let c=a.renderCachePool.pop();void 0===c&&a.renderCache.length<50&&(c=a.renderCache.length,a.renderCache.push(this._createFBO())),void 0!==c&&(a.proxyCachedFBO[h.key]={},a.proxyCachedFBO[h.key][s.start]=c,a.renderCache[c].dirty=!0)}this._tilesDirty={}}_setupStencil(g,a,c,d){if(!d||!this._sourceTilesOverlap[d.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const e=this.painter.context,f=e.gl;if(a.length<=1)return void(this._overlapStencilType=!1);let b;if(c.isTileClipped())b=a.length,this._overlapStencilMode.test={func:f.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(a[0].overscaledZ>a[a.length-1].overscaledZ))return void(this._overlapStencilType=!1);b=1,this._overlapStencilMode.test={func:f.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+b>255&&(e.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=b,this._overlapStencilMode.ref=this._stencilRef,c.isTileClipped()&&this._renderTileClippingMasks(a,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return"Clip"===this._overlapStencilType||"Mask"===this._overlapStencilType}stencilModeForRTTOverlap(b){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[b.key]),this._overlapStencilMode):a.StencilMode.disabled}_renderTileClippingMasks(f,g){const b=this.painter,d=this.painter.context,c=d.gl;b._tileClippingMaskIDs={},d.setColorMode(a.ColorMode.disabled),d.setDepthMode(a.DepthMode.disabled);const h=b.useProgram("clippingMask");for(const e of f){const i=b._tileClippingMaskIDs[e.key]=--g;h.draw(d,c.TRIANGLES,a.DepthMode.disabled,new a.StencilMode({func:c.ALWAYS,mask:0},i,255,c.KEEP,c.KEEP,c.REPLACE),a.ColorMode.disabled,a.CullFaceMode.disabled,bm(e.projMatrix),"$clipping",b.tileExtentBuffer,b.quadTriangleIndexBuffer,b.tileExtentSegments)}}pointCoordinate(e){const d=this.painter.transform;if(e.x<0||e.x>d.width||e.y<0||e.y>d.height)return null;const b=[e.x,e.y,1,1];a.transformMat4$1(b,b,d.pixelMatrixInverse),a.scale$1(b,b,1/b[3]),b[0]/=d.worldSize,b[1]/=d.worldSize;const g=d._camera.position,i=a.mercatorZfromAltitude(1,d.center.lat),c=[g[0],g[1],g[2]/i,0],f=a.subtract([],b.slice(0,3),c);a.normalize(f,f);const h=this.raycast(c,f,this._exaggeration);return null!==h&&h?(a.scaleAndAdd(c,c,f,h),c[3]=c[2],c[2]*=i,c):null}drawDepth(){const e=this.painter,b=e.context,i=this.proxySourceCache,c=Math.ceil(e.width),d=Math.ceil(e.height);if(this._depthFBO&&(this._depthFBO.width!==c||this._depthFBO.height!==d)&&(this._depthFBO.destroy(),delete this._depthFBO,delete this._depthTexture),!this._depthFBO){const f=b.gl,g=b.createFramebuffer(c,d,!0);b.activeTexture.set(f.TEXTURE0);const h=new a.Texture(b,{width:c,height:d,data:null},f.RGBA);h.bind(f.NEAREST,f.CLAMP_TO_EDGE),g.colorAttachment.set(h.texture);const j=b.createRenderbuffer(b.gl.DEPTH_COMPONENT16,c,d);g.depthAttachment.set(j),this._depthFBO=g,this._depthTexture=h}b.bindFramebuffer.set(this._depthFBO.framebuffer),b.viewport.set([0,0,c,d]),function(b,c,h,i){if("globe"===b.transform.projection.name)return;const d=b.context,e=d.gl;d.clear({depth:1});const f=b.useProgram("terrainDepth"),j=new a.DepthMode(e.LESS,a.DepthMode.ReadWrite,b.depthRangeFor3D);for(const g of i){const k=h.getTile(g),l=bg(g.projMatrix,0);c.setupElevationDraw(k,f),f.draw(d,e.TRIANGLES,j,a.StencilMode.disabled,a.ColorMode.unblended,a.CullFaceMode.backCCW,l,"terrain_depth",c.gridBuffer,c.gridIndexBuffer,c.gridNoSkirtSegments)}}(e,this,i,this.proxyCoords)}_setupProxiedCoordsForOrtho(a,f,c){if(a.getSource() instanceof s)return this._setupProxiedCoordsForImageSource(a,f,c);this._findCoveringTileCache[a.id]=this._findCoveringTileCache[a.id]||{};const k=this.proxiedCoords[a.id]=[],l=this.proxyCoords;for(let g=0;g(a.min.x=Math.min(a.min.x,b.x-o.x),a.min.y=Math.min(a.min.y,b.y-o.y),a.max.x=Math.max(a.max.x,b.x-o.x),a.max.y=Math.max(a.max.y,b.y-o.y),a),{min:new a.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE),max:new a.pointGeometry(-Number.MAX_VALUE,-Number.MAX_VALUE)}),n=(b,c)=>{const d=b.wrap+b.canonical.x/(1<g+p.max.x||e+fh+p.max.y};for(let f=0;fa.key===c.tileID.key);if(j)return j}if(c.tileID.key!==b.key){const d=b.canonical.z-c.tileID.canonical.z;let f,g,h;e=a.create();const k=c.tileID.wrap-b.wrap<0?(g=(f=a.EXTENT>>d)*((c.tileID.canonical.x<=g){const h=c.canonical.z-g;d.getSource().reparseOverscaled?(e=Math.max(c.canonical.z+2,d.transform.tileZoom),f=new a.OverscaledTileID(e,c.wrap,g,c.canonical.x>>h,c.canonical.y>>h)):0!==h&&(e=g,f=new a.OverscaledTileID(e,c.wrap,g,c.canonical.x>>h,c.canonical.y>>h))}f.key!==c.key&&(m.push(f.key),b=d.getTile(f))}const n=a=>{m.forEach(b=>{l[b]=a}),m.length=0};for(e-=1;e>=o&&(!b||!b.hasData());e--){b&&n(b.tileID.key);const j=f.calculateScaledKey(e);if((b=d.getTileByID(j))&&b.hasData())break;const k=l[j];if(null===k)break;void 0===k?m.push(j):b=d.getTileByID(k)}return n(b?b.tileID.key:null),b&&b.hasData()?b:null}findDEMTileFor(a){return this.enabled?this._findTileCoveringTileID(a,this.sourceCache):null}prepareDrawTile(a){this.renderedToTile=!0}_clearRenderCacheForTile(b,c){let a=this._tilesDirty[b];a||(a=this._tilesDirty[b]={}),a[c.key]=!0}getWirefameBuffer(){if(!this.wireframeSegments){const b=function(g){let f,e,b;const c=new a.StructArrayLayout2ui4,d=131;for(e=1;e<129;e++){for(f=1;f<129;f++)b=e*d+f,c.emplaceBack(b,b+1),c.emplaceBack(b,b+d),c.emplaceBack(b+1,b+d),128===e&&c.emplaceBack(b+d,b+d+1);c.emplaceBack(b+1,b+1+d)}return c}();this.wireframeIndexBuffer=this.painter.context.createIndexBuffer(b),this.wireframeSegments=a.SegmentVector.simpleSegment(0,0,this.gridBuffer.length,b.length)}return[this.wireframeIndexBuffer,this.wireframeSegments,]}}function bs(b){const c=[];for(let a=0;am.indexOf(t)&&m.push(t);let n=e?e.defines():[];n=n.concat(r.map(a=>`#define ${a}`));const D=n.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",a9,a8.fragmentSource,v.fragmentSource,k.fragmentSource).join("\n"),E=n.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",a9,a8.vertexSource,v.vertexSource,u.vertexSource,k.vertexSource).join("\n"),o=d.createShader(d.FRAGMENT_SHADER);if(d.isContextLost())return void(this.failedToCreate=!0);d.shaderSource(o,D),d.compileShader(o),d.attachShader(this.program,o);const p=d.createShader(d.VERTEX_SHADER);if(d.isContextLost())return void(this.failedToCreate=!0);d.shaderSource(p,E),d.compileShader(p),d.attachShader(this.program,p),this.attributes={};const i={};this.numAttributes=l.length;for(let f=0;f>16,g>>16],u_pixel_coord_lower:[65535&f,65535&g]}}const bv=(h,f,i,j)=>{const b=f.style.light,c=b.properties.get("position"),d=[c.x,c.y,c.z],g=a.create$1();"viewport"===b.properties.get("anchor")&&(a.fromRotation(g,-f.transform.angle),a.transformMat3(d,d,g));const e=b.properties.get("color");return{u_matrix:h,u_lightpos:d,u_lightintensity:b.properties.get("intensity"),u_lightcolor:[e.r,e.g,e.b],u_vertical_gradient:+i,u_opacity:j}},bw=(d,b,e,f,g,h,c)=>a.extend(bv(d,b,e,f),bu(h,b,c),{u_height_factor:-Math.pow(2,g.overscaledZ)/c.tileSize/8}),bx=a=>({u_matrix:a}),by=(b,c,d,e)=>a.extend(bx(b),bu(d,c,e)),bz=(a,b)=>({u_matrix:a,u_world:b}),bA=(b,c,d,e,f)=>a.extend(by(b,c,d,e),{u_world:f}),bB=(d,g,e,c)=>{const b=d.transform;let f;return f="map"===c.paint.get("circle-pitch-alignment")?b.calculatePixelsToTileUnitsMatrix(e):new Float32Array([b.pixelsToGLUnits[0],0,0,b.pixelsToGLUnits[1],]),{u_camera_to_center_distance:b.cameraToCenterDistance,u_matrix:d.translatePosMatrix(g.projMatrix,e,c.paint.get("circle-translate"),c.paint.get("circle-translate-anchor")),u_device_pixel_ratio:a.exported.devicePixelRatio,u_extrude_scale:f}},bC=b=>{const a=[];return"map"===b.paint.get("circle-pitch-alignment")&&a.push("PITCH_WITH_MAP"),"map"===b.paint.get("circle-pitch-scale")&&a.push("SCALE_WITH_MAP"),a},bD=(d,b,e)=>{const c=a.EXTENT/e.tileSize;return{u_matrix:d,u_camera_to_center_distance:b.cameraToCenterDistance,u_extrude_scale:[b.pixelsToGLUnits[0]/c,b.pixelsToGLUnits[1]/c,]}},bE=(a,b,c=1)=>({u_matrix:a,u_color:b,u_overlay:0,u_overlay_scale:c}),bF=(a,b,c,d)=>({u_matrix:a,u_extrude_scale:V(b,1,c),u_intensity:d}),bG=(d,b,g,e,h,i)=>{const f=d.transform,j=f.calculatePixelsToTileUnitsMatrix(b),c={u_matrix:bJ(d,b,g,h),u_pixels_to_tile_units:j,u_device_pixel_ratio:a.exported.devicePixelRatio,u_units_to_pixels:[1/f.pixelsToGLUnits[0],1/f.pixelsToGLUnits[1],],u_dash_image:0,u_gradient_image:1,u_image_height:i,u_texsize:[0,0],u_scale:[0,0,0],u_mix:0,u_alpha_discard_threshold:0};if(bK(g)){const k=bI(b,d.transform);c.u_texsize=b.lineAtlasTexture.size,c.u_scale=[k,e.fromScale,e.toScale,],c.u_mix=e.t}return c},bH=(e,b,f,d,g)=>{const c=e.transform,h=bI(b,c);return{u_matrix:bJ(e,b,f,g),u_texsize:b.imageAtlasTexture.size,u_pixels_to_tile_units:c.calculatePixelsToTileUnitsMatrix(b),u_device_pixel_ratio:a.exported.devicePixelRatio,u_image:0,u_scale:[h,d.fromScale,d.toScale],u_fade:d.t,u_units_to_pixels:[1/c.pixelsToGLUnits[0],1/c.pixelsToGLUnits[1],],u_alpha_discard_threshold:0}};function bI(a,b){return 1/V(a,1,b.tileZoom)}function bJ(c,a,b,d){return c.translatePosMatrix(d||a.tileID.projMatrix,a,b.paint.get("line-translate"),b.paint.get("line-translate-anchor"))}function bK(b){const a=b.paint.get("line-dasharray").value;return a.value||"constant"!==a.kind}const bL=(e,f,g,d,a,h)=>{var b,c;return{u_matrix:e,u_tl_parent:f,u_scale_parent:g,u_fade_t:d.mix,u_opacity:d.opacity*a.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:a.paint.get("raster-brightness-min"),u_brightness_high:a.paint.get("raster-brightness-max"),u_saturation_factor:(c=a.paint.get("raster-saturation"))>0?1-1/(1.001-c):-c,u_contrast_factor:(b=a.paint.get("raster-contrast"))>0?1/(1-b):1+b,u_spin_weights:bM(a.paint.get("raster-hue-rotate")),u_perspective_transform:h}};function bM(a){a*=Math.PI/180;const c=Math.sin(a),b=Math.cos(a);return[(2*b+1)/3,(-Math.sqrt(3)*c-b+1)/3,(Math.sqrt(3)*c-b+1)/3,]}const bN=(a,b,e,f,d,g,h,i,j,k,l,m,n,o)=>{const c=d.transform;return{u_is_size_zoom_constant:+("constant"===a||"source"===a),u_is_size_feature_constant:+("constant"===a||"camera"===a),u_size_t:b?b.uSizeT:0,u_size:b?b.uSize:0,u_camera_to_center_distance:c.cameraToCenterDistance,u_pitch:c.pitch/360*2*Math.PI,u_rotate_symbol:+e,u_aspect_ratio:c.width/c.height,u_fade_change:d.options.fadeDuration?d.symbolFadeChange:1,u_matrix:g,u_label_plane_matrix:h,u_coord_matrix:i,u_is_text:+j,u_pitch_with_map:+f,u_texsize:k,u_tile_id:l,u_zoom_transition:m,u_inv_rot_matrix:n,u_merc_center:o,u_texture:0}},bO=(d,e,f,c,b,g,h,i,j,k,l,m,n,o,p)=>{const{cameraToCenterDistance:q,_pitch:r}=b.transform;return a.extend(bN(d,e,f,c,b,g,h,i,j,k,m,n,o,p),{u_gamma_scale:c?q*Math.cos(b.terrain?0:r):1,u_device_pixel_ratio:a.exported.devicePixelRatio,u_is_halo:+l})},bP=(b,c,d,e,f,g,h,i,j,k,l,m,n,o)=>a.extend(bO(b,c,d,e,f,g,h,i,!0,j,!0,l,m,n,o),{u_texsize_icon:k,u_texture_icon:1}),bQ=(a,b,c)=>({u_matrix:a,u_opacity:b,u_color:c}),bR=(b,c,d,e,f,g)=>a.extend(function(f,c,b,a){const d=b.imageManager.getPattern(f.from.toString()),e=b.imageManager.getPattern(f.to.toString()),{width:k,height:l}=b.imageManager.getPixelSize(),g=Math.pow(2,a.tileID.overscaledZ),h=a.tileSize*Math.pow(2,b.transform.tileZoom)/g,i=h*(a.tileID.canonical.x+a.tileID.wrap*g),j=h*a.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:d.tl,u_pattern_br_a:d.br,u_pattern_tl_b:e.tl,u_pattern_br_b:e.br,u_texsize:[k,l],u_mix:c.t,u_pattern_size_a:d.displaySize,u_pattern_size_b:e.displaySize,u_scale_a:c.fromScale,u_scale_b:c.toScale,u_tile_units_to_pixels:1/V(a,1,b.transform.tileZoom),u_pixel_coord_upper:[i>>16,j>>16,],u_pixel_coord_lower:[65535&i,65535&j,]}}(e,g,d,f),{u_matrix:b,u_opacity:c}),bS={fillExtrusion:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_lightpos:new a.Uniform3f(b,c.u_lightpos),u_lightintensity:new a.Uniform1f(b,c.u_lightintensity),u_lightcolor:new a.Uniform3f(b,c.u_lightcolor),u_vertical_gradient:new a.Uniform1f(b,c.u_vertical_gradient),u_opacity:new a.Uniform1f(b,c.u_opacity)}),fillExtrusionPattern:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_lightpos:new a.Uniform3f(b,c.u_lightpos),u_lightintensity:new a.Uniform1f(b,c.u_lightintensity),u_lightcolor:new a.Uniform3f(b,c.u_lightcolor),u_vertical_gradient:new a.Uniform1f(b,c.u_vertical_gradient),u_height_factor:new a.Uniform1f(b,c.u_height_factor),u_image:new a.Uniform1i(b,c.u_image),u_texsize:new a.Uniform2f(b,c.u_texsize),u_pixel_coord_upper:new a.Uniform2f(b,c.u_pixel_coord_upper),u_pixel_coord_lower:new a.Uniform2f(b,c.u_pixel_coord_lower),u_scale:new a.Uniform3f(b,c.u_scale),u_fade:new a.Uniform1f(b,c.u_fade),u_opacity:new a.Uniform1f(b,c.u_opacity)}),fill:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix)}),fillPattern:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_image:new a.Uniform1i(b,c.u_image),u_texsize:new a.Uniform2f(b,c.u_texsize),u_pixel_coord_upper:new a.Uniform2f(b,c.u_pixel_coord_upper),u_pixel_coord_lower:new a.Uniform2f(b,c.u_pixel_coord_lower),u_scale:new a.Uniform3f(b,c.u_scale),u_fade:new a.Uniform1f(b,c.u_fade)}),fillOutline:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_world:new a.Uniform2f(b,c.u_world)}),fillOutlinePattern:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_world:new a.Uniform2f(b,c.u_world),u_image:new a.Uniform1i(b,c.u_image),u_texsize:new a.Uniform2f(b,c.u_texsize),u_pixel_coord_upper:new a.Uniform2f(b,c.u_pixel_coord_upper),u_pixel_coord_lower:new a.Uniform2f(b,c.u_pixel_coord_lower),u_scale:new a.Uniform3f(b,c.u_scale),u_fade:new a.Uniform1f(b,c.u_fade)}),circle:(b,c)=>({u_camera_to_center_distance:new a.Uniform1f(b,c.u_camera_to_center_distance),u_extrude_scale:new a.UniformMatrix2f(b,c.u_extrude_scale),u_device_pixel_ratio:new a.Uniform1f(b,c.u_device_pixel_ratio),u_matrix:new a.UniformMatrix4f(b,c.u_matrix)}),collisionBox:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_camera_to_center_distance:new a.Uniform1f(b,c.u_camera_to_center_distance),u_extrude_scale:new a.Uniform2f(b,c.u_extrude_scale)}),collisionCircle:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_inv_matrix:new a.UniformMatrix4f(b,c.u_inv_matrix),u_camera_to_center_distance:new a.Uniform1f(b,c.u_camera_to_center_distance),u_viewport_size:new a.Uniform2f(b,c.u_viewport_size)}),debug:(b,c)=>({u_color:new a.UniformColor(b,c.u_color),u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_overlay:new a.Uniform1i(b,c.u_overlay),u_overlay_scale:new a.Uniform1f(b,c.u_overlay_scale)}),clippingMask:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix)}),heatmap:(b,c)=>({u_extrude_scale:new a.Uniform1f(b,c.u_extrude_scale),u_intensity:new a.Uniform1f(b,c.u_intensity),u_matrix:new a.UniformMatrix4f(b,c.u_matrix)}),heatmapTexture:(b,c)=>({u_image:new a.Uniform1i(b,c.u_image),u_color_ramp:new a.Uniform1i(b,c.u_color_ramp),u_opacity:new a.Uniform1f(b,c.u_opacity)}),hillshade:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_image:new a.Uniform1i(b,c.u_image),u_latrange:new a.Uniform2f(b,c.u_latrange),u_light:new a.Uniform2f(b,c.u_light),u_shadow:new a.UniformColor(b,c.u_shadow),u_highlight:new a.UniformColor(b,c.u_highlight),u_accent:new a.UniformColor(b,c.u_accent)}),hillshadePrepare:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_image:new a.Uniform1i(b,c.u_image),u_dimension:new a.Uniform2f(b,c.u_dimension),u_zoom:new a.Uniform1f(b,c.u_zoom),u_unpack:new a.Uniform4f(b,c.u_unpack)}),line:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_pixels_to_tile_units:new a.UniformMatrix2f(b,c.u_pixels_to_tile_units),u_device_pixel_ratio:new a.Uniform1f(b,c.u_device_pixel_ratio),u_units_to_pixels:new a.Uniform2f(b,c.u_units_to_pixels),u_dash_image:new a.Uniform1i(b,c.u_dash_image),u_gradient_image:new a.Uniform1i(b,c.u_gradient_image),u_image_height:new a.Uniform1f(b,c.u_image_height),u_texsize:new a.Uniform2f(b,c.u_texsize),u_scale:new a.Uniform3f(b,c.u_scale),u_mix:new a.Uniform1f(b,c.u_mix),u_alpha_discard_threshold:new a.Uniform1f(b,c.u_alpha_discard_threshold)}),linePattern:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_texsize:new a.Uniform2f(b,c.u_texsize),u_pixels_to_tile_units:new a.UniformMatrix2f(b,c.u_pixels_to_tile_units),u_device_pixel_ratio:new a.Uniform1f(b,c.u_device_pixel_ratio),u_image:new a.Uniform1i(b,c.u_image),u_units_to_pixels:new a.Uniform2f(b,c.u_units_to_pixels),u_scale:new a.Uniform3f(b,c.u_scale),u_fade:new a.Uniform1f(b,c.u_fade),u_alpha_discard_threshold:new a.Uniform1f(b,c.u_alpha_discard_threshold)}),raster:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_tl_parent:new a.Uniform2f(b,c.u_tl_parent),u_scale_parent:new a.Uniform1f(b,c.u_scale_parent),u_fade_t:new a.Uniform1f(b,c.u_fade_t),u_opacity:new a.Uniform1f(b,c.u_opacity),u_image0:new a.Uniform1i(b,c.u_image0),u_image1:new a.Uniform1i(b,c.u_image1),u_brightness_low:new a.Uniform1f(b,c.u_brightness_low),u_brightness_high:new a.Uniform1f(b,c.u_brightness_high),u_saturation_factor:new a.Uniform1f(b,c.u_saturation_factor),u_contrast_factor:new a.Uniform1f(b,c.u_contrast_factor),u_spin_weights:new a.Uniform3f(b,c.u_spin_weights),u_perspective_transform:new a.Uniform2f(b,c.u_perspective_transform)}),symbolIcon:(b,c)=>({u_is_size_zoom_constant:new a.Uniform1i(b,c.u_is_size_zoom_constant),u_is_size_feature_constant:new a.Uniform1i(b,c.u_is_size_feature_constant),u_size_t:new a.Uniform1f(b,c.u_size_t),u_size:new a.Uniform1f(b,c.u_size),u_camera_to_center_distance:new a.Uniform1f(b,c.u_camera_to_center_distance),u_pitch:new a.Uniform1f(b,c.u_pitch),u_rotate_symbol:new a.Uniform1i(b,c.u_rotate_symbol),u_aspect_ratio:new a.Uniform1f(b,c.u_aspect_ratio),u_fade_change:new a.Uniform1f(b,c.u_fade_change),u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_label_plane_matrix:new a.UniformMatrix4f(b,c.u_label_plane_matrix),u_coord_matrix:new a.UniformMatrix4f(b,c.u_coord_matrix),u_is_text:new a.Uniform1i(b,c.u_is_text),u_pitch_with_map:new a.Uniform1i(b,c.u_pitch_with_map),u_texsize:new a.Uniform2f(b,c.u_texsize),u_tile_id:new a.Uniform3f(b,c.u_tile_id),u_zoom_transition:new a.Uniform1f(b,c.u_zoom_transition),u_inv_rot_matrix:new a.UniformMatrix4f(b,c.u_inv_rot_matrix),u_merc_center:new a.Uniform2f(b,c.u_merc_center),u_texture:new a.Uniform1i(b,c.u_texture)}),symbolSDF:(b,c)=>({u_is_size_zoom_constant:new a.Uniform1i(b,c.u_is_size_zoom_constant),u_is_size_feature_constant:new a.Uniform1i(b,c.u_is_size_feature_constant),u_size_t:new a.Uniform1f(b,c.u_size_t),u_size:new a.Uniform1f(b,c.u_size),u_camera_to_center_distance:new a.Uniform1f(b,c.u_camera_to_center_distance),u_pitch:new a.Uniform1f(b,c.u_pitch),u_rotate_symbol:new a.Uniform1i(b,c.u_rotate_symbol),u_aspect_ratio:new a.Uniform1f(b,c.u_aspect_ratio),u_fade_change:new a.Uniform1f(b,c.u_fade_change),u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_label_plane_matrix:new a.UniformMatrix4f(b,c.u_label_plane_matrix),u_coord_matrix:new a.UniformMatrix4f(b,c.u_coord_matrix),u_is_text:new a.Uniform1i(b,c.u_is_text),u_pitch_with_map:new a.Uniform1i(b,c.u_pitch_with_map),u_texsize:new a.Uniform2f(b,c.u_texsize),u_texture:new a.Uniform1i(b,c.u_texture),u_gamma_scale:new a.Uniform1f(b,c.u_gamma_scale),u_device_pixel_ratio:new a.Uniform1f(b,c.u_device_pixel_ratio),u_tile_id:new a.Uniform3f(b,c.u_tile_id),u_zoom_transition:new a.Uniform1f(b,c.u_zoom_transition),u_inv_rot_matrix:new a.UniformMatrix4f(b,c.u_inv_rot_matrix),u_merc_center:new a.Uniform2f(b,c.u_merc_center),u_is_halo:new a.Uniform1i(b,c.u_is_halo)}),symbolTextAndIcon:(b,c)=>({u_is_size_zoom_constant:new a.Uniform1i(b,c.u_is_size_zoom_constant),u_is_size_feature_constant:new a.Uniform1i(b,c.u_is_size_feature_constant),u_size_t:new a.Uniform1f(b,c.u_size_t),u_size:new a.Uniform1f(b,c.u_size),u_camera_to_center_distance:new a.Uniform1f(b,c.u_camera_to_center_distance),u_pitch:new a.Uniform1f(b,c.u_pitch),u_rotate_symbol:new a.Uniform1i(b,c.u_rotate_symbol),u_aspect_ratio:new a.Uniform1f(b,c.u_aspect_ratio),u_fade_change:new a.Uniform1f(b,c.u_fade_change),u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_label_plane_matrix:new a.UniformMatrix4f(b,c.u_label_plane_matrix),u_coord_matrix:new a.UniformMatrix4f(b,c.u_coord_matrix),u_is_text:new a.Uniform1i(b,c.u_is_text),u_pitch_with_map:new a.Uniform1i(b,c.u_pitch_with_map),u_texsize:new a.Uniform2f(b,c.u_texsize),u_texsize_icon:new a.Uniform2f(b,c.u_texsize_icon),u_texture:new a.Uniform1i(b,c.u_texture),u_texture_icon:new a.Uniform1i(b,c.u_texture_icon),u_gamma_scale:new a.Uniform1f(b,c.u_gamma_scale),u_device_pixel_ratio:new a.Uniform1f(b,c.u_device_pixel_ratio),u_is_halo:new a.Uniform1i(b,c.u_is_halo)}),background:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_opacity:new a.Uniform1f(b,c.u_opacity),u_color:new a.UniformColor(b,c.u_color)}),backgroundPattern:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_opacity:new a.Uniform1f(b,c.u_opacity),u_image:new a.Uniform1i(b,c.u_image),u_pattern_tl_a:new a.Uniform2f(b,c.u_pattern_tl_a),u_pattern_br_a:new a.Uniform2f(b,c.u_pattern_br_a),u_pattern_tl_b:new a.Uniform2f(b,c.u_pattern_tl_b),u_pattern_br_b:new a.Uniform2f(b,c.u_pattern_br_b),u_texsize:new a.Uniform2f(b,c.u_texsize),u_mix:new a.Uniform1f(b,c.u_mix),u_pattern_size_a:new a.Uniform2f(b,c.u_pattern_size_a),u_pattern_size_b:new a.Uniform2f(b,c.u_pattern_size_b),u_scale_a:new a.Uniform1f(b,c.u_scale_a),u_scale_b:new a.Uniform1f(b,c.u_scale_b),u_pixel_coord_upper:new a.Uniform2f(b,c.u_pixel_coord_upper),u_pixel_coord_lower:new a.Uniform2f(b,c.u_pixel_coord_lower),u_tile_units_to_pixels:new a.Uniform1f(b,c.u_tile_units_to_pixels)}),terrainRaster:k,terrainDepth:k,skybox:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_sun_direction:new a.Uniform3f(b,c.u_sun_direction),u_cubemap:new a.Uniform1i(b,c.u_cubemap),u_opacity:new a.Uniform1f(b,c.u_opacity),u_temporal_offset:new a.Uniform1f(b,c.u_temporal_offset)}),skyboxGradient:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_color_ramp:new a.Uniform1i(b,c.u_color_ramp),u_center_direction:new a.Uniform3f(b,c.u_center_direction),u_radius:new a.Uniform1f(b,c.u_radius),u_opacity:new a.Uniform1f(b,c.u_opacity),u_temporal_offset:new a.Uniform1f(b,c.u_temporal_offset)}),skyboxCapture:(b,c)=>({u_matrix_3f:new a.UniformMatrix3f(b,c.u_matrix_3f),u_sun_direction:new a.Uniform3f(b,c.u_sun_direction),u_sun_intensity:new a.Uniform1f(b,c.u_sun_intensity),u_color_tint_r:new a.Uniform4f(b,c.u_color_tint_r),u_color_tint_m:new a.Uniform4f(b,c.u_color_tint_m),u_luminance:new a.Uniform1f(b,c.u_luminance)}),globeRaster:(b,c)=>({u_proj_matrix:new a.UniformMatrix4f(b,c.u_proj_matrix),u_globe_matrix:new a.UniformMatrix4f(b,c.u_globe_matrix),u_merc_matrix:new a.UniformMatrix4f(b,c.u_merc_matrix),u_zoom_transition:new a.Uniform1f(b,c.u_zoom_transition),u_merc_center:new a.Uniform2f(b,c.u_merc_center),u_image0:new a.Uniform1i(b,c.u_image0)}),globeAtmosphere:(b,c)=>({u_center:new a.Uniform2f(b,c.u_center),u_radius:new a.Uniform1f(b,c.u_radius),u_screen_size:new a.Uniform2f(b,c.u_screen_size),u_pixel_ratio:new a.Uniform1f(b,c.u_pixel_ratio),u_opacity:new a.Uniform1f(b,c.u_opacity),u_fadeout_range:new a.Uniform1f(b,c.u_fadeout_range),u_start_color:new a.Uniform3f(b,c.u_start_color),u_end_color:new a.Uniform3f(b,c.u_end_color)})};let bT;function bU(b,H,s,A,t,I,B){var u;const f=b.context,C=f.gl,D=b.useProgram("collisionBox"),j=[];let g=0,E=0;for(let v=0;v0){const l=a.create(),J=x;a.mul(l,d.placementInvProjMatrix,b.transform.glCoordMatrix),a.mul(l,l,d.placementViewportMatrix),j.push({circleArray:y,circleOffset:E,transform:J,invTransform:l}),g+=y.length/4,E=g}e&&(b.terrain&&b.terrain.setupElevationDraw(k,D),D.draw(f,C.LINES,a.DepthMode.disabled,a.StencilMode.disabled,b.colorModeForRenderPass(),a.CullFaceMode.disabled,bD(x,b.transform,k),s.id,e.layoutVertexBuffer,e.indexBuffer,e.segments,null,b.transform.zoom,null,e.collisionVertexBuffer,e.collisionVertexBufferExt))}if(!B||!j.length)return;const K=b.useProgram("collisionCircle"),c=new a.StructArrayLayout2f1f2i16;c.resize(4*g),c._trim();let m=0;for(const h of j)for(let z=0;z[0,0,0];e.clear();for(let j=0;j=0&&(r[b.associatedIconIndex]={shiftedAnchor:x,angle:y})}else aO(b.numGlyphs,e)}if(p){d.clear();const A=c.icon.placedSymbolArray;for(let f=0;f[0,0,0];aG(d,g.projMatrix,b,i,C,W,j,ad,am,g)}const D=b.translatePosMatrix(g.projMatrix,e,J,K),E=n||i&&Q||al?bV:C,F=b.translatePosMatrix(W,e,J,K,!0),an=o&&0!==h.paint.get(i?"text-halo-width":"icon-halo-width").constantOr(1);let Y;const G=N.createInversionMatrix(g.toUnwrapped());Y=o?d.iconsInText?bP(m.kind,y,u,j,b,D,E,F,p,T,z,x,G,v):bO(m.kind,y,u,j,b,D,E,F,i,p,!0,z,x,G,v):bN(m.kind,y,u,j,b,D,E,F,i,p,z,x,G,v);const Z={program:ag,buffers:l,uniformValues:Y,atlasTexture:A,atlasTextureIcon:U,atlasInterpolation:B,atlasInterpolationIcon:S,isSDF:o,hasHalo:an,tile:e,labelPlaneMatrixInv:aj};if(ae&&d.canOverlap){O=!0;const ao=l.segments.get();for(const $ of ao)r.push({segments:new a.SegmentVector([$]),sortKey:$.sortKey,state:Z})}else r.push({segments:l.segments,sortKey:0,state:Z})}for(const H of(O&&r.sort((a,b)=>a.sortKey-b.sortKey),r)){const c=H.state;if(b.terrain&&b.terrain.setupElevationDraw(c.tile,c.program,{useDepthForOcclusion:!w,labelPlaneMatrixInv:c.labelPlaneMatrixInv}),t.activeTexture.set(k.TEXTURE0),c.atlasTexture.bind(c.atlasInterpolation,k.CLAMP_TO_EDGE),c.atlasTextureIcon&&(t.activeTexture.set(k.TEXTURE1),c.atlasTextureIcon&&c.atlasTextureIcon.bind(c.atlasInterpolationIcon,k.CLAMP_TO_EDGE)),c.isSDF){const I=c.uniformValues;c.hasHalo&&(I.u_is_halo=1,b$(c.buffers,H.segments,h,b,c.program,P,L,M,I)),I.u_is_halo=0}b$(c.buffers,H.segments,h,b,c.program,P,L,M,c.uniformValues)}}function b$(b,f,c,d,g,h,i,j,k){const e=d.context;g.draw(e,e.gl.TRIANGLES,h,i,j,a.CullFaceMode.disabled,k,c.id,b.layoutVertexBuffer,b.indexBuffer,f,c.paint,d.transform.zoom,b.programConfigurations.get(c.id),b.dynamicLayoutVertexBuffer,b.opacityVertexBuffer)}function b_(b,y,c,z,A,B,s){const e=b.context.gl,l=c.paint.get("fill-pattern"),g=l&&l.constantOr(1),m=c.getCrossfadeParameters();let n,i,o,p,q;for(const h of(s?(i=g&&!c.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",n=e.LINES):(i=g?"fillPattern":"fill",n=e.TRIANGLES),z)){const d=y.getTile(h);if(g&&!d.patternsLoaded())continue;const f=d.getBucket(c);if(!f)continue;b.prepareDrawTile(h);const j=f.programConfigurations.get(c.id),t=b.useProgram(i,j);g&&(b.context.activeTexture.set(e.TEXTURE0),d.imageAtlasTexture.bind(e.LINEAR,e.CLAMP_TO_EDGE),j.updatePaintBuffers(m));const r=l.constantOr(null);if(r&&d.imageAtlas){const u=d.imageAtlas,v=u.patternPositions[r.to.toString()],w=u.patternPositions[r.from.toString()];v&&w&&j.setConstantPatternPositions(v,w)}const k=b.translatePosMatrix(h.projMatrix,d,c.paint.get("fill-translate"),c.paint.get("fill-translate-anchor"));if(s){p=f.indexBuffer2,q=f.segments2;const x=b.terrain&&b.terrain.renderingToTexture?b.terrain.drapeBufferSize:[e.drawingBufferWidth,e.drawingBufferHeight,];o="fillOutlinePattern"===i&&g?bA(k,b,m,d,x):bz(k,x)}else p=f.indexBuffer,q=f.segments,o=g?by(k,b,m,d):bx(k);b.prepareDrawProgram(b.context,t,h.toUnwrapped()),t.draw(b.context,n,A,b.stencilModeForClipping(h),B,a.CullFaceMode.disabled,o,c.id,f.layoutVertexBuffer,p,q,c.paint,b.transform.zoom,j)}}function b0(b,m,c,x,y,z,A){const f=b.context,h=f.gl,n=c.paint.get("fill-extrusion-pattern"),k=n.constantOr(1),o=c.getCrossfadeParameters(),p=c.paint.get("fill-extrusion-opacity");for(const g of x){const e=m.getTile(g),d=e.getBucket(c);if(!d)continue;const i=d.programConfigurations.get(c.id),j=b.useProgram(k?"fillExtrusionPattern":"fillExtrusion",i);if(b.terrain){const q=b.terrain;if(!d.enableTerrain)continue;if(q.setupElevationDraw(e,j,{useMeterToDem:!0}),b1(f,m,g,d,c,q),!d.centroidVertexBuffer){const r=j.attributes.a_centroid_pos;void 0!==r&&h.vertexAttrib2f(r,0,0)}}k&&(b.context.activeTexture.set(h.TEXTURE0),e.imageAtlasTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),i.updatePaintBuffers(o));const l=n.constantOr(null);if(l&&e.imageAtlas){const s=e.imageAtlas,t=s.patternPositions[l.to.toString()],u=s.patternPositions[l.from.toString()];t&&u&&i.setConstantPatternPositions(t,u)}const v=b.translatePosMatrix(g.projMatrix,e,c.paint.get("fill-extrusion-translate"),c.paint.get("fill-extrusion-translate-anchor")),w=c.paint.get("fill-extrusion-vertical-gradient"),B=k?bw(v,b,w,p,g,o,e):bv(v,b,w,p);b.prepareDrawProgram(f,j,g.toUnwrapped()),j.draw(f,f.gl.TRIANGLES,y,z,A,a.CullFaceMode.backCCW,B,c.id,d.layoutVertexBuffer,d.indexBuffer,d.segments,c.paint,b.transform.zoom,i,b.terrain?d.centroidVertexBuffer:null)}}function b1(w,D,p,c,E,q){const x=[b=>{let c=b.canonical.x-1,d=b.wrap;return c<0&&(c=(1<{let c=b.canonical.x+1,d=b.wrap;return c===1<new a.OverscaledTileID(b.overscaledZ,b.wrap,b.canonical.z,b.canonical.x,(0===b.canonical.y?1<new a.OverscaledTileID(b.overscaledZ,b.wrap,b.canonical.z,b.canonical.x,b.canonical.y===(1<{const b=D.getSource().maxzoom,c=b=>{const a=D.getTileByID(b);if(a&&a.hasData())return a.getBucket(E)};let d,e,f;return(a.overscaledZ===a.canonical.z||a.overscaledZ>=b)&&(d=c(a.key)),a.overscaledZ>=b&&(e=c(a.calculateScaledKey(a.overscaledZ+1))),a.overscaledZ>b&&(f=c(a.calculateScaledKey(a.overscaledZ-1))),d||e||f},F=[0,0,0],G=(b,c)=>(F[0]=Math.min(b.min.y,c.min.y),F[1]=Math.max(b.max.y,c.max.y),F[2]=a.EXTENT-c.min.x>b.max.x?c.min.x-a.EXTENT:b.max.x,F),H=(b,c)=>(F[0]=Math.min(b.min.x,c.min.x),F[1]=Math.max(b.max.x,c.max.x),F[2]=a.EXTENT-c.min.y>b.max.y?c.min.y-a.EXTENT:b.max.y,F),z=[(a,b)=>G(a,b),(a,b)=>G(b,a),(a,b)=>H(a,b),(a,b)=>H(b,a),],j=new a.pointGeometry(0,0);let r,s,A;const B=(e,f,b,c,d)=>{const g=[[c?b:e,c?e:b,0],[c?b:f,c?f:b,0],],i=d<0?a.EXTENT+d:d,h=[c?i:(e+f)/2,c?(e+f)/2:i,0,];return 0===b&&d<0||0!==b&&d>0?q.getForTilePoints(A,[h],!0,s):g.push(h),q.getForTilePoints(p,g,!0,r),Math.max(g[0][2],g[1][2],h[2])/q.exaggeration()};for(let d=0;d<4;d++){const k=c.borders[d];if(0===k.length&&(c.borderDone[d]=!0),c.borderDone[d])continue;const t=A=x[d](p),b=y(t);if(!b||!b.enableTerrain|| !(s=q.findDEMTileFor(t))||!s.dem)continue;if(!r){const l=q.findDEMTileFor(p);if(!l||!l.dem)return;r=l}const f=(d<2?1:5)-d,h=b.borders[f];let g=0;for(let m=0;mu[0]+3);)b.borderDone[f]||b.encodeCentroid(void 0,e,!1),g++;if(e&&gu[1]-3)&&(n++,++g!==h.length);)e=b.featuresOnBorder[h[g]];if(e=b.featuresOnBorder[h[v]],i.intersectsCount()>1||e.intersectsCount()>1||1!==n){1!==n&&(g=v),c.encodeCentroid(void 0,i,!1),b.borderDone[f]||b.encodeCentroid(void 0,e,!1);continue}const o=z[d](i,e),C=d%2?a.EXTENT-1:0;j.x=B(o[0],Math.min(a.EXTENT-1,o[1]),C,d<2,o[2]),j.y=0,c.encodeCentroid(j,i,!1),b.borderDone[f]||b.encodeCentroid(j,e,!1)}else c.encodeCentroid(void 0,i,!1)}c.borderDone[d]=c.needsCentroidUpdate=!0,b.borderDone[f]||(b.borderDone[f]=b.needsCentroidUpdate=!0)}(c.needsCentroidUpdate|| !c.centroidVertexBuffer&&0!==c.centroidVertexArray.length)&&c.uploadCentroid(w)}const b2=new a.Color(1,0,0,1),b3=new a.Color(0,1,0,1),b4=new a.Color(0,0,1,1),b5=new a.Color(1,0,1,1),b6=new a.Color(0,1,1,1);function b7(a,c,b,d){b9(a,0,c+b/2,a.transform.width,b,d)}function b8(a,c,b,d){b9(a,c-b/2,0,b,a.transform.height,d)}function b9(d,e,f,g,h,i){const c=d.context,b=c.gl;b.enable(b.SCISSOR_TEST),b.scissor(e*a.exported.devicePixelRatio,f*a.exported.devicePixelRatio,g*a.exported.devicePixelRatio,h*a.exported.devicePixelRatio),c.clear({color:i}),b.disable(b.SCISSOR_TEST)}function ca(b,h,c){const f=b.context,e=f.gl,i=c.projMatrix,g=b.useProgram("debug"),d=h.getTileByID(c.key);b.terrain&&b.terrain.setupElevationDraw(d,g);const j=a.DepthMode.disabled,k=a.StencilMode.disabled,o=b.colorModeForRenderPass(),l="$debug";f.activeTexture.set(e.TEXTURE0),b.emptyTexture.bind(e.LINEAR,e.CLAMP_TO_EDGE),d._makeDebugTileBoundsBuffers(b.context,b.transform.projection);const p=d._tileDebugBuffer||b.debugBuffer,q=d._tileDebugIndexBuffer||b.debugIndexBuffer,r=d._tileDebugSegments||b.debugSegments;g.draw(f,e.LINE_STRIP,j,k,o,a.CullFaceMode.disabled,bE(i,a.Color.red),l,p,q,r);const m=d.latestRawTileData,s=Math.floor((m&&m.byteLength||0)/1024),t=h.getTile(c).tileSize,u=512/Math.min(t,512)*(c.overscaledZ/b.transform.zoom)*.5;let n=c.canonical.toString();c.overscaledZ!==c.canonical.z&&(n+=` => ${c.overscaledZ}`),function(b,d){b.initDebugOverlayCanvas();const c=b.debugOverlayCanvas,e=b.context.gl,a=b.debugOverlayCanvas.getContext("2d");a.clearRect(0,0,c.width,c.height),a.shadowColor="white",a.shadowBlur=2,a.lineWidth=1.5,a.strokeStyle="white",a.textBaseline="top",a.font="bold 36px Open Sans, sans-serif",a.fillText(d,5,5),a.strokeText(d,5,5),b.debugOverlayTexture.update(c),b.debugOverlayTexture.bind(e.LINEAR,e.CLAMP_TO_EDGE)}(b,`${n} ${s}kb`),g.draw(f,e.TRIANGLES,j,k,a.ColorMode.alphaBlended,a.CullFaceMode.disabled,bE(i,a.Color.transparent,u),l,b.debugBuffer,b.quadTriangleIndexBuffer,b.debugSegments)}const w=a.createLayout([{name:"a_pos_3f",components:3,type:"Float32"},]),{members:cb}=w;function cc(a,b,c,d){a.emplaceBack(b,c,d)}class cd{constructor(b){this.vertexArray=new a.StructArrayLayout3f12,this.indices=new a.StructArrayLayout3ui6,cc(this.vertexArray,-1,-1,1),cc(this.vertexArray,1,-1,1),cc(this.vertexArray,-1,1,1),cc(this.vertexArray,1,1,1),cc(this.vertexArray,-1,-1,-1),cc(this.vertexArray,1,-1,-1),cc(this.vertexArray,-1,1,-1),cc(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=b.createVertexBuffer(this.vertexArray,cb),this.indexBuffer=b.createIndexBuffer(this.indices),this.segment=a.SegmentVector.simpleSegment(0,0,36,12)}}function ce(f,b,j,k,l,m){var g,h,i,c,d;const e=f.gl,n=b.paint.get("sky-atmosphere-color"),o=b.paint.get("sky-atmosphere-halo-color"),p=b.paint.get("sky-atmosphere-sun-intensity"),q=(g=a.fromMat4([],k),h=l,i=p,c=n,d=o,{u_matrix_3f:g,u_sun_direction:h,u_sun_intensity:i,u_color_tint_r:[c.r,c.g,c.b,c.a],u_color_tint_m:[d.r,d.g,d.b,d.a],u_luminance:5e-5});e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+m,b.skyboxTexture,0),j.draw(f,e.TRIANGLES,a.DepthMode.disabled,a.StencilMode.disabled,a.ColorMode.unblended,a.CullFaceMode.frontCW,q,"skyboxCapture",b.skyboxGeometry.vertexBuffer,b.skyboxGeometry.indexBuffer,b.skyboxGeometry.segment)}const cf={symbol:function(c,d,b,e,h){if("translucent"!==c.renderPass)return;const f=a.StencilMode.disabled,g=c.colorModeForRenderPass();b.layout.get("text-variable-anchor")&&function(k,e,g,l,m,n,o){const b=e.transform,h="map"===m,i="map"===n,p=b.projection.createTileTransform(b,b.worldSize);for(const f of k){const d=l.getTile(f),c=d.getBucket(g);if(!c||c.projection!==b.projection.name||!c.text||!c.text.segments.get().length)continue;const j=a.evaluateSizeForZoom(c.textSizeData,b.zoom),q=e.transform.calculatePixelsToTileUnitsMatrix(d),r=aB(f.projMatrix,d.tileID.canonical,i,h,e.transform,q),s="none"!==g.layout.get("icon-text-fit")&&c.hasIconData();if(j){const t=Math.pow(2,b.zoom-d.tileID.overscaledZ);bX(c,h,i,o,a.symbolSize,b,r,f,t,j,s,p)}}}(e,c,b,d,b.layout.get("text-rotation-alignment"),b.layout.get("text-pitch-alignment"),h),0!==b.paint.get("icon-opacity").constantOr(1)&&bZ(c,d,b,e,!1,b.paint.get("icon-translate"),b.paint.get("icon-translate-anchor"),b.layout.get("icon-rotation-alignment"),b.layout.get("icon-pitch-alignment"),b.layout.get("icon-keep-upright"),f,g),0!==b.paint.get("text-opacity").constantOr(1)&&bZ(c,d,b,e,!0,b.paint.get("text-translate"),b.paint.get("text-translate-anchor"),b.layout.get("text-rotation-alignment"),b.layout.get("text-pitch-alignment"),b.layout.get("text-keep-upright"),f,g),d.map.showCollisionBoxes&&(bU(c,d,b,e,b.paint.get("text-translate"),b.paint.get("text-translate-anchor"),!0),bU(c,d,b,e,b.paint.get("icon-translate"),b.paint.get("icon-translate-anchor"),!1))},circle:function(b,r,c,j){if("translucent"!==b.renderPass)return;const s=c.paint.get("circle-opacity"),t=c.paint.get("circle-stroke-width"),u=c.paint.get("circle-stroke-opacity"),k=void 0!==c.layout.get("circle-sort-key").constantOr(1);if(0===s.constantOr(1)&&(0===t.constantOr(1)||0===u.constantOr(1)))return;const f=b.context,v=f.gl,w=b.depthModeForSublayer(0,a.DepthMode.ReadOnly),x=a.StencilMode.disabled,y=b.colorModeForRenderPass(),e=[];for(let g=0;ga.sortKey-b.sortKey);const B={useDepthForOcclusion:"globe"!==b.transform.projection.name};for(const p of e){const{programConfiguration:C,program:i,layoutVertexBuffer:D,indexBuffer:E,uniformValues:F,tile:q}=p.state,G=p.segments;b.terrain&&b.terrain.setupElevationDraw(q,i,B),b.prepareDrawProgram(f,i,q.tileID.toUnwrapped()),i.draw(f,v.TRIANGLES,w,x,y,a.CullFaceMode.disabled,F,c.id,D,E,G,c.paint,b.transform.zoom,C)}},heatmap:function(b,k,c,l){if(0!==c.paint.get("heatmap-opacity")){if("offscreen"===b.renderPass){const d=b.context,g=d.gl,n=a.StencilMode.disabled,o=new a.ColorMode([g.ONE,g.ONE],a.Color.transparent,[!0,!0,!0,!0]);(function(b,c,e){const a=b.gl;b.activeTexture.set(a.TEXTURE1),b.viewport.set([0,0,c.width/4,c.height/4,]);let d=e.heatmapFbo;if(d)a.bindTexture(a.TEXTURE_2D,d.colorAttachment.get()),b.bindFramebuffer.set(d.framebuffer);else{const f=a.createTexture();a.bindTexture(a.TEXTURE_2D,f),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR),d=e.heatmapFbo=b.createFramebuffer(c.width/4,c.height/4,!1),function(b,c,d,e){const a=b.gl;a.texImage2D(a.TEXTURE_2D,0,a.RGBA,c.width/4,c.height/4,0,a.RGBA,b.extRenderToTextureHalfFloat?b.extTextureHalfFloat.HALF_FLOAT_OES:a.UNSIGNED_BYTE,null),e.colorAttachment.set(d)}(b,c,f,d)}})(d,b,c),d.clear({color:a.Color.transparent});for(let h=0;h{const b=[];bK(a)&&b.push("RENDER_LINE_DASH"),a.paint.get("line-gradient")&&b.push("RENDER_LINE_GRADIENT");const c=a.paint.get("line-pattern").constantOr(1),d=1!==a.paint.get("line-opacity").constantOr(1);return!c&&d&&b.push("RENDER_LINE_ALPHA_DISCARD"),b})(c);let m=v.includes("RENDER_LINE_ALPHA_DISCARD");for(const h of(b.terrain&&b.terrain.clipOrMaskOverlapStencilType()&&(m=!1),H)){const f=s.getTile(h);if(j&&!f.patternsLoaded())continue;const i=f.getBucket(c);if(!i)continue;b.prepareDrawTile(h);const k=i.programConfigurations.get(c.id),O=b.useProgram(N,k,v),n=u.constantOr(null);if(n&&f.imageAtlas){const w=f.imageAtlas,x=w.patternPositions[n.to.toString()],y=w.patternPositions[n.from.toString()];x&&y&&k.setConstantPatternPositions(x,y)}const o=t.constantOr(null),p=L.constantOr(null);if(!j&&o&&p&&f.lineAtlas){const z=f.lineAtlas,A=z.getDash(o.to,p),B=z.getDash(o.from,p);A&&B&&k.setConstantPatternPositions(A,B)}const C=b.terrain?h.projMatrix:null,D=j?bH(b,f,c,l,C):bG(b,f,c,l,C,i.lineClipsArray.length);if(M){const e=i.gradients[c.id];let E=e.texture;if(c.gradientVersion!==e.version){let F=256;if(c.stepInterpolant){const P=s.getSource().maxzoom,Q=h.canonical.z===P?Math.ceil(1<{O.draw(g,d.TRIANGLES,R,e,S,a.CullFaceMode.disabled,D,c.id,i.layoutVertexBuffer,i.indexBuffer,i.segments,c.paint,b.transform.zoom,k,i.layoutVertexBuffer2)};if(m){const r=b.stencilModeForClipping(h).ref;0===r&&b.terrain&&g.clear({stencil:0});const G={func:d.EQUAL,mask:255};D.u_alpha_discard_threshold=.8,q(new a.StencilMode(G,r,255,d.KEEP,d.KEEP,d.INVERT)),D.u_alpha_discard_threshold=0,q(new a.StencilMode(G,r,255,d.KEEP,d.KEEP,d.KEEP))}else q(b.stencilModeForClipping(h))}m&&(b.resetStencilClippingMasks(),b.terrain&&g.clear({stencil:0}))},fill:function(b,d,c,e){const h=c.paint.get("fill-color"),f=c.paint.get("fill-opacity");if(0===f.constantOr(1))return;const g=b.colorModeForRenderPass(),i=c.paint.get("fill-pattern"),j=b.opaquePassEnabledForLayer()&&!i.constantOr(1)&&1===h.constantOr(a.Color.transparent).a&&1===f.constantOr(0)?"opaque":"translucent";if(b.renderPass===j){const k=b.depthModeForSublayer(1,"opaque"===b.renderPass?a.DepthMode.ReadWrite:a.DepthMode.ReadOnly);b_(b,d,c,e,k,g,!1)}if("translucent"===b.renderPass&&c.paint.get("fill-antialias")){const l=b.depthModeForSublayer(c.getPaintProperty("fill-outline-color")?2:0,a.DepthMode.ReadOnly);b_(b,d,c,e,l,g,!0)}},"fill-extrusion":function(b,d,c,e){const g=c.paint.get("fill-extrusion-opacity");if(0!==g&&"translucent"===b.renderPass){const f=new a.DepthMode(b.context.gl.LEQUAL,a.DepthMode.ReadWrite,b.depthRangeFor3D);if(1!==g||c.paint.get("fill-extrusion-pattern").constantOr(1))b0(b,d,c,e,f,a.StencilMode.disabled,a.ColorMode.disabled),b0(b,d,c,e,f,b.stencilModeFor3D(),b.colorModeForRenderPass()),b.resetStencilClippingMasks();else{const h=b.colorModeForRenderPass();b0(b,d,c,e,f,a.StencilMode.disabled,h)}}},hillshade:function(b,j,e,f){if("offscreen"!==b.renderPass&&"translucent"!==b.renderPass)return;const k=b.context,g=b.depthModeForSublayer(0,a.DepthMode.ReadOnly),h=b.colorModeForRenderPass(),i=b.terrain&&b.terrain.renderingToTexture,[l,m]="translucent"!==b.renderPass||i?[{},f]:b.stencilConfigForOverlap(f);for(const c of m){const d=j.getTile(c);if(d.needsHillshadePrepare&&"offscreen"===b.renderPass)bf(b,d,e,g,a.StencilMode.disabled,h);else if("translucent"===b.renderPass){const n=i&&b.terrain?b.terrain.stencilModeForRTTOverlap(c):l[c.overscaledZ];bd(b,c,d,e,g,n,h)}}k.viewport.set([0,0,b.width,b.height]),b.resetStencilClippingMasks()},raster:function(b,j,f,m,H,x){if("translucent"!==b.renderPass||0===f.paint.get("raster-opacity")||!m.length)return;const g=b.context,c=g.gl,h=j.getSource(),n=b.useProgram("raster"),q=b.colorModeForRenderPass(),i=b.terrain&&b.terrain.renderingToTexture,[y,o]=h instanceof s||i?[{},m]:b.stencilConfigForOverlap(m),z=o[o.length-1].overscaledZ,A=!b.options.moving;for(const e of o){const r=i?a.DepthMode.disabled:b.depthModeForSublayer(e.overscaledZ-z,1===f.paint.get("raster-opacity")?a.DepthMode.ReadWrite:a.DepthMode.ReadOnly,c.LESS),t=e.toUnwrapped(),d=j.getTile(e);if(i&&(!d||!d.hasData()))continue;const B=i?e.projMatrix:b.transform.calculateProjMatrix(t,A),C=b.terrain&&i?b.terrain.stencilModeForRTTOverlap(e):y[e.overscaledZ],u=x?0:f.paint.get("raster-fade-duration");d.registerFadeDuration(u);const k=j.findLoadedParent(e,0),D=bn(d,k,j,b.transform,u);let l,v;b.terrain&&b.terrain.prepareDrawTile(e);const p="nearest"===f.paint.get("raster-resampling")?c.NEAREST:c.LINEAR;g.activeTexture.set(c.TEXTURE0),d.texture.bind(p,c.CLAMP_TO_EDGE),g.activeTexture.set(c.TEXTURE1),k?(k.texture.bind(p,c.CLAMP_TO_EDGE),l=Math.pow(2,k.tileID.overscaledZ-d.tileID.overscaledZ),v=[d.tileID.canonical.x*l%1,d.tileID.canonical.y*l%1,]):d.texture.bind(p,c.CLAMP_TO_EDGE);const w=bL(B,v||[0,0],l||1,D,f,h instanceof s?h.perspectiveTransform:[0,0]);if(b.prepareDrawProgram(g,n,t),h instanceof s)n.draw(g,c.TRIANGLES,r,a.StencilMode.disabled,q,a.CullFaceMode.disabled,w,f.id,h.boundsBuffer,b.quadTriangleIndexBuffer,h.boundsSegments);else{const{tileBoundsBuffer:E,tileBoundsIndexBuffer:F,tileBoundsSegments:G}=b.getTileBoundsBuffers(d);n.draw(g,c.TRIANGLES,r,C,q,a.CullFaceMode.disabled,w,f.id,E,F,G)}}b.resetStencilClippingMasks()},background:function(b,j,e,k){const l=e.paint.get("background-color"),f=e.paint.get("background-opacity");if(0===f)return;const g=b.context,m=g.gl,n=b.transform,o=n.tileSize,d=e.paint.get("background-pattern");if(b.isPatternMissing(d))return;const p=!d&&1===l.a&&1===f&&b.opaquePassEnabledForLayer()?"opaque":"translucent";if(b.renderPass!==p)return;const t=a.StencilMode.disabled,u=b.depthModeForSublayer(0,"opaque"===p?a.DepthMode.ReadWrite:a.DepthMode.ReadOnly),v=b.colorModeForRenderPass(),q=b.useProgram(d?"backgroundPattern":"background");let h,i=k;i||(h=b.getBackgroundTiles(),i=Object.values(h).map(a=>a.tileID)),d&&(g.activeTexture.set(m.TEXTURE0),b.imageManager.bind(b.context));const w=e.getCrossfadeParameters();for(const c of i){const r=c.toUnwrapped(),s=k?c.projMatrix:b.transform.calculateProjMatrix(r);b.prepareDrawTile(c);const x=j?j.getTile(c):h?h[c.key]:new a.Tile(c,o,n.zoom,b),y=d?bR(s,f,b,d,{tileID:c,tileSize:o},w):bQ(s,f,l);b.prepareDrawProgram(g,q,r);const{tileBoundsBuffer:z,tileBoundsIndexBuffer:A,tileBoundsSegments:B}=b.getTileBoundsBuffers(x);q.draw(g,m.TRIANGLES,u,t,v,a.CullFaceMode.disabled,y,e.id,z,A,B)}},sky:function(b,k,c){const d=b.transform,i="mercator"===d.projection.name||"globe"===d.projection.name?1:a.smoothstep(7,8,d.zoom),e=c.paint.get("sky-opacity")*i;if(0===e)return;const j=b.context,f=c.paint.get("sky-type"),g=new a.DepthMode(j.gl.LEQUAL,a.DepthMode.ReadOnly,[0,1]),h=b.frameCounter/1e3%1;"atmosphere"===f?"offscreen"===b.renderPass?c.needsSkyboxCapture(b)&&(function(h,e,k,l){const d=h.context,b=d.gl;let i=e.skyboxFbo;if(!i){i=e.skyboxFbo=d.createFramebuffer(32,32,!1),e.skyboxGeometry=new cd(d),e.skyboxTexture=d.gl.createTexture(),b.bindTexture(b.TEXTURE_CUBE_MAP,e.skyboxTexture),b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE),b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE),b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MIN_FILTER,b.LINEAR),b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MAG_FILTER,b.LINEAR);for(let j=0;j<6;++j)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,b.RGBA,32,32,0,b.RGBA,b.UNSIGNED_BYTE,null)}d.bindFramebuffer.set(i.framebuffer),d.viewport.set([0,0,32,32,]);const f=e.getCenter(h,!0),g=h.useProgram("skyboxCapture"),c=new Float64Array(16);a.identity(c),a.rotateY(c,c,-(.5*Math.PI)),ce(d,e,g,c,f,0),a.identity(c),a.rotateY(c,c,.5*Math.PI),ce(d,e,g,c,f,1),a.identity(c),a.rotateX(c,c,-(.5*Math.PI)),ce(d,e,g,c,f,2),a.identity(c),a.rotateX(c,c,.5*Math.PI),ce(d,e,g,c,f,3),a.identity(c),ce(d,e,g,c,f,4),a.identity(c),a.rotateY(c,c,Math.PI),ce(d,e,g,c,f,5),d.viewport.set([0,0,h.width,h.height,])}(b,c),c.markSkyboxValid(b)):"sky"===b.renderPass&&function(b,c,i,j,k){var f,g;const d=b.context,e=d.gl,l=b.transform,h=b.useProgram("skybox");d.activeTexture.set(e.TEXTURE0),e.bindTexture(e.TEXTURE_CUBE_MAP,c.skyboxTexture);const m=(f=l.skyboxMatrix,g=c.getCenter(b,!1),{u_matrix:f,u_sun_direction:g,u_cubemap:0,u_opacity:j,u_temporal_offset:k});b.prepareDrawProgram(d,h),h.draw(d,e.TRIANGLES,i,a.StencilMode.disabled,b.colorModeForRenderPass(),a.CullFaceMode.backCW,m,"skybox",c.skyboxGeometry.vertexBuffer,c.skyboxGeometry.indexBuffer,c.skyboxGeometry.segment)}(b,c,g,e,h):"gradient"===f&&"sky"===b.renderPass&&function(c,b,m,n,o){var g,h,i,j,k;const d=c.context,e=d.gl,p=c.transform,l=c.useProgram("skyboxGradient");b.skyboxGeometry||(b.skyboxGeometry=new cd(d)),d.activeTexture.set(e.TEXTURE0);let f=b.colorRampTexture;f||(f=b.colorRampTexture=new a.Texture(d,b.colorRamp,e.RGBA)),f.bind(e.LINEAR,e.CLAMP_TO_EDGE);const q=(g=p.skyboxMatrix,h=b.getCenter(c,!1),i=b.paint.get("sky-gradient-radius"),j=n,k=o,{u_matrix:g,u_color_ramp:0,u_center_direction:h,u_radius:a.degToRad(i),u_opacity:j,u_temporal_offset:k});c.prepareDrawProgram(d,l),l.draw(d,e.TRIANGLES,m,a.StencilMode.disabled,c.colorModeForRenderPass(),a.CullFaceMode.backCW,q,"skyboxGradient",b.skyboxGeometry.vertexBuffer,b.skyboxGeometry.indexBuffer,b.skyboxGeometry.segment)}(b,c,g,e,h)},debug:function(c,d,b){for(let a=0;aa.getOpacity(this.transform.pitch)||.03>a.properties.get("horizon-blend"))return void(this.transform.fogCullDistSq=null);const[b,c]=a.getFovAdjustedRange(this.transform._fov);if(b>c)return void(this.transform.fogCullDistSq=null);const d=b+.78*(c-b);this.transform.fogCullDistSq=d*d}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}resize(b,c){if(this.width=b*a.exported.devicePixelRatio,this.height=c*a.exported.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height,]),this.style)for(const d of this.style.order)this.style._layers[d].resize()}setup(){const b=this.context,c=new a.StructArrayLayout2i4;c.emplaceBack(0,0),c.emplaceBack(a.EXTENT,0),c.emplaceBack(0,a.EXTENT),c.emplaceBack(a.EXTENT,a.EXTENT),this.tileExtentBuffer=b.createVertexBuffer(c,a.posAttributes.members),this.tileExtentSegments=a.SegmentVector.simpleSegment(0,0,4,2);const d=new a.StructArrayLayout2i4;d.emplaceBack(0,0),d.emplaceBack(a.EXTENT,0),d.emplaceBack(0,a.EXTENT),d.emplaceBack(a.EXTENT,a.EXTENT),this.debugBuffer=b.createVertexBuffer(d,a.posAttributes.members),this.debugSegments=a.SegmentVector.simpleSegment(0,0,4,5);const e=new a.StructArrayLayout2i4;e.emplaceBack(-1,-1),e.emplaceBack(1,-1),e.emplaceBack(-1,1),e.emplaceBack(1,1),this.viewportBuffer=b.createVertexBuffer(e,a.posAttributes.members),this.viewportSegments=a.SegmentVector.simpleSegment(0,0,4,2);const f=new a.StructArrayLayout4i8;f.emplaceBack(0,0,0,0),f.emplaceBack(a.EXTENT,0,a.EXTENT,0),f.emplaceBack(0,a.EXTENT,0,a.EXTENT),f.emplaceBack(a.EXTENT,a.EXTENT,a.EXTENT,a.EXTENT),this.mercatorBoundsBuffer=b.createVertexBuffer(f,a.boundsAttributes.members),this.mercatorBoundsSegments=a.SegmentVector.simpleSegment(0,0,4,2);const h=new a.StructArrayLayout3ui6;h.emplaceBack(0,1,2),h.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=b.createIndexBuffer(h);const i=new a.StructArrayLayout1ui2;for(const j of[0,1,3,2,0])i.emplaceBack(j);this.debugIndexBuffer=b.createIndexBuffer(i),this.emptyTexture=new a.Texture(b,{width:1,height:1,data:new Uint8Array([0,0,0,0])},b.gl.RGBA),this.identityMat=a.create();const g=this.context.gl;this.stencilClearMode=new a.StencilMode({func:g.ALWAYS,mask:0},0,255,g.ZERO,g.ZERO,g.ZERO),this.loadTimeStamps.push(a.window.performance.now())}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(a){return a._makeTileBoundsBuffers(this.context,this.transform.projection),a._tileBoundsBuffer?{tileBoundsBuffer:a._tileBoundsBuffer,tileBoundsIndexBuffer:a._tileBoundsIndexBuffer,tileBoundsSegments:a._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const b=this.context,c=b.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.useProgram("clippingMask").draw(b,c.TRIANGLES,a.DepthMode.disabled,this.stencilClearMode,a.ColorMode.disabled,a.CullFaceMode.disabled,bm(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(h,d,b){if(!d||this.currentStencilSource===d.id||!h.isTileClipped()||!b||0===b.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let g=!1;for(const i of b)if(void 0===this._tileClippingMaskIDs[i.key]){g=!0;break}if(!g)return}this.currentStencilSource=d.id;const e=this.context,c=e.gl;this.nextStencilID+b.length>256&&this.clearStencil(),e.setColorMode(a.ColorMode.disabled),e.setDepthMode(a.DepthMode.disabled);const j=this.useProgram("clippingMask");for(const f of(this._tileClippingMaskIDs={},b)){const k=d.getTile(f),l=this._tileClippingMaskIDs[f.key]=this.nextStencilID++,{tileBoundsBuffer:m,tileBoundsIndexBuffer:n,tileBoundsSegments:o}=this.getTileBoundsBuffers(k);j.draw(e,c.TRIANGLES,a.DepthMode.disabled,new a.StencilMode({func:c.ALWAYS,mask:0},l,255,c.KEEP,c.KEEP,c.REPLACE),a.ColorMode.disabled,a.CullFaceMode.disabled,bm(f.projMatrix),"$clipping",m,n,o)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const c=this.nextStencilID++,b=this.context.gl;return new a.StencilMode({func:b.NOTEQUAL,mask:255},c,255,b.KEEP,b.KEEP,b.REPLACE)}stencilModeForClipping(c){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(c);const b=this.context.gl;return new a.StencilMode({func:b.EQUAL,mask:255},this._tileClippingMaskIDs[c.key],0,b.KEEP,b.KEEP,b.REPLACE)}stencilConfigForOverlap(h){const c=this.context.gl,b=h.sort((a,b)=>b.overscaledZ-a.overscaledZ),f=b[b.length-1].overscaledZ,d=b[0].overscaledZ-f+1;if(d>1){this.currentStencilSource=void 0,this.nextStencilID+d>256&&this.clearStencil();const g={};for(let e=0;e=0;this.currentLayer--){const k=this.style._layers[c[this.currentLayer]],l=b._getLayerSourceCache(k);if(k.isSky())continue;const x=l?g[l.id]:void 0;this._renderTileClippingMasks(k,l,x),this.renderLayer(this,l,k,x)}if(this.renderPass="sky",(a.globeToMercatorTransition(this.transform.zoom)>0||"globe"!==this.transform.projection.name)&&this.transform.isHorizonVisible())for(this.currentLayer=0;this.currentLayer{const a=b._getLayerSourceCache(c);a&&!c.isHidden(this.transform.zoom)&&(!t||t.getSource().maxzoom0?a.pop():null}isPatternMissing(a){if(!a)return!1;if(!a.from||!a.to)return!0;const b=this.imageManager.getPattern(a.from.toString()),c=this.imageManager.getPattern(a.to.toString());return!b||!c}currentGlobalDefines(){const b=this.terrain&&this.terrain.renderingToTexture,c=this.style&&this.style.fog,a=[];return this.terrain&&!this.terrain.renderingToTexture&&a.push("TERRAIN"),c&&!b&&0!==c.getOpacity(this.transform.pitch)&&a.push("FOG"),b&&a.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&a.push("OVERDRAW_INSPECTOR"),a}useProgram(a,c,e){this.cache=this.cache||{};const d=this.currentGlobalDefines().concat(e||[]),b=bt.cacheKey(a,d,c);return this.cache[b]||(this.cache[b]=new bt(this.context,a,ba[a],c,bS[a],d)),this.cache[b]}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 a=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height,]),this.context.blendEquation.set(a.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=a.window.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new a.Texture(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this._terrain&&this._terrain.destroy(),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}prepareDrawTile(a){this.terrain&&this.terrain.prepareDrawTile(a)}prepareDrawProgram(c,d,e){if(this.terrain&&this.terrain.renderingToTexture)return;const a=this.style.fog;if(a){const b=a.getOpacity(this.transform.pitch);0!==b&&d.setFogUniformValues(c,((b,c,d,e)=>{const a=c.properties.get("color"),f=b.frameCounter/1e3%1,g=[a.r/a.a,a.g/a.a,a.b/a.a,e,];return{u_fog_matrix:d?b.transform.calculateFogTileMatrix(d):b.identityMat,u_fog_range:c.getFovAdjustedRange(b.transform._fov),u_fog_color:g,u_fog_horizon_blend:c.properties.get("horizon-blend"),u_fog_temporal_offset:f}})(this,a,e,b))}}setTileLoadedFlag(a){this.tileLoaded=a}saveCanvasCopy(){this.frameCopies.push(this.canvasCopy()),this.tileLoaded=!1}canvasCopy(){const a=this.context.gl,b=a.createTexture();return a.bindTexture(a.TEXTURE_2D,b),a.copyTexImage2D(a.TEXTURE_2D,0,a.RGBA,0,0,a.drawingBufferWidth,a.drawingBufferHeight,0),b}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const a=this.style&&this.style.fog;return!!a&&0!==a.getOpacity(this.transform.pitch)}getBackgroundTiles(){const d=this._backgroundTiles,c=this._backgroundTiles={},e=this.transform.coveringTiles({tileSize:512});for(const b of e)c[b.key]=d[b.key]||new a.Tile(b,512,this.transform.tileZoom,this);return c}clearBackgroundTiles(){this._backgroundTiles={}}}class ch{constructor(a=0,b=0,c=0,d=0){if(isNaN(a)||a<0||isNaN(b)||b<0||isNaN(c)||c<0||isNaN(d)||d<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=a,this.bottom=b,this.left=c,this.right=d}interpolate(b,c,d){return null!=c.top&&null!=b.top&&(this.top=a.number(b.top,c.top,d)),null!=c.bottom&&null!=b.bottom&&(this.bottom=a.number(b.bottom,c.bottom,d)),null!=c.left&&null!=b.left&&(this.left=a.number(b.left,c.left,d)),null!=c.right&&null!=b.right&&(this.right=a.number(b.right,c.right,d)),this}getCenter(b,c){const d=a.clamp((this.left+b-this.right)/2,0,b),e=a.clamp((this.top+c-this.bottom)/2,0,c);return new a.pointGeometry(d,e)}equals(a){return this.top===a.top&&this.bottom===a.bottom&&this.left===a.left&&this.right===a.right}clone(){return new ch(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function ci(b,c){const d=a.getColumn(b,3);a.fromQuat(b,c),a.setColumn(b,3,d)}function cj(c,b){a.setColumn(c,3,[b[0],b[1],b[2],1])}function ck(c,d){const b=a.identity$1([]);return a.rotateZ$1(b,b,-d),a.rotateX$1(b,b,-c),b}function cl(b,c){const f=[b[0],b[1],0],d=[c[0],c[1],0];if(a.length(f)>=1e-15){const g=a.normalize([],f);a.scale$2(d,g,a.dot(d,g)),c[0]=d[0],c[1]=d[1]}const e=a.cross([],c,b);if(1e-15>a.len(e))return null;const h=Math.atan2(-e[1],e[0]);return ck(Math.atan2(Math.sqrt(b[0]*b[0]+b[1]*b[1]),-b[2]),h)}class x{constructor(a,b){this.position=a,this.orientation=b}get position(){return this._position}set position(b){this._position=this._renderWorldCopies?function(b){if(!b)return;const c=Array.isArray(b)?new a.MercatorCoordinate(b[0],b[1],b[2]):b;return c.x=a.wrap(c.x,0,1),c}(b):b}lookAtPoint(e,b){if(this.orientation=null,!this.position)return;const f=this._elevation?this._elevation.getAtPointOrZero(a.MercatorCoordinate.fromLngLat(e)):0,c=this.position,d=a.MercatorCoordinate.fromLngLat(e,f),g=[d.x-c.x,d.y-c.y,d.z-c.z];b||(b=[0,0,1]),b[2]=Math.abs(b[2]),this.orientation=cl(g,b)}setPitchBearing(b,c){this.orientation=ck(a.degToRad(b),a.degToRad(-c))}}class cm{constructor(b,c){this._transform=a.identity([]),this._orientation=a.identity$1([]),c&&(this._orientation=c,ci(this._transform,this._orientation)),b&&cj(this._transform,b)}get mercatorPosition(){const b=this.position;return new a.MercatorCoordinate(b[0],b[1],b[2])}get position(){const b=a.getColumn(this._transform,3);return[b[0],b[1],b[2]]}set position(a){cj(this._transform,a)}get orientation(){return this._orientation}set orientation(a){this._orientation=a,ci(this._transform,this._orientation)}getPitchBearing(){const a=this.forward(),b=this.right();return{bearing:Math.atan2(-b[1],b[0]),pitch:Math.atan2(Math.sqrt(a[0]*a[0]+a[1]*a[1]),-a[2])}}setPitchBearing(a,b){this._orientation=ck(a,b),ci(this._transform,this._orientation)}forward(){const b=a.getColumn(this._transform,2);return[-b[0],-b[1],-b[2]]}up(){const b=a.getColumn(this._transform,1);return[-b[0],-b[1],-b[2]]}right(){const b=a.getColumn(this._transform,0);return[b[0],b[1],b[2]]}getCameraToWorld(c,d){const b=new Float64Array(16);return a.invert(b,this.getWorldToCamera(c,d)),b}getWorldToCameraPosition(e,f,c){const d=this.position;a.scale$2(d,d,-e);const b=new Float64Array(16);return a.fromScaling(b,[c,c,c]),a.translate(b,b,d),b[10]*=f,b}getWorldToCamera(f,c){const b=new Float64Array(16),e=new Float64Array(4),d=this.position;return a.conjugate(e,this._orientation),a.scale$2(d,d,-f),a.fromQuat(b,e),a.translate(b,b,d),b[1]*=-1,b[5]*=-1,b[9]*=-1,b[13]*=-1,b[8]*=c,b[9]*=c,b[10]*=c,b[11]*=c,b}getCameraToClipPerspective(c,d,e,f){const b=new Float64Array(16);return a.perspective(b,c,d,e,f),b}getDistanceToElevation(b){const c=0===b?0:a.mercatorZfromAltitude(b,this.position[1]),d=this.forward();return(c-this.position[2])/d[2]}clone(){return new cm([...this.position],[...this.orientation])}}function cn(b,e){const f=cp(b),c=function(c,y,d,h,v){const l=new a.LngLat(d.lng-180*cq,d.lat),m=new a.LngLat(d.lng+180*cq,d.lat),n=c.project(l.lng,l.lat),o=c.project(m.lng,m.lat),e=-Math.atan2(o.y-n.y,o.x-n.x),i=a.MercatorCoordinate.fromLngLat(d);i.y=a.clamp(i.y,-0.999975,.999975);const f=i.toLngLat(),g=c.project(f.lng,f.lat),p=a.MercatorCoordinate.fromLngLat(f);p.x+=cq;const q=p.toLngLat(),r=c.project(q.lng,q.lat),w=cs(r.x-g.x,r.y-g.y,e),s=a.MercatorCoordinate.fromLngLat(f);s.y+=cq;const t=s.toLngLat(),u=c.project(t.lng,t.lat),j=cs(u.x-g.x,u.y-g.y,e),x=Math.abs(w.x)/Math.abs(j.y),k=a.identity([]);a.rotateZ(k,k,-e*(1-(v?0:h)));const b=a.identity([]);return a.scale(b,b,[1,1-(1-x)*h,1]),b[4]=-j.x/j.y*h,a.rotateZ(b,b,e),a.multiply$1(b,k,b),b}(b.projection,0,b.center,f,e),d=co(b);return a.scale(c,c,[d,d,1]),c}function co(b){const c=b.projection,d=cp(b),e=cr(c,b.center),f=cr(c,a.LngLat.convert(c.center));return Math.pow(2,e*d+(1-d)*f)}function cp(b){const c=b.projection.range;if(!c)return 0;const e=Math.max(b.width,b.height),d=Math.log(e/1024)/Math.LN2;return a.smoothstep(c[0]+d,c[1]+d,b.zoom)}const cq=1/4e4;function cr(d,c){const b=a.clamp(c.lat,-a.MAX_MERCATOR_LATITUDE,a.MAX_MERCATOR_LATITUDE),e=new a.LngLat(c.lng-180*cq,b),f=new a.LngLat(c.lng+180*cq,b),g=d.project(e.lng,b),h=d.project(f.lng,b),i=a.MercatorCoordinate.fromLngLat(e),j=a.MercatorCoordinate.fromLngLat(f),k=h.x-g.x,l=h.y-g.y,m=j.x-i.x,n=j.y-i.y;return Math.log(Math.sqrt((m*m+n*n)/(k*k+l*l)))/Math.LN2}function cs(a,b,c){const d=Math.cos(c),e=Math.sin(c);return{x:a*d-b*e,y:a*e+b*d}}class ct{constructor(e,f,b,c,d){this.tileSize=512,this._renderWorldCopies=void 0===d||d,this._minZoom=e||0,this._maxZoom=f||22,this._minPitch=null==b?0:b,this._maxPitch=null==c?60:c,this.setProjection(),this.setMaxBounds(),this.width=0,this.height=0,this._center=new a.LngLat(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 ch,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._distanceTileDataCache={},this._camera=new cm,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._projectionScaler=1,this._horizonShift=.1}clone(){const a=new ct(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return a.setProjection(this.getProjection()),a._elevation=this._elevation,a._centerAltitude=this._centerAltitude,a.tileSize=this.tileSize,a.setMaxBounds(this.getMaxBounds()),a.width=this.width,a.height=this.height,a.cameraElevationReference=this.cameraElevationReference,a._center=this._center,a._setZoom(this.zoom),a._cameraZoom=this._cameraZoom,a.angle=this.angle,a._fov=this._fov,a._pitch=this._pitch,a._nearZ=this._nearZ,a._farZ=this._farZ,a._averageElevation=this._averageElevation,a._unmodified=this._unmodified,a._edgeInsets=this._edgeInsets.clone(),a._camera=this._camera.clone(),a._calcMatrices(),a.freezeTileCoverage=this.freezeTileCoverage,a}get elevation(){return this._elevation}set elevation(a){this._elevation!==a&&(this._elevation=a,a?this._updateCenterElevation()&&this._updateCameraOnTerrain():(this._cameraZoom=null,this._centerAltitude=0),this._calcMatrices())}updateElevation(a){this._terrainEnabled()&&null==this._cameraZoom&&this._updateCenterElevation()&&this._updateCameraOnTerrain(),a&&this._constrainCameraAltitude(),this._calcMatrices()}getProjection(){return a.pick(this.projection,["name","center","parallels",])}setProjection(b){null==b&&(b={name:"mercator"}),this.projectionOptions=b;const c=this.projection?this.getProjection():void 0;return this.projection=a.getProjection(b),!D(c,this.getProjection())&&(this._calcMatrices(),!0)}get minZoom(){return this._minZoom}set minZoom(a){this._minZoom!==a&&(this._minZoom=a,this.zoom=Math.max(this.zoom,a))}get maxZoom(){return this._maxZoom}set maxZoom(a){this._maxZoom!==a&&(this._maxZoom=a,this.zoom=Math.min(this.zoom,a))}get minPitch(){return this._minPitch}set minPitch(a){this._minPitch!==a&&(this._minPitch=a,this.pitch=Math.max(this.pitch,a))}get maxPitch(){return this._maxPitch}set maxPitch(a){this._maxPitch!==a&&(this._maxPitch=a,this.pitch=Math.min(this.pitch,a))}get renderWorldCopies(){return this._renderWorldCopies&& !0===this.projection.supportsWorldCopies}set renderWorldCopies(a){void 0===a?a=!0:null===a&&(a=!1),this._renderWorldCopies=a}get worldSize(){return this.tileSize*this.scale}get cameraWorldSize(){const a=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(a))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.cameraWorldSize)}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new a.pointGeometry(this.width,this.height)}get bearing(){return a.wrap(this.rotation,-180,180)}set bearing(a){this.rotation=a}get rotation(){return-this.angle/Math.PI*180}set rotation(m){var b,c,d,g,h,i,j,k,e,f;const l=-m*Math.PI/180;this.angle!==l&&(this._unmodified=!1,this.angle=l,this._calcMatrices(),this.rotationMatrix=(b=new a.ARRAY_TYPE(4),a.ARRAY_TYPE!=Float32Array&&(b[1]=0,b[2]=0),b[0]=1,b[3]=1,b),c=this.rotationMatrix,d=this.rotationMatrix,g=this.angle,h=d[0],i=d[1],j=d[2],k=d[3],e=Math.sin(g),f=Math.cos(g),c[0]=h*f+j*e,c[1]=i*f+k*e,c[2]=-(h*e)+j*f,c[3]=-(i*e)+k*f)}get pitch(){return this._pitch/Math.PI*180}set pitch(c){const b=a.clamp(c,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==b&&(this._unmodified=!1,this._pitch=b,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(a){a=Math.max(.01,Math.min(60,a)),this._fov!==a&&(this._unmodified=!1,this._fov=a/180*Math.PI,this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(a){this._averageElevation=a,this._calcFogMatrices()}get zoom(){return this._zoom}set zoom(b){const a=Math.min(Math.max(b,this.minZoom),this.maxZoom);this._zoom!==a&&(this._unmodified=!1,this._setZoom(a),this._terrainEnabled()&&this._updateCameraOnTerrain(),this._constrain(),this._calcMatrices())}_setZoom(a){this._zoom=a,this.scale=this.zoomScale(a),this.tileZoom=Math.floor(a),this.zoomFraction=a-this.tileZoom}_updateCenterElevation(){if(!this._elevation)return!1;const a=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center),-1);return -1===a?(this._cameraZoom=null,!1):(this._centerAltitude=a,!0)}_updateCameraOnTerrain(){this._cameraZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize)}sampleAverageElevation(){if(!this._elevation)return 0;const i=this._elevation,d=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8],],f=this.horizonLineFromTop();let g=0,e=0;for(let b=0;bc.maxzoom&&(d=c.maxzoom);const r=this.locationCoordinate(this.center),e=1<{const d=1/4e4,g=new a.MercatorCoordinate(b.x+d,b.y,b.z),h=new a.MercatorCoordinate(b.x,b.y+d,b.z),i=b.toLngLat(),j=g.toLngLat(),k=h.toLngLat(),c=this.locationCoordinate(i),e=this.locationCoordinate(j),f=this.locationCoordinate(k),l=Math.hypot(e.x-c.x,e.y-c.y),m=Math.hypot(f.x-c.x,f.y-c.y);return Math.sqrt(l*m)*O/d},j=b=>{const c=F,d=N;return{aabb:a.tileAABB(this,e,0,0,0,b,d,c,this.projection),zoom:0,x:0,y:0,minZ:d,maxZ:c,wrap:b,fullyVisible:!1}},f=[];let h=[];const k=d,v=c.reparseOverscaled?A:d,G=a=>a*a,Q=G((u-this._centerAltitude)*E),H=b=>{if(!this._elevation||!b.tileID||!C)return;const c=this._elevation.getMinMaxForTile(b.tileID),a=b.aabb;c?(a.min[2]=c.min,a.max[2]=c.max,a.center[2]=(a.min[2]+a.max[2])/2):(b.shouldSplit=I(b),b.shouldSplit||(a.min[2]=a.max[2]=a.center[2]=this._centerAltitude))},I=b=>{if(b.zoom.85?1:h}const i=d*d+e*e+c;return i{if(b*G(.707)0;){const b=f.pop(),l=b.x,m=b.y;let n=b.fullyVisible;if(!n){const w=b.aabb.intersects(D);if(0===w)continue;n=2===w}if(b.zoom!==k&&I(b))for(let g=0;g<4;g++){const o=(l<<1)+g%2,p=(m<<1)+(g>>1),q={aabb:C?b.aabb.quadrant(g):a.tileAABB(this,e,b.zoom+1,o,p,b.wrap,b.minZ,b.maxZ,this.projection),zoom:b.zoom+1,x:o,y:p,wrap:b.wrap,fullyVisible:n,tileID:void 0,shouldSplit:void 0,minZ:b.minZ,maxZ:b.maxZ};B&&(q.tileID=new a.OverscaledTileID(b.zoom+1===k?v:b.zoom+1,b.wrap,b.zoom+1,o,p),H(q)),f.push(q)}else{const x=b.zoom===k?v:b.zoom;if(c.minzoom&&c.minzoom>x)continue;const y=s[0]-(.5+l+(b.wrap<{const e=[0,0,0,1],f=[a.EXTENT,a.EXTENT,0,1],i=this.calculateFogTileMatrix(d.tileID.toUnwrapped());a.transformMat4$1(e,e,i),a.transformMat4$1(f,f,i);const g=a.getAABBPointSquareDist(e,f);if(0===g)return!0;let j=!1;const k=this._elevation;if(k&&g>R&&0!==S){const m=this.calculateProjMatrix(d.tileID.toUnwrapped());let b;c.isTerrainDEM||(b=k.getMinMaxForTile(d.tileID)),b||(b={min:N,max:F});const l=a.furthestTileCorner(this.rotation),h=[l[0]*a.EXTENT,l[1]*a.EXTENT,b.max,];a.transformMat4(h,h,m),j=(1-h[1])*this.height*.5a.distanceSq-b.distanceSq).map(a=>a.tileID)}resize(a,b){this.width=a,this.height=b,this.pixelsToGLUnits=[2/a,-2/b],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(a){return Math.pow(2,a)}scaleZoom(a){return Math.log(a)/Math.LN2}project(b){const d=a.clamp(b.lat,-a.MAX_MERCATOR_LATITUDE,a.MAX_MERCATOR_LATITUDE),c=this.projection.project(b.lng,d);return new a.pointGeometry(c.x*this.worldSize,c.y*this.worldSize)}unproject(a){return this.projection.unproject(a.x/this.worldSize,a.y/this.worldSize)}get point(){return this.project(this.center)}setLocationAtPoint(e,f){const b=this.pointCoordinate(f),c=this.pointCoordinate(this.centerPoint),d=this.locationCoordinate(e);this.setLocation(new a.MercatorCoordinate(d.x-(b.x-c.x),d.y-(b.y-c.y)))}setLocation(a){this.center=this.coordinateLocation(a),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(a){return this.projection.locationPoint(this,a)}locationPoint3D(a){return this._coordinatePoint(this.locationCoordinate(a),!0)}pointLocation(a){return this.coordinateLocation(this.pointCoordinate(a))}pointLocation3D(a){return this.coordinateLocation(this.pointCoordinate3D(a))}locationCoordinate(b,c){const e=c?a.mercatorZfromAltitude(c,b.lat):void 0,d=this.projection.project(b.lng,b.lat);return new a.MercatorCoordinate(d.x,d.y,e)}coordinateLocation(a){return this.projection.unproject(a.x,a.y)}pointRayIntersection(d,f){const h=null!=f?f:this._centerAltitude,b=[d.x,d.y,0,1],c=[d.x,d.y,1,1];a.transformMat4$1(b,b,this.pixelMatrixInverse),a.transformMat4$1(c,c,this.pixelMatrixInverse);const i=c[3];a.scale$1(b,b,1/b[3]),a.scale$1(c,c,1/i);const e=b[2],g=c[2];return{p0:b,p1:c,t:e===g?0:(h-e)/(g-e)}}screenPointToMercatorRay(d){const b=[d.x,d.y,0,1],c=[d.x,d.y,1,1];return a.transformMat4$1(b,b,this.pixelMatrixInverse),a.transformMat4$1(c,c,this.pixelMatrixInverse),a.scale$1(b,b,1/b[3]),a.scale$1(c,c,1/c[3]),b[2]=a.mercatorZfromAltitude(b[2],this._center.lat)*this.worldSize,c[2]=a.mercatorZfromAltitude(c[2],this._center.lat)*this.worldSize,a.scale$1(b,b,1/this.worldSize),a.scale$1(c,c,1/this.worldSize),new a.Ray([b[0],b[1],b[2]],a.normalize([],a.sub([],c,b)))}rayIntersectionCoordinate(e){const{p0:b,p1:c,t:d}=e,f=a.mercatorZfromAltitude(b[2],this._center.lat),g=a.mercatorZfromAltitude(c[2],this._center.lat);return new a.MercatorCoordinate(a.number(b[0],c[0],d)/this.worldSize,a.number(b[1],c[1],d)/this.worldSize,a.number(f,g,d))}pointCoordinate(a,b=this._centerAltitude){return this.projection.createTileTransform(this,this.worldSize).pointCoordinate(a.x,a.y,b)}pointCoordinate3D(c){if(!this.elevation)return this.pointCoordinate(c);const i=this.elevation;let b=this.elevation.pointCoordinate(c);if(b)return new a.MercatorCoordinate(b[0],b[1],b[2]);let f=0,d=this.horizonLineFromTop();if(c.y>d)return this.pointCoordinate(c);const j=.02*d,e=c.clone();for(let g=0;g<10&&d-f>j;g++){e.y=a.number(f,d,.66);const h=i.pointCoordinate(e);h?(d=e.y,b=h):f=e.y}return b?new a.MercatorCoordinate(b[0],b[1],b[2]):this.pointCoordinate(c)}isPointAboveHorizon(a){if(this.elevation)return!this.elevation.pointCoordinate(a);{const b=this.horizonLineFromTop();return a.y0?new a.pointGeometry(b[0]/b[3],b[1]/b[3]):new a.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE)}_getBounds(j,k){var f,l,g,m,h,n,i,o;const p=new a.pointGeometry(this._edgeInsets.left,this._edgeInsets.top),q=new a.pointGeometry(this.width-this._edgeInsets.right,this._edgeInsets.top),r=new a.pointGeometry(this.width-this._edgeInsets.right,this.height-this._edgeInsets.bottom),s=new a.pointGeometry(this._edgeInsets.left,this.height-this._edgeInsets.bottom);let b=this.pointCoordinate(p,j),c=this.pointCoordinate(q,j);const d=this.pointCoordinate(r,k),e=this.pointCoordinate(s,k);return b.y>1&&c.y>=0?b=new a.MercatorCoordinate((1-e.y)/(f=e,((l=b).y-f.y)/(l.x-f.x))+e.x,1):b.y<0&&c.y<=1&&(b=new a.MercatorCoordinate(-e.y/(g=e,((m=b).y-g.y)/(m.x-g.x))+e.x,0)),c.y>1&&b.y>=0?c=new a.MercatorCoordinate((1-d.y)/(h=d,((n=c).y-h.y)/(n.x-h.x))+d.x,1):c.y<0&&b.y<=1&&(c=new a.MercatorCoordinate(-d.y/(i=d,((o=c).y-i.y)/(o.x-i.x))+d.x,0)),new a.LngLatBounds().extend(this.coordinateLocation(b)).extend(this.coordinateLocation(c)).extend(this.coordinateLocation(e)).extend(this.coordinateLocation(d))}_getBounds3D(){const a=this.elevation;if(!a.visibleDemTiles.length)return this._getBounds(0,0);const b=a.visibleDemTiles.reduce((a,b)=>{if(b.dem){const c=b.dem.tree;a.min=Math.min(a.min,c.minimums[0]),a.max=Math.max(a.max,c.maximums[0])}return a},{min:Number.MAX_VALUE,max:0});return this._getBounds(b.min*a.exaggeration(),b.max*a.exaggeration())}getBounds(){return this._terrainEnabled()?this._getBounds3D():this._getBounds(0,0)}horizonLineFromTop(b=!0){const c=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))+this.centerOffset.y,a=this.height/2-c*(1-this._horizonShift);return b?Math.max(0,a):a}getMaxBounds(){return this.maxBounds}setMaxBounds(b){this.maxBounds=b,this.minLat=-a.MAX_MERCATOR_LATITUDE,this.maxLat=a.MAX_MERCATOR_LATITUDE,this.minLng=-180,this.maxLng=180,b&&(this.minLat=b.getSouth(),this.maxLat=b.getNorth(),this.minLng=b.getWest(),this.maxLng=b.getEast(),this.maxLngi&&(g=i-l),i-he&&(b=e-k),e-d.5?j-1:j,k>.5?k-1:k,0,]),this.alignedProjMatrix=l,b=a.create(),a.scale(b,b,[this.width/2,-this.height/2,1,]),a.translate(b,b,[1,-1,0]),this.labelPlaneMatrix=b,b=a.create(),a.scale(b,b,[1,-1,1]),a.translate(b,b,[-1,-1,0]),a.scale(b,b,[2/this.width,2/this.height,1,]),this.glCoordMatrix=b,this.pixelMatrix=a.multiply$1(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),this._calcFogMatrices(),this._distanceTileDataCache={},b=a.invert(new Float64Array(16),this.pixelMatrix),!b)throw new Error("failed to invert matrix");this.pixelMatrixInverse=b,this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const e=this.cameraWorldSize,f=this.cameraPixelsPerMeter,b=this._camera.position,g=1/this.height,d=[e,e,f];a.scale$2(d,d,g),a.scale$2(b,b,-1),a.multiply$2(b,b,d);const c=a.create();a.translate(c,c,b),a.scale(c,c,d),this.mercatorFogMatrix=c,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(e,f,g)}_computeCameraPosition(a){const e=(a=a||this.pixelsPerMeter)/this.pixelsPerMeter,b=this._camera.forward(),d=this.point,c=this._mercatorZfromZoom(this._cameraZoom?this._cameraZoom:this._zoom)*e-a/this.worldSize*this._centerAltitude;return[d.x/this.worldSize-b[0]*c,d.y/this.worldSize-b[1]*c,a/this.worldSize*this._centerAltitude-b[2]*c,]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(b){const e=this._maxCameraBoundsDistance()*Math.cos(this._pitch),c=b[2];let d=1;c>0&&(d=Math.min((e-this._camera.position[2])/c,1)),this._camera.position=a.scaleAndAdd([],this._camera.position,b,d),this._updateStateFromCamera()}_updateStateFromCamera(){const b=this._camera.position,e=this._camera.forward(),{pitch:c,bearing:f}=this._camera.getPitchBearing(),g=a.mercatorZfromAltitude(this._centerAltitude,this.center.lat)*this._projectionScaler,h=this._mercatorZfromZoom(this._maxZoom)*Math.cos(a.degToRad(this._maxPitch)),d=Math.max((b[2]-g)/Math.cos(c),h),i=this._zoomFromMercatorZ(d);a.scaleAndAdd(b,b,e,d),this._pitch=a.clamp(c,a.degToRad(this.minPitch),a.degToRad(this.maxPitch)),this.angle=a.wrap(f,-Math.PI,Math.PI),this._setZoom(a.clamp(i,this._minZoom,this._maxZoom)),this._terrainEnabled()&&this._updateCameraOnTerrain(),this._center=this.coordinateLocation(new a.MercatorCoordinate(b[0],b[1],b[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(a){return Math.pow(2,a)*this.tileSize}_mercatorZfromZoom(a){return this.cameraToCenterDistance/this._worldSizeFromZoom(a)}_minimumHeightOverTerrain(){const a=Math.min((null!=this._cameraZoom?this._cameraZoom:this._zoom)+2,this._maxZoom);return this._mercatorZfromZoom(a)}_zoomFromMercatorZ(a){return this.scaleZoom(this.cameraToCenterDistance/(a*this.tileSize))}_terrainEnabled(){return!(!this._elevation|| !this.projection.supportsTerrain&&(a.warnOnce("Terrain is not yet supported with alternate projections. Use mercator to enable terrain."),1))}anyCornerOffEdge(b,c){const f=Math.min(b.x,c.x),g=Math.max(b.x,c.x),e=Math.min(b.y,c.y),h=Math.max(b.y,c.y);if(el||d.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+a.radToDeg(this.fovAboveCenter)>88||this.anyCornerOffEdge(new a.pointGeometry(0,0),new a.pointGeometry(this.width,this.height))}zoomDeltaToMovement(c,d){const b=a.length(a.sub([],this._camera.position,c)),e=this._zoomFromMercatorZ(b)+d;return b-this._mercatorZfromZoom(e)}getCameraPoint(){const b=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new a.pointGeometry(0,b))}}function cu(a,b){let c=!1,d=null;const e=()=>{d=null,c&&(a(),d=setTimeout(e,b),c=!1)};return()=>(c=!0,d||e(),d)}const d={linearity:.3,easing:a.bezier(0,0,.3,1)},cv=a.extend({deceleration:2500,maxSpeed:1400},d),cw=a.extend({deceleration:20,maxSpeed:1400},d),cx=a.extend({deceleration:1e3,maxSpeed:360},d),cy=a.extend({deceleration:1e3,maxSpeed:90},d);function cz(a,b){(!a.duration||a.durationf.unproject(a)),g=d.reduce((a,b,d,c)=>a.add(b.div(c.length)),new a.pointGeometry(0,0));super(e,{points:d,point:g,lngLats:i,lngLat:f.unproject(g),originalEvent:c}),this._defaultPrevented=!1}}class cD extends a.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(a,c,b){super(a,{originalEvent:b}),this._defaultPrevented=!1}}class cE{constructor(a,b){this._map=a,this._clickTolerance=b.clickTolerance}reset(){delete this._mousedownPos}wheel(a){return this._firePreventable(new cD(a.type,this._map,a))}mousedown(a,b){return this._mousedownPos=b,this._firePreventable(new cB(a.type,this._map,a))}mouseup(a){this._map.fire(new cB(a.type,this._map,a))}preclick(c){const b=a.extend({},c);b.type="preclick",this._map.fire(new cB(b.type,this._map,b))}click(a,b){this._mousedownPos&&this._mousedownPos.dist(b)>=this._clickTolerance||(this.preclick(a),this._map.fire(new cB(a.type,this._map,a)))}dblclick(a){return this._firePreventable(new cB(a.type,this._map,a))}mouseover(a){this._map.fire(new cB(a.type,this._map,a))}mouseout(a){this._map.fire(new cB(a.type,this._map,a))}touchstart(a){return this._firePreventable(new cC(a.type,this._map,a))}touchmove(a){this._map.fire(new cC(a.type,this._map,a))}touchend(a){this._map.fire(new cC(a.type,this._map,a))}touchcancel(a){this._map.fire(new cC(a.type,this._map,a))}_firePreventable(a){if(this._map.fire(a),a.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class cF{constructor(a){this._map=a}reset(){this._delayContextMenu=!1,delete this._contextMenuEvent}mousemove(a){this._map.fire(new cB(a.type,this._map,a))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new cB("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(a){this._delayContextMenu?this._contextMenuEvent=a:this._map.fire(new cB(a.type,this._map,a)),this._map.listens("contextmenu")&&a.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class cG{constructor(a,b){this._map=a,this._el=a.getCanvasContainer(),this._container=a.getContainer(),this._clickTolerance=b.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(a,c){this.isEnabled()&&a.shiftKey&&0===a.button&&(b.disableDrag(),this._startPos=this._lastPos=c,this._active=!0)}mousemoveWindow(d,e){if(!this._active)return;const a=e;if(this._lastPos.equals(a)|| !this._box&&a.dist(this._startPos){this._box&&(this._box.style.transform=`translate(${f}px,${h}px)`,this._box.style.width=g-f+"px",this._box.style.height=i-h+"px")})}mouseupWindow(c,f){if(!this._active||0!==c.button)return;const d=this._startPos,e=f;if(this.reset(),b.suppressClick(),d.x!==e.x||d.y!==e.y)return this._map.fire(new a.Event("boxzoomend",{originalEvent:c})),{cameraAnimation:a=>a.fitScreenCoordinates(d,e,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",c)}keydown(a){this._active&&27===a.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",a))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),b.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(b,c){return this._map.fire(new a.Event(b,{originalEvent:c}))}}function cH(b,d){const c={};for(let a=0;athis.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=d.timeStamp),b.length===this.numTouches&&(this.centroid=function(b){const c=new a.pointGeometry(0,0);for(const d of b)c._add(d);return c.div(b.length)}(c),this.touches=cH(b,c)))}touchmove(g,c,d){if(this.aborted||!this.centroid)return;const e=cH(d,c);for(const a in this.touches){const f=this.touches[a],b=e[a];(!b||b.dist(f)>30)&&(this.aborted=!0)}}touchend(b,d,c){if((!this.centroid||b.timeStamp-this.startTime>500)&&(this.aborted=!0),0===c.length){const a=!this.aborted&&this.centroid;if(this.reset(),a)return a}}}(b),this.numTaps=b.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(a,b,c){this.singleTap.touchstart(a,b,c)}touchmove(a,b,c){this.singleTap.touchmove(a,b,c)}touchend(b,c,d){const a=this.singleTap.touchend(b,c,d);if(a){const e=b.timeStamp-this.lastTime<500,f=!this.lastTap||30>this.lastTap.dist(a);if(e&&f||this.reset(),this.count++,this.lastTime=b.timeStamp,this.lastTap=a,this.count===this.numTaps)return this.reset(),a}}}class cJ{constructor(){this._zoomIn=new cI({numTouches:1,numTaps:2}),this._zoomOut=new cI({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(a,b,c){this._zoomIn.touchstart(a,b,c),this._zoomOut.touchstart(a,b,c)}touchmove(a,b,c){this._zoomIn.touchmove(a,b,c),this._zoomOut.touchmove(a,b,c)}touchend(a,b,c){const d=this._zoomIn.touchend(a,b,c),e=this._zoomOut.touchend(a,b,c);return d?(this._active=!0,a.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:b=>b.easeTo({duration:300,zoom:b.getZoom()+1,around:b.unproject(d)},{originalEvent:a})}):e?(this._active=!0,a.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:b=>b.easeTo({duration:300,zoom:b.getZoom()-1,around:b.unproject(e)},{originalEvent:a})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const cK={0:1,2:2};class f{constructor(a){this.reset(),this._clickTolerance=a.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,delete this._lastPoint,delete this._eventButton}_correctButton(a,b){return!1}_move(a,b){return{}}mousedown(a,d){if(this._lastPoint)return;const c=b.mouseButton(a);this._correctButton(a,c)&&(this._lastPoint=d,this._eventButton=c)}mousemoveWindow(c,a){const b=this._lastPoint;if(b){if(c.preventDefault(),function(a,c){const b=cK[c];return void 0===a.buttons||(a.buttons&b)!==b}(c,this._eventButton))this.reset();else if(this._moved||!(a.dist(b)0&&(this._active=!0);const b=cH(g,k),h=new a.pointGeometry(0,0),d=new a.pointGeometry(0,0);let c=0;for(const e in b){const f=b[e],i=this._touches[e];i&&(h._add(f),d._add(f.sub(i)),c++,b[e]=f)}if(this._touches=b,c{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show")},500)}}class g{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}_start(a){}_move(a,b,c){return{}}touchstart(c,b,a){this._firstTwoTouches||a.length<2||(this._firstTwoTouches=[a[0].identifier,a[1].identifier,],this._start([b[0],b[1]]))}touchmove(c,d,e){if(!this._firstTwoTouches)return;c.preventDefault();const[f,g]=this._firstTwoTouches,a=cP(e,d,f),b=cP(e,d,g);if(!a||!b)return;const h=this._aroundCenter?null:a.add(b).div(2);return this._move([a,b],h,c)}touchend(h,a,c){if(!this._firstTwoTouches)return;const[d,e]=this._firstTwoTouches,f=cP(c,a,d),g=cP(c,a,e);f&&g||(this._active&&b.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(a){this._enabled=!0,this._aroundCenter=!!a&&"center"===a.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function cP(b,c,d){for(let a=0;aMath.abs(cQ(this._distance,this._startDistance))))return this._active=!0,{zoomDelta:cQ(this._distance,c),pinchAround:b}}}function cS(a,b){return 180*a.angleWith(b)/Math.PI}class cT extends g{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(a){this._startVector=this._vector=a[0].sub(a[1]),this._minDiameter=a[0].dist(a[1])}_move(a,b){const c=this._vector;if(this._vector=a[0].sub(a[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:cS(this._vector,c),pinchAround:b}}_isBelowThreshold(a){this._minDiameter=Math.min(this._minDiameter,a.mag());const b=25/(Math.PI*this._minDiameter)*360,c=cS(a,this._startVector);return Math.abs(c)Math.abs(a.x)}class cV extends g{constructor(a){super(),this._map=a}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}_start(a){this._lastPoints=a,cU(a[0].sub(a[1]))&&(this._valid=!1)}_move(a,e,b){const c=a[0].sub(this._lastPoints[0]),d=a[1].sub(this._lastPoints[1]);if(!(this._map._cooperativeGestures&&b.touches.length<3)&&(this._valid=this.gestureBeginsVertically(c,d,b.timeStamp),this._valid))return this._lastPoints=a,this._active=!0,{pitchDelta:-((c.y+d.y)/2*.5)}}gestureBeginsVertically(a,b,c){if(void 0!==this._valid)return this._valid;const d=a.mag()>=2,e=b.mag()>=2;if(!d&&!e)return;if(!d||!e)return void 0===this._firstMove&&(this._firstMove=c),c-this._firstMove<100&&void 0;const f=a.y>0==b.y>0;return cU(a)&&cU(b)&&f}}class cW{constructor(){const a={panStep:100,bearingStep:15,pitchStep:10};this._panStep=a.panStep,this._bearingStep=a.bearingStep,this._pitchStep=a.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(a){if(a.altKey||a.ctrlKey||a.metaKey)return;let d=0,b=0,c=0,e=0,f=0;switch(a.keyCode){case 61:case 107:case 171:case 187:d=1;break;case 189:case 109:case 173:d=-1;break;case 37:a.shiftKey?b=-1:(a.preventDefault(),e=-1);break;case 39:a.shiftKey?b=1:(a.preventDefault(),e=1);break;case 38:a.shiftKey?c=1:(a.preventDefault(),f=-1);break;case 40:a.shiftKey?c=-1:(a.preventDefault(),f=1);break;default:return}return this._rotationDisabled&&(b=0,c=0),{cameraAnimation:g=>{const h=g.getZoom();g.easeTo({duration:300,easeId:"keyboardHandler",easing:cX,zoom:d?Math.round(h)+d*(a.shiftKey?2:1):h,bearing:g.getBearing()+b*this._bearingStep,pitch:g.getPitch()+c*this._pitchStep,offset:[-e*this._panStep,-f*this._panStep,],center:g.getCenter()},{originalEvent:a})}}}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 cX(a){return a*(2-a)}const cY=4.000244140625;class cZ{constructor(b,c){this._map=b,this._el=b.getCanvasContainer(),this._handler=c,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,a.bindAll(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert","_isFullscreen",],this)}setZoomRate(a){this._defaultZoomRate=a}setWheelZoomRate(a){this._wheelZoomRate=a}isEnabled(){return!!this._enabled}isActive(){return!!this._active|| void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(a){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!a&&"center"===a.around,this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(b){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(b.ctrlKey||b.metaKey||this.isZooming()||this._isFullscreen()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let c=b.deltaMode===a.window.WheelEvent.DOM_DELTA_LINE?40*b.deltaY:b.deltaY;const d=a.exported.now(),e=d-(this._lastWheelEventTime||0);this._lastWheelEventTime=d,0!==c&&c%cY==0?this._type="wheel":0!==c&&4>Math.abs(c)?this._type="trackpad":e>400?(this._type=null,this._lastValue=c,this._timeout=setTimeout(this._onTimeout,40,b)):this._type||(this._type=200>Math.abs(e*c)?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,c+=this._lastValue)),b.shiftKey&&c&&(c/=4),this._type&&(this._lastWheelEvent=b,this._delta-=c,this._active||this._start(b)),b.preventDefault()}_onTimeout(a){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(a)}_start(a){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 c=b.mousePos(this._el,a);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:c,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const b=this._map.transform,c=()=>b._terrainEnabled()&&this._aroundCoord?b.computeZoomRelativeTo(this._aroundCoord):b.zoom;if(0!==this._delta){const k="wheel"===this._type&&Math.abs(this._delta)>cY?this._wheelZoomRate:this._defaultZoomRate;let d=2/(1+Math.exp(-Math.abs(this._delta*k)));this._delta<0&&0!==d&&(d=1/d);const l=c(),m=Math.pow(2,l),n="number"==typeof this._targetZoom?b.zoomScale(this._targetZoom):m;this._targetZoom=Math.min(b.maxZoom,Math.max(b.minZoom,b.scaleZoom(n*d))),"wheel"===this._type&&(this._startZoom=c(),this._easing=this._smoothOutEasing(200)),this._delta=0}const g="number"==typeof this._targetZoom?this._targetZoom:c(),h=this._startZoom,i=this._easing;let f,e=!1;if("wheel"===this._type&&h&&i){const j=Math.min((a.exported.now()-this._lastWheelEventTime)/200,1),o=i(j);f=a.number(h,g,o),j<1?this._frameId||(this._frameId=!0):e=!0}else f=g,e=!0;return this._active=!0,e&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!e,zoomDelta:f-c(),around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(g){let c=a.ease;if(this._prevEase){const b=this._prevEase,e=(a.exported.now()-b.start)/b.duration,f=b.easing(e+.01)-b.easing(e),d=.27/Math.sqrt(f*f+1e-4)*.01,h=Math.sqrt(.0729-d*d);c=a.bezier(d,h,.25,1)}return this._prevEase={start:a.exported.now(),duration:g,easing:c},c}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=b.create("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(a.window.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`)}_isFullscreen(){return!!a.window.document.fullscreenElement}_showBlockerAlert(){"hidden"===this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="visible"),this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show")},200)}}class c${constructor(a,b){this._clickZoom=a,this._tapZoom=b}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 c_{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(a,b){return a.preventDefault(),{cameraAnimation(c){c.easeTo({duration:300,zoom:c.getZoom()+(a.shiftKey?-1:1),around:c.unproject(b)},{originalEvent:a})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class c0{constructor(){this._tap=new cI({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,this._tap.reset()}touchstart(b,c,a){this._swipePoint||(this._tapTime&&b.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?a.length>0&&(this._swipePoint=c[0],this._swipeTouch=a[0].identifier):this._tap.touchstart(b,c,a))}touchmove(a,b,c){if(this._tapTime){if(this._swipePoint){if(c[0].identifier!==this._swipeTouch)return;const d=b[0],e=d.y-this._swipePoint.y;return this._swipePoint=d,a.preventDefault(),this._active=!0,{zoomDelta:e/128}}}else this._tap.touchmove(a,b,c)}touchend(a,c,b){this._tapTime?this._swipePoint&&0===b.length&&this.reset():this._tap.touchend(a,c,b)&&(this._tapTime=a.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class c1{constructor(a,b,c){this._el=a,this._mousePan=b,this._touchPan=c}enable(a){this._inertiaOptions=a||{},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 c2{constructor(a,b,c){this._pitchWithRotate=a.pitchWithRotate,this._mouseRotate=b,this._mousePitch=c}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 c3{constructor(a,b,c,d){this._el=a,this._touchZoom=b,this._touchRotate=c,this._tapDragZoom=d,this._rotationDisabled=!1,this._enabled=!0}enable(a){this._touchZoom.enable(a),this._rotationDisabled||this._touchRotate.enable(a),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 c4=a=>a.zoom||a.drag||a.pitch||a.rotate;class c5 extends a.Event{}function c6(a){return a.panDelta&&a.panDelta.mag()||a.zoomDelta||a.bearingDelta||a.pitchDelta}const c7="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class c8 extends a.Evented{constructor(b,c){super(),this._moving=!1,this._zooming=!1,this.transform=b,this._bearingSnap=c.bearingSnap,a.bindAll(["_renderFrameCallback"],this)}getCenter(){return new a.LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(a,b){return this.jumpTo({center:a},b)}panBy(b,c,d){return b=a.pointGeometry.convert(b).mult(-1),this.panTo(this.transform.center,a.extend({offset:b},c),d)}panTo(b,c,d){return this.easeTo(a.extend({center:b},c),d)}getZoom(){return this.transform.zoom}setZoom(a,b){return this.jumpTo({zoom:a},b),this}zoomTo(b,c,d){return this.easeTo(a.extend({zoom:b},c),d)}zoomIn(a,b){return this.zoomTo(this.getZoom()+1,a,b),this}zoomOut(a,b){return this.zoomTo(this.getZoom()-1,a,b),this}getBearing(){return this.transform.bearing}setBearing(a,b){return this.jumpTo({bearing:a},b),this}getPadding(){return this.transform.padding}setPadding(a,b){return this.jumpTo({padding:a},b),this}rotateTo(b,c,d){return this.easeTo(a.extend({bearing:b},c),d)}resetNorth(b,c){return this.rotateTo(0,a.extend({duration:1e3},b),c),this}resetNorthPitch(b,c){return this.easeTo(a.extend({bearing:0,pitch:0,duration:1e3},b),c),this}snapToNorth(a,b){return Math.abs(this.getBearing())i=>{if(t&&(c.zoom=a.number(d,g,i)),u&&(c.bearing=a.number(e,n,i)),v&&(c.pitch=a.number(f,o,i)),w&&(c.interpolatePadding(z,p,i),h=c.centerPoint.add(q)),k)c.setLocationAtPoint(k,s);else{const l=c.zoomScale(c.zoom-d),x=g>d?Math.min(2,B):Math.max(.5,B),y=Math.pow(x,1-i),j=c.unproject(r.add(A.mult(i*y)).mult(l));c.setLocationAtPoint(c.renderWorldCopies?j.wrap():j,h)}return b.preloadOnly||this._fireMoveEvents(m),c};if(b.preloadOnly){const x=this._emulate(l,b.duration,c);return this._preloadTiles(x),this}const y={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=t,this._rotating=u,this._pitching=v,this._padding=w,this._easeId=b.easeId,this._prepareEase(m,b.noMoveStart,y),this._ease(l(c),a=>{c.recenterOnTerrain(),this._afterEase(m,a)},b),this}_prepareEase(b,d,c={}){this._moving=!0,this.transform.cameraElevationReference="sea",d||c.moving||this.fire(new a.Event("movestart",b)),this._zooming&&!c.zooming&&this.fire(new a.Event("zoomstart",b)),this._rotating&&!c.rotating&&this.fire(new a.Event("rotatestart",b)),this._pitching&&!c.pitching&&this.fire(new a.Event("pitchstart",b))}_fireMoveEvents(b){this.fire(new a.Event("move",b)),this._zooming&&this.fire(new a.Event("zoom",b)),this._rotating&&this.fire(new a.Event("rotate",b)),this._pitching&&this.fire(new a.Event("pitch",b))}_afterEase(b,c){if(this._easeId&&c&&this._easeId===c)return;delete this._easeId,this.transform.cameraElevationReference="ground";const d=this._zooming,e=this._rotating,f=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,d&&this.fire(new a.Event("zoomend",b)),e&&this.fire(new a.Event("rotateend",b)),f&&this.fire(new a.Event("pitchend",b)),this.fire(new a.Event("moveend",b))}flyTo(b,g){if(!b.essential&&a.exported.prefersReducedMotion){const r=a.pick(b,["center","zoom","bearing","pitch","around",]);return this.jumpTo(r,g)}this.stop(),b=a.extend({offset:[0,0],speed:1.2,curve:1.42,easing:a.ease},b);const c=this.transform,f=this.getZoom(),h=this.getBearing(),k=this.getPitch(),J=this.getPadding(),l="zoom"in b?a.clamp(+b.zoom,c.minZoom,c.maxZoom):f,s="bearing"in b?this._normalizeBearing(b.bearing,h):h,t="pitch"in b?+b.pitch:k,u="padding"in b?b.padding:c.padding,v=c.zoomScale(l-f),w=a.pointGeometry.convert(b.offset);let x=c.centerPoint.add(w);const m=c.pointLocation(x),n=a.LngLat.convert(b.center||m);this._normalizeCenter(n);const y=c.project(m),z=c.project(n).sub(y);let d=b.curve;const e=Math.max(c.width,c.height),i=e/v,o=z.mag();if("minZoom"in b){const A=a.clamp(Math.min(b.minZoom,f,l),c.minZoom,c.maxZoom),B=e/c.zoomScale(A-f);d=Math.sqrt(B/o*2)}const K=d*d;function p(b){const a=(i*i-e*e+(b?-1:1)*K*K*o*o)/(2*(b?i:e)*K*o);return Math.log(Math.sqrt(a*a+1)-a)}function L(a){return(Math.exp(a)-Math.exp(-a))/2}function M(a){return(Math.exp(a)+Math.exp(-a))/2}const C=p(0);let D=function(a){return M(C)/M(C+d*a)},E=function(b){var a;return e*((M(C)*(L(a=C+d*b)/M(a))-L(C))/K)/o},j=(p(1)-C)/d;if(1e-6>Math.abs(o)||!isFinite(j)){if(1e-6>Math.abs(e-i))return this.easeTo(b,g);const N=ib.maxDuration&&(b.duration=0);const F=h!==s,G=t!==k,H=!c.isPaddingEqual(u),q=c=>d=>{const e=d*j,i=1/D(e);c.zoom=1===d?l:f+c.scaleZoom(i),F&&(c.bearing=a.number(h,s,d)),G&&(c.pitch=a.number(k,t,d)),H&&(c.interpolatePadding(J,u,d),x=c.centerPoint.add(w));const m=1===d?n:c.unproject(y.add(z.mult(E(e))).mult(i));return c.setLocationAtPoint(c.renderWorldCopies?m.wrap():m,x),c._updateCenterElevation(),b.preloadOnly||this._fireMoveEvents(g),c};if(b.preloadOnly){const I=this._emulate(q,b.duration,c);return this._preloadTiles(I),this}return this._zooming=!0,this._rotating=F,this._pitching=G,this._padding=H,this._prepareEase(g,!1),this._ease(q(c),()=>this._afterEase(g),b),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(b,c){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const d=this._onEaseEnd;delete this._onEaseEnd,d.call(this,c)}if(!b){const a=this.handlers;a&&a.stop(!1)}return this}_ease(c,d,b){!1===b.animate||0===b.duration?(c(1),d()):(this._easeStart=a.exported.now(),this._easeOptions=b,this._onEaseFrame=c,this._onEaseEnd=d,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const b=Math.min((a.exported.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(b)),b<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(b,c){b=a.wrap(b,-180,180);const d=Math.abs(b-c);return Math.abs(b-360-c)180?-360:c< -180?360:0}_emulate(d,e,f){const b=Math.ceil(15*e/1e3),c=[],g=d(f.clone());for(let a=0;a<=b;a++){const h=g(a/b);c.push(h.clone())}return c}}class y{constructor(b={}){this.options=b,a.bindAll(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact",],this)}getDefaultPosition(){return"bottom-right"}onAdd(c){const a=this.options&&this.options.compact;return this._map=c,this._container=b.create("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=b.create("button","mapboxgl-ctrl-attrib-button",this._container),b.create("span","mapboxgl-ctrl-icon",this._compactButton).setAttribute("aria-hidden",!0),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=b.create("div","mapboxgl-ctrl-attrib-inner",this._container),this._innerContainer.setAttribute("role","list"),a&&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===a&&(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(a,c){const b=this._map._getUIString(`AttributionControl.${c}`);a.setAttribute("aria-label",b),a.removeAttribute("title"),a.firstElementChild&&a.firstElementChild.setAttribute("title",b)}_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 b=this._editLink;b||(b=this._editLink=this._container.querySelector(".mapbox-improve-map"));const c=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||a.config.ACCESS_TOKEN},];if(b){const d=c.reduce((b,a,d)=>(a.value&&(b+=`${a.key}=${a.value}${da.indexOf(b.attribution)&&a.push(b.attribution)}}a.sort((a,b)=>a.length-b.length),a=a.filter((c,d)=>{for(let b=d+1;b=0)return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?a=[...this.options.customAttribution,...a,]:a.unshift(this.options.customAttribution));const c=a.join(" | ");c!==this._attribHTML&&(this._attribHTML=c,a.length?(this._innerContainer.innerHTML=c,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 c9{constructor(){a.bindAll(["_updateLogo"],this),a.bindAll(["_updateCompact"],this)}onAdd(c){this._map=c,this._container=b.create("div","mapboxgl-ctrl");const a=b.create("a","mapboxgl-ctrl-logo");return a.target="_blank",a.rel="noopener nofollow",a.href="https://www.mapbox.com/",a.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),a.setAttribute("rel","noopener nofollow"),this._container.appendChild(a),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(a){a&&"metadata"!==a.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const a=this._map.style._sourceCaches;if(0===Object.entries(a).length)return!0;for(const c in a){const b=a[c].getSource();if(b.hasOwnProperty("mapbox_logo")&&!b.mapbox_logo)return!1}return!0}_updateCompact(){const a=this._container.children;if(a.length){const b=a[0];this._map.getCanvasContainer().offsetWidth<250?b.classList.add("mapboxgl-compact"):b.classList.remove("mapboxgl-compact")}}}class da{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(b){const a=++this._id;return this._queue.push({callback:b,id:a,cancelled:!1}),a}remove(c){const a=this._currentlyRunning,d=a?this._queue.concat(a):this._queue;for(const b of d)if(b.id===c)return void(b.cancelled=!0)}run(b=0){const c=this._currentlyRunning=this._queue;for(const a of(this._queue=[],c))if(!a.cancelled&&(a.callback(b),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function db(b,d,c){if(b=new a.LngLat(b.lng,b.lat),d){const f=new a.LngLat(b.lng-360,b.lat),g=new a.LngLat(b.lng+360,b.lat),h=360*Math.ceil(Math.abs(b.lng-c.center.lng)/360),i=c.locationPoint(b).distSqr(d),j=d.x<0||d.y<0||d.x>c.width||d.y>c.height;c.locationPoint(f).distSqr(d)180;){const e=c.locationPoint(b);if(e.x>=0&&e.y>=0&&e.x<=c.width&&e.y<=c.height)break;b.lng>c.center.lng?b.lng-=360:b.lng+=360}return b}const dc={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 z extends a.Evented{constructor(c,e){if(super(),(c instanceof a.window.HTMLElement||e)&&(c=a.extend({element:c},e)),a.bindAll(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer",],this),this._anchor=c&&c.anchor||"center",this._color=c&&c.color||"#3FB1CE",this._scale=c&&c.scale||1,this._draggable=c&&c.draggable||!1,this._clickTolerance=c&&c.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=c&&c.rotation||0,this._rotationAlignment=c&&c.rotationAlignment||"auto",this._pitchAlignment=c&&c.pitchAlignment&&"auto"!==c.pitchAlignment?c.pitchAlignment:this._rotationAlignment,this._updateMoving=()=>this._update(!0),c&&c.element)this._element=c.element,this._offset=a.pointGeometry.convert(c&&c.offset||[0,0]);else{this._defaultMarker=!0,this._element=b.create("div");const f=41,g=27,d=b.createSVG("svg",{display:"block",height:f*this._scale+"px",width:g*this._scale+"px",viewBox:`0 0 ${g} ${f}`},this._element),h=b.createSVG("radialGradient",{id:"shadowGradient"},b.createSVG("defs",{},d));b.createSVG("stop",{offset:"10%","stop-opacity":.4},h),b.createSVG("stop",{offset:"100%","stop-opacity":.05},h),b.createSVG("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},d),b.createSVG("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"},d),b.createSVG("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"},d),b.createSVG("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},d),this._offset=a.pointGeometry.convert(c&&c.offset||[0,-14])}this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",a=>{a.preventDefault()}),this._element.addEventListener("mousedown",a=>{a.preventDefault()});const i=this._element.classList;for(const j in dc)i.remove(`mapboxgl-marker-anchor-${j}`);i.add(`mapboxgl-marker-anchor-${this._anchor}`),this._popup=null}addTo(a){return a===this._map||(this.remove(),this._map=a,a.getCanvasContainer().appendChild(this._element),a.on("move",this._updateMoving),a.on("moveend",this._update),a.on("remove",this._clearFadeTimer),a._addMarker(this),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick)),this}remove(){return this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._updateMoving),this._map.off("moveend",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),this._map.off("remove",this._clearFadeTimer),this._map._removeMarker(this),delete this._map),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(b){return this._lngLat=a.LngLat.convert(b),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(c){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")),c){if(!("offset"in c.options)){const b=38.1,a=13.5,d=Math.sqrt(Math.pow(a,2)/2);c.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-b],"bottom-left":[d,-1*(b-a+d),],"bottom-right":[-d,-1*(b-a+d),],left:[a,-1*(b-a)],right:[-a,-1*(b-a)]}:this._offset}this._popup=c,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(a){const b=a.code,c=a.charCode||a.keyCode;"Space"!==b&&"Enter"!==b&&32!==c&&13!==c||this.togglePopup()}_onMapClick(c){const a=c.originalEvent.target,b=this._element;this._popup&&(a===b||b.contains(a))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const a=this._popup;return a&&(a.isOpen()?(a.remove(),this._element.setAttribute("aria-expanded","false")):(a.addTo(this._map),this._element.setAttribute("aria-expanded","true"))),this}_evaluateOpacity(){const a=this._pos?this._pos.sub(this._transformedOffset()):null;if(!this._withinScreenBounds(a))return void this._clearFadeTimer();const b=this._map.unproject(a);let c=!1;if(this._map.transform._terrainEnabled()&&this._map.getTerrain()){const d=this._map.getFreeCameraOptions();if(d.position){const e=d.position.toLngLat();c=e.distanceTo(b)<.9*e.distanceTo(this._lngLat)}}const f=(1-this._map._queryFogOpacity(b))*(c?.2:1);this._element.style.opacity=`${f}`,this._popup&&this._popup._setOpacity(`${f}`),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_withinScreenBounds(a){const b=this._map.transform;return!!a&&a.x>=0&&a.x=0&&a.y{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),this._map._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(this._map.getTerrain()||this._map.getFog())&&!this._fadeTimer&&(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))}))}_transformedOffset(){if(!this._defaultMarker)return this._offset;const b=this._map.transform,a=this._offset.mult(this._scale);return"map"===this._rotationAlignment&&a._rotate(b.angle),"map"===this._pitchAlignment&&(a.y*=Math.cos(b._pitch)),a}getOffset(){return this._offset}setOffset(b){return this._offset=a.pointGeometry.convert(b),this._update(),this}_onMove(b){if(!this._isDragging){const c=this._clickTolerance||this._map._clickTolerance;this._isDragging=b.point.dist(this._pointerdownPos)>=c}this._isDragging&&(this._pos=b.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new a.Event("dragstart"))),this.fire(new a.Event("drag")))}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),"active"===this._state&&this.fire(new a.Event("dragend")),this._state="inactive"}_addDragHandler(a){this._element.contains(a.originalEvent.target)&&(a.preventDefault(),this._positionDelta=a.point.sub(this._pos).add(this._transformedOffset()),this._pointerdownPos=a.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))}setDraggable(a){return this._draggable=!!a,this._map&&(a?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(a){return this._rotation=a||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(a){return this._rotationAlignment=a||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(a){return this._pitchAlignment=a&&"auto"!==a?a:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}}const{HTMLImageElement:dd,HTMLElement:de,ImageBitmap:df}=a.window;function dg(a){a.parentNode&&a.parentNode.removeChild(a)}class dh{constructor(c,b,d=!1){this._clickTolerance=10,this.element=b,this.mouseRotate=new cM({clickTolerance:c.dragRotate._mouseRotate._clickTolerance}),this.map=c,d&&(this.mousePitch=new cN({clickTolerance:c.dragRotate._mousePitch._clickTolerance})),a.bindAll(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset",],this),b.addEventListener("mousedown",this.mousedown),b.addEventListener("touchstart",this.touchstart,{passive:!1}),b.addEventListener("touchmove",this.touchmove),b.addEventListener("touchend",this.touchend),b.addEventListener("touchcancel",this.reset)}down(a,c){this.mouseRotate.mousedown(a,c),this.mousePitch&&this.mousePitch.mousedown(a,c),b.disableDrag()}move(d,e){const a=this.map,b=this.mouseRotate.mousemoveWindow(d,e);if(b&&b.bearingDelta&&a.setBearing(a.getBearing()+b.bearingDelta),this.mousePitch){const c=this.mousePitch.mousemoveWindow(d,e);c&&c.pitchDelta&&a.setPitch(a.getPitch()+c.pitchDelta)}}off(){const a=this.element;a.removeEventListener("mousedown",this.mousedown),a.removeEventListener("touchstart",this.touchstart,{passive:!1}),a.removeEventListener("touchmove",this.touchmove),a.removeEventListener("touchend",this.touchend),a.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){b.enableDrag(),a.window.removeEventListener("mousemove",this.mousemove),a.window.removeEventListener("mouseup",this.mouseup)}mousedown(c){this.down(a.extend({},c,{ctrlKey:!0,preventDefault:()=>c.preventDefault()}),b.mousePos(this.element,c)),a.window.addEventListener("mousemove",this.mousemove),a.window.addEventListener("mouseup",this.mouseup)}mousemove(a){this.move(a,b.mousePos(this.element,a))}mouseup(a){this.mouseRotate.mouseupWindow(a),this.mousePitch&&this.mousePitch.mouseupWindow(a),this.offTemp()}touchstart(a){1!==a.targetTouches.length?this.reset():(this._startPos=this._lastPos=b.touchPos(this.element,a.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>a.preventDefault()},this._startPos))}touchmove(a){1!==a.targetTouches.length?this.reset():(this._lastPos=b.touchPos(this.element,a.targetTouches)[0],this.move({preventDefault:()=>a.preventDefault()},this._lastPos))}touchend(a){0===a.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)5280?dm(d,c,f/5280,a._getUIString("ScaleControl.Miles"),a):dm(d,c,f,a._getUIString("ScaleControl.Feet"),a)}else b&&"nautical"===b.unit?dm(d,c,e/1852,a._getUIString("ScaleControl.NauticalMiles"),a):e>=1e3?dm(d,c,e/1e3,a._getUIString("ScaleControl.Kilometers"),a):dm(d,c,e,a._getUIString("ScaleControl.Meters"),a)}function dm(d,e,a,f,b){const c=function(b){const c=Math.pow(10,`${Math.floor(b)}`.length-1);let a=b/c;return a=a>=10?10:a>=5?5:a>=3?3:a>=2?2:a>=1?1:function(a){const b=Math.pow(10,Math.ceil(-Math.log(a)/Math.LN10));return Math.round(a*b)/b}(a),c*a}(a),g=c/a;b._requestDomTask(()=>{d.style.width=e*g+"px",d.innerHTML=`${c} ${f}`})}const A={version:a.version,supported:l,setRTLTextPlugin:a.setRTLTextPlugin,getRTLTextPluginStatus:a.getRTLTextPluginStatus,Map:class extends c8{constructor(c){if(null!=(c=a.extend({},{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,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,optimizeForTerrain:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,transformRequest:null,accessToken:null,fadeDuration:300,crossSourceCollisions:!0},c)).minZoom&&null!=c.maxZoom&&c.minZoom>c.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=c.minPitch&&null!=c.maxPitch&&c.minPitch>c.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=c.minPitch&&c.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=c.maxPitch&&c.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(super(new ct(c.minZoom,c.maxZoom,c.minPitch,c.maxPitch,c.renderWorldCopies),c),this._interactive=c.interactive,this._minTileCacheSize=c.minTileCacheSize,this._maxTileCacheSize=c.maxTileCacheSize,this._failIfMajorPerformanceCaveat=c.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=c.preserveDrawingBuffer,this._antialias=c.antialias,this._trackResize=c.trackResize,this._bearingSnap=c.bearingSnap,this._refreshExpiredTiles=c.refreshExpiredTiles,this._fadeDuration=c.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=c.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=c.collectResourceTiming,this._optimizeForTerrain=c.optimizeForTerrain,this._renderTaskQueue=new da,this._domRenderTaskQueue=new da,this._controls=[],this._markers=[],this._mapId=a.uniqueId(),this._locale=a.extend({},{"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","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use \u2318 + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"},c.locale),this._clickTolerance=c.clickTolerance,this._cooperativeGestures=c.cooperativeGestures,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevation=new class{constructor(a){this.jumpTo(a)}getValue(b){if(b<=this._startTime)return this._start;if(b>=this._endTime)return this._end;const c=a.easeCubicInOut((b-this._startTime)/(this._endTime-this._startTime));return this._start*(1-c)+this._end*c}isEasing(a){return a>=this._startTime&&a<=this._endTime}jumpTo(a){this._startTime=-1/0,this._endTime=-1/0,this._start=a,this._end=a}easeTo(b,a,c){this._start=this.getValue(a),this._end=b,this._startTime=a,this._endTime=a+c}}(0),this._requestManager=new a.RequestManager(c.transformRequest,c.accessToken,c.testMode),this._silenceAuthErrors=!!c.testMode,"string"==typeof c.container){if(this._container=a.window.document.getElementById(c.container),!this._container)throw new Error(`Container '${c.container}' not found.`)}else{if(!(c.container instanceof de))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=c.container}if(this._container.childNodes.length>0&&a.warnOnce("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."),c.maxBounds&&this.setMaxBounds(c.maxBounds),a.bindAll(["_onWindowOnline","_onWindowResize","_onMapScroll","_contextLost","_contextRestored",],this),this._setupContainer(),this._setupPainter(),void 0===this.painter)throw new Error("Failed to initialize WebGL.");this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),void 0!==a.window&&(a.window.addEventListener("online",this._onWindowOnline,!1),a.window.addEventListener("resize",this._onWindowResize,!1),a.window.addEventListener("orientationchange",this._onWindowResize,!1),a.window.addEventListener("webkitfullscreenchange",this._onWindowResize,!1)),this.handlers=new class{constructor(c,d){this._map=c,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new class{constructor(a){this._map=a,this.clear()}clear(){this._inertiaBuffer=[]}record(b){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:a.exported.now(),settings:b})}_drainInertiaBuffer(){const b=this._inertiaBuffer,c=a.exported.now();for(;b.length>0&&c-b[0].time>160;)b.shift()}_onMoveEnd(k){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const b={zoom:0,bearing:0,pitch:0,pan:new a.pointGeometry(0,0),pinchAround:void 0,around:void 0};for(const{settings:d}of this._inertiaBuffer)b.zoom+=d.zoomDelta||0,b.bearing+=d.bearingDelta||0,b.pitch+=d.pitchDelta||0,d.panDelta&&b.pan._add(d.panDelta),d.around&&(b.around=d.around),d.pinchAround&&(b.pinchAround=d.pinchAround);const e=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,c={};if(b.pan.mag()){const f=cA(b.pan.mag(),e,a.extend({},cv,k||{}));c.offset=b.pan.mult(f.amount/b.pan.mag()),c.center=this._map.transform.center,cz(c,f)}if(b.zoom){const g=cA(b.zoom,e,cw);c.zoom=this._map.transform.zoom+g.amount,cz(c,g)}if(b.bearing){const h=cA(b.bearing,e,cx);c.bearing=this._map.transform.bearing+a.clamp(h.amount,-179,179),cz(c,h)}if(b.pitch){const i=cA(b.pitch,e,cy);c.pitch=this._map.transform.pitch+i.amount,cz(c,i)}if(c.zoom||c.bearing){const j=void 0===b.pinchAround?b.around:b.pinchAround;c.around=j?this._map.unproject(j):this._map.getCenter()}return this.clear(),a.extend(c,{noMoveStart:!0})}}(c),this._bearingSnap=d.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new class{constructor(){this.constants=[1,1,.01],this.radius=0}setup(c,d){const b=a.sub([],d,c);this.radius=a.length(b[2]<0?a.div([],b,this.constants):[b[0],b[1],0])}projectRay(c){a.div(c,c,this.constants),a.normalize(c,c),a.mul$1(c,c,this.constants);const b=a.scale$2([],c,this.radius);if(b[2]>0){const e=a.scale$2([],[0,0,1],a.dot(b,[0,0,1])),f=a.scale$2([],a.normalize([],[b[0],b[1],0]),this.radius),d=a.add([],b,a.scale$2([],a.sub([],a.add([],f,e),b),2));b[0]=d[0],b[1]=d[1]}return b}},this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(d),a.bindAll(["handleEvent","handleWindowEvent"],this);const b=this._el;for(const[e,f,g]of(this._listeners=[[b,"touchstart",{passive:!0},],[b,"touchmove",{passive:!1},],[b,"touchend",void 0],[b,"touchcancel",void 0],[b,"mousedown",void 0],[b,"mousemove",void 0],[b,"mouseup",void 0],[a.window.document,"mousemove",{capture:!0},],[a.window.document,"mouseup",void 0],[b,"mouseover",void 0],[b,"mouseout",void 0],[b,"dblclick",void 0],[b,"click",void 0],[b,"keydown",{capture:!1},],[b,"keyup",void 0],[b,"wheel",{passive:!1},],[b,"contextmenu",void 0],[a.window,"blur",void 0],],this._listeners))e.addEventListener(f,e===a.window.document?this.handleWindowEvent:this.handleEvent,g)}destroy(){for(const[b,c,d]of this._listeners)b.removeEventListener(c,b===a.window.document?this.handleWindowEvent:this.handleEvent,d)}_addDefaultHandlers(b){const a=this._map,d=a.getCanvasContainer();this._add("mapEvent",new cE(a,b));const n=a.boxZoom=new cG(a,b);this._add("boxZoom",n);const e=new cJ,f=new c_;a.doubleClickZoom=new c$(f,e),this._add("tapZoom",e),this._add("clickZoom",f);const g=new c0;this._add("tapDragZoom",g);const o=a.touchPitch=new cV(a);this._add("touchPitch",o);const h=new cM(b),i=new cN(b);a.dragRotate=new c2(b,h,i),this._add("mouseRotate",h,["mousePitch"]),this._add("mousePitch",i,["mouseRotate"]);const j=new cL(b),k=new cO(a,b);a.dragPan=new c1(d,j,k),this._add("mousePan",j),this._add("touchPan",k,["touchZoom","touchRotate",]);const l=new cT,m=new cR;a.touchZoomRotate=new c3(d,m,l,g),this._add("touchRotate",l,["touchPan","touchZoom",]),this._add("touchZoom",m,["touchPan","touchRotate",]),this._add("blockableMapEvent",new cF(a));const p=a.scrollZoom=new cZ(a,this);this._add("scrollZoom",p,["mousePan"]);const q=a.keyboard=new cW;for(const c of(this._add("keyboard",q),["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard",]))b.interactive&&b[c]&&a[c].enable(b[c])}_add(a,b,c){this._handlers.push({handlerName:a,handler:b,allowed:c}),this._handlersById[a]=b}stop(a){if(!this._updatingCamera){for(const{handler:b}of this._handlers)b.reset();this._inertia.clear(),this._fireEvents({},{},a),this._changes=[]}}isActive(){for(const{handler:a}of this._handlers)if(a.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return Boolean(c4(this._eventsInProgress))||this.isZooming()}_blockedByActive(c,a,d){for(const b in c)if(b!==d&&(!a||0>a.indexOf(b)))return!0;return!1}handleWindowEvent(a){this.handleEvent(a,`${a.type}Window`)}_getMapTouches(c){const a=[];for(const b of c)this._el.contains(b.target)&&a.push(b);return a}handleEvent(a,j){this._updatingCamera=!0;const k="renderFrame"===a.type,l=k?void 0:a,d={needsRenderFrame:!1},m={},e={},g=a.touches?this._getMapTouches(a.touches):void 0,p=g?b.touchPos(this._el,g):k?void 0:b.mousePos(this._el,a);for(const{handlerName:h,handler:c,allowed:q}of this._handlers){if(!c.isEnabled())continue;let f;this._blockedByActive(e,q,h)?c.reset():c[j||a.type]&&(f=c[j||a.type](a,p,g),this.mergeHandlerResult(d,m,f,h,l),f&&f.needsRenderFrame&&this._triggerRenderFrame()),(f||c.isActive())&&(e[h]=c)}const i={};for(const n in this._previousActiveHandlers)e[n]||(i[n]=l);this._previousActiveHandlers=e,(Object.keys(i).length||c6(d))&&(this._changes.push([d,m,i]),this._triggerRenderFrame()),(Object.keys(e).length||c6(d))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:o}=d;o&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],o(this._map))}mergeHandlerResult(e,c,b,f,g){if(!b)return;a.extend(e,b);const d={handlerName:f,originalEvent:b.originalEvent||g};void 0!==b.zoomDelta&&(c.zoom=d),void 0!==b.panDelta&&(c.drag=d),void 0!==b.pitchDelta&&(c.pitch=d),void 0!==b.bearingDelta&&(c.rotate=d)}_applyChanges(){const c={},d={},e={};for(const[b,f,g]of this._changes)b.panDelta&&(c.panDelta=(c.panDelta||new a.pointGeometry(0,0))._add(b.panDelta)),b.zoomDelta&&(c.zoomDelta=(c.zoomDelta||0)+b.zoomDelta),b.bearingDelta&&(c.bearingDelta=(c.bearingDelta||0)+b.bearingDelta),b.pitchDelta&&(c.pitchDelta=(c.pitchDelta||0)+b.pitchDelta),void 0!==b.around&&(c.around=b.around),void 0!==b.aroundCoord&&(c.aroundCoord=b.aroundCoord),void 0!==b.pinchAround&&(c.pinchAround=b.pinchAround),b.noInertia&&(c.noInertia=b.noInertia),a.extend(d,f),a.extend(e,g);this._updateMapTransform(c,d,e),this._changes=[]}_updateMapTransform(d,f,k){const g=this._map,b=g.transform,l=a=>[a.x,a.y,a.z];if((b=>{const a=this._eventsInProgress.drag;return a&&!this._handlersById[a.handlerName].isActive()})()&&!c6(d)){const t=b.zoom;b.cameraElevationReference="sea",b.recenterOnTerrain(),b.cameraElevationReference="ground",t!==b.zoom&&this._map._update(!0)}if(!c6(d))return this._fireEvents(f,k,!0);let{panDelta:m,zoomDelta:h,bearingDelta:n,pitchDelta:o,around:c,aroundCoord:u,pinchAround:p}=d;void 0!==p&&(c=p),f.drag&&!this._eventsInProgress.drag&&c&&(this._dragOrigin=l(b.pointCoordinate3D(c)),this._trackingEllipsoid.setup(b._camera.position,this._dragOrigin)),b.cameraElevationReference="sea",g._stop(!0),c=c||g.transform.centerPoint,n&&(b.bearing+=n),o&&(b.pitch+=o),b._updateCameraState();const e=[0,0,0];if(m){const i=b.pointCoordinate(c),j=b.pointCoordinate(c.sub(m));i&&j&&(e[0]=j.x-i.x,e[1]=j.y-i.y)}const v=b.zoom,q=[0,0,0];if(h){const r=l(u||b.pointCoordinate3D(c)),s={dir:a.normalize([],a.sub([],r,b._camera.position))};if(s.dir[2]<0){const w=b.zoomDeltaToMovement(r,h);a.scale$2(q,s.dir,w)}}const x=a.add(e,e,q);b._translateCameraConstrained(x),h&&Math.abs(b.zoom-v)>1e-4&&b.recenterOnTerrain(),b.cameraElevationReference="ground",this._map._update(),d.noInertia||this._inertia.record(d),this._fireEvents(f,k,!0)}_fireEvents(b,p,q){const j=c4(this._eventsInProgress),c=c4(b),g={};for(const d in b){const{originalEvent:r}=b[d];this._eventsInProgress[d]||(g[`${d}start`]=r),this._eventsInProgress[d]=b[d]}for(const k in!j&&c&&this._fireEvent("movestart",c.originalEvent),g)this._fireEvent(k,g[k]);for(const l in c&&this._fireEvent("move",c.originalEvent),b){const{originalEvent:s}=b[l];this._fireEvent(l,s)}const h={};let e;for(const i in this._eventsInProgress){const{handlerName:m,originalEvent:t}=this._eventsInProgress[i];this._handlersById[m].isActive()||(delete this._eventsInProgress[i],e=p[m]||t,h[`${i}end`]=e)}for(const n in h)this._fireEvent(n,h[n]);const u=c4(this._eventsInProgress);if(q&&(j||c)&&!u){this._updatingCamera=!0;const f=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),o=a=>0!==a&& -this._bearingSnap{delete this._frameId,this.handleEvent(new c5("renderFrame",{timeStamp:a})),this._applyChanges()})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}(this,c),this._localFontFamily=c.localFontFamily,this._localIdeographFontFamily=c.localIdeographFontFamily,c.style&&this.setStyle(c.style,{localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),c.projection&&this.setProjection(c.projection),this._hash=c.hash&&new class{constructor(b){this._hashName=b&&encodeURIComponent(b),a.bindAll(["_getCurrentHash","_onHashChange","_updateHash",],this),this._updateHash=cu(this._updateHashUnthrottled.bind(this),300)}addTo(b){return this._map=b,a.window.addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return a.window.removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),delete this._map,this}getHashString(k){const f=this._map.getCenter(),d=Math.round(100*this._map.getZoom())/100,c=Math.pow(10,Math.ceil((d*Math.LN2+Math.log(512/360/.5))/Math.LN10)),g=Math.round(f.lng*c)/c,h=Math.round(f.lat*c)/c,i=this._map.getBearing(),e=this._map.getPitch();let b="";if(b+=k?`/${g}/${h}/${d}`:`${d}/${h}/${g}`,(i||e)&&(b+="/"+Math.round(10*i)/10),e&&(b+=`/${Math.round(e)}`),this._hashName){const l=this._hashName;let m=!1;const j=a.window.location.hash.slice(1).split("&").map(a=>{const c=a.split("=")[0];return c===l?(m=!0,`${c}=${b}`):a}).filter(a=>a);return m||j.push(`${l}=${b}`),`#${j.join("&")}`}return`#${b}`}_getCurrentHash(){const b=a.window.location.hash.replace("#","");if(this._hashName){let c;return b.split("&").map(a=>a.split("=")).forEach(a=>{a[0]===this._hashName&&(c=a)}),(c&&c[1]||"").split("/")}return b.split("/")}_onHashChange(){const a=this._getCurrentHash();if(a.length>=3&&!a.some(a=>isNaN(a))){const b=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(a[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+a[2],+a[1]],zoom:+a[0],bearing:b,pitch:+(a[4]||0)}),!0}return!1}_updateHashUnthrottled(){const b=a.window.location.href.replace(/(#.+)?$/,this.getHashString());a.window.history.replaceState(a.window.history.state,null,b)}}("string"==typeof c.hash&&c.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:c.center,zoom:c.zoom,bearing:c.bearing,pitch:c.pitch}),c.bounds&&(this.resize(),this.fitBounds(c.bounds,a.extend({},c.fitBoundsOptions,{duration:0})))),this.resize(),c.attributionControl&&this.addControl(new y({customAttribution:c.customAttribution})),this._logoControl=new c9,this.addControl(this._logoControl,c.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",b=>{this._update("style"===b.dataType),this.fire(new a.Event(`${b.dataType}data`,b))}),this.on("dataloading",b=>{this.fire(new a.Event(`${b.dataType}dataloading`,b))})}_getMapId(){return this._mapId}addControl(b,c){if(void 0===c&&(c=b.getDefaultPosition?b.getDefaultPosition():"top-right"),!b||!b.onAdd)return this.fire(new a.ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const e=b.onAdd(this);this._controls.push(b);const d=this._controlPositions[c];return -1!==c.indexOf("bottom")?d.insertBefore(e,d.firstChild):d.appendChild(e),this}removeControl(b){if(!b||!b.onRemove)return this.fire(new a.ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const c=this._controls.indexOf(b);return c> -1&&this._controls.splice(c,1),b.onRemove(this),this}hasControl(a){return this._controls.indexOf(a)> -1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(b){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 c=!this._moving;return c&&this.fire(new a.Event("movestart",b)).fire(new a.Event("move",b)),this.fire(new a.Event("resize",b)),c&&this.fire(new a.Event("moveend",b)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(b){return this.transform.setMaxBounds(a.LngLatBounds.convert(b)),this._update()}setMinZoom(b){if((b=null==b?-2:b)>= -2&&b<=this.transform.maxZoom)return this.transform.minZoom=b,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=b,this._update(),this.getZoom()>b?this.setZoom(b):this.fire(new a.Event("zoomstart")).fire(new a.Event("zoom")).fire(new a.Event("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(b){if((b=null==b?0:b)<0)throw new Error("minPitch must be greater than or equal to 0");if(b>=0&&b<=this.transform.maxPitch)return this.transform.minPitch=b,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(b>=this.transform.minPitch)return this.transform.maxPitch=b,this._update(),this.getPitch()>b?this.setPitch(b):this.fire(new a.Event("pitchstart")).fire(new a.Event("pitch")).fire(new a.Event("pitchend")),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(a){return this.transform.renderWorldCopies=a,this._update()}getProjection(){return this.transform.getProjection()}setProjection(a){return this._lazyInitEmptyStyle(),"string"==typeof a&&(a={name:a}),this._runtimeProjection=a,this.style.updateProjection(),this._transitionFromGlobe=!1,this}project(b){return this.transform.locationPoint3D(a.LngLat.convert(b))}unproject(b){return this.transform.pointLocation3D(a.pointGeometry.convert(b))}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()}_createDelegatedListener(a,b,c){if("mouseenter"===a||"mouseover"===a){let h=!1;const d=d=>{const e=b.filter(a=>this.getLayer(a)),f=e.length?this.queryRenderedFeatures(d.point,{layers:e}):[];f.length?h||(h=!0,c.call(this,new cB(a,this,d.originalEvent,{features:f}))):h=!1},e=()=>{h=!1};return{layers:new Set(b),listener:c,delegates:{mousemove:d,mouseout:e}}}if("mouseleave"===a||"mouseout"===a){let i=!1;const f=d=>{const e=b.filter(a=>this.getLayer(a));(e.length?this.queryRenderedFeatures(d.point,{layers:e}):[]).length?i=!0:i&&(i=!1,c.call(this,new cB(a,this,d.originalEvent)))},g=b=>{i&&(i=!1,c.call(this,new cB(a,this,b.originalEvent)))};return{layers:new Set(b),listener:c,delegates:{mousemove:f,mouseout:g}}}return{layers:new Set(b),listener:c,delegates:{[a]:a=>{const d=b.filter(a=>this.getLayer(a)),e=d.length?this.queryRenderedFeatures(a.point,{layers:d}):[];e.length&&(a.features=e,c.call(this,a),delete a.features)}}}}on(a,b,d){if(void 0===d)return super.on(a,b);Array.isArray(b)||(b=[b]);const c=this._createDelegatedListener(a,b,d);for(const e in this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[a]=this._delegatedListeners[a]||[],this._delegatedListeners[a].push(c),c.delegates)this.on(e,c.delegates[e]);return this}once(b,a,c){if(void 0===c)return super.once(b,a);Array.isArray(a)||(a=[a]);const d=this._createDelegatedListener(b,a,c);for(const e in d.delegates)this.once(e,d.delegates[e]);return this}off(b,a,d){if(void 0===d)return super.off(b,a);a=new Set(Array.isArray(a)?a:[a]);const e=(a,b)=>{if(a.size!==b.size)return!1;for(const c of a)if(!b.has(c))return!1;return!0},c=this._delegatedListeners?this._delegatedListeners[b]:void 0;return c&&(f=>{for(let b=0;b{b?this.fire(new a.ErrorEvent(b)):d&&this._updateDiff(d,c)})}else"object"==typeof b&&this._updateDiff(b,c)}_updateDiff(c,d){try{this.style.setState(c)&&this._update(!0)}catch(b){a.warnOnce(`Unable to perform style diff: ${b.message||b.error||b}. Rebuilding the style from scratch.`),this._updateStyle(c,d)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():a.warnOnce("There is no style added to the map.")}addSource(a,b){return this._lazyInitEmptyStyle(),this.style.addSource(a,b),this._update(!0)}isSourceLoaded(b){const c=this.style&&this.style._getSourceCaches(b);if(0!==c.length)return c.every(a=>a.loaded());this.fire(new a.ErrorEvent(new Error(`There is no source with ID '${b}'`)))}areTilesLoaded(){const a=this.style&&this.style._sourceCaches;for(const d in a){const b=a[d]._tiles;for(const e in b){const c=b[e];if("loaded"!==c.state&&"errored"!==c.state)return!1}}return!0}addSourceType(a,b,c){return this._lazyInitEmptyStyle(),this.style.addSourceType(a,b,c)}removeSource(a){return this.style.removeSource(a),this._updateTerrain(),this._update(!0)}getSource(a){return this.style.getSource(a)}addImage(c,b,{pixelRatio:e=1,sdf:f=!1,stretchX:g,stretchY:h,content:i}={}){if(this._lazyInitEmptyStyle(),b instanceof dd||df&&b instanceof df){const{width:j,height:k,data:l}=a.exported.getImageData(b);this.style.addImage(c,{data:new a.RGBAImage({width:j,height:k},l),pixelRatio:e,stretchX:g,stretchY:h,content:i,sdf:f,version:0})}else{if(void 0===b.width|| void 0===b.height)return this.fire(new a.ErrorEvent(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:m,height:n,data:o}=b,d=b;this.style.addImage(c,{data:new a.RGBAImage({width:m,height:n},new Uint8Array(o)),pixelRatio:e,stretchX:g,stretchY:h,content:i,sdf:f,version:0,userImage:d}),d.onAdd&&d.onAdd(this,c)}}}updateImage(d,b){const c=this.style.getImage(d);if(!c)return this.fire(new a.ErrorEvent(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const g=b instanceof dd||df&&b instanceof df?a.exported.getImageData(b):b,{width:e,height:f,data:h}=g;return void 0===e|| void 0===f?this.fire(new a.ErrorEvent(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`"))):e!==c.data.width||f!==c.data.height?this.fire(new a.ErrorEvent(new Error("The width and height of the updated image must be that same as the previous version of the image"))):(c.data.replace(h,!(b instanceof dd||df&&b instanceof df)),void this.style.updateImage(d,c))}hasImage(b){return b?!!this.style.getImage(b):(this.fire(new a.ErrorEvent(new Error("Missing required image id"))),!1)}removeImage(a){this.style.removeImage(a)}loadImage(b,c){a.getImage(this._requestManager.transformRequest(b,a.ResourceType.Image),(d,b)=>{c(d,b instanceof dd?a.exported.getImageData(b):b)})}listImages(){return this.style.listImages()}addLayer(a,b){return this._lazyInitEmptyStyle(),this.style.addLayer(a,b),this._update(!0)}moveLayer(a,b){return this.style.moveLayer(a,b),this._update(!0)}removeLayer(a){return this.style.removeLayer(a),this._update(!0)}getLayer(a){return this.style.getLayer(a)}setLayerZoomRange(a,b,c){return this.style.setLayerZoomRange(a,b,c),this._update(!0)}setFilter(a,b,c={}){return this.style.setFilter(a,b,c),this._update(!0)}getFilter(a){return this.style.getFilter(a)}setPaintProperty(a,b,c,d={}){return this.style.setPaintProperty(a,b,c,d),this._update(!0)}getPaintProperty(a,b){return this.style.getPaintProperty(a,b)}setLayoutProperty(a,b,c,d={}){return this.style.setLayoutProperty(a,b,c,d),this._update(!0)}getLayoutProperty(a,b){return this.style.getLayoutProperty(a,b)}setLight(a,b={}){return this._lazyInitEmptyStyle(),this.style.setLight(a,b),this._update(!0)}getLight(){return this.style.getLight()}setTerrain(a){return this._lazyInitEmptyStyle(),!a&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(a),this._averageElevationLastSampledAt=-1/0,this._update(!0)}_updateProjection(){"globe"===this.transform.projection.name&&this.transform.zoom>=a.GLOBE_ZOOM_THRESHOLD_MAX&&!this._transitionFromGlobe&&(this.setProjection({name:"mercator"}),this._transitionFromGlobe=!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(a){return this._lazyInitEmptyStyle(),this.style.setFog(a),this._update(!0)}getFog(){return this.style?this.style.getFog():null}_queryFogOpacity(b){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(a.LngLat.convert(b),this.transform):0}setFeatureState(a,b){return this.style.setFeatureState(a,b),this._update()}removeFeatureState(a,b){return this.style.removeFeatureState(a,b),this._update()}getFeatureState(a){return this.style.getFeatureState(a)}_updateContainerDimensions(){if(!this._container)return;const d=this._container.getBoundingClientRect().width||400,e=this._container.getBoundingClientRect().height||300;let b,c=this._container;for(;c&&!b;){const f=a.window.getComputedStyle(c).transform;f&&"none"!==f&&(b=f.match(/matrix.*\((.+)\)/)[1].split(", ")),c=c.parentElement}b?(this._containerWidth=b[0]&&"0"!==b[0]?Math.abs(d/b[0]):d,this._containerHeight=b[3]&&"0"!==b[3]?Math.abs(e/b[3]):e):(this._containerWidth=d,this._containerHeight=e)}_detectMissingCSS(){"rgb(250, 128, 114)"!==a.window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&a.warnOnce("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 a=this._container;a.classList.add("mapboxgl-map"),(this._missingCSSCanary=b.create("div","mapboxgl-canary",a)).style.visibility="hidden",this._detectMissingCSS();const c=this._canvasContainer=b.create("div","mapboxgl-canvas-container",a);this._interactive&&c.classList.add("mapboxgl-interactive"),this._canvas=b.create("canvas","mapboxgl-canvas",c),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex","0"),this._canvas.setAttribute("aria-label","Map"),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const d=this._controlContainer=b.create("div","mapboxgl-control-container",a),e=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right",].forEach(a=>{e[a]=b.create("div",`mapboxgl-ctrl-${a}`,d)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(b,c){const d=a.exported.devicePixelRatio||1;this._canvas.width=d*Math.ceil(b),this._canvas.height=d*Math.ceil(c),this._canvas.style.width=`${b}px`,this._canvas.style.height=`${c}px`}_addMarker(a){this._markers.push(a)}_removeMarker(b){const a=this._markers.indexOf(b);-1!==a&&this._markers.splice(a,1)}_setupPainter(){const c=a.extend({},l.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),b=this._canvas.getContext("webgl",c)||this._canvas.getContext("experimental-webgl",c);b?(a.storeAuthState(b,!0),this.painter=new cg(b,this.transform),this.on("data",a=>{"source"===a.dataType&&this.painter.setTileLoadedFlag(!0)}),a.exported$1.testSupport(b)):this.fire(new a.ErrorEvent(new Error("Failed to initialize WebGL")))}_contextLost(b){b.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new a.Event("webglcontextlost",{originalEvent:b}))}_contextRestored(b){this._setupPainter(),this.resize(),this._update(),this.fire(new a.Event("webglcontextrestored",{originalEvent:b}))}_onMapScroll(a){if(a.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(a){return this.style&&(this._styleDirty=this._styleDirty||a,this._sourcesDirty=!0,this.triggerRepaint()),this}_requestRenderFrame(a){return this._update(),this._renderTaskQueue.add(a)}_cancelRenderFrame(a){this._renderTaskQueue.remove(a)}_requestDomTask(a){!this.loaded()||this.loaded()&&!this.isMoving()?a():this._domRenderTaskQueue.add(a)}_render(h){let c;const b=this.painter.context.extTimerQuery,d=a.exported.now();this.listens("gpu-timing-frame")&&(c=b.createQueryEXT(),b.beginQueryEXT(b.TIME_ELAPSED_EXT,c));let e=this._updateAverageElevation(d);if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(h),this._domRenderTaskQueue.run(h),this._removed)return;this._updateProjection();let i=!1;const f=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const j=this.transform.zoom,o=this.transform.pitch,k=a.exported.now();this.style.zoomHistory.update(j,k);const l=new a.EvaluationParameters(j,{now:k,fadeDuration:f,pitch:o,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),g=l.crossFadingFactor();1===g&&g===this._crossFadingFactor||(i=!0,this._crossFadingFactor=g),this.style.update(l)}if(this.style&&this.style.fog&&this.style.fog.hasTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0),this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),this.style._updateSources(this.transform),this._forceMarkerUpdate()),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,f,this._crossSourceCollisions),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showTerrainWireframe:this.showTerrainWireframe,showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:f,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),speedIndexTiming:this.speedIndexTiming}),this.fire(new a.Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new a.Event("load"))),this.style&&(this.style.hasTransitions()||i)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),this.listens("gpu-timing-frame")){const q=a.exported.now()-d;b.endQueryEXT(b.TIME_ELAPSED_EXT,c),setTimeout(()=>{const d=b.getQueryObjectEXT(c,b.QUERY_RESULT_EXT)/1e6;b.deleteQueryEXT(c),this.fire(new a.Event("gpu-timing-frame",{cpuTime:q,gpuTime:d}))},50)}if(this.listens("gpu-timing-layer")){const r=this.painter.collectGpuTimers();setTimeout(()=>{const b=this.painter.queryGpuTimers(r);this.fire(new a.Event("gpu-timing-layer",{layerTimes:b}))},50)}const m=this._sourcesDirty||this._styleDirty||this._placementDirty||e;if(m||this._repaint)this.triggerRepaint();else{const n=!this.isMoving()&&this.loaded();if(n&&(e=this._updateAverageElevation(d,!0)),e)this.triggerRepaint();else if(this._triggerFrame(!1),n&&(this.fire(new a.Event("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const p=this._calculateSpeedIndex();this.fire(new a.Event("speedindexcompleted",{speedIndex:p})),this.speedIndexTiming=!1}}return!this._loaded||this._fullyLoaded||m||(this._fullyLoaded=!0,this._authenticate()),this}_forceMarkerUpdate(){for(const a of this._markers)a._update()}_updateAverageElevation(b,e=!1){const c=a=>(this.transform.averageElevation=a,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&c(0);if((e||b-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(b)){const f=this.transform.averageElevation;let a=this.transform.sampleAverageElevation();isNaN(a)?a=0:this._averageElevationLastSampledAt=b;const d=Math.abs(f-a);if(d>1){if(this._isInitialLoad)return this._averageElevation.jumpTo(a),c(a);this._averageElevation.easeTo(a,b,300)}else if(d>1e-4)return this._averageElevation.jumpTo(a),c(a)}return!!this._averageElevation.isEasing(b)&&c(this._averageElevation.getValue(b))}_authenticate(){a.getMapSessionAPI(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,c=>{if(c&&(c.message===a.AUTH_ERR_MSG||401===c.status)){const b=this.painter.context.gl;a.storeAuthState(b,!1),this._logoControl instanceof c9&&this._logoControl._updateLogo(),b&&b.clear(b.DEPTH_BUFFER_BIT|b.COLOR_BUFFER_BIT|b.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new a.ErrorEvent(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/")))}}),a.postMapLoadEvent(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_updateTerrain(){this.painter.updateTerrain(this.style,this.isMoving()||this.isRotating()||this.isZooming())}_calculateSpeedIndex(){const d=this.painter.canvasCopy(),a=this.painter.getCanvasCopiesAndTimestamps();a.timeStamps.push(performance.now());const b=this.painter.context.gl,e=b.createFramebuffer();function c(c){b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,c,0);const a=new Uint8Array(b.drawingBufferWidth*b.drawingBufferHeight*4);return b.readPixels(0,0,b.drawingBufferWidth,b.drawingBufferHeight,b.RGBA,b.UNSIGNED_BYTE,a),a}return b.bindFramebuffer(b.FRAMEBUFFER,e),this._canvasPixelComparison(c(d),a.canvasCopies.map(c),a.timeStamps)}_canvasPixelComparison(b,f,e){let g=e[1]-e[0];const i=b.length/4;for(let c=0;c{const b=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,b&&this._render(a)}))}_preloadTiles(c){const b=this.style&&Object.values(this.style._sourceCaches)||[];return a.asyncAll(b,(a,b)=>a._preloadTiles(c,b),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(a){this._trackResize&&this.resize({originalEvent:a})._update()}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(a){this._showTileBoundaries!==a&&(this._showTileBoundaries=a,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(a){this._showTerrainWireframe!==a&&(this._showTerrainWireframe=a,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(a){this._speedIndexTiming!==a&&(this._speedIndexTiming=a,this._update())}get showPadding(){return!!this._showPadding}set showPadding(a){this._showPadding!==a&&(this._showPadding=a,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(a){this._showCollisionBoxes!==a&&(this._showCollisionBoxes=a,a?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(a){this._showOverdrawInspector!==a&&(this._showOverdrawInspector=a,this._update())}get repaint(){return!!this._repaint}set repaint(a){this._repaint!==a&&(this._repaint=a,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(a){this._vertices=a,this._update()}_setCacheLimits(b,c){a.setCacheLimits(b,c)}get version(){return a.version}},NavigationControl:class{constructor(c){this.options=a.extend({},{showCompass:!0,showZoom:!0,visualizePitch:!1},c),this._container=b.create("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",a=>a.preventDefault()),this.options.showZoom&&(a.bindAll(["_setButtonTitle","_updateZoomButtons",],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",a=>this._map.zoomIn({},{originalEvent:a})),b.create("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden",!0),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",a=>this._map.zoomOut({},{originalEvent:a})),b.create("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden",!0)),this.options.showCompass&&(a.bindAll(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",a=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:a}):this._map.resetNorth({},{originalEvent:a})}),this._compassIcon=b.create("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden",!0))}_updateZoomButtons(){const a=this._map.getZoom(),b=a===this._map.getMaxZoom(),c=a===this._map.getMinZoom();this._zoomInButton.disabled=b,this._zoomOutButton.disabled=c,this._zoomInButton.setAttribute("aria-disabled",b.toString()),this._zoomOutButton.setAttribute("aria-disabled",c.toString())}_rotateCompassArrow(){const a=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitch*(Math.PI/180)),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${this._map.transform.angle*(180/Math.PI)}deg)`:`rotate(${this._map.transform.angle*(180/Math.PI)}deg)`;this._map._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=a)})}onAdd(a){return this._map=a,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new dh(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){this._container.remove(),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(c,d){const a=b.create("button",c,this._container);return a.type="button",a.addEventListener("click",d),a}_setButtonTitle(a,c){const b=this._map._getUIString(`NavigationControl.${c}`);a.setAttribute("aria-label",b),a.firstElementChild&&a.firstElementChild.setAttribute("title",b)}},GeolocateControl:class extends a.Evented{constructor(b){super(),this.options=a.extend({},{positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,showUserHeading:!1},b),a.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation",],this),this._onDeviceOrientationListener=this._onDeviceOrientation.bind(this),this._updateMarkerRotationThrottled=cu(this._updateMarkerRotation,20)}onAdd(d){var c;return this._map=d,this._container=b.create("div","mapboxgl-ctrl mapboxgl-ctrl-group"),c=this._setupUI,void 0!==di?c(di):void 0!==a.window.navigator.permissions?a.window.navigator.permissions.query({name:"geolocation"}).then(a=>{c(di="denied"!==a.state)}):c(di=!!a.window.navigator.geolocation),this._container}onRemove(){void 0!==this._geolocationWatchID&&(a.window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,dj=0,dk=!1}_isOutOfMapMaxBounds(c){const a=this._map.getMaxBounds(),b=c.coords;return a&&(b.longitudea.getEast()||b.latitudea.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(b){if(this._map){if(this._isOutOfMapMaxBounds(b))return this._setErrorState(),this.fire(new a.Event("outofmaxbounds",b)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=b,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(b),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(b),this.options.showUserLocation&&this._dotElement.classList.remove("mapboxgl-user-location-dot-stale"),this.fire(new a.Event("geolocate",b)),this._finish()}}_updateCamera(b){const c=new a.LngLat(b.coords.longitude,b.coords.latitude),d=b.coords.accuracy,e=this._map.getBearing(),f=a.extend({bearing:e},this.options.fitBoundsOptions);this._map.fitBounds(c.toBounds(d),f,{geolocateSource:!0})}_updateMarker(b){if(b){const c=new a.LngLat(b.coords.longitude,b.coords.latitude);this._accuracyCircleMarker.setLngLat(c).addTo(this._map),this._userLocationDotMarker.setLngLat(c).addTo(this._map),this._accuracy=b.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const a=this._map._containerHeight/2,c=this._map.unproject([0,a]),d=this._map.unproject([100,a]),e=c.distanceTo(d)/100,b=Math.ceil(2*this._accuracy/e);this._circleElement.style.width=`${b}px`,this._circleElement.style.height=`${b}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&"number"==typeof this._heading?(this._userLocationDotMarker.setRotation(this._heading),this._dotElement.classList.add("mapboxgl-user-location-show-heading")):(this._dotElement.classList.remove("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0))}_onError(b){if(this._map){if(this.options.trackUserLocation){if(1===b.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 c=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",c),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",c),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===b.code&&dk)return;this._setErrorState()}}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("mapboxgl-user-location-dot-stale"),this.fire(new a.Event("error",b)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(e){if(this._container.addEventListener("contextmenu",a=>a.preventDefault()),this._geolocateButton=b.create("button","mapboxgl-ctrl-geolocate",this._container),b.create("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden",!0),this._geolocateButton.type="button",!1===e){a.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");const c=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",c),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",c)}else{const d=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",d),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",d)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=b.create("div","mapboxgl-user-location"),this._dotElement.appendChild(b.create("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(b.create("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new z({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=b.create("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new z({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",b=>{b.geolocateSource||"ACTIVE_LOCK"!==this._watchState||b.originalEvent&&"resize"===b.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new a.Event("trackuserlocationend")))})}_onDeviceOrientation(a){this._userLocationDotMarker&&(a.webkitCompassHeading?this._heading=a.webkitCompassHeading:!0===a.absolute&&(this._heading=-1*a.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return a.warnOnce("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 a.Event("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":dj--,dk=!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 a.Event("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 a.Event("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 b;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),++dj>1?(b={maximumAge:6e5,timeout:0},dk=!0):(b=this.options.positionOptions,dk=!1),this._geolocationWatchID=a.window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,b),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else a.window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const b=()=>{a.window.addEventListener("ondeviceorientationabsolute"in a.window?"deviceorientationabsolute":"deviceorientation",this._onDeviceOrientationListener)};void 0!==a.window.DeviceMotionEvent&&"function"==typeof a.window.DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then(a=>{"granted"===a&&b()}).catch(console.error):b()}_clearWatch(){a.window.navigator.geolocation.clearWatch(this._geolocationWatchID),a.window.removeEventListener("deviceorientation",this._onDeviceOrientationListener),a.window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientationListener),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:y,ScaleControl:class{constructor(b){this.options=a.extend({},{maxWidth:100,unit:"metric"},b),a.bindAll(["_onMove","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_onMove(){dl(this._map,this._container,this.options)}onAdd(a){return this._map=a,this._container=b.create("div","mapboxgl-ctrl mapboxgl-ctrl-scale",a.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._onMove),this._map=void 0}setUnit(a){this.options.unit=a,dl(this._map,this._container,this.options)}},FullscreenControl:class{constructor(b){this._fullscreen=!1,b&&b.container&&(b.container instanceof a.window.HTMLElement?this._container=b.container:a.warnOnce("Full screen control 'container' must be a DOM element.")),a.bindAll(["_onClickFullscreen","_changeIcon",],this),"onfullscreenchange"in a.window.document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in a.window.document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(c){return this._map=c,this._container||(this._container=this._map.getContainer()),this._controlContainer=b.create("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",a.warnOnce("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,a.window.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!a.window.document.fullscreenEnabled&&!a.window.document.webkitFullscreenEnabled)}_setupUI(){const c=this._fullscreenButton=b.create("button","mapboxgl-ctrl-fullscreen",this._controlContainer);b.create("span","mapboxgl-ctrl-icon",c).setAttribute("aria-hidden",!0),c.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),a.window.document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const a=this._getTitle();this._fullscreenButton.setAttribute("aria-label",a),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",a)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(a.window.document.fullscreenElement||a.window.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()?a.window.document.exitFullscreen?a.window.document.exitFullscreen():a.window.document.webkitCancelFullScreen&&a.window.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class extends a.Evented{constructor(b){super(),this.options=a.extend(Object.create({closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"}),b),a.bindAll(["_update","_onClose","remove","_onMouseMove","_onMouseUp","_onDrag",],this),this._classList=new Set(b&&b.className?b.className.trim().split(/\s+/):[])}addTo(b){return this._map&&this.remove(),this._map=b,this.options.closeOnClick&&this._map.on("preclick",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._map._canvasContainer.classList.add("mapboxgl-track-pointer")):this._map.on("move",this._update),this.fire(new a.Event("open")),this}isOpen(){return!!this._map}remove(){return this._content&&this._content.remove(),this._container&&(this._container.remove(),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),delete this._map),this.fire(new a.Event("close")),this}getLngLat(){return this._lngLat}setLngLat(b){return this._lngLat=a.LngLat.convert(b),this._pos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._map._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._map._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(b){return this.setDOMContent(a.window.document.createTextNode(b))}setHTML(e){const b=a.window.document.createDocumentFragment(),c=a.window.document.createElement("body");let d;for(c.innerHTML=e;d=c.firstChild;)b.appendChild(d);return this.setDOMContent(b)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(a){return this.options.maxWidth=a,this._update(),this}setDOMContent(a){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=b.create("div","mapboxgl-popup-content",this._container);return this._content.appendChild(a),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(a){return this._classList.add(a),this._container&&this._updateClassList(),this}removeClassName(a){return this._classList.delete(a),this._container&&this._updateClassList(),this}setOffset(a){return this.options.offset=a,this._update(),this}toggleClassName(b){let a;return this._classList.delete(b)?a=!1:(this._classList.add(b),a=!0),this._container&&this._updateClassList(),a}_createCloseButton(){this.options.closeButton&&(this._closeButton=b.create("button","mapboxgl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.setAttribute("aria-label","Close popup"),this._closeButton.setAttribute("aria-hidden","true"),this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_onMouseUp(a){this._update(a.point)}_onMouseMove(a){this._update(a.point)}_onDrag(a){this._update(a.point)}_getAnchor(e){if(this.options.anchor)return this.options.anchor;const b=this._pos,c=this._container.offsetWidth,d=this._container.offsetHeight;let a;return a=b.y+e.bottom.ythis._map.transform.height-d?["bottom"]:[],b.xthis._map.transform.width-c/2&&a.push("right"),0===a.length?"bottom":a.join("-")}_updateClassList(){const a=[...this._classList];a.push("mapboxgl-popup"),this._anchor&&a.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&a.push("mapboxgl-popup-track-pointer"),this._container.className=a.join(" ")}_update(c){if(this._map&&(this._lngLat||this._trackPointer)&&this._content){if(this._container||(this._container=b.create("div","mapboxgl-popup",this._map.getContainer()),this._tip=b.create("div","mapboxgl-popup-tip",this._container),this._container.appendChild(this._content)),this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._map.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=db(this._lngLat,this._pos,this._map.transform)),!this._trackPointer||c){const e=this._pos=this._trackPointer&&c?c:this._map.project(this._lngLat),d=function(b){if(b||(b=new a.pointGeometry(0,0)),"number"==typeof b){const d=Math.round(Math.sqrt(.5*Math.pow(b,2)));return{center:new a.pointGeometry(0,0),top:new a.pointGeometry(0,b),"top-left":new a.pointGeometry(d,d),"top-right":new a.pointGeometry(-d,d),bottom:new a.pointGeometry(0,-b),"bottom-left":new a.pointGeometry(d,-d),"bottom-right":new a.pointGeometry(-d,-d),left:new a.pointGeometry(b,0),right:new a.pointGeometry(-b,0)}}if(b instanceof a.pointGeometry||Array.isArray(b)){const c=a.pointGeometry.convert(b);return{center:c,top:c,"top-left":c,"top-right":c,bottom:c,"bottom-left":c,"bottom-right":c,left:c,right:c}}return{center:a.pointGeometry.convert(b.center||[0,0,]),top:a.pointGeometry.convert(b.top||[0,0]),"top-left":a.pointGeometry.convert(b["top-left"]||[0,0]),"top-right":a.pointGeometry.convert(b["top-right"]||[0,0]),bottom:a.pointGeometry.convert(b.bottom||[0,0,]),"bottom-left":a.pointGeometry.convert(b["bottom-left"]||[0,0]),"bottom-right":a.pointGeometry.convert(b["bottom-right"]||[0,0]),left:a.pointGeometry.convert(b.left||[0,0]),right:a.pointGeometry.convert(b.right||[0,0,])}}(this.options.offset),f=this._anchor=this._getAnchor(d),g=e.add(d[f]).round();this._map._requestDomTask(()=>{this._container&&f&&(this._container.style.transform=`${dc[f]} translate(${g.x}px,${g.y}px)`)})}this._updateClassList()}}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const a=this._container.querySelector("a[href], [tabindex]:not([tabindex='-1']), [contenteditable]:not([contenteditable='false']), button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])");a&&a.focus()}_onClose(){this.remove()}_setOpacity(a){this._content&&(this._content.style.opacity=a),this._tip&&(this._tip.style.opacity=a)}},Marker:z,Style:c,LngLat:a.LngLat,LngLatBounds:a.LngLatBounds,Point:a.pointGeometry,MercatorCoordinate:a.MercatorCoordinate,FreeCameraOptions:x,Evented:a.Evented,config:a.config,prewarm:function(){ao().acquire(am)},clearPrewarmedResources:function(){const a=an;a&&(a.isPreloaded()&&1===a.numActive()?(a.release(am),an=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 a.config.ACCESS_TOKEN},set accessToken(t){a.config.ACCESS_TOKEN=t},get baseApiUrl(){return a.config.API_URL},set baseApiUrl(t){a.config.API_URL=t},get workerCount(){return e.workerCount},set workerCount(e){e.workerCount=e},get maxParallelImageRequests(){return a.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(t){a.config.MAX_PARALLEL_IMAGE_REQUESTS=t},clearStorage(b){a.clearTileCache(b)},workerUrl:"",workerClass:null,setNow:a.exported.setNow,restoreNow:a.exported.restoreNow};return A}),b})}},]) diff --git a/crates/swc_ecma_minifier/tests/full/feedback-mapbox/785-e1932cc99ac3bb67/output.js b/crates/swc_ecma_minifier/tests/full/feedback-mapbox/785-e1932cc99ac3bb67/output.js index 41108e96e676..dddbc6cb95f5 100644 --- a/crates/swc_ecma_minifier/tests/full/feedback-mapbox/785-e1932cc99ac3bb67/output.js +++ b/crates/swc_ecma_minifier/tests/full/feedback-mapbox/785-e1932cc99ac3bb67/output.js @@ -1 +1 @@ -(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[785],{840:function(a,b,c){var d;!function(g,B,Q,l){"use strict";var m,R=["","webkit","Moz","MS","ms","o"],C=B.createElement("div"),S=Math.round,T=Math.abs,U=Date.now;function V(a,b,c){return setTimeout(G(a,c),b)}function W(a,c,b){return!!Array.isArray(a)&&(D(a,b[c],b),!0)}function D(a,c,d){var b;if(a){if(a.forEach)a.forEach(c,d);else if(l!==a.length)for(b=0;b\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",b=g.console&&(g.console.warn||g.console.log);return b&&b.call(g.console,d,e),c.apply(this,arguments)}}m="function"!=typeof Object.assign?function(b){if(b===l||null===b)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(b),c=1;c -1}function _(a){return a.trim().split(/\s+/g)}function aa(a,d,c){if(a.indexOf&&!c)return a.indexOf(d);for(var b=0;baa(e,f)&&b.push(c[a]),e[a]=f,a++}return g&&(b=d?b.sort(function(a,b){return a[d]>b[d]}):b.sort()),b}function n(e,a){for(var c,d,f=a[0].toUpperCase()+a.slice(1),b=0;b1&&!b.firstMultiple?b.firstMultiple=an(a):1===h&&(b.firstMultiple=!1);var i=b.firstInput,c=b.firstMultiple,j=c?c.center:i.center,k=a.center=ao(e);a.timeStamp=U(),a.deltaTime=a.timeStamp-i.timeStamp,a.angle=as(j,k),a.distance=ar(j,k),al(b,a),a.offsetDirection=aq(a.deltaX,a.deltaY);var d=ap(a.deltaTime,a.deltaX,a.deltaY);a.overallVelocityX=d.x,a.overallVelocityY=d.y,a.overallVelocity=T(d.x)>T(d.y)?d.x:d.y,a.scale=c?au(c.pointers,e):1,a.rotation=c?at(c.pointers,e):0,a.maxPointers=b.prevInput?a.pointers.length>b.prevInput.maxPointers?a.pointers.length:b.prevInput.maxPointers:a.pointers.length,am(b,a);var f=g.element;Z(a.srcEvent.target,f)&&(f=a.srcEvent.target),a.target=f}function al(a,b){var c=b.center,d=a.offsetDelta||{},e=a.prevDelta||{},f=a.prevInput||{};(1===b.eventType||4===f.eventType)&&(e=a.prevDelta={x:f.deltaX||0,y:f.deltaY||0},d=a.offsetDelta={x:c.x,y:c.y}),b.deltaX=e.x+(c.x-d.x),b.deltaY=e.y+(c.y-d.y)}function am(h,a){var d,e,f,g,b=h.lastInterval||a,i=a.timeStamp-b.timeStamp;if(8!=a.eventType&&(i>25||l===b.velocity)){var j=a.deltaX-b.deltaX,k=a.deltaY-b.deltaY,c=ap(i,j,k);e=c.x,f=c.y,d=T(c.x)>T(c.y)?c.x:c.y,g=aq(j,k),h.lastInterval=a}else d=b.velocity,e=b.velocityX,f=b.velocityY,g=b.direction;a.velocity=d,a.velocityX=e,a.velocityY=f,a.direction=g}function an(a){for(var c=[],b=0;b=T(b)?a<0?2:4:b<0?8:16}function ar(b,c,a){a||(a=ah);var d=c[a[0]]-b[a[0]],e=c[a[1]]-b[a[1]];return Math.sqrt(d*d+e*e)}function as(b,c,a){a||(a=ah);var d=c[a[0]]-b[a[0]],e=c[a[1]]-b[a[1]];return 180*Math.atan2(e,d)/Math.PI}function at(a,b){return as(b[1],b[0],ai)+as(a[1],a[0],ai)}function au(a,b){return ar(b[0],b[1],ai)/ar(a[0],a[1],ai)}f.prototype={handler:function(){},init:function(){this.evEl&&H(this.element,this.evEl,this.domHandler),this.evTarget&&H(this.target,this.evTarget,this.domHandler),this.evWin&&H(ae(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&I(this.element,this.evEl,this.domHandler),this.evTarget&&I(this.target,this.evTarget,this.domHandler),this.evWin&&I(ae(this.element),this.evWin,this.domHandler)}};var av={mousedown:1,mousemove:2,mouseup:4};function u(){this.evEl="mousedown",this.evWin="mousemove mouseup",this.pressed=!1,f.apply(this,arguments)}e(u,f,{handler:function(a){var b=av[a.type];1&b&&0===a.button&&(this.pressed=!0),2&b&&1!==a.which&&(b=4),this.pressed&&(4&b&&(this.pressed=!1),this.callback(this.manager,b,{pointers:[a],changedPointers:[a],pointerType:L,srcEvent:a}))}});var aw={pointerdown:1,pointermove:2,pointerup:4,pointercancel:8,pointerout:8},ax={2:K,3:"pen",4:L,5:"kinect"},M="pointerdown",N="pointermove pointerup pointercancel";function v(){this.evEl=M,this.evWin=N,f.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}g.MSPointerEvent&&!g.PointerEvent&&(M="MSPointerDown",N="MSPointerMove MSPointerUp MSPointerCancel"),e(v,f,{handler:function(a){var b=this.store,e=!1,d=aw[a.type.toLowerCase().replace("ms","")],f=ax[a.pointerType]||a.pointerType,c=aa(b,a.pointerId,"pointerId");1&d&&(0===a.button||f==K)?c<0&&(b.push(a),c=b.length-1):12&d&&(e=!0),!(c<0)&&(b[c]=a,this.callback(this.manager,d,{pointers:b,changedPointers:[a],pointerType:f,srcEvent:a}),e&&b.splice(c,1))}});var ay={touchstart:1,touchmove:2,touchend:4,touchcancel:8};function w(){this.evTarget="touchstart",this.evWin="touchstart touchmove touchend touchcancel",this.started=!1,f.apply(this,arguments)}function az(b,d){var a=ab(b.touches),c=ab(b.changedTouches);return 12&d&&(a=ac(a.concat(c),"identifier",!0)),[a,c]}e(w,f,{handler:function(c){var a=ay[c.type];if(1===a&&(this.started=!0),this.started){var b=az.call(this,c,a);12&a&&b[0].length-b[1].length==0&&(this.started=!1),this.callback(this.manager,a,{pointers:b[0],changedPointers:b[1],pointerType:K,srcEvent:c})}}});var aA={touchstart:1,touchmove:2,touchend:4,touchcancel:8};function x(){this.evTarget="touchstart touchmove touchend touchcancel",this.targetIds={},f.apply(this,arguments)}function aB(h,g){var b=ab(h.touches),c=this.targetIds;if(3&g&&1===b.length)return c[b[0].identifier]=!0,[b,b];var a,d,e=ab(h.changedTouches),f=[],i=this.target;if(d=b.filter(function(a){return Z(a.target,i)}),1===g)for(a=0;a -1&&d.splice(a,1)},2500)}}function aE(b){for(var d=b.srcEvent.clientX,e=b.srcEvent.clientY,a=0;a -1&&this.requireFail.splice(b,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(a){return!!this.simultaneous[a.id]},emit:function(d){var c=this,a=this.state;function b(a){c.manager.emit(a,d)}a<8&&b(c.options.event+aM(a)),b(c.options.event),d.additionalEvent&&b(d.additionalEvent),a>=8&&b(c.options.event+aM(a))},tryEmit:function(a){if(this.canEmit())return this.emit(a);this.state=32},canEmit:function(){for(var a=0;ac.threshold&&b&c.direction},attrTest:function(a){return h.prototype.attrTest.call(this,a)&&(2&this.state|| !(2&this.state)&&this.directionTest(a))},emit:function(a){this.pX=a.deltaX,this.pY=a.deltaY;var b=aN(a.direction);b&&(a.additionalEvent=this.options.event+b),this._super.emit.call(this,a)}}),e(p,h,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[aI]},attrTest:function(a){return this._super.attrTest.call(this,a)&&(Math.abs(a.scale-1)>this.options.threshold||2&this.state)},emit:function(a){if(1!==a.scale){var b=a.scale<1?"in":"out";a.additionalEvent=this.options.event+b}this._super.emit.call(this,a)}}),e(q,i,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[aG]},process:function(a){var b=this.options,c=a.pointers.length===b.pointers,d=a.distanceb.time;if(this._input=a,d&&c&&(!(12&a.eventType)||e)){if(1&a.eventType)this.reset(),this._timer=V(function(){this.state=8,this.tryEmit()},b.time,this);else if(4&a.eventType)return 8}else this.reset();return 32},reset:function(){clearTimeout(this._timer)},emit:function(a){8===this.state&&(a&&4&a.eventType?this.manager.emit(this.options.event+"up",a):(this._input.timeStamp=U(),this.manager.emit(this.options.event,this._input)))}}),e(r,h,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[aI]},attrTest:function(a){return this._super.attrTest.call(this,a)&&(Math.abs(a.rotation)>this.options.threshold||2&this.state)}}),e(s,h,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:30,pointers:1},getTouchAction:function(){return o.prototype.getTouchAction.call(this)},attrTest:function(a){var b,c=this.options.direction;return 30&c?b=a.overallVelocity:6&c?b=a.overallVelocityX:24&c&&(b=a.overallVelocityY),this._super.attrTest.call(this,a)&&c&a.offsetDirection&&a.distance>this.options.threshold&&a.maxPointers==this.options.pointers&&T(b)>this.options.velocity&&4&a.eventType},emit:function(a){var b=aN(a.offsetDirection);b&&this.manager.emit(this.options.event+b,a),this.manager.emit(this.options.event,a)}}),e(j,i,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[aH]},process:function(a){var b=this.options,c=a.pointers.length===b.pointers,d=a.distance1)for(var a=1;ac.length)&&(a=c.length);for(var b=0,d=new Array(a);bc?c:a}Math.hypot||(Math.hypot=function(){for(var b=0,a=arguments.length;a--;)b+=arguments[a]*arguments[a];return Math.sqrt(b)}),bd=new h(4),h!=Float32Array&&(bd[0]=0,bd[1]=0,bd[2]=0,bd[3]=0);const aG=Math.log2||function(a){return Math.log(a)*Math.LOG2E};function aH(e,f,g){var h=f[0],i=f[1],j=f[2],k=f[3],l=f[4],m=f[5],n=f[6],o=f[7],p=f[8],q=f[9],r=f[10],s=f[11],t=f[12],u=f[13],v=f[14],w=f[15],a=g[0],b=g[1],c=g[2],d=g[3];return e[0]=a*h+b*l+c*p+d*t,e[1]=a*i+b*m+c*q+d*u,e[2]=a*j+b*n+c*r+d*v,e[3]=a*k+b*o+c*s+d*w,a=g[4],b=g[5],c=g[6],d=g[7],e[4]=a*h+b*l+c*p+d*t,e[5]=a*i+b*m+c*q+d*u,e[6]=a*j+b*n+c*r+d*v,e[7]=a*k+b*o+c*s+d*w,a=g[8],b=g[9],c=g[10],d=g[11],e[8]=a*h+b*l+c*p+d*t,e[9]=a*i+b*m+c*q+d*u,e[10]=a*j+b*n+c*r+d*v,e[11]=a*k+b*o+c*s+d*w,a=g[12],b=g[13],c=g[14],d=g[15],e[12]=a*h+b*l+c*p+d*t,e[13]=a*i+b*m+c*q+d*u,e[14]=a*j+b*n+c*r+d*v,e[15]=a*k+b*o+c*s+d*w,e}function aI(b,a,f){var g,h,i,j,k,l,m,n,o,p,q,r,c=f[0],d=f[1],e=f[2];return a===b?(b[12]=a[0]*c+a[4]*d+a[8]*e+a[12],b[13]=a[1]*c+a[5]*d+a[9]*e+a[13],b[14]=a[2]*c+a[6]*d+a[10]*e+a[14],b[15]=a[3]*c+a[7]*d+a[11]*e+a[15]):(g=a[0],h=a[1],i=a[2],j=a[3],k=a[4],l=a[5],m=a[6],n=a[7],o=a[8],p=a[9],q=a[10],r=a[11],b[0]=g,b[1]=h,b[2]=i,b[3]=j,b[4]=k,b[5]=l,b[6]=m,b[7]=n,b[8]=o,b[9]=p,b[10]=q,b[11]=r,b[12]=g*c+k*d+o*e+a[12],b[13]=h*c+l*d+p*e+a[13],b[14]=i*c+m*d+q*e+a[14],b[15]=j*c+n*d+r*e+a[15]),b}function aJ(a,b,f){var c=f[0],d=f[1],e=f[2];return a[0]=b[0]*c,a[1]=b[1]*c,a[2]=b[2]*c,a[3]=b[3]*c,a[4]=b[4]*d,a[5]=b[5]*d,a[6]=b[6]*d,a[7]=b[7]*d,a[8]=b[8]*e,a[9]=b[9]*e,a[10]=b[10]*e,a[11]=b[11]*e,a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15],a}function aK(a,b){var c=a[0],d=a[1],e=a[2],f=a[3],g=a[4],h=a[5],i=a[6],j=a[7],k=a[8],l=a[9],m=a[10],n=a[11],o=a[12],p=a[13],q=a[14],r=a[15],s=b[0],t=b[1],u=b[2],v=b[3],w=b[4],x=b[5],y=b[6],z=b[7],A=b[8],B=b[9],C=b[10],D=b[11],E=b[12],F=b[13],G=b[14],H=b[15];return Math.abs(c-s)<=1e-6*Math.max(1,Math.abs(c),Math.abs(s))&&Math.abs(d-t)<=1e-6*Math.max(1,Math.abs(d),Math.abs(t))&&Math.abs(e-u)<=1e-6*Math.max(1,Math.abs(e),Math.abs(u))&&Math.abs(f-v)<=1e-6*Math.max(1,Math.abs(f),Math.abs(v))&&Math.abs(g-w)<=1e-6*Math.max(1,Math.abs(g),Math.abs(w))&&Math.abs(h-x)<=1e-6*Math.max(1,Math.abs(h),Math.abs(x))&&Math.abs(i-y)<=1e-6*Math.max(1,Math.abs(i),Math.abs(y))&&Math.abs(j-z)<=1e-6*Math.max(1,Math.abs(j),Math.abs(z))&&Math.abs(k-A)<=1e-6*Math.max(1,Math.abs(k),Math.abs(A))&&Math.abs(l-B)<=1e-6*Math.max(1,Math.abs(l),Math.abs(B))&&Math.abs(m-C)<=1e-6*Math.max(1,Math.abs(m),Math.abs(C))&&Math.abs(n-D)<=1e-6*Math.max(1,Math.abs(n),Math.abs(D))&&Math.abs(o-E)<=1e-6*Math.max(1,Math.abs(o),Math.abs(E))&&Math.abs(p-F)<=1e-6*Math.max(1,Math.abs(p),Math.abs(F))&&Math.abs(q-G)<=1e-6*Math.max(1,Math.abs(q),Math.abs(G))&&Math.abs(r-H)<=1e-6*Math.max(1,Math.abs(r),Math.abs(H))}function aL(a,b,c){return a[0]=b[0]+c[0],a[1]=b[1]+c[1],a}function aM(a,b,c,d){var e=b[0],f=b[1];return a[0]=e+d*(c[0]-e),a[1]=f+d*(c[1]-f),a}function aN(a,b){if(!a)throw new Error(b||"@math.gl/web-mercator: assertion failed.")}be=new h(2),h!=Float32Array&&(be[0]=0,be[1]=0),bf=new h(3),h!=Float32Array&&(bf[0]=0,bf[1]=0,bf[2]=0);const n=Math.PI,aO=n/4,aP=n/180,aQ=180/n;function aR(a){return Math.pow(2,a)}function aS([b,a]){return aN(Number.isFinite(b)),aN(Number.isFinite(a)&&a>= -90&&a<=90,"invalid latitude"),[512*(b*aP+n)/(2*n),512*(n+Math.log(Math.tan(aO+.5*(a*aP))))/(2*n)]}function aT([a,b]){return[(a/512*(2*n)-n)*aQ,2*(Math.atan(Math.exp(b/512*(2*n)-n))-aO)*aQ,]}function aU(a){return 2*Math.atan(.5/a)*aQ}function aV(a){return .5/Math.tan(.5*a*aP)}function aW(i,c,j=0){const[a,b,e]=i;if(aN(Number.isFinite(a)&&Number.isFinite(b),"invalid pixel coordinate"),Number.isFinite(e)){const k=aC(c,[a,b,e,1,]);return k}const f=aC(c,[a,b,0,1,]),g=aC(c,[a,b,1,1,]),d=f[2],h=g[2];return aM([],f,g,d===h?0:((j||0)-d)/(h-d))}const aX=Math.PI/180;function aY(a,c,d){const{pixelUnprojectionMatrix:e}=a,b=aC(e,[c,0,1,1,]),f=aC(e,[c,a.height,1,1,]),h=d*a.distanceScales.unitsPerMeter[2],i=(h-b[2])/(f[2]-b[2]),j=aM([],b,f,i),g=aT(j);return g[2]=d,g}class aZ{constructor({width:f,height:c,latitude:l=0,longitude:m=0,zoom:p=0,pitch:n=0,bearing:q=0,altitude:a=null,fovy:b=null,position:o=null,nearZMultiplier:t=.02,farZMultiplier:u=1.01}={width:1,height:1}){f=f||1,c=c||1,null===b&&null===a?b=aU(a=1.5):null===b?b=aU(a):null===a&&(a=aV(b));const r=aR(p);a=Math.max(.75,a);const s=function({latitude:c,longitude:i,highPrecision:j=!1}){aN(Number.isFinite(c)&&Number.isFinite(i));const b={},d=Math.cos(c*aP),e=1.4222222222222223/d,a=12790407194604047e-21/d;if(b.unitsPerMeter=[a,a,a,],b.metersPerUnit=[1/a,1/a,1/a,],b.unitsPerDegree=[1.4222222222222223,e,a,],b.degreesPerUnit=[.703125,1/e,1/a,],j){const f=aP*Math.tan(c*aP)/d,k=1.4222222222222223*f/2,g=12790407194604047e-21*f,h=g/e*a;b.unitsPerDegree2=[0,k,g,],b.unitsPerMeter2=[h,0,h,]}return b}({longitude:m,latitude:l}),d=aS([m,l]);if(d[2]=0,o){var e,g,h,i,j,k;i=d,j=d,k=(e=[],g=o,h=s.unitsPerMeter,e[0]=g[0]*h[0],e[1]=g[1]*h[1],e[2]=g[2]*h[2],e),i[0]=j[0]+k[0],i[1]=j[1]+k[1],i[2]=j[2]+k[2]}this.projectionMatrix=function({width:h,height:i,pitch:j,altitude:k,fovy:l,nearZMultiplier:m,farZMultiplier:n}){var a,f,g,c,b,d,e;const{fov:o,aspect:p,near:q,far:r}=function({width:f,height:g,fovy:a=aU(1.5),altitude:d,pitch:h=0,nearZMultiplier:i=1,farZMultiplier:j=1}){void 0!==d&&(a=aU(d));const b=.5*a*aP,c=aV(a),e=h*aP;return{fov:2*b,aspect:f/g,focalDistance:c,near:i,far:(Math.sin(e)*(Math.sin(b)*c/Math.sin(Math.min(Math.max(Math.PI/2-e-b,.01),Math.PI-.01)))+c)*j}}({width:h,height:i,altitude:k,fovy:l,pitch:j,nearZMultiplier:m,farZMultiplier:n}),s=(a=[],f=o,g=p,c=q,b=r,e=1/Math.tan(f/2),a[0]=e/g,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=e,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[11]=-1,a[12]=0,a[13]=0,a[15]=0,null!=b&&b!==1/0?(d=1/(c-b),a[10]=(b+c)*d,a[14]=2*b*c*d):(a[10]=-1,a[14]=-2*c),a);return s}({width:f,height:c,pitch:n,fovy:b,nearZMultiplier:t,farZMultiplier:u}),this.viewMatrix=function({height:F,pitch:G,bearing:H,altitude:I,scale:l,center:E=null}){var a,b,m,f,g,n,o,p,q,r,s,t,u,c,d,v,h,i,w,x,y,z,A,B,C,D,j,k;const e=aB();return aI(e,e,[0,0,-I]),a=e,b=e,m=-G*aP,f=Math.sin(m),g=Math.cos(m),n=b[4],o=b[5],p=b[6],q=b[7],r=b[8],s=b[9],t=b[10],u=b[11],b!==a&&(a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]),a[4]=n*g+r*f,a[5]=o*g+s*f,a[6]=p*g+t*f,a[7]=q*g+u*f,a[8]=r*g-n*f,a[9]=s*g-o*f,a[10]=t*g-p*f,a[11]=u*g-q*f,c=e,d=e,v=H*aP,h=Math.sin(v),i=Math.cos(v),w=d[0],x=d[1],y=d[2],z=d[3],A=d[4],B=d[5],C=d[6],D=d[7],d!==c&&(c[8]=d[8],c[9]=d[9],c[10]=d[10],c[11]=d[11],c[12]=d[12],c[13]=d[13],c[14]=d[14],c[15]=d[15]),c[0]=w*i+A*h,c[1]=x*i+B*h,c[2]=y*i+C*h,c[3]=z*i+D*h,c[4]=A*i-w*h,c[5]=B*i-x*h,c[6]=C*i-y*h,c[7]=D*i-z*h,aJ(e,e,[l/=F,l,l]),E&&aI(e,e,(j=[],k=E,j[0]=-k[0],j[1]=-k[1],j[2]=-k[2],j)),e}({height:c,scale:r,center:d,pitch:n,bearing:q,altitude:a}),this.width=f,this.height=c,this.scale=r,this.latitude=l,this.longitude=m,this.zoom=p,this.pitch=n,this.bearing=q,this.altitude=a,this.fovy=b,this.center=d,this.meterOffset=o||[0,0,0],this.distanceScales=s,this._initMatrices(),this.equals=this.equals.bind(this),this.project=this.project.bind(this),this.unproject=this.unproject.bind(this),this.projectPosition=this.projectPosition.bind(this),this.unprojectPosition=this.unprojectPosition.bind(this),Object.freeze(this)}_initMatrices(){var b,c,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,a;const{width:I,height:J,projectionMatrix:K,viewMatrix:L}=this,G=aB();aH(G,G,K),aH(G,G,L),this.viewProjectionMatrix=G;const d=aB();aJ(d,d,[I/2,-J/2,1]),aI(d,d,[1,-1,0]),aH(d,d,G);const H=(b=aB(),e=(c=d)[0],f=c[1],g=c[2],h=c[3],i=c[4],j=c[5],k=c[6],l=c[7],m=c[8],n=c[9],o=c[10],p=c[11],q=c[12],r=c[13],s=c[14],t=c[15],u=e*j-f*i,v=e*k-g*i,w=e*l-h*i,x=f*k-g*j,y=f*l-h*j,z=g*l-h*k,A=m*r-n*q,B=m*s-o*q,C=m*t-p*q,D=n*s-o*r,E=n*t-p*r,F=o*t-p*s,a=u*F-v*E+w*D+x*C-y*B+z*A,a?(a=1/a,b[0]=(j*F-k*E+l*D)*a,b[1]=(g*E-f*F-h*D)*a,b[2]=(r*z-s*y+t*x)*a,b[3]=(o*y-n*z-p*x)*a,b[4]=(k*C-i*F-l*B)*a,b[5]=(e*F-g*C+h*B)*a,b[6]=(s*w-q*z-t*v)*a,b[7]=(m*z-o*w+p*v)*a,b[8]=(i*E-j*C+l*A)*a,b[9]=(f*C-e*E-h*A)*a,b[10]=(q*y-r*w+t*u)*a,b[11]=(n*w-m*y-p*u)*a,b[12]=(j*B-i*D-k*A)*a,b[13]=(e*D-f*B+g*A)*a,b[14]=(r*v-q*x-s*u)*a,b[15]=(m*x-n*v+o*u)*a,b):null);if(!H)throw new Error("Pixel project matrix not invertible");this.pixelProjectionMatrix=d,this.pixelUnprojectionMatrix=H}equals(a){return a instanceof aZ&&a.width===this.width&&a.height===this.height&&aK(a.projectionMatrix,this.projectionMatrix)&&aK(a.viewMatrix,this.viewMatrix)}project(a,{topLeft:f=!0}={}){const g=this.projectPosition(a),b=function(d,e){const[a,b,c=0]=d;return aN(Number.isFinite(a)&&Number.isFinite(b)&&Number.isFinite(c)),aC(e,[a,b,c,1])}(g,this.pixelProjectionMatrix),[c,d]=b,e=f?d:this.height-d;return 2===a.length?[c,e]:[c,e,b[2]]}unproject(f,{topLeft:g=!0,targetZ:a}={}){const[h,d,e]=f,i=g?d:this.height-d,j=a&&a*this.distanceScales.unitsPerMeter[2],k=aW([h,i,e],this.pixelUnprojectionMatrix,j),[b,c,l]=this.unprojectPosition(k);return Number.isFinite(e)?[b,c,l]:Number.isFinite(a)?[b,c,a]:[b,c]}projectPosition(a){const[b,c]=aS(a),d=(a[2]||0)*this.distanceScales.unitsPerMeter[2];return[b,c,d]}unprojectPosition(a){const[b,c]=aT(a),d=(a[2]||0)*this.distanceScales.metersPerUnit[2];return[b,c,d]}projectFlat(a){return aS(a)}unprojectFlat(a){return aT(a)}getMapCenterByLngLatPosition({lngLat:c,pos:d}){var a,b;const e=aW(d,this.pixelUnprojectionMatrix),f=aS(c),g=aL([],f,(a=[],b=e,a[0]=-b[0],a[1]=-b[1],a)),h=aL([],this.center,g);return aT(h)}getLocationAtPoint({lngLat:a,pos:b}){return this.getMapCenterByLngLatPosition({lngLat:a,pos:b})}fitBounds(c,d={}){const{width:a,height:b}=this,{longitude:e,latitude:f,zoom:g}=function({width:m,height:n,bounds:o,minExtent:f=0,maxZoom:p=24,padding:a=0,offset:g=[0,0]}){const[[q,r],[s,t]]=o;if(Number.isFinite(a)){const b=a;a={top:b,bottom:b,left:b,right:b}}else aN(Number.isFinite(a.top)&&Number.isFinite(a.bottom)&&Number.isFinite(a.left)&&Number.isFinite(a.right));const c=aS([q,aF(t,-85.051129,85.051129),]),d=aS([s,aF(r,-85.051129,85.051129),]),h=[Math.max(Math.abs(d[0]-c[0]),f),Math.max(Math.abs(d[1]-c[1]),f),],e=[m-a.left-a.right-2*Math.abs(g[0]),n-a.top-a.bottom-2*Math.abs(g[1]),];aN(e[0]>0&&e[1]>0);const i=e[0]/h[0],j=e[1]/h[1],u=(a.right-a.left)/2/i,v=(a.bottom-a.top)/2/j,w=[(d[0]+c[0])/2+u,(d[1]+c[1])/2+v,],k=aT(w),l=Math.min(p,aG(Math.abs(Math.min(i,j))));return aN(Number.isFinite(l)),{longitude:k[0],latitude:k[1],zoom:l}}(Object.assign({width:a,height:b,bounds:c},d));return new aZ({width:a,height:b,longitude:e,latitude:f,zoom:g})}getBounds(b){const a=this.getBoundingRegion(b),c=Math.min(...a.map(a=>a[0])),d=Math.max(...a.map(a=>a[0])),e=Math.min(...a.map(a=>a[1])),f=Math.max(...a.map(a=>a[1]));return[[c,e],[d,f],]}getBoundingRegion(a={}){return function(a,d=0){const{width:e,height:h,unproject:b}=a,c={targetZ:d},i=b([0,h],c),j=b([e,h],c);let f,g;const k=a.fovy?.5*a.fovy*aX:Math.atan(.5/a.altitude),l=(90-a.pitch)*aX;return k>l-.01?(f=aY(a,0,d),g=aY(a,e,d)):(f=b([0,0],c),g=b([e,0],c)),[i,j,g,f]}(this,a.z||0)}}const a$=["longitude","latitude","zoom"],a_={curve:1.414,speed:1.2};function a0(d,h,i){var f,j,k,o,p,q;i=Object.assign({},a_,i);const g=i.curve,l=d.zoom,w=[d.longitude,d.latitude],x=aR(l),y=h.zoom,z=[h.longitude,h.latitude],A=aR(y-l),r=aS(w),B=aS(z),s=(f=[],j=B,k=r,f[0]=j[0]-k[0],f[1]=j[1]-k[1],f),a=Math.max(d.width,d.height),e=a/A,t=(p=(o=s)[0],q=o[1],Math.hypot(p,q)*x),c=Math.max(t,.01),b=g*g,m=(e*e-a*a+b*b*c*c)/(2*a*b*c),n=(e*e-a*a-b*b*c*c)/(2*e*b*c),u=Math.log(Math.sqrt(m*m+1)-m),v=Math.log(Math.sqrt(n*n+1)-n);return{startZoom:l,startCenterXY:r,uDelta:s,w0:a,u1:t,S:(v-u)/g,rho:g,rho2:b,r0:u,r1:v}}var N=function(){if("undefined"!=typeof Map)return Map;function a(a,c){var b=-1;return a.some(function(a,d){return a[0]===c&&(b=d,!0)}),b}return function(){function b(){this.__entries__=[]}return Object.defineProperty(b.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),b.prototype.get=function(c){var d=a(this.__entries__,c),b=this.__entries__[d];return b&&b[1]},b.prototype.set=function(b,c){var d=a(this.__entries__,b);~d?this.__entries__[d][1]=c:this.__entries__.push([b,c])},b.prototype.delete=function(d){var b=this.__entries__,c=a(b,d);~c&&b.splice(c,1)},b.prototype.has=function(b){return!!~a(this.__entries__,b)},b.prototype.clear=function(){this.__entries__.splice(0)},b.prototype.forEach=function(e,a){void 0===a&&(a=null);for(var b=0,c=this.__entries__;b0},a.prototype.connect_=function(){a1&&!this.connected_&&(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),a4?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},a.prototype.disconnect_=function(){a1&&this.connected_&&(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},a.prototype.onTransitionEnd_=function(b){var a=b.propertyName,c=void 0===a?"":a;a3.some(function(a){return!!~c.indexOf(a)})&&this.refresh()},a.getInstance=function(){return this.instance_||(this.instance_=new a),this.instance_},a.instance_=null,a}(),a6=function(b,c){for(var a=0,d=Object.keys(c);a0},a}(),bj="undefined"!=typeof WeakMap?new WeakMap:new N,O=function(){function a(b){if(!(this instanceof a))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var c=a5.getInstance(),d=new bi(b,c,this);bj.set(this,d)}return a}();["observe","unobserve","disconnect"].forEach(function(a){O.prototype[a]=function(){var b;return(b=bj.get(this))[a].apply(b,arguments)}});var bk=void 0!==o.ResizeObserver?o.ResizeObserver:O;function bl(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function bm(d,c){for(var b=0;b=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function(a){throw a},f:b}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var e,f,g=!0,h=!1;return{s:function(){e=a[Symbol.iterator]()},n:function(){var a=e.next();return g=a.done,a},e:function(a){h=!0,f=a},f:function(){try{g||null==e.return||e.return()}finally{if(h)throw f}}}}function br(a,c){if(a){if("string"==typeof a)return bs(a,c);var b=Object.prototype.toString.call(a).slice(8,-1);if("Object"===b&&a.constructor&&(b=a.constructor.name),"Map"===b||"Set"===b)return Array.from(a);if("Arguments"===b||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b))return bs(a,c)}}function bs(c,a){(null==a||a>c.length)&&(a=c.length);for(var b=0,d=new Array(a);b1&& void 0!==arguments[1]?arguments[1]:"component";b.debug&&a.checkPropTypes(Q,b,"prop",c)}var i=function(){function a(b){var c=this;if(bl(this,a),g(this,"props",R),g(this,"width",0),g(this,"height",0),g(this,"_fireLoadEvent",function(){c.props.onLoad({type:"load",target:c._map})}),g(this,"_handleError",function(a){c.props.onError(a)}),!b.mapboxgl)throw new Error("Mapbox not available");this.mapboxgl=b.mapboxgl,a.initialized||(a.initialized=!0,this._checkStyleSheet(this.mapboxgl.version)),this._initialize(b)}return bn(a,[{key:"finalize",value:function(){return this._destroy(),this}},{key:"setProps",value:function(a){return this._update(this.props,a),this}},{key:"redraw",value:function(){var a=this._map;a.style&&(a._frame&&(a._frame.cancel(),a._frame=null),a._render())}},{key:"getMap",value:function(){return this._map}},{key:"_reuse",value:function(b){this._map=a.savedMap;var d=this._map.getContainer(),c=b.container;for(c.classList.add("mapboxgl-map");d.childNodes.length>0;)c.appendChild(d.childNodes[0]);this._map._container=c,a.savedMap=null,b.mapStyle&&this._map.setStyle(bu(b.mapStyle),{diff:!1}),this._map.isStyleLoaded()?this._fireLoadEvent():this._map.once("styledata",this._fireLoadEvent)}},{key:"_create",value:function(b){if(b.reuseMaps&&a.savedMap)this._reuse(b);else{if(b.gl){var d=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=function(){return HTMLCanvasElement.prototype.getContext=d,b.gl}}var c={container:b.container,center:[0,0],zoom:8,pitch:0,bearing:0,maxZoom:24,style:bu(b.mapStyle),interactive:!1,trackResize:!1,attributionControl:b.attributionControl,preserveDrawingBuffer:b.preserveDrawingBuffer};b.transformRequest&&(c.transformRequest=b.transformRequest),this._map=new this.mapboxgl.Map(Object.assign({},c,b.mapOptions)),this._map.once("load",this._fireLoadEvent),this._map.on("error",this._handleError)}return this}},{key:"_destroy",value:function(){this._map&&(this.props.reuseMaps&&!a.savedMap?(a.savedMap=this._map,this._map.off("load",this._fireLoadEvent),this._map.off("error",this._handleError),this._map.off("styledata",this._fireLoadEvent)):this._map.remove(),this._map=null)}},{key:"_initialize",value:function(a){var d=this;a=Object.assign({},R,a),bw(a,"Mapbox"),this.mapboxgl.accessToken=a.mapboxApiAccessToken||R.mapboxApiAccessToken,this.mapboxgl.baseApiUrl=a.mapboxApiUrl,this._create(a);var b=a.container;Object.defineProperty(b,"offsetWidth",{configurable:!0,get:function(){return d.width}}),Object.defineProperty(b,"clientWidth",{configurable:!0,get:function(){return d.width}}),Object.defineProperty(b,"offsetHeight",{configurable:!0,get:function(){return d.height}}),Object.defineProperty(b,"clientHeight",{configurable:!0,get:function(){return d.height}});var c=this._map.getCanvas();c&&(c.style.outline="none"),this._updateMapViewport({},a),this._updateMapSize({},a),this.props=a}},{key:"_update",value:function(b,a){if(this._map){bw(a=Object.assign({},this.props,a),"Mapbox");var c=this._updateMapViewport(b,a),d=this._updateMapSize(b,a);this._updateMapStyle(b,a),!a.asyncRender&&(c||d)&&this.redraw(),this.props=a}}},{key:"_updateMapStyle",value:function(b,a){b.mapStyle!==a.mapStyle&&this._map.setStyle(bu(a.mapStyle),{diff:!a.preventStyleDiffing})}},{key:"_updateMapSize",value:function(b,a){var c=b.width!==a.width||b.height!==a.height;return c&&(this.width=a.width,this.height=a.height,this._map.resize()),c}},{key:"_updateMapViewport",value:function(d,e){var b=this._getViewState(d),a=this._getViewState(e),c=a.latitude!==b.latitude||a.longitude!==b.longitude||a.zoom!==b.zoom||a.pitch!==b.pitch||a.bearing!==b.bearing||a.altitude!==b.altitude;return c&&(this._map.jumpTo(this._viewStateToMapboxProps(a)),a.altitude!==b.altitude&&(this._map.transform.altitude=a.altitude)),c}},{key:"_getViewState",value:function(b){var a=b.viewState||b,f=a.longitude,g=a.latitude,h=a.zoom,c=a.pitch,d=a.bearing,e=a.altitude;return{longitude:f,latitude:g,zoom:h,pitch:void 0===c?0:c,bearing:void 0===d?0:d,altitude:void 0===e?1.5:e}}},{key:"_checkStyleSheet",value:function(){var c=arguments.length>0&& void 0!==arguments[0]?arguments[0]:"0.47.0";if(void 0!==P)try{var a=P.createElement("div");if(a.className="mapboxgl-map",a.style.display="none",P.body.appendChild(a),!("static"!==window.getComputedStyle(a).position)){var b=P.createElement("link");b.setAttribute("rel","stylesheet"),b.setAttribute("type","text/css"),b.setAttribute("href","https://api.tiles.mapbox.com/mapbox-gl-js/v".concat(c,"/mapbox-gl.css")),P.head.appendChild(b)}}catch(d){}}},{key:"_viewStateToMapboxProps",value:function(a){return{center:[a.longitude,a.latitude,],zoom:a.zoom,bearing:a.bearing,pitch:a.pitch}}},]),a}();g(i,"initialized",!1),g(i,"propTypes",Q),g(i,"defaultProps",R),g(i,"savedMap",null);var S=b(6158),A=b.n(S);function bx(a){return Array.isArray(a)||ArrayBuffer.isView(a)}function by(a,b){if(a===b)return!0;if(bx(a)&&bx(b)){if(a.length!==b.length)return!1;for(var c=0;c=Math.abs(a-b)}function bz(a,b,c){return Math.max(b,Math.min(c,a))}function bA(a,c,b){return bx(a)?a.map(function(a,d){return bA(a,c[d],b)}):b*c+(1-b)*a}function bB(a,b){if(!a)throw new Error(b||"react-map-gl: assertion failed.")}function bC(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}function bD(c){for(var a=1;a0,"`scale` must be a positive number");var f=this._state,b=f.startZoom,c=f.startZoomLngLat;Number.isFinite(b)||(b=this._viewportProps.zoom,c=this._unproject(i)||this._unproject(d)),bB(c,"`startZoomLngLat` prop is required for zoom behavior to calculate where to position the map.");var g=this._calculateNewZoom({scale:e,startZoom:b||0}),j=new aZ(Object.assign({},this._viewportProps,{zoom:g})),k=j.getMapCenterByLngLatPosition({lngLat:c,pos:d}),h=aA(k,2),l=h[0],m=h[1];return this._getUpdatedMapState({zoom:g,longitude:l,latitude:m})}},{key:"zoomEnd",value:function(){return this._getUpdatedMapState({startZoomLngLat:null,startZoom:null})}},{key:"_getUpdatedMapState",value:function(b){return new a(Object.assign({},this._viewportProps,this._state,b))}},{key:"_applyConstraints",value:function(a){var b=a.maxZoom,c=a.minZoom,d=a.zoom;a.zoom=bz(d,c,b);var e=a.maxPitch,f=a.minPitch,g=a.pitch;return a.pitch=bz(g,f,e),Object.assign(a,function({width:j,height:e,longitude:b,latitude:a,zoom:d,pitch:k=0,bearing:c=0}){(b< -180||b>180)&&(b=aD(b+180,360)-180),(c< -180||c>180)&&(c=aD(c+180,360)-180);const f=aG(e/512);if(d<=f)d=f,a=0;else{const g=e/2/Math.pow(2,d),h=aT([0,g])[1];if(ai&&(a=i)}}return{width:j,height:e,longitude:b,latitude:a,zoom:d,pitch:k,bearing:c}}(a)),a}},{key:"_unproject",value:function(a){var b=new aZ(this._viewportProps);return a&&b.unproject(a)}},{key:"_calculateNewLngLat",value:function(a){var b=a.startPanLngLat,c=a.pos,d=new aZ(this._viewportProps);return d.getMapCenterByLngLatPosition({lngLat:b,pos:c})}},{key:"_calculateNewZoom",value:function(a){var c=a.scale,d=a.startZoom,b=this._viewportProps,e=b.maxZoom,f=b.minZoom;return bz(d+Math.log2(c),f,e)}},{key:"_calculateNewPitchAndBearing",value:function(c){var f=c.deltaScaleX,a=c.deltaScaleY,g=c.startBearing,b=c.startPitch;a=bz(a,-1,1);var e=this._viewportProps,h=e.minPitch,i=e.maxPitch,d=b;return a>0?d=b+a*(i-b):a<0&&(d=b-a*(h-b)),{pitch:d,bearing:g+180*f}}},{key:"_getRotationParams",value:function(c,d){var h=c[0]-d[0],e=c[1]-d[1],i=c[1],a=d[1],f=this._viewportProps,j=f.width,g=f.height,b=0;return e>0?Math.abs(g-a)>5&&(b=e/(a-g)*1.2):e<0&&a>5&&(b=1-i/a),{deltaScaleX:h/j,deltaScaleY:b=Math.min(1,Math.max(-1,b))}}},]),a}();function bG(a){return a[0].toLowerCase()+a.slice(1)}function bH(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}function bI(c){for(var a=1;a1&& void 0!==arguments[1]?arguments[1]:{},b=a.current&&a.current.getMap();return b&&b.queryRenderedFeatures(c,d)}}},[]);var p=(0,c.useCallback)(function(b){var a=b.target;a===o.current&&a.scrollTo(0,0)},[]),q=d&&c.createElement(bJ,{value:bO(bO({},b),{},{viewport:b.viewport||bQ(bO({map:d,props:a},m)),map:d,container:b.container||h.current})},c.createElement("div",{key:"map-overlays",className:"overlays",ref:o,style:bR,onScroll:p},a.children)),r=a.className,s=a.width,t=a.height,u=a.style,v=a.visibilityConstraints,w=Object.assign({position:"relative"},u,{width:s,height:t}),x=a.visible&&function(c){var b=arguments.length>1&& void 0!==arguments[1]?arguments[1]:B;for(var a in b){var d=a.slice(0,3),e=bG(a.slice(3));if("min"===d&&c[e]b[a])return!1}return!0}(a.viewState||a,v),y=Object.assign({},bR,{visibility:x?"inherit":"hidden"});return c.createElement("div",{key:"map-container",ref:h,style:w},c.createElement("div",{key:"map-mapbox",ref:n,style:y,className:r}),q,!l&&!a.disableTokenWarning&&c.createElement(bS,null))});j.supported=function(){return A()&&A().supported()},j.propTypes=T,j.defaultProps=U;var q=j;function bT(c,a){(null==a||a>c.length)&&(a=c.length);for(var b=0,d=new Array(a);b=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function(a){throw a},f:b}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var e,f,g=!0,h=!1;return{s:function(){e=a[Symbol.iterator]()},n:function(){var a=e.next();return g=a.done,a},e:function(a){h=!0,f=a},f:function(){try{g||null==e.return||e.return()}finally{if(h)throw f}}}}(this.propNames||[]);try{for(a.s();!(b=a.n()).done;){var c=b.value;if(!by(d[c],e[c]))return!1}}catch(f){a.e(f)}finally{a.f()}return!0}},{key:"initializeProps",value:function(a,b){return{start:a,end:b}}},{key:"interpolateProps",value:function(a,b,c){bB(!1,"interpolateProps is not implemented")}},{key:"getDuration",value:function(b,a){return a.transitionDuration}},]),a}();function bU(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function bV(a,b){return(bV=Object.setPrototypeOf||function(a,b){return a.__proto__=b,a})(a,b)}function bW(b,a){if("function"!=typeof a&&null!==a)throw new TypeError("Super expression must either be null or a function");b.prototype=Object.create(a&&a.prototype,{constructor:{value:b,writable:!0,configurable:!0}}),Object.defineProperty(b,"prototype",{writable:!1}),a&&bV(b,a)}function bX(a){return(bX="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a})(a)}function bY(b,a){if(a&&("object"===bX(a)||"function"==typeof a))return a;if(void 0!==a)throw new TypeError("Derived constructors may only return object or undefined");return bU(b)}function bZ(a){return(bZ=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)})(a)}var b$={longitude:1,bearing:1};function b_(a){return Number.isFinite(a)||Array.isArray(a)}function b0(b,c,a){return b in b$&&Math.abs(a-c)>180&&(a=a<0?a+360:a-360),a}function b1(a,c){if("undefined"==typeof Symbol||null==a[Symbol.iterator]){if(Array.isArray(a)||(e=b2(a))||c&&a&&"number"==typeof a.length){e&&(a=e);var d=0,b=function(){};return{s:b,n:function(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function(a){throw a},f:b}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var e,f,g=!0,h=!1;return{s:function(){e=a[Symbol.iterator]()},n:function(){var a=e.next();return g=a.done,a},e:function(a){h=!0,f=a},f:function(){try{g||null==e.return||e.return()}finally{if(h)throw f}}}}function b2(a,c){if(a){if("string"==typeof a)return b3(a,c);var b=Object.prototype.toString.call(a).slice(8,-1);if("Object"===b&&a.constructor&&(b=a.constructor.name),"Map"===b||"Set"===b)return Array.from(a);if("Arguments"===b||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b))return b3(a,c)}}function b3(c,a){(null==a||a>c.length)&&(a=c.length);for(var b=0,d=new Array(a);b=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function(a){throw a},f:b}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var e,f,g=!0,h=!1;return{s:function(){e=a[Symbol.iterator]()},n:function(){var a=e.next();return g=a.done,a},e:function(a){h=!0,f=a},f:function(){try{g||null==e.return||e.return()}finally{if(h)throw f}}}}function b9(a,c){if(a){if("string"==typeof a)return ca(a,c);var b=Object.prototype.toString.call(a).slice(8,-1);if("Object"===b&&a.constructor&&(b=a.constructor.name),"Map"===b||"Set"===b)return Array.from(a);if("Arguments"===b||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b))return ca(a,c)}}function ca(c,a){(null==a||a>c.length)&&(a=c.length);for(var b=0,d=new Array(a);b0&& void 0!==arguments[0]?arguments[0]:{};return bl(this,d),g(bU(a=e.call(this)),"propNames",b4),a.props=Object.assign({},b7,b),a}bn(d,[{key:"initializeProps",value:function(h,i){var j,e={},f={},c=b1(b5);try{for(c.s();!(j=c.n()).done;){var a=j.value,g=h[a],k=i[a];bB(b_(g)&&b_(k),"".concat(a," must be supplied for transition")),e[a]=g,f[a]=b0(a,g,k)}}catch(n){c.e(n)}finally{c.f()}var l,d=b1(b6);try{for(d.s();!(l=d.n()).done;){var b=l.value,m=h[b]||0,o=i[b]||0;e[b]=m,f[b]=b0(b,m,o)}}catch(p){d.e(p)}finally{d.f()}return{start:e,end:f}}},{key:"interpolateProps",value:function(c,d,e){var f,g=function(h,i,j,p={}){var c,d,e,k;const a={},{startZoom:q,startCenterXY:r,uDelta:s,w0:t,u1:l,S:u,rho:m,rho2:v,r0:b}=a0(h,i,p);if(l<.01){for(const f of a$){const w=h[f],x=i[f];a[f]=aE(w,x,j)}return a}const n=j*u,y=q+(k=1/(Math.cosh(b)/Math.cosh(b+m*n)),aG(k)),g=(c=[],d=s,e=t*((Math.cosh(b)*Math.tanh(b+m*n)-Math.sinh(b))/v)/l,c[0]=d[0]*e,c[1]=d[1]*e,c);aL(g,g,r);const o=aT(g);return a.longitude=o[0],a.latitude=o[1],a.zoom=y,a}(c,d,e,this.props),a=b1(b6);try{for(a.s();!(f=a.n()).done;){var b=f.value;g[b]=bA(c[b],d[b],e)}}catch(h){a.e(h)}finally{a.f()}return g}},{key:"getDuration",value:function(c,b){var a=b.transitionDuration;return"auto"===a&&(a=function(f,g,a={}){a=Object.assign({},a_,a);const{screenSpeed:c,speed:h,maxDuration:d}=a,{S:i,rho:j}=a0(f,g,a),e=1e3*i;let b;return b=Number.isFinite(c)?e/(c/j):e/h,Number.isFinite(d)&&b>d?0:b}(c,b,this.props)),a}},])}(C);var cb=["longitude","latitude","zoom","bearing","pitch",],D=function(b){bW(a,b);var c,d,e=(c=a,d=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(a){return!1}}(),function(){var a,b=bZ(c);if(d){var e=bZ(this).constructor;a=Reflect.construct(b,arguments,e)}else a=b.apply(this,arguments);return bY(this,a)});function a(){var c,b=arguments.length>0&& void 0!==arguments[0]?arguments[0]:{};return bl(this,a),c=e.call(this),Array.isArray(b)&&(b={transitionProps:b}),c.propNames=b.transitionProps||cb,b.around&&(c.around=b.around),c}return bn(a,[{key:"initializeProps",value:function(g,c){var d={},e={};if(this.around){d.around=this.around;var h=new aZ(g).unproject(this.around);Object.assign(e,c,{around:new aZ(c).project(h),aroundLngLat:h})}var i,b=b8(this.propNames);try{for(b.s();!(i=b.n()).done;){var a=i.value,f=g[a],j=c[a];bB(b_(f)&&b_(j),"".concat(a," must be supplied for transition")),d[a]=f,e[a]=b0(a,f,j)}}catch(k){b.e(k)}finally{b.f()}return{start:d,end:e}}},{key:"interpolateProps",value:function(e,a,f){var g,b={},c=b8(this.propNames);try{for(c.s();!(g=c.n()).done;){var d=g.value;b[d]=bA(e[d],a[d],f)}}catch(i){c.e(i)}finally{c.f()}if(a.around){var j=new aZ(Object.assign({},a,b)).getMapCenterByLngLatPosition({lngLat:a.aroundLngLat,pos:bA(e.around,a.around,f)}),h=aA(j,2),k=h[0],l=h[1];b.longitude=k,b.latitude=l}return b}},]),a}(C),r=function(){},E={BREAK:1,SNAP_TO_END:2,IGNORE:3,UPDATE:4},V={transitionDuration:0,transitionEasing:function(a){return a},transitionInterpolator:new D,transitionInterruption:E.BREAK,onTransitionStart:r,onTransitionInterrupt:r,onTransitionEnd:r},F=function(){function a(){var c=this,b=arguments.length>0&& void 0!==arguments[0]?arguments[0]:{};bl(this,a),g(this,"_animationFrame",null),g(this,"_onTransitionFrame",function(){c._animationFrame=requestAnimationFrame(c._onTransitionFrame),c._updateViewport()}),this.props=null,this.onViewportChange=b.onViewportChange||r,this.onStateChange=b.onStateChange||r,this.time=b.getTime||Date.now}return bn(a,[{key:"getViewportInTransition",value:function(){return this._animationFrame?this.state.propsInTransition:null}},{key:"processViewportChange",value:function(c){var a=this.props;if(this.props=c,!a||this._shouldIgnoreViewportChange(a,c))return!1;if(this._isTransitionEnabled(c)){var d=Object.assign({},a),b=Object.assign({},c);if(this._isTransitionInProgress()&&(a.onTransitionInterrupt(),this.state.interruption===E.SNAP_TO_END?Object.assign(d,this.state.endProps):Object.assign(d,this.state.propsInTransition),this.state.interruption===E.UPDATE)){var f,g,h,e=this.time(),i=(e-this.state.startTime)/this.state.duration;b.transitionDuration=this.state.duration-(e-this.state.startTime),b.transitionEasing=(h=(f=this.state.easing)(g=i),function(a){return 1/(1-h)*(f(a*(1-g)+g)-h)}),b.transitionInterpolator=d.transitionInterpolator}return b.onTransitionStart(),this._triggerTransition(d,b),!0}return this._isTransitionInProgress()&&(a.onTransitionInterrupt(),this._endTransition()),!1}},{key:"_isTransitionInProgress",value:function(){return Boolean(this._animationFrame)}},{key:"_isTransitionEnabled",value:function(a){var b=a.transitionDuration,c=a.transitionInterpolator;return(b>0||"auto"===b)&&Boolean(c)}},{key:"_isUpdateDueToCurrentTransition",value:function(a){return!!this.state.propsInTransition&&this.state.interpolator.arePropsEqual(a,this.state.propsInTransition)}},{key:"_shouldIgnoreViewportChange",value:function(b,a){return!b||(this._isTransitionInProgress()?this.state.interruption===E.IGNORE||this._isUpdateDueToCurrentTransition(a):!this._isTransitionEnabled(a)||a.transitionInterpolator.arePropsEqual(b,a))}},{key:"_triggerTransition",value:function(b,a){bB(this._isTransitionEnabled(a)),this._animationFrame&&cancelAnimationFrame(this._animationFrame);var c=a.transitionInterpolator,d=c.getDuration?c.getDuration(b,a):a.transitionDuration;if(0!==d){var e=a.transitionInterpolator.initializeProps(b,a),f={inTransition:!0,isZooming:b.zoom!==a.zoom,isPanning:b.longitude!==a.longitude||b.latitude!==a.latitude,isRotating:b.bearing!==a.bearing||b.pitch!==a.pitch};this.state={duration:d,easing:a.transitionEasing,interpolator:a.transitionInterpolator,interruption:a.transitionInterruption,startTime:this.time(),startProps:e.start,endProps:e.end,animation:null,propsInTransition:{}},this._onTransitionFrame(),this.onStateChange(f)}}},{key:"_endTransition",value:function(){this._animationFrame&&(cancelAnimationFrame(this._animationFrame),this._animationFrame=null),this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1})}},{key:"_updateViewport",value:function(){var d=this.time(),a=this.state,e=a.startTime,f=a.duration,g=a.easing,h=a.interpolator,i=a.startProps,j=a.endProps,c=!1,b=(d-e)/f;b>=1&&(b=1,c=!0),b=g(b);var k=h.interpolateProps(i,j,b),l=new bF(Object.assign({},this.props,k));this.state.propsInTransition=l.getViewportProps(),this.onViewportChange(this.state.propsInTransition,this.props),c&&(this._endTransition(),this.props.onTransitionEnd())}},]),a}();g(F,"defaultProps",V);var W=b(840),k=b.n(W);const cc={mousedown:1,mousemove:2,mouseup:4};!function(a){const b=a.prototype.handler;a.prototype.handler=function(a){const c=this.store;a.button>0&&"pointerdown"===a.type&& !function(b,c){for(let a=0;ab.pointerId===a.pointerId)&&c.push(a),b.call(this,a)}}(k().PointerEventInput),k().MouseInput.prototype.handler=function(a){let b=cc[a.type];1&b&&a.button>=0&&(this.pressed=!0),2&b&&0===a.which&&(b=4),this.pressed&&(4&b&&(this.pressed=!1),this.callback(this.manager,b,{pointers:[a],changedPointers:[a],pointerType:"mouse",srcEvent:a}))};const cd=k().Manager;var e=k();const ce=e?[[e.Pan,{event:"tripan",pointers:3,threshold:0,enable:!1},],[e.Rotate,{enable:!1},],[e.Pinch,{enable:!1},],[e.Swipe,{enable:!1},],[e.Pan,{threshold:0,enable:!1},],[e.Press,{enable:!1},],[e.Tap,{event:"doubletap",taps:2,enable:!1},],[e.Tap,{event:"anytap",enable:!1},],[e.Tap,{enable:!1},],]:null,cf={tripan:["rotate","pinch","pan"],rotate:["pinch"],pinch:["pan"],pan:["press","doubletap","anytap","tap"],doubletap:["anytap"],anytap:["tap"]},cg={doubletap:["tap"]},ch={pointerdown:"pointerdown",pointermove:"pointermove",pointerup:"pointerup",touchstart:"pointerdown",touchmove:"pointermove",touchend:"pointerup",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup"},s={KEY_EVENTS:["keydown","keyup"],MOUSE_EVENTS:["mousedown","mousemove","mouseup","mouseover","mouseout","mouseleave",],WHEEL_EVENTS:["wheel","mousewheel"]},ci={tap:"tap",anytap:"anytap",doubletap:"doubletap",press:"press",pinch:"pinch",pinchin:"pinch",pinchout:"pinch",pinchstart:"pinch",pinchmove:"pinch",pinchend:"pinch",pinchcancel:"pinch",rotate:"rotate",rotatestart:"rotate",rotatemove:"rotate",rotateend:"rotate",rotatecancel:"rotate",tripan:"tripan",tripanstart:"tripan",tripanmove:"tripan",tripanup:"tripan",tripandown:"tripan",tripanleft:"tripan",tripanright:"tripan",tripanend:"tripan",tripancancel:"tripan",pan:"pan",panstart:"pan",panmove:"pan",panup:"pan",pandown:"pan",panleft:"pan",panright:"pan",panend:"pan",pancancel:"pan",swipe:"swipe",swipeleft:"swipe",swiperight:"swipe",swipeup:"swipe",swipedown:"swipe"},cj={click:"tap",anyclick:"anytap",dblclick:"doubletap",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup",mouseover:"pointerover",mouseout:"pointerout",mouseleave:"pointerleave"},X="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",G="undefined"!=typeof window?window:b.g;void 0!==b.g?b.g:window;let Y=!1;try{const l={get passive(){return Y=!0,!0}};G.addEventListener("test",l,l),G.removeEventListener("test",l,l)}catch(ck){}const cl=-1!==X.indexOf("firefox"),{WHEEL_EVENTS:cm}=s,cn="wheel";class co{constructor(b,c,a={}){this.element=b,this.callback=c,this.options=Object.assign({enable:!0},a),this.events=cm.concat(a.events||[]),this.handleEvent=this.handleEvent.bind(this),this.events.forEach(a=>b.addEventListener(a,this.handleEvent,!!Y&&{passive:!1}))}destroy(){this.events.forEach(a=>this.element.removeEventListener(a,this.handleEvent))}enableEventType(a,b){a===cn&&(this.options.enable=b)}handleEvent(b){if(!this.options.enable)return;let a=b.deltaY;G.WheelEvent&&(cl&&b.deltaMode===G.WheelEvent.DOM_DELTA_PIXEL&&(a/=G.devicePixelRatio),b.deltaMode===G.WheelEvent.DOM_DELTA_LINE&&(a*=40));const c={x:b.clientX,y:b.clientY};0!==a&&a%4.000244140625==0&&(a=Math.floor(a/4.000244140625)),b.shiftKey&&a&&(a*=.25),this._onWheel(b,-a,c)}_onWheel(a,b,c){this.callback({type:cn,center:c,delta:b,srcEvent:a,pointerType:"mouse",target:a.target})}}const{MOUSE_EVENTS:cp}=s,cq="pointermove",cr="pointerover",cs="pointerout",ct="pointerleave";class cu{constructor(b,c,a={}){this.element=b,this.callback=c,this.pressed=!1,this.options=Object.assign({enable:!0},a),this.enableMoveEvent=this.options.enable,this.enableLeaveEvent=this.options.enable,this.enableOutEvent=this.options.enable,this.enableOverEvent=this.options.enable,this.events=cp.concat(a.events||[]),this.handleEvent=this.handleEvent.bind(this),this.events.forEach(a=>b.addEventListener(a,this.handleEvent))}destroy(){this.events.forEach(a=>this.element.removeEventListener(a,this.handleEvent))}enableEventType(a,b){a===cq&&(this.enableMoveEvent=b),a===cr&&(this.enableOverEvent=b),a===cs&&(this.enableOutEvent=b),a===ct&&(this.enableLeaveEvent=b)}handleEvent(a){this.handleOverEvent(a),this.handleOutEvent(a),this.handleLeaveEvent(a),this.handleMoveEvent(a)}handleOverEvent(a){this.enableOverEvent&&"mouseover"===a.type&&this.callback({type:cr,srcEvent:a,pointerType:"mouse",target:a.target})}handleOutEvent(a){this.enableOutEvent&&"mouseout"===a.type&&this.callback({type:cs,srcEvent:a,pointerType:"mouse",target:a.target})}handleLeaveEvent(a){this.enableLeaveEvent&&"mouseleave"===a.type&&this.callback({type:ct,srcEvent:a,pointerType:"mouse",target:a.target})}handleMoveEvent(a){if(this.enableMoveEvent)switch(a.type){case"mousedown":a.button>=0&&(this.pressed=!0);break;case"mousemove":0===a.which&&(this.pressed=!1),this.pressed||this.callback({type:cq,srcEvent:a,pointerType:"mouse",target:a.target});break;case"mouseup":this.pressed=!1}}}const{KEY_EVENTS:cv}=s,cw="keydown",cx="keyup";class cy{constructor(a,c,b={}){this.element=a,this.callback=c,this.options=Object.assign({enable:!0},b),this.enableDownEvent=this.options.enable,this.enableUpEvent=this.options.enable,this.events=cv.concat(b.events||[]),this.handleEvent=this.handleEvent.bind(this),a.tabIndex=b.tabIndex||0,a.style.outline="none",this.events.forEach(b=>a.addEventListener(b,this.handleEvent))}destroy(){this.events.forEach(a=>this.element.removeEventListener(a,this.handleEvent))}enableEventType(a,b){a===cw&&(this.enableDownEvent=b),a===cx&&(this.enableUpEvent=b)}handleEvent(a){const b=a.target||a.srcElement;("INPUT"!==b.tagName||"text"!==b.type)&&"TEXTAREA"!==b.tagName&&(this.enableDownEvent&&"keydown"===a.type&&this.callback({type:cw,srcEvent:a,key:a.key,target:a.target}),this.enableUpEvent&&"keyup"===a.type&&this.callback({type:cx,srcEvent:a,key:a.key,target:a.target}))}}const cz="contextmenu";class cA{constructor(a,b,c={}){this.element=a,this.callback=b,this.options=Object.assign({enable:!0},c),this.handleEvent=this.handleEvent.bind(this),a.addEventListener("contextmenu",this.handleEvent)}destroy(){this.element.removeEventListener("contextmenu",this.handleEvent)}enableEventType(a,b){a===cz&&(this.options.enable=b)}handleEvent(a){this.options.enable&&this.callback({type:cz,center:{x:a.clientX,y:a.clientY},srcEvent:a,pointerType:"mouse",target:a.target})}}const cB={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4},cC={srcElement:"root",priority:0};class cD{constructor(a){this.eventManager=a,this.handlers=[],this.handlersByElement=new Map,this.handleEvent=this.handleEvent.bind(this),this._active=!1}isEmpty(){return!this._active}add(f,g,a,h=!1,i=!1){const{handlers:j,handlersByElement:e}=this;a&&("object"!=typeof a||a.addEventListener)&&(a={srcElement:a}),a=a?Object.assign({},cC,a):cC;let b=e.get(a.srcElement);b||(b=[],e.set(a.srcElement,b));const c={type:f,handler:g,srcElement:a.srcElement,priority:a.priority};h&&(c.once=!0),i&&(c.passive=!0),j.push(c),this._active=this._active||!c.passive;let d=b.length-1;for(;d>=0&&!(b[d].priority>=c.priority);)d--;b.splice(d+1,0,c)}remove(f,g){const{handlers:b,handlersByElement:e}=this;for(let c=b.length-1;c>=0;c--){const a=b[c];if(a.type===f&&a.handler===g){b.splice(c,1);const d=e.get(a.srcElement);d.splice(d.indexOf(a),1),0===d.length&&e.delete(a.srcElement)}}this._active=b.some(a=>!a.passive)}handleEvent(c){if(this.isEmpty())return;const b=this._normalizeEvent(c);let a=c.srcEvent.target;for(;a&&a!==b.rootElement;){if(this._emit(b,a),b.handled)return;a=a.parentNode}this._emit(b,"root")}_emit(e,f){const a=this.handlersByElement.get(f);if(a){let g=!1;const h=()=>{e.handled=!0},i=()=>{e.handled=!0,g=!0},c=[];for(let b=0;b{const b=this.manager.get(a);b&&cf[a].forEach(a=>{b.recognizeWith(a)})}),b.recognizerOptions){const e=this.manager.get(d);if(e){const f=b.recognizerOptions[d];delete f.enable,e.set(f)}}for(const[h,c]of(this.wheelInput=new co(a,this._onOtherEvent,{enable:!1}),this.moveInput=new cu(a,this._onOtherEvent,{enable:!1}),this.keyInput=new cy(a,this._onOtherEvent,{enable:!1,tabIndex:b.tabIndex}),this.contextmenuInput=new cA(a,this._onOtherEvent,{enable:!1}),this.events))c.isEmpty()||(this._toggleRecognizer(c.recognizerName,!0),this.manager.on(h,c.handleEvent))}destroy(){this.element&&(this.wheelInput.destroy(),this.moveInput.destroy(),this.keyInput.destroy(),this.contextmenuInput.destroy(),this.manager.destroy(),this.wheelInput=null,this.moveInput=null,this.keyInput=null,this.contextmenuInput=null,this.manager=null,this.element=null)}on(a,b,c){this._addEventHandler(a,b,c,!1)}once(a,b,c){this._addEventHandler(a,b,c,!0)}watch(a,b,c){this._addEventHandler(a,b,c,!1,!0)}off(a,b){this._removeEventHandler(a,b)}_toggleRecognizer(a,b){const{manager:d}=this;if(!d)return;const c=d.get(a);if(c&&c.options.enable!==b){c.set({enable:b});const e=cg[a];e&&!this.options.recognizers&&e.forEach(e=>{const f=d.get(e);b?(f.requireFailure(a),c.dropRequireFailure(e)):f.dropRequireFailure(a)})}this.wheelInput.enableEventType(a,b),this.moveInput.enableEventType(a,b),this.keyInput.enableEventType(a,b),this.contextmenuInput.enableEventType(a,b)}_addEventHandler(b,e,d,f,g){if("string"!=typeof b){for(const h in d=e,b)this._addEventHandler(h,b[h],d,f,g);return}const{manager:i,events:j}=this,c=cj[b]||b;let a=j.get(c);!a&&(a=new cD(this),j.set(c,a),a.recognizerName=ci[c]||c,i&&i.on(c,a.handleEvent)),a.add(b,e,d,f,g),a.isEmpty()||this._toggleRecognizer(a.recognizerName,!0)}_removeEventHandler(a,h){if("string"!=typeof a){for(const c in a)this._removeEventHandler(c,a[c]);return}const{events:d}=this,i=cj[a]||a,b=d.get(i);if(b&&(b.remove(a,h),b.isEmpty())){const{recognizerName:e}=b;let f=!1;for(const g of d.values())if(g.recognizerName===e&&!g.isEmpty()){f=!0;break}f||this._toggleRecognizer(e,!1)}}_onBasicInput(a){const{srcEvent:c}=a,b=ch[c.type];b&&this.manager.emit(b,a)}_onOtherEvent(a){this.manager.emit(a.type,a)}}function cF(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}function cG(c){for(var a=1;a0),e=d&&!this.state.isHovering,h=!d&&this.state.isHovering;(c||e)&&(a.features=b,c&&c(a)),e&&cP.call(this,"onMouseEnter",a),h&&cP.call(this,"onMouseLeave",a),(e||h)&&this.setState({isHovering:d})}}function cT(b){var c=this.props,d=c.onClick,f=c.onNativeClick,g=c.onDblClick,h=c.doubleClickZoom,a=[],e=g||h;switch(b.type){case"anyclick":a.push(f),e||a.push(d);break;case"click":e&&a.push(d)}(a=a.filter(Boolean)).length&&((b=cN.call(this,b)).features=cO.call(this,b.point),a.forEach(function(a){return a(b)}))}var m=(0,c.forwardRef)(function(b,h){var i,t,f=(0,c.useContext)(bK),u=(0,c.useMemo)(function(){return b.controller||new Z},[]),v=(0,c.useMemo)(function(){return new cE(null,{touchAction:b.touchAction,recognizerOptions:b.eventRecognizerOptions})},[]),g=(0,c.useRef)(null),e=(0,c.useRef)(null),a=(0,c.useRef)({width:0,height:0,state:{isHovering:!1,isDragging:!1}}).current;a.props=b,a.map=e.current&&e.current.getMap(),a.setState=function(c){a.state=cM(cM({},a.state),c),g.current.style.cursor=b.getCursor(a.state)};var j=!0,k=function(b,c,d){if(j){i=[b,c,d,];return}var e=a.props,f=e.onViewStateChange,g=e.onViewportChange;Object.defineProperty(b,"position",{get:function(){return[0,0,bM(a.map,b),]}}),f&&f({viewState:b,interactionState:c,oldViewState:d}),g&&g(b,c,d)};(0,c.useImperativeHandle)(h,function(){var a;return{getMap:(a=e).current&&a.current.getMap,queryRenderedFeatures:a.current&&a.current.queryRenderedFeatures}},[]);var d=(0,c.useMemo)(function(){return cM(cM({},f),{},{eventManager:v,container:f.container||g.current})},[f,g.current]);d.onViewportChange=k,d.viewport=f.viewport||bQ(a),a.viewport=d.viewport;var w=function(b){var c=b.isDragging,d=void 0!==c&&c;if(d!==a.state.isDragging&&a.setState({isDragging:d}),j){t=b;return}var e=a.props.onInteractionStateChange;e&&e(b)},l=function(){a.width&&a.height&&u.setOptions(cM(cM(cM({},a.props),a.props.viewState),{},{isInteractive:Boolean(a.props.onViewStateChange||a.props.onViewportChange),onViewportChange:k,onStateChange:w,eventManager:v,width:a.width,height:a.height}))},m=function(b){var c=b.width,d=b.height;a.width=c,a.height=d,l(),a.props.onResize({width:c,height:d})};(0,c.useEffect)(function(){return v.setElement(g.current),v.on({pointerdown:cQ.bind(a),pointermove:cS.bind(a),pointerup:cR.bind(a),pointerleave:cP.bind(a,"onMouseOut"),click:cT.bind(a),anyclick:cT.bind(a),dblclick:cP.bind(a,"onDblClick"),wheel:cP.bind(a,"onWheel"),contextmenu:cP.bind(a,"onContextMenu")}),function(){v.destroy()}},[]),bL(function(){if(i){var a;k.apply(void 0,function(a){if(Array.isArray(a))return ax(a)}(a=i)||function(a){if("undefined"!=typeof Symbol&&null!=a[Symbol.iterator]||null!=a["@@iterator"])return Array.from(a)}(a)||ay(a)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())}t&&w(t)}),l();var n=b.width,o=b.height,p=b.style,r=b.getCursor,s=(0,c.useMemo)(function(){return cM(cM({position:"relative"},p),{},{width:n,height:o,cursor:r(a.state)})},[p,n,o,r,a.state]);return i&&a._child||(a._child=c.createElement(bJ,{value:d},c.createElement("div",{key:"event-canvas",ref:g,style:s},c.createElement(q,aw({},b,{width:"100%",height:"100%",style:null,onResize:m,ref:e}))))),j=!1,a._child});m.supported=q.supported,m.propTypes=$,m.defaultProps=_;var cU=m;function cV(b,a){if(b===a)return!0;if(!b||!a)return!1;if(Array.isArray(b)){if(!Array.isArray(a)||b.length!==a.length)return!1;for(var c=0;c prop: ".concat(e))}}(d,a,f.current):d=function(a,c,d){if(a.style&&a.style._loaded){var b=function(c){for(var a=1;a=0||(d[a]=c[a]);return d}(a,d);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(a);for(c=0;c=0)&&Object.prototype.propertyIsEnumerable.call(a,b)&&(e[b]=a[b])}return e}(d,["layout","paint","filter","minzoom","maxzoom","beforeId",]);if(p!==a.beforeId&&b.moveLayer(c,p),e!==a.layout){var q=a.layout||{};for(var g in e)cV(e[g],q[g])||b.setLayoutProperty(c,g,e[g]);for(var r in q)e.hasOwnProperty(r)||b.setLayoutProperty(c,r,void 0)}if(f!==a.paint){var s=a.paint||{};for(var h in f)cV(f[h],s[h])||b.setPaintProperty(c,h,f[h]);for(var t in s)f.hasOwnProperty(t)||b.setPaintProperty(c,t,void 0)}for(var i in cV(m,a.filter)||b.setFilter(c,m),(n!==a.minzoom||o!==a.maxzoom)&&b.setLayerZoomRange(c,n,o),j)cV(j[i],a[i])||b.setLayerProperty(c,i,j[i])}(c,d,a,b)}catch(e){console.warn(e)}}(a,d,b,e.current):function(a,d,b){if(a.style&&a.style._loaded){var c=cZ(cZ({},b),{},{id:d});delete c.beforeId,a.addLayer(c,b.beforeId)}}(a,d,b),e.current=b,null}).propTypes=ab;var f={captureScroll:!1,captureDrag:!0,captureClick:!0,captureDoubleClick:!0,capturePointerMove:!1},d={captureScroll:a.bool,captureDrag:a.bool,captureClick:a.bool,captureDoubleClick:a.bool,capturePointerMove:a.bool};function c_(){var d=arguments.length>0&& void 0!==arguments[0]?arguments[0]:{},a=(0,c.useContext)(bK),e=(0,c.useRef)(null),f=(0,c.useRef)({props:d,state:{},context:a,containerRef:e}),b=f.current;return b.props=d,b.context=a,(0,c.useEffect)(function(){return function(a){var b=a.containerRef.current,c=a.context.eventManager;if(b&&c){var d={wheel:function(c){var b=a.props;b.captureScroll&&c.stopPropagation(),b.onScroll&&b.onScroll(c,a)},panstart:function(c){var b=a.props;b.captureDrag&&c.stopPropagation(),b.onDragStart&&b.onDragStart(c,a)},anyclick:function(c){var b=a.props;b.captureClick&&c.stopPropagation(),b.onNativeClick&&b.onNativeClick(c,a)},click:function(c){var b=a.props;b.captureClick&&c.stopPropagation(),b.onClick&&b.onClick(c,a)},dblclick:function(c){var b=a.props;b.captureDoubleClick&&c.stopPropagation(),b.onDoubleClick&&b.onDoubleClick(c,a)},pointermove:function(c){var b=a.props;b.capturePointerMove&&c.stopPropagation(),b.onPointerMove&&b.onPointerMove(c,a)}};return c.watch(d,b),function(){c.off(d)}}}(b)},[a.eventManager]),b}function c0(b){var a=b.instance,c=c_(b),d=c.context,e=c.containerRef;return a._context=d,a._containerRef=e,a._render()}var H=function(b){bW(a,b);var d,e,f=(d=a,e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(a){return!1}}(),function(){var a,b=bZ(d);if(e){var c=bZ(this).constructor;a=Reflect.construct(b,arguments,c)}else a=b.apply(this,arguments);return bY(this,a)});function a(){var b;bl(this,a);for(var e=arguments.length,h=new Array(e),d=0;d2&& void 0!==arguments[2]?arguments[2]:"x";if(null===a)return b;var c="x"===d?a.offsetWidth:a.offsetHeight;return c7(b/100*c)/c*100};function c9(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}var ae=Object.assign({},ac,{className:a.string,longitude:a.number.isRequired,latitude:a.number.isRequired,style:a.object}),af=Object.assign({},ad,{className:""});function t(b){var d,j,e,k,f,l,m,a,h=(d=b,e=(j=aA((0,c.useState)(null),2))[0],k=j[1],f=aA((0,c.useState)(null),2),l=f[0],m=f[1],a=c_(c2(c2({},d),{},{onDragStart:c5})),a.callbacks=d,a.state.dragPos=e,a.state.setDragPos=k,a.state.dragOffset=l,a.state.setDragOffset=m,(0,c.useEffect)(function(){return function(a){var b=a.context.eventManager;if(b&&a.state.dragPos){var c={panmove:function(b){return function(b,a){var h=a.props,c=a.callbacks,d=a.state,i=a.context;b.stopPropagation();var e=c3(b);d.setDragPos(e);var f=d.dragOffset;if(c.onDrag&&f){var g=Object.assign({},b);g.lngLat=c4(e,f,h,i),c.onDrag(g)}}(b,a)},panend:function(b){return function(c,a){var h=a.props,d=a.callbacks,b=a.state,i=a.context;c.stopPropagation();var e=b.dragPos,f=b.dragOffset;if(b.setDragPos(null),b.setDragOffset(null),d.onDragEnd&&e&&f){var g=Object.assign({},c);g.lngLat=c4(e,f,h,i),d.onDragEnd(g)}}(b,a)},pancancel:function(d){var c,b;return c=d,b=a.state,void(c.stopPropagation(),b.setDragPos(null),b.setDragOffset(null))}};return b.watch(c),function(){b.off(c)}}}(a)},[a.context.eventManager,Boolean(e)]),a),o=h.state,p=h.containerRef,q=b.children,r=b.className,s=b.draggable,A=b.style,t=o.dragPos,u=function(b){var a=b.props,e=b.state,f=b.context,g=a.longitude,h=a.latitude,j=a.offsetLeft,k=a.offsetTop,c=e.dragPos,d=e.dragOffset,l=f.viewport,m=f.map;if(c&&d)return[c[0]+d[0],c[1]+d[1],];var n=bM(m,{longitude:g,latitude:h}),o=l.project([g,h,n,]),i=aA(o,2),p=i[0],q=i[1];return[p+=j,q+=k]}(h),n=aA(u,2),v=n[0],w=n[1],x="translate(".concat(c7(v),"px, ").concat(c7(w),"px)"),y=s?t?"grabbing":"grab":"auto",z=(0,c.useMemo)(function(){var a=function(c){for(var a=1;a0){var t=b,u=e;for(b=0;b<=1;b+=.5)k=(i=n-b*h)+h,e=Math.max(0,d-i)+Math.max(0,k-p+d),e0){var w=a,x=f;for(a=0;a<=1;a+=v)l=(j=m-a*g)+g,f=Math.max(0,d-j)+Math.max(0,l-o+d),f1||h< -1||f<0||f>p.width||g<0||g>p.height?i.display="none":i.zIndex=Math.floor((1-h)/2*1e5)),i),S=(0,c.useCallback)(function(b){t.props.onClose();var a=t.context.eventManager;a&&a.once("click",function(a){return a.stopPropagation()},b.target)},[]);return c.createElement("div",{className:"mapboxgl-popup mapboxgl-popup-anchor-".concat(L," ").concat(N),style:R,ref:u},c.createElement("div",{key:"tip",className:"mapboxgl-popup-tip",style:{borderWidth:O}}),c.createElement("div",{key:"content",ref:j,className:"mapboxgl-popup-content"},P&&c.createElement("button",{key:"close-button",className:"mapboxgl-popup-close-button",type:"button",onClick:S},"\xd7"),Q))}function db(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}u.propTypes=ag,u.defaultProps=ah,c.memo(u);var ai=Object.assign({},d,{toggleLabel:a.string,className:a.string,style:a.object,compact:a.bool,customAttribution:a.oneOfType([a.string,a.arrayOf(a.string),])}),aj=Object.assign({},f,{className:"",toggleLabel:"Toggle Attribution"});function v(a){var b=c_(a),d=b.context,i=b.containerRef,j=(0,c.useRef)(null),e=aA((0,c.useState)(!1),2),f=e[0],m=e[1];(0,c.useEffect)(function(){var h,e,c,f,g,b;return d.map&&(h=(e={customAttribution:a.customAttribution},c=d.map,f=i.current,g=j.current,(b=new(A()).AttributionControl(e))._map=c,b._container=f,b._innerContainer=g,b._updateAttributions(),b._updateEditLink(),c.on("styledata",b._updateData),c.on("sourcedata",b._updateData),b)),function(){var a;return h&&void((a=h)._map.off("styledata",a._updateData),a._map.off("sourcedata",a._updateData))}},[d.map]);var h=void 0===a.compact?d.viewport.width<=640:a.compact;(0,c.useEffect)(function(){!h&&f&&m(!1)},[h]);var k=(0,c.useCallback)(function(){return m(function(a){return!a})},[]),l=(0,c.useMemo)(function(){return function(c){for(var a=1;ac)return 1}return 0}(b.map.version,"1.6.0")>=0?2:1:2},[b.map]),f=b.viewport.bearing,d={transform:"rotate(".concat(-f,"deg)")},2===e?c.createElement("span",{className:"mapboxgl-ctrl-icon","aria-hidden":"true",style:d}):c.createElement("span",{className:"mapboxgl-ctrl-compass-arrow",style:d})))))}function dj(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}y.propTypes=ao,y.defaultProps=ap,c.memo(y);var aq=Object.assign({},d,{className:a.string,style:a.object,maxWidth:a.number,unit:a.oneOf(["imperial","metric","nautical"])}),ar=Object.assign({},f,{className:"",maxWidth:100,unit:"metric"});function z(a){var d=c_(a),f=d.context,h=d.containerRef,e=aA((0,c.useState)(null),2),b=e[0],j=e[1];(0,c.useEffect)(function(){if(f.map){var a=new(A()).ScaleControl;a._map=f.map,a._container=h.current,j(a)}},[f.map]),b&&(b.options=a,b._onMove());var i=(0,c.useMemo)(function(){return function(c){for(var a=1;a\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",b=g.console&&(g.console.warn||g.console.log);return b&&b.call(g.console,d,e),c.apply(this,arguments)}}m="function"!=typeof Object.assign?function(b){if(b===l||null===b)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(b),c=1;c -1}function _(a){return a.trim().split(/\s+/g)}function aa(a,d,c){if(a.indexOf&&!c)return a.indexOf(d);for(var b=0;baa(e,f)&&b.push(c[a]),e[a]=f,a++}return g&&(b=d?b.sort(function(a,b){return a[d]>b[d]}):b.sort()),b}function n(e,a){for(var c,d,f=a[0].toUpperCase()+a.slice(1),b=0;b1&&!b.firstMultiple?b.firstMultiple=an(a):1===h&&(b.firstMultiple=!1);var i=b.firstInput,c=b.firstMultiple,j=c?c.center:i.center,k=a.center=ao(e);a.timeStamp=U(),a.deltaTime=a.timeStamp-i.timeStamp,a.angle=as(j,k),a.distance=ar(j,k),al(b,a),a.offsetDirection=aq(a.deltaX,a.deltaY);var d=ap(a.deltaTime,a.deltaX,a.deltaY);a.overallVelocityX=d.x,a.overallVelocityY=d.y,a.overallVelocity=T(d.x)>T(d.y)?d.x:d.y,a.scale=c?au(c.pointers,e):1,a.rotation=c?at(c.pointers,e):0,a.maxPointers=b.prevInput?a.pointers.length>b.prevInput.maxPointers?a.pointers.length:b.prevInput.maxPointers:a.pointers.length,am(b,a);var f=g.element;Z(a.srcEvent.target,f)&&(f=a.srcEvent.target),a.target=f}function al(a,b){var c=b.center,d=a.offsetDelta||{},e=a.prevDelta||{},f=a.prevInput||{};(1===b.eventType||4===f.eventType)&&(e=a.prevDelta={x:f.deltaX||0,y:f.deltaY||0},d=a.offsetDelta={x:c.x,y:c.y}),b.deltaX=e.x+(c.x-d.x),b.deltaY=e.y+(c.y-d.y)}function am(h,a){var d,e,f,g,b=h.lastInterval||a,i=a.timeStamp-b.timeStamp;if(8!=a.eventType&&(i>25||l===b.velocity)){var j=a.deltaX-b.deltaX,k=a.deltaY-b.deltaY,c=ap(i,j,k);e=c.x,f=c.y,d=T(c.x)>T(c.y)?c.x:c.y,g=aq(j,k),h.lastInterval=a}else d=b.velocity,e=b.velocityX,f=b.velocityY,g=b.direction;a.velocity=d,a.velocityX=e,a.velocityY=f,a.direction=g}function an(a){for(var c=[],b=0;b=T(b)?a<0?2:4:b<0?8:16}function ar(b,c,a){a||(a=ah);var d=c[a[0]]-b[a[0]],e=c[a[1]]-b[a[1]];return Math.sqrt(d*d+e*e)}function as(b,c,a){a||(a=ah);var d=c[a[0]]-b[a[0]],e=c[a[1]]-b[a[1]];return 180*Math.atan2(e,d)/Math.PI}function at(a,b){return as(b[1],b[0],ai)+as(a[1],a[0],ai)}function au(a,b){return ar(b[0],b[1],ai)/ar(a[0],a[1],ai)}f.prototype={handler:function(){},init:function(){this.evEl&&H(this.element,this.evEl,this.domHandler),this.evTarget&&H(this.target,this.evTarget,this.domHandler),this.evWin&&H(ae(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&I(this.element,this.evEl,this.domHandler),this.evTarget&&I(this.target,this.evTarget,this.domHandler),this.evWin&&I(ae(this.element),this.evWin,this.domHandler)}};var av={mousedown:1,mousemove:2,mouseup:4};function u(){this.evEl="mousedown",this.evWin="mousemove mouseup",this.pressed=!1,f.apply(this,arguments)}e(u,f,{handler:function(a){var b=av[a.type];1&b&&0===a.button&&(this.pressed=!0),2&b&&1!==a.which&&(b=4),this.pressed&&(4&b&&(this.pressed=!1),this.callback(this.manager,b,{pointers:[a],changedPointers:[a],pointerType:L,srcEvent:a}))}});var aw={pointerdown:1,pointermove:2,pointerup:4,pointercancel:8,pointerout:8},ax={2:K,3:"pen",4:L,5:"kinect"},M="pointerdown",N="pointermove pointerup pointercancel";function v(){this.evEl=M,this.evWin=N,f.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}g.MSPointerEvent&&!g.PointerEvent&&(M="MSPointerDown",N="MSPointerMove MSPointerUp MSPointerCancel"),e(v,f,{handler:function(a){var b=this.store,e=!1,d=aw[a.type.toLowerCase().replace("ms","")],f=ax[a.pointerType]||a.pointerType,c=aa(b,a.pointerId,"pointerId");1&d&&(0===a.button||f==K)?c<0&&(b.push(a),c=b.length-1):12&d&&(e=!0),!(c<0)&&(b[c]=a,this.callback(this.manager,d,{pointers:b,changedPointers:[a],pointerType:f,srcEvent:a}),e&&b.splice(c,1))}});var ay={touchstart:1,touchmove:2,touchend:4,touchcancel:8};function w(){this.evTarget="touchstart",this.evWin="touchstart touchmove touchend touchcancel",this.started=!1,f.apply(this,arguments)}function az(b,d){var a=ab(b.touches),c=ab(b.changedTouches);return 12&d&&(a=ac(a.concat(c),"identifier",!0)),[a,c]}e(w,f,{handler:function(c){var a=ay[c.type];if(1===a&&(this.started=!0),this.started){var b=az.call(this,c,a);12&a&&b[0].length-b[1].length==0&&(this.started=!1),this.callback(this.manager,a,{pointers:b[0],changedPointers:b[1],pointerType:K,srcEvent:c})}}});var aA={touchstart:1,touchmove:2,touchend:4,touchcancel:8};function x(){this.evTarget="touchstart touchmove touchend touchcancel",this.targetIds={},f.apply(this,arguments)}function aB(h,g){var b=ab(h.touches),c=this.targetIds;if(3&g&&1===b.length)return c[b[0].identifier]=!0,[b,b];var a,d,e=ab(h.changedTouches),f=[],i=this.target;if(d=b.filter(function(a){return Z(a.target,i)}),1===g)for(a=0;a -1&&d.splice(a,1)},2500)}}function aE(b){for(var d=b.srcEvent.clientX,e=b.srcEvent.clientY,a=0;a -1&&this.requireFail.splice(b,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(a){return!!this.simultaneous[a.id]},emit:function(d){var c=this,a=this.state;function b(a){c.manager.emit(a,d)}a<8&&b(c.options.event+aM(a)),b(c.options.event),d.additionalEvent&&b(d.additionalEvent),a>=8&&b(c.options.event+aM(a))},tryEmit:function(a){if(this.canEmit())return this.emit(a);this.state=32},canEmit:function(){for(var a=0;ac.threshold&&b&c.direction},attrTest:function(a){return h.prototype.attrTest.call(this,a)&&(2&this.state|| !(2&this.state)&&this.directionTest(a))},emit:function(a){this.pX=a.deltaX,this.pY=a.deltaY;var b=aN(a.direction);b&&(a.additionalEvent=this.options.event+b),this._super.emit.call(this,a)}}),e(p,h,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[aI]},attrTest:function(a){return this._super.attrTest.call(this,a)&&(Math.abs(a.scale-1)>this.options.threshold||2&this.state)},emit:function(a){if(1!==a.scale){var b=a.scale<1?"in":"out";a.additionalEvent=this.options.event+b}this._super.emit.call(this,a)}}),e(q,i,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[aG]},process:function(a){var b=this.options,c=a.pointers.length===b.pointers,d=a.distanceb.time;if(this._input=a,d&&c&&(!(12&a.eventType)||e)){if(1&a.eventType)this.reset(),this._timer=V(function(){this.state=8,this.tryEmit()},b.time,this);else if(4&a.eventType)return 8}else this.reset();return 32},reset:function(){clearTimeout(this._timer)},emit:function(a){8===this.state&&(a&&4&a.eventType?this.manager.emit(this.options.event+"up",a):(this._input.timeStamp=U(),this.manager.emit(this.options.event,this._input)))}}),e(r,h,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[aI]},attrTest:function(a){return this._super.attrTest.call(this,a)&&(Math.abs(a.rotation)>this.options.threshold||2&this.state)}}),e(s,h,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:30,pointers:1},getTouchAction:function(){return o.prototype.getTouchAction.call(this)},attrTest:function(a){var b,c=this.options.direction;return 30&c?b=a.overallVelocity:6&c?b=a.overallVelocityX:24&c&&(b=a.overallVelocityY),this._super.attrTest.call(this,a)&&c&a.offsetDirection&&a.distance>this.options.threshold&&a.maxPointers==this.options.pointers&&T(b)>this.options.velocity&&4&a.eventType},emit:function(a){var b=aN(a.offsetDirection);b&&this.manager.emit(this.options.event+b,a),this.manager.emit(this.options.event,a)}}),e(j,i,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[aH]},process:function(a){var b=this.options,c=a.pointers.length===b.pointers,d=a.distance1)for(var a=1;ac.length)&&(a=c.length);for(var b=0,d=new Array(a);bc?c:a}Math.hypot||(Math.hypot=function(){for(var b=0,a=arguments.length;a--;)b+=arguments[a]*arguments[a];return Math.sqrt(b)}),bd=new h(4),h!=Float32Array&&(bd[0]=0,bd[1]=0,bd[2]=0,bd[3]=0);const aG=Math.log2||function(a){return Math.log(a)*Math.LOG2E};function aH(e,f,g){var h=f[0],i=f[1],j=f[2],k=f[3],l=f[4],m=f[5],n=f[6],o=f[7],p=f[8],q=f[9],r=f[10],s=f[11],t=f[12],u=f[13],v=f[14],w=f[15],a=g[0],b=g[1],c=g[2],d=g[3];return e[0]=a*h+b*l+c*p+d*t,e[1]=a*i+b*m+c*q+d*u,e[2]=a*j+b*n+c*r+d*v,e[3]=a*k+b*o+c*s+d*w,a=g[4],b=g[5],c=g[6],d=g[7],e[4]=a*h+b*l+c*p+d*t,e[5]=a*i+b*m+c*q+d*u,e[6]=a*j+b*n+c*r+d*v,e[7]=a*k+b*o+c*s+d*w,a=g[8],b=g[9],c=g[10],d=g[11],e[8]=a*h+b*l+c*p+d*t,e[9]=a*i+b*m+c*q+d*u,e[10]=a*j+b*n+c*r+d*v,e[11]=a*k+b*o+c*s+d*w,a=g[12],b=g[13],c=g[14],d=g[15],e[12]=a*h+b*l+c*p+d*t,e[13]=a*i+b*m+c*q+d*u,e[14]=a*j+b*n+c*r+d*v,e[15]=a*k+b*o+c*s+d*w,e}function aI(b,a,f){var g,h,i,j,k,l,m,n,o,p,q,r,c=f[0],d=f[1],e=f[2];return a===b?(b[12]=a[0]*c+a[4]*d+a[8]*e+a[12],b[13]=a[1]*c+a[5]*d+a[9]*e+a[13],b[14]=a[2]*c+a[6]*d+a[10]*e+a[14],b[15]=a[3]*c+a[7]*d+a[11]*e+a[15]):(g=a[0],h=a[1],i=a[2],j=a[3],k=a[4],l=a[5],m=a[6],n=a[7],o=a[8],p=a[9],q=a[10],r=a[11],b[0]=g,b[1]=h,b[2]=i,b[3]=j,b[4]=k,b[5]=l,b[6]=m,b[7]=n,b[8]=o,b[9]=p,b[10]=q,b[11]=r,b[12]=g*c+k*d+o*e+a[12],b[13]=h*c+l*d+p*e+a[13],b[14]=i*c+m*d+q*e+a[14],b[15]=j*c+n*d+r*e+a[15]),b}function aJ(a,b,f){var c=f[0],d=f[1],e=f[2];return a[0]=b[0]*c,a[1]=b[1]*c,a[2]=b[2]*c,a[3]=b[3]*c,a[4]=b[4]*d,a[5]=b[5]*d,a[6]=b[6]*d,a[7]=b[7]*d,a[8]=b[8]*e,a[9]=b[9]*e,a[10]=b[10]*e,a[11]=b[11]*e,a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15],a}function aK(a,b){var c=a[0],d=a[1],e=a[2],f=a[3],g=a[4],h=a[5],i=a[6],j=a[7],k=a[8],l=a[9],m=a[10],n=a[11],o=a[12],p=a[13],q=a[14],r=a[15],s=b[0],t=b[1],u=b[2],v=b[3],w=b[4],x=b[5],y=b[6],z=b[7],A=b[8],B=b[9],C=b[10],D=b[11],E=b[12],F=b[13],G=b[14],H=b[15];return Math.abs(c-s)<=1e-6*Math.max(1,Math.abs(c),Math.abs(s))&&Math.abs(d-t)<=1e-6*Math.max(1,Math.abs(d),Math.abs(t))&&Math.abs(e-u)<=1e-6*Math.max(1,Math.abs(e),Math.abs(u))&&Math.abs(f-v)<=1e-6*Math.max(1,Math.abs(f),Math.abs(v))&&Math.abs(g-w)<=1e-6*Math.max(1,Math.abs(g),Math.abs(w))&&Math.abs(h-x)<=1e-6*Math.max(1,Math.abs(h),Math.abs(x))&&Math.abs(i-y)<=1e-6*Math.max(1,Math.abs(i),Math.abs(y))&&Math.abs(j-z)<=1e-6*Math.max(1,Math.abs(j),Math.abs(z))&&Math.abs(k-A)<=1e-6*Math.max(1,Math.abs(k),Math.abs(A))&&Math.abs(l-B)<=1e-6*Math.max(1,Math.abs(l),Math.abs(B))&&Math.abs(m-C)<=1e-6*Math.max(1,Math.abs(m),Math.abs(C))&&Math.abs(n-D)<=1e-6*Math.max(1,Math.abs(n),Math.abs(D))&&Math.abs(o-E)<=1e-6*Math.max(1,Math.abs(o),Math.abs(E))&&Math.abs(p-F)<=1e-6*Math.max(1,Math.abs(p),Math.abs(F))&&Math.abs(q-G)<=1e-6*Math.max(1,Math.abs(q),Math.abs(G))&&Math.abs(r-H)<=1e-6*Math.max(1,Math.abs(r),Math.abs(H))}function aL(a,b,c){return a[0]=b[0]+c[0],a[1]=b[1]+c[1],a}function aM(a,b,c,d){var e=b[0],f=b[1];return a[0]=e+d*(c[0]-e),a[1]=f+d*(c[1]-f),a}function aN(a,b){if(!a)throw new Error(b||"@math.gl/web-mercator: assertion failed.")}be=new h(2),h!=Float32Array&&(be[0]=0,be[1]=0),bf=new h(3),h!=Float32Array&&(bf[0]=0,bf[1]=0,bf[2]=0);const n=Math.PI,aO=n/4,aP=n/180,aQ=180/n;function aR(a){return Math.pow(2,a)}function aS([b,a]){return aN(Number.isFinite(b)),aN(Number.isFinite(a)&&a>= -90&&a<=90,"invalid latitude"),[512*(b*aP+n)/(2*n),512*(n+Math.log(Math.tan(aO+.5*(a*aP))))/(2*n)]}function aT([a,b]){return[(a/512*(2*n)-n)*aQ,2*(Math.atan(Math.exp(b/512*(2*n)-n))-aO)*aQ,]}function aU(a){return 2*Math.atan(.5/a)*aQ}function aV(a){return .5/Math.tan(.5*a*aP)}function aW(i,c,j=0){const[a,b,e]=i;if(aN(Number.isFinite(a)&&Number.isFinite(b),"invalid pixel coordinate"),Number.isFinite(e)){const k=aC(c,[a,b,e,1,]);return k}const f=aC(c,[a,b,0,1,]),g=aC(c,[a,b,1,1,]),d=f[2],h=g[2];return aM([],f,g,d===h?0:((j||0)-d)/(h-d))}const aX=Math.PI/180;function aY(a,c,d){const{pixelUnprojectionMatrix:e}=a,b=aC(e,[c,0,1,1,]),f=aC(e,[c,a.height,1,1,]),h=d*a.distanceScales.unitsPerMeter[2],i=(h-b[2])/(f[2]-b[2]),j=aM([],b,f,i),g=aT(j);return g[2]=d,g}class aZ{constructor({width:f,height:c,latitude:l=0,longitude:m=0,zoom:p=0,pitch:n=0,bearing:q=0,altitude:a=null,fovy:b=null,position:o=null,nearZMultiplier:t=.02,farZMultiplier:u=1.01}={width:1,height:1}){f=f||1,c=c||1,null===b&&null===a?b=aU(a=1.5):null===b?b=aU(a):null===a&&(a=aV(b));const r=aR(p);a=Math.max(.75,a);const s=function({latitude:c,longitude:i,highPrecision:j=!1}){aN(Number.isFinite(c)&&Number.isFinite(i));const b={},d=Math.cos(c*aP),e=1.4222222222222223/d,a=12790407194604047e-21/d;if(b.unitsPerMeter=[a,a,a,],b.metersPerUnit=[1/a,1/a,1/a,],b.unitsPerDegree=[1.4222222222222223,e,a,],b.degreesPerUnit=[.703125,1/e,1/a,],j){const f=aP*Math.tan(c*aP)/d,k=1.4222222222222223*f/2,g=12790407194604047e-21*f,h=g/e*a;b.unitsPerDegree2=[0,k,g,],b.unitsPerMeter2=[h,0,h,]}return b}({longitude:m,latitude:l}),d=aS([m,l]);if(d[2]=0,o){var e,g,h,i,j,k;i=d,j=d,k=(e=[],g=o,h=s.unitsPerMeter,e[0]=g[0]*h[0],e[1]=g[1]*h[1],e[2]=g[2]*h[2],e),i[0]=j[0]+k[0],i[1]=j[1]+k[1],i[2]=j[2]+k[2]}this.projectionMatrix=function({width:h,height:i,pitch:j,altitude:k,fovy:l,nearZMultiplier:m,farZMultiplier:n}){var a,f,g,c,b,d,e;const{fov:o,aspect:p,near:q,far:r}=function({width:f,height:g,fovy:a=aU(1.5),altitude:d,pitch:h=0,nearZMultiplier:i=1,farZMultiplier:j=1}){void 0!==d&&(a=aU(d));const b=.5*a*aP,c=aV(a),e=h*aP;return{fov:2*b,aspect:f/g,focalDistance:c,near:i,far:(Math.sin(e)*(Math.sin(b)*c/Math.sin(Math.min(Math.max(Math.PI/2-e-b,.01),Math.PI-.01)))+c)*j}}({width:h,height:i,altitude:k,fovy:l,pitch:j,nearZMultiplier:m,farZMultiplier:n}),s=(a=[],f=o,g=p,c=q,b=r,e=1/Math.tan(f/2),a[0]=e/g,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=e,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[11]=-1,a[12]=0,a[13]=0,a[15]=0,null!=b&&b!==1/0?(d=1/(c-b),a[10]=(b+c)*d,a[14]=2*b*c*d):(a[10]=-1,a[14]=-2*c),a);return s}({width:f,height:c,pitch:n,fovy:b,nearZMultiplier:t,farZMultiplier:u}),this.viewMatrix=function({height:F,pitch:G,bearing:H,altitude:I,scale:l,center:E=null}){var a,b,m,f,g,n,o,p,q,r,s,t,u,c,d,v,h,i,w,x,y,z,A,B,C,D,j,k;const e=aB();return aI(e,e,[0,0,-I]),a=e,b=e,m=-G*aP,f=Math.sin(m),g=Math.cos(m),n=b[4],o=b[5],p=b[6],q=b[7],r=b[8],s=b[9],t=b[10],u=b[11],b!==a&&(a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]),a[4]=n*g+r*f,a[5]=o*g+s*f,a[6]=p*g+t*f,a[7]=q*g+u*f,a[8]=r*g-n*f,a[9]=s*g-o*f,a[10]=t*g-p*f,a[11]=u*g-q*f,c=e,d=e,v=H*aP,h=Math.sin(v),i=Math.cos(v),w=d[0],x=d[1],y=d[2],z=d[3],A=d[4],B=d[5],C=d[6],D=d[7],d!==c&&(c[8]=d[8],c[9]=d[9],c[10]=d[10],c[11]=d[11],c[12]=d[12],c[13]=d[13],c[14]=d[14],c[15]=d[15]),c[0]=w*i+A*h,c[1]=x*i+B*h,c[2]=y*i+C*h,c[3]=z*i+D*h,c[4]=A*i-w*h,c[5]=B*i-x*h,c[6]=C*i-y*h,c[7]=D*i-z*h,aJ(e,e,[l/=F,l,l]),E&&aI(e,e,(j=[],k=E,j[0]=-k[0],j[1]=-k[1],j[2]=-k[2],j)),e}({height:c,scale:r,center:d,pitch:n,bearing:q,altitude:a}),this.width=f,this.height=c,this.scale=r,this.latitude=l,this.longitude=m,this.zoom=p,this.pitch=n,this.bearing=q,this.altitude=a,this.fovy=b,this.center=d,this.meterOffset=o||[0,0,0],this.distanceScales=s,this._initMatrices(),this.equals=this.equals.bind(this),this.project=this.project.bind(this),this.unproject=this.unproject.bind(this),this.projectPosition=this.projectPosition.bind(this),this.unprojectPosition=this.unprojectPosition.bind(this),Object.freeze(this)}_initMatrices(){var b,c,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,a;const{width:I,height:J,projectionMatrix:K,viewMatrix:L}=this,G=aB();aH(G,G,K),aH(G,G,L),this.viewProjectionMatrix=G;const d=aB();aJ(d,d,[I/2,-J/2,1]),aI(d,d,[1,-1,0]),aH(d,d,G);const H=(b=aB(),e=(c=d)[0],f=c[1],g=c[2],h=c[3],i=c[4],j=c[5],k=c[6],l=c[7],m=c[8],n=c[9],o=c[10],p=c[11],q=c[12],r=c[13],s=c[14],t=c[15],u=e*j-f*i,v=e*k-g*i,w=e*l-h*i,x=f*k-g*j,y=f*l-h*j,z=g*l-h*k,A=m*r-n*q,B=m*s-o*q,C=m*t-p*q,D=n*s-o*r,E=n*t-p*r,F=o*t-p*s,a=u*F-v*E+w*D+x*C-y*B+z*A,a?(a=1/a,b[0]=(j*F-k*E+l*D)*a,b[1]=(g*E-f*F-h*D)*a,b[2]=(r*z-s*y+t*x)*a,b[3]=(o*y-n*z-p*x)*a,b[4]=(k*C-i*F-l*B)*a,b[5]=(e*F-g*C+h*B)*a,b[6]=(s*w-q*z-t*v)*a,b[7]=(m*z-o*w+p*v)*a,b[8]=(i*E-j*C+l*A)*a,b[9]=(f*C-e*E-h*A)*a,b[10]=(q*y-r*w+t*u)*a,b[11]=(n*w-m*y-p*u)*a,b[12]=(j*B-i*D-k*A)*a,b[13]=(e*D-f*B+g*A)*a,b[14]=(r*v-q*x-s*u)*a,b[15]=(m*x-n*v+o*u)*a,b):null);if(!H)throw new Error("Pixel project matrix not invertible");this.pixelProjectionMatrix=d,this.pixelUnprojectionMatrix=H}equals(a){return a instanceof aZ&&a.width===this.width&&a.height===this.height&&aK(a.projectionMatrix,this.projectionMatrix)&&aK(a.viewMatrix,this.viewMatrix)}project(a,{topLeft:f=!0}={}){const g=this.projectPosition(a),b=function(d,e){const[a,b,c=0]=d;return aN(Number.isFinite(a)&&Number.isFinite(b)&&Number.isFinite(c)),aC(e,[a,b,c,1])}(g,this.pixelProjectionMatrix),[c,d]=b,e=f?d:this.height-d;return 2===a.length?[c,e]:[c,e,b[2]]}unproject(f,{topLeft:g=!0,targetZ:a}={}){const[h,d,e]=f,i=g?d:this.height-d,j=a&&a*this.distanceScales.unitsPerMeter[2],k=aW([h,i,e],this.pixelUnprojectionMatrix,j),[b,c,l]=this.unprojectPosition(k);return Number.isFinite(e)?[b,c,l]:Number.isFinite(a)?[b,c,a]:[b,c]}projectPosition(a){const[b,c]=aS(a),d=(a[2]||0)*this.distanceScales.unitsPerMeter[2];return[b,c,d]}unprojectPosition(a){const[b,c]=aT(a),d=(a[2]||0)*this.distanceScales.metersPerUnit[2];return[b,c,d]}projectFlat(a){return aS(a)}unprojectFlat(a){return aT(a)}getMapCenterByLngLatPosition({lngLat:c,pos:d}){var a,b;const e=aW(d,this.pixelUnprojectionMatrix),f=aS(c),g=aL([],f,(a=[],b=e,a[0]=-b[0],a[1]=-b[1],a)),h=aL([],this.center,g);return aT(h)}getLocationAtPoint({lngLat:a,pos:b}){return this.getMapCenterByLngLatPosition({lngLat:a,pos:b})}fitBounds(c,d={}){const{width:a,height:b}=this,{longitude:e,latitude:f,zoom:g}=function({width:m,height:n,bounds:o,minExtent:f=0,maxZoom:p=24,padding:a=0,offset:g=[0,0]}){const[[q,r],[s,t]]=o;if(Number.isFinite(a)){const b=a;a={top:b,bottom:b,left:b,right:b}}else aN(Number.isFinite(a.top)&&Number.isFinite(a.bottom)&&Number.isFinite(a.left)&&Number.isFinite(a.right));const c=aS([q,aF(t,-85.051129,85.051129),]),d=aS([s,aF(r,-85.051129,85.051129),]),h=[Math.max(Math.abs(d[0]-c[0]),f),Math.max(Math.abs(d[1]-c[1]),f),],e=[m-a.left-a.right-2*Math.abs(g[0]),n-a.top-a.bottom-2*Math.abs(g[1]),];aN(e[0]>0&&e[1]>0);const i=e[0]/h[0],j=e[1]/h[1],u=(a.right-a.left)/2/i,v=(a.bottom-a.top)/2/j,w=[(d[0]+c[0])/2+u,(d[1]+c[1])/2+v,],k=aT(w),l=Math.min(p,aG(Math.abs(Math.min(i,j))));return aN(Number.isFinite(l)),{longitude:k[0],latitude:k[1],zoom:l}}(Object.assign({width:a,height:b,bounds:c},d));return new aZ({width:a,height:b,longitude:e,latitude:f,zoom:g})}getBounds(b){const a=this.getBoundingRegion(b),c=Math.min(...a.map(a=>a[0])),d=Math.max(...a.map(a=>a[0])),e=Math.min(...a.map(a=>a[1])),f=Math.max(...a.map(a=>a[1]));return[[c,e],[d,f],]}getBoundingRegion(a={}){return function(a,d=0){const{width:e,height:h,unproject:b}=a,c={targetZ:d},i=b([0,h],c),j=b([e,h],c);let f,g;const k=a.fovy?.5*a.fovy*aX:Math.atan(.5/a.altitude),l=(90-a.pitch)*aX;return k>l-.01?(f=aY(a,0,d),g=aY(a,e,d)):(f=b([0,0],c),g=b([e,0],c)),[i,j,g,f]}(this,a.z||0)}}const a$=["longitude","latitude","zoom"],a_={curve:1.414,speed:1.2};function a0(d,h,i){var f,j,k,o,p,q;i=Object.assign({},a_,i);const g=i.curve,l=d.zoom,w=[d.longitude,d.latitude],x=aR(l),y=h.zoom,z=[h.longitude,h.latitude],A=aR(y-l),r=aS(w),B=aS(z),s=(f=[],j=B,k=r,f[0]=j[0]-k[0],f[1]=j[1]-k[1],f),a=Math.max(d.width,d.height),e=a/A,t=(p=(o=s)[0],q=o[1],Math.hypot(p,q)*x),c=Math.max(t,.01),b=g*g,m=(e*e-a*a+b*b*c*c)/(2*a*b*c),n=(e*e-a*a-b*b*c*c)/(2*e*b*c),u=Math.log(Math.sqrt(m*m+1)-m),v=Math.log(Math.sqrt(n*n+1)-n);return{startZoom:l,startCenterXY:r,uDelta:s,w0:a,u1:t,S:(v-u)/g,rho:g,rho2:b,r0:u,r1:v}}var N=function(){if("undefined"!=typeof Map)return Map;function a(a,c){var b=-1;return a.some(function(a,d){return a[0]===c&&(b=d,!0)}),b}return function(){function b(){this.__entries__=[]}return Object.defineProperty(b.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),b.prototype.get=function(c){var d=a(this.__entries__,c),b=this.__entries__[d];return b&&b[1]},b.prototype.set=function(b,c){var d=a(this.__entries__,b);~d?this.__entries__[d][1]=c:this.__entries__.push([b,c])},b.prototype.delete=function(d){var b=this.__entries__,c=a(b,d);~c&&b.splice(c,1)},b.prototype.has=function(b){return!!~a(this.__entries__,b)},b.prototype.clear=function(){this.__entries__.splice(0)},b.prototype.forEach=function(e,a){void 0===a&&(a=null);for(var b=0,c=this.__entries__;b0},a.prototype.connect_=function(){a1&&!this.connected_&&(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),a4?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},a.prototype.disconnect_=function(){a1&&this.connected_&&(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},a.prototype.onTransitionEnd_=function(b){var a=b.propertyName,c=void 0===a?"":a;a3.some(function(a){return!!~c.indexOf(a)})&&this.refresh()},a.getInstance=function(){return this.instance_||(this.instance_=new a),this.instance_},a.instance_=null,a}(),a6=function(b,c){for(var a=0,d=Object.keys(c);a0},a}(),bj="undefined"!=typeof WeakMap?new WeakMap:new N,O=function(){function a(b){if(!(this instanceof a))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var c=a5.getInstance(),d=new bi(b,c,this);bj.set(this,d)}return a}();["observe","unobserve","disconnect"].forEach(function(a){O.prototype[a]=function(){var b;return(b=bj.get(this))[a].apply(b,arguments)}});var bk=void 0!==o.ResizeObserver?o.ResizeObserver:O;function bl(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function bm(d,c){for(var b=0;b=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function(a){throw a},f:b}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var e,f,g=!0,h=!1;return{s:function(){e=a[Symbol.iterator]()},n:function(){var a=e.next();return g=a.done,a},e:function(a){h=!0,f=a},f:function(){try{g||null==e.return||e.return()}finally{if(h)throw f}}}}function br(a,c){if(a){if("string"==typeof a)return bs(a,c);var b=Object.prototype.toString.call(a).slice(8,-1);if("Object"===b&&a.constructor&&(b=a.constructor.name),"Map"===b||"Set"===b)return Array.from(a);if("Arguments"===b||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b))return bs(a,c)}}function bs(c,a){(null==a||a>c.length)&&(a=c.length);for(var b=0,d=new Array(a);b1&& void 0!==arguments[1]?arguments[1]:"component";b.debug&&a.checkPropTypes(Q,b,"prop",c)}var i=function(){function a(b){var c=this;if(bl(this,a),g(this,"props",R),g(this,"width",0),g(this,"height",0),g(this,"_fireLoadEvent",function(){c.props.onLoad({type:"load",target:c._map})}),g(this,"_handleError",function(a){c.props.onError(a)}),!b.mapboxgl)throw new Error("Mapbox not available");this.mapboxgl=b.mapboxgl,a.initialized||(a.initialized=!0,this._checkStyleSheet(this.mapboxgl.version)),this._initialize(b)}return bn(a,[{key:"finalize",value:function(){return this._destroy(),this}},{key:"setProps",value:function(a){return this._update(this.props,a),this}},{key:"redraw",value:function(){var a=this._map;a.style&&(a._frame&&(a._frame.cancel(),a._frame=null),a._render())}},{key:"getMap",value:function(){return this._map}},{key:"_reuse",value:function(b){this._map=a.savedMap;var d=this._map.getContainer(),c=b.container;for(c.classList.add("mapboxgl-map");d.childNodes.length>0;)c.appendChild(d.childNodes[0]);this._map._container=c,a.savedMap=null,b.mapStyle&&this._map.setStyle(bu(b.mapStyle),{diff:!1}),this._map.isStyleLoaded()?this._fireLoadEvent():this._map.once("styledata",this._fireLoadEvent)}},{key:"_create",value:function(b){if(b.reuseMaps&&a.savedMap)this._reuse(b);else{if(b.gl){var d=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=function(){return HTMLCanvasElement.prototype.getContext=d,b.gl}}var c={container:b.container,center:[0,0],zoom:8,pitch:0,bearing:0,maxZoom:24,style:bu(b.mapStyle),interactive:!1,trackResize:!1,attributionControl:b.attributionControl,preserveDrawingBuffer:b.preserveDrawingBuffer};b.transformRequest&&(c.transformRequest=b.transformRequest),this._map=new this.mapboxgl.Map(Object.assign({},c,b.mapOptions)),this._map.once("load",this._fireLoadEvent),this._map.on("error",this._handleError)}return this}},{key:"_destroy",value:function(){this._map&&(this.props.reuseMaps&&!a.savedMap?(a.savedMap=this._map,this._map.off("load",this._fireLoadEvent),this._map.off("error",this._handleError),this._map.off("styledata",this._fireLoadEvent)):this._map.remove(),this._map=null)}},{key:"_initialize",value:function(a){var d=this;a=Object.assign({},R,a),bw(a,"Mapbox"),this.mapboxgl.accessToken=a.mapboxApiAccessToken||R.mapboxApiAccessToken,this.mapboxgl.baseApiUrl=a.mapboxApiUrl,this._create(a);var b=a.container;Object.defineProperty(b,"offsetWidth",{configurable:!0,get:function(){return d.width}}),Object.defineProperty(b,"clientWidth",{configurable:!0,get:function(){return d.width}}),Object.defineProperty(b,"offsetHeight",{configurable:!0,get:function(){return d.height}}),Object.defineProperty(b,"clientHeight",{configurable:!0,get:function(){return d.height}});var c=this._map.getCanvas();c&&(c.style.outline="none"),this._updateMapViewport({},a),this._updateMapSize({},a),this.props=a}},{key:"_update",value:function(b,a){if(this._map){bw(a=Object.assign({},this.props,a),"Mapbox");var c=this._updateMapViewport(b,a),d=this._updateMapSize(b,a);this._updateMapStyle(b,a),!a.asyncRender&&(c||d)&&this.redraw(),this.props=a}}},{key:"_updateMapStyle",value:function(b,a){b.mapStyle!==a.mapStyle&&this._map.setStyle(bu(a.mapStyle),{diff:!a.preventStyleDiffing})}},{key:"_updateMapSize",value:function(b,a){var c=b.width!==a.width||b.height!==a.height;return c&&(this.width=a.width,this.height=a.height,this._map.resize()),c}},{key:"_updateMapViewport",value:function(d,e){var b=this._getViewState(d),a=this._getViewState(e),c=a.latitude!==b.latitude||a.longitude!==b.longitude||a.zoom!==b.zoom||a.pitch!==b.pitch||a.bearing!==b.bearing||a.altitude!==b.altitude;return c&&(this._map.jumpTo(this._viewStateToMapboxProps(a)),a.altitude!==b.altitude&&(this._map.transform.altitude=a.altitude)),c}},{key:"_getViewState",value:function(b){var a=b.viewState||b,f=a.longitude,g=a.latitude,h=a.zoom,c=a.pitch,d=a.bearing,e=a.altitude;return{longitude:f,latitude:g,zoom:h,pitch:void 0===c?0:c,bearing:void 0===d?0:d,altitude:void 0===e?1.5:e}}},{key:"_checkStyleSheet",value:function(){var c=arguments.length>0&& void 0!==arguments[0]?arguments[0]:"0.47.0";if(void 0!==P)try{var a=P.createElement("div");if(a.className="mapboxgl-map",a.style.display="none",P.body.appendChild(a),!("static"!==window.getComputedStyle(a).position)){var b=P.createElement("link");b.setAttribute("rel","stylesheet"),b.setAttribute("type","text/css"),b.setAttribute("href","https://api.tiles.mapbox.com/mapbox-gl-js/v".concat(c,"/mapbox-gl.css")),P.head.appendChild(b)}}catch(d){}}},{key:"_viewStateToMapboxProps",value:function(a){return{center:[a.longitude,a.latitude,],zoom:a.zoom,bearing:a.bearing,pitch:a.pitch}}},]),a}();g(i,"initialized",!1),g(i,"propTypes",Q),g(i,"defaultProps",R),g(i,"savedMap",null);var S=b(6158),A=b.n(S);function bx(a){return Array.isArray(a)||ArrayBuffer.isView(a)}function by(a,b){if(a===b)return!0;if(bx(a)&&bx(b)){if(a.length!==b.length)return!1;for(var c=0;c=Math.abs(a-b)}function bz(a,b,c){return Math.max(b,Math.min(c,a))}function bA(a,c,b){return bx(a)?a.map(function(a,d){return bA(a,c[d],b)}):b*c+(1-b)*a}function bB(a,b){if(!a)throw new Error(b||"react-map-gl: assertion failed.")}function bC(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}function bD(c){for(var a=1;a0,"`scale` must be a positive number");var f=this._state,b=f.startZoom,c=f.startZoomLngLat;Number.isFinite(b)||(b=this._viewportProps.zoom,c=this._unproject(i)||this._unproject(d)),bB(c,"`startZoomLngLat` prop is required for zoom behavior to calculate where to position the map.");var g=this._calculateNewZoom({scale:e,startZoom:b||0}),j=new aZ(Object.assign({},this._viewportProps,{zoom:g})),k=j.getMapCenterByLngLatPosition({lngLat:c,pos:d}),h=aA(k,2),l=h[0],m=h[1];return this._getUpdatedMapState({zoom:g,longitude:l,latitude:m})}},{key:"zoomEnd",value:function(){return this._getUpdatedMapState({startZoomLngLat:null,startZoom:null})}},{key:"_getUpdatedMapState",value:function(b){return new a(Object.assign({},this._viewportProps,this._state,b))}},{key:"_applyConstraints",value:function(a){var b=a.maxZoom,c=a.minZoom,d=a.zoom;a.zoom=bz(d,c,b);var e=a.maxPitch,f=a.minPitch,g=a.pitch;return a.pitch=bz(g,f,e),Object.assign(a,function({width:j,height:e,longitude:b,latitude:a,zoom:d,pitch:k=0,bearing:c=0}){(b< -180||b>180)&&(b=aD(b+180,360)-180),(c< -180||c>180)&&(c=aD(c+180,360)-180);const f=aG(e/512);if(d<=f)d=f,a=0;else{const g=e/2/Math.pow(2,d),h=aT([0,g])[1];if(ai&&(a=i)}}return{width:j,height:e,longitude:b,latitude:a,zoom:d,pitch:k,bearing:c}}(a)),a}},{key:"_unproject",value:function(a){var b=new aZ(this._viewportProps);return a&&b.unproject(a)}},{key:"_calculateNewLngLat",value:function(a){var b=a.startPanLngLat,c=a.pos,d=new aZ(this._viewportProps);return d.getMapCenterByLngLatPosition({lngLat:b,pos:c})}},{key:"_calculateNewZoom",value:function(a){var c=a.scale,d=a.startZoom,b=this._viewportProps,e=b.maxZoom,f=b.minZoom;return bz(d+Math.log2(c),f,e)}},{key:"_calculateNewPitchAndBearing",value:function(c){var f=c.deltaScaleX,a=c.deltaScaleY,g=c.startBearing,b=c.startPitch;a=bz(a,-1,1);var e=this._viewportProps,h=e.minPitch,i=e.maxPitch,d=b;return a>0?d=b+a*(i-b):a<0&&(d=b-a*(h-b)),{pitch:d,bearing:g+180*f}}},{key:"_getRotationParams",value:function(c,d){var h=c[0]-d[0],e=c[1]-d[1],i=c[1],a=d[1],f=this._viewportProps,j=f.width,g=f.height,b=0;return e>0?Math.abs(g-a)>5&&(b=e/(a-g)*1.2):e<0&&a>5&&(b=1-i/a),{deltaScaleX:h/j,deltaScaleY:b=Math.min(1,Math.max(-1,b))}}},]),a}();function bG(a){return a[0].toLowerCase()+a.slice(1)}function bH(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}function bI(c){for(var a=1;a1&& void 0!==arguments[1]?arguments[1]:{},b=a.current&&a.current.getMap();return b&&b.queryRenderedFeatures(c,d)}}},[]);var p=(0,c.useCallback)(function(b){var a=b.target;a===o.current&&a.scrollTo(0,0)},[]),q=d&&c.createElement(bJ,{value:bO(bO({},b),{},{viewport:b.viewport||bQ(bO({map:d,props:a},m)),map:d,container:b.container||h.current})},c.createElement("div",{key:"map-overlays",className:"overlays",ref:o,style:bR,onScroll:p},a.children)),r=a.className,s=a.width,t=a.height,u=a.style,v=a.visibilityConstraints,w=Object.assign({position:"relative"},u,{width:s,height:t}),x=a.visible&&function(c){var b=arguments.length>1&& void 0!==arguments[1]?arguments[1]:B;for(var a in b){var d=a.slice(0,3),e=bG(a.slice(3));if("min"===d&&c[e]b[a])return!1}return!0}(a.viewState||a,v),y=Object.assign({},bR,{visibility:x?"inherit":"hidden"});return c.createElement("div",{key:"map-container",ref:h,style:w},c.createElement("div",{key:"map-mapbox",ref:n,style:y,className:r}),q,!l&&!a.disableTokenWarning&&c.createElement(bS,null))});j.supported=function(){return A()&&A().supported()},j.propTypes=T,j.defaultProps=U;var q=j;function bT(c,a){(null==a||a>c.length)&&(a=c.length);for(var b=0,d=new Array(a);b=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function(a){throw a},f:b}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var e,f,g=!0,h=!1;return{s:function(){e=a[Symbol.iterator]()},n:function(){var a=e.next();return g=a.done,a},e:function(a){h=!0,f=a},f:function(){try{g||null==e.return||e.return()}finally{if(h)throw f}}}}(this.propNames||[]);try{for(a.s();!(b=a.n()).done;){var c=b.value;if(!by(d[c],e[c]))return!1}}catch(f){a.e(f)}finally{a.f()}return!0}},{key:"initializeProps",value:function(a,b){return{start:a,end:b}}},{key:"interpolateProps",value:function(a,b,c){bB(!1,"interpolateProps is not implemented")}},{key:"getDuration",value:function(b,a){return a.transitionDuration}},]),a}();function bU(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function bV(a,b){return(bV=Object.setPrototypeOf||function(a,b){return a.__proto__=b,a})(a,b)}function bW(b,a){if("function"!=typeof a&&null!==a)throw new TypeError("Super expression must either be null or a function");b.prototype=Object.create(a&&a.prototype,{constructor:{value:b,writable:!0,configurable:!0}}),Object.defineProperty(b,"prototype",{writable:!1}),a&&bV(b,a)}function bX(a){return(bX="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a})(a)}function bY(b,a){if(a&&("object"===bX(a)||"function"==typeof a))return a;if(void 0!==a)throw new TypeError("Derived constructors may only return object or undefined");return bU(b)}function bZ(a){return(bZ=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)})(a)}var b$={longitude:1,bearing:1};function b_(a){return Number.isFinite(a)||Array.isArray(a)}function b0(b,c,a){return b in b$&&Math.abs(a-c)>180&&(a=a<0?a+360:a-360),a}function b1(a,c){if("undefined"==typeof Symbol||null==a[Symbol.iterator]){if(Array.isArray(a)||(e=b2(a))||c&&a&&"number"==typeof a.length){e&&(a=e);var d=0,b=function(){};return{s:b,n:function(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function(a){throw a},f:b}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var e,f,g=!0,h=!1;return{s:function(){e=a[Symbol.iterator]()},n:function(){var a=e.next();return g=a.done,a},e:function(a){h=!0,f=a},f:function(){try{g||null==e.return||e.return()}finally{if(h)throw f}}}}function b2(a,c){if(a){if("string"==typeof a)return b3(a,c);var b=Object.prototype.toString.call(a).slice(8,-1);if("Object"===b&&a.constructor&&(b=a.constructor.name),"Map"===b||"Set"===b)return Array.from(a);if("Arguments"===b||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b))return b3(a,c)}}function b3(c,a){(null==a||a>c.length)&&(a=c.length);for(var b=0,d=new Array(a);b=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function(a){throw a},f:b}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var e,f,g=!0,h=!1;return{s:function(){e=a[Symbol.iterator]()},n:function(){var a=e.next();return g=a.done,a},e:function(a){h=!0,f=a},f:function(){try{g||null==e.return||e.return()}finally{if(h)throw f}}}}function b9(a,c){if(a){if("string"==typeof a)return ca(a,c);var b=Object.prototype.toString.call(a).slice(8,-1);if("Object"===b&&a.constructor&&(b=a.constructor.name),"Map"===b||"Set"===b)return Array.from(a);if("Arguments"===b||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b))return ca(a,c)}}function ca(c,a){(null==a||a>c.length)&&(a=c.length);for(var b=0,d=new Array(a);b0&& void 0!==arguments[0]?arguments[0]:{};return bl(this,d),g(bU(a=e.call(this)),"propNames",b4),a.props=Object.assign({},b7,b),a}bn(d,[{key:"initializeProps",value:function(h,i){var j,e={},f={},c=b1(b5);try{for(c.s();!(j=c.n()).done;){var a=j.value,g=h[a],k=i[a];bB(b_(g)&&b_(k),"".concat(a," must be supplied for transition")),e[a]=g,f[a]=b0(a,g,k)}}catch(n){c.e(n)}finally{c.f()}var l,d=b1(b6);try{for(d.s();!(l=d.n()).done;){var b=l.value,m=h[b]||0,o=i[b]||0;e[b]=m,f[b]=b0(b,m,o)}}catch(p){d.e(p)}finally{d.f()}return{start:e,end:f}}},{key:"interpolateProps",value:function(c,d,e){var f,g=function(h,i,j,p={}){var c,d,e,k;const a={},{startZoom:q,startCenterXY:r,uDelta:s,w0:t,u1:l,S:u,rho:m,rho2:v,r0:b}=a0(h,i,p);if(l<.01){for(const f of a$){const w=h[f],x=i[f];a[f]=aE(w,x,j)}return a}const n=j*u,y=q+(k=1/(Math.cosh(b)/Math.cosh(b+m*n)),aG(k)),g=(c=[],d=s,e=t*((Math.cosh(b)*Math.tanh(b+m*n)-Math.sinh(b))/v)/l,c[0]=d[0]*e,c[1]=d[1]*e,c);aL(g,g,r);const o=aT(g);return a.longitude=o[0],a.latitude=o[1],a.zoom=y,a}(c,d,e,this.props),a=b1(b6);try{for(a.s();!(f=a.n()).done;){var b=f.value;g[b]=bA(c[b],d[b],e)}}catch(h){a.e(h)}finally{a.f()}return g}},{key:"getDuration",value:function(c,b){var a=b.transitionDuration;return"auto"===a&&(a=function(f,g,a={}){a=Object.assign({},a_,a);const{screenSpeed:c,speed:h,maxDuration:d}=a,{S:i,rho:j}=a0(f,g,a),e=1e3*i;let b;return b=Number.isFinite(c)?e/(c/j):e/h,Number.isFinite(d)&&b>d?0:b}(c,b,this.props)),a}},])}(C);var cb=["longitude","latitude","zoom","bearing","pitch",],D=function(b){bW(a,b);var c,d,e=(c=a,d=function(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(a){return!1}}(),function(){var a,b=bZ(c);if(d){var e=bZ(this).constructor;a=Reflect.construct(b,arguments,e)}else a=b.apply(this,arguments);return bY(this,a)});function a(){var c,b=arguments.length>0&& void 0!==arguments[0]?arguments[0]:{};return bl(this,a),c=e.call(this),Array.isArray(b)&&(b={transitionProps:b}),c.propNames=b.transitionProps||cb,b.around&&(c.around=b.around),c}return bn(a,[{key:"initializeProps",value:function(g,c){var d={},e={};if(this.around){d.around=this.around;var h=new aZ(g).unproject(this.around);Object.assign(e,c,{around:new aZ(c).project(h),aroundLngLat:h})}var i,b=b8(this.propNames);try{for(b.s();!(i=b.n()).done;){var a=i.value,f=g[a],j=c[a];bB(b_(f)&&b_(j),"".concat(a," must be supplied for transition")),d[a]=f,e[a]=b0(a,f,j)}}catch(k){b.e(k)}finally{b.f()}return{start:d,end:e}}},{key:"interpolateProps",value:function(e,a,f){var g,b={},c=b8(this.propNames);try{for(c.s();!(g=c.n()).done;){var d=g.value;b[d]=bA(e[d],a[d],f)}}catch(i){c.e(i)}finally{c.f()}if(a.around){var j=new aZ(Object.assign({},a,b)).getMapCenterByLngLatPosition({lngLat:a.aroundLngLat,pos:bA(e.around,a.around,f)}),h=aA(j,2),k=h[0],l=h[1];b.longitude=k,b.latitude=l}return b}},]),a}(C),r=function(){},E={BREAK:1,SNAP_TO_END:2,IGNORE:3,UPDATE:4},V={transitionDuration:0,transitionEasing:function(a){return a},transitionInterpolator:new D,transitionInterruption:E.BREAK,onTransitionStart:r,onTransitionInterrupt:r,onTransitionEnd:r},F=function(){function a(){var c=this,b=arguments.length>0&& void 0!==arguments[0]?arguments[0]:{};bl(this,a),g(this,"_animationFrame",null),g(this,"_onTransitionFrame",function(){c._animationFrame=requestAnimationFrame(c._onTransitionFrame),c._updateViewport()}),this.props=null,this.onViewportChange=b.onViewportChange||r,this.onStateChange=b.onStateChange||r,this.time=b.getTime||Date.now}return bn(a,[{key:"getViewportInTransition",value:function(){return this._animationFrame?this.state.propsInTransition:null}},{key:"processViewportChange",value:function(c){var a=this.props;if(this.props=c,!a||this._shouldIgnoreViewportChange(a,c))return!1;if(this._isTransitionEnabled(c)){var d=Object.assign({},a),b=Object.assign({},c);if(this._isTransitionInProgress()&&(a.onTransitionInterrupt(),this.state.interruption===E.SNAP_TO_END?Object.assign(d,this.state.endProps):Object.assign(d,this.state.propsInTransition),this.state.interruption===E.UPDATE)){var f,g,h,e=this.time(),i=(e-this.state.startTime)/this.state.duration;b.transitionDuration=this.state.duration-(e-this.state.startTime),b.transitionEasing=(h=(f=this.state.easing)(g=i),function(a){return 1/(1-h)*(f(a*(1-g)+g)-h)}),b.transitionInterpolator=d.transitionInterpolator}return b.onTransitionStart(),this._triggerTransition(d,b),!0}return this._isTransitionInProgress()&&(a.onTransitionInterrupt(),this._endTransition()),!1}},{key:"_isTransitionInProgress",value:function(){return Boolean(this._animationFrame)}},{key:"_isTransitionEnabled",value:function(a){var b=a.transitionDuration,c=a.transitionInterpolator;return(b>0||"auto"===b)&&Boolean(c)}},{key:"_isUpdateDueToCurrentTransition",value:function(a){return!!this.state.propsInTransition&&this.state.interpolator.arePropsEqual(a,this.state.propsInTransition)}},{key:"_shouldIgnoreViewportChange",value:function(b,a){return!b||(this._isTransitionInProgress()?this.state.interruption===E.IGNORE||this._isUpdateDueToCurrentTransition(a):!this._isTransitionEnabled(a)||a.transitionInterpolator.arePropsEqual(b,a))}},{key:"_triggerTransition",value:function(b,a){bB(this._isTransitionEnabled(a)),this._animationFrame&&cancelAnimationFrame(this._animationFrame);var c=a.transitionInterpolator,d=c.getDuration?c.getDuration(b,a):a.transitionDuration;if(0!==d){var e=a.transitionInterpolator.initializeProps(b,a),f={inTransition:!0,isZooming:b.zoom!==a.zoom,isPanning:b.longitude!==a.longitude||b.latitude!==a.latitude,isRotating:b.bearing!==a.bearing||b.pitch!==a.pitch};this.state={duration:d,easing:a.transitionEasing,interpolator:a.transitionInterpolator,interruption:a.transitionInterruption,startTime:this.time(),startProps:e.start,endProps:e.end,animation:null,propsInTransition:{}},this._onTransitionFrame(),this.onStateChange(f)}}},{key:"_endTransition",value:function(){this._animationFrame&&(cancelAnimationFrame(this._animationFrame),this._animationFrame=null),this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1})}},{key:"_updateViewport",value:function(){var d=this.time(),a=this.state,e=a.startTime,f=a.duration,g=a.easing,h=a.interpolator,i=a.startProps,j=a.endProps,c=!1,b=(d-e)/f;b>=1&&(b=1,c=!0),b=g(b);var k=h.interpolateProps(i,j,b),l=new bF(Object.assign({},this.props,k));this.state.propsInTransition=l.getViewportProps(),this.onViewportChange(this.state.propsInTransition,this.props),c&&(this._endTransition(),this.props.onTransitionEnd())}},]),a}();g(F,"defaultProps",V);var W=b(840),k=b.n(W);const cc={mousedown:1,mousemove:2,mouseup:4};!function(a){const b=a.prototype.handler;a.prototype.handler=function(a){const c=this.store;a.button>0&&"pointerdown"===a.type&& !function(b,c){for(let a=0;ab.pointerId===a.pointerId)&&c.push(a),b.call(this,a)}}(k().PointerEventInput),k().MouseInput.prototype.handler=function(a){let b=cc[a.type];1&b&&a.button>=0&&(this.pressed=!0),2&b&&0===a.which&&(b=4),this.pressed&&(4&b&&(this.pressed=!1),this.callback(this.manager,b,{pointers:[a],changedPointers:[a],pointerType:"mouse",srcEvent:a}))};const cd=k().Manager;var e=k();const ce=e?[[e.Pan,{event:"tripan",pointers:3,threshold:0,enable:!1},],[e.Rotate,{enable:!1},],[e.Pinch,{enable:!1},],[e.Swipe,{enable:!1},],[e.Pan,{threshold:0,enable:!1},],[e.Press,{enable:!1},],[e.Tap,{event:"doubletap",taps:2,enable:!1},],[e.Tap,{event:"anytap",enable:!1},],[e.Tap,{enable:!1},],]:null,cf={tripan:["rotate","pinch","pan"],rotate:["pinch"],pinch:["pan"],pan:["press","doubletap","anytap","tap"],doubletap:["anytap"],anytap:["tap"]},cg={doubletap:["tap"]},ch={pointerdown:"pointerdown",pointermove:"pointermove",pointerup:"pointerup",touchstart:"pointerdown",touchmove:"pointermove",touchend:"pointerup",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup"},s={KEY_EVENTS:["keydown","keyup"],MOUSE_EVENTS:["mousedown","mousemove","mouseup","mouseover","mouseout","mouseleave",],WHEEL_EVENTS:["wheel","mousewheel"]},ci={tap:"tap",anytap:"anytap",doubletap:"doubletap",press:"press",pinch:"pinch",pinchin:"pinch",pinchout:"pinch",pinchstart:"pinch",pinchmove:"pinch",pinchend:"pinch",pinchcancel:"pinch",rotate:"rotate",rotatestart:"rotate",rotatemove:"rotate",rotateend:"rotate",rotatecancel:"rotate",tripan:"tripan",tripanstart:"tripan",tripanmove:"tripan",tripanup:"tripan",tripandown:"tripan",tripanleft:"tripan",tripanright:"tripan",tripanend:"tripan",tripancancel:"tripan",pan:"pan",panstart:"pan",panmove:"pan",panup:"pan",pandown:"pan",panleft:"pan",panright:"pan",panend:"pan",pancancel:"pan",swipe:"swipe",swipeleft:"swipe",swiperight:"swipe",swipeup:"swipe",swipedown:"swipe"},cj={click:"tap",anyclick:"anytap",dblclick:"doubletap",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup",mouseover:"pointerover",mouseout:"pointerout",mouseleave:"pointerleave"},X="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",G="undefined"!=typeof window?window:b.g;void 0!==b.g?b.g:window;let Y=!1;try{const l={get passive(){return Y=!0,!0}};G.addEventListener("test",l,l),G.removeEventListener("test",l,l)}catch(ck){}const cl=-1!==X.indexOf("firefox"),{WHEEL_EVENTS:cm}=s,cn="wheel";class co{constructor(b,c,a={}){this.element=b,this.callback=c,this.options=Object.assign({enable:!0},a),this.events=cm.concat(a.events||[]),this.handleEvent=this.handleEvent.bind(this),this.events.forEach(a=>b.addEventListener(a,this.handleEvent,!!Y&&{passive:!1}))}destroy(){this.events.forEach(a=>this.element.removeEventListener(a,this.handleEvent))}enableEventType(a,b){a===cn&&(this.options.enable=b)}handleEvent(b){if(!this.options.enable)return;let a=b.deltaY;G.WheelEvent&&(cl&&b.deltaMode===G.WheelEvent.DOM_DELTA_PIXEL&&(a/=G.devicePixelRatio),b.deltaMode===G.WheelEvent.DOM_DELTA_LINE&&(a*=40));const c={x:b.clientX,y:b.clientY};0!==a&&a%4.000244140625==0&&(a=Math.floor(a/4.000244140625)),b.shiftKey&&a&&(a*=.25),this._onWheel(b,-a,c)}_onWheel(a,b,c){this.callback({type:cn,center:c,delta:b,srcEvent:a,pointerType:"mouse",target:a.target})}}const{MOUSE_EVENTS:cp}=s,cq="pointermove",cr="pointerover",cs="pointerout",ct="pointerleave";class cu{constructor(b,c,a={}){this.element=b,this.callback=c,this.pressed=!1,this.options=Object.assign({enable:!0},a),this.enableMoveEvent=this.options.enable,this.enableLeaveEvent=this.options.enable,this.enableOutEvent=this.options.enable,this.enableOverEvent=this.options.enable,this.events=cp.concat(a.events||[]),this.handleEvent=this.handleEvent.bind(this),this.events.forEach(a=>b.addEventListener(a,this.handleEvent))}destroy(){this.events.forEach(a=>this.element.removeEventListener(a,this.handleEvent))}enableEventType(a,b){a===cq&&(this.enableMoveEvent=b),a===cr&&(this.enableOverEvent=b),a===cs&&(this.enableOutEvent=b),a===ct&&(this.enableLeaveEvent=b)}handleEvent(a){this.handleOverEvent(a),this.handleOutEvent(a),this.handleLeaveEvent(a),this.handleMoveEvent(a)}handleOverEvent(a){this.enableOverEvent&&"mouseover"===a.type&&this.callback({type:cr,srcEvent:a,pointerType:"mouse",target:a.target})}handleOutEvent(a){this.enableOutEvent&&"mouseout"===a.type&&this.callback({type:cs,srcEvent:a,pointerType:"mouse",target:a.target})}handleLeaveEvent(a){this.enableLeaveEvent&&"mouseleave"===a.type&&this.callback({type:ct,srcEvent:a,pointerType:"mouse",target:a.target})}handleMoveEvent(a){if(this.enableMoveEvent)switch(a.type){case"mousedown":a.button>=0&&(this.pressed=!0);break;case"mousemove":0===a.which&&(this.pressed=!1),this.pressed||this.callback({type:cq,srcEvent:a,pointerType:"mouse",target:a.target});break;case"mouseup":this.pressed=!1}}}const{KEY_EVENTS:cv}=s,cw="keydown",cx="keyup";class cy{constructor(a,c,b={}){this.element=a,this.callback=c,this.options=Object.assign({enable:!0},b),this.enableDownEvent=this.options.enable,this.enableUpEvent=this.options.enable,this.events=cv.concat(b.events||[]),this.handleEvent=this.handleEvent.bind(this),a.tabIndex=b.tabIndex||0,a.style.outline="none",this.events.forEach(b=>a.addEventListener(b,this.handleEvent))}destroy(){this.events.forEach(a=>this.element.removeEventListener(a,this.handleEvent))}enableEventType(a,b){a===cw&&(this.enableDownEvent=b),a===cx&&(this.enableUpEvent=b)}handleEvent(a){const b=a.target||a.srcElement;("INPUT"!==b.tagName||"text"!==b.type)&&"TEXTAREA"!==b.tagName&&(this.enableDownEvent&&"keydown"===a.type&&this.callback({type:cw,srcEvent:a,key:a.key,target:a.target}),this.enableUpEvent&&"keyup"===a.type&&this.callback({type:cx,srcEvent:a,key:a.key,target:a.target}))}}const cz="contextmenu";class cA{constructor(a,b,c={}){this.element=a,this.callback=b,this.options=Object.assign({enable:!0},c),this.handleEvent=this.handleEvent.bind(this),a.addEventListener("contextmenu",this.handleEvent)}destroy(){this.element.removeEventListener("contextmenu",this.handleEvent)}enableEventType(a,b){a===cz&&(this.options.enable=b)}handleEvent(a){this.options.enable&&this.callback({type:cz,center:{x:a.clientX,y:a.clientY},srcEvent:a,pointerType:"mouse",target:a.target})}}const cB={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4},cC={srcElement:"root",priority:0};class cD{constructor(a){this.eventManager=a,this.handlers=[],this.handlersByElement=new Map,this.handleEvent=this.handleEvent.bind(this),this._active=!1}isEmpty(){return!this._active}add(f,g,a,h=!1,i=!1){const{handlers:j,handlersByElement:e}=this;a&&("object"!=typeof a||a.addEventListener)&&(a={srcElement:a}),a=a?Object.assign({},cC,a):cC;let b=e.get(a.srcElement);b||(b=[],e.set(a.srcElement,b));const c={type:f,handler:g,srcElement:a.srcElement,priority:a.priority};h&&(c.once=!0),i&&(c.passive=!0),j.push(c),this._active=this._active||!c.passive;let d=b.length-1;for(;d>=0&&!(b[d].priority>=c.priority);)d--;b.splice(d+1,0,c)}remove(f,g){const{handlers:b,handlersByElement:e}=this;for(let c=b.length-1;c>=0;c--){const a=b[c];if(a.type===f&&a.handler===g){b.splice(c,1);const d=e.get(a.srcElement);d.splice(d.indexOf(a),1),0===d.length&&e.delete(a.srcElement)}}this._active=b.some(a=>!a.passive)}handleEvent(c){if(this.isEmpty())return;const b=this._normalizeEvent(c);let a=c.srcEvent.target;for(;a&&a!==b.rootElement;){if(this._emit(b,a),b.handled)return;a=a.parentNode}this._emit(b,"root")}_emit(e,f){const a=this.handlersByElement.get(f);if(a){let g=!1;const h=()=>{e.handled=!0},i=()=>{e.handled=!0,g=!0},c=[];for(let b=0;b{const b=this.manager.get(a);b&&cf[a].forEach(a=>{b.recognizeWith(a)})}),b.recognizerOptions){const e=this.manager.get(d);if(e){const f=b.recognizerOptions[d];delete f.enable,e.set(f)}}for(const[h,c]of(this.wheelInput=new co(a,this._onOtherEvent,{enable:!1}),this.moveInput=new cu(a,this._onOtherEvent,{enable:!1}),this.keyInput=new cy(a,this._onOtherEvent,{enable:!1,tabIndex:b.tabIndex}),this.contextmenuInput=new cA(a,this._onOtherEvent,{enable:!1}),this.events))c.isEmpty()||(this._toggleRecognizer(c.recognizerName,!0),this.manager.on(h,c.handleEvent))}destroy(){this.element&&(this.wheelInput.destroy(),this.moveInput.destroy(),this.keyInput.destroy(),this.contextmenuInput.destroy(),this.manager.destroy(),this.wheelInput=null,this.moveInput=null,this.keyInput=null,this.contextmenuInput=null,this.manager=null,this.element=null)}on(a,b,c){this._addEventHandler(a,b,c,!1)}once(a,b,c){this._addEventHandler(a,b,c,!0)}watch(a,b,c){this._addEventHandler(a,b,c,!1,!0)}off(a,b){this._removeEventHandler(a,b)}_toggleRecognizer(a,b){const{manager:d}=this;if(!d)return;const c=d.get(a);if(c&&c.options.enable!==b){c.set({enable:b});const e=cg[a];e&&!this.options.recognizers&&e.forEach(e=>{const f=d.get(e);b?(f.requireFailure(a),c.dropRequireFailure(e)):f.dropRequireFailure(a)})}this.wheelInput.enableEventType(a,b),this.moveInput.enableEventType(a,b),this.keyInput.enableEventType(a,b),this.contextmenuInput.enableEventType(a,b)}_addEventHandler(b,e,d,f,g){if("string"!=typeof b){for(const h in d=e,b)this._addEventHandler(h,b[h],d,f,g);return}const{manager:i,events:j}=this,c=cj[b]||b;let a=j.get(c);!a&&(a=new cD(this),j.set(c,a),a.recognizerName=ci[c]||c,i&&i.on(c,a.handleEvent)),a.add(b,e,d,f,g),a.isEmpty()||this._toggleRecognizer(a.recognizerName,!0)}_removeEventHandler(a,h){if("string"!=typeof a){for(const c in a)this._removeEventHandler(c,a[c]);return}const{events:d}=this,i=cj[a]||a,b=d.get(i);if(b&&(b.remove(a,h),b.isEmpty())){const{recognizerName:e}=b;let f=!1;for(const g of d.values())if(g.recognizerName===e&&!g.isEmpty()){f=!0;break}f||this._toggleRecognizer(e,!1)}}_onBasicInput(a){const{srcEvent:c}=a,b=ch[c.type];b&&this.manager.emit(b,a)}_onOtherEvent(a){this.manager.emit(a.type,a)}}function cF(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}function cG(c){for(var a=1;a0),e=d&&!this.state.isHovering,h=!d&&this.state.isHovering;(c||e)&&(a.features=b,c&&c(a)),e&&cP.call(this,"onMouseEnter",a),h&&cP.call(this,"onMouseLeave",a),(e||h)&&this.setState({isHovering:d})}}function cT(b){var c=this.props,d=c.onClick,f=c.onNativeClick,g=c.onDblClick,h=c.doubleClickZoom,a=[],e=g||h;switch(b.type){case"anyclick":a.push(f),e||a.push(d);break;case"click":e&&a.push(d)}(a=a.filter(Boolean)).length&&((b=cN.call(this,b)).features=cO.call(this,b.point),a.forEach(function(a){return a(b)}))}var m=(0,c.forwardRef)(function(b,h){var i,t,f=(0,c.useContext)(bK),u=(0,c.useMemo)(function(){return b.controller||new Z},[]),v=(0,c.useMemo)(function(){return new cE(null,{touchAction:b.touchAction,recognizerOptions:b.eventRecognizerOptions})},[]),g=(0,c.useRef)(null),e=(0,c.useRef)(null),a=(0,c.useRef)({width:0,height:0,state:{isHovering:!1,isDragging:!1}}).current;a.props=b,a.map=e.current&&e.current.getMap(),a.setState=function(c){a.state=cM(cM({},a.state),c),g.current.style.cursor=b.getCursor(a.state)};var j=!0,k=function(b,c,d){if(j){i=[b,c,d,];return}var e=a.props,f=e.onViewStateChange,g=e.onViewportChange;Object.defineProperty(b,"position",{get:function(){return[0,0,bM(a.map,b),]}}),f&&f({viewState:b,interactionState:c,oldViewState:d}),g&&g(b,c,d)};(0,c.useImperativeHandle)(h,function(){var a;return{getMap:(a=e).current&&a.current.getMap,queryRenderedFeatures:a.current&&a.current.queryRenderedFeatures}},[]);var d=(0,c.useMemo)(function(){return cM(cM({},f),{},{eventManager:v,container:f.container||g.current})},[f,g.current]);d.onViewportChange=k,d.viewport=f.viewport||bQ(a),a.viewport=d.viewport;var w=function(b){var c=b.isDragging,d=void 0!==c&&c;if(d!==a.state.isDragging&&a.setState({isDragging:d}),j){t=b;return}var e=a.props.onInteractionStateChange;e&&e(b)},l=function(){a.width&&a.height&&u.setOptions(cM(cM(cM({},a.props),a.props.viewState),{},{isInteractive:Boolean(a.props.onViewStateChange||a.props.onViewportChange),onViewportChange:k,onStateChange:w,eventManager:v,width:a.width,height:a.height}))},m=function(b){var c=b.width,d=b.height;a.width=c,a.height=d,l(),a.props.onResize({width:c,height:d})};(0,c.useEffect)(function(){return v.setElement(g.current),v.on({pointerdown:cQ.bind(a),pointermove:cS.bind(a),pointerup:cR.bind(a),pointerleave:cP.bind(a,"onMouseOut"),click:cT.bind(a),anyclick:cT.bind(a),dblclick:cP.bind(a,"onDblClick"),wheel:cP.bind(a,"onWheel"),contextmenu:cP.bind(a,"onContextMenu")}),function(){v.destroy()}},[]),bL(function(){if(i){var a;k.apply(void 0,function(a){if(Array.isArray(a))return ax(a)}(a=i)||function(a){if("undefined"!=typeof Symbol&&null!=a[Symbol.iterator]||null!=a["@@iterator"])return Array.from(a)}(a)||ay(a)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())}t&&w(t)}),l();var n=b.width,o=b.height,p=b.style,r=b.getCursor,s=(0,c.useMemo)(function(){return cM(cM({position:"relative"},p),{},{width:n,height:o,cursor:r(a.state)})},[p,n,o,r,a.state]);return i&&a._child||(a._child=c.createElement(bJ,{value:d},c.createElement("div",{key:"event-canvas",ref:g,style:s},c.createElement(q,aw({},b,{width:"100%",height:"100%",style:null,onResize:m,ref:e}))))),j=!1,a._child});m.supported=q.supported,m.propTypes=$,m.defaultProps=_;var cU=m;function cV(b,a){if(b===a)return!0;if(!b||!a)return!1;if(Array.isArray(b)){if(!Array.isArray(a)||b.length!==a.length)return!1;for(var c=0;c prop: ".concat(e))}}(d,a,f.current):d=function(a,c,d){if(a.style&&a.style._loaded){var b=function(c){for(var a=1;a=0||(d[a]=c[a]);return d}(a,d);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(a);for(c=0;c=0)&&Object.prototype.propertyIsEnumerable.call(a,b)&&(e[b]=a[b])}return e}(d,["layout","paint","filter","minzoom","maxzoom","beforeId",]);if(p!==a.beforeId&&b.moveLayer(c,p),e!==a.layout){var q=a.layout||{};for(var g in e)cV(e[g],q[g])||b.setLayoutProperty(c,g,e[g]);for(var r in q)e.hasOwnProperty(r)||b.setLayoutProperty(c,r,void 0)}if(f!==a.paint){var s=a.paint||{};for(var h in f)cV(f[h],s[h])||b.setPaintProperty(c,h,f[h]);for(var t in s)f.hasOwnProperty(t)||b.setPaintProperty(c,t,void 0)}for(var i in cV(m,a.filter)||b.setFilter(c,m),(n!==a.minzoom||o!==a.maxzoom)&&b.setLayerZoomRange(c,n,o),j)cV(j[i],a[i])||b.setLayerProperty(c,i,j[i])}(c,d,a,b)}catch(e){console.warn(e)}}(a,d,b,e.current):function(a,d,b){if(a.style&&a.style._loaded){var c=cZ(cZ({},b),{},{id:d});delete c.beforeId,a.addLayer(c,b.beforeId)}}(a,d,b),e.current=b,null}).propTypes=ab;var f={captureScroll:!1,captureDrag:!0,captureClick:!0,captureDoubleClick:!0,capturePointerMove:!1},d={captureScroll:a.bool,captureDrag:a.bool,captureClick:a.bool,captureDoubleClick:a.bool,capturePointerMove:a.bool};function c_(){var d=arguments.length>0&& void 0!==arguments[0]?arguments[0]:{},a=(0,c.useContext)(bK),e=(0,c.useRef)(null),f=(0,c.useRef)({props:d,state:{},context:a,containerRef:e}),b=f.current;return b.props=d,b.context=a,(0,c.useEffect)(function(){return function(a){var b=a.containerRef.current,c=a.context.eventManager;if(b&&c){var d={wheel:function(c){var b=a.props;b.captureScroll&&c.stopPropagation(),b.onScroll&&b.onScroll(c,a)},panstart:function(c){var b=a.props;b.captureDrag&&c.stopPropagation(),b.onDragStart&&b.onDragStart(c,a)},anyclick:function(c){var b=a.props;b.captureClick&&c.stopPropagation(),b.onNativeClick&&b.onNativeClick(c,a)},click:function(c){var b=a.props;b.captureClick&&c.stopPropagation(),b.onClick&&b.onClick(c,a)},dblclick:function(c){var b=a.props;b.captureDoubleClick&&c.stopPropagation(),b.onDoubleClick&&b.onDoubleClick(c,a)},pointermove:function(c){var b=a.props;b.capturePointerMove&&c.stopPropagation(),b.onPointerMove&&b.onPointerMove(c,a)}};return c.watch(d,b),function(){c.off(d)}}}(b)},[a.eventManager]),b}function c0(b){var a=b.instance,c=c_(b),d=c.context,e=c.containerRef;return a._context=d,a._containerRef=e,a._render()}var H=function(b){bW(a,b);var d,e,f=(d=a,e=function(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(a){return!1}}(),function(){var a,b=bZ(d);if(e){var c=bZ(this).constructor;a=Reflect.construct(b,arguments,c)}else a=b.apply(this,arguments);return bY(this,a)});function a(){var b;bl(this,a);for(var e=arguments.length,h=new Array(e),d=0;d2&& void 0!==arguments[2]?arguments[2]:"x";if(null===a)return b;var c="x"===d?a.offsetWidth:a.offsetHeight;return c7(b/100*c)/c*100};function c9(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}var ae=Object.assign({},ac,{className:a.string,longitude:a.number.isRequired,latitude:a.number.isRequired,style:a.object}),af=Object.assign({},ad,{className:""});function t(b){var d,j,e,k,f,l,m,a,h=(d=b,e=(j=aA((0,c.useState)(null),2))[0],k=j[1],f=aA((0,c.useState)(null),2),l=f[0],m=f[1],a=c_(c2(c2({},d),{},{onDragStart:c5})),a.callbacks=d,a.state.dragPos=e,a.state.setDragPos=k,a.state.dragOffset=l,a.state.setDragOffset=m,(0,c.useEffect)(function(){return function(a){var b=a.context.eventManager;if(b&&a.state.dragPos){var c={panmove:function(b){return function(b,a){var h=a.props,c=a.callbacks,d=a.state,i=a.context;b.stopPropagation();var e=c3(b);d.setDragPos(e);var f=d.dragOffset;if(c.onDrag&&f){var g=Object.assign({},b);g.lngLat=c4(e,f,h,i),c.onDrag(g)}}(b,a)},panend:function(b){return function(c,a){var h=a.props,d=a.callbacks,b=a.state,i=a.context;c.stopPropagation();var e=b.dragPos,f=b.dragOffset;if(b.setDragPos(null),b.setDragOffset(null),d.onDragEnd&&e&&f){var g=Object.assign({},c);g.lngLat=c4(e,f,h,i),d.onDragEnd(g)}}(b,a)},pancancel:function(d){var c,b;return c=d,b=a.state,void(c.stopPropagation(),b.setDragPos(null),b.setDragOffset(null))}};return b.watch(c),function(){b.off(c)}}}(a)},[a.context.eventManager,Boolean(e)]),a),o=h.state,p=h.containerRef,q=b.children,r=b.className,s=b.draggable,A=b.style,t=o.dragPos,u=function(b){var a=b.props,e=b.state,f=b.context,g=a.longitude,h=a.latitude,j=a.offsetLeft,k=a.offsetTop,c=e.dragPos,d=e.dragOffset,l=f.viewport,m=f.map;if(c&&d)return[c[0]+d[0],c[1]+d[1],];var n=bM(m,{longitude:g,latitude:h}),o=l.project([g,h,n,]),i=aA(o,2),p=i[0],q=i[1];return[p+=j,q+=k]}(h),n=aA(u,2),v=n[0],w=n[1],x="translate(".concat(c7(v),"px, ").concat(c7(w),"px)"),y=s?t?"grabbing":"grab":"auto",z=(0,c.useMemo)(function(){var a=function(c){for(var a=1;a0){var t=b,u=e;for(b=0;b<=1;b+=.5)k=(i=n-b*h)+h,e=Math.max(0,d-i)+Math.max(0,k-p+d),e0){var w=a,x=f;for(a=0;a<=1;a+=v)l=(j=m-a*g)+g,f=Math.max(0,d-j)+Math.max(0,l-o+d),f1||h< -1||f<0||f>p.width||g<0||g>p.height?i.display="none":i.zIndex=Math.floor((1-h)/2*1e5)),i),S=(0,c.useCallback)(function(b){t.props.onClose();var a=t.context.eventManager;a&&a.once("click",function(a){return a.stopPropagation()},b.target)},[]);return c.createElement("div",{className:"mapboxgl-popup mapboxgl-popup-anchor-".concat(L," ").concat(N),style:R,ref:u},c.createElement("div",{key:"tip",className:"mapboxgl-popup-tip",style:{borderWidth:O}}),c.createElement("div",{key:"content",ref:j,className:"mapboxgl-popup-content"},P&&c.createElement("button",{key:"close-button",className:"mapboxgl-popup-close-button",type:"button",onClick:S},"\xd7"),Q))}function db(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}u.propTypes=ag,u.defaultProps=ah,c.memo(u);var ai=Object.assign({},d,{toggleLabel:a.string,className:a.string,style:a.object,compact:a.bool,customAttribution:a.oneOfType([a.string,a.arrayOf(a.string),])}),aj=Object.assign({},f,{className:"",toggleLabel:"Toggle Attribution"});function v(a){var b=c_(a),d=b.context,i=b.containerRef,j=(0,c.useRef)(null),e=aA((0,c.useState)(!1),2),f=e[0],m=e[1];(0,c.useEffect)(function(){var h,e,c,f,g,b;return d.map&&(h=(e={customAttribution:a.customAttribution},c=d.map,f=i.current,g=j.current,(b=new(A()).AttributionControl(e))._map=c,b._container=f,b._innerContainer=g,b._updateAttributions(),b._updateEditLink(),c.on("styledata",b._updateData),c.on("sourcedata",b._updateData),b)),function(){var a;return h&&void((a=h)._map.off("styledata",a._updateData),a._map.off("sourcedata",a._updateData))}},[d.map]);var h=void 0===a.compact?d.viewport.width<=640:a.compact;(0,c.useEffect)(function(){!h&&f&&m(!1)},[h]);var k=(0,c.useCallback)(function(){return m(function(a){return!a})},[]),l=(0,c.useMemo)(function(){return function(c){for(var a=1;ac)return 1}return 0}(b.map.version,"1.6.0")>=0?2:1:2},[b.map]),f=b.viewport.bearing,d={transform:"rotate(".concat(-f,"deg)")},2===e?c.createElement("span",{className:"mapboxgl-ctrl-icon","aria-hidden":"true",style:d}):c.createElement("span",{className:"mapboxgl-ctrl-compass-arrow",style:d})))))}function dj(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}y.propTypes=ao,y.defaultProps=ap,c.memo(y);var aq=Object.assign({},d,{className:a.string,style:a.object,maxWidth:a.number,unit:a.oneOf(["imperial","metric","nautical"])}),ar=Object.assign({},f,{className:"",maxWidth:100,unit:"metric"});function z(a){var d=c_(a),f=d.context,h=d.containerRef,e=aA((0,c.useState)(null),2),b=e[0],j=e[1];(0,c.useEffect)(function(){if(f.map){var a=new(A()).ScaleControl;a._map=f.map,a._container=h.current,j(a)}},[f.map]),b&&(b.options=a,b._onMove());var i=(0,c.useMemo)(function(){return function(c){for(var a=1;a= 0 && (type = (namespaces = type.split(".")).shift(), namespaces.sort()), ontype = 0 > type.indexOf(":") && "on" + type, (event = event[jQuery.expando] ? event : new jQuery.Event(type, "object" == typeof event && event)).isTrigger = !0, event.namespace = namespaces.join("."), event.namespace_re = event.namespace ? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)") : null, event.result = undefined, event.target || (event.target = elem), data = null == data ? [ - event - ] : jQuery.makeArray(data, [ - event - ]), special = jQuery.event.special[type] || {}, onlyHandlers || !special.trigger || !1 !== special.trigger.apply(elem, data))) { - if (!onlyHandlers && !special.noBubble && !jQuery.isWindow(elem)) { - for(bubbleType = special.delegateType || type, rfocusMorph.test(bubbleType + type) || (cur = cur.parentNode); cur; cur = cur.parentNode)eventPath.push(cur), tmp = cur; - tmp === (elem.ownerDocument || document1) && eventPath.push(tmp.defaultView || tmp.parentWindow || window1); - } - for(i = 0; (cur = eventPath[i++]) && !event.isPropagationStopped();)event.type = i > 1 ? bubbleType : special.bindType || type, (handle = (jQuery._data(cur, "events") || {})[event.type] && jQuery._data(cur, "handle")) && handle.apply(cur, data), (handle = ontype && cur[ontype]) && jQuery.acceptData(cur) && handle.apply && !1 === handle.apply(cur, data) && event.preventDefault(); - if (event.type = type, !onlyHandlers && !event.isDefaultPrevented() && (!special._default || !1 === special._default.apply(elem.ownerDocument, data)) && !("click" === type && jQuery.nodeName(elem, "a")) && jQuery.acceptData(elem) && ontype && elem[type] && !jQuery.isWindow(elem)) { - (tmp = elem[ontype]) && (elem[ontype] = null), jQuery.event.triggered = type; - try { - elem[type](); - } catch (e) {} - jQuery.event.triggered = undefined, tmp && (elem[ontype] = tmp); - } - return event.result; + if (cur = tmp = elem = elem || document1, !(3 === elem.nodeType || 8 === elem.nodeType || rfocusMorph.test(type + jQuery.event.triggered)) && (type.indexOf(".") >= 0 && (type = (namespaces = type.split(".")).shift(), namespaces.sort()), ontype = 0 > type.indexOf(":") && "on" + type, (event = event[jQuery.expando] ? event : new jQuery.Event(type, "object" == typeof event && event)).isTrigger = !0, event.namespace = namespaces.join("."), event.namespace_re = event.namespace ? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)") : null, event.result = undefined, event.target || (event.target = elem), data = null == data ? [ + event + ] : jQuery.makeArray(data, [ + event + ]), special = jQuery.event.special[type] || {}, onlyHandlers || !special.trigger || !1 !== special.trigger.apply(elem, data))) { + if (!onlyHandlers && !special.noBubble && !jQuery.isWindow(elem)) { + for(bubbleType = special.delegateType || type, rfocusMorph.test(bubbleType + type) || (cur = cur.parentNode); cur; cur = cur.parentNode)eventPath.push(cur), tmp = cur; + tmp === (elem.ownerDocument || document1) && eventPath.push(tmp.defaultView || tmp.parentWindow || window1); + } + for(i = 0; (cur = eventPath[i++]) && !event.isPropagationStopped();)event.type = i > 1 ? bubbleType : special.bindType || type, (handle = (jQuery._data(cur, "events") || {})[event.type] && jQuery._data(cur, "handle")) && handle.apply(cur, data), (handle = ontype && cur[ontype]) && jQuery.acceptData(cur) && handle.apply && !1 === handle.apply(cur, data) && event.preventDefault(); + if (event.type = type, !onlyHandlers && !event.isDefaultPrevented() && (!special._default || !1 === special._default.apply(elem.ownerDocument, data)) && !("click" === type && jQuery.nodeName(elem, "a")) && jQuery.acceptData(elem) && ontype && elem[type] && !jQuery.isWindow(elem)) { + (tmp = elem[ontype]) && (elem[ontype] = null), jQuery.event.triggered = type; + try { + elem[type](); + } catch (e) {} + jQuery.event.triggered = undefined, tmp && (elem[ontype] = tmp); } + return event.result; } }, dispatch: function(event) { diff --git a/crates/swc_ecma_minifier/tests/projects/output/jquery.mobile-1.4.2.js b/crates/swc_ecma_minifier/tests/projects/output/jquery.mobile-1.4.2.js index 700870978f33..68915ef5b02f 100644 --- a/crates/swc_ecma_minifier/tests/projects/output/jquery.mobile-1.4.2.js +++ b/crates/swc_ecma_minifier/tests/projects/output/jquery.mobile-1.4.2.js @@ -69,7 +69,7 @@ var removeData, orig2, uuid = 0, runiqueId = /^ui-id-\d+$/; function focusable(element, isTabIndexNotNaN) { var map, mapName, img, nodeName = element.nodeName.toLowerCase(); - return "area" === nodeName ? (mapName = (map = element.parentNode).name, !!element.href && !!mapName && "map" === map.nodeName.toLowerCase() && !!(img = $("img[usemap=#" + mapName + "]")[0]) && visible(img)) : (/input|select|textarea|button|object/.test(nodeName) ? !element.disabled : "a" === nodeName ? element.href || isTabIndexNotNaN : isTabIndexNotNaN) && visible(element); + return "area" === nodeName ? (mapName = (map = element.parentNode).name, !!element.href && !!mapName && "map" === map.nodeName.toLowerCase() && !!(img = $("img[usemap=#" + mapName + "]")[0]) && visible(img)) : (/input|select|textarea|button|object/.test(nodeName) ? !element.disabled : "a" === nodeName && element.href || isTabIndexNotNaN) && visible(element); } function visible(element) { return $.expr.filters.visible(element) && !$(element).parents().addBack().filter(function() { @@ -336,7 +336,7 @@ }, returnValue = value.apply(this, arguments), this._super = __super, this._superApply = __superApply, returnValue; }; }), constructor.prototype = $3.widget.extend(basePrototype, { - widgetEventPrefix: existingConstructor ? basePrototype.widgetEventPrefix || name : name + widgetEventPrefix: existingConstructor && basePrototype.widgetEventPrefix || name }, proxiedPrototype, { constructor: constructor, namespace: namespace, @@ -1585,7 +1585,7 @@ ]); return; } - if (this._triggerPageBeforeChange(toPage, triggerData, settings) && !((beforeTransition = this._triggerWithDeprecated("beforetransition", triggerData)).deprecatedEvent.isDefaultPrevented() || beforeTransition.event.isDefaultPrevented())) { + if (!(!this._triggerPageBeforeChange(toPage, triggerData, settings) || (beforeTransition = this._triggerWithDeprecated("beforetransition", triggerData)).deprecatedEvent.isDefaultPrevented() || beforeTransition.event.isDefaultPrevented())) { if (isPageTransitioning = !0, toPage[0] !== $16.mobile.firstPage[0] || settings.dataUrl || (settings.dataUrl = $16.mobile.path.documentUrl.hrefNoHash), fromPage = settings.fromPage, url = settings.dataUrl && $16.mobile.path.convertUrlToDataUrl(settings.dataUrl) || toPage.jqmData("url"), pageUrl = url, $16.mobile.path.getFilePath(url), active = $16.mobile.navigate.history.getActive(), activeIsInitialPage = 0 === $16.mobile.navigate.history.activeIndex, historyDir = 0, pageTitle = document1.title, isDialog = ("dialog" === settings.role || "dialog" === toPage.jqmData("role")) && !0 !== toPage.jqmData("dialog"), fromPage && fromPage[0] === toPage[0] && !settings.allowSamePageTransition) { isPageTransitioning = !1, this._triggerWithDeprecated("transition", triggerData), this.element.trigger("pagechange", triggerData), settings.fromHashChange && $16.mobile.navigate.history.direct({ url: url @@ -1678,10 +1678,7 @@ if ($lastVClicked = $(target), $.data(target, "mobile-button")) { if (!getAjaxFormData($(target).closest("form"), !0)) return; target.parentNode && (target = target.parentNode); - } else { - if (!((target = findClosestLink(target)) && "#" !== $.mobile.path.parseUrl(target.getAttribute("href") || "#").hash)) return; - if (!$(target).jqmHijackable().length) return; - } + } else if (!((target = findClosestLink(target)) && "#" !== $.mobile.path.parseUrl(target.getAttribute("href") || "#").hash) || !$(target).jqmHijackable().length) return; ~target.className.indexOf("ui-link-inherit") ? target.parentNode && (btnEls = $.data(target.parentNode, "buttonElements")) : btnEls = $.data(target, "buttonElements"), btnEls ? target = btnEls.outer : needClosest = !0, $btn = $(target), needClosest && ($btn = $btn.closest(".ui-btn")), $btn.length > 0 && !$btn.hasClass("ui-state-disabled") && ($.mobile.removeActiveLinkClass(!0), $.mobile.activeClickedLink = $btn, $.mobile.activeClickedLink.addClass($.mobile.activeBtnClass)); } }), $.mobile.document.bind("click", function(event) { diff --git a/crates/swc_ecma_minifier/tests/projects/output/react-dom-17.0.2.js b/crates/swc_ecma_minifier/tests/projects/output/react-dom-17.0.2.js index da12c46da567..4324776a52f0 100644 --- a/crates/swc_ecma_minifier/tests/projects/output/react-dom-17.0.2.js +++ b/crates/swc_ecma_minifier/tests/projects/output/react-dom-17.0.2.js @@ -56,8 +56,7 @@ } } function shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag) { - if (null == value) return !0; - if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag)) return !0; + if (null == value || shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag)) return !0; if (isCustomComponentTag) return !1; if (null !== propertyInfo) switch(propertyInfo.type){ case 3: @@ -723,7 +722,7 @@ var didWarnSelectedSetOnOption = !1, didWarnInvalidChild = !1; function validateProps(element, props) { "object" == typeof props.children && null !== props.children && React.Children.forEach(props.children, function(child) { - if (null != child) "string" != typeof child && "number" != typeof child && "string" == typeof child.type && (didWarnInvalidChild || (didWarnInvalidChild = !0, error1("Only strings and numbers are supported as